:root {
  color-scheme: dark;
  --bg: #10100f;
  --panel: #171715;
  --panel-2: #1d1c19;
  --line: #34322c;
  --text: #f0eee7;
  --muted: #aaa49a;
  --quiet: #777168;
  --brass: #c2a15c;
  --bad: #d68073;
  --good: #8abf9f;
  --review: #d4b06a;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
textarea,
select {
  font: inherit;
}

button,
select {
  min-height: 40px;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 24px;
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(32px, 5vw, 68px);
  line-height: 0.96;
  font-weight: 500;
  letter-spacing: 0;
}

h2,
h3 {
  margin: 0;
  font-weight: 500;
  letter-spacing: 0;
}

h2 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

h3 {
  font-size: clamp(22px, 2.4vw, 30px);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brass);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status {
  color: var(--muted);
  font-size: 13px;
  border: 1px solid var(--line);
  padding: 9px 11px;
  border-radius: 4px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.35fr) minmax(280px, 0.85fr);
  gap: 14px;
  padding-top: 14px;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

.golden-loader {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #121211;
  padding: 10px;
}

.golden-loader select {
  width: 100%;
  margin-top: 8px;
}

.golden-note {
  margin: 8px 0 0;
  color: var(--quiet);
  font-size: 13px;
  line-height: 1.35;
}

.golden-note.is-active {
  color: var(--good);
}

.golden-note.is-edited {
  color: var(--review);
}

textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  color: var(--text);
  background: #0c0c0b;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  line-height: 1.5;
}

select,
button {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
}

button {
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--brass);
}

button:disabled {
  color: var(--quiet);
  cursor: not-allowed;
}

.toolbar,
.panel-head,
.verdicts {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.run-mode-note {
  margin: 0;
  color: var(--quiet);
  font-size: 13px;
  line-height: 1.35;
  max-width: 320px;
}

.verdicts .label {
  flex: 1 0 100%;
}

.reviewer-draft textarea {
  flex: 1 0 100%;
  min-height: 96px;
  box-sizing: border-box;
}

.reviewer-draft .run-gate-actions {
  flex: 1 0 100%;
}

.result-panel,
.eval-panel {
  min-height: 520px;
}

.empty {
  color: var(--quiet);
}

.claim-text {
  margin: 0 0 16px;
  font-size: 24px;
  line-height: 1.18;
  font-weight: 500;
}

.meta-grid,
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.run-eval-context {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}

.run-eval-context > .label {
  grid-column: 1 / -1;
}

.meta,
.metric,
.market,
.recommended-market,
.event,
.inspection {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: #121211;
}

.meta-value,
.truncate {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-value-row,
.inspection-meta,
.copy-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.meta-value-row .meta-value,
.copy-inline .trace {
  flex: 1 1 auto;
}

.inspection-short {
  display: -webkit-box;
  margin: 12px 0 10px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.inspection-details {
  margin: 8px 0 12px;
}

.inspection-details summary {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #181713;
  color: var(--brass);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.inspection-details p {
  max-height: 300px;
  overflow: auto;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.recommended-market {
  margin: 12px 0 14px;
}

.run-market-context,
.run-governance {
  margin: 12px 0 14px;
}

.run-market-context {
  max-height: 340px;
  overflow: auto;
  padding-right: 4px;
}

.run-market-row,
.run-gate,
.run-question-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: #121211;
}

.run-market-row + .run-market-row {
  margin-top: 8px;
}

.run-market-row p,
.run-gate p,
.run-question-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.run-market-row details,
.recommended-market .rules-details {
  margin-top: 8px;
  color: var(--muted);
}

.run-market-row summary,
.recommended-market .rules-details summary {
  cursor: pointer;
  color: var(--brass);
  font-size: 13px;
}

.run-market-row details p,
.market-row details p,
.recommended-market .rules-details p {
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.run-gate {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.85fr);
  gap: 10px;
  align-items: start;
}

.run-question-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.run-gate strong,
.run-question-card strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.run-gate-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.run-gate-actions button {
  flex: 1 1 120px;
}

.verdicts.is-highlighted {
  box-shadow: 0 0 0 1px var(--brass), 0 0 0 4px rgba(194, 161, 92, 0.16);
}

.market-title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.market-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.recommended-market p {
  overflow-wrap: anywhere;
}

.flag-warn {
  color: #d4ad5a;
}

.risk-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.risk-tags span {
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--quiet);
  font-size: 12px;
  line-height: 1.2;
  padding: 5px 7px;
}

.label {
  display: block;
  color: var(--quiet);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.fit-scale {
  margin: 4px 0 14px;
}

.fit-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0d0d0c;
}

.fit-option {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--line);
  padding: 0 8px;
  color: var(--quiet);
  background: #11100e;
  text-align: center;
  font-size: 12px;
  line-height: 1.15;
}

.fit-option:last-child {
  border-right: 0;
}

.fit-option.is-active {
  color: var(--brass);
  box-shadow: inset 0 0 0 1px var(--brass);
  background: #18140e;
}

.flag-bad {
  color: var(--bad);
}

.flag-good {
  color: var(--good);
}

.flag-review {
  color: var(--review);
}

ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

li {
  margin-bottom: 6px;
  color: var(--muted);
}

.event {
  margin-top: 8px;
}

.event strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.event time {
  color: var(--quiet);
  font-size: 11px;
}

.trace {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.copy-button {
  position: relative;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #181713;
  cursor: pointer;
}

.copy-button::before,
.copy-button::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--muted);
  border-radius: 2px;
}

.copy-button::before {
  top: 10px;
  left: 8px;
}

.copy-button::after {
  top: 7px;
  left: 11px;
  background: #181713;
}

.copy-button:hover,
.copy-button.copied {
  border-color: var(--brass);
}

.copy-button:hover::before,
.copy-button:hover::after,
.copy-button.copied::before,
.copy-button.copied::after {
  border-color: var(--brass);
}

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

.trace a {
  color: var(--brass);
  text-decoration: none;
}

.trace a:hover {
  text-decoration: underline;
}

.candidate-workbench {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.candidate-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.candidate-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.candidate-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.candidate-scope-note {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--quiet);
}

.candidate-stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px;
  background: #121211;
}

