/* Gaanim Playground, in the identity of the documentation site
   (docs/assets/base.css, docs/assets/brand/README.md): graphite surfaces
   without a blue tint, violet for what came before and gold for the current
   frame, square corners (everything is a frame), controls that step forward
   leaving two ghost frames, and labels in the code face. */
@font-face {
  font-family: "JetBrains Mono";
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/JetBrainsMono-Variable.ttf") format("truetype");
}

:root {
  --ink: #121212;
  --surface: #171717;
  --raised: #1b1b1b;
  --muted-bg: #242424;
  --line: #292929;
  --line-strong: #3d3d3d;
  --text: #ededed;
  --muted: #a0a0a0;
  --faint: #6b6b73;
  --primary: #a99fff;
  --primary-strong: #c9c3ff;
  --primary-soft: rgba(169, 159, 255, 0.12);
  --violet: #7c6cff;
  --haze: #3f37a8;
  --gold: #ffc933;
  --brand-ink: #14112e;
  /* Gold as text and thin lines; on white it darkens to stay legible. */
  --gold-ink: #ffc933;
  --on-primary: #14112e;
  --warn: #fbbf24;
  --danger: #f87171;
  --hover: rgba(255, 255, 255, 0.04);
  --stderr: #e2b4b4;
  --checker-a: #242424;
  --checker-b: #1b1b1b;
  --backdrop: rgba(10, 10, 10, 0.72);
  --scrim: rgba(18, 18, 18, 0.82);
  --shadow: rgba(0, 0, 0, 0.45);
  --drop: rgba(124, 108, 255, 0.24);
  --error-line: rgba(248, 113, 113, 0.12);
  --show-dark: block;
  --show-light: none;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --frame-1: color-mix(in srgb, var(--primary) 45%, transparent);
  --frame-2: color-mix(in srgb, var(--primary) 20%, transparent);
  --frames: -3px 0 0 var(--frame-1), -6px 0 0 var(--frame-2);
  --frame-motion: 0.15s steps(3, end);
  --side: 42%;
  --player: 58%;
  --explorer-width: 232px;
  color-scheme: dark;
  /* Monaco's context menu lives in a shadow root outside the editor, which
     its theme's variables do not reach: they come from here. */
  --vscode-menu-background: var(--raised);
  --vscode-menu-foreground: var(--text);
  --vscode-menu-border: var(--line-strong);
  --vscode-menu-selectionBackground: var(--primary-soft);
  --vscode-menu-selectionForeground: var(--primary-strong);
  --vscode-menu-selectionBorder: transparent;
  --vscode-menu-separatorBackground: var(--line-strong);
  --vscode-widget-shadow: var(--shadow);
}

/* The light theme of the documentation site (docs/assets/base.css): it
   follows the system unless the site's toggle chose one (localStorage
   "theme", shared with the docs). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
  --ink: #ffffff;
  --surface: #fafafa;
  --raised: #ffffff;
  --muted-bg: #f0f0f2;
  --line: #e5e5e7;
  --line-strong: #d4d4d8;
  --text: #18181b;
  --muted: #52525b;
  --faint: #8a8a93;
  --primary: #5b4af0;
  --primary-strong: #4636d6;
  --primary-soft: rgba(91, 74, 240, 0.1);
  --violet: #7c6cff;
  --haze: #cbc6ff;
  --gold-ink: #a16207;
  --on-primary: #ffffff;
  --warn: #b45309;
  --danger: #dc2626;
  --hover: rgba(0, 0, 0, 0.04);
  --stderr: #9f1239;
  --checker-a: #ececef;
  --checker-b: #f8f8f9;
  --backdrop: rgba(24, 24, 27, 0.4);
  --scrim: rgba(255, 255, 255, 0.86);
  --shadow: rgba(24, 24, 27, 0.16);
  --drop: rgba(91, 74, 240, 0.14);
  --error-line: rgba(220, 38, 38, 0.08);
  --show-dark: none;
  --show-light: block;
  color-scheme: light;
  }
}
:root[data-theme="light"] {
  --ink: #ffffff;
  --surface: #fafafa;
  --raised: #ffffff;
  --muted-bg: #f0f0f2;
  --line: #e5e5e7;
  --line-strong: #d4d4d8;
  --text: #18181b;
  --muted: #52525b;
  --faint: #8a8a93;
  --primary: #5b4af0;
  --primary-strong: #4636d6;
  --primary-soft: rgba(91, 74, 240, 0.1);
  --violet: #7c6cff;
  --haze: #cbc6ff;
  --gold-ink: #a16207;
  --on-primary: #ffffff;
  --warn: #b45309;
  --danger: #dc2626;
  --hover: rgba(0, 0, 0, 0.04);
  --stderr: #9f1239;
  --checker-a: #ececef;
  --checker-b: #f8f8f9;
  --backdrop: rgba(24, 24, 27, 0.4);
  --scrim: rgba(255, 255, 255, 0.86);
  --shadow: rgba(24, 24, 27, 0.16);
  --drop: rgba(91, 74, 240, 0.14);
  --error-line: rgba(220, 38, 38, 0.08);
  --show-dark: none;
  --show-light: block;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* Monaco sizes its widgets (the suggestions list, hovers) for the browser's
   default box model: border-box cut the last suggestion short. */
