/* ── THEMES ─────────────────────────────────────────────────── */

/* Tokyo Night (dark, default) */
:root,
[data-theme="tokyo-night"] {
  --bg: #1a1b26;
  --fg: #a9b1d6;
  --muted: #565f89;
  --accent: #7aa2f7;
  --border: #292e42;
  --shadow: rgba(0,0,0,0.55);
  --code-bg: #13141f;
  --code-fg: #a9b1d6;
  --code-kw: #bb9af7;
  --code-type: #2ac3de;
  --code-fn: #7aa2f7;
  --code-str: #9ece6a;
  --code-num: #ff9e64;
  --code-op: #89ddff;
  --code-cmt: #565f89;
  --code-err: #f7768e;
  --code-attr: #73daca;
}

/* Rosé Pine Dawn (light) */
[data-theme="rose-pine"] {
  --bg: #faf4ed;
  --fg: #575279;
  --muted: #9893a5;
  --accent: #b4637a;
  --border: #f2e9e1;
  --shadow: transparent;
  --code-bg: #fffcf8;
  --code-fg: #575279;
  --code-kw: #b4637a;
  --code-type: #286983;
  --code-fn: #56949f;
  --code-str: #907aa9;
  --code-num: #ea9d34;
  --code-op: #286983;
  --code-cmt: #9893a5;
  --code-err: #b4637a;
  --code-attr: #56949f;
}

/* Gruvbox Dark */
[data-theme="gruvbox"] {
  --bg: #282828;
  --fg: #ebdbb2;
  --muted: #928374;
  --accent: #d79921;
  --border: #3c3836;
  --shadow: rgba(0,0,0,0.55);
  --code-bg: #1d2021;
  --code-fg: #ebdbb2;
  --code-kw: #fb4934;
  --code-type: #8ec07c;
  --code-fn: #fabd2f;
  --code-str: #b8bb26;
  --code-num: #d3869b;
  --code-op: #83a598;
  --code-cmt: #928374;
  --code-err: #fb4934;
  --code-attr: #8ec07c;
}

/* Dracula (dark) */
[data-theme="dracula"] {
  --bg: #282a36;
  --fg: #f8f8f2;
  --muted: #6272a4;
  --accent: #bd93f9;
  --border: #44475a;
  --shadow: rgba(0,0,0,0.55);
  --code-bg: #21222c;
  --code-fg: #f8f8f2;
  --code-kw: #ff79c6;
  --code-type: #8be9fd;
  --code-fn: #50fa7b;
  --code-str: #f1fa8c;
  --code-num: #bd93f9;
  --code-op: #ff79c6;
  --code-cmt: #6272a4;
  --code-err: #ff5555;
  --code-attr: #8be9fd;
}

/* Github Light */
[data-theme="github-light"] {
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --border: #d1d9e0;
  --shadow: transparent;
  --code-bg: #f6f8fa;
  --code-fg: #1f2328;
  --code-kw: #cf222e;
  --code-type: #953800;
  --code-fn: #8250df;
  --code-str: #0a3069;
  --code-num: #0550ae;
  --code-op: #cf222e;
  --code-cmt: #656d76;
  --code-err: #cf222e;
  --code-attr: #0a3069;
}

/* Papercolor Light */
[data-theme="papercolor-light"] {
  --bg: #eeeeee;
  --fg: #444444;
  --muted: #878787;
  --accent: #005f87;
  --border: #d0d0d0;
  --shadow: transparent;
  --code-bg: #fafafa;
  --code-fg: #444444;
  --code-kw: #d70000;
  --code-type: #005f87;
  --code-fn: #0087af;
  --code-str: #5f8700;
  --code-num: #af005f;
  --code-op: #0087af;
  --code-cmt: #878787;
  --code-err: #d70000;
  --code-attr: #008700;
}

/* Hacker (secret, terminal-only) */
[data-theme="hacker"] {
  --bg: #0a0a0a;
  --fg: #00ff41;
  --muted: #00802080;
  --accent: #00ff41;
  --border: #003300;
  --shadow: rgba(0,255,65,0.1);
  --code-bg: #050505;
  --code-fg: #00ff41;
  --code-kw: #39ff14;
  --code-type: #00e5ff;
  --code-fn: #00ff41;
  --code-str: #7fff00;
  --code-num: #00ffcc;
  --code-op: #39ff14;
  --code-cmt: #003300;
  --code-err: #ff0040;
  --code-attr: #00e5ff;
}
[data-theme="hacker"] body {
  text-shadow: 0 0 8px rgba(0,255,65,0.3);
}
[data-theme="hacker"] ::selection {
  background: rgba(0,255,65,0.25);
}

::selection {
  background: rgba(122, 162, 247, 0.25);
}

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

/* ── Page transitions (cross-document View Transitions API) ── */
@view-transition { navigation: auto; }
::view-transition-old(root) {
  animation: vt-out 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}
::view-transition-new(root) {
  animation: vt-in 0.25s cubic-bezier(0, 0, 0.2, 1) forwards;
}
@keyframes vt-out {
  to { opacity: 0; transform: translateY(6px); }
}
@keyframes vt-in {
  from { opacity: 0; transform: translateY(-6px); }
}

html {
  font-size: 16px;
  background: var(--bg);
  scrollbar-width: none;       /* Firefox */
  -ms-overflow-style: none;    /* IE/Edge */
}
html::-webkit-scrollbar { display: none; } /* Chrome/Safari */

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 17px;
  line-height: 1.7;
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

body.page.writing  { max-width: 780px; }
body.page.projects { max-width: min(960px, 90vw); }

a { color: var(--accent); text-decoration: none; transition: color 0.2s ease; }
a:hover { text-decoration: underline; }

