:root {
  color-scheme: light;
  --paper: #f3efe6;
  --paper-strong: #fffaf0;
  --ink: #191817;
  --muted: #645f56;
  --line: #24211c;
  --line-soft: #d7cec0;
  --amber: #c5791f;
  --green: #25845e;
  --red: #bd3d35;
  --blue: #2f6288;
  --violet: #6a4ea2;
  --wash: #e6dccd;
  --shadow: 0 18px 40px rgba(28, 24, 19, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(25, 24, 23, 0.045) 1px, transparent 1px),
    linear-gradient(180deg, rgba(25, 24, 23, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 24px 24px;
  font-family: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
}

button,
textarea {
  font: inherit;
  overflow-wrap: anywhere;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1480px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 34px;
}

.mapper-band,
.results-band {
  border: 2px solid var(--line);
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.mapper-band {
  min-height: min(700px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto 1fr;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(280px, 0.72fr) minmax(280px, 1.28fr);
  gap: 18px;
  align-items: end;
  padding: 16px 20px;
  border-bottom: 2px solid var(--line);
  background:
    linear-gradient(135deg, rgba(37, 132, 94, 0.16), transparent 46%),
    linear-gradient(315deg, rgba(197, 121, 31, 0.14), transparent 58%),
    #fff8e9;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 0;
  max-width: 780px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 4vw, 3.45rem);
  line-height: 0.98;
  font-weight: 900;
}

h2 {
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.04;
}

.source-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.source-strip span,
.micro-list span,
.risk-pill,
.badge,
.deadline-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fffdf7;
  font-size: 0.78rem;
  font-weight: 750;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(300px, 0.58fr);
  min-height: 0;
}

.input-panel,
.score-panel {
  padding: 18px;
}

.input-panel {
  border-right: 2px solid var(--line);
}

.panel-head,
.score-topline,
.output-head {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
}

.panel-head p,
.output-head p,
.score-summary {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.action-row,
.copy-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.tab-button,
.copy-button {
  min-height: 40px;
  border: 2px solid var(--line);
  border-radius: 5px;
  padding: 9px 13px;
  color: var(--ink);
  font-weight: 850;
  background: #fffaf1;
  box-shadow: 3px 3px 0 var(--line);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-button {
  color: #fffdf7;
  background: var(--green);
}

.ghost-button:hover,
.tab-button:hover,
.copy-button:hover {
  background: #f2e3cb;
}

.primary-button:hover {
  background: #1f704f;
}

.primary-button:active,
.ghost-button:active,
.tab-button:active,
.copy-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--line);
}

#evidence-input,
.copy-output {
  width: 100%;
  min-height: 380px;
  margin-top: 16px;
  border: 2px solid var(--line);
  border-radius: 5px;
  padding: 16px;
  color: #161514;
  background: #fffdf7;
  box-shadow: inset 0 0 0 4px rgba(37, 132, 94, 0.08);
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.52;
  resize: vertical;
}

.score-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background:
    linear-gradient(180deg, rgba(47, 98, 136, 0.14), transparent 58%),
    #fffaf0;
}

.score-topline h2 {
  margin: 0;
  font-size: clamp(3.4rem, 8vw, 6.4rem);
}

.score-max {
  color: var(--muted);
  font-size: 1.25rem;
  font-family: "Avenir Next", "Gill Sans", "Segoe UI", sans-serif;
}

.risk-pill.neutral {
  color: var(--muted);
}

.risk-pill.low {
  color: var(--green);
}

.risk-pill.medium {
  color: var(--blue);
}

.risk-pill.high {
  color: var(--amber);
}

.risk-pill.critical {
  color: var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 2px solid var(--line);
}

.metric-grid div {
  min-height: 88px;
  padding: 12px;
  background: #fffdf7;
}

.metric-grid div:nth-child(odd) {
  border-right: 2px solid var(--line);
}

.metric-grid div:nth-child(-n + 2) {
  border-bottom: 2px solid var(--line);
}

.metric-grid span {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.15rem;
  font-weight: 900;
}

.metric-grid p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.micro-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.results-band {
  margin-top: 18px;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px;
  border-bottom: 2px solid var(--line);
  background: #ece0ce;
}

.tab-button {
  flex: 0 0 auto;
  box-shadow: none;
}

.tab-button.is-active {
  color: #fffdf7;
  background: var(--line);
}

.pane {
  padding: 18px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  border: 2px solid var(--line);
  background: #fffdf7;
}

th,
td {
  padding: 10px;
  border: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
  line-height: 1.35;
}

th {
  color: #fffdf7;
  background: var(--line);
  font-size: 0.75rem;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
}

.model-cell {
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.badge {
  min-height: 24px;
  margin: 0 4px 4px 0;
  padding: 3px 7px;
  font-size: 0.73rem;
}

.badge.critical,
.deadline-chip.critical {
  border-color: var(--red);
  color: #fffdf7;
  background: var(--red);
}

.badge.high,
.deadline-chip.high {
  border-color: var(--amber);
  background: #ffe3b2;
}

.badge.medium,
.deadline-chip.medium {
  border-color: var(--blue);
  background: #dbeefd;
}

.badge.low,
.deadline-chip.low {
  border-color: var(--green);
  background: #dff4e9;
}

.badge.neutral,
.deadline-chip.neutral {
  background: #f1ece3;
}

.region-grid,
.check-grid,
.queue-list,
.risk-list,
.owner-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.region-item,
.check-item,
.queue-item,
.risk-item,
.owner-item,
.empty-state {
  min-height: 88px;
  border: 2px solid var(--line);
  border-radius: 5px;
  padding: 12px;
  background: #fffdf7;
}

.region-item h3,
.check-item h3,
.queue-item h3,
.risk-item h3,
.owner-item h3,
.empty-state h3 {
  margin: 0 0 7px;
  font-size: 0.98rem;
}

.region-item p,
.check-item p,
.queue-item p,
.risk-item p,
.owner-item p,
.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.split-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.copy-grid {
  justify-content: flex-start;
  margin: 12px 0;
}

.copy-output {
  min-height: 260px;
  margin-top: 0;
}

.copy-status {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--green);
  font-weight: 800;
}

.state-note {
  border-left: 5px solid var(--amber);
}

@media (max-width: 980px) {
  .shell {
    width: min(100% - 18px, 760px);
    padding-top: 9px;
  }

  .masthead,
  .tool-grid,
  .split-output {
    grid-template-columns: 1fr;
  }

  .mapper-band {
    min-height: auto;
  }

  .input-panel {
    border-right: 0;
    border-bottom: 2px solid var(--line);
  }

  .source-strip,
  .action-row {
    justify-content: flex-start;
  }

  #evidence-input {
    min-height: 250px;
  }

  .region-grid,
  .check-grid,
  .queue-list,
  .risk-list,
  .owner-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .masthead,
  .input-panel,
  .score-panel,
  .pane {
    padding: 10px;
  }

  h1 {
    font-size: 1.55rem;
    line-height: 1;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.68rem;
  }

  .panel-head,
  .score-topline,
  .output-head {
    display: block;
  }

  .action-row {
    margin-top: 9px;
  }

  .primary-button,
  .ghost-button,
  .copy-button {
    min-width: 0;
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.9rem;
  }

  .source-strip {
    gap: 6px;
    margin-top: 10px;
  }

  .source-strip span,
  .micro-list span {
    min-height: 24px;
    padding: 4px 7px;
    font-size: 0.7rem;
  }

  #evidence-input {
    min-height: 190px;
    margin-top: 12px;
    font-size: 0.82rem;
  }

  .score-panel {
    gap: 10px;
  }

  .score-topline h2 {
    font-size: 2.4rem;
  }

  .metric-grid div {
    min-height: 66px;
    padding: 8px;
  }

  .metric-grid span {
    font-size: 1.55rem;
  }

  table {
    min-width: 780px;
  }
}
