/* Layout: one album page per view — a narrow, large-type column for the storytellers, a wider working desk for the editor. */
:root {
  --paper: #EDF0EA;
  --card: #FAFBF7;
  --ink: #18233A;
  --muted: #586274;
  --line: #CFD5CB;
  --accent: #2A45AE;
  --accent-ink: #FFFFFF;
  --soft: #E0E6F4;
  --rec: #B3302A;
  --rec-ink: #FFFFFF;
  --ok: #2C6A44;
  --ok-soft: #DCEBDF;
  --warn: #8F5C00;
  --warn-soft: #F4E7CC;
  --corner: #2B3550;
  --display: 'Literata', Georgia, 'Times New Roman', serif;
  --ui: 'Atkinson Hyperlegible', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10151E; --card: #19202D; --ink: #E7E9E3; --muted: #A2AABA; --line: #2D3648;
    --accent: #93A9FF; --accent-ink: #0D1322; --soft: #222C45; --rec: #FF7C70; --rec-ink: #1A0A08; --ok: #86CF9E; --ok-soft: #1C3426;
    --warn: #E9B95C; --warn-soft: #3A2E15; --corner: #4A5576; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--ui); font-size: 17px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
img { max-width: 100%; }
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; text-wrap: balance; margin: 0; letter-spacing: -0.005em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.top { position: sticky; top: 0; z-index: 5; background: var(--paper); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 1.15rem; font-weight: 600; min-width: 0; color: inherit; text-decoration: none; }
.brand-mark { width: 26px; height: 26px; flex: none; position: relative; border: 2px solid var(--ink); border-radius: 2px; }
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: 9px; height: 9px; background: var(--ink); }
.brand-mark::before { top: -2px; left: -2px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.brand-mark::after { bottom: -2px; right: -2px; clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.top-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

main { padding-block: 24px 64px; padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
.notice { border-radius: var(--r); padding: 12px 16px; margin-bottom: 16px; background: var(--warn-soft); color: var(--ink); border: 1px solid var(--line); }
.notice.ok { background: var(--ok-soft); }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.eyebrow { font-size: 0.78rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 10px 20px; border-radius: var(--r); border: 1.5px solid var(--ink); background: transparent; cursor: pointer; font-weight: 700; text-align: center; text-decoration: none; color: inherit; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { border-color: var(--line); font-weight: 400; }
.btn.danger { border-color: var(--rec); color: var(--rec); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 0.92rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* Storyteller view */
.teller { font-size: 20px; }
.teller .btn { min-height: 64px; font-size: 1.1rem; }
.greet { font-family: var(--display); font-size: clamp(1.7rem, 5vw, 2.3rem); }
.qcard { position: relative; background: var(--card); padding: 34px 30px 30px; border-radius: 3px; box-shadow: 0 1px 0 var(--line), 0 10px 30px -18px rgba(20, 30, 60, 0.35); }
.qcard .corner { position: absolute; width: 30px; height: 30px; background: var(--corner); }
.qcard .c1 { top: -6px; left: -6px; clip-path: polygon(0 0, 100% 0, 0 100%); }
.qcard .c2 { top: -6px; right: -6px; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.qcard .c3 { bottom: -6px; left: -6px; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.qcard .c4 { bottom: -6px; right: -6px; clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.qtext { font-family: var(--display); font-style: italic; font-size: clamp(1.55rem, 4.6vw, 2.15rem); line-height: 1.28; margin-top: 10px; }
.answer-btns { display: grid; gap: 12px; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: currentColor; flex: none; }
.btn.primary .rec-dot { background: var(--rec); box-shadow: 0 0 0 3px var(--accent-ink); }
.filepick { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.alt-qs { display: grid; gap: 10px; }
.alt-qs button { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; cursor: pointer; font-family: var(--display); font-style: italic; font-size: 1.05rem; color: inherit; }
textarea.big { width: 100%; min-height: 240px; padding: 14px; border-radius: var(--r); border: 1.5px solid var(--line); background: var(--card); font-family: var(--display); font-size: 1.15rem; line-height: 1.55; resize: vertical; }
.bar { height: 12px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0%; background: var(--accent); transition: width .3s; }
.thanks-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 2rem; font-weight: 700; }

/* Recorder */
.stage { position: relative; background: #0d0f14; border-radius: 14px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 62vh; width: 100%; display: grid; place-items: center; }
@media (min-width: 700px) { .stage { aspect-ratio: 16 / 10; } }
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage video.mirror { transform: scaleX(-1); }
.stage .audio-face { display: grid; place-items: center; gap: 18px; color: #e7e9e3; text-align: center; padding: 20px; }
.meter-bars { display: flex; gap: 6px; align-items: flex-end; height: 90px; }
.meter-bars i { width: 12px; background: #93A9FF; border-radius: 3px; height: 8%; transition: height .08s; }
.rec-badge { position: absolute; top: 14px; left: 14px; display: flex; gap: 8px; align-items: center; background: rgba(0,0,0,.55); color: #fff; padding: 6px 12px; border-radius: 999px; font-variant-numeric: tabular-nums; font-weight: 700; }
.rec-badge .dot { width: 12px; height: 12px; border-radius: 50%; background: #ff4b3e; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-controls { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }
.rec-big { width: 88px; height: 88px; border-radius: 50%; border: 5px solid var(--ink); background: var(--card); display: grid; place-items: center; cursor: pointer; padding: 0; }
.rec-big span { width: 60px; height: 60px; border-radius: 50%; background: var(--rec); transition: all .2s; }
.rec-big.on span { width: 34px; height: 34px; border-radius: 6px; }
.rec-hint { text-align: center; font-weight: 700; }
.preview { width: 100%; max-width: 100%; border-radius: var(--r); background: #000; max-height: 60vh; }
audio.preview { background: transparent; }

/* Lists */
.list { display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; text-align: left; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; cursor: pointer; color: inherit; }
.item:hover { border-color: var(--muted); }
.item .t { font-family: var(--display); font-size: 1.08rem; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.item .m { color: var(--muted); font-size: 0.9rem; grid-column: 1; min-width: 0; }
.item .side { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pill { display: inline-block; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--ink); white-space: nowrap; }
.pill.neu { background: var(--accent); color: var(--accent-ink); }
.pill.fertig { background: var(--ok-soft); color: var(--ok); }
.pill.hochladen, .pill.offen, .pill.fehler { background: var(--warn-soft); color: var(--warn); }
.tnum { font-variant-numeric: tabular-nums; }
.empty { border: 1.5px dashed var(--line); border-radius: var(--r); padding: 22px; color: var(--muted); }

/* Editor desk */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 0.75rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.cols > * { min-width: 0; }
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 0.92rem; }
input.in, select.in, textarea.in { width: 100%; min-width: 0; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; background: var(--paper); font-weight: 400; font-size: 1rem; }
textarea.in { min-height: 140px; resize: vertical; line-height: 1.5; }
textarea.story-in { font-family: var(--display); font-size: 1.05rem; min-height: 280px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 0.92rem; color: inherit; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.queue { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.queue li { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.queue li.now { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.qt { font-family: var(--display); min-width: 0; overflow-wrap: anywhere; }
.acts { display: flex; gap: 4px; }
.iconbtn { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--card); border-radius: 8px; cursor: pointer; display: grid; place-items: center; font-size: 0.95rem; color: inherit; }
.iconbtn[disabled] { opacity: .35; cursor: default; }
details.lib { border-top: 1px solid var(--line); padding-block: 10px; }
details.lib summary { cursor: pointer; font-family: var(--display); font-weight: 600; font-size: 1.05rem; }
.libq { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.libq:last-child { border-bottom: 0; }
.libq .qt { font-style: italic; }
.have { font-size: 0.8rem; color: var(--ok); font-weight: 700; }
.photos { display: flex; gap: 12px; flex-wrap: wrap; }
.photo { position: relative; width: 130px; }
.photo img { width: 130px; height: 100px; object-fit: cover; border: 6px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.18); display: block; }
.photo button { position: absolute; top: -8px; right: -8px; }
.player { display: grid; gap: 8px; }
.player video, .player audio { width: 100%; max-width: 100%; border-radius: var(--r); }
.player video { background: #000; max-height: 62vh; }
.parts { display: flex; gap: 6px; flex-wrap: wrap; }
.copybox { width: 100%; min-height: 150px; }
.meter { height: 10px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--accent); }
.dirty-note { color: var(--warn); font-weight: 700; font-size: 0.9rem; }
.confirm { border: 1.5px solid var(--rec); border-radius: var(--r); padding: 14px; display: grid; gap: 10px; }
.story-text { font-family: var(--display); font-size: 1.12rem; line-height: 1.65; max-width: 65ch; display: grid; gap: 0.9em; }
.linkbox { font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem; overflow-wrap: anywhere; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; user-select: all; }
.status-chip { display: inline-flex; gap: 8px; align-items: center; font-size: 0.9rem; color: var(--muted); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.book-q { font-family: var(--display); font-style: italic; color: var(--muted); font-size: 1.1rem; }
.events { display: grid; gap: 0; max-height: 420px; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 7.5em 1fr; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.ev:first-child { border-top: 0; }
.ev.bad span:last-child { color: var(--warn); font-weight: 700; }
@media (max-width: 480px) { .ev { grid-template-columns: 1fr; gap: 2px; } }
