:root {
  --bg: #0b1020;
  --text: #e9ecf1;
  --muted: #b6bfd2;
  --accent: #7aa2ff;
  --bad: #ff7a7a;
  --ok: #7affc7;
  --warn: #ffb347;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --surface-1: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.02);
  --table-head-bg: rgba(15, 23, 50, 0.92);
  --table-head-text: #f8fafc;
  --table-head-border: rgba(255, 255, 255, 0.18);
  --table-row-hover: rgba(122, 162, 255, 0.06);
  --table-row-border: rgba(255, 255, 255, 0.08);
  --cfa-canvas-bg: rgba(0, 0, 0, 0.2);
  --tab-bg-active: #1f2937;
  --tab-bg-inactive: #374151;
  --tab-text-active: #e5e7eb;
  --tab-text-inactive: #9ca3af;
  --tab-border: #4b5563;
  --plot-bg: rgba(15, 23, 42, 0.45);
  --plot-border: rgba(255, 255, 255, 0.08);
  --plot-grid: rgba(255, 255, 255, 0.08);
  --plot-grid-strong: rgba(148, 163, 184, 0.6);
  --plot-tick: #94a3b8;
  --plot-axis-x: #ffb347;
  --plot-axis-y: #7aa2ff;
  --plot-point: #94a3b8;
  --plot-point-outline: rgba(15, 23, 42, 0.6);
  --plot-hull-a-fill: rgba(255, 179, 71, 0.18);
  --plot-hull-a-stroke: #ffb347;
  --plot-hull-b-fill: rgba(122, 162, 255, 0.18);
  --plot-hull-b-stroke: #7aa2ff;
  --plot-arrow-a: #ffb347;
  --plot-arrow-b: #7aa2ff;
  --frame-toggle-width: 52px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
    Arial, "Apple Color Emoji", "Segoe UI Emoji";

  /* Resizable layout defaults */
  --topH: 520px; /* height of top region */
  --leftW: 56%; /* width of left top card */
  --minTopH: 300px;
  --maxTopH: 720px;
  --minLeftW: 34%;
  --maxLeftW: 72%;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: radial-gradient(
      1200px 800px at 20% 10%,
      rgba(122, 162, 255, 0.2),
      transparent 60%
    ),
    radial-gradient(
      1000px 700px at 80% 0%,
      rgba(122, 255, 199, 0.12),
      transparent 60%
    ),
    var(--bg);
  min-height: 100vh;
}
body.light-mode {
  --bg: #f5f6fb;
  --text: #111827;
  --muted: #374151;
  --accent: #2563eb;
  --bad: #dc2626;
  --ok: #16a34a;
  --warn: #b45309;
  --border: rgba(15, 23, 42, 0.14);
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --surface-1: rgba(255, 255, 255, 0.9);
  --surface-2: rgba(244, 246, 255, 0.75);
  --table-head-bg: #d3dbe8;
  --table-head-text: #111827;
  --table-head-border: rgba(15, 23, 42, 0.14);
  --table-row-hover: rgba(37, 99, 235, 0.08);
  --table-row-border: rgba(15, 23, 42, 0.08);
  --cfa-canvas-bg: rgba(15, 23, 42, 0.05);
  --tab-bg-active: #111827;
  --tab-bg-inactive: #e5e7eb;
  --tab-text-active: #f8fafc;
  --tab-text-inactive: #111827;
  --tab-border: rgba(15, 23, 42, 0.18);
  --plot-bg: rgba(15, 23, 42, 0.06);
  --plot-border: rgba(15, 23, 42, 0.18);
  --plot-grid: rgba(15, 23, 42, 0.08);
  --plot-grid-strong: rgba(15, 23, 42, 0.22);
  --plot-tick: #475569;
  --plot-axis-x: #b45309;
  --plot-axis-y: #1d4ed8;
  --plot-point: #64748b;
  --plot-point-outline: rgba(15, 23, 42, 0.5);
  --plot-hull-a-fill: rgba(245, 158, 11, 0.18);
  --plot-hull-a-stroke: #b45309;
  --plot-hull-b-fill: rgba(37, 99, 235, 0.18);
  --plot-hull-b-stroke: #1d4ed8;
  --plot-arrow-a: #b45309;
  --plot-arrow-b: #1d4ed8;
  background: radial-gradient(
      1200px 800px at 20% 10%,
      rgba(37, 99, 235, 0.12),
      transparent 60%
    ),
    radial-gradient(
      1000px 700px at 80% 0%,
      rgba(16, 185, 129, 0.12),
      transparent 60%
    ),
    var(--bg);
}
body.about-open {
  overflow: hidden;
}

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

/* Visual indicator for terms with tooltips */
.tooltip-term {
  border-bottom: 1px dotted rgba(122, 162, 255, 0.5);
  cursor: help;
  position: relative;
}

.tooltip-term:hover {
  border-bottom-color: rgba(122, 162, 255, 0.8);
}

/* JavaScript-based smart tooltips that escape overflow */
.smart-tooltip {
  position: fixed;
  left: -9999px !important;
  top: -9999px !important;
  padding: 10px 14px;
  background-color: rgba(15, 23, 42, 0.98);
  color: rgba(233, 236, 241, 1);
  border: 1px solid rgba(122, 162, 255, 0.3);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  max-width: 320px;
  pointer-events: none;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  text-align: left;
  opacity: 1;
  transition: opacity 0.18s ease;
}
body.light-mode .smart-tooltip {
  background-color: rgba(255, 255, 255, 0.98);
  color: #111827;
  border-color: rgba(37, 99, 235, 0.2);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.16);
}

.smart-tooltip.positioned {
  animation: tooltipFadeIn 0.5s ease;
  left: var(--tooltip-left) !important;
  top: var(--tooltip-top) !important;
}

