@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@300;400;500&display=swap');

:root {
  --purple: #c084fc;
  --purple-light: #ede9fe;
  --purple-dark: #7c3aed;
  --accent-cyan: #22d3ee;
  --accent-magenta: #f472b6;
  --accent-blue: #60a5fa;
  --purple-dim: rgba(162, 89, 255, 0.22);
  --purple-border: rgba(255, 255, 255, 0.14);
  --bg-deep: #06060f;
  --bg-mid: #0a0a16;
  --bg-card: rgba(22, 20, 38, 0.78);
  --text: #faf8ff;
  --sub: rgba(238, 232, 255, 0.9);
  --sub-muted: rgba(220, 214, 245, 0.78);
  --glow: 0 0 32px rgba(168, 85, 247, 0.35);

  /* Dark glass + vivid ambient (reference: layered glass over glow) */
  --glass-blur: blur(28px) saturate(1.7);
  --glass-sheen: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(100, 210, 255, 0.08) 38%,
    rgba(244, 114, 182, 0.07) 72%,
    rgba(255, 255, 255, 0.04) 100%
  );
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-border-soft: rgba(255, 255, 255, 0.11);

  --neo-surface: var(--glass-sheen);
  --neo-surface-soft: linear-gradient(168deg, rgba(16, 14, 30, 0.96) 0%, rgba(6, 6, 14, 0.98) 100%);
  --neo-shadow-raised:
    12px 16px 36px rgba(0, 0, 0, 0.55),
    -6px -8px 24px rgba(60, 200, 230, 0.14),
    0 0 0 1px rgba(255, 255, 255, 0.07),
    0 0 55px rgba(180, 80, 255, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  --neo-shadow-raised-hover:
    14px 18px 42px rgba(0, 0, 0, 0.58),
    -7px -9px 28px rgba(70, 210, 235, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 70px rgba(200, 100, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  --neo-shadow-raised-sm:
    7px 10px 24px rgba(0, 0, 0, 0.48),
    -4px -6px 18px rgba(50, 190, 220, 0.12),
    0 0 40px rgba(160, 90, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  --neo-shadow-inset:
    inset 3px 4px 12px rgba(0, 0, 0, 0.45),
    inset -2px -3px 14px rgba(80, 160, 200, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --neo-shadow-inset-deep:
    inset 4px 5px 14px rgba(0, 0, 0, 0.5),
    inset -3px -4px 16px rgba(70, 140, 190, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --neo-radius-lg: 22px;
  --neo-radius-md: 15px;
  --neo-radius-sm: 11px;

  /* ── Gradient theming vars (overridden per theme) ── */
  --html-bg-solid: #06060f;
  --html-bg: linear-gradient(172deg, #0a0814 0%, #06060f 38%, #08081a 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(200, 80, 240, 0.44), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(30, 200, 210, 0.36), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(90, 60, 200, 0.22), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(56, 189, 248, 0.18), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(244, 114, 182, 0.14), transparent 48%);
  --accent-bar-grad: linear-gradient(90deg, #22d3ee, #a78bfa, #f472b6);
  --thumb-grad: linear-gradient(135deg, rgba(56, 189, 248, 0.55) 0%, rgba(167, 139, 250, 0.65) 48%, rgba(244, 114, 182, 0.55) 100%);
  --glow-color-1: rgba(162, 89, 255, 0.5);
  --glow-h2-1: rgba(180, 100, 255, 0.45);
  --glow-h2-2: rgba(40, 200, 220, 0.2);
  --glow-active: rgba(162, 89, 255, 0.7);
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  min-height: 100%;
  width: 100%;
  background: var(--html-bg);
  transition: background 0.6s ease;
}

/* Theme fade: transition all color-consuming properties on key elements */
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background 0.6s ease,
    background-color 0.6s ease,
    border-color 0.6s ease,
    color 0.6s ease,
    box-shadow 0.6s ease,
    text-shadow 0.6s ease !important;
}

html, body {
  min-height: 100%;
  width: 100%;
}

/* Slow-drifting color lights (content stays above at z-index 10+) */
body::before {
  content: '';
  position: fixed;
  inset: -22%;
  z-index: 0;
  pointer-events: none;
  will-change: transform;
  background: var(--body-before-bg);
  animation: bg-amb-drift 32s ease-in-out infinite alternate;
}

body::after {
  content: '';
  position: fixed;
  inset: -15%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  will-change: transform;
  background: var(--body-after-bg);
  animation: bg-amb-drift2 26s ease-in-out infinite alternate;
}

@keyframes bg-amb-drift {
  0%   { transform: translate(0%, 0%) scale(1) rotate(0deg); }
  33%  { transform: translate(5%, -4%) scale(1.06) rotate(1.2deg); }
  66%  { transform: translate(-4%, 6%) scale(1.03) rotate(-0.8deg); }
  100% { transform: translate(2%, 3%) scale(1.05) rotate(0.4deg); }
}

@keyframes bg-amb-drift2 {
  0%   { transform: translate(0%, 0%) scale(1.05); }
  100% { transform: translate(-6%, 5%) scale(1.12); }
}

body {
  display: flex;
  background: transparent;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ── Answer Behaviour Toggle ─────────────────────────────────────────────── */
.behaviour-toggle-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 14px;
}

.behaviour-toggle {
  cursor: pointer;
  user-select: none;
  width: 100%;
  max-width: 340px;
}

.behaviour-track {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-md);
  padding: 4px;
  height: 48px;
  overflow: hidden;
  transition: box-shadow 0.2s;
  box-shadow: var(--neo-shadow-inset-deep);
}

.behaviour-toggle:hover .behaviour-track {
  box-shadow:
    inset 5px 5px 14px rgba(0, 0, 0, 0.5),
    inset -4px -4px 16px rgba(150, 100, 200, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.behaviour-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: calc(33.333% - 3px);
  background: var(--thumb-grad);
  border-radius: 10px;
  border: none;
  box-shadow:
    4px 4px 14px rgba(0, 0, 0, 0.4),
    -2px -2px 12px rgba(100, 200, 255, 0.2),
    0 0 20px rgba(180, 100, 255, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  left: 4px;
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.2s ease;
  z-index: 0;
}

/* Thumb positions: left=autosubmit, mid=smartselect, right=showanswer */
.behaviour-thumb.mid {
  left: calc(33.333%);
}

.behaviour-thumb.right {
  left: calc(66.666%);
}

.behaviour-labels {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
}

.behaviour-label {
  flex: 1;
  text-align: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sub-muted);
  transition: color 0.22s ease;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  padding: 0 2px;
  user-select: none;
}

.behaviour-label.active {
  color: #fff;
  text-shadow: 0 0 10px var(--glow-active);
}

.behaviour-desc {
  text-align: center;
  font-size: 0.8rem;
  color: var(--sub);
  line-height: 1.55;
  min-height: 2.4em;
  transition: opacity 0.2s;
  opacity: 0.95;
}

/* ── Sidebar ── */
.sidebar {
  position: relative;
  z-index: 50;
  width: 86px;
  height: 100vh;
  /* Lighter than --neo-surface-soft so ambient gradient shows through */
  background: linear-gradient(
    168deg,
    rgba(16, 14, 30, 0.52) 0%,
    rgba(6, 6, 14, 0.58) 100%
  );
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: 1px solid rgba(255, 255, 255, 0.09);
  padding: 18px 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
  justify-content: flex-start;
  box-shadow:
    10px 0 32px rgba(8, 6, 18, 0.18),
    inset -1px 0 0 rgba(255, 255, 255, 0.06);
}

.sidebar::after {
  display: none;
}

.logo {
  display: flex;
  justify-content: center;
  padding: 6px 0 10px;
  border-bottom: none;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.1);
}

.logo img {
  width: 52px;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 12px var(--glow-color-1));
}

/* ── Nav (icons + custom hover label, no native title) ── */
.nav {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.nav button {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 10px 6px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(220, 210, 245, 0.88);
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  transition: color 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
  box-shadow: var(--neo-shadow-inset);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav button .nav-icon {
  display: block;
  flex-shrink: 0;
}

.nav button:hover,
.nav button:focus-visible {
  color: #fff;
  z-index: 500;
  background: var(--purple-dim);
  box-shadow:
    inset 3px 3px 8px rgba(0, 0, 0, 0.5),
    inset -2px -2px 10px rgba(0, 0, 0, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nav button.active {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border-color: var(--glass-border);
  color: #fff;
  box-shadow: var(--neo-shadow-raised-sm);
}

/* Custom tooltip (uses data-nav-tip; not browser title) */
.nav button::after {
  content: attr(data-nav-tip);
  position: absolute;
  z-index: 9999;
  left: calc(100% + 12px);
  top: 50%;
  transform: translate(0, -50%);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
  color: #ffffff;
  background: #0a0814;
  background-image: linear-gradient(155deg, rgba(40, 26, 70, 1) 0%, rgba(10, 8, 20, 1) 100%);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.65),
    0 0 24px rgba(140, 90, 220, 0.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease, transform 0.16s ease;
}

.nav button:hover::after,
.nav button:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translate(4px, -50%);
}

/* ── Main content ── */
.main {
  position: relative;
  z-index: 10;
  flex: 1;
  padding: 32px 56px;
  overflow-y: auto;
  height: 100vh;
  background: transparent;
}

.section {
  display: none;
  animation: fadeUp 0.4s cubic-bezier(.22,1,.36,1) both;
}

.section.active {
  display: block;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.history-duration {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: rgba(200, 180, 255, 0.85);
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 0 22px var(--glow-h2-1),
    0 0 36px var(--glow-h2-2);
  margin-bottom: 22px;
  padding-bottom: 12px;
  border-bottom: none;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.14);
}

/* ── Dashboard tab ── */
.dashboard-lead {
  font-size: 0.78rem;
  line-height: 1.55;
  color: rgba(218, 212, 242, 0.72);
  max-width: 720px;
  margin: -8px 0 20px;
  letter-spacing: 0.04em;
}

.dashboard-stat-line {
  margin-bottom: 6px !important;
}

.dashboard-stat-line--small {
  font-size: 1.15rem !important;
  line-height: 1.25;
  word-break: break-word;
}

.card-substat {
  font-size: 0.7rem !important;
  margin-top: 2px !important;
  margin-bottom: 0 !important;
  opacity: 0.85;
}

.card-microcopy {
  font-size: 0.72rem !important;
  font-weight: 500 !important;
  color: rgba(190, 180, 225, 0.55) !important;
  margin: 0 0 10px !important;
  line-height: 1.45 !important;
  text-shadow: none !important;
  letter-spacing: 0.05em;
}

.dashboard-overview-card {
  margin-top: 16px;
}

.dash-overview-wrap {
  position: relative;
  width: 100%;
  height: min(320px, 42vh);
  min-height: 220px;
  margin-top: 8px;
}

.dash-overview-wrap canvas {
  width: 100% !important;
  height: 100% !important;
  min-height: 200px;
}

.graph-box--chart {
  min-height: 100px;
}

.graph-box--chart canvas {
  height: 100px !important;
  max-height: 120px;
}

.dashboard-extra-grid {
  margin-top: 16px;
}

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: stretch;
}

/* Dashboard grids: fixed 3-col layout so cards are all equal */
#dashboard > .grid,
#dashboard > .grid.dashboard-extra-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
}

@media (max-width: 1100px) {
  #dashboard > .grid,
  #dashboard > .grid.dashboard-extra-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  #dashboard > .grid,
  #dashboard > .grid.dashboard-extra-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Cards (match History tab: same glass + inset depth) ── */
.card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-lg);
  padding: 20px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  transition: box-shadow 0.24s ease, border-color 0.24s ease, background 0.24s ease;
  overflow: visible;
  box-shadow: var(--neo-shadow-inset-deep);
}

/* Cards inside dashboard grids stretch to fill the row */
#dashboard > .grid > .card {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* Push chart in Avg Response card to the bottom so heading rows align */
#dashboard > .grid > .card > .graph-box--chart {
  margin-top: auto;
}

.card:hover {
  background: rgba(255, 255, 255, 0.065);
  border-color: var(--glass-border);
  box-shadow:
    var(--neo-shadow-inset-deep),
    0 0 0 1px rgba(180, 150, 255, 0.08);
}

.card h3 {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(236, 230, 255, 0.88);
  margin-bottom: 14px;
}

.card p {
  font-size: 1.6rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
  margin-bottom: 12px;
}

#balanceCard p {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 8px 0 4px;
  letter-spacing: -0.5px;
}

.mode-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-radius: 999px;
  border: none;
  opacity: 0.9;
  background: rgba(0, 0, 0, 0.2);
  box-shadow: var(--neo-shadow-inset);
}

#modelSaveStatus {
  transition: opacity 0.3s;
}

