:root {
  --bg: #15171a; --fg: #e8eaed; --muted: #8b9198; --line: #2a2e34; --card: #1c1f24;
  --accent: #e5484d; --accent-fg: #fff; --focus: #7cc4ff; --ok: #3ddc84;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f7f7f8; --fg: #1a1c1e; --muted: #6b7178; --line: #dcdfe3; --card: #fff; color-scheme: light; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- Record page ---------- */
.record-page { overflow: hidden; }
.record-main {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.25rem; padding: 1rem;
}
.rec-btn {
  --size: min(70vmin, 420px);
  width: var(--size); height: var(--size); border-radius: 50%; border: 0; cursor: pointer;
  background: var(--card); color: var(--fg); box-shadow: 0 0 0 6px var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  font-size: clamp(1.6rem, 7vmin, 3rem); font-weight: 600; letter-spacing: .02em;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.rec-btn:active { transform: scale(.97); }
.rec-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); box-shadow: 0 0 0 10px rgba(229,72,77,.35); animation: pulse 1.6s ease-in-out infinite; }
.rec-timer { font-variant-numeric: tabular-nums; font-size: .6em; font-weight: 500; min-height: 1.2em; }
.status { margin: 0; min-height: 1.5em; font-size: 1.15rem; color: var(--muted); text-align: center; }
.status.saved { color: var(--ok); }
.status.warn { color: #f5b942; }
.queue { margin: 0; font-size: .95rem; color: #f5b942; }
.hint { margin: 0; font-size: .85rem; color: var(--muted); opacity: .6; }
@media (pointer: coarse) { .hint { display: none; } }
.corner-link {
  position: fixed; top: calc(.75rem + env(safe-area-inset-top)); right: calc(1rem + env(safe-area-inset-right));
  padding: .5rem .8rem; border-radius: .5rem; background: var(--card); color: var(--muted); text-decoration: none; font-size: .95rem;
}
.corner-link:hover { color: var(--fg); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 10px rgba(229,72,77,.35); } 50% { box-shadow: 0 0 0 18px rgba(229,72,77,.15); } }
@media (prefers-reduced-motion: reduce) { .rec-btn, .rec-btn[aria-pressed="true"] { animation: none; transition: none; } }

/* ---------- Notes page ---------- */
.notes-page { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 0; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }
.inline-status { color: var(--muted); font-size: .95rem; }
.inline-status.saved { color: var(--ok); }
.inline-status.warn { color: #f5b942; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: .5rem; padding: .5rem .9rem; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-sm { padding: .3rem .6rem; font-size: .9rem; }
.btn-danger { color: var(--accent); }
.btn-rec { display: inline-flex; align-items: center; gap: .5rem; font-weight: 600; }
.btn-rec .dot { width: .8em; height: .8em; border-radius: 50%; background: var(--accent); }
.btn-rec[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-rec[aria-pressed="true"] .dot { background: #fff; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs [role="tab"] {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: .6rem .9rem; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.tabs [role="tab"][aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 1.5em; padding: 0 .4em; border-radius: 1em; background: var(--line); font-size: .8em; text-align: center; margin-left: .25em; }

.toolbar { display: flex; align-items: center; gap: 1rem; padding: .75rem 0; }
.search { flex: 1; }
.search input {
  width: 100%; max-width: 32rem; padding: .55rem .8rem; border-radius: .5rem; border: 1px solid var(--line); background: var(--card); color: var(--fg); font: inherit;
}
.sync { color: var(--muted); font-size: .85rem; }

.sheet { width: 100%; border-collapse: collapse; }
.sheet th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85rem; padding: .5rem .6rem; border-bottom: 1px solid var(--line); }
.sheet td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.note.is-done { opacity: .55; }
.note.is-done .transcript { text-decoration: line-through; text-decoration-color: var(--muted); }
.col-audio { width: 16rem; }
.col-done { width: 4rem; text-align: center; }
.col-actions { width: 11rem; white-space: nowrap; }
.when { font-size: .9rem; margin-bottom: .3rem; }
audio { width: 100%; max-width: 15rem; height: 36px; display: block; }
.meta { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.muted { color: var(--muted); }
.failed { color: var(--accent); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
textarea.grow {
  width: 100%; resize: none; overflow: hidden; border: 1px solid transparent; border-radius: .4rem; background: transparent; color: var(--fg);
  font: inherit; line-height: 1.4; padding: .35rem .45rem; margin: -.35rem -.45rem;
}
textarea.grow:hover { border-color: var(--line); }
textarea.grow:focus { background: var(--card); border-color: var(--muted); outline: none; box-shadow: 0 0 0 3px rgba(124,196,255,.35); }
.check input { width: 1.4rem; height: 1.4rem; accent-color: var(--accent); cursor: pointer; }
.confirm { display: inline-flex; gap: .3rem; }
.empty { color: var(--muted); padding: 2rem 0; text-align: center; }
.more-wrap { text-align: center; padding: 1rem 0 2rem; }

/* Cards on narrow screens: same fields, same order, no horizontal scroll. */
@media (max-width: 900px) {
  .sheet thead { display: none; }
  .sheet, .sheet tbody, .sheet tr, .sheet td { display: block; width: 100%; }
  .sheet tr.note { background: var(--card); border: 1px solid var(--line); border-radius: .75rem; margin: .75rem 0; padding: .5rem .75rem; }
  .sheet td { border: 0; padding: .45rem 0; }
  .sheet td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .2rem; }
  .sheet td[data-label=""]::before { display: none; }
  .col-audio, .col-done, .col-actions { width: auto; }
  .col-done { text-align: left; }
  .col-done .check { display: inline-flex; align-items: center; gap: .5rem; }
  .col-done .check .visually-hidden { position: static; width: auto; height: auto; clip: auto; }
  audio { max-width: 100%; }
  textarea.grow { margin: 0; border-color: var(--line); background: var(--bg); }
}
