/* ---------------------------------------------------------------------------
   Board: flat desktop-utility chrome.
   Neutral graphite surfaces, 1px hairlines, 4-6px radii, one accent that only
   marks the active tool, the default action and focus. Numbers (room, zoom,
   sizes, coordinates) are set in the mono stack with tabular figures.
   ------------------------------------------------------------------------- */
:root {
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  /* Mirrors FONT_STACK in render.js so the inline text editor matches committed text. */
  --canvas-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bar: #f6f6f7;            /* top bar, options bar, tool rail, status bar */
  --desk: #e2e3e6;           /* behind the paper; app.js reads this */
  --surface: #ffffff;        /* menus, dialogs */
  --raised: #ffffff;         /* buttons and fields that sit on a bar */
  --footer: #f6f6f7;         /* dialog action strip */
  --line: #dcdde1;           /* hairline between regions */
  --line-strong: #c2c4ca;    /* control outline */
  --text: #1a1b1e;
  --text-2: #51545b;
  --text-3: #6a6d75;
  --hover: rgba(20, 22, 28, 0.06);
  --active: rgba(20, 22, 28, 0.11);
  --accent: #2c5cc5;         /* fills; carries white text */
  --accent-hover: #244fae;
  --accent-text: #2c5cc5;    /* accent used as ink on a surface; app.js reads this for handles */
  --accent-soft: rgba(44, 92, 197, 0.1);
  --danger: #c8323a;         /* fill; carries white text */
  --danger-text: #bd2830;
  --ok: #23945f;
  --warn: #c98200;
  --thumb: #ffffff;
  --thumb-line: #a4a7af;
  --toast: #25262a;
  --toast-ink: #f4f4f6;
  --scrim: rgba(18, 19, 22, 0.32);
  --shadow-pop: 0 6px 20px rgba(18, 19, 22, 0.14), 0 1px 3px rgba(18, 19, 22, 0.08);
  --shadow-dialog: 0 16px 48px rgba(18, 19, 22, 0.22), 0 2px 6px rgba(18, 19, 22, 0.1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bar: #242528;
    --desk: #17181a;
    --surface: #2b2c30;
    --raised: #313237;
    --footer: #26272b;
    --line: #36373c;
    --line-strong: #4c4e55;
    --text: #ededf0;
    --text-2: #b4b6bd;
    --text-3: #999ba3;
    --hover: rgba(255, 255, 255, 0.07);
    --active: rgba(255, 255, 255, 0.13);
    --accent: #3a68d0;
    --accent-hover: #3e6fd9;
    --accent-text: #8aadff;
    --accent-soft: rgba(110, 150, 255, 0.16);
    --danger-text: #ff8a8e;
    --ok: #3fbf83;
    --warn: #e2a52b;
    --thumb: #d9dade;
    --thumb-line: #d9dade;
    --toast: #ededf0;
    --toast-ink: #1a1b1e;
    --scrim: rgba(0, 0, 0, 0.5);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-dialog: 0 18px 54px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bar: #242528;
  --desk: #17181a;
  --surface: #2b2c30;
  --raised: #313237;
  --footer: #26272b;
  --line: #36373c;
  --line-strong: #4c4e55;
  --text: #ededf0;
  --text-2: #b4b6bd;
  --text-3: #999ba3;
  --hover: rgba(255, 255, 255, 0.07);
  --active: rgba(255, 255, 255, 0.13);
  --accent: #3a68d0;
  --accent-hover: #3e6fd9;
  --accent-text: #8aadff;
  --accent-soft: rgba(110, 150, 255, 0.16);
  --danger-text: #ff8a8e;
  --ok: #3fbf83;
  --warn: #e2a52b;
  --thumb: #d9dade;
  --thumb-line: #d9dade;
  --toast: #ededf0;
  --toast-ink: #1a1b1e;
  --scrim: rgba(0, 0, 0, 0.5);
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-dialog: 0 18px 54px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bar);
  color: var(--text);
  font: 12.5px/1.4 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 1px; }

