/* Zettel. Anthrazit als Grundfarbe, Mint als Akzent (wie Angebote und Fitness,
   damit die Apps eine Familie bleiben). Dunkel ist der Standard, hell über
   data-theme="light". Die Farben stehen genauso in icons-quelle.svg. */
@font-face { font-family: "Roboto Slab"; src: url("fonts/roboto-slab-latin.woff2") format("woff2"); font-weight: 300 700; font-display: swap; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Roboto Slab"; src: url("fonts/roboto-slab-latin-ext.woff2") format("woff2"); font-weight: 300 700; font-display: swap; unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --bg: #23262a; --bg-elev: #2b2f34; --bg-elev2: #34383e; --line: #454a52;
  --fg: #e7e9ec; --fg-muted: #a4abb4; --fg-dim: #848b95;
  --accent: #6fd39b; --accent-fg: #16261d;
  --gut: #6fd39b; --neutral: #d9c46a; --achtung: #f08a7a;
  --einkaufen: #7fe0c8; --claude: #b48cff;
  --radius: 14px; --radius-s: 9px; --shadow: 0 6px 18px rgba(0,0,0,.35);
  --font: "Roboto Slab", Georgia, "Times New Roman", serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5f6; --bg-elev: #ffffff; --bg-elev2: #eceef0; --line: #d8dbdf;
  --fg: #1c1f22; --fg-muted: #53585e; --fg-dim: #6d737a;
  --accent: #277d4f; --accent-fg: #ffffff;
  --gut: #2c8a57; --neutral: #9a7f10; --achtung: #c8422f;
  --einkaufen: #178a74; --claude: #7248c9;
  --shadow: 0 6px 18px rgba(0,0,0,.10);
  color-scheme: light;
}

html, body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); font-variant-numeric: tabular-nums; }
* { box-sizing: border-box; }
/* Global statt je Klasse: jede Klasse, die selbst display setzt, hat sonst dieselbe
   Spezifität wie [hidden] und gewinnt je nach Regelreihenfolge. */
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 600; margin: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--fg); background: var(--bg-elev2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .55rem .7rem; width: 100%; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
/* Sicherheitsnetz: icon() setzt keine Groesse, ein SVG ohne passende Regel wird
   sonst so gross wie sein Container. Auf dem iPhone war der Chat-Spinner dadurch
   halbseitengross. Die Regeln weiter unten sind spezifischer und gewinnen. */
svg { width: 20px; height: 20px; flex: 0 0 auto; }

/* Layout */
.page { max-width: 880px; margin: 0 auto; padding: 1rem 1rem 6.5rem; }
.topbar { display: flex; align-items: center; gap: .5rem; padding: .5rem 0 .75rem; }
.topbar h1 { font-size: 1.35rem; flex: 1; }
.iconbtn { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--bg-elev2); color: var(--fg-muted); position: relative; flex: 0 0 auto; }
.iconbtn:hover, .iconbtn:focus-visible { color: var(--fg); outline: 2px solid var(--accent); outline-offset: 2px; }
.iconbtn.klein { width: 32px; height: 32px; }
.iconbtn.klein svg { width: 16px; height: 16px; }
.iconbtn svg, .btn svg { width: 20px; height: 20px; }
.btn { display: inline-flex; align-items: center; gap: .5rem; padding: .6rem 1rem; border-radius: var(--radius-s); background: var(--bg-elev2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.btn.danger { color: var(--achtung); }
.btn.block { width: 100%; justify-content: center; }
.btn.klein { padding: .35rem .7rem; font-size: .85rem; }
.spin { animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.meta { font-size: .78rem; color: var(--fg-dim); margin-top: .5rem; }
.sub { font-size: .8rem; color: var(--fg-muted); }
.chip { display: inline-flex; align-items: center; padding: .12rem .55rem; border-radius: 999px; background: var(--bg-elev2); color: var(--fg-muted); font-size: .74rem; white-space: nowrap; }
.hint { display: flex; gap: .5rem; align-items: flex-start; font-size: .92rem; margin: .3rem 0; }
.grow { flex: 1; min-width: 0; }

/* Karten */
.card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); position: relative; }
.card + .card { margin-top: .9rem; }
/* Panels einer Seite: der Abstand haengt am Behaelter, nicht an der Nachbarschaft
   zweier .card. Die Chat-Karte baut ihren eigenen Rahmen, mit .card + .card allein
   klebten auf der Detailseite Herkunft, Chat und Verlauf aneinander. */
.stapel { display: flex; flex-direction: column; gap: .9rem; }
.stapel > .card + .card { margin-top: 0; }
.stapel > .form-actions { margin-top: .6rem; }   /* Loeschen steht fuer sich */
.card h2 { font-size: 1.05rem; }
.card-head { display: flex; align-items: center; gap: .6rem; }
.card-head h2 { font-size: 1.05rem; flex: 1; }
/* Ohne feste Groesse wird ein SVG im Kartenkopf so hoch wie die Karte. */
.card-head > svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--fg-muted); }
/* Abstaende zwischen den Bausteinen einer Karte. Auf dem iPhone klebten sonst
   Listenzeilen, Hinweise und Knoepfe aneinander (gemessen 11.09.2026). Die Karte
   bleibt ein Block-Container: flex column wuerde jeden Knopf auf die ganze Breite
   ziehen. */
