/* Room Palette - an editor's chrome that keeps out of the way of the room's colours: warm greys, one teal
 * accent, system sans. Dark is the default because a dim neutral surround is how colour is judged on screen
 * (photo editors do the same); light is one click away and remembered. */
:root, :root[data-theme="dark"] {
  --bg: #1d1c1a; --chrome: #262422; --chrome-2: #2e2c29; --stage: #3d3b38; --line: #3a3733; --line-2: #4a4641;
  --text: #ece9e4; --muted: #a59f97; --faint: #77726b;
  --accent: #2fb5a8; --accent-ink: #08201d; --accent-soft: rgba(47, 181, 168, 0.16);
  --warn: #e3b25f; --bad: #ec8a78; --ok: #7cc79a;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #ecebe8; --chrome: #f7f6f3; --chrome-2: #efede9; --stage: #d3d0cb; --line: #dedad4; --line-2: #cbc6be;
  --text: #22201d; --muted: #6c675f; --faint: #9a958c;
  --accent: #17867c; --accent-ink: #ffffff; --accent-soft: rgba(23, 134, 124, 0.12);
  --warn: #9a6512; --bad: #b2412b; --ok: #2f7d4f;
  --shadow: 0 8px 24px rgba(40, 30, 20, 0.18);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--accent); }
