/* the gublan playground. colours follow gublan studio's "moss" theme, and its "paper" theme in light mode.
   settings > look can switch to any of the studio's themes; playground.js then sets these variables itself. */
:root {
  --bg: #141414;
  --panel: #1c1c1c;
  --panel-alt: #262626;
  --editor-bg: #171717;
  --text: #e5e5e5;
  --muted: #aaaaaa;
  --dim: #6f6f6f;
  --accent: #647f4a;
  --accent-light: #94b66c;
  --accent-text: #10140c;
  --border: #2c2c2c;
  --hover: #232323;
  --select: #2f3d27;
  --match: #34422a;
  --active-line: #1b1f18;
  --error: #e16b6b;
  --warning: #d7bd75;
  --error-line: #332222;
  --stage-bg: #101010;
  --syn-command: #94b66c;
  --syn-flow: #b9cf8f;
  --syn-string: #a8c49a;
  --syn-number: #d7bd75;
  --syn-comment: #6b7266;
  --syn-brace: #8fb3a0;
  --syn-function: #cfe0b0;
  --syn-keyword: #c2c79a;
  --syn-color: #b0c48a;
  --syn-operator: #9aa596;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --code-size: 14px;
  --code-line: 21px;
  --speed: 1;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.2, .9, .3, 1.25);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f1ec;
    --panel: #e9e6df;
    --panel-alt: #dedad1;
    --editor-bg: #fbfaf7;
    --text: #1f2119;
    --muted: #5d5f55;
    --dim: #8c8a82;
    --accent: #3f6a1f;
    --accent-light: #3f6a1f;
    --accent-text: #ffffff;
    --border: #d3cfc6;
    --hover: #e0ddd5;
    --select: #cddcb8;
    --match: #d8e6c0;
    --active-line: #eef2e6;
    --error: #b23b3b;
    --warning: #8a6400;
    --error-line: #f3dcdc;
    --stage-bg: #e4e1da;
    --syn-command: #3f6a1f;
    --syn-flow: #5a7a1a;
    --syn-string: #2f7a4a;
    --syn-number: #9a6a00;
    --syn-comment: #8a8f84;
    --syn-brace: #2f6a6a;
    --syn-function: #2f5a20;
    --syn-keyword: #6a6a1a;
    --syn-color: #5a7a2a;
    --syn-operator: #5a6257;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  transition: background-color calc(.3s * var(--speed)), color calc(.3s * var(--speed));
}
a { color: var(--accent-light); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
kbd { font: 12px var(--mono); padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--panel-alt); }

/* the "animations" setting off (or the system asking for less motion) */
.no-motion *, .no-motion *::before, .no-motion *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
}

/* ----- loading progress along the very top ----- */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 50; pointer-events: none; }
.progress span {
  display: block; height: 100%; width: 0; background: var(--accent-light);
  box-shadow: 0 0 8px var(--accent-light);
  transition: width calc(.5s * var(--speed)) var(--ease), opacity .4s;
}
.progress.done span { opacity: 0; }

/* ----- top bar ----- */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  animation: drop-in calc(.35s * var(--speed)) var(--ease) both;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; }
.brand img { transition: transform calc(.4s * var(--speed)) var(--spring); }
.brand:hover img { transform: rotate(-8deg) scale(1.08); }
.brand em { font-style: normal; font-weight: 400; color: var(--muted); }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

button, select, .download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-alt);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background-color calc(.15s * var(--speed)), border-color calc(.15s * var(--speed)),
              transform calc(.12s * var(--speed)) var(--ease), box-shadow calc(.2s * var(--speed));
}
button:hover:not(:disabled), select:hover, .download:hover { background: var(--hover); }
button:active:not(:disabled), .download:active { transform: scale(.96); }
button:focus-visible, select:focus-visible, .download:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 1px; }
button:disabled { opacity: 0.45; cursor: default; }
button svg, .download svg { width: 14px; height: 14px; fill: currentColor; flex: none; }
button.icon { width: 32px; padding: 0; justify-content: center; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.primary:hover:not(:disabled) { background: var(--accent-light); border-color: var(--accent-light); }
.running button.primary#run { animation: breathe calc(1.6s * var(--speed)) ease-in-out infinite; }
select { padding-right: 8px; max-width: 220px; }
@keyframes breathe { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent-light) 30%, transparent); } }