:where(.monaco-editor, .monaco-editor *) { box-sizing: content-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--ink);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
button, select, input { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: 0.92em; color: var(--text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }
/* Running the scene, next to the brand. */
.controls { display: flex; align-items: center; gap: 8px; }
[hidden] { display: none !important; }

/* ---- Top bar ------------------------------------------------------------ */
.bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface);
  min-width: 0;
}
/* The brand's icon alone, without the wordmark. */
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; margin-right: 6px; white-space: nowrap; }
.brand img { display: block; image-rendering: pixelated; }
.brand .product { font: 500 13px/1 var(--mono); color: var(--muted); letter-spacing: 0.02em; }
button.primary, button.ghost, .select select {
  height: 32px; padding: 0 12px; border-radius: 0; cursor: pointer; white-space: nowrap;
  font: 500 13px/1 var(--mono);
}
button.primary {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary);
}
button.primary:hover:not(:disabled) { background: var(--primary-strong); border-color: var(--primary-strong); }
button.primary:disabled { background: var(--muted-bg); border-color: var(--line-strong); color: var(--faint); cursor: progress; }
button.ghost { border: 1px solid var(--line-strong); background: transparent; }
button.ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-strong); }
button.ghost.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
/* Icon buttons of the bar: what each does is in its title. */
button.ghost.square { display: inline-grid; place-items: center; width: 32px; padding: 0; }
button.square svg { display: block; }
/* The theme button shows the theme it switches to. */
#theme .when-dark { display: var(--show-dark); }
#theme .when-light { display: var(--show-light); }
button.square .stroke { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
button.square .stroke.accent { stroke: var(--gold-ink); }
/* A switch: on, it takes the violet and its icon turns gold. */
button.ghost.toggle[aria-pressed="true"] { border-color: var(--violet); color: var(--gold-ink); background: var(--primary-soft); }
button.ghost.toggle[aria-pressed="true"] .stroke { fill: currentColor; }
button:disabled { opacity: 0.6; cursor: default; }
/* Controls step forward one frame at a time and leave two ghost frames behind,
   like the symbol. */
button.primary, button.ghost {
  transition: transform var(--frame-motion), box-shadow var(--frame-motion),
    border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}
:is(button.primary, button.ghost):hover:not(:disabled) {
  transform: translateX(3px);
  box-shadow: var(--frames);
}
button:focus-visible, select:focus-visible, .splitter:focus-visible, .drop:focus-within {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.select select {
  appearance: none; border: 1px solid var(--line-strong); background: var(--ink);
  padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px; background-repeat: no-repeat;
  max-width: 260px;
}
.select select:hover { border-color: var(--primary); }
.select.compact select { max-width: 96px; }
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 170px;
  display: flex; flex-direction: column; padding: 4px;
  background: var(--raised); border: 1px solid var(--line-strong);
  box-shadow: 0 24px 64px var(--shadow);
}
.menu-list button {
  text-align: left; padding: 6px 10px; border: 0; background: transparent; cursor: pointer;
  font-family: var(--mono); font-size: 13px;
}
.menu-list button:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary-strong); }