.smart-tooltip.is-hiding {
  opacity: 0;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Layout container: keep consistent left/right margins for ALL panels */
header,
.wrap,
.footer {
  /* full-width page, but content is centered and constrained */
  width: 100%;
  max-width: 1200px;
  min-width: 500px;
  margin: 0 auto;
}
.footer a {
  color: var(--accent);
  text-decoration: none;
}
header {
  padding: 28px 18px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.nav-stack {
  position: relative;
}
.nav-stack summary {
  list-style: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(122, 162, 255, 0.14);
  color: #e9ecf1;
  border: 1px solid rgba(122, 162, 255, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.nav-stack summary::-webkit-details-marker {
  display: none;
}
.nav-stack summary::before {
  content: "";
  width: 16px;
  height: 2px;
  background: rgba(233, 236, 241, 0.95);
  box-shadow:
    0 -5px 0 rgba(233, 236, 241, 0.9),
    0 5px 0 rgba(233, 236, 241, 0.9);
}
.nav-stack summary:focus-visible {
  outline: 2px solid rgba(122, 162, 255, 0.7);
  outline-offset: 2px;
}
.nav-stack[open] summary {
  background: rgba(122, 162, 255, 0.24);
  border-color: rgba(122, 162, 255, 0.7);
}
.nav-stack-menu {
  position: absolute;
  top: 42px;
  left: 0;
  background: rgba(17, 24, 39, 0.98);
  border: 1px solid rgba(122, 162, 255, 0.25);
  border-radius: 12px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  z-index: 30;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}
.nav-stack[open] .nav-stack-menu {
  display: flex;
}
.nav-stack-menu a {
  color: #e9ecf1;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  letter-spacing: 0.3px;
}
.nav-stack-menu a:hover {
  background: rgba(122, 162, 255, 0.16);
}
.nav-stack-menu a:focus-visible {
  outline: 2px solid rgba(122, 162, 255, 0.7);
  outline-offset: 2px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.about-btn,
.theme-toggle {
  background: rgba(122, 162, 255, 0.14);
  color: #e9ecf1;
  border: 1px solid rgba(122, 162, 255, 0.35);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.about-btn.icon-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.about-btn.icon-btn i {
  font-size: 13px;
}
.buy-now-btn {
  background: rgba(255, 179, 71, 0.2);
  border-color: rgba(255, 179, 71, 0.45);
  color: #fff2e1;
}
.buy-now-btn:hover {
  background: rgba(255, 179, 71, 0.28);
  border-color: rgba(255, 179, 71, 0.7);
}
body.light-mode .buy-now-btn {
  background: rgba(180, 83, 9, 0.12);
  border-color: rgba(180, 83, 9, 0.35);
  color: #7c2d12;
}
body.light-mode .buy-now-btn:hover {
  background: rgba(180, 83, 9, 0.18);
  border-color: rgba(180, 83, 9, 0.6);
}
.about-btn:hover,
.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
body.light-mode .about-btn,
body.light-mode .theme-toggle {
  background: rgba(37, 99, 235, 0.08);
  color: #111827;
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
body.light-mode .about-btn:hover,
body.light-mode .theme-toggle:hover {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}
body.light-mode .nav-stack summary {
  background: rgba(37, 99, 235, 0.08);
  color: #111827;
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
body.light-mode .nav-stack summary::before {
  background: rgba(17, 24, 39, 0.9);
  box-shadow:
    0 -5px 0 rgba(17, 24, 39, 0.75),
    0 5px 0 rgba(17, 24, 39, 0.75);
}
body.light-mode .nav-stack[open] summary {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(37, 99, 235, 0.5);
}
body.light-mode .nav-stack-menu {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(37, 99, 235, 0.2);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}
body.light-mode .nav-stack-menu a {
  color: #1f2937;
}
body.light-mode .nav-stack-menu a:hover {
  background: rgba(37, 99, 235, 0.12);
}

.about-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 24, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2000;
}
.light-mode .about-backdrop {
  background: rgba(15, 23, 42, 0.18);
}
.about-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.about-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 90vw);
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(8, 12, 24, 0.98));
  border-left: 1px solid rgba(122, 162, 255, 0.25);
  box-shadow: -12px 0 36px rgba(0, 0, 0, 0.45);
  padding: 24px 22px;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 2100;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.light-mode .about-panel {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.98),
    rgba(244, 246, 255, 0.98)
  );
  border-left-color: rgba(37, 99, 235, 0.18);
  box-shadow: -12px 0 36px rgba(15, 23, 42, 0.12);
}
.about-panel.open {
  transform: translateX(0);
}
.about-panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.3px;
}
.about-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.about-title-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted rgba(122, 162, 255, 0.6);
  padding-bottom: 2px;
}
.about-title-link:hover {
  color: #93c5fd;
}
.about-panel .close-btn {
  align-self: flex-end;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #e9ecf1;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.light-mode .about-panel .close-btn {
  border-color: rgba(15, 23, 42, 0.2);
  color: #111827;
}
.light-mode .about-title-link {
  color: #1d4ed8;
  border-bottom-color: rgba(29, 78, 216, 0.5);
}
.about-panel .about-text {
  color: #cfd6e8;
  font-size: 13px;
  line-height: 1.6;
}
.light-mode .about-panel .about-text,
.light-mode .about-panel ul {
  color: #374151;
}
.about-panel ul {
  padding-left: 18px;
  margin: 8px 0;
  color: #cfd6e8;
  font-size: 13px;
  line-height: 1.6;
}
.references-cite a {
  color: var(--accent);
  text-decoration: none;
}
.references-cite a:hover {
  text-decoration: underline;
}
.references-content {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(122, 162, 255, 0.2);
  color: #cfd6e8;
  font-size: 13px;
  line-height: 1.6;
}
.light-mode .references-content {
  color: #374151;
  border-top-color: rgba(37, 99, 235, 0.18);
}
.references-content h1 {
  margin: 16px 0 6px;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: #f8fafc;
}
.light-mode .references-content h1 {
  color: #111827;
}
.references-content p,
.references-content .MsoNormal {
  margin: 0 0 8px;
}
.references-content hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin: 12px 0;
}
.light-mode .references-content hr {
  border-top-color: rgba(15, 23, 42, 0.12);
}
.references-content a {
  color: var(--accent);
  text-decoration: none;
}
.references-content a:hover {
  text-decoration: underline;
}
.references-content .WordSection1 {
  margin: 0;
}

.account-panel {
  gap: 14px;
}

.auth-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
}
.auth-status.is-error {
  color: var(--bad);
}
.auth-status.is-success {
  color: var(--ok);
}
.auth-status.is-warning {
  color: var(--warn);
}
.purchase-status {
  min-height: 18px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.purchase-status.is-error {
  color: var(--bad);
}
.purchase-status.is-success {
  color: var(--ok);
}
.purchase-status.is-warning {
  color: var(--warn);
}
.purchase-license {
  margin-top: 6px;
  color: var(--muted);
}
.purchase-license code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}
.purchase-wrap {
  max-width: 1100px;
  margin: 0 auto;
}
.purchase-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .purchase-grid {
    grid-template-columns: 1fr;
  }
}
.purchase-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.purchase-addon {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
}
.purchase-addon input {
  margin: 0;
}
.purchase-note {
  color: var(--muted);
  line-height: 1.4;
}
.purchase-summary {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
body.light-mode .purchase-summary {
  background: #ffffff;
}
.purchase-summary-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.purchase-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text);
}
.purchase-summary-note {
  color: var(--muted);
  line-height: 1.4;
}

.auth-tabs {
  display: flex;
  gap: 8px;
}
.auth-tab {
  background: rgba(122, 162, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(122, 162, 255, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.auth-tab.is-active {
  background: rgba(122, 162, 255, 0.24);
  border-color: rgba(122, 162, 255, 0.45);
  font-weight: 600;
}
body.light-mode .auth-tab {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  color: #111827;
}
body.light-mode .auth-tab.is-active {
  background: rgba(37, 99, 235, 0.18);
  border-color: rgba(37, 99, 235, 0.45);
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 12px;
}
.auth-form.is-active {
  display: flex;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.auth-field input,
.auth-field select,
.auth-field textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  font-size: 13px;
  font-family: var(--sans);
}
.auth-field textarea {
  resize: vertical;
  min-height: 48px;
}
.auth-field input.tooltip-term-input {
  border-bottom: 1px dotted rgba(122, 162, 255, 0.6);
}
body.light-mode .auth-field input.tooltip-term-input {
  border-bottom-color: rgba(37, 99, 235, 0.5);
}
body.light-mode .auth-field input,
body.light-mode .auth-field select,
body.light-mode .auth-field textarea {
  background: #ffffff;
  color: #111827;
  border-color: rgba(15, 23, 42, 0.18);
}

.auth-profile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
}
.auth-profile-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text);
}
.auth-label {
  color: var(--muted);
}
.auth-profile.hidden {
  display: none;
}

.auth-license {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.auth-license.hidden {
  display: none;
}
.auth-license-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.auth-license-summary {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}
.auth-license-summary code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}
body.light-mode .auth-license-summary code {
  background: rgba(15, 23, 42, 0.08);
}
.auth-license-claim,
.auth-license-admin,
.auth-license-request {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.auth-license-key {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.auth-seat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
}
body.light-mode .auth-seat-row {
  background: rgba(15, 23, 42, 0.05);
}
.auth-license-seats {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.auth-subscription-addons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0;
}
.auth-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn.small {
  padding: 6px 10px;
  font-size: 11px;
}

.auth-verify {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 6px;
}
.auth-verify-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}
.auth-verify-btn {
  border-color: rgba(255, 179, 71, 0.7);
  background: rgba(255, 179, 71, 0.14);
  color: #ffe9c7;
  box-shadow: 0 0 0 1px rgba(255, 179, 71, 0.25);
}
.auth-verify-btn:hover {
  border-color: rgba(255, 179, 71, 0.95);
  background: rgba(255, 179, 71, 0.22);
}
body.light-mode .auth-verify-btn {
  border-color: rgba(180, 83, 9, 0.6);
  background: rgba(180, 83, 9, 0.12);
  color: #7c2d12;
  box-shadow: 0 0 0 1px rgba(180, 83, 9, 0.18);
}
body.light-mode .auth-verify-btn:hover {
  border-color: rgba(180, 83, 9, 0.85);
  background: rgba(180, 83, 9, 0.18);
}
.auth-verify-link {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
}
.auth-verify-link:hover {
  text-decoration: underline;
}

