/* AI Agents Arena — Hand-Written Design System (Light & Dark with System Fallback) */

:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --surface-hover: #e8eef5;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-soft: #64748b;
  --accent: #0f52ba;
  --accent-strong: #1d4ed8;
  --accent-bg: #eff6ff;
  --accent-border: #bfdbfe;
  --accent-text: #ffffff;
  --focus-ring: rgba(15, 82, 186, 0.18);
  --ok-text: #166534;
  --ok-bg: #dcfce7;
  --warn-text: #9a3412;
  --warn-bg: #ffedd5;
  --err-text: #b91c1c;
  --err-bg: #fef2f2;
  --chart-bar: #93c5fd;
  --chart-bar-hover: #3b82f6;
  --chart-line: #0f52ba;
  --chart-grid: #e2e8f0;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.06), 0 2px 6px rgba(15, 23, 42, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --container-max: 1140px;
  --header-height: 71px;
  --font-display: "Inter", "Plus Jakarta Sans", "SF Pro Display", "Segoe UI Variable Display", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-sans: "Inter", "SF Pro Text", "Segoe UI Variable Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Noto Sans", "Ubuntu", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Cascadia Code", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #111827;
    --surface-subtle: #1e293b;
    --surface-hover: #273449;
    --border: #1e293b;
    --border-strong: #334155;
    --text: #f1f5f9;
    --text-muted: #cbd5e1;
    --text-soft: #94a3b8;
    --accent: #60a5fa;
    --accent-strong: #3b82f6;
    --accent-bg: #172554;
    --accent-border: #1e40af;
    --accent-text: #0b1120;
    --focus-ring: rgba(96, 165, 250, 0.25);
    --ok-text: #4ade80;
    --ok-bg: #052e16;
    --warn-text: #fbbf24;
    --warn-bg: #451a03;
    --err-text: #f87171;
    --err-bg: #450a0a;
    --chart-bar: #1d4ed8;
    --chart-bar-hover: #60a5fa;
    --chart-line: #93c5fd;
    --chart-grid: #1e293b;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.35);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111827;
  --surface-subtle: #1e293b;
  --surface-hover: #273449;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-soft: #94a3b8;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --accent-bg: #172554;
  --accent-border: #1e40af;
  --accent-text: #0b1120;
  --focus-ring: rgba(96, 165, 250, 0.25);
  --ok-text: #4ade80;
  --ok-bg: #052e16;
  --warn-text: #fbbf24;
  --warn-bg: #451a03;
  --err-text: #f87171;
  --err-bg: #450a0a;
  --chart-bar: #1d4ed8;
  --chart-bar-hover: #60a5fa;
  --chart-line: #93c5fd;
  --chart-grid: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.35);
}

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

html {
  font-size: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  padding-top: var(--header-height);
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem; /* 17px */
  line-height: 1.65;
  font-kerning: normal;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 150ms ease;
}

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

button,
[role="button"],
select,
summary,
label[for],
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  z-index: 1000;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  min-height: 70px;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  flex-wrap: nowrap;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 750;
  font-size: 1.15rem;
  letter-spacing: -0.025em;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 44px;
}

.brand-link:hover {
  color: var(--accent);
}

.brand-mark {
  color: var(--text);
  flex-shrink: 0;
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.primary-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.96875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  border-bottom: 2px solid transparent;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.primary-nav a:hover {
  color: var(--text);
  background: var(--surface-subtle);
}

.primary-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.header-cta-wrap {
  flex-shrink: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.theme-toggle:hover {
  background: var(--surface-subtle);
  border-color: var(--accent);
  color: var(--text);
}

.theme-icon-sun {
  display: none;
}

.theme-icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-icon-moon {
    display: none;
  }
}

:root[data-theme="dark"] .theme-icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.nav-toggle:hover {
  background: var(--surface-subtle);
}

.nav-toggle-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 1px;
  transition: transform 150ms ease, opacity 150ms ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.625rem 1.15rem;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-sm {
  min-height: 42px;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-text);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

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

/* Main & Typography */
.site-main {
  padding-top: 2rem;
  padding-bottom: 4rem;
}

.breadcrumbs ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  list-style: none;
  margin: 0 0 1.125rem 0;
  padding: 0;
  font-size: 0.875rem;
  color: var(--text-soft);
}

.breadcrumbs li + li::before {
  content: "/";
  margin-right: 0.45rem;
  color: var(--border-strong);
}

.breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.15rem 0.25rem;
  border-radius: 4px;
}

.breadcrumbs a:hover {
  color: var(--text);
  text-decoration: underline;
}

.page-intro {
  margin-bottom: 1.75rem;
  max-width: 78ch;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  color: var(--text);
}

