/* ==========================================================================
   Texas Instruments TI-30XS MultiView™ — Slim & Compact Edition (v10)
   Slightly Reduced Width & Height + Ultra-Crisp LCD & Key Buttons
   ========================================================================== */

:root {
  --bg-page: #ffffff;
  --chassis-navy: #20314a;
  --chassis-navy-dark: #142033;
  --chassis-navy-highlight: #324a6e;
  --faceplate-silver: #e2e6ec;
  --faceplate-border: #bcc4d0;
  --lcd-bezel: #101824;
  --lcd-bg: #cdd8c5;
  --lcd-bg-top: #d6e0ce;
  --lcd-ink: #111910;
  --lcd-ink-muted: rgba(17, 25, 16, 0.22);
  --btn-dark: #252c37;
  --btn-dark-top: #353f4e;
  --btn-num: #f8fafc;
  --btn-num-bottom: #dfe5ed;
  --btn-blue: #235899;
  --btn-blue-top: #3270bd;
  --btn-2nd: #3c8c54;
  --btn-2nd-top: #4da868;
}

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

html,
body {
  width: 100%;
  min-height: 100vh;
  background-color: transparent;
  color: #1e293b;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(8px, 1.5vh, 14px) clamp(8px, 2vw, 16px) clamp(14px, 2.5vh, 28px);
}

.studio-stage {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(8px, 1.2vh, 12px);
}

/* Compact Top Toolbar */
.top-toolbar {
  width: 100%;
  max-width: 368px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}

.toolbar-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.badge-authentic {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: #1d4ed8;
  text-transform: uppercase;
}

.toolbar-brand h1 {
  font-size: 13.5px;
  font-weight: 800;
  color: #0f172a;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}

/* Bilingual Guide Drawer */
.guide-drawer {
  width: 100%;
  max-width: 720px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.07);
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.guide-card h3 {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}

.guide-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
  line-height: 1.4;
  color: #334155;
}

.guide-card code {
  background: #e2e8f0;
  color: #0f172a;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
}

/* ==========================================================================
   Compact & Responsive Calculator Hardware Chassis
   ========================================================================== */
.calculator-chassis {
  position: relative;
  width: min(368px, 95vw);
  background: linear-gradient(165deg, var(--chassis-navy-highlight) 0%, var(--chassis-navy) 22%, var(--chassis-navy-dark) 100%);
  border-radius: 20px 20px 28px 28px;
  padding: 12px 12px 12px;
  box-shadow:
    0 18px 36px rgba(15, 23, 42, 0.2),
    0 6px 14px rgba(15, 23, 42, 0.12),
    inset 0 2px 3px rgba(255, 255, 255, 0.28),
    inset 0 -3px 6px rgba(0, 0, 0, 0.55);
  border: 1.5px solid #162235;
}

/* Side Rubber Grip Ridges */
.grip-left,
.grip-right {
  position: absolute;
  top: 175px;
  bottom: 48px;
  width: 4px;
  background: repeating-linear-gradient(
    to bottom,
    #111927 0px,
    #111927 3px,
    #32496b 3px,
    #32496b 6px
  );
  opacity: 0.85;
}

.grip-left {
  left: 2.5px;
  border-radius: 3px 0 0 3px;
}

.grip-right {
  right: 2.5px;
  border-radius: 0 3px 3px 0;
}

/* Compact Upper Bezel & Inline Solar Strip */
.upper-bezel {
  padding: 0 2px 8px;
}

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
}