p { margin-bottom: 0.8em; }
ul { list-style: none; }
li { padding: 6px 0; }

/* restore list styling inside article content */
body.page ul { list-style: disc; padding-left: 1.4em; }
body.page ol { list-style: decimal; padding-left: 1.4em; }
body.page li { padding: 4px 0; }

/* ── CODE BLOCKS ─────────────────────────────────────────── */

/* Chroma wrapper (Hugo syntax highlighting) */
body.page .highlight {
  margin: 1.4em 0;
  border-radius: 4px;
  overflow: hidden;
  border-left: 3px solid var(--accent);
}
body.page .highlight pre {
  margin: 0;
  border: none;
  border-radius: 0;
  border-left: none;
}

/* pre/code shared base — adapts to active theme via --code-* vars */
body.page pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 1rem 1.2rem;
  border-radius: 4px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.65;
  margin: 1.2em 0;
  border-left: 3px solid var(--accent);
}
body.page code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}
body.page pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}
body.page :not(pre) > code {
  background: var(--border);
  color: var(--accent);
  padding: 0.15em 0.45em;
  border-radius: 3px;
  font-size: 0.85em;
}

/* Chroma token colors — adapts to active theme via CSS variables */
.chroma { background: var(--code-bg); color: var(--code-fg); }
.chroma .err { color: var(--code-err); }
.chroma .k,  .chroma .kc, .chroma .kd,
.chroma .kn, .chroma .kp, .chroma .kr { color: var(--code-kw); font-style: italic; } /* keyword */
.chroma .kt  { color: var(--code-type); }         /* keyword type */
.chroma .na  { color: var(--code-attr); }         /* attr name */
.chroma .nb  { color: var(--code-type); }         /* builtin */
.chroma .nc  { color: var(--code-type); }         /* class name */
.chroma .nf, .chroma .fm { color: var(--code-fn); } /* func name */
.chroma .nn  { color: var(--code-fg); }           /* namespace */
.chroma .s,  .chroma .sa, .chroma .sb,
.chroma .sc, .chroma .dl, .chroma .sd,
.chroma .s2, .chroma .se, .chroma .sh,
.chroma .si, .chroma .sx, .chroma .sr,
.chroma .s1, .chroma .ss { color: var(--code-str); } /* string */
.chroma .m,  .chroma .mb, .chroma .mf,
.chroma .mh, .chroma .mi, .chroma .il,
.chroma .mo  { color: var(--code-num); }          /* number */
.chroma .o,  .chroma .ow { color: var(--code-op); } /* operator */
.chroma .p   { color: var(--code-fg); }           /* punctuation */
.chroma .c,  .chroma .ch, .chroma .cm,
.chroma .c1, .chroma .cs, .chroma .cp,
.chroma .cpf { color: var(--code-cmt); font-style: italic; } /* comment */
.chroma .gi  { color: var(--code-str); }          /* diff added */
.chroma .gd  { color: var(--code-err); }          /* diff deleted */
.chroma .gu  { color: var(--code-fn); font-weight: bold; } /* diff heading */
.chroma .ln, .chroma .lnt { color: var(--code-cmt); padding-right: 1em; user-select: none; } /* line numbers */

/* ── READING PROGRESS COLUMN ──────────────────────────────── */
#read-progress {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0.7;
  pointer-events: none;
  z-index: 10;
}
#read-progress canvas { display: block; }
@media (max-width: 1000px) { #read-progress { display: none; } }

h1 { font-size: 1.6rem; font-weight: 700; }
h2 { color: var(--muted); margin: 32px 0 10px; font-size: 1.3rem; font-weight: 700; }

.now-link { color: var(--muted); }
.now-link:hover { color: var(--accent); text-decoration: none; }
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0 0; }
h3 { color: var(--muted); margin: 28px 0 6px; font-size: 1rem; }

