/* ===== RESET & SHARED ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --radius-calc:  20px;
  --radius-btn:   8px;
  --transition:   0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ══════════════════════════════════════════════════════════
   THEME 1 — RETRO  (Classic 1980s LCD Calculator — default)
   Sci: dark navy      | Num: warm gray    | Op: brick red
   Eq: deep maroon     | Nav: slate        | AC/DEL: vivid red
   Body: aged cream ivory | Display: dark LCD green
   ══════════════════════════════════════════════════════════ */
:root, [data-theme="retro"] {
  /* Layout */
  --bg:           #E8E0CC;  --bg-mid:       #DDD5BE;
  --bg-light:     #EDE5D2;  --bg-card:      #D4C8A4;
  --bg-sidebar:   #D9D1BA;  --bg-header:    #CEC5AD;
  --calc-body:    #DDD4BC;  --calc-border:  #B8AE96;
  /* Display — dark LCD panel with authentic greenish crystal tint */
  --display-bg:   #090E08;  --display-text: #7EAA7A;
  /* Buttons */
  --btn-sci:      #1B2A40;  --btn-sci-h:    #243A54;   /* dark navy */
  --btn-num:      #525049;  --btn-num-h:    #636158;   /* warm charcoal */
  --btn-op:       #BC1E1E;  --btn-op-h:     #D02222;   /* brick red */
  --btn-eq:       #800000;  --btn-eq-h:     #960000;   /* deep maroon */
  --btn-nav:      #4A5262;  --btn-nav-h:    #5A6272;   /* slate */
  --btn-red:      #D01A00;  --btn-red-h:    #E82000;   /* vivid red */
  /* Text on buttons */
  --btn-sci-text: #C8D8F0;  /* cool light blue */
  --btn-num-text: #EAE6DE;  /* warm white */
  --btn-op-text:  #FFFFFF;
  --btn-eq-text:  #FFD8D8;  /* light blush */
  --btn-nav-text: #C8D4E8;
  --btn-red-text: #FFFFFF;
  /* Shadows — soft inset for aged plastic */
  --shadow-calc: 0 8px 28px rgba(0,0,0,0.15), 0 3px 8px rgba(0,0,0,0.10), 0 0 0 1px rgba(0,0,0,0.06);
  /* UI */
  --text:          #28251E;  --text-dim:     #6B6456;
  --text-sidebar:  #3A3628;  --border:       #C0B8A0;
  --sidebar-active:#BC1E1E;  --sidebar-act-t:#FFFFFF;
  --info-badge:    #BC1E1E;  --primary:      #BC1E1E;
  --accent:        #1B2A40;  --error:        #CC0000;
  --success:       #2E7A2E;
}

/* ══════════════════════════════════════════════════════════
   THEME 2 — DARK NEON  (#0F172A + #22C55E + #38BDF8)
   Sci: violet-purple  | Num: dark slate  | Op: neon green
   Eq: sky cyan        | Nav: deep blue   | AC/DEL: red
   ══════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  --bg:           #0F172A;  --bg-mid:       #070D1A;
  --bg-light:     #1E293B;  --bg-card:      #1A2540;
  --bg-sidebar:   #0D1424;  --bg-header:    #070D1A;
  --calc-body:    #1A2540;  --calc-border:  #0A1525;
  --display-bg:   #050C18;  --display-text: #38BDF8;
  /* Buttons */
  --btn-sci:      #6D28D9;  --btn-sci-h:    #7C3AED;   /* violet */
  --btn-num:      #1E3A5F;  --btn-num-h:    #254A70;   /* deep blue-slate */
  --btn-op:       #22C55E;  --btn-op-h:     #16A34A;   /* neon green */
  --btn-eq:       #38BDF8;  --btn-eq-h:     #0EA5E9;   /* sky cyan */
  --btn-nav:      #1E293B;  --btn-nav-h:    #263348;   /* dark slate */
  --btn-red:      #EF4444;  --btn-red-h:    #DC2626;   /* red */
  --btn-sci-text: #E9D5FF;
  --btn-num-text: #93C5FD;
  --btn-op-text:  #FFFFFF;
  --btn-eq-text:  #0F172A;
  --btn-nav-text: #94A3B8;
  --btn-red-text: #FFFFFF;
  --shadow-calc: 0 12px 40px rgba(0,0,0,0.7), 0 0 50px rgba(34,197,94,0.1), 0 0 50px rgba(56,189,248,0.08);
  --text:          #E2E8F0;  --text-dim:     #64748B;
  --text-sidebar:  #94A3B8;  --border:       #1E293B;
  --sidebar-active:#22C55E;  --sidebar-act-t:#0F172A;
  --info-badge:    #6D28D9;  --primary:      #38BDF8;
  --accent:        #22C55E;  --error:        #EF4444;
  --success:       #22C55E;
}

/* ══════════════════════════════════════════════════════════
   THEME 3 — SOFT PASTEL  (#F8FAFC + #A78BFA + #F472B6)
   Sci: deep indigo  | Num: light gray (dark text) | Op: lavender
   Eq: hot pink      | Nav: soft lilac              | AC/DEL: pink
   ══════════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg:           #F8FAFC;  --bg-mid:       #F1F5F9;
  --bg-light:     #FFFFFF;  --bg-card:      #EEF0F8;
  --bg-sidebar:   #F8FAFC;  --bg-header:    #FFFFFF;
  --calc-body:    #FFFFFF;  --calc-border:  #CBD5E1;
  --display-bg:   #EFF1FB;  --display-text: #1E1B4B;
  /* Buttons */
  --btn-sci:      #4F46E5;  --btn-sci-h:    #6D28D9;   /* deep indigo */
  --btn-num:      #DDE3EF;  --btn-num-h:    #C9D3E4;   /* soft gray */
  --btn-op:       #A78BFA;  --btn-op-h:     #9061F9;   /* lavender */
  --btn-eq:       #F472B6;  --btn-eq-h:     #EC4899;   /* hot pink */
  --btn-nav:      #C4B5FD;  --btn-nav-h:    #A78BFA;   /* lilac */
  --btn-red:      #FB7185;  --btn-red-h:    #F43F5E;   /* rose-red */
  --btn-sci-text: #FFFFFF;
  --btn-num-text: #1E1B4B;
  --btn-op-text:  #FFFFFF;
  --btn-eq-text:  #FFFFFF;
  --btn-nav-text: #4C1D95;
  --btn-red-text: #FFFFFF;
  --shadow-calc: 0 12px 40px rgba(167,139,250,0.25), 0 4px 16px rgba(244,114,182,0.15);
  --text:          #0F172A;  --text-dim:     #64748B;
  --text-sidebar:  #475569;  --border:       #E2E8F0;
  --sidebar-active:#F472B6;  --sidebar-act-t:#FFFFFF;
  --info-badge:    #4F46E5;  --primary:      #A78BFA;
  --accent:        #F472B6;  --error:        #F43F5E;
  --success:       #34D399;
}

