/* ==========================================================================
   TI-84 Plus CE Original Model — Compact Dimensions + Large Crisp LCD Text
   ========================================================================== */

:root {
  --ti-2nd-label: #7dd3fc;
  --ti-alpha-label: #86efac;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: transparent;
  color: #090d16;
  min-height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem;
}

/* Top Utility Bar — Matched to Compact Width */
.app-topbar {
  width: 100%;
  max-width: 368px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 3px;
}

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

.status-dot {
  width: 8.5px;
  height: 8.5px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}

.brand-badge h1 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  color: #090d16;
  letter-spacing: -0.01em;
}

.brand-badge .subtitle {
  font-weight: 600;
  color: #475569;
  font-size: 11.5px;
}

.guide-toggle-btn {
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: #ffffff;
  color: #1d4ed8;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
}

.guide-toggle-btn:hover {
  background: #eff6ff;
  border-color: #60a5fa;
}

/* Collapsible Quick Guide */
.guide-panel {
  width: 100%;
  max-width: 368px;
  margin-bottom: 10px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: #1e293b;
  box-shadow: 0 12px 28px -6px rgba(15, 23, 42, 0.14);
}

.hidden {
  display: none !important;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  color: #090d16;
  padding-bottom: 5px;
  margin-bottom: 7px;
  border-bottom: 1px solid #e2e8f0;
}

.guide-header button {
  background: none;
  border: none;
  color: #475569;
  font-weight: 800;
  cursor: pointer;
  font-size: 13.5px;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px 8px;
  font-size: 10.5px;
  font-weight: 500;
}

.guide-grid kbd {
  background: #f1f5f9;
  border: 1px solid #94a3b8;
  padding: 1px 4px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  color: #090d16;
}

.guide-note {
  margin: 7px 0 0 0;
  font-size: 10.5px;
  color: #334155;
  line-height: 1.45;
}

/* Calculator Hardware Casing — Slightly Reduced Height & Width (368px) */
.ti-casing {
  width: 100%;
  max-width: 368px;
  background: linear-gradient(160deg, #232730 0%, #171a21 55%, #101217 100%);
  border-radius: 22px 22px 40px 40px;
  padding: 11px 13px 18px 13px;
  box-shadow:
    0 20px 42px -12px rgba(15, 23, 42, 0.35),
    0 6px 16px -4px rgba(15, 23, 42, 0.2),
    0 0 0 2px #090b0e,
    inset 0 2px 3px rgba(255, 255, 255, 0.14),
    inset 0 -4px 8px rgba(0, 0, 0, 0.65);
  position: relative;
}

/* Compact Screen Bezel */
.ti-screen-bezel {
  background: linear-gradient(180deg, #0b0c0f 0%, #16181d 100%);
  border-radius: 12px 12px 17px 17px;
  padding: 8px 10px 10px 10px;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.9),
    0 1px 0 rgba(255, 255, 255, 0.08);
  border: 1.5px solid #3b404b;
}

.ti-brand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  padding: 0 3px;
}

.ti-brand-logo {
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.05em;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ti-model-name {
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: #ffffff;
}

.ti-model-ce {
  color: #38bdf8;
  font-style: italic;
}

/* Color LCD Viewport — Crisp & Spacious */
.ti-lcd-wrapper {
  width: 100%;
  aspect-ratio: 4 / 2.85;
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.25);
  border: 2px solid #090a0c;
  position: relative;
  font-family: 'JetBrains Mono', monospace;
  color: #090d16;
}

/* Crisp High-Contrast Top Status Bar */
.ti-status-bar {
  height: 20px;
  background: #1e293b;
  color: #ffffff;
  font-size: 9.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.status-indicators {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modifier-badge {
  padding: 1px 4px;
  border-radius: 2px;
  font-weight: 800;
  font-size: 9px;
}

.badge-2nd {
  background: #38bdf8;
  color: #082f49;
}

.badge-alpha {
  background: #4ade80;
  color: #052e16;
}

.battery-icon {
  width: 15px;
  height: 8.5px;
  border: 1.5px solid #ffffff;
  border-radius: 1.5px;
  padding: 1px;
  display: flex;
  align-items: center;
  position: relative;
}

.battery-icon::after {
  content: '';
  position: absolute;
  right: -3.5px;
  top: 1.5px;
  width: 2px;
  height: 3px;
  background: #ffffff;
  border-radius: 0 1px 1px 0;
}

.battery-fill {
  width: 100%;
  height: 100%;
  background: #4ade80;
}

/* Main LCD Viewport */
.ti-lcd-content {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

/* Contextual Bottom LCD Softkey Bar */
.ti-softkey-bar {
  height: 19px;
  background: #f1f5f9;
  border-top: 1.5px solid #94a3b8;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  flex-shrink: 0;
}

.softkey-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 800;
  color: #0f172a;
  border-right: 1px solid #cbd5e1;
  cursor: pointer;
  letter-spacing: -0.02em;
  transition: background 0.1s ease, color 0.1s ease;
}

.softkey-tab:last-child {
  border-right: none;
}

.softkey-tab:hover {
  background: #dbeafe;
  color: #1d4ed8;
}

.softkey-tab.alpha-active {
  background: #16a34a;
  color: #ffffff;
}

.softkey-tab.softkey-highlight {
  background: #1d4ed8;
  color: #ffffff;
}

/* Home Screen MathPrint History — LARGER, ULTRA-CLEAR TEXT */
.home-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 5px 8px;
  overflow-y: auto;
  font-size: 14.5px;
  line-height: 1.42;
}

.home-screen::-webkit-scrollbar {
  width: 4px;
}

.home-screen::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 2px;
}

