/* Whiteboard (/whiteboard). The board itself is an SVG styled with attributes
   (see public/js/whiteboard.js) so it exports faithfully; this sheet only
   covers the chrome around it plus the on-screen-only selection affordances. */

main.container:has(.wb-app) { max-width: none; padding: 0; margin-top: 0; overflow: visible; }

.wb-app {
  /* --wb-nav-spill: how far the site header's content overflows its bar on a
     narrow screen (it wraps); the whiteboard starts below that, not under it. */
  padding-top: var(--wb-nav-spill, 0px);
  box-sizing: border-box;
  --wb-tray-w: 320px;
  --wb-sel: #58a6ff;
  position: relative;
  display: flex;
  height: calc(100dvh - var(--wb-top, 90px));
  min-height: 440px;
  background: var(--bg-deep);
  overflow: hidden;
  color: var(--text);
}

/* ── Tray ─────────────────────────────────────────────────────────────────── */
.wb-tray {
  position: relative;
  z-index: 4;
  flex: none;
  width: var(--wb-tray-w);
  margin-left: calc(-1 * var(--wb-tray-w));
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  transition: margin-left 0.25s ease, box-shadow 0.15s;
}
.wb-app.is-tray-open .wb-tray { margin-left: 0; }
.wb-tray.is-drop-remove { box-shadow: inset 0 0 0 3px var(--danger); }
.wb-tray.is-drop-remove::after {
  content: 'Drop to remove';
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--danger-bg) 88%, transparent);
  color: var(--danger); font-weight: 700; letter-spacing: 0.04em;
  pointer-events: none;
}

.wb-tabs { display: flex; gap: 2px; padding: 8px; border-bottom: 1px solid var(--border); align-items: stretch; }
.wb-tab {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 2px 6px; border: 0; border-radius: var(--radius-lg);
  background: none; color: var(--text-muted); font: inherit; font-size: var(--font-xs); font-weight: 600;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.wb-tab i { font-size: 0.95rem; }
.wb-tab:hover { color: var(--text); background: var(--surface-2); }
.wb-tab.is-active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }
.wb-tray-close {
  flex: none; width: 30px; border: 0; border-radius: var(--radius-md);
  background: none; color: var(--text-muted); cursor: pointer;
}
.wb-tray-close:hover { color: var(--text); background: var(--surface-2); }

.wb-panel { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 24px; }
.wb-panel.is-active { display: block; }
.wb-h {
  margin: 18px 0 8px; font-size: var(--font-xs); font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
  display: flex; justify-content: space-between;
}
.wb-panel > .wb-h:first-child { margin-top: 2px; }
.wb-h-val { color: var(--text); letter-spacing: 0; }
.wb-hint { margin: 6px 0 10px; font-size: var(--font-sm); color: var(--text-subtle); line-height: 1.4; }
.wb-hint kbd {
  display: inline-block; min-width: 1.4em; padding: 0 4px; border: 1px solid var(--border-muted);
  border-bottom-width: 2px; border-radius: var(--radius-sm); font: inherit; font-size: 0.7rem; text-align: center;
}
.wb-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

.wb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1 1 auto; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--font-base); font-weight: 600;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.wb-btn:hover { border-color: var(--border-muted); }
.wb-btn-primary { background: var(--accent-emph); border-color: var(--accent-emph); color: var(--on-accent); flex: none; }
.wb-btn-danger { color: var(--danger); }
.wb-btn-danger:hover { border-color: var(--danger-border); background: var(--danger-bg); }

/* Search */
.wb-search { position: relative; }
.wb-search i { z-index: 1; pointer-events: none; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); font-size: 0.85rem; }
.wb-search input {
  width: 100%; padding: 10px 12px 10px 34px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg); color: var(--text); font: inherit; font-size: var(--font-md);
}
.wb-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-fade); }
.wb-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.wb-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: none; color: var(--text-muted); font: inherit; font-size: var(--font-sm); cursor: pointer;
}
.wb-chip:hover { color: var(--text); border-color: var(--border-muted); }
.wb-chip.is-active { color: var(--on-accent); background: var(--accent-emph); border-color: var(--accent-emph); }
.wb-chips-domain { margin-top: 6px; }
.wb-chip-domain span { width: 8px; height: 8px; border-radius: 50%; background: var(--dc); }
.wb-chip-domain.is-active { background: color-mix(in srgb, var(--dc) 22%, transparent); border-color: var(--dc); color: var(--text); }

