/* ============================================================================
   SOLVEPOP SCI v1.9.0 — Copyright (c) 2026 SolvePop — TACTILE SCIENTIFIC HARDWARE STYLESHEET
   1. Strict CSP compatible (zero inline styles required).
   2. All 6 hardware skins pass WCAG AA button contrast (>= 4.5:1).
   3. >= 44px minimum touch targets on interactive controls.
   ============================================================================ */

@font-face {
  font-family: "CalcClue Sans";
  src: url("fonts/lato-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CalcClue Sans";
  src: url("fonts/lato-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "CalcClue Sans";
  src: url("fonts/lato-900.woff2") format("woff2");
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* Skin 1: Graphing Classic (Default Free — Matte Charcoal Handheld) */
:root,
body[data-skin="graphing"] {
  --bg-page: #eef2f6;
  --bg-card: #ffffff;
  --bg-casing: #1e293b;
  --casing-border: #0f172a;
  --casing-highlight: rgba(255, 255, 255, 0.16);
  --casing-label: #cbd5e1;
  --screen-bg: #dbeafe;
  --screen-text: #0f172a;
  --screen-border: #334155;
  --btn-num: #f8fafc;
  --btn-num-text: #0f172a;
  --btn-fn: #334155;
  --btn-fn-text: #f8fafc;
  --btn-util: #475569;
  --btn-util-text: #ffffff;
  --btn-op: #0369a1;
  --btn-op-text: #ffffff;
  --btn-eq: #0f766e;
  --btn-eq-text: #ffffff;
  --btn-shift: #b45309;
  --btn-shift-text: #ffffff;
  --accent: #0369a1;
  --accent-text: #ffffff;
  --status-ok: #047857;
  --status-warn: #9a3412;
  --status-err: #b91c1c;
  --graph-c0: #0369a1;
  --graph-c1: #047857;
  --graph-c2: #9a3412;
  --text-main: #0f172a;
  --text-muted: #475569;
  --card-border: rgba(15, 23, 42, 0.11);
  --pattern-tint: rgba(15, 23, 42, 0.05);
  --radius: 18px;
  --btn-radius: 10px;
  --font-main: "CalcClue Sans", system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
  color-scheme: light;
}

/* Skin 2: Blueprint Desk (Free — Crisp Engineering CAD Sheet) */
body[data-skin="blueprint"] {
  --bg-page: #e0f2fe;
  --bg-card: #ffffff;
  --bg-casing: #0c4a6e;
  --casing-border: #082f49;
  --casing-highlight: rgba(186, 230, 253, 0.35);
  --casing-label: #e0f2fe;
  --screen-bg: #f0f9ff;
  --screen-text: #082f49;
  --screen-border: #0284c7;
  --btn-num: #ffffff;
  --btn-num-text: #082f49;
  --btn-fn: #075985;
  --btn-fn-text: #f0f9ff;
  --btn-util: #0369a1;
  --btn-util-text: #ffffff;
  --btn-op: #1d4ed8;
  --btn-op-text: #ffffff;
  --btn-eq: #047857;
  --btn-eq-text: #ffffff;
  --btn-shift: #b45309;
  --btn-shift-text: #ffffff;
  --accent: #0369a1;
  --accent-text: #ffffff;
  --status-ok: #047857;
  --status-warn: #9a3412;
  --status-err: #b91c1c;
  --graph-c0: #0369a1;
  --graph-c1: #047857;
  --graph-c2: #9a3412;
  --text-main: #082f49;
  --text-muted: #0369a1;
  --card-border: rgba(3, 105, 161, 0.2);
  --pattern-tint: rgba(3, 105, 161, 0.11);
  --radius: 10px;
  --btn-radius: 6px;
  color-scheme: light;
}

/* Skin 3: Cyber Terminal (Pro / Beta Free — Dark Phosphor HUD) */
body[data-skin="cyber"] {
  --bg-page: #070b14;
  --bg-card: #111827;
  --bg-casing: #0f172a;
  --casing-border: #0ea5e9;
  --casing-highlight: rgba(56, 189, 248, 0.3);
  --casing-label: #38bdf8;
  --screen-bg: #020617;
  --screen-text: #34d399;
  --screen-border: #0ea5e9;
  --btn-num: #1e293b;
  --btn-num-text: #f8fafc;
  --btn-fn: #0f2937;
  --btn-fn-text: #bae6fd;
  --btn-util: #334155;
  --btn-util-text: #f8fafc;
  --btn-op: #0369a1;
  --btn-op-text: #ffffff;
  --btn-eq: #047857;
  --btn-eq-text: #ffffff;
  --btn-shift: #b45309;
  --btn-shift-text: #ffffff;
  --accent: #0369a1;
  --accent-text: #ffffff;
  --status-ok: #34d399;
  --status-warn: #fbbf24;
  --status-err: #fb7185;
  --graph-c0: #38bdf8;
  --graph-c1: #34d399;
  --graph-c2: #fbbf24;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --card-border: rgba(56, 189, 248, 0.22);
  --pattern-tint: rgba(56, 189, 248, 0.08);
  --radius: 8px;
  --btn-radius: 6px;
  color-scheme: dark;
}

/* Skin 4: Retro 80s Pocket (Pro / Beta Free — Brushed Warm Aluminum & Amber LED) */
body[data-skin="retro"] {
  --bg-page: #f5f0e6;
  --bg-card: #fffdf8;
  --bg-casing: #3f3b36;
  --casing-border: #1c1917;
  --casing-highlight: rgba(254, 243, 199, 0.25);
  --casing-label: #fde68a;
  --screen-bg: #1c1917;
  --screen-text: #fbbf24;
  --screen-border: #78716c;
  --btn-num: #e7e5e4;
  --btn-num-text: #1c1917;
  --btn-fn: #57534e;
  --btn-fn-text: #fafaf9;
  --btn-util: #44403c;
  --btn-util-text: #fafaf9;
  --btn-op: #9a3412;
  --btn-op-text: #ffffff;
  --btn-eq: #0f766e;
  --btn-eq-text: #ffffff;
  --btn-shift: #a16207;
  --btn-shift-text: #ffffff;
  --accent: #9a3412;
  --accent-text: #ffffff;
  --status-ok: #047857;
  --status-warn: #9a3412;
  --status-err: #b91c1c;
  --graph-c0: #0369a1;
  --graph-c1: #047857;
  --graph-c2: #9a3412;
  --text-main: #1c1917;
  --text-muted: #57534e;
  --card-border: rgba(28, 25, 23, 0.14);
  --pattern-tint: rgba(120, 113, 108, 0.09);
  --radius: 12px;
  --btn-radius: 6px;
  color-scheme: light;
}

/* Skin 5: Lab Carbon (Pro / Beta Free — Matte Carbon Stealth) */
body[data-skin="carbon"] {
  --bg-page: #121216;
  --bg-card: #1c1c22;
  --bg-casing: #18181b;
  --casing-border: #09090b;
  --casing-highlight: rgba(255, 255, 255, 0.12);
  --casing-label: #d4d4d8;
  --screen-bg: #09090b;
  --screen-text: #f4f4f5;
  --screen-border: #3f3f46;
  --btn-num: #27272a;
  --btn-num-text: #fafafa;
  --btn-fn: #3f3f46;
  --btn-fn-text: #f4f4f5;
  --btn-util: #52525b;
  --btn-util-text: #ffffff;
  --btn-op: #be123c;
  --btn-op-text: #ffffff;
  --btn-eq: #0f766e;
  --btn-eq-text: #ffffff;
  --btn-shift: #b45309;
  --btn-shift-text: #ffffff;
  --accent: #be123c;
  --accent-text: #ffffff;
  --status-ok: #34d399;
  --status-warn: #fbbf24;
  --status-err: #fb7185;
  --graph-c0: #38bdf8;
  --graph-c1: #34d399;
  --graph-c2: #fbbf24;
  --text-main: #fafafa;
  --text-muted: #a1a1aa;
  --card-border: rgba(255, 255, 255, 0.12);
  --pattern-tint: rgba(255, 255, 255, 0.05);
  --radius: 20px;
  --btn-radius: 12px;
  color-scheme: dark;
}

/* Skin 6: Ocean (Pro — Matches SolvePop Kids Ocean!) */
body[data-skin="ocean"] {
  --bg-page: #ecfeff;
  --bg-card: #ffffff;
  --bg-casing: #0e7490;
  --casing-border: #155e75;
  --casing-highlight: rgba(165, 243, 252, 0.35);
  --casing-label: #ecfeff;
  --screen-bg: #cffafe;
  --screen-text: #083344;
  --screen-border: rgba(14, 116, 144, 0.28);
  --btn-num: #f0f9ff;
  --btn-num-text: #0c4a6e;
  --btn-fn: #155e75;
  --btn-fn-text: #ecfeff;
  --btn-util: #083344;
  --btn-util-text: #ecfeff;
  --btn-op: #0369a1;
  --btn-op-text: #ffffff;
  --btn-eq: #0f766e;
  --btn-eq-text: #ffffff;
  --btn-shift: #9a3412;
  --btn-shift-text: #ffffff;
  --accent: #0e7490;
  --accent-text: #ffffff;
  --status-ok: #047857;
  --status-warn: #9a3412;
  --status-err: #b91c1c;
  --graph-c0: #0369a1;
  --graph-c1: #047857;
  --graph-c2: #9a3412;
  --text-main: #083344;
  --text-muted: #155e75;
  --card-border: rgba(14, 116, 144, 0.22);
  --pattern-tint: rgba(14, 116, 144, 0.11);
  --radius: 24px;
  --btn-radius: 14px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-main);
  color: var(--text-main);
  background-color: var(--bg-page);
  background-image:
    linear-gradient(to right, var(--pattern-tint) 1px, transparent 1px),
    linear-gradient(to bottom, var(--pattern-tint) 1px, transparent 1px);
  background-size: 24px 24px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 14px 16px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, select, input {
  font-family: inherit;
}

button, select, a.pill-btn {
  min-height: 44px;
}

.hidden {
  display: none !important;
}

.top-bar, .beta-free-banner, .skin-bar, .workspace, .app-footer {
  max-width: 1120px;
  margin: 0 auto 12px;
}

/* Header */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 2px solid var(--card-border);
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  border-radius: 10px;
  flex-shrink: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand h1 {
  font-size: 1.32rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.brand-kicker {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--accent);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 999px;
}

.subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill-btn, .dev-toggle-btn, .unlock-cta {
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  touch-action: manipulation;
}

.pill-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 2px solid var(--card-border);
}

.pill-btn:hover {
  border-color: var(--accent);
}

.pill-btn.speaking {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.dev-toggle-btn {
  background: #fef3c7;
  color: #78350f;
  border: 2px dashed #b45309;
}

.dev-toggle-btn.dev-on {
  background: #dcfce7;
  color: #14532d;
  border-color: #15803d;
}

.unlock-cta {
  background: var(--accent);
  color: var(--accent-text);
  border: 2px solid transparent;
}

.unlock-cta.pro-active {
  background: #047857;
  color: #ffffff;
}

/* Free Beta Banner */
.beta-free-banner {
  background: var(--bg-card);
  color: var(--text-main);
  border: 2px solid var(--status-ok);
  padding: 8px 14px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}

.beta-dismiss-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--card-border);
  border-radius: 999px;
  min-width: 44px;
  font-weight: 800;
  cursor: pointer;
}

/* Skin Strip */
.skin-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 2px solid var(--card-border);
  padding: 8px 14px;
  border-radius: var(--radius);
}

