:root {
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface-2: #f0ece6;
  --ink: #1d1b19;
  --muted: #6b655f;
  --faint: #a49d95;
  --line: #e6e0d8;
  --accent: #e2552f;
  --accent-ink: #ffffff;
  --accent-soft: #fde6de;
  --ok: #1f8a4c;
  --ok-soft: #dcf2e4;
  --warn: #a8650a;
  --warn-soft: #fbedd5;
  --bad: #c0362c;
  --bad-soft: #fbe1de;
  --info: #2f5fd0;
  --info-soft: #e1e9fb;
  --shadow: 0 1px 2px rgb(29 27 25 / 6%), 0 4px 16px rgb(29 27 25 / 6%);
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312;
    --surface: #1d1b1a;
    --surface-2: #262321;
    --ink: #f1eee9;
    --muted: #aaa39b;
    --faint: #6f6962;
    --line: #322e2b;
    --accent: #ff7350;
    --accent-ink: #1d0f0a;
    --accent-soft: #3d2219;
    --ok: #5fd08c;
    --ok-soft: #173323;
    --warn: #f2b45a;
    --warn-soft: #3a2a12;
    --bad: #ff7b70;
    --bad-soft: #3d1b18;
    --info: #8eaefc;
    --info-soft: #1d2740;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--font);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.75rem, 6vw, 2.5rem); letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--mono); font-size: 0.85em; }
.hidden { display: none !important; }
.icon { display: inline-flex; align-items: center; }
.account { margin-bottom: 16px; }

/* Layout */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.03em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.logo-bg { fill: var(--accent); }
.logo-wave { stroke: var(--accent-ink); fill: none; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav button.link { padding: 6px 10px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 0.95rem; }
.nav a:hover, .nav button.link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--ink); background: var(--surface-2); }
main { max-width: 760px; margin: 0 auto; padding: 24px 16px 96px; }
.stack { display: grid; gap: 16px; }
.stack-lg { display: grid; gap: 28px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card.flat { box-shadow: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-weight: 650; cursor: pointer; text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 0.9rem; }
.btn.block { width: 100%; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--accent); font-weight: 600; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

/* Forms */
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 0.95rem; }
input[type="text"], textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); padding: 12px 14px; outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
textarea { resize: vertical; min-height: 120px; line-height: 1.45; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }

/* Composer */
.hero { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 8px 0 4px; }
.hero p { max-width: 34rem; }
.mic-wrap { display: grid; justify-items: center; gap: 10px; padding: 12px 0 4px; }
.mic {
  --level: 0;
  position: relative;
  width: 104px; height: 104px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform 0.1s ease, background 0.2s ease;
}
.mic svg { width: 40px; height: 40px; position: relative; z-index: 1; }
.mic::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  background: var(--accent-soft);
  transform: scale(calc(1 + var(--level) * 0.45));
  opacity: 0; transition: transform 0.08s linear, opacity 0.2s ease;
  z-index: 0;
}
.mic.recording::before { opacity: 1; }
.mic.recording { background: color-mix(in srgb, var(--accent) 85%, black); }
.mic.busy { opacity: 0.6; cursor: progress; }
.mic:active { transform: scale(0.97); }
.mic-label { font-weight: 650; min-height: 1.5em; }
.mic-label .timer { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font-size: 0.875rem; cursor: pointer;
}
.chip:hover { color: var(--ink); background: var(--surface-2); }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.work::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* App grid */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.app-card { display: grid; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.app-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.thumb { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.thumb .initials { font-size: 2rem; font-weight: 800; color: var(--faint); letter-spacing: -0.04em; }
.app-card .meta { padding: 12px 14px 14px; display: grid; gap: 4px; }
.app-card .meta .url { font-size: 0.8rem; color: var(--muted); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lists */
.list { display: grid; }
.list > * { padding: 12px 0; border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; }
.list a.item { color: var(--ink); display: grid; gap: 2px; font-weight: 500; }
.list a.item:hover { text-decoration: none; }
.list a.item:hover .title { color: var(--accent); }
.item .title { font-weight: 650; }
.clip { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Build page */
.quote { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; color: var(--ink); font-size: 1.05rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.stations { display: grid; gap: 0; }
.station { display: grid; grid-template-columns: 44px 1fr; gap: 14px; position: relative; padding-bottom: 18px; }
.station:not(:last-child)::after { content: ""; position: absolute; left: 21px; top: 46px; bottom: 2px; width: 2px; background: var(--line); }
.station.done:not(:last-child)::after { background: var(--ok); opacity: 0.5; }
.station .badge { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--faint); border: 2px solid transparent; }
.station .badge svg { width: 22px; height: 22px; }
.station.active .badge { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); animation: glow 1.6s ease-in-out infinite; }
.station.done .badge { background: var(--ok-soft); color: var(--ok); }
.station.stopped .badge { background: var(--bad-soft); color: var(--bad); }
@keyframes glow { 50% { box-shadow: 0 0 0 6px var(--accent-soft); } }
.station .body { display: grid; gap: 4px; min-width: 0; padding-top: 2px; }
.station .name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 750; }
.station .role { color: var(--muted); font-size: 0.9rem; }
.station .now { font-size: 0.92rem; color: var(--ink); overflow-wrap: anywhere; }
.station.active .now::before { content: "› "; color: var(--accent); font-weight: 800; }
.todos { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; font-size: 0.9rem; }
.todos li { display: grid; grid-template-columns: 18px 1fr; gap: 8px; color: var(--muted); }
.todos li.completed { color: var(--faint); text-decoration: line-through; }
.todos li.in_progress { color: var(--ink); font-weight: 600; }
.todos li::before { content: "○"; color: var(--faint); }
.todos li.completed::before { content: "✓"; color: var(--ok); text-decoration: none; }
.todos li.in_progress::before { content: "◐"; color: var(--accent); }
.issues { margin: 6px 0 0; padding-left: 18px; font-size: 0.9rem; color: var(--muted); display: grid; gap: 4px; }

.result { display: grid; gap: 14px; }
.result.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.result.bad { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.shot { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.shot img { display: block; width: 100%; height: auto; }
.big-link { font-size: 1.15rem; overflow-wrap: anywhere; }

details { border-top: 1px solid var(--line); padding-top: 12px; }
.spec details, .spec:empty + details { border-top: 0; padding-top: 0; }
.spec:empty { display: none; }
:is(strong, span) + .pill { margin-left: 8px; }
details > summary { cursor: pointer; font-weight: 650; color: var(--muted); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; }
details[open] > summary::before { content: "▾ "; }
.log { display: grid; gap: 6px; margin-top: 10px; font-size: 0.85rem; }
.log .line { display: grid; grid-template-columns: 74px 1fr; gap: 10px; color: var(--muted); }
.log .line .who { font-weight: 700; text-transform: capitalize; color: var(--faint); }
.log .line.error { color: var(--bad); }
.md { display: grid; gap: 8px; font-size: 0.95rem; margin-top: 10px; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { font-size: 1rem; margin-top: 6px; }
.md ul, .md ol { margin: 0; padding-left: 20px; display: grid; gap: 2px; }
.md code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* Misc */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); z-index: 50;
}
.toast.bad { background: var(--bad); color: #fff; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 0.85rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.stat .n { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.stat .l { color: var(--muted); font-size: 0.85rem; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; min-height: 40vh; }

@media (max-width: 480px) {
  main { padding-top: 16px; }
  .card { padding: 16px; }
  .nav a, .nav button.link { padding: 6px 8px; font-size: 0.9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
