/* Lawh — chrome layout: top bar, stage, panel, dock, tray, messages. Board materials live in boards.css. */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: var(--lh);
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--dock-h);
  grid-template-areas: "top" "main" "dock";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* studio wall: flat tone + faint noise, no decoration */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  background-size: 160px 160px;
  opacity: var(--noise-alpha);
  pointer-events: none;
  z-index: -1;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------- icons & buttons ---------- */
.ic {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
.ic--play { fill: currentColor; stroke: none; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--chip);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  user-select: none;
  white-space: nowrap;
}
.btn:hover { background: var(--chip-hover); border-color: var(--line-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn--icon { width: 34px; padding: 0; }
.btn--ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn--primary {
  background: var(--fg);
  color: var(--bg);
  border-color: transparent;
}
.btn--primary:hover { background: var(--fg); opacity: 0.92; }
.btn--toggle[aria-pressed="true"] {
  background: var(--accent-chrome);
  border-color: var(--accent-chrome);
  color: var(--accent-ink);
}
.btn--toggle[aria-pressed="true"]:hover { background: #f26e10; }

/* ---------- top bar ---------- */
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--fg);
  text-decoration: none;
  padding: 0 4px 4px;
  margin-inline-end: 4px;
  letter-spacing: 0.01em;
}
.wordmark:focus-visible { outline: none; border-radius: var(--r-xs); box-shadow: var(--focus); }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

/* theme chips: tiny realistic swatches of each board */
.themes {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: var(--r-md);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--fg-2);
  cursor: pointer;
  font: inherit;
  font-size: var(--fs-xs);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.chip:hover { background: var(--chip-hover); color: var(--fg); }
.chip[aria-checked="true"] { background: var(--chip); color: var(--fg); border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.chip:focus-visible { outline: none; box-shadow: var(--focus); }
.chip__label { display: none; padding-inline-end: 6px; }
.chip[aria-checked="true"] .chip__label { display: inline; }

.swatch {
  position: relative;
  display: block;
  width: 30px; height: 20px;
  border-radius: 4px;
  overflow: hidden;
  flex: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.14) inset;
}
.swatch::before, .swatch::after { content: ""; position: absolute; }
.swatch[data-swatch="whiteboard"] {
  background: linear-gradient(135deg, #ffffff 0%, #f5f6f6 55%, #e9ebeb 100%);
  border: 2px solid #b9bdc2;
  border-bottom-width: 4px;
}
.swatch[data-swatch="whiteboard"]::before { inset: auto 4px 1px; height: 2px; border-radius: 1px; background: #4a74ff; opacity: 0.9; }
.swatch[data-swatch="chalkboard"] {
  background: radial-gradient(60% 80% at 40% 40%, rgba(255,255,255,0.12), transparent 70%), #2b3a34;
  border: 3px solid #7a5230;
  border-top-color: #8d6038; border-bottom-color: #5d3c22;
}
.swatch[data-swatch="chalkboard"]::before { inset: auto 5px 2px; height: 2px; background: #f3efe4; opacity: 0.8; border-radius: 1px; }
.swatch[data-swatch="glassboard"] {
  background: linear-gradient(115deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.04) 40%, transparent 41%), #151b22;
  border: 1px solid rgba(255,255,255,0.25);
}
.swatch[data-swatch="glassboard"]::before, .swatch[data-swatch="glassboard"]::after {
  width: 4px; height: 4px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #8d949b 70%);
}
.swatch[data-swatch="glassboard"]::before { top: 2px; left: 2px; box-shadow: 22px 0 0 0 #c3c8cd; }
.swatch[data-swatch="glassboard"]::after { bottom: 2px; left: 2px; box-shadow: 22px 0 0 0 #c3c8cd; }
.swatch[data-swatch="acrylic"] {
  background: linear-gradient(160deg, #f4f7f8, #e6ecef);
  border: 1px solid #c9d5d8;
  box-shadow: 0 2px 0 #9fd1d3 inset, 0 0 0 1px rgba(0,0,0,0.08) inset;
}
.swatch[data-swatch="acrylic"]::before { inset: 4px 4px auto auto; width: 10px; height: 3px; border-radius: 2px; background: #e4572e; }
.swatch[data-swatch="flipchart"] {
  background: linear-gradient(#f8f3e6, #f1eadb);
  border: 1px solid #d8d0bd;
}
.swatch[data-swatch="flipchart"]::before { inset: 0 0 auto; height: 5px; background: #4a4f55; }
.swatch[data-swatch="flipchart"]::after { inset: 9px 4px auto; height: 2px; background: #243b6b; border-radius: 1px; opacity: 0.8; }
.swatch[data-swatch="smartboard"] {
  background: radial-gradient(80% 90% at 50% 40%, #16202b, #0c1117);
  border: 2px solid #1c2128;
  border-bottom-width: 4px;
  box-shadow: 0 0 0 1px #33393f inset;
}
.swatch[data-swatch="smartboard"]::before { inset: auto 3px 0 auto; width: 3px; height: 2px; border-radius: 1px; background: #4f8cff; box-shadow: 0 0 4px #4f8cff; }

/* single chip trigger for mobile sheet */
.theme-current { display: none; width: auto; padding: 0 10px 0 6px; gap: 8px; }
.theme-current__label { font-size: var(--fs-sm); }

/* chrome toggle: show the opposite of current */
html[data-chrome="light"] .ic--moon { display: block; }
html[data-chrome="light"] .ic--sun { display: none; }
html[data-chrome="dark"] .ic--moon { display: none; }
html[data-chrome="dark"] .ic--sun { display: block; }

/* ---------- main: stage + panel ---------- */
.main {
  grid-area: main;
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr);
  grid-template-areas: "panel stage"; /* RTL: first column sits on the right */
  min-height: 0;
  transition: grid-template-columns var(--t-med) var(--ease);
}
body.panel-closed .main { grid-template-columns: 0px minmax(0, 1fr); }
.stage { grid-area: stage; }
.panel { grid-area: panel; }

.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: clamp(14px, 3vh, 30px) 3%;
  display: grid;
  place-items: center;
  container-type: size;
  background: var(--wall);
  overflow: hidden;
}

/* the board fits 16:9 inside the stage (≈ 94 % of its width at most); frame paddings are per theme vars */
.board {
  --ft: 14px; --fb: 14px; --fw: 14px;
  position: relative;
  width: min(100cqw, calc((100cqh - var(--ft) - var(--fb) - 16px) * 16 / 9 + 2 * var(--fw)));
  padding: var(--ft) var(--fw) var(--fb);
  box-shadow: var(--board-shadow);
  transition: opacity var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}
.board.is-switching .board__surface, .board.is-switching .board__frame, .board.is-switching .board__standoffs, .board.is-switching .board__ledge { opacity: 0; }
.board__surface, .board__frame, .board__standoffs, .board__ledge { transition: opacity var(--t-fast) var(--ease); }

.board__surface {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  /* palette vars are set on .board by ui.js; surface default */
  background: var(--surface, #f7f8f7);
  cursor: default;
}
.board__surface canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#ai-layer { z-index: 1; }
#user-layer { z-index: 2; pointer-events: none; }
body.mode-user #user-layer { pointer-events: auto; cursor: crosshair; }
body.mode-user .board__surface { cursor: crosshair; }

.board__hint {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 8%;
  text-align: center;
  font-family: var(--font-board-ar);
  font-size: clamp(16px, 2.6cqw, 34px);
  color: var(--ink, #1b2430);
  opacity: 0.32;
  pointer-events: none;
  transition: opacity var(--t-slow) var(--ease);
}
.board .board__hint.is-hidden { opacity: 0; }

.board__frame { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.board__standoffs, .board__ledge { position: absolute; inset: 0; pointer-events: none; display: none; }

/* ---------- free-draw tray (user mode only) ---------- */
.tray {
  position: absolute;
  left: 50%;
  bottom: -18px;
  transform: translate(-50%, 8px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--r-pill);
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), visibility 0s linear var(--t-med);
}
body.mode-user .tray { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }
.tray__group { display: flex; align-items: center; gap: 4px; }
.tray__sep { width: 1px; height: 20px; background: var(--line-2); margin: 0 2px; }
.tray__color, .tray__size, .tray__tool {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--fg);
  width: 30px; height: 30px;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.tray__color:focus-visible, .tray__size:focus-visible, .tray__tool:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--panel-2), 0 0 0 4px var(--accent-chrome); }
.tray__color { background: var(--c); box-shadow: 0 0 0 1px rgba(0,0,0,0.12) inset, 0 1px 2px rgba(0,0,0,0.25); }
.tray__color[data-color="ink"]    { --c: var(--ink); }
.tray__color[data-color="accent"] { --c: var(--accent); }
.tray__color[data-color="red"]    { --c: var(--red); }
.tray__color[data-color="blue"]   { --c: var(--blue); }
.tray__color[data-color="green"]  { --c: var(--green); }
.tray__color[data-color="yellow"] { --c: var(--yellow); }
.tray__color:hover { transform: scale(1.08); }
.tray__color.is-active { box-shadow: 0 0 0 2px var(--panel-2), 0 0 0 4px var(--fg); }
.tray__size i { display: block; border-radius: 50%; background: currentColor; }
.tray__size[data-size="s"] i { width: 4px; height: 4px; }
.tray__size[data-size="m"] i { width: 8px; height: 8px; }
.tray__size[data-size="l"] i { width: 13px; height: 13px; }
.tray__size.is-active, .tray__tool.is-active, .tray__tool[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tray__tool:hover, .tray__size:hover { background: var(--chip-hover); }
.tray__tool.is-active:hover, .tray__tool[aria-pressed="true"]:hover { background: var(--fg); }

/* ---------- AI panel ---------- */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-inline-start: 1px solid var(--line);
  background: var(--panel);
  transition: opacity var(--t-med) var(--ease);
}
body.panel-closed .panel { opacity: 0; pointer-events: none; }
.panel__handle { display: none; }
.panel__head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 14px 0 8px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.panel__title { font-weight: 500; font-size: var(--fs-sm); color: var(--fg-3); letter-spacing: 0.02em; }
.panel__status { flex: 1; font-size: var(--fs-xs); color: var(--fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel__status:empty { display: none; }
.panel__close { display: none; }
.panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 18px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
}
@media (prefers-reduced-motion: reduce) { .panel__body { scroll-behavior: auto; } }

.messages { display: flex; flex-direction: column; gap: 10px; }
.messages__empty { color: var(--fg-3); font-size: var(--fs-sm); padding: 20px 6px; text-align: center; }
.messages__empty p { margin: 0; }
.messages:not(:has(.msg)) .messages__empty { display: block; }
.messages:has(.msg) .messages__empty { display: none; }

.msg {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: msg-in var(--t-med) var(--ease) both;
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg--user {
  align-self: flex-end; /* left in RTL: "me" */
  background: var(--fg);
  color: var(--bg);
  border-end-start-radius: 4px;
}
.msg--ai {
  align-self: flex-start;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-end-end-radius: 4px;
}
.msg--say {
  align-self: stretch;
  max-width: none;
  background: transparent;
  color: var(--fg-2);
  font-style: italic;
  padding: 2px 6px 2px 2px;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.msg--say::before {
  content: "";
  flex: none;
  width: 12px; height: 12px;
  align-self: center;
  background: currentColor;
  opacity: 0.65;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20l4.2-1 10.3-10.3a1.8 1.8 0 0 0 0-2.6l-.6-.6a1.8 1.8 0 0 0-2.6 0L5 15.8 4 20Z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 20l4.2-1 10.3-10.3a1.8 1.8 0 0 0 0-2.6l-.6-.6a1.8 1.8 0 0 0-2.6 0L5 15.8 4 20Z' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.msg--error {
  align-self: stretch;
  max-width: none;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(209, 52, 59, 0.25);
}
html[data-chrome="dark"] .msg--error { color: #ff8a8f; }

/* plan card */
.plan {
  align-self: stretch;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px 12px;
  box-shadow: var(--shadow-sm);
  animation: msg-in var(--t-med) var(--ease) both;
}
.plan__reply { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--fg-2); }
.plan__title { margin: 0 0 6px; font-size: var(--fs-md); font-weight: 600; }
.plan__steps { margin: 0 0 12px; padding-inline-start: 22px; font-size: var(--fs-sm); color: var(--fg-2); }
.plan__steps li { padding: 2px 0; }
.plan__steps li::marker { color: var(--fg-3); font-weight: 500; }
.plan__actions { display: flex; gap: 8px; }
.plan__actions .btn { height: 34px; }
.plan.is-stale { opacity: 0.6; }
.plan.is-stale .plan__actions { display: none; }

/* thinking dots */
.thinking {
  display: none;
  gap: 5px;
  align-items: center;
  padding: 10px 4px 0;
  height: 28px;
}
.thinking.is-on { display: flex; }
.thinking i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-3);
  animation: think 1.1s ease-in-out infinite;
}
.thinking i:nth-child(2) { animation-delay: 0.15s; }
.thinking i:nth-child(3) { animation-delay: 0.3s; }
@keyframes think { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .thinking i { animation: none; opacity: 0.7; } }

/* ---------- dock ---------- */
.dock {
  grid-area: dock;
  position: relative;
  z-index: 46; /* above the mobile panel sheet and its scrim: you can keep typing */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.dock__controls { display: flex; align-items: center; gap: 6px; flex: none; }
.speed select {
  appearance: none;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--chip);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  min-width: 60px;
  text-align: center;
}
.speed select:focus-visible { outline: none; box-shadow: var(--focus); }
body[data-play="playing"] .ic--play { display: none; }
body:not([data-play="playing"]) .ic--pause { display: none; }

.dock__form {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
}
#prompt {
  flex: 1;
  min-width: 0;
  resize: none;
  min-height: 38px;
  max-height: calc(4 * 1.5em + 20px);
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--input);
  color: var(--fg);
  font: inherit;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
#prompt::placeholder { color: var(--fg-3); }
#prompt:focus { outline: none; border-color: var(--accent-chrome); box-shadow: 0 0 0 3px var(--accent-soft); }
.dock__send { height: 38px; padding: 0 16px; border-radius: var(--r-md); }
.dock__send .ic { width: 16px; height: 16px; }

/* ---------- scrim for sheets ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 12, 16, 0.4);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
}
.scrim[hidden] { display: block; pointer-events: none; }
.scrim:not([hidden]) { opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  :root { --panel-w: 300px; }
  .btn__label { display: none; }
  #mode-toggle .btn__label { display: inline; }
}

@media (max-width: 899px) {
  :root { --topbar-h: 48px; --dock-h: 62px; }
  .main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "stage"; }
  body.panel-closed .main { grid-template-columns: minmax(0, 1fr); }
  .panel { grid-area: auto; }
  .stage { padding: 12px 3% 40px; }
  .themes { display: none; }
  .theme-current { display: inline-flex; }
  body.themes-open .themes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    position: fixed;
    z-index: 50;
    inset: auto 12px 12px;
    padding: 10px;
    border-radius: var(--r-lg);
    background: var(--panel);
    box-shadow: var(--shadow-lg);
    animation: sheet-in var(--t-med) var(--ease) both;
  }
  body.themes-open .chip { height: 40px; justify-content: flex-start; padding: 0 8px; }
  body.themes-open .chip__label { display: inline; }
  #panel-toggle { display: none; }

  /* panel becomes a bottom sheet above the dock */
  .panel {
    position: fixed;
    z-index: 45;
    inset: auto 0 var(--dock-h) 0;
    height: min(58vh, 460px);
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(calc(100% + 8px));
    visibility: hidden;
    transition: transform var(--t-slow) var(--ease), visibility 0s linear var(--t-slow);
  }
  body:not(.panel-closed) .panel { transform: translateY(0); visibility: visible; transition-delay: 0s; }
  body.panel-closed .panel { opacity: 1; pointer-events: none; }
  .panel__handle {
    display: block;
    width: 38px; height: 4px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: var(--line-2);
  }
  .panel__head { height: 40px; }
  .panel__close { display: inline-flex; }
  #mode-toggle .btn__label { display: none; }
  .dock { gap: 8px; padding: 0 10px; }
  .dock__send .btn__label { display: none; }
  .dock__send { width: 38px; padding: 0; }
  /* tray: a fixed toolbar just above the dock, two rows */
  .tray {
    position: fixed;
    left: 10px; right: 10px;
    bottom: calc(var(--dock-h) + 10px);
    transform: translateY(8px);
    z-index: 30;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 4px;
    padding: 8px;
    border-radius: var(--r-lg);
  }
  body.mode-user .tray { transform: none; }
  .tray__colors { flex-basis: 100%; justify-content: center; gap: 8px; }
  .tray__sep { display: none; }
  .tray__sizes { margin-inline-end: 10px; }
}

@keyframes sheet-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (max-width: 480px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .wordmark { font-size: 1.5rem; margin-inline-end: 0; }
  .theme-current__label { display: none; }
  .theme-current { padding: 0 6px; }
  .topbar__actions { gap: 6px; }
  .stage { padding: 10px 3% 36px; }
  .dock__controls { gap: 4px; }
  .speed select { min-width: 52px; padding: 0 6px; }
  .tray__color, .tray__size, .tray__tool { width: 30px; height: 30px; }
}

@media (max-width: 380px) {
  #clear-board { display: none; }
}

/* reduced motion: cut transitions, keep state changes */
@media (prefers-reduced-motion: reduce) {
  .msg, .plan { animation: none; }
  .board.is-switching .board__surface { opacity: 1; }
}

/* ---- pages (multi-page explanations) ---- */
.pages { display: inline-flex; align-items: center; gap: 2px; padding: 0 2px; border: 1px solid var(--line); border-radius: var(--r-md, 10px); background: var(--chip); }
.pages[hidden] { display: none; }
.pages__btn { width: 28px; height: 28px; min-width: 28px; font-size: 18px; line-height: 1; border: 0; background: transparent; }
.pages__label { font: 600 12px/1 var(--font-ui); color: var(--fg-2); min-width: 32px; text-align: center; letter-spacing: .3px; font-variant-numeric: tabular-nums; }