/* ── Toggle pills ── */
.toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

/* ── Token section ── */
.token-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

#tokenDisplay {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-sm);
  padding: 11px 14px;
  color: #fdfcff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  outline: none;
  letter-spacing: 0.04em;
  box-shadow: var(--neo-shadow-inset-deep);
}

#tokenDisplay::placeholder {
  color: rgba(230, 224, 245, 0.5);
  font-size: 0.82rem;
}

/* Token action buttons */
.token-action-btn {
  flex-shrink: 0;
  padding: 10px 14px;
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-sm);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  color: #e4d4ff;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--neo-shadow-raised-sm);
}

.token-action-btn:hover:not(:disabled) {
  color: #fff;
  box-shadow: var(--neo-shadow-raised-hover);
}

.token-action-btn:disabled,
.token-action-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

.token-action-btn.copied {
  border-color: rgba(110, 231, 183, 0.45);
  background: rgba(110, 231, 183, 0.16);
  color: #a7f3d0;
}

/* Reveal lockout indicator */
.reveal-lockout {
  font-size: 0.72rem;
  color: rgba(248, 81, 73, 0.8);
  margin-top: 6px;
  display: none;
  font-family: 'JetBrains Mono', monospace;
}

.reveal-lockout.visible {
  display: block;
}

/* Auto-hide countdown */
.token-auto-hide {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--sub-muted);
  font-family: 'JetBrains Mono', monospace;
  display: none;
}

.token-auto-hide.visible {
  display: flex;
}

.token-timer-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--neo-shadow-inset);
}

.token-timer-fill {
  height: 100%;
  background: var(--accent-bar-grad);
  border-radius: 2px;
  transition: width 1s linear;
  width: 100%;
  box-shadow: 0 0 10px rgba(100, 200, 255, 0.35);
}

.toggle {
  padding: 6px 12px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--sub);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: var(--neo-shadow-inset);
}

.toggle:hover {
  color: var(--purple-light);
  box-shadow:
    inset 3px 3px 7px rgba(0, 0, 0, 0.48),
    inset -2px -2px 8px rgba(130, 90, 190, 0.06);
}

.toggle.active {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  border-color: var(--glass-border);
  color: #fff;
  box-shadow: var(--neo-shadow-raised-sm);
}

/* ── Graph ── */
.graph-box {
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-md);
  padding: 12px 14px;
  box-shadow: var(--neo-shadow-inset-deep);
}

canvas {
  width: 100%;
  height: 80px;
  display: block;
}

/* ── History panel ── */
.history, .console {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-lg);
  padding: 16px;
  height: 360px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  line-height: 1.7;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--neo-shadow-inset-deep);
  color: rgba(245, 242, 255, 0.94);
}

.history::-webkit-scrollbar,
.console::-webkit-scrollbar {
  width: 4px;
}
.console::-webkit-scrollbar-track {
  background: transparent;
}
.console::-webkit-scrollbar-thumb {
  background: var(--purple-dim);
  border-radius: 2px;
}

/* ── History list ── */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-date-sep {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(210, 190, 255, 0.75);
  padding: 18px 0 8px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease,
              opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1), transform 0.46s cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  box-shadow: var(--neo-shadow-inset);
}

.history-row.row-reveal {
  opacity: 0;
  transform: translateY(22px);
}

.history-row:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--glass-border-soft);
  box-shadow:
    inset 3px 3px 8px rgba(6, 4, 16, 0.28),
    inset -2px -2px 10px rgba(100, 140, 200, 0.1);
}

.site-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border-soft);
  box-shadow: var(--neo-shadow-inset);
}

.history-info {
  flex: 1;
  min-width: 0;
}

.history-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-url {
  font-size: 0.72rem;
  color: var(--sub-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  min-width: 64px;
}

.history-row--expandable { flex-wrap: wrap; }

.history-detail {
  flex-basis: 100%;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.28s ease, opacity 0.2s ease, margin-top 0.28s ease, padding-top 0.28s ease;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.history-row--open .history-detail {
  max-height: 460px;
  opacity: 1;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border-soft);
}

.history-detail-row {
  display: flex;
  gap: 10px;
  font-size: 0.78rem;
  line-height: 1.5;
}

.history-detail-k {
  flex-shrink: 0;
  width: 72px;
  color: var(--sub-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  padding-top: 1px;
}

.history-detail-v {
  color: var(--sub);
  word-break: break-word;
  white-space: pre-wrap;
}

.history-detail-answer {
  color: var(--text);
  font-weight: 600;
}

.history-detail-tags {
  flex-wrap: wrap;
  gap: 6px;
}

.history-tag {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border-soft);
  color: var(--sub-muted);
}

.history-meta-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.model-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  max-width: 24px;
  max-height: 24px;
  border-radius: 4px;
  object-fit: contain;
  object-position: center center;
  cursor: default;
  transition: transform 0.15s ease;
  display: block;
  flex-shrink: 0;
  box-sizing: border-box;
}

.model-icon:hover {
  transform: scale(1.2);
}

.history-cost {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: #f85149;
}

.history-time {
  font-size: 0.68rem;
  color: var(--sub-muted);
}

.history-footer {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.load-more {
  padding: 10px 28px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.06);
  color: var(--sub);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s, box-shadow 0.2s;
  box-shadow: var(--neo-shadow-inset);
}

.load-more:hover {
  color: #fff;
  box-shadow: var(--neo-shadow-raised-sm);
}

.load-more:disabled {
  opacity: 0.35;
  cursor: default;
}

.log {
  margin-bottom: 4px;
  color: rgba(230, 220, 250, 0.85);
}

.time {
  color: var(--purple-dim);
  margin-right: 6px;
}

.ok {
  color: #7ee787;
}

.err {
  color: #f85149;
}

/* ── History filters ── */
.history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-lg);
  box-shadow: var(--neo-shadow-inset-deep);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-icon {
  color: rgba(210, 190, 255, 0.75);
  flex-shrink: 0;
}

.filter-sep {
  font-size: 0.68rem;
  color: var(--sub-muted);
  opacity: 0.9;
  padding: 0 1px;
  white-space: nowrap;
}

.filter-divider {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.filter-input {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-sm);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  padding: 7px 11px;
  outline: none;
  transition: box-shadow 0.18s, border-color 0.18s;
  color-scheme: dark;
  box-shadow: var(--neo-shadow-inset);
}

.filter-input:focus {
  box-shadow:
    var(--neo-shadow-inset),
    0 0 0 1px rgba(180, 150, 255, 0.35);
}

.filter-input[type="text"] { width: 170px; }
.filter-date               { width: 132px; }
.filter-time               { width: 88px; }

.filter-select {
  width: auto !important;
  margin-top: 0 !important;
  padding: 7px 28px 7px 11px;
  background-color: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-sm);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23c9a8ff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
  outline: none;
  transition: box-shadow 0.18s, border-color 0.18s;
  box-shadow: var(--neo-shadow-inset);
}

.filter-select:focus {
  box-shadow:
    var(--neo-shadow-inset),
    0 0 0 1px rgba(180, 150, 255, 0.35);
}

.filter-clear-btn {
  display: none;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 7px 12px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-sm);
  color: rgba(236, 228, 255, 0.92);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
  transition: box-shadow 0.15s, color 0.15s;
  box-shadow: var(--neo-shadow-raised-sm);
}

.filter-clear-btn:hover {
  color: #fff;
  box-shadow: var(--neo-shadow-raised-hover);
}

/* ── Select ── */
select {
  width: 100%;
  margin-top: 12px;
  padding: 11px 14px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background-color: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23c9a8ff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s;
  box-shadow: var(--neo-shadow-inset-deep);
}

select:focus {
  outline: none;
  box-shadow:
    var(--neo-shadow-inset-deep),
    0 0 0 1px rgba(180, 150, 255, 0.35);
}

select option {
  background: #242230;
  color: var(--text);
}

/* ── Mode selector ── */
.mode-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn {
  padding: 9px 18px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: var(--sub);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.18s, box-shadow 0.18s, border-color 0.18s;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--neo-shadow-inset);
}

.mode-btn:hover {
  color: var(--purple-light);
  box-shadow:
    inset 3px 3px 8px rgba(0, 0, 0, 0.48),
    inset -2px -2px 10px rgba(130, 90, 190, 0.07);
}

.mode-btn.active {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  border-color: var(--glass-border);
  color: #fff;
  box-shadow: var(--neo-shadow-raised-sm);
}

.mode-btn--max {
  border-color: rgba(255, 196, 90, 0.4);
  color: #ffd27a;
}
.mode-btn--max:hover { color: #ffe0a0; }
.mode-btn--max.active {
  background: linear-gradient(155deg, rgba(255, 200, 90, 0.28), rgba(255, 170, 60, 0.12));
  border-color: rgba(255, 200, 90, 0.6);
  color: #fff5e0;
  box-shadow: var(--neo-shadow-raised-sm), 0 0 18px rgba(255, 190, 80, 0.3);
}

.mode-btn[data-mode="auto"].active {
  background: linear-gradient(155deg, rgba(124, 111, 255, 0.3), rgba(100, 210, 255, 0.12));
  border-color: rgba(140, 130, 255, 0.55);
  box-shadow: var(--neo-shadow-raised-sm), 0 0 16px rgba(124, 111, 255, 0.28);
}

.card--overridden {
  opacity: 0.55;
  pointer-events: none;
}
.card--overridden .mode-override-note {
  pointer-events: auto;
}

/* ── Shortcut recorder ── */
.shortcut-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.shortcut-display {
  flex: 1;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-sm);
  padding: 11px 14px;
  color: #fdfcff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  transition: box-shadow 0.2s, color 0.2s, border-color 0.2s;
  box-shadow: var(--neo-shadow-inset-deep);
}

.shortcut-display.recording {
  box-shadow:
    var(--neo-shadow-inset-deep),
    0 0 0 1px var(--purple);
  color: var(--purple);
  animation: shortcut-pulse 1s ease-in-out infinite;
}

@keyframes shortcut-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

kbd.kbd {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--glass-border-soft);
  border-radius: 6px;
  padding: 2px 7px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: #e8d8ff;
  box-shadow: var(--neo-shadow-inset);
}

/* Visually hidden; keeps #profileLabel for script + screen readers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── Sidebar Footer (sign out only) ── */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  width: 100%;
}

.profile-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px 6px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  transition: box-shadow 0.2s, border-color 0.2s;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: var(--neo-shadow-inset);
}