.history-item {
  margin-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 2.5px;
}

.history-expr {
  text-align: left;
  color: #1e293b;
  word-break: break-all;
  font-weight: 700;
  font-size: 14px;
}

.history-res {
  text-align: right;
  color: #090d16;
  font-weight: 800;
  font-size: 15.5px;
}

.history-err {
  text-align: right;
  color: #b91c1c;
  font-weight: 800;
  font-size: 13px;
}

.current-input-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-height: 22px;
  font-weight: 800;
  font-size: 15.5px;
  color: #090d16;
  word-break: break-all;
  padding-top: 2px;
}

.cursor-block {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: #090d16;
  animation: blinkCursor 1s steps(2, start) infinite;
  vertical-align: middle;
  margin-left: 1px;
}

.cursor-ins {
  display: inline-block;
  width: 8px;
  height: 3.5px;
  background: #090d16;
  animation: blinkCursor 1s steps(2, start) infinite;
  vertical-align: bottom;
  margin-left: 1px;
}

.cursor-2nd {
  background: #2563eb;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  width: 10px;
  text-align: center;
  line-height: 16px;
}

.cursor-alpha {
  background: #16a34a;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  width: 10px;
  text-align: center;
  line-height: 16px;
}

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

/* List Screens (Y=, Window, Mode, Menus, Stat Editor, Numeric Solver) — Larger Clear Text */
.lcd-list-screen {
  flex: 1;
  padding: 5px 7px;
  font-size: 13px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2.5px;
}

.lcd-header-tabs {
  display: flex;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  border-bottom: 1.5px solid #cbd5e1;
  padding-bottom: 2px;
  margin-bottom: 2px;
  color: #475569;
}

.lcd-tab-active {
  background: #0f172a;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 2px;
}

.y-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 5px;
  border-radius: 3px;
  min-height: 22px;
  font-weight: 700;
  font-size: 13px;
  color: #090d16;
}

.y-row.selected {
  background: #dbeafe;
  outline: 1.5px solid #3b82f6;
}

.y-row.active-menu {
  background: #0f172a;
  color: #ffffff;
  font-weight: 700;
}

.y-color-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.y-eq-toggle {
  font-weight: 800;
  padding: 0 3px;
  cursor: pointer;
}

.y-eq-toggle.active {
  background: #0f172a;
  color: #ffffff;
}

/* Numeric Solver Screen Cards */
.solver-box {
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  padding: 3px 5px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.solver-result-bar {
  margin-top: auto;
  padding: 4px 6px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
  color: #1e3a8a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Mode Screen */
.mode-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  padding: 1.5px 2px;
}

.mode-option {
  padding: 1px 5px;
  border-radius: 2px;
  cursor: pointer;
  color: #1e293b;
}

.mode-option.selected {
  background: #0f172a;
  color: #ffffff;
  font-weight: 800;
}

.mode-option.cursor-focus {
  outline: 2px solid #2563eb;
}

/* Table & Stat List Grid — Larger Clear Numbers */
.table-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: right;
}

.table-grid th {
  background: #e2e8f0;
  color: #090d16;
  padding: 2.5px 4px;
  border: 1px solid #94a3b8;
  text-align: center;
  font-weight: 800;
}

.table-grid td {
  padding: 2px 4px;
  border: 1px solid #cbd5e1;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.table-row-selected td {
  background: #dbeafe;
  font-weight: 800;
}

.cell-focused {
  background: #2563eb !important;
  color: #ffffff !important;
  font-weight: 800 !important;
}

/* Graph Canvas Overlay */
.graph-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.trace-banner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid #94a3b8;
  padding: 2px 6px;
  font-size: 11.5px;
  font-weight: 800;
  color: #090d16;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trace-top-label {
  position: absolute;
  top: 2px;
  left: 4px;
  background: rgba(255, 255, 255, 0.94);
  padding: 1.5px 5px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 800;
  border: 1px solid #e2e8f0;
}

/* Compact Keypad Section — Slightly Reduced Height While Keeping Every Key Crisp */
.ti-keypad {
  margin-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 4.5px;
}

.top-func-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 2px;
}

