/* Typed CSS custom property — lets us animate gradient angle */
@property --border-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

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

:root {
  --bg:             #060610;
  --surface:        #0e0e1e;
  --surface2:       #15152a;
  --border:         #1e1e38;
  --text:           #ecedf8;
  --muted:          #6264a0;
  --accent:         #6366f1;
  --accent-light:   #818cf8;
  --accent-lighter: #a5b4fc;
  --aurora-2:       #7c3aed;
  --aurora-3:       #0ea5e9;
  --aurora-4:       #ec4899;
  --danger:         #f87171;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Cinematic vignette — darkens screen edges */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 38%, rgba(6,6,16,0.82) 100%);
  pointer-events: none;
  z-index: 998;
}

/* CRT scanline texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.045) 0px,
    rgba(0,0,0,0.045) 1px,
    transparent      1px,
    transparent      3px
  );
  pointer-events: none;
  z-index: 999;
}

/* ── Warp flash overlay ────────────────────────── */
#warp-flash {
  position: fixed;
  inset: 0;
  background: rgba(190, 180, 255, 1);
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.75s ease-out;
}

/* ── Background layers ────────────────────────── */

#veil-stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.aurora {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.aurora-blob { position: absolute; border-radius: 50%; filter: blur(90px); }

.b1 {
  width: 820px; height: 660px;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--accent) 58%, transparent) 0%, transparent 65%);
  top: -340px; left: calc(50% - 410px);
  animation: blob1 22s ease-in-out infinite;
}
.b2 {
  width: 620px; height: 500px;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--aurora-2) 42%, transparent) 0%, transparent 65%);
  top: -170px; right: -230px;
  animation: blob2 30s ease-in-out infinite;
}
.b3 {
  width: 520px; height: 420px;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--aurora-3) 26%, transparent) 0%, transparent 65%);
  bottom: -150px; left: -130px;
  animation: blob3 25s ease-in-out infinite;
}
/* 4th blob: hot magenta for contrast */
.b4 {
  width: 450px; height: 340px;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--aurora-4) 20%, transparent) 0%, transparent 65%);
  bottom: 5%; right: -90px;
  animation: blob4 19s ease-in-out infinite;
}

@keyframes blob1 {
  0%,100% { transform: translate(  0px,   0px) scale(1.00); }
  25%      { transform: translate(-50px,  65px) scale(1.07); }
  50%      { transform: translate( 65px,  20px) scale(0.95); }
  75%      { transform: translate(-28px, -52px) scale(1.05); }
}
@keyframes blob2 {
  0%,100% { transform: translate(  0px,   0px) scale(1.00); }
  33%      { transform: translate(-72px,  58px) scale(1.10); }
  66%      { transform: translate( 38px, -62px) scale(0.92); }
}
@keyframes blob3 {
  0%,100% { transform: translate(  0px,   0px) scale(1.00); }
  40%      { transform: translate( 62px, -52px) scale(1.14); }
  80%      { transform: translate(-42px,  38px) scale(0.89); }
}
@keyframes blob4 {
  0%,100% { transform: translate(  0px,   0px) scale(1.00); }
  30%      { transform: translate(-52px, -45px) scale(1.11); }
  70%      { transform: translate( 42px,  52px) scale(0.91); }
}

/* Cursor glow orb — positioned by fx.js */
#cursor-glow {
  position: fixed;
  width: 460px; height: 460px;
  margin-left: -230px; margin-top: -230px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--accent) 20%, transparent) 0%,
    color-mix(in srgb, var(--accent) 8%, transparent) 40%,
    transparent 65%
  );
  pointer-events: none;
  z-index: 2;
  will-change: left, top;
}

/* ── Home screen ──────────────────────────────── */

.home {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

/* RGB chromatic aberration burst on warp */
.home.warping { animation: chromatic 0.45s ease-out forwards; }

@keyframes chromatic {
  0%   { filter: none; }
  20%  { filter: drop-shadow( 6px 0 0 rgba(255,0,128,0.60)) drop-shadow(-6px 0 0 rgba(0,128,255,0.60)); }
  55%  { filter: drop-shadow( 9px 0 0 rgba(255,0,128,0.45)) drop-shadow(-9px 0 0 rgba(0,128,255,0.45)); }
  85%  { filter: drop-shadow( 3px 0 0 rgba(255,0,128,0.18)) drop-shadow(-3px 0 0 rgba(0,128,255,0.18)); }
  100% { filter: none; }
}

header {
  margin-top: auto;
  text-align: center;
  padding: 0 1rem 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* ── Logo ─────────────────────────────────────── */

.logo-wrap {
  position: relative;
  margin-bottom: 1rem;
  animation: logo-float 5s ease-in-out 1.2s infinite;
}

/* Two staggered sonar-ring pulses radiating from the logo */
.logo-wrap::before,
.logo-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  border: 2px solid rgba(99, 102, 241, 0.60);
  pointer-events: none;
  animation: ring-pulse 3s ease-out infinite;
}
.logo-wrap::after { animation-delay: 1.5s; }

@keyframes ring-pulse {
  0%   { transform: scale(1.0); opacity: 0.70; }
  75%  { transform: scale(3.2); opacity: 0.00; }
  100% { transform: scale(3.2); opacity: 0.00; }
}

.logo-mark {
  position: relative;
  z-index: 0;
  width: 60px; height: 60px;
  border-radius: 20px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 80%, black), var(--accent-light), var(--accent-lighter));
  display: flex;
  align-items: center;
  justify-content: center;
  animation:
    logo-entrance 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both,
    logo-glow     4s  ease-in-out 0.7s infinite,
    morph         9s  ease-in-out 0.7s infinite;
}

@keyframes morph {
  0%,100% { border-radius: 20px 28px 22px 16px / 16px 22px 28px 20px; }
  25%      { border-radius: 28px 16px 28px 24px / 24px 28px 18px 26px; }
  50%      { border-radius: 18px 26px 16px 28px / 28px 16px 26px 18px; }
  75%      { border-radius: 26px 18px 24px 22px / 22px 24px 20px 24px; }
}

