/* =========================================================================
   Aurora OS — design system
   Aurora palette: deep indigo night, teal/violet/pink northern lights.
   ========================================================================= */

:root {
  --accent-1: #70ffd0;   /* teal */
  --accent-2: #a884ff;   /* violet */
  --accent-3: #ff7ac6;   /* pink */
  --accent-grad: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 55%, var(--accent-3) 100%);

  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --shadow-1: 0 8px 30px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.25);
  --shadow-2: 0 20px 60px rgba(0,0,0,.55), 0 4px 12px rgba(0,0,0,.35);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Dark (default) */
[data-theme="dark"] {
  --bg: #0a0d1c;
  --bg-deep: #06080f;
  --panel: rgba(20, 24, 42, 0.72);
  --panel-solid: #14182a;
  --panel-2: rgba(30, 34, 56, 0.85);
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);
  --text: #e8ecf5;
  --text-dim: rgba(232,236,245,0.62);
  --text-faint: rgba(232,236,245,0.42);
  --hover: rgba(255,255,255,0.06);
  --active: rgba(255,255,255,0.10);
  --selection: rgba(168,132,255,0.35);
  --danger: #ff6b6b;
  --warn: #ffb86b;
  --ok: #6bffb0;
  --bar-grad: linear-gradient(90deg, rgba(112,255,208,0.85), rgba(168,132,255,0.85), rgba(255,122,198,0.85));
}

/* Light */
[data-theme="light"] {
  --bg: #f3f4fa;
  --bg-deep: #e6e9f5;
  --panel: rgba(255,255,255,0.78);
  --panel-solid: #ffffff;
  --panel-2: rgba(255,255,255,0.92);
  --border: rgba(10,14,30,0.10);
  --border-strong: rgba(10,14,30,0.18);
  --text: #15182b;
  --text-dim: rgba(21,24,43,0.62);
  --text-faint: rgba(21,24,43,0.42);
  --hover: rgba(10,14,30,0.06);
  --active: rgba(10,14,30,0.10);
  --selection: rgba(168,132,255,0.25);
  --danger: #d6394a;
  --warn: #c97612;
  --ok: #168f54;
  --bar-grad: linear-gradient(90deg, #4dd6b0, #9577e8, #df5fa9);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 var(--font);
  color: var(--text);
  background: var(--bg-deep);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--selection); color: var(--text); }

/* =========================================================================
   Boot
   ========================================================================= */
.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(1100px 700px at 20% 10%, rgba(168,132,255,0.35), transparent 60%),
    radial-gradient(900px 700px at 90% 90%, rgba(112,255,208,0.30), transparent 60%),
    radial-gradient(700px 500px at 80% 20%, rgba(255,122,198,0.22), transparent 60%),
    var(--bg-deep);
  z-index: 9999;
  animation: bootIn .5s ease-out;
}
.boot-inner { text-align: center; padding: 24px; }
.boot-logo svg { filter: drop-shadow(0 8px 24px rgba(168,132,255,0.5)); }
.boot-title {
  font-size: 34px; font-weight: 700; letter-spacing: .5px;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 18px 0 6px;
}
.boot-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }
.boot-bar {
  width: 280px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,0.08); overflow: hidden;
  margin: 0 auto 12px;
}
.boot-bar-fill {
  width: 0%; height: 100%; background: var(--bar-grad);
  border-radius: 999px; transition: width .35s ease;
}
.boot-status { color: var(--text-faint); font-size: 12px; font-family: var(--mono); min-height: 1em; }

@keyframes bootIn { from { opacity: 0; } to { opacity: 1; } }
.boot.fade-out { animation: bootOut .6s ease forwards; }
@keyframes bootOut { to { opacity: 0; transform: scale(1.04); filter: blur(6px); } }

/* =========================================================================
   Desktop
   ========================================================================= */
.desktop {
  position: fixed; inset: 0;
  overflow: hidden;
}

