:root{
  --bg:#171310;
  --bg-soft:#241d15;
  --bg-softer:#2d2419;
  --text:#ede0c4;
  --text-dim:#d9c9a3;
  --accent:#e8a33d;
  --accent-dim:#a97426;
  --danger:#b33f2e;
  --success:#6e8b5d;
  --muted:#a78c62;
  --muted-dark:#8a7050;
  --line: rgba(167,140,98,0.35);

  --font-display:'Cinzel', serif;
  --font-display-deco:'Cinzel Decorative', serif;
  --font-body:'Spectral', serif;
  --font-mono:'JetBrains Mono', monospace;
}

/* ============================================================
   THEME: Nova Blue — indigo + electric blue
   ============================================================ */
body.theme-blue{
  --bg:#0a0d1f;
  --bg-soft:#131a3a;
  --bg-softer:#1a2352;
  --text:#e8edff;
  --text-dim:#aab4e8;
  --accent:#3ba7ff;
  --accent-dim:#1f6fc4;
  --danger:#ff5c5c;
  --success:#5ee6d0;
  --muted:#7c8ad4;
  --muted-dark:#525fa0;
  --line: rgba(124,138,212,0.35);

  --font-display:'Orbitron', sans-serif;
  --font-display-deco:'Orbitron', sans-serif;
  --font-body:'Rajdhani', sans-serif;
}

/* ============================================================
   THEME: Terminal Green — near-black, acid-green, ambient rain
   ============================================================ */
body.theme-green{
  --bg:#070907;
  --bg-soft:#0e1310;
  --bg-softer:#141b17;
  --text:#c9f7d1;
  --text-dim:#84b28e;
  --accent:#39e673;
  --accent-dim:#23a355;
  --danger:#ff4d4d;
  --success:#39e673;
  --muted:#5a7a63;
  --muted-dark:#3f5947;
  --line: rgba(90,122,99,0.35);

  --font-display:'Space Mono', monospace;
  --font-display-deco:'Space Mono', monospace;
  --font-body:'IBM Plex Mono', monospace;
}
body.theme-green{ background-image:
    radial-gradient(ellipse at 20% -10%, rgba(57,230,115,0.06), transparent 55%),
    radial-gradient(ellipse at 90% 10%, rgba(57,230,115,0.04), transparent 45%);
}

/* ============================================================
   THEME: Paper — light mode
   ============================================================ */
body.theme-light{
  --bg:#f5f0e6;
  --bg-soft:#ffffff;
  --bg-softer:#ece4d3;
  --text:#2b2318;
  --text-dim:#55492f;
  --accent:#b3651f;
  --accent-dim:#8a4d16;
  --danger:#a83232;
  --success:#3f7d4f;
  --muted:#8a7b5c;
  --muted-dark:#6b5d42;
  --line: rgba(90,70,40,0.25);
}
body.theme-light .toast{ box-shadow:0 8px 24px rgba(0,0,0,0.15); }
body.theme-light .playground{ box-shadow:0 4px 16px rgba(0,0,0,0.08); }

/* ============================================================
   THEME: Violet Dusk — deep purple + magenta
   ============================================================ */
body.theme-violet{
  --bg:#140a1f;
  --bg-soft:#1f1230;
  --bg-softer:#2a1a40;
  --text:#f0e6ff;
  --text-dim:#c9b3e8;
  --accent:#b673ff;
  --accent-dim:#8a4fd1;
  --danger:#ff5c7a;
  --success:#7de8c9;
  --muted:#8a70b0;
  --muted-dark:#5f4d80;
  --line: rgba(138,112,176,0.35);
}

/* ============================================================
   THEME: Solar Dark — Solarized-inspired teal/cyan
   ============================================================ */
body.theme-solar{
  --bg:#00252f;
  --bg-soft:#073642;
  --bg-softer:#0e4552;
  --text:#eee8d5;
  --text-dim:#93a1a1;
  --accent:#2aa198;
  --accent-dim:#1f7a73;
  --danger:#dc322f;
  --success:#859900;
  --muted:#657b83;
  --muted-dark:#4a5c61;
  --line: rgba(101,123,131,0.35);

  --font-display:'Space Mono', monospace;
  --font-display-deco:'Space Mono', monospace;
  --font-body:'IBM Plex Mono', monospace;
}

/* ============================================================
   THEME: Rose — warm pink/coral
   ============================================================ */
body.theme-rose{
  --bg:#1f0f14;
  --bg-soft:#2e161e;
  --bg-softer:#3d1f29;
  --text:#ffe4ea;
  --text-dim:#e0b3c0;
  --accent:#ff6b8b;
  --accent-dim:#d1486a;
  --danger:#ff4d4d;
  --success:#6ee7b7;
  --muted:#b8899a;
  --muted-dark:#8a5f6d;
  --line: rgba(184,137,154,0.35);
}