.logo-svg { width: 32px; height: 32px; }

.logo-svg line {
  stroke-dasharray: 24; stroke-dashoffset: 24;
  animation: draw-svg 0.5s ease-out 0.55s both;
}
.logo-svg path {
  stroke-dasharray: 62; stroke-dashoffset: 62;
  animation: draw-svg 0.7s ease-out 0.75s both;
}
@keyframes draw-svg { to { stroke-dashoffset: 0; } }

@keyframes logo-entrance {
  from { opacity: 0; transform: scale(0.4) rotate(-12deg); }
  to   { opacity: 1; transform: scale(1)   rotate(  0deg); }
}
@keyframes logo-float {
  0%,100% { transform: translateY(  0px); }
  50%      { transform: translateY(-9px); }
}
@keyframes logo-glow {
  0%,100% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent),
      0 0 48px color-mix(in srgb, var(--accent) 55%, transparent),
      0 0 110px color-mix(in srgb, var(--accent) 22%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent),
      0 0 68px color-mix(in srgb, var(--accent) 80%, transparent),
      0 0 140px color-mix(in srgb, var(--accent) 38%, transparent);
  }
}

/* ── Title ────────────────────────────────────── */

header h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  background: linear-gradient(
    110deg,
    color-mix(in srgb, var(--accent-lighter) 30%, white) 15%, color-mix(in srgb, var(--accent-lighter) 60%, white) 30%, var(--accent-light) 50%, color-mix(in srgb, var(--accent-lighter) 60%, white) 70%, color-mix(in srgb, var(--accent-lighter) 30%, white) 85%
  );
  background-size: 250% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation:
    slide-up-fade    0.5s ease-out  0.2s both,
    gradient-shimmer 5s  linear     1.0s infinite,
    glitch           6s  step-end   3.0s infinite;
}

/* Dramatic digital glitch — fires every 6s */
@keyframes glitch {
  0%, 79%, 100% { transform: none; filter: none; }
  80%   { transform: translate(-7px, 2px) skewX(-5deg); filter: hue-rotate(160deg) brightness(1.8); }
  80.4% { transform: translate( 8px,-3px) skewX( 4deg); filter: hue-rotate(315deg) brightness(2.2); }
  80.8% { transform: translate(-4px, 0)   skewX(-1deg); filter: none; }
  81.2% { transform: translate( 4px, 1px);               filter: hue-rotate(100deg) brightness(1.5); }
  81.6% { transform: none;                               filter: none; }
  90%   { transform: translate( 5px, 0);                 filter: hue-rotate(70deg)  brightness(1.6); }
  90.4% { transform: translate(-3px, 0);                 filter: none; }
  90.8% { transform: none; }
}

.subtitle {
  color: var(--muted);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  animation: slide-up-fade 0.5s ease-out 0.4s both;
}

@keyframes slide-up-fade {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(  0  ); }
}
@keyframes gradient-shimmer { to { background-position: 250% center; } }

/* ── Search card ──────────────────────────────── */

main {
  width: 100%;
  max-width: 560px;
  padding: 1.75rem;
  background: rgba(14, 14, 30, 0.65);
  backdrop-filter: blur(28px) saturate(1.5);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  border: 1px solid rgba(99, 102, 241, 0.14);
  border-radius: 22px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.03),
    0 24px 64px rgba(0,0,0,0.55);
  margin: 0 1rem;
  animation: slide-up-fade 0.6s ease-out 0.5s both;
  transform-style: preserve-3d;
  transition: border-color 0.3s, box-shadow 0.3s;
  will-change: transform;
}

main:has(.search-bar:focus-within) {
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 24px 64px rgba(0,0,0,0.55),
    0 0 110px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* ── Search form ──────────────────────────────── */

#sj-form { width: 100%; display: flex; flex-direction: column; gap: 1rem; }

/* Spinning conic-gradient border — the signature effect */
.search-bar {
  display: flex;
  gap: 0.4rem;
  border-radius: 999px;
  padding: 0.35rem 0.35rem 0.35rem 0.85rem;
  background:
    linear-gradient(var(--surface2), var(--surface2)) padding-box,
    conic-gradient(
      from var(--border-angle),
      color-mix(in srgb, var(--accent) 75%, transparent)  0%,
      color-mix(in srgb, var(--accent-lighter) 75%, transparent) 35%,
      rgba(192,132,252,0.55) 60%,
      color-mix(in srgb, var(--accent) 75%, transparent) 100%
    ) border-box;
  border: 1.5px solid transparent;
  animation: rotate-border 3s linear infinite;
  transition: filter 0.25s;
}
.search-bar:focus-within {
  animation: rotate-border 1.4s linear infinite, focus-glow 2s ease-in-out infinite;
}
@keyframes rotate-border { to { --border-angle: 360deg; } }
@keyframes focus-glow {
  0%,100% { filter: drop-shadow(0 0 14px color-mix(in srgb, var(--accent) 50%, transparent)); }
  50%      { filter: drop-shadow(0 0 34px color-mix(in srgb, var(--accent) 90%, transparent)); }
}

.search-bar input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 0.95rem; font-family: inherit;
  padding: 0.5rem 0; min-width: 0;
}
.search-bar input::placeholder { color: var(--muted); }

/* ── Submit button ────────────────────────────── */