/* ----- the panes ----- */
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 5px minmax(0, 1fr);
  background: var(--border);
}
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); position: relative; }
.editor-pane { animation: rise calc(.45s * var(--speed)) var(--ease) .05s both; }
.run-pane { animation: rise calc(.45s * var(--speed)) var(--ease) .12s both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes drop-in { from { opacity: 0; transform: translateY(-8px); } }

.splitter { background: var(--border); cursor: col-resize; position: relative; z-index: 3; transition: background-color .15s; }
.splitter:hover, .splitter.dragging, .splitter:focus-visible { background: var(--accent); outline: none; }
.splitter.horizontal { cursor: row-resize; height: 5px; flex: none; }
body.resizing, body.resizing * { cursor: inherit; user-select: none; }
body.resizing iframe { pointer-events: none; }

/* ----- file tabs ----- */
.file-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 36px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.file-list { display: flex; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.file-list::-webkit-scrollbar { display: none; }
.file-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 14px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  height: 36px;
  background: none;
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
  animation: tab-in calc(.25s * var(--speed)) var(--ease) both;
}
.file-tab:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.file-tab[aria-selected="true"] { background: var(--editor-bg); color: var(--text); }
.file-tab::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent-light);
  transform: scaleX(0); transition: transform calc(.22s * var(--speed)) var(--ease);
}
.file-tab[aria-selected="true"]::after { transform: scaleX(1); }
.file-tab .close {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; font-size: 14px;
  color: var(--dim); opacity: 0; transition: opacity .15s, background-color .15s;
}
.file-tab:hover .close, .file-tab[aria-selected="true"] .close { opacity: 1; }
.file-tab .close:hover { background: var(--panel-alt); color: var(--text); }
.file-tab.leaving { animation: tab-out calc(.18s * var(--speed)) ease-in both; }
@keyframes tab-in { from { opacity: 0; transform: translateY(-6px); } }
@keyframes tab-out { to { opacity: 0; transform: translateY(-6px); max-width: 0; padding: 0; } }
.add-file { height: 36px; width: 36px; justify-content: center; padding: 0; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 18px; }
.file-tabs .status { margin-left: auto; padding: 0 14px; align-self: center; font-size: 13px; color: var(--muted); }

.status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.busy::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--warning); animation: pulse 1s ease-in-out infinite alternate; }
.status.good { color: var(--accent-light); }
.status.bad { color: var(--error); }
.status.changed { animation: status-in calc(.3s * var(--speed)) var(--ease); }
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }
@keyframes status-in { from { opacity: 0; transform: translateY(4px); } }

/* ----- find and replace ----- */
.findbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 10px;
  background: var(--panel-alt); border-bottom: 1px solid var(--border);
  animation: slide-down calc(.2s * var(--speed)) var(--ease);
}
.findbar input { flex: 1 1 130px; min-width: 0; height: 28px; padding: 0 8px; border: 1px solid var(--border); border-radius: 5px; background: var(--editor-bg); color: var(--text); font: 13px var(--mono); }
.findbar button { height: 28px; padding: 0 8px; font-size: 12px; }
.find-count { font-size: 12px; color: var(--muted); min-width: 56px; text-align: center; }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } }

/* ----- editor: a textarea over a highlighted copy of the same text ----- */
.editor {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: auto;
  background: var(--editor-bg);
  font: var(--code-size)/var(--code-line) var(--mono);
  tab-size: 4;
}
.gutter {
  flex: none;
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 44px;
  height: max-content;
  min-height: 100%;
  padding: 12px 10px 40vh 8px;
  text-align: right;
  color: var(--dim);
  background: var(--editor-bg);
  border-right: 1px solid var(--border);
  user-select: none;
}
.gutter div { cursor: pointer; transition: color .15s; }
.gutter div:hover { color: var(--text); }
.gutter .current { color: var(--text); }
.gutter .error { color: var(--error); font-weight: 700; }
.gutter .warning { color: var(--warning); }
.code { position: relative; flex: 1; min-width: max-content; height: max-content; min-height: 100%; }
.highlight, #source {
  margin: 0;
  padding: 12px 16px 40vh 14px;
  font: inherit;
  white-space: pre;
  tab-size: inherit;
  border: 0;
}
.highlight { position: relative; z-index: 1; pointer-events: none; color: var(--text); }
#source {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  outline: none;
}
.smooth-caret #source { caret-color: transparent; }
#source::selection { background: var(--select); color: transparent; }
.highlight .line-error { background: var(--error-line); }
.t-command { color: var(--syn-command); }
.t-flow { color: var(--syn-flow); font-weight: 600; }
.t-string { color: var(--syn-string); }
.t-number { color: var(--syn-number); }
.t-comment { color: var(--syn-comment); font-style: italic; }
.t-brace { color: var(--syn-brace); }
.t-function { color: var(--syn-function); }
.t-keyword { color: var(--syn-keyword); }
.t-color { color: var(--syn-color); text-decoration: underline 2px; text-underline-offset: 3px; }
.t-operator { color: var(--syn-operator); }
.b0 { color: var(--syn-number); }
.b1 { color: var(--syn-keyword); }
.b2 { color: var(--syn-brace); }
.find-hit { background: var(--match); border-radius: 2px; }
.find-current { background: var(--select); box-shadow: 0 0 0 1px var(--accent-light); border-radius: 2px; }