/* ============================================================
   THEME: Slate — neutral gray, minimal/low-distraction
   ============================================================ */
body.theme-slate{
  --bg:#16181b;
  --bg-soft:#1e2124;
  --bg-softer:#26292d;
  --text:#e4e6eb;
  --text-dim:#a8adb5;
  --accent:#8fa3b3;
  --accent-dim:#6a7f8f;
  --danger:#e0645a;
  --success:#7fb88a;
  --muted:#767c85;
  --muted-dark:#565c64;
  --line: rgba(118,124,133,0.3);

  --font-display:'Rajdhani', sans-serif;
  --font-display-deco:'Rajdhani', sans-serif;
  --font-body:'Rajdhani', sans-serif;
}

/* ============================================================
   AMBIENT BACKGROUND ANIMATIONS (one per theme — see index.html)
   ============================================================ */
#bgAnimCanvas{ position:fixed; inset:0; z-index:0; pointer-events:none; opacity:.55; }
body.theme-green #bgAnimCanvas{ opacity:.16; } /* the original rain effect is much denser/brighter internally */
.sb-shell{ position:relative; z-index:1; }

/* ============================================================
   THEME PICKER
   ============================================================ */
.theme-picker{ position:relative; }
.theme-picker-panel{
  display:none; position:absolute; top:calc(100% + 8px); right:0; background:var(--bg-soft); border:1px solid var(--line);
  border-radius:10px; padding:8px; flex-direction:column; gap:4px; z-index:50; min-width:220px;
  box-shadow:0 16px 40px rgba(0,0,0,0.45); max-height:70vh; overflow-y:auto;
}
.theme-picker-panel.show{ display:flex; }
body.theme-light .theme-picker-panel{ box-shadow:0 16px 40px rgba(0,0,0,0.18); }
.theme-swatch{
  display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; cursor:pointer; border:1px solid transparent;
  background:none; width:100%; text-align:left; font-family:var(--font-mono); color:var(--text-dim); transition:background .15s;
}
.theme-swatch:hover{ background:var(--bg-softer); }
.theme-swatch.active{ border-color:var(--accent); color:var(--text); background:var(--bg-softer); }
.theme-swatch .dot{ width:18px;height:18px;border-radius:50%; flex:0 0 auto; border:2px solid rgba(255,255,255,0.2); }
.theme-swatch .tx{ display:flex; flex-direction:column; gap:1px; }
.theme-swatch .tx b{ font-size:12.5px; font-weight:600; }
.theme-swatch .tx span{ font-size:10.5px; opacity:.65; }

*{ box-sizing:border-box; }
html{ scroll-behavior:smooth; }
body{
  margin:0; min-height:100vh; background:var(--bg); color:var(--text);
  font-family:var(--font-body);
  background-image:
    radial-gradient(ellipse at 20% -10%, rgba(232,163,61,0.08), transparent 55%),
    radial-gradient(ellipse at 90% 10%, rgba(110,139,93,0.06), transparent 45%);
}
::selection{ background:var(--accent); color:var(--bg); }
a{ color:var(--accent); }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-stack{ position:fixed; bottom:20px; right:20px; z-index:9999; display:flex; flex-direction:column; gap:10px; align-items:flex-end; }
.toast{
  background:var(--bg-soft); border:1px solid var(--line); border-left:3px solid var(--accent);
  color:var(--text); font-family:var(--font-mono); font-size:12.5px; padding:11px 16px; border-radius:8px;
  box-shadow:0 8px 24px rgba(0,0,0,0.4); max-width:320px; opacity:0; transform:translateY(8px);
  transition:opacity .25s, transform .25s;
}
.toast.show{ opacity:1; transform:translateY(0); }
.toast.error{ border-left-color:var(--danger); }

/* ============================================================
   PLAYGROUND (editor + console)
   ============================================================ */
.playground{ margin:18px 0 24px; border-radius:10px; overflow:hidden; border:1px solid var(--line); background:var(--bg); }
.pg-head{
  background:var(--bg-softer); padding:9px 16px; display:flex; align-items:center; justify-content:space-between;
  font-family:var(--font-mono); font-size:11.5px; color:var(--muted); letter-spacing:.05em; text-transform:uppercase;
}
.pg-head .pg-btns{ display:flex; gap:8px; text-transform:none; letter-spacing:0; }
.pg-head button{
  font-family:var(--font-mono); font-size:11.5px; text-transform:uppercase; letter-spacing:.04em;
  background:var(--accent); color:var(--bg); border:none; border-radius:5px; padding:6px 14px; cursor:pointer;
  transition:opacity .15s;
}
.pg-head button:disabled{ opacity:.5; cursor:default; }
/* standalone (not scoped to .pg-head) so it also works in the Notes panel and
   the top bar — a class-only rule at equal specificity to ".pg-head button"
   still needs to win by source order, hence "button.pg-reset" here, after it */