.pulse-highlight {
  position: relative;
  border-radius: 8px;
  animation: pulseHighlight 0.85s ease-in-out 0s 2;
  box-shadow: 0 0 0 0 rgba(122, 162, 255, 0.55);
}

@keyframes pulseHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(122, 162, 255, 0.55);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(122, 162, 255, 0.12);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(122, 162, 255, 0.0);
  }
}

.gate-wrap {
  display: inline-flex;
  align-items: center;
}
.is-gated {
  opacity: 0.7;
  cursor: not-allowed;
}
p.sub {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
  max-width: 92ch;
}

.wrap {
  /* internal gutter + vertical spacing between panels */
  padding: 14px 18px 34px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (max-width: 980px) {
  header,
  .wrap,
  .footer {
    max-width: 100%;
  }
}

/* TOP: 2 cards + vertical handle */

/* Remove previous resizable top region; frames are stacked vertically */
.topRegion {
  display: none;
}

/* Vertical resize handle */
/* hide legacy resize handles (no longer used) */
.vHandle {
  cursor: col-resize;
  position: relative;
  display: none;
}
.vHandle:after {
  display: none;
}

/* Horizontal resize handle */
.hHandle {
  display: none;
}
.hHandle:after {
  display: none;
}

.card {
  background: linear-gradient(
    180deg,
    var(--surface-1),
    var(--surface-2)
  );
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Frame-specific styles: collapsed vs expanded */
.frame .hd {
  cursor: default;
  position: relative;
  padding-left: calc(16px + var(--frame-toggle-width));
}
.frame .frame-toggle {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--frame-toggle-width);
  border: none;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.frame .frame-toggle::before {
  content: "";
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid rgba(233, 236, 241, 0.7);
  transform: translateX(1px) rotate(0deg);
  transition: transform 0.2s ease, border-left-color 0.2s ease;
}
.frame:not(.collapsed) .frame-toggle::before {
  transform: translateX(1px) rotate(90deg);
  border-left-color: rgba(233, 236, 241, 0.95);
}
.frame .frame-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}
.frame .frame-toggle:focus-visible {
  outline: 2px solid rgba(122, 162, 255, 0.6);
  outline-offset: -2px;
}
.light-mode .frame .frame-toggle {
  background: rgba(15, 23, 42, 0.04);
}
.light-mode .frame .frame-toggle::before {
  border-left-color: rgba(17, 24, 39, 0.65);
}
.light-mode .frame:not(.collapsed) .frame-toggle::before {
  border-left-color: rgba(17, 24, 39, 0.95);
}
.frame .bd {
  display: block;
  max-height: none;
  overflow: visible;
}
.frame.collapsed .bd {
  display: none;
}
.frame.collapsed {
  opacity: 0.98;
}
.frame.disabled {
  opacity: 0.6;
  filter: grayscale(10%);
}
.frame.disabled .hd {
  cursor: default;
}
.frame.disabled .frame-toggle {
  cursor: not-allowed;
  opacity: 0.6;
}
.frame.disabled .bd {
  display: none;
}
/* Use flex gap for spacing; avoid stacking margins fighting with gap */
.frame + .frame {
  margin-top: 0;
}
.card .hd {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.card.frame .hd {
  padding-left: calc(16px + var(--frame-toggle-width));
}
body.light-mode .card .hd {
  background: rgba(15, 23, 42, 0.03);
}
.card .hd .title {
  font-weight: 650;
  font-size: 14px;
  letter-spacing: 0.3px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-video-btn {
  width: 18px;
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.85;
}
.panel-video-btn img {
  width: 16px;
  height: 16px;
  display: block;
}
.panel-video-btn:hover {
  opacity: 1;
}
.panel-video-btn:focus-visible {
  outline: 2px solid rgba(122, 162, 255, 0.7);
  outline-offset: 2px;
  border-radius: 4px;
}
.panel-video-menu {
  position: fixed;
  z-index: 5000;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(122, 162, 255, 0.35);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  padding: 10px;
  color: #e5e7eb;
  min-width: 220px;
}
.panel-video-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel-video-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.35);
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}
.panel-video-item:hover {
  border-color: rgba(122, 162, 255, 0.45);
  background: rgba(30, 58, 138, 0.25);
}
.panel-video-item.is-disabled {
  opacity: 0.6;
  cursor: default;
}
.panel-video-item.is-disabled:hover {
  border-color: transparent;
  background: rgba(15, 23, 42, 0.35);
}
body.light-mode .panel-video-menu {
  background: #ffffff;
  color: #111827;
  border-color: rgba(15, 23, 42, 0.15);
}
body.light-mode .panel-video-item {
  background: rgba(15, 23, 42, 0.04);
}
body.light-mode .panel-video-item:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.25);
}
body.light-mode .panel-video-item.is-disabled:hover {
  background: rgba(15, 23, 42, 0.04);
  border-color: transparent;
}
.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
}
.light-mode .pill {
  background: rgba(15, 23, 42, 0.04);
}
.runtime-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  border: 1px solid var(--runtime-color, rgba(122, 162, 255, 0.45));
  color: #ffffff;
  background: var(--runtime-bg, rgba(122, 162, 255, 0.15));
}
.runtime-pill.tooltip-term {
  border-bottom: none;
}
.runtime-pill .runtime-label {
  color: #ffffff;
  font-weight: 600;
}
.runtime-pill .runtime-value {
  color: #ffffff;
}
body.light-mode .runtime-pill {
  background: var(--runtime-bg-light, rgba(122, 162, 255, 0.12));
}
body.light-mode .runtime-pill .runtime-label {
  color: #ffffff;
}
body.light-mode .runtime-pill .runtime-value {
  color: #ffffff;
}
.runtime-pill[data-runtime="few-seconds"],
.runtime-pill[data-runtime="very-short"] {
  --runtime-color: #1e3a8a;
  --runtime-bg: rgba(30, 58, 138, 0.22);
  --runtime-bg-light: rgba(30, 58, 138, 0.12);
}
.runtime-pill[data-runtime="lt-minute"],
.runtime-pill[data-runtime="short"],
.runtime-pill[data-runtime="moderate"] {
  --runtime-color: #1d4ed8;
  --runtime-bg: rgba(29, 78, 216, 0.2);
  --runtime-bg-light: rgba(29, 78, 216, 0.12);
}
.runtime-pill[data-runtime="few-minutes"],
.runtime-pill[data-runtime="moderately-long"] {
  --runtime-color: #f59e0b;
  --runtime-bg: rgba(245, 158, 11, 0.2);
  --runtime-bg-light: rgba(245, 158, 11, 0.12);
}
.runtime-pill[data-runtime="several-minutes"],
.runtime-pill[data-runtime="long"],
.runtime-pill[data-runtime="very-long"],
.runtime-pill[data-runtime="go-walk"] {
  --runtime-color: #f97316;
  --runtime-bg: rgba(249, 115, 22, 0.2);
  --runtime-bg-light: rgba(249, 115, 22, 0.12);
}
.card .bd {
  padding: 16px;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
body.light-mode select,
body.light-mode input[type="number"],
body.light-mode input[type="text"],
body.light-mode input[type="search"] {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: var(--table-row-border) !important;
}
body.light-mode select option {
  background: #ffffff;
  color: #111827;
}

select {
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  border: 1px solid var(--border);
}

select option {
  background: #0f1724;
  color: var(--text);
}
input[type="file"] {
  display: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(122, 162, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: transform 0.06s ease, background 0.2s ease, border-color 0.2s ease;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}
.btn:hover {
  background: rgba(122, 162, 255, 0.18);
  border-color: rgba(122, 162, 255, 0.35);
}
.btn:active {
  transform: translateY(1px);
}
.btn.secondary {
  background: rgba(255, 255, 255, 0.06);
}
.btn.danger {
  background: rgba(255, 122, 122, 0.12);
}

.struct-type-filter {
  font-size: 10px;
  padding: 3px 6px;
  background: var(--tab-bg-inactive);
  color: var(--tab-text-inactive);
  border-color: var(--tab-border);
}

.struct-type-filter.is-active {
  background: var(--tab-bg-active);
  color: var(--tab-text-active);
  border-color: var(--tab-border);
}

.struct-dummy-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 3050;
  background: rgba(8, 12, 24, 0.58);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.struct-dummy-dialog {
  width: min(920px, 96vw);
  max-height: min(86vh, 780px);
  overflow: auto;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(122, 162, 255, 0.35);
  border-radius: 14px;
  box-shadow: 0 24px 54px rgba(0, 0, 0, 0.45);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #e5e7eb;
}

.struct-dummy-title {
  font-size: 14px;
  font-weight: 700;
}

.struct-dummy-subtitle,
.struct-dummy-helper {
  font-size: 12px;
  color: #b6bfd2;
}

.struct-dummy-helper {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 10px;
  padding: 7px 9px;
}

.struct-dummy-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.struct-dummy-sort {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0.35px;
  text-transform: uppercase;
  padding: 0;
  cursor: pointer;
}

.struct-dummy-sort:hover {
  color: #e2e8f0;
}

.struct-dummy-sort.is-active {
  color: #e2e8f0;
  border-bottom-color: rgba(122, 162, 255, 0.65);
}

.struct-dummy-table {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.struct-dummy-row {
  display: grid;
  grid-template-columns: 72px 80px minmax(180px, 1fr) 60px minmax(180px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.58);
}

.struct-dummy-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  color: #94a3b8;
  border-style: dashed;
  background: rgba(15, 23, 42, 0.38);
}

.struct-dummy-row.is-reference {
  border-color: rgba(122, 162, 255, 0.45);
  background: rgba(37, 99, 235, 0.12);
}

.struct-dummy-row.is-underrepresented {
  border-color: rgba(249, 115, 22, 0.5);
  background: rgba(249, 115, 22, 0.12);
}

.struct-dummy-cell {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
}

.struct-dummy-category {
  font-size: 12px;
  color: #e5e7eb;
  overflow-wrap: anywhere;
}

.struct-dummy-count {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 700;
  color: #e5e7eb;
}

.struct-dummy-name {
  width: 100%;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.62);
  color: #e5e7eb;
  padding: 6px 8px;
  font-size: 12px;
}

.struct-dummy-feedback {
  min-height: 18px;
  font-size: 12px;
  color: #9ca3af;
}

.struct-dummy-feedback.is-error {
  color: #fb923c;
}

.struct-dummy-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

body.light-mode .struct-dummy-dialog-overlay {
  background: rgba(15, 23, 42, 0.22);
}

body.light-mode .struct-dummy-dialog {
  background: rgba(255, 255, 255, 0.98);
  color: #111827;
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 20px 46px rgba(15, 23, 42, 0.18);
}

body.light-mode .struct-dummy-subtitle,
body.light-mode .struct-dummy-helper {
  color: #475569;
}

body.light-mode .struct-dummy-helper {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.2);
}

