@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ── Design tokens ── */
:root {
  --page: #111111;
  --panel: #1b1b1b;
  --panel-soft: #171717;
  --ink: #f1f1f1;
  --muted: #b4b4b4;
  --dim: #888888;
  --line: #353535;
  --line-light: #474747;
  --accent: #d9d9d9;
  --pass: #a8d4a0;
  --conditional: #dfc17c;
  --fail: #f0a4a4;
  --radius: 10px;
}

/* ── Reset ── */
* {
  box-sizing: border-box;
}

html {
  background: var(--page);
  color-scheme: dark;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type='checkbox'] {
  cursor: pointer;
}

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

/* ── App shell ── */
.app-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 20px;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 1px 20px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line-light);
  border-radius: 8px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  letter-spacing: -0.08em;
}

.eyebrow,
.section-label {
  margin: 0;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin: 1px 0 0;
  color: var(--ink);
  font-size: clamp(28px, 3vw, 37px);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 1.08;
}

h2 {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

/* ── Grid layout ── */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  margin-top: 20px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

/* ── Control panel (input side) ── */
.control-card {
  position: sticky;
  top: 16px;
  padding: 20px;
}

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

fieldset {
  margin: 0;
  padding: 16px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.primary-inputs {
  padding-top: 0;
  border-top: 0;
}

legend {
  margin-bottom: 12px;
  padding: 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

label:not(.switch-label) {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 12px;
}

label:not(.switch-label) > span:first-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

em {
  color: var(--dim);
  font-size: 11px;
  font-style: normal;
}

input[type='number'],
select {
  width: 100%;
  min-height: 43px;
  padding: 9px 12px;
  border: 1px solid var(--line-light);
  border-radius: 8px;
  outline: 0;
  background: #111111;
  color: var(--ink);
  font-size: 14px;
  transition: border-color 150ms ease, background 150ms ease;
}

input[type='number']:hover,
select:hover {
  border-color: #666666;
}

input[type='number']:focus,
select:focus,
summary:focus-visible,
button:focus-visible,
a:focus-visible {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(217, 217, 217, 0.16);
}

input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.resolution-row,
.two-up {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 9px;
}

.two-up {
  grid-template-columns: 0.75fr 1.25fr;
}

.resolution-row label {
  min-width: 0;
}

.times {
  padding-bottom: 11px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 18px;
}

/* ── Preset buttons ── */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.preset {
  padding: 7px 9px;
  border: 1px solid var(--line-light);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}

.preset:hover,
.preset.is-selected {
  border-color: var(--accent);
  background: #2a2a2a;
  color: var(--ink);
}

/* ── Advanced settings accordion ── */
.advanced-settings {
  border-top: 1px solid var(--line);
}

.advanced-settings summary,
.gate-row summary {
  list-style: none;
}

.advanced-settings summary::-webkit-details-marker,
.gate-row summary::-webkit-details-marker {
  display: none;
}

.advanced-settings > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 0;
  color: var(--ink);
  cursor: pointer;
}

.advanced-settings > summary > span:first-child {
  display: grid;
  gap: 3px;
}

.advanced-settings summary strong {
  font-size: 14px;
}

.advanced-settings summary small {
  overflow: hidden;
  color: var(--dim);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-chevron {
  display: inline-block;
  color: var(--dim);
  font-size: 16px;
  line-height: 1;
  transition: transform 160ms ease;
}

details[open] > summary .summary-chevron {
  transform: rotate(180deg);
}

.advanced-body {
  padding-bottom: 3px;
}

.advanced-body fieldset:first-child {
  padding-top: 0;
  border-top: 0;
}

/* ── Toggle / switch ── */
.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 5px 0 13px;
}

.toggle-line.is-muted {
  opacity: 0.55;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}

.switch-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 32px;
  height: 19px;
  border: 1px solid var(--line-light);
  border-radius: 999px;
  background: #222222;
}

.switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #888888;
  content: '';
  transition: transform 150ms ease, background 150ms ease;
}

.switch-label input:checked + .switch {
  background: #3e3e3e;
}

.switch-label input:checked + .switch::after {
  background: var(--accent);
  transform: translateX(13px);
}

.switch-label input:focus-visible + .switch {
  box-shadow: 0 0 0 2px rgba(217, 217, 217, 0.16);
}

.field-note {
  margin: -1px 0 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.55;
}

/* ── Result column ── */
.result-column {
  display: grid;
  gap: 14px;
  min-width: 0;
}

/* ── Verdict card (hero) ── */
.verdict-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 28px 26px;
  border-left: 4px solid var(--pass);
  background: var(--panel);
}

