/* Personal Brain – Hell/Dunkel ueber Tokens */
:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efede8;
  --surface-3: #e6e3dc;
  --text: #1e1d1b;
  --muted: #6b6862;
  --border: #e2dfd8;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --accent-soft: #dcebe5;
  --rec: #c8402f;
  --rec-soft: #f7dfda;
  --warn: #9a6400;
  --warn-soft: #fbedd0;
  --err: #b4312a;
  --err-soft: #f8dedb;
  --ok: #2f6f5e;
  --shadow: 0 1px 2px rgba(30, 29, 27, .06), 0 4px 16px rgba(30, 29, 27, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121413;
    --surface: #1a1d1c;
    --surface-2: #222625;
    --surface-3: #2b302e;
    --text: #ecebe7;
    --muted: #9c9b95;
    --border: #2e3331;
    --accent: #6cc3a8;
    --accent-text: #0e1a16;
    --accent-soft: #1f3530;
    --rec: #ef6a58;
    --rec-soft: #3a211d;
    --warn: #e8b04f;
    --warn-soft: #362a14;
    --err: #ef7a70;
    --err-soft: #3a1f1d;
    --ok: #6cc3a8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121413;
  --surface: #1a1d1c;
  --surface-2: #222625;
  --surface-3: #2b302e;
  --text: #ecebe7;
  --muted: #9c9b95;
  --border: #2e3331;
  --accent: #6cc3a8;
  --accent-text: #0e1a16;
  --accent-soft: #1f3530;
  --rec: #ef6a58;
  --rec-soft: #3a211d;
  --warn: #e8b04f;
  --warn-soft: #362a14;
  --err: #ef7a70;
  --err-soft: #3a1f1d;
  --ok: #6cc3a8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 1em; height: 1em; flex: none; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.error { color: var(--err); margin: 0; font-size: .9rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Grundgeruest ---------- */
.app { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; grid-template-areas: "top" "main" "tabs"; }
.topbar {
  grid-area: top; position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.view { grid-area: main; min-width: 0; padding: 20px 16px 32px; width: 100%; max-width: 760px; margin: 0 auto; outline: none; }

.tabs {
  grid-area: tabs; position: sticky; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 9px; color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 550;
  min-height: 56px; justify-content: center;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a[aria-current="page"] { color: var(--accent); }
.badge {
  position: absolute; top: 5px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--rec); color: #fff; font-size: .68rem; line-height: 18px; text-align: center; font-weight: 700;
}

@media (min-width: 900px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "top top" "tabs main"; }
  .tabs {
    position: sticky; top: 57px; align-self: start; height: calc(100dvh - 57px);
    display: flex; flex-direction: column; gap: 2px; padding: 16px 12px;
    border-top: 0; border-right: 1px solid var(--border); background: transparent;
  }
  .tabs a { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: .95rem; padding: 10px 12px; min-height: 0; border-radius: var(--radius-sm); }
  .tabs a[aria-current="page"] { background: var(--accent-soft); }
  .tabs a:hover { background: var(--surface-2); }
  .badge { position: static; margin-left: auto; }
  .view { padding-top: 28px; }
}

/* ---------- Bausteine ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: .92rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--err); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .84rem; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill svg { width: 14px; height: 14px; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: var(--err-soft); color: var(--err); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.rec { background: var(--rec-soft); color: var(--rec); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-size: .85rem; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip .n { opacity: .7; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.tag { color: var(--muted); font-size: .82rem; }

.field { display: grid; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: .8rem; }
input[type="text"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }

.segmented { display: inline-grid; grid-auto-flow: column; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; font-weight: 600; font-size: .88rem; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .5; margin-bottom: 8px; }

/* ---------- Aufnahme ---------- */
.recorder { display: grid; justify-items: center; gap: 14px; padding: 28px 16px 24px; text-align: center; }
.rec-button {
  position: relative; width: 132px; height: 132px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--rec); color: #fff; box-shadow: 0 8px 28px color-mix(in srgb, var(--rec) 35%, transparent);
  transition: transform .15s ease;
}
.rec-button:active { transform: scale(.96); }
.rec-button svg { width: 52px; height: 52px; }
.rec-button::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--rec) 40%, transparent);
  transform: scale(var(--level, 1)); transition: transform .08s linear; opacity: 0;
}
.recording .rec-button::after { opacity: 1; }
.rec-time { font-size: 2rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.rec-hint { margin: 0; color: var(--muted); max-width: 32ch; }
.recording .rec-time { color: var(--rec); }

.quick-text textarea { min-height: 80px; }

.note-card { display: grid; gap: 8px; cursor: pointer; }
.note-card:hover { border-color: var(--surface-3); }
.note-card .meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .82rem; }
.note-card .meta svg { width: 15px; height: 15px; }
.note-card h3 { font-size: 1rem; }
.note-card .preview { margin: 0; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.note-card .summary { margin: 0; color: var(--muted); font-size: .92rem; }
.suggestion {
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); background: var(--accent-soft);
  border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 6px; cursor: default;
}
.suggestion .label { display: flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.suggestion .label svg { width: 15px; height: 15px; }

.outbox-item { display: flex; align-items: center; gap: 10px; }

/* ---------- Protokoll ---------- */
.log-entry summary { list-style: none; cursor: pointer; display: grid; gap: 4px; }
.log-entry summary::-webkit-details-marker { display: none; }
.log-entry .line1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.log-entry pre {
  margin: 10px 0 0; padding: 10px; background: var(--surface-2); border-radius: 8px;
  font: .78rem/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto;
}
.log-entry h4 { margin: 12px 0 0; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.diff { display: grid; gap: 4px; margin-top: 8px; font-size: .88rem; }
.diff div { overflow-wrap: anywhere; }
.diff del { color: var(--err); }
.diff ins { color: var(--ok); text-decoration: none; font-weight: 600; }

/* ---------- Einstellungen ---------- */
.settings-group { display: grid; gap: 16px; }
.model-list { max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.model-list button {
  display: flex; width: 100%; text-align: left; gap: 8px; align-items: baseline; justify-content: space-between;
  border: 0; border-bottom: 1px solid var(--border); background: transparent; padding: 9px 12px; cursor: pointer;
}
.model-list button:last-child { border-bottom: 0; }
.model-list button:hover { background: var(--surface-2); }
.model-list button[aria-selected="true"] { background: var(--accent-soft); }
.model-list .mid { font-family: var(--mono); font-size: .76rem; color: var(--muted); overflow-wrap: anywhere; }
.model-list .mname { font-weight: 600; font-size: .9rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.login-card .field { text-align: left; }
.login-card p { margin: 0; }
.login-mark { width: 48px; height: 48px; color: var(--accent); margin: 0 auto; }

/* ---------- Detail-Sheet ---------- */
.sheet {
  border: 0; padding: 0; width: min(680px, 100vw); max-height: 92dvh; margin: auto auto 0;
  border-radius: 20px 20px 0 0; background: var(--surface); color: var(--text); box-shadow: 0 -8px 40px rgba(0,0,0,.25);
}
.sheet::backdrop { background: rgba(0, 0, 0, .45); }
@media (min-width: 700px) { .sheet { margin: auto; border-radius: 20px; } }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 1; }
.sheet-body { padding: 16px; display: grid; gap: 14px; }
.sheet-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px 20px; }
audio { width: 100%; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; animation: toast-in .18s ease; }
.toast.err { background: var(--err); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@media (min-width: 900px) { .toasts { bottom: 24px; } }

.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } .rec-button::after { transition: none; } }

/* ---------- V1.0.1: Diktat ueber Web Speech API ---------- */
.recorder.recording, .recorder.review { justify-items: stretch; text-align: left; gap: 16px; }
.wave { display: flex; align-items: center; justify-content: center; gap: 3px; height: 56px; }
.wave i {
  display: block; width: 5px; height: 100%; border-radius: 3px; background: var(--rec);
  transform: scaleY(.06); transform-origin: center; transition: transform .09s linear; opacity: .85;
}
.live {
  font-size: 1.35rem; line-height: 1.5; min-height: 7.5em; max-height: 45vh; overflow-y: auto;
  overflow-wrap: anywhere; padding: 4px 2px;
}
.live .final { color: var(--text); }
.live .interim { color: var(--muted); }
.caret {
  display: inline-block; width: 2px; height: 1.15em; margin-left: 2px; vertical-align: -.2em;
  background: var(--accent); animation: caret-blink 1s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }
.rec-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.rec-row .rec-time:first-child { justify-self: start; }
.rec-max { justify-self: end; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.rec-button.small { width: 76px; height: 76px; }
.rec-button.small svg { width: 30px; height: 30px; }
.rec-button.small::after { display: none; }
.rec-button.off { background: var(--surface-3); color: var(--muted); box-shadow: none; cursor: default; }
.recorder.review h2 { margin: 0; }
.review-text { font-size: 1.1rem; min-height: 9em; }
.notice {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: .95rem; text-align: left;
}
.recorder .rec-hint.small { font-size: .82rem; }
@media (prefers-reduced-motion: reduce) { .caret { animation: none; } .wave i { transition: none; } }

/* ---------- V1.1: Passkeys ---------- */
.passkey-btn { min-height: 56px; font-size: 1.05rem; gap: 10px; }
.passkey-btn svg { width: 26px; height: 26px; }
.linklike { background: none; border: 0; padding: 6px; color: var(--muted); font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linklike:hover { color: var(--text); }
.passkey-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.passkey-item > svg { width: 24px; height: 24px; color: var(--accent); }
.field-title { font-size: .85rem; font-weight: 600; color: var(--muted); margin-top: 6px; }
.offer { text-align: center; justify-items: center; padding: 28px 20px; }
.offer-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.offer-icon svg { width: 34px; height: 34px; }
.offer .row { justify-content: center; }
.btn.block { white-space: normal; text-align: center; }
.login-card > * { min-width: 0; }