header { margin-bottom: 48px; }
.header-top { display: flex; justify-content: space-between; align-items: center; }
.nav {
  display: flex; flex-wrap: wrap;
  gap: 6px 28px; margin-top: 16px;
}
.nav a {
  color: var(--accent);
  text-decoration: none;
  position: relative;
  padding: 2px 0;
  transition: color 0.2s ease;
}
.nav a::after {
  content: '';
  position: absolute;
  left: 0; bottom: 0;
  width: 0; height: 1px;
  background: var(--fg);
  transition: width 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.nav a:hover { color: var(--fg); }
.nav a:hover::after { width: 100%; }
.nav-primary { font-weight: 700; }
.nav a:not(.nav-primary) { opacity: 0.55; }
.nav a:not(.nav-primary):hover { opacity: 1; }
.nav-toggle { display: none; }
.m-nav-btn { display: none; }
.tagline, .yr, footer { color: var(--muted); }
.tagline { font-style: italic; }
.li-name, .project-title { font-weight: 700; font-size: 1.15rem; }
.li-name-plain { font-weight: 700; color: var(--fg); }
.li-meta { color: var(--muted); margin-top: 3px; }
body.projects li, body.home li { padding: 10px 0; }
.bio { margin-bottom: 12px; }
.toggle {
  background: none; border: none; padding: 2px 0; font: inherit; cursor: pointer;
  color: var(--muted);
  transition: color 0.2s ease, transform 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.toggle:hover { color: var(--accent); }
.toggle:active { transform: scale(0.92); }
.header-controls { display: flex; gap: 10px; align-items: center; }

.writing-li { display: flex; justify-content: space-between; gap: 8px; }
.writing-li a { color: var(--fg); }

.article-nav { display: flex; justify-content: space-between; margin-top: 40px; }
.article-nav-next { margin-left: auto; }

.album-cover { display: block; width: 280px; height: 280px; object-fit: cover; margin-bottom: 20px; }

.contact-blurb { color: var(--muted); margin-bottom: 10px; }
.contact-email {
  display: inline-block;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  user-select: none;
}
.contact-email:hover { text-decoration: underline; }
.contact-email .email-expand {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
}
.contact-email:hover .email-expand { text-decoration: none; }

.back { display: inline-block; color: var(--muted); margin-bottom: 28px; }
.back:hover { color: var(--accent); text-decoration: none; }

.project-title { font-size: 1.4rem; margin-bottom: 6px; }

/* ── ARTICLE PROSE ─────────────────────────────────────────── */
body.page p  { line-height: 1.85; margin-bottom: 1em; }
body.page h1 { font-size: 1.4rem; color: var(--fg); margin: 0 0 8px; }
body.page h2 { font-size: 1.15rem; color: var(--fg); font-weight: 700; margin: 36px 0 10px; }
body.page h3 { font-size: 1rem; color: var(--fg); font-weight: 700; margin: 28px 0 8px; }
.project-meta  { color: var(--muted); margin-bottom: 20px; }

.links { display: flex; gap: 16px; margin-top: 24px; flex-wrap: wrap; }
.links a { color: var(--accent); }

/* ── PICKS ─────────────────────────────────────────────────── */
.picks-intro { color: var(--muted); margin-bottom: 8px; }
.picks-intro p { margin: 0; }
.picks-list { display: flex; flex-direction: column; gap: 0; }
.pick-card {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.pick-card:first-child { border-top: 1px solid var(--border); }
.pick-head { display: flex; flex-direction: column; gap: 2px; }
.pick-title {
  font-weight: 700; font-size: 1rem; color: var(--fg);
  text-decoration: none; transition: color 0.15s;
}
a.pick-title:hover { color: var(--accent); }
.pick-arrow { font-size: 0.8em; opacity: 0.5; transition: opacity 0.15s; }
a.pick-title:hover .pick-arrow { opacity: 1; }
.pick-author { color: var(--muted); font-size: 0.82rem; }
.pick-body { color: var(--muted); font-size: 0.88rem; margin-top: 6px; line-height: 1.6; }
.pick-body p { margin: 0; }

#copy-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px) scale(0.95);
  background: var(--fg);
  color: var(--bg);
  font-size: 0.8rem;
  padding: 8px 18px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1);
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
#copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

/* ── SHARED FORM INPUTS (guestbook + arcade) ─────────────────── */
.gb-form { margin-bottom: 0; }
.gb-row { display: flex; gap: 12px; margin-bottom: 10px; align-items: stretch; }
.gb-row input { flex: 1; }
#gb-msg { width: 100%; resize: vertical; }
.gb-form input, .gb-form textarea {
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: inherit;
  padding: 8px 12px;
  outline: none;
  border-radius: 0;
  transition: border-color 0.15s;
}
.gb-form input:focus, .gb-form textarea:focus { border-color: var(--accent); }
#gb-submit {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: inherit;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
#gb-submit:hover { color: var(--accent); border-color: var(--accent); }
#gb-submit:disabled { opacity: 0.5; cursor: default; }
#gb-status { margin-top: 8px; font-size: 0.9rem; min-height: 1.2em; }
.gb-entry { padding: 16px 0; border-bottom: 1px solid var(--border); }
.gb-entry:first-child { border-top: none; }
.gb-entry-name { font-weight: 700; color: var(--accent); margin-right: 12px; }
.gb-entry-date { color: var(--muted); font-size: 0.88rem; }
.gb-entry-msg { margin-top: 6px; line-height: 1.6; }

/* ── ARCADE ──────────────────────────────────────────────────── */

@keyframes arc-fadein { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* background dot grid — scoped to arcade pages */
.arc-bg-dots {
  position: fixed; inset: 0;
  background-image: radial-gradient(var(--border) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none; z-index: -1; opacity: 0.55;
}

/* ── Hero ── */
.arc-hero {
  margin-bottom: 40px;
  padding: 48px 0 32px;
}
.arc-title-big {
  font-size: clamp(2.4rem, 7vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--fg);
  line-height: 1;
  margin: 0 0 14px;
}
.arc-title-big::before { content: '[ '; color: var(--muted); font-weight: 400; }
.arc-title-big::after  { content: ' ]'; color: var(--muted); font-weight: 400; }
.arc-banner-tagline {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 10px;
  letter-spacing: 0.03em;
}
.arc-stat-line {
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.6;
}
.arc-stat-val { color: var(--accent); font-weight: 700; }
/* ── Arcade intro ── */
.arc-intro {
  margin: 0 0 36px;
  border: 1px solid var(--border);
  background: var(--code-bg);
}
.arc-intro-row {
  display: flex; gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 0.83rem; line-height: 1.5;
  align-items: baseline;
}
.arc-intro-row:last-child { border-bottom: none; }
.arc-intro-key {
  color: var(--accent); font-weight: 600;
  min-width: 72px; flex-shrink: 0; letter-spacing: 0.02em;
}
.arc-intro-val { color: var(--muted); }
.arc-intro-val code, .arc-ic {
  color: var(--fg); background: var(--bg);
  padding: 0 4px; font-family: inherit; font-size: inherit;
  border: 1px solid var(--border);
}
.arc-kbd {
  color: var(--fg); background: var(--bg);
  padding: 0 4px; font-family: inherit; font-size: inherit;
  border: 1px solid var(--border); border-radius: 0;
}

/* ── Loading ── */
.arc-loading-state { color:var(--muted); padding:24px 0; }

/* ── Games section ── */
.arc-games-section { margin-bottom: 12px; }
.arc-games-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px;
}
.arc-games-label {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.2em;
  opacity: 0.6;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Cards ── */
#arc-games { display: flex; flex-direction: column; gap: 0; }
.arc-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px 14px 16px 14px;
  border: 1px solid var(--border);
  border-bottom: none;
  text-decoration: none !important;
  color: var(--fg);
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s;
  animation: arc-fadein 0.28s ease both;
  position: relative;
  overflow: hidden;
}
.arc-card:last-child { border-bottom: 1px solid var(--border); }
.arc-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.18s;
}
.arc-card::after { display: none; }
.arc-card:hover {
  background: color-mix(in srgb, var(--accent) 5%, var(--code-bg));
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 8%, transparent);
  text-decoration: none;
}
.arc-card:hover::before { opacity: 1; }
.arc-card:hover .arc-card-title { color: var(--accent); }
.arc-card:hover .arc-card-num { color: var(--accent); opacity: 0.5; }
.arc-card:hover .arc-card-play { opacity: 1; transform: translateX(0); }
.arc-card-num {
  font-size: 0.68rem;
  color: var(--muted);
  opacity: 0.35;
  min-width: 24px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.arc-card-body { flex: 1; min-width: 0; }
.arc-card-title { font-weight: 700; font-size: 1rem; display: block; margin-bottom: 3px; transition: color 0.15s; }
.arc-card-meta { color: var(--muted); font-size: 0.78rem; display: block; margin-bottom: 4px; }
.arc-card-desc { color: var(--muted); font-size: 0.82rem; opacity: 0.65; display: block; }
.arc-card-draft { opacity: 0.5; }
.arc-card-draft:hover { opacity: 0.75; }
.arc-draft-badge { font-size: 0.65rem; font-weight: 400; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 3px; margin-left: 6px; vertical-align: middle; letter-spacing: 0.04em; }
.arc-card-play {
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.18s, transform 0.18s;
  white-space: nowrap;
}

/* ── Write-a-game CTA section ── */
.arc-cta-section {
  border: 1px solid var(--border);
  margin: 48px 0 48px;
  padding: 28px 28px;
  background: var(--code-bg);
}
.arc-cta-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.arc-cta-desc {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.6;
}
.arc-cta-btn {
  background: none;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 8px 18px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.arc-cta-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

/* ── Edit link (game page) ── */
/* Manage section */
.ag-manage { margin-top: 28px; }
.ag-manage-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ag-manage-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  padding: 7px 16px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}
.ag-manage-btn:hover { color: var(--accent); border-color: var(--accent); }
.ag-manage-muted { opacity: 0.6; }
.ag-manage-muted:hover { opacity: 1; }
.ag-manage-danger:hover { color: #e06c75; border-color: #e06c75; }
.ag-manage-panel {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--code-bg);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ag-manage-inp {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.78rem;
  padding: 5px 10px;
  outline: none;
  width: 140px;
  transition: border-color 0.15s;
}
.ag-manage-inp:focus { border-color: var(--accent); }
.ag-manage-actions { display: flex; gap: 6px; }
.ag-manage-status { font-size: 0.75rem; color: var(--muted); }

/* ── Section headers ── */
.arc-section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--accent);
  margin: 48px 0 20px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}
.arc-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--accent), var(--border));
  opacity: 0.6;
}

