/* The one control vocabulary for every surface: the canvas (shell/main.ts puts it first in <head>), the
   outer shell (its css string) and the gallery (/assets/ui.css, before one-sun.css). Colours are the
   room's tokens (shell/themes.css); a host places and sizes its controls, never restyles them.

   .btn       a bordered button. Kinds: primary, ghost, danger (+ solid for the destructive confirm).
              Sizes: sm, lg; icon is a bare square for a glyph alone.
   .tool-btn  a bare toolbar button (HUD, call dock, director bar). icon squares it, sm shrinks it,
              danger turns it vermilion. Pressed and expanded read as pressed.
   .menu      a list of .item rows (a glyph or .room-swatch, a .label, a <kbd> or .value, a chev),
              split by <hr> or titled .group / .group-label sections; .item.danger is vermilion.
              A popover menu shows only while open; the host places it. Keyboard: shell/roving_menu.ts. */

[hidden] { display: none !important; }

/* The one key cap: menus, the shortcuts sheet, trays, the gallery's search hint. A host sizes it, never restyles it. */
kbd {
  display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: var(--r-xs); background: var(--paper); color: var(--ink-2);
  font: var(--w-body) var(--fs-caption)/1 var(--font-mono); font-variant-numeric: tabular-nums;
}

/* Glyphs inside a control or a menu row are stroked line art in currentColor, so a classless glyph from any
   host draws the same way; each surface's own icon class (svg.i, svg.icon, .cm-i, .ig-icon, .ca-i) wins over
   these zero-specificity defaults. */
:where(.btn, .tool-btn, .menu .item) svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:where(.btn) svg { width: 15px; height: 15px; }
:where(.tool-btn) svg { width: 18px; height: 18px; }

/* ---------- .btn ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: none;
  height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line-control);
  background: var(--paper); color: var(--ink); font: var(--w-ui) var(--fs-ui)/1 var(--font-ui); letter-spacing: -0.005em;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--t-tap) ease, border-color var(--t-tap) ease, color var(--t-tap) ease, transform var(--t-tap) ease;
}
.btn:hover:not(:disabled) { background: var(--raised); border-color: var(--ink-3); color: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.btn.primary { background: var(--cobalt); color: var(--on-cobalt); border-color: transparent; }
.btn.primary:hover { background: var(--cobalt-hi); color: var(--on-cobalt); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.danger { color: var(--vermilion-ink); border-color: color-mix(in oklab, var(--vermilion-ink) 40%, transparent); background: transparent; }
.btn.danger.ghost { border-color: transparent; }
.btn.danger:hover, .btn.danger[data-armed] { color: var(--vermilion-ink); background: var(--vermilion-tint); border-color: color-mix(in oklab, var(--vermilion-ink) 40%, transparent); }
.btn.danger.solid { background: var(--vermilion-ink); color: var(--on-cobalt); border-color: transparent; }
/* Hover deepens toward the ink (never the lighter --vermilion), so the label keeps ≥4.5:1 in every room. */
.btn.danger.solid:hover { background: color-mix(in oklab, var(--vermilion-ink) 88%, var(--ink)); color: var(--on-cobalt); }
.btn.sm { height: 30px; padding: 0 10px; font-size: var(--fs-secondary); }
.btn.lg { height: 44px; padding: 0 20px; font-size: var(--fs-body); border-radius: var(--r-md); }
.btn.icon { width: 32px; height: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.icon:hover { background: var(--hover); color: var(--ink); }
.btn.icon.sm { width: 28px; height: 28px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
/* Touch: small buttons keep a finger-sized hit area. */
@media (pointer: coarse) {
  .btn.sm { height: 36px; }
  .btn.icon, .btn.icon.sm { width: 36px; height: 36px; }
}

/* ---------- .tool-btn ---------- */
.tool-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; position: relative;
  min-width: 34px; height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink); font: var(--w-ui) var(--fs-secondary)/1 var(--font-ui); letter-spacing: -0.005em;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--t-tap) var(--ease-settle), color var(--t-tap) var(--ease-settle);
}
.tool-btn:hover { background: var(--hover); }
.tool-btn:active, .tool-btn[aria-pressed="true"], .tool-btn[aria-expanded="true"] { background: var(--press); }
.tool-btn:focus-visible { outline: 2px solid var(--cobalt); outline-offset: -2px; }
.tool-btn.icon { width: 34px; padding: 0; }
.tool-btn.sm { min-width: 26px; height: 26px; border-radius: var(--r-xs); }
.tool-btn.sm.icon { width: 26px; }
.tool-btn.danger { color: var(--vermilion-ink); }
.tool-btn.danger:hover { background: var(--vermilion-tint); }
.tool-btn:disabled, .tool-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; background: transparent; }