body.light-mode .struct-dummy-sort:hover,
body.light-mode .struct-dummy-sort.is-active {
  color: #0f172a;
}

body.light-mode .struct-dummy-sort.is-active {
  border-bottom-color: rgba(37, 99, 235, 0.55);
}

body.light-mode .struct-dummy-row {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.12);
}

body.light-mode .struct-dummy-header {
  color: #64748b;
  background: rgba(15, 23, 42, 0.02);
}

body.light-mode .struct-dummy-row.is-reference {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.28);
}

body.light-mode .struct-dummy-row.is-underrepresented {
  background: rgba(249, 115, 22, 0.14);
  border-color: rgba(194, 65, 12, 0.38);
}

body.light-mode .struct-dummy-category,
body.light-mode .struct-dummy-count {
  color: #111827;
}

body.light-mode .struct-dummy-name {
  background: #ffffff;
  color: #111827;
  border-color: rgba(15, 23, 42, 0.16);
}

@media (max-width: 760px) {
  .struct-dummy-row {
    grid-template-columns: 52px 62px minmax(130px, 1fr) 48px minmax(120px, 1fr);
    gap: 6px;
    padding: 7px;
  }
  .struct-dummy-dialog {
    padding: 10px;
  }
}

#efaGenerateBtn,
#cfaRunBtn {
  background: rgba(122, 162, 255, 0.26);
  border-color: rgba(122, 162, 255, 0.65);
  font-weight: 700;
  letter-spacing: 0.2px;
}
#efaGenerateBtn:hover,
#cfaRunBtn:hover {
  background: rgba(122, 162, 255, 0.34);
  border-color: rgba(122, 162, 255, 0.8);
}

@keyframes cfa-run-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(122, 162, 255, 0);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(122, 162, 255, 0.45);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(122, 162, 255, 0);
  }
}

#cfaRunBtn.cfa-run-flash {
  animation: cfa-run-flash 0.35s ease-in-out 2;
}

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.kv .box {
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.kv .k {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  margin-bottom: 6px;
}

.cfa-resize-handle {
  width: 8px;
  cursor: col-resize;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cfa-var-grid {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    minmax(min(100%, var(--cfa-var-tile-width, 120px)), var(--cfa-var-tile-width, 120px))
  );
  gap: 6px;
  justify-content: start;
  user-select: none;
}

.cfa-var-tile {
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #cfd6e8;
  font-size: 11px;
  text-align: center;
  cursor: grab;
  white-space: nowrap;
  overflow: hidden;
}
body.light-mode .cfa-var-tile {
  border-color: rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.04);
  color: #1f2937;
}

.cfa-var-tile.selected {
  background: rgba(122, 180, 255, 0.65);
  color: #fff;
}
body.light-mode .cfa-var-tile.selected {
  background: rgba(37, 99, 235, 0.18);
  color: #1d4ed8;
}

.cfa-var-tile.used {
  background: rgba(122, 180, 255, 0.25);
  color: #7ab4ff;
  pointer-events: none;
  opacity: 0.5;
  cursor: not-allowed;
}
body.light-mode .cfa-var-tile.used {
  background: rgba(37, 99, 235, 0.08);
  color: #6b7280;
}

.ac-layout {
  display: flex;
  align-items: stretch;
  min-height: 460px;
  gap: 8px;
}

.ac-setup {
  flex: 0 0 360px;
  min-width: 260px;
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ac-setup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#acTukeyWrap label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#acTukeyWrap input[type="checkbox"] {
  margin: 0;
}

.ac-setup-row select {
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: rgba(15, 23, 36, 0.8);
  color: #e5e7eb;
  min-width: 170px;
}

body.light-mode .ac-setup-row select {
  background: #ffffff;
  color: #111827;
  border-color: #cbd5e1;
}

.ac-var-grid-wrap {
  border: 1px solid #334155;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.22);
  padding: 8px;
  min-height: 220px;
  max-height: 360px;
}

body.light-mode .ac-var-grid-wrap {
  border-color: #cbd5e1;
  background: rgba(15, 23, 42, 0.03);
}

