:root {
  color-scheme: light;
  --paper: #f7f8f2;
  --panel: #ffffff;
  --panel-alt: #f0f5ec;
  --ink: #20261f;
  --muted: #657061;
  --line: #cfd7c7;
  --line-strong: #9fac97;
  --green: #2f6b4f;
  --green-dark: #194832;
  --amber: #b66b1e;
  --red: #b33b34;
  --blue: #35668c;
  --violet: #6a4a7c;
  --yellow: #f0c85a;
  --shadow: 0 18px 50px rgba(34, 48, 34, 0.13);
  --radius: 7px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", "Helvetica Neue", sans-serif;
  line-height: 1.45;
  background:
    linear-gradient(90deg, rgba(47, 107, 79, 0.08) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(0deg, rgba(47, 107, 79, 0.06) 1px, transparent 1px) 0 0 / 44px 44px,
    var(--paper);
}

button,
textarea,
input {
  font: inherit;
}

a {
  color: var(--green-dark);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

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

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 450px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.title-block,
.source-note,
.panel,
.privacy-strip,
.results-section {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.93);
  box-shadow: var(--shadow);
}

.title-block {
  padding: 20px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green-dark);
  font-family: "Bahnschrift", "Aptos Condensed", sans-serif;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Bahnschrift", "Aptos Display", "Segoe UI", sans-serif;
  letter-spacing: 0;
  line-height: 1.03;
}

h1 {
  max-width: 980px;
  font-size: clamp(2.2rem, 4vw, 5rem);
}

h2 {
  font-size: clamp(1.35rem, 2vw, 2.2rem);
}

h3 {
  font-size: 1.05rem;
}

.positioning {
  max-width: 980px;
  margin: 14px 0 0;
  color: #3f4a3c;
  font-size: clamp(1rem, 1.4vw, 1.22rem);
}

.source-note {
  display: grid;
  gap: 10px;
  align-content: center;
  padding: 16px;
  color: #344233;
  font-size: 0.94rem;
}

.source-date,
.local-badge,
.status-chip,
.result-status,
.risk-pill,
.confidence-pill,
.deadline-chip {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #eff5eb;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.1;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, 0.82fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border-radius: var(--radius);
}

.evidence-panel,
.summary-panel {
  padding: 18px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.lens-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.lens-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.lens-switch label {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf7;
  color: #4b5648;
  cursor: pointer;
  font-weight: 800;
}

.lens-switch input {
  position: absolute;
  opacity: 0;
}

.lens-switch label:has(input:checked) {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #4e5a4b;
  font-size: 0.92rem;
}

code {
  padding: 1px 5px;
  border: 1px solid #d7dfcf;
  border-radius: 5px;
  background: #f3f7ef;
  color: #304833;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.88em;
}

textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fffef9;
  color: #1f271d;
  resize: vertical;
  padding: 13px;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(240, 200, 90, 0.85);
  outline-offset: 2px;
}

.input-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.82rem;
}

.input-message {
  min-height: 22px;
  margin: 8px 0 0;
  color: var(--green-dark);
  font-weight: 800;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 13px;
}

button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 850;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.primary-action,
.secondary-action,
.ghost-action,
.copy-button,
.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary-action {
  background: var(--green-dark);
  color: #fff;
  border-color: var(--green-dark);
  padding: 0 16px;
}

.secondary-action {
  background: #fff7d6;
  color: #583c05;
  border-color: #d7b047;
  padding: 0 14px;
}

.ghost-action {
  background: #fff;
  color: #4a5447;
  padding: 0 14px;
}

.button-glyph {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-family: "Cascadia Mono", monospace;
}

.summary-panel {
  position: sticky;
  top: 12px;
}

.score-band {
  display: grid;
  gap: 14px;
  margin: 0 0 14px;
  padding: 15px;
  border: 1px solid var(--line);
  border-left: 7px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-alt);
}

.score-band.state-high {
  border-left-color: var(--red);
  background: #fff0ed;
}

.score-band.state-medium {
  border-left-color: var(--amber);
  background: #fff7e7;
}

.score-band.state-low {
  border-left-color: var(--blue);
  background: #eef6fb;
}

.score-band.state-context {
  border-left-color: var(--violet);
  background: #f6eff9;
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.score-value {
  display: block;
  margin-top: 3px;
  font-size: clamp(1.7rem, 3vw, 3.3rem);
  line-height: 1;
}

.score-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.score-facts div,
.metric-grid div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  padding: 10px;
}

dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

dd {
  margin: 2px 0 0;
  font-weight: 850;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 0 0 14px;
}

.metric-grid dd {
  font-size: 1.45rem;
}

