/* GameDev Toolbox: shared styles for every page. */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --border: #e3e2dd;
  --border-strong: #c9c7c0;
  --text: #17171b;
  --text-2: #45454d;
  --text-3: #62626b;
  --accent: #1c5cab;
  --accent-hover: #184f95;
  --accent-soft: #eaf1fb;
  --on-accent: #ffffff;
  --focus: #2a78d6;
  --danger: #b42318;
  --danger-soft: #fdf0ef;
  --warning-soft: #fdf6e7;
  --warning-border: #e7c77d;
  --success: #067647;
  --chart-line: #2a78d6;
  --chart-grid: #e8e7e2;
  --chart-axis: #c9c7c0;
  --shadow: 0 1px 2px rgb(16 16 20 / 0.04), 0 1px 3px rgb(16 16 20 / 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --container: 1200px;
  --gutter: 16px;
}

/* Dark tokens, twice: once for the OS setting (used before theme.js runs or
   without JavaScript), once for the explicit toggle. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111113;
    --surface: #19191c;
    --surface-2: #222226;
    --border: #2d2d32;
    --border-strong: #45454d;
    --text: #f1f1ef;
    --text-2: #c9c8c1;
    --text-3: #a3a2ab;
    --accent: #86b6ef;
    --accent-hover: #9ec5f4;
    --accent-soft: #1a2940;
    --on-accent: #0b1627;
    --focus: #86b6ef;
    --danger: #ff8f85;
    --danger-soft: #34191a;
    --warning-soft: #2e2615;
    --warning-border: #6b5520;
    --success: #5fd49a;
    --chart-line: #3987e5;
    --chart-grid: #2b2b30;
    --chart-axis: #45454d;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111113;
  --surface: #19191c;
  --surface-2: #222226;
  --border: #2d2d32;
  --border-strong: #45454d;
  --text: #f1f1ef;
  --text-2: #c9c8c1;
  --text-3: #a3a2ab;
  --accent: #86b6ef;
  --accent-hover: #9ec5f4;
  --accent-soft: #1a2940;
  --on-accent: #0b1627;
  --focus: #86b6ef;
  --danger: #ff8f85;
  --danger-soft: #34191a;
  --warning-soft: #2e2615;
  --warning-border: #6b5520;
  --success: #5fd49a;
  --chart-line: #3987e5;
  --chart-grid: #2b2b30;
  --chart-axis: #45454d;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.35);
}

@media (min-width: 768px) {
  :root { --gutter: 24px; }
}

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
}

main { flex: 1 0 auto; }

/* Components set display: grid/flex, which would otherwise override [hidden]. */
[hidden] { display: none !important; }

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

h1, h2, h3 {
  margin: 0 0 0.5em;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.75rem, 1.35rem + 1.8vw, 2.5rem); font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 650; }
h3 { font-size: 1.0625rem; font-weight: 650; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.25em; }
li + li { margin-top: 0.35em; }

code, .formula {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

pre {
  margin: 0 0 1em;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 10;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--focus);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 8px; }

.muted { color: var(--text-3); }
.small { font-size: 0.875rem; }

/* ------------------------------------------------------------------ header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.0625rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand img { width: 28px; height: 28px; flex: none; }

.site-nav { margin-left: auto; }
.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-nav li + li { margin-top: 0; }
.site-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (max-width: 767px) {
  .header-inner { padding-block: 10px 6px; }
  .theme-toggle { margin-left: auto; }
  .site-nav {
    order: 3;
    width: 100%;
    margin-left: -8px;
  }
  .site-nav ul { gap: 2px; }
  .site-nav a { padding: 8px; }
}

/* ------------------------------------------------------------------ footer */

.site-footer {
  margin-top: 64px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
}

.footer-inner {
  display: grid;
  gap: 20px;
  padding-block: 32px;
}

.footer-brand { margin: 0 0 4px; font-weight: 700; }
.footer-inner p { margin: 0; }

.footer-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.footer-nav li + li { margin-top: 0; }
.footer-nav a { color: var(--text-2); }
.footer-nav a:hover { color: var(--text); }

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 0.875rem;
}

@media (min-width: 768px) {
  .footer-inner { grid-template-columns: 1fr auto; align-items: start; }
  .footer-meta { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------------ page scaffolding */

.page { padding-top: 32px; }

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  color: var(--text-3);
}
.breadcrumbs li + li { margin-top: 0; }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumbs a { color: var(--text-2); }

.page-header { margin-bottom: 28px; max-width: 760px; }
.page-header .lede { font-size: 1.125rem; color: var(--text-2); }

.lede { font-size: 1.125rem; color: var(--text-2); }

.section { margin-top: 56px; }
.section-header { max-width: 720px; margin-bottom: 20px; }
.section-header p { color: var(--text-2); }

.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.8em; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin-top: 1.5em; }

