:root {
  --bg: #f6f1e9;
  --surface: #fffaf3;
  --text: #2a2622;
  --muted: #7a7168;
  --line: #e4dbcf;
  --accent: #c8553d;
  --accent-soft: #f0d6cc;
  --good: #4f7d5c;
  --warn-bg: #fbe9e3;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916;
    --surface: #25221e;
    --text: #ece5db;
    --muted: #a0968b;
    --line: #3a352f;
    --accent: #e0775f;
    --accent-soft: #4a2c24;
    --good: #83b590;
    --warn-bg: #3a2621;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 ui-serif, Georgia, "Iowan Old Style", serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 48px; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.2em 0 0.6em; }
h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-family: system-ui, sans-serif; margin: 2em 0 0.6em; }
h3 { margin: 0 0 0.2em; font-size: 1.1rem; }
code { font-size: 0.9em; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 640px; margin: 0 auto; padding: 14px 16px;
  font-family: system-ui, sans-serif;
}
.topbar a { text-decoration: none; color: var(--muted); }
.topbar .brand { color: var(--text); font-weight: 600; }
.topbar nav { display: flex; gap: 18px; }

.meta { color: var(--muted); font-size: 0.9rem; font-family: system-ui, sans-serif; margin: 0; }
.small { font-size: 0.78rem; margin-top: 2em; }
.bad { color: var(--accent); }

.streak {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  font-family: system-ui, sans-serif; font-size: 0.95rem; color: var(--muted);
  margin: 4px 0 8px;
}
.streak .flame { color: var(--muted); font-size: 1.1rem; }
.streak.done .flame { color: var(--good); }
.streak strong { color: var(--text); }

/* recorder */
.recorder { text-align: center; }
.dial { position: relative; width: min(72vw, 300px); aspect-ratio: 1; margin: 24px auto 8px; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial circle { fill: none; stroke-width: 6; }
.dial .track { stroke: var(--line); }
.dial .progress { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 0.25s linear, stroke 0.4s; }
.recorder.reached .dial .progress { stroke: var(--good); }
.dial-text { position: absolute; inset: 0; display: grid; place-content: center; }
.elapsed { font: 600 3.2rem/1 system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.target { color: var(--muted); font-family: system-ui, sans-serif; margin-top: 6px; }
.hint { color: var(--muted); min-height: 3.2em; margin: 8px auto 16px; max-width: 26em; }

.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.controls #discard { justify-self: end; }
.controls #finish { justify-self: start; }
.mic {
  width: 84px; height: 84px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 35%, transparent);
  grid-column: 2;
}
.mic svg { width: 36px; height: 36px; fill: currentColor; }
.mic:disabled { opacity: 0.4; cursor: not-allowed; }
[data-state="recording"] .mic { animation: pulse 2s ease-in-out infinite; }
[data-state="recording"] .mic svg { display: none; }
[data-state="recording"] .mic::before { content: ""; width: 26px; height: 28px; border-left: 9px solid #fff; border-right: 9px solid #fff; box-sizing: border-box; }
[data-state="paused"] .mic { background: var(--muted); }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--accent) 18%, transparent); } }
.status { color: var(--muted); font-family: system-ui, sans-serif; font-size: 0.9rem; min-height: 1.5em; }

/* buttons */
button { font: 500 1rem system-ui, sans-serif; border-radius: 999px; padding: 10px 20px; cursor: pointer; }
.primary { background: var(--text); color: var(--bg); border: 1px solid var(--text); }
.primary:disabled { opacity: 0.3; cursor: not-allowed; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.danger { color: var(--accent); }
.button-link { display: inline-block; margin: 1em 0; font-family: system-ui, sans-serif; text-decoration: none; }

/* notices */
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; font-family: system-ui, sans-serif; font-size: 0.95rem; }
.notice.warn { background: var(--warn-bg); border-color: transparent; }
.notice.ok { color: var(--good); }
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin: 0; }
.spinner { display: inline-block; width: 0.9em; height: 0.9em; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -0.1em; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* lists */
.entry-list { list-style: none; padding: 0; margin: 0; }
.entry-list a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; text-decoration: none; color: var(--text); }
.card .excerpt { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }
.empty { text-align: center; color: var(--muted); margin-top: 3em; }

/* entry */
.prose p, .prose li { max-width: 38em; }
.prose ul { padding-left: 1.2em; }
.transcript .prose p { margin: 0 0 1em; }
audio { width: 100%; margin: 1em 0; }
.entry-actions { display: flex; gap: 10px; margin-top: 2em; flex-wrap: wrap; }
.entry-actions form { margin: 0; }

/* settings */
.settings { display: grid; gap: 20px; }
.settings label { display: grid; gap: 6px; font-family: system-ui, sans-serif; font-weight: 500; }
.settings label.check { display: flex; align-items: center; gap: 10px; font-weight: 400; }
.settings input:not([type=checkbox]), .settings select {
  font: 1rem system-ui, sans-serif; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); width: 100%;
}
.settings .help { font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.settings button { justify-self: start; }
.logout { margin-top: 2em; }
.login { max-width: 320px; margin: 10vh auto 0; }
