/* Gundam Match Lab Industrial Instrument design system */

:root {
  color-scheme: light;
  --color-background: #ecefeb;
  --color-surface: #fafbf8;
  --color-surface-raised: #f2f4f0;
  --color-surface-strong: #e5e8e3;
  --color-text-primary: #171a18;
  --color-text-secondary: #626a65;
  --color-text-inverse: #ffffff;
  --color-border: #d5d9d4;
  --color-border-strong: #9fa7a1;
  --color-accent: #167987;
  --color-accent-strong: #0e616b;
  --color-accent-soft: #dcecee;
  --color-success: #2a7055;
  --color-success-soft: #e2eee7;
  --color-warning: #806328;
  --color-warning-soft: #f0ebdf;
  --color-error: #963f43;
  --color-error-soft: #f2e5e5;
  --color-info: #5b6a6e;
  --color-info-soft: #e7ebea;
  --color-data: #8b9690;
  --color-data-strong: #3a4440;
  --color-emphasis-surface: #202521;
  --color-emphasis-text: #ffffff;
  --color-emphasis-muted: #cbd3ce;
  --color-emphasis-highlight: #f2c85c;
  --color-focus: #0e7481;
  --color-overlay: rgba(12, 16, 18, 0.62);

  --instrument-paper: var(--color-background);
  --instrument-surface: var(--color-surface);
  --instrument-surface-raised: var(--color-surface-raised);
  --instrument-ink: var(--color-text-primary);
  --instrument-muted: var(--color-text-secondary);
  --instrument-rule: var(--color-border);
  --instrument-accent: var(--color-accent);
  --instrument-success: var(--color-success);
  --instrument-warning: var(--color-warning);
  --instrument-danger: var(--color-error);
  --instrument-focus: var(--color-focus);

  --font-display: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --radius-small: 3px;
  --radius-medium: 5px;
  --radius-large: 7px;
  --radius-xlarge: 8px;

  --shadow-small: 0 1px 1px rgba(19, 24, 21, 0.05);
  --shadow-medium: 0 12px 32px rgba(19, 24, 21, 0.08);
  --shadow-large: 0 24px 56px rgba(19, 24, 21, 0.14);

  --type-display: 2.75rem;
  --type-h1: 2.05rem;
  --type-h2: 1.5rem;
  --type-h3: 1.05rem;
  --type-body: 0.9375rem;
  --type-small: 0.78125rem;
  --type-caption: 0.6875rem;
  --content-max: 1440px;

  /* Legacy aliases keep every simulator module on the same semantic system. */
  --bg: var(--color-background);
  --panel: var(--color-surface);
  --ink: var(--color-text-primary);
  --muted: var(--color-text-secondary);
  --line: var(--color-border);
  --red: var(--color-error);
  --blue: var(--color-data-strong);
  --green: var(--color-success);
  --amber: var(--color-warning);
  --yellow: #c69a2a;
  --cyan: var(--color-data);
  --soft-blue: var(--color-surface-raised);
  --soft-green: var(--color-success-soft);
  --soft-yellow: var(--color-warning-soft);
  --shadow: var(--shadow-medium);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --color-background: #111310;
  --color-surface: #171a17;
  --color-surface-raised: #1d211d;
  --color-surface-strong: #272c27;
  --color-text-primary: #f0f2ed;
  --color-text-secondary: #a2aaa4;
  --color-text-inverse: #0d1113;
  --color-border: #303630;
  --color-border-strong: #535d55;
  --color-accent: #79c8ce;
  --color-accent-strong: #a0dce0;
  --color-accent-soft: #1b3334;
  --color-success: #78b998;
  --color-success-soft: #1d3026;
  --color-warning: #c8aa6c;
  --color-warning-soft: #30291d;
  --color-error: #d88b8e;
  --color-error-soft: #332123;
  --color-info: #9ba7a3;
  --color-info-soft: #252b28;
  --color-data: #647069;
  --color-data-strong: #c6cdc8;
  --color-emphasis-surface: #202521;
  --color-emphasis-text: #ffffff;
  --color-emphasis-muted: #cbd3ce;
  --color-emphasis-highlight: #f2c85c;
  --color-focus: #8edce3;
  --color-overlay: rgba(0, 0, 0, 0.76);
  --shadow-small: 0 1px 1px rgba(0, 0, 0, 0.22);
  --shadow-medium: 0 14px 34px rgba(0, 0, 0, 0.3);
  --shadow-large: 0 26px 60px rgba(0, 0, 0, 0.44);
  --yellow: #e0bb5b;
  --cyan: var(--color-data);
}

html {
  scroll-padding-top: 88px;
}

body {
  background: var(--color-background);
  color: var(--color-text-primary);
  font-size: var(--type-body);
  line-height: 1.55;
}

body::before {
  background: none;
}

::selection {
  background: var(--color-accent-soft);
  color: var(--color-text-primary);
}

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

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  padding: 0;
}

.topbar {
  position: sticky;
  z-index: 100;
  top: 0;
  grid-template-columns: minmax(230px, auto) minmax(420px, 1fr) auto;
  gap: var(--space-5);
  max-width: none;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  padding: 10px max(24px, calc((100% - var(--content-max)) / 2 + 24px));
  background: var(--color-surface);
  box-shadow: var(--shadow-small);
}

.topbar::after {
  display: none;
}

.brand-lockup {
  min-height: 44px;
  gap: var(--space-3);
  color: var(--color-text-primary);
}

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

.brand-title {
  color: var(--color-text-primary);
  font-size: 1.25rem;
  line-height: 1;
  text-transform: none;
}

.eyebrow,
.ds-caption {
  color: var(--color-accent);
  font-size: var(--type-caption);
  font-weight: 800;
  line-height: 1.3;
  text-transform: uppercase;
}

.topbar-nav {
  justify-content: center;
  gap: var(--space-1);
  border: 0;
  padding: 0;
  background: transparent;
}

.nav-group > summary {
  min-height: 44px;
  border-radius: var(--radius-medium);
  padding: 0 var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--type-small);
}

.nav-group.active > summary,
.nav-group > summary:hover,
.nav-group[open] > summary {
  background: var(--color-surface-strong);
  color: var(--color-text-primary);
}

.nav-menu {
  min-width: 204px;
  border-color: var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-2);
  background: var(--color-surface);
  box-shadow: var(--shadow-large);
}

.topbar-nav .nav-menu a,
.topbar-nav .nav-menu button {
  min-height: 44px;
  border-radius: var(--radius-medium);
  padding: 8px 10px;
  color: var(--color-text-primary);
  font-size: var(--type-small);
}

.topbar-nav .nav-menu a:hover,
.topbar-nav .nav-menu button:hover,
.topbar-nav .nav-menu a[aria-current="page"] {
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
}

.topbar-actions {
  align-items: center;
  flex-wrap: nowrap;
  gap: var(--space-2);
}

.theme-switch,
.ds-switch {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  font-weight: 700;
}

.theme-switch input,
.ds-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.theme-switch i,
.ds-switch i {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--color-surface-strong);
  transition: border-color 140ms ease, background 140ms ease;
}

.theme-switch i::after,
.ds-switch i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-text-secondary);
  content: "";
  transition: transform 140ms ease, background 140ms ease;
}

.theme-switch input:checked + i,
.ds-switch input:checked + i {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.theme-switch input:checked + i::after,
.ds-switch input:checked + i::after {
  background: var(--color-accent);
  transform: translateX(16px);
}

.theme-switch input:focus-visible + i,
.ds-switch input:focus-visible + i {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.ui-button,
.load-deck-button,
.icon-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-medium);
  padding: 0 var(--space-4);
  clip-path: none;
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: var(--type-small);
  font-weight: 750;
  line-height: 1;
  text-transform: none;
  transition: border-color 140ms ease, background 140ms ease, color 140ms ease, transform 140ms ease;
}

.primary-button,
.ui-button.primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.secondary-button,
.ui-button.secondary {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.ui-button.tertiary {
  background: transparent;
  color: var(--color-accent-strong);
}

.ui-button.destructive {
  background: var(--color-error);
  color: var(--color-text-inverse);
}

.ui-button.icon {
  width: 42px;
  padding: 0;
  font-size: 1.1rem;
}

.primary-button:hover,
.secondary-button:hover,
.ui-button:hover,
.load-deck-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover,
.ui-button.primary:hover {
  background: var(--color-accent-strong);
}

.secondary-button:hover,
.ui-button.secondary:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-strong);
}

.ui-button.loading i {
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: ds-spin 700ms linear infinite;
}

button:disabled {
  opacity: 0.48;
}

.dashboard {
  max-width: var(--content-max);
  padding: var(--space-5) var(--space-5) var(--space-8);
}

.tab-view {
  gap: var(--space-5);
}

.deck-tab-view {
  grid-template-areas:
    "guided guided"
    "intro intro"
    "deck results";
  grid-template-columns: minmax(360px, 0.9fr) minmax(540px, 1.45fr);
}

.guided-dashboard {
  grid-area: guided;
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-5) 0 var(--space-6);
}

.guided-dashboard-head {
  align-items: end;
  margin-bottom: var(--space-4);
}

.guided-dashboard h2 {
  margin-top: var(--space-1);
  font-size: var(--type-display);
  line-height: 1.08;
}

.guided-dashboard-head > p {
  max-width: 420px;
  font-size: var(--type-small);
  text-align: right;
}

.guided-actions {
  gap: var(--space-3);
}

.guided-actions button {
  min-height: 104px;
  border-color: var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-4);
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-small);
}

.guided-actions button:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-medium);
}

.guided-actions button strong {
  font-size: var(--type-body);
}

.guided-actions button span {
  color: var(--color-text-secondary);
  font-size: var(--type-small);
}

.guided-actions button b {
  color: var(--color-accent);
}

.dashboard-signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.dashboard-signal {
  display: grid;
  min-width: 0;
  min-height: 132px;
  align-content: start;
  gap: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-4);
  background: var(--color-surface-raised);
}

.dashboard-signal > span {
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  font-weight: 800;
  text-transform: uppercase;
}

.dashboard-signal > strong {
  overflow-wrap: anywhere;
  font-size: var(--type-body);
  line-height: 1.35;
}

.dashboard-signal > small {
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  line-height: 1.4;
}

.dashboard-signal > a,
.dashboard-signal > button {
  width: fit-content;
  margin-top: auto;
  border: 0;
  padding: var(--space-2) 0 0;
  background: transparent;
  color: var(--color-accent-strong);
  font-size: var(--type-small);
  font-weight: 750;
  text-align: left;
}

.dashboard-next-action {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.product-intro {
  grid-area: intro;
  grid-template-columns: minmax(280px, 0.6fr) minmax(560px, 1.4fr);
  gap: var(--space-5);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border);
  padding: 0 0 var(--space-5);
}

.product-intro-copy,
.workflow-path,
.example-deck-list {
  position: relative;
  z-index: 1;
}

.product-intro-copy {
  grid-row: auto;
}

.product-intro h2 {
  margin: var(--space-1) 0 var(--space-2);
  font-size: var(--type-h1);
  line-height: 1.15;
}

.product-intro-copy > p:not(.eyebrow) {
  font-size: var(--type-body);
}

.workflow-path {
  align-self: center;
}

.workflow-path > span strong,
.example-deck-list .example-deck-rank {
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

.example-deck-list {
  grid-column: 1 / -1;
  gap: var(--space-2);
}

.example-deck-list button {
  min-height: 86px;
  border-color: var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-3);
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-small);
}

.panel {
  border: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-5);
  background: var(--color-surface);
  box-shadow: var(--shadow-small);
}