.ti-logo-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ti-brand-name {
  color: #ffffff;
  font-size: clamp(9px, 2.4vw, 10px);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.model-badge {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.model-title {
  color: #ffffff;
  font-size: clamp(12px, 3.2vw, 13.5px);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.model-sub {
  color: #ffd447;
  font-size: clamp(10px, 2.7vw, 11px);
  font-weight: 800;
  font-style: italic;
}

.solar-panel {
  width: 72px;
  height: 16px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #2d1f1d 0%, #462f2b 50%, #241715 100%);
  border: 1px solid #0e1520;
  border-radius: 3px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.75);
}

.solar-panel span {
  border-right: 1px solid rgba(255, 210, 180, 0.16);
}

.solar-panel span:last-child {
  border-right: none;
}

/* Compact 4-Line MultiView LCD Screen */
.lcd-frame {
  background: #0d141f;
  padding: 5px;
  border-radius: 9px;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.85),
    0 1px 0 rgba(255, 255, 255, 0.18);
}

.lcd-screen {
  background: linear-gradient(180deg, var(--lcd-bg-top) 0%, var(--lcd-bg) 100%);
  color: var(--lcd-ink);
  height: clamp(106px, 15.8vh, 118px);
  border-radius: 5px;
  padding: 4px 7px 4px;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 2px 5px rgba(17, 25, 16, 0.25);
  position: relative;
  overflow: hidden;
  transition: filter 0.2s ease, opacity 0.2s ease;
}

.lcd-screen.screen-off {
  background: #9aa693;
}

.lcd-screen.screen-off .lcd-status-bar,
.lcd-screen.screen-off .lcd-viewport {
  visibility: hidden;
}

.lcd-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(17, 25, 16, 0.18);
  padding-bottom: 2px;
  margin-bottom: 2px;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(8.5px, 2.2vw, 9.5px);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.ind {
  color: var(--lcd-ink-muted);
  padding: 0 2px;
  border-radius: 2px;
}

.ind.active {
  color: var(--lcd-ink);
}

.ind.highlight-2nd {
  background: var(--lcd-ink);
  color: var(--lcd-bg);
}

.lcd-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(13.5px, 3.6vw, 15px);
  font-weight: 700;
  line-height: 1.25;
  overflow: hidden;
}

/* History & Active Lines */
.lcd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 19px;
  white-space: nowrap;
  overflow: hidden;
}

.lcd-row.selected-history {
  background: rgba(17, 25, 16, 0.12);
  border-radius: 3px;
  padding: 0 3px;
}

.lcd-expr {
  display: inline-flex;
  align-items: center;
  gap: 1.5px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.lcd-ans {
  margin-left: auto;
  text-align: right;
  font-weight: 800;
  padding-left: 8px;
}

.lcd-active-line {
  display: flex;
  align-items: center;
  min-height: 23px;
  border-top: 1px dashed rgba(17, 25, 16, 0.16);
  padding-top: 2px;
}

.cursor-block {
  display: inline-block;
  width: 7.5px;
  height: 15px;
  background: var(--lcd-ink);
  animation: blinkCursor 1s steps(2, start) infinite;
  vertical-align: middle;
  margin: 0 1px;
}

.cursor-block.ins-mode {
  width: 2px;
}

@keyframes blinkCursor {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.12; }
}

/* MathPrint Stacked Fraction on LCD */
.mp-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.05;
  margin: 0 2px;
}

.mp-num {
  border-bottom: 1.5px solid var(--lcd-ink);
  padding: 0 3px 1px;
  min-width: 12px;
  text-align: center;
}

.mp-den {
  padding: 1px 3px 0;
  min-width: 12px;
  text-align: center;
}

/* MathPrint Raised Exponent Box on LCD */
.mp-sup {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  transform: translateY(-5px);
  margin: 0 1px;
  padding: 0 2px;
}

.mp-sup.active-sup {
  border-bottom: 1.5px solid var(--lcd-ink);
}

.mp-box {
  display: inline-block;
  min-width: 10px;
  min-height: 10px;
  border: 1px dotted var(--lcd-ink);
  background: rgba(17, 25, 16, 0.08);
  border-radius: 1.5px;
}

.mp-box.focused {
  background: rgba(17, 25, 16, 0.26);
  border-style: solid;
}

/* Mode / Menu / Data / Table Interactive Screens */
.lcd-menu-grid {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  font-size: 11.5px;
}

.lcd-menu-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.5px 2px;
}

.lcd-menu-opt {
  padding: 0 3.5px;
  border-radius: 2px;
}

.lcd-menu-opt.chosen {
  background: var(--lcd-ink);
  color: var(--lcd-bg);
}

.lcd-menu-opt.cursor-opt {
  outline: 1.5px solid var(--lcd-ink);
}

.lcd-table-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  height: 100%;
  font-size: 11.5px;
  border-top: 1px solid var(--lcd-ink);
}

