:root {
  --red: #d82336;
  --red-strong: #ad1122;
  --red-rgb: 216, 35, 54;
  --blue: #2563c7;
  --blue-rgb: 37, 99, 199;
  --green: #11815e;
  --green-rgb: 17, 129, 94;
  --evidence: #167a94;
  --evidence-rgb: 22, 122, 148;
  --amber: #8b5a08;
  --ink: #17213a;
  --muted: #626979;
  --line: #dfe3ea;
  --line-strong: #c9cfda;
  --soft: #f4f6fa;
  --canvas: #edf1f7;
  --panel: #ffffff;
  --control: #ffffff;
  --focus: #1557b0;
  --shadow: 0 14px 42px rgba(23, 33, 58, .09);
  --shadow-soft: 0 8px 24px rgba(23, 33, 58, .07);
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

html { overflow-x: clip; scroll-behavior: smooth; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 48% -12%, rgba(var(--red-rgb), .07), transparent 34rem),
    linear-gradient(135deg, #f8f9fb 0, var(--canvas) 52%, #f7f9fb 100%);
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button, a { transition: border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled, textarea:disabled { cursor: not-allowed; opacity: .55; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip {
  position: fixed;
  z-index: 100;
  top: -5rem;
  left: 1rem;
  min-height: 44px;
  padding: 11px 15px;
  border-radius: 10px;
  color: #fff;
  background: #111827;
  font-weight: 800;
  text-decoration: none;
}
.skip:focus { top: 1rem; }

.topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(210px, 300px) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 8px 22px;
  border-bottom: 1px solid rgba(23, 33, 58, .09);
  background: rgba(255, 255, 255, .93);
  box-shadow: 0 6px 24px rgba(23, 33, 58, .04);
  backdrop-filter: blur(18px);
}
.brand {
  min-height: 44px;
  display: flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand span { min-width: 0; display: flex; flex-direction: column; }
.brand strong { font-size: 15px; }
.brand small, .top-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.top-title { min-width: 0; text-align: center; }
.top-title h1 { margin: 3px 0 0; overflow: hidden; font-size: 18px; letter-spacing: -.02em; text-overflow: ellipsis; white-space: nowrap; }
.topbar nav { display: flex; gap: 8px; }
.topbar nav a {
  min-height: 44px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #394153;
  background: var(--control);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}
.topbar nav a:hover { border-color: rgba(var(--red-rgb), .36); color: var(--red); box-shadow: var(--shadow-soft); }
.topbar svg, .form-actions svg, .rail-foot svg, .tabs svg { width: 18px; height: 18px; }

.statusbar {
  min-height: 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 9px 22px;
  border-bottom: 1px solid #e5d59d;
  color: #684d00;
  background: #fff8da;
  font-size: 13px;
}
.statusbar[data-kind="ready"] { border-color: #afdcc9; color: #0d6243; background: #eaf8f2; }
.statusbar[data-kind="error"] { border-color: #efb8bf; color: #9b0010; background: #fff0f2; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 999px; background: currentColor; box-shadow: 0 0 0 4px rgba(104, 77, 0, .12); }
.statusbar strong { font-size: 13px; }
.statusbar > span:last-child { color: inherit; opacity: .82; }

.workspace {
  width: 100%;
  max-width: 1800px;
  display: grid;
  grid-template-columns: minmax(220px, 250px) minmax(0, 1fr) minmax(320px, 370px);
  gap: 12px;
  align-items: start;
  margin: 0 auto;
  padding: 12px;
}
.workspace[data-unavailable="true"] .panel { opacity: .82; }
.panel {
  --section: var(--red);
  --section-rgb: var(--red-rgb);
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(var(--section-rgb), .17);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow), inset 0 4px 0 var(--section);
}
.rail { --section: var(--blue); --section-rgb: var(--blue-rgb); }
.builder { --section: var(--red); --section-rgb: var(--red-rgb); padding-bottom: 8px; }
.inspector { --section: var(--green); --section-rgb: var(--green-rgb); }
.rail, .inspector {
  position: sticky;
  top: 84px;
  max-height: calc(100dvh - 96px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(var(--section-rgb), .4) transparent;
  scrollbar-width: thin;
}
.rail::-webkit-scrollbar, .inspector::-webkit-scrollbar, .check-list::-webkit-scrollbar, .allocation-wrap::-webkit-scrollbar { width: 9px; height: 9px; }
.rail::-webkit-scrollbar-thumb, .inspector::-webkit-scrollbar-thumb, .check-list::-webkit-scrollbar-thumb, .allocation-wrap::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: rgba(var(--section-rgb), .4); background-clip: padding-box; }

.panel-head, .builder-head, .section-head, .subhead, .stage-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.panel-head, .builder-head {
  min-height: 74px;
  padding: 15px 17px;
  border-bottom: 1px solid rgba(var(--section-rgb), .16);
  background: linear-gradient(100deg, rgba(var(--section-rgb), .11), rgba(var(--section-rgb), .025) 75%);
}
.panel-head > div > span, .builder-head > div > span, .section-head > div > span, .subhead > div > span, .stage-heading > div > span, .dialog-head span, .export-card > div > span {
  display: block;
  color: var(--section, var(--red));
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.panel-head h2, .builder-head h2, .section-head h3, .subhead h3, .stage-heading h3, .dialog-head h2, .export-card h3 { margin: 3px 0 0; letter-spacing: -.025em; }
.panel-head h2 { font-size: 18px; }
.builder-head h2 { font-size: 22px; }
.builder-head p, .stage-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 1px solid rgba(var(--section-rgb), .2);
  border-radius: 12px;
  color: var(--section);
  background: rgba(var(--section-rgb), .08);
  font-size: 22px;
}
.icon-button:hover { background: rgba(var(--section-rgb), .15); }

.question-stepper { padding: 16px 20px 4px; }
.question-stepper ol { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.question-stepper li { --step: var(--blue); --step-rgb: var(--blue-rgb); min-width: 0; }
.question-stepper li[data-step="design"] { --step: var(--red); --step-rgb: var(--red-rgb); }
.question-stepper li[data-step="evidence"] { --step: var(--evidence); --step-rgb: var(--evidence-rgb); }
.question-stepper li[data-step="review"] { --step: var(--green); --step-rgb: var(--green-rgb); }
.question-stepper a {
  min-height: 64px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 0 9px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(var(--step-rgb), .18);
  border-radius: 13px;
  color: var(--ink);
  background: linear-gradient(110deg, rgba(var(--step-rgb), .08), rgba(var(--step-rgb), .018));
  text-decoration: none;
}
.question-stepper a:hover, .question-stepper a[aria-current="step"] { border-color: rgba(var(--step-rgb), .45); box-shadow: 0 7px 20px rgba(var(--step-rgb), .1); transform: translateY(-1px); }
.question-stepper a[aria-current="step"] { background: linear-gradient(110deg, rgba(var(--step-rgb), .15), rgba(var(--step-rgb), .035)); }
.question-stepper a > span { grid-row: 1 / 3; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: #fff; background: var(--step); font-size: 13px; font-weight: 900; }
.question-stepper strong { align-self: end; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.question-stepper small { align-self: start; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }

.blueprint-summary {
  position: sticky;
  z-index: 25;
  top: 84px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  margin: 10px 20px 0;
  padding: 10px 12px;
  border: 1px solid rgba(var(--red-rgb), .2);
  border-radius: 14px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 10px 28px rgba(23, 33, 58, .1);
  backdrop-filter: blur(16px);
}
.summary-context { min-width: 190px; flex: 1 1 240px; }
.summary-context span { display: block; color: var(--red); font-size: 10px; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.summary-context strong { display: block; margin-top: 2px; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.blueprint-summary dl { min-width: min(100%, 360px); flex: 1 1 390px; display: grid; grid-template-columns: repeat(5, minmax(58px, 1fr)); gap: 5px; margin: 0; }
.blueprint-summary dl > div { min-width: 0; padding: 4px 7px; border-left: 1px solid var(--line); text-align: center; }
.blueprint-summary dt { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.blueprint-summary dd { margin: 1px 0 0; color: var(--ink); font-size: 15px; font-weight: 900; }

.builder-state { display: flex; align-items: center; gap: 7px; }
.builder-state span, .builder-state b { padding: 6px 9px; border-radius: 999px; background: rgba(var(--red-rgb), .09); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.builder-state b { color: #fff; background: #202737; }
.builder form { padding: 18px 20px 22px; }

.field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.field > span, fieldset legend { color: #50596b; font-size: 12px; font-weight: 900; letter-spacing: .065em; text-transform: uppercase; }
.field small { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0; text-transform: none; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--control);
  padding: 10px 11px;
  font-size: 14px;
}
.field textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--section, var(--red)); box-shadow: 0 0 0 3px rgba(var(--section-rgb, var(--red-rgb)), .11); }
.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.span-2 { grid-column: span 2; }
.rail > .field { padding: 14px 16px 8px; }

.blueprint-stage { scroll-margin-top: 168px; }
.context-stage {
  margin: 0;
  padding: 16px;
  border: 1px solid rgba(var(--blue-rgb), .2);
  border-radius: 15px;
  background: linear-gradient(120deg, rgba(var(--blue-rgb), .07), rgba(var(--blue-rgb), .018) 60%);
  box-shadow: inset 4px 0 0 var(--blue);
}
.context-stage { --section: var(--blue); --section-rgb: var(--blue-rgb); }
.stage-heading { align-items: flex-start; margin-bottom: 15px; }
.stage-heading h3 { font-size: 17px; }
.setup-badge {
  min-height: 34px;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  flex: 0 0 auto;
  padding: 7px 9px;
  border: 1px solid rgba(var(--blue-rgb), .2);
  border-radius: 999px;
  color: var(--blue);
  background: rgba(var(--blue-rgb), .08);
  font-size: 11px;
  font-weight: 900;
}
.setup-badge svg { width: 17px; height: 17px; }
.setup-hint {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 13px 0 0;
  padding: 10px 11px;
  border: 1px solid rgba(var(--blue-rgb), .16);
  border-radius: 11px;
  color: #344f75;
  background: rgba(var(--blue-rgb), .055);
  font-size: 12px;
}
.setup-hint svg { width: 18px; height: 18px; flex: 0 0 auto; }
.setup-hint[data-kind="empty"] { border-color: rgba(var(--red-rgb), .3); color: var(--red-strong); background: rgba(var(--red-rgb), .06); }
.setup-hint[data-kind="ready"] { border-color: rgba(var(--green-rgb), .28); color: var(--green); background: rgba(var(--green-rgb), .055); }

.bank-context { display: flex; gap: 9px; margin: 5px 16px 15px; padding: 11px; border-radius: 11px; background: rgba(var(--blue-rgb), .055); }
.context-icon { width: 30px; height: 30px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 9px; color: var(--blue); background: var(--control); font-weight: 900; }
.bank-context div { min-width: 0; display: flex; flex-direction: column; }
.bank-context strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.bank-context small { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.subhead { padding: 13px 16px 8px; border-top: 1px solid var(--line); }
.subhead h3 { font-size: 15px; }
.subhead button, .section-head button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--section, var(--red));
  background: transparent;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 900;
}
.subhead button:hover, .section-head button:hover { border-color: rgba(var(--section-rgb, var(--red-rgb)), .18); background: rgba(var(--section-rgb, var(--red-rgb)), .08); }
.blueprint-list { padding: 4px 8px 10px; }
.blueprint-card {
  width: 100%;
  min-height: 58px;
  display: block;
  margin: 2px 0;
  padding: 11px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}
.blueprint-card:hover { background: var(--soft); }
.blueprint-card[aria-current="true"] { border-color: rgba(var(--blue-rgb), .34); background: rgba(var(--blue-rgb), .08); box-shadow: inset 3px 0 0 var(--blue); }
.blueprint-card strong, .blueprint-card span { display: block; }
.blueprint-card strong { font-size: 13px; line-height: 1.35; }
.blueprint-card span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.blueprint-card em { display: inline-block; margin-top: 7px; padding: 4px 7px; border-radius: 999px; color: #555d6d; background: var(--soft); font-size: 10px; font-style: normal; font-weight: 900; letter-spacing: .04em; }
.blueprint-card em[data-status="APPROVED"] { color: #0b6245; background: rgba(var(--green-rgb), .12); }
.rail-foot { display: flex; gap: 9px; padding: 13px 15px; border-top: 1px solid var(--line); color: var(--muted); background: var(--soft); font-size: 12px; line-height: 1.45; }
.rail-foot svg { flex: 0 0 auto; color: var(--green); }

.contract-section {
  --section: var(--red);
  --section-rgb: var(--red-rgb);
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid rgba(var(--section-rgb), .19);
  border-radius: 14px;
  background: var(--panel);
}
.design-stage { box-shadow: inset 4px 0 0 var(--red); }
.source-section { --section: var(--evidence); --section-rgb: var(--evidence-rgb); box-shadow: inset 4px 0 0 var(--evidence); }
.standards-section { --section: var(--green); --section-rgb: var(--green-rgb); box-shadow: inset 4px 0 0 var(--green); }
.section-head { min-height: 66px; padding: 10px 13px; border-bottom: 1px solid rgba(var(--section-rgb), .15); background: linear-gradient(105deg, rgba(var(--section-rgb), .075), transparent 72%); }
.section-head h3 { font-size: 16px; }
.section-head > div:last-child, .section-tools { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; justify-content: flex-end; }
.total-pill { padding: 7px 9px; border-radius: 999px; color: #4f596c; background: rgba(var(--section-rgb), .09); font-size: 11px; white-space: nowrap; }
.total-pill b { color: var(--ink); }

.allocation-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 12px 12px 4px; }
.allocation-presets button {
  min-width: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--control);
  text-align: left;
}
.allocation-presets button:hover, .allocation-presets button[aria-pressed="true"] { border-color: rgba(var(--red-rgb), .4); background: rgba(var(--red-rgb), .055); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.preset-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; color: var(--red); background: rgba(var(--red-rgb), .1); }
.preset-icon svg { width: 20px; height: 20px; }
.allocation-presets strong, .allocation-presets small { display: block; overflow: hidden; text-overflow: ellipsis; }
.allocation-presets strong { font-size: 12px; }
.allocation-presets small { margin-top: 3px; color: var(--muted); font-size: 11px; white-space: nowrap; }

.allocation-wrap { width: 100%; max-width: 100%; overflow: auto; contain: layout inline-size paint; margin-top: 8px; overscroll-behavior-inline: contain; scrollbar-color: rgba(var(--red-rgb), .4) transparent; scrollbar-width: thin; }
.allocation-wrap table { width: 100%; min-width: 850px; border-collapse: collapse; }
.allocation-wrap th { padding: 11px 8px; border-bottom: 1px solid var(--line); color: #596274; font-size: 11px; font-weight: 900; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
.allocation-wrap td { padding: 8px; border-bottom: 1px solid var(--line); }
.allocation-wrap select, .allocation-wrap input { width: 100%; min-width: 62px; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: var(--control); padding: 8px; font-size: 13px; }
.allocation-wrap td:first-child { min-width: 170px; }
.allocation-wrap td:nth-child(3), .allocation-wrap td:nth-child(4) { min-width: 125px; }
.row-remove { width: 44px; height: 44px; border: 1px solid transparent; border-radius: 9px; color: #a51426; background: transparent; font-size: 18px; }
.row-remove:hover { border-color: #efbbc1; background: #fff0f2; }
.section-note { margin: 8px 0 0; padding: 0 13px 12px; color: var(--muted); font-size: 12px; }

.evidence-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 12px; scroll-margin-top: 168px; }
.source-section, .standards-section { min-height: 320px; }
.search { position: relative; display: block; margin: 10px 11px 4px; }
.search svg { position: absolute; top: 13px; left: 12px; width: 18px; height: 18px; color: var(--muted); }
.search input { width: 100%; min-height: 44px; padding: 9px 10px 9px 38px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); background: var(--control); font-size: 14px; }
.check-list { max-height: 244px; overflow-y: auto; padding: 6px 9px 10px; overscroll-behavior: contain; scrollbar-color: rgba(var(--section-rgb), .4) transparent; scrollbar-width: thin; }
.check-row { min-height: 48px; display: flex; gap: 10px; align-items: flex-start; padding: 9px; border-radius: 9px; }
.check-row:hover { background: rgba(var(--section-rgb), .075); }
.check-row input { width: 20px; height: 20px; flex: 0 0 auto; margin: 1px 0 0; accent-color: var(--section); }
.check-row span { min-width: 0; }
.check-row strong, .check-row small { display: block; }
.check-row strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.check-row small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.empty { padding: 26px 15px; color: var(--muted); text-align: center; }
.empty strong, .empty span { display: block; }
.empty strong { color: #465065; font-size: 13px; }
.empty span { margin-top: 5px; font-size: 12px; line-height: 1.5; }
.empty.large { padding: 44px 20px; }
.feedback { margin-top: 13px; padding: 11px 12px; border: 1px solid #edb8c0; border-radius: 10px; color: #980011; background: #fff0f2; font-size: 13px; }
.feedback[data-kind="success"] { border-color: #acdcca; color: #0b6243; background: #eaf8f2; }
.generation-policy {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 13px;
  padding: 11px 12px;
  border: 1px solid #dfd2aa;
  border-radius: 11px;
  color: #6a4d00;
  background: #fff9e7;
}
.generation-policy > svg { width: 21px; height: 21px; flex: 0 0 auto; }
.generation-policy strong, .generation-policy small { display: block; }
.generation-policy strong { font-size: 13px; }
.generation-policy small { margin-top: 2px; color: inherit; font-size: 12px; opacity: .82; }
.generation-policy[data-kind="ready"] { border-color: #acdcca; color: #0b6243; background: #eaf8f2; }
.generation-policy[data-kind="blocked"], .generation-policy[data-kind="error"] { border-color: #edb8c0; color: #980011; background: #fff0f2; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 15px; }
.form-actions > span { display: flex; gap: 7px; align-items: center; margin-right: auto; color: var(--muted); font-size: 12px; }
.primary, .secondary, .approve, .reject, .export-card button {
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 900;
}
.primary { border-color: var(--red); color: #fff; background: var(--red); }
.primary:hover { border-color: var(--red-strong); background: var(--red-strong); box-shadow: 0 8px 18px rgba(var(--red-rgb), .18); }
.secondary { color: #343d4f; background: var(--control); }
.approve { border-color: #acdcca; color: #0a6546; background: #e8f7f0; }
.reject { border-color: #efbbc1; color: #9c0011; background: #fff0f2; }

.question-section { --section: var(--green); --section-rgb: var(--green-rgb); scroll-margin-top: 168px; margin-top: 4px; padding: 18px 20px; border-top: 1px solid rgba(var(--green-rgb), .18); background: linear-gradient(180deg, rgba(var(--green-rgb), .035), transparent 180px); }
.question-section > .section-head { margin: -18px -20px 0; padding-right: 20px; padding-left: 20px; }
.review-metrics { display: flex; flex-wrap: wrap; gap: 7px; }
.review-metrics span { padding: 7px 9px; border-radius: 9px; color: #3d5a50; background: rgba(var(--green-rgb), .1); font-size: 11px; }
.question-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 12px; }
.question-card { min-width: 0; min-height: 72px; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 11px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: var(--control); text-align: left; }
.question-card:hover { border-color: rgba(var(--green-rgb), .35); box-shadow: var(--shadow-soft); transform: translateY(-1px); }
.question-card[aria-current="true"] { border-color: var(--green); box-shadow: 0 0 0 3px rgba(var(--green-rgb), .1); }
.question-no { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--green); background: rgba(var(--green-rgb), .1); font-weight: 900; }
.question-card strong, .question-card small { display: block; }
.question-card strong { display: -webkit-box; overflow: hidden; font-size: 13px; line-height: 1.4; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.question-card small { margin-top: 5px; color: var(--muted); font-size: 11px; }
.question-state { width: 10px; height: 10px; margin: 6px; border: 2px solid var(--panel); border-radius: 999px; background: #b57814; box-shadow: 0 0 0 1px #b57814; }
.question-state[data-status="APPROVED"] { background: var(--green); box-shadow: 0 0 0 1px var(--green); }
.question-state[data-status="REJECTED"] { background: var(--red); box-shadow: 0 0 0 1px var(--red); }

.format-badge { padding: 6px 8px; border-radius: 999px; color: var(--green) !important; background: rgba(var(--green-rgb), .1); font-size: 10px !important; font-weight: 900; }
.inspector-empty { padding: 54px 30px; text-align: center; }
.empty-visual { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 14px; border-radius: 17px; color: var(--green); background: rgba(var(--green-rgb), .1); font-size: 25px; }
.inspector-empty strong { font-size: 16px; }
.inspector-empty p { color: var(--muted); font-size: 13px; line-height: 1.55; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 9px; border-bottom: 1px solid var(--line); }
.tabs button { min-height: 44px; display: flex; gap: 5px; align-items: center; justify-content: center; border: 0; border-radius: 9px; color: #5d6677; background: transparent; font-size: 12px; font-weight: 900; }
.tabs button[aria-selected="true"] { color: #fff; background: #202737; }
.tabs svg { width: 15px; height: 15px; }
.preview { min-height: 145px; padding: 16px; border-bottom: 1px solid var(--line); background: var(--soft); }
.preview[role="tabpanel"]:focus-visible { outline-offset: -4px; }
.preview h3 { margin: 0 0 11px; font-size: 14px; line-height: 1.5; }
.preview ol, .preview ul, .preview dl { font-size: 13px; line-height: 1.6; }
.preview ol, .preview ul { padding-left: 22px; }
.preview dt { margin-top: 8px; font-weight: 900; }
.preview dd { margin: 2px 0; color: var(--muted); }
.preview .protected-callout { padding: 10px; border-radius: 9px; color: #694800; background: #fff4d7; font-size: 13px; }
.item-editor { padding: 16px !important; }
.item-editor > .field, .item-editor > [data-config-matching], .item-editor > [data-config-practical], .item-editor > .mini-grid, .item-editor fieldset { margin-top: 12px; }
.editor-title { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.editor-title h3 { margin: 0; font-size: 15px; }
.editor-title span { padding: 5px 8px; border-radius: 999px; background: var(--soft); font-size: 11px; }
.protected-editor { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 13px; padding: 11px; border: 1px solid #e1ce98; border-radius: 11px; background: #fff9e7; }
.protected-editor > div { display: flex; gap: 9px; align-items: center; }
.protected-editor svg { width: 22px; height: 22px; flex: 0 0 auto; color: #815800; }
.protected-editor strong, .protected-editor small { display: block; }
.protected-editor strong { font-size: 12px; }
.protected-editor small { margin-top: 2px; color: #765f2c; font-size: 11px; }
.protected-editor button { min-height: 44px; flex: 0 0 auto; border: 0; border-radius: 9px; color: #fff; background: #3d3219; padding: 8px 10px; font-size: 12px; font-weight: 900; }
.mini-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mini-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
fieldset { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
fieldset legend { padding: 0 6px; }
.lock-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.lock-grid label { min-height: 38px; display: flex; gap: 6px; align-items: center; color: #4d5667; font-size: 12px; }
.lock-grid input { width: 18px; height: 18px; accent-color: var(--green); }
.editor-actions { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; margin-top: 13px; }
.export-card { margin: 0 16px 17px; padding: 13px; border: 1px solid rgba(var(--green-rgb), .2); border-radius: 13px; background: rgba(var(--green-rgb), .055); }
.export-card { --section: var(--green); --section-rgb: var(--green-rgb); }
.export-card h3 { font-size: 15px; }
.export-card p { color: var(--muted); font-size: 12px; }
.export-card > button { width: 100%; border-color: #202737; color: #fff; background: #202737; }

dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 26px 90px rgba(12, 19, 34, .34);
}
dialog::backdrop { background: rgba(17, 24, 39, .58); backdrop-filter: blur(3px); }
dialog form { padding: 20px; }
dialog .field, dialog .mini-grid, dialog .bank-context-grid, dialog .feedback { margin-top: 13px; }
.dialog-head { display: flex; gap: 12px; justify-content: space-between; }
.dialog-head h2 { font-size: 20px; }
.dialog-head button { width: 44px; height: 44px; flex: 0 0 auto; border: 0; border-radius: 11px; color: var(--ink); background: var(--soft); font-size: 22px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 17px; }
.setup-inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.setup-inline small { color: var(--muted); font-size: 12px; }
.bank-context-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; margin: -1px; padding: 0; border: 0; clip: rect(0, 0, 0, 0); white-space: nowrap; }

html[data-theme="ai"] {
  --red: #6d5dfc;
  --red-strong: #5143d8;
  --red-rgb: 109, 93, 252;
  --focus: #5143d8;
}
html[data-theme="dark"] {
  --ink: #f3f6fb;
  --muted: #acb5c5;
  --line: #364256;
  --line-strong: #4b5870;
  --soft: #202a39;
  --canvas: #0c121d;
  --panel: #151d2a;
  --control: #1a2433;
  --focus: #79b8ff;
  --shadow: 0 16px 48px rgba(0, 0, 0, .3);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, .22);
  color-scheme: dark;
}
html[data-theme="dark"] body { background: radial-gradient(circle at 48% -12%, rgba(var(--red-rgb), .1), transparent 34rem), var(--canvas); }
html[data-theme="dark"] .topbar { border-color: rgba(255, 255, 255, .07); background: rgba(13, 19, 30, .92); }
html[data-theme="dark"] .topbar nav a { color: var(--ink); }
html[data-theme="dark"] .statusbar { border-color: #5f4d21; color: #ffe39b; background: #2c2514; }
html[data-theme="dark"] .statusbar[data-kind="ready"], html[data-theme="dark"] .generation-policy[data-kind="ready"] { border-color: #245f4b; color: #8ae2c2; background: #142e25; }
html[data-theme="dark"] .statusbar[data-kind="error"], html[data-theme="dark"] .generation-policy[data-kind="blocked"], html[data-theme="dark"] .generation-policy[data-kind="error"], html[data-theme="dark"] .feedback { border-color: #70404a; color: #ffabb5; background: #351c23; }
html[data-theme="dark"] .blueprint-summary { background: rgba(21, 29, 42, .94); }
html[data-theme="dark"] .field > span, html[data-theme="dark"] fieldset legend { color: #c4ccda; }
html[data-theme="dark"] .setup-hint { color: #bcd8ff; }
html[data-theme="dark"] .total-pill, html[data-theme="dark"] .review-metrics span { color: #c6d0df; }
html[data-theme="dark"] .empty strong { color: #d4dae5; }
html[data-theme="dark"] .generation-policy, html[data-theme="dark"] .protected-editor, html[data-theme="dark"] .preview .protected-callout { border-color: #5f4d21; color: #ffe39b; background: #2c2514; }
html[data-theme="dark"] .row-remove:hover { background: #381c23; }
html[data-theme="dark"] .question-state { border-color: var(--panel); }

@media (max-width: 1500px) {
  .workspace { grid-template-columns: minmax(210px, 225px) minmax(0, 1fr) minmax(310px, 340px); }
  .field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .allocation-presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1240px) {
  .workspace { grid-template-columns: minmax(210px, 235px) minmax(0, 1fr); }
  .inspector { position: static; grid-column: 1 / -1; max-height: none; overflow: visible; }
  .inspector > [data-inspector-content]:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .65fr); align-items: start; }
  .inspector .tabs, .inspector .preview { grid-column: 1; }
  .inspector .item-editor { grid-column: 2; grid-row: 1 / span 3; }
  .inspector .export-card { grid-column: 1; }
}

@media (max-width: 900px) {
  html { scroll-behavior: auto; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding-inline: 14px; }
  .top-title { display: none; }
  .workspace { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .rail, .inspector { position: static; max-height: none; overflow: visible; }
  .rail { order: 1; }
  .builder { order: 2; }
  .inspector { order: 3; }
  .blueprint-summary { position: static; }
  .question-stepper ol { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evidence-grid { grid-template-columns: minmax(0, 1fr); }
  .source-section, .standards-section { min-height: 0; }
  .check-list { max-height: none; }
  .inspector > [data-inspector-content]:not([hidden]) { display: block; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar { min-height: 64px; padding: 7px 10px; }
  .brand img { width: 36px; height: 36px; }
  .brand small { display: none; }
  .topbar nav a { padding-inline: 10px; }
  .statusbar { padding: 9px 12px; }
  .statusbar > span:last-child { flex-basis: 100%; padding-left: 17px; }
  .workspace { padding: 8px; }
  .panel { border-radius: 15px; }
  .panel-head, .builder-head { min-height: 68px; padding: 13px 14px; }
  .builder-head { align-items: flex-start; }
  .builder-head h2 { font-size: 19px; }
  .builder-state { flex-direction: column; align-items: flex-end; }
  .question-stepper { padding: 12px 12px 3px; }
  .question-stepper a { min-height: 62px; }
  .blueprint-summary { margin: 9px 12px 0; }
  .blueprint-summary dl { min-width: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .blueprint-summary dl > div { border-left: 0; border-top: 1px solid var(--line); }
  .builder form, .question-section { padding: 14px 12px 18px; }
  .question-section > .section-head { margin: -14px -12px 0; padding-inline: 12px; }
  .field-grid, .mini-grid, .mini-grid.three, .bank-context-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .context-stage { padding: 13px; }
  .stage-heading, .section-head { align-items: flex-start; flex-direction: column; }
  .setup-badge { align-self: flex-start; }
  .section-head > div:last-child, .section-tools { width: 100%; justify-content: flex-start; }
  .allocation-presets { grid-template-columns: minmax(0, 1fr); }
  .allocation-wrap table { min-width: 760px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions > span { margin: 0 0 3px; }
  .form-actions button { width: 100%; }
  .question-list { grid-template-columns: minmax(0, 1fr); }
  .protected-editor { align-items: stretch; flex-direction: column; }
  .editor-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-actions button:first-child { grid-column: 1 / -1; }
  .dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  dialog form { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media (forced-colors: active) {
  .panel, .question-stepper a, .blueprint-summary, .blueprint-stage, .contract-section, .allocation-presets button, .question-card, .generation-policy { border: 1px solid CanvasText; }
  .panel { border-top-width: 4px; }
  .question-stepper a[aria-current="step"], .question-card[aria-current="true"], .blueprint-card[aria-current="true"] { outline: 3px solid Highlight; }
  .question-state { border: 2px solid CanvasText; }
}