.panel::after {
  display: none;
}

.panel-head {
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel h2 {
  color: var(--color-text-primary);
  font-size: var(--type-h2);
  line-height: 1.2;
  text-transform: none;
}

.panel h3 {
  color: var(--color-text-primary);
  font-size: var(--type-h3);
  line-height: 1.3;
  text-transform: none;
}

.panel-intro,
.field-help,
.status-line,
.tuning-panel small {
  color: var(--color-text-secondary);
}

input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  padding: 10px 12px;
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  box-shadow: none;
}

textarea {
  line-height: 1.55;
  resize: vertical;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--color-border-strong);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-accent);
  background: var(--color-surface);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  min-height: 18px;
  accent-color: var(--color-accent);
}

.control-grid,
.tuning-controls,
.optimizer-controls {
  gap: var(--space-3);
}

.field-label,
.control-grid span,
.matchup-controls > label > span,
.tuning-controls label > span {
  color: var(--color-text-secondary);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: var(--type-caption);
  letter-spacing: 0;
}

.score-chip,
.stat-pill,
.model-status,
.confidence-level,
.tuning-confidence,
.ui-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--color-surface-strong);
  color: var(--color-text-secondary);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  font-size: var(--type-caption);
  font-weight: 750;
  line-height: 1;
  text-transform: none;
}

.ui-badge.success,
.confidence-level.high,
.model-status.trusted {
  border-color: var(--color-success);
  background: var(--color-success-soft);
  color: var(--color-success);
}

.ui-badge.warning,
.confidence-level.moderate,
.model-status.neutral {
  border-color: var(--color-warning);
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.ui-badge.error,
.confidence-level.low,
.model-status.experimental {
  border-color: var(--color-error);
  background: var(--color-error-soft);
  color: var(--color-error);
}

.ui-badge.info {
  border-color: var(--color-info);
  background: var(--color-info-soft);
  color: var(--color-info);
}

.status-box,
.coverage-warning,
.ds-alert {
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-info);
  border-radius: var(--radius-medium);
  background: var(--color-info-soft);
  color: var(--color-text-primary);
}

.status-box.ok,
.coverage-warning.trusted {
  border-left-color: var(--color-success);
  background: var(--color-success-soft);
}

.status-box.error,
.coverage-warning.experimental {
  border-left-color: var(--color-error);
  background: var(--color-error-soft);
}

.deck-assessment {
  border-color: var(--color-border);
}

.assessment-evidence,
.tuning-applied-evidence {
  border-color: var(--color-border);
}

.assessment-evidence > span,
.tuning-applied-evidence > span {
  border-color: var(--color-border);
}

.deck-health-row progress,
progress {
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--color-surface-strong);
  color: var(--color-accent);
}

progress::-webkit-progress-bar {
  background: var(--color-surface-strong);
}

progress::-webkit-progress-value {
  background: var(--color-accent);
}

progress::-moz-progress-bar {
  background: var(--color-accent);
}

.metric-tile,
.metric-range-tile,
.matchup-summary > *,
.understanding-facts > *,
.role-counts button,
.rank-row,
.event-row,
.rule-row {
  border-color: var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.rule-row {
  grid-template-columns: minmax(130px, 0.25fr) minmax(0, 1fr);
  align-items: start;
  border-left-color: var(--color-accent);
}

.rule-row .event-meta {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
  white-space: normal;
}

.card-assistant-answer,
.card-assistant-result,
.optimizer-recommendation,
.tuning-recommendation,
.tuning-results-preview,
.tuning-applied-state,
.arena-setup-player,
.arena-live-player,
.replay-card-inspector {
  border-color: var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.card-assistant-result:hover {
  border-color: var(--color-accent);
  background: var(--color-surface);
}

.results-table,
.optimizer-result-list,
.tuning-comparison-table,
.ds-table-wrap {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-surface);
}

.metric-group + .metric-group,
.optimizer-result-row + .optimizer-result-row {
  border-top: 1px solid var(--color-border);
}

.metric-group-title,
.optimizer-result-head,
.tuning-table-head {
  position: sticky;
  z-index: 2;
  top: 0;
  background: var(--color-surface-strong);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  text-transform: uppercase;
}

.metric-row,
.optimizer-result-row,
.tuning-table-row {
  border-color: var(--color-border);
}

.metric-row:nth-child(odd),
.optimizer-result-row:nth-child(even),
.tuning-table-row:nth-child(even) {
  background: var(--color-surface-raised);
}

.metric-percent,
.meta-win-value,
.tuning-score,
.tuning-delta {
  font-variant-numeric: tabular-nums;
}

.finish-chart,
.meta-win-track,
.metric-track,
.burst-track,
.ds-chart-row > i {
  background: var(--color-surface-strong);
}

.tuning-panel {
  border-color: var(--color-border);
}

.tuning-hero {
  border-color: var(--color-border);
  background: var(--color-surface);
}

.tuning-mode-control {
  border-color: var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-surface-strong);
}

.tuning-mode-control button {
  min-height: 44px;
}

.tuning-deck-versus {
  align-items: start;
}

.tuning-versus-mark {
  align-self: start;
  margin-top: 120px;
  border-color: var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.tuning-mode-tab {
  min-height: 40px;
  border-radius: var(--radius-small);
  color: var(--color-text-secondary);
}

.tuning-mode-tab.active,
.tuning-mode-tab[aria-selected="true"] {
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-small);
}

.tuning-step,
.optimizer-workspace,
.optimizer-step,
.tuning-baseline,
.tuning-variant,
.tuning-preset-field,
.tuning-presets button,
.tuning-simulation-plan,
.optimizer-advanced,
.optimizer-review {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.tuning-step {
  border-radius: var(--radius-large);
}

.tuning-step.active {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.tuning-step.complete {
  border-color: var(--color-success);
}

.tuning-step-number,
.optimizer-step-number {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.tuning-step.complete .tuning-step-number {
  border-color: var(--color-success);
  background: var(--color-success-soft);
  color: var(--color-success);
}

.tuning-presets button {
  border-radius: var(--radius-large);
}

.tuning-presets button.recommended,
.tuning-presets button[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.tuning-primary-action {
  border-color: var(--color-border);
  background: var(--color-surface);
}

.tuning-primary-action .primary-button {
  min-height: 48px;
  padding-inline: var(--space-6);
}

.tuning-change.added,
.tuning-change.removed {
  border-color: var(--color-border);
  background: var(--color-surface);
}

.tuning-change.added {
  border-left-color: var(--color-success);
}

.tuning-change.removed {
  border-left-color: var(--color-error);
}

.optimizer-advanced > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
}

.app-dialog {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-large);
}

.app-dialog::backdrop {
  background: var(--color-overlay);
}

.changelog-entry,
.changelog-archive,
.changelog-archive-list > div {
  border-color: var(--color-border);
}

.changelog-latest {
  background: var(--color-accent-soft);
}

/* Living Design System */

.design-system-workspace {
  display: grid;
  gap: var(--space-7);
}

.design-system-workspace[hidden] {
  display: none;
}

.ds-page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-6) 0 var(--space-5);
}

.ds-page-header h1,
.ds-page-header h2 {
  margin: var(--space-1) 0 var(--space-2);
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: var(--type-display);
  line-height: 1.05;
}

.ds-page-header p:not(.eyebrow) {
  max-width: 760px;
  margin: 0;
  color: var(--color-text-secondary);
}

.ds-export-link {
  text-decoration: none;
}

.ds-section {
  display: grid;
  gap: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-7);
}

.ds-section-head {
  display: flex;
  align-items: start;
  gap: var(--space-3);
}

.ds-section-head > span {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  font-weight: 800;
}

.ds-section h3 {
  margin: 2px 0 0;
  font-size: var(--type-h1);
  line-height: 1.1;
}

.ds-token-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: var(--space-2);
}

.ds-color-token {
  display: grid;
  min-width: 0;
  gap: var(--space-1);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
}

.ds-color-token i {
  height: 68px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-small);
}

.ds-color-token strong {
  color: var(--color-text-primary);
  font-size: var(--type-small);
}

.ds-color-token.background i { background: var(--color-background); }
.ds-color-token.surface i { background: var(--color-surface); }
.ds-color-token.raised i { background: var(--color-surface-raised); }
.ds-color-token.accent i { background: var(--color-accent); }
.ds-color-token.success i { background: var(--color-success); }
.ds-color-token.warning i { background: var(--color-warning); }
.ds-color-token.error i { background: var(--color-error); }
.ds-color-token.info i { background: var(--color-info); }

.ds-foundation-grid,
.ds-component-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

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

.ds-specimen {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-5);
  background: var(--color-surface);
  box-shadow: var(--shadow-small);
}

.ds-specimen > .ds-caption {
  display: block;
  margin-bottom: var(--space-4);
}

.ds-type-scale {
  display: grid;
  gap: var(--space-2);
}

.ds-display {
  font-family: "Barlow Condensed", "Arial Narrow", sans-serif;
  font-size: var(--type-display);
  line-height: 1;
}

.ds-h1 { font-size: var(--type-h1); }
.ds-h2 { font-size: var(--type-h2); }
.ds-h3 { font-size: var(--type-h3); }

.ds-type-scale p,
.ds-type-scale small {
  margin: 0;
  color: var(--color-text-secondary);
}

.ds-spacing-scale {
  display: flex;
  min-height: 120px;
  align-items: end;
  gap: var(--space-3);
}

.ds-spacing-scale i {
  width: 22px;
  background: var(--color-accent);
}

.ds-spacing-scale i::after {
  display: block;
  padding-top: calc(100% + 6px);
  color: var(--color-text-secondary);
  content: attr(data-size);
  font-size: var(--type-caption);
  font-style: normal;
  text-align: center;
}

.ds-spacing-scale i[data-size="4"] { height: 4px; }
.ds-spacing-scale i[data-size="8"] { height: 8px; }
.ds-spacing-scale i[data-size="12"] { height: 12px; }
.ds-spacing-scale i[data-size="16"] { height: 16px; }
.ds-spacing-scale i[data-size="24"] { height: 24px; }
.ds-spacing-scale i[data-size="32"] { height: 32px; }
.ds-spacing-scale i[data-size="48"] { height: 48px; }
.ds-spacing-scale i[data-size="64"] { height: 64px; }

.ds-radius-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.ds-radius-row i {
  display: grid;
  min-height: 64px;
  place-items: center;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  font-style: normal;
}

.ds-radius-row .small { border-radius: var(--radius-small); }
.ds-radius-row .medium { border-radius: var(--radius-medium); }
.ds-radius-row .large { border-radius: var(--radius-large); }
.ds-radius-row .raised { border-radius: var(--radius-large); box-shadow: var(--shadow-medium); }

.ds-button-row,
.ds-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.ds-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.ds-form-grid label:not(.ds-check):not(.ds-switch) {
  display: grid;
  gap: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  font-weight: 700;
}

.ds-check {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-primary);
  font-size: var(--type-small);
}

.ds-alert {
  display: grid;
  gap: 2px;
  margin-top: var(--space-3);
  padding: var(--space-3);
  font-size: var(--type-small);
}

.ds-alert.warning {
  border-left-color: var(--color-warning);
  background: var(--color-warning-soft);
}

.ds-progress-head {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  font-size: var(--type-small);
}

.ds-specimen progress {
  width: 100%;
  height: 8px;
}

.ds-progress-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-1);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.ds-progress-steps li {
  border-top: 2px solid var(--color-border);
  padding-top: var(--space-2);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
}

