/* =====================================================================
   opencode companion — app styling (mirrors the main-site visual language)
   Light surfaces, navy text, blue accents, rounded cards, soft shadows.
   ===================================================================== */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --border: #e2e8f2;
  --border-strong: #c8d2e3;
  --fg: #17233c;
  --muted: #5a6b85;
  --muted-2: #71809a;
  --accent: #285ac5;
  --accent-hover: #1f4da9;
  --accent-soft: #eaf0fb;
  --green: #1a7f37;
  --green-bg: #e6f4ea;
  --red: #c62828;
  --red-bg: #fdecea;
  --amber: #b7791f;
  --amber-bg: #fdf4e3;
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(var(--shadow-rgb),.05), 0 8px 24px rgba(var(--shadow-rgb),.06);
  --shadow-rgb: 23,35,60;
  --surface-rgb: 255,255,255;
  --surface-3: #f4f6fb;
  --accent-solid: var(--accent);
  --accent-solid-hover: var(--accent-hover);
  --accent-rgb: 40,90,197;
  --danger-border: #ecc3c3;
  --notice-border: #f0dcb0;
  --focus-ring: 0 0 0 3px rgba(40,90,197,.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.45; margin: 6px 0 0; }

/* ---------- skeleton placeholders ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 12px; margin: 8px 0; }
.skeleton-title { height: 16px; width: 55%; margin: 8px 0; }
.skeleton-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.skeleton-row:first-child { border-top: none; }
.skeleton-avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.skeleton-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.skeleton-panel { padding: 14px; }
.skeleton-panel + .skeleton-panel { margin-top: 14px; }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
}

/* ---------- empty states ---------- */
.empty-state {
  text-align: center;
  padding: 28px 14px;
}
.empty-state p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}
.empty-state .primary { margin-top: 4px; }

/* ---------- app header (sticky: brand + module tabs) ---------- */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.hdr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}
.hdr-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--fg);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.hdr-mark { font-size: 16px; color: var(--accent); }
.hdr-mod {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.hdr-right { display: flex; align-items: center; gap: 8px; }
.hdr-sys { font-size: 11px; font-weight: 700; color: var(--green); }
.hdr-code {
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 11px;
  padding: 2px 10px;
}

/* ---------- module tabs (underline) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
  padding: 8px 0 0;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 6px;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--accent-hover); }

/* ---------- main ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px 40px;
}
.view { display: none; }
.view.active { display: block; }

.mod-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 2px 8px;
  margin: 0 0 4px;
}
.mod-head a { color: var(--accent); font-size: 12px; font-weight: 600; text-decoration: none; }
.mod-head a:hover { text-decoration: underline; }

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.panel-head {
  background: transparent;
  color: var(--fg);
  font-size: 13px;
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.panel-body { padding: 14px; }

/* ---------- sub-tabs ---------- */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.sub-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
}
.sub-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.sub-panel { display: none; }
.sub-panel.active { display: block; }

/* ---------- forms / inputs ---------- */
input[type="text"], input[type="password"], input[type="number"], textarea {
  width: 100%;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;               /* >= 16px prevents iOS auto-zoom */
  padding: 10px 12px;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-solid);
  box-shadow: var(--focus-ring);
}
input:focus-visible, textarea:focus-visible, select:focus-visible,
button:focus-visible, .btn:focus-visible,
.tab:focus-visible, .sub-tab:focus-visible, .req-type:focus-visible,
.landing-mode-btn:focus-visible, .fresh-device-btn:focus-visible,
.log-item:focus-visible, .card summary:focus-visible,
.checklist-go:focus-visible, .cfg-group-toggle:focus-visible,
.proj-ledger:focus-visible, .pricing-cta:focus-visible,
.landing-primary:focus-visible, .landing-secondary:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
select {
  width: 100%;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
}
label { font-size: 12px; color: var(--muted); }

/* ---------- buttons ---------- */
button, .btn {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; }
.primary {
  background: var(--accent-solid);
  color: #fff;
  border-color: var(--accent-solid);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb),.18);
}
.primary:hover { background: var(--accent-solid-hover); border-color: var(--accent-solid-hover); }
.danger { color: var(--red); border-color: var(--danger-border); }
.danger:hover { background: var(--red-bg); }
.ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--muted); }
.ghost:hover { background: var(--surface-2); }

