/* LabBlocks editor chrome: the menu bar, tabs, side cards, menus and dialogs around the block
   editor. The block editor itself is scratch-blocks and styles itself. Two modes:
   html[data-mode="default"] (light) and html[data-mode="dark"].

   Layout: one column of menu bar over the editor and a side pane of cards. Below 900px wide the
   side pane becomes a drawer (opened from the "Project" tab); below 700px and 560px the menu bar
   folds its search and labels away so nothing overlaps. */

:root {
  --bg: #EDF2F4;                  /* page */
  --surface: #FFFFFF;             /* cards, editor, dialogs */
  --surface-2: #F5F8F9;
  --surface-3: #E3EAED;           /* hovers, quiet chips */
  --line: rgba(22, 46, 58, 0.16);
  --line-soft: rgba(22, 46, 58, 0.09);
  --text: #26343E;
  --text-soft: rgba(38, 52, 62, 0.72);
  --brand: #0F7C8C;               /* a deep lab teal */
  --brand-dark: #0B6371;
  --brand-tint: hsla(188, 80%, 38%, 0.14);
  --brand-tint-strong: hsla(188, 80%, 38%, 0.28);
  --accent-text: #0B6371;         /* brand-coloured text on a surface */
  --ok: #167A4A;
  --ok-bg: rgba(22, 122, 74, 0.12);
  --warn: #A94F00;
  --warn-bg: #FFF3E3;
  --warn-line: rgba(217, 119, 6, 0.5);
  --bad: #C2372F;
  --input-bg: #FFFFFF;
  --overlay: rgba(8, 24, 30, 0.55);
  --shadow-1: 0 1px 2px rgba(15, 35, 45, 0.07);
  --shadow-2: 0 8px 24px rgba(15, 35, 45, 0.16);
  --shadow-3: 0 18px 50px rgba(8, 24, 30, 0.32);
  --r-s: 8px;
  --r-m: 12px;
  --r-l: 16px;
  --gap: 0.75rem;
  --bar-h: 3.25rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

html[data-mode="dark"] {
  --bg: #0C1012;
  --surface: #151A1D;
  --surface-2: #1B2226;
  --surface-3: #263036;
  --line: rgba(255, 255, 255, 0.16);
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #E4EBEE;
  --text-soft: rgba(228, 235, 238, 0.72);
  --brand: #0E6E7C;
  --brand-dark: #0A5762;
  --brand-tint: rgba(34, 190, 210, 0.16);
  --brand-tint-strong: rgba(34, 190, 210, 0.34);
  --accent-text: #5ED4E4;
  --ok: #4FDB9C;
  --ok-bg: rgba(79, 219, 156, 0.14);
  --warn: #FFB870;
  --warn-bg: #33240F;
  --warn-line: rgba(255, 184, 112, 0.5);
  --bad: #FF8A80;
  --input-bg: #1B2226;
  --overlay: rgba(2, 8, 10, 0.72);
  --shadow-1: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible, [role="menuitem"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-3); padding: 0.05em 0.35em; border-radius: 5px; }
.muted { opacity: 0.75; }

#gui { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ------------------------------------------------------------------ menu bar */

.menu-bar {
  position: relative; z-index: 90;
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  height: var(--bar-h); flex: none;
  padding: 0 0.75rem;
  background: var(--brand); color: #fff;
  font-size: 0.8rem; font-weight: 600;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}
.menu-bar__main, .menu-bar__side { display: flex; align-items: center; gap: 0.25rem; min-width: 0; }
.menu-bar__main { flex: 1 1 auto; }
.menu-bar__side { flex: none; gap: 0.5rem; }
.menu-bar__brand { display: flex; align-items: center; gap: 0.5rem; margin-right: 0.5rem; user-select: none; flex: none; }
.menu-bar__logo { height: 1.5rem; width: auto; }
.menu-bar__name { font-size: 1.05rem; font-weight: 700; letter-spacing: 0.01em; }
.menu-bar__item-group { display: flex; align-items: center; gap: 0.15rem; flex: none; }
.menu-bar__item {
  display: flex; align-items: center; gap: 0.4rem;
  height: 2.15rem; padding: 0 0.7rem;
  border: none; border-radius: var(--r-s); background: none; color: #fff;
  font-weight: 600; font-size: 0.8rem; cursor: pointer; white-space: nowrap;
}
.menu-bar__item:hover, .menu-bar__item[aria-expanded="true"] { background: rgba(255, 255, 255, 0.16); }
.menu-bar__icon { width: 1.1rem; height: 1.1rem; }
.menu-bar__caret { width: 0.55rem; height: 0.55rem; opacity: 0.85; }
.menu-bar__divider { width: 1px; height: 1.5rem; background: rgba(255, 255, 255, 0.28); margin: 0 0.5rem; flex: none; }
.menu-bar__title {
  flex: 0 1 15rem; min-width: 5rem;
  height: 2.15rem; padding: 0 0.7rem;
  border: 1px solid transparent; border-radius: var(--r-s);
  background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 600; font-size: 0.8rem;
  text-overflow: ellipsis;
}
.menu-bar__title:hover { background: rgba(255, 255, 255, 0.24); }
.menu-bar__title:focus { outline: none; background: #fff; color: #26343E; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }
.menu-bar__saved { margin-left: 0.6rem; font-weight: 400; opacity: 0.85; white-space: nowrap; }

.menu-bar__search {
  position: relative;
  display: flex; align-items: center; gap: 0.4rem;
  height: 2.15rem; width: 14rem; padding: 0 0.7rem;
  background: rgba(255, 255, 255, 0.16); border-radius: 999px;
}
.menu-bar__search:focus-within { background: #fff; color: #26343E; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }
.menu-bar__search svg { width: 1rem; height: 1rem; flex: none; }
.menu-bar__search input { flex: 1; min-width: 0; border: none; background: none; outline: none; font-weight: 600; font-size: 0.8rem; }
.menu-bar__search input::placeholder { color: inherit; opacity: 0.85; }
.menu-bar__search input::-webkit-search-cancel-button { display: none; }

.menu-bar__build {
  display: flex; align-items: center; gap: 0.45rem;
  height: 2.15rem; padding: 0 1rem;
  border: none; border-radius: var(--r-s);
  background: #fff; color: var(--brand-dark); font-weight: 700; font-size: 0.8rem;
  cursor: pointer; white-space: nowrap;
}
.menu-bar__build:hover { background: #E4F5F7; }
.menu-bar__build svg { width: 1.05rem; height: 1.05rem; flex: none; }
.menu-bar__build[disabled] { opacity: 0.65; cursor: progress; }

/* dropdown menus */
.menu {
  position: absolute; top: calc(var(--bar-h) - 0.25rem);
  min-width: 13rem; max-width: calc(100vw - 1rem);
  margin: 0; padding: 0.35rem; list-style: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-m);
  box-shadow: var(--shadow-2);
  z-index: 95;
}
.menu__item {
  display: flex; align-items: center; gap: 0.6rem;
  min-height: 2.15rem; padding: 0.3rem 0.65rem; border-radius: 8px;
  font-size: 0.82rem; font-weight: 500; white-space: nowrap; cursor: pointer; user-select: none;
}
.menu__item:hover, .menu__item:focus { background: var(--brand-tint); outline: none; }
.menu__item[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.menu__section { margin-top: 0.3rem; position: relative; }
.menu__section::before { content: ""; position: absolute; left: 0.5rem; right: 0.5rem; top: -0.2rem; height: 1px; background: var(--line-soft); }
.menu__heading { padding: 0.5rem 0.65rem 0.2rem; font-size: 0.66rem; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.menu__heading:not(:first-child) { margin-top: 0.3rem; }
.menu__icon { width: 1.1rem; height: 1.1rem; flex: none; color: var(--accent-text); }
.menu__label { flex: 1; }
.menu__check { width: 1rem; height: 1rem; flex: none; color: var(--accent-text); font-weight: 700; text-align: center; line-height: 1rem; }
.menu__item[aria-checked="true"] .menu__check::before { content: "✓"; }
.menu__item[aria-checked="true"] { background: var(--brand-tint); }

/* ---------------------------------------------------------------------- body */

.gui__body {
  flex: 1; min-height: 0;
  display: flex; gap: var(--gap);
  padding: 0 var(--gap) var(--gap);
}
.editor-wrapper { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.tabs { display: flex; align-items: center; gap: 0.25rem; height: 3rem; flex: none; }
.tab, .tab-action {
  display: flex; align-items: center; gap: 0.45rem;
  height: 2.1rem; padding: 0 0.95rem;
  border: none; border-radius: 999px;
  background: none; color: var(--text-soft);
  font-size: 0.82rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab svg, .tab-action svg { width: 1.1rem; height: 1.1rem; flex: none; }
.tab:hover, .tab-action:hover { background: var(--surface-3); color: var(--text); }
.tab.is-selected { background: var(--brand); color: #fff; }
.tab-action { display: none; margin-left: auto; }
body.pane-open .tab-action { background: var(--brand-tint); color: var(--accent-text); }

.tab-panels { position: relative; flex: 1; min-height: 0; }
.blocks, .help-panel {
  position: absolute; inset: 0;
  border: 1px solid var(--line); border-radius: var(--r-m);
  background: var(--surface);
  overflow: hidden;
}
.help-panel { overflow-y: auto; padding: 1.5rem 2rem 2rem; line-height: 1.6; font-size: 0.88rem; }
.help-panel h2 { margin: 0 0 0.75rem; font-size: 1.2rem; color: var(--accent-text); }
.help-panel h3 { margin: 1.35rem 0 0.3rem; font-size: 0.98rem; }
.help-panel p { margin: 0; max-width: 46rem; }
.help-panel kbd { font: inherit; font-size: 0.78rem; padding: 0.05rem 0.4rem; border-radius: 5px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--surface-2); }

/* scratch-blocks inside the blocks area */
.blocks .injectionDiv { position: absolute; inset: 0; }
.blocks .blocklyMainBackground { stroke: none; }
.blocks .blocklyToolboxDiv, .blocks .blocklyToolbox {
  border-right: 1px solid var(--line-soft);
  box-sizing: content-box;
  -ms-overflow-style: none;
}
.blocks .blocklyToolboxDiv::-webkit-scrollbar, .blocks .blocklyToolbox::-webkit-scrollbar { display: none; }
.blocks .blocklyFlyout { border-right: 1px solid var(--line-soft); box-sizing: content-box; }
.blocks .scratchCategoryMenuItemLabel { font-size: 0.65rem; }
.blocks .blocklyMinimalBody { min-width: auto; min-height: auto; }

/* ----------------------------------------------------------- right-hand pane */

.side-pane {
  width: 22rem; flex: none;
  display: flex; flex-direction: column; gap: var(--gap);
  min-height: 0; overflow-y: auto;
  padding-bottom: 0.1rem;
}
.side-pane__bar { display: none; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0 0.15rem; flex: none; }
.side-pane__title { font-size: 0.9rem; font-weight: 700; }
.side-pane__close { width: 2rem; height: 2rem; border: none; border-radius: 50%; background: var(--surface-3); font-size: 1.15rem; line-height: 1; cursor: pointer; }
.side-pane__close:hover { background: var(--line); }
.pane-backdrop { display: none; }

.stage-card, .info-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-1);
  flex: none;
}
.stage-card { display: flex; flex-direction: column; min-height: 16rem; }
.stage-card__header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
}
.stage-card__title { margin: 0; font-size: 0.9rem; font-weight: 700; }
.green-flag {
  width: 2.1rem; height: 2.1rem; padding: 0.3rem;
  border: none; border-radius: var(--r-s); background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.green-flag:hover { background: var(--ok-bg); }
.green-flag.is-active { background: var(--brand-tint-strong); }
.build-state {
  margin-left: auto; padding: 0.2rem 0.65rem; border-radius: 999px;
  font-size: 0.7rem; font-weight: 700; background: var(--surface-3); color: var(--text-soft);
}
.build-state[data-state="busy"] { background: var(--brand-tint); color: var(--accent-text); }
.build-state[data-state="ok"] { background: var(--ok-bg); color: var(--ok); }
.build-state[data-state="error"] { background: var(--warn-bg); color: var(--warn); }

.stage-card__body { flex: 1; padding: 0.85rem; overflow-y: auto; font-size: 0.82rem; line-height: 1.5; }
.build-empty p { margin: 0 0 0.4rem; }
.build-result { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.7rem 0.8rem; border-radius: var(--r-s); background: var(--ok-bg); }
.build-result__icon { width: 1.3rem; height: 1.3rem; flex: none; color: var(--ok); }
.build-result b { display: block; }
.issues { list-style: none; margin: 0.5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.issue {
  display: flex; gap: 0.5rem; align-items: flex-start;
  width: 100%; text-align: left; padding: 0.55rem 0.7rem;
  border: 1px solid var(--warn-line); border-radius: var(--r-s);
  background: var(--warn-bg); cursor: pointer;
}
.issue:hover { box-shadow: 0 0 0 3px var(--warn-line); }
.issue__icon { width: 1rem; height: 1rem; flex: none; margin-top: 0.1rem; color: var(--warn); }
.issue__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.issue__code { display: block; font-size: 0.65rem; opacity: 0.7; font-weight: 700; }
.issue__go { font-size: 0.7rem; font-weight: 700; color: var(--accent-text); white-space: nowrap; }

.info-card { padding: 0.85rem; }
.info-card__title { margin: 0 0 0.6rem; font-size: 0.9rem; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.72rem; font-weight: 700; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  width: 100%; height: 2.15rem; padding: 0 0.65rem;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--input-bg); font-size: 0.8rem; font-weight: 400;
}
.field textarea { height: auto; padding: 0.45rem 0.65rem; resize: vertical; min-height: 2.8rem; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-strong); }
.info-advanced { margin-top: 0.7rem; font-size: 0.78rem; }
.info-advanced summary { cursor: pointer; font-weight: 700; margin-bottom: 0.5rem; }
.info-card__stats { margin: 0.75rem 0 0; font-size: 0.72rem; color: var(--text-soft); }

/* ------------------------------------------------------------ alerts (toasts) */

.alerts {
  position: fixed; top: calc(var(--bar-h) + 0.6rem); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 1.5rem);
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem; z-index: 200; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.6rem 1rem; border-radius: var(--r-s);
  font-size: 0.82rem; font-weight: 600;
  background: var(--surface); color: var(--ok); border: 1px solid var(--ok);
  box-shadow: var(--shadow-2); pointer-events: auto;
}
.toast--error, .toast--warning { color: var(--warn); border-color: var(--warn-line); background: var(--warn-bg); }
.toast__icon { width: 1.1rem; height: 1.1rem; flex: none; }

/* -------------------------------------------------------------------- modals */

.sb-modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 0.75rem; overflow-y: auto;
}
.sb-modal {
  display: flex; flex-direction: column;
  width: 26rem; max-width: 100%; max-height: calc(100vh - 1.5rem); max-height: calc(100dvh - 1.5rem);
  margin: auto;
  border: 1px solid var(--line); border-radius: var(--r-l);
  overflow: hidden; color: var(--text); user-select: none;
  background: var(--surface); box-shadow: var(--shadow-3);
}
.sb-modal--procedure { width: 44rem; }
.sb-modal__header {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.85rem 1rem 0.85rem 1.5rem;
  border-bottom: 1px solid var(--line-soft);
}
.sb-modal__title { font-size: 1.05rem; font-weight: 700; }
.sb-modal__close {
  flex: none; width: 2rem; height: 2rem; border-radius: 50%; border: none;
  background: none; color: var(--text-soft); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.sb-modal__close:hover { background: var(--surface-3); color: var(--text); }
.sb-modal__body { flex: 1; min-height: 0; overflow-y: auto; padding: 1.4rem 1.5rem 1.5rem; }
.sb-prompt__label { display: block; font-weight: 600; margin: 0 0 0.6rem; font-size: 0.85rem; }
.sb-prompt__message { margin: 0 0 1.4rem; font-size: 0.9rem; line-height: 1.55; }
.sb-prompt__input {
  width: 100%; height: 2.75rem; margin-bottom: 1.3rem; padding: 0 0.9rem;
  border: 1px solid var(--line); border-radius: var(--r-s);
  background: var(--input-bg); font-size: 0.88rem; user-select: text;
}
.sb-prompt__input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-strong); }
select.sb-prompt__input { padding: 0 0.6rem; cursor: pointer; color: inherit; }
textarea.sb-prompt__input { height: 4.5rem; padding: 0.6rem 0.9rem; line-height: 1.45; resize: vertical; font-family: inherit; }
.sb-prompt__row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.sb-prompt__row--3 { grid-template-columns: 1fr 1fr 1fr; }
textarea.sb-prompt__input--tall { height: 7rem; }
.sb-prompt__input--tight { margin-bottom: 0.4rem; }
.sb-prompt__about { margin: 0 0 1.2rem; font-size: 0.8rem; color: var(--text-soft); }
.sb-prompt__hint { margin: -0.9rem 0 1.2rem; font-size: 0.76rem; color: var(--text-soft); }
.sb-prompt__hint[data-slot="error"] { color: var(--bad); margin: 0 0 1rem; }
.sb-prompt__hint[data-slot="error"]:empty { display: none; }
.sb-prompt__hint--below { margin: 0 0 1.2rem 1.45rem; }
.sb-prompt__hint code { font-size: 0.95em; }
.sb-prompt__types { border: none; margin: 0 0 1.4rem; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem 1rem; font-size: 0.85rem; }
.sb-prompt__types legend { padding: 0; margin-bottom: 0.5rem; }
.sb-radio { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.sb-radio input { margin: 3px; accent-color: var(--brand); }
.sb-modal__buttons { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.5rem; }
.sb-btn {
  padding: 0.6rem 1.1rem; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 0.85rem; cursor: pointer;
}
.sb-btn:hover { background: var(--surface-3); }
.sb-btn--ok { background: var(--brand); border-color: var(--brand); color: #fff; }
.sb-btn--ok:hover { background: var(--brand-dark); }

/* "Make a Block" */
.proc-editor__workspace { position: relative; height: 200px; background: var(--bg); border-radius: var(--r-s); overflow: hidden; }
.proc-editor__workspace .injectionDiv { position: absolute; inset: 0; }
.proc-editor__workspace .blocklySvg { background-color: var(--bg); }
.proc-editor__workspace .blocklyMainBackground { fill: var(--bg) !important; stroke: none; }
.proc-editor__options { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.proc-card {
  flex: 1 1 7rem; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 1rem 0.5rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-m);
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; text-align: center;
}
.proc-card:hover, .proc-card:focus-visible { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint-strong); outline: none; }
.proc-card__icon { height: 48px; width: auto; margin-bottom: 0.5rem; }
.proc-card__title { font-weight: 700; font-size: 0.8rem; }
.proc-card__sub { font-size: 0.75rem; color: var(--text-soft); }
.proc-editor__hint { margin-top: 1rem; font-size: 0.78rem; color: var(--text-soft); }
.proc-editor__error { margin-top: 0.75rem; padding: 0.55rem 0.75rem; border-radius: var(--r-s); background: var(--warn-bg); border: 1px solid var(--warn-line); color: var(--warn); font-size: 0.8rem; font-weight: 700; }
.sb-modal--procedure .sb-modal__buttons { margin-top: 1rem; }
.proc-card--other { cursor: default; gap: 0.3rem; }
.proc-card__select {
  width: 100%; max-width: 8.5rem; font: inherit; font-size: 0.72rem; padding: 0.2rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); color: inherit;
}
.proc-card__add {
  font: inherit; font-size: 0.74rem; font-weight: 700; color: #fff; background: var(--brand);
  border: none; border-radius: 6px; padding: 0.25rem 0.85rem; cursor: pointer;
}
.proc-card__add:hover { background: var(--brand-dark); }

/* ---- Config card and Player settings card ---- */
.info-card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.info-card__head .info-card__title { margin: 0; }
.info-card__hint { margin: 0 0 0.65rem; font-size: 0.74rem; line-height: 1.45; color: var(--text-soft); }
.info-card__hint code { font-size: 0.95em; }
.small-btn {
  border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
  color: var(--accent-text); font: inherit; font-size: 0.74rem; font-weight: 700; padding: 0.3rem 0.65rem; cursor: pointer; white-space: nowrap;
}
.small-btn:hover { background: var(--brand-tint); }
.config-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.config-list__empty { font-size: 0.76rem; color: var(--text-soft); }
.config-item {
  display: flex; align-items: flex-start; gap: 0.4rem; padding: 0.5rem 0.6rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--input-bg);
}
.config-item__main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.45rem; font-size: 0.8rem; }
.config-item__name { font-weight: 700; overflow-wrap: anywhere; }
.config-item__type { font-size: 0.68rem; padding: 0.05rem 0.45rem; border-radius: 999px; background: var(--brand-tint); color: var(--accent-text); }
.config-item__default { font-family: var(--mono); font-size: 0.72rem; color: var(--text-soft); overflow-wrap: anywhere; }
.config-item__desc { flex-basis: 100%; font-size: 0.73rem; color: var(--text-soft); }
.config-item__actions { display: flex; gap: 0.1rem; flex: none; }
.icon-btn { border: none; background: none; color: inherit; cursor: pointer; font-size: 0.85rem; padding: 0.2rem 0.35rem; border-radius: 6px; opacity: 0.7; }
.icon-btn:hover { opacity: 1; background: var(--brand-tint); }
.icon-btn:disabled { opacity: 0.25; cursor: default; background: none; }