.ac-var-grid-wrap .cfa-var-grid {
  --cfa-var-tile-width: 120px;
}

.ac-var-grid-wrap .cfa-var-tile {
  cursor: pointer;
}

.ac-divider {
  width: 8px;
  min-width: 8px;
  border-radius: 6px;
  cursor: col-resize;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.02)
  );
  border: 1px solid rgba(255, 255, 255, 0.12);
}

body.light-mode .ac-divider {
  background: linear-gradient(
    180deg,
    rgba(15, 23, 42, 0.12),
    rgba(15, 23, 42, 0.04)
  );
  border-color: rgba(15, 23, 42, 0.18);
}

.ac-output {
  flex: 1 1 auto;
  min-width: 280px;
  overflow: auto;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.22);
}

body.light-mode .ac-output {
  border-color: #cbd5e1;
  background: rgba(15, 23, 42, 0.03);
}

.ac-output-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.ac-icon-btn {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ac-icon-btn.is-active {
  border-color: rgba(122, 180, 255, 0.75);
  box-shadow: inset 0 0 0 1px rgba(122, 180, 255, 0.35);
}

.ac-result-card {
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.24);
  margin-bottom: 10px;
}

body.light-mode .ac-result-card {
  border-color: #cbd5e1;
  background: rgba(15, 23, 42, 0.03);
}

.ac-result-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.ac-hist-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #9ca3af;
}

body.light-mode .ac-hist-toggle {
  color: #475569;
}

@media (max-width: 980px) {
  .ac-layout {
    flex-direction: column;
    min-height: 0;
  }
  .ac-setup {
    max-width: 100%;
    min-width: 0;
    flex-basis: auto !important;
  }
  .ac-divider {
    display: none;
  }
}

.cfa-progress {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cfa-progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
}

.cfa-progress-pct {
  font-variant-numeric: tabular-nums;
  color: #cfd6e8;
}

.cfa-progress-bar {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.cfa-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7ab4ff, #9cd2ff);
  transition: width 0.2s ease;
}

.cfa-progress-step.is-complete .cfa-progress-fill {
  background: linear-gradient(90deg, #7ab4ff, #7cffc7);
}

.cfa-progress-step.is-active .cfa-progress-label {
  color: #e2e8f7;
}
body.light-mode .cfa-progress-step.is-active .cfa-progress-label {
  color: #1f2937;
}

.cfa-progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kv .v {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.2px;
  word-break: break-word;
}

.note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.qca-template-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.qca-template-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.qca-template-actions .btn {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}
.qca-template-text {
  flex: 1 1 260px;
  min-width: 220px;
}
body.light-mode .note {
  color: #4b5563;
}
.warn {
  color: var(--bad);
  font-weight: 600;
}
.warn-warm {
  color: #ffb347;
  font-weight: 600;
}
body.light-mode .warn-warm {
  color: #b45309;
}

.scroll {
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.efa-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
}

.efa-progress-bar {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(122, 162, 255, 0.18);
  overflow: hidden;
}

.efa-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(122, 162, 255, 0) 0%,
    rgba(122, 162, 255, 0.6) 50%,
    rgba(122, 255, 199, 0.6) 75%,
    rgba(122, 255, 199, 0) 100%
  );
  animation: efaProgressSlide 1.6s ease-in-out infinite;
}

@keyframes efaProgressSlide {
  0% {
    left: -40%;
  }
  50% {
    left: 60%;
  }
  100% {
    left: 110%;
  }
}

table {
  width: auto;
  border-collapse: collapse;
  font-size: 13px;
  display: block;
  max-width: 100%;
}
th,
td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--table-row-border);
  vertical-align: top;
}
th {
  color: var(--table-head-text);
  font-weight: 650;
  font-size: 12px;
  letter-spacing: 0.25px;
  position: sticky;
  top: 0;
  background: var(--table-head-bg);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--table-head-border);
  z-index: 2;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th .sort {
  margin-left: 6px;
  font-size: 11px;
  opacity: 0.85;
}
th:hover {
  color: var(--table-head-text);
}
tr:hover td {
  background: var(--table-row-hover);
}
body.light-mode th {
  background: var(--table-head-bg) !important;
  color: var(--table-head-text) !important;
}
body.light-mode tr[style*="background: #1f2937"],
body.light-mode tr[style*="background:#1f2937"],
body.light-mode tr[style*="background: #0f172a"],
body.light-mode tr[style*="background:#0f172a"],
body.light-mode tr[style*="background: #111827"],
body.light-mode tr[style*="background:#111827"] {
  background: var(--table-head-bg) !important;
}
body.light-mode [style*="color:#e9ecf1"],
body.light-mode [style*="color: #e9ecf1"] {
  color: #111827 !important;
}
body.light-mode [style*="color: rgb(233, 236, 241)"] {
  color: #111827 !important;
}
body.light-mode [style*="color:#cfd6e8"],
body.light-mode [style*="color: #cfd6e8"] {
  color: #1f2937 !important;
}
body.light-mode [style*="color: rgb(207, 214, 232)"] {
  color: #1f2937 !important;
}
body.light-mode [style*="color:#e5e7eb"],
body.light-mode [style*="color: #e5e7eb"] {
  color: #111827 !important;
}
body.light-mode [style*="color: rgb(229, 231, 235)"] {
  color: #111827 !important;
}
body.light-mode [style*="color:#9ca3af"],
body.light-mode [style*="color: #9ca3af"] {
  color: #374151 !important;
}
body.light-mode [style*="color: rgb(156, 163, 175)"] {
  color: #374151 !important;
}
body.light-mode [style*="color:#b6bfd2"],
body.light-mode [style*="color: #b6bfd2"] {
  color: #374151 !important;
}
body.light-mode [style*="color: rgb(182, 191, 210)"] {
  color: #374151 !important;
}
body.light-mode [style*="color: rgb(182, 191, 210)"] {
  color: #374151 !important;
}
body.light-mode [style*="color:#7ab4ff"],
body.light-mode [style*="color: #7ab4ff"] {
  color: #1d4ed8 !important;
}
body.light-mode [style*="color: rgb(122, 180, 255)"] {
  color: #1d4ed8 !important;
}
body.light-mode [style*="color:#7affc7"],
body.light-mode [style*="color: #7affc7"] {
  color: #15803d !important;
}
body.light-mode [style*="color: rgb(122, 255, 199)"] {
  color: #15803d !important;
}
body.light-mode [style*="color:#ffb347"],
body.light-mode [style*="color: #ffb347"] {
  color: #b45309 !important;
}
body.light-mode [style*="color: rgb(255, 179, 71)"] {
  color: #b45309 !important;
}

.copy-hover-wrap {
  position: relative;
  display: block;
  max-width: 100%;
}

.table-copy-wrap {
  position: relative;
  display: block;
  max-width: 100%;
  width: 100%;
  overflow-x: auto;
  padding-right: 36px;
}

.copy-hover-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 5;
}

.copy-hover-wrap:hover .copy-hover-btn,
.copy-hover-wrap:focus-within .copy-hover-btn {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  .copy-hover-btn {
    opacity: 1;
    pointer-events: auto;
  }
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.2px;
  background: rgba(255, 255, 255, 0.06);
}
.badge.ok {
  border-color: rgba(122, 255, 199, 0.35);
  background: rgba(122, 255, 199, 0.1);
}
.badge.accent {
  border-color: rgba(122, 162, 255, 0.35);
  background: rgba(122, 162, 255, 0.1);
}

.tiny {
  font-size: 12px;
  color: var(--muted);
}
body.light-mode .tiny {
  color: #4b5563;
}

