:root {
  --bg: #23282f;
  --panel: #2e343d;
  --panel-2: #38404a;
  --panel-3: #424b57;
  --line: #20252b;
  --text: #d9dde4;
  --muted: #8a93a3;
  --faint: #5d6574;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --code-bg: #0b0d11; /* the code editor: near black, matching the Monaco "bsb-black" theme in codedock.js */
  --orange: #f97316;
  --danger: #ef4444;
  --radius: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
}
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); }
[hidden] { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  grid-template-rows: 42px 1fr;
  grid-template-areas: "top top top" "left stage right";
  height: 100vh;
}

/* ---------- toolbar ---------- */
.toolbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  -webkit-app-region: no-drag;
}
.tb-group { display: flex; gap: 2px; padding-right: 10px; border-right: 1px solid var(--line); }
.tb-group:last-child { border-right: 0; padding-right: 0; }
.tb-group.seg { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px; }
.tb-center { flex: 1; display: flex; justify-content: center; align-items: center; gap: 10px; }
.size-label { color: var(--muted); font-size: 12px; min-width: 90px; font-variant-numeric: tabular-nums; }
.tb-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; min-width: 30px; padding: 0 7px;
  justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--text); cursor: pointer;
}
.tb-btn:hover:not(:disabled) { background: var(--panel-3); }
.tb-btn:disabled { opacity: 0.35; cursor: default; }
.tb-btn.active { background: var(--accent-soft); color: #fff; }
.tb-btn.text { padding: 0 10px; }
.tb-btn.primary { background: var(--accent); color: #fff; }
.tb-btn.primary:hover { background: #2f6fde; }

/* ---------- panels ---------- */
.panel { background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.panel.left { grid-area: left; border-right: 1px solid var(--line); }
.panel.right { grid-area: right; border-left: 1px solid var(--line); }
.pane { display: flex; flex-direction: column; min-height: 0; }
.lib-pane { flex: 1.6; }
.pages-pane { flex: 1; border-top: 2px solid var(--line); }
.props-pane { flex: 1.6; }
.pages-pane .pane-body { padding-bottom: 6px; }
.layers-pane { flex: 1; border-top: 2px solid var(--line); }
.pane-head {
  padding: 9px 12px 7px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.pane-body { overflow: auto; overflow-x: hidden; min-height: 0; flex: 1; }
/* thin scrollbars everywhere in the app chrome */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track, *::-webkit-scrollbar-corner { background: transparent; }
*::-webkit-scrollbar-thumb { background: #4a5260; border-radius: 6px; }
*::-webkit-scrollbar-thumb:hover { background: #5f6a7c; }

.search { padding: 0 10px 8px; display: flex; gap: 6px; }
.search input { flex: 1; min-width: 0; }
.search .btn-sm { padding: 0 9px; font-weight: 700; }
.search input {
  width: 100%; height: 30px; padding: 0 10px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none;
}
.search input:focus { border-color: var(--accent); }

/* library */
.lib-cat { padding: 0 8px 6px; }
.lib-cat-head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  padding: 6px 4px; background: none; border: 0; cursor: pointer;
  color: var(--muted); font-size: 12px; font-weight: 600;
}
.lib-cat-head:hover { color: var(--text); }
.chev { display: inline-block; transition: transform 0.15s; font-size: 10px; }
.lib-cat.closed .chev { transform: rotate(-90deg); }
.lib-cat.closed .lib-grid { display: none; }
.lib-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px; }
.lib-item {
  min-width: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 7px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid transparent;
  cursor: grab;
}
.lib-item:hover { border-color: var(--accent); background: var(--panel-3); }
.lib-item:active { cursor: grabbing; }
.lib-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-icon {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 20px; border-radius: 4px;
  background: #2f3542; color: #9ec1ff;
  font: 700 9.5px/1 ui-monospace, Consolas, monospace; letter-spacing: 0.02em;
}
.lib-icon.big { width: 38px; height: 28px; font-size: 11px; }

/* layers */
.layer-row {
  display: flex; align-items: center; gap: 6px;
  height: 26px; padding-right: 8px;
  cursor: pointer; white-space: nowrap;
  border-top: 2px solid transparent; border-bottom: 2px solid transparent;
}
.layer-row:hover, .layer-row.hover { background: var(--panel-2); }
.layer-row.selected { background: var(--accent-soft); color: #fff; }
.layer-row.drop-before { border-top-color: var(--orange); }
.layer-row.drop-after { border-bottom-color: var(--orange); }
.layer-row.drop-inside { background: rgba(249, 115, 22, 0.18); }
.caret { width: 14px; text-align: center; color: var(--muted); font-size: 10px; transition: transform 0.12s; flex: none; }
.caret.closed { transform: rotate(-90deg); }
.caret.none { visibility: hidden; }
.layer-icon { font: 700 8.5px/1 ui-monospace, Consolas, monospace; color: #9ec1ff; width: 24px; flex: none; }
.layer-name { flex: none; }
.layer-hint { color: var(--faint); overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* ---------- code dock ---------- */
.dock { display: flex; flex-direction: column; min-height: 0; border-top: 1px solid var(--line); background: var(--panel); }
.dock-head { display: flex; align-items: center; gap: 10px; padding: 0 8px; border-bottom: 1px solid var(--line); }
.dock-head .tab { padding: 6px 12px; }
.dock-note { color: var(--faint); font-size: 11.5px; }
.dock .code-view { border-radius: 0; }
.status-row { display: flex; align-items: center; background: var(--panel); border-top: 1px solid var(--line); }
.status-row .breadcrumb { flex: 1; min-width: 0; border-top: 0; }
.dock-toggle { height: 26px; margin-right: 6px; font-size: 12px; }

/* ---------- properties filter ---------- */
.props-filter { position: sticky; top: 0; z-index: 2; display: flex; gap: 4px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.props-filter input {
  flex: 1; min-width: 0; height: 29px; padding: 0 8px; user-select: text;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none;
}
.props-filter input:focus { border-color: var(--accent); }
.props-filter .btn-sm { padding: 0 9px; font-weight: 700; }

/* ---------- breakpoint bar ---------- */
.bp-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px; position: relative;
  height: 38px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.bp-group { display: flex; gap: 2px; padding: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
.bp-btn {
  display: flex; align-items: baseline; gap: 5px; height: 26px; padding: 0 10px;
  background: none; border: 0; border-radius: 4px; color: var(--muted); cursor: pointer;
}
.bp-btn b { font-size: 12px; font-weight: 700; }
.bp-btn i { font-style: normal; font-size: 10.5px; color: var(--faint); }
.bp-btn:hover { color: var(--text); background: var(--panel-3); }
.bp-btn.active { background: var(--accent); color: #fff; }
.bp-btn.active i { color: rgba(255, 255, 255, 0.75); }
.bp-bar .size-label { position: absolute; right: 12px; min-width: 0; }

/* ---------- stage ---------- */
.stage { grid-area: stage; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.canvas-wrap {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; justify-content: center;
  padding: 14px;
  background-image: radial-gradient(#1d2128 1px, transparent 1px);
  background-size: 16px 16px;
}
.frame-holder {
  height: 100%; max-width: 100%;
  transition: width 0.25s ease;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 0 0 1px #262b33, 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
#canvas { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.breadcrumb {
  display: flex; align-items: center; gap: 2px;
  height: 30px; padding: 0 10px; overflow: hidden; white-space: nowrap;
  background: var(--panel); border-top: 1px solid var(--line);
}
.crumb { background: none; border: 0; padding: 3px 6px; border-radius: 4px; color: var(--muted); cursor: pointer; }
.crumb:hover { background: var(--panel-3); color: var(--text); }
.crumb.active { color: #fff; background: var(--accent-soft); }
.crumb-sep { color: var(--faint); }

/* ---------- right panel ---------- */
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.tabs.inline { border: 0; padding: 0; }
.tab {
  background: none; border: 0; padding: 7px 12px; cursor: pointer;
  color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; border-bottom-color: var(--accent); }

.props { padding-bottom: 30px; }
.props-head { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); }
.props-titles { flex: 1; min-width: 0; }
.props-title { font-weight: 600; font-size: 14px; color: #fff; }
.props-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  display: grid; place-items: center; width: 28px; height: 28px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-3); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.psec { border-bottom: 1px solid var(--line); }
.psec summary {
  list-style: none; cursor: pointer; padding: 10px 12px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.psec summary::-webkit-details-marker { display: none; }
.psec summary::before { content: "▾"; display: inline-block; margin-right: 6px; transition: transform 0.12s; }
.psec:not([open]) summary::before { transform: rotate(-90deg); }
.psec-body { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 9px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { color: var(--muted); font-size: 12px; }
.field input[type="text"], .field select, .field textarea, .psec-body > input[type="text"], .util select {
  width: 100%; padding: 5px 8px; min-height: 29px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none;
  user-select: text;
}
.field textarea { resize: vertical; line-height: 1.45; }
.mono { font-family: ui-monospace, Consolas, monospace !important; font-size: 12px !important; }
.field input:focus, .field select:focus, .field textarea:focus, .psec-body > input:focus, .util select:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.img-field { display: flex; gap: 4px; }
.img-field input { flex: 1; min-width: 0; }
.btn-sm {
  padding: 0 10px; height: 29px; border-radius: var(--radius);
  background: var(--panel-3); border: 1px solid var(--line); cursor: pointer; white-space: nowrap;
}
.btn-sm:hover { border-color: var(--accent); }

.util-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.util { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.util select { min-height: 27px; padding: 3px 5px; font-size: 12px; }
.util select.set { border-color: rgba(59, 130, 246, 0.6); color: #fff; }
.hint { color: var(--faint); font-size: 11.5px; }
.hint.pad { padding: 8px 12px; }
.hint code { color: var(--muted); }

.styles-pane { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.css-editor {
  flex: 1; width: 100%; resize: none; border: 0; outline: none; padding: 12px;
  background: #15181d; color: #e6edf3;
  font: 12.5px/1.55 ui-monospace, Consolas, monospace; tab-size: 2; user-select: text;
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; z-index: 50; }
.modal-card {
  width: min(1000px, 92vw); height: min(720px, 86vh);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.spacer { flex: 1; }
.code-view {
  flex: 1; margin: 0; overflow: auto; padding: 14px 16px;
  background: #111317; color: #d6e2f0; border-radius: 0 0 10px 10px;
  font: 12.5px/1.55 ui-monospace, Consolas, monospace; user-select: text; white-space: pre;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 46px; transform: translate(-50%, 20px);
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border-radius: 8px;
  background: #2b313c; color: #fff; border: 1px solid #3a4250;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 60; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: var(--accent); border: 0; color: #fff; padding: 4px 10px; border-radius: 5px; cursor: pointer; }

/* ---------- pages ---------- */
.pane-head { display: flex; align-items: center; }
.head-btn {
  margin-left: auto; display: grid; place-items: center; width: 22px; height: 22px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; color: var(--text);
}
.head-btn:hover { border-color: var(--accent); color: #fff; }
.head-btn svg { width: 13px; height: 13px; }
.page-row {
  display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 8px 0 10px; cursor: pointer; white-space: nowrap;
}
.page-row:hover { background: var(--panel-2); }
.page-row.active { background: var(--accent-soft); color: #fff; }
.page-ico { width: 14px; text-align: center; color: #9ec1ff; flex: none; }
.page-name { flex: none; }
.page-title { color: var(--faint); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.page-actions { display: none; gap: 1px; flex: none; }
.page-row:hover .page-actions { display: flex; }
.page-row:hover .page-title { display: none; }
.page-actions button {
  display: grid; place-items: center; width: 22px; height: 22px; padding: 0;
  background: none; border: 0; border-radius: 4px; cursor: pointer; color: var(--muted);
}
.page-actions button:hover:not(:disabled) { background: var(--panel-3); color: #fff; }
.page-actions button.danger:hover:not(:disabled) { color: var(--danger); }
.page-actions button:disabled { opacity: 0.3; cursor: default; }
.page-row.renaming { background: var(--panel-2); }
.page-rename {
  flex: 1; min-width: 0; height: 22px; padding: 0 6px; user-select: text;
  background: var(--bg); border: 1px solid var(--accent); border-radius: 4px; outline: none;
}
.page-ext { color: var(--muted); }
.page-label {
  padding: 2px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text); font-size: 12px;
}

/* ---------- JavaScript tab ---------- */
.js-pane .css-editor { flex: 2; min-height: 120px; }
.js-pane .css-editor.small { flex: 1; min-height: 70px; }
.code-head {
  padding: 7px 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); background: var(--panel);
}
.code-head code, .code-head .muted { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--faint); margin-left: 6px; }

/* ---------- Bootstrap Studio-style chrome ---------- */
.toolbar { gap: 4px; padding: 0 6px; }
.toolbar .tb-group { border-right: 0; padding-right: 0; margin-right: 8px; }
.toolbar .tb-btn.text { height: 34px; font-weight: 600; font-size: 12px; padding: 0 10px; }
.pane-head { padding: 0 12px; height: 34px; font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: none; color: #fff; border-bottom: 1px solid var(--line); background: var(--panel); }
.tabs { padding: 0; height: 34px; background: var(--panel); }
.tab { font-size: 12px; padding: 0 14px; }
.doc-tabs { display: flex; align-items: flex-end; height: 30px; padding: 0; background: var(--bg); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.doc-tabs::-webkit-scrollbar { display: none; }
.doc-tab { display: flex; flex: none; align-items: center; gap: 7px; height: 30px; max-width: 220px; padding: 0 8px 0 14px; background: var(--bg); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; border-right: 1px solid var(--line); }
.doc-tab:hover { color: #fff; background: var(--panel-2); }
.doc-tab.active { background: var(--panel); color: #fff; box-shadow: inset 0 2px 0 var(--accent); }
.doc-tab-name { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-dirty { white-space: pre; font-size: 9px; color: var(--orange); }
.doc-close, .doc-add { flex: none; background: none; border: 0; color: inherit; cursor: pointer; border-radius: 4px; font-size: 15px; line-height: 1; padding: 2px 6px; }
.doc-close { opacity: 0; }
.doc-tab:hover .doc-close, .doc-tab.active .doc-close { opacity: .7; }
.doc-close:hover, .doc-add:hover { background: var(--panel-3); color: #fff; opacity: 1; }
.doc-add { height: 30px; padding: 0 12px; color: var(--muted); font-size: 17px; }
.bp-bar { height: 34px; justify-content: flex-start; padding: 0 10px; background: var(--panel-2); border-bottom: 0; }
.bp-bar .size-label { position: static; font-size: 11px; color: #cbd2dc; }
.bp-bar .spacer { flex: 1; }
.page-select { height: 26px; padding: 0 8px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); outline: none; }
.canvas-wrap { padding: 24px; background-image: none; }
.frame-holder { border-radius: 0; box-shadow: none; }
.status-row { background: var(--bg); border-top: 0; height: 26px; }
.dock-tab { align-self: flex-end; height: 24px; padding: 0 14px; background: var(--panel); color: #fff; border: 0; font-size: 12px; font-weight: 600; cursor: pointer; }
.dock-tab:hover { background: var(--panel-2); }
.status-row .breadcrumb { height: 26px; background: transparent; }
.psec summary, .code-head { color: #cfd5de; }

/* ---------- script files ---------- */
.js-pane { overflow-y: auto; }
.script-files { display: flex; flex-direction: column; flex: none; }
.script-bar { display: flex; gap: 4px; padding: 8px 12px 0; }
.script-bar select { flex: 1; min-width: 0; height: 29px; padding: 0 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none; }
.script-meta { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; }
.script-meta .field input[type="text"] { width: 100%; padding: 5px 8px; min-height: 29px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none; user-select: text; }
.script-code { flex: none; height: 260px; }

.tbl-tools { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Monaco code editors ---------- */
.code-host { flex: 1; min-height: 0; width: 100%; overflow: hidden; background: var(--code-bg); }
.js-pane .code-host { flex: 2; min-height: 120px; }
.js-pane .code-host.small { flex: 1; min-height: 70px; }
.js-pane .code-host.script-code { flex: none; height: 260px; min-height: 0; }
.code-host .monaco-editor, .code-host .monaco-editor * { user-select: text; }

/* ---------- code dock (tabbed editor) ---------- */
.dock { position: relative; height: 340px; }
.dock-resize { position: absolute; left: 0; right: 0; top: -3px; height: 6px; cursor: ns-resize; z-index: 5; }
.dock-resize:hover { background: var(--accent); opacity: .5; }
body.dock-resizing { user-select: none; cursor: ns-resize; }
body.dock-resizing #canvas { pointer-events: none; }
.dock-head { padding: 0; align-items: stretch; background: var(--bg); gap: 0; }
.dock-tabs { display: flex; overflow-x: auto; min-width: 0; }
.dock-tabs::-webkit-scrollbar { height: 0; }
.dock-file { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 10px; flex: none; cursor: pointer; color: var(--muted); font-size: 12px; border-right: 1px solid var(--line); background: var(--panel); }
.dock-file:hover { color: var(--text); background: var(--panel-2); }
.dock-file.active { color: #fff; background: var(--code-bg); box-shadow: inset 0 2px 0 var(--accent); }
.dock-file-x { background: none; border: 0; color: inherit; font-size: 15px; line-height: 1; padding: 0 3px; border-radius: 3px; cursor: pointer; opacity: .6; }
.dock-file-x:hover { opacity: 1; background: var(--panel-3); }
.dock-settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 12px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.dock-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--muted); }
.dock-field input { height: 26px; width: 150px; padding: 0 7px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none; user-select: text; }
.dock-field input.narrow { width: 56px; }
.dock-field input:focus { border-color: var(--accent); }
.dock-check { align-self: flex-end; height: 26px; font-size: 12px; }
.dock-editor { flex: 1; min-height: 0; position: relative; overflow: hidden; background: var(--code-bg); }
.dock-editor .css-editor { position: absolute; inset: 0; width: 100%; height: 100%; }
.dock-empty { flex: 1; display: grid; place-content: center; text-align: center; gap: 6px; padding: 20px; color: var(--faint); font-size: 12.5px; line-height: 1.6; background: var(--code-bg); }

/* ---------- sidebar: file list ---------- */
.tabs .head-btn { margin: auto 8px auto auto; }
.files { padding: 4px 0 10px; }
.file-group-head { display: flex; align-items: center; padding: 8px 12px 3px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.file-group-head .head-btn { margin-left: auto; }
.file-row { display: flex; align-items: center; gap: 8px; height: 26px; padding: 0 8px 0 14px; cursor: pointer; white-space: nowrap; }
.file-row:hover { background: var(--panel-2); }
.file-row.open { background: rgba(59, 130, 246, 0.08); }
.file-row.active { background: var(--accent-soft); color: #fff; }
.file-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.file-ico { flex: none; min-width: 26px; padding: 2px 4px; text-align: center; border-radius: 4px; background: #2f3542; color: #9ec1ff; font: 700 9px/1 ui-monospace, Consolas, monospace; }
.file-del { display: none; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.file-row:hover .file-del { display: block; }
.file-del:hover { background: var(--panel-3); color: var(--danger); }

/* ---------- code dock: full window ---------- */
.dock.full { position: fixed; left: 0; right: 0; bottom: 0; top: 42px; height: auto !important; z-index: 40; border-top: 0; }
.dock.full .dock-resize { display: none; }
.dock-full-btn { font-size: 16px; }
.dock-full-btn.active { background: var(--accent-soft); color: #fff; }

/* delete buttons are always visible (dimmed) so unused JavaScript files are easy to remove */
.file-del { display: block; opacity: .45; }
.file-row:hover .file-del, .file-del:hover { opacity: 1; }
.export-opts { margin-top: 6px; border-top: 1px solid var(--line); }
.export-opt { padding: 4px 14px; font-size: 12px; }

.file-empty { padding: 4px 14px 6px; color: var(--faint); font-size: 12px; }

/* ---------- settings window ---------- */
.settings-card { width: min(720px, 94vw); height: min(680px, 90vh); background: var(--bg); }
.settings-card .set-field input[type="text"], .settings-card .set-field select, .settings-card .set-color input[type="color"], .settings-card .set-thumb, .settings-card .set-urls { background: var(--panel); }
.settings-card .modal-head { gap: 14px; }
.settings-title { padding: 0 6px; }
.settings-body { flex: 1; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.settings-foot { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12px; }
.settings-foot .muted { flex: 1; color: var(--faint); }
.set-field { display: flex; flex-direction: column; gap: 5px; }
.set-label { font-size: 12px; font-weight: 600; color: var(--text); }
.set-help { font-size: 11.5px; color: var(--faint); line-height: 1.45; }
.set-field input[type="text"], .set-field select { width: 100%; height: 30px; padding: 0 9px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none; user-select: text; }
.set-field input:focus, .set-field select:focus { border-color: var(--accent); }
.set-check { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; font-size: 12.5px; cursor: pointer; }
.set-check input { accent-color: var(--accent); align-self: center; margin: 0; }
.set-check em { flex-basis: 100%; margin-left: 22px; font-style: normal; font-size: 11.5px; color: var(--faint); }
.set-color { display: flex; gap: 8px; }
.set-color input[type="color"] { width: 40px; height: 30px; padding: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
.set-image { display: flex; gap: 12px; align-items: center; }
.set-thumb { flex: none; width: 120px; height: 72px; display: grid; place-items: center; overflow: hidden; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--panel-2); color: var(--faint); font-size: 11.5px; }
.set-thumb img { width: 100%; height: 100%; object-fit: contain; }
.set-image-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.set-btns { display: flex; gap: 6px; }
.set-path { font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-urls { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; background: var(--panel-2); border-radius: var(--radius); }
.set-url { display: flex; gap: 12px; font-size: 12px; }
.set-url span { flex: none; width: 140px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.set-url code { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-sm.full { width: 100%; }
.sec-tools { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 8px; grid-column: 1 / -1; }
.sec-tools .btn-sm { padding: 1px 10px; font-size: 11px; }
.sec-tools .btn-sm:disabled { opacity: .45; cursor: default; }

/* ---------- utilities: breakpoint switch + counts ---------- */
.bp-strip { display: flex; align-items: center; gap: 3px; padding: 9px 12px 6px; border-top: 1px solid var(--line); }
.bp-strip-label { margin-right: auto; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bp-chip { position: relative; height: 22px; padding: 0 7px; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.bp-chip:hover { color: var(--text); border-color: var(--accent); }
.bp-chip.active { color: #fff; background: var(--accent); border-color: var(--accent); }
.bp-chip.used::after { content: ''; position: absolute; top: -3px; right: -3px; width: 7px; height: 7px; border-radius: 50%; background: var(--orange); border: 1px solid var(--panel); }
.psec-count { margin-left: 8px; padding: 0 6px; font-size: 10px; letter-spacing: 0; font-weight: 700; color: #9ec1ff; background: var(--accent-soft); border-radius: 8px; }

/* color field: picker + text + clear */
.color-field { display: flex; gap: 4px; }
.color-field input[type="color"] { flex: none; width: 36px; height: 29px; padding: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.color-field input[type="text"] { flex: 1; min-width: 0; }

/* ---------- icon picker + icon field ---------- */
.icon-card { width: min(860px, 94vw); height: min(680px, 90vh); }
.icon-search { padding: 10px 14px 4px; }
.icon-search input { width: 100%; height: 34px; padding: 0 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none; user-select: text; }
.icon-search input:focus { border-color: var(--accent); }
.icon-grid { flex: 1; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; padding: 10px 14px 14px; align-content: start; }
.icon-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 7px; background: var(--panel-2); border: 1px solid transparent; border-radius: var(--radius); cursor: pointer; color: var(--text); }
.icon-cell:hover { border-color: var(--accent); background: var(--panel-3); }
.icon-cell.active { border-color: var(--accent); background: var(--accent-soft); }
.icon-glyph { display: grid; place-items: center; height: 28px; }
.icon-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10.5px; color: var(--muted); }
.icon-more { grid-column: 1 / -1; justify-self: center; }
.icon-none { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--faint); }
.icon-field { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); cursor: pointer; }
.icon-field:hover { border-color: var(--accent); }
.icon-field-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; }
.icon-field-go { color: var(--accent); font-size: 12px; }
.util-full { grid-column: 1 / -1; }

/* ---------- fonts tab ---------- */
.font-card { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); }
.font-head { display: flex; align-items: center; gap: 8px; }
.font-name { flex: 1; min-width: 0; font-weight: 600; }
.font-badge { flex: none; padding: 1px 8px; font-size: 11px; color: #9ec1ff; background: var(--accent-soft); border-radius: 9px; }
.font-grid { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.font-files { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.font-file { display: flex; gap: 6px; align-items: center; width: 100%; }
.font-file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.font-file select { height: 28px; padding: 0 6px; width: auto; }
.font-add { display: flex; gap: 6px; }
.font-add input { height: 30px; padding: 0 9px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none; user-select: text; }
.font-add input:first-child { flex: 1; }
.font-add input:nth-child(2) { width: 110px; }
.font-card .set-help code { color: var(--text); }

.font-host { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.font-subsets { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.font-host-row { display: flex; gap: 6px; flex-wrap: wrap; }
.font-host-row .btn-sm:disabled { opacity: .5; cursor: default; }

.dt-controls { display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }

/* ---------- Monaco's right-click menu ----------
   The menu is drawn in a shadow root that gets none of the editor theme's colors, so it had no background and black text.
   CSS custom properties inherit into a shadow root, so the colors it asks for are defined here, on the page. */
:root {
  --vscode-foreground: #d4d7dc;
  --vscode-descriptionForeground: #8a93a3;
  --vscode-disabledForeground: #6b7280;
  --vscode-menu-background: #11151b;
  --vscode-menu-foreground: #d4d7dc;
  --vscode-menu-selectionBackground: #1b3a63;
  --vscode-menu-selectionForeground: #ffffff;
  --vscode-menu-selectionBorder: transparent;
  --vscode-menu-separatorBackground: #2a303a;
  --vscode-menu-border: #2a303a;
  --vscode-widget-shadow: rgba(0, 0, 0, 0.6);
  --vscode-shadow-lg: rgba(0, 0, 0, 0.6);
  --vscode-scrollbar-shadow: transparent;
}

/* ---------- right-click menu and name prompt ---------- */
.ctx-menu {
  position: fixed; z-index: 100; min-width: 160px; padding: 4px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.ctx-item {
  display: block; width: 100%; text-align: left; padding: 6px 10px;
  background: none; border: 0; border-radius: 5px; color: var(--text); cursor: pointer; font-size: 12px;
}
.ctx-item:hover { background: var(--accent-soft); color: #fff; }
.ctx-item.danger { color: #f87171; }
.ctx-item.danger:hover { background: rgba(248, 113, 113, 0.18); }
.ctx-sep { height: 1px; margin: 4px 2px; background: var(--line); }
.ask-card { width: min(380px, 92vw); height: auto; }
.ask-card .modal-head { padding: 10px 12px; }
.ask-body { padding: 12px; }
.ask-body input {
  width: 100%; height: 30px; padding: 0 10px; user-select: text;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none;
}
.ask-body input:focus { border-color: var(--accent); }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 12px 12px; }
.ask-actions .btn-sm { padding: 5px 14px; }
.ask-actions .btn-sm.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- template picker ---------- */
.tpl-card { width: min(520px, 92vw); height: min(560px, 86vh); }
.tpl-list { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.tpl-row { display: flex; align-items: center; gap: 6px; }
.tpl-use {
  flex: 1; min-width: 0; display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 9px 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); cursor: pointer; text-align: left;
}
.tpl-use:hover { border-color: var(--accent); background: var(--panel-3); }
.tpl-use span { color: var(--muted); font-size: 11px; }
.tpl-empty { color: var(--muted); font-size: 12px; padding: 6px 2px; }

/* ---------- save-as-block dialog ---------- */
.blk-card { width: min(560px, 94vw); max-height: 88vh; }
.blk-body { overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.blk-field { display: flex; flex-direction: column; gap: 5px; }
.blk-label { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; color: var(--muted); }
.blk-code {
  width: 100%; resize: vertical; padding: 8px 10px; user-select: text;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); outline: none;
  color: var(--text); font: 12px/1.5 ui-monospace, Consolas, monospace;
}
.blk-code:focus { border-color: var(--accent); }
.blk-images { display: flex; flex-wrap: wrap; gap: 6px; }
.blk-img { display: flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 8px 3px 3px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.blk-img img { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; }
.blk-none, .blk-note { font-size: 11px; color: var(--muted); }
.blk-list { max-height: 130px; overflow: auto; display: flex; flex-direction: column; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; }
.blk-item { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 4px; font-size: 12px; cursor: pointer; font-weight: 400; color: var(--text); }
.blk-item:hover { background: var(--panel-3); }
.blk-item-label { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.blk-item-label.mono { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; }
.blk-item-label em { color: var(--muted); font-style: normal; }
.blk-pic { display: flex; align-items: center; gap: 6px; }
.blk-pic img { width: 24px; height: 24px; object-fit: cover; border-radius: 4px; flex: none; }
