/* Baton — one stylesheet, two layouts.
   COMPACT (default): the phone. One column, one card, thumb-reachable.
   ROOMY (min-width: 768px): iPad + desktop. Queue list beside the card.
   Everything else scales. */

:root {
  --bg: #faf9f7; --bg-2: #ffffff; --bg-3: #f1efeb;
  --ink: #1a1a1a; --ink-2: #5b5852; --ink-3: #8b877f; --line: #e6e2dc;
  --accent: #0f6e6e; --accent-ink: #fff; --accent-soft: #e3f1f0;
  --halt: #b45309; --halt-soft: #fff4e5; --halt-line: #f2c58a;
  --ok: #1f7a3a; --ok-soft: #e6f4ea; --no: #a12d2d; --no-soft: #fbe9e9;
  --nathan: #0f6e6e; --voice: #6d3fb0; --code: #2757a8; --huginn: #8a5a12; --ask: #a06b00; --down: #6b6b6b;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px -12px rgba(30,25,15,.18);
  --nav-h: 56px; --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151413; --bg-2: #1e1d1b; --bg-3: #262523;
    --ink: #eeeae3; --ink-2: #b8b3aa; --ink-3: #807b73; --line: #33312e;
    --accent: #4fb3b0; --accent-ink: #0d1b1b; --accent-soft: #163333;
    --halt: #f0a44a; --halt-soft: #2c2114; --halt-line: #6b4a1c;
    --ok: #62c481; --ok-soft: #14301c; --no: #e57373; --no-soft: #331b1b;
    --nathan: #4fb3b0; --voice: #b493e6; --code: #7ea6ec; --huginn: #d4a24b; --ask: #e0b24a; --down: #9a9a9a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -14px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  min-height: 100dvh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -.01em; }
code { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg-3); padding: 1px 5px; border-radius: 5px; }
input, textarea, select, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=number], input:not([type]), textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }
select { width: auto; }
.main { padding: 14px var(--gutter) 24px; max-width: 720px; margin: 0 auto; }
.muted { color: var(--ink-2); } .small { font-size: 13px; } .pad { padding: 16px 4px; }
.meta { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.meta.link { color: var(--accent); }
.err { color: var(--no); background: var(--no-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.big { font-size: 20px; }

/* ---- busy + flash ---- */
.busy { position: fixed; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--accent), transparent); opacity: 0; transition: opacity .2s; z-index: 50; }
.htmx-request .busy, .busy.htmx-request { opacity: 1; animation: slide 1s linear infinite; }
@keyframes slide { from { background-position: -200px 0 } to { background-position: 200px 0 } }
.flash { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 60; max-width: 90vw; text-align: center; }
.flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- nav: bottom tab bar (compact) ---- */
.nav { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; justify-content: space-around; align-items: stretch; background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-top: 1px solid var(--line); z-index: 40; }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--ink-3); font-size: 11px; text-decoration: none; }
.nav a .ic, .nav a .glyph { font-size: 20px; line-height: 1; }
.nav a.on { color: var(--accent); }
.nav .brand .glyph { color: var(--accent); }

/* ---- count strip ---- */
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.strip::-webkit-scrollbar { display: none; }
.pill { flex: 1 0 auto; display: flex; align-items: baseline; gap: 6px; padding: 8px 12px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; min-width: 72px; justify-content: center; }
.pill .n { font-weight: 700; font-size: 18px; color: var(--ink); }
.pill .w { font-size: 12.5px; }
.pill.on { border-color: var(--lane, var(--accent)); box-shadow: inset 0 0 0 1px var(--lane, var(--accent)); }
.pill:hover { text-decoration: none; border-color: var(--lane, var(--accent)); }
.lane-awaiting-nathan { --lane: var(--nathan); } .lane-awaiting-voice { --lane: var(--voice); }
.lane-awaiting-claude-code { --lane: var(--code); } .lane-awaiting-huginn { --lane: var(--huginn); }
.lane-awaiting-huginn-ask { --lane: var(--ask); } .lane-baton-down { --lane: var(--down); }
.pill .n { color: var(--lane, var(--ink)); }

