:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #edf1f4;
  --text: #1e1e1e;
  --heading: #003349;
  --muted: #4b4f54;
  --border: #d5dbe0;
  --control-border: #6b7177;
  --accent: #0077c8;
  --accent-hover: #005f9e;
  --accent-soft: #e5f1fa;
  --on-accent: #ffffff;
  --focus: #0077c8;
  --danger: #a94442;
  --success: #3c763d;
  --success-bg: #dff0d8;
  --brand: #003349;
  --on-brand: #ffffff;
  --on-brand-muted: #c9d8e0;
  --brand-accent: #8edd65;
  --brand-gradient: linear-gradient(90deg, #0077c8, #8edd65);
  --shadow: 0 1px 3px rgba(0, 51, 73, 0.08);
  --card-hover-bg: #ffffff;
  --card-hover-shadow: 0 6px 16px rgba(0, 51, 73, 0.14), 0 2px 4px rgba(0, 51, 73, 0.08);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f172a;
    --surface: #152036;
    --surface-2: #1e293b;
    --text: #cbd5e1;
    --heading: #e2e8f0;
    --muted: #94a3b8;
    --border: #253248;
    --control-border: #7c8ba1;
    --accent: #5eead4;
    --accent-hover: #99f6e4;
    --accent-soft: #173244;
    --on-accent: #0f172a;
    --focus: #5eead4;
    --danger: #fda4af;
    --success: #86efac;
    --success-bg: #1a333d;
    --brand: #0f172a;
    --on-brand: #e2e8f0;
    --on-brand-muted: #94a3b8;
    --brand-accent: #5eead4;
    --brand-gradient: linear-gradient(#1e293b, #1e293b);
    --shadow: none;
    --card-hover-bg: #1a253b;
    --card-hover-shadow: inset 0 1px 0 0 rgba(148, 163, 184, 0.1), 0 10px 24px -6px rgba(2, 6, 23, 0.7);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #152036;
  --surface-2: #1e293b;
  --text: #cbd5e1;
  --heading: #e2e8f0;
  --muted: #94a3b8;
  --border: #253248;
  --control-border: #7c8ba1;
  --accent: #5eead4;
  --accent-hover: #99f6e4;
  --accent-soft: #173244;
  --on-accent: #0f172a;
  --focus: #5eead4;
  --danger: #fda4af;
  --success: #86efac;
  --success-bg: #1a333d;
  --brand: #0f172a;
  --on-brand: #e2e8f0;
  --on-brand-muted: #94a3b8;
  --brand-accent: #5eead4;
  --brand-gradient: linear-gradient(#1e293b, #1e293b);
  --shadow: none;
  --card-hover-bg: #1a253b;
  --card-hover-shadow: inset 0 1px 0 0 rgba(148, 163, 184, 0.1), 0 10px 24px -6px rgba(2, 6, 23, 0.7);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Noto Sans", "Atkinson Hyperlegible", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

main:focus,
h2[tabindex="-1"]:focus {
  outline: none;
}

.wrap {
  width: min(1180px, 100% - 2rem);
  margin-inline: auto;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 10;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Header and hero (one navy masthead) */
.app-header,
.hero {
  background: var(--brand);
  color: var(--on-brand);
}

.app-header :focus-visible,
.hero :focus-visible {
  outline-color: var(--brand-accent);
}

.app-header .btn-ghost {
  border-color: var(--on-brand-muted);
  color: var(--on-brand);
}

.app-header .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
}

.hero {
  margin-bottom: 2rem;
  padding-block: 1.5rem 2.25rem;
  border-bottom: 4px solid transparent;
  border-image: var(--brand-gradient) 1;
}

.hero h1 {
  color: var(--on-brand);
}

.hero .intro {
  margin-bottom: 1.25rem;
  color: var(--on-brand-muted);
  font-size: 1.125rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-hero {
  background: var(--brand-accent);
  color: var(--brand);
}

.btn-hero:hover {
  background: var(--on-brand);
}

.hero .btn-hero-secondary {
  border-color: var(--on-brand-muted);
  color: var(--on-brand);
}

.btn-hero-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.byline {
  margin: 1.25rem 0 0;
  font-size: 0.9375rem;
  color: var(--on-brand-muted);
}

.byline a {
  color: var(--brand-accent);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.75rem;
}

.brand {
  margin: 0;
  font-weight: 700;
}

main {
  padding-bottom: 3rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

h1,
h2,
h3,
h4 {
  color: var(--heading);
  font-weight: 700;
}

h1 {
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

/* Short accent bar under each section heading */
.panel h2::after {
  content: "";
  display: block;
  width: 2.5rem;
  height: 3px;
  margin-top: 0.5rem;
  border-radius: 2px;
  background: var(--accent);
}

h3 {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.0625rem;
}

/* Sub-sections inside the results panel */
.results > h3,
.summary-grid h3 {
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.1875rem;
  font-weight: 700;
}

.intro {
  max-width: 70ch;
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* Panels */
.panel {
  margin-bottom: 1.5rem;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 1.5rem;
  align-items: start;
}

.workspace .panel {
  margin-bottom: 0;
}

.workspace + .panel {
  margin-top: 1.5rem;
}

.notice {
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
}

.notice-error {
  border-left-color: var(--danger);
}

/* How it works */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 700;
}

.steps p {
  margin: 0;
  color: var(--muted);
}

.steps strong {
  display: block;
  color: var(--heading);
}

.scenario-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sample-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.sample-notice p {
  margin: 0;
  max-width: 65ch;
}

/* Scenario */
.scenario-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem 1rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.badge {
  margin: 0;
  padding: 0.125rem 0.625rem;
  border: 1px solid var(--control-border);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
}

.badge.is-submitted {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-bg);
}

.scenario-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.scenario-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-top: 4px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  transition: box-shadow 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.scenario-card:hover,
.scenario-card:focus-within {
  background: var(--card-hover-bg);
  box-shadow: var(--card-hover-shadow);
  transform: translateY(-2px);
}

@media (prefers-reduced-motion: reduce) {
  .scenario-card {
    transition: none;
  }

  .scenario-card:hover,
  .scenario-card:focus-within {
    transform: none;
  }
}

.scenario-card.is-current {
  border-color: var(--accent);
  border-top-color: var(--accent);
}

.scenario-card h3,
.scenario-card p {
  margin: 0;
}

.scenario-card .btn,
.scenario-card .badge {
  margin-top: auto;
}

.scenario-status {
  font-size: 0.9375rem;
  font-weight: 600;
}

.is-current-badge {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.meta div {
  padding: 0.625rem 0.75rem;
  background: var(--surface-2);
  border-radius: 6px;
}

.meta dt {
  font-size: 0.8125rem;
  color: var(--muted);
}

.meta dd {
  margin: 0;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 4px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--control-border);
  color: var(--text);
}

.btn-secondary:hover,
.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  border-color: var(--control-border);
  color: var(--text);
}

.btn-small {
  min-height: 36px;
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.btn-danger {
  color: var(--danger);
}

.icon {
  width: 1em;
  height: 1em;
}

/* Form */
.field {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-weight: 600;
}

.req {
  color: var(--danger);
}

.hint {
  margin: 0.125rem 0 0.375rem;
  font-size: 0.875rem;
  color: var(--muted);
}

input[type="text"],
textarea,
select {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.hint + input,
.hint + textarea {
  margin-top: 0;
}

textarea {
  resize: vertical;
}

[aria-invalid="true"] {
  border-color: var(--danger);
  border-width: 2px;
}

.error {
  margin: 0.375rem 0 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--danger);
}

.criterion-help {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.criterion-help:not(:empty) {
  padding: 0.625rem 0.75rem;
  background: var(--surface-2);
  border-radius: 6px;
}

.criterion-help p {
  margin: 0 0 0.375rem;
}

.criterion-help p:last-child {
  margin-bottom: 0;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Findings list */
.count {
  font-weight: 400;
  color: var(--muted);
}

.findings {
  margin: 0;
  padding: 0;
  list-style: none;
}

.finding {
  padding: 1rem 0;
  border-top: 1px solid var(--border);
}

.finding:first-child {
  border-top: 0;
  padding-top: 0;
}

.finding h3 {
  margin: 0 0 0.375rem;
  font-size: 1rem;
}

.finding-number {
  font-family: var(--mono);
  color: var(--muted);
}

.finding p {
  margin: 0 0 0.5rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.finding-details {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
}

.finding-details dt {
  font-weight: 600;
  color: var(--muted);
}

.finding-details dd {
  margin: 0 0 0.375rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sc-tag {
  display: inline-block;
  padding: 0.0625rem 0.5rem;
  border: 1px solid var(--control-border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.finding-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Results */
.score {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface-2);
  border-radius: 8px;
}

.score-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.answer-key {
  margin: 0;
  padding: 0;
  list-style: none;
}

.violation {
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--control-border);
  border-radius: 6px;
}

.violation.is-identified {
  border-left-color: var(--success);
}

.violation h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
}

.violation-id {
  font-family: var(--mono);
  color: var(--muted);
}

.violation dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.375rem 1rem;
  margin: 0 0 0.75rem;
}

.violation dt {
  font-weight: 600;
  color: var(--muted);
}

.violation dd {
  margin: 0;
}

.violation code {
  font-family: var(--mono);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.matches {
  font-size: 0.9375rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: fit-content;
  padding: 0.375rem 0.75rem 0.375rem 0.5rem;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  cursor: pointer;
}

.check input {
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  accent-color: var(--success);
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.summary-list {
  margin: 0;
  padding-left: 1.25rem;
}

.summary-list li {
  margin-bottom: 0.25rem;
}

/* Footer */
.app-footer {
  padding-block: 1.5rem;
  border-top: 4px solid transparent;
  border-image: var(--brand-gradient) 1;
  background: var(--brand);
  font-size: 0.875rem;
  color: var(--on-brand-muted);
}

.app-footer a {
  color: var(--brand-accent);
}

.app-footer :focus-visible {
  outline-color: var(--brand-accent);
}

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

@media (max-width: 480px) {
  .panel {
    padding: 1rem;
  }

  .violation dl {
    grid-template-columns: 1fr;
  }

  .violation dd {
    margin-bottom: 0.375rem;
  }
}
