:root {
  --bg: #F4F1EA;
  --card: #FFFDF8;
  --ink: #1C1B19;
  --ink2: #5E5A52;
  --ink3: #9A958B;
  --line: #E4DFD4;
  --g: #2F5DA8;          /* geschäftlich */
  --g-soft: #E3EAF6;
  --p: #C2613A;          /* privat */
  --p-soft: #F7E6DD;
  --ok: #3B7D4F;
  --warn: #B83A2E;
  --shadow: 0 1px 2px rgb(40 30 10 / .06), 0 6px 18px rgb(40 30 10 / .06);
  --r: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412; --card: #1F1D1A; --ink: #F1EDE4; --ink2: #B5AFA3; --ink3: #7C766B; --line: #302D28;
    --g: #7FA6E8; --g-soft: #1F2A3D; --p: #E99470; --p-soft: #3A2620; --ok: #7CC291; --warn: #EF8070;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--ink2); }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: grid; gap: 14px; text-align: center; }
.login-card h1 { margin: 6px 0 0; font-size: 30px; letter-spacing: -.02em; }
.login-card p { margin: 0 0 8px; }
.brand-mark { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; background: var(--ink); color: var(--bg); display: grid; place-items: center; }
.brand-mark svg { width: 34px; height: 34px; stroke-width: 2.6; }
.err { color: var(--warn); min-height: 1.2em; margin: 0; font-size: 14px; }

/* ---------- Layout ---------- */
.app { max-width: 720px; margin: 0 auto; min-height: 100%; padding: calc(var(--safe-t) + 14px) 16px calc(120px + var(--safe-b)); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 8px 2px 14px; }
.day-name { font-size: 32px; font-weight: 700; letter-spacing: -.025em; line-height: 1.05; }
.day-date { color: var(--ink2); font-size: 15px; margin-top: 2px; }
.top-actions { display: flex; gap: 6px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: var(--ink2); background: var(--card); box-shadow: var(--shadow); }
.icon-btn:active { transform: scale(.96); }

.tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.tabs button { padding: 8px 4px; border-radius: 9px; font-size: 14.5px; font-weight: 600; color: var(--ink2); white-space: nowrap; }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
.cnt { font-weight: 500; color: var(--ink3); font-size: 13px; }
.cnt:empty { display: none; }

.filters { display: flex; gap: 8px; margin: 14px 0 6px; }
.chip { padding: 6px 13px; border-radius: 999px; font-size: 14px; font-weight: 500; color: var(--ink2); border: 1px solid var(--line); background: transparent; }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.g.active { background: var(--g); border-color: var(--g); color: #fff; }
.chip.p.active { background: var(--p); border-color: var(--p); color: #fff; }

/* ---------- Liste ---------- */
.group-h { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 4px 8px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink3); }
.group-h.warn { color: var(--warn); }
.group-h button { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--warn); font-size: 13.5px; }
.cards { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }

.item { position: relative; display: grid; grid-template-columns: 44px 1fr auto; align-items: center; min-height: 60px; padding: 6px 6px 6px 0; border-top: 1px solid var(--line); touch-action: pan-y; background: var(--card); transition: transform .2s ease, opacity .25s ease; }
.item:first-child { border-top: 0; }
.item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.item.g { --c: var(--g); --cs: var(--g-soft); }
.item.p { --c: var(--p); --cs: var(--p-soft); }
.check { width: 44px; height: 48px; display: grid; place-items: center; }
.check i { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--c); display: grid; place-items: center; transition: background .15s; }
.check i svg { width: 15px; height: 15px; stroke: #fff; stroke-width: 3; opacity: 0; }
.item.done .check i { background: var(--c); }
.item.done .check i svg { opacity: 1; }
.item.done .t-title { color: var(--ink3); text-decoration: line-through; text-decoration-color: var(--ink3); }
.body { min-width: 0; padding: 6px 4px; cursor: pointer; }
.t-title { font-size: 16.5px; line-height: 1.3; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; font-size: 13px; color: var(--ink2); }
.meta .time { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.meta .late { color: var(--warn); font-weight: 600; }
.meta svg { width: 13px; height: 13px; vertical-align: -2px; stroke-width: 2.2; }
.meta .note { color: var(--ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.later-btn { height: 36px; padding: 0 11px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--ink2); background: var(--bg); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.later-btn svg { width: 16px; height: 16px; }
.later-btn:active { background: var(--line); }
.swipe-hint { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 18px; font-weight: 600; font-size: 14px; color: #fff; pointer-events: none; }

.empty { text-align: center; padding: 56px 20px 20px; color: var(--ink3); }
.empty b { display: block; color: var(--ink2); font-size: 18px; margin-bottom: 4px; }
.empty .big { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%; background: var(--card); display: grid; place-items: center; box-shadow: var(--shadow); color: var(--ok); }

/* ---------- Eingabe unten ---------- */
.composer { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 12px calc(10px + var(--safe-b)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.compose-row, .preview { max-width: 696px; margin: 0 auto; }
.compose-row { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow), 0 0 0 1px var(--line); padding: 6px 6px 6px 16px; }
.compose-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16.5px; padding: 8px 0; }
.compose-row input::placeholder { color: var(--ink3); }
.mic, .add { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.mic { background: var(--ink); color: var(--bg); }
.mic.rec { background: var(--warn); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgb(184 58 46 / .18); } }
.add { background: var(--ok); color: #fff; }
.add svg { stroke-width: 2.8; }
.preview { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 8px; }
.pv { padding: 5px 11px; border-radius: 999px; font-size: 13.5px; font-weight: 600; background: var(--card); box-shadow: 0 0 0 1px var(--line); color: var(--ink); display: inline-flex; align-items: center; gap: 5px; }
.pv svg { width: 14px; height: 14px; stroke-width: 2.2; }
.pv.cat.g { background: var(--g); color: #fff; box-shadow: none; }
.pv.cat.p { background: var(--p); color: #fff; box-shadow: none; }
.pv.off { color: var(--ink3); }

/* ---------- Bottom-Sheets ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgb(0 0 0 / .32); animation: fade .2s ease; }
.sheet-card { position: relative; width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); display: grid; gap: 10px; animation: up .25s cubic-bezier(.2,.8,.2,1); }
.sheet-card h2 { margin: 4px 0 2px; font-size: 21px; }
.grab { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 6px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 22px; } }

.e-title { font-size: 20px; font-weight: 600; border: 0; outline: 0; background: transparent; padding: 6px 0; }
textarea, .sheet input[type=email], .sheet input[type=date], .sheet input[type=time], .sheet select, .login input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 12px; outline: 0; resize: vertical; min-height: 46px;
}
textarea:focus, .sheet input:focus, .sheet select:focus, .login input:focus { border-color: var(--ink3); }
.lbl { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink3); margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--bg); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { padding: 9px 4px; border-radius: 9px; font-size: 14.5px; font-weight: 600; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
#eCat button.on[data-v=g] { background: var(--g); color: #fff; }
#eCat button.on[data-v=p] { background: var(--p); color: #fff; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.quick button { padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 14px; font-weight: 500; }
.quick button.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toggles { display: flex; gap: 8px; }
.tog { display: inline-flex; align-items: center; gap: 7px; padding: 9px 12px; border-radius: 12px; background: var(--bg); font-size: 14.5px; font-weight: 500; cursor: pointer; user-select: none; }
.tog.wide { justify-self: start; }
.tog input { width: 18px; height: 18px; accent-color: var(--ink); margin: 0; }
.hint { font-size: 13px; color: var(--ink3); margin: 0; }
.sheet-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; }
.btn { min-height: 46px; padding: 0 18px; border-radius: 13px; font-weight: 600; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.btn.primary { background: var(--ink); color: var(--bg); box-shadow: none; flex: 1; max-width: 220px; margin-left: auto; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--warn); }
.btn:active { transform: scale(.98); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + var(--safe-b)); z-index: 30; display: flex; align-items: center; gap: 14px; background: var(--ink); color: var(--bg); padding: 11px 12px 11px 16px; border-radius: 14px; font-size: 14.5px; box-shadow: 0 8px 24px rgb(0 0 0 / .25); max-width: calc(100% - 24px); animation: up .2s ease; }
.toast button { color: var(--p); font-weight: 700; }
@media (prefers-color-scheme: dark) { .toast button { color: #C2613A; } }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  .app { padding-top: 40px; }
  .day-name { font-size: 40px; }
  .item { min-height: 56px; }
  .later-btn { opacity: .0; transition: opacity .15s; }
  .item:hover .later-btn, .later-btn:focus-visible { opacity: 1; }
  .composer { bottom: 18px; background: none; }
}

/* ---------- Druck / PDF ---------- */
.print-area { display: none; }
@media print {
  @page { size: A4; margin: 16mm 16mm 18mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .app, .sheet, .toast, .login { display: none !important; }
  .print-area { display: block; }
  .pr-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid #000; padding-bottom: 6pt; margin-bottom: 10pt; }
  .pr-head h1 { font-size: 20pt; margin: 0; letter-spacing: -.01em; }
  .pr-head .sub { font-size: 10pt; color: #555; text-align: right; }
  .pr-day { margin: 14pt 0 4pt; font-size: 12.5pt; font-weight: 700; break-after: avoid; }
  .pr-cat { margin: 8pt 0 3pt; font-size: 9pt; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
  .pr-cat.g { color: #2F5DA8; } .pr-cat.p { color: #C2613A; }
  .pr-row { display: grid; grid-template-columns: 14pt 42pt 1fr; gap: 4pt; padding: 4pt 0; border-bottom: .5pt solid #ccc; break-inside: avoid; }
  .pr-box { width: 10pt; height: 10pt; border: 1pt solid #000; border-radius: 2pt; margin-top: 2pt; }
  .pr-box.x { background: #000; }
  .pr-time { font-weight: 700; font-variant-numeric: tabular-nums; }
  .pr-note { color: #555; font-size: 9.5pt; margin-top: 1pt; white-space: pre-wrap; }
  .pr-late { color: #B83A2E; font-size: 9pt; font-weight: 700; }
  .pr-foot { margin-top: 18pt; font-size: 8.5pt; color: #777; }
  .pr-lines { margin-top: 14pt; }
  .pr-lines div { border-bottom: .5pt solid #bbb; height: 20pt; }
}