/* ── Form ── */
.arc-form-box { padding: 0; }
.arc-form { margin-top: 0; }
.arc-row { display: flex; gap: 12px; margin-bottom: 10px; }
.arc-row input { flex: 1; min-width: 0; }
.arc-form input {
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: inherit;
  padding: 8px 12px;
  outline: none;
  border-radius: 0;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.arc-form input:focus { border-color: var(--accent); }

/* ── Editor with line numbers ── */
.arc-editor-wrapper { margin-bottom: 10px; }
.arc-editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-bottom: none;
}
.arc-editor-label { color: var(--accent); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; }
.arc-char-count { font-size: 0.75rem; color: var(--muted); transition: color 0.15s; }
.arc-char-warn  { color: #e0af68 !important; }
.arc-char-over  { color: #f7768e !important; }

.arc-editor {
  display: flex;
  align-items: flex-start;
  background: var(--code-bg);
  border: 1px solid var(--border);
  margin-bottom: 0;
  transition: border-color 0.15s;
  overflow-y: auto;
  min-height: 220px;
  max-height: 520px;
}
.arc-editor:focus-within { border-color: var(--accent); }
.arc-editor-nums {
  padding: 8px 8px 8px 6px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--muted);
  opacity: 0.35;
  text-align: right;
  user-select: none;
  white-space: pre;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 28px;
  position: sticky;
  top: 0;
}
.arc-editor-right {
  flex: 1;
  position: relative;
  min-width: 0;
}
.arc-editor-hl {
  position: absolute;
  top: 0; left: 0; right: 0;
  margin: 0;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.6;
  pointer-events: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: visible;
  border: none;
  box-sizing: border-box;
  color: var(--fg);
}
#arc-code {
  position: relative;
  display: block;
  width: 100%;
  box-sizing: border-box;
  background: transparent;
  color: transparent;
  caret-color: var(--fg);
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.6;
  padding: 8px 12px;
  resize: none;
  overflow: hidden;
  z-index: 1;
  scrollbar-width: none;
}
#arc-code::-webkit-scrollbar { display: none; }

/* ── Collapsible docs ── */
.arc-docs-details > summary { list-style: none; }
.arc-docs-details > summary::-webkit-details-marker { display: none; }
.arc-docs-details > summary::marker { display: none; }
.arc-docs-details > summary { margin-bottom: 0; }
.arc-docs-details[open] > summary { margin-bottom: 20px; }
.arc-docs-summary::before { content: '▶ '; font-size: 0.7rem; color: var(--accent); opacity: 0.6; vertical-align: middle; }
.arc-docs-details[open] .arc-docs-summary::before { content: '▼ '; }
.arc-submit-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
#arc-submit, #arc-test {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: inherit;
  padding: 8px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
