:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #eceef7;
  --text: #171a2b;
  --muted: #5d6280;
  --line: #d9dcea;
  --primary: #3f51b5;
  --on-primary: #ffffff;
  --accent: #3f51b5;
  --danger: #c62828;
  --new: #64b5f6;
  --progress: #fb8c00;
  --complete: #43a047;
  --shadow: 0 6px 24px rgba(20, 27, 52, .12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131c;
    --surface: #1b1d2b;
    --surface-2: #262a3f;
    --text: #eceefb;
    --muted: #a3a8c6;
    --line: #333852;
    --primary: #4a5fd0;
    --accent: #8c9eff;
    --danger: #ef7b7b;
    --shadow: 0 6px 24px rgba(0, 0, 0, .45);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.shell { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* header */
.topbar { display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 8px; padding-top: max(14px, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 38px; height: 38px; border-radius: 10px; }
.brand span { font-weight: 800; letter-spacing: .18em; font-size: 20px; }
.icon-btn { background: none; border: 0; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

/* tabs */
.tabs { display: flex; gap: 4px; margin: 4px 16px 12px; padding: 4px; background: var(--surface-2); border-radius: 14px; }
.tab { flex: 1; border: 0; background: none; padding: 10px 6px; border-radius: 10px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.badge { background: var(--primary); color: var(--on-primary); border-radius: 999px; font-size: 12px; min-width: 20px; padding: 1px 6px; }

main { flex: 1; padding: 0 16px 32px; }

/* home */
.home { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 6vh; }
.mic-btn { width: 200px; height: 200px; border-radius: 50%; border: 0; background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; box-shadow: 0 10px 40px rgba(63, 81, 181, .45); transition: transform .12s; }
.mic-btn:hover { transform: scale(1.03); }
.mic-btn:active { transform: scale(.97); }
.mic-btn svg { width: 104px; height: 104px; fill: currentColor; }
.hint { margin: 24px 0 0; color: var(--muted); }
.link-btn { margin-top: 36px; background: none; border: 0; color: var(--accent); font-weight: 600; padding: 10px 14px; border-radius: 10px; }
.link-btn:hover { background: var(--surface-2); }

/* cards and buttons */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.btn { display: block; width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px 16px; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.text { border-color: transparent; background: none; color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.small { width: auto; display: inline-block; padding: 8px 12px; border-radius: 10px; font-size: 14px; }
.btn + .btn { margin-top: 10px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }

/* status dots and picker */
.dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex: none; position: relative; }
.dot.NEW { background: var(--new); }
.dot.IN_PROGRESS { background: var(--progress); }
.dot.COMPLETE { background: var(--complete); }
.dot.COMPLETE::after { content: ""; position: absolute; left: 6px; top: 3px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.dot.big { width: 24px; height: 24px; }
.dot.big.COMPLETE::after { left: 8px; top: 4px; width: 5px; height: 10px; }
.status-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-picker button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; font-size: 14px; font-weight: 600; }
.status-picker button[aria-pressed="true"] { background: var(--surface-2); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.label { font-size: 13px; color: var(--muted); margin: 0 0 6px; }

/* categorize */
.cat-progress { color: var(--muted); font-size: 13px; }
.cat-date { color: var(--accent); font-size: 14px; margin-top: 2px; }
.cat-note { font-size: 24px; line-height: 1.3; margin: 18px 0 24px; min-height: 110px; white-space: pre-wrap; overflow-wrap: anywhere; }
.caught-up { text-align: center; padding: 8vh 0; }
.caught-up .face { font-size: 96px; line-height: 1; }
.caught-up p { font-size: 22px; font-weight: 600; margin: 16px 0 0; }

/* browse */
.group-head { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 18px 6px 6px;
  font-weight: 700; color: var(--accent); font-size: 16px; }
.note-row { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0;
  border-radius: 12px; padding: 10px 6px; }
.note-row:hover { background: var(--surface-2); }
.note-row .dot { margin-top: 3px; }
.note-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.note-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

/* forms */
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 150px; resize: vertical; font-size: 18px; }
.field { margin-top: 14px; }
.error { color: var(--danger); min-height: 1.4em; margin: 10px 0 0; }

/* login */
.login { max-width: 380px; margin: 0 auto; padding: 12vh 20px 32px; text-align: center; }
.login img { width: 96px; height: 96px; border-radius: 24px; }
.login h1 { letter-spacing: .22em; margin: 14px 0 22px; }
.login form { text-align: left; }

/* dialogs */
dialog { border: 0; border-radius: 22px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 10, 22, .6); }
.dlg { padding: 20px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dlg-head h2 { margin: 0; font-size: 20px; }
.section { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.section h3 { margin: 0 0 10px; font-size: 16px; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item small { display: block; color: var(--muted); }
.token-box { margin-top: 12px; padding: 12px; border: 1px dashed var(--accent); border-radius: 12px; background: var(--surface-2); }
.token-box code { display: block; overflow-wrap: anywhere; font-size: 13px; margin: 8px 0; user-select: all; }

/* listening overlay */
.listening { text-align: center; }
.listening .pulse { width: 84px; height: 84px; margin: 6px auto 16px; border-radius: 50%; background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; animation: pulse 1.4s ease-out infinite; }
.listening .pulse svg { width: 44px; height: 44px; fill: currentColor; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 95, 208, .6); } 100% { box-shadow: 0 0 0 28px rgba(74, 95, 208, 0); } }
.heard { min-height: 3.2em; font-size: 20px; margin: 0 0 18px; overflow-wrap: anywhere; }
.heard.placeholder { color: var(--muted); }

/* toast */
#toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0;
  background: #20233a; color: #fff; padding: 12px 18px; border-radius: 14px; max-width: min(520px, 92vw); text-align: center;
  transition: all .25s; pointer-events: none; z-index: 100; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { .listening .pulse { animation: none; } * { transition: none !important; } }