.ds-progress-steps li.complete { border-color: var(--color-success); color: var(--color-success); }
.ds-progress-steps li.active { border-color: var(--color-accent); color: var(--color-text-primary); }

.ds-data-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: var(--space-3);
}

.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-small);
}

.ds-table th,
.ds-table td {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3);
  text-align: left;
}

.ds-table th:not(:first-child),
.ds-table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ds-table th {
  position: sticky;
  top: 0;
  background: var(--color-surface-strong);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  text-transform: uppercase;
}

.ds-table tbody tr:nth-child(even) {
  background: var(--color-surface-raised);
}

.ds-chart {
  display: grid;
  align-content: start;
  gap: var(--space-3);
  margin: 0;
}

.ds-chart figcaption {
  display: grid;
  gap: var(--space-1);
}

.ds-chart-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) minmax(100px, 2fr) 42px;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--type-small);
}

.ds-chart-row > i {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
}

.ds-chart-row > i > b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-info);
}

.ds-chart-row.positive > i > b { background: var(--color-success); }
.ds-chart-row.warning > i > b { background: var(--color-warning); }

.ds-chart-row > strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.ds-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
}

.ds-chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.ds-chart-legend i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--color-info);
}

.ds-chart-legend span:nth-child(2) i { background: var(--color-success); }
.ds-chart-legend span:nth-child(3) i { background: var(--color-warning); }

.ds-state-grid,
.ds-layout-rules {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--space-2);
}

.ds-state-grid > div,
.ds-layout-rules > div {
  display: grid;
  min-height: 88px;
  align-content: center;
  gap: var(--space-1);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-3);
  background: var(--color-surface);
}

.ds-state-grid span,
.ds-layout-rules span {
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
}

.ds-state-grid strong,
.ds-layout-rules strong {
  overflow-wrap: anywhere;
  font-size: var(--type-small);
}

.ds-state-grid .active { border-color: var(--color-accent); }
.ds-state-grid .selected { background: var(--color-accent-soft); }
.ds-state-grid .success { border-color: var(--color-success); background: var(--color-success-soft); }
.ds-state-grid .warning { border-color: var(--color-warning); background: var(--color-warning-soft); }
.ds-state-grid .error { border-color: var(--color-error); background: var(--color-error-soft); }

