/* =====================================================================
   MyMathsClub Scientific Calculator - Stylesheet
   Casio fx-991ES PLUS Realistic Styling & Modern Web Architecture
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800;900&family=Roboto:wght@400;500;700&family=Share+Tech+Mono&display=swap');

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --accent-gold: #d4a34b;
  --accent-red: #ef4444;
  --accent-green: #22c55e;
  --dark-bg: #0f172a;
  --surface-card: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --lcd-bg: #b9c4b6;
  --lcd-text: #111827;
}

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

/* Base Body & Layout */
body {
  margin: 0;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #1a001d;
  color: #f3e8ff;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Embed container / Standalone viewport */
#calculator-viewport {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 24px 16px;
  position: relative;
  background: radial-gradient(circle at 50% 20%, #520960 0%, #36003f 50%, #1a001d 100%);
}

#calc-stage {
  flex-shrink: 0;
  position: relative;
  display: block;
  user-select: none;
  overflow: visible;
}

/* Realistic Casio fx-991ES PLUS style faceplate */
.calc-body {
  width: 420px;
  min-height: 860px;
  height: 860px;
  background-color: #1a1c20;
  background-image:
    linear-gradient(135deg,
      rgba(255,255,255,0.12) 0%,
      rgba(255,255,255,0.03) 18%,
      rgba(255,255,255,0) 42%,
      rgba(0,0,0,0.18) 70%,
      rgba(0,0,0,0.45) 100%),
    linear-gradient(45deg, #22252a 25%, transparent 25%, transparent 75%, #22252a 75%, #22252a),
    linear-gradient(45deg, #22252a 25%, transparent 25%, transparent 75%, #22252a 75%, #22252a);
  background-size: cover, 3px 3px, 3px 3px;
  background-position: 0 0, 0 0, 1.5px 1.5px;
  border-radius: 18px;
  padding: 18px 20px 28px;
  box-shadow:
    0 25px 60px -15px rgba(0, 0, 0, 0.8),
    0 10px 24px -5px rgba(0, 0, 0, 0.6),
    inset 0 2px 2px rgba(255, 255, 255, 0.18),
    inset 2px 0 2px rgba(255, 255, 255, 0.08),
    inset 0 -3px 5px rgba(0, 0, 0, 0.7),
    inset -3px 0 5px rgba(0, 0, 0, 0.5);
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  overflow: visible;
}

/* Divi / WordPress Keypad Normalization & Height Lockdown */
.calc-body button,
.calc-body .btn,
.calc-body .btn-num,
.calc-body .btn-action,
.calc-body .btn-del-ac,
.calc-body .btn-exe,
.calc-body .btn-special,
.calc-body .nav-btn,
.calc-body .mode-pill {
  line-height: 1 !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-family: inherit !important;
}

.calc-body .btn {
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  padding: 0 !important;
}

.calc-body .btn-num,
.calc-body .btn-action,
.calc-body .btn-del-ac,
.calc-body .btn-exe {
  height: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  padding: 0 !important;
}

/* Top Branding Bar */
.branding-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
  padding: 0 4px;
}

.brand-left {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: 'Outfit', sans-serif;
  font-weight: 900;
  font-style: italic;
  color: #ffffff;
  font-size: 20px;
  letter-spacing: 1px;
  line-height: 1;
}

.brand-name span {
  color: #38bdf8;
}

.brand-vpam {
  font-size: 8px;
  color: #94a3b8;
  line-height: 1.3;
  letter-spacing: 0.6px;
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

.brand-vpam-sub {
  font-size: 7.5px;
  color: #64748b;
  font-weight: 500;
}

.brand-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

/* Solar Cell Panel */
.solar-cell {
  width: 90px;
  height: 24px;
  border-radius: 3px;
  background:
    linear-gradient(115deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.03) 35%, transparent 60%),
    repeating-linear-gradient(90deg, #2a241f 0 1px, #15100c 1px 22px),
    linear-gradient(#241d18, #110c08);
  border: 1px solid #000;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.15), inset 0 -2px 3px rgba(0,0,0,0.65), 0 1px 2px rgba(0,0,0,0.4);
}

.brand-edition {
  color: #cbd5e1;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* High-Contrast LCD Screen */
.display-screen {
  background-color: var(--lcd-bg);
  background-image:
    linear-gradient(rgba(0,0,0,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.025) 1px, transparent 1px);
  background-size: 2px 2px;
  border-radius: 6px;
  height: 126px;
  margin-bottom: 12px;
  padding: 6px 12px 8px;
  position: relative;
  border: 3px solid #111317;
  box-shadow: inset 0 3px 10px rgba(0,0,0,0.35);
  font-family: 'Share Tech Mono', monospace;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Status Bar on LCD */
.display-status-bar {
  display: flex;
  align-items: center;
  font-size: 9.5px;
  color: #111;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  padding-bottom: 2px;
  gap: 7px;
  font-family: sans-serif;
  height: 16px;
}

.display-status-bar span {
  opacity: 0.12;
  transition: opacity 0.2s ease, color 0.2s ease;
  font-weight: 600;
}

.display-status-bar span.active {
  opacity: 1;
  font-weight: 800;
  color: #052e16;
}

#status-mode {
  opacity: 1 !important;
  color: #0f172a;
  font-weight: 800;
  font-size: 10px;
}

/* Display Content Area */
.display-content {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: calc(100% - 20px);
}

.display-expr {
  text-align: left;
  font-size: 20px;
  min-height: 26px;
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  color: #111827;
  scrollbar-width: none;
  cursor: text;
  display: flex;
  align-items: center;
}

.display-expr::-webkit-scrollbar {
  display: none;
}

/* Caret blinking */
.expr-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: #0f172a;
  margin: 0 -1px;
  vertical-align: middle;
  animation: cursor-blink 1.05s step-end infinite;
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.display-result {
  text-align: right;
  font-size: 30px;
  color: #090d16;
  font-weight: 500;
  min-height: 38px;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.display-result::-webkit-scrollbar { display: none; }

/* Display Zoom Mode */
.display-content.zoomed .display-result { font-size: 38px; }
.display-content.zoomed .display-expr { font-size: 24px; }

/* Mode Toolbar (DEG/RAD, FRAC, NORM, ZOOM) */
.mode-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px 10px;
}

.mode-pill {
  background-color: #272a30;
  color: #e2e8f0;
  border: 1px solid #333842;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  cursor: pointer;
  box-shadow: 0 2px 0 #0f1115, 0 3px 5px rgba(0,0,0,0.3);
  transition: all 0.12s ease;
  font-family: inherit;
}

.mode-pill:hover {
  background-color: #32363e;
}

.mode-pill:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 #0f1115;
}

.mode-pill.active-pill {
  background-color: #0284c7;
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 2px 0 #0369a1, 0 3px 6px rgba(2, 132, 199, 0.4);
}

.mode-zoom {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease;
}

.mode-zoom:hover { color: #f1f5f9; }
.mode-zoom.active-pill { color: #38bdf8; }

.white-bar {
  height: 1px;
  background-color: rgba(255,255,255,0.08);
  margin-bottom: 18px;
}

/* Keypad Grid (6 columns) */
.btn-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px 6px;
  margin-bottom: 16px;
}

.relative {
  position: relative;
}

.w-full {
  width: 100%;
}

.btn {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, #383c44 0%, #2b2e35 52%, #22242a 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 7px 0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 3px 0 #0c0d10, 0 5px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.15);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s ease;
  user-select: none;
  outline: none;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #0c0d10, 0 1px 2px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
}

.btn-top-label {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  white-space: nowrap;
  font-family: inherit;
  width: 175%;
  text-align: center;
  pointer-events: none;
  display: flex;
  justify-content: center;
  gap: 4px;
}

.btn-top-label .yellow { color: var(--accent-gold); font-weight: 700; }
.btn-top-label .pink { color: #f87171; font-weight: 700; }

.btn-special {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, #2c3038 0%, #1e2126 52%, #16181d 100%);
  box-shadow: 0 3px 0 #08090c, 0 5px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
}

/* Modifiers Glow (SHIFT & ALPHA) */
.calc-body.mode-shift .btn,
.calc-body.mode-alpha .btn {
  opacity: 0.32;
}

.calc-body.mode-shift #btn-shift,
.calc-body.mode-alpha #btn-alpha,
.calc-body.mode-shift #btn-alpha,
.calc-body.mode-alpha #btn-shift {
  opacity: 1;
}

.calc-body.mode-shift #btn-shift {
  box-shadow: 0 0 0 2px var(--accent-gold), 0 0 14px 2px rgba(212,163,75,0.7);
}

.calc-body.mode-alpha #btn-alpha {
  box-shadow: 0 0 0 2px #ef4444, 0 0 14px 2px rgba(239,68,68,0.7);
}

.calc-body.mode-shift .btn[data-shift-val] {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--accent-gold), 0 0 12px 2px rgba(212,163,75,0.55);
  z-index: 2;
}

.calc-body.mode-alpha .btn[data-alpha-val] {
  opacity: 1;
  box-shadow: 0 0 0 2px #ef4444, 0 0 12px 2px rgba(239,68,68,0.55);
  z-index: 2;
}

.calc-body.mode-shift .btn-top-label,
.calc-body.mode-alpha .btn-top-label {
  opacity: 0.32;
}

.calc-body.mode-shift .relative:has(.btn[data-shift-val]) .btn-top-label,
.calc-body.mode-alpha .relative:has(.btn[data-alpha-val]) .btn-top-label {
  opacity: 1;
}

/* Replay D-Pad Navigation */
.nav-pad-container {
  grid-column: 3 / span 2;
  grid-row: 1 / span 2;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.nav-pad {
  width: 94px;
  height: 72px;
  background-color: #2b2f38;
  border-radius: 40px;
  position: relative;
  box-shadow: 0 3px 0 #0d0f13, 0 5px 7px rgba(0,0,0,0.35), inset 0 1px 1px rgba(255,255,255,0.08);
}

.nav-btn {
  position: absolute;
  background: transparent;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 32px;
  height: 22px;
  transition: color 0.1s ease;
}

.nav-btn:hover { color: #38bdf8; }
.nav-btn:active { transform: scale(0.92); }

.nav-up { top: 3px; left: 50%; transform: translateX(-50%); }
.nav-left { left: 3px; top: 50%; transform: translateY(-50%); }
.nav-right { right: 3px; top: 50%; transform: translateY(-50%); }
.nav-down { bottom: 3px; left: 50%; transform: translateX(-50%); }

.nav-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 26px; height: 26px;
  background-color: #16181d;
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
  pointer-events: none;
}

/* Numeric Keypad (5 columns) */
.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 18px 8px;
  margin-top: 26px;
}

.btn-num {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0) 45%),
    linear-gradient(180deg, #ffffff 0%, #f1f3f5 52%, #d8dbe0 100%);
  color: #0f172a;
  font-size: 18px;
  font-weight: 800;
  border-radius: 8px;
  padding: 8px 0;
  box-shadow: 0 3px 0 #7e8590, 0 5px 8px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.95);
}