/* ---- File menu dialogs: examples, recent projects, share link ---- */
.sb-modal--examples { width: 34rem; }
.example-list { display: grid; gap: 0.5rem; margin-bottom: 1.25rem; max-height: min(60vh, 28rem); overflow-y: auto; }
.example-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.15rem 0.6rem; align-items: start;
  padding: 0.75rem 0.85rem; border: 1px solid var(--line); border-radius: var(--r-m); cursor: pointer;
}
.example-card:hover { background: var(--brand-tint); }
.example-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-tint-strong); }
.example-card input { grid-row: span 3; margin: 0.2rem 0 0; accent-color: var(--brand); }
.example-card__name { font-weight: 700; font-size: 0.92rem; }
.example-card__desc { font-size: 0.78rem; line-height: 1.45; color: var(--text-soft); }
.example-card__shows { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.2rem; }
.example-card__shows span { font-size: 0.68rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--brand-tint); color: var(--accent-text); }
textarea.share-link { height: 6.5rem; font-family: var(--mono); font-size: 0.72rem; word-break: break-all; margin-bottom: 0.6rem; }
.share-hint { margin: 0 0 1.25rem; }
.recent-card { position: relative; }
.recent-card__now { font-size: 0.65rem; font-weight: 400; padding: 0.05rem 0.5rem; margin-left: 0.4rem; border-radius: 999px; background: var(--brand); color: #fff; }
.recent-card input:disabled { visibility: hidden; }
.recent-card__delete { position: absolute; top: 0.4rem; right: 0.4rem; }
.recent-empty { margin: 1rem 0; font-size: 0.85rem; color: var(--text-soft); }

/* ☁ "Keep after the server restarts" in New Variable */
.sb-check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; cursor: pointer; margin: -0.5rem 0 0.35rem; }
.sb-check input { margin: 0; accent-color: var(--brand); width: 1rem; height: 1rem; }
.sb-check.is-disabled { opacity: 0.5; cursor: default; }

