:root {
  --forest: #2A4840; --terra: #C4713A; --parchment: #F6F1E7; --cream: #EDE5D4; --sage: #7A9589; --ink: #1A1917;
  --bg: var(--parchment); --surface: #FFFDF8; --surface2: var(--cream); --text: var(--ink); --muted: #6b675f;
  --line: #ddd3bf; --accent: var(--terra); --accent-ink: #fff; --head: var(--forest); --danger: #b3382c;
  --radius: 14px; --shadow: 0 1px 2px rgba(26,25,23,.06), 0 4px 14px rgba(26,25,23,.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14201c; --surface: #1c2b26; --surface2: #243630; --text: #efe9dc; --muted: #a39f94;
    --line: #2f423b; --head: #e8dfc9; --accent: #d98349; --danger: #e5675a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* Kopf */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(10px + env(safe-area-inset-top, 0px)) 0 8px; border-bottom: 1px solid var(--line); }
.top .bar { display: flex; align-items: center; gap: 10px; }
.top h1 { margin: 0; font-size: 22px; color: var(--head); letter-spacing: -.01em; flex: 0 0 auto; }
.top input[type=search] { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.iconbtn { border: 0; background: transparent; padding: 8px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.iconbtn:hover { background: var(--surface2); }
.iconbtn svg { width: 22px; height: 22px; }
.net { font-size: 12px; color: var(--accent); white-space: nowrap; }

.seg { display: flex; gap: 4px; margin-top: 10px; background: var(--surface2); padding: 3px; border-radius: 999px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 7px 4px; border-radius: 999px; color: var(--muted); font-size: 14px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 11px; font-size: 13px; color: var(--muted); }
.chip.on { background: var(--head); color: var(--bg); border-color: var(--head); }
.chips .sep { flex: 0 0 1px; background: var(--line); margin: 3px 2px; }

/* Liste */
main { padding-bottom: calc(190px + var(--safe-b)); }
.group { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; }
.card:active { transform: scale(.995); }
.card .r1 { display: flex; gap: 8px; align-items: baseline; }
.card h3 { margin: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; flex: 1; }
.card .snip { margin: 4px 0 0; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--muted); }
.card .meta .tagpill { background: var(--surface2); border-radius: 999px; padding: 1px 8px; }
.card .meta .area { color: var(--accent); font-weight: 600; }
.card .meta time { margin-left: auto; }
.card.pending { border-style: dashed; opacity: .85; }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }

/* Composer */
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(26,25,23,.08); padding: 10px 0 calc(10px + var(--safe-b)); }
.composer .wrap { display: grid; gap: 8px; }
.composer .row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; resize: none; max-height: 40vh; border: 1px solid var(--line); border-radius: 18px; padding: 10px 14px; background: var(--bg); min-height: 44px; line-height: 1.35; }
.composer .opts { display: none; gap: 8px; flex-wrap: wrap; align-items: center; }
.composer.open .opts { display: flex; }
.composer select, .composer .opts input { border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: var(--bg); font-size: 14px; max-width: 100%; }
.composer .opts input { flex: 1; min-width: 120px; }
.kindsw { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.kindsw button { border: 0; background: var(--bg); padding: 6px 11px; font-size: 14px; color: var(--muted); }
.kindsw button.on { background: var(--head); color: var(--bg); }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: 0 0 auto; }
.round svg { width: 22px; height: 22px; }
.round.mic { background: var(--surface2); color: var(--text); }
.round.send { background: var(--accent); color: var(--accent-ink); }
.round.send:disabled { opacity: .4; }
.recbar { display: none; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--danger); border-radius: 999px; padding: 6px 8px 6px 14px; color: var(--danger); font-weight: 600; }
.recbar.on { display: flex; }
.recbar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.recbar button { margin-left: auto; border: 0; border-radius: 999px; background: var(--danger); color: #fff; padding: 6px 14px; }
@keyframes pulse { 50% { opacity: .25; } }
.memo { display: none; align-items: center; gap: 8px; }
.memo.on { display: flex; }
.memo audio { flex: 1; height: 36px; min-width: 0; }
.round.mic.recording { background: var(--danger); color: #fff; }

/* Dialoge */
dialog { border: 0; padding: 0; background: var(--bg); color: var(--text); width: 100%; max-width: 760px; height: 100dvh; max-height: 100dvh; margin: 0 auto; }
dialog::backdrop { background: rgba(0,0,0,.4); }
@media (min-width: 800px) { dialog { height: min(88dvh, 860px); margin: 6dvh auto; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.35); } }
.dlg { display: flex; flex-direction: column; height: 100%; }
.dlg header { display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px; border-bottom: 1px solid var(--line); }
.dlg header input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: 18px; font-weight: 600; color: var(--head); padding: 6px; }
.dlg .scroll { flex: 1; overflow-y: auto; padding: 14px 16px calc(24px + var(--safe-b)); display: grid; gap: 14px; align-content: start; }
.dlg textarea.big { width: 100%; min-height: 140px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); resize: vertical; line-height: 1.5; }
.dlg label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; display: block; margin-bottom: 5px; }
.dlg .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dlg select, .dlg input.tags { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--surface); }
.dlg audio { width: 100%; }
.dlg .note { font-size: 13px; color: var(--muted); }
.dlg .err { color: var(--danger); }
.dlg .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.saved { font-size: 12px; color: var(--sage); min-width: 64px; text-align: right; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; text-align: center; }
.login h1 { color: var(--head); margin: 0 0 4px; }
.login input { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.login .err { color: var(--danger); min-height: 1.4em; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(210px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast button { background: none; border: 0; color: var(--terra); font-weight: 700; margin-left: 10px; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