/* EFA variable list styling for better contrast */
#efaVarList {
  background: transparent; /* keep card background */
  color: var(--text);
  border-radius: 8px;
}
/* EFA variable grid layout */
#efaVarListContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  align-content: flex-start;
}
.efa-var-row {
  color: var(--text);
  padding: 8px 12px !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.15s ease;
}
.efa-var-row:hover {
  background: rgba(122, 162, 255, 0.08);
  border-color: rgba(122, 162, 255, 0.2);
}
.efa-var-row.selected {
  background: rgba(122, 162, 255, 0.25) !important;
  border-color: rgba(122, 162, 255, 0.5) !important;
  color: var(--text) !important;
  font-weight: 600;
}
.search {
  flex: 1 1 260px;
  max-width: 420px;
  min-width: 220px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  outline: none;
}
.search:focus {
  border-color: rgba(122, 162, 255, 0.55);
}

.qca-panel .bd {
  gap: 16px;
  max-height: none;
  overflow: visible;
}

.qca-setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.qca-setup-section {
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.qca-section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--text);
}

.qca-run-row {
  margin-left: auto;
}

#qcaRunBtn {
  background: rgba(122, 162, 255, 0.26);
  border-color: rgba(122, 162, 255, 0.65);
  font-weight: 700;
  letter-spacing: 0.2px;
}

#qcaRunBtn:hover {
  background: rgba(122, 162, 255, 0.34);
  border-color: rgba(122, 162, 255, 0.8);
}

.qca-setup-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.qca-setup-tab-btn {
  padding: 6px 10px;
  border: 1px solid var(--tab-border);
  border-radius: 6px;
  background: var(--tab-bg-inactive);
  color: var(--tab-text-inactive);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.qca-setup-tab-btn.is-active {
  background: var(--tab-bg-active);
  color: var(--tab-text-active);
}

.qca-setup-tab-btn.is-ready {
  border-color: var(--ok);
  box-shadow: 0 0 0 1px var(--ok);
}

.qca-setup-tab-btn:focus-visible {
  outline: 2px solid rgba(122, 162, 255, 0.6);
  outline-offset: 2px;
}

.qca-setup-tab-content {
  display: none;
}

.qca-setup-tab-content.is-active {
  display: block;
}

.qca-tab-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.qca-tab-btn {
  padding: 6px 10px;
  border: 1px solid var(--tab-border);
  border-radius: 6px;
  background: var(--tab-bg-inactive);
  color: var(--tab-text-inactive);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.qca-tab-btn.is-active {
  background: var(--tab-bg-active);
  color: var(--tab-text-active);
}

.qca-tab-btn:focus-visible {
  outline: 2px solid rgba(122, 162, 255, 0.6);
  outline-offset: 2px;
}

.qca-tab-content {
  display: none;
}

.qca-tab-content.is-active {
  display: block;
}

.qca-split {
  display: flex;
  align-items: stretch;
  gap: 0;
  --qca-split-left: 62%;
  min-height: 260px;
}

.qca-split-left {
  flex: 0 0 var(--qca-split-left);
  min-width: 260px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qca-split-right {
  flex: 1 1 calc(100% - var(--qca-split-left));
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qca-split-divider {
  width: 8px;
  cursor: col-resize;
  margin: 0 10px;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.08)
  );
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  touch-action: none;
}

.qca-split-divider:hover {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0.06)
  );
}

.qca-results-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qca-output-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qca-output-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.qca-interpretation-panel {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qca-interpretation-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--muted);
}

.qca-interpretation-subtitle {
  font-size: 12px;
  font-weight: 650;
  color: var(--text);
  margin-top: 4px;
}

.qca-interpretation-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qca-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.qca-toggle input {
  accent-color: var(--accent);
}

body.light-mode .qca-setup-section {
  background: rgba(15, 23, 42, 0.04);
}

body.light-mode .qca-interpretation-panel {
  background: rgba(15, 23, 42, 0.03);
}

.qca-roles {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qca-role-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.qca-role-row label {
  min-width: 160px;
  font-size: 12px;
  color: var(--muted);
}

.qca-role-row select {
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  border: 1px solid var(--border);
  min-width: 200px;
}

.qca-conditions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
  max-height: 220px;
  overflow: auto;
}

.qca-condition-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.qca-condition-item.is-disabled {
  opacity: 0.5;
}

.qca-warning-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
}

.qca-selection-summary {
  margin-top: 10px;
}

.qca-results-block {
  margin-top: 12px;
}

.qca-table-interpretation {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.qca-table-purpose {
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.qca-export-row + .qca-export-row {
  margin-top: 14px;
}

.qca-export-row {
  row-gap: 12px;
}

.qca-export-row .btn {
  padding-top: 12px;
  padding-bottom: 12px;
  min-height: 44px;
}

#reportCard .qca-export-row .btn {
  padding-top: 12px;
  padding-bottom: 12px;
  min-height: 46px;
}

.qca-findings-table th,
.qca-findings-table td {
  vertical-align: middle;
}

.qca-findings-divider td {
  border-top: 2px solid rgba(255, 255, 255, 0.25);
}

.qca-findings-summary td {
  font-weight: 600;
}

.qca-findings-legend {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.qca-findings-bullets {
  margin: 10px 0 8px;
  padding-left: 18px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.qca-findings-caveat {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.qca-solutions-split {
  display: flex;
  align-items: stretch;
  gap: 0;
  --qca-sol-left: 60%;
  min-height: 260px;
}

.qca-solutions-left {
  flex: 0 0 var(--qca-sol-left);
  min-width: 260px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qca-solutions-right {
  flex: 1 1 calc(100% - var(--qca-sol-left));
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qca-solutions-divider {
  width: 8px;
  cursor: col-resize;
  margin: 0 10px;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.08)
  );
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.qca-solutions-divider:hover {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0.06)
  );
}

.qca-robust-controls {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qca-robust-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qca-robust-head {
  display: grid;
  grid-template-columns: minmax(160px, 220px) repeat(3, minmax(90px, 120px));
  gap: 8px;
  align-items: end;
  font-size: 11px;
  color: var(--muted);
  padding-bottom: 4px;
}

.qca-robust-row {
  display: grid;
  grid-template-columns: minmax(160px, 220px) repeat(3, minmax(90px, 120px));
  gap: 8px;
  align-items: center;
}

.qca-robust-label {
  font-size: 12px;
  color: var(--muted);
}

.qca-robust-row input[type="number"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
  font-size: 12px;
  width: 100%;
}

@media (max-width: 900px) {
  .qca-split {
    flex-direction: column;
  }
  .qca-split-left,
  .qca-split-right {
    min-width: 100%;
  }
  .qca-split-divider {
    width: 100%;
    height: 8px;
    cursor: row-resize;
    margin: 10px 0;
  }
  .qca-solutions-split {
    flex-direction: column;
  }
  .qca-solutions-left,
  .qca-solutions-right {
    flex: 1 1 auto;
    min-width: 100%;
  }
  .qca-solutions-divider {
    width: 100%;
    height: 8px;
    cursor: row-resize;
    margin: 10px 0;
  }
}

.qca-mode-options {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.qca-mode-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.qca-mode-option input {
  margin-top: 2px;
}

.qca-mode-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
}

.qca-calibration-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.qca-calibration-head {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) repeat(3, minmax(80px, 1fr)) minmax(140px, 1.2fr);
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  padding: 6px 2px 0;
}

.qca-calibration-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.2fr) repeat(3, minmax(80px, 1fr)) minmax(140px, 1.2fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  min-width: 0;
}

.qca-calibration-row .qca-calibration-var {
  font-weight: 650;
}

.qca-calibration-row input[type="number"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.16);
  color: var(--text);
  font-size: 12px;
  width: 100%;
  min-width: 0;
}

.qca-calibration-note {
  color: var(--muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

#qcaCalibrationSection {
  overflow-x: auto;
  overflow-y: visible;
}

#qcaCalibrationSection.is-disabled {
  opacity: 0.6;
  filter: grayscale(15%);
}

.qca-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
}