.ds-layout-rules {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.design-export-page {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
}

html[data-theme="dark"] :where(
  .topbar,
  .nav-menu,
  .panel,
  .guided-actions button,
  .example-deck-list button,
  .dashboard-signal,
  .metric-tile,
  .metric-range-tile,
  .matchup-summary > *,
  .understanding-facts > *,
  .role-counts button,
  .rank-row,
  .event-row,
  .rule-row,
  .card-assistant-answer,
  .card-assistant-result,
  .optimizer-recommendation,
  .tuning-recommendation,
  .tuning-results-preview,
  .tuning-applied-state,
  .arena-setup-player,
  .arena-live-player,
  .arena-live-unit,
  .arena-live-hand-card,
  .replay-card-inspector,
  .changelog-panel
) {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

html[data-theme="dark"] img {
  color-scheme: only light;
}

@media (max-width: 920px) {
  .tuning-versus-mark {
    align-self: center;
    margin-top: 0;
  }
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .topbar-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .deck-tab-view {
    grid-template-areas: "guided" "intro" "deck" "results";
    grid-template-columns: 1fr;
  }

  .product-intro {
    grid-template-columns: 1fr;
  }

  .dashboard-signal-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-next-action {
    grid-column: auto;
  }

  .ds-token-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  html {
    scroll-padding-top: 12px;
  }

  .topbar {
    position: relative;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    padding: 10px 12px;
  }

  .topbar-nav,
  .topbar-actions {
    grid-column: 1;
  }

  .topbar-nav {
    grid-row: 2;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .topbar-actions {
    grid-row: 3;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .topbar-actions button {
    flex: 0 0 auto;
  }

  .theme-switch {
    margin-right: auto;
  }

  .dashboard {
    padding: var(--space-3) 10px var(--space-7);
  }

  .guided-dashboard {
    padding-top: var(--space-4);
  }

  .guided-dashboard-head,
  .ds-page-header {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .guided-dashboard-head {
    display: grid;
  }

  .guided-dashboard-head > p {
    text-align: left;
  }

  .guided-dashboard h2,
  .ds-page-header h1,
  .ds-page-header h2 {
    font-size: 1.8rem;
  }

  .guided-actions,
  .dashboard-signal-grid,
  .example-deck-list,
  .ds-component-grid,
  .ds-data-grid,
  .ds-layout-rules {
    grid-template-columns: 1fr;
  }

  .dashboard-next-action {
    grid-column: auto;
  }

  .guided-actions button {
    min-height: 92px;
  }

  .product-intro {
    gap: var(--space-4);
  }

  .workflow-path {
    grid-template-columns: 1fr;
  }

  .workflow-path > i {
    display: none;
  }

  .panel {
    padding: var(--space-4);
  }

  .panel-head {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel-head > :last-child {
    justify-self: start;
  }

  .rule-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .rule-row .event-meta {
    text-align: left;
  }

  .tuning-step,
  .optimizer-workspace {
    border-radius: var(--radius-large);
  }

  .tuning-primary-action {
    position: sticky;
    z-index: 10;
    bottom: 8px;
    margin-inline: -4px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-large);
    padding: var(--space-2);
    box-shadow: var(--shadow-large);
  }

  .tuning-primary-action .primary-button {
    width: 100%;
    min-height: 48px;
  }

  .ds-page-header {
    display: grid;
  }

  .ds-export-link {
    width: fit-content;
  }

  .ds-token-grid,
  .ds-foundation-grid,
  .ds-state-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ds-form-grid {
    grid-template-columns: 1fr;
  }

  .ds-table-wrap {
    overflow: visible;
  }

  .ds-table,
  .ds-table tbody,
  .ds-table tr,
  .ds-table td {
    display: block;
  }

  .ds-table thead {
    display: none;
  }

  .ds-table tr {
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3);
  }

  .ds-table td {
    display: grid;
    grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1fr);
    border: 0;
    padding: var(--space-1) 0;
    text-align: right;
  }

  .ds-table td::before {
    color: var(--color-text-secondary);
    font-size: var(--type-caption);
    font-weight: 700;
    text-align: left;
  }

  .ds-table td:nth-child(1)::before { content: "Metric"; }
  .ds-table td:nth-child(2)::before { content: "Current"; }
  .ds-table td:nth-child(3)::before { content: "Modified"; }
  .ds-table td:nth-child(4)::before { content: "Difference"; }

  .ds-chart-row {
    grid-template-columns: minmax(90px, 1fr) minmax(90px, 1.2fr) 38px;
  }
}

@media (max-width: 430px) {
  .brand-copy .eyebrow,
  .theme-switch > span {
    display: none;
  }

  .nav-group > summary {
    min-height: 44px;
    padding: 0 8px;
    font-size: var(--type-caption);
  }

  .ds-token-grid,
  .ds-foundation-grid,
  .ds-state-grid {
    grid-template-columns: 1fr;
  }

  .ds-progress-steps {
    grid-template-columns: 1fr;
  }

  .ds-progress-steps li {
    border-top: 0;
    border-left: 2px solid var(--color-border);
    padding: 3px 0 3px var(--space-2);
  }
}

/* Test Lab contrast contract: emphasis cards stay dark in both themes. */
.matchup-summary > .matchup-score {
  border-color: var(--color-emphasis-highlight);
  background: var(--color-emphasis-surface);
  color: var(--color-emphasis-text);
}

.matchup-score .edge-value {
  color: var(--color-emphasis-highlight);
}

.matchup-score .edge-label,
.matchup-score .metric-label {
  color: var(--color-emphasis-muted);
}

.comparison-row,
.replay-hand-card,
.replay-unit,
.replay-base,
.replay-shields,
.decision-inspector {
  color: var(--color-text-primary);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

}

@keyframes ds-spin {
  to { transform: rotate(360deg); }
}

/* Industrial Instrument language */

body {
  font-family: var(--font-body);
  line-height: 1.65;
}

a {
  color: var(--color-text-primary);
  text-decoration-color: var(--color-border-strong);
  text-underline-offset: 3px;
}

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

:where(h1, h2, h3, h4, h5, h6),
.brand-title,
.ds-display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0;
}

.brand-title {
  font-size: 1.2rem;
  font-weight: 650;
  line-height: 1.1;
}

.eyebrow,
.ds-caption,
.field-label,
.tuning-step-state,
.changelog-updated {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0;
}

.eyebrow,
.ds-caption {
  text-transform: uppercase;
}

.topbar {
  min-height: 68px;
  border-bottom-color: var(--color-border);
  background: var(--color-surface);
  box-shadow: none;
}

.brand-mark {
  width: 36px;
  height: 34px;
}

.nav-group > summary {
  position: relative;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-small);
  font-weight: 600;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.nav-group.active > summary,
.nav-group[open] > summary {
  border-bottom-color: var(--color-accent);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.nav-group > summary:hover {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.nav-menu {
  border-color: var(--color-border);
  box-shadow: var(--shadow-medium);
}

.topbar-nav .nav-menu a:hover,
.topbar-nav .nav-menu button:hover,
.topbar-nav .nav-menu a[aria-current="page"] {
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.primary-button,
.secondary-button,
.ui-button,
.load-deck-button,
.icon-button {
  font-family: var(--font-body);
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease, transform 90ms ease;
}

.primary-button:hover,
.ui-button.primary:hover {
  box-shadow: 0 3px 10px rgba(14, 97, 107, 0.16);
  transform: translateY(-1px);
}

.secondary-button:hover,
.ui-button.secondary:hover,
.ui-button.tertiary:hover,
.icon-button:hover {
  box-shadow: var(--shadow-small);
  transform: translateY(-1px);
}

.primary-button:active,
.secondary-button:active,
.ui-button:active,
.load-deck-button:active,
.icon-button:active {
  box-shadow: none;
  transform: translateY(1px) scale(0.99);
}

.dashboard {
  padding-top: var(--space-6);
}

.deck-tab-view {
  gap: var(--space-7);
}

.guided-dashboard {
  border-bottom: 0;
  padding: var(--space-6) 0 var(--space-7);
}

.guided-dashboard-head {
  margin-bottom: var(--space-5);
}

.guided-dashboard h2 {
  max-width: 780px;
  font-size: var(--type-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: 0;
}

.guided-dashboard-head > p {
  max-width: 360px;
  line-height: 1.6;
}

.guided-actions {
  gap: var(--space-4);
}

.guided-actions button {
  min-height: 116px;
  border-color: var(--color-border);
  padding: var(--space-5);
  background: var(--color-surface);
  box-shadow: none;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 90ms ease;
}

.guided-actions button:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-raised);
  box-shadow: var(--shadow-small);
}

.guided-actions button:active {
  transform: translateY(1px) scale(0.995);
}

.guided-actions button strong {
  font-size: 0.9rem;
  font-weight: 650;
}

.guided-actions button span {
  margin-top: var(--space-1);
  line-height: 1.55;
}

.guided-actions button b {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-weight: 500;
}

.dashboard-signal-grid {
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.dashboard-signal {
  min-height: 128px;
  border-color: transparent;
  padding: var(--space-4);
  background: var(--color-surface-raised);
}

.dashboard-signal > span {
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0;
}

.dashboard-signal > strong {
  font-weight: 600;
}

.dashboard-signal > a,
.dashboard-signal > button {
  color: var(--color-text-primary);
  font-weight: 650;
}

.dashboard-next-action {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
}

.product-intro {
  gap: var(--space-7);
  overflow: visible;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-7) 0;
}

.product-intro h2 {
  max-width: 480px;
  font-size: var(--type-h1);
  font-weight: 600;
  line-height: 1.18;
}

.product-intro-copy > p:not(.eyebrow) {
  max-width: 470px;
  color: var(--color-text-secondary);
  line-height: 1.65;
}

.workflow-path {
  gap: var(--space-4);
}

.workflow-path > span {
  color: var(--color-text-secondary);
  font-size: var(--type-small);
  font-weight: 550;
}

.workflow-path > span strong,
.example-deck-list .example-deck-rank {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.workflow-path > i {
  color: var(--color-border-strong);
}

.example-deck-list {
  gap: var(--space-3);
}

.example-deck-list button {
  min-height: 92px;
  border-color: transparent;
  background: var(--color-surface-raised);
  box-shadow: none;
}

.example-deck-list button:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
}

.panel {
  border-color: var(--color-border);
  padding: var(--space-6);
  background: var(--color-surface);
  box-shadow: none;
  animation: instrument-enter 180ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.panel-head {
  margin-bottom: var(--space-5);
}

.panel h2 {
  font-size: var(--type-h2);
  font-weight: 600;
  line-height: 1.25;
}

.panel h3,
.panel h4 {
  font-weight: 600;
}

.panel-intro,
.field-help,
.status-line,
.tuning-panel small {
  line-height: 1.6;
}

input,
textarea,
select {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  font-family: var(--font-body);
  line-height: 1.5;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-accent);
  background: var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-accent-soft);
}

.score-chip,
.stat-pill,
.model-status,
.confidence-level,
.tuning-confidence,
.ui-badge,
.support-badge {
  min-height: 24px;
  border-color: var(--color-border);
  padding: 4px 7px;
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0;
}

.ui-badge.info {
  border-color: var(--color-border-strong);
  background: transparent;
  color: var(--color-text-secondary);
}

.metric-value,
.metric-percent,
.metric-confidence,
.meta-win-value,
.tuning-score,
.tuning-delta,
.tuning-recommendation-metrics strong,
.tuning-evidence-grid strong,
.assessment-evidence strong,
.matchup-summary strong,
.dashboard-signal small,
.changelog-release strong,
.changelog-release time,
.ds-metric-sample,
.ds-recommendation-value,
.ds-chart-row > strong,
.ds-table td:not(:first-child),
.ds-layout-rules strong,
.ds-progress-head span {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: 0;
}

.metric-value {
  font-weight: 600;
}

.deck-assessment {
  border: 0;
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-large);
  padding: var(--space-5);
  background: var(--color-surface-raised);
}

.metric-strip {
  gap: var(--space-3);
}

.metric-tile,
.metric-range-tile,
.matchup-summary > *,
.understanding-facts > *,
.role-counts button,
.rank-row,
.event-row,
.rule-row {
  border-color: transparent;
  background: var(--color-surface-raised);
  box-shadow: none;
}

.rule-row {
  border-left-color: var(--color-data-strong);
}

.results-table,
.optimizer-result-list,
.tuning-comparison-table,
.ds-table-wrap {
  border-color: var(--color-border);
  background: transparent;
  box-shadow: none;
}

.metric-group + .metric-group,
.optimizer-result-row + .optimizer-result-row {
  margin-top: var(--space-5);
  border-top: 0;
}

.metric-group-title,
.optimizer-result-head,
.tuning-table-head {
  min-height: 42px;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0;
}

.metric-row,
.optimizer-result-row,
.tuning-table-row,
.tuning-summary-row {
  min-height: 54px;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
}

.metric-row {
  padding: var(--space-3) var(--space-4);
}

.metric-row:nth-child(odd),
.optimizer-result-row:nth-child(even),
.tuning-table-row:nth-child(even) {
  background: transparent;
}

.metric-row:nth-child(n) .bar-fill,
.finish-track > span,
.meta-win-track > span,
.metric-track > span,
.burst-track > span,
.ds-chart-row > i > b {
  background: var(--color-data);
}

.ds-chart-row.positive > i > b {
  background: var(--color-success);
}

.ds-chart-row.warning > i > b {
  background: var(--color-warning);
}

.bar-track,
.finish-track,
.meta-win-track,
.metric-track,
.burst-track,
.ds-chart-row > i {
  border-radius: 2px;
  background: var(--color-surface-strong);
}

.tuning-panel {
  display: grid;
  gap: var(--space-5);
}

.tuning-question-head {
  padding: var(--space-3) 0 var(--space-5);
  border-bottom-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.tuning-question-head h2 {
  max-width: 780px;
  font-size: var(--type-h1);
  line-height: 1.16;
}

.tuning-lede {
  max-width: 640px;
  color: var(--color-text-secondary);
  font-size: var(--type-body);
  line-height: 1.65;
}

.tuning-mode-control {
  width: fit-content;
  border-color: var(--color-border);
  background: var(--color-surface-raised);
}

.tuning-mode-control button {
  font-weight: 600;
}

.tuning-mode-control button.active,
.tuning-mode-control button[aria-selected="true"] {
  border-bottom: 2px solid var(--color-accent);
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: none;
}

.tuning-experiment-path {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
}

.tuning-step,
.optimizer-workspace,
.optimizer-step,
.tuning-baseline,
.tuning-variant,
.tuning-preset-field,
.tuning-presets button,
.tuning-simulation-plan,
.optimizer-advanced,
.optimizer-review {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  box-shadow: none;
}

.tuning-step {
  padding: var(--space-5);
}

.tuning-step.active {
  border-color: var(--color-accent);
  background: var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-accent);
}

.tuning-step.complete {
  border-color: var(--color-success);
  background: var(--color-surface);
}

.tuning-step-number,
.optimizer-step-number {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.tuning-presets button {
  min-height: 112px;
  padding: var(--space-4);
}

.tuning-presets button.recommended,
.tuning-presets button[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-surface);
  box-shadow: inset 0 -2px 0 var(--color-accent);
}

.tuning-simulation-plan {
  background: var(--color-surface);
}

.tuning-primary-action {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
}

.tuning-change-empty,
.optimizer-results-preview {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
}

.tuning-results-preview {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.tuning-recommendation {
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-xlarge);
  padding: var(--space-7);
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-medium);
  animation: recommendation-settle 240ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.tuning-recommendation.variant {
  border-left-color: var(--color-success);
}

.tuning-recommendation.baseline,
.tuning-recommendation.failed {
  border-left-color: var(--color-error);
}

.tuning-recommendation.limited,
.tuning-recommendation.inconclusive {
  border-left-color: var(--color-warning);
}

.tuning-recommendation .eyebrow,
.tuning-recommendation h3 {
  color: var(--color-text-primary);
}

.tuning-recommendation h3 {
  font-size: 1.65rem;
  font-weight: 600;
}

.tuning-recommendation-summary {
  max-width: 760px;
  margin-top: var(--space-4);
  color: var(--color-text-secondary);
  font-size: var(--type-body);
  line-height: 1.65;
}

.tuning-recommendation-metrics {
  margin-top: var(--space-6);
  border: 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.tuning-recommendation-metrics > span {
  min-height: 100px;
  border-right-color: var(--color-border);
  padding: var(--space-4);
  background: transparent;
}

.tuning-recommendation-metrics small {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.tuning-recommendation-metrics strong {
  color: var(--color-text-primary);
  font-size: 1.5rem;
  font-weight: 600;
}

.tuning-recommendation-metrics strong.positive {
  color: var(--color-success);
}

.tuning-recommendation-metrics strong.negative {
  color: var(--color-error);
}

.tuning-recommendation-metrics strong.neutral {
  color: var(--color-warning);
}

.tuning-recommendation-why {
  margin-top: var(--space-5);
  border-color: var(--color-border);
  color: var(--color-text-primary);
}

.tuning-reliability-warning {
  border-color: var(--color-warning);
  background: var(--color-warning-soft);
  color: var(--color-text-primary);
}

.optimizer-recommendation {
  margin-bottom: var(--space-5);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-large);
  padding: var(--space-5);
  background: var(--color-surface);
  box-shadow: var(--shadow-medium);
}

.optimizer-recommendation-grid {
  border-color: var(--color-border);
}

.optimizer-recommendation-grid > span {
  border-color: var(--color-border);
}

.optimizer-recommendation-grid strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.card-assistant-panel {
  padding: var(--space-6);
}

.card-assistant-form {
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.card-assistant-form input,
.card-assistant-form button {
  min-height: 50px;
}

.card-assistant-suggestions {
  display: block;
  margin-top: var(--space-3);
  border: 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: transparent;
}

.card-assistant-suggestions > summary,
.ds-disclosure > summary,
.optimizer-advanced > summary,
.tuning-confidence-method > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: var(--type-small);
  font-weight: 600;
  list-style: none;
}

.card-assistant-suggestions > summary::-webkit-details-marker,
.ds-disclosure > summary::-webkit-details-marker,
.optimizer-advanced > summary::-webkit-details-marker,
.tuning-confidence-method > summary::-webkit-details-marker {
  display: none;
}

.card-assistant-suggestions > summary::after,
.ds-disclosure > summary::after {
  color: var(--color-text-secondary);
  content: "+";
  font-family: var(--font-mono);
  font-size: 1rem;
}

.card-assistant-suggestions[open] > summary::after,
.ds-disclosure[open] > summary::after {
  content: "-";
}

.card-assistant-suggestion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 0 0 var(--space-3);
}

.card-assistant-suggestion-actions button {
  min-height: 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small);
  padding: 7px 10px;
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  font-size: var(--type-small);
  font-weight: 550;
}

.card-assistant-suggestion-actions button:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
}

.card-assistant-query {
  border-left-color: var(--color-data-strong);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.card-assistant-answer {
  margin-top: var(--space-4);
  border: 0;
  background: transparent;
}

.card-assistant-answer-head {
  min-height: 64px;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
}

.card-assistant-criteria span,
.card-assistant-result-reasons span {
  border-color: transparent;
  background: var(--color-surface-strong);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-weight: 500;
}

.card-assistant-results {
  border-top: 0;
}

.card-assistant-result {
  grid-template-columns: 72px minmax(0, 1fr) 126px;
  min-height: 132px;
  gap: var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  border-radius: 0;
  padding: var(--space-4) 0;
  background: transparent;
  color: var(--color-text-primary);
}

.card-assistant-result:hover {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
}

.card-assistant-result > img {
  width: 72px;
  height: 100px;
  border-color: var(--color-border);
  border-radius: var(--radius-small);
  background: var(--color-surface-strong);
}

.card-assistant-result-copy {
  gap: var(--space-2);
}

.card-assistant-result-title strong {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: none;
}

.card-assistant-result-title small {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: none;
}

.card-assistant-result-effect {
  color: var(--color-text-secondary);
  font-size: 0.72rem;
  line-height: 1.6;
}

.card-assistant-result-aside > strong {
  color: var(--color-text-primary);
  font-family: var(--font-mono);
}

.optimizer-advanced,
.tuning-confidence-method,
.deck-support-audit,
.game-log,
.ds-disclosure {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.ds-disclosure {
  padding: 0 var(--space-3);
}

.ds-disclosure p {
  margin: 0;
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) 0;
  color: var(--color-text-secondary);
  font-size: var(--type-small);
  line-height: 1.6;
}

.ds-specimen {
  border-color: var(--color-border);
  background: var(--color-surface);
  box-shadow: none;
}

.ds-display {
  font-size: var(--type-display);
  font-weight: 600;
}

.ds-metric-sample {
  margin: var(--space-2) 0;
  font-size: 2rem;
  font-weight: 600;
}

.ds-recommendation {
  grid-column: 1 / -1;
  display: grid;
  min-height: 250px;
  align-content: center;
  justify-items: start;
  border-left: 3px solid var(--color-accent);
  padding: var(--space-7);
  box-shadow: var(--shadow-medium);
}

.ds-recommendation h4 {
  margin: 0;
  font-size: var(--type-h1);
  font-weight: 600;
}

.ds-recommendation-value {
  margin: var(--space-2) 0;
  font-size: 2.5rem;
  font-weight: 600;
}

.ds-recommendation p {
  margin: 0 0 var(--space-4);
  color: var(--color-text-secondary);
}

.ds-card-levels {
  display: grid;
  gap: var(--space-3);
}

.ds-card-levels > div {
  display: grid;
  gap: 2px;
  border-radius: var(--radius-medium);
  padding: var(--space-3);
}

.ds-card-levels span {
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
}

.ds-card-levels .primary {
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface);
  box-shadow: var(--shadow-medium);
}

