/* ------------------------------------------------------------------ *
 * W-System design system — minimal, near-black, one restrained accent.
 * Gleiche Sprache wie FitnessOS: Definition durch feine Borders und
 * Top-Light, nie durch Füllungen. Akzent (Champagner) nur, wo Bedeutung ist.
 * ------------------------------------------------------------------ */
:root {
  --bg: #050506;
  --surface: #0b0c0d;
  --surface-2: #141517;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #f4f5f6;
  --muted: #8b9096;
  --faint: #5a5f66;
  --accent: #d7bd83;
  --accent-ink: #171103;
  --positive: #57e08a;
  --danger: #ff5c5c;
  --radius: 12px;
  --tabbar-h: calc(64px + env(safe-area-inset-bottom));
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15.5px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-strong); }

/* Zahlen & Zeiten: Mono, tabellarisch — Werte zittern nie. */
.data { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ── Layout ── */
#app { max-width: 480px; margin-inline: auto; min-height: 100dvh; }
.screen { padding: calc(16px + env(safe-area-inset-top)) 18px calc(var(--tabbar-h) + 28px); }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.brand { font-size: 13px; font-weight: 600; color: var(--muted); }
.statusdot { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--faint); }
.statusdot i { width: 6px; height: 6px; border-radius: 50%; background: var(--positive);
  animation: breathe 2.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.5; box-shadow: 0 0 0 0 rgba(87, 224, 138, 0); }
  50% { opacity: 1; box-shadow: 0 0 6px 0 rgba(87, 224, 138, 0.5); } }
.statusdot.pending i { background: var(--accent); animation: livepulse 2.4s ease-in-out infinite; }
.statusdot.offline i { background: var(--faint); animation: none; }
h1 { font-size: 28px; font-weight: 750; letter-spacing: -0.03em; margin: 14px 0 3px; }
.sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.sub .red { color: var(--danger); }
h2 { font-size: 12.5px; font-weight: 600; color: var(--faint); margin: 26px 0 8px 2px; }