.wallpaper {
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 800px at 18% 12%, rgba(168,132,255,0.55), transparent 60%),
    radial-gradient(900px 700px at 85% 88%, rgba(112,255,208,0.45), transparent 60%),
    radial-gradient(700px 500px at 78% 18%, rgba(255,122,198,0.40), transparent 60%),
    radial-gradient(900px 700px at 8% 88%, rgba(120,160,255,0.35), transparent 60%),
    linear-gradient(160deg, #0a0d20 0%, #160b2a 45%, #08131c 100%);
  background-size: cover;
  transition: background .8s ease;
}
[data-theme="light"] .wallpaper {
  background:
    radial-gradient(1000px 700px at 18% 12%, rgba(168,132,255,0.45), transparent 60%),
    radial-gradient(900px 700px at 85% 88%, rgba(112,255,208,0.40), transparent 60%),
    radial-gradient(700px 500px at 78% 18%, rgba(255,122,198,0.30), transparent 60%),
    linear-gradient(160deg, #e5e9f8 0%, #ecdef5 50%, #dff5ee 100%);
}

.wallpaper.w-custom {
  background-image: var(--wp-img, none);
  background-size: cover;
  background-position: center;
}

/* Desktop icons */
.desktop-icons {
  position: absolute;
  top: 18px; left: 18px;
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(auto-fill, 96px);
  gap: 6px 10px;
  z-index: 1;
}
.dicon {
  width: 84px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 6px; border-radius: var(--radius-md);
  cursor: default;
  text-align: center;
  outline: none;
  transition: background .15s ease;
}
.dicon:hover { background: var(--hover); }
.dicon.selected { background: var(--active); box-shadow: 0 0 0 1px var(--border-strong) inset; }
.dicon-glyph {
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.dicon-glyph svg { display: block; }
.dicon-label {
  color: var(--text);
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
  max-width: 84px;
  word-wrap: break-word;
  line-height: 1.2;
}
[data-theme="light"] .dicon-label { text-shadow: 0 1px 2px rgba(255,255,255,.8); }

/* =========================================================================
   Windows
   ========================================================================= */
.windows {
  position: absolute; inset: 0;
  pointer-events: none; /* children enable it */
}
.win {
  position: absolute;
  min-width: 240px; min-height: 160px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  display: flex; flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  animation: winIn .22s cubic-bezier(.2,.8,.2,1);
}
.win.minimized { display: none; }
.win.maximized {
  left: 0 !important; top: 0 !important;
  width: 100% !important; height: calc(100% - 56px) !important;
  border-radius: 0;
}
.win:not(.focused) { box-shadow: 0 6px 22px rgba(0,0,0,.4); }
.win:not(.focused) .win-title { color: var(--text-dim); }

@keyframes winIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.win-titlebar {
  display: flex; align-items: center;
  height: 36px; padding: 0 8px 0 12px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
  user-select: none;
  cursor: grab;
}
.win-titlebar:active { cursor: grabbing; }
.win-title {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win-title-icon {
  width: 18px; height: 18px; border-radius: 5px;
  display: grid; place-items: center; flex: none;
}
.win-controls { display: flex; gap: 2px; }
.win-btn {
  width: 30px; height: 28px; border-radius: var(--radius-sm);
  background: transparent; border: 0; color: var(--text-dim);
  display: grid; place-items: center;
  transition: background .12s ease, color .12s ease;
}
.win-btn:hover { background: var(--hover); color: var(--text); }
.win-btn.close:hover { background: var(--danger); color: white; }

.win-body {
  flex: 1; overflow: hidden;
  position: relative;
  display: flex;
  background: var(--panel-2);
}
.win-body iframe { border: 0; width: 100%; height: 100%; background: transparent; }

/* Resize handles */
.resize { position: absolute; z-index: 2; }
.resize.n  { top: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.resize.s  { bottom: -3px; left: 8px; right: 8px; height: 6px; cursor: ns-resize; }
.resize.e  { right: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.resize.w  { left: -3px; top: 8px; bottom: 8px; width: 6px; cursor: ew-resize; }
.resize.ne { top: -3px; right: -3px; width: 12px; height: 12px; cursor: nesw-resize; }
.resize.nw { top: -3px; left: -3px; width: 12px; height: 12px; cursor: nwse-resize; }
.resize.se { bottom: -3px; right: -3px; width: 12px; height: 12px; cursor: nwse-resize; }
.resize.sw { bottom: -3px; left: -3px; width: 12px; height: 12px; cursor: nesw-resize; }
.win.maximized .resize { display: none; }

/* =========================================================================
   Taskbar
   ========================================================================= */
.taskbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 52px;
  display: flex; align-items: center;
  padding: 6px 8px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  z-index: 100;
  gap: 6px;
}
.start-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; height: 40px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text);
  transition: background .15s ease, border-color .15s ease;
}
.start-btn:hover { background: var(--hover); }
.start-btn.active { background: var(--active); border-color: var(--border-strong); }
.start-label { font-weight: 600; font-size: 13px; }

.task-apps {
  flex: 1;
  display: flex; align-items: center; gap: 4px;
  margin-left: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.task-apps::-webkit-scrollbar { display: none; }

.task-app {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 10px;
  border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent;
  color: var(--text); font-size: 12.5px;
  max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s ease, border-color .15s ease;
}
.task-app:hover { background: var(--hover); }
.task-app.active {
  background: var(--active);
  border-color: var(--border-strong);
}
.task-app.active::before {
  content: ""; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-2);
  margin-right: 2px;
}
.task-app-glyph {
  width: 18px; height: 18px; border-radius: 5px;
  display: grid; place-items: center; flex: none;
}

.task-tray { display: flex; align-items: center; gap: 4px; }
.tray-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim);
  display: grid; place-items: center;
  transition: background .12s ease, color .12s ease;
}
.tray-btn:hover { background: var(--hover); color: var(--text); }