h1 {
  margin: 0 0 0.65rem 0;
  font-size: clamp(1.95rem, 3.2vw, 2.5rem);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.lead {
  margin: 0 0 0.8rem 0;
  font-size: 1.15rem;
  font-weight: 420;
  line-height: 1.58;
  letter-spacing: -0.006em;
  color: var(--text-muted);
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  font-size: 0.875rem;
  color: var(--text-soft);
  margin: 0;
}

.meta-sep {
  color: var(--border-strong);
}

h2 {
  margin: 2.5rem 0 0.875rem 0;
  font-size: 1.48rem;
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: -0.022em;
}

h3 {
  margin: 1.65rem 0 0.55rem 0;
  font-size: 1.16rem;
  font-weight: 650;
  line-height: 1.32;
  letter-spacing: -0.014em;
}

p {
  margin: 0 0 1.05rem 0;
}

ul, ol {
  margin: 0 0 1.15rem 0;
  padding-left: 1.4rem;
}

li {
  margin-bottom: 0.45rem;
}

.prose {
  max-width: 76ch;
}

.prose code,
.formula-block,
.formula-expr {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.prose code {
  background: var(--surface-subtle);
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.formula-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.125rem 1.35rem;
  overflow-x: auto;
  margin: 1.15rem 0 1.45rem 0;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
}

/* Structured Calculation Pipeline */
.formula-pipeline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin: 1.25rem 0 1.75rem 0;
}

.formula-pipeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border);
}

.formula-pipeline-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.formula-pipeline-meta {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
  white-space: nowrap;
}

.formula-stage {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.formula-stage:last-child {
  border-bottom: 0;
}

.formula-stage-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin-bottom: 0.75rem;
}

.formula-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.formula-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  margin: 0;
}

.formula-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 0.05rem;
}

.formula-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.formula-label-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.65rem;
}

.formula-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.formula-note {
  font-size: 0.8125rem;
  color: var(--text-soft);
}

.prose code.formula-expr,
code.formula-expr {
  display: block;
  width: 100%;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-variant-ligatures: none;
  font-size: 0.845rem;
  line-height: 1.58;
  letter-spacing: -0.01em;
  white-space: normal;
  overflow-wrap: anywhere;
}

.formula-expr .formula-op {
  color: var(--accent);
  font-weight: 600;
}

.formula-pipeline-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface-subtle);
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Calculator Shell */
.calc-shell {
  margin-top: 1.25rem;
  margin-bottom: 3rem;
}

.calc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.875rem 1.25rem;
  margin-bottom: 1.25rem;
}

.preset-group {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  padding: 0.3rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.preset-btn {
  min-height: 44px;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.preset-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.preset-btn.is-active {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.calc-privacy-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-soft);
}

.mobile-kpi-strip {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem;
  margin-bottom: 1.125rem;
  box-shadow: var(--shadow-sm);
}

.mobile-kpi-item .kpi-label {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-soft);
}

.mobile-kpi-item .kpi-val {
  font-size: 1.25rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: minmax(330px, 440px) minmax(0, 1fr);
  gap: 1.75rem;
  align-items: start;
}

.calc-inputs-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  margin: 0 0 1.05rem 0;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel-section + .panel-section {
  margin-top: 1.35rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border);
}

.advanced-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  list-style: none;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem 0 -0.5rem;
  border-radius: var(--radius-sm);
  user-select: none;
  transition: background-color 150ms ease;
}

.advanced-summary:hover {
  background: var(--surface-subtle);
}

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

.summary-chevron::before {
  content: "+";
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text-muted);
}

.advanced-details[open] .summary-chevron::before {
  content: "-";
}

.advanced-body {
  margin-top: 1.125rem;
}

.field-group {
  margin-bottom: 1rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

input[type="number"],
input[type="text"],
input[type="email"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

input[type="number"]:hover,
input[type="text"]:hover,
input[type="email"]:hover,
select:hover,
textarea:hover {
  border-color: var(--text-soft);
}

input[type="number"]:focus,
input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--surface);
}

input[type="number"]:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input[type="number"] {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

select {
  cursor: pointer;
  padding-right: 2.25rem;
}

textarea {
  min-height: 132px;
  resize: vertical;
}

.tip-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

/* Expand invisible touch target to 44x44 without bloating label height */
.tip-btn::after {
  content: "";
  position: absolute;
  inset: -8px;
}

.tip-btn:hover,
.tip-btn[aria-expanded="true"] {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.tip-text {
  margin: 0.35rem 0 0.6rem 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.field-error {
  display: block;
  min-height: 1.15em;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--err-text);
}

/* Results Panel */
.calc-results-panel {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
  min-width: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.875rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  box-shadow: var(--shadow-sm);
}

.kpi-card-accent {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  border-top: 3px solid var(--accent);
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.055em;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.825rem;
  line-height: 1.15;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--text);
}

.kpi-sub {
  font-size: 0.84375rem;
  color: var(--text-muted);
}

.fit-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.9375rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: var(--shadow-sm);
}