.btn-row { display: flex; gap: 8px; align-items: center; margin: 10px 0 0; }
.btn-row:first-child { margin-top: 0; }

/* Ensure every interactive control is a 44px tap target on small screens. */
button, .btn, input, textarea, select,
.tab, .sub-tab, .req-type,
.landing-mode-btn, .fresh-device-btn,
.log-item, .card summary,
.checklist-go, .cfg-group-toggle,
.proj-ledger, .pricing-cta,
.landing-primary, .landing-secondary {
  min-height: 44px;
  min-width: 44px;
}
input[type="checkbox"], input[type="radio"] { min-height: auto; min-width: auto; }
.card summary { min-height: 44px; }
.checklist-go { min-height: 44px; min-width: 44px; }
.hdr-code { min-height: 24px; min-width: auto; }
.conn-pill { min-height: 24px; min-width: auto; }
.badge { min-height: 18px; min-width: auto; }
.tab-badge { min-height: 16px; min-width: 16px; }
.btn-row select { flex: 1; }
.btn-row input { flex: 1; }
.btn-row button { flex: none; }
.btn-row a { color: var(--accent); font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.muted-row { justify-content: space-between; }
.picker-row { display: flex; gap: 8px; }

/* ---------- notice ---------- */
.notice {
  background: var(--amber-bg);
  border: 1px solid var(--notice-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 12px;
}
.notice .hint { margin: 0 0 10px; }

/* ---------- lists / cards ---------- */
.list { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.list > * + * { border-top: 1px solid var(--border); }

.card summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  font-size: 13px;
  background: var(--surface);
}
.card summary::-webkit-details-marker { display: none; }
.card summary::before { content: "›"; font-size: 14px; color: var(--muted-2); flex: none; transform: rotate(0deg); transition: transform .12s ease; }
.card[open] summary::before { transform: rotate(90deg); }
.card[open] summary { background: var(--surface-2); }
.card summary .card-title { font-weight: 600; word-break: break-word; flex: 1; }
.card-body {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  line-height: 1.55;
}
.card-text { margin: 2px 0; white-space: pre-wrap; word-break: break-word; }
.card-h { font-size: 11px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; }
.card-ul { margin: 0 0 0 18px; padding: 0; }
.card-ul li { margin: 3px 0; }
.card-body a { color: var(--accent); font-size: 12.5px; }
.card-pr { margin: 8px 0 0; }
.card-pr a { font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}
.badge.ok { color: var(--green); background: var(--green-bg); }
.badge.warn { color: var(--amber); background: var(--amber-bg); }

/* ---------- connection pill + recovery card (Home) ---------- */
.conn-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  flex: none;
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.conn-pill--connected { color: var(--green); background: var(--green-bg); }
.conn-pill--device-offline { color: var(--amber); background: var(--amber-bg); }
.conn-pill--relay-unreachable { color: var(--red); background: var(--red-bg); }
.conn-recovery { padding-top: 8px; }
.conn-recovery-title { margin: 0 0 6px; font-weight: 600; }
.conn-recovery .card-ul { margin-bottom: 8px; }

/* ---------- approvals (destructive-action gate) ---------- */
.tab-badge {
  display: inline-block;
  min-width: 16px;
  padding: 0 5px;
  margin-left: 4px;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  border-radius: 999px;
  color: #fff;
  background: var(--amber);
}
.tab-badge.hidden { display: none; }
.approval-item { padding: 12px 14px; }
.approval-head { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; }
.approval-cmd {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- request type segmented buttons ---------- */
.req-types { display: flex; margin: 0 0 14px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; }
.req-type {
  flex: 1;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 4px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
}
.req-type.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(var(--shadow-rgb),.12); }

/* ---------- config ---------- */
.cfg-sec {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 18px 0 8px;
}
.cfg-sec:first-child { margin-top: 0; }
.cfg-note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fg);
  margin: 0 0 12px;
}
.cfg-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.cfg-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.gh-code {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.6;
}
.gh-code strong { font-size: 18px; letter-spacing: 2px; }
.cfg-check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 12px 0; color: var(--fg); }
.cfg-check input { width: auto; }
#config-form button[type="submit"] { margin-top: 14px; }

.cfg-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.cfg-step { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 12px; }
.cfg-step-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.cfg-step-label { font-size: 13px; font-weight: 600; color: var(--fg); }
.cfg-step-row { display: flex; flex-direction: column; gap: 10px; }
.cfg-step-row label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.cfg-step-row .cfg-check { margin: 0; font-size: 13px; color: var(--fg); }