/*
 * Ad slots (filled by assets/js/ads.js). A slot stays [hidden] unless an ad
 * key is configured, and collapses again if no ad renders. The label only
 * appears once an ad is showing, so an empty box is never drawn.
 */
.ad-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 40px;
}
.tool-sidebar .ad-slot { margin-top: 0; }
.ad-label {
  margin: 0;
  color: var(--text-3);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  visibility: hidden;
}
.ad-slot.is-filled .ad-label { visibility: visible; }
.ad-body { display: flex; justify-content: center; max-width: 100%; }
.ad-frame {
  display: block;
  max-width: 100%;
  border: 0;
  background: transparent;
}

/* ------------------------------------------------------------------ components */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--on-accent);
}
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.875rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}
.badge-available {
  border-color: color-mix(in srgb, var(--success) 40%, transparent);
  background: color-mix(in srgb, var(--success) 10%, transparent);
  color: var(--success);
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.privacy-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.875rem;
}
.privacy-note svg { width: 16px; height: 16px; flex: none; color: var(--success); }

.notice {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.875rem;
}
.notice-info {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent-soft);
}
.notice-warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
}

ul.card-grid { margin: 0; padding: 0; list-style: none; }
ul.card-grid > li + li { margin-top: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 16px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tool-card h3 { margin: 0; }
.tool-card p { margin: 0; color: var(--text-2); font-size: 0.9375rem; }
.tool-card .card-actions { margin-top: auto; padding-top: 6px; }
.tool-card-planned { box-shadow: none; background: transparent; border-style: dashed; }

.feature-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.feature-list li { display: flex; gap: 10px; margin: 0; }
.feature-list svg { width: 18px; height: 18px; flex: none; margin-top: 3px; color: var(--success); }

/* ------------------------------------------------------------------ home */

.hero { padding-block: 48px 8px; }
.hero h1 { font-size: clamp(2rem, 1.4rem + 2.6vw, 3rem); margin-bottom: 0.25em; }
.hero .tagline { font-size: clamp(1.125rem, 1rem + 0.6vw, 1.375rem); color: var(--text-2); font-weight: 500; margin-bottom: 0.75em; }
.hero .lede { max-width: 620px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.featured {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
@media (min-width: 900px) {
  .featured { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.featured h2 { margin-bottom: 0.4em; }

.sample-table-caption { margin: 0 0 8px; font-size: 0.8125rem; color: var(--text-3); }

.value-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 16px;
}
.value-grid h3 { margin-bottom: 0.3em; }
.value-grid p { margin: 0; color: var(--text-2); font-size: 0.9375rem; }

/* ------------------------------------------------------------------ forms */

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; font-size: 0.9375rem; font-weight: 650; }
/* Floating the legend keeps the fieldset's top border from running through it. */
.field-group > legend { float: left; width: 100%; }
.field-group > legend + * { clear: both; }
.legend-optional { color: var(--text-3); font-weight: 500; }

.field-group + .field-group {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label,
.field-label { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.hint { margin: 0; font-size: 0.8125rem; color: var(--text-3); line-height: 1.45; }

.field-row { display: grid; gap: 12px; }
.field-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

input[type="number"],
input[type="text"],
select {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}
input[type="number"]:focus-visible,
input[type="text"]:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 0;
  border-color: var(--focus);
}
input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
}
input::placeholder { color: var(--text-3); opacity: 1; }

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
}

.choice-list { display: grid; gap: 8px; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.choice:hover { border-color: var(--border-strong); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input {
  width: 16px;
  height: 16px;
  margin: 3px 0 0;
  flex: none;
  accent-color: var(--accent);
}
.choice-title { display: block; font-size: 0.9375rem; font-weight: 600; }
.choice-desc { display: block; font-size: 0.8125rem; color: var(--text-2); line-height: 1.45; }
.choice-formula { display: block; margin-top: 2px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-3); }

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
  cursor: pointer;
}
.checkbox input {
  width: 16px;
  height: 16px;
  margin: 4px 0 0;
  flex: none;
  accent-color: var(--accent);
}

.stat-grid {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}
.stat-grid .col-head {
  align-self: end;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  line-height: 1.3;
}
.stat-name { font-size: 0.9375rem; font-weight: 600; }
.stat-grid .field-error { grid-column: 1 / -1; margin-top: -2px; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}
.form-actions .btn-primary { flex: 1 1 auto; }

.error-summary {
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
}
.error-summary:focus-visible { outline-offset: 3px; }
.error-summary h3 { margin: 0 0 6px; font-size: 0.9375rem; color: var(--danger); }
.error-summary ul { margin: 0; padding-left: 18px; font-size: 0.875rem; }
.error-summary a { color: var(--text); }

/* ------------------------------------------------------------------ tool layout */

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (min-width: 1024px) {
  .tool-layout { grid-template-columns: minmax(330px, 370px) minmax(0, 1fr); }
}

.tool-inputs h2,
.results-header h2 { font-size: 1.1875rem; margin: 0; }
.tool-inputs h2 { margin-bottom: 16px; }

.tool-sidebar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; min-width: 0; }

.tool-results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }

.results-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
}
.results-meta { margin: 0; font-size: 0.875rem; color: var(--text-3); }

.results-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-2);
}
.empty-state p { margin: 0 auto; max-width: 420px; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 1180px) and (min-width: 1024px), (max-width: 700px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.stat-tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}
.stat-tile p { margin: 0; }
.stat-tile-label { font-size: 0.8125rem; font-weight: 600; color: var(--text-2); }
.stat-tile-value {
  margin: 2px 0 4px !important;
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.stat-tile-detail { font-size: 0.8125rem; color: var(--text-3); line-height: 1.45; }

.panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 12px;
}
.panel-heading h3 { margin: 0; }

/* ------------------------------------------------------------------ charts */

.chart-readout {
  min-height: 1.5em;
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
  border-radius: var(--radius-sm);
}
@media (max-width: 560px) {
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
}
.chart-grid:focus-visible { outline-offset: 6px; }

.stat-chart-card { margin: 0; min-width: 0; }
.stat-chart-title { margin-bottom: 2px; font-size: 0.875rem; font-weight: 600; }

.stat-chart {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
}
.stat-chart .chart-gridline { stroke: var(--chart-grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.stat-chart .chart-baseline { stroke: var(--chart-axis); stroke-width: 1; vector-effect: non-scaling-stroke; }
.stat-chart .chart-tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.stat-chart .chart-area { fill: var(--chart-line); fill-opacity: 0.1; stroke: none; }
.stat-chart .chart-line {
  fill: none;
  stroke: var(--chart-line);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.stat-chart .chart-dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; }
.stat-chart .chart-value {
  fill: var(--text);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.stat-chart .chart-crosshair { stroke: var(--text-3); stroke-width: 1; vector-effect: non-scaling-stroke; }
.stat-chart .chart-hit { fill: transparent; cursor: crosshair; }

/* ------------------------------------------------------------------ table */

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px 16px;
  margin-bottom: 12px;
}
.table-toolbar .field-filter { flex: 1 1 200px; }
.table-toolbar .field-step { flex: 0 1 190px; }
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.table-status { margin: 0 0 8px; font-size: 0.875rem; color: var(--text-3); }

.table-wrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}
.stat-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 14px;
  background: var(--surface-2);
  box-shadow: inset 0 -1px 0 var(--border);
  color: var(--text-2);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.stat-table tbody th,
.stat-table tbody td {
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}
.stat-table thead th:first-child,
.stat-table tbody th { text-align: left; }
.stat-table tbody th { font-weight: 600; }
.stat-table tbody tr:last-child > * { border-bottom: 0; }
.stat-table tbody tr:hover { background: var(--surface-2); }
.stat-table .table-empty { padding: 24px 14px; text-align: center; color: var(--text-3); white-space: normal; }

.export-note { margin: 10px 0 0; font-size: 0.8125rem; color: var(--text-3); }

.action-status { margin: 8px 0 0; min-height: 1.4em; font-size: 0.875rem; color: var(--success); font-weight: 500; }
.action-status.is-error { color: var(--danger); }

/* Off-screen buffer for the clipboard fallback. */
.clipboard-buffer {
  position: fixed;
  top: 0;
  left: -9999px;
  opacity: 0;
}

/* ------------------------------------------------------------------ guide */

.guide {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
}
@media (min-width: 1024px) {
  .guide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 48px; }
}
.guide h2 { margin-top: 0; }

.formula-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1em;
  font-size: 0.9375rem;
}
.formula-table th,
.formula-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.formula-table thead th { font-size: 0.8125rem; color: var(--text-2); }
.formula-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ 404 */

.not-found { padding-block: 64px; max-width: 620px; }
.not-found .hero-actions { margin-top: 20px; }

/* ------------------------------------------------------------------ print */

@media print {
  .site-header, .site-footer, .tool-inputs, .table-toolbar, .export-note, .action-status, .skip-link { display: none !important; }
  .table-wrap { max-height: none; overflow: visible; }
  .tool-layout { display: block; }
}
