/* Tagwerk – warmes Papier, Serifen, Bernstein */
:root {
  color-scheme: light dark;
  --paper: #F3EDE5; --paper-deep: #EDE6D8; --card: #FFFDF8; --card-raised: #FFFFFF;
  --ink: #2A2622; --ink-2: #6B6353; --amber: #C27A1F; --amber-soft: #F3E3C6; --line: #E3DACA;
  --danger: #D9382E; --shadow: 0 2px 6px rgba(0,0,0,.05);
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --sans: -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  --rounded: ui-rounded, -apple-system, system-ui, sans-serif;
  /* Abstands-Skala */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  /* Trefferflächen: 44 px Standard, 48 px Hauptaktionen */
  --tap: 44px; --tap-main: 48px;
  --radius: 16px;
  /* Tab-Leiste: 48 px Knopf + 2 × 6 px Innenabstand + 1 px Linie */
  --tabbar-h: 61px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17150F; --paper-deep: #211E17; --card: #2A2620; --card-raised: #332E27;
    --ink: #EFE8DA; --ink-2: #A89F8E; --amber: #E39A3A; --amber-soft: #3D2F18; --line: #3A342B;
    --danger: #F0574C;
    --shadow: 0 2px 8px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 17px; overscroll-behavior-y: none; }
body { -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; }
input, textarea { -webkit-user-select: text; user-select: text; font-family: inherit; font-size: inherit; color: inherit; }
button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.hidden { display: none !important; }
svg.i { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }

/* Fokus: ein sichtbarer Ring für Tastatur und Schalter-Navigation */
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
/* Bewegung nur, wenn erwünscht */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .mic.rec::after { display: none; }
}

#app { display: flex; flex-direction: column; height: 100dvh; height: 100vh; }
@supports (height: 100dvh) { #app { height: 100dvh; } }
#views { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: env(safe-area-inset-top); }
.view { padding: var(--s2) 0 var(--s5); min-height: 100%; }

/* Kopfzeilen */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: var(--s1) var(--s4) 0; }
.wordmark { display: inline-flex; align-items: center; gap: 6px; color: var(--amber); font: italic 700 15px var(--serif); }
.screen-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s4) var(--s2); }
.screen-head h1 { margin: 0; font: 700 34px/1.1 var(--serif); }
.screen-head .sub { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.day-head { padding: var(--s2) var(--s4) var(--s2); text-align: center; }
.day-head .row { display: flex; align-items: center; justify-content: space-between; }
.weekday { font: 600 12px var(--rounded); letter-spacing: 2px; text-transform: uppercase; color: var(--amber); }
.day-title { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 0; font: 700 26px/1.15 var(--serif); color: var(--ink); }
.day-title .chev { color: var(--ink-2); font-size: 12px; }
.day-meta { display: flex; justify-content: center; align-items: center; gap: 10px; margin-top: var(--s2); font-size: 13px; color: var(--ink-2); }

/* Knöpfe */
.round { position: relative; width: var(--tap-main); height: var(--tap-main); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--card); border: 1px solid var(--line); color: var(--amber); flex: none; }
.round svg.i { width: 22px; height: 22px; }
.round.small { width: var(--tap); height: var(--tap); color: var(--ink-2); }
.round.small svg.i { width: 20px; height: 20px; }
/* 36 px sichtbar, 44 px Trefferfläche über ein Pseudo-Element (Hoch/Runter in Listen) */
.round.tiny { width: 36px; height: 36px; color: var(--ink-2); }
.round.tiny svg.i { width: 18px; height: 18px; }
.round.tiny::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; }
.round.filled { background: var(--amber); border-color: transparent; color: #fff; box-shadow: 0 3px 8px rgba(194,122,31,.35); }
.round.muted { color: var(--ink-2); }
.round:active { transform: scale(.95); }
.pill { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s3); border-radius: 999px; background: var(--amber-soft); color: var(--amber); font: 600 13px var(--rounded); }
button.pill::before { content: ""; position: absolute; inset: -4px 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap); padding: 10px 18px; border-radius: 12px; background: var(--amber); color: #fff; font-weight: 600; }
.btn.secondary { background: var(--card); color: var(--amber); border: 1px solid var(--line); }
.btn.danger { background: rgba(217,56,46,.12); color: var(--danger); }
.btn.block { width: 100%; }
.textbtn { display: inline-flex; align-items: center; gap: var(--s1); min-height: var(--tap); color: var(--amber); font-weight: 600; padding: 0 var(--s2); }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.entry { display: flex; gap: var(--s3); padding: 14px; margin: 0 var(--s4) var(--s3); }
.entry .stripe { width: 4px; border-radius: 2px; flex: none; }
.entry .body { flex: 1; min-width: 0; }
.entry .head { display: flex; align-items: center; gap: 6px; font: 700 12px var(--rounded); }
.entry .head .time { margin-left: auto; color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums; }
.entry .text { margin: 6px 0 0; white-space: pre-wrap; word-wrap: break-word; line-height: 1.35; }
.entry .reminder { margin-top: var(--s1); font-size: 13px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ring { background: transparent !important; border: 1.5px solid currentColor; }
/* Kategorie-Symbol statt Farbpunkt */
.sym { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: -3px; }
.sym.ring { opacity: .5; }
.chip .sym { width: 16px; height: 16px; }
.symgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s2) 6px; }
.symgrid button { width: var(--tap); height: var(--tap); border-radius: 12px; justify-self: center; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); background: var(--paper-deep); color: var(--ink-2); }
.symgrid button.on { border: 2px solid currentColor; background: color-mix(in srgb, currentColor 14%, var(--card)); }
.symgrid button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.symgrid button.none { font: 600 11px var(--rounded); }
.thumbs { display: flex; gap: var(--s2); margin-top: 10px; overflow-x: auto; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); background: var(--paper-deep); flex: none; }
mark { background: rgba(194,122,31,.28); color: inherit; font-weight: 700; border-radius: 3px; }