.clock {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 0 10px;
  font-family: var(--mono);
  line-height: 1.1;
}
#clockTime { font-size: 13px; }
.clock-date { font-size: 11px; color: var(--text-dim); }

/* =========================================================================
   Start menu
   ========================================================================= */
.start-menu {
  position: absolute; left: 8px; bottom: 60px;
  width: 360px; max-height: 60vh;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  padding: 14px;
  z-index: 110;
  animation: menuIn .18s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; gap: 10px;
}
.start-menu[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.start-head-title {
  font-size: 18px; font-weight: 700;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.start-head-sub { font-size: 11px; color: var(--text-dim); }
.start-search input {
  width: 100%; padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.start-search input:focus { border-color: var(--accent-2); background: var(--active); }

.start-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  overflow-y: auto;
  padding: 4px;
  flex: 1;
}
.start-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px; border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease, transform .12s ease, border-color .12s ease;
}
.start-item:hover { background: var(--hover); border-color: var(--border); }
.start-item:active { transform: scale(.97); }
.start-item-glyph {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--panel-2);
  display: grid; place-items: center;
  border: 1px solid var(--border);
}
.start-item-label { font-size: 11.5px; text-align: center; }

.start-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-dim);
  padding-top: 6px; border-top: 1px solid var(--border);
}
.link-btn {
  background: transparent; border: 0; color: var(--accent-2);
  padding: 2px 6px; border-radius: 4px;
}
.link-btn:hover { background: var(--hover); }

/* =========================================================================
   Context menu
   ========================================================================= */