.card > * + * { margin-top: .7rem; }
.card > .sub + .sub { margin-top: .15rem; }             /* zwei Zeilen, ein Block */
.card.herkunft > .sub + .sub { margin-top: .35rem; }    /* drei eigene Angaben */
.card > .row-flex + .row-flex { margin-top: .4rem; }    /* eine Reihe gleicher Zeilen */
.card > h3 + * { margin-top: 0; }                       /* h3 bringt eigene Abstaende */
/* Bausteine mit eigenem Abstand: in der Karte uebernimmt die Regel oben. */
.card > .field { margin-bottom: 0; }
.card > .segment, .card > .inline-form, .card > .code-box, .card > .anhaenge,
.card > .form-actions, .card > .meta { margin-top: .7rem; }

.card.hinweis { border-color: var(--claude); }
.card.einkauf { border-left: 4px solid var(--einkaufen); }

/* Reiterleiste */
.reiter { display: flex; gap: .3rem; padding: 0 0 .85rem; }
.reiter button { flex: 1; padding: .5rem .3rem; border-radius: var(--radius-s); background: var(--bg-elev2); color: var(--fg-muted); display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.reiter button[aria-current="page"] { background: var(--bg-elev); color: var(--fg); box-shadow: inset 0 -2px 0 var(--accent); }
.reiter svg { width: 17px; height: 17px; }
.plakette { min-width: 20px; padding: 0 .3rem; height: 20px; border-radius: 999px; background: var(--achtung); color: var(--bg); font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* Eintragszeilen */
.zeilen { display: flex; flex-direction: column; }
.zeile { display: flex; align-items: flex-start; gap: .6rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.zeile:first-child { border-top: 0; }
.kaestchen { flex: 0 0 26px; height: 26px; margin-top: .1rem; border: 2px solid var(--fg-dim); border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: transparent; }
.kaestchen svg { width: 16px; height: 16px; }
.kaestchen[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.zeileninhalt { flex: 1; text-align: left; padding: 0; }
.zeileninhalt .titel { display: block; }
.zeile[data-marke="ueberfaellig"] .titel { color: var(--achtung); }
.zeile[data-marke="dringend"] .kaestchen, .zeile[data-marke="ueberfaellig"] .kaestchen { border-color: var(--achtung); }
.zeile[data-marke="heute"] .kaestchen { border-color: var(--neutral); }
.zeile.weg { opacity: 0; transform: translateX(1.2rem); transition: opacity .18s ease, transform .18s ease; }
.zeile.erledigt .titel { text-decoration: line-through; color: var(--fg-dim); }
.zeileninhalt .sub { display: flex; flex-wrap: wrap; gap: .1rem .5rem; align-items: center; }
.zeileninhalt .sub svg { width: 13px; height: 13px; vertical-align: -2px; }

/* Listenköpfe */
.listenkopf { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left; padding: 0 0 .4rem; }
.listenkopf h2 { flex: 1; font-size: 1.05rem; }
.listenkopf .zahl { color: var(--fg-muted); }
.listenkopf > svg { width: 18px; height: 18px; transition: transform .15s; color: var(--fg-muted); }
.listenkopf[aria-expanded="false"] > svg { transform: rotate(-90deg); }
.marke { font-size: .7rem; padding: .1rem .45rem; border-radius: 999px; background: var(--claude); color: var(--bg); }
.unterliste { padding-left: 1.2rem; }
.erledigt-block { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.erledigt-block > summary { cursor: pointer; font-size: .82rem; color: var(--fg-dim); list-style: none; }
.erledigt-block > summary::-webkit-details-marker { display: none; }

/* Erfassungsleiste */
.erfassen { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; gap: .5rem; align-items: flex-end;
  background: var(--bg-elev); border-top: 1px solid var(--line);
  padding: .6rem max(.75rem, env(safe-area-inset-right)) calc(.6rem + env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left)); }
.erfassen textarea { flex: 1; resize: none; line-height: 1.35; height: 2.6rem;
  min-height: 2.6rem; max-height: calc(1.35em * 4 + 1.2rem); overflow-y: auto; }
.erfassen .iconbtn { flex: 0 0 auto; }
.erfassen-blatt { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--bg-elev); border-top: 1px solid var(--line); box-shadow: var(--shadow);
  padding: 1rem max(.75rem, env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) max(.75rem, env(safe-area-inset-left)); }
.erfassen-blatt .vorschau { display: flex; gap: .5rem; overflow-x: auto; }
.erfassen-blatt .vorschau img { height: 96px; border-radius: var(--radius-s); }
.segment { display: flex; gap: .4rem; margin-top: .7rem; }
.segment button { flex: 1; padding: .6rem .4rem; border-radius: var(--radius-s); background: var(--bg-elev2); color: var(--fg-muted); border: 1px solid var(--line); }
.segment button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
.laeuft { display: flex; align-items: center; gap: .5rem; color: var(--fg-muted); font-size: .9rem; }
.laeuft svg { width: 18px; height: 18px; }

/* Aufnahme */
.aufnahme-kopf { display: flex; align-items: center; gap: .5rem; }
.aufnahme-kopf svg { width: 20px; height: 20px; color: var(--achtung); }
.aufnahme-kopf .num { font-size: 1.2rem; font-weight: 600; }
.pegel { height: 10px; border-radius: 999px; background: var(--bg-elev2); margin: .8rem 0; overflow: hidden; }
.pegel-balken { height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }
.iconbtn.laeuft-rot { background: var(--achtung); color: var(--bg); animation: pulsieren 1.2s ease-in-out infinite; }
@keyframes pulsieren { 50% { opacity: .55; } }

/* Listen, Zeilen, Formulare */
.row-flex { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: var(--radius-s); background: var(--bg-elev2); }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; }
.field label { font-size: .82rem; color: var(--fg-muted); }
.field textarea { resize: vertical; }
.field .mit-loeschen { display: flex; gap: .4rem; align-items: center; }
/* segment und inline-form haben ausserhalb einer Karte ihren eigenen Abstand,
   im Feld uebernimmt das gap des Feldes. */
.field > .segment, .field > .inline-form { margin-top: .1rem; }

.field.gespeichert input, .field.gespeichert select, .field.gespeichert textarea { border-color: var(--accent); transition: border-color .2s; }
.form-error { color: var(--achtung); font-size: .88rem; margin-top: .6rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .2rem; }
.inline-form { display: flex; gap: .5rem; margin-top: .6rem; }
.inline-form input { flex: 1; }
.code-box { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; background: var(--bg-elev2); padding: .6rem .7rem; border-radius: var(--radius-s); margin-top: .6rem; }
.einstellungen .card h3 { font-size: .95rem; color: var(--fg-muted); margin: 1.1rem 0 .5rem; }
.einstellungen .card h3:first-of-type { margin-top: .3rem; }

/* Anhänge */
.anhaenge { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; margin-top: .6rem; }
.anhang { position: relative; }
.anhang img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-s); display: block; }
.anhang .weg-btn { position: absolute; top: .2rem; right: .2rem; background: rgba(0,0,0,.55); color: #fff; }
.bild-gross { max-width: 100%; max-height: 80vh; border-radius: var(--radius-s); }

/* Verlauf */
.verlauf { margin-top: 0; }                             /* einziges Kind der Karte */
.verlauf summary { cursor: pointer; font-size: .82rem; color: var(--fg-dim); }
.verlauf .zeileneintrag { font-size: .8rem; color: var(--fg-muted); padding: .15rem 0; }

/* Login */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-card h1 { text-align: center; margin-bottom: 1rem; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; overscroll-behavior: contain; touch-action: none; background: var(--bg-elev); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal { touch-action: pan-y; background: var(--bg-elev); width: 100%; max-width: 720px; height: 100%; max-height: 100dvh; border-radius: 0; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.modal-head { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: 1.05rem; }
.modal-body { padding: 1rem; overflow: auto; flex: 1; min-height: 0; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-foot { padding: .8rem 1rem; border-top: 1px solid var(--line); display: flex; gap: .6rem; }

/* Toast, über der Erfassungsleiste */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(4.8rem + env(safe-area-inset-bottom)); background: var(--bg-elev2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: .55rem .8rem; display: flex; gap: .75rem; align-items: center; box-shadow: var(--shadow); z-index: 30; max-width: calc(100vw - 1.5rem); }
.toast.error { border-color: var(--achtung); }
.toast button { text-decoration: underline; white-space: nowrap; }
.offline-hint { text-align: center; padding: .3rem; }

/* Chat, Inhalt kommt in plan-3 */
.chat-thread { display: flex; flex-direction: column; gap: .7rem; }
.chat-msg { display: flex; flex-direction: column; max-width: 88%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.claude { align-self: flex-start; align-items: flex-start; }
.chat-bubble { border-radius: var(--radius-s); padding: .55rem .75rem; }
.chat-bubble.user { background: var(--bg-elev2); }
.chat-bubble.claude { background: transparent; padding-left: 0; padding-right: 0; }
.chat-bubble.claude.pending { display: flex; align-items: center; gap: .5rem; color: var(--fg-muted); }
.chat-bubble.claude.error { color: var(--achtung); }
.chat-ts { font-size: .7rem; color: var(--fg-dim); margin-top: .2rem; }
.chat-foot { display: flex; gap: .6rem; align-items: flex-end; width: 100%; }
.chat-foot textarea { flex: 1; resize: none; line-height: 1.35; max-height: calc(1.35em * 5 + 1.2rem); overflow-y: auto; }

/* Markdown */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md p { margin: .5rem 0; }
.md ul, .md ol { margin: .5rem 0; padding-left: 1.2rem; }
.md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--bg-elev2); padding: .05rem .3rem; border-radius: 4px; }

@media (min-width: 720px) {
  .modal-backdrop { align-items: center; background: rgba(0,0,0,.55); }
  .modal { border-radius: var(--radius); height: auto; max-height: 85vh; padding-top: 0; padding-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } .zeile.weg { transition: none; } }