.verdict-card[data-status='conditional'] {
  border-left-color: var(--conditional);
}

.verdict-card[data-status='fail'] {
  border-left-color: var(--fail);
}

.verdict-icon {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-top: 2px;
  border: 2px solid var(--pass);
  border-radius: 50%;
  color: var(--pass);
  font-family: 'DM Mono', monospace;
  font-size: 22px;
  font-weight: 700;
}

.verdict-card[data-status='conditional'] .verdict-icon {
  border-color: var(--conditional);
  color: var(--conditional);
}

.verdict-card[data-status='fail'] .verdict-icon {
  border-color: var(--fail);
  color: var(--fail);
}

.verdict-copy {
  min-width: 0;
}

.mode-chip {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 4px 8px;
  border: 1px solid var(--line-light);
  border-radius: 5px;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  white-space: nowrap;
}

.verdict-copy h2 {
  margin: 10px 0 8px;
  color: var(--ink);
  font-size: clamp(34px, 4vw, 48px);
  letter-spacing: -0.06em;
  line-height: 1;
}

.verdict-card[data-status='pass'] .verdict-copy h2 {
  color: var(--pass);
}

.verdict-card[data-status='conditional'] .verdict-copy h2 {
  color: var(--conditional);
}

.verdict-card[data-status='fail'] .verdict-copy h2 {
  color: var(--fail);
}

.verdict-copy p {
  max-width: 700px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Gates wrapper (collapsible) ── */
.gates-wrapper {
  overflow: hidden;
}

.gates-wrapper > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  cursor: pointer;
  list-style: none;
}

.gates-wrapper > summary::-webkit-details-marker {
  display: none;
}

.gates-summary-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gates-summary-content .section-label {
  font-size: 10px;
}

.gates-summary-content strong {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* Status coloring on the gates headline */
.gates-wrapper[data-all-pass='true'] .gates-summary-content strong {
  color: var(--pass);
}

.gates-wrapper[data-all-pass='false'] .gates-summary-content strong {
  color: var(--fail);
}

.gate-list {
  display: grid;
  gap: 9px;
  padding: 0 20px 20px;
}

/* ── Individual gate row ── */
.gate-row {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.gate-row[data-status='fail'] {
  border-color: rgba(240, 164, 164, 0.65);
}

.gate-row > summary {
  padding: 13px 14px 12px;
  cursor: pointer;
}

.gate-head {
  display: grid;
  grid-template-columns: 27px minmax(0, 1fr) auto 16px;
  align-items: center;
  gap: 10px;
}

.gate-status {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line-light);
  border-radius: 50%;
  color: var(--accent);
  font-family: 'DM Mono', monospace;
  font-size: 13px;
}

.gate-row[data-status='fail'] .gate-status {
  border-color: var(--fail);
  color: var(--fail);
}

.gate-name {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.gate-name strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gate-name small {
  overflow: hidden;
  color: var(--dim);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gate-value {
  display: flex;
  justify-content: flex-end;
  min-width: 140px;
}

.gate-value strong {
  color: var(--ink);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.gate-track {
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #303030;
}

.bar-fill {
  width: var(--bar-width, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 220ms ease, background 160ms ease;
}

.bar-fill[data-state='fail'] {
  background: var(--fail);
}

/* ── Gate detail (expanded) ── */
.gate-detail {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 13px 14px 14px 51px;
  border-top: 1px solid var(--line);
  background: #151515;
}

.detail-item {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.detail-item span {
  color: var(--dim);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.detail-item strong {
  overflow: hidden;
  color: var(--ink);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gate-row[data-status='fail'] .detail-item strong {
  color: var(--fail);
}

/* ── Footer ── */
.footer {
  padding: 16px 1px 0;
  color: var(--dim);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
}

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

/* ── Responsive ── */
@media (max-width: 900px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .control-card {
    position: static;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 24px, 560px);
    padding-top: 16px;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
  }

  .verdict-card {
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 20px;
  }

  .verdict-copy h2 {
    font-size: 34px;
  }

  .gate-head {
    grid-template-columns: 27px minmax(0, 1fr) 16px;
  }

  .gate-value {
    grid-column: 2 / 3;
    justify-content: flex-start;
    min-width: 0;
    margin-top: 4px;
  }

  .gate-head .summary-chevron {
    grid-column: 3;
    grid-row: 1 / span 2;
  }

  .gate-detail {
    grid-template-columns: 1fr;
    padding-left: 14px;
  }
}

@media (max-width: 400px) {
  .brand-lockup {
    gap: 10px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  h1 {
    font-size: 27px;
  }
}