/* the greyed-out "Empty" stand-in in the Player Settings palette (no settings yet) */
.lbFlyoutButtonEmpty { opacity: 0.45; pointer-events: none; }

/* ---- Welcome screen ---- */
.sb-modal--welcome { width: 38rem; }
.welcome-lead { margin: 0 0 1rem; font-size: 1rem; line-height: 1.55; }
.welcome-steps { margin: 0 0 1rem; padding-left: 1.3rem; font-size: 0.88rem; line-height: 1.55; }
.welcome-steps li { margin-bottom: 0.4rem; }
.welcome-tip { margin: 0 0 1rem; font-size: 0.82rem; line-height: 1.5; color: var(--text-soft); }
.welcome-note { margin-bottom: 1.25rem; padding: 0.75rem 0.95rem; border-left: 4px solid var(--warn); border-radius: var(--r-s); background: var(--warn-bg); color: var(--warn); font-size: 0.82rem; line-height: 1.5; }
.welcome-note b { color: inherit; }
.welcome-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.welcome-action { display: grid; gap: 0.15rem; padding: 0.75rem 0.95rem; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.welcome-action:hover, .welcome-action:focus-visible { border-color: var(--brand); background: var(--brand-tint); outline: none; }
.welcome-action--primary { border-color: var(--brand); background: var(--brand); color: #fff; }
.welcome-action--primary:hover, .welcome-action--primary:focus-visible { background: var(--brand-dark); }
.welcome-action__label { font-size: 0.95rem; font-weight: 700; }
.welcome-action__hint { font-size: 0.75rem; opacity: 0.85; }
.welcome-legal { margin: 1.1rem 0 0; padding-top: 0.85rem; border-top: 1px solid var(--line-soft); font-size: 0.7rem; line-height: 1.55; color: var(--text-soft); }
.welcome-legal a { color: var(--accent-text); font-weight: 700; }

/* ------------------------------------------------------------- small windows */

/* medium: less in the menu bar, the editor keeps the room */
@media (max-width: 1100px) {
  .menu-bar__saved { display: none; }
  .menu-bar__search { width: 12rem; }
  .side-pane { width: 20rem; }
}

/* the side pane becomes a drawer; the "Project" tab opens it */
@media (max-width: 900px) {
  .menu-bar__name { display: none; }
  .menu-bar__title { flex-basis: 11rem; }
  .tab-action { display: flex; }
  .side-pane {
    position: fixed; z-index: 70; top: var(--bar-h); right: 0; bottom: 0;
    width: min(24rem, 100vw); padding: var(--gap);
    background: var(--bg); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(8, 24, 30, 0.22);
    transform: translateX(105%); visibility: hidden;
  }
  body.pane-animate .side-pane { transition: transform 0.2s ease, visibility 0s linear 0.2s; }
  body.pane-open .side-pane { transform: none; visibility: visible; }
  body.pane-animate.pane-open .side-pane { transition: transform 0.2s ease; }
  .side-pane__bar { display: flex; }
  body.pane-open .pane-backdrop { display: block; position: fixed; z-index: 65; top: var(--bar-h); left: 0; right: 0; bottom: 0; background: var(--overlay); }
  .help-panel { padding: 1.25rem 1.25rem 1.75rem; }
}

/* small: the search folds into an icon that opens when tapped */
@media (max-width: 700px) {
  .menu-bar { padding: 0 0.5rem; gap: 0.25rem; }
  .menu-bar__item { padding: 0 0.55rem; }
  .menu-bar__title { flex-basis: 8rem; min-width: 4rem; }
  .menu-bar__search { width: 2.15rem; padding: 0; justify-content: center; gap: 0; }
  .menu-bar__search input { width: 0; flex: none; padding: 0; }
  .menu-bar__search:focus-within {
    position: fixed; z-index: 96; top: 0.55rem; right: 0.5rem; left: 0.5rem; width: auto;
    padding: 0 0.7rem; justify-content: flex-start; gap: 0.4rem;
  }
  .menu-bar__search:focus-within input { width: auto; flex: 1; }
  .sb-modal__body { padding: 1.2rem 1.2rem 1.3rem; }
  .sb-modal__header { padding-left: 1.2rem; }
}

/* phone sized: names and labels give way to icons */
@media (max-width: 560px) {
  .menu-bar__divider, .menu-bar__title { display: none; }
  .menu-bar__brand { margin-right: 0; }
  .menu-bar__item[data-menu="settings"] > span { display: none; }
  .menu-bar__item[data-menu="settings"] .menu-bar__caret { display: none; }
  .menu-bar__build { width: 2.15rem; padding: 0; justify-content: center; }
  .menu-bar__build > span { display: none; }
  .tabs { height: 2.75rem; }
  .gui__body { padding: 0 0.5rem 0.5rem; }
  .info-grid { grid-template-columns: 1fr; }
  .sb-prompt__row, .sb-prompt__row--3, .sb-prompt__types { grid-template-columns: 1fr; }
  .welcome-actions { grid-template-columns: 1fr; }
  .sb-modal-overlay { padding: 0.4rem; }
  .sb-modal { max-height: calc(100vh - 0.8rem); max-height: calc(100dvh - 0.8rem); }
  .example-list { max-height: 45vh; }
}

/* short windows: the menu dropdowns and dialogs scroll instead of running off */
@media (max-height: 520px) {
  .menu { max-height: calc(100dvh - var(--bar-h) - 0.5rem); overflow-y: auto; }
  .welcome-lead { font-size: 0.92rem; }
}

@media (prefers-reduced-motion: reduce) {
  body.pane-animate .side-pane { transition: none; }
}