#arc-test:hover  { color: var(--accent); border-color: var(--accent); }
#arc-submit { color: var(--fg); border-color: var(--fg); }
#arc-submit:hover { color: var(--accent); border-color: var(--accent); }
#arc-submit:disabled, #arc-test:disabled { opacity: 0.5; cursor: default; }
#arc-status { font-size: 0.85rem; }
.arc-hint { font-size: 0.75rem; color: var(--muted); opacity: 0.5; margin-left: auto; white-space: nowrap; }
.arc-slug-preview { font-size: 0.72rem; color: var(--accent); opacity: 0.7; letter-spacing: 0.04em; }

/* ── Snippets ── */
.arc-snippets { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.arc-snippet {
  border: 1px solid var(--border);
  transition: border-color 0.18s;
}
.arc-snippet:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.arc-snippet-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--code-bg);
}
.arc-snippet-title { font-size: 0.82rem; color: var(--fg); font-weight: 600; display: block; }
.arc-snippet-desc  { font-size: 0.74rem; color: var(--muted); display: block; margin-top: 2px; opacity: 0.75; }

/* ── Snippet runner ── */
.arc-snippet-runner {
  border: 1px solid var(--border);
  border-top: none;
  background: var(--code-bg, #1a1b26);
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.arc-runner-bar {
  padding: 4px 10px;
  font-size: 0.68rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--fg) 3%, transparent);
}
.arc-runner-out {
  padding: 8px 12px;
  font-size: 0.82rem;
  line-height: 1.7;
  min-height: 28px;
  max-height: 200px;
  overflow-y: auto;
}