.key-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.key-sub-labels {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 8.8px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 2px;
  padding: 0 1.5px;
  min-height: 10px;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
}

.lbl-2nd {
  color: var(--ti-2nd-label);
}

.lbl-alpha {
  color: var(--ti-alpha-label);
}

.lbl-center {
  width: 100%;
  text-align: center;
}

.ti-btn {
  width: 100%;
  border: none;
  border-radius: 5px 5px 8px 8px;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.1s ease;
  position: relative;
  outline: none;
}

.ti-btn:active, .ti-btn.pressed {
  transform: translateY(1.5px) scale(0.97);
  filter: brightness(0.92);
}

.btn-graph {
  height: 20px;
  font-size: 9.5px;
  font-weight: 800;
  color: #090d16;
  background: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 100%);
  box-shadow: 0 2px 0 #475569, 0 2.5px 3px rgba(0,0,0,0.45);
  border-radius: 5px 5px 7px 7px;
}

.btn-graph.f-mode-glow {
  background: linear-gradient(180deg, #dcfce7 0%, #86efac 100%);
  box-shadow: 0 2px 0 #15803d, 0 0 8px rgba(74, 222, 128, 0.55);
}

.mid-control-area {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 7px;
  align-items: center;
  margin-bottom: 1px;
}

.mid-left-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

/* Compact Circular Blue D-Pad */
.dpad-container {
  width: 90px;
  height: 90px;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(circle at 35% 35%, #3b82f6 0%, #1d4ed8 75%, #1e3a8a 100%);
  border-radius: 50%;
  box-shadow:
    0 3px 7px rgba(0, 0, 0, 0.6),
    inset 0 2px 3px rgba(255, 255, 255, 0.4),
    0 0 0 2px #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dpad-center-cap {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #1e293b, #0f172a);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.15);
  pointer-events: none;
  z-index: 2;
}

.dpad-btn {
  position: absolute;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: transform 0.08s ease;
}

.dpad-btn:active, .dpad-btn.pressed {
  transform: scale(0.88);
  color: #bae6fd;
}

.dpad-up { top: 1px; left: 22px; width: 46px; height: 26px; }
.dpad-down { bottom: 1px; left: 22px; width: 46px; height: 26px; }
.dpad-left { left: 1px; top: 22px; width: 26px; height: 46px; }
.dpad-right { right: 1px; top: 22px; width: 26px; height: 46px; }

.main-key-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4.5px 5px;
}

.btn-dark {
  height: 24px;
  font-size: 10.5px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.75);
  background: linear-gradient(180deg, #434957 0%, #272b35 100%);
  box-shadow: 0 2px 0 #111318, 0 2.5px 3px rgba(0,0,0,0.45);
}

.btn-2nd {
  height: 24px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
  box-shadow: 0 2px 0 #075985, 0 2.5px 3px rgba(0,0,0,0.45);
}

.btn-alpha {
  height: 24px;
  font-size: 10px;
  font-weight: 800;
  color: #052e16;
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  box-shadow: 0 2px 0 #14532d, 0 2.5px 3px rgba(0,0,0,0.45);
}

.btn-num {
  height: 26.5px;
  font-size: 14px;
  font-weight: 800;
  color: #090d16;
  background: linear-gradient(180deg, #ffffff 0%, #e2e8f0 100%);
  box-shadow: 0 2px 0 #64748b, 0 2.5px 3px rgba(0,0,0,0.45);
  border-radius: 6px 6px 9px 9px;
}

.btn-op {
  height: 26.5px;
  font-size: 14.5px;
  font-weight: 800;
  color: #090d16;
  background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
  box-shadow: 0 2px 0 #475569, 0 2.5px 3px rgba(0,0,0,0.45);
  border-radius: 6px 6px 9px 9px;
}

.btn-enter {
  height: 26.5px;
  font-size: 10.5px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 100%);
  box-shadow: 0 2px 0 #1e3a8a, 0 2.5px 3px rgba(0,0,0,0.45);
  border-radius: 6px 6px 9px 9px;
}

.btn-enter.solve-mode-glow {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  color: #052e16;
  text-shadow: none;
  box-shadow: 0 2px 0 #14532d, 0 0 8px rgba(74, 222, 128, 0.65);
}

.lcd-off-screen {
  position: absolute;
  inset: 0;
  background: #14171d;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

@media (max-width: 400px) {
  .ti-casing {
    padding: 9px 10px 15px 10px;
    border-radius: 18px 18px 32px 32px;
  }
  .dpad-container {
    width: 82px;
    height: 82px;
  }
  .dpad-up { left: 18px; }
  .dpad-down { left: 18px; }
  .dpad-left { top: 18px; }
  .dpad-right { top: 18px; }
}


/* 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: transparent;
}
.app-topbar {
  color: var(--tool-text);
}
.app-topbar .subtitle {
  color: var(--tool-muted);
}

:root[data-site-theme="dark"] .brand-badge h1 {
  color: var(--tool-text);
}