.active-line {
  position: absolute; left: 0; right: 0; height: var(--code-line); top: 12px; z-index: 0;
  background: var(--active-line); pointer-events: none; opacity: 0;
  transition: transform calc(.12s * var(--speed)) var(--ease), opacity .15s;
}
.show-line .active-line { opacity: 1; }

/* the smooth caret: glides to where you type and breathes instead of blinking hard */
.caret {
  position: absolute; left: 0; top: 0; z-index: 3; width: 2px; height: var(--code-line);
  background: var(--accent-light); pointer-events: none; opacity: 0; border-radius: 1px;
  transition: transform calc(.09s * var(--speed)) var(--ease), width .12s, height .12s, opacity .1s;
}
.smooth-caret .focused .caret { opacity: 1; }
.caret.snap { transition: none; }
.caret.blink-fade { animation: caret-fade 1.1s ease-in-out .55s infinite; }
.caret.blink-blink { animation: caret-blink 1.06s steps(1) .53s infinite; }
.caret.block { background: color-mix(in srgb, var(--accent-light) 55%, transparent); border-radius: 2px; }
.caret.underline { border-radius: 0; }
@keyframes caret-fade { 0%, 100% { opacity: 1; } 50% { opacity: .1; } }
@keyframes caret-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* letters you just typed */
.fx-fade { animation: fx-fade calc(.22s * var(--speed)) var(--ease) both; }
.fx-ink { animation: fx-ink calc(.45s * var(--speed)) ease-out both; }
.fx-glow { animation: fx-glow calc(.5s * var(--speed)) ease-out both; border-radius: 2px; }
.fx-paste { animation: fx-glow calc(.7s * var(--speed)) ease-out both; }
.fx-jump { animation: fx-line calc(.8s * var(--speed)) ease-out both; }
.fx-error { animation: fx-error calc(1.1s * var(--speed)) ease-out both; }
@keyframes fx-fade { from { opacity: 0; } }
@keyframes fx-ink { from { color: var(--text); text-shadow: 0 0 6px var(--accent-light); } }
@keyframes fx-glow { from { background: color-mix(in srgb, var(--accent-light) 40%, transparent); } to { background: transparent; } }
@keyframes fx-line { from { background: color-mix(in srgb, var(--accent) 45%, transparent); } to { background: transparent; } }
@keyframes fx-error { from { background: color-mix(in srgb, var(--error) 40%, transparent); } to { background: transparent; } }

/* ----- suggestions and the hint bar ----- */
.complete {
  position: absolute; z-index: 20; min-width: 240px; max-width: min(460px, 90%); max-height: 240px; overflow: auto;
  padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-alt);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .35); font-size: 13px;
  transform-origin: top left; animation: pop-in calc(.14s * var(--speed)) var(--ease);
}
.complete .item { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; padding: 4px 8px; border-radius: 5px; cursor: pointer; }
.complete .item b { font: 600 13px var(--mono); color: var(--syn-command); }
.complete .item.fn b { color: var(--syn-function); }
.complete .item.var b { color: var(--text); }
.complete .item span { color: var(--muted); font: 12px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.complete .item.chosen { background: var(--select); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-4px); } }