/* ── Game card hover preview ── */
.arc-card-preview {
  position: absolute;
  left: 50%; top: 100%;
  transform: translateX(-50%);
  background: var(--code-bg, #1a1b26);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--muted);
  white-space: pre;
  max-width: 280px;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.arc-card:hover .arc-card-preview { opacity: 1; }

/* ── Misc ── */
.arc-source-block {
  margin: 0;
  padding: 12px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
}
.arc-code-inp {
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.88rem;
  padding: 4px 10px;
  outline: none;
  width: 160px;
  transition: border-color 0.15s;
}
.arc-code-inp:focus { border-color: var(--accent); }
.arc-del-confirm {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.arc-del-confirm:hover { color: #e06c75; border-color: #e06c75; }
.arc-del-status { font-size: 0.82rem; color: var(--muted); }

/* ── GAME PAGE ─────────────────────────────────────── */

@keyframes ag-appear { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

.ag-back { margin-bottom:32px; }
.ag-back a { color:var(--muted); font-size:0.85rem; text-decoration:none; transition:color 0.15s; letter-spacing:0.02em; }
.ag-back a:hover { color:var(--accent); }

.ag-loading-state { color:var(--muted); padding:32px 0; }

.ag-content { animation: ag-appear 0.3s ease both; }

/* Title */
.ag-title-area { margin-bottom:20px; }
.ag-title { font-size:1.9rem; margin-bottom:6px; line-height:1.2; }
.ag-title::before { content:'[ '; color:var(--muted); font-weight:400; }
.ag-title::after  { content:' ]'; color:var(--muted); font-weight:400; }
.ag-desc { color:var(--muted); margin:0; line-height:1.5; }

/* Meta panel */
.ag-meta-panel {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  margin: 24px 0 32px;
  font-size: 0.85rem;
}
.ag-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 20px;
  border-right: 1px solid var(--border);
  min-width: 0;
}
.ag-meta-item:last-child { border-right: none; }
.ag-meta-lbl { font-size: 0.68rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.ag-meta-val { color: var(--fg); }
.ag-meta-val-accent { color: var(--accent); font-weight: 700; }
.ag-meta-val-muted { color: var(--muted); font-size: 0.85rem; }

/* Actions */
.ag-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 40px; }

/* Play button — the star */
.ag-play-btn {
  position: relative;
  overflow: hidden;
  background: none;
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 13px 36px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}
.ag-play-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-101%);
  transition: transform 0.22s ease;
  z-index: 0;
}
.ag-play-btn:hover::before { transform: translateX(0); }
.ag-play-btn:hover { color: var(--bg); }
.ag-play-btn:active { opacity: 0.85; }
.ag-play-btn-inner { position: relative; z-index: 1; }

/* Secondary button */
.ag-action-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: inherit;
  padding: 13px 22px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ag-action-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Source section */
.ag-source-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.ag-source-title { font-size:0.78rem; font-weight:700; color:var(--muted); letter-spacing:0.1em; text-transform:uppercase; }
.ag-copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  padding: 3px 10px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.ag-copy-btn:hover, .ag-copy-btn.copied { color: var(--accent); border-color: var(--accent); }

/* Code window */
.ag-source-window { border: 1px solid var(--border); }
.ag-source-window-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  background: var(--code-bg);
  border-bottom: 1px solid var(--border);
}
.ag-window-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ag-dot-red    { background: #f7768e; }
.ag-dot-yellow { background: #e0af68; }
.ag-dot-green  { background: #9ece6a; }
.ag-window-filename { margin-left: 10px; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.04em; opacity: 0.7; }
.ag-source-body { display: flex; background: var(--code-bg); overflow: hidden; }
.ag-line-nums {
  padding: 12px 10px 12px 12px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
  opacity: 0.4;
  text-align: right;
  user-select: none;
  flex-shrink: 0;
  white-space: pre;
  border-right: 1px solid var(--border);
}
.ag-source-code {
  flex: 1;
  margin: 0;
  padding: 12px;
  border: none;
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre;
  background: transparent;
  min-width: 0;
}

.ag-del-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.ag-upd-textarea {
  width: 100%;
  min-height: 180px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 10px 12px;
  outline: none;
  resize: vertical;
  line-height: 1.6;
  box-sizing: border-box;
}
.ag-upd-textarea:focus { border-color: var(--accent); }

/* Error */
.ag-error { color: var(--muted); padding: 40px 0; }

@media (max-width: 540px) {
  .ag-meta-panel { flex-direction: column; }
  .ag-meta-item { border-right: none; border-bottom: 1px solid var(--border); }
  .ag-meta-item:last-child { border-bottom: none; }
  .ag-title { font-size: 1.4rem; }
  .arc-hint { display: none; }
}


/* lua syntax highlight */
/* lua syntax highlight — rich multi-class scheme */
.lh-kw      { color: var(--code-kw); }              /* if then else end while do for return break */
.lh-kw2     { color: var(--code-fn); }              /* local function */
.lh-val     { color: var(--code-num); }             /* true false nil */
.lh-op      { color: var(--code-op); }              /* and or not + - == .. etc */
.lh-builtin { color: var(--code-type); }            /* print tonumber type pairs … */
.lh-std     { color: var(--code-attr); }            /* math string table io */
.lh-arcade  { color: var(--accent); }               /* sleep clear colored color sound */
.lh-fn      { color: var(--code-fn); }              /* user function calls */
.lh-str     { color: var(--code-str); }
.lh-num     { color: var(--code-num); }
.lh-cmt     { color: var(--code-cmt); font-style: italic; }

/* terminal game header */
.term-game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  opacity: 0.8;
}
.term-game-header-id { color: var(--muted); }

footer { margin-top: 64px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 0.77rem; }
.footer-meta { color: var(--muted); }
.footer-links { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.footer-links a { color: var(--muted); transition: color 0.2s ease; }
.footer-links a:hover { color: var(--accent); text-decoration: none; }

.social { display: flex; gap: 26px; margin-top: 14px; }
.social a {
  color: var(--fg); font-weight: 700; text-decoration: none; display: inline-block;
  transition: color 0.2s ease, transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.social a:hover { color: var(--accent); transform: translate(2px, -2px); }
.social a:active { transform: scale(0.95); }
.copy-email {
  color: var(--fg);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  padding-right: 10px;
}
.copy-email:hover { color: var(--accent); text-decoration: underline; }
.copy-email:hover .email-expand { text-decoration: none; }
.email-expand {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  opacity: 0;
  color: var(--muted);
  font-weight: 400;
  user-select: text;
  cursor: text;
  padding-right: 6px;
  transition: max-width 0.25s ease, opacity 0.2s ease;
}
.copy-email:hover .email-expand {
  max-width: 240px;
  opacity: 1;
  transition: max-width 0.25s ease, opacity 0.2s ease;
}
.copy-email .email-expand {
  transition: max-width 0.25s ease, opacity 0.2s ease 0.1s;
}


/* ================================================================
   BG EFFECT — Boids flocking simulation (canvas)
   To remove: delete this block in style.css,
              delete the BG EFFECT section in script.js,
              remove <canvas id="bg-canvas"> from baseof.html
   ================================================================ */

body { background: transparent; text-shadow: 0 0 18px var(--shadow), 0 0 6px var(--shadow); }

#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: -1;
  transition: opacity 0.4s ease;
}

body.page #bg-canvas { opacity: 0.25; }


/* Touch-only devices (phones/tablets) */
@media (hover: none) and (pointer: coarse) {
  #term-btn { display: none; }
}

/* ── MOBILE NAV ──────────────────────────────────────────────── */
@media (max-width: 540px) {
  h1 { font-size: 1.35rem; }
  header { margin-bottom: 36px; }
  .nav {
    gap: 4px 18px;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .nav a {
    padding: 3px 0;
    font-size: 0.88rem;
  }
  .m-nav-btn { display: none; }
  .social { gap: 16px; margin-top: 12px; font-size: 0.9rem; }
}

/* ── MOBILE SETTINGS SHEET ───────────────────────────────────── */
#m-sheet {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  pointer-events: none;
  visibility: hidden;
  transition: background 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              backdrop-filter 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              -webkit-backdrop-filter 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 0s 0.35s;
}
#m-sheet.open {
  background: rgba(0,0,0,0.35);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  pointer-events: auto;
  visibility: visible;
  transition: background 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              backdrop-filter 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              -webkit-backdrop-filter 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 0s 0s;
}

#m-sheet-panel {
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  backdrop-filter: blur(40px) saturate(1.8);
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 16px 16px 0 0;
  padding: 0 0 max(20px, env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.05);
  scrollbar-width: none;
}
#m-sheet-panel::-webkit-scrollbar { display: none; }
#m-sheet.open #m-sheet-panel { transform: translateY(0); }

.ms-handle {
  width: 36px; height: 4px;
  background: var(--muted);
  opacity: 0.25;
  border-radius: 2px;
  margin: 10px auto 6px;
}

.ms-section { padding: 8px 0 4px; }
.ms-section + .ms-section { border-top: 1px solid var(--border); }

.ms-title {
  padding: 4px 20px 6px;
  font-size: 0.68rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* theme items */
.ms-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 20px;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, transform 0.12s;
}
.ms-item:active { background: var(--border); transform: scale(0.98); }
.ms-item.active { color: var(--fg); }

.ms-swatch {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid transparent;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.ms-item.active .ms-swatch {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent);
}

.ms-name { flex: 1; }

.ms-label {
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.45;
  transition: opacity 0.15s;
}
.ms-item.active .ms-label { opacity: 0.85; color: var(--accent); }

/* segmented mode picker */
.ms-seg {
  display: flex;
  margin: 4px 20px 8px;
  background: var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.ms-seg button {
  flex: 1;
  padding: 6px 0;
  background: none;
  border: none;
  font: inherit;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
.ms-seg button:active { transform: scale(0.96); }
.ms-seg button.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* preset chips */
.ms-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 20px 8px;
}
.ms-preset {
  padding: 5px 12px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.ms-preset:active { transform: scale(0.95); }
.ms-preset.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* ── SPAWN CLICK OVERLAY ─────────────────────────────────────── */
#spawn-overlay {
  position: fixed;
  inset: 0;
  z-index: 998;
  cursor: crosshair;
  background: rgba(0,0,0,0);
  pointer-events: none;
  visibility: hidden;
  transition: background 0.25s ease, visibility 0s 0.25s;
}
#spawn-overlay.active {
  background: rgba(0,0,0,0.12);
  pointer-events: auto;
  visibility: visible;
  transition: background 0.25s ease, visibility 0s 0s;
}

#spawn-hint {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  padding: 9px 22px;
  background: var(--bg);
  border: 1px solid var(--accent);
  border-top: none;
  color: var(--fg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 24px var(--shadow);
  animation: spawn-hint-pulse 1.6s ease-in-out infinite;
}
@keyframes spawn-hint-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}
#spawn-hint .sh-name  { color: var(--accent); font-weight: 700; }
#spawn-hint .sh-count { color: var(--accent); }
#spawn-hint .sh-esc   { color: var(--muted); }

/* ── HIDDEN TERMINAL ─────────────────────────────────────────── */
#term-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0);
  -webkit-backdrop-filter: blur(0px);
  backdrop-filter: blur(0px);
  pointer-events: none;
  visibility: hidden;
  transition: background 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              backdrop-filter 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              -webkit-backdrop-filter 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 0s 0.3s;
}
#term-overlay.open {
  background: rgba(0,0,0,0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  visibility: visible;
  transition: background 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              backdrop-filter 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              -webkit-backdrop-filter 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              visibility 0s 0s;
}

