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

/* ==========================================================================
   THEME DEFINITIONS
   ========================================================================== */
:root, [data-theme="deep-cosmos"] {
  --bg-gradient: radial-gradient(circle at 20% 20%, #1e1b4b 0%, #0f172a 50%, #030712 100%);
  --panel-bg: rgba(15, 23, 42, 0.75);
  --panel-border: rgba(147, 51, 234, 0.25);
  --panel-glow: 0 0 40px rgba(124, 58, 237, 0.15);
  --display-bg: rgba(2, 6, 23, 0.7);
  --display-border: rgba(147, 51, 234, 0.2);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #8b5cf6;
  --accent-hover: #7c3aed;
  --accent-glow: rgba(139, 92, 246, 0.4);
  --btn-num: rgba(255, 255, 255, 0.05);
  --btn-num-hover: rgba(255, 255, 255, 0.12);
  --btn-op: rgba(139, 92, 246, 0.18);
  --btn-op-text: #c084fc;
  --btn-ctrl: rgba(239, 68, 68, 0.15);
  --btn-ctrl-text: #f87171;
  --btn-sci: rgba(56, 189, 248, 0.12);
  --btn-sci-text: #38bdf8;
  --btn-eq: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  --btn-eq-text: #ffffff;
  --card-bg: rgba(30, 41, 59, 0.6);
  --shadow-main: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

[data-theme="cyberpunk-neon"] {
  --bg-gradient: radial-gradient(circle at 10% 10%, #052e16 0%, #022c22 40%, #020617 100%);
  --panel-bg: rgba(6, 30, 20, 0.85);
  --panel-border: rgba(16, 185, 129, 0.35);
  --panel-glow: 0 0 45px rgba(16, 185, 129, 0.2);
  --display-bg: rgba(2, 20, 12, 0.85);
  --display-border: rgba(16, 185, 129, 0.3);
  --text-main: #f0fdf4;
  --text-muted: #6ee7b7;
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-glow: rgba(16, 185, 129, 0.5);
  --btn-num: rgba(16, 185, 129, 0.08);
  --btn-num-hover: rgba(16, 185, 129, 0.18);
  --btn-op: rgba(245, 158, 11, 0.18);
  --btn-op-text: #fbbf24;
  --btn-ctrl: rgba(244, 63, 94, 0.18);
  --btn-ctrl-text: #fb7185;
  --btn-sci: rgba(6, 182, 212, 0.15);
  --btn-sci-text: #22d3ee;
  --btn-eq: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --btn-eq-text: #022c22;
  --card-bg: rgba(6, 44, 28, 0.7);
  --shadow-main: 0 25px 50px -12px rgba(2, 44, 34, 0.8);
}

[data-theme="sunset-horizon"] {
  --bg-gradient: radial-gradient(circle at 80% 20%, #4c0519 0%, #2e1065 50%, #09090b 100%);
  --panel-bg: rgba(36, 16, 35, 0.8);
  --panel-border: rgba(244, 63, 94, 0.3);
  --panel-glow: 0 0 40px rgba(244, 63, 94, 0.2);
  --display-bg: rgba(18, 8, 20, 0.8);
  --display-border: rgba(244, 63, 94, 0.25);
  --text-main: #fff1f2;
  --text-muted: #fda4af;
  --accent: #f43f5e;
  --accent-hover: #e11d48;
  --accent-glow: rgba(244, 63, 94, 0.4);
  --btn-num: rgba(255, 255, 255, 0.06);
  --btn-num-hover: rgba(255, 255, 255, 0.14);
  --btn-op: rgba(251, 146, 60, 0.2);
  --btn-op-text: #fdba74;
  --btn-ctrl: rgba(244, 63, 94, 0.2);
  --btn-ctrl-text: #fda4af;
  --btn-sci: rgba(192, 132, 252, 0.15);
  --btn-sci-text: #d8b4fe;
  --btn-eq: linear-gradient(135deg, #f43f5e 0%, #ea580c 100%);
  --btn-eq-text: #ffffff;
  --card-bg: rgba(50, 20, 45, 0.6);
  --shadow-main: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

[data-theme="nordic-frost"] {
  --bg-gradient: radial-gradient(circle at 50% 10%, #e0f2fe 0%, #f1f5f9 60%, #e2e8f0 100%);
  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(2, 132, 199, 0.2);
  --panel-glow: 0 0 35px rgba(2, 132, 199, 0.12);
  --display-bg: rgba(248, 250, 252, 0.95);
  --display-border: rgba(203, 213, 225, 0.8);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --accent-glow: rgba(2, 132, 199, 0.25);
  --btn-num: rgba(241, 245, 249, 0.9);
  --btn-num-hover: rgba(226, 232, 240, 1);
  --btn-op: rgba(2, 132, 199, 0.12);
  --btn-op-text: #0284c7;
  --btn-ctrl: rgba(239, 68, 68, 0.1);
  --btn-ctrl-text: #dc2626;
  --btn-sci: rgba(99, 102, 241, 0.1);
  --btn-sci-text: #4f46e5;
  --btn-eq: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  --btn-eq-text: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.9);
  --shadow-main: 0 25px 45px -10px rgba(15, 23, 42, 0.12);
}

[data-theme="amethyst-nebula"] {
  --bg-gradient: radial-gradient(circle at 30% 30%, #3b0764 0%, #180828 60%, #030008 100%);
  --panel-bg: rgba(30, 10, 48, 0.8);
  --panel-border: rgba(217, 70, 239, 0.3);
  --panel-glow: 0 0 45px rgba(217, 70, 239, 0.2);
  --display-bg: rgba(15, 4, 25, 0.85);
  --display-border: rgba(217, 70, 239, 0.25);
  --text-main: #faf5ff;
  --text-muted: #e9d5ff;
  --accent: #d946ef;
  --accent-hover: #c026d3;
  --accent-glow: rgba(217, 70, 239, 0.4);
  --btn-num: rgba(255, 255, 255, 0.05);
  --btn-num-hover: rgba(255, 255, 255, 0.13);
  --btn-op: rgba(232, 121, 249, 0.18);
  --btn-op-text: #f0abfc;
  --btn-ctrl: rgba(251, 113, 133, 0.18);
  --btn-ctrl-text: #fda4af;
  --btn-sci: rgba(168, 85, 247, 0.18);
  --btn-sci-text: #c084fc;
  --btn-eq: linear-gradient(135deg, #d946ef 0%, #9333ea 100%);
  --btn-eq-text: #ffffff;
  --card-bg: rgba(45, 16, 70, 0.65);
  --shadow-main: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

[data-theme="retro-synthwave"] {
  --bg-gradient: radial-gradient(circle at 50% 20%, #1e0533 0%, #0c021c 60%, #030008 100%);
  --panel-bg: rgba(20, 5, 35, 0.9);
  --panel-border: rgba(6, 182, 212, 0.4);
  --panel-glow: 0 0 50px rgba(236, 72, 153, 0.25);
  --display-bg: rgba(8, 2, 18, 0.95);
  --display-border: rgba(236, 72, 153, 0.4);
  --text-main: #ffffff;
  --text-muted: #22d3ee;
  --accent: #ec4899;
  --accent-hover: #db2777;
  --accent-glow: rgba(236, 72, 153, 0.5);
  --btn-num: rgba(34, 211, 238, 0.08);
  --btn-num-hover: rgba(34, 211, 238, 0.18);
  --btn-op: rgba(236, 72, 153, 0.2);
  --btn-op-text: #f472b6;
  --btn-ctrl: rgba(244, 63, 94, 0.2);
  --btn-ctrl-text: #fb7185;
  --btn-sci: rgba(34, 211, 238, 0.15);
  --btn-sci-text: #67e8f9;
  --btn-eq: linear-gradient(135deg, #ec4899 0%, #06b6d4 100%);
  --btn-eq-text: #ffffff;
  --card-bg: rgba(32, 10, 54, 0.75);
  --shadow-main: 0 25px 50px -12px rgba(236, 72, 153, 0.3);
}

/* ==========================================================================
   GLOBAL RESET & LAYOUT
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100vh;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  background: var(--bg-gradient);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.4s ease, color 0.3s ease;
}

/* Ambient Background Light Orbs */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.28;
  animation: floatOrb 18s ease-in-out infinite alternate;
}

.orb-1 {
  width: 450px;
  height: 450px;
  background: var(--accent);
  top: -100px;
  left: 10%;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: #38bdf8;
  bottom: -150px;
  right: 10%;
  animation-duration: 24s;
  animation-direction: alternate-reverse;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.1); }
  100% { transform: translate(-40px, 70px) scale(0.95); }
}

/* App Wrapper */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top, 20px)) max(16px, env(safe-area-inset-right, 16px)) max(40px, env(safe-area-inset-bottom, 40px)) max(16px, env(safe-area-inset-left, 16px));
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
  width: 100%;
}

/* ==========================================================================
   HEADER & NAVIGATION
   ========================================================================== */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: var(--shadow-main);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--btn-eq);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--btn-eq-text);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.brand-info h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text-main) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.install-app-btn {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25) 0%, rgba(99, 102, 241, 0.25) 100%);
  border-color: rgba(139, 92, 246, 0.4);
  color: var(--accent);
  position: relative;
}