.ctx-menu {
  position: absolute;
  min-width: 180px;
  list-style: none; margin: 0; padding: 6px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  z-index: 200;
  animation: menuIn .14s cubic-bezier(.2,.8,.2,1);
}
.ctx-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.ctx-item:hover { background: var(--hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(255,107,107,.14); }
.ctx-sep {
  height: 1px; background: var(--border); margin: 4px 2px;
}

/* =========================================================================
   Notifications
   ========================================================================= */
.notif {
  position: absolute; right: 14px; bottom: 64px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 250;
  pointer-events: none;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: var(--shadow-1);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  pointer-events: auto;
  animation: toastIn .25s ease;
  max-width: 320px;
}
.toast.leaving { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }

/* =========================================================================
   Scrollbars (subtle)
   ========================================================================= */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================================
   App internals (shared)
   ========================================================================= */
.app-root {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: var(--panel-2);
  color: var(--text);
  overflow: hidden;
}
.app-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
}
.app-btn {
  padding: 6px 10px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid transparent;
  color: var(--text); font-size: 12.5px;
  transition: background .12s ease, border-color .12s ease;
}
.app-btn:hover { background: var(--hover); border-color: var(--border); }
.app-btn.primary {
  background: linear-gradient(135deg, rgba(168,132,255,.35), rgba(112,255,208,.30));
  border-color: var(--border-strong);
}
.app-btn.primary:hover { filter: brightness(1.08); }
.app-btn.danger { color: var(--danger); }
.app-btn.danger:hover { background: rgba(255,107,107,.14); border-color: rgba(255,107,107,.35); }

.app-path {
  flex: 1;
  font-family: var(--mono); font-size: 12px;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text-dim);
  outline: none;
}
.app-path:focus { border-color: var(--accent-2); color: var(--text); }

.app-body { flex: 1; overflow: auto; }

/* ---- File Manager ---- */
.fm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 6px;
  padding: 10px;
}
.fm-item {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px; border-radius: var(--radius-md);
  cursor: default; user-select: none;
  text-align: center;
  border: 1px solid transparent;
}
.fm-item:hover { background: var(--hover); }
.fm-item.selected { background: var(--active); border-color: var(--border-strong); }
.fm-glyph {
  width: 48px; height: 48px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
}
.fm-name {
  font-size: 12.5px;
  word-break: break-word;
  max-width: 100px;
  line-height: 1.2;
}
.fm-empty {
  text-align: center; padding: 40px 20px;
  color: var(--text-dim); font-size: 13px;
}

/* ---- Text Editor ---- */
.te-area {
  width: 100%; height: 100%;
  border: 0; outline: none; resize: none;
  padding: 16px 18px;
  background: transparent; color: var(--text);
  font: 14px/1.55 var(--mono);
  user-select: text;
}
.te-status {
  font-size: 11px; color: var(--text-dim);
  padding: 4px 12px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  display: flex; justify-content: space-between;
}

/* ---- Terminal ---- */
.term {
  width: 100%; height: 100%;
  background: #07091a;
  color: #cfe7ff;
  font: 13px/1.5 var(--mono);
  padding: 10px 12px;
  overflow-y: auto;
  user-select: text;
}
.term .ln { white-space: pre-wrap; word-break: break-word; }
.term .prompt { color: var(--accent-1); }
.term .err   { color: var(--danger); }
.term .ok    { color: var(--ok); }
.term .dim   { color: var(--text-faint); }
.term .hl    { color: var(--accent-3); }
.term-input-line {
  display: flex; align-items: baseline; gap: 6px;
}
.term-input {
  flex: 1;
  background: transparent; border: 0; outline: none;
  color: #cfe7ff;
  font: inherit;
  caret-color: var(--accent-1);
}
.term .cursor::after { content: "\2588"; animation: blink 1s steps(1) infinite; color: var(--accent-1); }
@keyframes blink { 50% { opacity: 0; } }

/* ---- Settings ---- */
.settings {
  padding: 16px;
  display: grid; gap: 16px;
  overflow: auto;
}
.settings h3 { margin: 0 0 6px; font-size: 13px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.settings .row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.wp-swatch {
  width: 56px; height: 40px; border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  background-size: cover; background-position: center;
  transition: border-color .15s ease, transform .12s ease;
}
.wp-swatch:hover { transform: scale(1.04); }
.wp-swatch.active { border-color: var(--accent-2); }

/* small util */
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--text-dim); }
.mono { font-family: var(--mono); }

/* =========================================================================
   Calculator
   ========================================================================= */