.btn-num:active {
  box-shadow: 0 0 0 #7e8590, 0 1px 2px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.6);
}

.btn-action {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, #383d46 0%, #292d34 52%, #202227 100%);
  border-radius: 8px;
  color: #ffffff;
  font-size: 16px;
  box-shadow: 0 3px 0 #0d0e12, 0 5px 8px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.15);
}

.btn-del-ac {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 45%),
    linear-gradient(180deg, #84cc16 0%, #65a30d 52%, #4d7c0f 100%);
  color: #ffffff;
  font-weight: 800;
  border-radius: 8px;
  box-shadow: 0 3px 0 #365314, 0 5px 8px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.35);
}

.btn-del-ac:active {
  box-shadow: 0 0 0 #365314, 0 1px 2px rgba(0,0,0,0.35);
}

.btn-exe {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, #0284c7 0%, #0369a1 52%, #075985 100%);
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  border-radius: 8px;
  box-shadow: 0 3px 0 #0c4a6e, 0 5px 8px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.25);
}

.btn-exe:active {
  box-shadow: 0 0 0 #0c4a6e, 0 1px 2px rgba(0,0,0,0.35);
}

/* Modals for Modes, Function Picker, Tools (STAT/MATRIX/EQN/TABLE/VECTOR) */
.func-modal {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
  border-radius: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  transition: opacity 0.2s ease;
}

