/* Begleit-App – Gestaltung nach DESIGN.md: Fluent 2 mit Touch-Dichte, eine Akzentfarbe, Farbe nur mit Bedeutung,
   Systemschrift des Handys (Segoe UI gibt es dort nicht). Ziele mindestens 44 px. Hell und dunkel nach dem System. */
:root {
  --accent: #005fb8; --accent-ink: #ffffff; --ground: #f3f3f3; --card: #fbfbfb; --line: #e0e0e0; --ink: #1b1b1b; --mute: #5c5c5c;
  --shelf: #ededed; --field-edge: #838383; --warn: #9a5b00; --ok: #0f7b0f; --bad: #c42b1c;
  --r-sm: 4px; --r-md: 8px; --r-card: 12px; --tap: 44px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --accent: #60cdff; --accent-ink: #000000; --ground: #202020; --card: #2b2b2b; --line: #3b3b3b; --ink: #f3f3f3; --mute: #ababab;
    --shelf: #353535; --field-edge: #9a9a9a; --warn: #fce100; --ok: #6ccb5f; --bad: #ff99a4; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 400 16px/1.45 var(--font); background: var(--ground); color: var(--ink); min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Kopfzeile und Reiterleiste */
.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 16px 8px; background: var(--ground); }
.bar h1 { flex: 1; margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.3px; }
.icon-btn { min-width: var(--tap); min-height: var(--tap); display: inline-grid; place-items: center; border: 0; border-radius: var(--r-md); background: transparent; padding: 0; cursor: pointer; }
.icon-btn:active { background: var(--shelf); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .icon-btn.spin svg { animation: none; } }
main { padding: 0 16px calc(84px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; outline: none; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding: 4px env(safe-area-inset-right) calc(4px + env(safe-area-inset-bottom)) env(safe-area-inset-left); }
.tabs button { min-height: 56px; border: 0; background: none; display: grid; justify-items: center; align-content: center; gap: 2px; font-size: 12px; color: var(--mute); cursor: pointer; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Bausteine */
.loading { color: var(--mute); padding: 32px 0; text-align: center; }
h2.sec { font-size: 15px; font-weight: 600; margin: 22px 0 8px; color: var(--mute); }
h2.sec.bad { color: var(--bad); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); padding: 14px 16px; margin: 0 0 12px; }
.list { list-style: none; margin: 0 0 12px; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.list > li { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 6px 12px 6px 16px; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; display: grid; gap: 1px; text-align: left; }
.list .grow > span:first-child { overflow-wrap: anywhere; }
.row-btn { flex: 1; min-width: 0; display: grid; gap: 1px; text-align: left; border: 0; background: none; padding: 6px 0; min-height: var(--tap); cursor: pointer; }
.sub { font-size: 13px; color: var(--mute); }
.when { font-variant-numeric: tabular-nums; color: var(--mute); font-size: 14px; min-width: 46px; }
.done > .grow > span:first-child, .done .row-btn > span:first-child { text-decoration: line-through; color: var(--mute); }
.over { color: var(--bad); }
.tag { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; background: var(--shelf); color: var(--mute); }
.empty { color: var(--mute); padding: 18px 16px; margin: 0; }
.hint { color: var(--mute); font-size: 14px; }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.btn { min-height: var(--tap); padding: 8px 16px; border: 1px solid var(--line); border-bottom-color: var(--field-edge); border-radius: var(--r-sm);
  background: var(--card); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { background: var(--shelf); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn svg { width: 18px; height: 18px; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btns .btn { flex: 1 1 auto; }

/* Abhaken: großes Ziel, eigenes Kästchen */
.check { flex: none; width: var(--tap); height: var(--tap); margin-left: -10px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; }
.check::before { content: ''; width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--field-edge); box-sizing: border-box; }
.check[aria-checked="true"]::before { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"]::after { content: ''; position: absolute; width: 6px; height: 11px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: translate(0, -1px) rotate(45deg); }
.check { position: relative; }

/* Heute */
.today-date { font-size: 15px; color: var(--mute); margin: 0 0 12px; }
.wx { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; }
.wx-now { font-size: 40px; font-weight: 600; line-height: 1; grid-row: span 2; }
.wx-days { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 8px; margin-top: 12px; text-align: center; font-size: 14px; }
.wx-days b, .wx-days span { display: block; }
.wx-days b { font-weight: 600; }
.src { font-size: 12px; color: var(--mute); margin-top: 10px; }

/* Formulare */
.field { display: grid; gap: 4px; margin: 0 0 14px; }
.field > span { font-size: 14px; color: var(--mute); }
.field input, .field select, .field textarea { min-height: var(--tap); width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-bottom-color: var(--field-edge);
  border-radius: var(--r-sm); background: var(--card); }
.field textarea { min-height: 140px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; background: var(--shelf); border-radius: var(--r-md); padding: 3px; margin: 0 0 14px; }
.seg button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.code-in { font: 600 22px/1.2 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: .12em; text-transform: uppercase; text-align: center; }
.sas { font: 600 34px/1.1 ui-monospace, 'SF Mono', Menlo, Consolas, monospace; letter-spacing: .08em; text-align: center; margin: 12px 0; }
.add-row { display: flex; gap: 8px; margin: 0 0 12px; }
.add-row input { flex: 1; min-height: var(--tap); padding: 8px 12px; border: 1px solid var(--line); border-bottom-color: var(--field-edge); border-radius: var(--r-sm); background: var(--card); min-width: 0; }

/* Notizen */
.note-body { overflow-wrap: anywhere; }
.note-body ul, .note-body ol { padding-left: 22px; }
.note-body table { border-collapse: collapse; }
.note-body td, .note-body th { border: 1px solid var(--line); padding: 4px 8px; }
.pin { color: var(--accent); }

/* Blatt (Bearbeiten, Details) */
.sheet { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 720px; max-height: 92dvh; border-radius: 16px 16px 0 0; background: var(--ground); color: var(--ink); }
.sheet::backdrop { background: rgba(0, 0, 0, .4); }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; gap: 8px; padding: 12px 8px 4px 16px; background: var(--ground); }
.sheet-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; }
.sheet-body { padding: 4px 16px calc(20px + env(safe-area-inset-bottom)); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 20; max-width: 560px; margin: 0 auto;
  background: var(--ink); color: var(--ground); border-radius: var(--r-md); padding: 12px 16px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.setup { padding-top: 12px; }
.setup h2 { font-size: 20px; margin: 8px 0 8px; }
.setup small.hint { display: block; margin: -6px 0 14px; }
.steps { padding-left: 20px; }
.steps li { margin: 0 0 8px; }