.status-ok,
.status-warn {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.status-ok {
  color: var(--ok-text);
  background: var(--ok-bg);
}

.status-warn {
  color: var(--warn-text);
  background: var(--warn-bg);
}

.calc-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.action-feedback {
  font-size: 0.875rem;
  color: var(--ok-text);
  font-weight: 600;
}

.chart-card,
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
}

.chart-card h3,
.table-card h3 {
  margin: 0 0 0.875rem 0;
  font-size: 1.03125rem;
}

.chart-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.875rem;
}

.chart-header h3 {
  margin: 0;
}

.chart-legend {
  font-size: 0.8125rem;
  color: var(--text-soft);
}

.chart-frame {
  width: 100%;
  aspect-ratio: 640 / 240;
  min-height: 185px;
}

.cost-chart-svg {
  width: 100%;
  height: 100%;
}

.svg-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.svg-bar {
  fill: var(--chart-bar);
  transition: fill 120ms ease;
  cursor: pointer;
}

.svg-bar:hover {
  fill: var(--chart-bar-hover);
}

.svg-line {
  stroke: var(--chart-line);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.svg-axis-label {
  fill: var(--text-soft);
  font-size: 11px;
  font-family: var(--font-mono);
}

/* Tables */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-subtle);
  white-space: nowrap;
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background-color 120ms ease;
}

.data-table tbody tr:hover {
  background: var(--surface-subtle);
}

.comparison-table tbody tr[data-model-id] {
  cursor: pointer;
}

.data-table tr.is-selected-model {
  background: var(--accent-bg);
}

.data-table tr.is-selected-model:hover {
  background: var(--accent-bg);
}

.inline-flag {
  display: inline-flex;
  align-items: center;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  vertical-align: middle;
}

.flag-cheapest {
  color: var(--ok-text);
  background: var(--ok-bg);
}

.flag-selected {
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
}

.comparison-section {
  margin-top: 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  box-shadow: var(--shadow-sm);
}

.comparison-header h2 {
  margin: 0 0 0.4rem 0;
  font-size: 1.25rem;
}

.comparison-sub {
  margin: 0 0 1.125rem 0;
  font-size: 0.875rem;
  color: var(--text-soft);
}

.tool-support-bar {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.tool-support-bar a {
  font-weight: 600;
}

/* Cards & Editorial Grids */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0 2.5rem 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card h3 {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.3;
}

.card-kicker {
  font-size: 0.78125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.96875rem;
  line-height: 1.6;
}

.card-link {
  margin-top: auto;
  padding-top: 0.65rem;
  font-weight: 600;
  font-size: 0.9375rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 36px;
}

.card-link::after {
  content: "\2192";
  transition: transform 150ms ease;
}

.card:hover .card-link::after {
  transform: translateX(3px);
}

/* Framework Picker */
.picker-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  gap: 1.75rem;
  align-items: start;
  margin: 1.5rem 0 2.5rem 0;
}

.picker-questions {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.375rem;
  box-shadow: var(--shadow-sm);
}

.question-card fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.question-card legend {
  font-weight: 700;
  font-size: 1.03125rem;
  margin-bottom: 0.75rem;
  line-height: 1.35;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 46px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.option-label:hover {
  background: var(--surface-subtle);
  border-color: var(--border-strong);
}

.option-label:has(input:checked) {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.option-label input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.picker-result-box {
  background: var(--surface);
  border: 1px solid var(--accent-border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.375rem;
  position: sticky;
  top: calc(var(--header-height) + 1.25rem);
  box-shadow: var(--shadow-md);
}

.picker-result-box h2 {
  margin: 0.25rem 0 0.45rem 0;
  font-size: 1.4rem;
}

/* FAQ */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin: 1.25rem 0 2.5rem 0;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 150ms ease;
}

.faq-item:hover {
  border-color: var(--border-strong);
}

.faq-item summary {
  font-weight: 700;
  cursor: pointer;
  min-height: 52px;
  padding: 0.65rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  list-style: none;
  user-select: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-soft);
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: "-";
  color: var(--accent);
}

.faq-item p {
  margin: 0 0 1rem 0;
  padding-top: 0.25rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* Contact Form & Alerts */
.alert {
  padding: 0.95rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
  font-weight: 500;
}

.alert-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-text);
}

.alert-err {
  background: var(--err-bg);
  color: var(--err-text);
  border-color: var(--err-text);
}