/* ---- Layout ------------------------------------------------------------- */
#layout {
  display: grid;
  grid-template-columns: var(--explorer-width) minmax(0, 1fr) 6px minmax(300px, var(--side));
  min-height: 0;
}
body.explorer-hidden { --explorer-width: 0px; }
body.explorer-hidden .explorer { display: none; }
/* Each pane keeps its column, so a hidden explorer leaves its own empty
   instead of shifting the others into it. */
#layout > .explorer { grid-area: 1 / 1; }
#layout > .editor-pane { grid-area: 1 / 2; }
#layout > #split-x { grid-area: 1 / 3; }
#layout > .side { grid-area: 1 / 4; }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.side { display: grid; grid-template-rows: minmax(120px, var(--player)) 6px minmax(100px, 1fr); }
.splitter { background: var(--line); transition: background 0.15s; }
.splitter:hover, .splitter.dragging { background: var(--violet); }
.splitter.vertical { cursor: col-resize; }
.splitter.horizontal { cursor: row-resize; }

.tabs {
  display: flex; align-items: center; gap: 2px; padding: 0 8px; min-height: 34px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.tab {
  padding: 8px 10px; border: 0; background: transparent; color: var(--muted);
  border-bottom: 2px solid transparent; font: 500 12.5px/1.2 var(--mono); cursor: pointer;
}
span.tab { cursor: default; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--gold); }
.tab .count { margin-left: 4px; padding: 0 5px; background: var(--muted-bg); color: var(--muted); font-size: 11px; }
.tabs .hint { margin-left: auto; color: var(--faint); font-size: 12px; font-family: var(--mono); }
button.icon {
  display: grid; place-items: center; width: 28px; height: 28px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
}
button.icon:hover { background: var(--primary-soft); color: var(--primary-strong); }

.editor { flex: 1; min-height: 0; position: relative; }
.placeholder { display: grid; place-items: center; height: 100%; color: var(--faint); font-family: var(--mono); }

/* ---- Player ------------------------------------------------------------- */
.player-wrap { position: relative; background: var(--ink); min-height: 0; }
#player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.player-overlay {
  /* Centered by its margins, so it may grow to the player's width. */
  position: absolute; left: 0; right: 0; top: 12px; width: max-content; margin-inline: auto;
  display: flex; align-items: center; gap: 10px; padding: 6px 12px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line-strong);
  color: var(--muted); font: 12.5px/1.2 var(--mono); pointer-events: none;
  flex-wrap: wrap; justify-content: center; max-width: calc(100% - 24px);
}
.player-overlay .overlay-hint { flex-basis: 100%; text-align: center; color: var(--faint); font-size: 11.5px; }
/* Three frames light up in turn, from the faintest to the current one. */
.loader { display: inline-flex; gap: 3px; flex: none; }
.loader i { width: 6px; height: 6px; opacity: 0.25; animation: frame 0.9s steps(1, end) infinite; }
.loader i:nth-child(1) { background: var(--haze); }
.loader i:nth-child(2) { background: var(--violet); animation-delay: 0.3s; }
.loader i:nth-child(3) { background: var(--gold); animation-delay: 0.6s; }
@keyframes frame { 0%, 66% { opacity: 1; } 67%, 100% { opacity: 0.25; } }

/* ---- Console and files -------------------------------------------------- */
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--ink); }
.tab-body { flex: 1; min-height: 0; overflow: auto; }
#console {
  padding: 8px 12px; font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word;
}
#console .line { margin: 0; }
#console .stderr { color: var(--stderr); }
#console .error { color: var(--danger); }
#console .info { color: var(--muted); }
#console .ok { color: var(--primary); }
#console .hint { color: var(--gold-ink); }
#console .hint::before { content: "→ "; }
/* New output while the packages show: a gold frame on the console's tab. */
.tab.unread::after { content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 6px; vertical-align: middle; background: var(--gold); }