.install-app-btn:hover {
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #fff;
}

.install-pulse-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
  animation: installPulse 2s infinite;
}

@keyframes installPulse {
  0% { transform: scale(0.9); opacity: 0.8; box-shadow: 0 0 4px #22c55e; }
  50% { transform: scale(1.3); opacity: 1; box-shadow: 0 0 12px #22c55e; }
  100% { transform: scale(0.9); opacity: 0.8; box-shadow: 0 0 4px #22c55e; }
}

.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--panel-bg);
}

.desktop-only-btn {
  display: inline-flex;
}

.quick-menu-toggle-btn {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.15);
  color: var(--accent);
}

.quick-menu-toggle-btn:hover {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 16px var(--accent-glow);
}

/* Mode Navigation Wrapper with Scroll Controls */
.mode-nav-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 4px;
}

.nav-scroll-arrow {
  width: 32px;
  height: 42px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-muted);
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  z-index: 5;
  flex-shrink: 0;
  transition: all 0.2s ease;
  user-select: none;
}

.nav-scroll-arrow:hover {
  color: var(--text-main);
  background: var(--accent);
  border-color: var(--accent);
}

/* Tab Bar */
.mode-nav {
  display: flex;
  gap: 8px;
  padding: 6px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  flex: 1;
}

.mode-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  flex: 1;
  min-width: 105px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
  scroll-snap-align: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn svg {
  width: 17px;
  height: 17px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.tab-btn.active {
  background: var(--btn-eq);
  color: var(--btn-eq-text);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.tab-btn.active svg {
  transform: scale(1.1);
}

/* Main Workspace */
.main-stage {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  position: relative;
}

.calculator-card {
  flex: 1;
  background: var(--panel-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow-main), var(--panel-glow);
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   DISPLAY SCREEN
   ========================================================================== */
.display-wrapper {
  background: var(--display-bg);
  border: 1px solid var(--display-border);
  border-radius: 18px;
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4);
  position: relative;
}

.display-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-badges {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-badge {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.status-badge.accent {
  background: var(--accent);
  color: #fff;
}

.status-badge.clickable {
  cursor: pointer;
  user-select: none;
}

.status-badge.clickable:hover {
  background: var(--accent-hover);
  color: #fff;
}

.hidden {
  display: none !important;
}

.copy-btn {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.copy-btn:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}

.display-expression {
  min-height: 24px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  color: var(--text-muted);
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  margin-bottom: 4px;
}

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

.display-main {
  font-family: 'JetBrains Mono', monospace;
  font-size: 38px;
  font-weight: 700;
  text-align: right;
  color: var(--text-main);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

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

.display-preview {
  min-height: 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  text-align: right;
  opacity: 0.85;
}

/* ==========================================================================
   MEMORY BAR
   ========================================================================== */
.memory-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.mem-btn {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mem-btn:hover {
  background: var(--btn-sci);
  color: var(--btn-sci-text);
  border-color: var(--accent);
}

/* ==========================================================================
   KEYPAD BUTTONS GRID
   ========================================================================== */
.keypad-container {
  display: grid;
  gap: 10px;
}

.standard-scientific-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.scientific-section {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.btn {
  position: relative;
  min-height: 54px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--btn-num);
  color: var(--text-main);
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: var(--btn-num-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn.op {
  background: var(--btn-op);
  color: var(--btn-op-text);
  font-size: 20px;
}

.btn.control {
  background: var(--btn-ctrl);
  color: var(--btn-ctrl-text);
  font-weight: 700;
}

.btn.sci {
  background: var(--btn-sci);
  color: var(--btn-sci-text);
  font-size: 14px;
  font-weight: 600;
  min-height: 44px;
}

.btn.sci sub, .btn.sci sup {
  font-size: 10px;
}

.btn.equals {
  background: var(--btn-eq);
  color: var(--btn-eq-text);
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn.wide {
  grid-column: span 2;
}

/* ==========================================================================
   PROGRAMMER MODE STYLES
   ========================================================================== */
.programmer-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.prog-base-selector {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: var(--display-bg);
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--display-border);
}

.prog-base-item {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.prog-base-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.prog-base-item.active-base {
  background: var(--btn-op);
  border: 1px solid var(--accent);
}

.prog-base-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.prog-base-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prog-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.select-dropdown {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.select-dropdown option {
  background: #0f172a;
  color: #fff;
}

/* 64-Bit Interactive Bitfield */
.prog-bitfield-wrapper {
  background: var(--display-bg);
  border: 1px solid var(--display-border);
  border-radius: 14px;
  padding: 14px;
}

.prog-bit-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.prog-byte-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prog-byte-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

.prog-bits-row {
  display: flex;
  gap: 3px;
}

.prog-bit-btn {
  width: 22px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.prog-bit-btn.bit-on {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.prog-bit-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

/* ==========================================================================
   FINANCIAL CALCULATOR STYLES
   ========================================================================== */
.finance-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
  overflow-x: auto;
}

.sub-tab-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.sub-tab-btn.active {
  background: var(--btn-sci);
  color: var(--btn-sci-text);
  border-color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-field {
  background: var(--display-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.finance-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.result-card {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result-card.highlight {
  border-color: var(--accent);
  background: var(--btn-op);
}

.result-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.result-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-main);
}

.progress-bar-container {
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
  margin: 12px 0 6px 0;
}

.progress-bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.bar-principal { background: var(--accent); }
.bar-interest { background: #f59e0b; }

/* Tip Slider & Quick % Buttons */
.quick-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.chip-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-btn.active, .chip-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ==========================================================================
   UNIT CONVERTER STYLES
   ========================================================================== */
.converter-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.converter-categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.converter-categories::-webkit-scrollbar {
  display: none;
}

.converter-card-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.convert-box {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.swap-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--btn-eq);
  color: #fff;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 0.2s ease;
}

.swap-btn:hover {
  transform: rotate(180deg) scale(1.05);
}

/* ==========================================================================
   DATE CALCULATOR STYLES
   ========================================================================== */
.date-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.date-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.date-metric-card {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 16px;
  text-align: center;
}

.metric-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}

.metric-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

/* ==========================================================================
   GRAPHING ENGINE STYLES
   ========================================================================== */
.graph-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.graph-formula-bar {
  display: flex;
  gap: 10px;
  align-items: center;
}

.graph-presets-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 360px;
  background: #020617;
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  overflow: hidden;
}

#graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.canvas-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   HISTORY DRAWER & SLIDE-OUT
   ========================================================================== */
.history-drawer {
  position: fixed;
  top: 0;
  right: -380px;
  width: 360px;
  max-width: 90vw;
  height: 100vh;
  background: var(--panel-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-left: 1px solid var(--panel-border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
  transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--panel-border);
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}

.history-actions-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.history-item:hover {
  transform: translateX(-4px);
  border-color: var(--accent);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.history-item-mode {
  text-transform: uppercase;
  font-weight: 700;
}

.history-item-expr {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
  word-break: break-all;
}

.history-item-res {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  text-align: right;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  gap: 8px;
  text-align: center;
}

/* Overlay Backdrop */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   THEME & SHORTCUT MODALS
   ========================================================================== */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  background: var(--panel-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px;
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 120;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.theme-btn {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.theme-btn.active-theme {
  border-color: var(--accent);
  background: var(--btn-op);
  box-shadow: 0 0 16px var(--accent-glow);
}

.theme-color-preview {
  width: 20px;
  height: 20px;
  border-radius: 50%;
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.shortcut-table td {
  padding: 8px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}

.kbd {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-main);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
#omni-toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.omni-toast {
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  color: #fff;
  padding: 10px 18px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.omni-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   PORTFOLIO FOOTER & ABOUT MODAL (MALIK DIGITAL SKILLS)
   ========================================================================== */
.app-footer {
  margin-top: 24px;
  padding: 16px 20px;
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.footer-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}

.footer-desc strong {
  color: var(--text-main);
  font-weight: 600;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link,
.footer-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.footer-link:hover,
.footer-link-btn:hover {
  background: var(--btn-op);
  border-color: var(--accent);
  color: #ffffff;
  transform: translateY(-1px);
}

.footer-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--btn-op);
  border: 1px solid var(--panel-border);
}

.portfolio-tags-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.portfolio-tag-card {
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.portfolio-tag-card strong {
  font-size: 13px;
  color: var(--text-main);
}

.portfolio-tag-card span {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.info-author-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  flex-wrap: wrap;
  gap: 12px;
}

.author-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.author-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  font-weight: 700;
}

.author-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.author-email {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-primary-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--btn-eq);
  color: var(--btn-eq-text);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 4px 15px var(--accent-glow);
  transition: all 0.2s ease;
}

.btn-primary-link:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
}

/* ==========================================================================
   QUICK ACTIONS MODAL & MOBILE INSTALL BANNER
   ========================================================================== */
.quick-menu-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.quick-act-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.quick-act-card:hover {
  background: rgba(139, 92, 246, 0.16);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px var(--accent-glow);
}

.quick-act-card:active {
  transform: scale(0.98);
}

.quick-act-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.quick-act-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quick-act-text strong {
  font-size: 13.5px;
  color: var(--text-main);
  font-weight: 600;
}

.quick-act-text span {
  font-size: 11px;
  color: var(--text-muted);
}

.quick-setting-section {
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.quick-setting-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.sound-profile-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sound-chip,
.angle-chip {
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}

.sound-chip:hover,
.angle-chip:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
}

.sound-chip.active,
.angle-chip.active {
  background: var(--btn-eq);
  color: var(--btn-eq-text);
  border-color: transparent;
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* Floating Mobile Install App Banner */
.mobile-install-banner {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 440px;
  background: var(--panel-bg);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7), 0 0 24px var(--accent-glow);
  z-index: 999;
  animation: slideUpBanner 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpBanner {
  0% { transform: translate(-50%, 60px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}

.banner-icon-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.banner-icon-wrap img {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.banner-text strong {
  font-size: 13.5px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner-text span {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.banner-install-btn {
  padding: 7px 16px;
  background: var(--btn-eq);
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 10px var(--accent-glow);
  transition: all 0.2s ease;
  font-family: inherit;
}

.banner-install-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.03);
}

.banner-dismiss-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s ease;
}

.banner-dismiss-btn:hover {
  color: #f87171;
  background: rgba(239, 68, 68, 0.15);
  border-color: #f87171;
}


/* ==========================================================================
   MULTI-TIER RESPONSIVE DESIGN FOR ALL MOBILE & TABLET DEVICES
   ========================================================================== */

/* 1. Tablets & Medium Screens (<= 1024px) */
@media (max-width: 1024px) {
  .app-container {
    padding: max(16px, env(safe-area-inset-top, 16px)) max(14px, env(safe-area-inset-right, 14px)) max(32px, env(safe-area-inset-bottom, 32px)) max(14px, env(safe-area-inset-left, 14px));
    gap: 16px;
  }

  .calculator-card {
    padding: 20px;
    border-radius: 20px;
  }
}

/* 2. Large Phones, Phablets & Small Tablets (<= 768px) */
@media (max-width: 768px) {
  .app-container {
    padding: max(12px, env(safe-area-inset-top, 12px)) max(10px, env(safe-area-inset-right, 10px)) max(28px, env(safe-area-inset-bottom, 28px)) max(10px, env(safe-area-inset-left, 10px));
    gap: 14px;
  }

  .header-bar {
    padding: 10px 14px;
    border-radius: 16px;
  }

  .brand-info h1 {
    font-size: 17px;
  }

  .brand-info span {
    font-size: 10px;
  }

  .header-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 10px;
  }

  .tab-btn {
    min-width: 90px;
    padding: 8px 12px;
    font-size: 12.5px;
    gap: 6px;
    border-radius: 10px;
  }

  .calculator-card {
    padding: 16px 14px;
    border-radius: 18px;
  }

  .display-wrapper {
    padding: 10px 14px;
    margin-bottom: 10px;
    border-radius: 14px;
  }

  .display-main {
    font-size: clamp(24px, 6.5vw, 32px);
    line-height: 1.15;
  }

  .display-expression {
    font-size: 13px;
    min-height: 18px;
  }

  .display-preview {
    font-size: 11.5px;
    min-height: 14px;
  }

  .memory-bar {
    gap: 4px;
    margin-bottom: 10px;
  }

  .mem-btn {
    padding: 5px 3px;
    font-size: 9.5px;
    border-radius: 6px;
  }

  .standard-scientific-grid {
    gap: 7px;
  }

  .scientific-section {
    gap: 5px;
    margin-bottom: 8px;
    padding-bottom: 8px;
  }

  .btn {
    min-height: clamp(42px, 6vh, 48px);
    font-size: 16px;
    padding: 6px;
    border-radius: 12px;
  }

  .btn.sci {
    min-height: 40px;
    font-size: 13px;
    padding: 6px 2px;
    border-radius: 10px;
  }

  .btn.op {
    font-size: 18px;
  }

  .btn.equals {
    font-size: 20px;
  }

  /* Programmer Mode */
  .prog-base-selector {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
  }

  .prog-bit-grid {
    gap: 8px;
    justify-content: center;
  }

  .prog-bits-row {
    gap: 2px;
  }

  .prog-bit-btn {
    width: 19px;
    height: 25px;
    font-size: 11px;
  }

  /* Converter Mode */
  .converter-card-pair {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .swap-btn {
    margin: 4px auto;
    width: 40px;
    height: 40px;
  }

  /* Financial Mode */
  .finance-results-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  /* Date Mode */
  .date-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* 2D Graph Mode */
  .canvas-wrapper {
    height: 280px;
    border-radius: 14px;
  }

  /* Modals */
  .modal {
    width: calc(100vw - 28px);
    max-width: 480px;
    padding: 20px 16px;
    border-radius: 16px;
    max-height: 88vh;
  }

  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .portfolio-tags-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .footer-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .info-author-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* 3. Small Tablets & Phones (<= 640px) */
@media (max-width: 640px) {
  .desktop-only-btn {
    display: none !important;
  }

  .quick-menu-toggle-btn {
    display: inline-flex !important;
  }

  .nav-scroll-arrow {
    display: flex;
  }

  .header-bar {
    padding: 8px 12px;
    border-radius: 14px;
  }

  .brand {
    gap: 8px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
  }

  .brand-info h1 {
    font-size: 16px;
    letter-spacing: -0.3px;
  }

  .header-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 10px;
  }

  .quick-actions-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mode-nav {
    padding: 4px;
    border-radius: 12px;
    gap: 6px;
  }

  .tab-btn {
    min-width: 82px;
    padding: 8px 10px;
    font-size: 12px;
    gap: 6px;
    border-radius: 9px;
  }

  .tab-btn svg {
    width: 15px;
    height: 15px;
  }
}

/* 4. Standard Mobile Phones (<= 480px) */
@media (max-width: 480px) {
  .app-container {
    padding: max(8px, env(safe-area-inset-top, 8px)) 8px max(24px, env(safe-area-inset-bottom, 24px)) 8px;
    gap: 10px;
  }

  .header-bar {
    padding: 8px 10px;
    border-radius: 14px;
  }

  .brand {
    gap: 8px;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .brand-icon svg {
    width: 17px;
    height: 17px;
  }

  .brand-info h1 {
    font-size: 14.5px;
    letter-spacing: -0.3px;
  }

  .brand-info span {
    display: none;
  }

  .header-actions {
    gap: 5px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border-radius: 9px;
  }

  .icon-btn svg {
    width: 16px;
    height: 16px;
  }

  .mode-nav {
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
  }

  .tab-btn {
    min-width: 76px;
    padding: 7px 8px;
    font-size: 11.5px;
    gap: 5px;
    border-radius: 8px;
  }

  .tab-btn svg {
    width: 14px;
    height: 14px;
  }

  .calculator-card {
    padding: 12px 10px;
    border-radius: 14px;
  }

  .display-wrapper {
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 12px;
  }

  .display-main {
    font-size: clamp(22px, 7vw, 28px);
  }

  .display-expression {
    font-size: 12.5px;
    min-height: 18px;
  }

  .display-preview {
    font-size: 11.5px;
    min-height: 14px;
  }

  .meta-badges {
    gap: 4px;
  }

  .status-badge {
    padding: 1px 6px;
    font-size: 10px;
    border-radius: 4px;
  }

  .keypad-container.standard-scientific-grid {
    gap: 6px;
  }

  .memory-bar {
    gap: 3px;
    margin-bottom: 8px;
  }

  .mem-btn {
    padding: 5px 2px;
    font-size: 9.5px;
    border-radius: 5px;
  }

  .btn {
    min-height: 44px;
    font-size: 15px;
    padding: 6px;
    border-radius: 10px;
  }

  .scientific-section {
    gap: 5px;
    margin-bottom: 8px;
    padding-bottom: 8px;
  }

  .btn.sci {
    min-height: 36px;
    font-size: 12px;
    padding: 4px 1px;
    border-radius: 8px;
  }

  .btn.op {
    font-size: 17px;
  }

  .btn.control {
    font-size: 15px;
  }

  .btn.equals {
    font-size: 18px;
  }

  /* Programmer Mode Mobile */
  .prog-base-selector {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 8px;
    border-radius: 10px;
  }

  .prog-base-item {
    padding: 6px 8px;
    border-radius: 7px;
  }

  .prog-base-label {
    font-size: 9.5px;
  }

  .prog-base-value {
    font-size: 13px;
  }

  .prog-controls-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .select-dropdown {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
  }

  .prog-bitfield-wrapper {
    padding: 8px;
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .prog-bit-grid {
    gap: 6px;
    justify-content: center;
  }

  .prog-bits-row {
    gap: 2px;
  }

  .prog-bit-btn {
    width: 17px;
    height: 23px;
    font-size: 10px;
    border-radius: 3px;
  }

  .prog-byte-label {
    font-size: 8.5px;
  }

  .prog-btn {
    min-height: 36px;
    font-size: 12.5px;
    padding: 4px;
  }

  /* Financial Mode Mobile */
  .finance-tabs {
    gap: 4px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .sub-tab-btn {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 7px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }

  .input-group {
    gap: 4px;
  }

  .input-group label {
    font-size: 10.5px;
  }

  .input-field {
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 8px;
  }

  .finance-results-grid {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 12px;
  }

  .result-card {
    padding: 10px 12px;
    border-radius: 8px;
  }

  .result-label {
    font-size: 10.5px;
  }

  .result-value {
    font-size: 18px;
  }

  .quick-chips {
    gap: 4px;
    margin-top: 4px;
  }

  .chip-btn {
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 6px;
  }

  /* Converter Mode Mobile */
  .converter-container {
    gap: 12px;
  }

  .converter-categories {
    gap: 4px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .conv-cat-chip {
    padding: 5px 10px;
    font-size: 11.5px;
    border-radius: 6px;
  }

  .convert-box {
    padding: 10px 12px;
    border-radius: 10px;
    gap: 8px;
  }

  .convert-box label {
    font-size: 10.5px;
  }

  /* Date Mode Mobile */
  .date-container {
    gap: 12px;
  }

  .date-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .date-metric-card {
    padding: 10px 6px;
    border-radius: 8px;
  }

  .metric-num {
    font-size: 20px;
  }

  .metric-desc {
    font-size: 10px;
  }

  /* 2D Graph Mode Mobile */
  .graph-container {
    gap: 10px;
  }

  .graph-formula-bar {
    gap: 6px;
  }

  .graph-presets-row {
    gap: 4px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .graph-preset-btn {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 6px;
  }

  .canvas-wrapper {
    height: 240px;
    border-radius: 10px;
  }

  .canvas-controls {
    bottom: 6px;
    right: 6px;
    gap: 4px;
    padding: 2px;
  }

  .canvas-controls .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  /* History Tape Drawer Mobile */
  .history-drawer {
    width: 100%;
    max-width: 100vw;
    right: -100vw;
    border-left: 0;
  }

  .drawer-header {
    padding: 14px;
  }

  .history-actions-bar {
    padding: 8px 14px;
    gap: 5px;
    flex-wrap: wrap;
  }

  .history-list {
    padding: 10px 14px;
    gap: 8px;
  }

  .history-item {
    padding: 10px 12px;
    border-radius: 10px;
  }

  /* Modals Mobile */
  .modal {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    padding: 14px 12px;
    border-radius: 14px;
    max-height: 88vh;
  }

  .modal-header {
    margin-bottom: 12px;
  }

  .modal-header h3 {
    font-size: 15px;
  }

  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .theme-btn {
    padding: 8px 10px;
    font-size: 11.5px;
    gap: 6px;
    border-radius: 8px;
  }

  .theme-color-preview {
    width: 16px;
    height: 16px;
  }

  .shortcut-table td {
    padding: 6px 4px;
    font-size: 11.5px;
  }

  .portfolio-tags-grid {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 14px;
  }

  .portfolio-tag-card {
    padding: 8px 10px;
    border-radius: 8px;
  }

  .info-author-box {
    padding: 10px 12px;
    border-radius: 10px;
    gap: 8px;
  }

  .btn-primary-link {
    width: 100%;
    justify-content: center;
    padding: 8px 14px;
    font-size: 12px;
    border-radius: 8px;
  }

  /* Footer Mobile */
  .app-footer {
    padding: 10px 12px;
    border-radius: 12px;
    margin-top: 12px;
  }

  .footer-desc {
    font-size: 11px;
  }

  .footer-links {
    gap: 5px;
  }

  .footer-link,
  .footer-link-btn {
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 6px;
  }

  .footer-badge {
    padding: 3px 6px;
    font-size: 9.5px;
    border-radius: 4px;
  }
}

/* 4. Compact & Small Screens (<= 360px) */
@media (max-width: 360px) {
  .brand-info span {
    display: none;
  }

  .brand-info h1 {
    font-size: 13.5px;
  }

  .header-actions {
    gap: 2px;
  }

  .icon-btn {
    width: 29px;
    height: 29px;
    border-radius: 6px;
  }

  .tab-btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .btn {
    min-height: 40px;
    font-size: 14px;
    padding: 4px;
    border-radius: 8px;
  }

  .btn.sci {
    min-height: 32px;
    font-size: 11px;
  }

  .prog-bit-btn {
    width: 15px;
    height: 20px;
    font-size: 9px;
  }

  .theme-grid {
    grid-template-columns: 1fr;
  }

  .date-metrics-grid {
    grid-template-columns: 1fr;
  }
}

/* 5. Mobile Landscape Orientation */
@media (max-height: 550px) and (orientation: landscape) {
  .app-container {
    padding: max(6px, env(safe-area-inset-top, 6px)) max(8px, env(safe-area-inset-right, 8px)) max(16px, env(safe-area-inset-bottom, 16px)) max(8px, env(safe-area-inset-left, 8px));
    gap: 8px;
  }

  .header-bar {
    padding: 6px 12px;
  }

  .display-wrapper {
    padding: 6px 12px;
    margin-bottom: 8px;
  }

  .display-main {
    font-size: 20px;
    line-height: 1.1;
  }

  .display-expression {
    min-height: 16px;
    font-size: 11px;
  }

  .btn {
    min-height: 36px;
    font-size: 14px;
    padding: 4px;
  }

  .btn.sci {
    min-height: 30px;
    font-size: 11px;
  }

  .canvas-wrapper {
    height: 180px;
  }
}