/* daylog – Tokens und Bausteine. Warmes Creme, freundliches Blau als Akzent, Schrift Figtree.
   Karten ohne Rand mit weichem Schatten, Pillen als Knöpfe, weich gefüllte Eingaben.
   Farben nur als Variablen auf :root; dunkel überschrieben unter prefers-color-scheme (ohne data-theme=light)
   und erneut unter [data-theme=dark]. */
/* Figtree (SIL Open Font License, public/fonts/OFL.txt), selbst gehostet: keine fremde Verbindung vor dem ersten Zeichnen */
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400 800; font-display: swap; src: url('/fonts/figtree-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Figtree'; font-style: normal; font-weight: 400 800; font-display: swap; src: url('/fonts/figtree-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }


:root {
  color-scheme: light;
  --background: #F7F2EA;
  --foreground: #26241F;
  --card: #FFFCF7;
  --card-foreground: #26241F;
  --surface: #F4EEE4;            /* weiche Fläche in einer Karte */
  --muted: #EFE8DC;
  --muted-foreground: #6F6A5F;
  --subtle-foreground: #9C968A;
  --border: rgba(38, 36, 31, 0.06);
  --border-strong: rgba(38, 36, 31, 0.14);
  --input: rgba(38, 36, 31, 0.14);
  --ring: #2F6BEA;
  --primary: #2C68F2;
  --primary-foreground: #ffffff;
  --primary-soft: rgba(47, 107, 234, 0.12);
  --accent: rgba(38, 36, 31, 0.05);        /* Hover-Wash */
  --accent-strong: rgba(38, 36, 31, 0.09);
  --destructive: #D0463A;
  --destructive-foreground: #ffffff;
  --info: #2F6BEA;
  --info-soft: rgba(47, 107, 234, 0.12);
  --shadow: 0 2px 10px -6px rgba(60, 40, 10, 0.18), 0 12px 30px -24px rgba(60, 40, 10, 0.3);
  --shadow-lg: 0 4px 14px -6px rgba(60, 40, 10, 0.2), 0 30px 60px -30px rgba(60, 40, 10, 0.4);

  /* Illustrationen und Akzente */
  --sun: #FFA41C;
  --sun-deep: #F2762C;
  --sun-soft: #FFD46A;
  --peach: #FFC49A;
  --lavender: #A88EFF;
  --lavender-deep: #7D63E8;
  --mint: #9EE0B4;
  --sky: #9CCBFF;
  --coral: #FF7452;
  --rose: #F7B2A2;                         /* Band «Attacke» */
  --hill: #6DB39B;                         /* Hügel, Sonne, Mond der Szenen (js/illus.js) */
  --hill-top: #D9CB6A;
  --sun-glow: #FFE07A;
  --moon: #FFF4DC;
  --ink: #3A2E22;                          /* Gesichter und Striche auf farbigen Bändern */
  --band-ink: #3A2E22;                     /* Knöpfe auf einem Band */

  /* Schweregrad: Perfekt und Gut grün, darunter eine Rampe */
  --lv-perfection: #12A150;
  --lv-good: #8ACB8F;
  --lv-light: #A8A29A;
  --lv-moderate: #F28B30;
  --lv-bad: #E0392D;
  --lv-extreme: #8E1C16;
  --lv-none: #E6DFD3;                      /* nicht erfasst */

  /* Akutmedikation */
  --med-triptan: #2C68F2;
  --med-triptan-2: #EDA100;
  --med-nsaid: #D6539A;
  --med-other: #8B8880;
  --proph: #3F3D36;
  --sleep: #7D63E8;
  --shield: #1496A0;                      /* Prophylaxe: Schutzschild, nicht «natürlich» */
  /* Tönung von Kacheln und Tasten direkt auf dem Seitenhintergrund (hell kräftiger, sonst verschwinden sie im Creme) */
  --btn-soft: #EFE8DC; --btn-soft-hover: #E7DFD1; --btn-edge: transparent;
  --mix-tile: 44%; --mix-tile-lv: 30%; --mix-sleep: 22%; --mix-btn: 15%; --mix-attack: 24%; --tile-shadow: none; --scene-dim: 0;
  --cmp-a: #56544C;
  --cmp-b: #7D63E8;
  --good-delta: #0E8A4A;
  --bad-delta: #C53A2B;

  --radius: 14px;
  --radius-lg: 24px;
  --radius-xl: 28px;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --dur: 220ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tabbar-h: 50px;   /* wie iOS: 49 pt Inhalt, darunter der sichere Rand */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #1B1917;
  --foreground: #F6F1E8;
  --card: #262320;
  --card-foreground: #F6F1E8;
  --surface: #2F2B27;
  --muted: #353029;
  --muted-foreground: #B5AEA2;
  --subtle-foreground: #7F786D;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.16);
  --input: rgba(255, 255, 255, 0.16);
  --ring: #6B98FF;
  --primary: #6B98FF;
  --primary-foreground: #0F1830;
  --primary-soft: rgba(107, 152, 255, 0.18);
  --accent: rgba(255, 255, 255, 0.06);
  --accent-strong: rgba(255, 255, 255, 0.11);
  --destructive: #F07065;
  --destructive-foreground: #1B1917;
  --info: #6B98FF;
  --info-soft: rgba(107, 152, 255, 0.2);
  --shadow: 0 2px 10px -6px rgba(0, 0, 0, 0.5), 0 12px 30px -24px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 4px 14px -6px rgba(0, 0, 0, 0.6), 0 30px 60px -30px rgba(0, 0, 0, 0.8);
  --sun: #E89A2A;
  --sun-deep: #DE6E2E;
  --sun-soft: #8A6420;
  --peach: #8A4F2E;
  --lavender: #6E57D6;
  --lavender-deep: #9E8CF2;
  --mint: #2F7A55;
  --sky: #2E6AA6;
  --coral: #F08468;
  --rose: #8A4A40;
  --hill: #3D6E60;
  --hill-top: #7C7440;
  --sun-glow: #F2C25A;
  --moon: #F3E6C4;
  --ink: #2A211A;
  --band-ink: #F6F1E8;
  --lv-perfection: #1FBF66;
  --lv-good: #7DC487;
  --lv-light: #9C968D;
  --lv-moderate: #F39A45;
  --lv-bad: #EC5143;
  --lv-extreme: #B23A30;
  --lv-none: #3A3530;
  --med-triptan: #6B98FF;
  --med-triptan-2: #D69100;
  --med-nsaid: #DA5F8F;
  --med-other: #8B8880;
  --proph: #D8D2C6;
  --sleep: #9E8CF2;
  --shield: #3DC1C9;
  --btn-soft: #353029; --btn-soft-hover: #3D3731; --btn-edge: transparent;
  --mix-tile: 42%; --mix-tile-lv: 30%; --mix-sleep: 20%; --mix-btn: 20%; --mix-attack: 24%; --tile-shadow: none; --scene-dim: 0.06;
  --cmp-a: #C3BDB1;
  --cmp-b: #9E8CF2;
  --good-delta: #3FC27A;
  --bad-delta: #F07065;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #1B1917;
    --foreground: #F6F1E8;
    --card: #262320;
    --card-foreground: #F6F1E8;
    --surface: #2F2B27;
    --muted: #353029;
    --muted-foreground: #B5AEA2;
    --subtle-foreground: #7F786D;
    --border: rgba(255, 255, 255, 0.07);
    --border-strong: rgba(255, 255, 255, 0.16);
    --input: rgba(255, 255, 255, 0.16);
    --ring: #6B98FF;
    --primary: #6B98FF;
    --primary-foreground: #0F1830;
    --primary-soft: rgba(107, 152, 255, 0.18);
    --accent: rgba(255, 255, 255, 0.06);
    --accent-strong: rgba(255, 255, 255, 0.11);
    --destructive: #F07065;
    --destructive-foreground: #1B1917;
    --info: #6B98FF;
    --info-soft: rgba(107, 152, 255, 0.2);
    --shadow: 0 2px 10px -6px rgba(0, 0, 0, 0.5), 0 12px 30px -24px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 4px 14px -6px rgba(0, 0, 0, 0.6), 0 30px 60px -30px rgba(0, 0, 0, 0.8);
    --sun: #E89A2A;
    --sun-deep: #DE6E2E;
    --sun-soft: #8A6420;
    --peach: #8A4F2E;
    --lavender: #6E57D6;
    --lavender-deep: #9E8CF2;
    --mint: #2F7A55;
    --sky: #2E6AA6;
    --coral: #F08468;
    --rose: #8A4A40;
    --hill: #3D6E60;
    --hill-top: #7C7440;
    --sun-glow: #F2C25A;
    --moon: #F3E6C4;
    --ink: #2A211A;
    --band-ink: #F6F1E8;
    --lv-perfection: #1FBF66;
    --lv-good: #7DC487;
    --lv-light: #9C968D;
    --lv-moderate: #F39A45;
    --lv-bad: #EC5143;
    --lv-extreme: #B23A30;
    --lv-none: #3A3530;
    --med-triptan: #6B98FF;
    --med-triptan-2: #D69100;
    --med-nsaid: #DA5F8F;
    --med-other: #8B8880;
    --proph: #D8D2C6;
    --sleep: #9E8CF2;
  --shield: #3DC1C9;
  --btn-soft: #353029; --btn-soft-hover: #3D3731; --btn-edge: transparent;
  --mix-tile: 42%; --mix-tile-lv: 30%; --mix-sleep: 20%; --mix-btn: 20%; --mix-attack: 24%; --tile-shadow: none; --scene-dim: 0.06;
    --cmp-a: #C3BDB1;
    --cmp-b: #9E8CF2;
    --good-delta: #3FC27A;
    --bad-delta: #F07065;
  }
}

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background: var(--background); color: var(--foreground);
  font: 500 15.5px/1.5 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
b, strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted-foreground); }
.subtle { color: var(--subtle-foreground); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }

/* ---------- Knöpfe (Pillen) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--primary); color: var(--primary-foreground); border: 0;
  font-size: 15px; font-weight: 700; line-height: 1; white-space: nowrap; text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease), opacity var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:hover { background: color-mix(in srgb, var(--primary) 90%, #000); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
/* Weiche Tasten: im hellen Modus dunkler als der Creme-Hintergrund und mit feiner Kante, sonst verschwinden sie */
.btn-outline, .btn-secondary { background: var(--btn-soft); color: var(--foreground); box-shadow: inset 0 0 0 1px var(--btn-edge); }
.btn-outline:hover, .btn-secondary:hover { background: var(--btn-soft-hover); }
.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover { background: var(--accent); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive:hover { background: color-mix(in srgb, var(--destructive) 90%, #000); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13.5px; font-weight: 600; }
.btn-lg { height: 56px; padding: 0 24px; font-size: 17px; }
.btn-pill { border-radius: 999px; }
.btn-icon { width: 44px; padding: 0; color: var(--muted-foreground); }
.btn-icon.btn-sm { width: 34px; }
.btn-block { width: 100%; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-lg svg { width: 22px; height: 22px; }

/* ---------- Karten und Flächen ---------- */
.card { background: var(--card); color: var(--card-foreground); border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.hr { height: 1px; background: var(--border); margin: 12px 0; }

/* ---------- Eingaben (weich gefüllt) ---------- */
.input, .select, .textarea {
  width: 100%; height: 48px; padding: 0 16px; border-radius: 16px;
  background: var(--surface); border: 0; color: var(--foreground); font-size: 16px; font-weight: 500; line-height: 1.2;
  transition: box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.card .input, .card .select, .card .textarea { background: var(--surface); }
.textarea { height: auto; min-height: 112px; padding: 14px 16px; resize: vertical; line-height: 1.45; border-radius: 18px; }
.input::placeholder, .textarea::placeholder { color: var(--subtle-foreground); font-weight: 500; }
.input:focus, .select:focus, .textarea:focus { outline: none; box-shadow: 0 0 0 2px var(--primary); }
.select { appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239C968A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }
.label { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted-foreground); margin-bottom: 6px; }
.field { margin-bottom: 14px; }

/* Schalter */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--muted); transition: background var(--dur) var(--ease); }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22); transition: transform var(--dur) var(--ease); }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--ring); outline-offset: 2px; }