/* read-only config values */
.cfg-val { font-family: var(--mono); color: var(--fg); font-weight: 500; font-size: 13px; }
.cfg-step-facts { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.cfg-step-facts strong { color: var(--fg); font-weight: 600; }

/* ---------- config groups (Everyday / Advanced) ---------- */
.cfg-group { margin-bottom: 14px; }
.cfg-group-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0 0 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg);
  cursor: pointer;
}
.cfg-group-toggle:hover { color: var(--accent); }
.cfg-group-icon {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted-2);
  transition: transform .18s ease;
}
.cfg-group-toggle.collapsed .cfg-group-icon { transform: rotate(-90deg); }
.cfg-group-body { padding-top: 10px; }
.cfg-group-body .cfg-sec:first-child { margin-top: 0; }
.cfg-group-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

/* ---------- ledger ---------- */
.ledger-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
#ledger-content { min-height: 20vh; white-space: pre; font-family: var(--mono); font-size: 13px; }

.ledger-add { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.ledger-add input { flex: 1 1 100%; min-width: 0; }
.ledger-add select { flex: 1 1 auto; min-width: 0; }
.ledger-add button { flex: 0 0 auto; }

.ledger-rows { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.ledger-rows .hint { margin: 10px 12px; }

.ledger-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
}
.ledger-row:first-child { border-top: none; }
.ledger-row-text { flex: 1; min-width: 0; word-break: break-word; line-height: 1.45; }
.ledger-row.done .ledger-row-text { text-decoration: line-through; color: var(--muted); }
.ledger-row.progress .ledger-row-text { color: var(--muted); }
.ledger-row-actions { display: flex; gap: 6px; flex: none; }
.ledger-row-btn { font-size: 11px; padding: 5px 10px; }
.ledger-row.editing { gap: 6px; }
.ledger-row-input { flex: 1; min-width: 0; }
.ledger-row.editing .ledger-row-btn { flex: none; }

#ledger-lists .cfg-sec .hint { font-size: 10px; font-weight: 400; letter-spacing: 0; text-transform: none; }

.raw-ledger { margin-top: 14px; }
.raw-ledger summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.raw-ledger form { margin-top: 10px; }

/* ---------- review / sessions ---------- */
.review-steps { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.step { border-top: 1px solid var(--border); padding: 10px 12px; }
.step:first-child { border-top: none; }
.step-kind { font-size: 10.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.step-text, .step-args {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 8px 10px;
}
.step-reasoning { background: var(--surface-3); }
.step-user { background: var(--accent-soft); }
.step-tool .step-kind { color: var(--accent); }

.review-diff { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.diff-file { border-top: 1px solid var(--border); }
.diff-file:first-child { border-top: none; }
.diff-file-head { display: flex; align-items: center; gap: 8px; background: var(--surface-2); padding: 7px 12px; font-size: 12px; border-bottom: 1px solid var(--border); }
.diff-name { font-weight: 600; word-break: break-all; flex: 1; }
.diff-lines {
  margin: 0;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 40vh;
  overflow-y: auto;
}
.diff-add { background: var(--green-bg); color: var(--green); display: inline-block; width: 100%; }
.diff-del { background: var(--red-bg); color: var(--red); display: inline-block; width: 100%; }
.diff-hunk { color: var(--accent); }
.diff-ctx { color: var(--muted); }
.diff-stat-add { color: var(--green); font-weight: 700; }
.diff-stat-del { color: var(--red); font-weight: 700; }

/* ---------- log / transcripts ---------- */
.log-item {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  color: var(--fg);
  border: none;
  border-radius: 0;
  box-shadow: none;
  font-size: 13px;
  font-weight: 400;
  padding: 12px;
}
.log-item:hover { background: var(--surface-2); }
.log-viewer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 9px 12px;
  margin-top: 12px;
}
.log-content {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 70vh;
  overflow-y: auto;
  padding: 12px;
  margin: 0;
}

/* ---------- install hint ---------- */
.install-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--amber-bg);
  border-bottom: 1px solid var(--notice-border);
  color: var(--fg);
  font-size: 12.5px;
  padding: 10px 14px;
}
.install-hint-text { flex: 1; line-height: 1.45; }
.install-hint-text strong { color: var(--amber); }
.install-hint button { font-size: 12px; padding: 6px 12px; }

/* ---------- first-run checklist (non-blocking onboarding banner) ---------- */
.checklist {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.checklist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  max-width: 680px;
  margin: 0 auto;
}
.checklist-title { font-size: 13px; font-weight: 700; color: var(--fg); }
.checklist-progress { color: var(--muted); font-weight: 500; font-size: 12px; margin-left: 6px; }
.checklist-list {
  list-style: none;
  margin: 8px auto 0;
  padding: 0;
  max-width: 680px;
  display: grid;
  gap: 4px;
}
.checklist-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}
.checklist-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-strong);
  flex: none;
}
.checklist-step.done .checklist-dot { background: var(--green); }
.checklist-step.done .checklist-label { text-decoration: line-through; }
.checklist-go { margin-left: auto; font-size: 11.5px; padding: 3px 10px; }

