:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --text: #16172b;
  --muted: #62657d;
  --border: #dfe1ec;
  --accent: #4f46e5;
  --accent-2: #7c3aed;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --rec: #ef4444;
  --task: #0e7490;
  --idea: #a16207;
  --note: #4b5563;
  --reminder: #be185d;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 14px rgb(0 0 0 / .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1020;
    --surface: #1a1b30;
    --surface-2: #24263f;
    --text: #ececf6;
    --muted: #a3a6c2;
    --border: #30334f;
    --accent: #818cf8;
    --accent-2: #a78bfa;
    --accent-text: #0f1020;
    --danger: #f87171;
    --task: #67e8f9;
    --idea: #fcd34d;
    --note: #cbd5e1;
    --reminder: #f9a8d4;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; flex: 1; }
.pill { font-size: 12px; padding: 2px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }

.icon-btn { background: none; border: 0; padding: 8px; border-radius: 10px; color: var(--muted); cursor: pointer; }
.icon-btn.small { padding: 2px 8px; font-size: 18px; line-height: 1; }

main { padding: 0 16px; max-width: 640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

.banner {
  margin: 0 16px 12px; padding: 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  font-size: 14px;
}
.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }

/* capture */
.capture { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 8px; }
.mic {
  width: 128px; height: 128px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff; box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 40%, transparent);
  display: grid; place-items: center; transition: transform .15s;
}
.mic:active { transform: scale(.96); }
.mic.listening { background: var(--rec); animation: pulse 1.4s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 55%, transparent); }
  70% { box-shadow: 0 0 0 26px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.hint { color: var(--muted); font-size: 14px; margin: 0; text-align: center; }
.hint.left { text-align: left; margin: 4px 0 8px; }

textarea, .search, input[type=datetime-local], input[type=password], select {
  width: 100%; border: 1px solid var(--border); background: var(--surface);
  border-radius: 12px; padding: 12px 14px; outline: none;
}
textarea:focus, .search:focus, input:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }

.row { display: flex; gap: 10px; width: 100%; }
.row > * { flex: 1; }
.row.tight { gap: 6px; flex-wrap: wrap; }
.row.tight > * { flex: 0 0 auto; }

.btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 12px;
  padding: 12px 14px; font-weight: 600; cursor: pointer; text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 10px; }
.btn.tiny { padding: 6px 10px; font-size: 13px; border-radius: 9px; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.file-btn { cursor: pointer; }

.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 0 8px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 14px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.list { display: flex; flex-direction: column; gap: 10px; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 20px 0; }

.note, .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card { margin-top: 12px; }
.card-title { font-size: 17px; margin: 0 0 4px; }
.note-head { display: flex; align-items: center; gap: 8px; }
.note-title { margin: 0; font-size: 16px; flex: 1; }
.note.done .note-title { text-decoration: line-through; color: var(--muted); }
.kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); }
.kind.task { color: var(--task); } .kind.idea { color: var(--idea); } .kind.note { color: var(--note); } .kind.reminder { color: var(--reminder); }
.kind.pending { color: var(--muted); }
.note-summary { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.note-full { margin-top: 6px; font-size: 14px; }
.note-full summary { color: var(--accent); cursor: pointer; }
.note-text { white-space: pre-wrap; margin: 6px 0 0; }
.note-remind { margin-top: 10px; padding: 10px; border-radius: 12px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.note-remind .when { font-weight: 600; color: var(--reminder); font-size: 14px; }
.note-remind.due .when::before { content: "🔔 "; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tags span { font-size: 12px; color: var(--muted); }
.note-actions { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.when-edit { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.note-time { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
.error-text { color: var(--danger); font-size: 13px; margin: 6px 0 0; }

.answer { line-height: 1.55; }
.answer h3, .answer h4 { margin: 14px 0 6px; font-size: 16px; }
.answer h3:first-child, .answer h4:first-child { margin-top: 0; }
.answer ul { padding-left: 20px; margin: 6px 0; }
.answer p { margin: 6px 0; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { position: relative; background: none; border: 0; padding: 8px 0 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tab span { font-size: 20px; filter: grayscale(1); opacity: .7; }
.tab.active { color: var(--accent); font-weight: 600; }
.tab.active span { filter: none; opacity: 1; }
.badge { position: absolute; top: 4px; left: calc(50% + 8px); background: var(--rec); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; }

dialog { border: 0; border-radius: 20px; padding: 0; width: min(92vw, 440px); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.settings { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.settings h2 { margin: 0; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.settings small { font-weight: 400; color: var(--muted); }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 10;
  max-width: 560px; margin: 0 auto; background: var(--text); color: var(--bg);
  padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgb(0 0 0 / .25);
}