/* ---- Packages ----------------------------------------------------------- */
.packages { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.packages[hidden] { display: none; }
.package-search { display: flex; gap: 8px; }
.package-field { position: relative; flex: 1; min-width: 0; }
.package-field input {
  width: 100%; height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 0;
  background: var(--ink); color: var(--text); font: 13px/1 var(--mono); outline: none;
}
.package-field input:focus { border-color: var(--primary); }
.package-suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 10; margin: 0; padding: 4px; list-style: none;
  max-height: 280px; overflow: auto; background: var(--raised); border: 1px solid var(--line-strong);
  box-shadow: 0 16px 40px var(--shadow);
}
.package-suggestions li {
  display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; gap: 2px 8px; padding: 6px 8px; cursor: pointer;
}
.package-suggestions li.active, .package-suggestions li:hover { background: var(--primary-soft); }
.package-suggestions li.disabled { cursor: not-allowed; }
.package-suggestions .name { font: 600 13px/1.3 var(--mono); color: var(--text); }
.package-suggestions .version { font: 12px/1.3 var(--mono); color: var(--muted); }
.package-suggestions .source {
  justify-self: end; padding: 1px 6px; border: 1px solid var(--line-strong); color: var(--muted); font: 11px/1.3 var(--mono);
}
.package-suggestions .source.pyodide { border-color: var(--violet); color: var(--primary-strong); }
.package-suggestions .summary {
  grid-column: 1 / -1; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.package-suggestions .summary.warn { color: var(--warn); white-space: normal; }
.package-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.package-list .empty { padding: 10px 0; color: var(--faint); font-size: 12.5px; }
.package-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 2px 8px;
  padding: 4px 0 4px 2px; border-bottom: 1px solid var(--line);
}
.package-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 600 13px/1.3 var(--mono); }
.package-name .spec { font-weight: 400; color: var(--muted); }
.package-status { white-space: nowrap; font: 12px/1.3 var(--mono); color: var(--muted); }
.package-status.ok { color: var(--primary); }
.package-status.busy { color: var(--gold-ink); }
.package-status.error { color: var(--danger); }
.package-reason { grid-column: 1 / -1; margin: 0 0 4px; color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }
.package-reason a { margin-left: 4px; color: var(--primary-strong); text-decoration: underline; cursor: pointer; }
#console a.action { color: var(--primary-strong); text-decoration: underline; }
#console a { color: var(--primary); cursor: pointer; text-decoration: underline dotted; }
#console .empty { color: var(--faint); font-family: ui-sans-serif, system-ui, sans-serif; }

.note { margin: 0; color: var(--faint); font-size: 12.5px; }

/* ---- Explorer ----------------------------------------------------------- */
.explorer { background: var(--surface); border-right: 1px solid var(--line); }
.explorer-head {
  display: flex; align-items: center; gap: 2px; min-height: 34px; padding: 0 4px 0 12px;
  border-bottom: 1px solid var(--line);
}
.explorer-title { font: 600 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tree {
  list-style: none; margin: 0; padding: 4px 0; flex: 1; min-height: 0; overflow: auto;
  font: 12.5px/1 var(--mono); outline: none;
}
.tree.drop-root { box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-soft); }
.tree .row {
  display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px 0 calc(8px + var(--depth) * 14px);
  color: var(--text); white-space: nowrap; cursor: pointer; user-select: none; outline: none;
  border-left: 2px solid transparent;
}
.tree .row:hover { background: var(--hover); }
.tree .row.active { background: var(--primary-soft); border-left-color: var(--gold); }
.tree .row.selected { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 60%, transparent); }
.tree .row.drop-target { background: var(--drop); }
.tree .chevron { width: 10px; flex: none; color: var(--faint); font-size: 10px; text-align: center; }
.tree .name { overflow: hidden; text-overflow: ellipsis; }
.tree .row.folder .name { color: var(--text); }
.entry-mark { margin-left: auto; padding-left: 6px; color: var(--gold-ink); font-size: 9px; }
.tree input.rename {
  flex: 1; min-width: 0; height: 20px; padding: 0 4px; border: 1px solid var(--primary); border-radius: 0;
  background: var(--ink); color: var(--text); font: inherit; outline: none;
}
.explorer-note { margin: 0; padding: 10px 12px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11.5px; line-height: 1.45; }