.profile-row:hover {
  box-shadow:
    inset 3px 3px 8px rgba(0, 0, 0, 0.48),
    inset -2px -2px 10px rgba(130, 90, 190, 0.06);
}

.signout-btn {
  background: linear-gradient(155deg, rgba(55, 22, 26, 0.95), rgba(28, 10, 12, 0.98));
  border: none;
  border-radius: var(--neo-radius-sm);
  color: #f85149;
  cursor: pointer;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.2s;
  flex-shrink: 0;
  box-shadow: var(--neo-shadow-raised-sm);
}

.signout-btn:hover {
  box-shadow: var(--neo-shadow-raised-hover);
}

/* ── Analytics (soft neumorphism, single surface) ── */
.ana-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  opacity: 0.72;
  padding: 40px 0;
  justify-content: center;
  color: var(--sub);
}

.ana-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

/* Author `display:flex` must not override the `hidden` attribute */
.ana-loading[hidden],
.ana-content[hidden] {
  display: none !important;
}

/* Analytics: History-style glass, stepped slightly darker than History */
#analytics .ana-mono {
  background: rgba(255, 255, 255, 0.038);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.095);
  border-radius: var(--neo-radius-lg);
  padding: 22px 22px 26px;
  box-shadow: var(--neo-shadow-inset-deep);
}

#analytics .ana-mono:hover {
  background: rgba(255, 255, 255, 0.048);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow:
    var(--neo-shadow-inset-deep),
    0 0 0 1px rgba(180, 150, 255, 0.055);
}

#analytics .ana-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 132px), 1fr));
  gap: 11px;
  width: 100%;
}

#analytics .ana-stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 100px;
  padding: 14px 14px 16px;
  border-radius: var(--neo-radius-md);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--neo-shadow-inset);
  transition: box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

#analytics .ana-stat:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 3px 3px 8px rgba(6, 4, 16, 0.28),
    inset -2px -2px 10px rgba(100, 140, 200, 0.1);
}

#analytics .ana-stat h3 {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(230, 224, 250, 0.78);
  margin-bottom: 8px;
}

.ana-value {
  font-size: 1.48rem;
  font-weight: 700;
  color: #fff;
  text-shadow:
    0 0 20px rgba(180, 120, 255, 0.35),
    0 0 28px rgba(50, 200, 220, 0.15),
    0 1px 2px rgba(0, 0, 0, 0.35);
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.ana-label {
  font-size: 0.74rem;
  font-weight: 500;
  color: rgba(232, 226, 255, 0.82);
  opacity: 1;
  margin-top: 6px;
  letter-spacing: 0.04em;
}

#analytics .ana-value {
  color: rgba(252, 249, 255, 0.94);
  text-shadow:
    0 0 16px rgba(180, 120, 255, 0.28),
    0 0 22px rgba(50, 200, 220, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.4);
}

#analytics .ana-label {
  color: rgba(218, 212, 242, 0.72);
}

#analytics .ana-subhead {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(232, 226, 255, 0.78);
  margin: 22px 0 11px;
}

#analytics .ana-stats-grid + .ana-subhead {
  margin-top: 18px;
}

#analytics .ana-subhead--inline {
  margin: 18px 0 10px;
}

/* Chart wells: same family as History, slightly dimmer */
#analytics .ana-chart-hint {
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: rgba(180, 170, 220, 0.5);
  margin: -4px 0 10px;
}

#analytics .ana-chart-well {
  border-radius: var(--neo-radius-md);
  padding: 12px 14px 8px;
  min-height: 200px;
  background: rgba(255, 255, 255, 0.036);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.095);
  box-shadow: var(--neo-shadow-inset-deep);
  position: relative;
}

#analytics .ana-chart-well canvas {
  width: 100% !important;
  height: 200px !important;
  display: block;
}

#analytics #modelChartWrap {
  min-height: 180px;
  position: relative;
}

#analytics #modelChartWrap canvas {
  max-height: 260px;
}

/* Two columns inside the same slab */
#analytics .ana-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
  margin-top: 6px;
  align-items: start;
}

#analytics .ana-split-col {
  min-width: 0;
  padding-top: 2px;
}

#analytics .ana-split-col:first-child {
  padding-right: 18px;
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.03);
}

#analytics .ana-split-col:last-child {
  padding-left: 4px;
}

#analytics.analytics-page .site-bar-row,
#analytics.analytics-page .model-bar-row {
  display: flex;
  align-items: center;
  width: 100%;
}

/* Top sites in Analytics: History-style rows, slightly dimmer */
#analytics .site-bar-row {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--neo-shadow-inset);
  transition: box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

#analytics .site-bar-row:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 3px 3px 8px rgba(6, 4, 16, 0.28),
    inset -2px -2px 10px rgba(100, 140, 200, 0.1);
}

/* Model distribution bars */
.model-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 11px;
}

.model-bar-row:last-child {
  margin-bottom: 0;
}

.model-bar-label {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
  flex: 0 1 38%;
  max-width: 200px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-bar-track {
  flex: 1;
  min-width: 48px;
  height: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--glass-border-soft);
  box-shadow: var(--neo-shadow-inset);
}

.model-bar-fill {
  height: 100%;
  background: var(--accent-bar-grad);
  border-radius: 4px;
  transition: width 0.5s ease;
  box-shadow:
    0 0 14px rgba(100, 200, 255, 0.35),
    0 0 18px rgba(200, 100, 255, 0.25);
}

.model-bar-pct {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(210, 175, 255, 0.95);
  width: 40px;
  text-align: right;
  flex-shrink: 0;
  font-family: 'JetBrains Mono', monospace;
}

/* Top sites */
.site-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--neo-radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  box-shadow: var(--neo-shadow-inset);
}

.site-bar-row:last-child {
  margin-bottom: 0;
}

.site-bar-info {
  flex: 1;
  min-width: 0;
}

.site-bar-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.site-acc {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
  vertical-align: middle;
  border: 1px solid transparent;
}

.site-acc.acc-high {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
}

.site-acc.acc-mid {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
}

.site-acc.acc-low {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.3);
}

.site-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--glass-border-soft);
  box-shadow: var(--neo-shadow-inset);
}

.site-bar-fill {
  height: 100%;
  background: var(--accent-bar-grad);
  border-radius: 4px;
  transition: width 0.5s ease;
  box-shadow:
    0 0 12px rgba(56, 189, 248, 0.35),
    0 0 16px rgba(167, 139, 250, 0.28);
}

.site-bar-count {
  font-size: 0.78rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: rgba(210, 175, 255, 0.95);
  flex-shrink: 0;
  white-space: nowrap;
  text-align: right;
}

.site-bar-count .site-bar-pct {
  font-weight: 500;
  font-size: 0.68rem;
  opacity: 0.72;
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after {
    animation: none;
  }
}

/* ── Mobile / Tablet ── */
@media (max-width: 768px) {
  body {
    flex-direction: column;
    overflow: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-right: none;
    border-bottom: none;
    box-shadow:
      0 10px 28px rgba(0, 0, 0, 0.4),
      inset 0 -1px 0 rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(
      168deg,
      rgba(16, 14, 30, 0.52) 0%,
      rgba(6, 6, 14, 0.58) 100%
    );
    backdrop-filter: blur(22px) saturate(1.45);
    -webkit-backdrop-filter: blur(22px) saturate(1.45);
  }

  .sidebar::after { display: none; }

  .logo {
    padding: 0;
    border-bottom: none;
    flex-shrink: 0;
  }

  .logo img { width: 90px; }

  .nav {
    flex-direction: row;
    flex: 1;
    gap: 10px;
  }

  .nav button {
    flex: 1;
    padding: 10px 6px;
  }

  .nav button::after {
    left: 50%;
    right: auto;
    top: calc(100% + 10px);
    transform: translate(-50%, 0);
  }

  .nav button:hover::after,
  .nav button:focus-visible::after {
    transform: translate(-50%, 2px);
  }

  .sidebar-footer {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    border-left: none;
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.05);
    padding-left: 12px;
  }

  .profile-row {
    padding: 6px 8px;
    justify-content: center;
  }

  .main {
    height: auto;
    overflow-y: visible;
    padding: 20px 16px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  #analytics .ana-split {
    grid-template-columns: 1fr;
    gap: 0;
  }

  #analytics .ana-split-col:first-child {
    padding-right: 0;
    padding-bottom: 18px;
    margin-bottom: 6px;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.05);
  }

  #analytics .ana-split-col:last-child {
    padding-left: 0;
  }

  .mode-selector {
    gap: 6px;
  }

  .mode-btn {
    padding: 8px 12px;
    font-size: 0.73rem;
  }

  .token-row {
    flex-wrap: wrap;
  }

  #tokenDisplay {
    width: 100%;
  }

  .shortcut-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  h2 { font-size: 0.95rem; }

  .card p { font-size: 1.3rem; }

  .token-action-btn span {
    display: none;
  }

  .token-action-btn {
    padding: 10px 12px;
  }
}

/* ── Theme Selector ─────────────────────────────────────────────────────────── */
.theme-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 12px;
  border-radius: var(--neo-radius-md);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: box-shadow 0.2s, border-color 0.2s, background 0.2s;
  box-shadow: var(--neo-shadow-inset);
  min-width: 68px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sub-muted);
}

.theme-swatch:hover {
  color: var(--purple-light);
  box-shadow:
    inset 3px 3px 8px rgba(0, 0, 0, 0.48),
    inset -2px -2px 10px rgba(130, 90, 190, 0.07);
}

.theme-swatch.active {
  border-color: var(--glass-border);
  box-shadow: var(--neo-shadow-raised-sm);
  color: #fff;
}

.theme-preview {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  box-shadow: var(--neo-shadow-inset);
  flex-shrink: 0;
}