/* ── Tile-Motiv (wie FitnessOS): Top-Light + hauchzartes Instrumenten-Grid ── */
.tile {
  position: relative; border-radius: var(--radius); border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.018), rgba(255,255,255,0) 38%), var(--surface);
  overflow: hidden; isolation: isolate;
}
.tile::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(130% 85% at 50% 0%, #000 0%, transparent 60%);
  mask-image: radial-gradient(130% 85% at 50% 0%, #000 0%, transparent 60%);
}

/* ── Listen: Zeilen in Tiles ── */
.row {
  display: flex; align-items: center; gap: 13px; padding: 13px 15px;
  border-bottom: 1px solid var(--border); min-height: 54px; transition: background 0.15s;
}
.row:last-child { border-bottom: none; }
.row:active { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 15px; font-weight: 500; letter-spacing: -0.01em; }
.row .m { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row.done .t { color: var(--faint); text-decoration: line-through; font-weight: 400; }
.row.inactive { opacity: 0.4; }
.time { min-width: 44px; font-size: 12.5px; color: var(--accent); }
.prio-mark { color: var(--accent); font-weight: 700; margin-right: 2px; }
.empty { color: var(--faint); font-size: 14px; padding: 24px 16px; text-align: center; }

/* ── Check-Kreis: der eine erlaubte Akzent-Moment ── */
.chk {
  width: 25px; height: 25px; border-radius: 50%; flex: 0 0 25px;
  border: 1.4px solid var(--border-strong); background: transparent; cursor: pointer;
  display: grid; place-content: center; padding: 0;
  transition: border-color 0.15s, background 0.18s, transform 0.12s;
}
.chk svg { width: 12px; height: 12px; stroke: transparent; transition: stroke 0.15s; }
.chk.on { background: var(--accent); border-color: var(--accent); animation: settle 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
.chk.on svg { stroke: var(--accent-ink); }
.chk:active { transform: scale(0.86); }
@keyframes settle { 0% { transform: scale(0.8); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* ── Buttons & Inputs ── */
.btn {
  border: 1px solid var(--border-strong); border-radius: 9px; padding: 12px 18px;
  font-weight: 600; font-size: 14.5px; cursor: pointer; background: var(--surface-2);
  color: var(--text); transition: transform 0.1s, border-color 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 13px; height: 13px; vertical-align: -2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.ghost { background: none; border: none; color: var(--faint); padding: 8px 9px; }
.btn.ghost:active { color: var(--danger); }
.btn.ghost svg { width: 14px; height: 14px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); }
input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  padding: 11px 13px; width: 100%; outline: none; transition: border-color 0.15s;
  font-size: 15px;
}
input:focus, select:focus, textarea:focus { border-color: rgba(215, 189, 131, 0.5); }
input::placeholder { color: var(--faint); }
input[type="time"], input[type="date"] { font-family: var(--font-mono); font-size: 14px; }
label.f { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
label.f > input, label.f > select, label.f > textarea { margin-top: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.quickadd { display: flex; gap: 9px; margin: 2px 0 4px; }
.quickadd input { flex: 1; }
.quickadd .btn { flex: 0 0 auto; padding: 10px 15px; display: grid; place-content: center; }
.quickadd .btn svg { width: 16px; height: 16px; }

/* ── Schalter ── */
.switch { position: relative; width: 44px; height: 26px; flex: 0 0 44px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border-strong); transition: 0.2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--faint); transition: 0.22s cubic-bezier(0.22, 1, 0.36, 1); }
.switch input:checked + i { background: rgba(215, 189, 131, 0.14); border-color: rgba(215, 189, 131, 0.4); }
.switch input:checked + i::after { transform: translateX(18px); background: var(--accent); }

/* ── Chips ── */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip { padding: 7px 12px; border-radius: 8px; background: var(--surface-2); color: var(--faint);
  font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid var(--border);
  transition: all 0.12s; }
.chip.on { color: var(--accent); border-color: rgba(215, 189, 131, 0.45); background: rgba(215, 189, 131, 0.07); }

/* ── Tab-Bar: Icons + Mikro-Label, aktiv = Textfarbe + Akzent-Punkt ── */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: rgba(6, 6, 8, 0.86);
  -webkit-backdrop-filter: blur(22px) saturate(1.3); backdrop-filter: blur(22px) saturate(1.3);
  border-top: 1px solid var(--border);
  padding: 9px 6px calc(9px + env(safe-area-inset-bottom));
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: none; border: none; color: var(--faint); font-size: 10.5px; font-weight: 600;
  cursor: pointer; padding: 2px 0;
  transition: color 0.15s, transform 0.1s; position: relative; }
.tab svg { width: 21px; height: 21px; }
.tab.on { color: var(--text); }
.tab.on::after { content: ""; position: absolute; bottom: -6px; width: 3.5px; height: 3.5px;
  border-radius: 50%; background: var(--accent); }
.tab:active { transform: scale(0.93); }

/* ── FAB: schwarz, feiner Rand, Akzent nur im Icon ── */
.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 14px); z-index: 15;
  width: 54px; height: 54px; border-radius: 14px; cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0) 45%), var(--surface-2);
  border: 1px solid var(--border-strong);
  display: grid; place-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  transition: transform 0.12s;
}
.fab svg { width: 20px; height: 20px; stroke: var(--accent); }
.fab:active { transform: scale(0.9); }

/* ── Sheet ── */
.backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, 0.6);
  opacity: 0; transition: opacity 0.22s; pointer-events: none; }
.backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 31;
  max-width: 480px; margin: 0 auto; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 13px 20px calc(20px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet.open { transform: translateY(0); }
.sheet .handle { width: 36px; height: 4px; border-radius: 3px; background: var(--surface-2);
  margin: 0 auto 18px; }
.sheet h3 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 18px; }