.search-bar button {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff; border: none; border-radius: 999px;
  padding: 0.52rem 1.45rem; font-size: 0.88rem; font-weight: 600;
  font-family: inherit; cursor: pointer; letter-spacing: 0.01em;
  transition: opacity 0.18s, box-shadow 0.18s, transform 0.12s;
  display: flex; align-items: center; gap: 0.5rem;
  min-width: 68px; justify-content: center; flex-shrink: 0;
}
.search-bar button::after {
  content: ''; position: absolute; inset: 0; left: -80%; width: 55%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.30), transparent);
  transform: skewX(-15deg); pointer-events: none;
}
.search-bar button:hover:not(:disabled)::after { animation: btn-shimmer 0.5s ease forwards; }
@keyframes btn-shimmer { to { left: 160%; } }
.search-bar button:hover:not(:disabled) {
  opacity: 0.88;
  box-shadow: 0 0 30px color-mix(in srgb, var(--accent) 70%, transparent);
  transform: translateY(-1px);
}
.search-bar button:active:not(:disabled) { transform: translateY(0); }
.search-bar button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Loading spinner ──────────────────────────── */

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
  border-radius: 50%; animation: spin 0.7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Autocomplete ─────────────────────────────── */

.ac-wrap {
  position: relative;
}

#ac-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(12, 12, 28, 0.97);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6), 0 0 0 1px color-mix(in srgb, var(--accent) 8%, transparent);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  overflow: hidden;
  z-index: 200;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}

#ac-dropdown.ac-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  cursor: pointer;
  transition: background 0.1s;
}
.ac-item:not(:last-child) {
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.ac-item:hover,
.ac-item.ac-active {
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}

.ac-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
}
.ac-icon--history  { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent-lighter); }
.ac-icon--bookmark { background: rgba(251,191,36,0.10);  color: #fbbf24; }
.ac-icon--suggestion { background: rgba(255,255,255,0.06); color: var(--muted); }

.ac-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.ac-label {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Search engine picker ─────────────────────── */

.engine-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0 0.15rem; }
.engine-label { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.engine-chips { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; cursor: pointer; }
.chip input[type="radio"] { display: none; }
.chip span {
  padding: 0.18rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 500;
  border: 1px solid var(--border); color: var(--muted); transition: all 0.15s; user-select: none;
}
.chip input[type="radio"]:checked + span {
  background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: color-mix(in srgb, var(--accent-lighter) 60%, white);
}
.chip:hover span { border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); }

/* ── Errors ───────────────────────────────────── */

#error-container {
  margin-top: 1.25rem; padding: 1rem 1.2rem;
  background: rgba(248,113,113,0.06); border: 1px solid rgba(248,113,113,0.28);
  border-radius: 12px; color: var(--danger); animation: slide-up-fade 0.3s ease-out both;
}
#sj-error { font-weight: 600; font-size: 0.88rem; margin-bottom: 0.25rem; }
#sj-error-code {
  font-size: 0.78rem; opacity: 0.65; white-space: pre-wrap;
  word-break: break-word; font-family: ui-monospace, "SF Mono", monospace;
}

/* ── Footer ───────────────────────────────────── */

footer {
  margin-top: auto; text-align: center; padding: 2rem 1rem;
  color: var(--muted); font-size: 0.78rem; position: relative; z-index: 1;
  animation: slide-up-fade 0.5s ease-out 0.7s both;
}
footer a { color: var(--accent-light); text-decoration: none; opacity: 0.75; transition: opacity 0.15s; }
footer a:hover { opacity: 1; text-decoration: underline; }

/* ── Browser chrome ───────────────────────────── */

#sj-frame-container {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); z-index: 100;
}

.toolbar {
  position: relative; display: flex; align-items: center; gap: 0.3rem;
  padding: 0.45rem 0.6rem;
  background: rgba(10,10,22,0.92);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 10%, transparent); flex-shrink: 0;
}

/* Animated shimmer stripe across the top of the toolbar */
.toolbar::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1.5px;
  background: linear-gradient(
    90deg, transparent 0%, var(--accent) 20%, var(--accent-lighter) 50%, var(--accent) 80%, transparent 100%
  );
  background-size: 200% 100%;
  animation: stripe-shimmer 2.2s linear infinite;
  opacity: 0.80;
}
@keyframes stripe-shimmer {
  from { background-position:  100% 0; }
  to   { background-position: -100% 0; }
}

.toolbar-btn {
  background: transparent; color: var(--muted); border: none; border-radius: 8px;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s; flex-shrink: 0;
}
.toolbar-btn:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.toolbar-btn:disabled { color: var(--border); cursor: default; }

.url-bar-wrap { flex: 1; position: relative; min-width: 0; }

#sj-url-bar {
  width: 100%; background: rgba(6,6,16,0.8); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 0.82rem; font-family: inherit;
  padding: 0.28rem 0.75rem; outline: none; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; transition: border-color 0.15s, box-shadow 0.15s;
}
#sj-url-bar:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
  white-space: normal; overflow: auto;
}

#sj-load-bar {
  position: absolute; bottom: 0; left: 0; height: 2px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-lighter)); border-radius: 0 0 8px 8px;
  transition: width 0.3s ease, opacity 0.3s; opacity: 0; pointer-events: none;
}
#sj-load-bar.loading { opacity: 1; width: 70%; transition: width 8s linear, opacity 0.3s; }
#sj-load-bar.done    { width: 100%; transition: width 0.15s ease; }

/* ── Quick-access tiles ──────────────────────────────────────────────────── */
.quick-links {
  width: 100%;
  max-width: 520px;
  margin: 1.1rem auto 0;
  padding: 0 0.25rem;
}

.ql-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.55rem;
  padding-left: 0.15rem;
}

.ql-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 0.55rem;
}

.ql-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.42rem;
  padding: 0.65rem 0.3rem 0.55rem;
  background: rgba(14,14,30,0.55);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.ql-tile:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  transform: translateY(-2px);
}
.ql-tile:active { transform: translateY(0); }

.ql-tile-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0;
  flex-shrink: 0;
}

.ql-tile-name {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

/* Remove button on bookmark tiles */
.ql-tile-remove {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(248,113,113,0.18);
  border: none;
  color: var(--danger);
  font-size: 0.65rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s;
  padding: 0;
}
.ql-tile:hover .ql-tile-remove { opacity: 1; }

/* ── Toolbar separator + extra buttons ───────────────────────────────────── */
.toolbar-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}