.hintbar {
  min-height: 28px; padding: 4px 14px; border-top: 1px solid var(--border); background: var(--panel);
  font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hintbar code { font: 12.5px var(--mono); color: var(--syn-command); }
.hintbar .fade { animation: status-in calc(.2s * var(--speed)) var(--ease); display: inline-block; }
.hintbar .bad { color: var(--error); }
.hintbar .warn { color: var(--warning); }
.hintbar kbd { font-size: 11px; padding: 0 4px; }

/* ----- the program's window ----- */
.stage {
  position: relative;
  flex: 1 1 60%;
  min-height: 160px;
  background: var(--stage-bg);
  overflow: hidden;
}
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; animation: stage-in calc(.35s * var(--speed)) var(--ease); }
@keyframes stage-in { from { opacity: 0; transform: scale(.985); } }
.stage-note {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  animation: status-in calc(.3s * var(--speed)) var(--ease);
}
.stage-note[hidden] { display: none; }
.stage-tools {
  position: absolute; top: 10px; right: 10px; z-index: 2; display: flex; gap: 6px;
  opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s var(--ease);
}
.stage:hover .stage-tools, .stage:focus-within .stage-tools { opacity: 1; transform: none; }
.stage-tools button { background: color-mix(in srgb, var(--panel-alt) 85%, transparent); backdrop-filter: blur(6px); }
.stage:fullscreen { background: #000; }

.boot {
  position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 14px;
  padding: 24px; background: var(--stage-bg); transition: opacity calc(.45s * var(--speed)) ease, transform calc(.45s * var(--speed)) var(--ease);
}
.boot.gone { opacity: 0; transform: scale(1.02); pointer-events: none; }
.boot-logo { animation: float 2.4s ease-in-out infinite; filter: drop-shadow(0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent)); }
@keyframes float { 50% { transform: translateY(-6px) rotate(-3deg); } }
.boot-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; color: var(--dim); font-size: 13.5px; }
.boot-steps li { display: flex; align-items: center; gap: 10px; transition: color .25s; }
.boot-steps li::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); flex: none;
  transition: border-color .25s, background-color .25s, transform .3s var(--spring);
}
.boot-steps li.active { color: var(--text); }
.boot-steps li.active::before { border-color: var(--accent-light); border-top-color: transparent; animation: spin .8s linear infinite; }
.boot-steps li.done { color: var(--muted); }
.boot-steps li.done::before { background: var(--accent-light); border-color: var(--accent-light); transform: scale(.85); }
.boot-steps li.failed { color: var(--error); }
.boot-steps li.failed::before { border-color: var(--error); background: var(--error); }
.boot-bar { width: min(260px, 70vw); height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.boot-bar span { display: block; height: 100%; width: 0; background: var(--accent-light); transition: width calc(.5s * var(--speed)) var(--ease); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- output, problems, reference, javascript ----- */
.tabs { position: relative; display: flex; align-items: stretch; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--border); }
.tab {
  height: 34px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--muted);
}
.tab:hover:not(:disabled) { background: none; color: var(--text); }
.tab:active:not(:disabled) { transform: none; }
.tab[aria-selected="true"] { color: var(--text); }
.tab-indicator {
  position: absolute; bottom: -1px; left: 0; height: 2px; width: 0; background: var(--accent-light);
  transition: transform calc(.25s * var(--speed)) var(--ease), width calc(.25s * var(--speed)) var(--ease);
}
.count { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--error); color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
.count.warn { background: var(--warning); color: #1a1408; }
.count.bump { animation: bump calc(.35s * var(--speed)) var(--spring); }
@keyframes bump { 40% { transform: scale(1.35); } }
.clear { margin: 4px 0 4px auto; height: 26px; font-size: 12px; }
.panel { flex: 1 1 40%; min-height: 80px; overflow: auto; background: var(--editor-bg); }
.panel:not([hidden]) { animation: panel-in calc(.2s * var(--speed)) var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }
.panel pre { margin: 0; padding: 10px 14px; font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; }
#output > span { display: block; animation: line-in calc(.18s * var(--speed)) var(--ease); }
@keyframes line-in { from { opacity: 0; transform: translateX(-4px); } }
#output .error { color: var(--error); }
#output .note { color: var(--muted); font-style: italic; }
#output .good { color: var(--accent-light); }
#problems { list-style: none; margin: 0; padding: 4px 0; font-size: 13px; }
#problems li { display: flex; gap: 10px; padding: 5px 14px; cursor: pointer; animation: line-in calc(.2s * var(--speed)) var(--ease) both; }
#problems li:hover { background: var(--hover); }
#problems .where { flex: none; min-width: 56px; font-family: var(--mono); color: var(--muted); }
#problems .error .where { color: var(--error); }
#problems .warning .where { color: var(--warning); }
#problems .empty { cursor: default; color: var(--muted); }
#problems .empty:hover { background: none; }

.ref-search { position: sticky; top: 0; z-index: 1; padding: 8px 12px; background: var(--editor-bg); border-bottom: 1px solid var(--border); }
.ref-search input { width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); font: inherit; }
.reference { padding: 4px 0 12px; font-size: 13px; }
.reference h3 { margin: 12px 14px 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-light); }
.reference .entry { padding: 6px 14px; border-left: 2px solid transparent; transition: background-color .15s, border-color .15s; }
.reference .entry:hover { background: var(--hover); border-left-color: var(--accent); }
.reference .entry.flash { animation: fx-line calc(1s * var(--speed)) ease-out; }
.reference code { font: 12.5px var(--mono); color: var(--syn-command); }
.reference .fn code { color: var(--syn-function); }
.reference .about { color: var(--muted); }
.reference .example { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.reference .example code { color: var(--text); opacity: .85; }
.reference .example button { height: 22px; padding: 0 8px; font-size: 11.5px; }
.reference .empty { padding: 10px 14px; color: var(--muted); }
.reference .swatch-row { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.reference .chip { display: inline-flex; align-items: center; gap: 6px; font: 12.5px var(--mono); color: var(--text); }
.reference .chip i { width: 14px; height: 14px; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .4); }

.foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.foot-links { display: flex; gap: 14px; }

/* ----- toasts ----- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; justify-items: center; pointer-events: none; }
.toast {
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  animation: toast-in calc(.3s * var(--speed)) var(--spring) both;
}
.toast.bad { background: var(--error); color: #fff; }
.toast.leaving { animation: toast-out calc(.25s * var(--speed)) ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ----- settings drawer ----- */
.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); animation: fade-in calc(.2s * var(--speed)) ease both; }
.scrim.leaving { animation: fade-out calc(.2s * var(--speed)) ease both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41; width: min(420px, 100vw);
  display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: -18px 0 40px rgba(0, 0, 0, .3); animation: drawer-in calc(.3s * var(--speed)) var(--ease) both;
}
.drawer.leaving { animation: drawer-out calc(.22s * var(--speed)) ease-in both; }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-out { to { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow: auto; padding: 4px 16px 24px; }
.drawer section { padding: 10px 0 6px; border-bottom: 1px solid var(--border); animation: rise calc(.35s * var(--speed)) var(--ease) both; }
.drawer section:nth-child(2) { animation-delay: .04s; }
.drawer section:nth-child(3) { animation-delay: .08s; }
.drawer section:nth-child(4) { animation-delay: .12s; }
.drawer section:nth-child(5) { animation-delay: .16s; }
.drawer h3 { margin: 6px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-light); }
.setting { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.setting > span:first-child { color: var(--muted); }
.setting select { width: 100%; max-width: none; height: 30px; }
.setting input[type="range"] { width: 100%; accent-color: var(--accent-light); }
.choices { display: flex; flex-wrap: wrap; gap: 4px; }
.choices button { height: 28px; padding: 0 10px; font-size: 12.5px; }
.choices button[aria-pressed="true"] { background: var(--select); border-color: var(--accent-light); color: var(--text); }
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; cursor: pointer; }
.check input { appearance: none; width: 34px; height: 20px; margin: 0; border-radius: 10px; background: var(--panel-alt); border: 1px solid var(--border); position: relative; cursor: pointer; flex: none; transition: background-color .2s; }
.check input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform calc(.22s * var(--speed)) var(--spring), background-color .2s; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { transform: translateX(14px); background: var(--accent-text); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.swatch[aria-pressed="true"] { border-color: var(--text); transform: scale(1.1); }
.swatch.theme-own { background: conic-gradient(var(--accent) 0 50%, var(--panel-alt) 0 100%); }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row input[type="color"] { width: 34px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 5px; background: none; cursor: pointer; }
.color-row code { font: 12px var(--mono); color: var(--dim); }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin: 6px 0; font-size: 13px; }
.drawer .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.drawer .about { margin: 2px 0 6px; font-size: 12px; color: var(--dim); }
.setting output { min-width: 44px; font: 12px var(--mono); color: var(--muted); text-align: right; }
.text-field { width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--editor-bg); color: var(--text); font: inherit; }
.keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.keys li { display: grid; grid-template-columns: 170px 1fr; gap: 8px; align-items: baseline; }
.keys li > span:last-child { color: var(--muted); }