.calc-root {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: var(--panel-2);
  color: var(--text);
  overflow: hidden;
  font-family: var(--font);
}
.calc-topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  font-size: 12px;
}
.calc-mode-toggle {
  padding: 4px 10px; border-radius: 999px;
  background: var(--hover); border: 1px solid var(--border);
  color: var(--text); font-size: 11.5px;
  transition: background .12s ease;
}
.calc-mode-toggle:hover { background: var(--active); }
.calc-angle {
  padding: 4px 8px; border-radius: 6px;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.5px;
}
.calc-angle:hover { background: var(--hover); color: var(--text); }
.calc-mem-badge {
  width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--text-faint);
  border: 1px solid var(--border);
  opacity: .35;
  transition: opacity .15s ease, color .15s ease, background .15s ease;
}
.calc-mem-badge.on {
  opacity: 1;
  color: var(--accent-3);
  border-color: rgba(255,122,198,.45);
  background: rgba(255,122,198,.10);
}
.calc-icon-btn {
  margin-left: auto;
  padding: 4px 10px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim); font-size: 11.5px;
}
.calc-icon-btn:hover { background: var(--hover); color: var(--text); border-color: var(--border); }

.calc-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.calc-display {
  flex: none;
  padding: 14px 16px 10px;
  background: linear-gradient(180deg, rgba(0,0,0,.18), transparent);
  text-align: right;
  user-select: text;
}
.calc-expr {
  font: 13px/1.3 var(--mono);
  color: var(--text-dim);
  min-height: 1.2em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.calc-expr.empty { visibility: hidden; }
.calc-main {
  font: 32px/1.15 var(--mono); font-weight: 600;
  color: var(--text);
  letter-spacing: 0.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  word-break: break-all;
  margin-top: 4px;
}

.calc-pad {
  flex: 1 1 0; min-height: 0;
  display: grid;
  gap: 4px;
  padding: 6px 8px;
  overflow: hidden;
}
.calc-pad.pad-standard {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 1fr);
}
.calc-pad.pad-scientific {
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 1fr;
}
.calc-std-wrap {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 4px;
}
.calc-sci-pane {
  display: flex; flex-direction: column;
  gap: 4px;
  min-height: 0;
}
.calc-sci-col {
  flex: 1 1 0; min-height: 0;
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.calc-sci-col .calc-btn { padding: 0; font-size: 11.5px; }
.calc-mem-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  flex: none;
}
.calc-mem-row .calc-btn { padding: 0; font-size: 10.5px; }