/* ── Toast ── */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 14px); z-index: 40;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 16px; border-radius: 9px; font-size: 13.5px; font-weight: 550;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  max-width: 86vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ── Login: Higgsfield-Asset als stiller Held ── */
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; padding: 0 36px; max-width: 480px; margin-inline: auto; }
.login .hero {
  width: 200px; height: 200px; border-radius: 50%; object-fit: cover;
  -webkit-mask-image: radial-gradient(circle, #000 55%, transparent 72%);
  mask-image: radial-gradient(circle, #000 55%, transparent 72%);
  margin-bottom: 4px;
}
.login h1 { font-size: 16px; letter-spacing: 0.3em; font-weight: 650; margin: 0; }
.login .err { color: var(--danger); font-size: 13px; min-height: 18px; }
.login input, .login .btn { width: 260px; }
.login input { text-align: center; }

/* ── Abos: Gesamtkarte mit Asset-Hintergrund ── */
.total {
  position: relative; border-radius: var(--radius); border: 1px solid var(--border-strong);
  padding: 20px 18px; margin-bottom: 8px; overflow: hidden; isolation: isolate;
  background: var(--surface); min-height: 132px;
  display: flex; flex-direction: column; justify-content: center;
}
.total .bgimg { position: absolute; inset: 0; z-index: -1; object-fit: cover;
  object-position: 78% 42%; width: 100%; height: 100%; opacity: 0.9; }
.total .shade { position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(5, 5, 6, 0.96) 34%, rgba(5, 5, 6, 0.12)); }
.total .big { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; }
.total .big .usd { font-size: 15px; color: var(--muted); font-weight: 650; }
.total .m { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.cancelzone { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.sub-ico {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  display: grid; place-content: center; color: var(--muted);
}
.sub-ico svg { width: 16px; height: 16px; }

/* ── Notizen: Detail-Sheet + Wissens-Netz ── */
.note-kind { font-size: 11px; font-weight: 650; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint); }
.note-body { font-size: 14px; line-height: 1.65; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; }
.note-body .note-h { display: block; font-weight: 700; font-size: 12px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent); margin: 10px 0 2px; }
.note-body .note-h:first-child { margin-top: 0; }
.note-go svg { width: 12px; height: 12px; color: var(--faint); }
.graph-wrap {
  border: 1px solid var(--border); border-radius: var(--radius); margin: 12px 0 10px;
  background:
    radial-gradient(120% 100% at 50% -30%, rgba(215, 189, 131, 0.06), transparent 55%),
    var(--surface);
  overflow: hidden;
}
.graph-wrap .graph { width: 100%; display: block; }
.legend { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 4px 0 2px; }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.legend .lg i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.amount { font-size: 14.5px; font-weight: 650; }
.badge { font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge.ok { color: var(--positive); }
.badge.warn { color: var(--danger); }

/* ── Segment ── */
.seg { display: flex; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 3px; margin-bottom: 14px; }
.seg button { flex: 1; border: none; background: none; color: var(--muted); padding: 8px;
  font-weight: 600; font-size: 13.5px; border-radius: 7px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }

/* ── Animationen: leise, opazitätsbasiert ── */
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }
.rise { animation: rise 0.3s ease both; }
@keyframes livepulse { 0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.35); } }
.hint { font-size: 12px; color: var(--faint); margin: 8px 2px; line-height: 1.55; }
.icon { width: 16px; height: 16px; }
svg.stroke { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round;
  stroke-linejoin: round; }

@media (prefers-reduced-motion: reduce) {
  .rise, .statusdot.pending i, .chk.on { animation: none; }
  .sheet, .backdrop, .switch i::after { transition: none; }
}

/* ── Tages-Element: EINE Sache pro Tag, große Bühne, einklappbar ── */
details.daily {
  position: relative; margin: 16px 0 18px; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; isolation: isolate;
  background:
    radial-gradient(120% 100% at 50% -30%, rgba(215, 189, 131, 0.09), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0) 40%), var(--surface);
}
details.daily::before { /* Bühnenlicht: goldene Haarlinie oben */
  content: ""; position: absolute; top: 0; left: 14%; right: 14%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(215, 189, 131, 0.55), transparent);
}
.daily summary {
  list-style: none; cursor: pointer; -webkit-user-select: none; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; font-size: 10.5px; font-weight: 650; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--faint);
}
.daily summary::-webkit-details-marker { display: none; }
.daily .d-chev svg { width: 12px; height: 12px; transform: rotate(90deg); transition: transform 0.2s; }
details.daily[open] .d-chev svg { transform: rotate(-90deg); }
.daily .d-body { padding: 2px 18px 20px; animation: rise 0.35s ease both; }
.d-line, .d-quote {
  font-family: "New York", "Iowan Old Style", Georgia, serif;
  font-size: 20px; line-height: 1.38; font-weight: 600; letter-spacing: -0.01em;
}
.d-quote { font-style: italic; font-weight: 500; }
.d-author { margin-top: 12px; color: var(--accent); font-size: 11px; font-weight: 650;
  letter-spacing: 0.14em; text-transform: uppercase; }