#app {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  grid-template-rows: 40px 44px minmax(0, 1fr) 26px;
  height: 100vh;
  height: 100dvh;
}

/* ------------------------------------------------------------------ top bar */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px 0 12px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; margin-right: 6px; }
.brand .logo { width: 20px; height: 20px; }
.spacer { flex: 1; min-width: 4px; }
.tb-group { display: flex; gap: 1px; }
.tb-btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 28px; border: 0; background: transparent; border-radius: 5px; white-space: nowrap;
}
.tb-btn { padding: 0 8px; }
.icon-btn { width: 28px; padding: 0; color: var(--text-2); }
.tb-btn:hover, .icon-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn:active, .icon-btn:active { background: var(--active); }
.icon-btn:disabled { opacity: 0.38; background: transparent; }
.tb-btn[aria-expanded="true"] { background: var(--active); }
.menu-btn { gap: 3px; padding: 0 5px 0 8px; }
.menu-btn .caret { width: 12px; height: 12px; color: var(--text-2); }
.menu-btn .burger { display: none; }

/* Room name and the button that copies its link, as one joined control. */
.link-group {
  display: flex; align-items: stretch; height: 26px; min-width: 0;
  border: 1px solid var(--line-strong); border-radius: 5px; background: var(--raised);
}
.room { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 0 9px; }
.room-label { color: var(--text-2); font-size: 12px; }
#room-name {
  font: 11.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--text);
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tb-btn.share {
  height: auto; margin: -1px -1px -1px 0; padding: 0 10px 0 8px; border-radius: 0 5px 5px 0;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 12px;
}
.tb-btn.share svg { width: 14px; height: 14px; }
.tb-btn.share:hover { background: var(--accent-hover); color: #fff; }
.tb-btn.share:active { background: var(--accent-hover); }

.peers { display: flex; align-items: center; padding-left: 6px; }
.peer {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 600; letter-spacing: 0.01em; color: #fff;
  border: 0; box-shadow: 0 0 0 1.5px var(--bar);
  margin-left: -5px; cursor: default; position: relative;
}
.peer.self { cursor: pointer; margin-left: 0; padding: 0; }
.peer.self:hover { box-shadow: 0 0 0 1.5px var(--bar), 0 0 0 2.5px var(--text-3); }
.peer.self + .peer { margin-left: 5px; }
.peer.more { background: var(--raised) !important; color: var(--text-2) !important; box-shadow: 0 0 0 1.5px var(--bar), inset 0 0 0 1px var(--line-strong); }

.status {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 6px 0 4px;
  font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.status[data-level="ok"] i { background: var(--ok); }
.status[data-level="off"] i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--text-3); }

/* ------------------------------------------------------------------ options bar */
.optbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 14px;
  padding: 0 8px 0 12px;
  background: var(--bar);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  overflow: hidden;
}
.opt-title {
  font-weight: 600; min-width: 100px; height: 20px; line-height: 20px; padding-right: 12px;
  border-right: 1px solid var(--line); white-space: nowrap;
}
.opt { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); white-space: nowrap; }
.opt > span { font-size: 12px; }
.opt output { font: 11.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--text); min-width: 5ch; }
.opt.hint { font-size: 12px; overflow: hidden; text-overflow: ellipsis; min-width: 0; display: block; }

/* Sliders: a hairline track filled up to the thumb (app.js sets --fill). */
.opt input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 116px; height: 20px; margin: 0;
  background: transparent; cursor: pointer; --fill: 0%;
}
.opt input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; border-radius: 1px;
  background: linear-gradient(to right, var(--text-2) var(--fill), var(--line-strong) var(--fill));
}
.opt input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%;
  background: var(--thumb); border: 1px solid var(--thumb-line); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14);
}
.opt input[type="range"]::-moz-range-track { height: 2px; border-radius: 1px; background: var(--line-strong); }
.opt input[type="range"]::-moz-range-progress { height: 2px; border-radius: 1px; background: var(--text-2); }
.opt input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--thumb); border: 1px solid var(--thumb-line); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14);
}
.opt input[type="range"]:focus-visible { outline: none; }
.opt input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent-text); outline-offset: 1px; }
.opt input[type="range"]:focus-visible::-moz-range-thumb { outline: 2px solid var(--accent-text); outline-offset: 1px; }

