@font-face {
  font-family: "Geist";
  src: url("/fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color: #111111;
  background: #ffffff;
  font-family: "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-synthesis: none;
  --mono: "Geist Mono", "SFMono-Regular", Consolas, monospace;
  --ink: #111111;
  --muted: #5f5f5f;
  --line: #e5e5e5;
  --line-strong: #9a9a9a;
  --surface: #ffffff;
  --surface-soft: #fafafa;
  --surface-raised: #f4f4f4;
  --inverse: #111111;
  --inverse-text: #ffffff;
  --danger: #b00020;
  --success: #0a7a3d;
  --focus: #111111;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--surface); letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, input, select, textarea, video { border-radius: 4px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link {
  position: fixed;
  left: 12px;
  top: 10px;
  z-index: 80;
  transform: translateY(-140%);
  background: var(--inverse);
  color: var(--inverse-text);
  padding: 8px 10px;
  text-decoration: none;
  font-weight: 700;
}
.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;
}

.app-header {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .98);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 750;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.brand-mark { width: 10px; height: 24px; background: var(--ink); border: 1px solid var(--ink); }
.brand-context { color: var(--muted); font-weight: 520; }
.header-progress { min-width: 0; flex: 1; display: flex; justify-content: flex-end; gap: 16px; color: var(--muted); font-size: .875rem; }
.header-progress span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-progress strong { color: var(--ink); white-space: nowrap; }
.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
}
.icon-button:hover { background: var(--surface-raised); border-color: var(--ink); }

main { min-height: calc(100vh - 56px); }
main h1[tabindex="-1"]:focus { outline: 0; }
.loading-state, .message-state {
  min-height: calc(100vh - 56px);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}
.message-state h1, .setup-shell h1, .complete-state h1 { margin: 0; font-size: clamp(1.5rem, 4vw, 2.25rem); line-height: 1.12; }
.message-state p, .complete-state p { max-width: 540px; margin: 0; color: var(--muted); line-height: 1.55; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.setup-shell { width: min(900px, calc(100% - 32px)); margin: 0 auto; padding: 48px 0 72px; }
.setup-kicker { margin: 0 0 10px; color: var(--muted); font-family: var(--mono); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.setup-intro { max-width: 650px; color: var(--muted); line-height: 1.55; margin: 12px 0 32px; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 40px; align-items: start; }
.setup-form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field label, .fieldset-label { font-size: .875rem; font-weight: 700; }
.field small, .field-help { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  transition: border-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
  outline: 0;
}
.consent-row { display: grid; grid-template-columns: 20px 1fr; align-items: start; gap: 9px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.consent-row input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--ink); }
.primary-button, .secondary-button {
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid var(--ink);
  font-weight: 740;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 120ms var(--ease-out);
}
.primary-button { background: var(--ink); color: var(--inverse-text); }
.primary-button:hover { background: #2b2b2b; }
.secondary-button { background: var(--surface); color: var(--ink); }
.secondary-button:hover { background: var(--surface-raised); }
.primary-button:active, .secondary-button:active, .icon-button:active, .tool-button:active, .segmented button:active { transform: scale(.98); }
.rules-panel { border-left: 2px solid var(--ink); padding: 4px 0 4px 20px; }
.rules-panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
.rules-panel ul { padding-left: 18px; margin: 0; display: grid; gap: 10px; color: var(--muted); font-size: .9rem; line-height: 1.45; }

.onboarding-video { width: 100%; aspect-ratio: 16 / 9; display: block; background: #202421; border: 1px solid var(--line-strong); margin: 0 0 28px; }
.knowledge-check { margin: 30px 0 0; border-top: 1px solid var(--line); padding-top: 24px; display: grid; gap: 22px; }
.knowledge-check legend { font-weight: 780; padding: 0; margin-bottom: 5px; }
.question { border: 0; margin: 0; padding: 0; display: grid; gap: 9px; }
.answer-row { display: flex; gap: 8px; flex-wrap: wrap; }
.answer-row label { border: 1px solid var(--line-strong); background: var(--surface); padding: 9px 14px; min-width: 90px; transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out); }
.answer-row label:has(input:checked) { border-color: var(--ink); background: var(--ink); color: var(--inverse-text); }
.answer-row input { accent-color: var(--ink); }

.workspace { height: calc(100vh - 56px); min-height: 620px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 420px); background: #111111; overflow: hidden; }
.evidence-column { min-width: 0; min-height: 0; display: grid; grid-template-rows: 48px minmax(460px, 1fr); }
.evidence-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; background: var(--surface); }
.segmented button { min-height: 34px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted); padding: 6px 12px; }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--ink); color: white; }
.tool-group { display: flex; align-items: center; gap: 6px; }
.tool-button { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 750; }
.tool-button:hover { background: var(--surface-raised); }
.range-control { display: flex; align-items: center; gap: 6px; margin-left: 4px; color: var(--muted); }
.range-control input { width: 84px; accent-color: var(--ink); }
.image-stage { position: relative; overflow: hidden; min-height: 0; touch-action: none; user-select: none; cursor: grab; background: #0b0b0b; }
.image-stage.is-dragging { cursor: grabbing; }
.image-stage img { position: absolute; left: 50%; top: 50%; max-width: none; max-height: none; transform-origin: center; will-change: transform, filter; pointer-events: none; }
.image-status { position: absolute; left: 12px; bottom: 12px; padding: 5px 8px; border-radius: 3px; color: white; background: rgba(12, 15, 13, .78); font-size: .75rem; }

.decision-rail { min-width: 0; min-height: 0; background: var(--surface); border-left: 1px solid #111; display: flex; flex-direction: column; }
.decision-scroll { flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.task-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.task-heading h1 { font-size: 1rem; margin: 0; }
.task-heading span { color: var(--muted); font-size: .8rem; }
.decision-guidance { margin: 0 0 14px; padding-left: 10px; border-left: 2px solid var(--ink); color: var(--muted); font-size: .81rem; line-height: 1.45; }
.derived-scene {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}
.derived-scene span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.derived-scene strong { text-align: right; font-size: .86rem; }
.derived-scene strong.error { color: var(--danger); }
.decision-group { border: 0; padding: 0; margin: 0 0 18px; }
.decision-group legend { font-size: .82rem; font-weight: 780; margin-bottom: 8px; padding: 0; }
.decision-options { display: grid; gap: 7px; }
.choice-label { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 8px; border: 1px solid var(--line); padding: 9px; border-radius: 4px; line-height: 1.35; font-size: .84rem; transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out), color 140ms var(--ease-out); }
.choice-label:hover { border-color: var(--ink); }
.choice-label:has(input:checked) { border-color: var(--ink); background: var(--ink); color: var(--inverse-text); }
.choice-label:focus-within, .inline-options label:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice-label input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--ink); }
.keycap { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--line-strong); background: var(--surface-soft); font-size: .72rem; font-weight: 750; }
.inline-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.inline-options label { position: relative; text-align: center; border: 1px solid var(--line); padding: 8px 5px; font-size: .78rem; line-height: 1.2; min-height: 36px; display: grid; place-items: center; transition: border-color 140ms var(--ease-out), background-color 140ms var(--ease-out), color 140ms var(--ease-out); }
.inline-options label:has(input:checked) { border-color: var(--ink); background: var(--ink); color: var(--inverse-text); }
.inline-options input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.condition-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.decision-actions { position: sticky; bottom: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px; padding: 12px 18px; background: var(--surface); border-top: 1px solid var(--line); }
.save-status { grid-column: 1 / -1; min-height: 16px; margin: 0; color: var(--muted); font-size: .75rem; }
.save-status.error { color: var(--danger); }