button.pg-reset{
  font-family:var(--font-mono); font-size:11.5px; text-transform:uppercase; letter-spacing:.04em;
  background:none; border:1px solid var(--muted-dark); color:var(--muted);
  border-radius:5px; padding:6px 14px; cursor:pointer; transition:all .15s; white-space:nowrap;
}
button.pg-reset:hover{ border-color:var(--accent); color:var(--accent); }
button.pg-reset:disabled{ opacity:.5; cursor:default; }

.pg-editor-row{ display:flex; align-items:stretch; }
.pg-linenum{
  flex:0 0 auto; min-width:2.6em; padding:16px 10px 16px 16px; text-align:right; user-select:none;
  font-family:var(--font-mono); font-size:13px; line-height:1.6; color:var(--muted-dark);
  background:#0d0a07; border-right:1px solid var(--line); white-space:pre; overflow:hidden; box-sizing:border-box;
}
.pg-editor-wrap{ position:relative; flex:1; min-width:0; }
.pg-highlight{
  position:absolute; inset:0; margin:0; overflow:hidden; pointer-events:none;
  background:#120e0a; color:#e8ddc4; font-family:var(--font-mono); font-size:13px; line-height:1.6;
  padding:16px 18px; white-space:pre-wrap; word-break:break-word; tab-size:4; box-sizing:border-box;
}
.pg-editor{
  position:relative; display:block; width:100%; box-sizing:border-box; border:none; resize:none; overflow:hidden;
  min-height:220px; background:transparent; color:transparent; caret-color:#e8ddc4;
  font-family:var(--font-mono); font-size:13px; line-height:1.6;
  padding:16px 18px; outline:none; tab-size:4; z-index:1;
}