/* ---- tags ---- */
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .01em; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag[class*="lane-"] { background: color-mix(in srgb, var(--lane) 14%, transparent); color: var(--lane); }
.tag.dim { background: var(--bg-3); color: var(--ink-2); font-weight: 500; }
.tag.warn { background: var(--halt-soft); color: var(--halt); }
.tag.t-live { background: var(--ok-soft); color: var(--ok); }
.tag.t-perm { background: var(--ok-soft); color: var(--ok); } .tag.t-disc { background: var(--halt-soft); color: var(--halt); }

/* ---- the card ---- */
.stage { margin-top: 6px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 14px; box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.card-head .meta { margin-left: auto; }
.card-title { font-size: 21px; margin-bottom: 8px; }
.card-title a { color: inherit; }
.ask { font-size: 16.5px; color: var(--ink); margin: 0 0 14px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--ink); cursor: pointer; text-decoration: none; font-weight: 550; line-height: 1.2; min-height: 42px; transition: transform .06s, background .12s; }
.btn:hover { text-decoration: none; background: var(--bg-3); } .btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 13.5px; border-radius: 10px; }
.btn.big { width: 100%; min-height: 52px; font-size: 17px; }
.btn.yes { background: var(--ok-soft); color: var(--ok); border-color: transparent; flex: 1; }
.btn.no { background: var(--no-soft); color: var(--no); border-color: transparent; flex: 1; }
.btn[class*="lane-"] { color: var(--lane); border-color: color-mix(in srgb, var(--lane) 35%, transparent); }
.sub { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); display: grid; gap: 8px; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; }
.days { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--ink-2); font-size: 14px; }
.days input { width: 68px; padding: 8px 10px; }
.stepper { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 14px; }
.stepper .step { min-height: 52px; font-size: 18px; }
.stepper .step:last-child { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.stepper .count { color: var(--ink-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 48px 12px; }

/* ---- halted / run-blocked ---- */
.pinned { margin: 0 0 14px; }
.pinned-h { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--halt); display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pinned-h .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--halt); box-shadow: 0 0 0 4px color-mix(in srgb, var(--halt) 25%, transparent); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--halt) 8%, transparent); } }
.rb { background: var(--halt-soft); border: 1px solid var(--halt-line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.rb-head { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; } .rb-head .meta:first-of-type { margin-left: auto; }
.rb-q { font-size: 17px; margin-bottom: 8px; }
.rb-form { display: grid; gap: 8px; margin-top: 8px; }
.more { font-size: 13px; color: var(--ink-2); } .more summary { cursor: pointer; padding: 8px 4px; list-style: none; } .more summary::-webkit-details-marker { display: none; }
.more input { margin-top: 6px; }
.rb.htmx-swapping { opacity: 0; transform: translateY(-6px); transition: all .2s; }

/* ---- lane page ---- */
.lane-bar { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; flex-wrap: wrap; }
.lane-h { font-size: 22px; flex: 1; }
.lane-h .muted { font-weight: 500; font-size: 16px; }
.seg { display: inline-flex; background: var(--bg-3); border-radius: 999px; padding: 3px; }
.seg a { padding: 5px 12px; border-radius: 999px; color: var(--ink-2); font-size: 14px; text-decoration: none; }
.seg a.on { background: var(--bg-2); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.list li a, .list li.pad-row { display: grid; gap: 2px; padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; }
.list li.pad-row { grid-template-columns: 1fr auto; align-items: center; }
.list li a:hover { border-color: var(--accent); }
.list li.on a { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.list li.rb a { background: var(--halt-soft); border-color: var(--halt-line); }
.list .t { font-weight: 600; } .list .s { color: var(--ink-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.list .m { color: var(--ink-3); font-size: 12px; }
.lane-body.card .list[data-roomy-only] { display: none; }

/* ---- doc ---- */
.doc-head { margin-bottom: 14px; } .doc-head h1 { font-size: 26px; margin: 8px 0 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.doc-actions { margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.doc-actions .sub, .doc-actions #doc-flash { flex-basis: 100%; }
.prose { font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.prose h1 { font-size: 22px; margin: 22px 0 8px; } .prose h2 { font-size: 19px; margin: 22px 0 8px; } .prose h3 { font-size: 16.5px; margin: 18px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; } .prose li { margin: 2px 0; }
.prose blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--ink-2); background: var(--bg-3); border-radius: 0 8px 8px 0; }
.prose pre { background: var(--bg-3); padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 0 0 14px; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.prose th { background: var(--bg-3); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.prose input[type=checkbox] { width: auto; margin-right: 6px; }
.fields { margin-top: 20px; font-size: 14px; } .fields summary { cursor: pointer; color: var(--ink-2); }
.fields dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 10px 0 0; } .fields dt { color: var(--ink-3); } .fields dd { margin: 0; overflow-wrap: anywhere; }
.tablewrap { overflow-x: auto; } .tablewrap table { border-collapse: collapse; width: 100%; font-size: 13.5px; margin-top: 8px; }
.tablewrap th, .tablewrap td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: right; } .tablewrap th:first-child, .tablewrap td:first-child { text-align: left; }

/* ---- search ---- */
.search input { font-size: 17px; padding: 14px 16px; border-radius: 14px; }
.results { margin-top: 12px; }

/* ---- alerts ---- */
.alerts { display: grid; gap: 10px; }
.alert { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.alert .card-title { font-size: 18px; }
.figures { margin: 4px 0 8px; font-size: 15px; }
.remarks { color: var(--ink-2); font-size: 14px; margin: 0 0 10px; }
.links { align-items: center; } .links .meta { margin-left: auto; }

/* ---- auth ---- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: calc(100dvh - var(--nav-h)); }
.auth { width: min(100%, 380px); text-align: center; display: grid; gap: 14px; }
.auth .mark { font-size: 44px; color: var(--accent); }
.auth h1 { font-size: 26px; }
.stack { display: grid; gap: 10px; }

/* ================= ROOMY: iPad + desktop ================= */
@media (min-width: 768px) {
  :root { --gutter: 24px; }
  body { padding-bottom: 0; padding-top: var(--nav-h); }
  .nav { top: 0; bottom: auto; border-top: 0; border-bottom: 1px solid var(--line); justify-content: flex-start; padding: 0 24px; gap: 4px; }
  .nav a { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 0 12px; font-size: 14px; }
  .nav a .ic, .nav a .glyph { font-size: 17px; }
  .nav .brand { margin-right: 12px; font-weight: 700; font-size: 16px; color: var(--ink); }
  .nav .brand .word { font-size: 16px; }
  .main { max-width: 1080px; padding-top: 22px; }
  .home { max-width: 760px; }
  .strip { gap: 10px; }
  .pill { flex: 0 1 auto; min-width: 110px; }
  .card { padding: 24px 26px 18px; }
  .card-title { font-size: 24px; }
  .stepper { grid-template-columns: auto 1fr auto; }
  .stepper .step { min-width: 120px; }
  .flash { bottom: auto; top: calc(var(--nav-h) + 14px); }
  /* queue list beside the card */
  .lane-body.card { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 20px; align-items: start; }
  .lane-body.card .list[data-roomy-only] { display: grid; max-height: calc(100dvh - 200px); overflow: auto; padding-right: 2px; }
  .lane-body.card .list .s { -webkit-line-clamp: 1; }
  .doc-page { max-width: 860px; }
  .alerts { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
  .auth-page { min-height: calc(100dvh - var(--nav-h) - 60px); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
