/* ------------------------------------------------------------------ tokens */
:root {
  --bg: #0e0f13;
  --bg-raised: #15171d;
  --bg-sunken: #0a0b0e;
  --panel: #1a1d24;
  --line: #262a33;
  --line-soft: #1f232a;
  --text: #e6e8ee;
  --text-dim: #99a0ad;
  --text-faint: #6b7280;
  --accent: #c084fc;
  --accent-strong: #a855f7;
  --accent-soft: rgba(192, 132, 252, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --ok: #4ade80;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
  --sidebar-w: 320px;
  --inspector-w: 350px;
  --code-w: 420px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 16px;
  height: 52px;
  flex: 0 0 52px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 13.5px; font-weight: 600; letter-spacing: -0.1px; }
.brand-sub { display: block; font-size: 11px; color: var(--text-faint); }
.brand-mark {
  display: grid;
  place-content: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--accent-strong), #6366f1);
  font: 600 13px/1 var(--mono);
  color: #0d0715;
}

.viewport-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.viewport-switch button {
  padding: 5px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
}
.viewport-switch button:hover { color: var(--text); }
.viewport-switch button.is-active { background: var(--accent-soft); color: #e9d5ff; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.workspace-tool.is-active { background: var(--accent-soft); border-color: var(--accent-strong); color: #e9d5ff; }

.switch { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); cursor: pointer; }
.switch input { accent-color: var(--accent-strong); width: 15px; height: 15px; }

.btn {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #3a3f4b; background: #1f232b; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #14061f; font-weight: 600; }
.btn-primary:hover { background: #b96bff; border-color: #b96bff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 11.5px; }
.btn.is-on { background: var(--accent-soft); border-color: var(--accent-strong); color: #e9d5ff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ------------------------------------------------------------------ layout */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--inspector-w);
  min-height: 0;
  position: relative;
}
.layout.code-hidden .codepane { display: none; }
.layout.sidebar-hidden { grid-template-columns: 42px minmax(0, 1fr) var(--inspector-w); }
.layout.inspector-hidden { grid-template-columns: var(--sidebar-w) minmax(0, 1fr) 42px; }
.layout.sidebar-hidden.inspector-hidden { grid-template-columns: 42px minmax(0, 1fr) 42px; }
.is-resizing, .is-resizing * { cursor: col-resize !important; user-select: none !important; }

/* ----------------------------------------------------------------- sidebar */
.sidebar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--line);
}
.panel-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-sunken);
  color: var(--text-dim);
  font: 500 10px/1 var(--mono);
  cursor: pointer;
}
.panel-toggle:hover { border-color: var(--accent-strong); color: var(--text); }
.panel-toggle-sidebar { position: absolute; top: 8px; right: -14px; z-index: 25; width: 28px; padding: 0; }
.panel-toggle-sidebar .panel-toggle-text { display: none; }
.panel-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 20;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
}
.panel-resizer::after {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: transparent;
  content: '';
  transition: background .15s ease;
}
.panel-resizer:hover::after, .is-resizing .panel-resizer::after { background: var(--accent-strong); }
.panel-resizer-sidebar { right: -4px; }
.panel-resizer-sidebar::after { right: 3px; }
.panel-resizer-inspector { left: -4px; }
.panel-resizer-inspector::after { left: 3px; }
.layout.sidebar-hidden .sidebar-tabs,
.layout.sidebar-hidden .sidebar-body { display: none; }
.layout.sidebar-hidden .sidebar { min-width: 0; }
.layout.sidebar-hidden .panel-toggle-sidebar { right: 6px; padding: 0; }
.layout.sidebar-hidden .panel-toggle-sidebar > span:first-child { transform: rotate(180deg); }
.layout.sidebar-hidden .panel-resizer-sidebar,
.layout.inspector-hidden .panel-resizer-inspector { display: none; }

.sidebar-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.sidebar-tabs button {
  padding: 12px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-faint);
  font-size: 11.5px;
  cursor: pointer;
}
.sidebar-tabs button:hover { color: var(--text-dim); }
.sidebar-tabs button.is-active { color: var(--text); border-bottom-color: var(--accent-strong); }

