/* Aufbau: eine schmale Spalte wie eine Handy-App; Karten, feste Tab-Leiste unten, Eingaben in einem Blatt von unten. */
@font-face { font-family: "Zen Old Mincho"; src: url("/fonts/zen-old-mincho-700.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Zen Maru Gothic"; src: url("/fonts/zen-maru-gothic-500.woff2") format("woff2"); font-weight: 300 500; font-display: swap; }
@font-face { font-family: "Zen Maru Gothic"; src: url("/fonts/zen-maru-gothic-700.woff2") format("woff2"); font-weight: 600 900; font-display: swap; }
/* Woki's Teahouse: Pfirsichblüten-Papier, Seladon-Glasur, Porzellanblau, Zinnober-Siegel.
   *-ink sind die dunkleren Textvarianten derselben Farben (Kontrast ≥ 4,5:1 auf ihren Flächen). */
:root {
  --bg: #F7EEEA; --surface: #FFFBF8; --surface-2: #EEDFD9; --ink: #3A2F35; --muted: #6E5D63; --line: #E6D4CD;
  --primary: #4F7D6B; --primary-ink: #3F6B5A; --primary-soft: #D9E8DF; --on-primary: #FFFFFF;
  --accent: #C7655A; --accent-ink: #A0463D; --accent-soft: #F6DAD3; --steam: #7F9CC4; --steam-soft: #E3E7F1;
  --danger: #A8322A; --danger-soft: #F6D9D4; --scrim: rgba(40, 26, 30, 0.45);
  --display: "Zen Old Mincho", "Songti SC", Georgia, serif;
  --body: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", -apple-system, "Segoe UI", system-ui, sans-serif;
  --r: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E1A1F; --surface: #29232A; --surface-2: #352D36; --ink: #F1E6E3; --muted: #B7A6AA; --line: #3D343E;
    --primary: #9CCBB6; --primary-ink: #A8D4C0; --primary-soft: #2A3A33; --on-primary: #14231C;
    --accent: #EE9A8E; --accent-ink: #F2A99F; --accent-soft: #3F2826; --steam: #9FB8DC; --steam-soft: #2A2C3A;
    --danger: #F08A7B; --danger-soft: #3E2220; --scrim: rgba(0, 0, 0, 0.55); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); margin: 0; }
body { color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app {
  max-width: 560px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(12px, env(safe-area-inset-top, 0px)); padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 16px;
}
h1, h2, h3 { font-family: var(--display); text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; font-weight: 700; line-height: 1.05; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
p { margin: 0; }
.eyebrow { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; border-radius: 8px; }

/* Kopf */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.head > div:first-child { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.daynav { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.iconbtn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; padding: 0; flex-shrink: 0; }
.iconbtn svg { width: 20px; height: 20px; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0 14px; height: 42px; font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.chip-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary-ink); color: var(--on-primary); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chips .chip-btn { height: 38px; padding: 0 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); display: inline-grid; place-items: center; font-family: var(--display); font-weight: 700; font-size: 0.95rem; flex-shrink: 0; border: 0; padding: 0; text-transform: uppercase; }
.avatar.big { width: 44px; height: 44px; font-size: 1.15rem; }
.avatar.sm { width: 24px; height: 24px; font-size: 0.72rem; }

/* Messbalken */
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meter { background: var(--surface); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.meter .big { font-family: var(--display); font-weight: 700; font-size: 1.6rem; line-height: 1; }
.meter .big small { font-family: var(--body); font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); position: relative; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; max-width: 100%; }
.bar .plan { background: var(--primary-soft); }
.bar .eaten { background: var(--primary); }
.meter.kcal .bar .plan { background: var(--accent-soft); }
.meter.kcal .bar .eaten { background: var(--accent); }
.meter .sub { font-size: 0.8rem; color: var(--muted); }

.hint { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; padding: 10px 12px; border-radius: 12px; background: var(--primary-soft); }
.hint.amber { background: var(--accent-soft); }
.hint svg { flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px; }

/* Karten */
.stack { display: flex; flex-direction: column; gap: 12px; }
.card, .meal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.meal.dinner { border: 4px double var(--primary); }
.meal.done { opacity: 0.62; }
.meal-top { display: flex; gap: 12px; align-items: flex-start; }
.meal-top > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.check { width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--line); background: transparent; display: grid; place-items: center; padding: 0; }
.check svg { width: 16px; height: 16px; opacity: 0; }
.check[aria-checked="true"], .got > .check { background: var(--primary); border-color: var(--primary-ink); color: var(--on-primary); }
.check[aria-checked="true"] svg, .got > .check svg { opacity: 1; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { font-size: 0.78rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pill.k { background: var(--accent-soft); color: var(--accent-ink); }
.pill.t { background: var(--surface-2); color: var(--muted); }
.ing { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ing li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.ing li:last-child { border-bottom: 0; }
.ing li span:last-child { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.basics { font-size: 0.85rem; color: var(--muted); }
.basics b { color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.linkbtn { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 7px 12px; font-size: 0.85rem; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; min-height: 36px; text-decoration: none; }
.linkbtn svg { width: 15px; height: 15px; }
.linkbtn.danger { color: var(--danger); border-color: var(--danger); }
.linkbtn:disabled { opacity: 0.5; cursor: default; }
.btn { border: 0; background: var(--primary); color: var(--on-primary); border-radius: 12px; padding: 12px 16px; font-weight: 700; min-height: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.5; }
.btn svg { width: 18px; height: 18px; }
.steps { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; font-size: 0.93rem; }
.note { font-size: 0.85rem; color: var(--muted); }
.who { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.slot-add { border: 1.5px dashed var(--line); background: transparent; border-radius: var(--r); padding: 12px 14px; display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; width: 100%; text-align: left; min-height: 48px; }
.slot-add svg { width: 18px; height: 18px; }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.row:last-child { border-bottom: 0; }
.row > .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .nm { font-weight: 600; overflow-wrap: anywhere; }
.row .why { font-size: 0.8rem; color: var(--muted); }
.rows { display: flex; flex-direction: column; }
button.row { background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; width: 100%; }

/* Einkauf */
.aisle { display: flex; flex-direction: column; gap: 2px; }
.aisle h3 { font-size: 0.78rem; font-family: var(--body); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 0 4px; }
.buy { display: flex; align-items: center; gap: 12px; padding: 9px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; width: 100%; }
.aisle .buy:last-child { border-bottom: 0; }
.buy .check { width: 26px; height: 26px; }
.buy > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.buy .nm { font-weight: 600; }
.buy .why { font-size: 0.8rem; color: var(--muted); }
.buy .qty { font-family: var(--display); font-weight: 700; font-size: 1.05rem; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; }
.buy .qty small { display: block; font-family: var(--body); font-weight: 500; font-size: 0.75rem; color: var(--muted); }
.buy.got .nm { text-decoration: line-through; color: var(--muted); }
.addbtn { width: 38px; height: 38px; flex-shrink: 0; border-radius: 50%; border: 1.5px solid var(--primary); background: transparent; color: var(--primary-ink); display: grid; place-items: center; padding: 0; }
.addbtn svg { width: 18px; height: 18px; }
.addbtn.x { border-color: var(--line); color: var(--muted); }
.split { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.seg-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg-tabs button { border: 0; background: transparent; border-radius: 9px; padding: 9px 8px; font-weight: 700; font-size: 0.92rem; color: var(--muted); min-height: 40px; }
.seg-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); }
.amount { font-family: var(--display); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.pos { color: var(--primary-ink); }
.amount.neg { color: var(--danger); }

/* Plan */
.dayrow { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; background: var(--surface); border-radius: 12px; border: 1px solid transparent; text-align: left; width: 100%; }
.dayrow.today { border-color: var(--primary-ink); }
.dayrow .wd { font-family: var(--display); font-weight: 700; line-height: 1.1; }
.dayrow .wd small { display: block; font-family: var(--body); font-weight: 500; font-size: 0.75rem; color: var(--muted); }
.dayrow .dn { min-width: 0; font-size: 0.93rem; }
.dayrow .dn small { display: block; color: var(--muted); font-size: 0.78rem; }
.dayrow .pp { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary-ink); font-size: 0.9rem; }
.week { display: flex; flex-direction: column; gap: 4px; }

/* Leute */
.person { display: flex; flex-direction: column; gap: 10px; }
.person-top { display: flex; align-items: center; gap: 12px; }
.person-top > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.person-top .nm { font-family: var(--display); font-weight: 700; font-size: 1.05rem; }
.streak { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--accent-ink); font-size: 0.88rem; }
.streak svg { width: 16px; height: 16px; }
.dots { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dot-day { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.dot-day i { width: 100%; max-width: 30px; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--surface-2) 0); display: grid; place-items: center; }
.dot-day i::after { content: ""; width: 62%; aspect-ratio: 1; border-radius: 50%; background: var(--surface); }
.dot-day.hit i { background: var(--primary); }
.dot-day.hit i::after { background: var(--primary); }
.notif { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; display: flex; gap: 10px; align-items: baseline; }
.notif:last-child { border-bottom: 0; }
.notif.unread { font-weight: 600; }
.notif time { font-size: 0.78rem; color: var(--muted); white-space: nowrap; margin-left: auto; font-weight: 500; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 1.25rem; font-weight: 700; letter-spacing: 0.12em; background: var(--surface-2); padding: 8px 12px; border-radius: 10px; user-select: all; }

/* Formulare */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .lbl { font-weight: 600; font-size: 0.92rem; }
.input, .field input:not([type="checkbox"]):not([type="file"]), .field select, .field textarea {
  padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; min-height: 46px; font-size: 16px;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.4; }
textarea.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; min-height: 180px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.inline { display: flex; gap: 8px; align-items: stretch; }
.inline .input { flex: 1; min-width: 0; }
.seg { display: flex; flex-direction: column; gap: 6px; }
.seg button { text-align: left; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.seg button[aria-pressed="true"] { border-color: var(--primary-ink); background: var(--primary-soft); }
.seg button small { display: block; color: var(--muted); }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 1.1rem; padding: 0; }
.stepper span { min-width: 3.2em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.ingrow { display: grid; grid-template-columns: 1fr 64px 76px 36px; gap: 6px; align-items: center; }
.ingrow input, .ingrow select { padding: 9px 8px !important; min-height: 42px !important; min-width: 0; }
.ingrow .cat { grid-column: 1 / -1; }
.ing-edit { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.err { color: var(--danger); font-size: 0.88rem; font-weight: 600; }
.okmsg { color: var(--primary-ink); font-size: 0.88rem; font-weight: 600; }

/* Anmeldung */
.auth { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.auth .woki { width: 112px; height: auto; margin-left: -6px; }

/* Blatt von unten */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  border-radius: 20px 20px 0 0; padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: -16px; background: var(--bg); padding: 12px 0 8px; margin: -12px 0 -4px; z-index: 2; }
.sheet-head h2 { min-width: 0; }
@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } }
  .meal, .card, .dayrow { transition: opacity .2s ease; }
}

/* Tab-Leiste */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(4px, env(safe-area-inset-left, 0px)); padding-right: max(4px, env(safe-area-inset-right, 0px)); }
.tabbar nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); }
.tab { border: 0; background: none; padding: 8px 2px 10px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 0.7rem; font-weight: 600; color: var(--muted); position: relative; min-width: 0; }
.tab svg { width: 24px; height: 24px; padding: 2px 14px; box-sizing: content-box; border-radius: 999px; }
.tab[aria-current="page"] { color: var(--primary-ink); }
.tab[aria-current="page"] svg { background: var(--primary-soft); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); font-size: 0.68rem; background: var(--danger); color: var(--surface); border-radius: 999px; padding: 0 6px; min-width: 18px; line-height: 18px; font-weight: 700; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 0.92rem; max-width: min(90vw, 480px); text-align: center; }
.toast.bad { background: var(--danger); color: var(--surface); }

/* Woki (public/js/woki.js): Farben je Rolle, Linien mit -s */
.woki { display: block; flex-shrink: 0; }
.wk-body { fill: var(--primary); } .wk-body-s { stroke: var(--primary); }
.wk-face { fill: var(--on-primary); } .wk-face-s { stroke: var(--on-primary); }
.wk-cheek { fill: var(--accent); }
.wk-steam-s { stroke: var(--steam); }
.wk-seal { fill: var(--accent); }
.wk-glyph { fill: var(--surface); }
.brand { display: flex; align-items: center; gap: 8px; margin-bottom: -8px; }
.brand .woki { width: 34px; height: auto; }
.brand span { font-family: var(--display); font-weight: 700; font-size: 1rem; }
.woki-card { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border-radius: var(--r); background: var(--steam-soft); border: 1px solid var(--line); text-align: left; width: 100%; color: var(--ink); }
.woki-card .woki { width: 64px; height: auto; }
.woki-card > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.woki-card h3 { font-size: 1.05rem; }
.woki-card p { font-size: 0.9rem; }
.woki-card.nudge { background: var(--accent-soft); }
.notif .woki { width: 26px; height: auto; align-self: center; }
@media (prefers-reduced-motion: no-preference) {
  .woki-card.nudge .woki { animation: wobble 1.6s ease-in-out 2; transform-origin: 50% 80%; }
  @keyframes wobble { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
}