.deadline-strip {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.deadline-strip div,
.next-action {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf7;
  padding: 10px;
}

.deadline-strip span,
.next-action span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.deadline-strip strong,
.next-action strong {
  display: block;
  margin-top: 3px;
}

.risk-note {
  margin: 12px 0 0;
  color: #5c6658;
  font-size: 0.9rem;
}

.privacy-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin: 18px 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.privacy-strip span {
  min-height: 50px;
  padding: 13px;
  border-right: 1px solid var(--line);
  background: #fff;
  font-weight: 850;
}

.privacy-strip span:last-child {
  border-right: 0;
  background: #eef6fb;
}

.results-section {
  border-radius: var(--radius);
  padding: 18px;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.tab-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.tab-button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 13px;
  background: #f9fbf5;
  color: #475342;
}

.tab-button.is-active {
  border-color: var(--green-dark);
  background: var(--green-dark);
  color: #fff;
}

.tab-panel {
  min-height: 260px;
}

.is-hidden {
  display: none;
}

.boundary-grid,
.checklist-grid,
.queue-grid,
.copy-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.boundary-item,
.check-item,
.missing-item,
.copy-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffef9;
  padding: 13px;
}

.boundary-item span,
.check-item span,
.missing-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.boundary-item strong,
.check-item strong,
.missing-item strong {
  display: block;
  margin: 5px 0;
}

.boundary-item p,
.check-item p,
.missing-item p {
  margin: 0;
  color: #576352;
}

.check-item.status-found {
  border-left: 7px solid var(--green);
}

.check-item.status-missing,
.missing-item.status-missing {
  border-left: 7px solid var(--red);
}

.check-item.status-review,
.missing-item.status-review {
  border-left: 7px solid var(--amber);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fffef9;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #edf3e9;
  color: #344231;
  font-size: 0.78rem;
  text-transform: uppercase;
}

td {
  color: #30392d;
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
  font-weight: 800;
}

.risk-pill.high,
.status-high {
  background: #fff0ed;
  color: var(--red);
  border-color: #e4a39e;
}

.risk-pill.medium,
.status-medium {
  background: #fff7e7;
  color: #7a4607;
  border-color: #e3bb71;
}

.risk-pill.low,
.status-low {
  background: #eef6fb;
  color: #244f72;
  border-color: #9ebbd2;
}

.risk-pill.context,
.status-context {
  background: #f6eff9;
  color: var(--violet);
  border-color: #cdb8d8;
}

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

.wide-copy {
  grid-column: 1 / -1;
}

.copy-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.copy-button {
  min-height: 34px;
  padding: 0 11px;
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.copy-feedback {
  min-height: 24px;
  margin: 12px 0 0;
  color: var(--green-dark);
  font-weight: 850;
}

@media (max-width: 1120px) {
  .app-header,
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .summary-panel {
    position: static;
  }

  .privacy-strip,
  .boundary-grid,
  .checklist-grid,
  .queue-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .app-shell {
    width: min(100vw - 18px, 680px);
    padding-top: 9px;
  }

  .title-block,
  .source-note,
  .evidence-panel,
  .summary-panel,
  .results-section {
    padding: 13px;
  }

  .panel-heading,
  .results-header,
  .input-meta,
  .copy-head {
    flex-direction: column;
    align-items: stretch;
  }

  .lens-switch,
  .score-facts,
  .metric-grid,
  .privacy-strip,
  .boundary-grid,
  .checklist-grid,
  .queue-grid,
  .copy-grid {
    grid-template-columns: 1fr;
  }

  .lens-switch {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 10px;
  }

  .lens-switch label {
    min-height: 38px;
    font-size: 0.78rem;
  }

  .field-label {
    margin-bottom: 6px;
    font-size: 0.8rem;
    line-height: 1.3;
  }

  .field-label code:nth-of-type(n+4) {
    display: none;
  }

  #evidence-input {
    height: 150px;
    min-height: 150px;
    max-height: 220px;
    padding: 10px;
    font-size: 0.82rem;
  }

  .input-meta {
    gap: 5px;
    margin-top: 6px;
    font-size: 0.76rem;
  }

  .input-meta span:last-child {
    display: none;
  }

  .input-message {
    min-height: 18px;
    margin-top: 5px;
  }

  .privacy-strip span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .privacy-strip span:last-child {
    border-bottom: 0;
  }

  .action-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
  }

  .action-row button {
    width: auto;
    min-height: 38px;
    padding: 0 6px;
    font-size: 0.8rem;
  }

  .button-glyph {
    width: 18px;
    height: 18px;
  }

  h1 {
    font-size: 1.52rem;
  }

  .positioning {
    margin-top: 8px;
    font-size: 0.88rem;
  }

  .source-note {
    gap: 7px;
    font-size: 0.84rem;
  }

  .source-note span:not(.source-date) {
    display: none;
  }

  .source-date,
  .local-badge,
  .status-chip,
  .result-status,
  .risk-pill,
  .confidence-pill,
  .deadline-chip {
    min-height: 24px;
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  table {
    min-width: 760px;
  }
}