#term-box {
  position: relative;
  width: 660px;
  max-width: 95vw;
  min-width: 320px;
  height: 46vh;
  min-height: 180px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(40px) saturate(1.8);
  backdrop-filter: blur(40px) saturate(1.8);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-bottom: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.05);
}
#term-overlay.open #term-box { transform: translateY(0); }
#term-resize {
  height: 6px; cursor: ns-resize; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
#term-resize::after {
  content: ''; width: 36px; height: 3px; border-radius: 2px;
  background: var(--border); opacity: 0.5; transition: opacity 0.15s;
}
#term-resize:hover::after { opacity: 1; }
#term-resize-l, #term-resize-r {
  position: absolute; top: 0; bottom: 0; width: 5px; z-index: 1;
}
#term-resize-l { left: -3px; cursor: ew-resize; }
#term-resize-r { right: -3px; cursor: ew-resize; }
#term-resize-l::after, #term-resize-r::after {
  content: ''; position: absolute; top: 50%; transform: translateY(-50%);
  width: 3px; height: 28px; border-radius: 2px;
  background: var(--border); opacity: 0; transition: opacity 0.15s;
}
#term-resize-l::after { right: 0; }
#term-resize-r::after { left: 0; }
#term-resize-l:hover::after, #term-resize-r:hover::after { opacity: 0.7; }

#term-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  flex-shrink: 0;
}
#term-close {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; font-size: 0.72rem; padding: 0;
}
#term-close:hover { color: var(--fg); }

#term-output {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  color: var(--fg);
  line-height: 1.65;
}
#term-output::-webkit-scrollbar { width: 3px; }
#term-output::-webkit-scrollbar-thumb { background: var(--border); }

/* global styled scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

#term-input-row {
  display: flex;
  align-items: center;
  padding: 6px 14px 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.term-prompt { color: var(--accent); flex-shrink: 0; margin-right: 4px; }
#term-input-wrap {
  flex: 1; position: relative; overflow: hidden;
}
#term-input {
  width: 100%; background: none; border: none; outline: none;
  color: var(--fg); font: inherit; caret-color: var(--accent);
  position: relative; z-index: 1;
}
#term-ghost {
  position: absolute; top: 0; left: 0;
  pointer-events: none; white-space: pre;
  font: inherit; color: var(--muted); opacity: 0.5;
}
#term-ghost-hidden { visibility: hidden; }
#term-ghost-suffix { opacity: 1; }
.term-line-cmd  { color: var(--muted); }
.term-line-err  { color: #f7768e; }
.term-line-ok   { color: var(--accent); }
.term-line-pre  { white-space: pre-wrap; word-break: break-all; font-family: inherit; margin: 0; }
.term-io-inline {
  display: flex; align-items: center;
  font-family: inherit; font-size: inherit;
  color: var(--fg); line-height: 1.65;
  white-space: pre;
}
.term-io-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--fg); font: inherit; caret-color: var(--accent);
  padding: 0; margin: 0;
}


/* ── DESKTOP SETTINGS PANEL (slide-in from right) ───────────── */
#ds-overlay, #ds-panel { display: none; }
#d-settings-btn { display: none; }