.skin-label {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.skin-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 2px solid transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  touch-action: manipulation;
}

.skin-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.skin-btn small {
  background: var(--accent);
  color: var(--accent-text);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.62rem;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.sw-graphing  { background: #1e293b; }
.sw-blueprint { background: #0284c7; }
.sw-cyber     { background: #0f766e; }
.sw-retro     { background: #b45309; }
.sw-carbon    { background: #be123c; }
.sw-ocean     { background: #0e7490; }

/* Main Grid */
.workspace {
  display: grid;
  grid-template-columns: 410px 1fr;
  gap: 20px;
  align-items: start;
}

.workspace-single {
  grid-template-columns: 1fr;
  max-width: 780px;
}

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

/* Tactile Physical Calculator Casing */
.calc-casing {
  background: var(--bg-casing);
  border-top: 2px solid var(--casing-highlight);
  border-bottom: 9px solid var(--casing-border);
  padding: 16px 16px 20px;
  border-radius: var(--radius);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.22);
}

/* Distinct Hardware Silhouettes per Skin */
body[data-skin="cyber"] .calc-casing {
  border: 2px solid var(--casing-border);
  border-bottom-width: 8px;
  box-shadow: 0 0 28px rgba(14, 165, 233, 0.22);
}

body[data-skin="retro"] .calc-casing {
  border: 3px solid var(--casing-border);
  border-top: 5px solid #a8a29e;
  border-bottom-width: 10px;
}

body[data-skin="blueprint"] .calc-casing {
  border: 2px solid rgba(186, 230, 253, 0.45);
  border-bottom: 8px solid var(--casing-border);
}

.casing-top-trim {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 2px;
}

.casing-model-tag {
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--casing-label);
}

.casing-solar {
  display: flex;
  gap: 3px;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 5px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.casing-solar span {
  width: 12px;
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(135deg, #334155, #0f172a);
}

/* Scientific LCD Screen */
.calc-screen {
  position: relative;
  overflow: hidden;
  background: var(--screen-bg);
  color: var(--screen-text);
  border: 3px solid var(--screen-border);
  border-radius: calc(var(--radius) * 0.6);
  padding: 10px 14px 12px;
  margin-bottom: 14px;
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.22);
}

.calc-screen::after {
  content: "";
  position: absolute;
  inset: 0 0 58% 0;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.14), transparent);
  pointer-events: none;
}

.screen-indicators {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 6px;
  margin-bottom: 6px;
}

.ind-badge {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1.5px solid currentColor;
  opacity: 0.88;
}

.ind-shift {
  background: var(--btn-shift);
  color: var(--btn-shift-text);
  border-color: transparent;
  opacity: 1;
}

.screen-quick-actions {
  margin-left: auto;
  display: flex;
  gap: 5px;
}

.screen-mini-btn {
  min-height: 32px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 900;
  border-radius: 7px;
  border: 2px solid currentColor;
  background: transparent;
  color: var(--screen-text);
  cursor: pointer;
  opacity: 0.96;
  white-space: nowrap;
}

.screen-mini-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.screen-mini-btn.active-toggle {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
  opacity: 1;
}

.expr-display {
  position: relative;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: right;
  opacity: 0.82;
  min-height: 1.35em;
  overflow-x: auto;
  white-space: nowrap;
}

.main-display {
  position: relative;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 2.05rem;
  font-weight: 900;
  line-height: 1.2;
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Keypads */
.sci-deck {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 10px;
}

.num-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.key {
  background: var(--btn-num);
  color: var(--btn-num-text);
  border: none;
  border-top: 2px solid rgba(255, 255, 255, 0.25);
  border-bottom: 4px solid rgba(0, 0, 0, 0.32);
  border-radius: var(--btn-radius);
  padding: 10px 4px;
  font-size: 1.15rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.07s ease, filter 0.12s ease;
}

.key:hover {
  filter: brightness(1.06);
}

.key:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.key-fn {
  background: var(--btn-fn);
  color: var(--btn-fn-text);
  font-size: 0.88rem;
  padding: 8px 3px;
}

.key-shift {
  background: var(--btn-shift);
  color: var(--btn-shift-text);
  font-size: 0.86rem;
}

.key-shift.shift-on {
  box-shadow: 0 0 0 2px #fde047;
  filter: brightness(1.12);
}

.key-mode {
  background: var(--btn-op);
  color: var(--btn-op-text);
  font-size: 0.84rem;
}

.key-util {
  background: var(--btn-util);
  color: var(--btn-util-text);
  font-size: 1rem;
}

.key-op {
  background: var(--btn-op);
  color: var(--btn-op-text);
  font-size: 1.32rem;
}

.key-eq {
  grid-column: span 2;
  background: var(--btn-eq);
  color: var(--btn-eq-text);
  font-size: 0.98rem;
}

/* Right Board: Step-by-Step + History Tape */
.clue-board {
  background: var(--bg-card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.07);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.board-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--card-border);
}

.board-header h2, .board-header h1 {
  font-size: 1.24rem;
  font-weight: 900;
}

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

.step-card {
  background: var(--bg-page);
  border-left: 5px solid var(--accent);
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 8px;
  line-height: 1.5;
  font-size: 0.94rem;
}

.step-card.final-card {
  border-left-color: var(--status-ok);
}

.step-card.error-card {
  border-left-color: var(--status-err);
}

.step-card.speaking-active {
  box-shadow: 0 0 0 3px var(--accent);
}

.welcome-card {
  line-height: 1.55;
}

.sample-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 12px;
}

.sample-chip {
  background: var(--bg-page);
  color: var(--text-main);
  border: 2px solid var(--accent);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  font-family: var(--font-mono);
  cursor: pointer;
}

.sample-chip:hover {
  background: var(--accent);
  color: var(--accent-text);
}

.compact-tips {
  padding-left: 18px;
  color: var(--text-muted);
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Reduction Ladder */
.ladder-stage {
  background: var(--bg-page);
  border: 2px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
}

.stage-title {
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.pemdas-ladder {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ladder-rung {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
}

.ladder-step-tag {
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ladder-highlight {
  background: var(--accent);
  color: var(--accent-text);
  padding: 2px 6px;
  border-radius: 6px;
}

.ladder-final {
  background: var(--btn-eq);
  color: var(--btn-eq-text);
  padding: 3px 9px;
  border-radius: 6px;
}

/* Calculation Tape */
.history-panel {
  margin-top: auto;
  padding-top: 12px;
  border-top: 2px dashed var(--card-border);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.history-header h3 {
  font-size: 0.9rem;
  font-weight: 900;
}

.mini-ghost-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--card-border);
  border-radius: 8px;
  padding: 4px 10px;
  min-height: 36px;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 185px;
  overflow-y: auto;
}

.history-empty {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 9px;
  padding: 4px 8px;
}

.history-expr-btn, .history-val-btn {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  cursor: pointer;
  min-height: 36px;
  padding: 4px 6px;
  border-radius: 6px;
}

.history-expr-btn {
  color: var(--text-muted);
  font-size: 0.84rem;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-val-btn {
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 900;
  flex-shrink: 0;
}

.history-expr-btn:hover, .history-val-btn:hover {
  background: var(--bg-card);
}

/* Footer */
.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  color: var(--text-muted);
  padding: 6px 0 18px;
}

.app-footer a, .footer-link-btn {
  color: var(--text-main);
  font-weight: 800;
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  font-size: inherit;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  background: var(--bg-card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  max-width: 520px;
  width: 100%;
  max-height: 92dvh;
  overflow-y: auto;
  padding: 20px 22px;
  box-shadow: 0 22px 46px rgba(0, 0, 0, 0.36);
}

.modal-wide {
  max-width: 660px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.icon-close-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 2px solid var(--card-border);
  min-width: 44px;
  border-radius: 999px;
  font-weight: 800;
  cursor: pointer;
}

.muted-text {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: 12px;
}

.info-box {
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.beta-box {
  border-color: var(--status-ok);
}

.field-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.inline-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-row input {
  flex: 1;
  min-width: 160px;
  padding: 8px 12px;
  min-height: 44px;
  border-radius: 8px;
  border: 2px solid var(--card-border);
  background: var(--bg-card);
  color: var(--text-main);
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  font-weight: 800;
}

.field-group select, .field-group textarea {
  padding: 9px 12px;
  border-radius: 9px;
  border: 2px solid var(--card-border);
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 0.9rem;
}

.field-group textarea {
  resize: vertical;
  min-height: 90px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.primary-btn, .ghost-btn, .danger-ghost-btn {
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 900;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
}

.primary-btn {
  background: var(--btn-eq);
  color: var(--btn-eq-text);
}

.full-width {
  width: 100%;
  margin-bottom: 12px;
}

.ghost-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 2px solid var(--card-border);
}

.danger-ghost-btn {
  background: var(--bg-card);
  color: var(--status-err);
  border: 2px solid var(--status-err);
}

.confirm-armed {
  background: var(--status-err) !important;
  color: #ffffff !important;
  border-color: var(--status-err) !important;
}

.status-msg {
  font-size: 0.85rem;
  font-weight: 800;
  min-height: 1.2em;
  margin-top: 6px;
}

.status-ok   { color: var(--status-ok); }
.status-warn { color: var(--status-warn); }
.status-err  { color: var(--status-err); }

/* Formula Grid */
.formula-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.formula-box {
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  padding: 12px 14px;
}

.formula-box h3 {
  font-size: 0.94rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.formula-box ul {
  padding-left: 16px;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Mobile Above-the-Fold Polish */
@media (max-width: 680px) {
  body {
    padding: 8px 10px;
  }
  .top-bar, .beta-free-banner, .skin-bar, .workspace {
    margin-bottom: 8px;
  }
  .top-bar {
    padding: 8px 12px;
    gap: 8px;
  }
  .brand h1 {
    font-size: 1.15rem;
  }
  .subtitle {
    display: none;
  }
  /* Compact wrapped skin grid on phones — Ocean & all skins visible with zero horizontal scrolling */
  .skin-bar {
    flex-wrap: wrap;
    overflow-x: visible;
    padding: 6px 8px;
    gap: 5px;
  }
  .skin-bar .skin-label {
    display: none;
  }
  .skin-bar .skin-btn {
    padding: 4px 8px;
    min-height: 32px;
    font-size: 0.74rem;
  }
}


/* ============================================================================
   v1.1 INTERACTIVE VISUAL MATH DIAGRAMS (UNIT CIRCLE, LOG MIRROR, POWERS, ROOTS)
   ============================================================================ */
.board-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.visual-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.visual-card {
  background: var(--bg-page);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 13px 15px;
}

.visual-card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.visual-card-header .stage-title {
  margin-bottom: 0;
}

.uc-angle-pill {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
}

/* Unit Circle Layout & SVG Styling */
.uc-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 14px;
  align-items: center;
}

@media (max-width: 620px) {
  .uc-layout {
    grid-template-columns: 1fr;
  }
}

.uc-svg {
  width: 100%;
  max-width: 240px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
}

.uc-axis { stroke: var(--text-muted); stroke-width: 1.4; opacity: 0.5; }
.uc-ring { fill: none; stroke: var(--text-muted); stroke-width: 2; opacity: 0.65; }
.uc-axis-lbl { fill: var(--text-muted); font-size: 11px; font-weight: 800; font-family: var(--font-mono); }
.uc-quad-lbl { fill: var(--text-muted); font-size: 11px; font-weight: 800; opacity: 0.45; }
.uc-arc { fill: none; stroke: var(--btn-shift); stroke-width: 2.8; }
.uc-leg-cos { stroke: var(--accent); stroke-width: 3.6; stroke-linecap: round; }
.uc-leg-sin { stroke: var(--btn-eq); stroke-width: 3.6; stroke-linecap: round; }
.uc-radius { stroke: var(--text-main); stroke-width: 2.5; stroke-linecap: round; }
.uc-origin { fill: var(--text-main); }
.uc-point { fill: var(--btn-shift); stroke: var(--bg-card); stroke-width: 2.2; }

.uc-readout {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.uc-coord-box {
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.uc-coord-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.uc-coord-val {
  font-family: var(--font-mono);
  font-size: 0.96rem;
}

.uc-metric {
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: 9px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.86rem;
}

.uc-metric.uc-row-hl {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.18);
  font-weight: 900;
}

.uc-metric.uc-row-err {
  border-color: var(--status-err);
  color: var(--status-err);
}

.uc-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.uc-dot-cos { background: var(--accent); }
.uc-dot-sin { background: var(--btn-eq); }
.uc-dot-tan { background: var(--btn-shift); }

.uc-fn {
  font-weight: 900;
  min-width: 56px;
}

.uc-val {
  margin-left: auto;
  text-align: right;
  font-weight: 800;
}

.uc-approx {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.78rem;
}

/* Quick Interactive Angle Chips */
.uc-chips-wrap {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1.5px dashed var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.uc-chips-label {
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.uc-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.uc-angle-chip {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.uc-angle-chip:hover {
  border-color: var(--accent);
}

.uc-angle-chip.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

/* Logarithm Mirror & Negative Exponent Reciprocal Flip */
.mirror-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.mirror-pill {
  flex: 1;
  min-width: 140px;
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 0.96rem;
}

.mirror-pill.mirror-err {
  border-color: var(--status-err);
}

.mp-tag {
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.mirror-arrow {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--accent);
}

.tok-base { color: var(--accent); font-weight: 900; }
.tok-exp  { color: var(--status-warn); font-weight: 900; }
.tok-val  { color: var(--status-ok); font-weight: 900; }

.visual-caption {
  font-size: 0.84rem;
  line-height: 1.48;
  color: var(--text-muted);
}

/* Exponent Factor Chain */
.factor-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
}

.factor-chip {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 4px 10px;
  font-weight: 900;
  font-size: 0.94rem;
}

.factor-op {
  font-weight: 900;
  color: var(--text-muted);
}

.factor-result {
  background: var(--btn-eq);
  color: var(--btn-eq-text);
  border-radius: 8px;
  padding: 4px 12px;
  font-weight: 900;
  font-size: 0.96rem;
}

/* Square & Cube Root Geometry SVG */
.root-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.root-svg {
  width: 146px;
  height: auto;
  flex-shrink: 0;
}

.root-shape { fill: var(--bg-card); stroke: var(--accent); stroke-width: 2.5; }
.root-cube-top { fill: var(--bg-card); stroke: var(--accent); stroke-width: 2; opacity: 0.85; }
.root-cube-side { fill: var(--bg-page); stroke: var(--accent); stroke-width: 2; }
.root-inner-lbl { fill: var(--text-main); font-size: 12px; font-weight: 900; font-family: var(--font-mono); }
.root-side-lbl { fill: var(--accent); font-size: 12px; font-weight: 900; font-family: var(--font-mono); }

/* Calculation Tape DEG/RAD Badge */
.history-mode-badge {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
  border-radius: 5px;
  padding: 2px 5px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 900;
  flex-shrink: 0;
}


/* ============================================================================
   v1.2 WORKSPACE TABS, MULTI-CURVE f(x) GRAPHER & SKIN STUDIO STYLES
   ============================================================================ */

/* Shared Page Backdrop Patterns & Key Shapes (used by body & Skin Studio preview) */
:is(body, .studio-preview-stage)[data-bg-pattern="solid"] {
  background-color: var(--bg-page);
  background-image: none;
}

:is(body, .studio-preview-stage)[data-bg-pattern="grid"] {
  background-color: var(--bg-page);
  background-image:
    linear-gradient(to right, var(--pattern-tint) 1px, transparent 1px),
    linear-gradient(to bottom, var(--pattern-tint) 1px, transparent 1px);
  background-size: 24px 24px;
}

:is(body, .studio-preview-stage)[data-bg-pattern="dots"] {
  background-color: var(--bg-page);
  background-image: radial-gradient(var(--pattern-tint) 2px, transparent 2px);
  background-size: 20px 20px;
}

:is(body, .studio-preview-stage)[data-key-shape="sharp"]   { --btn-radius: 5px; }
:is(body, .studio-preview-stage)[data-key-shape="rounded"] { --btn-radius: 10px; }
:is(body, .studio-preview-stage)[data-key-shape="pill"]    { --btn-radius: 999px; }

.studio-launch-btn {
  border-color: var(--accent);
}

.studio-launch-btn:hover {
  background: var(--accent);
  color: var(--accent-text);
}

/* Right Board View Tabs (Solve & Explain | Graph f(x)) */
.board-tabs {
  display: inline-flex;
  background: var(--bg-page);
  border: 2px solid var(--card-border);
  border-radius: 999px;
  padding: 3px;
  gap: 4px;
}

.board-tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 38px;
  font-size: 0.86rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.board-tab.active {
  background: var(--accent);
  color: var(--accent-text);
}

.board-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Multi-Curve f(x) Function Grapher */
.graph-inputs {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.graph-fn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 4px 8px;
}

.graph-en-check {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.graph-fn-badge {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 7px;
  color: #ffffff;
  flex-shrink: 0;
}

.g-badge-0 { background: #0369a1; }
.g-badge-1 { background: #0f766e; }
.g-badge-2 { background: #b45309; }

.graph-fn-input {
  flex: 1;
  min-width: 120px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.94rem;
  font-weight: 700;
  min-height: 36px;
  padding: 4px 6px;
}

.graph-tip-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1.5px solid var(--status-warn);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 0.82rem;
}

.graph-presets-row,
.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.preset-chip {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--card-border);
  border-radius: 999px;
  padding: 5px 11px;
  min-height: 36px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.preset-chip:hover {
  border-color: var(--accent);
}

.graph-canvas-wrap {
  border: 2px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-page);
  touch-action: none;
}

.graph-svg {
  width: 100%;
  height: auto;
  display: block;
  cursor: crosshair;
}

.g-bg { fill: var(--bg-card); }
.g-grid-line { stroke: var(--text-muted); stroke-width: 1; opacity: 0.16; }
.g-axis { stroke: var(--text-main); stroke-width: 1.8; opacity: 0.68; }
.g-tick-lbl { fill: var(--text-muted); font-size: 11px; font-weight: 800; font-family: var(--font-mono); }

.g-curve { fill: none; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.g-curve-0 { stroke: var(--graph-c0); }
.g-curve-1 { stroke: var(--graph-c1); }
.g-curve-2 { stroke: var(--graph-c2); }

.g-int-dot { stroke: var(--bg-card); stroke-width: 2; }
.g-trace-dot { stroke: var(--bg-card); stroke-width: 2.2; }
.g-dot-0 { fill: var(--graph-c0); }
.g-dot-1 { fill: var(--graph-c1); }
.g-dot-2 { fill: var(--graph-c2); }

.g-trace-line { stroke: var(--text-muted); stroke-width: 1.4; stroke-dasharray: 4 3; opacity: 0.75; }

.graph-trace-bar {
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 7px 12px;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--text-main);
  min-height: 36px;
}

.trace-val-0 { color: var(--graph-c0); font-weight: 800; }
.trace-val-1 { color: var(--graph-c1); font-weight: 800; }
.trace-val-2 { color: var(--graph-c2); font-weight: 800; }

.graph-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.g-summary-pill {
  background: var(--bg-page);
  border-left: 4px solid var(--accent);
  border-radius: 9px;
  padding: 7px 11px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

.g-pill-0 { border-left-color: var(--graph-c0); }
.g-pill-1 { border-left-color: var(--graph-c1); }
.g-pill-2 { border-left-color: var(--graph-c2); }

.graph-table-wrap {
  overflow-x: auto;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
}

.graph-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: center;
}

.graph-table th, .graph-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--card-border);
}

.graph-table thead th {
  background: var(--bg-page);
  font-weight: 900;
}

.gt-x { font-weight: 900; color: var(--text-muted); }
.gt-col-0 { color: var(--graph-c0); }
.gt-col-1 { color: var(--graph-c1); }
.gt-col-2 { color: var(--graph-c2); }

/* SolvePop Sci Skin Studio Modal */
.studio-preview-stage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid var(--card-border);
  margin-bottom: 12px;
}

.mini-sci-calc {
  background: var(--bg-casing);
  border-bottom: 4px solid var(--casing-border);
  border-radius: 12px;
  padding: 8px;
  width: 168px;
  flex-shrink: 0;
}

.mini-sci-screen {
  background: var(--screen-bg);
  color: var(--screen-text);
  border-radius: 6px;
  padding: 5px 8px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
  font-weight: 900;
}

.mini-sci-expr { font-size: 0.66rem; opacity: 0.8; }
.mini-sci-val  { font-size: 0.92rem; }

.mini-sci-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.mini-sk {
  background: var(--btn-num);
  color: var(--btn-num-text);
  border-radius: var(--btn-radius);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 900;
  padding: 4px 0;
  border-bottom: 2px solid rgba(0, 0, 0, 0.25);
}

.mini-sk-fn { background: var(--btn-fn); color: var(--btn-fn-text); }
.mini-sk-op { background: var(--btn-op); color: var(--btn-op-text); }
.mini-sk-eq { background: var(--btn-eq); color: var(--btn-eq-text); }

.mini-sci-info {
  flex: 1;
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mini-sci-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.studio-presets-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.preset-label {
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--text-muted);
}

.saved-themes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.saved-theme-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--bg-page);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  overflow: hidden;
}

.saved-theme-chip {
  background: transparent;
  color: var(--text-main);
  border: none;
  padding: 5px 10px;
  min-height: 38px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.delete-theme-btn {
  background: transparent;
  color: var(--status-err);
  border: none;
  min-width: 38px;
  min-height: 38px;
  font-weight: 900;
  cursor: pointer;
}

.studio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

@media (max-width: 520px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
  .studio-preview-stage {
    flex-direction: column;
    align-items: stretch;
  }
  .mini-sci-calc {
    width: 100%;
  }
}

.studio-group {
  background: var(--bg-page);
  border-radius: 10px;
  padding: 8px 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.studio-group label {
  font-size: 0.78rem;
  font-weight: 800;
}

.studio-group input[type="text"],
.studio-group select {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 700;
  min-height: 40px;
}

.color-pair {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.color-pair input[type="color"] {
  width: 44px;
  height: 34px;
  border: none;
  background: transparent;
  cursor: pointer;
}


/* ============================================================================
   v1.2.2 SIBLING CROSS-LINK STRIP & OPTION 1 MOBILE VISIBILITY POLISH
   ============================================================================ */
.keypad-jump-btn {
  display: none;
  border-color: var(--accent);
}

.sibling-promo-bar {
  max-width: 1120px;
  margin: 0 auto 10px;
  background: var(--bg-card);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 9px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-muted);
}

.sibling-promo-link {
  background: var(--accent);
  color: var(--accent-text);
  padding: 6px 14px;
  border-radius: 999px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  font-weight: 900;
  font-size: 0.82rem;
  text-decoration: none;
}

.sibling-promo-link:hover {
  filter: brightness(1.08);
}

@media (max-width: 900px) {
  .keypad-jump-btn {
    display: inline-flex;
  }
}

@media (max-width: 680px) {
  .calc-casing {
    padding: 12px 12px 14px;
  }
  .casing-top-trim {
    margin-bottom: 6px;
  }
  .calc-screen {
    padding: 8px 11px 9px;
    margin-bottom: 10px;
  }
  .main-display {
    font-size: 1.8rem;
  }
  .sci-deck {
    gap: 5px;
    margin-bottom: 7px;
  }
  .num-pad {
    gap: 6px;
  }
  .key {
    padding: 8px 4px;
    min-height: 44px;
    font-size: 1.08rem;
  }
  .key-fn {
    padding: 6px 2px;
    min-height: 44px;
    font-size: 0.84rem;
  }
}


/* ============================================================================
   v1.2.3 TABBED FORMULAS, INPUT GUIDE & CALCULUS REFERENCE MODAL
   ============================================================================ */
.formula-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.formula-tab {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--card-border);
  border-radius: 999px;
  padding: 6px 13px;
  min-height: 38px;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}

.formula-tab:hover {
  border-color: var(--accent);
}

.formula-tab.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.formula-box code {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-main);
}

.try-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px dashed var(--card-border);
}

.try-formula-chip {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 5px 11px;
  min-height: 36px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.try-formula-chip:hover {
  background: var(--accent);
  color: var(--accent-text);
}


/* ============================================================================
   v1.3 LAB GAMES SUITE (CURVE SNIPER, LAB MISSIONS & QUICK ARCADE)
   ============================================================================ */
.game-mode-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.game-mode-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 7px 8px;
  min-height: 40px;
  font-size: 0.82rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.game-mode-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.game-subview {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-top-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.game-pill-badge {
  display: inline-block;
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.72rem;
  font-weight: 900;
  margin-left: 6px;
}

.game-progress-tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--status-ok);
}

.game-compact-btn {
  min-height: 38px;
  padding: 7px 14px;
  font-size: 0.84rem;
}

/* Curve Sniper */
.sniper-level-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.sniper-lvl-btn {
  min-width: 38px;
  min-height: 36px;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}

.sniper-lvl-btn.cleared {
  border-color: var(--status-ok);
  color: var(--status-ok);
}

.sniper-lvl-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.sniper-arena {
  border: 2px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-page);
}

.sniper-svg {
  width: 100%;
  height: auto;
  display: block;
}

.sniper-target-ring {
  fill: none;
  stroke: var(--graph-c0);
  stroke-width: 2.6;
}

.sniper-target-core {
  fill: var(--graph-c0);
}

.sniper-target-ring.hit {
  stroke: var(--status-ok);
  stroke-width: 3.2;
}

.sniper-target-core.hit {
  fill: var(--status-ok);
}

.sniper-coord {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
}

.sniper-hazard {
  fill: var(--status-err);
  fill-opacity: 0.22;
  stroke: var(--status-err);
  stroke-width: 2.2;
}

.sniper-hazard-hit {
  fill-opacity: 0.55;
  stroke-width: 3.4;
}

.sniper-hazard-x {
  fill: var(--status-err);
  font-size: 12px;
  font-weight: 900;
}

.sniper-curve {
  fill: none;
  stroke: var(--graph-c2);
  stroke-width: 3;
  stroke-linecap: round;
}

.sniper-curve.cleared {
  stroke: var(--status-ok);
  stroke-width: 3.4;
}

.sniper-curve.crashed {
  stroke: var(--status-err);
  stroke-dasharray: 6 4;
}

.sniper-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 5px 8px;
}

.sniper-helper-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sniper-chips-row,
.sniper-action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Lab Missions */
.mission-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mission-tab-btn {
  background: var(--bg-page);
  color: var(--text-main);
  border: 1.5px solid var(--card-border);
  border-radius: 999px;
  padding: 5px 12px;
  min-height: 36px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.mission-tab-btn.cleared {
  border-color: var(--status-ok);
}

.mission-tab-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.mission-card {
  background: var(--bg-page);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mission-stage-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mission-pips {
  display: inline-flex;
  gap: 6px;
}

.m-pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  background: var(--bg-card);
}

.m-pip.curr {
  border-color: var(--accent);
  background: var(--accent);
}

.m-pip.done {
  border-color: var(--status-ok);
  background: var(--status-ok);
}

.mission-story {
  font-size: 0.92rem;
  line-height: 1.5;
}

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

.mission-answer-input {
  flex: 1;
  min-width: 120px;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.96rem;
  font-weight: 800;
}

.mission-unit {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.mission-tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mission-hint-box {
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 8px 11px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* Quick Arcade */
.arcade-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.arcade-cat-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.arcade-card {
  background: var(--bg-page);
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.arcade-question {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 900;
  text-align: center;
  padding: 12px 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
}

.arcade-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.arcade-choice-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 2px solid var(--card-border);
  border-radius: 11px;
  padding: 11px 10px;
  min-height: 46px;
  font-family: var(--font-mono);
  font-size: 0.96rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.arcade-choice-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.arcade-choice-btn.is-correct {
  border-color: var(--status-ok);
  background: var(--btn-eq);
  color: var(--btn-eq-text);
}

.arcade-choice-btn.is-wrong {
  border-color: var(--status-err);
  color: var(--status-err);
}

.arcade-footer-row {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 520px) {
  .game-mode-btn {
    font-size: 0.76rem;
    padding: 6px 4px;
  }
}


/* ============================================================================
   v1.4 OCEAN BACKDROPS, COLOR-CODED FORMULAS + GEOMETRY SVGS, LOG & MOBILE POLISH
   ============================================================================ */
:is(body, .studio-preview-stage)[data-bg-pattern="waves"] {
  background-color: var(--bg-page);
  background-image:
    radial-gradient(circle at 20px 26px, transparent 14px, var(--pattern-tint) 15px, var(--pattern-tint) 18px, transparent 19px),
    radial-gradient(circle at 0px 8px, transparent 14px, var(--pattern-tint) 15px, var(--pattern-tint) 18px, transparent 19px);
  background-size: 40px 34px;
}
:is(body, .studio-preview-stage)[data-bg-pattern="hex"] {
  background-color: var(--bg-page);
  background-image:
    linear-gradient(30deg, var(--pattern-tint) 12%, transparent 12.5%, transparent 87%, var(--pattern-tint) 87.5%, var(--pattern-tint)),
    linear-gradient(150deg, var(--pattern-tint) 12%, transparent 12.5%, transparent 87%, var(--pattern-tint) 87.5%, var(--pattern-tint)),
    linear-gradient(60deg, var(--pattern-tint) 25%, transparent 25.5%, transparent 75%, var(--pattern-tint) 75%, var(--pattern-tint));
  background-size: 28px 48px;
}
:is(body, .studio-preview-stage)[data-bg-pattern="crosshatch"] {
  background-color: var(--bg-page);
  background-image:
    repeating-linear-gradient(45deg, var(--pattern-tint) 0, var(--pattern-tint) 1px, transparent 1px, transparent 14px),
    repeating-linear-gradient(-45deg, var(--pattern-tint) 0, var(--pattern-tint) 1px, transparent 1px, transparent 14px);
}
:is(body, .studio-preview-stage)[data-bg-pattern="scanlines"] {
  background-color: var(--bg-page);
  background-image: repeating-linear-gradient(0deg, transparent, transparent 5px, var(--pattern-tint) 5px, var(--pattern-tint) 7px);
}
body[data-plain-bg="true"] { background-image: none !important; }

.plain-bg-toggle {
  background: var(--bg-page); color: var(--text-main); border: 1.5px solid var(--card-border);
  border-radius: 999px; padding: 6px 12px; min-height: 36px; font-size: 0.8rem; font-weight: 800;
  cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
.plain-bg-toggle.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* Formula Search Toolbar & Deep-Dive Cards */
.formula-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px;
}
.formula-search-input {
  flex: 1; min-width: 190px; min-height: 38px; padding: 6px 12px;
  border-radius: 999px; border: 1.5px solid var(--card-border);
  background: var(--bg-page); color: var(--text-main); font-size: 0.86rem; font-weight: 700;
}
.formula-box-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; margin-bottom: 6px;
}
.formula-tab-tag {
  font-size: 0.7rem; font-weight: 800; color: var(--text-muted);
  background: var(--bg-card); border: 1px solid var(--card-border); border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.formula-display-line {
  font-family: var(--font-mono); font-size: 0.9rem; font-weight: 900; line-height: 1.55;
  background: var(--bg-card); border: 1.5px solid var(--card-border); border-radius: 9px;
  padding: 7px 10px; margin-bottom: 6px; word-break: break-word;
}
.formula-summary {
  font-size: 0.83rem; line-height: 1.45; color: var(--text-muted); margin-bottom: 4px;
}

/* Color-Coded Semantic Math Tokens (WCAG AA + Colorblind-Safe Underline Patterns!) */
.mt {
  display: inline-block; padding: 0 4px; border-radius: 4px; font-weight: 900;
  background: rgba(128, 128, 128, 0.08);
}
.mt-a   { color: var(--graph-c0); border-bottom: 2px solid var(--graph-c0); }
.mt-b   { color: var(--graph-c1); border-bottom: 2px dashed var(--graph-c1); }
.mt-c   { color: var(--graph-c2); border-bottom: 2px dotted var(--graph-c2); }
.mt-out { color: var(--text-main); border: 1.5px solid var(--accent); }

.deep-dive-btn {
  margin-left: auto; background: transparent; color: var(--text-main);
  border: 1.5px solid var(--card-border); border-radius: 999px;
  padding: 5px 11px; min-height: 36px; font-size: 0.76rem; font-weight: 900;
  cursor: pointer; touch-action: manipulation;
}
.deep-dive-btn:hover { border-color: var(--accent); }

.deep-dive-panel {
  margin-top: 9px; padding-top: 9px; border-top: 1.5px dashed var(--card-border);
  display: flex; flex-direction: column; gap: 7px; font-size: 0.82rem; line-height: 1.48;
}
.deep-legend { padding-left: 16px; display: flex; flex-direction: column; gap: 4px; color: var(--text-main); }
.deep-why  { color: var(--text-muted); }
.deep-keys { color: var(--text-main); }
.deep-trap { color: var(--status-warn); }

/* Color-Matched Pure-SVG Geometry Diagrams */
.geo-svg {
  width: 100%; max-height: 112px; display: block;
  background: var(--bg-card); border: 1.5px solid var(--card-border); border-radius: 10px; padding: 4px;
}
.geo-shape    { fill: rgba(128, 128, 128, 0.08); stroke: var(--text-muted); stroke-width: 1.8; }
.geo-line-a   { stroke: var(--graph-c0); stroke-width: 3; stroke-linecap: round; }
.geo-line-b   { stroke: var(--graph-c1); stroke-width: 3; stroke-linecap: round; }
.geo-line-c   { stroke: var(--graph-c2); stroke-width: 3; stroke-linecap: round; }
.geo-arc-b    { fill: none; stroke: var(--graph-c1); stroke-width: 2.6; }
.geo-arc-c    { fill: none; stroke: var(--graph-c2); stroke-width: 3.4; stroke-linecap: round; }
.geo-dot-a    { fill: var(--graph-c0); }
.geo-dash     { stroke-dasharray: 4 3; }
.geo-right-sq { fill: none; stroke: var(--text-muted); stroke-width: 1.5; }
.geo-lbl-a    { fill: var(--graph-c0); font-family: var(--font-mono); font-size: 11px; font-weight: 900; }
.geo-lbl-b    { fill: var(--graph-c1); font-family: var(--font-mono); font-size: 11px; font-weight: 900; }
.geo-lbl-c    { fill: var(--graph-c2); font-family: var(--font-mono); font-size: 11px; font-weight: 900; }
.geo-cap      { fill: var(--text-muted); font-family: var(--font-mono); font-size: 10px; font-weight: 800; }

/* Session Activity Log Modal */
.session-log-summary {
  background: var(--bg-page); border: 1.5px solid var(--card-border); border-radius: 10px;
  padding: 8px 12px; font-size: 0.84rem; font-weight: 800; margin-bottom: 10px;
}
.session-log-list {
  max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; padding-right: 2px;
}
.log-entry-row {
  background: var(--bg-page); border: 1.5px solid var(--card-border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 8px 11px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.log-entry-row.log-ok { border-left-color: var(--status-ok); }
.log-entry-row.log-miss { border-left-color: var(--status-err); }
.log-entry-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.log-entry-top { font-size: 0.72rem; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.log-kind-pill { font-weight: 900; color: var(--text-main); }
.log-entry-expr { font-family: var(--font-mono); font-size: 0.86rem; word-break: break-word; }
.log-entry-detail { font-size: 0.76rem; color: var(--text-muted); }
.log-replay-btn { flex-shrink: 0; font-size: 0.76rem; }

@media (max-width: 560px) {
  .board-tabs { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 2px; }
  .board-tab { padding: 5px 2px; min-height: 33px; font-size: 0.72rem; text-align: center; white-space: nowrap; }
  .tab-long { display: none; }
}


/* ============================================================================
   v1.4.1 ACTIVE BUTTON HIGHLIGHT & LAB RANK PROGRESSION STRIP
   ============================================================================ */
.mini-ghost-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.lab-rank-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.8rem;
}

.lab-rank-badge {
  font-weight: 900;
  color: var(--text-main);
}

.lab-rank-next {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-muted);
}


/* ============================================================================
   v1.5 MOBILE COMPACT + HIDE KEYS, GRAPHER INTEGRAL/CROSSINGS, PLUG-IN SOLVERS & PRINT
   ============================================================================ */
.casing-trim-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mobile-keys-toggle {
  display: none;
  background: rgba(128, 128, 128, 0.18);
  color: var(--casing-label);
  border: 1.5px solid currentColor;
  border-radius: 999px;
  padding: 2px 9px;
  min-height: 28px;
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  white-space: nowrap;
}

.calc-casing.calc-keys-collapsed .sci-deck,
.calc-casing.calc-keys-collapsed .num-pad {
  display: none;
}

.calc-casing.calc-keys-collapsed .calc-screen {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .mobile-keys-toggle {
    display: inline-flex;
    align-items: center;
  }
}

@media (max-width: 680px) {
  .calc-casing {
    padding: 9px 10px 10px;
  }
  .casing-top-trim {
    margin-bottom: 5px;
  }
  .calc-screen {
    padding: 6px 10px 7px;
    margin-bottom: 7px;
  }
  .expr-display {
    font-size: 0.76rem;
    min-height: 16px;
  }
  .main-display {
    font-size: 1.55rem;
  }
  .sci-deck {
    gap: 4px;
    margin-bottom: 6px;
  }
  .num-pad {
    gap: 5px;
  }
  .key-fn {
    padding: 4px 2px;
    min-height: 36px;
    font-size: 0.78rem;
  }
  .key {
    padding: 6px 4px;
    min-height: 40px;
    font-size: 1.02rem;
  }
}

/* Grapher Integral Shading & Intersection Markers */
.graph-integral-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.integral-check-lbl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 900;
  cursor: pointer;
}

.integral-bounds-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-weight: 800;
}

.integral-bound-input {
  width: 64px;
  min-height: 32px;
  padding: 3px 6px;
  border-radius: 7px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
}

.integral-readout {
  color: var(--status-ok);
  font-weight: 900;
}

.g-integral-fill {
  fill: var(--graph-c0);
  fill-opacity: 0.2;
  stroke: var(--graph-c0);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.g-cross-ring {
  fill: var(--bg-card);
  stroke: var(--accent);
  stroke-width: 2.5;
}

.g-cross-core {
  fill: var(--accent);
}

.g-pill-cross {
  border-left: 4px solid var(--accent);
}

.g-pill-int {
  border-left: 4px solid var(--status-ok);
}

/* Interactive Plug-In Formula Solvers */
.solver-toggle-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  padding: 5px 11px;
  min-height: 36px;
  font-size: 0.76rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.formula-solver-panel {
  margin-top: 8px;
  padding: 9px 10px;
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.solver-inputs-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.solver-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-muted);
  flex: 1;
  min-width: 68px;
}

.solver-input {
  width: 100%;
  min-height: 34px;
  padding: 4px 7px;
  border-radius: 7px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.84rem;
}

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

.solver-err-msg {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--status-err);
}

/* Printable Study Sheet */
.sci-print-sheet {
  display: none;
}

@media print {
  body {
    background: #ffffff !important;
    background-image: none !important;
    color: #000000 !important;
    padding: 12px !important;
  }
  .top-bar, .beta-free-banner, .skin-bar, .workspace, .sibling-promo-bar, .app-footer, .modal-backdrop {
    display: none !important;
  }
  .sci-print-sheet {
    display: block !important;
    font-family: "CalcClue Sans", system-ui, sans-serif;
    color: #000000;
  }
  .print-sheet-head h1 { font-size: 1.35rem; margin-bottom: 4px; }
  .print-sheet-head p  { font-size: 0.88rem; margin-bottom: 12px; color: #333333; }
  .print-sheet-table   { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
  .print-sheet-table th, .print-sheet-table td { border: 1px solid #888888; padding: 6px 8px; text-align: left; }
  .print-sheet-table th { background: #f1f5f9; }
  .print-sheet-foot { margin-top: 14px; font-size: 0.78rem; color: #444444; }
}

.step-card a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
}


/* v1.5.2 Collapsible Smart Voice Picker Bar */
#voice-panel-btn[aria-expanded="true"] {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.voice-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-radius: 12px;
  padding: 8px 10px;
}

.voice-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-main);
  flex: 1;
  min-width: 170px;
}

.voice-rate-field {
  flex: 0 1 auto;
  min-width: 125px;
}

.voice-field select {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--card-border);
  background: var(--bg-card);
  color: var(--text-main);
  padding: 3px 8px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 800;
}


/* ============================================================================
   v1.6 DISTINCT PHYSICAL CALCULATOR BODY SHAPES (data-calc-shape)
   ============================================================================ */
body[data-calc-shape="ocean"] .calc-casing,
.studio-preview-stage[data-calc-shape="ocean"] .mini-sci-calc {
  border-radius: 30px 30px 26px 26px;
  border: 4px solid var(--casing-border);
  border-bottom-width: 11px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.16), 0 18px 34px rgba(8, 51, 68, 0.28);
}

body[data-calc-shape="ocean"] .calc-screen {
  border-radius: 18px;
  box-shadow: inset 0 3px 10px rgba(8, 51, 68, 0.22);
}

body[data-calc-shape="wedge"] .calc-casing,
.studio-preview-stage[data-calc-shape="wedge"] .mini-sci-calc {
  border-radius: 10px 10px 22px 22px;
  border: 3px solid var(--casing-border);
  border-top: 8px solid rgba(255, 255, 255, 0.24);
  border-bottom-width: 12px;
}

body[data-calc-shape="cyber"] .calc-casing,
.studio-preview-stage[data-calc-shape="cyber"] .mini-sci-calc {
  border-radius: 6px;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 16px, 100% calc(100% - 16px), calc(100% - 16px) 100%, 16px 100%, 0 calc(100% - 16px), 0 16px);
  border: 2px solid var(--accent);
  border-bottom-width: 7px;
  box-shadow: inset 0 0 18px rgba(56, 189, 248, 0.34);
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.35));
}

body[data-calc-shape="slim"] .calc-casing,
.studio-preview-stage[data-calc-shape="slim"] .mini-sci-calc {
  border-radius: 12px;
  border: 2px solid var(--casing-border);
  border-bottom-width: 5px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

body[data-calc-shape="pocket"] .calc-casing,
.studio-preview-stage[data-calc-shape="pocket"] .mini-sci-calc {
  border-radius: 26px;
  border: 3px solid var(--casing-border);
  border-bottom-width: 9px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.14), 0 16px 30px rgba(0, 0, 0, 0.24);
}


/* v1.7.1 Color-Coded LCD (scoped to .calc-screen) + Clue Board Ladder/Templates (scoped to data-page-tone) */
body[data-screen-tone="light"] .calc-screen {
  --eq-op-hi: #991b1b; --eq-op-lo: #92400e; --eq-fn: #6d28d9;
  --eq-var: #115e59; --eq-const: #1d4ed8;
  --eq-p0: #1d4ed8; --eq-p1: #065f46; --eq-p2: #9d174d; --eq-p-err: #991b1b;
}
body[data-screen-tone="dark"] .calc-screen {
  --eq-op-hi: #fb7185; --eq-op-lo: #fbbf24; --eq-fn: #c4b5fd;
  --eq-var: #5eead4; --eq-const: #7dd3fc;
  --eq-p0: #38bdf8; --eq-p1: #34d399; --eq-p2: #f472b6; --eq-p-err: #fca5a5;
}
body[data-page-tone="light"] .clue-board {
  --eq-op-hi: #991b1b; --eq-op-lo: #92400e; --eq-fn: #6d28d9;
  --eq-var: #115e59; --eq-const: #1d4ed8;
  --eq-p0: #1d4ed8; --eq-p1: #065f46; --eq-p2: #9d174d; --eq-p-err: #991b1b;
}
body[data-page-tone="dark"] .clue-board {
  --eq-op-hi: #fb7185; --eq-op-lo: #fbbf24; --eq-fn: #c4b5fd;
  --eq-var: #5eead4; --eq-const: #7dd3fc;
  --eq-p0: #38bdf8; --eq-p1: #34d399; --eq-p2: #f472b6; --eq-p-err: #fca5a5;
}
.eq-op-hi { color: var(--eq-op-hi); font-weight: 900; }
.eq-op-lo { color: var(--eq-op-lo); font-weight: 900; }
.eq-fn    { color: var(--eq-fn);    font-weight: 900; }
.eq-var   { color: var(--eq-var);   font-weight: 900; font-style: italic; }
.eq-const { color: var(--eq-const); font-weight: 900; }
.eq-p0    { color: var(--eq-p0);    font-weight: 900; }
.eq-p1    { color: var(--eq-p1);    font-weight: 900; }
.eq-p2    { color: var(--eq-p2);    font-weight: 900; }
.eq-p-err { color: var(--eq-p-err); font-weight: 900; text-decoration: underline wavy; }

:root, body[data-page-tone="light"] { --slot-a: #1d4ed8; --slot-b: #b91c1c; --slot-c: #047857; --slot-d: #6d28d9; }
body[data-page-tone="dark"] { --slot-a: #38bdf8; --slot-b: #fb7185; --slot-c: #34d399; --slot-d: #c4b5fd; }

.sibling-promo-link-beta {
  background: #047857;
  color: #ffffff;
}

.templates-stage { display: flex; flex-direction: column; gap: 12px; }
.tpl-picker-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 7px; }
.tpl-pick-btn { background: var(--bg-page); color: var(--text-main); border: 1.5px solid var(--card-border); border-radius: 12px; padding: 8px 10px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font-family: inherit; }
.tpl-pick-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tpl-pick-badge { font-size: 0.65rem; font-weight: 900; letter-spacing: 0.08em; opacity: 0.82; }
.tpl-pick-btn strong { font-size: 0.84rem; font-weight: 900; }
.tpl-card { background: var(--bg-page); border: 1.5px solid var(--card-border); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.tpl-card-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 4px; }
.tpl-card-head h3 { font-size: 1.02rem; font-weight: 900; margin: 0; }
.tpl-card-tools { display: flex; gap: 5px; flex-wrap: wrap; }
.tpl-mini-btn { background: var(--bg-card); color: var(--text-main); border: 1.5px solid var(--card-border); border-radius: 999px; padding: 3px 9px; min-height: 30px; font-family: inherit; font-size: 0.74rem; font-weight: 800; cursor: pointer; }
.tpl-mini-btn:hover { border-color: var(--accent); }
.tpl-mini-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tpl-blueprint-bar { background: var(--bg-card); border: 2px dashed var(--card-border); border-radius: 12px; padding: 9px 12px; display: flex; flex-direction: column; gap: 4px; overflow-x: auto; }
.tpl-stage-kicker { font-size: 0.65rem; font-weight: 900; letter-spacing: 0.08em; color: var(--text-muted); text-transform: uppercase; }
.tpl-blueprint-main { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.04rem; font-weight: 900; }
.tpl-blueprint-sub { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.84rem; font-weight: 700; color: var(--text-muted); }
.tpl-tok-blank { border-style: dashed; opacity: 0.92; }
.tpl-inputs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.tpl-field { background: var(--bg-card); border: 2px solid var(--card-border); border-left-width: 6px; border-radius: 12px; padding: 7px 9px; display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; font-weight: 900; }
.tpl-field.slot-a { border-left-color: var(--slot-a); color: var(--slot-a); }
.tpl-field.slot-b { border-left-color: var(--slot-b); color: var(--slot-b); }
.tpl-field.slot-c { border-left-color: var(--slot-c); color: var(--slot-c); }
.tpl-field.slot-d { border-left-color: var(--slot-d); color: var(--slot-d); }
.tpl-input { width: 100%; min-height: 34px; border-radius: 8px; border: 1.5px solid var(--card-border); background: var(--bg-page); color: var(--text-main); padding: 4px 8px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.96rem; font-weight: 900; }
.tpl-formula-stage { background: var(--bg-card); border: 1.5px solid var(--card-border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; overflow-x: auto; }
.tpl-eq-main { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 1.04rem; font-weight: 900; }
.tpl-eq-sub { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.86rem; color: var(--text-muted); font-weight: 700; }
.tpl-tok { display: inline-block; padding: 0 5px; border-radius: 6px; font-weight: 900; border: 1.5px solid currentColor; }
.tpl-tok.slot-a { color: var(--slot-a); } .tpl-tok.slot-b { color: var(--slot-b); } .tpl-tok.slot-c { color: var(--slot-c); } .tpl-tok.slot-d { color: var(--slot-d); }
.tpl-lamp { border-radius: 12px; padding: 10px 12px; border: 2px solid var(--card-border); display: flex; flex-direction: column; gap: 3px; font-size: 0.86rem; background: var(--bg-card); }
.tpl-lamp-ok { border-color: var(--status-ok); color: var(--status-ok); }
.tpl-lamp-warn { border-color: var(--status-warn); color: var(--status-warn); }
.tpl-lamp-err { border-color: var(--status-err); color: var(--status-err); }
.tpl-actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tpl-action-btn { background: var(--accent); color: var(--accent-text); border: none; border-radius: 10px; padding: 8px 14px; min-height: 38px; font-family: inherit; font-size: 0.84rem; font-weight: 900; cursor: pointer; }

.g-ghost-curve { fill: none; stroke: var(--text-muted); stroke-width: 2.2; stroke-dasharray: 6 5; opacity: 0.72; }
.shift-lab-box { background: var(--bg-page); border: 1.5px solid var(--card-border); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.shift-lab-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.shift-lab-hint { font-size: 0.78rem; color: var(--text-muted); font-weight: 700; }
.shift-lab-body { display: flex; flex-direction: column; gap: 10px; }
.shift-controls-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.shift-parent-lbl { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 900; }
.shift-parent-lbl select { min-height: 34px; border-radius: 8px; border: 1.5px solid var(--card-border); background: var(--bg-card); color: var(--text-main); padding: 3px 8px; font-family: inherit; font-weight: 800; font-size: 0.82rem; }
.shift-sliders-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.shift-slider-field { background: var(--bg-card); border: 1.5px solid var(--card-border); border-left-width: 5px; border-radius: 10px; padding: 7px 9px; display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem; font-weight: 800; }
.shift-slider-field.slot-a { border-left-color: var(--slot-a); } .shift-slider-field.slot-b { border-left-color: var(--slot-b); } .shift-slider-field.slot-c { border-left-color: var(--slot-c); }
.shift-explain-card { background: var(--bg-card); border: 1.5px solid var(--accent); border-radius: 10px; padding: 9px 11px; font-size: 0.84rem; line-height: 1.45; }
.shift-compare-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; background: var(--bg-card); border-radius: 10px; overflow: hidden; border: 1px solid var(--card-border); }
.shift-compare-table th, .shift-compare-table td { padding: 5px 8px; border-bottom: 1px solid var(--card-border); text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.shift-arrow-cell { font-weight: 900; color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

.sibling-promo-link-arcade { background: #6d28d9; color: #ffffff; }

/* Wave 6 (v1.8.4) — Ready Offline Pill */
.offline-pill {
  font-size: 0.74rem;
  font-weight: 900;
  background: #ecfdf5;
  color: #065f46;
  border: 1.5px solid #047857;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}


.skip-link {
  position: fixed;
  top: -80px;
  left: 12px;
  z-index: 9999;
  background: var(--accent, #0369a1);
  color: var(--accent-text, #ffffff);
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 900;
  font-size: 0.85rem;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
.skip-link:focus {
  top: 12px;
}

/* ============================================================================
   v1.8.9 MOBILE COMFORT, GRAPHER DECLUTTER & ZERO-BLOAT MICRO-GUIDES
   ============================================================================ */
.graph-extra-hidden {
  display: none !important;
}
.graph-quick-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.micro-guide-card {
  background: var(--bg-page);
  border: 1.5px solid var(--accent);
  border-left-width: 5px;
  border-radius: 11px;
  padding: 9px 12px;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text-main);
}
.micro-guide-card ul {
  margin: 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.micro-guide-card code {
  background: var(--bg-card);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.integral-bounds-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.integral-micro-hint {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
}
.graph-curve-clue {
  background: var(--bg-page);
  border: 1.5px solid var(--card-border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.38;
  color: var(--text-main);
}

@media (max-width: 680px) {
  .calc-casing { padding: 8px 9px 9px; }
  .calc-screen { padding: 5px 9px 6px; margin-bottom: 6px; }
  .main-display { font-size: 1.45rem; }
  .screen-mini-btn { min-height: 28px; padding: 2px 8px; font-size: 0.71rem; }
  .sci-deck { gap: 4px; margin-bottom: 5px; }
  .num-pad { gap: 4px; }
  .key-fn { min-height: 32px; padding: 3px 2px; font-size: 0.75rem; }
  .key { min-height: 36px; padding: 4px 3px; font-size: 0.96rem; }
  .clue-board { padding: 10px; gap: 8px; }
  .board-header { gap: 7px; }
  .board-actions { gap: 5px; }
  .board-actions .pill-btn {
    min-height: 32px;
    padding: 3px 9px;
    font-size: 0.74rem;
  }
  .top-bar .pill-btn {
    min-height: 34px;
    padding: 4px 10px;
    font-size: 0.75rem;
  }
  .graph-inputs { gap: 5px; }
  .graph-fn-row { padding: 3px 7px; gap: 6px; }
  .graph-fn-badge { font-size: 0.76rem; padding: 2px 7px; }
  .graph-fn-input { min-height: 34px; font-size: 0.88rem; }
  .graph-presets-row {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 5px;
    padding-bottom: 2px;
  }
  .preset-chip {
    flex-shrink: 0;
    min-height: 31px;
    padding: 3px 10px;
    font-size: 0.75rem;
  }
  .graph-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
  }
  .graph-toolbar .mini-ghost-btn {
    min-height: 32px;
    padding: 3px 8px;
    font-size: 0.76rem;
    flex-shrink: 0;
  }
  .graph-toolbar .tb-lbl { display: none; }
  .graph-quick-meta .mini-ghost-btn { min-height: 31px; padding: 3px 9px; font-size: 0.74rem; }
  .graph-integral-bar { padding: 6px 9px; gap: 6px; font-size: 0.78rem; }
  .graph-trace-bar { font-size: 0.76rem; padding: 6px 9px; min-height: 32px; }
  .graph-curve-clue { font-size: 0.76rem; padding: 6px 9px; }
  .tpl-picker-grid { grid-template-columns: repeat(2, 1fr); gap: 5px; }
  .tpl-pick-btn { padding: 6px 8px; }
  .tpl-pick-btn strong { font-size: 0.78rem; }
  .tpl-card { padding: 10px; gap: 9px; }
  .tpl-blueprint-main, .tpl-eq-main { font-size: 0.94rem; }
  .tpl-blueprint-sub, .tpl-eq-sub { font-size: 0.78rem; }
}