.d-shift { margin-top: 13px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.d-shift s { color: var(--faint); text-decoration-color: rgba(255, 92, 92, 0.5); }
.d-shift .d-arrow { margin: 0 7px; color: var(--accent); }
.d-shift em { color: var(--text); font-style: normal; font-weight: 550; }
.d-title { font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.d-text { font-size: 13px; color: var(--muted); line-height: 1.6; margin-top: 6px; }
.daily .chart { width: 100%; margin-top: 12px; display: block; }

/* ── Quick-Links (Heute) ── */
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2px; }
.links a {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 600; color: var(--text);
  background: linear-gradient(180deg, rgba(255,255,255,0.018), rgba(255,255,255,0) 38%), var(--surface);
  transition: border-color 0.15s;
}
.links a:active { border-color: var(--border-strong); }
.links a svg { width: 13px; height: 13px; color: var(--faint); }
.ai-links { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.ai-links a {
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 4px;
  text-align: center; font-size: 12.5px; font-weight: 550; color: var(--muted);
  background: var(--surface); transition: color 0.15s, border-color 0.15s;
}
.ai-links a:active { color: var(--text); border-color: var(--border-strong); }

/* ── Erledigt: kollabierbar ── */
details.collapse { border: none; }
details.collapse summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--faint); margin: 26px 0 8px 2px;
  -webkit-user-select: none; user-select: none;
}
details.collapse summary::-webkit-details-marker { display: none; }
details.collapse summary svg { width: 12px; height: 12px; transition: transform 0.18s; }
details.collapse[open] summary svg { transform: rotate(90deg); }

/* ── Abhaken: Häkchen kurz zeigen, dann Zeile leise verabschieden ── */
.row.out {
  opacity: 0; transform: translateX(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ── Voice-Eingabe ── */
.mic { position: relative; }
.mic.rec { border-color: var(--accent); color: var(--accent); }
.mic.rec::after {
  content: ""; position: absolute; inset: -1px; border-radius: 9px;
  border: 1px solid var(--accent); animation: recpulse 1.6s ease-out infinite;
  pointer-events: none;
}
@keyframes recpulse { 0% { opacity: 0.8; transform: scale(1); } 100% { opacity: 0; transform: scale(1.18); } }
.mic.busy { opacity: 0.55; pointer-events: none; }

/* ── Desktop: Navigation als obere Leiste, Spalte bleibt ruhig zentriert ── */
@media (min-width: 880px) {
  #app { max-width: 560px; display: flex; flex-direction: column; }
  .tabbar {
    position: static; order: -1; background: none; border-top: none;
    -webkit-backdrop-filter: none; backdrop-filter: none;
    justify-content: flex-start; gap: 4px;
    padding: 22px 18px 0;
  }
  .tab {
    flex: 0 0 auto; flex-direction: row; gap: 8px; font-size: 13.5px;
    padding: 8px 13px; border-radius: 9px;
  }
  .tab svg { width: 16px; height: 16px; }
  .tab.on { background: var(--surface); border: 1px solid var(--border); }
  .tab.on::after { display: none; }
  .screen { padding-top: 18px; padding-bottom: 60px; }
  .fab { left: calc(50% + 200px); right: auto; bottom: 44px; }
  .sheet { max-width: 560px; border-radius: 16px; bottom: auto; top: 12dvh;
    left: 50%; right: auto; transform: translate(-50%, -30px); opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease; }
  .sheet.open { transform: translate(-50%, 0); opacity: 1; }
  #toast { bottom: 34px; }
  body { padding-bottom: 0; }
}