.candidate-stat strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.25;
}

.candidate-stat a {
  color: var(--brass);
  text-decoration: none;
}

.workflow-board {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(480px, 1.28fr);
  gap: 14px;
  align-items: start;
}

.workflow-rail {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.workflow-step,
.workflow-step-face {
  width: 100%;
  display: block;
  text-align: left;
  padding: 12px;
  background: #121211;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.workflow-step {
  min-height: 92px;
}

.workflow-question {
  padding: 0;
  overflow: hidden;
}

.workflow-step-face {
  min-height: 76px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.workflow-step.is-active {
  border-color: var(--brass);
  background: #17140f;
}

.workflow-step-top,
.workflow-step-body,
.workflow-choice-row,
.screen-prompt {
  display: flex;
  gap: 8px;
}

.workflow-step-top {
  align-items: start;
  justify-content: space-between;
}

.workflow-step-top strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.25;
}

.workflow-step-body {
  margin-top: 10px;
  align-items: start;
  justify-content: space-between;
}

.workflow-step-body .small-label {
  flex: 1 1 0;
}

.workflow-choice-row {
  padding: 0 12px 12px;
}

.workflow-choice-row button,
.screen-prompt button {
  flex: 1 1 0;
}

.workflow-screen {
  min-width: 0;
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 16px;
}

.screen-prompt {
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #121211;
  padding: 12px;
  margin-top: 14px;
}

.screen-prompt p {
  flex: 2 1 260px;
  margin: 0;
  color: var(--muted);
}

.candidate-board {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1.18fr);
  gap: 14px;
  align-items: start;
}

.candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.candidate-row {
  width: 100%;
  display: block;
  min-height: 148px;
  text-align: left;
  padding: 12px;
  background: #121211;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.candidate-row.is-selected {
  border-color: var(--brass);
  background: #17140f;
}

