* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: transparent;
  color: #1f242d;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.page-wrapper {
  width: 100%;
  max-width: 372px;
  display: flex;
  justify-content: center;
}

.calculator-body {
  position: relative;
  width: 100%;
  background: linear-gradient(170deg, #2d323c 0%, #20242c 60%, #171a21 100%);
  border-radius: 22px 22px 30px 30px;
  padding: 13px 13px 17px;
  box-shadow:
    0 20px 40px rgba(15, 23, 42, 0.26),
    0 5px 12px rgba(15, 23, 42, 0.15),
    inset 0 2px 3px rgba(255, 255, 255, 0.16),
    inset 0 -4px 8px rgba(0, 0, 0, 0.55);
  border: 2px solid #474e5d;
}

.casing-top-ridge {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 105px;
  height: 2.5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}

/* Header & Solar Panel */
.calc-header {
  margin-bottom: 7px;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

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

.brand-name {
  color: #ffffff;
  font-weight: 800;
  font-size: 15.5px;
  letter-spacing: 1.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.model-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 1px;
}

.model-name {
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
}

.edition-badge {
  color: #38bdf8;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.solar-panel {
  width: 88px;
  height: 24px;
  background: #2b1d19;
  border: 2px solid #16181d;
  border-radius: 4px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  padding: 2px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.85);
}

.solar-cell {
  background: linear-gradient(135deg, #4f352e, #33201b);
  border-radius: 1px;
}

.display-subtitle {
  margin-top: 4px;
  text-align: center;
  font-size: 9px;
  letter-spacing: 1.1px;
  color: #e2e8f0;
  font-weight: 700;
}

/* Natural-V.P.A.M. LCD Screen — Slightly Larger, High-Clarity Text */
.lcd-bezel {
  background: #12151a;
  padding: 6px;
  border-radius: 9px;
  border: 1px solid #475569;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.85);
  margin-bottom: 10px;
}

.lcd-screen {
  background: linear-gradient(180deg, #d7e3d0 0%, #c6d6be 100%);
  border-radius: 4px;
  padding: 6px 10px 7px;
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.22);
  color: #091109;
  font-family: "Consolas", "Courier New", monospace;
}

.lcd-screen.powered-off .status-bar,
.lcd-screen.powered-off .lcd-expression,
.lcd-screen.powered-off .lcd-result {
  visibility: hidden;
}

.status-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 9.5px;
  font-weight: 800;
  border-bottom: 1px solid rgba(9, 17, 9, 0.24);
  padding-bottom: 2px;
}

.ind {
  opacity: 0.22;
  padding: 1px 3px;
  border-radius: 2px;
}

.ind.active {
  opacity: 1;
  background: #091109;
  color: #d7e3d0;
}

.lcd-expression {
  font-size: 17.5px;
  min-height: 28px;
  display: flex;
  align-items: center;
  overflow-x: auto;
  white-space: nowrap;
  padding: 3px 0 1px;
  font-weight: 800;
  color: #091109;
  letter-spacing: 0.2px;
}

/* Natural Textbook Display Fraction Styling */
.vpam-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 2px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.08;
}

.vpam-frac .num {
  border-bottom: 1.5px solid #091109;
  padding: 0 3px;
}

.vpam-frac .den {
  padding: 0 3px;
}

.cursor-caret {
  display: inline-block;
  width: 2px;
  height: 17px;
  background: #091109;
  vertical-align: middle;
  animation: blink 1s step-end infinite;
}

.cursor-caret.ins-mode {
  width: 8px;
  opacity: 0.45;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.lcd-result {
  font-size: 24.5px;
  font-weight: 800;
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
  letter-spacing: 0.4px;
  color: #050b05;
}

/* Top Control Cluster & Replay Pad */
.control-cluster {
  display: grid;
  grid-template-columns: 1fr 1.12fr 1fr;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
}

.top-side-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.replay-pad {
  position: relative;
  width: 90px;
  height: 58px;
  margin: 0 auto;
  background: linear-gradient(145deg, #4e5667, #313643);
  border-radius: 30px;
  border: 2px solid #1c2028;
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.replay-text {
  font-size: 8.5px;
  font-weight: 800;
  color: #f8fafc;
  letter-spacing: 0.6px;
  pointer-events: none;
}

.dpad-btn {
  position: absolute;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 10px;
  cursor: pointer;
  padding: 4px;
}

.dpad-btn:active {
  color: #38bdf8;
}

.dpad-up {
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
}

.dpad-down {
  bottom: 1px;
  left: 50%;
  transform: translateX(-50%);
}

.dpad-left {
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
}

.dpad-right {
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
}

/* Key Cell & Ultra-Crisp Printed Legends Above Every Key */
.key-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.sub-row {
  cursor: pointer;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1px 1.5px;
  font-size: 9px;
  line-height: 1.05;
  min-height: 12px;
  font-weight: 800;
  letter-spacing: -0.15px;
  white-space: nowrap;
}

.shift-text {
  color: #fde047;
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.98);
}

.alpha-text {
  color: #fda4af;
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.98);
  margin-left: auto;
}

/* Tactile Buttons Base */
.btn {
  position: relative;
  width: 100%;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1px 2px;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  box-shadow:
    0 2.5px 0 #0d1015,
    0 3px 5px rgba(0, 0, 0, 0.36),
    inset 0 1px 1px rgba(255, 255, 255, 0.25);
}

.btn:active,
.btn.pressed {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 #0d1015,
    0 2px 3px rgba(0, 0, 0, 0.3);
}

.sub-label {
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 1px;
}

.main-label {
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.1px;
}

/* Modifier & System Keys */
.btn-modifier,
.btn-system {
  background: linear-gradient(180deg, #586072 0%, #3e4452 100%);
  color: #ffffff;
  height: 29px;
  border-radius: 13px;
}

.btn-shift .main-label {
  color: #fde047;
  font-size: 10px;
  font-weight: 800;
}

.btn-alpha .main-label {
  color: #fda4af;
  font-size: 10px;
  font-weight: 800;
}

.btn-system .main-label {
  font-size: 10px;
  font-weight: 800;
}

/* Scientific Grid */
.sci-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4.5px 4px;
  margin-bottom: 9px;
}

.btn-sci {
  background: linear-gradient(180deg, #434958 0%, #2d323d 100%);
  color: #ffffff;
  height: 25px;
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.8);
}

.btn-sci .main-label {
  font-size: 11.5px;
  font-weight: 700;
}

.grid-spacer {
  visibility: hidden;
}

/* Numeric & Main Operator Grid */
.num-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5.5px 5px;
}