.sidebar-body { flex: 1; overflow-y: auto; min-height: 0; }
.panel { padding: 12px; }
.panel-note {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-faint);
}
.panel-note code { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.panel-search { margin-bottom: 10px; }
.panel-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-sunken);
}
.panel-search input:focus { outline: none; border-color: var(--accent-strong); }

/* control groups */
.group { border: 1px solid var(--line-soft); border-radius: var(--radius); margin-bottom: 8px; overflow: hidden; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 12px;
  border: 0; background: var(--panel);
  color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left;
}
.group-head:hover { background: #1f232b; }
.group-head .chev { margin-left: auto; color: var(--text-faint); transition: transform .15s; }
.group.is-open .group-head .chev { transform: rotate(90deg); }
.group-body { display: none; padding: 4px 12px 12px; background: var(--bg-raised); }
.group.is-open .group-body { display: block; }
.group-blurb { margin: 6px 0 12px; font-size: 11.5px; line-height: 1.55; color: var(--text-faint); }
.group-blurb code { font-family: var(--mono); font-size: 10.5px; }
.group-count {
  font: 500 10px/1 var(--mono);
  padding: 3px 5px; border-radius: 4px;
  background: var(--accent-soft); color: #e9d5ff;
}

/* individual control */
.ctrl { padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.ctrl:last-child { border-bottom: 0; }
.ctrl-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; }
.ctrl-label { font-size: 12.5px; color: var(--text-dim); }
.ctrl.is-set .ctrl-label { color: var(--text); font-weight: 500; }
.ctrl-sel {
  margin-left: auto;
  font: 400 10px/1 var(--mono);
  color: var(--text-faint);
  cursor: pointer;
  max-width: 46%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ctrl-sel:hover { color: var(--accent); }
.ctrl-help { margin: 5px 0 0; font-size: 11px; line-height: 1.5; color: var(--text-faint); }
.ctrl-row { display: flex; align-items: center; gap: 6px; }
.ctrl-row input[type="text"],
.ctrl-row input[type="number"],
.ctrl-row select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-sunken);
  font-size: 12.5px;
}
.ctrl-row input:focus, .ctrl-row select:focus { outline: none; border-color: var(--accent-strong); }
.ctrl-row input[type="range"] { flex: 1; accent-color: var(--accent-strong); min-width: 0; }
.ctrl-row input[type="color"] {
  width: 32px; height: 30px; padding: 0;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg-sunken); cursor: pointer; flex: 0 0 auto;
}
.ctrl-row select { flex: 0 0 auto; width: auto; }
.ctrl-row .num { flex: 0 0 68px; }
.ctrl-clear {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-faint);
  cursor: pointer; line-height: 1;
}
.ctrl-clear:hover { background: var(--danger-soft); color: var(--danger); }
.ctrl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 5px; }
.ctrl-grid label { font-size: 10px; color: var(--text-faint); display: block; margin-bottom: 2px; }
.ctrl-grid input { width: 100%; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-sunken); font-size: 11.5px; }
.swatch-row { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.swatch { width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(255,255,255,.14); cursor: pointer; padding: 0; }

/* presets */
.preset {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 12px; margin-bottom: 8px;
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel);
}
.preset.is-on { border-color: var(--accent-strong); background: linear-gradient(180deg, var(--accent-soft), transparent); }
.preset-main { flex: 1; min-width: 0; }
.preset-name { font-size: 13px; font-weight: 500; }
.preset-cat { font: 500 9.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.preset-blurb { margin: 5px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--text-faint); }
.preset button { flex: 0 0 auto; }

/* profile fields */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.field input[type="text"], .field input[type="number"], .field select, .field textarea {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg-sunken); font-size: 12.5px;
}
.field textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 11.5px; line-height: 1.55; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent-strong); }
.field-hint { margin: 4px 0 0; font-size: 11px; color: var(--text-faint); }
.field-inline { display: flex; align-items: center; gap: 8px; }
.field-inline label { margin: 0; }
.profile-import { margin: 0 0 16px; padding: 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg-raised); }
.profile-import > strong { display: block; font-size: 12.5px; color: var(--text); }
.profile-import > p:not(.field-hint) { margin: 5px 0 9px; font-size: 11.5px; line-height: 1.5; color: var(--text-faint); }
.profile-import-button {
  display: inline-flex;
  margin: 2px 0 8px;
  padding: 8px 12px;
  border-color: var(--accent-strong);
  background: linear-gradient(135deg, var(--accent-soft), rgba(99, 102, 241, .16));
  box-shadow: 0 6px 16px rgba(168, 85, 247, .16);
  color: #f3e8ff;
  font-weight: 600;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.profile-import-button:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(192, 132, 252, .28), rgba(99, 102, 241, .24));
  box-shadow: 0 9px 22px rgba(168, 85, 247, .25);
}
.profile-import-status { color: var(--accent) !important; }
.profile-library-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 4px 0 9px; }
.profile-library-switch { margin: 8px 0; }