/* What a file holds, as a pictogram in the brand's colors (main.js ICONS):
   lines in the type's color, accents in violet and gold. */
.file-icon { width: 16px; height: 16px; flex: none; color: var(--muted); }
.file-icon svg { display: block; width: 100%; height: 100%; overflow: visible; }
.file-icon .s, .file-icon .gs { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
.file-icon .gs { stroke: var(--gold-ink); }
.file-icon .g { fill: var(--gold-ink); }
.file-icon .v { fill: var(--violet); }
.file-icon .h { fill: var(--haze); }
.file-icon .o { fill: currentColor; opacity: 0.35; }
.file-icon .eye { fill: var(--surface); }
.file-icon:is(.folder-open, .markdown, .table, .image, .vector, .audio, .video, .code, .lottie) { color: var(--primary); }
.file-icon:is(.json, .font, .math) { color: var(--gold-ink); }
.file-icon.file { color: var(--faint); }
.file-icon.big { width: 56px; height: 56px; }

/* ---- Editor tabs and asset previews ------------------------------------- */
.editor-bar {
  display: flex; align-items: stretch; min-height: 34px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.editor-bar > button.icon { width: 34px; height: auto; flex: none; border-right: 1px solid var(--line); }
.editor-tabs { display: flex; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.editor-tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 0 4px 0 12px;
  border-right: 1px solid var(--line); border-bottom: 2px solid transparent; color: var(--muted);
}
.editor-tab .tab-name { padding: 8px 0; border: 0; background: transparent; color: inherit; font: 12.5px/1.2 var(--mono); cursor: pointer; }
.editor-tab.active { color: var(--text); background: var(--ink); border-bottom-color: var(--gold); }
.editor-tab:hover { color: var(--text); }
.editor-tab .tab-close {
  width: 20px; height: 20px; display: grid; place-items: center; border: 0; background: transparent;
  color: var(--faint); font-size: 15px; line-height: 1; cursor: pointer;
}
.editor-tab .tab-close:hover { color: var(--text); background: var(--primary-soft); }
.editor-tab .entry-mark { margin: 0 8px 0 0; padding: 0; }
.editor-bar .hint { align-self: center; padding: 0 10px; white-space: nowrap; }
.editor-stack { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.asset-view {
  position: absolute; inset: 0; overflow: auto; padding: 24px; background: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center;
}
.asset-stage { max-width: 100%; display: grid; place-items: center; }
.asset-stage img {
  max-width: min(100%, 720px); max-height: 50vh; display: block;
  background: repeating-conic-gradient(var(--checker-a) 0% 25%, var(--checker-b) 0% 50%) 0 / 16px 16px;
}
.asset-stage audio, .asset-stage video { max-width: min(100%, 560px); }
.font-sample { color: var(--text); }
.font-sample p { margin: 0 0 8px; }
.font-sample p:first-child { font-size: 44px; line-height: 1.2; }
.font-sample p:last-child { font-size: 18px; color: var(--muted); }
.asset-meta { margin: 0; color: var(--muted); font: 12px/1.4 var(--mono); }
.asset-snippet { padding: 6px 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--primary-strong); font-size: 12.5px; max-width: 100%; overflow-wrap: anywhere; }
.asset-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* Placed by its left edge (main.js), as wide as its longest item. */
.context-menu {
  position: fixed; top: 0; left: 0; right: auto; z-index: 50; min-width: 200px; width: max-content;
  max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto;
}
.context-menu hr { margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.context-menu button.danger { color: var(--danger); }
.context-menu button.current { color: var(--primary-strong); box-shadow: inset 2px 0 0 var(--gold); }

/* The project's name opens the projects menu. */
.project-switch {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; height: 26px; padding: 0 6px 0 0;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.project-switch .explorer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-switch .caret { font-size: 10px; color: var(--faint); }
.project-switch:hover .explorer-title, .project-switch:hover .caret { color: var(--primary-strong); }
.explorer-head input.project-rename {
  flex: 1; min-width: 0; height: 24px; padding: 0 6px; border: 1px solid var(--primary); background: var(--ink);
  font: 600 11px/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text); outline: none;
}
#toast .toast-action {
  margin-left: 6px; padding: 2px 8px; border: 1px solid var(--primary); background: transparent;
  color: var(--primary-strong); font: 12px/1.4 var(--mono); cursor: pointer;
}

/* ---- Status bar --------------------------------------------------------- */
.status {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px; min-height: 26px;
  border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font: 12px/1.3 var(--mono);
}
.status .dot { width: 8px; height: 8px; background: var(--faint); flex: none; }
.status .dot.busy { background: var(--gold); animation: blink 0.9s steps(1, end) infinite; }
.status .dot.ready { background: var(--primary); }
.status .dot.error { background: var(--danger); }
@keyframes blink { 50% { opacity: 0.3; } }
.status progress { width: 140px; height: 4px; appearance: none; border: 0; background: var(--muted-bg); }
.status progress::-webkit-progress-bar { background: var(--muted-bg); }
.status progress::-webkit-progress-value { background: var(--violet); }
.status progress::-moz-progress-bar { background: var(--violet); }
#versions { color: var(--faint); }

#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%); z-index: 30;
  max-width: calc(100% - 32px); padding: 10px 16px;
  background: var(--raised); border: 1px solid var(--line-strong); border-left: 3px solid var(--gold);
  box-shadow: 0 24px 64px var(--shadow);
}
#dropping {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: var(--scrim); pointer-events: none;
}
#dropping div {
  padding: 28px 40px; border: 2px dashed var(--primary); font: 15px/1.3 var(--mono); background: var(--surface);
}

