:root {
  color-scheme: light dark;
  --ink: #111817;
  --ink-2: #17211f;
  --paper: #f2f5f3;
  --paper-2: #e5ebe8;
  --muted: #6d7975;
  --line: #c5cfcb;
  --dark-line: #3a4743;
  --green: #62e89c;
  --coral: #ff6b57;
  --yellow: #ffd166;
  --cyan: #4cc9f0;
  --header: 58px;
}

* { box-sizing: border-box; }
html { background: var(--ink); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--ink);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--dark-line);
  background: var(--ink);
  color: #f8fffc;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}
.engine-proof {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #d7e2de;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: nowrap;
}
.engine-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 209, 102, .13);
}
.engine-proof.ready .engine-dot { background: var(--green); box-shadow: 0 0 0 3px rgba(98, 232, 156, .13); }

.workspace {
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - var(--header));
  display: grid;
  grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
  overflow-x: hidden;
}
.editor {
  min-width: 0;
  padding: 26px 24px 28px;
  background-color: var(--paper);
  background-image: linear-gradient(rgba(17, 24, 23, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(17, 24, 23, .045) 1px, transparent 1px);
  background-size: 24px 24px;
  border-right: 1px solid var(--dark-line);
}
.editor-head { max-width: 560px; }
.eyebrow {
  margin: 0 0 10px;
  color: #087a48;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
h1 {
  width: 100%;
  max-width: 560px;
  margin: 0;
  font-family: "Cabinet Grotesk", Arial, Helvetica, sans-serif;
  font-size: clamp(2rem, 4vw, 4.15rem);
  line-height: .94;
  letter-spacing: 0;
}
.intro {
  max-width: 630px;
  margin: 12px 0 0;
  color: #56625e;
  font-size: 13px;
  line-height: 1.45;
}
.source-boundary {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 18px 0 14px;
  padding: 10px 12px;
  border-left: 4px solid var(--coral);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}
.source-boundary svg { width: 17px; height: 17px; flex: 0 0 auto; color: #be2e1f; }
.sample-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.sample-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #aab5b1;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.sample-button:hover { border-color: var(--ink); transform: translateY(-1px); }
.sample-button svg { width: 16px; height: 16px; }

.schedule-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 13px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}
.schedule-panel legend {
  padding: 0 8px 0 0;
  color: #51605b;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.schedule-panel label { min-width: 0; }
.schedule-panel label span {
  display: block;
  margin-bottom: 5px;
  color: #5d6b66;
  font-size: 10px;
  font-weight: 800;
}
.schedule-panel input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.policy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.field-label, .field-hint { display: block; }
.field-label { font-size: 11px; font-weight: 800; }
.field-hint { margin-top: 2px; color: #6b7773; font-size: 10px; }
.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(86px, 1fr));
  border: 1px solid var(--ink);
}
.segmented button {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.segmented button + button { border-left: 1px solid var(--ink); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.manifest-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 15px 0 6px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.manifest-head span { color: #6e7b76; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: none; }
#roster-input {
  width: 100%;
  height: 174px;
  min-height: 140px;
  resize: vertical;
  padding: 12px;
  border: 1px solid #9ba8a3;
  background: rgba(255,255,255,.92);
  color: #23302c;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.45;
  white-space: pre;
  overflow: auto;
}
.input-error {
  margin: 8px 0 0;
  padding: 9px 10px;
  border-left: 4px solid var(--coral);
  background: #fff;
  color: #972919;
  font-size: 11px;
  font-weight: 700;
}
.editor-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  margin-top: 10px;
}
.compile-button {
  min-width: 0;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid #0c7a46;
  background: var(--green);
  color: #071c12;
  font-weight: 900;
  white-space: nowrap;
}
.compile-button:hover { background: #7af2ad; }
.compile-button svg { width: 18px; height: 18px; }
.icon-button, .proof-reset {
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  background: transparent;
}
.icon-button { height: 48px; color: var(--ink); }
.icon-button svg, .proof-reset svg { width: 17px; height: 17px; }

.proof {
  min-width: 0;
  padding: 26px 24px 30px;
  background: var(--ink-2);
  color: #eef8f4;
}
.proof-brand {
  color: #b9c8c2;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}
.proof-mast {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-top: 5px;
}
.parser-proof {
  min-height: 14px;
  margin: 0 0 7px;
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
}
h2 {
  margin: 0;
  color: var(--coral);
  font-family: "Cabinet Grotesk", Arial, Helvetica, sans-serif;
  font-size: clamp(2rem, 4vw, 4.35rem);
  line-height: .88;
  letter-spacing: 0;
}
.proof.ready h2 { color: var(--green); }
#policy-summary {
  margin: 9px 0 0;
  color: #c5d2cd;
  font-size: 12px;
  line-height: 1.35;
}
.proof-actions {
  display: grid;
  grid-template-columns: auto 44px;
  gap: 8px;
  align-items: center;
}
.export-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid #c99516;
  background: var(--yellow);
  color: #211700;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}
.export-button:disabled { cursor: not-allowed; opacity: .38; }
.export-button svg { width: 16px; height: 16px; }
.proof-reset { color: #d7e5df; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
  border-top: 1px solid var(--dark-line);
  border-bottom: 1px solid var(--dark-line);
}
.metric-strip > div {
  min-width: 0;
  padding: 11px 10px 12px;
  border-right: 1px solid var(--dark-line);
}
.metric-strip > div:first-child { padding-left: 0; }
.metric-strip > div:last-child { border-right: 0; }
.metric-strip span {
  display: block;
  margin-bottom: 5px;
  color: #91a39c;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}
.metric-strip strong {
  display: block;
  min-width: 0;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(.95rem, 1.6vw, 1.35rem);
  line-height: 1;
  overflow-wrap: anywhere;
}
.policy-proof {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--dark-line);
}
.policy-rail { display: flex; align-items: center; min-width: 0; }
.policy-node { width: 11px; height: 11px; flex: 0 0 auto; border: 2px solid currentColor; border-radius: 50%; }
.policy-node.full { color: var(--coral); }
.policy-node.split { color: var(--cyan); }
.policy-line { height: 1px; flex: 1 1 auto; background: #65746f; }
.policy-proof span, .policy-proof strong { display: block; }
.policy-proof span { color: #d8e4df; font-size: 11px; line-height: 1.35; }
.policy-proof strong { margin-top: 3px; color: var(--yellow); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.category-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--dark-line);
}
.category-total {
  min-width: 0;
  padding: 9px 9px 10px;
  border-right: 1px solid var(--dark-line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  overflow-wrap: anywhere;
}
.category-total:first-child { padding-left: 0; }
.category-total:last-child { border-right: 0; }
.category-total span { color: #91a39c; }
.category-total strong { color: #fff; }

.ledger { margin-top: 10px; border: 1px solid var(--dark-line); }
.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 28px;
  color: #879791;
  text-align: center;
}
.empty-state svg { width: 28px; height: 28px; }
.empty-state p { max-width: 340px; margin: 0; font-size: 12px; line-height: 1.45; }
.allocation-row {
  display: grid;
  grid-template-columns: minmax(132px, 1.1fr) minmax(108px, .9fr) minmax(118px, 1fr) minmax(104px, auto);
  min-width: 0;
  border-bottom: 1px solid var(--dark-line);
}
.allocation-row:last-child { border-bottom: 0; }
.allocation-row.is-hold { box-shadow: inset 4px 0 0 var(--coral); background: rgba(255, 107, 87, .045); }
.allocation-cell {
  min-width: 0;
  padding: 10px 9px;
  border-right: 1px solid var(--dark-line);
}
.allocation-cell:last-child { border-right: 0; }
.row-person strong, .row-person span, .row-evidence span, .row-evidence code { display: block; }
.row-person strong { color: #fff; font-size: 11px; overflow-wrap: anywhere; }
.row-person span { margin-top: 4px; color: #8fa19a; font-size: 9px; overflow-wrap: anywhere; }
.row-placement { color: #d4dfdb; font-size: 10px; line-height: 1.35; }
.row-placement strong { color: var(--cyan); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row-evidence span { color: #8fa19a; font-size: 8px; text-transform: uppercase; }
.row-evidence code { margin-top: 5px; color: #bdcbc6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; overflow-wrap: anywhere; }
.row-award { text-align: right; }
.row-award strong { display: block; color: #fff; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; white-space: nowrap; }
.status-pill {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 5px;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 900;
  text-transform: uppercase;
}
.is-hold .status-pill { border-color: var(--coral); color: var(--coral); }
.hold-reason { display: block; margin-top: 5px; color: var(--yellow); font-size: 8px; font-weight: 800; overflow-wrap: anywhere; }
.interpretation {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--dark-line);
  border-bottom: 1px solid var(--dark-line);
}
.interpretation svg { width: 18px; height: 18px; color: var(--yellow); }
.interpretation p { margin: 0; color: #c6d3ce; font-size: 10px; line-height: 1.45; }
.export-status { min-height: 14px; margin: 8px 0 0; color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }

@media (max-width: 1080px) {
  .proof-mast { grid-template-columns: minmax(0, 1fr); }
  .proof-actions { grid-template-columns: minmax(0, 1fr) 44px; }
  .allocation-row { grid-template-columns: minmax(120px, 1fr) minmax(100px, .85fr) minmax(110px, 1fr); }
  .row-award { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left; border-top: 1px solid var(--dark-line); }
}

@media (max-width: 760px) {
  :root { --header: 56px; }
  html { scroll-behavior: auto; }
  .topbar { padding: 0 12px; }
  .brand { font-size: 12px; }
  .brand-mark { width: 30px; height: 30px; }
  .engine-proof { max-width: 126px; font-size: 8px; overflow: hidden; text-overflow: ellipsis; }
  body.proof-focus .topbar { position: static; }
  .workspace { display: flex; flex-direction: column; min-height: 0; }
  .editor { order: 1; padding: 22px 12px 24px; border-right: 0; }
  .proof { order: 2; padding: 18px 12px 24px; }
  h1 { max-width: 100%; font-size: clamp(2.15rem, 10.7vw, 3rem); line-height: .97; }
  .intro { font-size: 12px; }
  .source-boundary { align-items: flex-start; }
  .sample-actions { grid-template-columns: 1fr; }
  .schedule-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .policy-row { grid-template-columns: 1fr; }
  .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #roster-input { height: 230px; }
  .proof-mast { grid-template-columns: 1fr; }
  h2 { font-size: clamp(2.25rem, 12vw, 3.15rem); }
  .proof-actions { grid-template-columns: minmax(0, 1fr) 44px; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-strip > div { min-height: 68px; border-bottom: 1px solid var(--dark-line); }
  .metric-strip > div:nth-child(2) { border-right: 0; }
  .metric-strip > div:nth-child(3), .metric-strip > div:nth-child(4) { border-bottom: 0; }
  .metric-strip > div:nth-child(3) { padding-left: 0; }
  .policy-proof { grid-template-columns: 70px minmax(0, 1fr); }
  .allocation-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); }
  .allocation-cell { border-right: 0; }
  .row-person, .row-placement { border-bottom: 1px solid var(--dark-line); }
  .row-person { border-right: 1px solid var(--dark-line); }
  .row-evidence { border-right: 1px solid var(--dark-line); }
  .row-award { grid-column: auto; border-top: 0; display: block; text-align: right; }
}

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