.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* AdSense Readiness Slot (only rendered when ADS_ENABLED=true) */
.ad-slot {
  margin: 2.25rem 0;
  min-height: 250px;
  padding: 0.875rem 1rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.ad-slot-label {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-bottom: 0.5rem;
}

/* Footer */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 3rem 0 2.25rem 0;
  font-size: 0.9375rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, 1fr);
  gap: 2.25rem;
  margin-bottom: 2.25rem;
}

.footer-col h2 {
  margin: 0 0 0.85rem 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-col li {
  margin-bottom: 0.4rem;
}

.footer-col a {
  display: inline-block;
  padding: 0.15rem 0;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-tagline,
.footer-note {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0.55rem 0 0 0;
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.35rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--text-soft);
}

.footer-bottom p {
  margin: 0;
}

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .calc-grid,
  .picker-grid {
    grid-template-columns: 1fr;
  }

  .mobile-kpi-strip {
    display: grid;
  }

  .picker-result-box {
    position: static;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 840px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .header-cta-wrap {
    display: none;
  }

  .primary-nav {
    display: none;
    order: 3;
    flex-basis: 100%;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    padding: 0.65rem 0 0.85rem 0;
    border-top: 1px solid var(--border);
    max-height: calc(100dvh - var(--header-height));
    overflow-y: auto;
  }

  .primary-nav.is-open {
    display: flex;
  }

  .primary-nav a {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border-bottom: 0;
    border-left: 3px solid transparent;
    border-radius: var(--radius-sm);
  }

  .primary-nav a[aria-current="page"] {
    background: var(--accent-bg);
    border-left-color: var(--accent);
    border-bottom: 0;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 0 1rem;
  }

  .field-row-2,
  .kpi-grid,
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .brand-name {
    font-size: 1rem;
  }

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

/* Page Transition Loader */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  visibility: hidden;
}

.page-loader.is-active {
  pointer-events: auto;
  visibility: visible;
}

.page-loader-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong), var(--accent));
  box-shadow: 0 0 12px var(--focus-ring);
  opacity: 0;
  transition: width 750ms cubic-bezier(0.16, 1, 0.3, 1), opacity 140ms ease;
}

.page-loader.is-active .page-loader-bar {
  width: 84%;
  opacity: 1;
}

.page-loader-scrim {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(246, 248, 251, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 180ms ease 50ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .page-loader-scrim {
    background: rgba(11, 17, 32, 0.66);
  }
}

:root[data-theme="dark"] .page-loader-scrim {
  background: rgba(11, 17, 32, 0.66);
}

.page-loader.is-active .page-loader-scrim {
  opacity: 1;
}

.page-loader-card {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.9rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  transform: translateY(6px) scale(0.97);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1) 50ms;
}

.page-loader.is-active .page-loader-card {
  transform: translateY(0) scale(1);
}

.page-loader-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 4px;
  height: 22px;
}

.page-loader-bars span {
  display: block;
  width: 5px;
  border-radius: 2px;
  background: var(--accent);
  transform-origin: bottom center;
  animation: aaaBarPulse 850ms ease-in-out infinite;
}

.page-loader-bars span:nth-child(1) {
  height: 11px;
  opacity: 0.6;
  animation-delay: 0ms;
}

.page-loader-bars span:nth-child(2) {
  height: 17px;
  animation-delay: 140ms;
}

.page-loader-bars span:nth-child(3) {
  height: 22px;
  background: var(--accent-strong);
  animation-delay: 280ms;
}

.page-loader-text {
  font-family: var(--font-display);
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
}

@keyframes aaaBarPulse {
  0%, 100% {
    transform: scaleY(0.55);
    opacity: 0.5;
  }
  50% {
    transform: scaleY(1);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
    transform: none !important;
    animation: none !important;
  }
}

/* Print Stylesheet */
@media print {
  :root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-subtle: #f8fafc;
    --border: #cbd5e1;
    --border-strong: #94a3b8;
    --text: #000000;
    --text-muted: #334155;
    --text-soft: #475569;
  }

  .site-header,
  .site-footer,
  .page-loader,
  .calc-toolbar,
  .calc-actions-bar,
  .tip-btn,
  .ad-slot,
  .breadcrumbs {
    display: none !important;
  }

  body {
    padding-top: 0;
    background: #ffffff;
    color: #000000;
    font-size: 11pt;
  }

  .calc-grid {
    grid-template-columns: 1fr;
  }

  .kpi-card,
  .chart-card,
  .table-card,
  .comparison-section,
  .calc-inputs-panel {
    border: 1px solid #999999;
    box-shadow: none;
    break-inside: avoid;
  }
}