.qca-info-icon.tooltip-term {
  border-bottom: none;
}

.qca-info-icon:hover {
  color: var(--text);
  border-color: rgba(122, 162, 255, 0.5);
  background: rgba(122, 162, 255, 0.12);
}

body.light-mode .qca-conditions {
  background: rgba(15, 23, 42, 0.04);
}

body.light-mode .qca-condition-item {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.12);
  color: #1f2937;
}

body.light-mode .qca-mode-option,
body.light-mode .qca-calibration-row {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.12);
}

body.light-mode .qca-calibration-row input[type="number"] {
  background: #ffffff;
  color: #111827;
}

.preview-controls {
  flex-wrap: nowrap;
}

.preview-hint {
  margin-bottom: 8px;
  line-height: 1.4;
}

.preview-hint-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.preview-hint-row .preview-hint {
  margin-bottom: 8px;
}

.preview-copy-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 32px;
  margin-bottom: 8px;
}

.table-copy-inline-btn.copy-hover-btn {
  position: static;
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 900px) {
  .preview-controls {
    flex-wrap: wrap;
  }
  .preview-hint-row {
    flex-wrap: wrap;
  }
  .preview-copy-slot {
    width: 100%;
  }
}

.preview-flag-head,
.preview-flag-cell {
  text-align: center;
  width: 36px;
  min-width: 36px;
}

.preview-flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(249, 115, 22, 0.6);
  background: rgba(249, 115, 22, 0.16);
  color: #f97316;
  font-weight: 700;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.preview-flag-btn.pending {
  background: rgba(249, 115, 22, 0.55);
  color: #fff;
}

body.light-mode .preview-flag-btn.pending {
  color: #111827;
}

.preview-col-toolbar {
  position: fixed;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 0;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 10px 24px rgba(2, 6, 23, 0.45);
  backdrop-filter: blur(8px);
}

.preview-col-toolbar.is-visible {
  display: inline-flex;
}

.preview-col-tool-btn {
  width: 38px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  font-size: 18px;
  line-height: 1;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.preview-col-tool-btn + .preview-col-tool-btn {
  border-left: 1px solid rgba(148, 163, 184, 0.25);
}

.preview-col-tool-btn:hover {
  background: rgba(122, 162, 255, 0.2);
  color: #f8fafc;
}

.preview-col-tool-btn:active {
  transform: translateY(1px);
}

.preview-col-tool-btn.is-armed {
  background: rgba(248, 113, 113, 0.24);
  color: #fecaca;
}

.preview-col-tool-btn.is-disabled,
.preview-col-tool-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: transparent;
}

body.light-mode .preview-col-toolbar {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
}

body.light-mode .preview-col-tool-btn {
  color: #334155;
}

body.light-mode .preview-col-tool-btn + .preview-col-tool-btn {
  border-left-color: rgba(15, 23, 42, 0.14);
}

body.light-mode .preview-col-tool-btn:hover {
  background: rgba(59, 130, 246, 0.14);
  color: #0f172a;
}

body.light-mode .preview-col-tool-btn.is-armed {
  background: rgba(239, 68, 68, 0.16);
  color: #b91c1c;
}

body.light-mode .preview-col-tool-btn.is-disabled,
body.light-mode .preview-col-tool-btn:disabled {
  background: transparent;
}

.preview-input-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: transparent;
}

.preview-input-dialog {
  position: absolute;
  min-width: 220px;
  max-width: 280px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(122, 162, 255, 0.35);
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  color: #e5e7eb;
}

.preview-confirm-dialog {
  min-width: 260px;
  max-width: 340px;
}

.preview-confirm-title {
  color: #fca5a5;
}

.preview-confirm-message {
  white-space: normal;
}

.preview-input-dialog-title {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.preview-input-dialog-message {
  margin-top: 4px;
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: #cbd5e1;
}

.preview-input-dialog-field {
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.6);
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 600;
}

.preview-input-dialog-field:focus {
  outline: none;
  border-color: rgba(122, 162, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(122, 162, 255, 0.25);
}

.preview-input-dialog-error {
  min-height: 14px;
  margin-top: 6px;
  font-size: 11px;
  line-height: 1.3;
  color: #fda4af;
}

.preview-input-dialog-actions {
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.preview-input-dialog-btn {
  border: 1px solid rgba(122, 162, 255, 0.35);
  border-radius: 8px;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.24);
  color: #e5e7eb;
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}

.preview-input-dialog-btn:hover {
  background: rgba(59, 130, 246, 0.34);
}

.preview-input-dialog-btn.danger {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.28);
  color: #fee2e2;
}

.preview-input-dialog-btn.danger:hover {
  background: rgba(239, 68, 68, 0.4);
}

.preview-input-dialog-btn.secondary {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(71, 85, 105, 0.4);
}

.preview-input-dialog-btn.secondary:hover {
  background: rgba(71, 85, 105, 0.55);
}

body.light-mode .preview-input-dialog {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
}

body.light-mode .preview-confirm-title {
  color: #b91c1c;
}

body.light-mode .preview-input-dialog-message {
  color: #475569;
}

body.light-mode .preview-input-dialog-field {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(248, 250, 252, 0.98);
  color: #0f172a;
}

body.light-mode .preview-input-dialog-error {
  color: #b91c1c;
}

body.light-mode .preview-input-dialog-btn {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.16);
  color: #0f172a;
}

body.light-mode .preview-input-dialog-btn:hover {
  background: rgba(59, 130, 246, 0.25);
}

body.light-mode .preview-input-dialog-btn.danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.16);
  color: #7f1d1d;
}

body.light-mode .preview-input-dialog-btn.danger:hover {
  background: rgba(239, 68, 68, 0.24);
}

body.light-mode .preview-input-dialog-btn.secondary {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(148, 163, 184, 0.22);
}

body.light-mode .preview-input-dialog-btn.secondary:hover {
  background: rgba(148, 163, 184, 0.34);
}

.cleaning-actions {
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.cleaning-actions-title {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.3px;
  color: var(--muted);
  margin-bottom: 6px;
}

.cleaning-actions ul {
  margin: 0;
  padding-left: 18px;
}

.cleaning-actions li {
  font-size: 12px;
  color: var(--text);
  margin: 4px 0;
}

body.light-mode .cleaning-actions li {
  color: #111827;
}

.footer {
  padding: 10px 18px 26px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

th.num,
td.num {
  text-align: right;
}
th.center,
td.center {
  text-align: center;
}
th.left,
td.left {
  text-align: left;
}

/* Dragging: prevent selection */
.dragging {
  user-select: none !important;
  cursor: grabbing !important;
}

/* Report panel: force an opaque, readable card on the right side */
.reportPanel {
  background: #0f1724 !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
  box-shadow: var(--shadow) !important;
}

/* EFA panel full-height layout when expanded */
.frame#efaCard {
  display: flex;
  flex-direction: column;
}

.frame#efaCard:not(.collapsed) .bd {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.frame#efaCard.collapsed .bd {
  display: none;
}

.frame#efaCard #efaVarList {
  flex: 1 1 auto;
  min-height: 250px;
  max-height: none;
  height: auto;
}
/* CFA panel styling */
.frame#cfaCard:not(.collapsed) .bd {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.frame#cfaCard.collapsed .bd {
  display: none;
}

.frame#cfaCard.collapsed .hd .row > :not(#cfaBuildFromEfaBtn) {
  display: none !important;
}

.cfa-var-item {
  transition: all 0.15s ease;
}

.cfa-var-item:not([style*="pointer-events: none"]):hover {
  background: rgba(122, 180, 255, 0.8) !important;
  transform: translateX(2px);
}

.cfa-control-bar {
  transform: scale(0.7);
  transform-origin: top right;
}