/* Chips (Mehrfachauswahl) und segmentierte Wahl */
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 999px;
  background: var(--surface); border: 0; color: var(--foreground); font-size: 14.5px; font-weight: 600;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); -webkit-tap-highlight-color: transparent; user-select: none;
}
.chip[aria-pressed="true"], .chip.is-on { background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; background: var(--muted); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted-foreground); font-size: 13.5px; font-weight: 600; white-space: nowrap; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--foreground); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }

/* Abzeichen und Punkte */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--muted); color: var(--muted-foreground); font-size: 12.5px; font-weight: 600; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Leiste «Neue Version» ---------- */
.update-bar {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 999px;
  background: var(--card); color: var(--foreground); box-shadow: var(--shadow-lg);
  font-size: 14px; font-weight: 600; z-index: 90; opacity: 0; transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
  /* mit left: 50% wäre sie auf die halbe Breite begrenzt und bräche um */
  width: max-content; max-width: calc(100vw - 32px);
}
.update-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.update-bar .btn { flex: none; white-space: nowrap; }
.update-bar.is-in { transform: translate(-50%, 0); opacity: 1; }
.update-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex: none; }
.update-close { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 0; background: transparent; color: var(--muted-foreground); }
.update-close:hover { background: var(--accent); color: var(--foreground); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); transform: translate(-50%, 20px);
  padding: 11px 18px; border-radius: 999px; background: var(--foreground); color: var(--background);
  font-size: 14px; font-weight: 600; z-index: 120; opacity: 0; transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease); pointer-events: none; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
}
.toast.is-in { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Dialog ---------- */
dialog.dlg { border: 0; border-radius: var(--radius-xl); background: var(--card); color: var(--foreground); padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
dialog.dlg::backdrop { background: rgba(30, 22, 12, 0.45); backdrop-filter: blur(2px); }

/* Schnelles Tippen (etwa mehrmals «+») darf auf dem Telefon nicht zoomen; Zwei-Finger-Zoom bleibt möglich */
html { touch-action: manipulation; }
button, a, input, select, textarea, label, summary, [role="button"], .tile, .lvl-cell, .lvl-row, .chip { touch-action: manipulation; }