/* reference */
.ref-group { margin-bottom: 6px; }
.ref-group h4 {
  margin: 14px 0 6px;
  font: 600 10px/1 var(--mono);
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-faint);
}
.ref-item { padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 8px; margin-bottom: 5px; background: var(--panel); }
.ref-element { font-size: 12px; color: var(--text-dim); margin-bottom: 5px; }
.ref-sels { display: flex; flex-wrap: wrap; gap: 4px; }
.ref-sel {
  font: 400 10.5px/1 var(--mono);
  padding: 3px 6px; border-radius: 5px;
  border: 1px solid var(--line);
  background: var(--bg-sunken); color: #d8b4fe;
  cursor: pointer;
}
.ref-sel:hover { border-color: var(--accent-strong); }
.ref-sel.is-id { color: var(--text-faint); }
.ref-empty { padding: 20px 4px; text-align: center; color: var(--text-faint); font-size: 12px; }

/* ------------------------------------------------------------------- stage */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-sunken); }
.stage-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px; height: 34px; flex: 0 0 34px;
  border-bottom: 1px solid var(--line);
  font: 400 11.5px/1 var(--mono);
  color: var(--text-faint);
  background: var(--bg-raised);
}
.stage-sep { opacity: .4; }
.stage-zoom {
  border: 0; padding: 2px 6px; border-radius: 5px;
  background: transparent; color: var(--text-dim);
  font: inherit; cursor: pointer;
}
.stage-zoom:hover { background: var(--accent-soft); color: #e9d5ff; }
.stage-zoom-slider {
  width: 88px;
  height: 4px;
  margin: 0 2px;
  accent-color: var(--accent-strong);
  cursor: ew-resize;
}
.stage-spacer { flex: 1; }
.pick-result { color: #d8b4fe; cursor: pointer; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-notice {
  margin: 0;
  padding: 8px 14px;
  flex: 0 0 auto;
  background: rgba(251, 191, 36, .08);
  border-bottom: 1px solid rgba(251, 191, 36, .22);
  font-size: 11.5px;
  line-height: 1.5;
  color: #e3c07a;
}
.stage-notice code { font-family: var(--mono); font-size: 10.5px; }
.stage-scroll { flex: 1; overflow: auto; display: flex; justify-content: flex-start; padding: 16px; min-height: 0; }
/* Auto margins centre a fitted canvas, but resolve to zero when the canvas is
 * wider than the viewport. That keeps x=0 reachable when panning a 1:1 view. */
.stage-sizer { flex: 0 0 auto; align-self: flex-start; margin-inline: auto; }
.stage-frame {
  transform-origin: top left;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .55);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.stage-frame iframe { display: block; border: 0; }

/* --------------------------------------------------------------- inspector */
.inspectorpane {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-raised);
  border-left: 1px solid var(--line);
}
.inspectorpane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.inspectorpane-head > div:first-child { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.inspectorpane-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.inspectorpane-actions { display: flex; flex-direction: row; align-items: center; gap: 6px; }
.inspector-kicker {
  color: var(--text-faint);
  font: 500 9px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.inspector-home {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.inspector-home:hover { border-color: var(--accent-strong); color: var(--text); }
.layout.inspector-hidden .inspectorpane-head { justify-content: center; padding: 7px; }
.layout.inspector-hidden .inspectorpane-head > div:first-child,
.layout.inspector-hidden .inspector-home,
.layout.inspector-hidden .inspectorpane-body { display: none; }
.layout.inspector-hidden .inspectorpane-actions { display: block; }
.layout.inspector-hidden .panel-toggle-inspector { padding: 0; }
.layout.inspector-hidden .panel-toggle-inspector { transform: rotate(180deg); }
.inspectorpane-body { flex: 1; min-height: 0; overflow-y: auto; }
.inspectorpane-body > .panel { min-height: 100%; }
.inspector-selection {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 10px;
  padding: 7px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-sunken);
}
.inspector-selection-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font: 500 10.5px/1.2 var(--mono);
}
.inspector-selection.has-selection { border-color: rgba(168, 85, 247, .4); }
.inspector-selection.has-selection .inspector-selection-label { color: #d8b4fe; }

/* ---------------------------------------------------------------- codepane */
.codepane {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  width: min(var(--code-w), calc(100% - var(--sidebar-w)));
  flex-direction: column;
  min-height: 0;
  background: var(--bg-raised);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, .45);
}
.codepane-head {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px; height: 40px; flex: 0 0 40px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.code-stats { margin-left: auto; font: 400 11px/1 var(--mono); color: var(--text-faint); }

.codepane-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 10px 12px; flex: 0 0 auto;
  border-top: 1px solid var(--line);
}

.editor {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--bg-sunken);
  position: relative;
}
.gutter {
  flex: 0 0 44px;
  padding: 12px 8px 12px 0;
  text-align: right;
  font: 400 12px/1.6 var(--mono);
  color: #3f4550;
  background: var(--bg-sunken);
  overflow: hidden;
  user-select: none;
  border-right: 1px solid var(--line-soft);
}
.gutter div.has-issue { color: var(--danger); font-weight: 500; }
.gutter div.has-advisory { color: var(--warn); font-weight: 500; }
.editor-scroll { flex: 1; position: relative; overflow: auto; min-width: 0; }