.theme-preview--asteria {
  background: radial-gradient(circle at 38% 38%, #a78bfa, #22d3ee 55%, #f472b6);
}
.theme-preview--aurora {
  background: radial-gradient(circle at 38% 38%, #34d399, #06b6d4 55%, #3b82f6);
}
.theme-preview--inferno {
  background: radial-gradient(circle at 38% 38%, #fbbf24, #f97316 50%, #ef4444);
}
.theme-preview--ocean {
  background: radial-gradient(circle at 38% 38%, #38bdf8, #60a5fa 55%, #818cf8);
}
.theme-preview--rose {
  background: radial-gradient(circle at 38% 38%, #fb923c, #f43f5e 52%, #be123c);
}
.theme-preview--matte {
  background: radial-gradient(circle at 38% 38%, #cbd5e1, #94a3b8 50%, #475569);
}

/* ── Appearance Controls ─────────────────────────────────────────────────── */
.appearance-controls {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.appear-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.appear-lbl {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sub-muted);
  flex-shrink: 0;
  min-width: 80px;
}

.appear-track {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-md);
  padding: 4px;
  height: 42px;
  width: 200px;
  overflow: hidden;
  box-shadow: var(--neo-shadow-inset-deep);
  transition: box-shadow 0.2s;
  flex-shrink: 0;
}

.appear-thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: calc(50% - 3px);
  background: var(--thumb-grad);
  border-radius: 10px;
  left: 4px;
  transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease;
  box-shadow:
    4px 4px 14px rgba(0, 0, 0, 0.4),
    -2px -2px 12px rgba(100, 200, 255, 0.2),
    0 0 20px rgba(180, 100, 255, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  z-index: 0;
}

.appear-thumb.right {
  left: calc(50%);
}

.appear-opts {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
}

.appear-opt {
  flex: 1;
  text-align: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sub-muted);
  cursor: pointer;
  user-select: none;
  transition: color 0.22s ease;
  z-index: 2;
  position: relative;
  white-space: nowrap;
}

.appear-opt.active {
  color: #fff;
  text-shadow: 0 0 10px var(--glow-active);
}

/* ── Themes ─────────────────────────────────────────────────────────────────── */

/* Aurora ; deep emerald / cyan / indigo */
[data-theme="aurora"] {
  --purple: #10b981;
  --purple-light: #a7f3d0;
  --purple-dark: #047857;
  --accent-cyan: #22d3ee;
  --accent-magenta: #818cf8;
  --accent-blue: #34d399;
  --purple-dim: rgba(16, 185, 129, 0.2);
  --purple-border: rgba(255, 255, 255, 0.14);
  --glow: 0 0 32px rgba(4, 120, 87, 0.38);
  --glow-color-1: rgba(4, 120, 87, 0.58);
  --glow-h2-1: rgba(16, 185, 129, 0.52);
  --glow-h2-2: rgba(34, 211, 238, 0.22);
  --glow-active: rgba(52, 211, 153, 0.85);
  --html-bg-solid: #010a05;
  --html-bg: linear-gradient(172deg, #020d07 0%, #010a05 38%, #030f08 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(4, 120, 87, 0.52), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(34, 211, 238, 0.34), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(129, 140, 248, 0.2), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(52, 211, 153, 0.22), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(34, 211, 238, 0.16), transparent 48%);
  --accent-bar-grad: linear-gradient(90deg, #22d3ee, #10b981, #818cf8);
  --thumb-grad: linear-gradient(135deg, rgba(34, 211, 238, 0.55) 0%, rgba(16, 185, 129, 0.65) 48%, rgba(129, 140, 248, 0.55) 100%);
}

/* Inferno ; molten amber / orange / deep red */
[data-theme="inferno"] {
  --purple: #f97316;
  --purple-light: #ffedd5;
  --purple-dark: #c2410c;
  --accent-cyan: #fbbf24;
  --accent-magenta: #ef4444;
  --accent-blue: #fb923c;
  --purple-dim: rgba(249, 115, 22, 0.22);
  --purple-border: rgba(255, 255, 255, 0.14);
  --glow: 0 0 32px rgba(194, 65, 12, 0.4);
  --glow-color-1: rgba(194, 65, 12, 0.6);
  --glow-h2-1: rgba(249, 115, 22, 0.52);
  --glow-h2-2: rgba(251, 191, 36, 0.22);
  --glow-active: rgba(249, 115, 22, 0.88);
  --html-bg-solid: #0c0501;
  --html-bg: linear-gradient(172deg, #0f0601 0%, #0c0501 38%, #110702 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(194, 65, 12, 0.55), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(239, 68, 68, 0.38), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(251, 191, 36, 0.22), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(249, 115, 22, 0.28), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(251, 191, 36, 0.18), transparent 48%);
  --accent-bar-grad: linear-gradient(90deg, #fbbf24, #f97316, #ef4444);
  --thumb-grad: linear-gradient(135deg, rgba(251, 191, 36, 0.55) 0%, rgba(249, 115, 22, 0.65) 48%, rgba(239, 68, 68, 0.55) 100%);
}

/* Ocean ; vivid sky / deep blue / violet */
[data-theme="ocean"] {
  --purple: #38bdf8;
  --purple-light: #bae6fd;
  --purple-dark: #0369a1;
  --accent-cyan: #22d3ee;
  --accent-magenta: #818cf8;
  --accent-blue: #60a5fa;
  --purple-dim: rgba(56, 189, 248, 0.22);
  --purple-border: rgba(255, 255, 255, 0.14);
  --glow: 0 0 32px rgba(3, 105, 161, 0.4);
  --glow-color-1: rgba(3, 105, 161, 0.58);
  --glow-h2-1: rgba(56, 189, 248, 0.52);
  --glow-h2-2: rgba(34, 211, 238, 0.22);
  --glow-active: rgba(96, 165, 250, 0.88);
  --html-bg-solid: #010610;
  --html-bg: linear-gradient(172deg, #010812 0%, #010610 38%, #020a16 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(3, 105, 161, 0.55), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(129, 140, 248, 0.38), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(34, 211, 238, 0.22), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(56, 189, 248, 0.28), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(129, 140, 248, 0.18), transparent 48%);
  --accent-bar-grad: linear-gradient(90deg, #22d3ee, #38bdf8, #818cf8);
  --thumb-grad: linear-gradient(135deg, rgba(34, 211, 238, 0.55) 0%, rgba(56, 189, 248, 0.65) 48%, rgba(129, 140, 248, 0.55) 100%);
}

/* Rose ; deep crimson / rose / warm gold */
[data-theme="rose"] {
  --purple: #f43f5e;
  --purple-light: #fecdd3;
  --purple-dark: #be123c;
  --accent-cyan: #fda4af;
  --accent-magenta: #fb923c;
  --accent-blue: #e11d48;
  --purple-dim: rgba(244, 63, 94, 0.22);
  --purple-border: rgba(255, 255, 255, 0.14);
  --glow: 0 0 32px rgba(190, 18, 60, 0.38);
  --glow-color-1: rgba(190, 18, 60, 0.6);
  --glow-h2-1: rgba(244, 63, 94, 0.5);
  --glow-h2-2: rgba(251, 146, 60, 0.22);
  --glow-active: rgba(244, 63, 94, 0.88);
  --html-bg-solid: #0f0106;
  --html-bg: linear-gradient(172deg, #120208 0%, #0f0106 38%, #140109 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(190, 18, 60, 0.52), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(244, 63, 94, 0.38), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(251, 146, 60, 0.18), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(244, 63, 94, 0.28), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(251, 146, 60, 0.15), transparent 48%);
  --accent-bar-grad: linear-gradient(90deg, #fb923c, #f43f5e, #be123c);
  --thumb-grad: linear-gradient(135deg, rgba(251, 146, 60, 0.55) 0%, rgba(244, 63, 94, 0.65) 48%, rgba(190, 18, 60, 0.55) 100%);
}

/* Matte ; charcoal / slate / silver */
[data-theme="matte"] {
  --purple: #94a3b8;
  --purple-light: #e2e8f0;
  --purple-dark: #475569;
  --accent-cyan: #cbd5e1;
  --accent-magenta: #64748b;
  --accent-blue: #7f8ea3;
  --purple-dim: rgba(148, 163, 184, 0.18);
  --purple-border: rgba(255, 255, 255, 0.12);
  --glow: 0 0 32px rgba(71, 85, 105, 0.28);
  --glow-color-1: rgba(71, 85, 105, 0.45);
  --glow-h2-1: rgba(148, 163, 184, 0.38);
  --glow-h2-2: rgba(203, 213, 225, 0.16);
  --glow-active: rgba(148, 163, 184, 0.68);
  --html-bg-solid: #060606;
  --html-bg: linear-gradient(172deg, #080808 0%, #060606 38%, #090909 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(71, 85, 105, 0.38), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(100, 116, 139, 0.3), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(148, 163, 184, 0.16), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(148, 163, 184, 0.2), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(100, 116, 139, 0.14), transparent 48%);
  --accent-bar-grad: linear-gradient(90deg, #64748b, #94a3b8, #cbd5e1);
  --thumb-grad: linear-gradient(135deg, rgba(100, 116, 139, 0.5) 0%, rgba(148, 163, 184, 0.6) 48%, rgba(203, 213, 225, 0.5) 100%);
}

/* ── Flashbang overlay ───────────────────────────────────────────────────── */
/* ── Dashboard loading overlay ───────────────────────────────────────────── */
#dash-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#dash-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* blur the main content while loading */
body.dash-loading .main,
body.dash-loading .sidebar {
  filter: blur(6px);
  opacity: 0.45;
  pointer-events: none;
  transition: filter 0.35s ease, opacity 0.35s ease;
}

.dash-loading-inner {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dash-loading-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent, #7c6fff);
  animation: dash-dot-bounce 1.2s ease-in-out infinite;
}
.dash-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.dash-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dash-dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1.15); opacity: 1; }
}

#flashbang-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s ease-out;
}

#flashbang-overlay.flash {
  opacity: 1;
  transition: none;
}

/* ── Gradient OFF ────────────────────────────────────────────────────────── */
html[data-gradient="off"] {
  background: var(--html-bg-solid) !important;
}

html[data-gradient="off"] body::before,
html[data-gradient="off"] body::after {
  display: none;
}

/* ── Light Mode ──────────────────────────────────────────────────────────── */
[data-color-mode="light"] {
  --text: #1c1530;
  --sub: rgba(38, 28, 65, 0.85);
  --sub-muted: rgba(62, 50, 100, 0.7);
  --glass-border: rgba(0, 0, 0, 0.13);
  --glass-border-soft: rgba(0, 0, 0, 0.08);
  --glass-sheen: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.82) 0%,
    rgba(210, 225, 255, 0.45) 38%,
    rgba(255, 210, 235, 0.28) 72%,
    rgba(255, 255, 255, 0.6) 100%
  );
  --neo-shadow-raised:
    6px 8px 22px rgba(0, 0, 0, 0.13),
    -3px -4px 14px rgba(255, 255, 255, 0.9),
    0 0 0 1px rgba(0, 0, 0, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
  --neo-shadow-raised-hover:
    8px 10px 28px rgba(0, 0, 0, 0.16),
    -4px -5px 18px rgba(255, 255, 255, 0.95),
    0 0 0 1px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 1);
  --neo-shadow-raised-sm:
    4px 6px 16px rgba(0, 0, 0, 0.11),
    -2px -3px 12px rgba(255, 255, 255, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --neo-shadow-inset:
    inset 2px 3px 8px rgba(0, 0, 0, 0.1),
    inset -2px -2px 8px rgba(255, 255, 255, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  --neo-shadow-inset-deep:
    inset 3px 4px 10px rgba(0, 0, 0, 0.12),
    inset -2px -3px 10px rgba(255, 255, 255, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  /* Asteria light bg (default) */
  --html-bg-solid: #ede9fe;
  --html-bg: linear-gradient(172deg, #f5f3ff 0%, #ede9fe 38%, #f0f4ff 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(192, 80, 240, 0.1), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(30, 200, 210, 0.08), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(90, 60, 200, 0.06), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(56, 189, 248, 0.06), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(244, 114, 182, 0.05), transparent 48%);
  --glow-h2-1: rgba(124, 58, 237, 0.22);
  --glow-h2-2: rgba(6, 182, 212, 0.14);
}

/* Sidebar in light mode */
[data-color-mode="light"] .sidebar {
  background: linear-gradient(168deg, rgba(255, 255, 255, 0.6) 0%, rgba(248, 245, 255, 0.68) 100%);
  border-right-color: rgba(0, 0, 0, 0.09);
  box-shadow: 6px 0 24px rgba(0, 0, 0, 0.07), inset -1px 0 0 rgba(255, 255, 255, 0.5);
}

[data-color-mode="light"] .nav button {
  background: rgba(255, 255, 255, 0.45);
  color: rgba(55, 40, 90, 0.8);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-color-mode="light"] .nav button:hover {
  color: var(--purple-dark);
  background: rgba(255, 255, 255, 0.6);
}

[data-color-mode="light"] .nav button.active {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.88), rgba(245, 242, 255, 0.65));
  color: var(--purple-dark);
  border-color: rgba(0, 0, 0, 0.11);
}

[data-color-mode="light"] .nav button::after {
  background: #faf8ff;
  background-image: linear-gradient(155deg, #ffffff 0%, #f1ecff 100%);
  color: #1c1530;
  border-color: rgba(0, 0, 0, 0.12);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
}

[data-color-mode="light"] h2 {
  color: var(--purple-dark);
  text-shadow:
    0 0 18px var(--glow-h2-1),
    0 0 30px var(--glow-h2-2);
}

[data-color-mode="light"] .card {
  background: rgba(255, 255, 255, 0.68);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-color-mode="light"] .card:hover {
  background: rgba(255, 255, 255, 0.82);
  border-color: rgba(0, 0, 0, 0.11);
}

[data-color-mode="light"] .card h3 {
  color: rgba(55, 40, 90, 0.7);
}

[data-color-mode="light"] .card p {
  color: var(--text);
}

[data-color-mode="light"] .history,
[data-color-mode="light"] .console {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text);
}

[data-color-mode="light"] .history-date-sep {
  color: rgba(80, 60, 130, 0.65);
}

[data-color-mode="light"] .history-row {
  background: rgba(255, 255, 255, 0.5);
  border-color: transparent;
}

[data-color-mode="light"] .history-row:hover {
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(0, 0, 0, 0.07);
}

[data-color-mode="light"] .behaviour-track {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.09);
}

[data-color-mode="light"] .theme-swatch {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(0, 0, 0, 0.09);
  color: rgba(55, 40, 90, 0.7);
}

[data-color-mode="light"] .theme-swatch:hover {
  background: rgba(255, 255, 255, 0.72);
  color: var(--purple-dark);
}

[data-color-mode="light"] .theme-swatch.active {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 0, 0, 0.13);
  color: var(--purple-dark);
}

[data-color-mode="light"] .appear-track {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.09);
}

[data-color-mode="light"] .appear-opt:not(.active) {
  color: var(--purple-dark);
}

[data-color-mode="light"] .mode-btn {
  background: rgba(255, 255, 255, 0.45);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--sub);
}

[data-color-mode="light"] .mode-btn:hover {
  color: var(--purple-dark);
  background: rgba(255, 255, 255, 0.65);
}

[data-color-mode="light"] .mode-btn.active {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.9), rgba(248, 245, 255, 0.65));
  border-color: rgba(0, 0, 0, 0.12);
  color: var(--purple-dark);
}

[data-color-mode="light"] .load-more {
  background: rgba(255, 255, 255, 0.5);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-color-mode="light"] .load-more:hover {
  background: rgba(255, 255, 255, 0.7);
}

[data-color-mode="light"] .dashboard-lead {
  color: rgba(55, 40, 90, 0.65);
}

[data-color-mode="light"] .card-microcopy {
  color: rgba(80, 65, 120, 0.5) !important;
}

[data-color-mode="light"] .history-duration {
  color: rgba(80, 60, 130, 0.72);
}

[data-color-mode="light"] .console::-webkit-scrollbar-thumb {
  background: rgba(var(--purple), 0.3);
}

/* Per-theme light mode backgrounds */
[data-color-mode="light"][data-theme="aurora"] {
  --html-bg: linear-gradient(172deg, #f0fff8 0%, #e6fff4 38%, #f0fffe 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(4, 120, 87, 0.1), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(34, 211, 238, 0.08), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(129, 140, 248, 0.06), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(52, 211, 153, 0.07), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(34, 211, 238, 0.05), transparent 48%);
  --glow-h2-1: rgba(4, 120, 87, 0.22);
  --glow-h2-2: rgba(34, 211, 238, 0.14);
}

[data-color-mode="light"][data-theme="inferno"] {
  --html-bg: linear-gradient(172deg, #fffaf0 0%, #fff7ed 38%, #fff9f5 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(194, 65, 12, 0.1), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(239, 68, 68, 0.08), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(251, 191, 36, 0.08), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(249, 115, 22, 0.08), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(251, 191, 36, 0.06), transparent 48%);
  --glow-h2-1: rgba(194, 65, 12, 0.22);
  --glow-h2-2: rgba(251, 191, 36, 0.14);
}

[data-color-mode="light"][data-theme="ocean"] {
  --html-bg: linear-gradient(172deg, #f0f8ff 0%, #e8f4ff 38%, #f0f4ff 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(3, 105, 161, 0.1), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(129, 140, 248, 0.08), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(34, 211, 238, 0.06), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(56, 189, 248, 0.08), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(129, 140, 248, 0.06), transparent 48%);
  --glow-h2-1: rgba(3, 105, 161, 0.22);
  --glow-h2-2: rgba(34, 211, 238, 0.14);
}

[data-color-mode="light"][data-theme="rose"] {
  --html-bg: linear-gradient(172deg, #fff0f4 0%, #ffe4e8 38%, #fff5f7 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(190, 18, 60, 0.1), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(244, 63, 94, 0.08), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(251, 146, 60, 0.06), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(244, 63, 94, 0.07), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(251, 146, 60, 0.05), transparent 48%);
  --glow-h2-1: rgba(190, 18, 60, 0.22);
  --glow-h2-2: rgba(251, 146, 60, 0.14);
}

[data-color-mode="light"][data-theme="matte"] {
  --html-bg: linear-gradient(172deg, #f8f9fa 0%, #f1f3f5 38%, #f8f9fa 100%);
  --body-before-bg:
    radial-gradient(ellipse 90% 70% at 72% 22%, rgba(71, 85, 105, 0.07), transparent 56%),
    radial-gradient(ellipse 85% 65% at 18% 82%, rgba(100, 116, 139, 0.06), transparent 54%),
    radial-gradient(ellipse 58% 52% at 52% 48%, rgba(148, 163, 184, 0.04), transparent 60%);
  --body-after-bg:
    radial-gradient(ellipse 70% 55% at 88% 78%, rgba(148, 163, 184, 0.05), transparent 50%),
    radial-gradient(ellipse 65% 50% at 8% 18%, rgba(100, 116, 139, 0.04), transparent 48%);
  --glow-h2-1: rgba(71, 85, 105, 0.2);
  --glow-h2-2: rgba(148, 163, 184, 0.12);
}

/* ── Snap Solve ─────────────────────────────────────────────────────────── */
.snap-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 2px;
}

.snap-row + .snap-row {
  border-top: 1px solid var(--glass-border-soft);
  margin-top: 4px;
}

.snap-lbl {
  flex: 0 0 130px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--sub-muted);
}

.snap-row--disabled .snap-range,
.snap-row--disabled .snap-hold-value {
  opacity: 0.4;
  pointer-events: none;
}

.snap-switch {
  position: relative;
  width: 48px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.22s ease, box-shadow 0.22s ease;
  box-shadow: var(--neo-shadow-inset-deep);
}

.snap-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--thumb-grad);
  box-shadow:
    3px 3px 10px rgba(0, 0, 0, 0.4),
    0 0 12px rgba(180, 100, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: left 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.snap-switch.on .snap-switch-thumb {
  left: 24px;
}

.snap-switch.on {
  background: rgba(180, 100, 255, 0.18);
  box-shadow:
    inset 2px 2px 8px rgba(0, 0, 0, 0.3),
    0 0 14px rgba(180, 100, 255, 0.2);
}

.snap-range {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border-soft);
  border-radius: 999px;
  outline: none;
  box-shadow: var(--neo-shadow-inset-deep);
}

.snap-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--thumb-grad);
  cursor: pointer;
  border: none;
  box-shadow:
    3px 3px 10px rgba(0, 0, 0, 0.4),
    0 0 12px rgba(180, 100, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  transition: transform 0.12s ease;
}

.snap-range::-webkit-slider-thumb:hover {
  transform: scale(1.08);
}

.snap-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--thumb-grad);
  cursor: pointer;
  border: none;
  box-shadow:
    3px 3px 10px rgba(0, 0, 0, 0.4),
    0 0 12px rgba(180, 100, 255, 0.22);
}

.snap-hold-value {
  flex: 0 0 48px;
  text-align: right;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 0 10px var(--glow-active);
  font-variant-numeric: tabular-nums;
}

/* ── Settings section header (Humanization, etc.) ───────────────────────── */
.settings-section-header {
  margin-top: 32px !important;
  background: var(--purple-dim) !important;
  border-color: var(--purple-border) !important;
}

.settings-collapsible {
  cursor: pointer;
  position: relative;
  padding-left: 40px !important;
  user-select: none;
  transition: background 0.12s ease;
}
.settings-collapsible:hover { background: rgba(192,132,252,0.16) !important; }
.settings-chevron {
  position: absolute;
  left: 14px; top: 18px;
  color: var(--purple);
  transition: transform 0.18s ease;
}

.settings-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--purple);
  text-shadow: 0 0 14px var(--glow-color-1);
}

