/* ═══════════════════════════════════════════════════════════════════════
   Wolf Theme System — shared across all pages
   Include this BEFORE page-specific <style> blocks.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: dark;   /* native <select> option popups render dark (fixes Windows/Chrome
                           white-on-white dropdown text in dark mode); light mode overrides below */
  --accent: #CC2030; --accent2: #FF3344; --accent-rgb: 204,32,48;
  --glass-bg: rgba(255,255,255,.04); --glass-border: rgba(255,255,255,.08);
  --surface: rgba(14,14,18,.72); --surface2: rgba(255,255,255,.06);
  --border: rgba(255,255,255,.09); --fg: #e8eaf0; --fg-dim: #8a8fa8;
  --glow-red: 0 0 32px rgba(204,32,48,.35);
  --bg-overlay-opacity: 0.85;
  /* legacy aliases — keep existing page styles working */
  --primary: #CC2030; --secondary: #FF3344;
  --error: #f87171; --danger: #CC2030; --danger2: #FF3344;
  --success: #34d399; --warn: #fbbf24;
}

/* ── Anti-flash canvas (accessibility) ─────────────────────────────────────
   The dark look is painted by body::before (a fixed layer) and light-mode by a
   body class set by JS after load — so html/body themselves had NO solid colour.
   Chrome/Firefox honour color-scheme for the canvas, but SAFARI paints the canvas
   WHITE during navigation/iframe-load before body::before renders → a full-white
   flash on every dark-mode page switch. A white strobe is a photosensitive-seizure
   risk, so give html a solid dark base that paints on the FIRST frame (render-blocking
   CSS), before body::before or any JS. theme.js's pre-paint bootstrap adds .pref-light
   for light-mode users so they don't get the inverse (dark) flash. */