.wb-results {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-flow: dense; gap: 8px;
}
.wb-result {
  position: relative; padding: 0; border: 0; border-radius: 7px; overflow: hidden;
  aspect-ratio: 0.716; background: var(--surface-2); cursor: grab;
  transition: transform 0.12s, box-shadow 0.12s;
}
.wb-result.is-landscape { grid-column: span 2; aspect-ratio: 1.397; }
/* Battlefield art is a portrait image with the picture on its side. */
.wb-result.is-landscape img {
  position: absolute; left: 50%; top: 50%; width: 71.6%; height: 139.7%;
  transform: translate(-50%, -50%) rotate(90deg);
}
.wb-result img { display: block; width: 100%; height: 100%; object-fit: cover; }
.wb-result:hover { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--accent), var(--shadow-md); }
.wb-result:active { cursor: grabbing; }
.wb-results-status { margin: 10px 0 0; font-size: var(--font-sm); color: var(--text-subtle); text-align: center; }

/* Counters */
.wb-token-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.wb-token-preset {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 12px 4px 9px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-2); color: var(--text-muted); font: inherit; font-size: var(--font-sm); cursor: grab;
  transition: border-color 0.15s, color 0.15s;
}
.wb-token-preset:hover { border-color: var(--border-muted); color: var(--text); }
.wb-token-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px;
  min-width: 34px; height: 30px; padding: 0 10px; border: 2px solid #fff; border-radius: var(--radius-pill);
  background: var(--tc); color: #fff; font-weight: 800; font-size: 0.9rem; box-shadow: var(--shadow-sm);
}
.wb-token-chip-damage, .wb-token-chip-counter { width: 34px; height: 34px; padding: 0; }
.wb-token-chip-stun { font-size: 0.68rem; letter-spacing: 0.08em; }

.wb-label-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.wb-label-chip {
  padding: 5px 11px; border: 0; border-radius: var(--radius-pill);
  background: var(--tc); color: #fff; font: inherit; font-size: var(--font-sm); font-weight: 700; cursor: grab;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,0.35);
}
.wb-label-chip:hover { filter: brightness(1.12); }
.wb-zone-chip {
  background: none; color: var(--text-2); border: 1.5px dashed var(--border-muted); box-shadow: none;
}
.wb-zone-chip:hover { border-color: var(--text-muted); filter: none; }
.wb-custom-label { display: flex; gap: 6px; margin-top: 10px; }
.wb-custom-label input {
  flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--bg); color: var(--text); font: inherit;
}
.wb-custom-label input:focus { outline: none; border-color: var(--accent); }

.wb-swatches { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 8px; }
.wb-swatch {
  width: 26px; height: 26px; padding: 0; border-radius: 50%; cursor: pointer;
  background: var(--sw); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-muted);
  transition: transform 0.12s;
}
.wb-swatch:hover { transform: scale(1.1); }
.wb-swatch.is-active { box-shadow: 0 0 0 2px var(--accent); }
.wb-swatches-lg .wb-swatch { width: 38px; height: 38px; border-radius: var(--radius-lg); }
/* The ten pen and label colours: one even row across the tray. */
#wb-ink-colors, #wb-label-colors { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; }
#wb-ink-colors .wb-swatch, #wb-label-colors .wb-swatch { width: 100%; height: auto; aspect-ratio: 1; }

.wb-seg { display: flex; padding: 3px; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.wb-seg-btn {
  flex: 1; min-width: 0; padding: 6px 4px; border: 0; border-radius: 7px;
  background: none; color: var(--text-muted); font: inherit; font-size: var(--font-sm); font-weight: 600; cursor: pointer;
}
.wb-seg-btn:hover { color: var(--text); }
.wb-seg-btn.is-active { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-sm); }

.wb-tool-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.wb-tool {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 2px 7px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface-2); color: var(--text-muted); font: inherit; font-size: 0.66rem; cursor: pointer;
}
.wb-tool i { font-size: 1rem; }
.wb-tool:hover { color: var(--text); }
.wb-tool.is-active { color: var(--accent); border-color: var(--accent); background: var(--accent-fade); }