.opt.check { gap: 7px; cursor: pointer; }
.opt.check input { accent-color: var(--accent); margin: 0; width: 14px; height: 14px; cursor: pointer; }

.seg { gap: 0; height: 26px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--raised); overflow: hidden; }
.seg button {
  border: 0; border-left: 1px solid var(--line); background: transparent; align-self: stretch; padding: 0 11px;
  color: var(--text-2); font-size: 12px;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--hover); color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--active); color: var(--text); }
.seg button:focus-visible { outline-offset: -2px; }

.opt.toggle { height: 26px; padding: 0 10px 0 9px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--raised); }
.opt.toggle:hover { color: var(--text); }
.opt.toggle[aria-pressed="true"] { background: var(--active); border-color: var(--text-3); color: var(--text); }

.colors { display: flex; align-items: center; gap: 12px; align-self: stretch; padding-left: 14px; border-left: 1px solid var(--line); }
.swatch-pair { position: relative; width: 36px; height: 32px; flex: none; }
.sw-main, .sw-sub {
  position: absolute; width: 22px; height: 22px; border-radius: 3px; border: 2px solid var(--bar);
  box-shadow: 0 0 0 1px var(--thumb-line); padding: 0;
}
.sw-main { left: 1px; top: 1px; z-index: 2; }
.sw-sub { left: 13px; top: 9px; z-index: 1; }
.sw-swap { position: absolute; right: -7px; top: -3px; width: 14px; height: 14px; border: 0; padding: 0; background: transparent; color: var(--text-2); border-radius: 3px; }
.sw-swap svg { width: 12px; height: 12px; display: block; margin: 1px; }
.sw-swap:hover { color: var(--text); }
.palette { display: grid; grid-template-columns: repeat(14, 16px); grid-auto-rows: 16px; gap: 2px; margin-left: 4px; }
.palette button {
  width: 16px; height: 16px; border-radius: 2px; border: 0; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(128, 128, 128, 0.45);
}
.palette button:hover { outline: 1px solid var(--text); outline-offset: 1px; }
.custom-color {
  position: relative; width: 28px; height: 28px; border-radius: 5px; display: grid; place-items: center;
  cursor: pointer; color: var(--text-2);
}
.custom-color:hover { background: var(--hover); color: var(--text); }
.custom-color input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* ------------------------------------------------------------------ tool rail */
.toolrail {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  background: var(--bar); border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden;
}
.tool {
  width: 32px; height: 32px; flex: none; border: 0; border-radius: 5px; padding: 0;
  background: transparent; display: grid; place-items: center; color: var(--text-2);
}
.tool svg { width: 18px; height: 18px; }
.tool:hover { background: var(--hover); color: var(--text); }
.tool:active { background: var(--active); }
.tool.active, .tool.active:hover { background: var(--accent); color: #fff; }
.rail-sep { width: 20px; height: 1px; background: var(--line); margin: 4px 0; flex: none; }

/* ------------------------------------------------------------------ stage */
.stage { position: relative; overflow: hidden; background: var(--desk); touch-action: none; min-width: 0; min-height: 0; }
.stage canvas { position: absolute; left: 0; top: 0; display: block; }
#cv-ui { cursor: crosshair; touch-action: none; }
.stage[data-cursor="grab"] #cv-ui { cursor: grab; }
.stage[data-cursor="grabbing"] #cv-ui { cursor: grabbing; }
.stage[data-cursor="move"] #cv-ui { cursor: move; }
.stage[data-cursor="text"] #cv-ui { cursor: text; }
.stage[data-cursor="nwse"] #cv-ui { cursor: nwse-resize; }
.stage[data-cursor="nesw"] #cv-ui { cursor: nesw-resize; }
.stage[data-cursor="none"] #cv-ui { cursor: none; }
.stage[data-cursor="copy"] #cv-ui { cursor: copy; }

#text-editor {
  position: absolute; z-index: 5; margin: 0; padding: 0; border: 0; outline: 1px dashed var(--accent);
  outline-offset: 2px; background: transparent; resize: none; overflow: hidden; white-space: pre;
  font-family: var(--canvas-font); line-height: 1.25; min-width: 20px; user-select: text; -webkit-user-select: text;
}

