/* ===== 全局重置 & 设计变量 ===== */
:root {
  --primary-bg: #0f0f1a;
  --secondary-bg: #1a1a2e;
  --card-bg: #222240;
  --text-primary: #f0f0f8;
  --text-secondary: #b0b0c8;
  --accent: #7c6cf0;
  --accent-light: #9d8cff;
  --accent-dark: #5a4ad0;
  --btn-number-bg: #2a2a48;
  --btn-operator-bg: #3a3a5c;
  --btn-equal-bg: #7c6cf0;
  --btn-clear-bg: #e74c6f;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: radial-gradient(ellipse at 20% 30%, #1a1a3e, #0b0b1a);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  color: var(--text-primary);
  transition: background 0.4s;
}

/* SPA 根容器 */
#app {
  width: 100%;
  max-width: 480px;
  background: var(--secondary-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(2px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ===== 头部 ===== */
.calc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  font-size: 1.6rem;
  color: var(--accent-light);
}

.app-title {
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #c0b0ff, #7c6cf0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-version {
  background: rgba(124, 108, 240, 0.2);
  padding: 4px 10px;
  border-radius: 40px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-light);
  border: 1px solid rgba(124, 108, 240, 0.3);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 50%;
  transition: var(--transition);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
}

/* ===== 显示区域 ===== */
.display-area {
  padding: 20px 24px 12px;
  background: rgba(0, 0, 0, 0.15);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  word-break: break-all;
}

.expression {
  font-size: 1.1rem;
  color: var(--text-secondary);
  text-align: right;
  min-height: 28px;
  letter-spacing: 0.3px;
  font-weight: 400;
}

.result {
  font-size: 2.8rem;
  font-weight: 700;
  text-align: right;
  color: var(--text-primary);
  line-height: 1.2;
  margin-top: 4px;
  letter-spacing: -0.02em;
  transition: var(--transition);
}

/* ===== 模式切换 (SPA 内导航) ===== */
.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px 4px;
  background: rgba(0, 0, 0, 0.1);
}

.mode-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.5px;
}

.mode-tab.active {
  background: var(--card-bg);
  color: var(--accent-light);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.mode-tab:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

/* ===== 按钮面板 ===== */
.button-panel {
  padding: 8px 12px 12px;
}

.hidden {
  display: none !important;
}

.btn-grid {
  display: grid;
  gap: 10px;
}

.basic-grid {
  grid-template-columns: repeat(4, 1fr);
}

.scientific-grid {
  grid-template-columns: repeat(4, 1fr);
}

.btn {
  border: none;
  background: var(--btn-number-bg);
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 600;
  padding: 16px 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.94);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-number {
  background: var(--btn-number-bg);
}

.btn-number:hover {
  background: #32325a;
}

.btn-operator {
  background: var(--btn-operator-bg);
  color: #c8b8ff;
}

.btn-operator:hover {
  background: #4a4a6e;
}

.btn-clear {
  background: var(--btn-clear-bg);
  color: white;
}

.btn-clear:hover {
  background: #d63c5f;
}

.btn-backspace {
  background: #3a3a5c;
  color: #e0d0f0;
}

.btn-backspace:hover {
  background: #4a4a6e;
}

.btn-equal {
  background: var(--btn-equal-bg);
  color: white;
  box-shadow: 0 4px 12px rgba(124, 108, 240, 0.3);
}

.btn-equal:hover {
  background: var(--accent-light);
  box-shadow: 0 4px 16px rgba(124, 108, 240, 0.5);
}

.btn-sci {
  background: #1e1e3a;
  color: #b0a0e0;
  font-size: 1rem;
  font-weight: 500;
}

.btn-sci:hover {
  background: #2a2a50;
  color: white;
}

.zero {
  grid-column: span 1;
}

/* ===== 历史面板 ===== */
.history-panel {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 18px 16px;
  background: rgba(0, 0, 0, 0.1);
  max-height: 160px;
  overflow-y: auto;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.history-header i {
  margin-right: 6px;
}

.icon-btn.small {
  font-size: 0.9rem;
  padding: 4px 6px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-item {
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: var(--radius-xs);
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  border-left: 3px solid var(--accent);
}

.history-item .expr {
  color: var(--text-secondary);
}

.history-item .val {
  font-weight: 600;
  color: var(--accent-light);
}

.history-empty {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
  padding: 12px;
}

/* ===== 底部 ===== */
.calc-footer {
  display: flex;
  justify-content: space-between;
  padding: 10px 20px;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
}

.footer-badge {
  background: rgba(124, 108, 240, 0.15);
  padding: 2px 10px;
  border-radius: 20px;
  color: var(--accent-light);
  font-weight: 600;
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.1);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-dark);
  border-radius: 6px;
}

/* ===== 响应式 ===== */
@media (max-width: 480px) {
  body { padding: 8px; }
  #app { max-width: 100%; border-radius: 24px; }
  .calc-header { padding: 14px 16px 10px; }
  .app-title { font-size: 1.2rem; }
  .result { font-size: 2.4rem; }
  .btn { padding: 14px 0; font-size: 1.2rem; }
  .btn-sci { font-size: 0.85rem; padding: 12px 0; }
  .history-panel { max-height: 120px; }
}

@media (min-width: 768px) {
  #app { max-width: 520px; }
  .btn { padding: 18px 0; font-size: 1.4rem; }
  .result { font-size: 3rem; }
}

/* 深色主题已内建，未来可扩展 light 模式 */
```
```javascript