/* ---- Embedding dialog -------------------------------------------------- */
#embed-dialog {
  width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 24px 64px var(--shadow); overflow: auto;
}
#embed-dialog::backdrop { background: var(--backdrop); }
.dialog-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
/* Three squares, faintest to brightest, mark a section as on the site. */
.dialog-head h2 { margin: 0; flex: 1; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.dialog-head h2::before {
  content: ""; width: 6px; height: 6px; flex: none; background: var(--gold);
  box-shadow: -9px 0 0 var(--violet), -18px 0 0 var(--haze); margin-left: 18px;
}
.embed-body {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr); gap: 24px; padding: 20px;
}
.embed-aside { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.embed-preview { margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* The page with everything inside, for whoever has no site: apart from the
   steps, under the preview. */
.embed-alone { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.embed-alone h3 { margin: 0; font: 600 13px/1.3 var(--mono); }
.embed-alone p { margin: 0; color: var(--muted); font-size: 13px; }
.embed-alone .row { display: flex; gap: 8px; align-items: center; }
.embed-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: var(--ink); border: 1px solid var(--line); overflow: hidden; }
.embed-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.embed-preview figcaption { display: flex; flex-direction: column; gap: 2px; color: var(--faint); font-size: 12.5px; }
#embed-meta { color: var(--muted); font-family: var(--mono); }
.embed-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.embed-steps li { counter-increment: step; display: flex; flex-direction: column; gap: 8px; }
.embed-steps h3 { margin: 0; font: 600 13px/1.3 var(--mono); display: flex; align-items: center; gap: 8px; }
/* Each step's number in a frame of its own. */
.embed-steps h3::before {
  content: counter(step); display: grid; place-items: center; width: 20px; height: 20px; flex: none;
  background: var(--primary-soft); border: 1px solid var(--primary); color: var(--primary-strong); font-size: 11px;
}
.embed-steps p { margin: 0; color: var(--muted); font-size: 13px; }
.embed-steps .note a, .embed-steps p a { color: var(--primary); }
.embed-steps .row { display: flex; gap: 8px; align-items: center; }
.embed-steps .row.end { justify-content: flex-end; }
.embed-steps input[type="url"], .embed-steps textarea, .field {
  width: 100%; border: 1px solid var(--line-strong); background: var(--ink);
}
.embed-steps input[type="url"] { height: 32px; padding: 0 10px; font-family: var(--mono); font-size: 13px; }
.embed-steps input[type="url"]:focus, .field:focus-within, .embed-steps textarea:focus {
  outline: 2px solid var(--primary); outline-offset: -1px;
}
.embed-steps input[type="url"].invalid { border-color: var(--danger); }
.field { display: flex; align-items: center; min-width: 0; height: 32px; padding: 0 10px; flex: 1; }
.field input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-family: var(--mono); font-size: 13px; }
.field .suffix { color: var(--faint); font-family: var(--mono); font-size: 13px; }
.options { display: flex; flex-wrap: wrap; gap: 6px 16px; font: 12.5px/1.3 var(--mono); }
.options label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.options input { accent-color: var(--violet); margin: 0; }
.embed-steps textarea {
  resize: vertical; padding: 8px 10px; font: 12px/1.5 var(--mono); color: var(--text); white-space: pre-wrap; word-break: break-all;
}
.note.warn { color: var(--warn); }

/* ---- Video dialog ------------------------------------------------------- */
#video-dialog {
  width: min(480px, calc(100vw - 32px)); padding: 0;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: 0 24px 64px var(--shadow);
}
#video-dialog::backdrop { background: var(--backdrop); }
.video-body { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.video-fields { display: flex; flex-wrap: wrap; gap: 12px 16px; }
.video-fields label { display: flex; flex-direction: column; gap: 6px; font: 600 12px/1.3 var(--mono); color: var(--muted); }
.video-meta { margin: 0; color: var(--text); font: 13px/1.4 var(--mono); }
#video-progress { width: 100%; height: 6px; appearance: none; border: 0; background: var(--muted-bg); }
#video-progress::-webkit-progress-bar { background: var(--muted-bg); }
#video-progress::-webkit-progress-value { background: var(--violet); }
#video-progress::-moz-progress-bar { background: var(--violet); }
.video-body .row { display: flex; gap: 8px; align-items: center; }
.video-body .row.end { justify-content: flex-end; }
.video-body .note { font-size: 13px; }

/* Error lines in the editor. */
.monaco-editor .gaanim-error-line { background: var(--error-line); }
.monaco-editor .gaanim-error-glyph { background: var(--danger); width: 4px !important; margin-left: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  :is(button.primary, button.ghost):hover:not(:disabled) { transform: none; }
}

/* ---- Narrow screens: editor above, player and panel below. -------------- */
@media (max-width: 860px) {
  .embed-body { grid-template-columns: 1fr; padding: 16px; }
  /* The page scrolls: the layout grows with the player and the panel
     instead of squeezing them into what the editor leaves. */
  body { overflow: visible; height: auto; min-height: 100%; grid-template-rows: auto auto auto; }
  #layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; }
  #layout > .editor-pane { grid-area: 1 / 1; }
  #layout > .side { grid-area: 2 / 1; }
  .explorer {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 35; width: min(300px, 86vw);
    box-shadow: 24px 0 64px var(--shadow); display: none;
  }
  body.explorer-open .explorer { display: flex; }
  .splitter.vertical { display: none; }
  .side { grid-template-rows: auto 6px 40vh; }
  /* Not stretched: a stretched grid item ignores its aspect ratio, and the
     player's row collapsed under the console. */
  .player-wrap { aspect-ratio: 16 / 9; align-self: start; }
  .brand .product { display: none; }
  /* What leaves the playground wraps to a second row when it must; the run
     controls stay next to the brand. */
  .bar { flex-wrap: wrap; row-gap: 6px; }
  /* While a run goes, Detener takes Ejecutar's place. */
  #stop:not([hidden]) ~ #run { display: none; }
}
@media (max-width: 420px) {
  #run span { display: none; }
}