.wb-scenes { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.wb-scene {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2);
}
.wb-scene.is-current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.wb-scene-open {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 5px 6px;
  border: 0; background: none; color: var(--text); font: inherit; font-size: var(--font-base); text-align: left; cursor: pointer;
}
.wb-scene-num {
  flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  background: var(--bg); color: var(--text-muted); font-size: var(--font-xs); font-weight: 700;
}
.wb-scene.is-current .wb-scene-num { background: var(--accent-emph); color: var(--on-accent); }
.wb-scene-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.wb-scene-act {
  flex: none; width: 26px; height: 26px; border: 0; border-radius: 6px;
  background: none; color: var(--text-subtle); font-size: 0.72rem; cursor: pointer;
}
.wb-scene-act:hover:not(:disabled) { color: var(--text); background: var(--surface); }
.wb-scene-act:disabled { opacity: 0.3; cursor: default; }
.wb-scene-input {
  flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--accent); border-radius: 7px;
  background: var(--bg); color: var(--text); font: inherit; font-weight: 600;
}
.wb-scene-input:focus { outline: none; }
.wb-keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 0; font-size: var(--font-sm); }
.wb-keys dt { white-space: nowrap; color: var(--text-2); }
.wb-keys dd { margin: 0; color: var(--text-muted); }
.wb-rune-steppers { display: flex; flex-direction: column; gap: 5px; }
.wb-rune-step {
  display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 9px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2);
}
.wb-rune-step.has-runes { border-color: var(--rc); box-shadow: inset 3px 0 0 var(--rc); }
.wb-rune-gem {
  flex: none; width: 15px; height: 21px; border-radius: 3px; background: var(--rc);
  display: grid; place-items: center; color: #fff; font-size: 0.6rem; font-weight: 800;
}
.wb-rune-name { flex: 1; min-width: 0; font-size: var(--font-sm); font-weight: 600; }
.wb-rune-n { min-width: 16px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.wb-rune-btn {
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
  background: var(--bg); color: var(--text-muted); font-size: 0.7rem; cursor: pointer;
}
.wb-rune-btn:hover:not(:disabled) { color: var(--text); }
.wb-rune-btn:disabled { opacity: 0.35; cursor: default; }
.wb-rune-total { margin: 8px 0 10px; font-size: var(--font-sm); color: var(--text-muted); text-align: right; }
.wb-btn-grow { flex: 1 1 0; }
.wb-zone-toggle i { font-size: 0.65rem; opacity: 0; width: 0; transition: width 0.15s, opacity 0.15s; }
.wb-zone-toggle.is-active { background: var(--accent-fade); border-color: var(--accent); color: var(--text); }
.wb-zone-toggle.is-active i { opacity: 1; width: 0.75em; }
.wb-zone-row { align-items: center; justify-content: space-between; margin-top: 8px; }
.wb-zone-row .wb-chip { margin: 0; }
.wb-zone-quick { font-size: var(--font-sm); color: var(--text-subtle); }
.wb-link { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.wb-link:hover { text-decoration: underline; }
#wb-mat-zones[hidden] { display: none; }
.wb-pill-btn.is-on { color: var(--accent); }
.wb-range { width: 100%; accent-color: var(--accent); }

/* ── Stage & board ────────────────────────────────────────────────────────── */
.wb-stage { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wb-board-wrap {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 66px 22px 22px;
}
.wb-board {
  display: block; flex: none; overflow: hidden;
  border-radius: 14px;
  background: var(--wb-board-bg, #1c2026);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.wb-board.wb-tool-select .wb-card,
.wb-board.wb-tool-select .wb-token,
.wb-board.wb-tool-select .wb-box rect { cursor: grab; }
.wb-app.is-dragging .wb-board, .wb-app.is-dragging .wb-board * { cursor: grabbing !important; }
.wb-board.wb-tool-pen, .wb-board.wb-tool-hl, .wb-board.wb-tool-arrow { cursor: crosshair; }
.wb-board.wb-tool-eraser { cursor: cell; }
.wb-board:not(.wb-tool-select) .wb-card,
.wb-board:not(.wb-tool-select) .wb-token,
.wb-board:not(.wb-tool-select) .wb-box { pointer-events: none; }

.wb-board .is-selected { filter: drop-shadow(0 0 1.5px var(--wb-sel)) drop-shadow(0 0 7px var(--wb-sel)); }
.wb-handle { fill: #fff; stroke: var(--wb-sel); stroke-width: 3; cursor: nwse-resize; }
.wb-marquee { fill: rgba(88,166,255,0.12); stroke: var(--wb-sel); stroke-width: 1.5; stroke-dasharray: 6 4; pointer-events: none; }


/* Floating tool pill */
.wb-pill {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 2px; padding: 5px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
  transition: opacity 0.2s;
  white-space: nowrap;
}
.wb-pill-tools { display: flex; gap: 2px; }
.wb-pill-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: none; color: var(--text-muted); font-size: 0.95rem; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.wb-pill-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.wb-pill-btn.is-active { background: var(--accent-emph); color: var(--on-accent); }
.wb-pill-btn:disabled { opacity: 0.35; cursor: default; }
.wb-scene-chip {
  max-width: 130px; height: 32px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--font-sm); font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
}
.wb-scene-chip:hover { border-color: var(--border-muted); }
.wb-pill-color span { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-muted); }
.wb-pill > *, .wb-pill-tools > * { flex: none; }
.wb-pill-text { width: auto; padding: 0 12px; border-radius: var(--radius-pill); font: inherit; font-size: var(--font-sm); font-weight: 700; }
.wb-pill-sep { width: 1px; height: 22px; margin: 0 4px; background: var(--border); }
.wb-app.is-tray-open #wb-tray-toggle { color: var(--accent); }

/* Selection toolbar */
.wb-seltools {
  position: absolute; z-index: 6;
  /* Wraps onto a second row rather than running off a narrow screen. */
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px; padding: 4px;
  max-width: calc(100% - 16px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  white-space: nowrap;
}
.wb-seltools[hidden] { display: none; }
.wb-seltools > * { flex: none; }
.wb-st-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 32px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px;
  background: none; color: var(--text-2); font: inherit; font-size: var(--font-sm); font-weight: 600; cursor: pointer;
}
.wb-st-btn:hover { background: var(--surface-2); color: var(--text); }
.wb-st-btn.is-on { color: var(--accent); background: var(--accent-fade); }
.wb-st-btn.is-open { background: var(--surface-2); color: var(--text); }
.wb-st-btn.is-danger:hover { color: var(--danger); background: var(--danger-bg); }
.wb-st-dot { width: 11px; height: 11px; border-radius: 50%; box-shadow: 0 0 0 1.5px rgba(255,255,255,0.7); }
.wb-st-sep { width: 1px; height: 20px; margin: 0 3px; background: var(--border); }
.wb-st-count { padding: 0 8px; font-size: var(--font-sm); font-weight: 700; color: var(--text-muted); }
.wb-st-size { font-size: var(--font-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.wb-st-val { min-width: 34px; text-align: center; font-weight: 800; font-size: var(--font-md); font-variant-numeric: tabular-nums; }

/* Colour palette, opened from the selection toolbar's colour buttons. */
.wb-colorpop {
  position: absolute; z-index: 7;
  display: grid; grid-template-columns: repeat(5, auto); gap: 8px; padding: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.wb-colorpop[hidden] { display: none; }

.wb-note-edit {
  position: absolute; z-index: 7; box-sizing: border-box; margin: 0;
  border: 2px solid var(--accent); border-radius: 10px; outline: none;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 600; line-height: 1.3; resize: none; overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.wb-note-edit[hidden] { display: none; }
.wb-board .wb-note.is-editing { opacity: 0; }
.wb-text-edit {
  position: absolute; z-index: 7; height: 36px; padding: 0 10px;
  border: 2px solid var(--accent); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 700;
  box-shadow: var(--shadow-lg);
}
.wb-text-edit:focus { outline: none; }

.wb-toast {
  position: absolute; left: 50%; bottom: 18px; z-index: 8;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  padding: 8px 16px; border-radius: var(--radius-pill);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md);
  font-size: var(--font-base); font-weight: 600;
  transition: opacity 0.2s, transform 0.2s;
}
.wb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.wb-inspect {
  position: fixed; inset: 0; z-index: 3000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(0,0,0,0.78); backdrop-filter: blur(3px); cursor: zoom-out;
}
.wb-inspect[hidden] { display: none; }
.wb-inspect img { max-height: 88vh; max-width: min(92vw, 520px); border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.wb-inspect img.is-landscape { max-width: min(94vw, 900px); }
.wb-inspect img.is-turned { transform: rotate(90deg); max-width: min(88vh, 640px); max-height: min(92vw, 900px); }

/* ── Focus mode: the board and nothing else, for a stream capture ─────────── */
.wb-app.is-focus { position: fixed; inset: 0; z-index: 2000; height: 100dvh; }
.wb-app.is-focus .wb-board-wrap { padding: 12px; }
.wb-app.is-focus .wb-pill { opacity: 0.18; }
.wb-app.is-focus .wb-pill:hover, .wb-app.is-focus .wb-pill:focus-within { opacity: 1; }
.wb-app.is-focus .wb-board { border-radius: 6px; }

.wb-grip { display: none; }

/* ── Phones: a dock at the bottom — the toolbar, and the tray as a sheet under
   it. The board fits the room left above, so the tray never covers any of it
   (an overlaid sheet did, which meant closing it to see the board and opening
   it again to add anything). Dragging the grip, the toolbar or the tabs sizes
   the sheet; public/js/whiteboard.js sets --wb-sheet-h. ────────────────────── */
@media (max-width: 720px) {
  .wb-app { flex-direction: column; min-height: 360px; }
  .wb-stage { flex: 1; min-height: 0; }
  /* Swiping beside the board would scroll the page, dock and all. */
  .wb-board-wrap { padding: 8px; touch-action: none; }

  .wb-tray {
    order: 2; flex: none;
    width: auto; height: var(--wb-sheet-h, 55%); margin-left: 0;
    border-right: 0; border-top: 1px solid var(--border);
    overflow: hidden;
    transition: height 0.25s ease, visibility 0s;
  }
  .wb-app:not(.is-tray-open) .wb-tray {
    height: 0; border-top-width: 0; visibility: hidden;
    transition: height 0.25s ease, visibility 0s 0.25s;
  }
  .wb-app.is-sheet-drag .wb-tray { transition: none; }
  .wb-tabs { padding: 4px 8px; touch-action: none; }
  .wb-tab { padding: 6px 2px 5px; gap: 3px; }
  .wb-tray-close i { transform: rotate(-90deg); }
  .wb-panel { padding-top: 10px; overscroll-behavior: contain; }
  /* The card filters are one swipeable row each, so results show sooner. */
  #wb-type-chips, #wb-domain-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -14px; padding-right: 14px; }
  #wb-type-chips > *, #wb-domain-chips > * { flex: none; }

  .wb-grip {
    order: 2; flex: none;
    display: flex; align-items: center; justify-content: center;
    height: 20px; padding: 0; border: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0;
    background: var(--surface); box-shadow: var(--shadow-up);
    cursor: ns-resize; touch-action: none;
  }
  .wb-grip span { width: 36px; height: 4px; border-radius: 2px; background: var(--border-muted); }

  .wb-pill {
    order: 3; position: static; transform: none;
    padding: 0 6px 6px; border: 0; border-radius: 0;
    background: var(--surface); box-shadow: none; backdrop-filter: none;
    overflow-x: auto; scrollbar-width: none; touch-action: pan-x;
  }
  /* Centred, but still scrollable from its first button when it overflows. */
  .wb-pill > :first-child { margin-left: auto; }
  .wb-pill > :last-child { margin-right: auto; }
  .wb-pill-btn { width: 34px; height: 34px; font-size: 0.9rem; }
  .wb-pill-text { width: auto; padding: 0 9px; font-size: var(--font-xs); }
  /* Highlighter, arrow and the board switcher stay in the tray on a phone. */
  .wb-pill [data-tool="hl"], .wb-pill [data-tool="arrow"], .wb-pill [data-tool="text"], .wb-pill-scene, .wb-pill-scene + .wb-pill-sep, #wb-zones-toggle { display: none; }
  .wb-pill-sep { margin: 0 2px; }
  .wb-results { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* The dock is at the bottom, so messages drop in from the top. */
  .wb-toast { top: 12px; bottom: auto; transform: translate(-50%, -12px); }

  .wb-app.is-focus .wb-grip { display: none; }

  .wb-st-btn span:not(.wb-st-dot):not(.wb-st-size):not(.wb-st-keep) { display: none; }
  .wb-colorpop { gap: 10px; }
  .wb-colorpop .wb-swatch { width: 32px; height: 32px; }
  .wb-scene-chip { max-width: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  .wb-tray, .wb-app:not(.is-tray-open) .wb-tray, .wb-result, .wb-toast { transition: none; }
}