/* ── Stealth badge ────────────────────────────────────────────────────────── */
.stealth-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: var(--neo-radius-sm);
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.28);
  color: #4ade80;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  animation: stealth-pulse 2.4s ease-in-out infinite;
}

@keyframes stealth-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.75; }
}

/* ── Discord-style save bar ──────────────────────────────────────────────── */
.settings-save-bar {
  position: fixed;
  bottom: -120px;
  left: 86px; /* sidebar width */
  right: 0;
  z-index: 200;
  padding: 0 28px 12px;
  transition: bottom 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.settings-save-bar.visible {
  bottom: 0;
  pointer-events: auto;
}

.save-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: rgba(12, 10, 24, 0.96);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--neo-radius-lg);
  box-shadow:
    0 -4px 32px rgba(0, 0, 0, 0.55),
    0 0 0 1px var(--purple-dim),
    0 0 48px var(--purple-dim);
}

.save-bar-left {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(255, 240, 160, 0.92);
  letter-spacing: 0.02em;
}

.save-bar-icon {
  color: rgba(255, 220, 80, 0.85);
  flex-shrink: 0;
}

.save-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.save-bar-reset {
  padding: 8px 18px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.07);
  color: var(--sub-muted);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: color 0.18s, box-shadow 0.18s;
  box-shadow: var(--neo-shadow-inset);
}

.save-bar-reset:hover {
  color: #fff;
  box-shadow: var(--neo-shadow-raised-sm);
}

.save-bar-save {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 22px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid rgba(167, 139, 250, 0.45);
  background: linear-gradient(135deg, rgba(109, 40, 217, 0.65) 0%, rgba(139, 92, 246, 0.55) 100%);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: box-shadow 0.18s, background 0.18s;
  box-shadow:
    0 0 18px rgba(139, 92, 246, 0.4),
    var(--neo-shadow-raised-sm);
}

.save-bar-save:hover {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.75) 0%, rgba(139, 92, 246, 0.68) 100%);
  box-shadow:
    0 0 28px rgba(139, 92, 246, 0.55),
    var(--neo-shadow-raised-hover);
}

.save-bar-save:active {
  transform: scale(0.97);
}

.save-bar-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 7px;
  font-size: 0.68rem !important;
  font-weight: 500 !important;
  color: rgba(200, 190, 230, 0.55) !important;
  letter-spacing: 0.04em;
  padding: 0 4px;
  opacity: 1 !important;
  text-shadow: none !important;
  line-height: 1.4 !important;
}

/* Mobile: save bar spans full width, stacks so text never gets crushed, and
   lifts above the iOS URL bar / home-indicator safe area. */
