:root {
  color-scheme: light;
  --page: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-blue: #edf5ff;
  --ink: #18212b;
  --muted: #617083;
  --line: #d8dee8;
  --line-strong: #adb9c9;
  --blue: #185ea5;
  --blue-strong: #0f3d70;
  --blue-soft: #e4f0ff;
  --green: #16714a;
  --green-soft: #e3f5ec;
  --amber: #9b6612;
  --amber-soft: #fff0d6;
  --red: #b13a3d;
  --red-soft: #f9e4e5;
  --plum: #6c4f93;
  --plum-soft: #eee7f7;
  --gray-soft: #edf1f5;
  --shadow: 0 16px 32px rgba(24, 33, 43, 0.08);
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  background:
    linear-gradient(90deg, rgba(24, 94, 165, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(22, 113, 74, 0.04) 1px, transparent 1px),
    var(--page);
  background-size: 30px 30px;
  color: var(--ink);
  font-family: Aptos, "IBM Plex Sans", "Helvetica Neue", ui-sans-serif, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-width: 320px;
  margin: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
a,
textarea {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--blue);
  font-weight: 730;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--blue-strong);
}

code {
  padding: 1px 4px;
  border-radius: 4px;
  background: var(--gray-soft);
  color: #243447;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
}

h1,
h2,
h3,
p,
td,
th,
button,
textarea,
span,
strong,
dd,
dt,
li,
pre {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  max-width: 980px;
  font-size: clamp(1.2rem, 2vw, 1.72rem);
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.32;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.34;
  letter-spacing: 0;
}

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0 34px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 0 2px 14px;
  border-bottom: 1px solid var(--line);
}

.title-block {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.positioning {
  max-width: 980px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.source-note {
  display: flex;
  flex: 0 1 520px;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  color: var(--muted);
  font-size: 0.74rem;
  text-align: right;
}

.source-date {
  color: var(--ink);
  font-weight: 760;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(410px, 0.95fr);
  gap: 14px;
  min-height: min(690px, calc(100vh - 126px));
  padding: 14px 0;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.evidence-panel,
.summary-panel {
  display: flex;
  flex-direction: column;
  padding: 18px;
}

.panel-heading,
.results-header,
.work-heading,
.copy-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.local-badge,
.status-chip,
.result-status,
.work-heading span {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 730;
  line-height: 1.2;
  text-align: center;
}

.field-label {
  margin: 16px 0 7px;
  color: #354255;
  font-size: 0.78rem;
  font-weight: 720;
}

.lens-switch {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(100%, 540px);
  margin: 14px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

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

.lens-switch label {
  min-width: 0;
}

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

.lens-switch span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.15;
  text-align: center;
  cursor: pointer;
}

.lens-switch input:checked + span {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 16px rgba(24, 94, 165, 0.22);
}

textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 330px;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
  background: #fbfcfe;
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 94, 165, 0.14);
}

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

.input-message {
  min-height: 19px;
  margin: 6px 0 0;
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 720;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.primary-action,
.secondary-action,
.ghost-action,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 780;
  cursor: pointer;
}

.primary-action {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.secondary-action {
  border-color: #8fb3d7;
  background: var(--blue-soft);
  color: var(--blue-strong);
}

.ghost-action {
  background: #fff;
}

.primary-action:hover,
.secondary-action:hover,
.ghost-action:hover,
.copy-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(24, 33, 43, 0.12);
}

.button-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 900;
}

.secondary-action .button-glyph,
.ghost-action .button-glyph {
  background: rgba(24, 94, 165, 0.1);
}

.summary-panel {
  justify-content: space-between;
}

.score-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  margin: 16px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.score-band.state-ready {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.score-band.state-watch {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

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

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

.score-value {
  display: block;
  margin-top: 2px;
  font-size: clamp(1.38rem, 3vw, 2.7rem);
  line-height: 1.05;
}

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

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

.score-facts dt,
.metric-grid dt,
.deadline-strip span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 720;
}

.score-facts dd,
.metric-grid dd,
.deadline-strip strong {
  display: block;
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
}

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

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

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

.next-action {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #9fc5ad;
  border-radius: var(--radius);
  background: var(--green-soft);
}

.next-action span {
  display: block;
  color: #3b7054;
  font-size: 0.72rem;
  font-weight: 780;
  text-transform: uppercase;
}

.next-action strong {
  display: block;
  margin-top: 2px;
  font-size: 0.9rem;
}

.risk-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

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

.privacy-strip span {
  min-height: 42px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: #3b4a5d;
  font-size: 0.78rem;
  font-weight: 760;
  text-align: center;
}

.results-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.results-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.tab-bar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.tab-button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
  cursor: pointer;
}

.tab-button.is-active {
  border-color: #96b8d7;
  background: #fff;
  color: var(--blue-strong);
}

.tab-panel {
  padding: 16px 18px 18px;
}

.is-hidden {
  display: none;
}

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

table {
  width: 100%;
  min-width: 790px;
  border-collapse: collapse;
}

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

th {
  background: var(--surface-soft);
  color: #425169;
  font-size: 0.72rem;
  font-weight: 820;
  text-transform: uppercase;
}

td {
  color: #233143;
  font-size: 0.8rem;
}

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

.empty-row td,
.empty-copy {
  color: var(--muted);
  font-style: italic;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 820;
  line-height: 1.15;
}

.badge-high,
.status-high {
  background: var(--red-soft);
  color: var(--red);
}

.badge-watch,
.status-watch {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-ready,
.status-ready {
  background: var(--green-soft);
  color: var(--green);
}

.badge-info,
.status-info {
  background: var(--blue-soft);
  color: var(--blue-strong);
}

.status-unknown {
  background: var(--gray-soft);
  color: var(--muted);
}

.risk-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.risk-card,
.copy-card,
.work-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.risk-card {
  padding: 12px;
}

.risk-card h3 {
  margin-bottom: 7px;
}

.risk-card p {
  margin: 7px 0 0;
  color: #43536a;
  font-size: 0.78rem;
}

.work-section {
  padding: 14px;
}

.sequence-list,
.work-list {
  margin: 12px 0 0;
  padding-left: 21px;
}

.sequence-list li,
.work-list li {
  margin: 8px 0;
  color: #2d3d50;
  font-size: 0.83rem;
}

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

.copy-card {
  padding: 12px;
}

.copy-button {
  min-height: 30px;
  padding: 5px 9px;
  border-color: #9fb2c8;
  background: #fff;
  color: var(--blue-strong);
  font-size: 0.74rem;
}

pre {
  min-height: 138px;
  max-height: 320px;
  margin: 10px 0 0;
  overflow: auto;
  white-space: pre-wrap;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: #233143;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.76rem;
  line-height: 1.48;
}

.copy-status {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 760;
}

@media (max-width: 980px) {
  .app-header,
  .panel-heading,
  .results-header {
    align-items: stretch;
    flex-direction: column;
  }

  .source-note {
    align-items: flex-start;
    flex: none;
    text-align: left;
  }

  .tool-grid {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  textarea {
    min-height: 280px;
  }

  .privacy-strip,
  .metric-grid,
  .deadline-strip,
  .risk-grid,
  .copy-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1540px);
    padding-top: 10px;
  }

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

  .lens-switch {
    grid-template-columns: 1fr;
    border-radius: var(--radius);
  }

  .lens-switch span {
    border-radius: var(--radius);
  }

  .score-facts {
    grid-template-columns: 1fr;
  }

  .action-row button {
    flex: 1 1 100%;
  }
}
