* {
  box-sizing: border-box;
  font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background: #060a12;
  color: #f8fafc;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.topbar {
  width: 100%;
  max-width: 680px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #f8fafc;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.back-btn:hover {
  background: rgba(56, 189, 248, 0.18);
  border-color: #38bdf8;
}

.topbar-hint {
  font-size: 0.82rem;
  color: #94a3b8;
}

.container {
  width: 100%;
  max-width: 420px;
  padding: 12px 16px 32px;
  margin: 0 auto;
}

.calc-body {
  width: 100%;
  max-width: 350px;
  margin: auto;
  border-radius: 16px;
  overflow: hidden;
  border: solid 1px rgba(56, 189, 248, 0.3);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.8);
}

.calc-screen {
  background: #0f172a;
  width: 100%;
  height: 150px;
  padding: 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.calc-operation {
  text-align: right;
  color: #94a3b8;
  font-size: 19px;
  min-height: 30px;
  padding-bottom: 10px;
  border-bottom: dotted 1px rgba(148, 163, 184, 0.25);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-typed {
  margin-top: 14px;
  font-size: 38px;
  font-weight: 700;
  text-align: right;
  color: #f8fafc;
  font-family: 'Consolas', 'Courier New', monospace;
}

.calc-button-row {
  width: 100%;
  background: #1e293b;
  display: flex;
}

.button {
  width: 20%;
  background: #1e293b;
  color: #f8fafc;
  padding: 20px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  border-right: solid 1px rgba(15, 23, 42, 0.7);
  border-bottom: solid 1px rgba(15, 23, 42, 0.7);
  transition: all 0.16s ease-in-out;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.button.l {
  color: #38bdf8;
  background: #172033;
}

.button.c {
  color: #f87171;
  background: #172033;
}

.button.eq {
  color: #060a12;
  background: linear-gradient(135deg, #38bdf8 0%, #6366f1 100%);
  font-weight: 800;
}

.button:hover {
  background: #38bdf8;
  color: #060a12;
}

.button.c:hover {
  background: #ef4444;
  color: #fff;
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.blink-me {
  color: #38bdf8;
  animation: blink-cursor 1s step-start infinite;
  display: inline-block;
}

/* Light Theme Overrides */
:root[data-theme="light"] body {
  background: #f1f5f9;
  color: #0f172a;
}

:root[data-theme="light"] .back-btn {
  background: #ffffff;
  border-color: rgba(2, 132, 199, 0.45);
  color: #0f172a;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

:root[data-theme="light"] .back-btn:hover {
  background: rgba(2, 132, 199, 0.1);
  border-color: #0284c7;
}

:root[data-theme="light"] .topbar-hint {
  color: #475569;
}

:root[data-theme="light"] .calc-body {
  border-color: rgba(2, 132, 199, 0.35);
  box-shadow: 0 18px 40px -10px rgba(15, 23, 42, 0.15);
}

:root[data-theme="light"] .calc-screen {
  background: #ffffff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}

:root[data-theme="light"] .calc-operation {
  color: #64748b;
  border-bottom-color: rgba(15, 23, 42, 0.15);
}

:root[data-theme="light"] .calc-typed {
  color: #0f172a;
}

:root[data-theme="light"] .calc-button-row {
  background: #f8fafc;
}

:root[data-theme="light"] .button {
  background: #ffffff;
  color: #0f172a;
  border-right: solid 1px #e2e8f0;
  border-bottom: solid 1px #e2e8f0;
}

:root[data-theme="light"] .button.l {
  color: #0284c7;
  background: #f1f5f9;
}

:root[data-theme="light"] .button.c {
  color: #dc2626;
  background: #fef2f2;
}

:root[data-theme="light"] .button.eq {
  color: #ffffff;
  background: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
}

:root[data-theme="light"] .button:hover {
  background: #0284c7;
  color: #ffffff;
}

:root[data-theme="light"] .button.c:hover {
  background: #dc2626;
  color: #ffffff;
}

:root[data-theme="light"] .blink-me {
  color: #0284c7;
}

/* Mobile & Landscape Responsive Adaptations */
@media (max-width: 480px) {
  .topbar {
    padding: 12px 14px;
  }
  .topbar-hint {
    display: none;
  }
  .back-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
  }
  .container {
    padding: 8px 10px 20px;
  }
  .calc-body {
    max-width: 330px;
  }
  .calc-screen {
    height: 125px;
    padding: 14px;
  }
  .calc-operation {
    font-size: 16px;
    min-height: 24px;
    padding-bottom: 6px;
  }
  .calc-typed {
    font-size: 32px;
    margin-top: 8px;
  }
  .button {
    padding: 16px 0;
    font-size: 20px;
  }
}

@media (max-height: 600px) {
  .topbar {
    padding: 6px 14px;
  }
  .topbar-hint {
    display: none;
  }
  .back-btn {
    padding: 5px 11px;
    font-size: 0.74rem;
  }
  .container {
    padding: 4px 10px 10px;
  }
  .calc-body {
    max-width: 320px;
  }
  .calc-screen {
    height: 85px;
    padding: 8px 12px;
  }
  .calc-operation {
    font-size: 14px;
    min-height: 18px;
    padding-bottom: 3px;
  }
  .calc-typed {
    font-size: 24px;
    margin-top: 4px;
  }
  .button {
    padding: 9px 0;
    font-size: 17px;
  }
}