@media (max-width: 768px) {
  .settings-save-bar {
    left: 0;
    padding: 0 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .save-bar-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }

  .save-bar-left {
    justify-content: center;
    white-space: nowrap;
  }

  .save-bar-right {
    width: 100%;
    gap: 10px;
  }

  .save-bar-reset,
  .save-bar-save {
    flex: 1 1 0;
    justify-content: center;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .save-bar-hint {
    justify-content: center;
    text-align: center;
  }
}

/* Light mode overrides for new elements */
[data-color-mode="light"] .settings-section-header {
  background: rgba(109, 40, 217, 0.06) !important;
}

[data-color-mode="light"] .save-bar-inner {
  background: rgba(248, 246, 255, 0.97);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow:
    0 -4px 24px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(109, 40, 217, 0.1);
}

[data-color-mode="light"] .save-bar-left {
  color: rgba(80, 50, 10, 0.9);
}

[data-color-mode="light"] .save-bar-hint {
  color: rgba(80, 65, 120, 0.5) !important;
}

/* ── Humanize history row ──────────────────────────────────────────── */
.humanize-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.22) 0%, rgba(109, 40, 217, 0.28) 100%);
  border: 1px solid rgba(139, 92, 246, 0.3);
  margin-right: 12px;
  flex-shrink: 0;
}

.humanize-icon {
  color: #a78bfa;
  width: 18px;
  height: 18px;
}

.humanize-stealth-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.6;
}

.humanize-token-cost {
  color: #a78bfa !important;
  font-size: 0.78rem;
  font-weight: 600;
}

.humanize-kind-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 5px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25) 0%, rgba(109, 40, 217, 0.3) 100%);
  color: #c4b5fd;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

/* Light mode for humanize row */
[data-color-mode="light"] .humanize-icon-wrap {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12) 0%, rgba(109, 40, 217, 0.16) 100%);
  border-color: rgba(139, 92, 246, 0.25);
}

[data-color-mode="light"] .humanize-icon {
  color: #7c3aed;
}

[data-color-mode="light"] .humanize-stealth-tag {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  border-color: rgba(16, 185, 129, 0.25);
}

[data-color-mode="light"] .humanize-token-cost {
  color: #7c3aed !important;
}

[data-color-mode="light"] .humanize-kind-badge {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(109, 40, 217, 0.18) 100%);
  color: #6d28d9;
  border-color: rgba(139, 92, 246, 0.3);
}

/* ── Billing ─────────────────────────────────────────────────────────────── */
.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.billing-card {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-lg);
  padding: 22px 20px 20px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--neo-shadow-inset-deep);
  display: flex;
  flex-direction: column;
  min-height: 380px;
  transition: border-color 0.24s ease, box-shadow 0.24s ease, background 0.24s ease, transform 0.24s ease;
}

.billing-card:hover {
  background: rgba(255, 255, 255, 0.065);
  border-color: var(--glass-border);
  transform: translateY(-2px);
}

.billing-card--current {
  border-color: rgba(167, 139, 250, 0.55);
  box-shadow:
    var(--neo-shadow-inset-deep),
    0 0 0 1px rgba(167, 139, 250, 0.35),
    0 0 28px rgba(167, 139, 250, 0.12);
}

.billing-card--canceling {
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow:
    var(--neo-shadow-inset-deep),
    0 0 0 1px rgba(251, 191, 36, 0.25),
    0 0 22px rgba(251, 191, 36, 0.08);
}

.billing-card-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.3);
  color: #d8c9ff;
  margin-bottom: 14px;
  align-self: flex-start;
}

.billing-card[data-tier="lite"]     .billing-card-badge { color: #cbd5e1; background: rgba(148,163,184,0.12); border-color: rgba(148,163,184,0.30); }
.billing-card[data-tier="standard"] .billing-card-badge { color: #93c5fd; background: rgba(96,165,250,0.13);  border-color: rgba(96,165,250,0.32); }
.billing-card[data-tier="premium"]  .billing-card-badge { color: #d8b4fe; background: rgba(192,132,252,0.14); border-color: rgba(192,132,252,0.32); }
.billing-card[data-tier="max"]      .billing-card-badge { color: #f0abfc; background: rgba(232,121,249,0.14); border-color: rgba(232,121,249,0.32); }

.billing-card-name {
  font-size: 1.55rem !important;
  font-weight: 700;
  margin-bottom: 4px !important;
  color: #fff;
}

.billing-card-price {
  font-size: 1.0rem !important;
  font-weight: 600;
  color: rgba(236, 230, 255, 0.92);
  margin-bottom: 4px !important;
}

.billing-card-price span {
  font-size: 0.78rem;
  font-weight: 500;
  color: rgba(236, 230, 255, 0.55);
}

.billing-card-tokens {
  font-size: 0.78rem !important;
  font-weight: 500;
  color: rgba(236, 230, 255, 0.55);
  margin-bottom: 18px !important;
}

.billing-features {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.billing-features li {
  position: relative;
  padding-left: 22px;
  font-size: 0.84rem !important;
  font-weight: 500 !important;
  color: rgba(236, 230, 255, 0.85) !important;
  line-height: 1.45;
  text-shadow: none !important;
  margin: 0 !important;
}

/* Included feature → green checkmark */
.billing-features li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  font-size: 0.95em;
  font-weight: 800;
  line-height: 1.45;
  color: #4ade80;
  text-shadow: 0 0 6px rgba(74, 222, 128, 0.45);
}

/* Excluded feature (e.g. Lite: Essay Writer / Humanizer) → red X, dimmed */
.billing-features li.feat-off {
  color: rgba(236, 230, 255, 0.45) !important;
}

.billing-features li.feat-off::before {
  content: "✕";
  color: #f87171;
  text-shadow: 0 0 6px rgba(248, 113, 113, 0.45);
}

.billing-buy-btn {
  margin-top: auto;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid rgba(167, 139, 250, 0.4);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.18), rgba(96, 165, 250, 0.14));
  color: #faf8ff;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.billing-buy-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.30), rgba(96, 165, 250, 0.22));
  border-color: rgba(167, 139, 250, 0.6);
}

.billing-buy-btn:active:not(:disabled) { transform: translateY(1px); }

.billing-buy-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.billing-buy-btn--current {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.35);
  color: #bbf7d0;
}

/* Status card */
.billing-status-card { margin-top: 6px; }
.billing-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.billing-current-plan {
  font-size: 1.3rem !important;
  font-weight: 700;
  margin-bottom: 4px !important;
  color: #fff;
}
.billing-portal-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: #faf8ff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.billing-portal-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--glass-border);
}

/* Toast (success / cancel banner after returning from Stripe) */
.billing-toast {
  display: none;
  margin: 8px 0 14px;
  padding: 12px 14px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.5;
}
.billing-toast.visible { display: block; }
.billing-toast.is-success {
  background: rgba(74, 222, 128, 0.10);
  border-color: rgba(74, 222, 128, 0.32);
  color: #bbf7d0;
}
.billing-toast.is-cancel {
  background: rgba(248, 113, 113, 0.10);
  border-color: rgba(248, 113, 113, 0.32);
  color: #fecaca;
}
.billing-toast.is-info {
  background: rgba(96, 165, 250, 0.10);
  border-color: rgba(96, 165, 250, 0.32);
  color: #bfdbfe;
}

.billing-test-banner {
  display: none;
  margin: 8px 0 14px;
  padding: 12px 14px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid rgba(251, 191, 36, 0.42);
  background: rgba(251, 191, 36, 0.10);
  color: #fde68a;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.55;
}
.billing-test-banner.visible { display: block; }
.billing-test-banner strong { color: #fef3c7; font-weight: 700; letter-spacing: 0.02em; }
.billing-test-banner code {
  font-family: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.82em;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fef3c7;
}

[data-color-mode="light"] .billing-test-banner {
  background: rgba(217, 119, 6, 0.12);
  border-color: rgba(217, 119, 6, 0.4);
  color: #92400e;
}
[data-color-mode="light"] .billing-test-banner strong { color: #78350f; }
[data-color-mode="light"] .billing-test-banner code {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(217, 119, 6, 0.35);
  color: #78350f;
}

.billing-footnote {
  margin-top: 24px;
  font-size: 0.78rem;
  font-weight: 400;
  color: rgba(236, 230, 255, 0.45);
  line-height: 1.6;
  text-shadow: none !important;
}

/* Light-mode parity */
[data-color-mode="light"] .billing-card-name { color: #1a1530; }
[data-color-mode="light"] .billing-card-price { color: rgba(40, 30, 70, 0.92); }
[data-color-mode="light"] .billing-card-tokens { color: rgba(40, 30, 70, 0.6); }
[data-color-mode="light"] .billing-features li { color: rgba(40, 30, 70, 0.85) !important; }
[data-color-mode="light"] .billing-current-plan { color: #1a1530; }
[data-color-mode="light"] .billing-footnote { color: rgba(40, 30, 70, 0.55); }

/* ── Thank-you celebration ─────────────────────────────────────────────── */
.thankyou-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 15, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.36s ease;
}
.thankyou-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.thankyou-card {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 40px));
  padding: 32px 28px 26px;
  border-radius: var(--neo-radius-lg);
  background: linear-gradient(155deg, rgba(28, 22, 50, 0.95), rgba(14, 10, 30, 0.97));
  border: 1px solid rgba(167, 139, 250, 0.4);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 24px 80px rgba(120, 60, 220, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  transform: translateY(12px) scale(0.96);
  transition: transform 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.thankyou-overlay.visible .thankyou-card {
  transform: translateY(0) scale(1);
}

.thankyou-emoji {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.22), rgba(34, 211, 238, 0.18));
  border: 1px solid rgba(74, 222, 128, 0.4);
  color: #bbf7d0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 28px rgba(74, 222, 128, 0.25);
  animation: thankyou-pop 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

@keyframes thankyou-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); }
}

.thankyou-title {
  font-size: 1.4rem !important;
  font-weight: 700;
  color: #fff !important;
  margin: 0 0 8px !important;
  letter-spacing: -0.01em;
  text-shadow: none !important;
}

.thankyou-sub {
  font-size: 0.92rem !important;
  font-weight: 500 !important;
  color: rgba(236, 230, 255, 0.7) !important;
  margin: 0 0 22px !important;
  line-height: 1.5;
  text-shadow: none !important;
}

.thankyou-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 28px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid rgba(167, 139, 250, 0.45);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.25), rgba(96, 165, 250, 0.18));
  color: #faf8ff;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.thankyou-close:hover {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.38), rgba(96, 165, 250, 0.28));
  border-color: rgba(167, 139, 250, 0.65);
}
.thankyou-close:active { transform: translateY(1px); }

[data-color-mode="light"] .thankyou-card {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.98), rgba(245, 240, 255, 0.98));
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 24px 80px rgba(139, 92, 246, 0.25);
}
[data-color-mode="light"] .thankyou-title { color: #1a1530 !important; }
[data-color-mode="light"] .thankyou-sub   { color: rgba(40, 30, 70, 0.7) !important; }
[data-color-mode="light"] .thankyou-emoji {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.18), rgba(8, 145, 178, 0.15));
  border-color: rgba(22, 163, 74, 0.4);
  color: #15803d;
}

/* ── Cancel subscription button (in status card) ────────────────────────── */
.billing-cancel-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.08);
  color: #fecaca;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}
.billing-cancel-btn:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.55);
}
.billing-cancel-btn:disabled,
.billing-cancel-btn--disabled {
  background: rgba(255, 255, 255, 0.04) !important;
  border-color: rgba(255, 255, 255, 0.10) !important;
  color: rgba(236, 230, 255, 0.4) !important;
  cursor: not-allowed !important;
}
[data-color-mode="light"] .billing-cancel-btn:disabled,
[data-color-mode="light"] .billing-cancel-btn--disabled {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.10) !important;
  color: rgba(40, 30, 70, 0.4) !important;
}
[data-color-mode="light"] .billing-cancel-btn {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.35);
  color: #b91c1c;
}