/* ---------- footer status bar ---------- */
.statusbar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px max(16px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  font-size: 12px;
  color: var(--muted);
}
.sb-label { color: var(--muted-2); font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; margin-right: 6px; }
.sb-right { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* ---------- project cards + wizard + spend ---------- */
.proj-grid { display: grid; gap: 10px; padding: 4px 0; }
.wz-head { cursor: pointer; }
.wz-head::marker { content: ""; }
.wz-head::before { content: "＋ "; }
.ledger-proj { display: flex; align-items: center; gap: 8px; margin: 0; }
.ledger-proj select { flex: 1; }
.proj-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
.proj-row a.ghost { font-size: 12.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.proj-spend { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }
.proj-spend .mono { width: 40px; text-align: right; }
.meter {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.meter i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.meter.full i { background: var(--red); }
.proj-budget {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}
.proj-budget label { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); }
.proj-budget input { width: 76px; }
.proj-budget select { flex: none; }
.proj-budget .hint { margin-left: auto; }

/* ---------- misc ---------- */
#proj-link { font-size: 12px; }

/* =====================================================================
   Public welcome page
   ===================================================================== */
.public-landing { display: none; }
body.public-home {
  display: block;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
body.public-home .app-header,
body.public-home > main,
body.public-home .statusbar,
body.public-home .install-hint,
body.public-home .checklist { display: none !important; }
body.public-home #public-landing { display: block; }
.landing-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px max(24px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--border);
  background: rgba(var(--surface-rgb),.92);
}
.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--fg);
  text-decoration: none;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.04em;
}
.landing-brand strong { font-weight: 750; }
.landing-mark { color: var(--accent); font-size: 22px; }
.landing-nav-link { color: var(--muted); font-size: 14px; text-decoration: none; }
.landing-nav-link:hover, .landing-footer a:hover { color: var(--accent-hover); text-decoration: underline; }
.landing-main { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.landing-hero { max-width: 790px; margin: 0 auto; padding: clamp(68px, 10vw, 124px) 0 72px; text-align: center; }
.landing-kicker { margin: 0 0 18px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.landing-hero h1 { margin: 0; color: var(--fg); font-size: clamp(42px, 7vw, 72px); line-height: 1.04; letter-spacing: -.065em; }
.landing-hero h1 span { color: var(--accent); }
.landing-lead { max-width: 650px; margin: 24px auto 0; color: var(--muted); font-size: clamp(16px, 2vw, 19px); line-height: 1.65; }
.landing-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px; margin-top: 32px; }
.landing-primary, .landing-setup-form button {
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 22px;
  border: 1px solid var(--accent-solid-hover);
  border-radius: 7px;
  background: var(--accent-solid);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(var(--accent-rgb),.18);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.landing-primary:hover, .landing-setup-form button:hover { transform: translateY(-1px); background: var(--accent-solid-hover); box-shadow: 0 9px 20px rgba(var(--accent-rgb),.24); }
.landing-secondary { padding: 12px 4px; color: var(--accent); font-size: 14px; font-weight: 650; text-decoration: none; }
.landing-secondary:hover { text-decoration: underline; }
.landing-caption { margin: 14px 0 0; color: var(--muted-2); font-size: 12px; }
.landing-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding-bottom: 68px; }
.landing-step { min-height: 190px; padding: 24px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: 0 8px 24px rgba(var(--shadow-rgb),.04); }
.step-number { display: inline-block; color: var(--accent); font: 700 12px var(--mono); letter-spacing: .12em; }
.landing-step h2 { margin: 20px 0 8px; color: var(--fg); font-size: 17px; letter-spacing: -.025em; }
.landing-step p, .landing-connect p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.landing-connect { display: flex; align-items: center; justify-content: space-between; gap: 32px; margin: 0 0 54px; padding: 28px 30px; border: 1px solid var(--border); border-radius: 9px; background: var(--accent-soft); }
.landing-connect .landing-kicker { margin-bottom: 8px; font-size: 10px; }
.landing-connect h2 { margin: 0 0 7px; color: var(--fg); font-size: 23px; letter-spacing: -.04em; }
.landing-setup { width: min(100%, 390px); }
.landing-setup-form { display: grid; grid-template-columns: 1fr; gap: 8px; }
.landing-setup-form input { min-width: 0; height: 46px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--fg); font: 500 14px var(--mono); letter-spacing: .03em; }
.landing-setup-form input:focus { outline: 3px solid rgba(var(--accent-rgb),.22); border-color: var(--accent-solid); }
.landing-setup-form button { min-height: 46px; font-size: 14px; }
.landing-setup-step { display: grid; gap: 10px; }
.setup-code { margin: 0; padding: 14px; border: 1px dashed var(--accent); border-radius: 6px; background: var(--surface); font: 600 13px/1.5 var(--mono); letter-spacing: .04em; word-break: break-all; white-space: pre-wrap; color: var(--accent-hover); }
.landing-error { grid-column: 1 / -1; min-height: 18px; color: var(--red) !important; font-size: 12px !important; }
.landing-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 18px 0 28px; border-top: 1px solid var(--border); color: var(--muted-2); font-size: 12px; }
.landing-footer a { color: var(--muted); text-decoration: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
  .landing-header { min-height: 64px; padding: 12px 18px; }
  .landing-main { padding: 0 18px; }
  .landing-hero { padding: 72px 0 56px; }
  .landing-steps { grid-template-columns: 1fr; gap: 10px; padding-bottom: 46px; }
  .landing-step { min-height: 0; padding: 20px; }
  .landing-step h2 { margin-top: 14px; }
  .landing-connect { align-items: stretch; flex-direction: column; gap: 18px; padding: 22px 18px; }
  .landing-setup { width: 100%; }
}
@media (max-width: 430px) {
  .tabs { flex-wrap: wrap; gap: 4px; padding-bottom: 8px; }
  .tab {
    flex: 1 1 28%;
    min-width: 80px;
    font-size: 12px;
    padding: 10px 4px;
    border-bottom: none;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
  }
  .tab.active { background: var(--accent-soft); color: var(--accent); }
}
@media (max-width: 360px) {
  .hdr-mod { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .landing-primary, .landing-setup-form button, .card summary::before { transition: none; }
}

/* ---------- fresh-device (boot from USB) section ---------- */
.fresh-intro { max-width: 560px; }
.fresh-intro .landing-kicker { margin-bottom: 8px; font-size: 10px; }
.fresh-intro h2 { margin: 0 0 7px; color: var(--fg); font-size: 23px; letter-spacing: -.04em; }
.fresh-intro p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.fresh-actions { display: flex; flex-direction: column; gap: 14px; width: min(100%, 460px); }
.fresh-device { display: flex; gap: 4px; background: var(--surface-2); border-radius: 7px; padding: 3px; }
.fresh-device-btn {
  flex: 1; background: transparent; border: none; border-radius: 5px;
  font: 600 13px var(--font); color: var(--muted); padding: 8px 6px; cursor: pointer;
}
.fresh-device-btn.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(var(--shadow-rgb),.12); }
.fresh-steps h3 { margin: 14px 0 4px; color: var(--fg); font-size: 13px; }
.fresh-steps p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.55; }
.fresh-ul { margin: 6px 0 0 18px; padding: 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.fresh-ul li { margin: 3px 0; }
.fresh-ul code { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); border-radius: 4px; padding: 1px 5px; }
.fresh-boot.hidden { display: none; }
@media (max-width: 700px) {
  .fresh-actions { width: 100%; }
}