/* ---------- .menu ---------- */
.menu {
  min-width: 188px; padding: var(--pop-pad); border-radius: var(--pop-radius); border: var(--hair) solid var(--line);
  background: var(--raised); color: var(--ink); box-shadow: var(--pop-shadow); font-variant-numeric: tabular-nums;
}
/* Off the UA's centred popover box; zero specificity so the host's own placement always wins. */
:where(.menu[popover]) { inset: auto; margin: 0; }
.menu:popover-open, .menu:not([popover]) { display: grid; gap: var(--pop-gap); }
.menu .group { display: grid; gap: var(--pop-gap); }
.menu .group-label {
  margin: 0; padding: 6px 10px 4px; color: var(--ink-3); user-select: none;
  font: var(--w-ui) var(--fs-caption)/1.2 var(--font-ui);
}
/* The one divider: a hairline with 5px above and below, inset 4px. */
.menu hr { height: 1px; margin: 5px 4px; border: 0; background: var(--pop-divider); }
.menu .item {
  appearance: none; display: flex; align-items: center; gap: var(--pop-item-gap); width: 100%; height: var(--pop-item-h); padding: var(--pop-item-pad);
  border: 0; border-radius: var(--pop-item-radius); background: transparent; color: var(--ink);
  font: var(--w-body) var(--fs-secondary)/1 var(--font-ui); letter-spacing: -0.005em; text-align: left; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.menu .item > svg { width: 15px; height: 15px; flex: none; color: var(--ink-2); transition: color var(--t-tap) var(--ease-settle); }
.menu .item > svg.chev { width: 13px; height: 13px; margin-left: -6px; color: var(--ink-3); }
.menu .item:hover, .menu .item:focus-visible { background: var(--hover); color: var(--ink); }
.menu .item:hover > svg, .menu .item:focus-visible > svg { color: var(--ink); }
.menu .item:focus-visible { outline: 2px solid var(--cobalt); outline-offset: -2px; }
.menu .item:active, .menu .item[aria-checked="true"] { background: var(--press); }
.menu .item:disabled, .menu .item[aria-disabled="true"] { color: var(--ink-3); background: transparent; cursor: default; }
.menu .item.danger, .menu .item.danger > svg { color: var(--vermilion-ink); }
.menu .item.danger:hover, .menu .item.danger:focus-visible { background: var(--vermilion-tint); }
.menu .item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu .item .value { color: var(--ink-3); font: var(--w-body) var(--fs-caption)/1 var(--font-ui); }
/* A room as a swatch: its ground, ringed, with its accent dot (--swatch-ground/--swatch-accent, else this room). */
.room-swatch {
  position: relative; width: 15px; height: 15px; flex: none; border-radius: 50%;
  background: var(--swatch-ground, var(--ground)); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--ink) 22%, transparent);
}
.room-swatch::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--swatch-accent, var(--cobalt)); }

@media (prefers-reduced-motion: reduce) {
  .btn, .tool-btn, .menu .item > svg { transition: none; }
  .btn:active { transform: none; }
}