.lcd-table-col {
  border-right: 1px solid rgba(17, 25, 16, 0.35);
  display: flex;
  flex-direction: column;
}

.lcd-table-col:last-child {
  border-right: none;
}

.lcd-table-hdr {
  background: rgba(17, 25, 16, 0.14);
  font-weight: 800;
  text-align: center;
  border-bottom: 1px solid var(--lcd-ink);
}

.lcd-table-cell {
  padding: 0.5px 4px;
  text-align: right;
  min-height: 18.5px;
}

.lcd-table-cell.active-cell {
  background: var(--lcd-ink);
  color: var(--lcd-bg);
}

/* ==========================================================================
   Compact Metallic Faceplate & Razor-Sharp Key Legends
   ========================================================================== */
.faceplate {
  background: linear-gradient(180deg, #eaedf2 0%, var(--faceplate-silver) 100%);
  border-radius: 14px 14px 22px 22px;
  padding: 7px 8px 10px;
  border: 1px solid var(--faceplate-border);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    0 2px 5px rgba(0, 0, 0, 0.35);
}

.top-control-deck {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 6px;
  align-items: center;
  margin-bottom: 5px;
}

.left-utility-cols {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3.5px 4.5px;
}

/* Key Slot + Ultra-Crisp 2nd Function Legend Pill */
.key-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.key-legend {
  min-height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8.5px, 2.2vw, 9.5px);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  color: #16243b;
  margin-bottom: 1.5px;
  white-space: nowrap;
  padding: 1px 4px;
  border-radius: 3.5px;
}

/* High-Contrast Dark Badge for Non-Empty 2nd Legends */
.key-legend:not(:empty) {
  background: #172438;
  color: #ffd859;
  box-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
}

.legend-frac-wrap {
  gap: 2px;
  padding: 1px 4px;
}

.stacked-nd-sm {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 7px;
  font-weight: 800;
  line-height: 0.92;
}

.stacked-nd-sm span:first-child {
  border-bottom: 1px solid #ffd859;
  padding: 0 1px;
}

/* Precision Stacked n/d Button Graphic */
.btn-frac-key {
  padding: 1px 0;
}

.stacked-nd {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 0.98;
}

.stacked-nd .nd-top {
  padding-bottom: 1px;
}

.stacked-nd .nd-bar {
  width: 13px;
  height: 1.6px;
  background-color: #ffffff;
  border-radius: 1px;
}

.stacked-nd .nd-bot {
  padding-top: 1px;
}

/* Precision Caret ^ Button Graphic */
.btn-caret-key {
  padding: 0;
}

.caret-svg {
  display: block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}

.x-root-sym {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 800;
}

.x-root-sym sup {
  font-size: 7px;
  margin-right: 0.5px;
}

.x-root-sym .rad-bar {
  display: inline-block;
  width: 5px;
  height: 1.2px;
  background: #ffd859;
  transform: translateY(-3.5px);
}