h2 { font-size: 17px; margin: 6px 0 4px; line-height: 1.3; }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 18px 0 8px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
h3 .small { text-transform: none; letter-spacing: 0; font-weight: 400; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* header */
.topbar { height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 14px; background: var(--chrome); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 15px; white-space: nowrap; }
.backlink { color: var(--muted); text-decoration: none; font-size: 12px; white-space: nowrap; }
.backlink:hover { color: var(--text); }
.logo svg { display: block; }
.logo .l1 { fill: var(--text); opacity: 0.85; } .logo .l2 { fill: var(--muted); } .logo .l3 { fill: var(--faint); } .logo .l4 { fill: var(--accent); }
.filechip { color: var(--muted); border: 1px solid var(--line-2); border-radius: 999px; padding: 2px 9px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topactions { display: flex; align-items: center; gap: 8px; }
.credits { color: var(--muted); }
.topup { font-size: 12px; text-decoration: none; }
.ghostbtn { background: transparent; border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 10px; font-size: 12px; }
.ghostbtn:hover { border-color: var(--muted); }
.iconbtn { padding: 5px 7px; display: inline-flex; }

/* editor */
.editor { display: grid; grid-template-columns: 52px minmax(0, 1fr) 384px; height: calc(100vh - 48px); min-height: 560px; }
.rail { background: var(--chrome); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0; }
.tool { width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tool svg .fill { fill: currentColor; }
.tool:hover { color: var(--text); background: var(--chrome-2); }
.tool.on { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.railsep { width: 22px; height: 1px; background: var(--line-2); margin: 6px 0; }

.stagecol { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; outline: none; touch-action: none; }
.stage.over::after { content: ""; position: absolute; inset: 10px; border: 2px dashed var(--accent); border-radius: 10px; pointer-events: none; }
.stage.pick { cursor: crosshair; } .stage.pan { cursor: grab; } .stage.dragging { cursor: grabbing; }
.canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.overlay { position: absolute; inset: 0; pointer-events: none; }
.drophint { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 24px; }
.dropart { width: 150px; height: 100px; margin-bottom: 4px; }
.dropart .frame { fill: none; stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 1.5; }
.dropart .floor { fill: var(--muted); opacity: 0.25; } .dropart .win { fill: var(--muted); opacity: 0.18; } .dropart .sofa { fill: var(--muted); opacity: 0.45; } .dropart .acc { fill: var(--accent); }
.droptitle { font-size: 18px; font-weight: 600; margin: 0; }
.dropsub { margin: 0; color: var(--muted); max-width: 420px; }
.examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; margin-top: 10px; }
.chip { background: var(--chrome); border: 1px solid var(--line-2); border-radius: 999px; padding: 5px 12px; font-size: 12px; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.linkbtn { background: none; border: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.stagebar { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 10px; background: rgba(20, 19, 18, 0.72); color: #e8e4de; padding: 3px 9px; border-radius: 6px; pointer-events: none; }

/* pins and ghosts on the picture */
.pin { position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%; border: 2.5px solid var(--accent); background: #fbfaf8; color: #1a1918; font-weight: 700; font-size: 13px; pointer-events: auto; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45); padding: 0; }
.pin.issue { background: #1a1918; color: #fbfaf8; }
.pin.idea { border-style: dashed; }
.pin.sel { transform: scale(1.18); box-shadow: 0 0 0 4px var(--accent-soft), 0 2px 8px rgba(0, 0, 0, 0.45); }
.ghost { position: absolute; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 7px; border: 2px dashed #fbfaf8; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 3px 10px rgba(0, 0, 0, 0.4); pointer-events: auto; padding: 0; opacity: 0.92; }
.ghost.reduce { background-image: repeating-linear-gradient(45deg, rgba(0,0,0,0.55) 0 4px, transparent 4px 9px) !important; }
.ghost .gl { position: absolute; top: 100%; left: 50%; transform: translate(-50%, 5px); white-space: nowrap; font-size: 11px; font-weight: 600; color: #fbfaf8; background: rgba(18, 17, 16, 0.78); padding: 1px 6px; border-radius: 4px; }
.ghost.sel { outline: 3px solid var(--accent); outline-offset: 2px; }
.pop { position: absolute; width: 270px; background: var(--chrome); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); z-index: 5; font-size: 13px; }
.pop strong { display: block; margin-bottom: 3px; }
.pop .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.loupe { position: absolute; z-index: 6; background: var(--chrome); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); font-size: 12px; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.loupe .sw { width: 34px; height: 34px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.3); }

.stripwrap { background: var(--chrome); border-top: 1px solid var(--line); padding: 8px 12px 6px; }
.strip { width: 100%; height: 64px; display: block; }
.strip .band { cursor: pointer; }
.strip .band.sel { stroke: var(--accent); stroke-width: 3; }
.strip text { font-size: 11px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
#stripNote { margin: 3px 0 0; min-height: 16px; }

/* inspector */
.inspector { background: var(--chrome); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; flex: none; }
.tab { flex: 1; background: none; border: none; border-bottom: 2px solid transparent; padding: 11px 4px 9px; color: var(--muted); font-weight: 600; font-size: 13px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 5px; vertical-align: 2px; }
.pane { overflow-y: auto; padding: 4px 16px 24px; flex: 1; min-height: 0; }
.exrow { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 12px 0 0; }
.exrow .chip { padding: 3px 9px; font-size: 11.5px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 12px 0 0; }
.facts dt { color: var(--muted); } .facts dd { margin: 0; }
.swatches { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.swatches li button { width: 100%; display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; }
.swatches li button:hover { background: var(--chrome-2); }
.swatches li button.sel { border-color: var(--accent); background: var(--accent-soft); }
.chipsw { width: 30px; height: 30px; border-radius: 6px; border: 1px solid rgba(0, 0, 0, 0.25); }
.swname { display: block; font-weight: 600; font-size: 13px; }
.swmeta { display: block; color: var(--muted); font-size: 11px; }
.swshare { font-variant-numeric: tabular-nums; font-size: 12px; text-align: right; }
.swshare .bar { display: block; height: 3px; background: var(--accent); border-radius: 2px; margin-top: 3px; margin-left: auto; }
.meterbar { width: 100%; height: auto; display: block; }
.meterbar text { font-size: 10.5px; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.paircheck { display: flex; align-items: center; gap: 8px; }
select, input[type="text"], textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line-2); border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 13px; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
.paircheck select { width: auto; flex: 1; min-width: 0; }
.freeexports, .exports { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.mini { background: var(--chrome-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 9px; font-size: 12px; }
.mini:hover { border-color: var(--muted); }
.primary { background: var(--accent); color: var(--accent-ink); border: none; border-radius: 8px; padding: 10px 16px; font-weight: 700; }
.primary.small { padding: 6px 12px; font-size: 12px; }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.notes { border-top: 1px solid var(--line); margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.field > span { font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 6px; align-items: center; color: var(--muted); margin: 0 0 8px; }
.runbox { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.runbox .primary { width: 100%; }
.runbox p { margin: 0; }
.notice { color: var(--muted); border-left: 2px solid var(--line-2); padding-left: 8px; }
.warn { color: var(--warn); }
.gate { color: var(--warn); }
.gateaction { font-size: 12px; font-weight: 600; }
.since { color: var(--text); background: var(--chrome-2); border-radius: 8px; padding: 8px 10px; margin: 0 0 8px; }
.progress { margin-top: 12px; background: var(--chrome-2); border-radius: 8px; padding: 10px 12px; }
.blockhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 12px; }
.steps { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.steps li { padding: 2px 0; }
.steps li.done { color: var(--text); } .steps li.active { color: var(--accent); font-weight: 600; }
.step-ic { display: inline-block; width: 14px; }

.verdictrow { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.verdict { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; padding: 3px 9px; border-radius: 999px; border: 1.5px solid currentColor; }
.verdict.working { color: var(--ok); } .verdict.tune { color: var(--accent); } .verdict.rework { color: var(--bad); }
.schemechip { font-size: 12px; color: var(--muted); }
.headline { font-size: 14px; margin: 6px 0 0; }
.roles, .callouts, .moves { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.roles li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: start; font-size: 13px; }
.roles .chipsw { width: 22px; height: 22px; border-radius: 5px; }
.roles .rl { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); font-weight: 700; }
.roles .rn { font-weight: 600; } .roles .rw { color: var(--muted); font-size: 12px; display: block; }
.callouts li, .moves li { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.callouts li:hover, .moves li:hover, .callouts li.sel, .moves li.sel { border-color: var(--accent); }
.cn { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; border: 2px solid var(--accent); margin-right: 6px; }
.cn.issue { background: var(--text); color: var(--bg); }
.kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-left: 4px; }
.moves .mv { display: flex; gap: 8px; align-items: center; }
.moves .msw { width: 22px; height: 22px; border-radius: 5px; border: 2px dashed var(--muted); flex: none; }
.moves .ck { display: block; color: var(--muted); font-size: 11.5px; margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.fix { color: var(--text); border-left: 2px solid var(--accent); padding-left: 8px; }
.recon { list-style: none; padding: 0; margin: 0; font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.recon li::before { content: "\2713"; color: var(--ok); margin-right: 6px; font-weight: 700; }
.recon li.bad::before { content: "!"; color: var(--bad); margin-right: 9px; }
.recon li.bad { color: var(--text); }
.raw { white-space: pre-wrap; word-break: break-word; background: var(--bg); padding: 10px; border-radius: 8px; font-size: 12px; max-height: 360px; overflow: auto; }
.history { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.history li button { width: 100%; text-align: left; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; }
.history li button:hover { border-color: var(--accent); }
.hstrip { display: flex; height: 10px; border-radius: 3px; overflow: hidden; }
.hstrip span { display: block; height: 100%; }
.hmeta { font-size: 11px; color: var(--muted); }

.foot { padding: 18px 16px 28px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); background: var(--bg); }
.foot p { margin: 4px 0; max-width: 980px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--chrome); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); padding: 9px 12px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; transition: opacity 0.5s; }
.toast.err { border-left-color: var(--bad); }
.toast.gone { opacity: 0; }

@media (max-width: 960px) {
  .editor { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 62vh auto; height: auto; min-height: 0; }
  .rail { flex-direction: row; overflow-x: auto; padding: 4px 8px; border-right: none; border-bottom: 1px solid var(--line); justify-content: flex-start; }
  .railsep { width: 1px; height: 22px; margin: 0 4px; flex: none; }
  .tool { flex: none; }
  .stagecol { min-height: 0; }
  .inspector { border-left: none; border-top: 1px solid var(--line); }
  .pane { overflow: visible; padding: 4px 16px 24px; }
  .brand .backlink { display: none; }
  .filechip { display: none; }
}
@media (max-width: 420px) {
  .row2 { grid-template-columns: 1fr; }
  .topactions .credits { display: none; }
}

/* docs pages (api.html, tokens.html) */
.sep { color: var(--faint); }
.doc { max-width: 920px; margin: 0 auto; padding: 24px 16px 40px; }
.doc h1 { font-size: 24px; margin: 8px 0 16px; line-height: 1.25; }
.doc h2 { margin: 32px 0 8px; font-size: 16px; }
.doc h3 { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--text); display: block; }
.doc p, .doc li { color: var(--text); opacity: 0.92; }
.doc pre { background: var(--chrome); border: 1px solid var(--line); border-radius: 0 8px 8px 8px; padding: 12px; overflow-x: auto; font-size: 12px; line-height: 1.5; margin: 0; }
.doc table { border-collapse: collapse; width: 100%; font-size: 13px; display: block; overflow-x: auto; }
.doc th, .doc td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.doc code { font-size: 12px; background: var(--chrome-2); padding: 0 3px; border-radius: 3px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.doc pre code { background: none; padding: 0; }
.codegroup { margin: 8px 0 16px; }
.doc .tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: -1px; padding: 0; border-bottom: none; }
.doc .tab { flex: none; background: var(--chrome-2); border: 1px solid var(--line); border-bottom: 0; border-radius: 6px 6px 0 0; padding: 4px 10px; font-size: 12px; color: var(--muted); font-weight: 400; }
.doc .tab.active { background: var(--chrome); color: var(--accent); font-weight: 600; }
.statebox { background: var(--chrome); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.statebox p { margin: 4px 0; }
.tokenrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }
.tokenrow .primary { width: auto; }
.tokenbox { word-break: break-all; }