/* ── Cancel modal ────────────────────────────────────────────────────────── */
.cancel-overlay,
.farewell-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 6, 15, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.cancel-overlay.visible,
.farewell-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.cancel-card,
.farewell-card {
  width: min(420px, calc(100vw - 40px));
  padding: 28px 26px 24px;
  border-radius: var(--neo-radius-lg);
  background: linear-gradient(155deg, rgba(28, 22, 50, 0.96), rgba(14, 10, 30, 0.97));
  border: 1px solid rgba(167, 139, 250, 0.3);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 24px 80px rgba(0, 0, 0, 0.45);
  transform: translateY(10px) scale(0.97);
  transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.cancel-overlay.visible .cancel-card,
.farewell-overlay.visible .farewell-card {
  transform: translateY(0) scale(1);
}

.cancel-title,
.farewell-title {
  font-size: 1.2rem !important;
  font-weight: 700;
  color: #fff !important;
  margin: 0 0 8px !important;
  text-shadow: none !important;
}

.cancel-sub,
.farewell-sub {
  font-size: 0.88rem !important;
  font-weight: 500 !important;
  color: rgba(236, 230, 255, 0.7) !important;
  margin: 0 0 18px !important;
  line-height: 1.55;
  text-shadow: none !important;
}

.cancel-reason-select {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 18px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: #faf8ff;
  font-size: 0.86rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.cancel-reason-select:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.5);
}

.cancel-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.cancel-actions-keep,
.cancel-actions-confirm,
.farewell-close {
  padding: 10px 18px;
  border-radius: var(--neo-radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
  font-family: inherit;
}

.cancel-actions-keep {
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: #faf8ff;
}
.cancel-actions-keep:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--glass-border);
}

.cancel-actions-confirm {
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.22), rgba(220, 38, 38, 0.18));
  color: #fecaca;
}
.cancel-actions-confirm:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.32), rgba(220, 38, 38, 0.28));
  border-color: rgba(248, 113, 113, 0.65);
}
.cancel-actions-confirm:disabled { opacity: 0.6; cursor: not-allowed; }
.cancel-actions-confirm:active:not(:disabled) { transform: translateY(1px); }

/* Farewell card */
.farewell-card { text-align: center; }
.farewell-emoji {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.2), rgba(96, 165, 250, 0.14));
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: #d8c9ff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.farewell-close {
  margin: 6px auto 0;
  display: block;
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: #faf8ff;
}
.farewell-close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--glass-border);
}

/* Light mode */
[data-color-mode="light"] .cancel-card,
[data-color-mode="light"] .farewell-card {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.98), rgba(245, 240, 255, 0.98));
  border-color: rgba(139, 92, 246, 0.3);
}
[data-color-mode="light"] .cancel-title,
[data-color-mode="light"] .farewell-title { color: #1a1530 !important; }
[data-color-mode="light"] .cancel-sub,
[data-color-mode="light"] .farewell-sub { color: rgba(40, 30, 70, 0.72) !important; }
[data-color-mode="light"] .cancel-reason-select {
  background: rgba(255, 255, 255, 0.7);
  color: #1a1530;
  border-color: rgba(0, 0, 0, 0.12);
}
[data-color-mode="light"] .cancel-actions-keep,
[data-color-mode="light"] .farewell-close {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.12);
  color: #1a1530;
}
[data-color-mode="light"] .farewell-emoji {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(96, 165, 250, 0.12));
  border-color: rgba(139, 92, 246, 0.32);
  color: #6d28d9;
}

/* ══════════════════════════════════════════════════════════════════════════
   ONBOARDING WALKTHROUGH
   ══════════════════════════════════════════════════════════════════════════ */
.onb-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 6, 15, 0.62);
  backdrop-filter: blur(8px) saturate(1.2);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.32s ease;
}
.onb-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.onb-card {
  position: relative;
  width: min(460px, calc(100vw - 40px));
  padding: 34px 30px 26px;
  border-radius: var(--neo-radius-lg);
  background: linear-gradient(155deg, rgba(28, 22, 50, 0.96), rgba(13, 10, 28, 0.98));
  border: 1px solid rgba(167, 139, 250, 0.4);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 28px 90px rgba(120, 60, 220, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
  text-align: center;
  transform: translateY(14px) scale(0.97);
  transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
.onb-overlay.visible .onb-card {
  transform: translateY(0) scale(1);
}

.onb-skip {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(236, 230, 255, 0.6);
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}
.onb-skip:hover {
  background: rgba(255, 255, 255, 0.09);
  color: rgba(245, 240, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.22);
}

.onb-icon {
  width: 70px;
  height: 70px;
  margin: 6px auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ddd0ff;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.26), rgba(34, 211, 238, 0.16));
  border: 1px solid rgba(167, 139, 250, 0.42);
  box-shadow: 0 0 34px rgba(168, 85, 247, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.onb-icon--emoji {
  font-size: 34px;
  line-height: 1;
}

.onb-figure {
  margin: 2px auto 18px;
  border-radius: var(--neo-radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  max-width: 100%;
}
.onb-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.onb-title {
  font-size: 1.38rem !important;
  font-weight: 700;
  color: #fff !important;
  margin: 0 0 10px !important;
  letter-spacing: -0.01em;
  text-shadow: none !important;
}

.onb-body {
  font-size: 0.92rem !important;
  font-weight: 400 !important;
  color: rgba(236, 230, 255, 0.74) !important;
  margin: 0 0 22px !important;
  line-height: 1.62;
  text-shadow: none !important;
  min-height: 4.2em;
}
.onb-body b { color: #efe9ff; font-weight: 600; }

.onb-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}
.onb-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1), background 0.2s ease;
}
.onb-dot.done { background: rgba(167, 139, 250, 0.55); }
.onb-dot.active {
  width: 24px;
  background: linear-gradient(90deg, #22d3ee, #a78bfa);
}

.onb-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.onb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 22px;
  border-radius: var(--neo-radius-sm);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease, color 0.18s ease;
}
.onb-btn:active { transform: translateY(1px); }

.onb-btn--ghost {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(236, 230, 255, 0.78);
}
.onb-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.24);
  color: #faf8ff;
}

.onb-btn--primary {
  flex: 1;
  border: 1px solid rgba(167, 139, 250, 0.5);
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.32), rgba(96, 165, 250, 0.24));
  color: #faf8ff;
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.3);
}
.onb-btn--primary:hover {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.46), rgba(96, 165, 250, 0.34));
  border-color: rgba(167, 139, 250, 0.7);
}

/* ── Light mode ── */
[data-color-mode="light"] .onb-card {
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.98), rgba(245, 240, 255, 0.98));
  border-color: rgba(139, 92, 246, 0.35);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.04),
    0 28px 90px rgba(139, 92, 246, 0.28);
}
[data-color-mode="light"] .onb-title { color: #1a1530 !important; }
[data-color-mode="light"] .onb-body  { color: rgba(40, 30, 70, 0.74) !important; }
[data-color-mode="light"] .onb-body b { color: #2a1f50; }
[data-color-mode="light"] .onb-icon  { color: #6d28d9; }
[data-color-mode="light"] .onb-skip  { color: rgba(40, 30, 70, 0.55); border-color: rgba(0,0,0,0.1); }
[data-color-mode="light"] .onb-skip:hover { color: #2a1f50; background: rgba(0,0,0,0.05); }
[data-color-mode="light"] .onb-dot   { background: rgba(40, 30, 70, 0.18); }
[data-color-mode="light"] .onb-btn--ghost {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.03);
  color: rgba(40, 30, 70, 0.78);
}
[data-color-mode="light"] .onb-btn--ghost:hover { color: #1a1530; background: rgba(0,0,0,0.06); }

/* ── Small screens ── */
@media (max-width: 520px) {
  .onb-card { padding: 28px 20px 22px; }
  .onb-title { font-size: 1.2rem !important; }
  .onb-body { font-size: 0.88rem !important; min-height: 5em; }
}

/* ── Use Best Settings ──────────────────────────────────────────────────── */
.best-settings-card {
  margin-top: 6px;
  background: linear-gradient(135deg, rgba(192,132,252,0.12), rgba(124,58,237,0.06)) !important;
  border-color: var(--purple-border) !important;
}
.best-settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.best-settings-text h3 {
  display: flex; align-items: center; gap: 7px; margin: 0 0 4px;
}
.best-settings-text p { margin: 0; font-size: 0.8rem; opacity: 0.62; line-height: 1.5; }
.best-settings-btn {
  flex-shrink: 0;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  font-size: 0.86rem; font-weight: 700; color: #fff; white-space: nowrap;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  border: 1px solid var(--purple-border);
  box-shadow: 0 4px 14px rgba(124,58,237,0.32);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.best-settings-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(124,58,237,0.42); }
.best-settings-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.bs-modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(8,5,20,0.62); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: bsFade 0.15s ease;
}
@keyframes bsFade { from { opacity: 0; } to { opacity: 1; } }
.bs-modal {
  width: 100%; max-width: 420px;
  background: var(--card-bg, #16142a); border: 1px solid var(--purple-border);
  border-radius: 18px; padding: 22px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
  animation: bsPop 0.18s cubic-bezier(0.2,0.9,0.3,1.2);
}
@keyframes bsPop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bs-modal-head {
  display: flex; align-items: center; gap: 9px;
  font-size: 1.05rem; font-weight: 800; color: var(--purple);
}
.bs-modal-sub { margin: 8px 0 16px; font-size: 0.82rem; opacity: 0.65; }
.bs-modal-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 20px; }
.bs-modal-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 12px; border-radius: 9px; background: rgba(255,255,255,0.03);
}
.bs-modal-k { font-size: 0.83rem; opacity: 0.7; }
.bs-modal-v { font-size: 0.85rem; font-weight: 700; }
.bs-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.bs-modal-cancel, .bs-modal-apply {
  padding: 9px 18px; border-radius: 9px; cursor: pointer; font-size: 0.85rem; font-weight: 700;
  border: 1px solid transparent; transition: opacity 0.12s ease;
}
.bs-modal-cancel { background: rgba(255,255,255,0.06); color: var(--text, #fff); border-color: rgba(255,255,255,0.1); }
.bs-modal-apply { background: linear-gradient(135deg, var(--purple), var(--purple-dark)); color: #fff; }
.bs-modal-apply:disabled { opacity: 0.65; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .onb-overlay, .onb-card, .onb-dot { transition: opacity 0.15s ease; }
  .onb-overlay.visible .onb-card { transform: none; }
}

/* ══════════════════════════════════════════════════════════════════════════
   NEW TABS — Activity, Supported Sites, Help + Settings additions
   ══════════════════════════════════════════════════════════════════════════ */

/* Sidebar divider between primary tabs and secondary tabs */
.nav-divider {
  width: 22px;
  height: 1px;
  margin: 8px auto;
  background: var(--glass-border-soft);
}

/* ── Activity feed ── */
.activity-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.activity-summary {
  font-size: 0.82rem;
  opacity: 0.6;
}
#activityRefreshBtn.is-spinning i { animation: spin 0.8s linear infinite; }

.activity-empty {
  text-align: center;
  padding: 48px 0;
  opacity: 0.5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.activity-empty p { font-size: 0.85rem; margin: 0; }

.activity-feed { display: flex; flex-direction: column; gap: 8px; }

.activity-day {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  opacity: 0.45;
  margin: 14px 2px 4px;
}
.activity-day:first-child { margin-top: 0; }

.activity-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-md);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.activity-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--glass-border);
  transform: translateX(2px);
}
.activity-ic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  object-fit: contain;
}
.activity-ic--hmz {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.25), rgba(96, 165, 250, 0.18));
  color: #c4b5fd;
}
.activity-ic--site { background: rgba(255, 255, 255, 0.06); padding: 6px; }
.activity-body { flex: 1; min-width: 0; }
.activity-line {
  font-size: 0.86rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-line strong { font-weight: 700; }
.activity-sub { font-size: 0.74rem; opacity: 0.55; margin-top: 2px; }
.activity-tag {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.18);
  color: #c4b5fd;
  margin-left: 4px;
}
.activity-cost {
  font-size: 0.78rem;
  font-weight: 600;
  opacity: 0.7;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* ── Supported sites ── */
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 20px;
}
.site-card {
  display: flex;
  gap: 13px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-md);
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.site-card:hover {
  border-color: var(--glass-border);
  transform: translateY(-2px);
  box-shadow: var(--neo-shadow-raised-sm);
}
.site-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.06);
  padding: 6px;
  object-fit: contain;
}
.site-card-body { flex: 1; min-width: 0; }
.site-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.site-card-name { font-size: 0.92rem; font-weight: 700; color: var(--text); }
.site-card-cat { font-size: 0.72rem; opacity: 0.5; margin-top: 1px; }
.site-card-note { font-size: 0.78rem; opacity: 0.65; margin-top: 7px; line-height: 1.45; }
.site-badge {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.site-badge--full { background: rgba(74, 222, 128, 0.15); color: #86efac; border: 1px solid rgba(74, 222, 128, 0.3); }
.site-badge--beta { background: rgba(251, 191, 36, 0.13); color: #fcd34d; border: 1px solid rgba(251, 191, 36, 0.28); }
.sites-footnote {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  font-size: 0.8rem;
  opacity: 0.6;
  line-height: 1.5;
}

/* ── Help & support ── */
.help-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.help-quick-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-md);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.help-quick-card:hover {
  border-color: var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}
.help-quick-card > i { color: #c4b5fd; }
.help-quick-title { font-size: 0.9rem; font-weight: 700; }
.help-quick-sub { font-size: 0.76rem; opacity: 0.6; line-height: 1.45; }

.help-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  margin: 28px 0 14px;
  color: var(--text);
}
.help-section-head i { color: #c4b5fd; }

.help-guides { display: flex; flex-direction: column; gap: 10px; }
.help-guide {
  display: flex;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-md);
}
.help-guide-ic {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.22), rgba(96, 165, 250, 0.15));
  color: #c4b5fd;
}
.help-guide-title { font-size: 0.88rem; font-weight: 700; color: var(--text); }
.help-guide-body { font-size: 0.8rem; opacity: 0.68; line-height: 1.55; margin-top: 4px; }
.help-guide-body b { color: var(--text); opacity: 0.95; }