@media (hover: hover) and (pointer: fine) {
  #t { display: none; }

  /* trigger button — inline in header-controls, styled like [:]  */
  #d-settings-btn { display: inline-block; }

  /* overlay backdrop */
  #ds-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 9990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }
  #ds-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  /* slide-in panel */
  #ds-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(380px, 90vw);
    background: var(--bg);
    border-left: 1px solid var(--border);
    z-index: 9991;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
    font-family: 'JetBrains Mono', monospace;
  }
  #ds-panel.open {
    transform: translateX(0);
  }

  /* header */
  .ds-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .ds-header-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--fg);
  }
  #ds-close {
    background: none; border: none;
    color: var(--muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.15s;
  }
  #ds-close:hover { color: var(--fg); }

  /* scrollable body */
  .ds-body {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    padding-bottom: 20px;
  }
  .ds-body::-webkit-scrollbar { display: none; }

  /* sections */
  .ds-section { padding: 16px 0 12px; }
  .ds-section + .ds-section { border-top: 1px solid var(--border); }

  .ds-title {
    padding: 0 20px 10px;
    font-size: 0.65rem;
    color: var(--accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    user-select: none;
  }

  /* ── theme dots ── */
  .ds-themes {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 4px 20px 4px;
  }
  .ds-theme-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                border-color 0.2s, box-shadow 0.2s;
    position: relative;
    background: none;
    padding: 0;
    outline: none;
  }
  .ds-theme-dot:hover { transform: scale(1.25); }
  .ds-theme-dot:active { transform: scale(0.9); }
  .ds-theme-dot.active {
    border-color: var(--fg);
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--fg);
  }
  .ds-theme-dot .ds-dot-inner {
    width: 100%; height: 100%;
    border-radius: 50%;
    display: block;
  }
  .ds-theme-dot .ds-dot-label {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: var(--fg);
    color: var(--bg);
    font-size: 0.6rem;
    padding: 3px 8px;
    border-radius: 5px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
  .ds-theme-dot:hover .ds-dot-label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  /* ── mode segmented control ── */
  .ds-seg {
    display: flex;
    margin: 0 20px 12px;
    background: var(--border);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
  }
  .ds-seg button {
    flex: 1;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.75rem;
    color: var(--muted);
    padding: 8px 0;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.25s, color 0.2s, box-shadow 0.25s;
  }
  .ds-seg button:hover { color: var(--fg); }
  .ds-seg button.active {
    background: var(--bg);
    color: var(--fg);
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
  }

  /* ── preset chips ── */
  .ds-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 20px 4px;
  }
  .ds-preset {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    font: inherit;
    font-size: 0.72rem;
    padding: 6px 14px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }
  .ds-preset:hover {
    color: var(--fg);
    border-color: var(--fg);
    transform: translateY(-1px);
  }
  .ds-preset:active { transform: scale(0.93) translateY(0); }
  .ds-preset.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
  }

  /* ── sliders & controls ── */
  .ds-sliders {
    padding: 0 20px 6px;
    transition: opacity 0.15s ease;
  }
  .ds-group-label {
    font-size: 0.62rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 14px 0 8px;
    opacity: 0.8;
  }
  .ds-group-label:first-child { margin-top: 0; }
  .ds-empty {
    font-size: 0.75rem;
    color: var(--muted);
    opacity: 0.5;
    padding: 16px 0;
    text-align: center;
  }
  .ds-slider-row, .ds-control-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    min-height: 28px;
  }
  .ds-slider-label {
    font-size: 0.68rem;
    color: var(--muted);
    width: 82px;
    flex-shrink: 0;
    text-align: left;
  }
  .ds-slider-val {
    font-size: 0.68rem;
    color: var(--accent);
    width: 34px;
    text-align: right;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    cursor: text;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background 0.15s;
  }
  .ds-slider-val:hover {
    background: color-mix(in srgb, var(--accent) 12%, transparent);
  }
  .ds-slider-val-input {
    font: inherit;
    font-size: 0.68rem;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    border: 1px solid var(--accent);
    border-radius: 4px;
    width: 34px;
    text-align: right;
    padding: 2px 4px;
    outline: none;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
  }
  .ds-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
  }
  .ds-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                box-shadow 0.2s;
    box-shadow: 0 0 0 3px var(--bg);
  }
  .ds-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 0 0 3px var(--bg), 0 0 12px var(--accent);
  }
  .ds-slider::-webkit-slider-thumb:active {
    transform: scale(1.05);
  }
  .ds-slider::-moz-range-thumb {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--bg);
    cursor: pointer;
  }

  /* ── rainbow segmented control ── */
  .ds-mini-seg {
    display: flex;
    flex: 1;
    background: var(--border);
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
  }
  .ds-mini-seg button {
    flex: 1;
    background: none;
    border: none;
    font: inherit;
    font-size: 0.65rem;
    color: var(--muted);
    padding: 6px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.25s, color 0.2s, box-shadow 0.25s;
    white-space: nowrap;
  }
  .ds-mini-seg button:hover { color: var(--fg); }
  .ds-mini-seg button:active { transform: scale(0.94); }
  .ds-mini-seg button.active {
    background: var(--bg);
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  }

  /* ── toggle switch ── */
  .ds-toggle {
    width: 38px; height: 20px;
    border-radius: 10px;
    border: none;
    background: var(--border);
    cursor: pointer;
    position: relative;
    padding: 0;
    transition: background 0.3s;
    outline: none;
    flex-shrink: 0;
  }
  .ds-toggle:active { transform: scale(0.92); }
  .ds-toggle.active { background: var(--accent); }
  .ds-toggle-knob {
    display: block;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--fg);
    position: absolute;
    top: 2px; left: 2px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                background 0.2s;
  }
  .ds-toggle.active .ds-toggle-knob {
    transform: translateX(18px);
    background: var(--bg);
  }

  /* trail sub-sliders (indented under toggle) */
  .ds-trail-sub {
    padding-left: 12px;
    margin-top: 4px;
  }
}