.func-modal.hidden {
  display: none !important;
}

.func-modal-panel {
  background: #f8fafc;
  color-scheme: light;
  color: #0f172a;
  width: 100%;
  height: 88%;
  border-radius: 18px 18px 16px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 28px rgba(0,0,0,0.5);
  font-family: inherit;
}

.func-modal-header {
  position: relative;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  padding: 16px 12px 12px;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
  background: #ffffff;
}

.func-modal-grip {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #cbd5e1;
}

.func-modal-close {
  position: absolute;
  right: 14px;
  top: 12px;
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
}

.func-modal-close:hover { color: #0f172a; }

.func-modal-list {
  overflow-y: auto;
  flex: 1;
}

.func-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid #e2e8f0;
  padding: 11px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease;
}

.func-row:hover { background: #f1f5f9; }
.func-row:active { background: #e2e8f0; }

.func-row-num {
  width: 20px;
  flex-shrink: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #2563eb;
}

.func-row-body { display: flex; flex-direction: column; }
.func-row-name {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}
.func-row-name b { color: #dc2626; font-weight: 700; }
.func-row-desc { font-size: 11px; color: #64748b; margin-top: 2px; }

.func-section {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  background: #e2e8f0;
  padding: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Natural Display Template Fields inside LCD */
.tmpl-field {
  display: inline-flex;
  align-items: center;
  min-width: 22px;
  min-height: 18px;
  border: 1.5px solid #1f2937;
  border-radius: 2px;
  background: transparent;
  padding: 0 3px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  color: #000;
  cursor: pointer;
  vertical-align: middle;
  white-space: nowrap;
}

.tmpl-field.active {
  border-color: #000;
  background: rgba(0,0,0,0.06);
}

.tmpl-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background: #000;
  animation: cursor-blink 0.75s step-end infinite;
}

.tmpl-sym {
  display: inline-flex;
  align-items: center;
  font-family: 'Share Tech Mono', monospace;
  color: #052e16;
  vertical-align: middle;
}

.display-content.tmpl-mode .display-expr {
  white-space: normal;
  overflow: visible;
}

.display-content.tmpl-mode .display-result {
  font-size: 9px !important;
  color: #14532d;
  text-align: center;
  border-top: 1px solid rgba(0,0,0,0.15);
  padding-top: 3px;
  font-family: 'Share Tech Mono', monospace;
}

/* Tool Bodies (STAT, TABLE, MATRIX, VECTOR, EQN) */
.tool-body {
  overflow-y: auto;
  flex: 1;
  padding: 16px;
  font-family: inherit;
  color: #0f172a;
}

.tool-form { display: flex; flex-direction: column; gap: 10px; }
.tool-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: #334155; }
.tool-field input, .tool-field textarea {
  font-family: 'Share Tech Mono', monospace;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
}
.tool-compute {
  margin-top: 4px;
  align-self: flex-start;
  background: #0284c7;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tool-compute:hover { background: #0369a1; }

.tool-table { width: 100%; border-collapse: collapse; font-family: 'Share Tech Mono', monospace; font-size: 13px; }
.tool-table th, .tool-table td { border: 1px solid #e2e8f0; padding: 6px 10px; text-align: left; }
.tool-table th { background: #f1f5f9; font-weight: 700; color: #1e293b; }
.tool-block { margin-bottom: 10px; }
.tool-block .k { font-size: 11px; font-weight: 700; color: #0284c7; }
.tool-block .v { font-family: 'Share Tech Mono', monospace; font-size: 14px; color: #0f172a; white-space: pre-wrap; }
.tool-err { color: #dc2626; font-size: 12px; font-weight: 600; padding: 4px 0; }
.tool-hint { font-size: 11.5px; color: #64748b; margin-bottom: 10px; }

/* Right Rail / Calculation History Panel */
#wm-side-rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 320px;
  min-width: 300px;
  align-self: center;
}

#history-panel {
  width: 100%;
  background: linear-gradient(180deg, #2b0232 0%, #1e0023 100%);
  border: 1px solid rgba(216, 180, 254, 0.2);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 680px;
  box-shadow: 0 12px 35px rgba(0,0,0,0.55), 0 0 20px rgba(54,0,63,0.3);
}

.hist-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #36003f;
  border-bottom: 1px solid rgba(216, 180, 254, 0.2);
}

.hist-hdr-title {
  color: #fbbf24;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.hist-clear-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hist-clear-btn:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

#hist-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #520960 transparent;
}

#hist-list::-webkit-scrollbar { width: 4px; }
#hist-list::-webkit-scrollbar-thumb { background: #520960; border-radius: 2px; }

.hist-item {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(216, 180, 254, 0.1);
  cursor: pointer;
  transition: background 0.12s ease;
}

.hist-item:hover { background: rgba(84, 9, 96, 0.35); }

.hist-expr {
  color: #d8b4fe;
  font-size: 13px;
  line-height: 1.4;
  font-family: 'Share Tech Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-result {
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  text-align: right;
  font-family: 'Share Tech Mono', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hist-result::before {
  content: '= ';
  color: #fbbf24;
  font-weight: 700;
}

.hist-mode-badge {
  display: inline-block;
  font-size: 9px;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 4px;
  padding: 0 5px;
  margin-bottom: 4px;
  font-weight: 700;
}

.hist-empty {
  color: #c084fc;
  font-size: 13px;
  text-align: center;
  padding: 40px 16px;
  line-height: 1.6;
}


/* Responsive Media Queries (Tablets & Mobile) */
@media (max-width: 1024px) {
  #calculator-viewport {
    flex-direction: column !important;
    align-items: center !important;
    min-height: auto !important;
    padding: 16px 8px 30px !important;
    gap: 24px !important;
    overflow: visible !important;
  }

  #calc-stage {
    margin-bottom: 24px !important;
    overflow: visible !important;
  }

  #wm-side-rail {
    width: 100% !important;
    max-width: 420px !important;
    margin-top: 10px !important;
  }

  #history-panel {
    max-height: 380px;
    height: auto;
  }
}