.ds-card-levels .secondary {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

.ds-card-levels .passive {
  border: 1px solid transparent;
  background: var(--color-surface-raised);
}

.ds-table {
  font-size: var(--type-small);
}

.ds-table th,
.ds-table td {
  padding: var(--space-4);
}

.ds-table th {
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0;
}

.ds-table tbody tr:nth-child(even) {
  background: transparent;
}

.ds-chart {
  gap: var(--space-4);
}

.ds-chart-row {
  min-height: 34px;
}

.ds-chart-legend {
  margin-top: var(--space-2);
}

.ds-chart-legend i {
  background: var(--color-data);
}

.ds-state-grid .selected {
  border-bottom: 2px solid var(--color-accent);
  background: var(--color-surface);
}

html[data-theme="dark"] :where(
  .tuning-experiment-path,
  .tuning-baseline,
  .tuning-variant,
  .tuning-change-empty,
  .tuning-preset-field,
  .tuning-presets button,
  .tuning-simulation-plan,
  .tuning-primary-action,
  .tuning-results-preview,
  .optimizer-workspace,
  .optimizer-step,
  .optimizer-review,
  .optimizer-results-preview,
  .card-assistant-query,
  .card-assistant-suggestion-actions button,
  .card-assistant-criteria span,
  .card-assistant-result-reasons span
) {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

html[data-theme="dark"] :where(
  .tuning-recommendation,
  .optimizer-recommendation,
  .tuning-step.active,
  .tuning-step.complete,
  .tuning-presets button[aria-pressed="true"]
) {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

@media (max-width: 1120px) {
  .guided-dashboard,
  .product-intro {
    padding-block: var(--space-6);
  }

  .dashboard-signal-grid {
    gap: var(--space-3);
  }

  .ds-recommendation {
    min-height: 220px;
  }
}

@media (max-width: 760px) {
  .dashboard {
    padding-top: var(--space-4);
  }

  .deck-health-grid {
    grid-template-columns: 1fr;
  }

  .deck-health-row {
    grid-template-columns: minmax(0, 112px) minmax(0, 1fr) 28px;
  }

  .deck-tab-view,
  .tab-view {
    gap: var(--space-5);
  }

  .guided-dashboard {
    padding: var(--space-5) 0;
  }

  .guided-dashboard h2,
  .tuning-question-head h2,
  .ds-page-header h1,
  .ds-page-header h2 {
    font-size: 1.85rem;
  }

  .guided-actions {
    gap: var(--space-3);
  }

  .guided-actions button {
    min-height: 88px;
    padding: var(--space-4);
  }

  .product-intro {
    gap: var(--space-5);
    padding: var(--space-5) 0;
  }

  .panel,
  .card-assistant-panel {
    padding: var(--space-5);
  }

  .tuning-step {
    padding: var(--space-4);
  }

  .tuning-recommendation {
    padding: var(--space-5);
  }

  .tuning-recommendation-metrics > span {
    min-height: 82px;
  }

  .card-assistant-form {
    grid-template-columns: 1fr;
  }

  .card-assistant-suggestion-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-assistant-suggestion-actions button {
    min-height: 44px;
    text-align: left;
  }

  .card-assistant-result {
    grid-template-columns: 58px minmax(0, 1fr);
    min-height: 114px;
    gap: var(--space-3);
    padding: var(--space-4) 0;
  }

  .card-assistant-result > img {
    width: 58px;
    height: 81px;
  }

  .card-assistant-result-aside {
    grid-column: 2;
    justify-items: start;
    text-align: left;
  }

  .ds-recommendation {
    grid-column: auto;
    min-height: 210px;
    padding: var(--space-5);
  }
}

@media (max-width: 430px) {
  .card-assistant-suggestion-actions {
    grid-template-columns: 1fr;
  }

  .ds-recommendation-value {
    font-size: 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .tuning-recommendation {
    animation: none;
  }

  .primary-button,
  .secondary-button,
  .ui-button,
  .load-deck-button,
  .icon-button,
  .guided-actions button,
  .nav-group > summary,
  input,
  textarea,
  select {
    transition: none;
  }
}

@media (forced-colors: active) {
  .primary-button,
  .secondary-button,
  .ui-button,
  .icon-button,
  .nav-group.active > summary,
  .tuning-recommendation,
  .optimizer-recommendation {
    border: 1px solid ButtonText;
  }

  progress,
  .bar-fill,
  .finish-track > span,
  .meta-win-track > span,
  .metric-track > span,
  .burst-track > span {
    forced-color-adjust: none;
    background: Highlight;
  }
}

/* V36 simplification and responsive hierarchy */
:root {
  --type-small: 0.875rem;
  --type-caption: 0.75rem;
}

small:not([aria-hidden="true"]),
.field-label,
.field-help,
.status-line,
.metric-label,
.tuning-step-state,
.optimizer-step label,
.optimizer-step small,
.optimizer-step p {
  font-size: 0.75rem;
}

input:not([type="range"]),
select,
textarea,
.primary-button,
.secondary-button,
.segmented-control button {
  font-size: 0.875rem;
}

.panel p:not(.eyebrow) {
  font-size: max(0.875rem, 1em);
}

.header-settings {
  position: relative;
}

.header-settings > summary {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-small) calc(var(--radius-large) + 2px) var(--radius-small) var(--radius-small);
  padding: 0 var(--space-3);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 750;
  list-style: none;
}

.header-settings > summary::-webkit-details-marker {
  display: none;
}

.header-settings > summary::after {
  margin-left: var(--space-2);
  color: var(--color-text-secondary);
  content: "+";
  font-family: var(--font-mono);
}

.header-settings[open] > summary::after {
  content: "-";
}

.header-settings > summary:focus-visible,
.deck-editor-disclosure > summary:focus-visible,
.card-filter-disclosure > summary:focus-visible,
.tuning-step-details > summary:focus-visible,
.matchup-detailed-comparison > summary:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.header-settings-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + var(--space-2));
  right: 0;
  display: grid;
  width: min(290px, calc(100vw - 24px));
  gap: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-3);
  background: var(--color-surface);
  box-shadow: var(--shadow-large);
}

.header-settings-menu .presentation-switch,
.header-settings-menu .theme-switch {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--color-text-primary);
  font-size: 0.875rem;
}

.deck-editor-disclosure {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-surface-raised);
}

.deck-editor-disclosure > summary,
.tuning-step-details > summary,
.card-filter-disclosure > summary,
.matchup-detailed-comparison > summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 750;
}

.deck-editor-disclosure > summary > span:first-child,
.tuning-step-details > summary > span {
  display: grid;
  gap: 2px;
}

.deck-editor-disclosure > summary small,
.tuning-step-details > summary small,
.deck-editor-disclosure > summary > span:last-child,
.card-filter-disclosure > summary span,
.matchup-detailed-comparison > summary span {
  color: var(--color-text-secondary);
  font-weight: 650;
}

.deck-editor-body {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4);
}

.deck-editor-body textarea {
  margin-bottom: 0;
}

.card-mode-control {
  width: fit-content;
  margin: 0 0 var(--space-4);
}

.card-browser {
  margin-top: 0;
  border-top: 0;
  padding-top: 0;
}

.card-browser-primary-search {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(220px, 1fr);
  align-items: end;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.card-browser-primary-search label {
  display: grid;
  gap: var(--space-2);
}

.card-browser-primary-search .status-line {
  min-height: 44px;
  align-content: center;
  margin: 0;
}

.card-filter-disclosure {
  margin-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.card-filter-disclosure > summary {
  display: none;
}

.card-browser-filters {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  margin: 0;
  padding: var(--space-3) 0;
}

.card-browser-filters .compact-button {
  min-width: 112px;
}

.tuning-step-details {
  border-top: 1px solid var(--color-border);
}

.tuning-step-details > summary {
  padding-right: 0;
  padding-left: 0;
}

.tuning-step-details > .tuning-baseline-summary {
  margin-top: var(--space-3);
}

.tuning-finish-editing {
  margin-top: var(--space-3);
}

.optimizer-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1fr);
  border-top: 1px solid var(--color-border-strong);
  background: var(--color-surface-raised);
}

.optimizer-setup-column {
  min-width: 0;
  border-right: 1px solid var(--color-border-strong);
  background: var(--color-surface);
}

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

.optimizer-step:nth-child(2n) {
  border-right: 0;
}

.optimizer-step:nth-child(-n + 2) {
  border-bottom: 1px solid var(--color-border);
}

.optimizer-review {
  min-width: 0;
  align-self: start;
}

.matchup-observed-differences {
  display: grid;
  gap: var(--space-4);
}

.matchup-differences-head {
  display: grid;
  gap: var(--space-1);
}

.matchup-differences-head h3,
.matchup-differences-head p {
  margin: 0;
}

.matchup-differences-head p,
.matchup-differences-empty {
  color: var(--color-text-secondary);
}

.matchup-leading-differences,
.matchup-detailed-comparison > div {
  display: grid;
  gap: var(--space-2);
}

.matchup-detailed-comparison {
  border-top: 1px solid var(--color-border);
}

.matchup-detailed-comparison > summary {
  padding-right: 0;
  padding-left: 0;
}

@media (max-width: 900px) {
  .meta-pulse-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    scroll-snap-type: none;
  }

  .meta-pulse-items > span {
    min-width: 0;
  }

  .optimizer-workspace {
    grid-template-columns: 1fr;
  }

  .optimizer-setup-column {
    border-right: 0;
    border-bottom: 1px solid var(--color-border-strong);
  }
}