.btn-num {
  background: linear-gradient(180deg, #f8fafc 0%, #cbd5e1 100%);
  color: #05080f;
  height: 29px;
  box-shadow:
    0 2.5px 0 #64748b,
    0 3px 5px rgba(0, 0, 0, 0.34),
    inset 0 1px 1px #ffffff;
}

.btn-num .main-label {
  font-size: 15px;
  font-weight: 800;
}

.btn-op,
.btn-eq {
  background: linear-gradient(180deg, #64748b 0%, #475569 100%);
  color: #ffffff;
  height: 29px;
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.7);
}

.btn-op .main-label,
.btn-eq .main-label {
  font-size: 16px;
  font-weight: 800;
}

.btn-action-red {
  background: linear-gradient(180deg, #e11d48 0%, #be123c 100%);
  color: #ffffff;
  height: 29px;
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.7);
  box-shadow:
    0 2.5px 0 #881337,
    0 3px 5px rgba(0, 0, 0, 0.34),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.btn-action-red .main-label {
  font-size: 13px;
  font-weight: 800;
}

/* =========================================================
   ULTRA-CRISP, HIGH-CONTRAST POPUP MODAL STYLING
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #ffffff;
  color: #090d16;
  border-radius: 16px;
  border: 2px solid #cbd5e1;
  width: 100%;
  max-width: 400px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 9px;
  margin-bottom: 12px;
}

.modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #1d4ed8;
  text-transform: uppercase;
}

.modal-header h2 {
  font-size: 16.5px;
  font-weight: 800;
  color: #090d16;
  letter-spacing: -0.2px;
}

.modal-close {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #e2e8f0;
}

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

.modal-option-btn {
  background: #f8fafc;
  border: 1.5px solid #94a3b8;
  border-radius: 9px;
  padding: 9px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: #090d16;
  cursor: pointer;
  line-height: 1.35;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.modal-option-btn:hover,
.modal-option-btn:focus {
  background: #eff6ff;
  border-color: #2563eb;
  color: #1e3a8a;
  outline: none;
}

.modal-option-sub {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
  margin-top: 2px;
  font-family: "Consolas", "Courier New", monospace;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.modal-hint {
  background: #f1f5f9;
  border-left: 3.5px solid #2563eb;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.4;
}

.modal-form label {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-form input,
.modal-form select {
  padding: 8px 10px;
  border: 1.5px solid #64748b;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #090d16;
  background: #ffffff;
  font-family: "Consolas", "Courier New", monospace;
}

.modal-form input:focus,
.modal-form select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.modal-primary-btn {
  background: #1d4ed8;
  color: #ffffff;
  border: none;
  border-radius: 9px;
  padding: 10px 13px;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 3px 6px rgba(29, 78, 216, 0.28);
}

.modal-primary-btn:hover {
  background: #1e40af;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-weight: 700;
  color: #090d16;
  font-family: "Consolas", "Courier New", monospace;
  margin-top: 4px;
}

.modal-table th,
.modal-table td {
  border: 1.5px solid #94a3b8;
  padding: 6px 9px;
  text-align: right;
}

.modal-table th {
  background: #e2e8f0;
  color: #090d16;
  font-weight: 800;
  text-align: center;
}


/* Graphly Math light/dark page theme integration. */
:root {
  color-scheme: light;
  --tool-surface: #ffffff;
  --tool-border: #e0e7f1;
  --tool-text: #182337;
  --tool-muted: #66748a;
}

:root[data-site-theme="dark"] {
  color-scheme: dark;
  --tool-surface: #151f30;
  --tool-border: #29374c;
  --tool-text: #eef4ff;
  --tool-muted: #a6b3c8;
}

body {
  background-color: transparent;
}