html { background-color: #08080c; }
html.pref-light { background-color: #f0f2f8; }

/* ── Animated mesh background ──────────────────────────────────────────── */
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%,  rgba(var(--accent-rgb),.18) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(var(--accent-rgb),.10) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%,  rgba(var(--accent-rgb),.05) 0%, transparent 70%),
    linear-gradient(160deg, #0c0c10 0%, #09090d 40%, #0d0d12 100%);
}
body.bg-void::before        { background: #060606; }
body.bg-aurora::before      { background: radial-gradient(ellipse 80% 60% at 0% 0%, rgba(var(--accent-rgb),.28) 0%, transparent 60%), radial-gradient(ellipse 60% 50% at 100% 100%, rgba(14,165,233,.18) 0%, transparent 55%), radial-gradient(ellipse 70% 60% at 50% 50%, rgba(139,92,246,.10) 0%, transparent 70%), #080808; }
body.bg-blueprint::before   { background: linear-gradient(rgba(14,165,233,.13) 1px, transparent 1px), linear-gradient(90deg, rgba(14,165,233,.13) 1px, transparent 1px), #040c14; background-size: 32px 32px, 32px 32px, auto; }
body.bg-carbon::before      { background: repeating-linear-gradient(45deg, rgba(255,255,255,.06) 0, rgba(255,255,255,.06) 1px, transparent 1px, transparent 6px), repeating-linear-gradient(-45deg, rgba(255,255,255,.06) 0, rgba(255,255,255,.06) 1px, transparent 1px, transparent 6px), #0a0a0a; }
body.bg-dots::before        { background: radial-gradient(circle, rgba(255,255,255,.18) 1px, transparent 1px) 16px 16px / 16px 16px, #06060e; }
body.bg-topographic::before { background: repeating-radial-gradient(ellipse 70% 50% at 50% 50%, transparent 0, transparent 8px, rgba(255,255,255,.07) 9px, transparent 10px), #080a08; }
body.bg-space::before       { background: radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,.85) 0%, transparent 100%), radial-gradient(1px 1px at 75% 60%, rgba(255,255,255,.70) 0%, transparent 100%), radial-gradient(2px 2px at 40% 80%, rgba(255,255,255,.50) 0%, transparent 100%), radial-gradient(1px 1px at 90% 10%, rgba(255,255,255,.65) 0%, transparent 100%), #020208; }
body.bg-upload::before      { background-image: linear-gradient(rgba(0,0,0,var(--bg-overlay-opacity,.85)), rgba(0,0,0,var(--bg-overlay-opacity,.85))), var(--upload-bg-url); background-size: cover; background-position: center; }
body.bg-upload              { background: transparent !important; }

/* ── Visual modes ──────────────────────────────────────────────────────── */
body.vmode-mono {
  --success: color-mix(in srgb, var(--accent) 46%, black);
  --warn:    color-mix(in srgb, var(--accent) 72%, white);
  --error:   color-mix(in srgb, var(--accent) 52%, black);
  --danger:  var(--accent);
  --green:   color-mix(in srgb, var(--accent) 46%, black);
  --red:     color-mix(in srgb, var(--accent) 52%, black);
  --amber:   color-mix(in srgb, var(--accent) 72%, white);
  --blue:    color-mix(in srgb, var(--accent) 52%, black);
  --purple:  color-mix(in srgb, var(--accent) 78%, white);
  --teal:    color-mix(in srgb, var(--accent) 58%, black);
}
body.vmode-duotone {
  --success: #3d5e50; --green: #3d5e50;
  --warn: #8a7a5a;    --amber: #8a7a5a;
  --error: #8a5a5a;   --red: #8a5a5a;
  --blue: #406070; --purple: #565070; --teal: #3d6060;
}
body.vmode-hcontrast { filter: grayscale(1) contrast(1.15); }

/* ── Light mode — backgrounds ──────────────────────────────────────────── */
body.light-mode { background: #f0f2f8; color: #111318; color-scheme: light; }
body.light-mode::before {
  background:
    radial-gradient(ellipse 80% 55% at 15% 0%, rgba(var(--accent-rgb),.05) 0%, transparent 60%),
    radial-gradient(ellipse 55% 45% at 85% 100%, rgba(var(--accent-rgb),.04) 0%, transparent 55%),
    linear-gradient(160deg, #eef0f5 0%, #f0f2f8 50%, #eceef4 100%) !important;
}
body.light-mode.bg-void::before        { background: #e8eaef !important; }
body.light-mode.bg-aurora::before      { background: radial-gradient(ellipse 80% 60% at 0% 0%, rgba(var(--accent-rgb),.10) 0%, transparent 60%), linear-gradient(160deg,#eef0f5,#f0f2f8) !important; }
body.light-mode.bg-blueprint::before   { background: linear-gradient(rgba(14,165,233,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(14,165,233,.08) 1px, transparent 1px), #eef2f8 !important; background-size: 32px 32px, 32px 32px, auto !important; }
body.light-mode.bg-carbon::before      { background: repeating-linear-gradient(45deg, rgba(0,0,0,.04) 0, rgba(0,0,0,.04) 1px, transparent 1px, transparent 6px), #ededf0 !important; }
body.light-mode.bg-dots::before        { background: radial-gradient(circle, rgba(0,0,0,.12) 1px, transparent 1px) 16px 16px / 16px 16px, #f0f2f8 !important; }
body.light-mode.bg-topographic::before { background: repeating-radial-gradient(ellipse 70% 50% at 50% 50%, transparent 0, transparent 8px, rgba(0,0,0,.05) 9px, transparent 10px), #f0f2f8 !important; }
body.light-mode.bg-space::before       { background: #f0f2f8 !important; }
body.light-mode.bg-upload::before      { background-image: linear-gradient(rgba(238,240,244,var(--bg-overlay-opacity,.85)), rgba(238,240,244,var(--bg-overlay-opacity,.85))), var(--upload-bg-url) !important; background-size: cover !important; background-position: center !important; }

/* ── Theme panel ───────────────────────────────────────────────────────── */
#theme-panel {
  position: fixed; top: 0; right: -290px; width: 270px; height: 100vh;
  background: rgba(10,10,14,.93);
  backdrop-filter: blur(32px) saturate(180%); -webkit-backdrop-filter: blur(32px) saturate(180%);
  border-left: 1px solid var(--glass-border); z-index: 900;
  transition: right .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; gap: .5rem;
  padding: 1.2rem 1rem 2rem; overflow-y: auto;
}
#theme-panel.open { right: 0; }
.tp-title { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--fg-dim); margin-top: .2rem; }
.tp-swatches { display: flex; flex-wrap: wrap; gap: .35rem; }
.tp-swatch {
  display: flex; align-items: center; gap: 5px; padding: .35rem .6rem;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px; cursor: pointer; font-size: .72rem; color: var(--fg-dim);
  transition: border-color .15s, color .15s, background .15s; white-space: nowrap;
}
.tp-swatch:hover  { border-color: rgba(var(--accent-rgb),.5); color: var(--fg); background: rgba(var(--accent-rgb),.08); }
.tp-swatch.active { border-color: var(--accent); color: var(--fg); background: rgba(var(--accent-rgb),.14); }
.tp-dot    { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.tp-divider { border: none; border-top: 1px solid rgba(255,255,255,.07); margin: .2rem 0; }
.tp-toggle { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .25rem 0; }
.tp-toggle-label { font-size: .75rem; color: var(--fg-dim); }
.tp-switch  { position: relative; display: inline-block; width: 34px; height: 18px; flex-shrink: 0; }
.tp-switch input { opacity: 0; width: 0; height: 0; }
.tp-slider  { position: absolute; inset: 0; background: rgba(255,255,255,.12); border-radius: 18px; cursor: pointer; transition: background .2s; }
.tp-slider::before { content: ''; position: absolute; width: 12px; height: 12px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.tp-switch input:checked + .tp-slider             { background: var(--accent); }
.tp-switch input:checked + .tp-slider::before     { transform: translateX(16px); }

/* ── Light mode — theme panel ──────────────────────────────────────────── */
body.light-mode #theme-panel     { background: rgba(250,251,253,.97); border-color: rgba(0,0,0,.1); }
body.light-mode .tp-title        { color: #888; }
body.light-mode .tp-swatch       { background: rgba(0,0,0,.04); border-color: rgba(0,0,0,.1); color: #555; }
body.light-mode .tp-swatch:hover { background: rgba(var(--accent-rgb),.07); color: #111; }
body.light-mode .tp-swatch.active{ background: rgba(var(--accent-rgb),.13); border-color: var(--accent); color: #111; }
body.light-mode .tp-divider      { border-color: rgba(0,0,0,.08); }
body.light-mode .tp-toggle-label { color: #555; }
body.light-mode .tp-slider       { background: rgba(0,0,0,.18); }