/* Bookmarked state — filled ribbon */
#btn-bookmark.bookmarked .bm-path {
  fill: var(--accent);
  stroke: var(--accent);
}

/* Copy-URL "copied" flash */
#btn-copy-url.copied {
  color: #4ade80;
}

/* Fullscreen active state */
#btn-fullscreen.in-fullscreen {
  color: var(--accent);
}

/* ── Settings gear button (home screen) ─────────────────────────────────── */
.settings-gear {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: var(--muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 10;
}
.settings-gear:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
}

/* ── Settings overlay + panel ────────────────────────────────────────────── */
#settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
#settings-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

#settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 100vw;
  background: rgba(10,10,24,0.96);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
  box-shadow: -12px 0 48px rgba(0,0,0,0.55);
}
#settings-panel.active {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.1rem 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}
.settings-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: background 0.12s, color 0.12s;
}
.settings-close:hover { background: var(--surface2); color: var(--text); }

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ── Sections ────────────────────────────────────────────────────────────── */
.settings-section {
  padding: 0.9rem 1.1rem 0.65rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.settings-section:last-child { border-bottom: none; }

.settings-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.3rem;
}
.settings-section-desc {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* ── Rows ────────────────────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.settings-row:last-child { margin-bottom: 0; }
.settings-row--actions { gap: 0.5rem; justify-content: flex-start; margin-top: 0.2rem; }
.settings-row--col    { flex-direction: column; align-items: stretch; gap: 0.5rem; }

.settings-label {
  font-size: 0.84rem;
  color: var(--text);
  flex: 1;
}

/* ── Form controls ───────────────────────────────────────────────────────── */
.settings-select,
.settings-input {
  background: rgba(6,6,16,0.75);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 0.3rem 0.6rem;
  outline: none;
  transition: border-color 0.15s;
  flex-shrink: 0;
}
.settings-select {
  cursor: pointer;
  max-width: 155px;
}
.settings-input {
  width: 155px;
}
.settings-select:focus,
.settings-input:focus {
  border-color: color-mix(in srgb, var(--accent) 60%, transparent);
}

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.2s;
}
.toggle-track::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::before { transform: translateX(18px); }

/* ── Danger buttons ──────────────────────────────────────────────────────── */
.settings-btn-danger {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.78rem;
  font-family: inherit;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.settings-btn-danger:hover {
  background: rgba(248,113,113,0.18);
  border-color: rgba(248,113,113,0.5);
}

/* ── Effects body-class overrides ────────────────────────────────────────── */
body.no-scanlines::after { content: none; }
body.no-vignette::before  { content: none; }

/* ── Tab bar ─────────────────────────────────────────────────────────────── */
#tab-bar {
  display: flex;
  align-items: center;
  height: 34px;
  padding: 0 4px;
  gap: 2px;
  background: rgba(6, 6, 16, 0.98);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
#tab-bar::-webkit-scrollbar { height: 3px; }
#tab-bar::-webkit-scrollbar-track { background: transparent; }
#tab-bar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.tab-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 6px 0 8px;
  border-radius: 7px;
  background: rgba(255,255,255,0.04);
  border: 1px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  max-width: 180px;
  min-width: 72px;
  transition: background 0.12s, border-color 0.12s;
}
.tab-chip:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.07); }
.tab-chip.tab-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}

.tab-favicon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  border-radius: 2px;
  object-fit: contain;
}

.tab-title {
  flex: 1;
  font-size: 0.71rem;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  user-select: none;
}
.tab-chip.tab-active .tab-title { color: var(--text); }

.tab-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.3);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  flex-shrink: 0;
  padding: 0;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s, background 0.1s;
}
.tab-chip:hover .tab-close,
.tab-chip.tab-active .tab-close { opacity: 1; }
.tab-close:hover { color: var(--text); background: rgba(255,255,255,0.1); }

#btn-new-tab {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
  margin-left: 2px;
}
#btn-new-tab:hover { background: rgba(255,255,255,0.07); color: var(--text); }

/* ── Tab frame area ───────────────────────────────────────────────────────── */
#tab-frame-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}
.sj-tab-frame {
  position: absolute;
  inset: 0;
  border: none;
  width: 100%;
  height: 100%;
  visibility: hidden;
}
.sj-tab-frame.sj-tab-active { visibility: visible; }

/* ── Games section ───────────────────────────────────────────────────────── */
.games-section {
  width: 100%;
  max-width: 520px;
  margin: 1.1rem auto 0;
  padding: 0 0.25rem;
}

.gs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  padding-left: 0.15rem;
}

.gs-header-btns {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.gs-icon-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}
.gs-icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.gs-toggle { transition: color 0.15s, background 0.15s; }
.gs-toggle.collapsed svg { transform: rotate(-90deg); }

.gs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 0.55rem;
  overflow: hidden;
  max-height: 600px;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  opacity: 1;
}
.gs-grid.collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* Game tiles reuse .ql-tile base but with emoji icon sizing */
.gs-tile-icon {
  font-size: 1.45rem;
  line-height: 1;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Splash screen ───────────────────────────────────────────────────────── */

#splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

/* Scanline sweep — bright horizontal beam from top to bottom */
#splash::before {
  content: '';
  position: absolute;
  left: 0; right: 0; height: 3px; top: -3px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    color-mix(in srgb, var(--accent) 70%, transparent) 15%,
    var(--accent-lighter)  50%,
    color-mix(in srgb, var(--accent) 70%, transparent) 85%,
    transparent 100%
  );
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 80%, transparent), 0 0 50px color-mix(in srgb, var(--accent) 35%, transparent);
  animation: splash-scan 0.6s cubic-bezier(0.4, 0, 0.6, 1) 0.15s forwards;
}

@keyframes splash-scan {
  from { top: -3px; }
  to   { top: 100%;  }
}

