:root {
  --bg-body: #050505;
  --bg-frame: #1a1a1a;
  --lcd-bg: #0a120b;
  --lcd-text: #00ff66;
  --btn-gray: #2c2c2c;
  --btn-black: #141414;
  --accent: #00ff9c;
  --shift-color: #ffb800;
  --alpha-color: #ff4d4d;
  --deg-glow: #00ff66;
  --rad-glow: #ff7700;
}

body.theme-neon {
  --bg-body: #020b08;
  --bg-frame: #071f16;
  --lcd-bg: #021a12;
  --lcd-text: #00ff9c;
  --btn-gray: #0a3a27;
  --btn-black: #041910;
  --accent: #00ff9c;
  --shift-color: #ffb800;
  --alpha-color: #ff4d4d;
}

body.theme-cyberpunk {
  --bg-body: #0f051d;
  --bg-frame: #1c0b36;
  --lcd-bg: #150028;
  --lcd-text: #00ffff;
  --btn-gray: #3a156e;
  --btn-black: #160033;
  --accent: #ff007f;
  --shift-color: #ffb800;
  --alpha-color: #00ffff;
}

body.theme-retro {
  --bg-body: #2b2b2b;
  --bg-frame: #d1d5db;
  --lcd-bg: #1a2218;
  --lcd-text: #87986a;
  --btn-gray: #6b7280;
  --btn-black: #374151;
  --accent: #2563eb;
  --shift-color: #d97706;
  --alpha-color: #dc2626;
}

* {
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  margin: 0;
  background: var(--bg-body);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: #fff;
  transition: background 0.3s ease;
}

.calculator-frame {
  background: var(--bg-frame);
  width: 100%;
  max-width: 420px;
  padding: 20px;
  border-radius: 30px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8), inset 0 2px 5px rgba(255,255,255,0.1);
  border: 4px solid #222;
}

.calc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.site-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  color: #aaa;
  margin: 0;
  letter-spacing: 1.5px;
}

.model-number {
  font-size: 9px;
  color: #777;
  display: block;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-guide {
  background: #222;
  border: 1px solid #444;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 0 #000;
}

.theme-select {
  background: #111;
  color: var(--accent);
  border: 1px solid #444;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 10px;
  outline: none;
  cursor: pointer;
}

/* OLED LCD SCREEN WITH SCANLINES */
.screen-container {
  background: #000;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 15px;
  border: 2px solid #333;
  position: relative;
  overflow: hidden;
}

.screen-container::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 50%);
  pointer-events: none;
}

.lcd-screen {
  background: var(--lcd-bg);
  height: 95px;
  border-radius: 4px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 5px 15px rgba(0,0,0,0.8);
  color: var(--lcd-text);
  position: relative;
  background-image: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.15),
    rgba(0,0,0,0.15) 1px,
    transparent 1px,
    transparent 2px
  );
}

.status-indicators {
  display: flex;
  gap: 6px;
  margin-bottom: 2px;
}