/* ---------- chat (primary surface) ---------- */
.chat-panel { display: flex; flex-direction: column; height: calc(100dvh - 230px); min-height: 300px; padding: 0; overflow: hidden; }
.chat-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 86%; display: flex; }
.chat-msg.user { align-self: flex-end; }
.chat-msg.agent { align-self: flex-start; }
.chat-bubble {
  padding: 9px 13px; border-radius: 15px; font-size: 14.5px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.chat-msg.user .chat-bubble { background: var(--accent-solid); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg.agent .chat-bubble { background: var(--surface-2); border: 1px solid var(--border); color: var(--fg); border-bottom-left-radius: 4px; }
.chat-msg.agent.error .chat-bubble { border-color: var(--danger-border); background: var(--red-bg); color: var(--red); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-form input { flex: 1; min-width: 0; }
.chat-form button { flex: none; }

/* ---------- landing mode toggle (set up / sign in) ---------- */
.landing-mode { display: flex; gap: 4px; background: var(--surface-2); border-radius: 7px; padding: 3px; margin-bottom: 10px; }
.landing-mode-btn {
  flex: 1; background: transparent; border: none; border-radius: 5px;
  font: 600 13px var(--font); color: var(--muted); padding: 8px 6px; cursor: pointer;
}
.landing-mode-btn.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(var(--shadow-rgb),.12); }

/* ---------- pricing / plans ---------- */
.landing-pricing { padding: 8px 0 64px; text-align: center; }
.landing-pricing h2 { margin: 0 0 26px; color: var(--fg); font-size: clamp(24px, 4vw, 34px); letter-spacing: -.04em; }
.pricing-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.pricing-slot {
  padding: 26px 22px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); box-shadow: 0 8px 24px rgba(var(--shadow-rgb),.05); text-align: left;
}
.pricing-slot h3 { margin: 0 0 10px; color: var(--fg); font-size: 17px; }
.pricing-price { font-size: 34px; font-weight: 750; color: var(--fg); letter-spacing: -.03em; }
.pricing-period { font-size: 14px; font-weight: 500; color: var(--muted); }
.pricing-blurb { margin: 8px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.pricing-slot ul { margin: 0 0 18px; padding: 0; list-style: none; }
.pricing-slot li { color: var(--muted); font-size: 13px; line-height: 1.9; }
.pricing-slot li::before { content: "✓ "; color: var(--green); font-weight: 700; }
.pricing-cta { width: 100%; }
.landing-pricing .landing-caption a { color: var(--accent); }
@media (max-width: 700px) {
  .pricing-grid { grid-template-columns: 1fr; gap: 12px; }
}

/* =====================================================================
   Dark mode override
   ===================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f19;
    --surface: #151b2b;
    --surface-2: #1e263a;
    --surface-3: #232c42;
    --surface-rgb: 21,27,43;
    --border: #2a3550;
    --border-strong: #3b4a6f;
    --fg: #e8ecf5;
    --muted: #9aa8c6;
    --muted-2: #7f8fb3;
    --accent: #5c9aff;
    --accent-hover: #8ab4ff;
    --accent-soft: #162244;
    --accent-solid: #285ac5;
    --accent-solid-hover: #1f4da9;
    --accent-rgb: 40,90,197;
    --green: #3cb371;
    --green-bg: #0f2a1a;
    --red: #ff6b6b;
    --red-bg: #2a1010;
    --amber: #f0b429;
    --amber-bg: #2d220a;
    --danger-border: #5a2a2a;
    --notice-border: #5c4a20;
    --focus-ring: 0 0 0 3px rgba(92,154,255,.25);
    --shadow-rgb: 0,0,0;
  }

  body.public-home { background: var(--bg); color: var(--fg); }
}

/* ===== Connections (GitHub + model providers) ===== */
.conn-row { border-top: 1px solid var(--border); padding: 12px 0; }
.conn-row:first-of-type { border-top: 0; padding-top: 0; }
.conn-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.conn-name { font-weight: 600; font-size: 14px; color: var(--fg); }
.conn-state {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.conn-state.on { color: var(--green); background: var(--green-bg); border-color: transparent; }
.prov-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.prov-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); }
.prov-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prov-name { font-weight: 600; font-size: 13px; color: var(--fg); }
.prov-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.prov-actions .prov-key {
  flex: 1; min-width: 0; min-height: 36px; padding: 6px 10px; font-size: 13px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
}
.prov-actions .prov-key:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring, 0 0 0 3px rgba(40,90,197,.18)); }
.prov-actions button { min-height: 36px; flex: none; }