/* Exit animation */
#splash.splash-exit {
  animation: splash-out 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes splash-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(1.04); }
}

#splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

/* Logo mark */
#splash-logo-mark {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 24px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 80%, black), var(--accent-light), var(--accent-lighter));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.75rem;
  opacity: 0;
  animation: splash-logo-in 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s forwards;
}

@keyframes splash-logo-in {
  from {
    opacity: 0;
    transform: scale(0.25) rotate(-18deg);
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent);
  }
  55% {
    box-shadow: 0 0 90px 24px color-mix(in srgb, var(--accent) 70%, transparent);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
      0 0 48px color-mix(in srgb, var(--accent) 55%, transparent),
      0 0 100px color-mix(in srgb, var(--accent) 22%, transparent);
  }
}

/* Ripple rings emanating from logo */
#splash-logo-mark::before,
#splash-logo-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 24px;
  border: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  opacity: 0;
  animation: splash-ring 1s ease-out 0.75s forwards;
}
#splash-logo-mark::after { animation-delay: 0.95s; }

@keyframes splash-ring {
  0%   { transform: scale(1);   opacity: 0.7; }
  100% { transform: scale(4.2); opacity: 0; }
}

/* VEIL title */
#splash-title {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  padding-left: 0.28em; /* offset for letter-spacing */
  background: linear-gradient(
    110deg,
    color-mix(in srgb, var(--accent-lighter) 30%, white) 10%, color-mix(in srgb, var(--accent-lighter) 60%, white) 28%, var(--accent-light) 50%, color-mix(in srgb, var(--accent-lighter) 60%, white) 72%, color-mix(in srgb, var(--accent-lighter) 30%, white) 90%
  );
  background-size: 250% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  overflow: hidden;
  margin-bottom: 0.55rem;
  animation: splash-title-shimmer 2.5s linear 0.9s infinite;
}

@keyframes splash-title-shimmer {
  from { background-position: 100% center; }
  to   { background-position:   0% center; }
}

#splash-title span {
  display: inline-block;
  opacity: 0;
  transform: translateY(44px);
  animation: splash-letter 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
#splash-title span:nth-child(1) { animation-delay: 0.60s; }
#splash-title span:nth-child(2) { animation-delay: 0.72s; }
#splash-title span:nth-child(3) { animation-delay: 0.84s; }
#splash-title span:nth-child(4) { animation-delay: 0.96s; }

@keyframes splash-letter {
  to { opacity: 1; transform: translateY(0); }
}

#splash-sub {
  font-size: 0.88rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0;
  animation: splash-fade-up 0.5s ease-out 1.25s forwards;
}

@keyframes splash-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#splash-hint {
  position: absolute;
  bottom: 2.25rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  opacity: 0;
  white-space: nowrap;
  animation: splash-hint-in 0.4s ease-out 1.7s forwards;
}

@keyframes splash-hint-in {
  from { opacity: 0; }
  to   { opacity: 0.4; }
}

/* Progress bar at the very bottom */
#splash-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-lighter), color-mix(in srgb, var(--accent-lighter) 80%, white));
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 70%, transparent);
  animation: splash-progress 2.15s linear 0.15s forwards;
}

@keyframes splash-progress {
  from { width: 0%; }
  to   { width: 100%; }
}

/* ── Lag Reduction / Performance mode ───────────────────────────────────── */

/* Remove backdrop-filter blur — by far the biggest GPU cost */
body.perf-mode main,
body.perf-mode .toolbar,
body.perf-mode .ql-tile,
body.perf-mode #settings-overlay,
body.perf-mode #settings-panel {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Freeze aurora blob animations and dim them */
body.perf-mode .aurora-blob {
  animation-play-state: paused !important;
  opacity: 0.35;
}

/* Stop the gradient shimmer sweep on the title */
body.perf-mode header h1 {
  animation: slide-up-fade 0.5s ease-out 0.2s both !important;
}

/* Stop logo float + ring pulse (keep entrance) */
body.perf-mode .logo-wrap {
  animation: none !important;
}
body.perf-mode .logo-wrap::before,
body.perf-mode .logo-wrap::after {
  animation: none !important;
  opacity: 0 !important;
}
body.perf-mode .logo-mark {
  animation: logo-entrance 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
}

/* Remove tile hover transitions so clicks feel snappier */
body.perf-mode .ql-tile {
  transition: none !important;
}
body.perf-mode .ql-tile:hover {
  transform: none !important;
}

/* ── Panic key display button ────────────────────────────────────────────── */
.panic-key-display {
  background: rgba(6,6,16,0.75);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8rem;
  font-family: ui-monospace, "Cascadia Code", monospace;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
  text-align: center;
}
.panic-key-display:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--text);
}
.panic-key-display.capturing {
  border-color: color-mix(in srgb, var(--accent) 85%, transparent);
  color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
  animation: panic-pulse 1s ease-in-out infinite;
}
@keyframes panic-pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
  50%       { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent); }
}

/* ── History panel ───────────────────────────────────────────────────────── */

#history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
#history-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Slides in from the LEFT (opposite of settings) */
#history-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 340px;
  max-width: 100vw;
  background: rgba(10,10,24,0.97);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.26s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 12px 0 48px rgba(0,0,0,0.55);
}
#history-panel.active {
  transform: translateX(0);
}

/* Search box */
.history-search-wrap {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
#history-search {
  width: 100%;
  background: rgba(6,6,16,0.75);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 0.35rem 0.65rem;
  outline: none;
  transition: border-color 0.15s;
}
#history-search:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
#history-search::placeholder { color: var(--muted); }

/* Scrollable list */
#history-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 0.25rem 0 0.5rem;
}

/* Day group header */
.history-group-header {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0.75rem 1rem 0.25rem;
}

/* Individual row */
.history-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 1rem;
  cursor: pointer;
  transition: background 0.12s;
}
.history-row:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }

.history-favicon {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
  object-fit: contain;
}

.history-info { flex: 1; min-width: 0; }

.history-title {
  font-size: 0.82rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.06rem;
}

.history-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.35rem;
  border-radius: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: color 0.12s, background 0.12s, opacity 0.12s;
}
.history-row:hover .history-remove { opacity: 1; }
.history-remove:hover {
  color: var(--danger);
  background: rgba(248,113,113,0.10);
}

.history-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 3rem 1.5rem;
  line-height: 1.6;
}

/* Footer */
.history-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
#history-clear-all {
  width: 100%;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.28);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.82rem;
  font-family: inherit;
  padding: 0.4rem 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#history-clear-all:hover {
  background: rgba(248,113,113,0.15);
  border-color: rgba(248,113,113,0.45);
}

/* History button on home screen */
.history-home-btn {
  position: absolute;
  top: 1rem;
  right: 3.5rem; /* sits left of the settings gear */
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: var(--muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 10;
}
.history-home-btn:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
}

/* ── Themes ─────────────────────────────────────────────────────────────── */
[data-theme="ember"] {
  --bg:             #0d0804;
  --surface:        #1a1008;
  --surface2:       #241608;
  --border:         #3d2010;
  --muted:          #a06040;
  --accent:         #f97316;
  --accent-light:   #fb923c;
  --accent-lighter: #fdba74;
  --aurora-2:       #dc2626;
  --aurora-3:       #d97706;
  --aurora-4:       #e11d48;
}

[data-theme="emerald"] {
  --bg:             #040d09;
  --surface:        #0a1810;
  --surface2:       #0f2415;
  --border:         #1a3d22;
  --muted:          #4a9060;
  --accent:         #10b981;
  --accent-light:   #34d399;
  --accent-lighter: #6ee7b7;
  --aurora-2:       #0d9488;
  --aurora-3:       #65a30d;
  --aurora-4:       #06b6d4;
}

[data-theme="rose"] {
  --bg:             #0d0608;
  --surface:        #1a0a10;
  --surface2:       #240f18;
  --border:         #3d1020;
  --muted:          #9e4060;
  --accent:         #f43f5e;
  --accent-light:   #fb7185;
  --accent-lighter: #fda4af;
  --aurora-2:       #a855f7;
  --aurora-3:       #f97316;
  --aurora-4:       #d946ef;
}

[data-theme="ocean"] {
  --bg:             #04080d;
  --surface:        #0a1018;
  --surface2:       #0d1824;
  --border:         #10243d;
  --muted:          #406090;
  --accent:         #06b6d4;
  --accent-light:   #22d3ee;
  --accent-lighter: #67e8f9;
  --aurora-2:       #3b82f6;
  --aurora-3:       #6366f1;
  --aurora-4:       #14b8a6;
}

[data-theme="void"] {
  --bg:             #080808;
  --surface:        #111111;
  --surface2:       #1a1a1a;
  --border:         #282828;
  --muted:          #606060;
  --accent:         #94a3b8;
  --accent-light:   #cbd5e1;
  --accent-lighter: #e2e8f0;
  --aurora-2:       #64748b;
  --aurora-3:       #475569;
  --aurora-4:       #334155;
}

[data-theme="chrome"] {
  --bg:             #ffffff;
  --surface:        #f1f3f4;
  --surface2:       #e8eaed;
  --border:         #dadce0;
  --text:           #202124;
  --muted:          #5f6368;
  --accent:         #1a73e8;
  --accent-light:   #4285f4;
  --accent-lighter: #8ab4f8;
  --aurora-2:       #ea4335;
  --aurora-3:       #fbbc04;
  --aurora-4:       #34a853;
  --danger:         #ea4335;
}

/* ── Chrome theme overrides ───────────────────────────────────────────────── */

/* Hide animated background effects */
:root[data-theme="chrome"] .aurora,
:root[data-theme="chrome"] #veil-stars,
:root[data-theme="chrome"] #cursor-glow { display: none !important; }

/* Hide vignette + CRT scanlines */
:root[data-theme="chrome"] body::before,
:root[data-theme="chrome"] body::after { display: none !important; }