.drop-hint {
  position: absolute; inset: 12px; z-index: 6; border: 1px dashed var(--accent-text); border-radius: 6px;
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--text); pointer-events: none;
}
.drop-hint svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ status bar */
.statusbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; padding: 0 4px 0 0;
  background: var(--bar); border-top: 1px solid var(--line);
  font: 11px var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2);
  min-width: 0; overflow: hidden;
}
.hud { display: flex; align-items: center; min-width: 0; overflow: hidden; }
.hud-item { display: inline-flex; align-items: center; gap: 7px; height: 14px; padding: 0 14px; border-right: 1px solid var(--line); white-space: nowrap; }
.hud-item svg { width: 12px; height: 12px; stroke-width: 1.8; color: var(--text-3); }
#hud-pos { min-width: 10ch; }
#hud-size::after { content: " px"; }
.zoombar { margin-left: auto; flex: none; display: flex; align-items: center; gap: 1px; }
.zoombar .icon-btn { width: 24px; height: 20px; border-radius: 4px; }
.zoombar svg { width: 14px; height: 14px; }
.zoom-label {
  min-width: 46px; height: 20px; padding: 0 4px; border: 0; background: transparent; border-radius: 4px;
  font: inherit; font-variant-numeric: tabular-nums; color: var(--text);
}
.zoom-label:hover { background: var(--hover); }
.zoom-label:active { background: var(--active); }
.bar-sep { width: 1px; height: 14px; background: var(--line); margin: 0 5px; }
#btn-grid[aria-pressed="true"] { background: var(--active); color: var(--text); }

/* ------------------------------------------------------------------ popovers & dialogs */
.catch { position: fixed; inset: 0; z-index: 40; background: transparent; }
.popover {
  position: fixed; z-index: 41; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px;
  box-shadow: var(--shadow-pop); padding: 4px;
}
.menu { min-width: 248px; display: flex; flex-direction: column; }
.menu button {
  display: flex; align-items: center; gap: 10px; height: 28px; padding: 0 10px 0 8px; border: 0; background: transparent;
  border-radius: 4px; text-align: left;
}
.menu button svg { width: 15px; height: 15px; color: var(--text-2); }
.menu button span { flex: 1; }
.menu button kbd { font: 11.5px var(--font); color: var(--text-2); }
.menu button:hover { background: var(--hover); }
.menu button:active { background: var(--active); }
.menu button:focus-visible { outline-offset: -2px; }
.menu button.danger, .menu button.danger svg { color: var(--danger-text); }
.menu-sep { height: 1px; background: var(--line); margin: 4px -4px; }

.profile { width: 232px; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text-2); }
.field input[type="number"], .field input:not([type]) {
  height: 28px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 0 8px; background: var(--raised);
  color: var(--text); font: 12.5px var(--font); user-select: text; -webkit-user-select: text; min-width: 0;
}
.field input[type="number"] { font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.field input:focus { outline: 2px solid var(--accent-text); outline-offset: -1px; }
.profile-colors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 7px; }
.profile-colors button { aspect-ratio: 1; border-radius: 50%; border: 0; padding: 0; }
.profile-colors button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--text); }