/* the little game window in settings > game window and popups */
.game-preview {
  container-type: inline-size;
  position: relative; display: flex; justify-content: center; align-items: center; overflow: hidden;
  width: 100%; max-height: 280px; margin: 8px 0 10px; padding: 7% 0; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; transition: background-color calc(.25s * var(--speed));
}
.gp-title { position: absolute; top: 0; left: 0; right: 0; z-index: 3; padding: 2px 8px; font-size: 10.5px; color: #e0e0e0; background: rgba(0, 0, 0, .35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp-fps { position: absolute; top: 22px; right: 6px; z-index: 3; padding: 0 5px; font: 10px var(--mono); color: var(--accent-light); background: rgba(0, 0, 0, .6); }
.gp-shade { position: absolute; inset: 0; z-index: 1; background: #000; transition: opacity calc(.2s * var(--speed)); }
.gp-box { position: relative; z-index: 2; padding: .7em .8em .6em; line-height: 1.3; border-top-width: 3px !important; }
.gp-field { margin-top: .5em; padding: .2em .4em; font-family: var(--mono); }
.gp-field i { display: inline-block; width: 2px; height: 1em; margin-left: 1px; vertical-align: -.15em; animation: caret-fade 1.1s ease-in-out infinite; }
.gp-hint { margin-top: .4em; font-size: .7em; }
.gp-pop { animation: gp-pop calc(.22s * var(--speed)) cubic-bezier(.2, .9, .3, 1.45) both; }
.gp-fade { animation: fade-in calc(.22s * var(--speed)) ease-out both; }
.gp-slide { animation: gp-slide calc(.24s * var(--speed)) var(--ease) both; }
@keyframes gp-pop { from { opacity: 0; transform: scale(.86); } }
@keyframes gp-slide { from { opacity: 0; transform: translateY(18px); } }

/* ----- command palette ----- */
.palette {
  position: fixed; left: 50%; top: 12vh; z-index: 45; width: min(560px, calc(100vw - 32px));
  transform: translateX(-50%); background: var(--panel-alt); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45); overflow: hidden; animation: palette-in calc(.18s * var(--speed)) var(--ease) both;
}
.palette.leaving { animation: palette-out calc(.14s * var(--speed)) ease-in both; }
@keyframes palette-in { from { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(.98); } }
@keyframes palette-out { to { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(.98); } }
.palette input { width: 100%; height: 44px; padding: 0 16px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: 15px var(--sans); outline: none; }
.palette ul { list-style: none; margin: 0; padding: 4px; max-height: 50vh; overflow: auto; }
.palette li { display: flex; justify-content: space-between; gap: 16px; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.palette li small { color: var(--dim); font: 12px var(--mono); white-space: nowrap; }
.palette li .kind { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-right: 8px; }
.palette li.chosen { background: var(--select); }
.palette li mark { background: none; color: var(--accent-light); font-weight: 600; }

/* ----- phones and narrow windows: stack the panes ----- */
@media (max-width: 820px) {
  html, body { height: auto; }
  .layout { display: flex; flex-direction: column; }
  .splitter { display: none; }
  .editor-pane { height: 60vh; }
  .stage { flex: none; height: 62vw; min-height: 240px; }
  .panel { flex: none; height: 40vh; }
  .bar { padding: 8px 16px; }
  .actions { gap: 6px; }
  .actions button, .download { padding: 0 10px; }
  .actions button span, .download span { display: none; }
  .actions button.primary span { display: inline; }
  select { max-width: 120px; }
  .stage-tools { opacity: 1; transform: none; }
  .setting { grid-template-columns: 1fr; gap: 4px; }
  .keys li { grid-template-columns: 1fr; gap: 2px; }
  .file-tabs .status { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-logo, .running button.primary#run { animation: none; }
}