.highlight, #css-input {
  margin: 0;
  padding: 12px;
  font: 400 12px/1.6 var(--mono);
  white-space: pre;
  tab-size: 2;
  border: 0;
}
.highlight {
  position: absolute; inset: 0 auto 0 0;
  pointer-events: none;
  color: var(--text);
  min-width: 100%;
}
/*
 * Both layers are sized to the widest line, not to the pane. Hardcoded markup
 * is written as one long line on purpose (a newline between two inline tags
 * renders as a gap), so the content is routinely far wider than the 420px pane
 * — and a textarea only as wide as the pane means everything you scroll right
 * to is unclickable and untypeable.
 */
/* The <pre> sizes itself to its widest line; a textarea cannot (its intrinsic
 * width comes from `cols`), so renderHighlight measures the <pre> and sets the
 * textarea to match. */
.highlight { width: max-content; }
.highlight, #css-input { min-width: 100%; }
#css-input {
  position: relative;
  display: block;
  min-height: 100%;
  background: transparent;
  color: transparent;
  caret-color: var(--accent);
  resize: none;
  overflow: hidden;
}
#css-input:focus { outline: none; }
#css-input::selection { background: rgba(168, 85, 247, .35); }

.tok-comment { color: #5b6472; font-style: italic; }
.tok-sel     { color: #7dd3fc; }
.tok-prop    { color: #c4b5fd; }
.tok-val     { color: #e6e8ee; }
.tok-num     { color: #fbbf24; }
.tok-str     { color: #86efac; }
.tok-at      { color: #f0abfc; }
.tok-punct   { color: #6b7280; }
.tok-imp     { color: #fb7185; font-weight: 500; }
.tok-blocked {
  text-decoration: underline wavy var(--danger);
  text-underline-offset: 3px;
  background: var(--danger-soft);
  border-radius: 2px;
}
/* Advisory: a real gap in the rendered layout, but nothing JanitorAI strips —
 * amber rather than the "this will vanish" red of .tok-blocked. */
.tok-advisory {
  text-decoration: underline wavy var(--warn);
  text-underline-offset: 3px;
  background: var(--warn-soft);
  border-radius: 2px;
}

.lint {
  flex: 0 0 auto;
  max-height: 34%;
  overflow-y: auto;
  border-top: 1px solid var(--line);
  background: var(--bg-raised);
}
.lint-clean { padding: 12px 14px; font-size: 12px; color: var(--text-faint); display: flex; align-items: center; gap: 8px; }
.lint-clean b { color: var(--ok); font-weight: 500; }
.lint-head {
  padding: 9px 14px 6px;
  font: 600 10px/1 var(--mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--danger);
}
.lint-head--advisory { color: var(--warn); }
.lint-head { display: flex; align-items: center; gap: 8px; }
.lint-fix {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid var(--warn); border-radius: 6px;
  background: transparent; color: var(--warn);
  font: 600 9.5px/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  cursor: pointer;
}
.lint-fix:hover { background: var(--warn-soft); }
.lint-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 14px;
  border: 0; border-top: 1px solid var(--line-soft);
  background: transparent; cursor: pointer;
}
.lint-item:hover { background: var(--danger-soft); }
.lint-item--advisory:hover { background: var(--warn-soft); }
.lint-title { font-size: 12px; color: var(--text); }
.lint-title code { font-family: var(--mono); font-size: 11px; color: #fca5a5; }
.lint-item--advisory .lint-title code { color: #fde68a; }
.lint-meta { font: 400 10.5px/1.4 var(--mono); color: var(--text-faint); margin-top: 2px; }
.lint-hint { font-size: 11.5px; line-height: 1.5; color: var(--text-dim); margin-top: 4px; }

/* ------------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 26px;
  transform: translateX(-50%);
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 12.5px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .5);
  z-index: 50;
}

/* --------------------------------------------------------------- narrow UI */
@media (max-width: 1400px) {
  :root { --sidebar-w: 300px; --inspector-w: 330px; --code-w: 390px; }
}
@media (max-width: 1150px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .inspectorpane {
    position: fixed;
    right: 0;
    top: 52px;
    bottom: 0;
    width: min(var(--inspector-w), 90vw);
    z-index: 35;
    box-shadow: -12px 0 40px rgba(0, 0, 0, .45);
  }
  .codepane {
    position: fixed; right: 0; top: 52px; bottom: 0;
    width: min(440px, 90vw); z-index: 40;
    box-shadow: -12px 0 40px rgba(0, 0, 0, .5);
  }
  .layout.code-hidden .codepane { display: none; }
}

@media (max-width: 760px) {
  :root { --sidebar-w: min(280px, 44vw); --inspector-w: min(330px, 88vw); }
  .topbar-actions { gap: 4px; }
  .topbar-actions .btn { padding-inline: 7px; font-size: 11px; }
  #changelog-toggle, #hardcoding-toggle { display: none; }
}

/* HTML tokens in the About Me editor */
.tok-tag  { color: #f0abfc; }
.tok-attr { color: #7dd3fc; }

.codepane-note {
  margin: 0;
  padding: 9px 12px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--line-soft);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-faint);
}
.codepane-note b { color: var(--text-dim); font-weight: 500; }
.codepane-note code { font-family: var(--mono); font-size: 10.5px; color: #d8b4fe; }

.viewport-switch input[type="number"] {
  width: 66px;
  margin-left: 2px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 12px;
}
.viewport-switch input[type="number"]:focus { outline: none; border-color: var(--accent-strong); }

/* ------------------------------------------------- preset sections & templates */
.preset-section { border: 1px solid var(--line-soft); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.preset-section > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 12px;
  background: var(--panel);
  font-size: 13px; font-weight: 500;
  cursor: pointer; list-style: none;
}
.preset-section > summary::-webkit-details-marker { display: none; }
.preset-section > summary::before {
  content: '›'; color: var(--text-faint);
  transition: transform .15s; display: inline-block;
}
.preset-section[open] > summary::before { transform: rotate(90deg); }
.preset-section > summary:hover { background: #1f232b; }
.preset-section-name { flex: 1; }
.preset-section-count {
  font: 500 10px/1 var(--mono);
  padding: 3px 6px; border-radius: 4px;
  background: var(--accent-soft); color: #e9d5ff;
}
.preset-section > .panel-note,
.preset-section > div { padding-left: 10px; padding-right: 10px; }
.preset-section > .panel-note { margin-top: 10px; }

.template {
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  background: var(--panel); margin-bottom: 10px; overflow: hidden;
}
.template.is-on { border-color: var(--accent-strong); }
.template-head { padding: 12px; position: relative; }
.template-credit {
  margin-top: 3px;
  font-size: 11.5px; color: var(--accent);
}
.template-actions { position: absolute; top: 12px; right: 12px; }

.template-parts { border-top: 1px solid var(--line-soft); }
.template-parts > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px;
  font-size: 12px; color: var(--text-dim);
  cursor: pointer; list-style: none;
}
.template-parts > summary::-webkit-details-marker { display: none; }
.template-parts > summary::before {
  content: '›'; color: var(--text-faint);
  transition: transform .15s; display: inline-block;
}
.template-parts[open] > summary::before { transform: rotate(90deg); }
.template-parts > summary:hover { background: var(--bg-raised); }
.template-parts-count {
  margin-left: auto;
  font: 500 10px/1 var(--mono);
  padding: 3px 6px; border-radius: 4px;
  background: var(--bg-sunken); color: var(--text-faint);
}

.part {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-raised);
}
.part.is-on { background: linear-gradient(90deg, var(--accent-soft), transparent); }
.part-main { flex: 1; min-width: 0; }
.part-name { font-size: 12.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.part-blurb { margin: 4px 0 0; font-size: 11px; line-height: 1.5; color: var(--text-faint); }
.part-badge {
  font: 500 9px/1 var(--mono);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 5px; border-radius: 4px;
  background: var(--bg-sunken); color: var(--text-faint);
  border: 1px solid var(--line);
}
.part-badge.is-good { color: #86efac; border-color: rgba(134, 239, 172, .3); }
.part-badge.is-html { color: #7dd3fc; border-color: rgba(125, 211, 252, .3); }

/* ---------------------------------------------------------------------- help */
.help-panel h2 { margin: 0 0 3px; font-size: 16px; }
.help-panel details {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 8px;
  overflow: hidden;
}
.help-panel summary {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 500;
}
.help-panel p,
.help-panel ol {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.55;
}
.help-panel ol { padding-left: 30px; }
.help-panel code { font-family: var(--mono); font-size: 11px; color: var(--text); }

/* ---------------------------------------------------------------- changelog */
.changelog {
  width: min(720px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
}
.changelog::backdrop { background: rgba(0, 0, 0, .6); }
.changelog-inner { padding: 22px 26px 24px; max-height: 80vh; overflow-y: auto; box-sizing: border-box; }
.changelog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.changelog-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.changelog-sub { margin: 4px 0 0; color: var(--text-dim); font-size: 13px; }
.changelog-close {
  appearance: none; width: 28px; height: 28px; flex: none;
  border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: var(--text-dim);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.changelog-close:hover { color: var(--text); background: var(--bg-raised); }
.changelog-entry { padding: 18px 0 8px; border-top: 1px solid var(--line-soft); }
.changelog-entry:first-child { border-top: 0; padding-top: 14px; }
.changelog-entry h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.changelog-entry p, .changelog-entry li { margin: 0 0 10px; color: var(--text-dim); font-size: 13.5px; line-height: 1.55; }
.changelog-entry ul { margin: 0 0 10px 18px; padding: 0; }
.changelog-entry a { color: var(--accent); text-decoration: none; }
.changelog-entry a:hover { text-decoration: underline; }
.changelog-entry code {
  font-family: var(--mono); font-size: 12.5px;
  background: var(--bg-sunken); padding: 1px 5px; border-radius: 4px;
}
.new-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 7px; vertical-align: middle; }
/* display above beats the browser's own [hidden] rule, so restate it. */
.new-dot[hidden] { display: none; }

/* ------------------------------------------------------------------ cards */
/* The hardcoding roster. Each character is a collapsed row so a long roster
 * still scans as a list; opening one reveals the fields that make its card. */
.cards-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.cards-actions .btn { flex: 1; }
.cards-status { margin: 0 0 10px; font-size: 11.5px; line-height: 1.5; color: var(--text-dim); }
.cards-status:empty { display: none; }
.cards-selection-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin: 0 0 9px; padding: 6px 7px;
  border: 1px solid var(--line-soft); border-radius: 7px;
  background: var(--bg-sunken); color: var(--text-faint); font-size: 10.5px;
}
.cards-select-all { display: inline-flex; align-items: center; gap: 5px; color: var(--text-dim); cursor: pointer; }
.cards-select-all input, .card-select { accent-color: var(--accent-strong); cursor: pointer; }
.cards-selection-count { margin-right: auto; font-family: var(--mono); }
.cards-selection-toolbar .btn { padding: 4px 7px; }
.cards-selection-toolbar #cards-delete-selected { color: var(--danger); }
.cards-empty { margin: 4px 0 12px; font-size: 11.5px; line-height: 1.6; color: var(--text-faint); }
.cards-empty b { color: var(--text-dim); font-weight: 600; }

.card-row {
  margin-bottom: 6px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-raised);
  overflow: hidden;
}
.card-row[open] { border-color: var(--accent-strong); }
.card-row > summary {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  padding: 9px 11px;
  cursor: pointer;
  list-style: none;
}
.card-row > summary .card-select { flex: 0 0 auto; margin: 0 2px 0 0; }
.card-row > summary .card-row-name { margin-right: auto; }
.card-row > summary::-webkit-details-marker { display: none; }
.card-row > summary:hover { background: var(--accent-soft); }
.card-row-name { font-size: 12.5px; color: var(--text); }
.card-row-meta { font: 400 10px/1 var(--mono); letter-spacing: .06em; color: var(--text-faint); text-transform: uppercase; }
.card-row label.field { display: block; margin: 0 11px 10px; font-size: 11.5px; color: var(--text-dim); }
.card-row label.field input, .card-row label.field textarea { margin-top: 4px; color: var(--text); }
.card-row textarea { min-height: 58px; }
.card-row-buttons { display: flex; gap: 6px; margin: 0 11px 11px; }
.card-row-buttons .card-remove { margin-left: auto; color: var(--danger); }

.cards-options { margin: 12px 0; border-top: 1px solid var(--line-soft); }
.cards-options > summary {
  padding: 9px 0 8px;
  font: 600 10px/1 var(--mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint);
  cursor: pointer;
}
.cards-options label.field { display: block; margin-bottom: 10px; font-size: 11.5px; color: var(--text-dim); }
.cards-options label.field input { margin-top: 4px; color: var(--text); }
.cards-options input[type="color"] {
  width: 100%; height: 30px; padding: 2px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg-sunken);
}
.cards-footer { display: flex; flex-direction: column; gap: 5px; padding-top: 4px; }
.cards-footer .btn { width: 100%; }

/* ------------------------------------------------------------ profile info */
/* Profile information is long, so each section is closed until asked for and
 * its summary carries a count of what is inside. */
.info-import { display: flex; gap: 6px; margin-bottom: 8px; }
.info-import .btn { flex: 1; text-align: center; }
.info-section { margin-bottom: 8px; border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.info-section[open] { border-color: var(--line); }
.info-section > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--panel);
  font-size: 13px; font-weight: 500;
  cursor: pointer; list-style: none;
}
.info-section > summary::-webkit-details-marker { display: none; }
.info-section > summary::before { content: '›'; display: inline-block; color: var(--text-faint); transition: transform .15s; }
.info-section[open] > summary::before { transform: rotate(90deg); }
.info-section > summary:hover { background: #1f232b; }
.info-section-name { flex: 1; }
.info-count { font: 500 10px/1 var(--mono); padding: 3px 6px; border-radius: 4px; background: var(--bg-sunken); color: var(--text-faint); }
.info-count:empty { display: none; }
.info-body { padding: 10px 10px 2px; }
.info-body label.field { display: block; margin-bottom: 10px; font-size: 11.5px; color: var(--text-dim); }
.info-body label.field input, .info-body label.field textarea, .info-body label.field select { margin-top: 4px; color: var(--text); }
.info-body input[type="url"] {
  width: 100%; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg-sunken); font-size: 12.5px;
}
.info-body input[type="url"]:focus { outline: none; border-color: var(--accent-strong); }
.info-body input[type="color"] {
  width: 100%; height: 30px; padding: 2px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg-sunken);
}
.info-body textarea { min-height: 64px; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 8px; }
.info-subhead { margin: 14px 0 7px; font: 600 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); }
.info-add { width: 100%; margin: 2px 0 10px; }
.info-thumb { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 5px; object-fit: cover; align-self: center; }
.info-list .card-row > summary, #cards-list .card-row > summary { align-items: center; }
/* Room for the Add all / Use button, which sits in the corner of the head. */
.template-head { padding-right: 92px; }