@media (max-width: 760px) {
  .header-settings {
    grid-column: 1 / -1;
    width: 100%;
  }

  .header-settings > summary {
    width: 100%;
    justify-content: space-between;
  }

  .header-settings-menu {
    position: static;
    width: 100%;
    margin-top: var(--space-2);
    border-radius: var(--radius-medium);
    box-shadow: none;
  }

  .header-utilities .topbar-actions {
    grid-template-columns: 1fr;
  }

  .card-filter-disclosure > summary {
    display: flex;
  }

  .card-browser-primary-search {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  .card-browser-filters {
    grid-template-columns: 1fr;
    padding: 0 0 var(--space-3);
  }

  .card-browser-filters .compact-button {
    width: 100%;
  }

  .optimizer-workflow {
    grid-template-columns: 1fr;
  }

  .optimizer-step,
  .optimizer-step:nth-child(2n) {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .optimizer-step:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 600px) {
  .meta-pulse-items {
    grid-template-columns: 1fr;
  }

  .meta-pulse-items > span:nth-child(n + 2) {
    display: none;
  }
}

@media (forced-colors: active) {
  .header-settings-menu,
  .deck-editor-disclosure,
  .card-filter-disclosure,
  .tuning-step-details,
  .matchup-detailed-comparison {
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
  }
}

/* V31 system interface: official-inspired structure without promotional styling. */

:root {
  --system-cut: 14px;
  --system-rule-on-dark: rgba(255, 255, 255, 0.2);
  --system-muted-on-dark: #cbd3ce;
}

.nav-group > summary > span {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.nav-group > summary {
  gap: 6px;
}

.nav-group.active > summary > span,
.nav-group[open] > summary > span {
  color: var(--color-accent-strong);
}

.meta-pulse {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 72px;
  overflow: hidden;
  border-bottom: 1px solid var(--color-emphasis-highlight);
  padding: 0 max(24px, calc((100% - var(--content-max)) / 2 + 24px));
  background: var(--color-emphasis-surface);
  color: var(--color-emphasis-text);
}

.meta-pulse::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18%;
  height: 2px;
  background: var(--color-emphasis-highlight);
  content: "";
  animation: meta-pulse-scan 6s ease-in-out infinite alternate;
}

.meta-pulse-label {
  display: flex;
  min-width: 150px;
  align-items: center;
  gap: var(--space-2);
  border-right: 1px solid var(--system-rule-on-dark);
  padding-right: var(--space-5);
}

.meta-pulse-label > span {
  width: 7px;
  height: 7px;
  background: var(--color-emphasis-highlight);
  box-shadow: 0 0 0 4px rgba(242, 200, 92, 0.14);
}

.meta-pulse-label > strong,
.meta-pulse-items b,
.meta-pulse-items small {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}

.meta-pulse-label > strong {
  font-size: var(--type-caption);
  letter-spacing: 0;
}

.meta-pulse-items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  scrollbar-width: none;
}

.meta-pulse-items::-webkit-scrollbar {
  display: none;
}

.meta-pulse-items > span {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: center;
  gap: 1px var(--space-3);
  min-width: 0;
  border-right: 1px solid var(--system-rule-on-dark);
  padding: var(--space-3) var(--space-5);
}

.meta-pulse-items > span:last-child {
  border-right: 0;
}

.meta-pulse-items b {
  grid-row: 1 / 3;
  align-self: center;
  color: var(--color-emphasis-highlight);
  font-size: var(--type-caption);
}

.meta-pulse-items small {
  overflow: hidden;
  color: var(--system-muted-on-dark);
  font-size: 0.625rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-pulse-items strong {
  overflow: hidden;
  color: var(--color-emphasis-text);
  font-size: var(--type-small);
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guided-dashboard {
  border-right: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
  padding-right: var(--space-5);
  padding-left: var(--space-5);
}

.guided-actions {
  counter-reset: command-action;
}

.guided-actions button {
  position: relative;
  counter-increment: command-action;
  border-radius: var(--radius-small) var(--radius-large) var(--radius-small) var(--radius-small);
}

.guided-actions button::before {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  color: var(--color-text-secondary);
  content: "0" counter(command-action);
  font-family: var(--font-mono);
  font-size: var(--type-caption);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.panel > .panel-head .eyebrow,
.guided-dashboard .eyebrow,
.tuning-question-head .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.panel > .panel-head .eyebrow::after,
.guided-dashboard .eyebrow::after,
.tuning-question-head .eyebrow::after {
  width: 28px;
  height: 1px;
  background: currentColor;
  content: "";
  opacity: 0.52;
}

.tuning-recommendation,
.optimizer-recommendation,
.matchup-summary > .matchup-score {
  border-color: var(--color-emphasis-highlight);
  border-radius: 0;
  background: var(--color-emphasis-surface);
  color: var(--color-emphasis-text);
  clip-path: polygon(
    0 0,
    calc(100% - var(--system-cut)) 0,
    100% var(--system-cut),
    100% 100%,
    var(--system-cut) 100%,
    0 calc(100% - var(--system-cut))
  );
}

.tuning-recommendation,
.optimizer-recommendation {
  border-left-width: 1px;
}

.tuning-recommendation .eyebrow,
.optimizer-recommendation .eyebrow {
  color: var(--color-emphasis-highlight);
}

.tuning-recommendation h3,
.optimizer-recommendation h3,
.tuning-recommendation strong,
.optimizer-recommendation strong {
  color: var(--color-emphasis-text);
}

.tuning-recommendation-summary,
.tuning-recommendation-metrics small,
.tuning-recommendation-metrics em,
.tuning-recommendation .tuning-executed-plan small,
.tuning-recommendation .tuning-result-interpretation .field-label,
.tuning-recommendation .tuning-result-interpretation p,
.tuning-recommendation .tuning-result-interpretation summary,
.optimizer-recommendation em,
.optimizer-recommendation p {
  color: var(--system-muted-on-dark);
}

.tuning-recommendation-metrics,
.tuning-recommendation-metrics > span,
.tuning-recommendation .tuning-executed-plan,
.tuning-recommendation .tuning-executed-plan > span,
.tuning-recommendation .tuning-result-interpretation,
.optimizer-recommendation-grid,
.optimizer-recommendation-grid > span {
  border-color: var(--system-rule-on-dark);
}

.tuning-recommendation .tuning-executed-plan,
.tuning-recommendation .tuning-result-interpretation,
.tuning-recommendation-why {
  background: rgba(255, 255, 255, 0.045);
}

.tuning-recommendation .tuning-result-interpretation strong,
.tuning-recommendation-why,
.tuning-recommendation-why strong,
.tuning-recommendation-why span {
  color: var(--color-emphasis-text);
}

.tuning-recommendation-metrics strong.positive {
  color: var(--color-emphasis-highlight);
}

.tuning-recommendation-metrics strong.negative {
  color: #ffb6b9;
}

.tuning-recommendation-metrics strong.neutral {
  color: #e4ce99;
}

.tuning-recommendation .tuning-confidence,
.optimizer-recommendation .confidence-level {
  border-color: var(--system-rule-on-dark);
  background: rgba(255, 255, 255, 0.08);
  color: var(--color-emphasis-text);
}

.tuning-recommendation .tuning-reliability-warning {
  clip-path: none;
}

.primary-button,
.secondary-button,
.ui-button,
.load-deck-button,
.icon-button,
.results-utility-menu > summary {
  border-radius: var(--radius-small) calc(var(--radius-large) + 2px) var(--radius-small) var(--radius-small);
}

@keyframes meta-pulse-scan {
  from {
    right: 82%;
  }
  to {
    right: 0;
  }
}

@media (max-width: 900px) {
  .meta-pulse {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .meta-pulse-label {
    min-width: 0;
    min-height: 38px;
    border-right: 0;
    border-bottom: 1px solid var(--system-rule-on-dark);
    padding: 0 var(--space-4);
  }

  .meta-pulse-items {
    grid-template-columns: repeat(3, minmax(15rem, 78vw));
    overflow-x: auto;
    scroll-snap-type: x proximity;
  }

  .meta-pulse-items > span {
    min-height: 64px;
    scroll-snap-align: start;
    padding: var(--space-3) var(--space-4);
  }
}

@media (max-width: 760px) {
  .guided-dashboard {
    padding-right: var(--space-4);
    padding-left: var(--space-4);
  }

  .meta-pulse-items strong {
    white-space: normal;
  }

  .tuning-recommendation,
  .optimizer-recommendation {
    --system-cut: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .meta-pulse::after {
    right: 0;
    animation: none;
  }
}

@media (forced-colors: active) {
  .meta-pulse,
  .tuning-recommendation,
  .optimizer-recommendation,
  .matchup-summary > .matchup-score {
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
    clip-path: none;
  }

  .meta-pulse-items strong,
  .tuning-recommendation h3,
  .optimizer-recommendation h3,
  .tuning-recommendation strong,
  .optimizer-recommendation strong {
    color: CanvasText;
  }
}

/* V30 focused workspace refinements */
.recent-experiment-strip {
  display: grid;
  grid-template-columns: auto minmax(12rem, 1fr) minmax(14rem, 1.4fr) auto;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.recent-experiment-strip > span,
.recent-experiment-strip > small {
  color: var(--color-text-secondary);
}

.recent-experiment-strip > span {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
}

.recent-experiment-strip > strong {
  color: var(--color-text-primary);
}

.recent-experiment-strip > a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--color-accent-strong);
  font-weight: 700;
}

.deck-utility-menu,
.analysis-details,
.matchup-meta-reference,
.help-release-notes {
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}

.deck-utility-menu {
  margin-top: var(--space-4);
}

.deck-utility-menu > summary,
.analysis-details > summary,
.matchup-meta-reference > summary,
.help-release-notes > summary {
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  color: var(--color-text-primary);
  font-weight: 700;
  list-style: none;
}

.deck-utility-menu > summary::-webkit-details-marker,
.analysis-details > summary::-webkit-details-marker,
.matchup-meta-reference > summary::-webkit-details-marker,
.help-release-notes > summary::-webkit-details-marker,
.results-utility-menu > summary::-webkit-details-marker {
  display: none;
}

.deck-utility-menu > summary::after,
.analysis-details > summary::after,
.matchup-meta-reference > summary::after,
.help-release-notes > summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 1.15rem;
}

.deck-utility-menu[open] > summary::after,
.analysis-details[open] > summary::after,
.matchup-meta-reference[open] > summary::after,
.help-release-notes[open] > summary::after {
  content: "−";
}

.deck-utility-menu > .button-row {
  margin: 0;
  padding: 0 var(--space-4) var(--space-4);
}

.deck-name-tool {
  border-top: 1px solid var(--color-border);
  padding: var(--space-4);
}

.deck-name-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: stretch;
}

.deck-name-controls input {
  min-width: 0;
  font-size: 0.875rem;
}

.deck-name-status {
  min-height: 1.25rem;
  margin: var(--space-2) 0 0;
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  line-height: 1.5;
}

.results-utility-menu {
  position: relative;
}

.results-utility-menu > summary {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  cursor: pointer;
  list-style: none;
  font-size: 1.25rem;
}

.results-utility-menu > button {
  position: absolute;
  z-index: 4;
  top: calc(100% + var(--space-2));
  right: 0;
  min-width: 10rem;
  box-shadow: var(--shadow-medium);
}

.analysis-details {
  margin-top: var(--space-5);
}

.analysis-details > summary span,
.matchup-meta-reference > summary span,
.help-release-notes > summary span {
  display: grid;
  gap: 2px;
}

.analysis-details > summary small,
.matchup-meta-reference > summary small,
.help-release-notes > summary small {
  color: var(--color-text-secondary);
  font-weight: 400;
}

.analysis-details > .deck-understanding,
.analysis-details > .results-table {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

.matchup-meta-reference {
  margin: var(--space-5) 0;
}

.matchup-meta-reference-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  border-top: 1px solid var(--color-border);
}

.matchup-meta-reference > .meta-field-summary,
.matchup-meta-reference > div:last-child {
  margin: 0;
  padding: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.matchup-meta-reference .event-list {
  margin-top: var(--space-3);
}

.help-guide {
  display: grid;
  grid-template-columns: minmax(12rem, 0.7fr) minmax(0, 1.8fr);
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  padding: var(--space-5) 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.help-guide h3 {
  margin: var(--space-1) 0 0;
}

.help-guide ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.help-guide li {
  display: grid;
  gap: var(--space-1);
}

.help-guide li strong {
  color: var(--color-text-primary);
}

.help-guide li span {
  color: var(--color-text-secondary);
}

.help-release-notes {
  margin-top: var(--space-5);
}

.help-release-notes > .changelog-panel {
  margin: 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

.deck-understanding .deck-health {
  margin-top: var(--space-5);
}

@media (max-width: 760px) {
  .recent-experiment-strip {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .recent-experiment-strip > a {
    margin-top: var(--space-2);
  }

  .help-guide,
  .help-guide ol {
    grid-template-columns: 1fr;
  }

  .matchup-meta-reference-head {
    align-items: stretch;
    flex-direction: column;
    padding: var(--space-3) var(--space-4);
  }

  .results-utility-menu > button {
    position: fixed;
    top: auto;
    right: var(--space-4);
    bottom: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .recent-experiment-strip > a {
    scroll-behavior: auto;
  }
}

/* V28 refinement pass: configuration trust, responsive identity, and disclosure. */

.topbar {
  grid-template-columns: minmax(218px, 240px) minmax(420px, 1fr) auto;
}

.header-utilities {
  display: contents;
}

.brand-lockup {
  min-width: 0;
}

.brand-art {
  display: flex;
  width: clamp(176px, 14vw, 210px);
  max-width: 100%;
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-small);
  padding: 4px 6px;
  background: transparent;
  line-height: 0;
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.brand-logo-dark {
  display: none;
}

.brand-logo-mark,
.mobile-section-label,
.mobile-context-action,
.mobile-menu-button {
  display: none;
}

html[data-theme="dark"] .brand-art {
  border-color: transparent;
}

html[data-theme="dark"] .brand-logo.brand-logo-light {
  display: none;
}

html[data-theme="dark"] .brand-logo.brand-logo-dark {
  display: block;
}

.ds-logo-specimen.reverse {
  background: #07111f;
}

.product-intro {
  display: block;
}

.home-tab-view {
  grid-template-areas:
    "intro"
    "guided";
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.product-intro-summary {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) 0;
  cursor: pointer;
  list-style: none;
}

.product-intro-summary::-webkit-details-marker {
  display: none;
}

.product-intro-summary > span:first-child {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.product-intro-summary strong {
  font-family: var(--font-display);
  font-size: var(--type-body);
  font-weight: 650;
}

.product-intro-summary-action {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0;
}

.product-intro-summary-action::after {
  content: "Show workflow";
  font-size: var(--type-caption);
}

.product-intro[open] .product-intro-summary-action::after {
  content: "Hide workflow";
}

.product-intro-content {
  display: grid;
  grid-template-columns: minmax(280px, 0.6fr) minmax(560px, 1.4fr);
  gap: var(--space-5);
  padding-top: var(--space-5);
}

.product-intro-content .product-intro-copy {
  grid-row: 1 / 3;
}

.report-disclosure {
  margin: var(--space-3) 0 0;
  border-left: 2px solid var(--color-border-strong);
  padding-left: var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  line-height: 1.55;
}

.confidence-level.not-run {
  border-color: var(--color-border-strong);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
}

.results-table {
  overflow: visible;
}

.metric-disclosure-bar {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface-raised);
}

.metric-disclosure-bar > span {
  color: var(--color-text-secondary);
  font-size: var(--type-small);
}

.metric-group-title {
  margin: 0;
  padding-right: var(--space-5);
  padding-left: var(--space-5);
}

summary.metric-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  cursor: pointer;
  list-style: none;
}

summary.metric-group-title::-webkit-details-marker {
  display: none;
}

summary.metric-group-title::after {
  content: "+";
  color: var(--color-text-secondary);
  font-size: 1rem;
}

.metric-group-collapsible[open] > summary::after {
  content: "-";
}

summary.metric-group-title small {
  margin-left: auto;
  color: var(--color-text-secondary);
  font-size: var(--type-caption);
  text-transform: none;
}

.metric-row {
  grid-template-columns: minmax(220px, 0.9fr) minmax(240px, 1.4fr) minmax(190px, auto);
  gap: var(--space-5);
  min-height: 68px;
  padding: var(--space-3) var(--space-5);
}

.metric-name-button {
  min-width: 0;
  width: 100%;
}

.metric-percent {
  min-width: 180px;
  padding-right: var(--space-1);
  text-align: right;
}

.metric-percent strong,
.metric-percent small {
  white-space: nowrap;
}

.tuning-experiment-path span {
  position: relative;
  padding-left: 18px;
}

.tuning-experiment-path span::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 8px;
  height: 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: 50%;
  background: var(--color-surface);
  transform: translateY(-50%);
}

.tuning-experiment-path span[data-state="complete"]::before {
  border-color: var(--color-success);
  background: var(--color-success);
}

.tuning-experiment-path span[data-state="active"] {
  color: var(--color-text-primary);
  font-weight: 650;
}

.tuning-experiment-path span[data-state="active"]::before {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.tuning-deck-versus {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  align-items: start;
  padding: var(--space-5) var(--space-5) 0;
}

.tuning-deck-versus .tuning-step {
  width: 100%;
  min-height: 100%;
}

.tuning-deck-versus .tuning-baseline,
.tuning-deck-versus .tuning-variant {
  background: var(--color-surface);
}

.tuning-baseline-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}

.tuning-baseline-summary > * {
  min-width: 0;
  border: 0;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3);
  background: transparent;
}

.tuning-baseline-summary > *:nth-child(odd) {
  background: transparent;
}

.tuning-baseline-summary > *:nth-child(2n + 1):not(.tuning-deck-name) {
  border-right: 0;
}

.tuning-baseline-summary > *:last-child,
.tuning-baseline-summary > *:nth-last-child(2) {
  border-bottom: 0;
}

.tuning-baseline-summary .tuning-deck-name {
  grid-column: 1 / -1;
  border-right: 0;
  font-size: var(--type-body);
}

.tuning-baseline-summary span {
  display: grid;
  gap: var(--space-1);
}

.tuning-baseline-summary small {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--type-caption);
  font-weight: 600;
  text-transform: uppercase;
}

.tuning-baseline-summary b {
  overflow-wrap: anywhere;
  font-size: var(--type-small);
  font-weight: 650;
}

.tuning-deck-actions {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.tuning-deck-list {
  min-width: 0;
  flex: 1 1 auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-medium);
  background: var(--color-surface-raised);
}

.tuning-deck-list > summary {
  min-height: 42px;
  padding: 10px var(--space-3);
  color: var(--color-text-primary);
  font-weight: 650;
  cursor: pointer;
}

.tuning-deck-list pre,
.tuning-deck-list textarea {
  width: 100%;
  max-height: 330px;
  margin: 0;
  border: 0;
  border-top: 1px solid var(--color-border);
  border-radius: 0;
  padding: var(--space-3);
  overflow: auto;
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  font-size: var(--type-caption);
  line-height: 1.55;
  white-space: pre-wrap;
}

.tuning-variant-editor {
  margin-top: var(--space-3);
}

.tuning-variant-editor textarea {
  min-height: 280px;
  resize: vertical;
}

.tuning-shared-changes {
  margin: var(--space-5) var(--space-5) 0;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-large);
  padding: var(--space-4);
  background: var(--color-surface-raised);
}

.tuning-preset-status {
  display: inline-block;
  margin-left: var(--space-2);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--type-caption);
  font-weight: 500;
  text-transform: none;
}

.tuning-presets button.recommended {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  box-shadow: none;
}

.tuning-presets button.recommended::after {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text-secondary);
}

.tuning-presets button[aria-pressed="true"],
.tuning-presets button.recommended[aria-pressed="true"] {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  box-shadow: inset 0 -3px 0 var(--color-accent);
}

.tuning-executed-plan {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.tuning-executed-plan > span {
  display: grid;
  gap: var(--space-1);
  min-width: 0;
  border-right: 1px solid var(--color-border);
  padding: var(--space-3);
}

.tuning-executed-plan > span:last-child {
  border-right: 0;
}

.tuning-executed-plan small {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--type-caption);
  text-transform: uppercase;
}

.tuning-executed-plan strong {
  overflow-wrap: anywhere;
  font-size: var(--type-small);
}

.tuning-reliability-warning {
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-warning);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.tuning-reliability-warning > strong,
.tuning-reliability-warning p,
.tuning-reliability-warning button,
.tuning-reliability-warning button strong {
  color: var(--color-text-primary);
}

.tuning-reliability-warning button {
  border-color: var(--color-border-strong);
  background: var(--color-surface);
}

.tuning-reliability-warning button small {
  color: var(--color-text-secondary);
}

.tuning-reason-list strong {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tuning-reason-indicator {
  display: inline-grid !important;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  margin: 0 !important;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--color-text-secondary) !important;
  font-family: var(--font-mono);
}

.tuning-reason-list li.favourable .tuning-reason-indicator {
  color: var(--color-success) !important;
}

.tuning-reason-list li.unfavourable .tuning-reason-indicator {
  color: var(--color-error) !important;
}

.card-assistant-result {
  grid-template-columns: 76px minmax(0, 1fr) minmax(132px, 158px);
  gap: var(--space-5);
  padding: 18px var(--space-3);
}

.card-assistant-result-copy {
  max-width: 820px;
}

.card-assistant-result-effect {
  max-width: 760px;
}

.card-assistant-result-aside {
  align-self: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.card-assistant-result-reasons span,
.support-badge {
  padding: 3px 6px;
  font-size: 0.62rem;
}

.primary-button:hover,
.secondary-button:hover,
.ui-button:hover,
.icon-button:hover,
.guided-actions button:hover,
.card-assistant-result:hover {
  transform: none;
}

.primary-button:active,
.secondary-button:active,
.ui-button:active,
.icon-button:active {
  transform: translateY(1px);
}

.ds-logo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.ds-logo-specimen {
  display: grid;
  min-width: 0;
  align-content: center;
  gap: var(--space-3);
  min-height: 180px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  padding: var(--space-5);
  background: var(--color-surface);
}

.ds-logo-specimen.reverse {
  background: #1e2420;
}

.ds-logo-specimen img {
  display: block;
  width: 100%;
  max-height: 128px;
  object-fit: contain;
  object-position: left center;
}

.ds-logo-specimen.mark img {
  width: 96px;
}

.ds-logo-specimen span {
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: var(--type-caption);
}

.ds-logo-specimen.reverse span {
  color: #f3f1e8;
}

.ds-contrast-table {
  width: 100%;
  margin-top: var(--space-4);
  border-collapse: collapse;
  font-size: var(--type-small);
}

.ds-contrast-table th,
.ds-contrast-table td {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3);
  text-align: left;
}

.ds-contrast-table td:last-child {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: minmax(218px, 1fr) auto;
  }

  .header-utilities {
    display: contents;
  }

  .product-intro-content {
    grid-template-columns: 1fr;
  }

  .product-intro-content .product-intro-copy {
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  html {
    scroll-padding-top: 76px;
  }

  .topbar {
    position: sticky;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto 44px;
    grid-template-rows: 48px;
    gap: var(--space-2);
    min-height: 64px;
    align-items: center;
    padding: var(--space-2) var(--space-3);
  }

  .brand-lockup {
    grid-column: 1;
    grid-row: 1;
    width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .brand-art {
    width: 38px;
    height: 38px;
    border-color: rgba(23, 27, 30, 0.16);
    padding: 3px;
  }

  .brand-logo {
    display: none !important;
  }

  .brand-logo-mark {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .brand-logo-mark.brand-logo-light {
    display: block;
  }

  .brand-logo-mark.brand-logo-dark {
    display: none;
  }

  html[data-theme="dark"] .brand-logo-mark.brand-logo-light {
    display: none;
  }

  html[data-theme="dark"] .brand-logo-mark.brand-logo-dark {
    display: block;
  }

  .mobile-section-label {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: var(--color-text-primary);
    font-size: 0.9rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-context-action {
    display: inline-flex;
    min-height: 44px;
    padding: 0 var(--space-3);
    white-space: nowrap;
  }

  .mobile-menu-button {
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-medium);
    background: var(--color-surface-raised);
    color: var(--color-text-primary);
    font-size: 1.45rem;
  }

  .header-utilities {
    position: absolute;
    z-index: 60;
    top: 100%;
    right: var(--space-3);
    left: var(--space-3);
    display: none;
    max-height: calc(100vh - 82px);
    gap: var(--space-3);
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-large);
    padding: var(--space-3);
    background: var(--color-surface);
    box-shadow: var(--shadow-large);
  }

  .header-utilities.open {
    display: grid;
  }

  .header-utilities .topbar-nav {
    display: grid;
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: 1fr;
    gap: var(--space-1);
    width: 100%;
  }

  .header-utilities .nav-group {
    position: static;
    width: 100%;
  }

  .header-utilities .nav-group > summary {
    width: 100%;
    min-height: 44px;
    justify-content: space-between;
    padding: 0 var(--space-3);
    font-size: var(--type-small);
  }

  .header-utilities .nav-menu,
  .header-utilities .nav-group:nth-last-child(-n + 2) .nav-menu {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: var(--space-1);
    border: 0;
    border-left: 2px solid var(--color-border);
    border-radius: 0;
    padding: 0 0 0 var(--space-3);
    box-shadow: none;
  }

  .header-utilities .nav-menu a,
  .header-utilities .nav-menu button {
    min-height: 44px;
  }

  .header-utilities .topbar-actions {
    display: grid;
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    width: 100%;
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-3);
  }

  .header-utilities .theme-switch {
    grid-column: 1 / -1;
    min-height: 44px;
    justify-content: space-between;
  }

  .header-utilities #runButton {
    display: none;
  }

  .product-intro-summary > span:first-child {
    display: grid;
    gap: 0;
  }

  .product-intro-content {
    gap: var(--space-4);
    padding-top: var(--space-4);
  }

  .metric-disclosure-bar {
    display: grid;
    padding: var(--space-3) var(--space-4);
  }

  .metric-disclosure-bar button {
    width: 100%;
  }

  .metric-group-title {
    padding-right: var(--space-4);
    padding-left: var(--space-4);
  }

  .metric-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2) var(--space-3);
    min-height: 88px;
    padding: var(--space-3) var(--space-4);
  }

  .metric-name-button {
    grid-column: 1 / -1;
  }

  .metric-percent {
    min-width: 112px;
  }

  .tuning-experiment-path {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }

  .tuning-experiment-path b {
    display: none;
  }

  .tuning-deck-versus {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-4) 0;
  }

  .tuning-shared-changes {
    margin: var(--space-4) var(--space-4) 0;
  }

  .tuning-baseline-summary {
    grid-template-columns: 1fr;
  }

  .tuning-baseline-summary > *,
  .tuning-baseline-summary > *:nth-child(2n + 1):not(.tuning-deck-name),
  .tuning-baseline-summary > *:nth-last-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .tuning-baseline-summary > *:last-child {
    border-bottom: 0;
  }

  .tuning-deck-actions {
    display: grid;
  }

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

  .tuning-executed-plan > span:nth-child(2) {
    border-right: 0;
  }

  .tuning-executed-plan > span:nth-child(-n + 2) {
    border-bottom: 1px solid var(--color-border);
  }

  .card-assistant-result {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: var(--space-3);
    padding: var(--space-4) 0;
  }

  .card-assistant-result-aside {
    grid-column: 2;
  }

  .ds-logo-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .topbar {
    grid-template-columns: 44px minmax(0, 1fr) auto 44px;
    gap: 6px;
  }

  .mobile-context-action {
    padding-inline: 10px;
    font-size: 0.72rem;
  }

  .metric-percent {
    min-width: 104px;
  }

  .metric-percent small {
    font-size: 0.62rem;
  }

  .tuning-executed-plan {
    grid-template-columns: 1fr;
  }

  .tuning-executed-plan > span,
  .tuning-executed-plan > span:nth-child(2) {
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .tuning-executed-plan > span:last-child {
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .product-intro,
  .header-utilities,
  .metric-group-collapsible,
  .card-assistant-result,
  .tuning-experiment-path span {
    scroll-behavior: auto;
    transition: none !important;
    animation: none !important;
  }
}

@media (forced-colors: active) {
  .mobile-menu-button,
  .tuning-reliability-warning,
  .tuning-deck-list,
  .tuning-shared-changes,
  .matchup-score,
  .comparison-row,
  .replay-board,
  .replay-player,
  .replay-hand-card,
  .replay-unit,
  .replay-base,
  .replay-shields,
  .decision-inspector {
    border: 1px solid ButtonText;
  }
}

@keyframes instrument-enter {
  from {
    opacity: 0.01;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes recommendation-settle {
  from {
    opacity: 0.01;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Application-wide accessibility contract for light and dark themes. */

.deck-health-row progress,
progress {
  color: var(--color-text-primary);
}

.icon-button.primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.segmented-control {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
}

.segmented-control button {
  min-height: 44px;
  color: var(--color-text-secondary);
}

.segmented-control button.active,
.segmented-control button[aria-pressed="true"],
.segmented-control button[aria-selected="true"] {
  background: var(--color-text-primary);
  color: var(--color-text-inverse);
}

.load-deck-button {
  min-height: 44px;
  background: var(--color-text-primary);
  color: var(--color-text-inverse);
}

.workflow-path > i,
.example-deck-list small {
  color: var(--color-text-secondary);
}

.burst-reference,
.support-details,
.deck-support-audit,
.game-log,
.arena-action-panel,
.arena-log {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.burst-reference {
  border-left-color: var(--color-error);
}

.burst-reference-head > span,
.burst-card-odds {
  color: var(--color-error);
}

.burst-summary,
.burst-summary > span,
.burst-card-list,
.burst-card-row,
.support-card-list,
.support-card-row {
  border-color: var(--color-border);
}

.burst-card-row,
.support-card-row,
.game-log li:nth-child(odd),
.arena-card-result,
.arena-live-hand-card,
.arena-live-unit,
.arena-live-base,
.arena-live-shields,
.arena-action-panel,
.arena-log {
  background: var(--color-surface);
  color: var(--color-text-primary);
}

.support-details {
  border-left-color: var(--color-warning);
}

.model-status.experimental,
.support-badge.partial {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.support-badge.stats_only,
.replay-base.destroyed,
.arena-live-base.destroyed {
  border-color: var(--color-error);
  background: var(--color-error-soft);
  color: var(--color-error);
}

.game-log li {
  color: var(--color-text-secondary);
}

.game-log li > span:first-child {
  color: var(--color-text-primary);
}

.arena-config-side.opponent,
.arena-live-player.opponent,
.arena-live-unit.is-rested {
  background: var(--color-warning-soft);
  color: var(--color-text-primary);
}

.arena-live-player.pilot {
  background: var(--color-accent-soft);
  color: var(--color-text-primary);
}

.arena-add-button,
.arena-action-head,
.arena-action-button,
.arena-live-counts > span {
  border-color: var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.arena-live-counts > span,
.arena-empty-zone,
.arena-empty-actions,
.arena-card-empty {
  color: var(--color-text-secondary);
}

.arena-event-band {
  background: var(--color-emphasis-surface);
  color: var(--color-emphasis-text);
}

.arena-event-band span {
  color: var(--color-emphasis-highlight);
}

.arena-end-turn {
  border-color: var(--color-error);
  background: var(--color-error);
  color: var(--color-text-inverse);
}

.dashboard-signal > a,
.dashboard-signal > button,
.bo3-rules-link,
.metric-name-button,
.card-assistant-suggestion-actions button,
.burst-details summary,
.support-details summary,
.deck-support-audit summary,
.game-log summary,
.arena-log summary {
  min-height: 44px;
}

.dashboard-signal > a,
.dashboard-signal > button,
.bo3-rules-link,
.burst-details summary,
.support-details summary,
.deck-support-audit summary,
.game-log summary,
.arena-log summary {
  display: inline-flex;
  align-items: center;
}

.ui-button.icon,
.icon-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.replay-game-tabs button,
.replay-speed-label select,
.arena-add-button,
.arena-zone-numbers input,
.arena-unit-state select,
.arena-unit-damage input {
  min-height: 44px;
}

@media (prefers-contrast: more) {
  :root {
    --color-border: #a1a8a2;
    --color-border-strong: #626b65;
  }

  html[data-theme="dark"] {
    --color-border: #616b63;
    --color-border-strong: #98a29a;
  }
}

@media (forced-colors: active) {
  .segmented-control,
  .burst-reference,
  .support-details,
  .deck-support-audit,
  .game-log,
  .arena-config-side,
  .arena-live-player,
  .arena-card-result,
  .arena-action-panel,
  .arena-log {
    border: 1px solid CanvasText;
    background: Canvas;
    color: CanvasText;
  }

  .segmented-control button.active,
  .segmented-control button[aria-pressed="true"],
  .segmented-control button[aria-selected="true"] {
    background: Highlight;
    color: HighlightText;
  }
}

/* Final V36 cascade guarantees. Keep these after legacy interface layers. */
.tuning-experiment-path[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .meta-pulse-items {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
    scroll-snap-type: none;
  }

  .meta-pulse-items > span {
    min-width: 0;
    scroll-snap-align: none;
  }
}

@media (max-width: 600px) {
  .meta-pulse-items {
    grid-template-columns: 1fr;
  }

  .meta-pulse-items > span:nth-child(n + 2) {
    display: none;
  }
}

@media (max-width: 430px) {
  .metric-percent small {
    font-size: 0.75rem;
  }
}

/* Meaningful labels and telemetry retain a readable 12px floor. */
.meta-pulse-items small,
.example-deck-profile,
.stat-pill,
.score-chip,
.assessment-outcome > span,
.confidence-level,
.metric-confidence,
.model-status,
.role-counts span:not(.info-mark),
.deck-health-head > span,
.deck-health-row > span,
.deck-health-row > strong,
.burst-reference-head > span,
.burst-effect,
.support-badge,
.field-label,
#tuningChangeCount,
.tuning-change span,
.tuning-change-preview h5,
.tuning-change-preview li > span,
.tuning-controls small,
.tuning-simulation-plan > div > span,
.tuning-results-preview li strong,
.tuning-results-preview li span,
.optimizer-results-preview span,
.meta-field-summary-head > span,
.meta-color-row > span:first-child,
.meta-color-row > strong,
.meta-leading-archetypes > span > strong,
.mobile-context-action {
  font-size: 0.75rem !important;
}

/* Keep Build status telemetry inside its panel at split-workspace widths. */
.deck-panel > .panel-head {
  flex-wrap: wrap;
}

.deck-panel > .panel-head > :first-child {
  flex: 1 1 150px;
  min-width: 0;
}

.deck-panel .deck-stats {
  flex: 1 1 320px;
  max-width: 100%;
  margin-right: 0;
}

.deck-panel .deck-stats > .stat-pill {
  min-width: 0;
  max-width: 100%;
  height: auto;
  line-height: 1.3;
  overflow-wrap: anywhere;
  white-space: normal;
}

@media (max-width: 760px) {
  .deck-panel .deck-stats {
    width: 100%;
    justify-content: flex-start;
  }

  .deck-name-controls {
    grid-template-columns: 1fr;
  }
}
