:root {
  color-scheme: dark;
  --ink: #12150f;
  --ink-2: #1a1f18;
  --ink-3: #252c22;
  --paper: #e4e8df;
  --paper-2: #cfd6ca;
  --mist: #9aa394;
  --line: rgba(228, 232, 223, 0.14);
  --accent: #e45a12;
  --accent-hover: #f16a22;
  --ok: #8bbf80;
  --warn: #e0b05f;
  --danger: #d87868;
  --focus: #ff9a5f;
  --sidebar: 248px;
  --assistant: 360px;
  font-family: "Golos Text", "Avenir Next", Avenir, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--ink); }
body { margin: 0; min-width: 320px; background: var(--ink); color: var(--paper); }
button, input, select, textarea { font: inherit; }
button, select, label.file-button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}
::selection { background: var(--accent); color: #fff; }
a { color: inherit; text-underline-offset: 3px; }

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 100;
  padding: 10px 14px; background: var(--paper); color: var(--ink);
  transform: translateY(-160%); transition: transform 180ms ease-out;
}
.skip-link:focus { transform: translateY(0); }
.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;
}

.auth-shell, .setup-shell {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr);
  align-items: center; padding: clamp(28px, 7vw, 110px); gap: clamp(48px, 8vw, 140px);
}
.auth-copy { max-width: 720px; }
.wordmark { font-weight: 760; letter-spacing: -.03em; text-decoration: none; }
.auth-copy h1 { margin: 80px 0 20px; max-width: 10ch; font-size: clamp(3rem, 6vw, 6rem); line-height: .94; letter-spacing: -.04em; }
.auth-copy p { color: var(--mist); max-width: 52ch; font-size: 1.12rem; line-height: 1.6; }
.auth-form {
  border-top: 1px solid var(--paper); border-bottom: 1px solid var(--line);
  padding: 30px 0 38px; display: grid; gap: 22px;
}
.auth-form h2 { margin: 0 0 16px; font-size: 1.3rem; }
label { display: grid; gap: 8px; color: var(--paper-2); font-size: .88rem; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 0;
  background: var(--ink-2); color: var(--paper); padding: 12px 13px;
}
input:hover, select:hover, textarea:hover { border-color: rgba(228, 232, 223, .34); }
.form-message { min-height: 1.4em; margin: 0; color: var(--danger); }
.setup-shell { display: block; max-width: 800px; padding-top: 20vh; }
.setup-shell p { color: var(--mist); line-height: 1.6; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
dialog {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line);
  background: var(--ink); color: var(--paper); padding: 28px;
}
dialog::backdrop { background: rgba(5, 7, 4, .72); }

