:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #161616;
  --muted: #6e6a62;
  --line: #e2ded6;
  --accent: #ffd200;
  --accent-ink: #161616;
  --rec: #e5322d;
  --ok: #1f8a4c;
  --err: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --surface: #1c1c1c;
    --ink: #f1efe9;
    --muted: #a19c92;
    --line: #2e2e2e;
    --shadow: none;
    --err: #ff7a6e;
    --ok: #5ccf8b;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:active { background: var(--line); }
.icon-btn[hidden] { display: none; }

.view { width: min(760px, 100%); margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 16px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.big { min-height: 60px; font-size: 18px; width: 100%; border-radius: 16px; }
.btn.stop { background: var(--rec); border-color: var(--rec); color: #fff; }
.link { border: 0; background: none; padding: 6px 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--err); }

.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 3px rgba(229,50,45,.2); }
.stop-sq { width: 14px; height: 14px; border-radius: 3px; background: #fff; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

.hint { margin: 0; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.error { margin: 0; color: var(--err); font-size: 14px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; margin: 0; }

.notice {
  display: block; width: 100%; text-align: left; padding: 14px 16px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 18%, var(--surface)); color: var(--ink); font: inherit; cursor: pointer;
}

/* Startseite */
.new-folder { display: flex; gap: 8px; }
.new-folder input, .add-todo input {
  flex: 1; min-width: 0; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit;
}
.day { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 8px; }
.folder-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: inherit; text-decoration: none;
}
.folder-card:active { transform: scale(.99); }
.folder-icon { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in srgb, var(--accent) 30%, transparent); }
.folder-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.folder-name { font-weight: 700; font-size: 17px; }
.folder-meta { font-size: 13px; color: var(--muted); }
.folder-preview { font-size: 14px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Aufnahme */
.recorder { display: grid; gap: 10px; justify-items: center; }
.recorder.live {
  padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--rec); box-shadow: var(--shadow);
}
.rec-time { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.meter { width: 100%; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--rec); transform-origin: left; transform: scaleX(.04); transition: transform .08s linear; }
.upload { cursor: pointer; }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.card h2 { font-size: 20px; }
.summary h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 18px 0 8px; }
.summary h4 { font-size: 16px; margin: 10px 0 4px; }
.summary ul { margin: 0; padding-left: 20px; }
.summary li { margin: 3px 0; }
.lead { margin: 0; font-size: 17px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); }

.todos { list-style: none; padding: 0 !important; display: grid; gap: 4px; }
.todos li { display: flex; align-items: center; gap: 6px; }
.todos label { flex: 1; display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.todos input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--ok); flex: none; }
.todos small { display: block; color: var(--muted); font-size: 13px; }
.todos .done span { text-decoration: line-through; color: var(--muted); }
.send {
  flex: none; display: grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--ink); cursor: pointer;
}
.send svg { width: 18px; height: 18px; }
.send.sent { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.add-todo { display: flex; gap: 8px; margin-top: 8px; }

/* Aufnahmen-Liste */
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 8px 0 0; }
.recs { display: grid; gap: 10px; }
.rec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; }
.rec-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.rec-head > div { display: grid; }
.rec-head .muted { font-size: 13px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status.err { color: var(--err); font-weight: 600; }
.players { display: grid; gap: 6px; }
.players audio { width: 100%; height: 40px; }
.transcript summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.transcript .text { margin: 8px 0; white-space: normal; line-height: 1.6; }
.transcript textarea.edit {
  width: 100%; margin: 8px 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit; resize: vertical;
}
.folder-actions { padding-top: 8px; }

/* Spinner */
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ink); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Einstellungen */
dialog {
  width: min(520px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  border: 1px solid var(--line); border-radius: 18px; padding: 0;
  background: var(--surface); color: var(--ink);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { display: grid; gap: 14px; padding: 20px; }
dialog h2 { font-size: 20px; }
dialog label { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
dialog label small { font-weight: 400; color: var(--muted); }
dialog input[type=text], dialog input[type=password], dialog textarea, dialog select {
  min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font: inherit; font-weight: 400;
}
dialog label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
dialog label.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; }
dialog details { display: grid; gap: 12px; }
dialog details[open] > *:not(summary) { margin-top: 12px; }
dialog summary { cursor: pointer; font-weight: 600; }
.shortcut-only { display: grid; gap: 8px; }
.shortcut-only[hidden] { display: none; }

/* Hinweis-Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-size: 15px; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.planner-only { display: grid; gap: 8px; }
.planner-only[hidden] { display: none; }
.login { display: grid; gap: 12px; margin-top: 8vh; }
.login input {
  min-height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--ink); font: inherit;
}

.cat {
  flex: none; height: 30px; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font: inherit; font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer;
}

.paused {
  display: grid; gap: 10px; padding: 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border: 1px solid var(--accent);
}
.paused p { margin: 0; font-size: 14px; }
