:root {
  --charcoal-bg: #15171a;    
  --charcoal-calc: #22252a;  
  --charcoal-hover: #2e3238; 
  
  --lemon-yellow: #FDE047;   
  --lemon-light: #fef08a;    
  
  --text-dark: #15171a;      
  --text-light: #ffffff;     
  --text-muted: #8b95a5;     
  
  --font-mono: 'JetBrains Mono', monospace;
}

* { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

body {
  background: var(--charcoal-bg);
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-family: var(--font-mono);
  position: relative;
}

.calculator {
  width: 400px;
  background: var(--charcoal-calc);
  border-radius: 35px;
  overflow: hidden;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.6);
  transition: width 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10;
  position: relative;
}

body.scientific-mode .calculator { 
  width: 650px; 
}

.display-container {
  background: var(--lemon-yellow);
  padding: 40px 30px;
  text-align: right;
  color: var(--text-dark);
  box-shadow: inset 0 -10px 20px rgba(0,0,0,0.05);
}

.top-bar { 
  display: flex; 
  justify-content: space-between; 
  align-items: flex-start;
  margin-bottom: 20px; 
}

#history { 
  font-size: 16px; 
  color: rgba(21, 23, 26, 0.6); 
  min-height: 22px; 
  letter-spacing: 1px;
  font-weight: 500;
}

#result { 
  font-size: 5rem; 
  font-weight: 500; 
  line-height: 1; 
  transition: font-size 0.2s ease;
}

.mode-toggle { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
}

.mode-toggle .label { 
  font-size: 10px; 
  text-transform: uppercase; 
  color: #8a7b26; 
  letter-spacing: 1px;
  font-weight: 600;
}

.switch { 
  position: relative; 
  display: inline-block; 
  width: 38px; 
  height: 22px; 
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider { 
  position: absolute; 
  cursor: pointer; 
  inset: 0; 
  background-color: var(--charcoal-calc); 
  border-radius: 34px; 
  transition: .4s; 
}

.slider:before { 
  position: absolute; 
  content: ""; 
  height: 16px; 
  width: 16px; 
  left: 3px; 
  bottom: 3px; 
  background-color: var(--text-light); 
  transition: .4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
  border-radius: 50%; 
}

input:checked + .slider:before { 
  transform: translateX(16px); 
}

.pad {
  padding: 35px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  background: var(--charcoal-calc);
  transition: grid-template-columns 0.5s ease;
}

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

.btn {
  background: transparent; 
  border: none; 
  color: var(--text-light);
  font-family: var(--font-mono); 
  font-size: 24px; 
  height: 60px;
  cursor: pointer; 
  display: flex; 
  justify-content: center; 
  align-items: center;
  border-radius: 15px; 
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  
  position: relative;
  overflow: hidden; 
}

.btn:hover { background: var(--charcoal-hover); }

.btn:active, .btn.active-visual { 
  transform: scale(0.92); 
  background: #373c44;
}

.btn.sci { display: none; color: var(--text-muted); font-size: 16px; }

body.scientific-mode .btn.sci { 
  display: flex; 
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

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

.btn.equal {
  background: var(--lemon-yellow); 
  color: var(--text-dark); 
  font-size: 32px;
  font-weight: 500;
  box-shadow: 0 8px 20px rgba(253, 224, 71, 0.15);
}

.btn.equal:hover {
  background: var(--lemon-light); 
  box-shadow: 0 10px 25px rgba(253, 224, 71, 0.3);
}

.btn.equal:active, .btn.equal.active-visual {
  background: #eab308; 
  transform: scale(0.92);
}

.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple-animation 0.5s linear;
  background-color: rgba(255, 255, 255, 0.15);
  pointer-events: none;
}

.btn.equal .ripple { background-color: rgba(0, 0, 0, 0.15); }

@keyframes ripple-animation {
  to { transform: scale(4); opacity: 0; }
}

.creator-tag {
  position: absolute;
  bottom: 30px;
  font-size: 14px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  z-index: 1;
}

.creator-tag a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

.creator-tag a:hover {
  color: var(--lemon-yellow);
  text-shadow: 0 0 8px rgba(253, 224, 71, 0.4);
}

@media (max-width: 700px) {
  body.scientific-mode .calculator { width: 95vw; }
  .pad { padding: 20px; gap: 10px; }
  .btn { height: 50px; font-size: 20px; }
  #result { font-size: 3.5rem; }
  .creator-tag { bottom: 15px; font-size: 12px; }
}