/* Compact Directional Oval D-Pad */
.dpad-cluster {
  position: relative;
  width: min(102px, 26vw);
  height: 68px;
  margin: 0 auto;
  background: linear-gradient(180deg, #323c4c 0%, #1d2430 100%);
  border-radius: 36px;
  box-shadow:
    0 3px 6px rgba(15, 23, 42, 0.32),
    inset 0 1.5px 2px rgba(255, 255, 255, 0.25);
  border: 1.5px solid #131820;
  display: grid;
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  grid-template-columns: 1fr 28px 1fr;
  grid-template-rows: 1fr 22px 1fr;
  padding: 2px;
}

.dpad-btn {
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: background 0.1s ease, transform 0.08s ease;
}

.dpad-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.dpad-btn:active,
.dpad-btn.pressed {
  background: rgba(255, 216, 89, 0.28);
  color: #ffd859;
  transform: scale(0.93);
}

.dpad-up { grid-area: up; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }
.dpad-down { grid-area: down; }

.dpad-center-cap {
  grid-area: center;
  background: radial-gradient(circle, #2a3342 0%, #181e28 100%);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main 5-Column Key Matrix */
.key-matrix {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3.5px 4.5px;
}

.key-slot-tall {
  grid-row: span 2;
}

/* Compact, Crisp Tactile Calculator Buttons */
.btn {
  width: 100%;
  height: clamp(27px, 4.2vh, 30px);
  border-radius: 6px;
  border: 1px solid #111827;
  font-family: 'Inter', sans-serif;
  font-size: clamp(11.5px, 2.9vw, 12.5px);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.02;
  transition: transform 0.06s ease, box-shadow 0.08s ease, filter 0.1s ease;
  position: relative;
}

.btn-math-sym {
  font-family: 'JetBrains Mono', 'Inter', sans-serif;
  font-size: clamp(12.5px, 3.1vw, 13.5px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.btn sup,
.btn sub {
  font-size: 8px;
  line-height: 0;
}

.btn small {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* Dark Function Keys */
.btn-dark {
  background: linear-gradient(180deg, var(--btn-dark-top) 0%, var(--btn-dark) 100%);
  color: #ffffff;
  box-shadow:
    0 2px 0 #11161f,
    0 2.5px 4px rgba(15, 23, 42, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Green 2nd Shift Key */
.btn-2nd {
  background: linear-gradient(180deg, var(--btn-2nd-top) 0%, var(--btn-2nd) 100%);
  color: #ffffff;
  font-weight: 800;
  border-color: #1f4f2e;
  box-shadow:
    0 2px 0 #194225,
    0 2.5px 4px rgba(15, 23, 42, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn-2nd.is-active {
  background: #ffd447;
  color: #111910;
  border-color: #b45309;
  box-shadow: 0 0 8px rgba(255, 212, 71, 0.85);
}

/* Crisp White Number Keys */
.btn-num {
  background: linear-gradient(180deg, var(--btn-num) 0%, var(--btn-num-bottom) 100%);
  color: #0f172a;
  font-size: clamp(13.5px, 3.4vw, 14.5px);
  font-weight: 800;
  border-color: #64748b;
  box-shadow:
    0 2px 0 #64748b,
    0 2.5px 4px rgba(15, 23, 42, 0.16),
    inset 0 1px 0 #ffffff;
}

/* Blue Operator Keys */
.btn-blue-op {
  background: linear-gradient(180deg, var(--btn-blue-top) 0%, var(--btn-blue) 100%);
  color: #ffffff;
  font-size: clamp(14.5px, 3.6vw, 15.5px);
  font-weight: 800;
  border-color: #143661;
  box-shadow:
    0 2px 0 #133157,
    0 2.5px 4px rgba(15, 23, 42, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

/* Tall Blue ENTER Key */
.btn-enter {
  height: 100%;
  min-height: clamp(72px, 10.6vh, 78px);
  background: linear-gradient(180deg, #2d6cb8 0%, #1d4e8c 100%);
  color: #ffffff;
  font-size: clamp(12px, 3vw, 13px);
  font-weight: 800;
  letter-spacing: 0.03em;
  border-color: #102d52;
  border-radius: 7px 7px 12px 7px;
  box-shadow:
    0 2.5px 0 #0f294a,
    0 3px 6px rgba(15, 23, 42, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn:hover {
  filter: brightness(1.07);
}

.btn:active,
.btn.pressed {
  transform: translateY(1.5px);
  box-shadow: 0 0.5px 0 #111827;
}

/* Extra-Small Screen Adjustments (< 360px width) */
@media (max-width: 360px) {
  .calculator-chassis {
    padding: 10px 9px 10px;
  }
  .faceplate {
    padding: 6px 6px 8px;
  }
  .key-legend {
    padding: 1px 2.5px;
    font-size: 8px;
  }
  .solar-panel {
    width: 58px;
    height: 14px;
  }
}

/* Enhanced LCD Text Crispness & Contrast */
.lcd-screen {
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

.lcd-ans {
  font-size: clamp(14.5px, 3.8vw, 16px);
  letter-spacing: -0.01em;
}


/* 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;
}

html,
body {
  background-color: transparent;
}
.top-toolbar {
  background: var(--tool-surface);
  border-color: var(--tool-border);
  color: var(--tool-text);
}

.top-toolbar .toolbar-brand h1 {
  color: var(--tool-text);
}

.top-toolbar .tool-btn {
  color: var(--tool-text);
  background: var(--tool-surface);
  border-color: var(--tool-border);
}