/* Base */
:root[data-theme="chrome"] body { background: #ffffff; }

/* Home title — blue gradient */
:root[data-theme="chrome"] header h1 {
  background: linear-gradient(110deg, #1a73e8 20%, #4285f4 50%, #1a73e8 80%);
  background-size: 250% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Logo ring pulse — Chrome blue instead of hardcoded indigo */
:root[data-theme="chrome"] .logo-wrap::before,
:root[data-theme="chrome"] .logo-wrap::after { border-color: rgba(26,115,232,0.45); }

/* Search card */
:root[data-theme="chrome"] main {
  background: #ffffff;
  border: 1px solid #dadce0;
  box-shadow: 0 1px 6px rgba(32,33,36,0.12);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root[data-theme="chrome"] main:has(.search-bar:focus-within) {
  border-color: #1a73e8;
  box-shadow: 0 1px 6px rgba(32,33,36,0.12), 0 0 0 2px rgba(26,115,232,0.15);
}

/* Search bar — flat, no spinning conic gradient */
:root[data-theme="chrome"] .search-bar {
  background: #f1f3f4;
  border: 1.5px solid #dadce0;
  animation: none;
}
:root[data-theme="chrome"] .search-bar:focus-within {
  background: #ffffff;
  border-color: #1a73e8;
  animation: none;
  filter: none;
  box-shadow: none;
}

/* Autocomplete dropdown */
:root[data-theme="chrome"] #ac-dropdown {
  background: #ffffff;
  border: 1px solid #dadce0;
  box-shadow: 0 8px 24px rgba(32,33,36,0.18);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root[data-theme="chrome"] .ac-item:not(:last-child) { border-bottom-color: #e8eaed; }
:root[data-theme="chrome"] .ac-item:hover,
:root[data-theme="chrome"] .ac-item.ac-active { background: #f1f3f4; }

/* Quick-link tiles */
:root[data-theme="chrome"] .ql-tile {
  background: #f8f9fa;
  border-color: #dadce0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root[data-theme="chrome"] .ql-tile:hover { background: #e8f0fe; border-color: #1a73e8; }

/* Settings + History home buttons */
:root[data-theme="chrome"] .settings-gear,
:root[data-theme="chrome"] .history-home-btn {
  background: #ffffff;
  border-color: #dadce0;
  color: #5f6368;
}
:root[data-theme="chrome"] .settings-gear:hover,
:root[data-theme="chrome"] .history-home-btn:hover {
  background: #e8f0fe;
  border-color: #1a73e8;
  color: #1a73e8;
}

/* Toolbar */
:root[data-theme="chrome"] .toolbar {
  background: #f1f3f4;
  border-bottom: 1px solid #dadce0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root[data-theme="chrome"] .toolbar::before { display: none; }
:root[data-theme="chrome"] .toolbar-btn { color: #5f6368; }
:root[data-theme="chrome"] .toolbar-btn:hover:not(:disabled) { background: #e8eaed; color: #202124; }
:root[data-theme="chrome"] .toolbar-sep { background: #dadce0; }

/* URL bar */
:root[data-theme="chrome"] #sj-url-bar {
  background: #ffffff;
  color: #202124;
  border: 1px solid #dadce0;
  box-shadow: none;
}
:root[data-theme="chrome"] #sj-url-bar:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26,115,232,0.2);
}

/* Tab bar */
:root[data-theme="chrome"] #tab-bar {
  background: #dee1e6;
  border-bottom: 1px solid #c4c7cc;
}
:root[data-theme="chrome"] #tab-bar::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); }

/* Tab chips */
:root[data-theme="chrome"] .tab-chip { background: rgba(0,0,0,0.05); border-color: transparent; }
:root[data-theme="chrome"] .tab-chip:hover { background: rgba(0,0,0,0.09); border-color: transparent; }
:root[data-theme="chrome"] .tab-chip.tab-active { background: #ffffff; border-color: #c4c7cc; }
:root[data-theme="chrome"] .tab-title { color: rgba(32,33,36,0.55); }
:root[data-theme="chrome"] .tab-chip.tab-active .tab-title { color: #202124; }
:root[data-theme="chrome"] .tab-close { color: rgba(32,33,36,0.4); }
:root[data-theme="chrome"] .tab-close:hover { color: #202124; background: rgba(0,0,0,0.08); }
:root[data-theme="chrome"] #btn-new-tab { color: rgba(32,33,36,0.45); }
:root[data-theme="chrome"] #btn-new-tab:hover { background: rgba(0,0,0,0.07); color: #202124; }

/* Settings panel */
:root[data-theme="chrome"] #settings-panel {
  background: #ffffff;
  box-shadow: -4px 0 24px rgba(32,33,36,0.14);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root[data-theme="chrome"] .settings-header { border-bottom-color: #e8eaed; }
:root[data-theme="chrome"] .settings-close:hover { background: #f1f3f4; color: #202124; }
:root[data-theme="chrome"] .settings-section { border-bottom-color: #e8eaed; }
:root[data-theme="chrome"] .settings-select,
:root[data-theme="chrome"] .settings-input {
  background: #ffffff;
  border-color: #dadce0;
  color: #202124;
}
:root[data-theme="chrome"] .settings-select:focus,
:root[data-theme="chrome"] .settings-input:focus { border-color: #1a73e8; }
:root[data-theme="chrome"] .panic-key-display {
  background: #ffffff;
  border-color: #dadce0;
  color: #202124;
}

/* History panel */
:root[data-theme="chrome"] #history-panel {
  background: #ffffff;
  box-shadow: 4px 0 24px rgba(32,33,36,0.14);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
:root[data-theme="chrome"] .history-search-wrap { border-bottom-color: #e8eaed; }
:root[data-theme="chrome"] #history-search {
  background: #f1f3f4;
  border-color: #dadce0;
  color: #202124;
}
:root[data-theme="chrome"] #history-search:focus { border-color: #1a73e8; }
:root[data-theme="chrome"] #history-search::placeholder { color: #5f6368; }
:root[data-theme="chrome"] .history-row:hover { background: #f1f3f4; }
:root[data-theme="chrome"] .history-footer { border-top-color: #e8eaed; }


/* ── Theme picker ─────────────────────────────────────────────────────────── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 2px;
  width: 100%;
}

.theme-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  outline: none;
}

.theme-swatch:hover  { transform: scale(1.1); }
.theme-swatch.active { border-color: var(--text); }

.theme-swatch[data-theme="veil"]    { background: linear-gradient(135deg, #060610 0%, #6366f1 100%); }
.theme-swatch[data-theme="ember"]   { background: linear-gradient(135deg, #0d0804 0%, #f97316 100%); }
.theme-swatch[data-theme="emerald"] { background: linear-gradient(135deg, #040d09 0%, #10b981 100%); }
.theme-swatch[data-theme="rose"]    { background: linear-gradient(135deg, #0d0608 0%, #f43f5e 100%); }
.theme-swatch[data-theme="ocean"]   { background: linear-gradient(135deg, #04080d 0%, #06b6d4 100%); }
.theme-swatch[data-theme="void"]    { background: linear-gradient(135deg, #080808 0%, #94a3b8 100%); }
.theme-swatch[data-theme="chrome"]  { background: linear-gradient(135deg, #f1f3f4 0%, #ffffff 50%, #1a73e8 100%); border-color: #dadce0; }
.theme-swatch[data-theme="aura"]    { background: linear-gradient(135deg, #0a0014 0%, #c026d3 50%, #f0abfc 100%); }
.theme-swatch[data-theme="crimson"] { background: linear-gradient(135deg, #0d0203 0%, #dc2626 50%, #fca5a5 100%); }
.theme-swatch[data-theme="gold"]    { background: linear-gradient(135deg, #0d0900 0%, #d97706 50%, #fde68a 100%); }
.theme-swatch--locked               { opacity: 0.45; cursor: not-allowed; font-size: 0.65rem; display: flex; align-items: center; justify-content: center; }
.theme-swatch--locked:hover         { transform: none; }

/* ── Aura theme ──────────────────────────────────────────────────────────── */
:root[data-theme="aura"] {
  --accent:        #c026d3;
  --accent-light:  #f0abfc;
  --accent-dark:   #86198f;
  --bg:            #0a0014;
  --surface:       rgba(30, 0, 50, 0.72);
  --border:        rgba(192, 38, 211, 0.18);
  --text:          #fdf4ff;
  --muted:         #c084fc;
}
:root[data-theme="aura"] .aurora div { filter: hue-rotate(60deg); }

/* ── Crimson theme ───────────────────────────────────────────────────────── */
:root[data-theme="crimson"] {
  --accent:        #dc2626;
  --accent-light:  #fca5a5;
  --accent-dark:   #991b1b;
  --bg:            #0d0203;
  --surface:       rgba(40, 5, 5, 0.72);
  --border:        rgba(220, 38, 38, 0.18);
  --text:          #fff1f2;
  --muted:         #f87171;
}
:root[data-theme="crimson"] .aurora div { filter: hue-rotate(180deg); }

/* ── Gold theme ──────────────────────────────────────────────────────────── */
:root[data-theme="gold"] {
  --accent:        #d97706;
  --accent-light:  #fde68a;
  --accent-dark:   #92400e;
  --bg:            #0d0900;
  --surface:       rgba(40, 28, 0, 0.72);
  --border:        rgba(217, 119, 6, 0.18);
  --text:          #fffbeb;
  --muted:         #fbbf24;
}
:root[data-theme="gold"] .aurora div { filter: hue-rotate(220deg); }

/* ── Ambassador locked gradient swatches ─────────────────────────────────── */
.bg-swatch--locked               { opacity: 0.45; cursor: not-allowed; font-size: 0.6rem; }
.bg-swatch--locked:hover         { transform: none; border-color: transparent; }
.bg-swatch[data-gradient="blaze"] { background: linear-gradient(135deg, #0d0200 0%, #c2410c 50%, #fb923c 100%); }
.bg-swatch[data-gradient="neon"]  { background: linear-gradient(135deg, #001a0d 0%, #059669 40%, #06b6d4 100%); }

/* ── Ambassador home star ────────────────────────────────────────────────── */
#ambassador-home-star {
  position: absolute;
  top: 0.9rem;
  left: 1.1rem;
  font-size: 1.1rem;
  line-height: 1;
  cursor: default;
  user-select: none;
  filter: drop-shadow(0 0 6px rgba(251,191,36,0.7));
  z-index: 10;
}

/* ── Ambassador section ──────────────────────────────────────────────────── */
.ambassador-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(90deg, rgba(245,158,11,0.15), rgba(251,191,36,0.08));
  border: 1px solid rgba(245,158,11,0.35);
  border-radius: 8px;
  color: #fbbf24;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  margin-bottom: 0.5rem;
  width: 100%;
}

.ambassador-input-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.ambassador-input-row .settings-input {
  flex: 1;
  font-size: 0.75rem;
  font-family: monospace;
}

.ambassador-error {
  font-size: 0.75rem;
  color: #f87171;
  margin-top: 0.25rem;
  padding-left: 0.1rem;
}

:root[data-theme="chrome"] .ambassador-badge {
  background: #fef9c3;
  border-color: #fde047;
  color: #92400e;
}
:root[data-theme="chrome"] .ambassador-error { color: #dc2626; }

/* ── Leaderboard ─────────────────────────────────────────────────────────── */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  margin-top: 0.25rem;
}

.lb-entry {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  transition: background 0.15s;
}

.lb-entry--me {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface2));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.lb-rank {
  font-size: 1rem;
  width: 1.6rem;
  text-align: center;
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-entry--me .lb-name { color: var(--accent-light); font-weight: 600; }

.lb-pts {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.lb-entry--me .lb-pts { color: var(--accent-lighter); }

.lb-empty {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0.5rem 0.2rem;
}

/* ── Custom background ───────────────────────────────────────────────────── */
#custom-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ── Background gradient picker ─────────────────────────────────────────── */
.bg-gradient-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
}

.bg-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
  outline: none;
  font-size: 0;
}

.bg-swatch:hover  { transform: scale(1.1); }
.bg-swatch.active { border-color: var(--text); }

/* None / clear swatch */
.bg-swatch[data-gradient=""] {
  background: rgba(255,255,255,0.05);
  border: 2px dashed rgba(255,255,255,0.18);
  color: var(--muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bg-swatch[data-gradient=""].active {
  border-style: solid;
  border-color: var(--text);
}

.bg-swatch[data-gradient="sunset"] { background: linear-gradient(135deg, #0d0508 0%, #3d1515 40%, #7a2c18 70%, #c95524 100%); }
.bg-swatch[data-gradient="cosmos"] { background: linear-gradient(135deg, #050515 0%, #1a0d3d 45%, #2a1858 75%, #0d0528 100%); }
.bg-swatch[data-gradient="forest"] { background: linear-gradient(135deg, #030d05 0%, #0a2010 45%, #183818 75%, #051808 100%); }
.bg-swatch[data-gradient="ocean"]  { background: linear-gradient(180deg, #02080d 0%, #051a30 45%, #083050 75%, #020c1a 100%); }
.bg-swatch[data-gradient="dusk"]   { background: linear-gradient(135deg, #0d0820 0%, #2a1848 45%, #522868 75%, #8a3858 100%); }

/* Full-width URL input inside col row */
.bg-url-input {
  width: 100% !important;
  flex-shrink: 1;
  font-size: 0.78rem;
}
