:root {
  --bg: #0b1120;
  --panel: #111a2e;
  --panel-2: #16213a;
  --line: #24304d;
  --text: #e6edf7;
  --muted: #8ea0bd;
  --accent: #6366f1;
  --accent-2: #818cf8;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2540 0%, var(--bg) 60%);
  color: var(--text);
  padding: max(14px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 18px; margin-top: 4px; }
h3 { font-size: 15px; }
p { margin: 6px 0; line-height: 1.5; }
a { color: var(--accent-2); }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.error { color: #fca5a5; font-size: 13px; min-height: 18px; }
.hidden { display: none !important; }

.screen { display: none; max-width: 760px; margin: 0 auto; }
.screen.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.auth-card { margin-top: 12vh; }
.auth-card h1 { text-align: center; }
.auth-card .muted { text-align: center; margin-bottom: 16px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input, select {
  width: 100%; margin-top: 6px; padding: 12px 14px;
  background: #0c1424; color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.btn {
  border: 1px solid var(--line); background: #1c2740; color: var(--text);
  padding: 11px 16px; border-radius: 12px; font-size: 15px; cursor: pointer;
  transition: transform .06s ease, filter .15s ease;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(180deg, var(--accent), #4f46e5); border-color: #4f46e5; font-weight: 600; }
.btn.danger { background: linear-gradient(180deg, #ef4444, #dc2626); border-color: #dc2626; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 16px; font-size: 17px; border-radius: 14px; }
.btn.small { padding: 6px 10px; font-size: 13px; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  flex: 1; padding: 10px; border-radius: 12px; background: #0c1424;
  border: 1px solid var(--line); color: var(--muted); cursor: pointer; font-size: 14px;
}
.tab.active { color: var(--text); border-color: var(--accent); background: #18223c; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { font-size: 20px; font-weight: 700; letter-spacing: .2px; }

.nav-tabs .tab { font-weight: 500; }

.view { display: none; }
.view.active { display: block; }

.search-row { margin-bottom: 12px; }
.search-row input { margin-top: 0; }

.notes-list { display: grid; gap: 10px; }
.note-card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: 14px; padding: 14px;
  cursor: pointer; transition: border-color .15s ease;
}
.note-card:active { border-color: var(--accent); }
.note-title { font-weight: 600; font-size: 16px; margin-bottom: 6px; }
.note-summary { color: var(--muted); font-size: 13px; margin: 8px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: #1e2b4a; color: #c7d2fe; }
.chip.soft { background: #17213a; color: var(--muted); }

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

.record-card { text-align: center; }
.rec-status { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.rec-status.live { color: #fca5a5; }
.rec-timer { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; margin: 4px 0; }
.rec-chunks { margin-bottom: 16px; }
.record-card label { text-align: left; }
.rec-actions { margin-top: 8px; }
.checkbox { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 13px; }
.checkbox input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }

.reclocker {
  display: none; align-items: center; gap: 8px; justify-content: center;
  background: #2a1215; border: 1px solid #7f1d1d; color: #fecaca;
  padding: 10px; border-radius: 12px; font-size: 13px; margin: 8px 0;
}
.reclocker.active { display: flex; }
.reclocker .dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.note-content { padding-bottom: 40px; }
.note-h1 { font-size: 24px; }
.note-section { margin-top: 20px; }
.note-section h2 { color: var(--accent-2); }
.bullets { margin: 0; padding-left: 20px; line-height: 1.6; }
.bullets li { margin: 4px 0; }
.terms { display: grid; gap: 6px; }
.term-row { font-size: 14px; line-height: 1.5; }
.term-row strong { color: #c7d2fe; }
.audio { width: 100%; margin: 12px 0; border-radius: 12px; }
.transcript summary { cursor: pointer; color: var(--accent-2); font-size: 14px; }
.transcript p { white-space: pre-wrap; font-size: 14px; color: var(--muted); }
.note-actions { margin-top: 28px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #1f2a44; color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: #7f1d1d; background: #2a1215; color: #fecaca; }