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

body {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-family: 'Inter', system-ui, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.calculator {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 24px;
  padding: 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
  position: relative;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: white;
}
.header h2 { font-size: 1.15rem; font-weight: 500; }
.controls button {
  background: rgba(255,255,255,0.15);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.92rem;
  cursor: pointer;
  margin-left: 8px;
}
.controls button:hover { background: rgba(255,255,255,0.25); }

/* Display */
.display {
  background: rgba(0,0,0,0.35);
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 20px;
  text-align: right;
  color: white;
  min-height: 110px;
  border: 1px solid rgba(255,255,255,0.08);
}
.expression { font-size: 1.05rem; opacity: 0.75; min-height: 24px; }
.result { font-size: 3rem; font-weight: 500; letter-spacing: -1px; }

/* Histórico */
.history-panel {
  display: none;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
  color: white;
  max-height: 240px;
  overflow-y: auto;
}
.history-panel.show { display: block; }
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
#history-list {
  list-style: none;
}
#history-list li {
  padding: 10px 12px;
  background: rgba(255,255,255,0.08);
  border-radius: 10px;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

/* Botões */
.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
button {
  height: 68px;
  border: none;
  border-radius: 18px;
  font-size: 1.55rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  background: rgba(255,255,255,0.12);
  color: white;
}
button:hover { background: rgba(255,255,255,0.22); transform: translateY(-2px); }
button:active { filter: brightness(0.9); }

/* Cores especiais */
.operator { background: rgba(255,193,7,0.22) !important; color: #ffeb3b; }
.equals {
  background: linear-gradient(135deg, #00c853, #64dd17) !important;
  grid-row: span 2;
}
.clear { background: rgba(244,67,54,0.22) !important; color: #ff8a80; }
.zero { grid-column: span 2; }

/* === MODO CIENTÍFICO === */
.calculator.scientific {
  max-width: 420px;
}
.calculator.scientific .buttons {
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.calculator.scientific .equals { grid-row: span 1; }
.calculator.scientific .zero { grid-column: span 1; }

.sci-button {
  display: none;
  font-size: 1.25rem;
  height: 58px;
}
.calculator.scientific .sci-button {
  display: flex;
  align-items: center;
  justify-content: center;
}