/* ══════════════════════════════════════════════════════════
   THEME 4 — GLASSMORPHISM  (gradient + #FACC15)
   Reference image exact:
   Sci: deep indigo-blue | Num: frosted light blue | Op: medium glass
   Eq: yellow            | Nav: glass medium        | AC/DEL: red
   ══════════════════════════════════════════════════════════ */
[data-theme="ocean"] {
  --bg:           #2563EB;  --bg-mid:       #1D4ED8;
  --bg-light:     rgba(255,255,255,0.12);
  --bg-card:      rgba(255,255,255,0.13);
  --bg-sidebar:   rgba(37,99,235,0.3);
  --bg-header:    rgba(30,80,220,0.35);
  --calc-body:    rgba(255,255,255,0.15);
  --calc-border:  rgba(255,255,255,0.28);
  --display-bg:   rgba(0,0,30,0.28);
  --display-text: #FFFFFF;
  /* Buttons — matching the reference image */
  --btn-sci:      rgba(68,75,200,0.92);  --btn-sci-h:  rgba(82,90,220,0.98);  /* deep indigo */
  --btn-num:      rgba(119,158,216,0.48); --btn-num-h: rgba(130,168,225,0.62); /* light blue glass */
  --btn-op:       rgba(100,138,210,0.60); --btn-op-h:  rgba(112,150,220,0.75); /* medium glass */
  --btn-eq:       #FACC15;               --btn-eq-h:  #EAB308;                /* yellow */
  --btn-nav:      rgba(90,125,200,0.45); --btn-nav-h: rgba(105,140,215,0.60); /* soft glass */
  --btn-red:      rgba(220,60,60,0.88);  --btn-red-h: rgba(235,50,50,0.96);   /* red */
  --btn-sci-text: #FFFFFF;
  --btn-num-text: #FFFFFF;
  --btn-op-text:  #FFFFFF;
  --btn-eq-text:  #1E1B00;
  --btn-nav-text: #FFFFFF;
  --btn-red-text: #FFFFFF;
  --shadow-calc: 0 16px 48px rgba(0,0,0,0.3), 0 0 0 1px rgba(255,255,255,0.22);
  --text:          #FFFFFF;  --text-dim:     rgba(255,255,255,0.65);
  --text-sidebar:  rgba(255,255,255,0.85); --border: rgba(255,255,255,0.22);
  --sidebar-active:#FACC15;  --sidebar-act-t:#1A1500;
  --info-badge:    #FACC15;  --primary:      #FACC15;
  --accent:        rgba(220,60,60,0.9); --error: #EF4444;
  --success:       #34D399;
}

/* ══════════════════════════════════════════════════════════
   THEME 5 — RETRO DIGITAL  (#1A1A1A + #FF9500 + #00FFAA)
   Sci: deep purple  | Num: charcoal (mono) | Op: orange
   Eq: neon green    | Nav: mid-gray        | AC/DEL: amber-red
   ══════════════════════════════════════════════════════════ */
[data-theme="forest"] {
  --bg:           #141414;  --bg-mid:       #0C0C0C;
  --bg-light:     #1E1E1E;  --bg-card:      #222222;
  --bg-sidebar:   #111111;  --bg-header:    #0A0A0A;
  --calc-body:    #1C1C1C;  --calc-border:  #050505;
  --display-bg:   #050505;  --display-text: #00FFAA;
  /* Buttons */
  --btn-sci:      #5B21B6;  --btn-sci-h:    #6D28D9;   /* deep purple */
  --btn-num:      #252525;  --btn-num-h:    #2E2E2E;   /* dark charcoal */
  --btn-op:       #C07000;  --btn-op-h:     #E08000;   /* burnt orange */
  --btn-eq:       #00FFAA;  --btn-eq-h:     #00E69A;   /* neon green */
  --btn-nav:      #333333;  --btn-nav-h:    #404040;   /* mid-gray */
  --btn-red:      #FF6B00;  --btn-red-h:    #FF7C00;   /* amber-orange */
  --btn-sci-text: #DDD6FE;
  --btn-num-text: #A0A0A0;
  --btn-op-text:  #FFFFFF;
  --btn-eq-text:  #002A1A;
  --btn-nav-text: #808080;
  --btn-red-text: #FFFFFF;
  --shadow-calc: 0 12px 48px rgba(0,0,0,0.85), 0 0 30px rgba(255,149,0,0.08), 0 0 60px rgba(0,255,170,0.06);
  --text:          #D0D0D0;  --text-dim:     #606060;
  --text-sidebar:  #A0A0A0;  --border:       #282828;
  --sidebar-active:#FF9500;  --sidebar-act-t:#1A0800;
  --info-badge:    #5B21B6;  --primary:      #FF9500;
  --accent:        #00FFAA;  --error:        #FF4444;
  --success:       #00FFAA;
}

/* ══════════════════════════════════════════════════════════
   THEME 6 — CUSTOM  (fully user-defined via JS inline vars)
   Fallback defaults mirror the Warm Casio theme.
   ══════════════════════════════════════════════════════════ */