.help-faq { display: flex; flex-direction: column; gap: 8px; }
.help-faq-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--neo-radius-sm);
  overflow: hidden;
}
.help-faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.help-faq-item summary::-webkit-details-marker { display: none; }
.help-faq-chev { transition: transform 0.2s ease; opacity: 0.6; flex-shrink: 0; }
.help-faq-item[open] .help-faq-chev { transform: rotate(180deg); }
.help-faq-a {
  padding: 0 16px 15px;
  font-size: 0.8rem;
  opacity: 0.7;
  line-height: 1.6;
}

/* ── Settings: Extension / Device ── */
.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.device-status { display: flex; align-items: center; gap: 9px; font-size: 0.85rem; font-weight: 600; }
.device-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6b7280;
  box-shadow: 0 0 0 0 rgba(107, 114, 128, 0);
  flex-shrink: 0;
}
.device-dot.on {
  background: #4ade80;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.6);
}
.device-version { font-size: 0.75rem; opacity: 0.5; }
.device-meta { font-size: 0.78rem; opacity: 0.6; margin-top: 8px; line-height: 1.5; }

/* ── Settings: Account security ── */
.account-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.account-current {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}
.account-danger-card { border-color: rgba(248, 113, 113, 0.28); }
.account-danger-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--neo-radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.45);
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.18), rgba(220, 38, 38, 0.14));
  transition: background 0.18s ease, border-color 0.18s ease;
}
.account-danger-btn:hover {
  background: linear-gradient(135deg, rgba(248, 113, 113, 0.3), rgba(220, 38, 38, 0.24));
  border-color: rgba(248, 113, 113, 0.65);
}

/* ── Account modals (reuse cancel-overlay base) ── */
.account-card { text-align: left; }
.account-input {
  width: 100%;
  padding: 11px 13px;
  margin-bottom: 10px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid var(--glass-border-soft);
  background: rgba(255, 255, 255, 0.05);
  color: #faf8ff;
  font-size: 0.86rem;
  font-family: inherit;
  box-sizing: border-box;
}
.account-input:focus {
  outline: none;
  border-color: rgba(167, 139, 250, 0.5);
}
.account-input--code {
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 0.4em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.account-confirm--primary {
  border: 1px solid rgba(167, 139, 250, 0.5) !important;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.3), rgba(96, 165, 250, 0.22)) !important;
  color: #ede9fe !important;
}
.account-confirm--primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.42), rgba(96, 165, 250, 0.32)) !important;
}
.account-modal-msg {
  font-size: 0.78rem;
  min-height: 1.1em;
  margin: 2px 0 14px;
  line-height: 1.4;
}
.account-modal-msg.is-err { color: #fca5a5; }
.account-modal-msg.is-ok  { color: #86efac; }

/* ── What's New — centered modal, built from the dashboard's own card language ── */
.whatsnew-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 6, 15, 0.58);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.whatsnew-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.whatsnew-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(460px, calc(100vw - 40px));
  max-height: min(80vh, 640px);
  border-radius: var(--neo-radius-lg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow:
    var(--neo-shadow-inset-deep),
    0 28px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(180, 150, 255, 0.08);
  transform: translateY(10px) scale(0.985);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}
.whatsnew-overlay.visible .whatsnew-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.whatsnew-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--glass-border-soft);
}
.whatsnew-eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.85);
  margin-bottom: 6px;
}
.whatsnew-ver {
  margin: 0;
  font-size: 1.32rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.whatsnew-date {
  flex-shrink: 0;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
  color: rgba(236, 230, 255, 0.7);
  box-shadow: var(--neo-shadow-inset);
  white-space: nowrap;
}

.whatsnew-body {
  padding: 18px 24px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.whatsnew-summary {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: rgba(236, 230, 255, 0.78);
}

.whatsnew-group {
  padding: 14px 16px 16px;
  border-radius: var(--neo-radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border-soft);
  box-shadow: var(--neo-shadow-inset);
}
.whatsnew-cat {
  display: inline-block;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 11px;
  border: 1px solid transparent;
}
.whatsnew-group--fixed   .whatsnew-cat { color: #86efac; background: rgba(74, 222, 128, 0.13);  border-color: rgba(74, 222, 128, 0.3); }
.whatsnew-group--added   .whatsnew-cat { color: #93c5fd; background: rgba(96, 165, 250, 0.14);  border-color: rgba(96, 165, 250, 0.32); }
.whatsnew-group--removed .whatsnew-cat { color: #fca5a5; background: rgba(248, 113, 113, 0.14); border-color: rgba(248, 113, 113, 0.32); }

.whatsnew-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.whatsnew-items li {
  position: relative;
  padding-left: 18px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: rgba(236, 230, 255, 0.82);
}
.whatsnew-items li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.6em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(196, 181, 253, 0.55);
}
.whatsnew-group--fixed   .whatsnew-items li::before { background: rgba(74, 222, 128, 0.6); }
.whatsnew-group--added   .whatsnew-items li::before { background: rgba(96, 165, 250, 0.6); }
.whatsnew-group--removed .whatsnew-items li::before { background: rgba(248, 113, 113, 0.6); }

.whatsnew-foot {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--glass-border-soft);
}
.whatsnew-okay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  padding: 11px 26px;
  border-radius: var(--neo-radius-sm);
  border: 1px solid rgba(167, 139, 250, 0.5);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #faf8ff;
  cursor: pointer;
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.32), rgba(96, 165, 250, 0.24));
  box-shadow: 0 6px 22px rgba(124, 58, 237, 0.3);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.whatsnew-okay:hover {
  background: linear-gradient(135deg, rgba(167, 139, 250, 0.46), rgba(96, 165, 250, 0.34));
  border-color: rgba(167, 139, 250, 0.7);
}
.whatsnew-okay:active { transform: translateY(1px); }

/* ── Light mode ── */
[data-color-mode="light"] .whatsnew-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(0, 0, 0, 0.08);
}
[data-color-mode="light"] .whatsnew-ver     { color: #1a1530; text-shadow: none; }
[data-color-mode="light"] .whatsnew-eyebrow  { color: #7c3aed; }
[data-color-mode="light"] .whatsnew-date     { background: rgba(0, 0, 0, 0.05); color: rgba(40, 30, 70, 0.7); }
[data-color-mode="light"] .whatsnew-summary,
[data-color-mode="light"] .whatsnew-items li { color: rgba(40, 30, 70, 0.82); }
[data-color-mode="light"] .whatsnew-group {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

/* ══════════════════════════════════════════════════════════════════════
   Responsive — consolidated mobile/tablet pass
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .main { padding: 24px 20px; }
  #dashboard > .grid,
  #dashboard > .grid.dashboard-extra-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-overview-wrap { height: min(280px, 46vh); }
}

@media (max-width: 768px) {
  /* History filter bar: let controls wrap instead of overflowing */
  .history-filters { gap: 10px; padding: 12px 14px; }
  .filter-group { flex: 1 1 auto; }
  .filter-input[type="text"] { width: 100%; flex: 1 1 140px; }
  .filter-date, .filter-time { flex: 1 1 auto; width: auto; }
  .filter-divider { display: none; }
  .filter-clear-btn { margin-left: 0; }

  /* Behaviour toggle full width */
  .behaviour-toggle { max-width: 100%; }

  /* Best-settings row stacks */
  .best-settings-row { flex-direction: column; align-items: stretch; text-align: left; }
  .best-settings-btn { width: 100%; justify-content: center; }

  /* History rows: keep meta from squeezing the title */
  .history-row { gap: 10px; padding: 11px 12px; }
  .history-meta { min-width: 52px; }

  /* Mode selector wraps cleanly */
  .mode-selector { gap: 6px; }
  .mode-btn { flex: 1 1 auto; justify-content: center; }
}

@media (max-width: 600px) {
  .main { padding: 18px 14px; }

  /* Single column everywhere on phones */
  #dashboard > .grid,
  #dashboard > .grid.dashboard-extra-grid,
  .grid { grid-template-columns: 1fr; }

  /* Sidebar-as-topbar: keep nav from crowding the logo */
  .logo img { width: 72px; }
  .nav { gap: 6px; }
  .nav button { padding: 9px 4px; }

  /* Analytics stat grid: 2-up instead of cramped auto-fit */
  #analytics .ana-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #analytics .ana-mono { padding: 18px 16px 20px; }

  /* Charts don't need to be tall on a phone */
  .dash-overview-wrap { height: 240px; min-height: 200px; }
  #analytics .ana-chart-well canvas { height: 180px !important; }

  /* Billing cards full width, drop the hover lift */
  .billing-grid { grid-template-columns: 1fr; gap: 14px; }
  .billing-card:hover { transform: none; }
}

@media (max-width: 400px) {
  #analytics .ana-stats-grid { grid-template-columns: 1fr; }
  .filter-input[type="text"] { flex-basis: 100%; }
}

/* Touch devices: larger tap targets, no sticky hover */
@media (hover: none) {
  .nav button,
  .mode-btn,
  .toggle,
  .token-action-btn,
  .btn,
  .behaviour-label { min-height: 42px; }
  .history-row { min-height: 48px; }
}