/* HQ: one stylesheet. Colors and fonts come from /theme.css (generated from the profile's
   brand), so the same rules dress any business. Mobile-first. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--font-text); -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
svg.ico { width: 18px; height: 18px; flex: none; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-text); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
::selection { background: var(--highlight); color: var(--highlight-ink); }

h1, h2, h3 { margin: 0; line-height: 1.15; }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.01em; }
.mono, code, kbd, .ref { font-family: var(--font-mono); }
.label {
  font: 500 11px/1.2 var(--font-mono); text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.stack.tight { gap: 8px; }
.stack.loose { gap: 22px; }
.grow { flex: 1 1 auto; min-width: 0; }
.wrap-anywhere { overflow-wrap: anywhere; }

/* ---- Buttons ---------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 15px;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent-btn); border-color: var(--accent-btn); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent-btn) 88%, var(--ink)); color: var(--accent-ink); }
.btn.big { min-height: 54px; padding: 0 28px; font-size: 17px; }
.btn.small { min-height: 34px; padding: 0 13px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.danger { color: var(--danger); }
.btn.highlight { background: var(--highlight); border-color: var(--highlight); color: var(--highlight-ink); }
.btn .ico { width: 18px; height: 18px; flex: none; }
.linkish { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: 15px; }
.linkish:hover { color: var(--ink); }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 999px; border: 0; background: transparent; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: var(--sunk); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---- Forms ------------------------------------------------------------------------ */
.field { display: grid; gap: 6px; align-content: start; }
.field > span:first-child { font-weight: 600; font-size: 14.5px; }
.field .hint { font-size: 13px; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), .field select, .field textarea, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea, textarea.input { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .req { color: var(--accent-text); }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; line-height: 1.35; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.err { color: var(--danger); font-size: 14px; font-weight: 500; }
.grid2 { display: grid; gap: 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: none; border: 0; background: transparent; min-height: 34px; padding: 0 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: 999px;
  font: 500 12px/1 var(--font-mono); letter-spacing: .03em; background: var(--sunk); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.chip.hi { background: var(--highlight-soft); color: var(--ink); border-color: transparent; }
.chip.solid { background: var(--accent-btn); color: var(--accent-ink); border-color: transparent; }
.chip.ok { color: var(--ok); }
.chip.warn { color: var(--warn); }
.chip.danger { color: var(--danger); }
.chip svg { width: 13px; height: 13px; }
button.chip { cursor: pointer; }
button.chip[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---- Surfaces --------------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.panel.flat { background: transparent; }
.panel.sunk { background: var(--sunk); }
.panel h2 { font-size: 18px; }
.note {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  padding: 14px 16px; border-radius: 14px; background: var(--highlight-soft); color: var(--ink); font-size: 15px;
}
.note.danger { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }
.note.accent { background: var(--accent-soft); }
.note svg { width: 20px; height: 20px; margin-top: 1px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 4px 0; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.disclose { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; color: var(--muted); }
.disclose::before { content: '›'; display: inline-block; transition: transform .15s; font-size: 18px; line-height: 1; }
details[open] > summary .disclose::before, details[open] > summary.disclose::before { transform: rotate(90deg); }

.progress { height: 10px; border-radius: 999px; background: var(--sunk); overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s ease; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: 14.5px;
  box-shadow: 0 10px 30px rgb(0 0 0 / .22); transition: opacity .2s ease, transform .2s ease; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--danger); color: #fff; }
@media (min-width: 900px) { .toast { bottom: 28px; } }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .display { font-size: 22px; color: var(--ink); display: block; margin-bottom: 6px; }

/* ---- Markdown --------------------------------------------------------------------- */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre { margin: 0 0 .7em; }
.md ul, .md ol { padding-left: 1.3em; }
.md h3, .md h4 { font-size: 1em; margin: 1em 0 .4em; }
.md code { font-size: .88em; background: var(--sunk); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--sunk); padding: 12px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--line); padding-left: 12px; color: var(--muted); }
.md hr { border: 0; border-top: 1px dashed var(--line); margin: 1em 0; }
.md a { color: var(--accent-text); }

/* ---- App shell -------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 9px; flex: none; object-fit: cover; }
.brand .name { font-family: var(--font-display); font-size: 19px; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand .hq { font: 500 11px/1 var(--font-mono); letter-spacing: .12em; color: var(--accent-text); margin-left: 2px; }
.brand .tag { display: none; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: none; gap: 2px; margin-left: 8px; }
.nav a {
  position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 13px; border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: 15px; color: var(--muted);
}
.nav a:hover { color: var(--ink); background: var(--sunk); }
.nav a[aria-current=page] { color: var(--ink); background: var(--sunk); }
.badge {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--accent-btn); color: var(--accent-ink); font: 600 11.5px/1 var(--font-mono);
}
.badge.hi { background: var(--highlight); color: var(--highlight-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }
.topbar .spacer { flex: 1; }
.topbar .new { display: none; }
.me { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: 600 13px/1 var(--font-mono); border: 0; cursor: pointer; flex: none; }
.menu { position: absolute; right: 12px; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 8px; min-width: 230px; box-shadow: 0 16px 40px rgb(0 0 0 / .16); display: grid; gap: 2px; }
.menu button, .menu a { text-align: left; padding: 10px 12px; border-radius: 10px; border: 0; background: none; cursor: pointer; text-decoration: none; font-weight: 500; }
.menu button:hover, .menu a:hover { background: var(--sunk); color: var(--ink); }
.menu .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-top: 1px solid var(--line);
}
.tabbar a { position: relative; display: grid; justify-items: center; gap: 3px; padding: 6px 0; text-decoration: none; font-size: 11.5px; font-weight: 600; color: var(--muted); border-radius: 12px; }
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a[aria-current=page] { color: var(--ink); }
.tabbar a.plus span.ico { width: 44px; height: 44px; margin-top: -14px; border-radius: 50%; background: var(--accent-btn); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent); }
.tabbar a.plus svg { width: 24px; height: 24px; }
.tabbar .badge { position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 10.5px; }
.tabbar .dot { position: absolute; top: 4px; left: calc(50% + 9px); }

main.app { max-width: 1120px; margin: 0 auto; padding: 18px 16px calc(110px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-family: var(--font-display); font-weight: 400; font-size: 28px; }

@media (min-width: 900px) {
  .nav { display: flex; }
  .topbar { padding: 12px 24px; }
  .topbar .new { display: inline-flex; }
  .brand .tag { display: block; }
  .tabbar { display: none; }
  main.app { padding: 28px 24px 60px; }
  .page-head h1 { font-size: 34px; }
}

/* ---- Board ------------------------------------------------------------------------ */
.filters { display: grid; gap: 10px; margin-bottom: 16px; }
.lanes { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.lanes::-webkit-scrollbar { display: none; }
.lanes button {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted);
}
.lanes button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.lanes button .n { font: 500 11px var(--font-mono); opacity: .7; margin-left: 4px; }
.search { position: relative; }
.search input { padding-left: 38px !important; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }

.group { margin: 22px 0 8px; display: flex; align-items: center; gap: 10px; }
.group h2 { font: 500 12px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.group .count { font: 500 12px var(--font-mono); color: var(--muted); }
.group::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.cards { display: grid; gap: 10px; }
@media (min-width: 900px) { .cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); } }
.card {
  position: relative; display: grid; gap: 8px; padding: 14px 16px 14px 18px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--line); text-decoration: none; color: var(--ink); overflow: hidden;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); box-shadow: 0 8px 24px rgb(0 0 0 / .07); transform: translateY(-1px); }
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.card.u-soon::before { background: var(--highlight); }
.card.u-urgent::before { background: var(--accent); }
.card .top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card .ref { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.card .title { font-weight: 600; font-size: 16px; line-height: 1.32; overflow-wrap: anywhere; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card .foot { display: flex; gap: 12px; color: var(--muted); font-size: 13px; align-items: center; flex-wrap: wrap; }
.card .foot span { display: inline-flex; gap: 4px; align-items: center; }
.card .foot svg { width: 14px; height: 14px; }
.card.closed { opacity: .72; }
.card .rank { margin-left: auto; font: 600 12px var(--font-mono); color: var(--accent-text); }

.status { display: inline-flex; align-items: center; gap: 6px; font: 500 12px/1 var(--font-mono); letter-spacing: .03em; padding: 5px 9px; border-radius: 999px; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.s-new { color: var(--accent-text); background: var(--accent-soft); }
.status.s-in_progress { color: var(--ink); background: var(--highlight-soft); }
.status.s-done { color: var(--ok); }
.status.s-parked, .status.s-declined { color: var(--muted); }

.pulse { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }
.pulse .metric { padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.pulse .v { font-family: var(--font-display); font-size: 24px; }

/* ---- Card page -------------------------------------------------------------------- */
.cardpage { display: grid; gap: 18px; }
@media (min-width: 980px) { .cardpage { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } .cardpage aside { position: sticky; top: 84px; } }
.cardpage h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; overflow-wrap: anywhere; }
@media (min-width: 900px) { .cardpage h1 { font-size: 30px; } }
.facts { display: grid; gap: 10px; }
.facts dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; margin: 0; font-size: 14.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.banner { display: grid; gap: 10px; padding: 16px; border-radius: 16px; border: 1.5px solid; }
.banner.guard { border-color: var(--accent); background: var(--accent-soft); }
.banner.parked { border-color: var(--line); background: var(--sunk); }
.banner.done { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); }
.banner .label { color: inherit; opacity: .8; }
.fieldlist { display: grid; gap: 12px; }
.fieldlist .f { display: grid; gap: 2px; }
.fieldlist .lock { display: inline-flex; gap: 4px; align-items: center; font: 500 11px var(--font-mono); color: var(--accent-text); text-transform: uppercase; letter-spacing: .08em; }
.fieldlist .lock svg { width: 12px; height: 12px; }
.checklist { display: grid; gap: 10px; }
.thread { display: grid; gap: 14px; }
.comment { display: grid; grid-template-columns: 36px 1fr; gap: 10px; }
.comment .av { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); font: 600 12px var(--font-mono); color: var(--muted); border: 1px solid var(--line); }
.comment .av.agent { background: var(--highlight-soft); color: var(--ink); }
.comment .av.system { background: var(--accent-soft); color: var(--accent-text); }
.comment .bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 10px 14px; min-width: 0; }
.comment .who { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 4px; font-size: 14px; }
.comment .who b { font-weight: 600; }
.comment.k-triage .bubble, .comment.k-approve .bubble, .comment.k-close .bubble, .comment.k-todo .bubble { background: var(--sunk); }
.files { display: grid; gap: 8px; }
.file { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; }
.file img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }
.file .ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; background: var(--sunk); font: 600 11px var(--font-mono); color: var(--muted); }
.drop { border: 1.5px dashed var(--line); border-radius: 14px; padding: 14px; text-align: center; color: var(--muted); font-size: 14px; cursor: pointer; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.history { display: grid; gap: 8px; font-size: 13.5px; }
.history li { list-style: none; display: grid; gap: 2px; padding-left: 14px; border-left: 2px solid var(--line); }
.history ul { margin: 0; padding: 0; display: grid; gap: 10px; }

/* ---- Composer --------------------------------------------------------------------- */
.types { display: flex; gap: 8px; flex-wrap: wrap; }
.types button { min-height: 40px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; font-size: 14.5px; }
.types button[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.dupes { display: grid; gap: 6px; }
.dupes a { display: flex; gap: 8px; align-items: baseline; padding: 8px 12px; border-radius: 10px; background: var(--highlight-soft); text-decoration: none; font-size: 14.5px; }
.title-input { font-size: 19px !important; font-weight: 600; }
.multiselect { display: flex; flex-wrap: wrap; gap: 6px; max-height: 210px; overflow: auto; padding: 8px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); }
.multiselect button { border: 1px solid var(--line); background: var(--sunk); border-radius: 999px; padding: 5px 11px; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.multiselect button[aria-pressed=true] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* ---- Work order ------------------------------------------------------------------- */
.queue { display: grid; gap: 8px; }
.qrow {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); touch-action: pan-y;
}
.qrow.dragging { opacity: .6; box-shadow: 0 12px 30px rgb(0 0 0 / .18); }
.qrow.over { border-color: var(--accent); }
.qrow .num { font: 600 15px var(--font-mono); color: var(--accent-text); text-align: center; }
.qrow .handle { cursor: grab; color: var(--muted); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; touch-action: none; }
.qrow .handle svg { width: 20px; height: 20px; }
.qrow .handle:active { cursor: grabbing; }
.qrow .what { min-width: 0; display: grid; gap: 4px; }
.qrow .what a { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.qrow .ctl { display: flex; gap: 4px; align-items: center; }
.qrow select { min-height: 34px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; }
.st { font: 500 12px var(--font-mono); padding: 3px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.st.ready { color: var(--ok); }
.st.claimed { background: var(--highlight-soft); color: var(--ink); }
.st.blocked { color: var(--danger); }
.st.needs_yes { color: var(--accent-text); background: var(--accent-soft); }

/* ---- To-dos ----------------------------------------------------------------------- */
.todo { display: grid; gap: 10px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.todo.done { opacity: .7; }
.todo ol { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.todo .why { font-size: 14.5px; color: var(--muted); }
.todo .over { color: var(--danger); font-weight: 600; }

/* ---- Settings --------------------------------------------------------------------- */
.settings { display: grid; gap: 20px; }
@media (min-width: 900px) { .settings { grid-template-columns: 230px minmax(0, 1fr); align-items: start; } .settings nav { position: sticky; top: 84px; } }
.settings nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.settings nav::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .settings nav { display: grid; gap: 2px; } }
.settings nav a { flex: none; padding: 9px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 14.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; justify-content: space-between; white-space: nowrap; }
.settings nav a[aria-current=page] { background: var(--sunk); color: var(--ink); }
.checklines { display: grid; gap: 4px; }
.checkline { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.checkline:last-child { border-bottom: 0; }
.tick { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.tick.ok { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ok); }
.tick.todo, .tick.fail { background: var(--accent-soft); color: var(--accent-text); }
.tick.warn { background: var(--highlight-soft); color: var(--warn); }
.tick.na, .tick.skip { background: var(--sunk); color: var(--muted); }
pre.cmd { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); font: 13px/1.5 var(--font-mono); overflow-x: auto; white-space: pre; max-height: 260px; }

/* ---- Installer -------------------------------------------------------------------- */
body.install { background: radial-gradient(1200px 600px at 100% -10%, var(--highlight-soft), transparent 60%), var(--bg); }
.ins-top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.dots { display: flex; gap: 5px; align-items: center; margin-left: auto; }
.dots button { width: 9px; height: 9px; padding: 0; border-radius: 999px; border: 0; background: var(--line); cursor: pointer; transition: width .2s ease, background .2s ease; }
.dots button.done { background: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.dots button[aria-current=step] { width: 26px; background: var(--accent); }
.dots button:disabled { cursor: default; }
.stepcount { font: 500 12px var(--font-mono); color: var(--muted); white-space: nowrap; }
.pullpill { display: inline-flex; gap: 8px; align-items: center; font: 500 12px var(--font-mono); color: var(--muted); padding: 5px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.pullpill i { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: var(--sunk); overflow: hidden; position: relative; }
.pullpill i b { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.ins { display: grid; gap: 28px; max-width: 1160px; margin: 0 auto; padding: 26px 16px calc(120px + env(safe-area-inset-bottom)); }
@media (min-width: 980px) { .ins { grid-template-columns: minmax(0, 640px) minmax(0, 1fr); gap: 56px; padding-top: 48px; } .ins .preview-wrap { position: sticky; top: 100px; align-self: start; } }
.ins h1 { font-family: var(--font-display); font-weight: 400; font-size: 32px; line-height: 1.08; }
@media (min-width: 900px) { .ins h1 { font-size: 44px; } }
.ins .lede { font-size: 17.5px; color: var(--muted); max-width: 54ch; }
.prefilled { justify-self: start; display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px 6px 8px; border-radius: 999px; background: var(--highlight); color: var(--highlight-ink); font: 600 13px/1 var(--font-text); }
.prefilled svg { width: 16px; height: 16px; }
.ins-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.ins-bar .inner { max-width: 1160px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.ins-bar .primary { margin-left: auto; }
@media (max-width: 520px) { .ins-bar .btn.big { padding: 0 20px; } .ins-bar .primary { flex: 1; } }

.choice { display: grid; gap: 10px; }
.choice > button, .choice > label.opt {
  display: grid; gap: 6px; text-align: left; padding: 16px 18px; border-radius: 18px; border: 1.5px solid var(--line); background: var(--surface); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.choice > button:hover, .choice > label.opt:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.choice > button[aria-pressed=true], .choice > label.opt:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice .t { display: flex; gap: 10px; align-items: center; font-weight: 700; font-size: 17px; }
.choice .d { color: var(--muted); font-size: 14.5px; }
.choice .swatches { display: flex; gap: 4px; }
.choice .swatches i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid rgb(0 0 0 / .08); }
.tpls { display: grid; gap: 10px; }
@media (min-width: 640px) { .tpls { grid-template-columns: 1fr 1fr; } }
.tpls button { position: relative; }
.tpls .first { grid-column: 1 / -1; }
.rec {
  display: grid; gap: 12px; padding: 20px; border-radius: 20px; border: 2px solid var(--accent); background: var(--surface);
  box-shadow: 0 14px 40px color-mix(in srgb, var(--accent) 14%, transparent);
}
.rec .model { font-family: var(--font-display); font-size: 26px; line-height: 1.1; }
.checks { display: grid; gap: 2px; }
.checks .checkline { grid-template-columns: 26px 1fr; }

/* Live header preview */
.preview { border-radius: 22px; overflow: hidden; border: 1px solid var(--line); background: var(--pv-bg, var(--bg)); color: var(--pv-ink, var(--ink)); box-shadow: 0 24px 60px rgb(0 0 0 / .10); }
.preview .pv-top { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid color-mix(in srgb, var(--pv-ink, var(--ink)) 12%, transparent); }
.preview .pv-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.preview .pv-name { font-family: var(--pv-display, var(--font-display)); font-size: 19px; line-height: 1; }
.preview .pv-tag { font-family: var(--pv-text, var(--font-text)); font-size: 12.5px; opacity: .7; }
.preview .pv-hq { font: 500 11px var(--pv-mono, var(--font-mono)); letter-spacing: .12em; color: var(--pv-accent, var(--accent)); }
.preview .pv-nav { display: flex; gap: 6px; padding: 12px 16px 0; font: 600 13px var(--pv-text, var(--font-text)); flex-wrap: wrap; }
.preview .pv-nav span { padding: 6px 11px; border-radius: 999px; opacity: .65; }
.preview .pv-nav span.on { background: color-mix(in srgb, var(--pv-ink, var(--ink)) 7%, transparent); opacity: 1; }
.preview .pv-body { padding: 14px 16px 18px; display: grid; gap: 10px; font-family: var(--pv-text, var(--font-text)); }
.preview .pv-card { position: relative; padding: 12px 14px 12px 16px; border-radius: 14px; background: color-mix(in srgb, var(--pv-bg, var(--bg)) 55%, #fff); border: 1px solid color-mix(in srgb, var(--pv-ink, var(--ink)) 12%, transparent); overflow: hidden; }
.preview .pv-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--pv-hi, var(--highlight)); }
.preview .pv-card.urgent::before { background: var(--pv-accent, var(--accent)); }
.preview .pv-ref { font: 500 11.5px var(--pv-mono, var(--font-mono)); opacity: .6; }
.preview .pv-title { font-weight: 600; font-size: 14.5px; }
.preview .pv-btn { justify-self: start; padding: 8px 14px; border-radius: 999px; background: var(--pv-accent, var(--accent)); color: var(--pv-accent-ink, var(--accent-ink)); font-weight: 700; font-size: 13.5px; }
.preview .pv-chip { display: inline-block; padding: 3px 8px; border-radius: 999px; font: 500 11px var(--pv-mono, var(--font-mono)); background: color-mix(in srgb, var(--pv-hi, var(--highlight)) 35%, transparent); }
.preview-caption { margin-top: 10px; text-align: center; }

.editlist { display: grid; gap: 8px; }
.editrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.editrow .pair { display: grid; gap: 6px; }
@media (min-width: 640px) { .editrow .pair { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); } }
.tplcard { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.tplcard > summary { padding: 14px 16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.tplcard .body { padding: 0 16px 16px; display: grid; gap: 14px; }
.fieldrow { display: grid; gap: 8px; padding: 10px; border-radius: 12px; background: var(--sunk); }
@media (min-width: 640px) { .fieldrow .top { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; } }
.fieldrow .top { display: grid; gap: 8px; }
.colorrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .colorrow { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.colorrow label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; }
.colorrow .sw { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); }
.colorrow input[type=color] { width: 34px; height: 34px; border: 0; padding: 0; background: none; border-radius: 8px; cursor: pointer; }
.colorrow .sw input[type=text] { border: 0 !important; background: transparent !important; box-shadow: none !important; width: 100%; font: 13px var(--font-mono); min-height: 0 !important; padding: 0 !important; }
.logo-pick { display: flex; gap: 14px; align-items: center; }
.logo-pick img { width: 64px; height: 64px; border-radius: 16px; object-fit: cover; border: 1px solid var(--line); }
.code-input { font: 600 28px/1 var(--font-mono) !important; letter-spacing: .14em; text-transform: uppercase; text-align: center; min-height: 64px !important; }
.center-card { max-width: 460px; margin: 10vh auto 0; padding: 0 16px; display: grid; gap: 16px; text-align: center; }
.center-card .panel { text-align: left; }

/* ---- Dialog ----------------------------------------------------------------------- */
dialog.dlg {
  width: min(520px, calc(100vw - 32px)); padding: 22px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgb(0 0 0 / .3);
}
dialog.dlg::backdrop { background: rgb(0 0 0 / .35); backdrop-filter: blur(2px); }
dialog.dlg h2 { font-size: 20px; }
.field .chip input { min-height: 0 !important; padding: 2px 0 !important; border: 0 !important; background: transparent !important; box-shadow: none !important; border-radius: 0 !important; }
.stack > div:empty { display: none; }