[data-theme="custom"] {
  --bg:           var(--custom-bg,           #2C2217);
  --bg-mid:       var(--custom-bg,           #231B12);
  --bg-light:     var(--custom-card,         #3A2E22);
  --bg-card:      var(--custom-card,         #3A2E22);
  --bg-sidebar:   var(--custom-bg,           #2C2217);
  --bg-header:    var(--custom-bg,           #251D14);
  --calc-body:    var(--custom-card,         #3A2E22);
  --calc-border:  var(--custom-border,       #5A4A35);
  --display-bg:   var(--custom-display,      #1A1208);
  --display-text: var(--custom-primary,      #D4A853);
  --btn-sci:      color-mix(in srgb, var(--custom-primary, #D4A853) 40%, #1a1a1a);
  --btn-sci-h:    color-mix(in srgb, var(--custom-primary, #D4A853) 55%, #1a1a1a);
  --btn-num:      color-mix(in srgb, var(--custom-card, #3A2E22) 80%, #000);
  --btn-num-h:    color-mix(in srgb, var(--custom-card, #3A2E22) 90%, #555);
  --btn-op:       var(--custom-accent,       #E8845A);
  --btn-op-h:     color-mix(in srgb, var(--custom-accent, #E8845A) 80%, #fff);
  --btn-eq:       var(--custom-primary,      #D4A853);
  --btn-eq-h:     color-mix(in srgb, var(--custom-primary, #D4A853) 85%, #fff);
  --btn-nav:      color-mix(in srgb, var(--custom-card, #3A2E22) 70%, #888);
  --btn-nav-h:    color-mix(in srgb, var(--custom-card, #3A2E22) 85%, #888);
  --btn-red:      #C0392B;  --btn-red-h:    #E74C3C;
  --btn-sci-text: var(--custom-primary, #D4A853);
  --btn-num-text: var(--custom-text,    #F5ECD7);
  --btn-op-text:  #fff;
  --btn-eq-text:  #1a1208;
  --btn-nav-text: var(--custom-text,   #F5ECD7);
  --btn-red-text: #fff;
  --shadow-calc:  0 8px 32px rgba(0,0,0,0.55);
  --text:         var(--custom-text,         #F5ECD7);
  --text-dim:     color-mix(in srgb, var(--custom-text, #F5ECD7) 55%, transparent);
  --text-sidebar: color-mix(in srgb, var(--custom-text, #F5ECD7) 75%, transparent);
  --border:       var(--custom-border,       #5A4A35);
  --sidebar-active: var(--custom-primary,    #D4A853);
  --sidebar-act-t:  #1A1208;
  --info-badge:   var(--custom-accent,       #E8845A);
  --primary:      var(--custom-primary,      #D4A853);
  --accent:       var(--custom-accent,       #E8845A);
  --error:        #E74C3C; --success: #27AE60;
}

/* ======= BASE BODY ======= */
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

/* Glassmorphism gradient background */
[data-theme="ocean"] body {
  background: linear-gradient(135deg, #1D4ED8 0%, #4F46E5 50%, #7C3AED 100%) fixed;
}

/* Retro: scanline on display */
[data-theme="forest"] .casio-display { position: relative; overflow: hidden; }
[data-theme="forest"] .casio-display::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,255,170,0.03) 3px, rgba(0,255,170,0.03) 4px);
  pointer-events: none;
}

/* Neon text glows */
[data-theme="dark"] .display-single,
[data-theme="dark"] .display-result-value,
[data-theme="dark"] .display-field-value {
  text-shadow: 0 0 10px rgba(56,189,248,0.7), 0 0 24px rgba(56,189,248,0.3);
}
[data-theme="forest"] .display-single,
[data-theme="forest"] .display-result-value,
[data-theme="forest"] .display-field-value {
  text-shadow: 0 0 8px rgba(0,255,170,0.9), 0 0 20px rgba(0,255,170,0.45);
  font-family: 'Courier New', monospace;
  letter-spacing: 0.05em;
}

/* Retro: authentic LCD crystal look — monospace, soft green glow */
[data-theme="retro"] .display-single,
[data-theme="retro"] .display-result-value,
[data-theme="retro"] .display-field-value {
  font-family: 'Courier New', monospace;
  letter-spacing: 0.07em;
  text-shadow: 0 0 4px rgba(126,170,122,0.55), 0 0 12px rgba(126,170,122,0.22);
}

/* ======= SKIP NAV ======= */
.skip-nav {
  position: absolute; top: -100%; left: 1rem;
  background: var(--accent); color: #fff;
  padding: 0.5rem 1rem; border-radius: 0 0 8px 8px;
  font-size: 0.875rem; font-weight: 600; z-index: 9999; text-decoration: none;
}
.skip-nav:focus { top: 0; }

/* ======= HEADER ======= */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; height: 56px;
  background: var(--bg-header); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  transition: background var(--transition), border-color var(--transition);
}
[data-theme="ocean"] .site-header {
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom-color: rgba(255,255,255,0.15);
}

.header-logo {
  display: flex; align-items: center; gap: 0.625rem;
  cursor: pointer; font-family: var(--font-display);
  font-size: clamp(0.9rem, 1.8vw, 1.125rem); font-weight: 700; color: var(--text);
  border-radius: 6px; padding: 0.25rem 0.5rem;
  white-space: nowrap; flex-shrink: 0;
  transition: opacity var(--transition);
}
.header-logo:hover { opacity: 0.8; }
.header-logo:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.logo-img  { height: 32px; width: auto; flex-shrink: 0; display: block; }
.logo-text { white-space: nowrap; }
.header-controls { display: flex; align-items: center; gap: 0.75rem; }

/* ── 5 theme swatches ── */
.theme-toggle {
  display: flex; align-items: center; gap: 6px;
  background: rgba(128,128,128,0.15); border-radius: 30px; padding: 5px 10px;
}
.theme-btn {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid transparent; cursor: pointer;
  transition: all var(--transition); flex-shrink: 0; outline: none;
}
.theme-btn[data-theme="retro"]  { background: #E8E0CC; border-color: rgba(168,152,112,0.8); }
.theme-btn[data-theme="dark"]   { background: #0F172A; border-color: rgba(56,189,248,0.5); }
.theme-btn[data-theme="light"]  { background: #F8FAFC; border-color: rgba(167,139,250,0.6); }
.theme-btn[data-theme="ocean"]  { background: linear-gradient(135deg, #2563EB, #7C3AED); }
.theme-btn[data-theme="forest"] { background: #141414; border-color: rgba(255,149,0,0.6); }
.theme-btn.active {
  border-color: #fff;
  box-shadow: 0 0 0 2.5px rgba(0,0,0,0.5), 0 0 0 4px rgba(255,255,255,0.85);
  transform: scale(1.35);
}
.theme-btn:hover:not(.active) { transform: scale(1.18); opacity: 0.9; }
.theme-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }

/* Custom theme swatch — rainbow gradient */
.theme-btn--custom {
  background: conic-gradient(#f87171, #fb923c, #facc15, #4ade80, #38bdf8, #818cf8, #f87171);
  display: flex; align-items: center; justify-content: center;
  color: #fff; border-color: rgba(255,255,255,0.3);
}
.theme-btn--custom svg { filter: drop-shadow(0 0 1px rgba(0,0,0,0.8)); }
[data-theme="custom"] .theme-btn--custom {
  border-color: #fff;
  box-shadow: 0 0 0 2.5px rgba(0,0,0,0.5), 0 0 0 4px rgba(255,255,255,0.85);
}

/* ════════════════════════════
   THEME CUSTOMIZER PANEL
   ════════════════════════════ */
.tcp {
  position: fixed; top: 60px; right: 0.75rem; z-index: 500;
  width: 280px; border-radius: 14px;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: 0 16px 48px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.25);
  animation: tcpSlideIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
  overflow: hidden;
}
.tcp[hidden] { display: none; }
@keyframes tcpSlideIn {
  from { opacity: 0; transform: translateY(-12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
.tcp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
}
.tcp-title {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; color: var(--text);
}
.tcp-close {
  width: 26px; height: 26px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; border-radius: 6px;
  font-size: 0.85rem; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.tcp-close:hover { background: rgba(128,128,128,0.2); color: var(--text); }

/* Presets */
.tcp-presets {
  display: flex; gap: 0.4rem; padding: 0.6rem 1rem; border-bottom: 1px solid var(--border);
}
.tcp-preset {
  flex: 1; border: none; background: var(--bg); border-radius: 8px;
  font-size: 1rem; cursor: pointer; padding: 0.3rem 0;
  transition: transform 0.15s, box-shadow 0.15s; border: 1px solid var(--border);
}
.tcp-preset:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.tcp-preset:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Color rows */
.tcp-body { padding: 0.5rem 1rem; display: flex; flex-direction: column; gap: 0.4rem; }
.tcp-row {
  display: flex; align-items: center; justify-content: space-between;
}
.tcp-label { font-size: 0.7rem; font-weight: 500; color: var(--text-dim); flex: 1; }
.tcp-color-wrap { display: flex; align-items: center; gap: 0.4rem; }
.tcp-color {
  width: 30px; height: 30px; border: 2px solid var(--border); border-radius: 8px;
  cursor: pointer; background: none; padding: 0;
  transition: border-color 0.15s, transform 0.15s;
  -webkit-appearance: none;
}
.tcp-color::-webkit-color-swatch-wrapper { padding: 0; border-radius: 6px; }
.tcp-color::-webkit-color-swatch { border: none; border-radius: 6px; }
.tcp-color:hover { border-color: var(--primary); transform: scale(1.1); }
.tcp-color:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.tcp-hex {
  font-size: 0.62rem; font-family: 'Courier New', monospace;
  color: var(--text-dim); min-width: 52px; letter-spacing: 0.03em;
}

/* Footer */
.tcp-footer {
  display: flex; gap: 0.5rem; padding: 0.65rem 1rem;
  border-top: 1px solid var(--border);
}
.tcp-btn {
  flex: 1; padding: 0.4rem; border-radius: 8px; border: 1px solid var(--border);
  font-size: 0.72rem; font-weight: 600; cursor: pointer; transition: all var(--transition);
}
.tcp-reset { background: transparent; color: var(--text-dim); }
.tcp-reset:hover { background: rgba(128,128,128,0.15); color: var(--text); }
.tcp-save  { background: var(--primary); color: #fff; border-color: var(--primary); }
.tcp-save:hover { filter: brightness(1.15); }
.tcp-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (max-width: 480px) {
  .tcp { width: calc(100vw - 1.5rem); right: 0.75rem; }
}

.header-divider { width: 1px; height: 24px; background: var(--border); }

/* Hamburger — hidden by default, shown on mobile in calc view */
.hamburger-btn {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; border-radius: 8px;
  transition: all var(--transition);
}
.hamburger-btn:hover { background: rgba(128,128,128,0.15); color: var(--text); }
.hamburger-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.sound-btn {
  width: 36px; height: 36px; border: none; background: transparent;
  cursor: pointer; color: var(--text-dim); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; line-height: 1;
  transition: all var(--transition);
}
.sound-btn[data-sound="on"]  { color: var(--primary); }
.sound-btn[data-sound="off"] { color: var(--text-dim); opacity: 0.55; }
.sound-btn:hover { color: var(--text); background: rgba(128,128,128,0.15); opacity: 1; }
.sound-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ======= VIEWS ======= */
.view { display: none; }
.view.active { display: block; }

/* ════════════════════════════
   HOME — fits one screen
   ════════════════════════════ */
.home-wrapper {
  display: flex; flex-direction: column;
  height: calc(100vh - 56px); overflow: hidden;
}
.home-content {
  flex: 1; max-width: 1200px; width: 100%;
  margin: 0 auto; padding: 1.25rem 2.5rem 0.75rem;
  display: flex; flex-direction: column; gap: 0.875rem;
}
.home-title-block { text-align: center; }
.home-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  font-weight: 900; color: var(--text);
  letter-spacing: -0.02em; line-height: 1.1;
}
.home-subtitle {
  font-size: 0.6875rem; font-weight: 600;
  letter-spacing: 0.2em; color: var(--text-dim); margin-top: 0.25rem;
}

/* Stats bar */
.home-stats {
  display: flex; align-items: center; justify-content: center;
  gap: 0.75rem; flex-wrap: wrap;
  margin: -0.25rem 0 0.25rem;
}
.stat-item {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  line-height: 1.1;
}
.stat-item strong {
  font-size: 1.05rem; font-weight: 800; color: var(--text);
  font-family: var(--font-display);
}
.stat-item span {
  font-size: 0.55rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-dim);
}
.stat-sep { color: var(--text-dim); opacity: 0.4; font-size: 0.85rem; }

.categories-top { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.cat-label {
  font-size: 0.75rem; font-weight: 700; color: var(--text);
  margin-bottom: 0.5rem; padding-left: 0.6rem;
  border-left: 3px solid var(--cat-accent, var(--primary));
  letter-spacing: 0.04em;
}
/* Per-category accent colors */
#cat-general { --cat-accent: #3B82F6; }   /* blue — math */
#cat-health  { --cat-accent: #22C55E; }   /* green — health */
#cat-finance { --cat-accent: #F59E0B; }   /* amber — finance */

.cat-divider { height: 1px; background: var(--border); margin-bottom: 0.625rem; }
.instrument-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.instrument-grid--wide { grid-template-columns: repeat(5, 1fr); gap: 0.5rem; }

.instrument-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.5rem; padding: 0.875rem 0.5rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
  transition: all var(--transition); color: var(--text-dim); min-height: 82px;
}
.instrument-card:hover {
  background: var(--bg-mid); color: var(--text);
  transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.instrument-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.inst-icon { display: flex; align-items: center; justify-content: center; }
.inst-icon svg { width: 24px; height: 24px; }
.inst-label { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.1em; color: inherit; text-align: center; }
.inst-desc  { font-size: 0.56rem; font-weight: 400; color: var(--text-dim); text-align: center; opacity: 0.75; line-height: 1.2; margin-top: -0.25rem; }
.instrument-card:hover .inst-desc { opacity: 1; }

/* Theme-specific card hover effects */
[data-theme="ocean"] .instrument-card { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-color: rgba(255,255,255,0.2); }
[data-theme="ocean"] .instrument-card:hover { background: rgba(255,255,255,0.22); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
[data-theme="dark"] .instrument-card:hover { border-color: #38BDF8; box-shadow: 0 4px 16px rgba(56,189,248,0.15); }
[data-theme="light"] .instrument-card:hover { border-color: #F472B6; box-shadow: 0 4px 16px rgba(244,114,182,0.2); }
[data-theme="forest"] .instrument-card:hover { border-color: #FF9500; box-shadow: 0 4px 16px rgba(255,149,0,0.15); }

.home-footer {
  max-width: 1200px; width: 100%; margin: 0 auto;
  padding: 0.625rem 2.5rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem; flex-shrink: 0;
}
.footer-copy { font-size: 0.75rem; color: var(--text-dim); }
.footer-links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.footer-links a { font-size: 0.75rem; color: var(--text-dim); text-decoration: none; transition: color var(--transition); }
.footer-links a:hover { color: var(--text); }
.footer-links a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 2px; }

/* ════════════════════════════
   CALCULATOR VIEW
   ════════════════════════════ */
#view-calc { display: none; height: calc(100vh - 56px); }
#view-calc.active { display: block; }
.calc-layout { display: grid; grid-template-columns: 220px 1fr 270px; height: 100%; }

/* Sidebar */
.sidebar {
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}
[data-theme="ocean"] .sidebar { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-right-color: rgba(255,255,255,0.15); }

.sidebar-nav {
  flex: 1; padding: 1rem 0.625rem 0.75rem; overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.sidebar-section-label {
  font-size: 0.625rem; font-weight: 700; letter-spacing: 0.14em;
  color: var(--text-dim); padding: 0 0.625rem; margin: 0.875rem 0 0.375rem;
}
.sidebar-section-label:first-child { margin-top: 0; }
.sidebar-divider { height: 1px; background: var(--border); margin: 0.625rem 0.375rem; opacity: 0.5; }

.sidebar-item {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.5rem 0.625rem; border: none; background: transparent;
  border-radius: 7px; cursor: pointer; font-size: 0.875rem;
  font-family: var(--font-body); color: var(--text-sidebar);
  text-align: left; transition: all var(--transition);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-item:hover { background: rgba(128,128,128,0.12); color: var(--text); }
.sidebar-item.active { background: var(--sidebar-active); color: var(--sidebar-act-t); }
.sidebar-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sidebar-icon { flex-shrink: 0; stroke: currentColor; }
[data-theme="dark"] .sidebar-item.active { box-shadow: 0 0 12px rgba(34,197,94,0.3); }
[data-theme="forest"] .sidebar-item.active { box-shadow: 0 0 10px rgba(255,149,0,0.25); }
[data-theme="ocean"] .sidebar-item.active { box-shadow: 0 0 12px rgba(250,204,21,0.35); }

.sidebar-footer {
  padding: 0.75rem 1rem 1rem; display: flex; flex-direction: column;
  gap: 0.3rem; border-top: 1px solid var(--border); flex-shrink: 0;
}
.sidebar-footer a { font-size: 0.75rem; color: var(--text-dim); text-decoration: none; transition: color var(--transition); }
.sidebar-footer a:hover { color: var(--text); }

/* Center + info */
.calc-center {
  display: flex; flex-direction: column; align-items: center;
  padding: 2.5rem 2rem; overflow-y: auto; height: 100%;
  transition: background var(--transition);
}
/* Steps toggle + panel sit below the calculator, not beside it */
.steps-toggle { align-self: stretch; }
.steps-panel  { align-self: stretch; }
.info-panel {
  background: var(--bg-light); border-left: 1px solid var(--border);
  padding: 1.75rem 1.25rem; overflow-y: auto; height: 100%;
  transition: background var(--transition), border-color var(--transition);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.info-panel::-webkit-scrollbar { width: 4px; }
.info-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
[data-theme="ocean"] .info-panel { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-left-color: rgba(255,255,255,0.15); }

.info-badge {
  display: inline-flex; align-items: center; background: var(--info-badge);
  color: var(--sidebar-act-t, #fff); font-size: 0.625rem; font-weight: 700;
  letter-spacing: 0.1em; padding: 0.3rem 0.75rem; border-radius: 30px; margin-bottom: 1rem;
}
.info-title { font-family: var(--font-display); font-size: 1.375rem; font-weight: 700; color: var(--text); line-height: 1.2; margin-bottom: 0.5rem; }
.info-desc { font-size: 0.8125rem; color: var(--text-dim); line-height: 1.6; margin-bottom: 1.25rem; }
.info-divider { height: 1px; background: var(--border); margin-bottom: 0.875rem; }
.info-features-label { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.12em; color: var(--text-dim); margin-bottom: 0.625rem; }
.info-features { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.info-features li { font-size: 0.8125rem; color: var(--text-dim); display: flex; align-items: flex-start; gap: 0.5rem; line-height: 1.4; }
.info-features li::before { content: '•'; color: var(--primary); font-weight: 700; flex-shrink: 0; }
.info-result-box { margin-top: 1.25rem; background: var(--bg-card); border-radius: 10px; padding: 0.875rem; border: 1px solid var(--border); }
[data-theme="ocean"] .info-result-box { backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.info-result-box h3 { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.1em; color: var(--text-dim); margin-bottom: 0.5rem; }
.info-result-item { display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0; border-bottom: 1px solid var(--border); font-size: 0.8125rem; }
.info-result-item:last-child { border-bottom: none; }
.info-result-item .label { color: var(--text-dim); font-size: 0.75rem; }
.info-result-item .value { color: var(--text); font-weight: 600; font-family: 'Courier New', monospace; font-size: 0.8125rem; }

/* ═══════════════════════════════════
   STEPS PANEL (below keypad)
   ═══════════════════════════════════ */
.steps-toggle {
  display: none; /* shown by JS when result is ready */
  width: 100%; margin-top: 0.75rem;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.45rem 0.75rem;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em;
  color: var(--text-dim); cursor: pointer; text-align: left;
  transition: all var(--transition);
}
.steps-toggle:hover { background: var(--bg-card); color: var(--text); }
.steps-toggle.active { background: var(--bg-card); color: var(--primary); border-color: var(--primary); }

.steps-panel {
  display: none;
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.875rem 1rem;
  font-size: 0.73rem;
  line-height: 1.9;
  animation: fadeInUp 0.2s ease;
}
.steps-panel.open { display: block; }
[data-theme="ocean"] .steps-panel { backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

.steps-heading {
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--primary);
  margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.375rem;
}
.step-row {
  display: flex; align-items: baseline; gap: 0.5rem;
  padding: 0.1rem 0; color: var(--text-dim);
}
.step-num {
  font-size: 0.6rem; font-weight: 700; color: var(--primary);
  background: rgba(128,128,128,0.1); border-radius: 3px;
  padding: 0.1rem 0.35rem; flex-shrink: 0; font-family: var(--font-body);
}
.step-text { flex: 1; font-family: 'Courier New', monospace; }
.step-text .highlight { color: var(--text); font-weight: 700; }
.step-formula {
  margin: 0.4rem 0; padding: 0.4rem 0.65rem;
  background: rgba(128,128,128,0.08); border-radius: 6px;
  font-family: 'Courier New', monospace; color: var(--text-dim);
  font-style: italic; font-size: 0.7rem;
}
.step-result-row {
  margin-top: 0.5rem; padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700;
}
.step-result-row .label { font-size: 0.65rem; letter-spacing: 0.06em; color: var(--text-dim); }
.step-result-row .value { color: var(--primary); font-family: 'Courier New', monospace; font-size: 0.85rem; }

/* ════════════════════════════
   SMART SUGGESTIONS BAR
   ════════════════════════════ */
.suggestions-row {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.4rem; margin-top: 0.85rem; padding-top: 0.7rem;
  border-top: 1px solid var(--border);
}
.suggestions-label {
  font-size: 0.62rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-dim); white-space: nowrap; margin-right: 0.15rem;
}
.suggestion-pill {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.22rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text-dim); font-size: 0.68rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s ease;
  white-space: nowrap; line-height: 1.4;
}
.suggestion-pill:hover {
  border-color: var(--primary); color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--bg));
  transform: translateY(-1px);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--primary) 20%, transparent);
}
.suggestion-pill:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* ════════════════════════════
   CASIO CALCULATOR WIDGET
   ════════════════════════════ */
.casio-calc {
  width: 380px; background: var(--calc-body);
  border-radius: var(--radius-calc); padding: 1.25rem 1.25rem 1.5rem;
  box-shadow: var(--shadow-calc); border: 2px solid var(--calc-border);
  position: relative; flex-shrink: 0;
  transition: background var(--transition), border-color var(--transition);
}
[data-theme="ocean"] .casio-calc {
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-color: rgba(255,255,255,0.28);
}

/* Widget header — clean replacement for CASIO-BS branding */
.calc-widget-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.875rem; padding: 0 0.125rem;
}
.calc-widget-title {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--text);
}
.calc-widget-icon {
  color: var(--primary); flex-shrink: 0;
  display: flex; align-items: center;
}
.calc-widget-name {
  font-family: var(--font-body); font-size: 0.8rem;
  font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-dim);
}
.calc-widget-actions { display: flex; gap: 4px; }
.calc-action-btn {
  width: 26px; height: 26px; border: none; background: rgba(128,128,128,0.12);
  border-radius: 6px; cursor: pointer; color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
}
.calc-action-btn:hover { background: rgba(128,128,128,0.25); color: var(--text); }
[data-theme="dark"]   .calc-widget-icon { color: #38BDF8; }
[data-theme="forest"] .calc-widget-icon { color: #00FFAA; }
[data-theme="ocean"]  .calc-widget-icon { color: #FACC15; }
[data-theme="forest"] .calc-widget-name { font-family: 'Courier New', monospace; }

/* Display */
.casio-display {
  background: var(--display-bg); border-radius: 8px;
  border: 2px solid rgba(0,0,0,0.18); padding: 0.75rem 1rem;
  margin-bottom: 1rem; min-height: 60px;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
  transition: background var(--transition);
}
[data-theme="ocean"] .casio-display { border-color: rgba(255,255,255,0.12); box-shadow: inset 0 2px 8px rgba(0,0,30,0.4); }
[data-theme="light"]  .casio-display { box-shadow: inset 0 2px 6px rgba(79,70,229,0.08); border-color: #DDE3EF; }

.display-single {
  text-align: right; font-family: 'Courier New', Courier, monospace;
  font-size: 2rem; font-weight: 700; color: var(--display-text);
  line-height: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.display-expr {
  text-align: right; font-family: 'Courier New', Courier, monospace;
  font-size: 0.6875rem; color: var(--display-text); opacity: 0.45;
  min-height: 16px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.display-multi { display: flex; flex-direction: column; gap: 4px; }
.display-field { display: flex; align-items: center; justify-content: space-between; padding: 2px 0; border-bottom: 1px solid rgba(128,128,128,0.15); }
.display-field:last-child { border-bottom: none; }
.display-field-label { font-size: 0.625rem; font-weight: 600; letter-spacing: 0.08em; color: var(--display-text); opacity: 0.55; display: flex; align-items: center; gap: 4px; font-family: 'Courier New', monospace; }
.field-arrow { color: var(--btn-red); font-size: 0.7rem; opacity: 1; }
.display-field-value { font-size: 0.9375rem; font-weight: 700; min-width: 80px; text-align: right; color: var(--display-text); font-family: 'Courier New', monospace; }
.display-result-field { margin-top: 4px; padding-top: 6px; border-top: 1.5px solid rgba(128,128,128,0.25); display: flex; align-items: center; justify-content: space-between; }
.display-result-label { font-size: 0.625rem; font-weight: 700; letter-spacing: 0.1em; color: var(--display-text); opacity: 0.6; font-family: 'Courier New', monospace; }
.display-result-value { font-family: 'Courier New', Courier, monospace; font-size: 1.125rem; font-weight: 700; color: var(--display-text); transition: color 0.2s ease; }
/* Helper placeholder when no result computed yet */
.display-result-value.is-placeholder {
  font-size: 0.68rem; font-weight: 400; opacity: 0.4;
  letter-spacing: 0; font-family: var(--font-body); font-style: italic;
}
.sci-display-sub { font-size: 0.6875rem; color: var(--display-text); opacity: 0.45; text-align: right; font-family: 'Courier New', monospace; min-height: 18px; margin-bottom: 2px; }

/* ════════════════════════════════════════════════
   BUTTONS — distinct color per type, per theme
   ════════════════════════════════════════════════ */
.casio-keypad { display: flex; flex-direction: column; gap: 0.5rem; }
.keypad-row { display: grid; gap: 0.5rem; }

.calc-btn {
  height: 52px; border: none; border-radius: var(--radius-btn);
  cursor: pointer; font-family: var(--font-body);
  font-size: 1rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); user-select: none;
  letter-spacing: 0.02em; position: relative; overflow: hidden;
}
.calc-btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.calc-btn:active { transform: scale(0.92); }

/* ── Scientific / function buttons ── */
.calc-btn.sci {
  background: var(--btn-sci);
  color: var(--btn-sci-text);
  font-size: 0.78rem; font-weight: 700;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.1);
}
.calc-btn.sci:hover { background: var(--btn-sci-h); }

/* ── Number buttons ── */
.calc-btn.num {
  background: var(--btn-num);
  color: var(--btn-num-text);
  box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
}
.calc-btn.num:hover { background: var(--btn-num-h); }

/* ── Operator buttons ── */
.calc-btn.orange {
  background: var(--btn-op);
  color: var(--btn-op-text);
  box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.calc-btn.orange:hover { background: var(--btn-op-h); }

/* ── Equals — unique accent per theme ── */
.calc-btn[data-action="eq"] {
  background: var(--btn-eq) !important;
  color: var(--btn-eq-text) !important;
  font-size: 1.1rem; font-weight: 800;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.2) !important;
}
.calc-btn[data-action="eq"]:hover { background: var(--btn-eq-h) !important; }

/* ── Nav (PREV/NEXT) buttons ── */
.calc-btn.nav-btn {
  background: var(--btn-nav);
  color: var(--btn-nav-text);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.07);
}
.calc-btn.nav-btn:hover { background: var(--btn-nav-h); }

/* ── Clear / Delete buttons ── */
.calc-btn.red {
  background: var(--btn-red);
  color: var(--btn-red-text);
  font-weight: 700;
  box-shadow: 0 4px 0 rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.12);
}
.calc-btn.red:hover { background: var(--btn-red-h); }

/* Wide zero */
.calc-btn.wide { grid-column: span 2; }

/* ── RETRO: classic 3D press depth ── */
[data-theme="retro"] .calc-btn.sci  { box-shadow: 0 5px 0 #0E1B2C, inset 0 1px 0 rgba(255,255,255,0.10); }
[data-theme="retro"] .calc-btn.num  { box-shadow: 0 5px 0 #2A2926, inset 0 1px 0 rgba(255,255,255,0.08); }
[data-theme="retro"] .calc-btn.orange { box-shadow: 0 5px 0 #720000, inset 0 1px 0 rgba(255,255,255,0.12); }
[data-theme="retro"] .calc-btn[data-action="eq"] { box-shadow: 0 5px 0 #4A0000 !important; }
[data-theme="retro"] .calc-btn.red  { box-shadow: 0 5px 0 #8A0E00, inset 0 1px 0 rgba(255,255,255,0.10); }

/* ── DARK NEON: glows ── */
[data-theme="dark"] .calc-btn.sci  { box-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 14px rgba(109,40,217,0.4); }
[data-theme="dark"] .calc-btn.orange { box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 0 16px rgba(34,197,94,0.45); }
[data-theme="dark"] .calc-btn[data-action="eq"] { box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 0 20px rgba(56,189,248,0.6) !important; }
[data-theme="dark"] .calc-btn.red  { box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 0 10px rgba(239,68,68,0.35); }

/* ── SOFT PASTEL: soft depth ── */
[data-theme="light"] .calc-btn.sci  { box-shadow: 0 4px 0 #3730A3, 0 2px 8px rgba(79,70,229,0.25); }
[data-theme="light"] .calc-btn.num  { box-shadow: 0 4px 0 #B0BCCE, inset 0 1px 0 rgba(255,255,255,0.9); }
[data-theme="light"] .calc-btn.orange { box-shadow: 0 4px 0 #6D35E0, 0 2px 8px rgba(167,139,250,0.3); }
[data-theme="light"] .calc-btn[data-action="eq"] { box-shadow: 0 4px 0 #BE185D, 0 2px 12px rgba(244,114,182,0.4) !important; }
[data-theme="light"] .calc-btn.nav-btn { box-shadow: 0 4px 0 #8B70E0; }
[data-theme="light"] .calc-btn.red  { box-shadow: 0 4px 0 #BE123C, 0 2px 8px rgba(251,113,133,0.3); }

/* ── GLASSMORPHISM: glass + glow ── */
[data-theme="ocean"] .calc-btn {
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.18);
}
[data-theme="ocean"] .calc-btn.sci  { box-shadow: 0 4px 0 rgba(40,50,160,0.6), 0 0 18px rgba(68,75,200,0.4); border-color: rgba(120,140,255,0.3); }
[data-theme="ocean"] .calc-btn.num  { box-shadow: 0 4px 0 rgba(0,0,60,0.25); }
[data-theme="ocean"] .calc-btn.orange { box-shadow: 0 4px 0 rgba(0,20,80,0.3); }
[data-theme="ocean"] .calc-btn[data-action="eq"] { box-shadow: 0 4px 0 rgba(0,0,0,0.3), 0 0 24px rgba(250,204,21,0.6) !important; border-color: rgba(250,204,21,0.4) !important; }
[data-theme="ocean"] .calc-btn.red  { box-shadow: 0 4px 0 rgba(160,20,20,0.5), 0 0 12px rgba(220,60,60,0.35); }

/* ── RETRO DIGITAL: neon glows ── */
[data-theme="forest"] .calc-btn.sci  { box-shadow: 0 4px 0 rgba(0,0,0,0.6), 0 0 14px rgba(91,33,182,0.5); }
[data-theme="forest"] .calc-btn.num  { font-family: 'Courier New', monospace; border: 1px solid #303030; box-shadow: 0 4px 0 #0A0A0A; }
[data-theme="forest"] .calc-btn.orange { box-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 12px rgba(192,112,0,0.4); }
[data-theme="forest"] .calc-btn[data-action="eq"] { box-shadow: 0 4px 0 rgba(0,0,0,0.6), 0 0 22px rgba(0,255,170,0.7), 0 0 8px rgba(0,255,170,0.9) !important; }
[data-theme="forest"] .calc-btn.red  { box-shadow: 0 4px 0 rgba(0,0,0,0.5), 0 0 10px rgba(255,107,0,0.4); }
[data-theme="forest"] .calc-btn.nav-btn { font-family: 'Courier New', monospace; border: 1px solid #303030; }

/* ═════════════ ANIMATIONS ═════════════ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes resultFlash {
  0%   { color: inherit; transform: scale(1); }
  25%  { color: var(--primary); transform: scale(1.06); }
  60%  { color: var(--primary); transform: scale(1.03); }
  100% { color: inherit; transform: scale(1); }
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
@keyframes fieldPulse {
  0%   { border-left-color: var(--primary); }
  50%  { border-left-color: transparent; }
  100% { border-left-color: var(--primary); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.casio-calc { animation: fadeInUp 0.28s ease; }

/* Result flash — triggered by JS adding .result-flash class */
.display-single.result-flash,
.display-result-value.result-flash {
  animation: resultFlash 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Active field cursor */
.display-field.active-field { border-left: 3px solid var(--primary); padding-left: 0.4rem; }
.display-field.active-field .display-field-value::after {
  content: '|';
  margin-left: 1px;
  font-weight: 300;
  color: var(--primary);
  animation: cursorBlink 1s step-end infinite;
}

/* Input error shake */
.display-error { animation: shake 0.4s ease; }

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

/* ═════════════ RESPONSIVE ═════════════ */
@media (max-width: 1200px) { .calc-layout { grid-template-columns: 200px 1fr 250px; } }
@media (max-width: 1024px) {
  .calc-layout { grid-template-columns: 200px 1fr; }
  .info-panel { display: none; }
  .instrument-grid--wide { grid-template-columns: repeat(4, 1fr); }
  .home-wrapper { height: auto; overflow: visible; }
  .home-content { padding: 1.5rem 1.5rem 1rem; }
}
@media (max-width: 900px) {
  .casio-calc { width: 340px; }
  .categories-top { grid-template-columns: 1fr; }
  .instrument-grid--wide { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .calc-layout { grid-template-columns: 1fr; }
  /* Sidebar: hidden by default, slides in on mobile */
  .sidebar {
    display: none; position: fixed; top: 56px; left: 0; bottom: 0;
    width: 240px; z-index: 200; overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,0.35); height: auto;
    transform: translateX(-100%); transition: transform 0.25s ease;
  }
  .sidebar.open { display: flex; transform: translateX(0); }
  /* Scrim behind open sidebar */
  .sidebar-scrim {
    display: none; position: fixed; inset: 0; z-index: 199;
    background: rgba(0,0,0,0.45);
  }
  .sidebar-scrim.visible { display: block; }
  /* Show hamburger only when in calc view (class added by JS) */
  .hamburger-btn.calc-mode { display: flex; }
  .calc-center { padding: 1.25rem 1rem; height: auto; }
  .casio-calc { width: 100%; max-width: 400px; }
  .steps-toggle { max-width: 400px; width: 100%; }
  .steps-panel { max-width: 400px; width: 100%; }
  .home-content { padding: 1.25rem 1rem 0.75rem; gap: 0.75rem; }
  .instrument-grid--wide { grid-template-columns: repeat(2, 1fr); }
  .home-footer { flex-direction: column; align-items: flex-start; padding: 0.75rem 1rem; }
}
@media (max-width: 480px) {
  .casio-calc { padding: 1rem; }
  .calc-btn { height: 46px; font-size: 0.9375rem; }
  .display-single { font-size: 1.625rem; }
  .instrument-card { min-height: 72px; padding: 0.75rem 0.5rem; }
}