.complete-state { min-height: calc(100vh - 56px); display: grid; place-content: center; justify-items: center; gap: 14px; padding: 32px; text-align: center; }
.complete-mark { width: 54px; height: 54px; display: grid; place-items: center; background: var(--success); color: white; border-radius: 50%; font-size: 1.6rem; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: var(--ink); color: white; padding: 10px 14px; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: min(460px, calc(100% - 32px)); text-align: center; transition: opacity 160ms var(--ease-out); }

@media (max-width: 900px) {
  .workspace { height: auto; min-height: calc(100vh - 56px); grid-template-columns: 1fr; overflow: visible; }
  .evidence-column { grid-template-rows: auto minmax(420px, 64vh); }
  .decision-rail { border-left: 0; border-top: 1px solid var(--line-strong); }
  .decision-scroll { overflow: visible; }
  .decision-rail { min-height: 0; }
  .decision-actions { position: static; }
  .setup-grid { grid-template-columns: 1fr; gap: 28px; }
  .header-progress span { display: none; }
}

@media (max-width: 600px) {
  .app-header { padding: 0 10px; gap: 10px; }
  .brand-context { display: none; }
  .setup-shell { width: min(100% - 24px, 920px); padding-top: 30px; }
  .evidence-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .tool-group { width: 100%; min-width: 0; justify-content: space-between; flex-wrap: wrap; }
  .range-control input { width: 65px; }
  .evidence-column { grid-template-rows: auto minmax(330px, 52vh); }
  .decision-scroll { padding: 14px 12px; }
  .decision-actions { padding: 12px; }
  .inline-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .condition-options { grid-template-columns: 1fr; }
}

@media (max-width: 340px) {
  .evidence-toolbar { padding-inline: 6px; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; min-width: 0; padding-inline: 6px; }
  .range-control { margin-left: 0; }
  .range-control input { width: 54px; }
}

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