.button {
  border: 1px solid transparent; border-radius: 8px; min-height: 42px;
  padding: 10px 15px; font-weight: 680; cursor: pointer;
  transition: background 180ms ease-out, border-color 180ms ease-out, color 180ms ease-out;
}
.button--primary { background: var(--accent); color: #fff; }
.button--primary:hover { background: var(--accent-hover); }
.button--primary:disabled { background: #493426; color: #917967; cursor: not-allowed; }
.button--quiet { background: transparent; color: var(--mist); border-color: var(--line); }
.button--quiet:hover, .button--outline:hover { color: var(--paper); border-color: var(--mist); }
.button--outline { background: transparent; color: var(--paper); border-color: var(--line); width: 100%; }
.icon-button {
  width: 42px; height: 42px; padding: 9px; border: 0; background: transparent; color: var(--paper);
  cursor: pointer; border-radius: 8px;
}
.icon-button:hover { background: var(--ink-3); }
.icon-button svg { width: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; }

.app-shell {
  min-height: 100vh; display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: 64px 1fr;
}
.app-shell::after {
  content: attr(data-watermark); position: fixed; inset: 0; z-index: 80; pointer-events: none;
  display: grid; place-items: center; color: rgba(228, 232, 223, .035);
  font-size: clamp(1rem, 3vw, 2.2rem); letter-spacing: .08em;
  transform: rotate(-22deg); white-space: pre-wrap; text-align: center;
}
.topbar {
  position: sticky; top: 0; z-index: 20; grid-column: 1 / -1;
  display: grid; grid-template-columns: var(--sidebar) 1fr auto; align-items: center;
  border-bottom: 1px solid var(--line); background: rgba(18, 21, 15, .96); padding: 0 22px;
}
.topbar__context { display: flex; align-items: baseline; gap: 18px; color: var(--paper-2); }
.freshness { color: var(--mist); font-size: .78rem; }
.nav-toggle { display: none; }
.sidebar {
  position: sticky; top: 64px; height: calc(100vh - 64px);
  display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid var(--line); padding: 24px 14px;
}
.sidebar nav { display: grid; gap: 4px; }
.nav-item {
  border: 0; border-radius: 7px; background: transparent; color: var(--mist);
  text-align: left; padding: 11px 12px; cursor: pointer;
}
.nav-item:hover { background: var(--ink-2); color: var(--paper); }
.nav-item.is-active { background: var(--paper); color: var(--ink); font-weight: 700; }
.sidebar__foot { border-top: 1px solid var(--line); padding: 18px 4px 0; }
.sidebar__foot p { color: var(--mist); font-size: .84rem; }

.workspace { min-width: 0; padding: 36px clamp(24px, 4vw, 68px) 90px; }
.workspace__head {
  display: flex; justify-content: space-between; align-items: end; gap: 28px;
  border-bottom: 1px solid var(--line); padding-bottom: 24px; margin-bottom: 28px;
}
.crumb, .section-label { margin: 0 0 8px; color: var(--mist); font-size: .78rem; }
.workspace h1 { margin: 0; font-size: 2rem; letter-spacing: -.03em; }
.sku-meta { margin: 8px 0 0; color: var(--mist); font-size: .88rem; }
.sku-picker { width: min(280px, 36vw); }

.decision-band {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 30px; align-items: end;
  background: var(--paper); color: var(--ink); padding: clamp(24px, 4vw, 46px);
}
.decision-band h2 { margin: 0; max-width: 24ch; font-size: clamp(1.7rem, 3vw, 2.7rem); line-height: 1.08; letter-spacing: -.035em; }
.decision-band p:not(.section-label) { max-width: 65ch; color: #4d554a; line-height: 1.55; }
.status-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line); margin-bottom: 54px;
}
.status-cell { min-height: 138px; padding: 24px 20px; border-right: 1px solid var(--line); }
.status-cell:last-child { border-right: 0; }
.status-cell__label { color: var(--mist); font-size: .78rem; }
.status-cell__value { margin: 20px 0 0; font-size: 1.08rem; line-height: 1.35; }
.status-cell__state { display: inline-block; margin-top: 8px; color: var(--warn); font-size: .76rem; }

.section-head { display: flex; justify-content: space-between; gap: 28px; align-items: end; margin: 0 0 24px; }
.section-head h2, .path-section h2 { margin: 0; font-size: 1.35rem; }
.section-head p { margin: 8px 0 0; color: var(--mist); max-width: 64ch; }
.legend { color: var(--mist); font-size: .76rem; white-space: nowrap; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 5px 0 12px; }
.dot--ready { background: var(--accent); }
.dot--blocked { background: #555d52; }

.workflow { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); overflow-x: auto; padding: 1px 0 20px; }
.workflow-step {
  position: relative; min-height: 196px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 24px 24px 22px 0; margin-right: 26px;
}
.workflow-step::after {
  content: ""; position: absolute; right: -26px; top: -1px; width: 26px; border-top: 1px solid var(--line);
}
.workflow-step__state { color: var(--mist); font-size: .76rem; }
.workflow-step.is-ready .workflow-step__state { color: var(--accent); }
.workflow-step h3 { margin: 28px 0 10px; font-size: 1.02rem; }
.workflow-step p { margin: 0; color: var(--mist); font-size: .86rem; line-height: 1.45; }

.fact-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.fact-row { min-height: 105px; padding: 20px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fact-row:nth-child(2n) { border-right: 0; }
.fact-row dt { color: var(--mist); font-size: .78rem; }
.fact-row dd { margin: 13px 0 0; line-height: 1.45; }
.fact-row small { display: block; color: var(--ok); margin-top: 8px; }

.option {
  display: grid; grid-template-columns: 170px minmax(0, 1fr) minmax(220px, .45fr);
  gap: 28px; padding: 28px 0; border-top: 1px solid var(--line);
}
.option__code { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.option h3 { margin: 0 0 10px; }
.option p { color: var(--mist); line-height: 1.5; }
.option__guard { color: var(--warn); font-size: .84rem; }

.task-list { border-top: 1px solid var(--line); }
.task {
  display: grid; grid-template-columns: 110px minmax(220px, .7fr) minmax(300px, 1fr) auto;
  gap: 22px; align-items: start; padding: 22px 0; border-bottom: 1px solid var(--line);
}
.task__state { color: var(--mist); font-size: .76rem; }
.task.is-ready .task__state { color: var(--accent); }
.task h3 { margin: 0; font-size: 1rem; }
.task p { margin: 0; color: var(--mist); line-height: 1.45; font-size: .87rem; }
.empty-state { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 54px 0; color: var(--mist); }
.template-list { display: grid; border-top: 1px solid var(--line); }
.template-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.template-row h3 { margin: 0 0 7px; font-size: 1rem; }
.template-row p { margin: 0; color: var(--mist); font-size: .86rem; }
.reading { max-width: 76ch; line-height: 1.7; }

.assistant {
  position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(var(--assistant), 100vw);
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--paper); color: var(--ink); transform: translateX(101%);
  transition: transform 220ms cubic-bezier(.2, .8, .2, 1); box-shadow: -16px 0 48px rgba(0, 0, 0, .28);
}
.assistant.is-open { transform: translateX(0); }
.assistant__head { display: flex; justify-content: space-between; padding: 22px; border-bottom: 1px solid #bdc5b9; }
.assistant__head h2 { margin: 0; font-size: 1.05rem; }
.assistant__head p { margin: 5px 0 0; color: #5e675b; font-size: .76rem; }
.assistant__head .icon-button { color: var(--ink); font-size: 1.4rem; }
.assistant__messages { overflow-y: auto; padding: 22px; }
.assistant-note, .assistant-message { padding: 14px 0; border-bottom: 1px solid #c6cdc2; line-height: 1.5; font-size: .9rem; }
.assistant__form { padding: 18px; border-top: 1px solid #bdc5b9; }
.assistant__form textarea { background: #f1f3ef; color: var(--ink); border-color: #b7beb3; resize: vertical; margin-bottom: 10px; }
.assistant-launch { position: fixed; right: 22px; bottom: 22px; z-index: 30; border: 0; border-radius: 8px; background: var(--accent); color: #fff; padding: 13px 17px; font-weight: 700; cursor: pointer; }

.admin-pilot { margin-top: 72px; padding-top: 32px; border-top: 1px solid var(--line); }
.admin-pilot__invite { display: flex; align-items: end; gap: 10px; }
.admin-pilot__invite label { color: var(--mist); font-size: .76rem; }
.admin-pilot__invite input { display: block; min-width: 90px; margin-top: 5px; }
.admin-pilot__filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 32px 0 14px; }
.admin-pilot__filters .is-active { border-color: var(--accent); color: #fff; }
.admin-pilot__repeats { margin: 24px 0; color: var(--mist); }
.admin-pilot__repeats ul { padding-left: 20px; }
.admin-pilot__repeats li + li { margin-top: 8px; }
.pilot-admin-thread { grid-template-columns: 110px minmax(180px, .45fr) minmax(320px, 1fr); }
.pilot-admin-thread blockquote {
  grid-column: 2 / -1; margin: 0; padding: 10px 14px; border-left: 2px solid var(--accent);
  color: var(--mist); font-size: .85rem;
}
.pilot-admin-thread .task__actions { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
#pilot-link { overflow-wrap: anywhere; }

.gates-board, .branch-actions, .gate-actions, .task__actions {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px;
}
.gates-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.gate-card, .branch-current {
  border: 1px solid var(--line); padding: 16px; background: var(--ink-2);
}
.gate-card h3 { margin: 0 0 8px; letter-spacing: -.02em; }
.fact-row.is-conflict { border-color: var(--danger); }
.letters-log { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 18px; }
.letters-log p { color: var(--mist); }

.locale-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.locale-tab.is-active, .timeline-filter.is-active { border-color: var(--accent); color: var(--paper); background: var(--ink); }
.timeline-item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.timeline-item time { display: block; color: var(--mist); font-size: .85rem; margin-bottom: 4px; }
.timeline-item .kind { text-transform: uppercase; letter-spacing: .04em; font-size: .75rem; color: var(--mist); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: auto auto 1fr auto; gap: 12px; }
  .nav-toggle { display: block; }
  .sidebar {
    position: fixed; z-index: 35; inset: 64px auto 0 0; width: min(var(--sidebar), 86vw);
    background: var(--ink); transform: translateX(-101%); transition: transform 200ms ease-out;
  }
  .sidebar.is-open { transform: translateX(0); }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .status-cell:nth-child(2) { border-right: 0; }
  .task { grid-template-columns: 90px 1fr; }
  .task p, .task .button { grid-column: 2; }
  .pilot-admin-thread blockquote, .pilot-admin-thread .task__actions { grid-column: 2; }
}

@media (max-width: 640px) {
  .auth-shell { grid-template-columns: 1fr; align-content: center; padding: 28px 20px; }
  .auth-copy h1 { margin-top: 42px; font-size: 3rem; }
  .topbar { padding: 0 12px; }
  .topbar__context, .topbar .wordmark { display: none; }
  .workspace { padding: 24px 16px 84px; }
  .workspace__head, .section-head { align-items: stretch; flex-direction: column; }
  .sku-picker { width: 100%; }
  .decision-band { grid-template-columns: 1fr; }
  .status-grid, .fact-sheet { grid-template-columns: 1fr; }
  .status-cell, .fact-row { border-right: 0; }
  .option { grid-template-columns: 1fr; gap: 10px; }
  .task { grid-template-columns: 1fr; gap: 9px; }
  .task p, .task .button { grid-column: 1; }
  .admin-pilot__invite { align-items: stretch; flex-direction: column; }
  .pilot-admin-thread blockquote, .pilot-admin-thread .task__actions { grid-column: 1; }
  .legend { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