.indicator {
  font-size: 8px;
  color: #444;
  background: rgba(0,0,0,0.4);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.indicator.deg.active {
  color: var(--deg-glow);
  background: rgba(0, 255, 102, 0.15);
  text-shadow: 0 0 8px var(--deg-glow);
  border: 1px solid rgba(0, 255, 102, 0.4);
}

.indicator.rad.active {
  color: var(--rad-glow);
  background: rgba(255, 119, 0, 0.15);
  text-shadow: 0 0 8px var(--rad-glow);
  border: 1px solid rgba(255, 119, 0, 0.4);
}

.indicator.shift-ind.active {
  color: var(--shift-color);
  background: rgba(255, 184, 0, 0.15);
  text-shadow: 0 0 8px var(--shift-color);
  border: 1px solid rgba(255, 184, 0, 0.4);
}

.indicator.alpha-ind.active {
  color: var(--alpha-color);
  background: rgba(255, 77, 77, 0.15);
  text-shadow: 0 0 8px var(--alpha-color);
  border: 1px solid rgba(255, 77, 77, 0.4);
}

.exp-layer {
  font-family: 'Orbitron', sans-serif;
  font-size: 15px;
  text-align: left;
  height: 25px;
  overflow-x: auto;
  white-space: nowrap;
}

.res-layer {
  font-family: 'Orbitron', sans-serif;
  font-size: 26px;
  font-weight: 700;
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
  text-shadow: 0 0 4px var(--lcd-text);
}

/* CONTROL ROW */
.control-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.btn-ctrl {
  width: 48px;
  height: 34px;
  border-radius: 12px;
  border: none;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 #000;
}

.shift { background: var(--shift-color); color: #000; }
.alpha { background: var(--alpha-color); color: #fff; }
.mode, .on { background: #444; color: #fff; }

.replayer {
  width: 85px;
  height: 85px;
  background: radial-gradient(circle at top, #2a2a2a, #111);
  border-radius: 50%;
  position: relative;
  border: 3px solid #000;
}

.dir-btn {
  position: absolute;
  width: 28px;
  height: 28px;
  background: #1c1c1c;
  border-radius: 6px;
  border: none;
  color: #ccc;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 0 #000;
}

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

/* GRID ALIGNMENTS & UNIFORM BUTTON WRAPPER */
.button-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.scientific { grid-template-columns: repeat(6, 1fr); }
.main-pad { grid-template-columns: repeat(5, 1fr); }

.btn-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 100%;
}

.shift-label {
  font-size: 8px;
  color: var(--shift-color);
  height: 12px;
  line-height: 12px;
  font-weight: bold;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
  display: block;
}

.alpha-label {
  color: var(--alpha-color);
  font-size: 8px;
  font-weight: bold;
  position: absolute;
  top: 0px;
  right: 2px;
  opacity: 0.8;
  transition: all 0.2s ease;
  pointer-events: none;
}

button {
  width: 100%;
  padding: 9px 0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.1s;
  box-shadow: 0 4px 0 #000;
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #000;
}

.scientific button {
  background: var(--btn-black);
  color: #fff;
  font-size: 11px;
  border-radius: 6px;
  padding: 7px 0;
}

.num { background: var(--btn-gray); color: #fff; font-size: 16px; }
.op { background: var(--btn-black); color: var(--accent); font-size: 16px; }
.action { background: #555; color: #fff; font-size: 11px; font-weight: 700; }
.del, .ac { background: #a33; }
.equal { background: #fff; color: #000; font-size: 18px; }

/* SHIFT & ALPHA GLOW EFFECTS */
body.shift-mode-active .has-shift button {
  box-shadow: 0 0 10px var(--shift-color) !important;
  border: 1px solid var(--shift-color);
}

body.shift-mode-active .shift-label {
  text-shadow: 0 0 8px var(--shift-color);
  font-size: 9px;
  transform: scale(1.1);
}

body.alpha-mode-active .has-alpha button {
  box-shadow: 0 0 10px var(--alpha-color) !important;
  border: 1px solid var(--alpha-color);
}

body.alpha-mode-active .alpha-label {
  text-shadow: 0 0 8px var(--alpha-color);
  font-size: 9px;
  transform: scale(1.1);
  opacity: 1;
}

/* COMPACT MODAL & FULLSCREEN STYLES (FIXED SCROLLING & OVERFLOW) */
.ai-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: none; justify-content: center; align-items: center; z-index: 2000; padding: 10px;
}

.ai-content {
  background: #181818; width: 100%; max-width: 420px; border-radius: 12px; padding: 12px;
  border: 1px solid var(--accent); box-shadow: 0 0 15px rgba(0,255,156,0.2);
  display: flex; flex-direction: column; max-height: 90vh; transition: all 0.2s ease;
  overflow: hidden;
}

.ai-content.fullscreen {
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

.ai-body {
  overflow-y: auto;
  flex: 1;
  padding-right: 2px;
}

.btn-fullscreen {
  background: #333 !important; color: #fff !important; font-size: 13px !important;
  border: 1px solid #555 !important; padding: 2px 6px !important; border-radius: 4px !important; cursor: pointer;
}

.ai-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-shrink: 0; }
.ai-header h3 { margin: 0; color: var(--accent); font-size: 14px; }
.ai-header button { background: none; color: #fff; font-size: 18px; width: auto; box-shadow: none; padding: 0; border: none; cursor: pointer; }

.ai-tab-row { display: flex; gap: 5px; margin-bottom: 8px; }
.tab-btn { background: #111; color: #888; border: 1px solid #333; font-size: 11px; padding: 5px 0; border-radius: 6px; box-shadow: none; flex: 1; }
.tab-btn.active { background: var(--accent); color: #000; font-weight: bold; border-color: var(--accent); }

.ai-sec { margin-bottom: 6px; }

/* MODERN TEXTAREA THEME */
.custom-dark-textarea {
  width: 100%;
  height: 70px;
  background: #0d1117;
  color: #00ff9c;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 8px;
  resize: none;
  font-size: 13px;
  font-family: 'Poppins', sans-serif;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
  outline: none;
  transition: all 0.2s ease;
}

.custom-dark-textarea:focus {
  border-color: #00ff9c;
  box-shadow: 0 0 8px rgba(0, 255, 156, 0.3);
}

.ai-response-box { 
  background: #0d0d0d; 
  padding: 10px; 
  border-radius: 6px; 
  max-height: 200px; 
  overflow-y: auto !important; 
  font-size: 12px; 
  color: #ddd; 
  border: 1px solid #333; 
  line-height: 1.4;
  margin-top: 8px;
  word-break: break-word;
}

.ai-content.fullscreen .ai-response-box {
  max-height: 60vh !important;
  flex: 1;
}

.ai-btns { display: flex; gap: 6px; margin: 8px 0; flex-shrink: 0; }
.ai-btns button { background: var(--accent); color: #000; font-weight: bold; font-size: 11px; padding: 7px 0; }
.ai-loader { text-align: center; color: var(--accent); font-size: 11px; margin: 4px 0; }

.notice-tag { font-size: 10px; color: #aaa; display: block; margin-bottom: 4px; }

/* DRAW PAD HEIGHT UPDATED */
.canvas-wrapper { position: relative; width: 100%; }
#mathCanvas { 
  background: #0a0a0a; 
  border: 1px solid var(--accent); 
  border-radius: 6px; 
  touch-action: none; 
  cursor: crosshair; 
  display: block; 
  width: 100%; 
  height: 195px; /* Small mode me canvas ki height ~25% badha di gayi hai */
}
.ai-content.fullscreen #mathCanvas {
  height: 40vh !important; /* Fullscreen mode me yeh screen ka exactly 40% height lega */
}

.btn-clear-pad { position: absolute; right: 5px; bottom: 5px; width: auto; font-size: 9px; padding: 2px 8px; background: #a33; color: #fff; box-shadow: none; border-radius: 4px; }

.scan-warning { margin: 0 0 8px 0; padding: 6px 10px; background: rgba(255,184,0,0.1); border-left: 3px solid var(--shift-color); font-size: 10px; color: #ffb800; border-radius: 4px; }
#imagePreview { max-width: 100%; max-height: 100px; border-radius: 6px; border: 1px solid #444; }

.cursor {
  display: inline-block;
  width: 2px;
  height: 15px;
  background: currentColor;
  margin-left: 1px;
  vertical-align: middle;
  animation: blink-animation 0.8s step-end infinite;
}

.scan-input-box {
  margin-top: 8px;
  text-align: center;
}

.custom-file-upload {
  display: inline-block;
  background: var(--btn-black);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.custom-file-upload:active {
  background: var(--accent);
  color: #000;
}

#imageInput {
  display: none;
}

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