:root {
  --bg: #0f1115; --panel: #171a21; --line: #262a33; --text: #e8e9ec; --muted: #8b909c;
  --accent: #ff4d4f; --ok: #3ecf8e; --warn: #f5a524; --hl: rgba(255, 214, 102, .22);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f6f7f9; --panel: #fff; --line: #e3e5ea; --text: #15171c; --muted: #6a7080; --hl: rgba(255, 196, 0, .3); color-scheme: light; }
}
* { box-sizing: border-box; }
/* display у блоков перебивает атрибут hidden - возвращаем ему силу. */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 8px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; display: inline-block; }
button:active, .btn:active { transform: scale(.98); }
.danger { color: var(--accent); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { color: var(--text); text-decoration: none; font-weight: 650; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.quota { font-size: 13px; color: var(--muted); text-align: right; }
.quota .bar { width: 110px; height: 4px; background: var(--line); border-radius: 2px; margin-top: 4px; overflow: hidden; margin-left: auto; }
.quota .bar i { display: block; height: 100%; background: var(--ok); }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px 140px; }
.search input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; }
.items { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; }
.item .t { font-weight: 600; overflow-wrap: anywhere; }
.item .m { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.item .hit { font-size: 14px; color: var(--muted); margin-top: 6px; }
.item .hit b { color: var(--text); background: var(--hl); font-weight: 500; border-radius: 3px; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); }
.badge.queued, .badge.processing { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.badge.done { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.badge.error { color: var(--accent); }
.empty { color: var(--muted); text-align: center; margin-top: 48px; }
.banner { background: color-mix(in srgb, var(--warn) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.banner .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

.dock { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; padding-bottom: max(18px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); max-width: 760px; margin: 0 auto; }
.upload { color: var(--muted); font-size: 14px; cursor: pointer; width: 110px; }
.upload-spacer { width: 110px; }
.rec-btn { width: 76px; height: 76px; border-radius: 50%; background: var(--accent); border: 5px solid color-mix(in srgb, var(--accent) 30%, var(--bg)); box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 45%, transparent); display: grid; place-items: center; padding: 0; }
.rec-btn span { width: 24px; height: 24px; border-radius: 50%; background: #fff; }

.recorder { position: fixed; inset: 0; z-index: 20; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; }
.rec-state { color: var(--accent); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.rec-state::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.recorder.paused .rec-state { color: var(--muted); }
.recorder.paused .rec-state::before { background: var(--muted); animation: none; }
@keyframes blink { 50% { opacity: .2; } }
.rec-time { font-size: 64px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
#meter { width: min(100%, 420px); height: 60px; }
.rec-title { width: min(100%, 420px); padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; text-align: center; }
.rec-actions { display: flex; gap: 10px; }
.rec-actions .stop { background: var(--accent); color: #fff; border: 0; padding: 12px 20px; font-weight: 600; }
.rec-actions .ghost { padding: 12px 20px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; max-width: 420px; }

.detail-head { position: sticky; top: 53px; background: var(--bg); padding-bottom: 10px; z-index: 3; border-bottom: 1px solid var(--line); }
.back { color: var(--muted); text-decoration: none; font-size: 14px; }
#d-title { font-size: 22px; margin: 6px 0 2px; outline: none; border-radius: 6px; overflow-wrap: anywhere; }
#d-title:focus { background: var(--panel); }
.meta { color: var(--muted); font-size: 13px; }
audio { width: 100%; margin-top: 10px; height: 40px; }
.actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.actions > * { font-size: 14px; padding: 6px 12px; }
.transcript { padding-top: 12px; }
.para { display: grid; grid-template-columns: 54px 1fr; gap: 10px; padding: 6px 0; }
.para .ts { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; padding-top: 3px; cursor: pointer; }
.para.found { background: var(--hl); border-radius: 8px; }
.w { cursor: pointer; border-radius: 3px; }
.w.now { background: var(--hl); }
.state { color: var(--muted); padding: 24px 0; text-align: center; }
.state .big { font-size: 18px; color: var(--text); margin-bottom: 4px; }

.toast { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 30; max-width: calc(100% - 32px); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--ok); width: 0; transition: width .2s; }

.top-right { display: flex; align-items: center; gap: 12px; }
.gear { color: var(--muted); text-decoration: none; font-size: 22px; line-height: 1; }
.welcome { max-width: 460px; margin: 0 auto; padding-top: 12px; text-align: center; }
.welcome h1 { margin: 8px 0; font-size: 28px; }
.welcome .lead { color: var(--muted); }
.rules { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin: 18px 0; }
.rules-title { font-weight: 600; margin-bottom: 4px; }
.rules ol { margin: 0; padding-left: 20px; }
.rules li { margin: 6px 0; font-size: 15px; }
.consent { display: flex; gap: 10px; text-align: left; font-size: 14px; align-items: flex-start; margin: 8px 0 16px; }
.consent input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.consent a, .set a { color: var(--accent); }
.primary { width: 100%; background: var(--accent); color: #fff; border: 0; padding: 14px; font-weight: 600; border-radius: 12px; }
.primary:disabled { opacity: .45; }
.fine { color: var(--muted); font-size: 13px; }
.set { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-top: 12px; }
.set-title { font-weight: 600; }
.set select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
#settings-view h1 { font-size: 24px; margin: 6px 0; }