.calc-btn {
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font: 600 14px/1 var(--font);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .08s ease;
  user-select: none;
}
.calc-btn:hover { background: var(--hover); border-color: var(--border-strong); }
.calc-btn:active { transform: scale(.96); background: var(--active); }
.calc-btn.wide { grid-column: span 2; }
.calc-btn.kind-num  { color: var(--text); }
.calc-btn.kind-util { color: var(--text-dim); }
.calc-btn.kind-op   {
  color: #0a0d1c;
  background: linear-gradient(135deg, rgba(112,255,208,.95), rgba(168,132,255,.85));
  border-color: rgba(255,255,255,.12);
}
[data-theme="light"] .calc-btn.kind-op { color: #fff; }
.calc-btn.kind-op:hover { filter: brightness(1.06); }
.calc-btn.kind-eq   {
  color: #fff;
  background: linear-gradient(135deg, #ff7ac6, #a884ff);
  border-color: rgba(255,255,255,.12);
}
.calc-btn.kind-eq:hover { filter: brightness(1.06); }
.calc-btn.kind-fn {
  color: var(--text);
  background: rgba(168,132,255,.14);
  border-color: rgba(168,132,255,.30);
}
.calc-btn.kind-const {
  color: var(--accent-3);
  background: rgba(255,122,198,.10);
  border-color: rgba(255,122,198,.30);
}
.calc-btn.kind-mem {
  color: var(--text-dim);
  background: var(--hover);
  border-color: var(--border);
  font-family: var(--mono);
  font-size: 11px;
}
.calc-btn.kind-mem:hover { color: var(--text); background: var(--active); }

/* History panel — sits below the pad */
.calc-history {
  flex: none;
  max-height: 28%;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,.10);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.calc-history-list {
  overflow-y: auto;
  padding: 4px 0;
  flex: 1;
}
.calc-history-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}
.calc-history-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px;
  padding: 6px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .12s ease, border-color .12s ease;
}
.calc-history-row:hover {
  background: var(--hover);
  border-left-color: var(--accent-2);
}
.calc-history-expr {
  font: 11.5px/1.3 var(--mono);
  color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.calc-history-res {
  font: 600 13px/1 var(--mono);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
   Spotlight (system-wide search)
   ========================================================================= */
.spotlight {
  position: fixed; inset: 0;
  z-index: 1000;
  display: grid;
  place-items: start center;
  padding-top: 14vh;
  background: rgba(8, 10, 22, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: spotIn .16s ease-out;
}
.spotlight[hidden] { display: none; }
@keyframes spotIn { from { opacity: 0; } to { opacity: 1; } }

.spotlight-panel {
  width: 640px; max-width: 92vw;
  max-height: 72vh;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2), 0 0 0 1px rgba(168,132,255,0.18) inset;
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: spotPanel .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes spotPanel {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.spotlight-input-row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.spotlight-icon { color: var(--accent-2); flex: none; }
#spotlightInput {
  flex: 1; min-width: 0;
  background: transparent;
  border: 0; outline: none;
  font: 500 18px/1.2 var(--font);
  color: var(--text);
  padding: 4px 0;
}
#spotlightInput::placeholder { color: var(--text-faint); font-weight: 400; }
#spotlightInput::-webkit-search-cancel-button { display: none; }
.spotlight-kbd {
  font: 10.5px/1 var(--mono);
  padding: 4px 7px;
  border-radius: 5px;
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--text-dim);
  flex: none;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.spotlight-results {
  flex: 1 1 auto; min-height: 120px; max-height: 56vh;
  overflow-y: auto;
  padding: 6px 0 8px;
}
.spotlight-section {
  font: 600 10.5px/1 var(--font);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 16px 4px;
}
.spotlight-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  margin: 0 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .08s ease, border-color .08s ease, transform .08s ease;
}
.spotlight-item.selected {
  background: linear-gradient(90deg, rgba(168,132,255,0.18), rgba(112,255,208,0.10));
  border-color: rgba(168,132,255,0.32);
}
.spotlight-item-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--panel-2);
  display: grid; place-items: center;
  flex: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}
.spotlight-item-icon svg { display: block; }
.spotlight-item-text { flex: 1; min-width: 0; }
.spotlight-item-title {
  font-size: 14px; font-weight: 500;
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.spotlight-item-title em {
  font-style: normal;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.spotlight-item-sub {
  font-size: 11.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono);
  margin-top: 1px;
}
.spotlight-item-kind {
  font: 600 10px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--hover);
  border: 1px solid var(--border);
  flex: none;
}
.spotlight-empty {
  padding: 36px 16px 28px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}
.spotlight-empty .spotlight-empty-title {
  font-size: 14px; font-weight: 500; color: var(--text-dim);
  margin-bottom: 4px;
}

.spotlight-foot {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.10);
}
.spotlight-foot kbd {
  font: 10.5px/1 var(--mono);
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--text);
  margin-right: 3px;
  min-width: 14px;
  display: inline-block;
  text-align: center;
}
.spotlight-foot-hint {
  margin-left: auto;
  display: flex; align-items: center; gap: 3px;
}
.spotlight-foot-hint kbd { font-size: 10px; padding: 1px 4px; }

/* Smaller viewports: tighten Spotlight */
@media (max-width: 640px) {
  .spotlight { padding-top: 6vh; }
  .spotlight-panel { max-height: 80vh; }
  .spotlight-foot { flex-wrap: wrap; gap: 8px 14px; }
  .spotlight-foot-hint { display: none; }
}