.candidate-row-top,
.candidate-detail-head,
.market-row-main,
.decision-line {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.candidate-row-top strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.25;
}

.candidate-source {
  display: block;
  margin: 10px 0;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.candidate-row-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.candidate-row-grid {
  margin-top: 8px;
}

.detail-grid {
  margin: 12px 0;
}

.detail-grid.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.small-label {
  display: block;
  color: var(--quiet);
  font-size: 11px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.small-label span {
  display: block;
  text-transform: uppercase;
}

.small-label strong {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: none;
}

.candidate-warning {
  display: block;
  margin-top: 10px;
  color: var(--review);
  font-size: 12px;
}

.candidate-tags,
.detail-tags,
.market-row-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.candidate-tags,
.detail-tags {
  margin-top: 8px;
}

.candidate-tags span,
.detail-tags span,
.market-row-chips span,
.status-chip {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 7px;
  font-size: 12px;
  line-height: 1.2;
}

.candidate-tags span,
.detail-tags span,
.market-row-chips span {
  color: var(--quiet);
}

.status-chip {
  flex: 0 0 auto;
  color: var(--muted);
  background: #151513;
  white-space: nowrap;
}

.status-promote {
  color: var(--good);
  border-color: rgba(138, 191, 159, 0.55);
}

.status-loaded,
.status-open,
.status-opened,
.status-ready,
.status-eligible,
.status-mirrored {
  color: var(--good);
  border-color: rgba(138, 191, 159, 0.55);
}

.status-needs-more-rules,
.status-candidate-only,
.status-no-suggestion,
.status-ask,
.status-waiting,
.status-locked,
.status-skipped,
.status-held,
.status-fallback {
  color: var(--review);
  border-color: rgba(212, 176, 106, 0.55);
}

.status-reject,
.status-present {
  color: var(--bad);
  border-color: rgba(214, 128, 115, 0.55);
}

.candidate-detail {
  min-width: 0;
  min-height: 640px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 16px;
}

.candidate-detail-head {
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.authority-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.authority-grid section,
.candidate-copy,
.market-row {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #121211;
  padding: 12px;
}

.authority-grid p,
.candidate-copy p,
.market-row p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.candidate-copy,
.candidate-markets {
  margin-top: 12px;
}

.candidate-copy textarea {
  min-height: 96px;
  box-sizing: border-box;
}

.candidate-markets {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.market-row-main {
  align-items: start;
}

.market-row-main strong {
  display: block;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.market-row details {
  margin-top: 8px;
  color: var(--muted);
}

.market-row summary {
  cursor: pointer;
  color: var(--brass);
  font-size: 13px;
}

@media (max-width: 1040px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .masthead {
    align-items: start;
    flex-direction: column;
  }

  .candidate-head {
    align-items: start;
    flex-direction: column;
  }

  .authority-grid {
    grid-template-columns: 1fr;
  }

  .run-gate {
    grid-template-columns: 1fr;
  }

  .run-question-grid {
    grid-template-columns: 1fr;
  }

  .candidate-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workflow-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .candidate-board,
  .workflow-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    padding: 16px;
  }

  .meta-grid,
  .metric-grid,
  .market-details,
  .candidate-stats,
  .candidate-row-grid,
  .detail-grid,
  .detail-grid.compact {
    grid-template-columns: 1fr;
  }

  .fit-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fit-option:nth-child(2) {
    border-right: 0;
  }

  .fit-option:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .toolbar button,
  .verdicts button,
  #improve-button,
  .candidate-actions,
  .candidate-actions button,
  .candidate-actions select {
    width: 100%;
  }

  .candidate-row-top,
  .candidate-detail-head,
  .market-row-main,
  .decision-line,
  .workflow-step-top,
  .workflow-step-body,
  .screen-prompt {
    align-items: start;
    flex-direction: column;
  }

  .workflow-choice-row {
    flex-direction: column;
  }

  .run-gate-actions {
    flex-direction: column;
  }
}