#cfaCanvas {
  cursor: crosshair;
}
#cfaCanvas text {
  user-select: none;
  -webkit-user-select: none;
}
body.light-mode #cfaCanvasWrap {
  background: var(--cfa-canvas-bg) !important;
}
body.light-mode #cfaCanvas {
  background: transparent !important;
}
body.light-mode #cfaCanvas text {
  fill: #1f2937 !important;
}
body.light-mode #cfaCanvas line,
body.light-mode #cfaCanvas path {
  stroke: rgba(15, 23, 42, 0.65) !important;
}
body.light-mode #cfaCanvas .canvas-hit {
  stroke: transparent !important;
}
body.light-mode #cfaCanvas polygon {
  fill: rgba(15, 23, 42, 0.65) !important;
}
body.light-mode #cfaCanvas rect[data-type="latent"] {
  fill: rgba(37, 99, 235, 0.12) !important;
  stroke: #1d4ed8 !important;
}
body.light-mode #cfaCanvas rect[data-type="manifest"] {
  fill: rgba(15, 23, 42, 0.03) !important;
  stroke: rgba(15, 23, 42, 0.35) !important;
}

.cfa-delete-btn {
  cursor: pointer !important;
}

.cfa-delete-btn * {
  cursor: pointer !important;
}

.cfa-fl-table td,
.cfa-fl-table th {
  transition: background 0.15s ease;
}

.cfa-fl-split {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 220px;
  flex-wrap: nowrap;
}

.cfa-fl-left {
  flex: 0 0 var(--fl-left, 65%);
  min-width: 260px;
  max-width: 100%;
}

.cfa-fl-right {
  flex: 1 1 calc(100% - var(--fl-left, 65%));
  min-width: 240px;
  max-width: 100%;
}

.cfa-fl-divider {
  width: 8px;
  cursor: col-resize;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.08)
  );
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  margin: 0 10px;
  touch-action: none;
  align-self: stretch;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.cfa-fl-divider:hover {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.16),
    rgba(255, 255, 255, 0.06)
  );
}

.efa-output-split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
  margin-top: 12px;
}

.efa-output-left {
  flex: 1 1 360px;
  min-width: 260px;
}

.efa-output-right {
  flex: 1 1 320px;
  min-width: 240px;
}

.efa-output-divider {
  width: 8px;
  align-self: stretch;
  margin: 0 8px;
  border-radius: 6px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.14),
    rgba(255, 255, 255, 0.05)
  );
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

@media (max-width: 900px) {
  .efa-output-divider {
    display: none;
  }
}

.cfa-fl-row-hover td {
  background: rgba(122, 162, 255, 0.08) !important;
}

.cfa-fl-col-hover {
  background: rgba(122, 162, 255, 0.08) !important;
}
/* Structural modeling panel styling */
.frame#structCard:not(.collapsed) .bd {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.frame#structCard.collapsed .bd {
  display: none;
}

.struct-control-bar {
  transform: scale(0.7);
  transform-origin: top right;
}

.struct-control-bar .btn {
  display: flex;
  align-items: center;
  justify-content: center;
}

.struct-mode-btn.is-active {
  background: var(--tab-bg-active) !important;
  color: var(--tab-text-active) !important;
  border-color: var(--tab-border) !important;
}

#structCanvas {
  cursor: crosshair;
}

#structCanvas text {
  user-select: none;
  -webkit-user-select: none;
}

body.light-mode #structCanvasWrap {
  background: var(--cfa-canvas-bg) !important;
}

body.light-mode #structCanvas {
  background: transparent !important;
}

body.light-mode #structCanvas text {
  fill: #1f2937 !important;
}

body.light-mode #structCanvas line,
body.light-mode #structCanvas path {
  stroke: rgba(15, 23, 42, 0.65) !important;
}
body.light-mode #structCanvas .canvas-hit {
  stroke: transparent !important;
}

body.light-mode #structCanvas polygon {
  fill: rgba(15, 23, 42, 0.65) !important;
}

body.light-mode #structCanvas [data-type="latent"] {
  fill: rgba(37, 99, 235, 0.12) !important;
  stroke: #1d4ed8 !important;
}

body.light-mode #structCanvas [data-type="composite"] {
  fill: rgba(245, 158, 11, 0.14) !important;
  stroke: rgba(161, 98, 7, 0.7) !important;
}

body.light-mode #structCanvas [data-type="observed"] {
  fill: rgba(15, 23, 42, 0.04) !important;
  stroke: rgba(15, 23, 42, 0.35) !important;
}

body.light-mode #structCanvas [data-type="indicator"] {
  fill: rgba(15, 23, 42, 0.08) !important;
  stroke: rgba(15, 23, 42, 0.35) !important;
}

.struct-tab-btn {
  padding: 4px 8px;
  border: 1px solid var(--tab-border);
  border-radius: 3px;
  background: var(--tab-bg-inactive);
  color: var(--tab-text-inactive);
  cursor: pointer;
  font-size: 12px;
}

.struct-tab-btn.is-active {
  background: var(--tab-bg-active);
  color: var(--tab-text-active);
}

.struct-model-tab-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--tab-border);
  border-radius: 4px;
  background: var(--tab-bg-inactive);
  color: var(--tab-text-inactive);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.struct-model-tab-btn.is-active {
  background: var(--tab-bg-active);
  color: var(--tab-text-active);
}

.cfa-model-tab-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--tab-border);
  border-radius: 4px;
  background: var(--tab-bg-inactive);
  color: var(--tab-text-inactive);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.cfa-model-tab-btn.is-active {
  background: var(--tab-bg-active);
  color: var(--tab-text-active);
}

.efa-model-tab-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--tab-border);
  border-radius: 4px;
  background: var(--tab-bg-inactive);
  color: var(--tab-text-inactive);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

.efa-model-tab-btn.is-active {
  background: var(--tab-bg-active);
  color: var(--tab-text-active);
}

.struct-path-row-active {
  background: rgba(96, 165, 250, 0.18) !important;
  box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.65);
}

.report-tab-buttons,
.efa-tab-buttons,
.cfa-tab-buttons,
.struct-tab-buttons {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--surface-1);
  padding: 6px 0 10px;
}
body.light-mode .report-tab-btn,
body.light-mode .efa-tab-btn,
body.light-mode .struct-tab-btn {
  background: var(--tab-bg-inactive) !important;
  color: var(--tab-text-inactive) !important;
  border-color: var(--tab-border) !important;
}
body.light-mode .report-tab-btn.is-active,
body.light-mode .efa-tab-btn.is-active,
body.light-mode .struct-tab-btn.is-active {
  background: var(--tab-bg-active) !important;
  color: var(--tab-text-active) !important;
}

body.light-mode .efa-type-filter,
body.light-mode .efa-estimator-btn,
body.light-mode .efa-extract-btn {
  background: #e5e7eb !important;
  color: #111827 !important;
  border-color: rgba(15, 23, 42, 0.18) !important;
}

body.light-mode .efa-type-filter.secondary,
body.light-mode .efa-estimator-btn.secondary,
body.light-mode .efa-extract-btn.secondary {
  background: #f1f5f9 !important;
  color: #475569 !important;
}

.release-notes-page .wrap {
  padding: 0 18px 40px;
}
.release-notes-card .bd {
  display: block;
}
.release-notes-content {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}
.release-notes-content h1,
.release-notes-content h2,
.release-notes-content h3 {
  margin: 16px 0 8px;
}
.release-notes-content h1 {
  font-size: 22px;
}
.release-notes-content h2 {
  font-size: 18px;
  color: #e2e8f0;
}
.release-notes-content h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}
.release-notes-content ul {
  padding-left: 18px;
  margin: 6px 0 14px;
}
.release-notes-content li {
  margin-bottom: 6px;
}
.light-mode .release-notes-content h2 {
  color: #111827;
}
