/* Nova Calculator - styles */
:root {
  --bg-1: #0f172a;
  --bg-2: #1e1b4b;
  --bg-3: #312e81;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-border: rgba(255, 255, 255, 0.10);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #a78bfa;
  --accent-2: #38bdf8;
  --danger: #f87171;
  --num: #1f2937;
  --num-hover: #273346;
  --op: #f59e0b;
  --op-hover: #fbbf24;
  --eq: linear-gradient(135deg, #7c3aed, #38bdf8);
  --func: #334155;
  --func-hover: #3f4f6c;
  --sci: #4b3a8c;
  --sci-hover: #5a47a8;
  --util: #1e293b;
  --util-hover: #25324a;
  --shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.6);
  --radius-lg: 22px;
  --radius-md: 14px;
}

[data-theme="light"] {
  --bg-1: #f7f7fb;
  --bg-2: #e9ecf6;
  --bg-3: #dde1ee;
  --panel: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #475569;
  --num: #ffffff;
  --num-hover: #f1f5f9;
  --func: #e2e8f0;
  --func-hover: #d1dae6;
  --sci: #ede9fe;
  --sci-hover: #ddd6fe;
  --util: #f1f5f9;
  --util-hover: #e2e8f0;
  --shadow: 0 20px 50px -20px rgba(15, 23, 42, 0.25);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-3), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, var(--bg-2), transparent 60%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(280px, 380px);
  gap: 22px;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
}

.calculator, .history-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #38bdf8);
  color: white; font-weight: 800; font-size: 22px;
  box-shadow: 0 8px 20px -8px rgba(124, 58, 237, 0.7);
}
.title h1 { margin: 0; font-size: 18px; letter-spacing: 0.2px; }
.title .subtitle { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.title { flex: 1; }
.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease;
}
.ghost:hover { background: rgba(255,255,255,0.06); }
.ghost:active { transform: scale(0.97); }

.display {
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  padding: 18px 18px 14px;
  margin-bottom: 16px;
  min-height: 116px;
  display: flex; flex-direction: column;
  justify-content: flex-end;
}
[data-theme="light"] .display { background: rgba(255,255,255,0.65); }

.expression {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  font-size: 14px;
  min-height: 18px;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}
.output {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: right;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}
.output.flash { animation: flash 220ms ease; }
@keyframes flash {
  0% { transform: scale(1); }
  50% { transform: scale(1.025); color: var(--accent); }
  100% { transform: scale(1); }
}
.memory-row { display: flex; gap: 8px; margin-top: 8px; min-height: 22px; }
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(124, 58, 237, 0.55);
  color: var(--accent);
  font-weight: 700;
}
.chip.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.55);
  color: var(--danger);
}

.pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.btn {
  appearance: none;
  border: 1px solid var(--panel-border);
  color: var(--text);
  background: var(--num);
  font-size: 17px;
  font-weight: 600;
  padding: 14px 0;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 70ms ease, background 120ms ease, box-shadow 150ms ease;
  font-family: inherit;
}
.btn:hover { background: var(--num-hover); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.func { background: var(--func); }
.btn.func:hover { background: var(--func-hover); }
.btn.util { background: var(--util); color: var(--muted); font-size: 14px; }
.btn.util:hover { background: var(--util-hover); color: var(--text); }
.btn.op {
  background: var(--op);
  color: #1a1300;
  box-shadow: 0 6px 18px -10px rgba(245, 158, 11, 0.8);
}
.btn.op:hover { background: var(--op-hover); }
.btn.sci { background: var(--sci); color: var(--text); font-size: 14px; }
.btn.sci:hover { background: var(--sci-hover); }
.btn.equals {
  background: var(--eq);
  color: white;
  box-shadow: 0 10px 26px -10px rgba(124, 58, 237, 0.75);
}

.history-panel { display: flex; flex-direction: column; min-height: 100%; }
.history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.history-head h2 { margin: 0; font-size: 16px; letter-spacing: 0.3px; }
.history-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 8px;
  max-height: 460px; overflow-y: auto;
  padding-right: 4px;
}
.history-item {
  display: flex; flex-direction: column;
  gap: 2px;
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--panel-border);
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease;
}
[data-theme="light"] .history-item { background: rgba(255,255,255,0.7); }
.history-item:hover { background: rgba(255,255,255,0.08); }
.history-item .expr { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.history-item .res  { font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; }
.history-item .meta { color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.history-empty {
  color: var(--muted); font-size: 13px; text-align: center;
  padding: 20px 8px; margin: 0;
}
.hint { color: var(--muted); font-size: 11px; margin-top: 14px; line-height: 1.6; }
.hint code, .hint kbd {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid var(--panel-border);
}