/* Checkliste */
.checklist { margin: 0 var(--s4) var(--s3); padding: var(--s1) 14px 2px; }
.checklist .ch-head { display: flex; align-items: center; gap: var(--s2); padding: 2px 0; }
.checklist .ch-title { flex: 1; display: inline-flex; align-items: center; gap: 6px; font: 600 12px var(--rounded); letter-spacing: 1.2px; text-transform: uppercase; color: var(--amber); }
.checklist .ch-count { font: 600 13px var(--rounded); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.checklist .ch-all { padding: var(--s1) 0 var(--s2); font-size: 13px; color: var(--ink-2); }
.task { display: flex; align-items: center; gap: var(--s3); padding: var(--s1) 0; border-top: 1px solid var(--line); }
.task .check { width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid var(--amber); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.task .check svg.i { width: 18px; height: 18px; stroke-width: 3; }
.task.done .check { background: var(--amber); }
.task .grow { flex: 1; min-width: 0; min-height: var(--tap); display: flex; align-items: center; gap: var(--s2); text-align: left; padding: var(--s1) 0; }
.task .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task.done .title { color: var(--ink-2); text-decoration: line-through; }
.task .meta { display: inline-flex; align-items: center; gap: 3px; font: 500 12px var(--rounded); color: var(--ink-2); flex: none; }
.task .meta svg.i { width: 14px; height: 14px; }
.checklist.future { opacity: .65; }
/* Wochentage: sieben Kreise à 44 px; die Reihe ragt in den Rand der Box, damit sie ab 375 px in eine Zeile passt */
.wdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s1); margin: 0 calc(-1 * var(--s3)); }
.wdays button { width: 100%; max-width: 48px; height: var(--tap); border-radius: 22px; justify-self: center; border: 1px solid var(--line); background: var(--paper-deep); font: 600 13px var(--rounded); color: var(--ink-2); }
.wdays button.on { background: var(--amber); border-color: transparent; color: #fff; }
.swatch.small { width: 14px; height: 14px; }

/* Koagulierungs-Protokoll */
.kv { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 3px var(--s3); margin-top: var(--s2); font-size: 14px; align-items: baseline; }
.kv .k { color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }
.kv .v { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.bad { color: var(--danger) !important; font-weight: 600; }
.warn { color: var(--amber) !important; font-weight: 600; }
.proto-title { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-weight: 600; }
.proto-row { display: flex; gap: var(--s3); padding: var(--s3) 14px; margin: 0 var(--s4) var(--s3); }
.proto-row .when { width: 66px; flex: none; font: 600 12px var(--rounded); color: var(--ink-2); line-height: 1.35; text-transform: uppercase; }
.proto-row .body { flex: 1; min-width: 0; }
.proto-row .t { font-weight: 600; }
.proto-row .vals { font-size: 14px; color: var(--ink-2); margin-top: 2px; }
.proto-row .chg { font-size: 13px; color: var(--amber); margin-top: 3px; }
.last-card { padding: 14px; margin: 0 var(--s4) var(--s3); }
.last-card .lh { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.last-card .lh h3 { margin: 0; font: 600 17px var(--sans); }
.last-card .lh small { color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.last-card .actions { display: flex; gap: var(--s2); margin-top: var(--s3); }
.last-card .actions .btn { font-size: 15px; padding: 10px 8px; white-space: nowrap; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { min-height: var(--tap); padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper-deep); font: 500 13px var(--rounded); color: var(--ink-2); }
.seg button.on { background: var(--amber); border-color: transparent; color: #fff; }
.seg button.on.isbad { background: var(--danger); }
.kval { display: flex; align-items: center; gap: 6px; flex: none; }
.kval input { width: 112px; min-height: var(--tap); text-align: right; background: var(--paper-deep); border: 0; border-radius: 8px; padding: 7px 10px; font-size: 16px; }
.kval input:focus-visible { outline: 2px solid var(--amber); outline-offset: 0; }
.kval .unit { font-size: 13px; color: var(--ink-2); max-width: 64px; }
.box .rowi > .lbl { min-width: 0; flex: 1; }
.box .rowi .muted.chg { color: var(--amber); }

/* Baustelle: Aufgaben */
.job { display: flex; gap: var(--s3); padding: var(--s3) 14px; margin: 0 var(--s4) var(--s3); }
.job .check { width: var(--tap); height: var(--tap); border-radius: 50%; border: 2px solid var(--amber); color: #fff; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.job .check svg.i { width: 18px; height: 18px; stroke-width: 3; }
.job.done .check { background: var(--amber); }
.job .jbody { flex: 1; min-width: 0; }
.job .jtitle { font-weight: 600; line-height: 1.3; }
.job.done .jtitle { color: var(--ink-2); text-decoration: line-through; }
.job .jmeta { display: flex; justify-content: space-between; gap: var(--s2); margin-top: var(--s1); font: 500 12px var(--rounded); color: var(--ink-2); }
.job .jmeta b { color: var(--amber); font-variant-numeric: tabular-nums; }
.job .bar { height: 6px; border-radius: 3px; background: var(--paper-deep); margin-top: 6px; overflow: hidden; }
.job .bar span { display: block; height: 100%; background: var(--amber); border-radius: 3px; transition: width .2s; }
.job.done .bar span { background: var(--ink-2); }
.job .text { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); white-space: pre-wrap; }
.job .thumbs { margin-top: var(--s2); }
.progress-row { display: flex; align-items: center; gap: var(--s3); padding: 2px 0; }
.progress-row input[type=range] { flex: 1; height: var(--tap); margin: 0; accent-color: var(--amber); }
.progress-row b { width: 48px; text-align: right; font-variant-numeric: tabular-nums; }

/* Leerzustand */
.empty { text-align: center; padding: var(--s4) var(--s5); }
.empty img { width: auto; max-width: 100%; max-height: 200px; border-radius: 18px; box-shadow: 0 6px 14px rgba(0,0,0,.08); }
.empty h2 { margin: var(--s3) 0 var(--s1); font: 600 20px var(--serif); }
.empty p { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.4; }

/* Chips: eine Zeile, seitlich scrollbar, beidseitiger Fade als Hinweis auf mehr */
.chips-wrap { position: relative; }
.chips { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); overflow-x: auto; padding: var(--s1) 24px var(--s1) var(--s4); scroll-padding-inline: var(--s4) 24px; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent); mask-image: linear-gradient(90deg, transparent, #000 20px, #000 calc(100% - 20px), transparent); }
.chips::-webkit-scrollbar { display: none; }
/* In Dialogen: Zeile bis an die Blattkanten ziehen, damit der Fade nicht auf dem ersten Chip liegt */
.chips.flush { margin-inline: calc(-1 * var(--s4)); padding-inline: var(--s4) 24px; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 0 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font: 500 15px var(--rounded); white-space: nowrap; color: var(--ink); flex: none; }
.chip.compact { min-height: 36px; padding: 0 var(--s3); font-size: 13px; }
.chip.compact::before { content: ""; position: absolute; inset: -4px 0; }
.chip .dot { width: 11px; height: 11px; }
.chip.on { font-weight: 700; border-width: 1.5px; }

/* Eingabeleiste */
.inputbar { background: var(--paper-deep); border-top: 1px solid var(--line); padding: var(--s1) 0 var(--s2); }
.pending { display: flex; gap: var(--s3); padding: var(--s3) var(--s4) 0; overflow-x: auto; }
.pending .p { position: relative; flex: none; }
.pending img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
/* Entfernen-Knopf: 32 px sichtbar, 44 px Trefferfläche; ragt 12 px über das Bild hinaus = Lücke zum Nachbarn */
.pending .rm, .photo-grid .rm { position: absolute; top: -6px; right: -6px; width: 32px; height: 32px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.pending .rm::before, .photo-grid .rm::before { content: ""; position: absolute; inset: -6px; border-radius: 50%; }
.input-row { display: flex; align-items: flex-end; gap: var(--s2); padding: var(--s2) var(--s3) 0; }
.input-row .round, .input-row .mic { width: var(--tap-main); height: var(--tap-main); }
.input-row textarea { flex: 1; min-width: 0; min-height: var(--tap-main); max-height: 130px; resize: none; padding: 12px 14px; border-radius: 24px; background: var(--card); border: 1px solid var(--line); line-height: 1.3; font-size: 16px; }
.input-row textarea::placeholder { color: var(--ink-2); opacity: .8; }
.input-row textarea:focus-visible { outline: 2px solid var(--amber); outline-offset: -1px; }
.mic { width: var(--tap-main); height: var(--tap-main); border-radius: 50%; background: var(--amber); color: #fff; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 3px 8px rgba(194,122,31,.35); position: relative; flex: none; }
.mic svg.i { width: 22px; height: 22px; }
.mic.rec { background: var(--danger); box-shadow: 0 3px 8px rgba(217,56,46,.35); }
.mic.rec::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 3px solid rgba(217,56,46,.35); animation: pulse 1.1s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: 1; } to { transform: scale(1.45); opacity: 0; } }
.status { padding: 6px var(--s4) 0; font-size: 14px; display: flex; gap: var(--s2); align-items: center; }
.status.ok { color: var(--amber); font-weight: 600; }
.status.err { color: var(--danger); }
.status.rec { color: var(--danger); }
.status a, .status button { color: var(--amber); font-weight: 600; font-size: 14px; margin-left: auto; }
.status button { display: inline-flex; align-items: center; justify-content: center; min-width: var(--tap); min-height: var(--tap); margin: -6px calc(-1 * var(--s2)) -6px auto; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--amber); color: #fff; font: 700 11px var(--rounded); display: flex; align-items: center; justify-content: center; }

/* Tab-Leiste */
#tabbar { display: flex; justify-content: space-around; background: var(--paper-deep); border-top: 1px solid var(--line); padding: 6px var(--s2) calc(6px + env(safe-area-inset-bottom)); }
#tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--tap-main); padding: 5px 2px; border-radius: 14px; color: var(--ink); font: 500 11px/1.2 var(--rounded); flex: 1; min-width: 0; white-space: nowrap; }
#tabbar button svg.i { width: 22px; height: 22px; }
#tabbar button.on { color: var(--amber); background: var(--amber-soft); }
#tabbar button:focus-visible { outline-offset: -2px; }
body.kb #tabbar { display: none; }

/* Kalender */
.cal-nav { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s4) var(--s2); }
.cal-nav h2 { margin: 0; font: 700 22px var(--serif); }
.weekdays, .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--s1); padding: 0 var(--s3); }
.weekdays span { text-align: center; font: 600 12px var(--rounded); color: var(--ink-2); }
.weekdays span.we { color: var(--amber); }
.grid { margin-top: 6px; row-gap: 6px; }
.cell { position: relative; min-width: 0; height: 56px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border: 1px solid transparent; }
.cell.has { background: var(--card); border-color: var(--line); }
.cell .n { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 500 16px var(--rounded); font-variant-numeric: tabular-nums; }
.cell.we .n { color: var(--ink-2); }
.cell.today .n { background: var(--amber); color: #fff; font-weight: 700; }
.cell.sel:not(.today) .n { border: 1.5px solid var(--amber); }
.cell .dots { display: flex; gap: 3px; height: 8px; align-items: center; }
.cell .dots .dot { width: 6px; height: 6px; }
.cell .dots .more { font: 700 9px var(--rounded); color: var(--ink-2); }
.cell .dots .sym { width: 12px; height: 12px; stroke-width: 2.6; }
.cell .tick { position: absolute; top: 3px; right: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--amber); color: #fff; display: flex; align-items: center; justify-content: center; }
.cell .tick svg.i { width: 9px; height: 9px; stroke-width: 3.5; }
.legend .tick { position: static; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); padding: 14px 20px 0; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

/* Suche */
.searchfield { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); margin: 0 var(--s4); padding: 0 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.searchfield:focus-within { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.searchfield input { flex: 1; min-height: 42px; border: 0; background: none; min-width: 0; }
/* Der Fokusring liegt auf dem runden Feld (focus-within), nicht auf dem eckigen Eingabeelement */
.searchfield input:focus-visible { outline: none; }
.searchfield svg { color: var(--ink-2); flex: none; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 20px 6px; font: 600 12px var(--rounded); letter-spacing: 1px; text-transform: uppercase; color: var(--amber); }
.group-head small { color: var(--ink-2); text-transform: none; letter-spacing: 0; font-weight: 400; }
.section-label { padding: var(--s3) 20px 6px; font: 600 12px var(--rounded); letter-spacing: 1.2px; text-transform: uppercase; color: var(--ink-2); }

/* Termine */
.appt { display: flex; gap: 14px; padding: 14px; margin: 0 var(--s4) var(--s3); }
.appt .when { width: 84px; flex: none; }
.appt .when .rel { font: 600 12px var(--rounded); text-transform: uppercase; color: var(--amber); }
.appt .when .t { font: 700 20px var(--rounded); font-variant-numeric: tabular-nums; }
.appt .when .d { font-size: 12px; color: var(--ink-2); }
.appt .bar { width: 3px; border-radius: 2px; flex: none; }
.appt.past { opacity: .72; }
.appt .body { flex: 1; min-width: 0; }
.appt .body .cat { display: flex; align-items: center; gap: 6px; font: 700 12px var(--rounded); }
.appt .body .text { margin: var(--s1) 0 0; }
.appt .body .rem { display: flex; align-items: center; flex-wrap: wrap; gap: 0 var(--s1); margin-top: 2px; font-size: 13px; color: var(--ink-2); }
/* Text bekommt die Breite; Knöpfe rutschen auf Handys in eine zweite Zeile, statt den Text zu quetschen */
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0 var(--s4) var(--s3); padding: var(--s3); border-radius: 12px; background: var(--amber-soft); font-size: 15px; line-height: 1.3; }
.banner > span { flex: 1 1 220px; min-width: 0; }
.banner > span:first-child { flex: none; }
.banner .pill { margin-left: auto; }
.banner > .i { flex-shrink: 0; }
.banner .pill { flex-shrink: 0; background: var(--card); }

/* Dialoge */
dialog { border: 0; padding: 0; background: var(--paper); color: var(--ink); width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.sheet { display: flex; flex-direction: column; height: 100%; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: calc(var(--s2) + env(safe-area-inset-top)) var(--s2) var(--s2); }
.sheet-head h2 { margin: 0; padding: 0 var(--s2); font: 700 20px/1.15 var(--serif); text-align: center; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-head .textbtn { flex: none; white-space: nowrap; min-height: var(--tap-main); }
.sheet-body { flex: 1; overflow-y: auto; padding: var(--s1) var(--s4) calc(40px + env(safe-area-inset-bottom)); }
.sheet-body .section-label { padding: var(--s4) 0 var(--s2); }
.sheet-body .section-label:first-child { padding-top: var(--s1); }
.box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--s3) 14px; }
/* Textfelder ohne eigenen Rahmen: der Fokus liegt sichtbar auf der Box */
.box:has(> textarea:focus-visible), .box:has(> input:focus-visible) { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.box > textarea:focus-visible, .box > input:focus-visible { outline: none; }
.box .rowi { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0; min-height: var(--tap); }
.box .rowi + .rowi { border-top: 1px solid var(--line); }
.box textarea { width: 100%; border: 0; background: none; resize: none; min-height: 84px; line-height: 1.35; }
.box > input[type=text] { min-height: var(--tap); }
.box input[type=date], .box input[type=time], .box select { min-height: var(--tap); background: var(--paper-deep); border: 0; border-radius: 8px; padding: 6px var(--s3); }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch::after { content: ""; position: absolute; inset: -7px -4px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: #c9c3b6; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch input:checked + span { background: var(--amber); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch:has(input:focus-visible) span { outline: 2px solid var(--amber); outline-offset: 2px; }
.photo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s3); }
.photo-grid .ph { position: relative; aspect-ratio: 1; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.photo-grid .add { aspect-ratio: 1; border: 1px dashed var(--line); border-radius: 10px; background: var(--card); color: var(--amber); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s1); font: 600 11px var(--rounded); }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list .item { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 14px; min-height: 56px; }
.list .item + .item { border-top: 1px solid var(--line); }
.list .item .grow { flex: 1; min-width: 0; }
.list .item button.grow { min-height: var(--tap); }
.list .item .cnt { color: var(--ink-2); font-size: 13px; }
.list .item input[type=time] { min-height: var(--tap); background: var(--paper-deep); border: 0; border-radius: 8px; padding: 6px var(--s3); }
.swatch { width: 26px; height: 26px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.swatch svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s3) 6px; }
.palette button { width: var(--tap); height: var(--tap); border-radius: 50%; justify-self: center; position: relative; }
.palette button.on::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2.5px solid var(--ink); }
.palette button.on::before { content: "✓"; color: #fff; font-weight: 700; }
.muted { color: var(--ink-2); font-size: 13px; }
.center { text-align: center; }
.foot { padding: 6px 2px 0; font-size: 12px; color: var(--ink-2); line-height: 1.4; }

/* Fotoanzeige */
#viewer { background: #000; color: #fff; }
#viewer .vbar { position: absolute; top: calc(var(--s3) + env(safe-area-inset-top)); left: var(--s3); right: var(--s3); display: flex; justify-content: space-between; align-items: center; z-index: 2; }
#viewer .vbar .round { background: rgba(255,255,255,.18); border: 0; color: #fff; }
#viewer .pages { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
#viewer .pages::-webkit-scrollbar { display: none; }
#viewer .page { flex: none; width: 100%; height: 100%; scroll-snap-align: start; display: flex; align-items: center; justify-content: center; }
#viewer .page img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Toast: knapp über der Tab-Leiste, Knopf 44 px hoch */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s3)); transform: translateX(-50%); display: flex; align-items: center; gap: var(--s2); min-height: var(--tap-main); background: var(--ink); color: var(--paper); padding: var(--s1) var(--s1) var(--s1) 18px; border-radius: 999px; font-size: 14px; line-height: 1.3; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 2 * var(--s4)); text-align: center; }
#toast:not(:has(button)) { padding-right: 18px; }
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { color: var(--amber); font-weight: 700; min-height: var(--tap); padding: 0 14px; border-radius: 999px; flex: none; }

/* Schmale Geräte (320–359 px): Abstände enger, Raster mit fünf Spalten */
@media (max-width: 359px) {
  .weekdays, .grid { gap: 0; padding: 0 var(--s1); }   /* 7 × 44,6 px bei 320 px */
  .input-row { gap: 6px; padding-inline: 10px; }
  .input-row > label.round { width: var(--tap); height: var(--tap); }
  #tabbar { padding-inline: var(--s1); }
  #tabbar button { padding-inline: 0; }
  .symgrid, .palette { grid-template-columns: repeat(5, 1fr); }
  /* zwei Zeilen: Mo–Fr und Sa So */
  .wdays { display: flex; flex-wrap: wrap; gap: var(--s2); justify-content: flex-start; margin: 0; max-width: 252px; }
  .wdays button { width: var(--tap); flex: none; }
  .entry, .checklist, .proto-row, .last-card, .job, .appt, .banner { margin-inline: var(--s3); }
  .input-row textarea { padding-inline: 10px; font-size: 15px; }
  .sheet-head { gap: var(--s1); padding-inline: var(--s1); }
  .sheet-head .textbtn { padding-inline: 6px; }
}
/* Suchfeld: nur ein Leeren-Knopf (das eigene X), nicht zusätzlich das native */
.searchfield input[type="search"]::-webkit-search-cancel-button, .searchfield input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
/* Leerzustands-Bilder im Dunkelmodus gedämpft, damit sie nicht als helle Kachel leuchten */
@media (prefers-color-scheme: dark) { .empty img { filter: brightness(.82) saturate(.9); } }

/* Status „Gespeichert“: Grün mit ≥ 4,5:1 auf Papier (#276B3F auf #EDE6D8 = 5,2:1, auf #F3EDE5 = 5,5:1) */
.status.ok { color: #276B3F; }
/* Diktat-Status in Dialogen: Zeile direkt unter der Box des Textfelds, bündig mit dem Blatt */
.sheet-body .status { padding: 6px 2px 0; }
@media (prefers-color-scheme: dark) {
  /* #6FCF8E auf #211E17 = 8,7:1 */
  .status.ok { color: #6FCF8E; }
}
/* Lange Einwort-Titel („Koagulierung“) dürfen bei 320 px trennen, statt die Knöpfe aus dem Bild zu schieben */
.screen-head > div:first-child { min-width: 0; }
/* Titel skaliert mit der Breite, damit „Koagulierung“ neben zwei Knöpfen in eine Zeile passt */
.screen-head h1 { font-size: clamp(26px, 8.4vw, 34px); overflow-wrap: normal; }

/* Jahr als Nebeninformation im Tagestitel, damit „24. Oktober“ auch bei 320 px einzeilig bleibt */
.day-title .year { font-size: .55em; font-weight: 600; color: var(--ink-2); align-self: baseline; margin-left: 2px; }
/* Kompakter Hinweis (z. B. Checkliste anlegen): eine Zeile, kleiner Knopf, wenig Höhe */
.banner.compact { padding: var(--s2) var(--s3); font-size: 14px; gap: var(--s2); align-items: center; }
.banner.compact .pill { min-height: 36px; }
/* Kleine goldene Aktionsbeschriftungen kräftiger: dunkleres Amber mit ≥ 4,5:1 auf Papier */
.entry .head, .checklist .ch-title, .weekday { color: #8F5610; }
@media (prefers-color-scheme: dark) { .entry .head, .checklist .ch-title, .weekday { color: var(--amber); } }
/* Tagestitel bleibt einzeilig: Schrift skaliert mit der Breite, Jahr klein daneben */
.day-title { white-space: nowrap; font-size: clamp(21px, 7vw, 26px); }

/* Nachbesserung 2: Textknöpfe mit ausreichendem Kontrast (hell 5,15:1), Suchfeld 44 px */
.textbtn { color: #8F5610; }
@media (prefers-color-scheme: dark) { .textbtn { color: var(--amber); } }
.searchfield input { min-height: 44px; }
/* Kategoriefarben sind für hellen Grund gewählt; im Dunkelmodus Beschriftung und Symbol aufhellen, damit sie lesbar bleiben */
@media (prefers-color-scheme: dark) { .entry .head > :not(.time), .entry .stripe, .chip .sym, .chip .dot { filter: brightness(1.45) saturate(.9); } }