.dialog-wrap { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: grid; place-items: center; padding: 12px; }
.dialog {
  width: min(500px, 100%); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: var(--shadow-dialog); padding: 0 16px; display: flex; flex-direction: column; gap: 14px;
  max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
}
.dialog > * { flex: none; }
.dialog.small { width: min(380px, 100%); }
.dialog.keys { width: min(600px, 100%); }
.dialog h2 {
  margin: 0 -16px; padding: 11px 16px 10px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600;
  position: sticky; top: 0; z-index: 1; background: var(--surface);
}
.dialog p { margin: 0; color: var(--text-2); }
.dialog .note { font-size: 12px; color: var(--text-2); }
.dialog .row { display: flex; align-items: flex-end; gap: 10px; }
.dialog .row .field { flex: 1; min-width: 0; }
.dialog .times { padding-bottom: 6px; color: var(--text-3); }
.color-field input { width: 100%; height: 28px; border: 1px solid var(--line-strong); border-radius: 5px; padding: 2px; background: var(--raised); cursor: pointer; }
.presets { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.presets button {
  border: 1px solid var(--line); background: transparent; border-radius: 5px; padding: 6px 9px 7px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; min-width: 0;
}
.presets button b { font-size: 12px; font-weight: 600; }
.presets button small { font: 10.5px var(--mono); font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.presets button:hover { background: var(--hover); border-color: var(--line-strong); }
.presets button[aria-pressed="true"] { border-color: var(--accent-text); box-shadow: inset 0 0 0 1px var(--accent-text); background: var(--accent-soft); }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin: 0 -16px; padding: 10px 16px;
  border-top: 1px solid var(--line); background: var(--footer); position: sticky; bottom: 0; z-index: 1;
}
.btn {
  height: 28px; min-width: 76px; padding: 0 14px; border-radius: 5px; border: 1px solid var(--line-strong);
  background: var(--raised); font-weight: 500;
}
.btn:hover { border-color: var(--text-3); }
.btn:active { background: var(--active); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger:hover { filter: brightness(0.93); }
.keys-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 20px; color: var(--text-2); font-size: 12px; }
.keys-grid kbd, .menu kbd { display: inline-block; }
.keys-grid kbd {
  min-width: 20px; padding: 2px 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px;
  background: var(--footer); color: var(--text); font: 10.5px/1.3 var(--mono); text-align: center; margin-right: 3px;
}

.toast {
  position: fixed; left: 50%; top: 96px; transform: translateX(-50%); z-index: 60;
  background: var(--toast); color: var(--toast-ink); padding: 7px 12px; border-radius: 5px; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); pointer-events: none; white-space: nowrap;
}

/* ------------------------------------------------------------------ narrower windows */
@media (max-width: 1500px) {
  .opt input[type="range"] { width: 96px; }
  .optbar { gap: 12px; }
}
@media (max-width: 1180px) {
  .opt-title { display: none; }
  .opt.hint { display: none; }
  .room-label { display: none; }
  .opt.check span, .opt.toggle span { display: none; }
}
@media (max-width: 900px) {
  #app { grid-template-rows: 40px auto minmax(0, 1fr) 26px; }
  .optbar { flex-wrap: wrap; padding: 6px 8px; row-gap: 6px; }
  .colors { border-left: 0; padding-left: 0; }
  .tb-btn span, .brand span, .room { display: none; }
  .menu-btn { padding: 0 6px; }
  .menu-btn .burger { display: block; }
  .menu-btn .caret { display: none; }
  .tb-btn.share { border-radius: 4px; margin: -1px; padding: 0 8px; }
  .palette { grid-template-columns: repeat(14, 15px); grid-auto-rows: 15px; }
  .palette button { width: 15px; height: 15px; }
  .hud-item { padding: 0 10px; }
  .toast { top: auto; bottom: 40px; }
}
@media (max-width: 480px) {
  /* Phone width: keep the board size and zoom readable side by side; the pointer readout goes. */
  .hud-item:first-child { display: none; }
  .hud-item { padding: 0 8px; gap: 5px; border-right: 0; }
  #hud-size::after { content: none; }
  .bar-sep { margin: 0 2px; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .presets button small { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .keys-grid { grid-template-columns: minmax(0, 1fr); }
  .toast { white-space: normal; width: max-content; max-width: calc(100vw - 32px); text-align: center; }
}