/* syntax token colors */
.tok-cm{ color:#7a9b6f; }
.tok-str{ color:#c9b98a; }
.tok-dir{ color:#8fb3d9; }
.tok-kw{ color:#e8a33d; }
.tok-reg{ color:#e07a5f; }
.tok-num{ color:#b98ee0; }
.tok-lbl{ color:#6fd3c7; font-weight:600; }
.tok-todo{ color:#ff9f6b; font-weight:700; }

.pg-savehint{
  font-family:var(--font-mono); font-size:10.5px; color:var(--muted-dark); padding:6px 16px 0;
  opacity:0; transition:opacity .3s;
}
.pg-savehint.show{ opacity:1; }
.pg-console-wrap{ border-top:1px solid var(--line); }
.pg-console-label{
  padding:7px 16px; font-family:var(--font-mono); font-size:10.5px; text-transform:uppercase; letter-spacing:.08em;
  color:var(--muted-dark); background:rgba(255,255,255,0.02);
}
.pg-console{
  background:#0a0a08; color:#a8f0a8; font-family:var(--font-mono); font-size:13px; line-height:1.55;
  padding:14px 18px; min-height:70px; max-height:320px; overflow-y:auto; white-space:pre-wrap; word-break:break-word;
}
.pg-console .pg-err{ color:#ff8a7a; }
.pg-console .pg-sys{ color:var(--muted); font-style:italic; }
.pg-input-row{ display:none; align-items:center; gap:8px; padding:9px 16px; border-top:1px solid var(--line); background:rgba(255,255,255,0.02); }
.pg-input-row.show{ display:flex; }
.pg-input-row .pg-prompt{ font-family:var(--font-mono); font-size:12px; color:var(--accent); }
.pg-input-row input{
  flex:1; background:#0a0a08; border:1px solid var(--muted-dark); border-radius:5px; padding:7px 10px;
  color:#a8f0a8; font-family:var(--font-mono); font-size:13px; outline:none;
}
.pg-input-row input:focus{ border-color:var(--accent); }
.pg-input-row button{
  font-family:var(--font-mono); font-size:11.5px; text-transform:uppercase; background:var(--accent); color:var(--bg);
  border:none; border-radius:5px; padding:7px 14px; cursor:pointer;
}

/* ============================================================
   FULLSCREEN MODE
   ============================================================ */
.pg-fullscreen-backdrop{
  position:fixed; top:0; left:0; right:0; bottom:0;
  height:100vh; height:100dvh;
  background:rgba(0,0,0,0.72); z-index:99998;
}
.playground.pg-fullscreen{
  position:fixed; top:16px; left:16px; right:16px; bottom:16px;
  height:auto; max-height:none;
  z-index:99999; display:flex; flex-direction:column;
  box-shadow:0 24px 70px rgba(0,0,0,0.65); max-width:none; margin:0; border-radius:12px;
}
@media (max-width:700px){
  .playground.pg-fullscreen{ top:0; left:0; right:0; bottom:0; border-radius:0; }
  .pg-fullscreen-backdrop{ background:rgba(0,0,0,0.9); }
}
.playground.pg-fullscreen .pg-editor-row{ flex:1 1 auto; min-height:0; display:flex; }
.playground.pg-fullscreen .pg-editor-wrap{ flex:1 1 auto; min-height:0; }
.playground.pg-fullscreen .pg-linenum{ height:100%; }
.playground.pg-fullscreen .pg-editor,
.playground.pg-fullscreen .pg-highlight{ height:100% !important; min-height:0; }
.playground.pg-fullscreen .pg-console-wrap{ flex:0 0 auto; max-height:34vh; overflow-y:auto; -webkit-overflow-scrolling:touch; }
.pg-fullscreen-btn{ font-size:14px !important; line-height:1; padding:6px 10px !important; min-width:36px; min-height:32px; }
.pg-copy-btn.copied{ background:var(--success) !important; color:var(--bg) !important; border-color:var(--success) !important; }

/* ============================================================
   PAGE LAYOUT
   ============================================================ */
.sb-shell{ max-width:920px; margin:0 auto; padding:28px 20px 90px; }
.sb-top{ display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:22px; flex-wrap:wrap; }
.sb-brand{ display:flex; align-items:center; gap:12px; }
.sb-seal{
  width:38px;height:38px;border-radius:10px; border:2px solid var(--accent); display:flex;align-items:center;justify-content:center;
  font-family:var(--font-mono); font-weight:700; color:var(--accent); font-size:16px; flex:0 0 auto;
}
.sb-brand h1{ font-family:var(--font-display); font-size:19px; margin:0; color:var(--text); letter-spacing:.01em; }
.sb-brand p{ margin:2px 0 0; font-size:12px; color:var(--muted); font-family:var(--font-mono); }
.sb-links{ display:flex; gap:8px; align-items:flex-start; flex-wrap:wrap; }
.sb-intro{ font-family:var(--font-body); font-size:15.5px; color:var(--text-dim); line-height:1.7; max-width:70ch; margin:0 0 22px; }
.sb-intro code{ font-family:var(--font-mono); background:var(--bg-softer); color:var(--accent); padding:1px 6px; border-radius:4px; font-size:0.86em; border:1px solid var(--line); }
.sb-examples{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:20px; }
.sb-examples button{
  font-family:var(--font-mono); font-size:11.5px; background:var(--bg-soft); border:1px solid var(--line); color:var(--text-dim);
  padding:7px 13px; border-radius:20px; cursor:pointer; transition:all .15s;
}
.sb-examples button:hover{ border-color:var(--accent); color:var(--accent); }
.sb-foot{ margin-top:30px; font-family:var(--font-mono); font-size:11.5px; color:var(--muted-dark); line-height:1.7; border-top:1px solid var(--line); padding-top:18px; }
.sb-foot a{ color:var(--accent); }

/* ============================================================
   WORKSPACE (notes panel + playground, side by side on wide screens)
   ============================================================ */
.sb-shell{ transition:max-width .2s; }
.sb-shell.wide{ max-width:1360px; }
.workspace{ display:block; }
.workspace.with-notes{ display:grid; grid-template-columns:1fr; gap:18px; align-items:start; }
@media (min-width:900px){
  .workspace.with-notes{ grid-template-columns:minmax(260px,1fr) minmax(340px,1.6fr); }
}
.notes-panel{
  display:none; flex-direction:column; border:1px solid var(--line); border-radius:10px; overflow:hidden;
  background:var(--bg-soft);
}
.notes-panel.show{ display:flex; }
.notes-head{
  background:var(--bg-softer); padding:9px 16px; display:flex; align-items:center; justify-content:space-between;
  font-family:var(--font-mono); font-size:11.5px; color:var(--muted); letter-spacing:.05em; text-transform:uppercase;
}
.notes-btns{ display:flex; gap:8px; text-transform:none; letter-spacing:0; }
#notesText{
  flex:1; min-height:260px; background:transparent; color:var(--text); border:none; padding:16px 18px;
  font-family:var(--font-body); font-size:14.5px; line-height:1.65; resize:vertical; outline:none;
}
@media (min-width:900px){
  .workspace.with-notes #notesText{ min-height:100%; }
}
