:root {
  --bg: #1e2230;
  --panel: #2a3042;
  --room: #343b52;
  --room-hover: #3e4762;
  --room-mine: #2f5d50;
  --border: #4a5370;
  --text: #e8ebf4;
  --muted: #9aa3bd;
  --accent: #5cc8a0;
  --error: #ff7a7a;
  --op: #f5c542;
  /* WCAG 2.2 AA: text >= 4.5:1, control outlines and icons >= 3:1 against
     every background they sit on (bg, panel, rooms). */
  --control-border: #848ead;  /* inputs, buttons, room outlines */
  --focus: #ffd166;           /* keyboard focus ring */
  --avatar: #9aa6f5;          /* others' avatars; dark initials on top */
  --avatar-me: #f6b38f;       /* your own avatar (peach; initials 9.9:1) */
  /* Green is reserved for "speaking": no avatar is ever filled with it,
     or the speaking ring would vanish into the circle. */
  --speaking: #3ecf7a;
  --on-light: #141829;        /* text on light fills (avatars) */
  /* Avatar headgear: black, with a light halo so it reads on the dark rooms
     (halo vs room 10:1) and black on the light avatars (>= 8:1). */
  --ctl-on: #ffffff;          /* controls bar: Chat while its panel is open (black on white) */
  --ctl-on-text: #000000;
  --ctl-dnd: #ff6b6b;
  --leave: #f8b4b4;           /* Leave: light red, unlike any toggle (dark text on it: 9.9:1) */
  --leave-hover: #f39a9a;         /* ...except DND, red like the avatar badge (black on it: 7.6:1) */
  --gear: #000;
  --link: #9cc2ff;            /* links in chat messages, on --panel: 7.2:1 */
  /* On a map's floorplan (light floors), the map's colors flip: dark lines
     and text, light halos. Contrasts against every floor and furniture
     color of static/maps/office.svg: */
  --plan-line: #3d4456;       /* room outlines: 3.2:1 or more */
  --plan-focus: #1d4ed8;      /* keyboard focus ring: 4.4:1 on floors */
  --plan-speaking: #0f6b35;   /* speaking ring: 4.3:1 on floors */
  --plan-text: #141829;       /* names, on a --plan-halo: 17.6:1 */
  --plan-halo: #ffffff;
  --plan-op: #7a5300;         /* the op's name, on the halo: 6.9:1 */
  --gear-halo: #e8ebf4;
  --gear-tip: #fff;           /* the boom microphone's tip */
  /* Google's sign-in button, dark theme, as its branding guidelines specify
     (border 4.2:1 on --panel; text 15:1 on its fill). */
  --gsi-bg: #131314;
  --gsi-bg-hover: #2a2a2b;    /* its 8% light overlay on hover */
  --gsi-border: #8e918f;
  --gsi-text: #e3e3e3;
  font-family: system-ui, sans-serif;
  color-scheme: dark;  /* dark scrollbars and form controls, matching the theme */
}

* { box-sizing: border-box; }
/* dvh: the height visible right now. On phones 100vh is the height with the
   browser's bars hidden, taller than the screen while they show, which put
   the controls bar below the screen. 100vh stays as the fallback. */
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Headings get focus only from script, so screen readers start reading at
   the new step. They aren't controls, so no ring that makes them look like one. */
.flow-title:focus { outline: none; }

/* Login */
.panel {
  max-width: 340px; margin: 15vh auto 0; padding: 2rem;
  background: var(--panel); border-radius: 12px;
}
.panel h1 { margin-top: 0; }
#login-form { display: flex; flex-direction: column; gap: .6rem; }
input, button, select {
  font: inherit; padding: .55rem .8rem; border-radius: 8px;
  border: 1px solid var(--control-border); background: var(--bg); color: var(--text);
}
button { background: var(--accent); color: #10261e; border: none; font-weight: 600; cursor: pointer; }
button.secondary { background: transparent; color: var(--text); border: 1px solid var(--control-border); font-weight: 500; }
/* Login intro: "New map" vs "Join map" (data-mode set from /api/maps/<id>) */
#intro { margin: 0 0 1rem; padding: .8rem 1rem; border-radius: 8px; border-left: 4px solid var(--border); background: var(--bg); }
#intro h2 { margin: 0 0 .3rem; font-size: 1.1rem; }
#intro p { margin: 0; color: var(--muted); font-size: .9rem; }
#intro-people { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
#intro-people:empty { display: none; }
#intro-people li { padding: .15rem .55rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--border); font-size: .85rem; }
#intro-people li.op { color: var(--op); border-color: var(--op); }
#login[data-mode="new"] #intro { border-left-color: var(--accent); }
#login[data-mode="new"] #intro h2::before { content: "✨ "; }
#login[data-mode="join"] #intro { border-left-color: var(--op); }
#login[data-mode="join"] #intro h2::before { content: "👋 "; }
#login:not([data-mode]) #intro { display: none; }
/* Start screen: a box per way in (guest / email / Google), or one of the
   follow-up steps (Google account without a name, signed in). */
.flow { display: flex; flex-direction: column; gap: .6rem; margin-top: .4rem; }
.flow form, .option { display: flex; flex-direction: column; gap: .6rem; }
.flow-title { font-size: 1.05rem; margin: 0; }
.flow .back { align-self: flex-start; }
.option { padding: .9rem 1rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.option-title { font-size: 1rem; margin: 0; }
/* The box heading says what the field is for: its label is for screen
   readers only (same as .visually-hidden). With accounts off there's no
   heading, so the guest label shows. */
body.accounts-on .box-label, .option .box-label[for="email"] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
body:not(.accounts-on) .option { padding: 0; border: none; background: none; } /* guest only: no box needed */
.hint, #code-hint { margin: 0; color: var(--muted); font-size: .85rem; }
#code-hint { color: var(--text); overflow-wrap: anywhere; } /* long addresses wrap */
.option .error:empty { min-height: 0; margin-top: -.6rem; } /* no gap until there's an error */
#code-create { display: flex; flex-direction: column; gap: .6rem; }
.divider { display: flex; align-items: center; gap: .6rem; margin: 0; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--control-border); }
.gsi-button {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 40px; padding: 0 12px; border-radius: 4px;
  background: var(--gsi-bg); border: 1px solid var(--gsi-border); color: var(--gsi-text);
  font-family: Roboto, Arial, sans-serif; font-size: 14px; font-weight: 500; letter-spacing: .25px;
}
.gsi-button:hover { background: var(--gsi-bg-hover); }
.gsi-logo { width: 20px; height: 20px; flex: none; }
.accounts-only { display: none; }
body.accounts-on .accounts-only { display: revert; }
button.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 500; text-decoration: underline; cursor: pointer; }
.verified { color: var(--accent); }
a { color: var(--accent); }

/* Account page */
.account-page { max-width: 440px; margin-top: 8vh; }
.account-page section { margin-top: 1.5rem; display: flex; flex-direction: column; gap: .6rem; align-items: flex-start; }
.account-page h2 { font-size: 1.05rem; margin: 0; }
.account-page form { display: flex; flex-direction: column; gap: .6rem; align-self: stretch; }
.account-page p, .account-page ul { margin: 0; }
.account-page ul { padding-left: 1.2rem; }
#name-msg, #devices-msg, #sessions, .danger-zone p:not(.error) { color: var(--muted); font-size: .9rem; }
.danger-zone { border-top: 1px solid var(--control-border); padding-top: 1.2rem; }
.picture-row { display: flex; gap: 1rem; align-items: center; }
.picture-preview {
  flex: none; width: 56px; height: 56px; border-radius: 50%; overflow: hidden;
  display: grid; place-items: center; background: var(--avatar-me); border: 2px solid #fff;
}
.picture-preview img { width: 100%; height: 100%; object-fit: cover; }
#picture-initials { color: var(--on-light); font-weight: 700; font-size: 1.1rem; }
.picture-controls { display: flex; flex-direction: column; gap: .4rem; }
.switch-field { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.switch-field input { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--accent); }
#picture-msg { color: var(--muted); font-size: .9rem; }
.map-id { color: var(--muted); font-size: .85rem; margin-top: -.5rem; word-break: break-all; }
.map-id #map-name-label { margin-right: .3rem; }
/* The name looks like text with a pencil, and is a button (keyboard, focus ring). */
.map-name { display: inline-flex; align-items: baseline; gap: .3rem; padding: .1rem .35rem; margin-left: -.35rem;
  background: none; border: 1px dashed transparent; border-radius: 4px; color: var(--text); font: inherit; cursor: text; }
.map-name:hover { border-color: var(--control-border); }
.map-name code { font-size: .9rem; }
.map-name-edit { color: var(--muted); }
#map-name-form { display: inline; }
#map-name-input { width: 100%; max-width: 22rem; margin-top: .25rem; font-family: ui-monospace, monospace; font-size: .9rem; }
#map-name-hint { margin-top: .25rem; }
.error { color: var(--error); min-height: 1.2em; margin: 0; }

/* Office */
#office { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#office header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; background: var(--panel);
}
/* The logo: white artwork made for the dark panels (static/img, from
   brand/fosscoco-logo.png). width/height attributes reserve its space. */
.logo { display: block; width: auto; }
.logo-login { height: 3rem; margin: 0 auto; } /* centered on the start screen */
.logo-bar { height: 1.6rem; }
/* Grows to fill the bar, but wraps to its own line instead of squeezing
   to a word per line; on phones it always sits below the buttons. */
#status { color: var(--muted); flex: 1 1 14rem; }
/* A heading that starts with the logo (the admin pages): "[Fosscoco] administration". */
.brand-title { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.brand-title .logo-bar { height: 1.5rem; }
.panel .brand-title { flex-direction: column; gap: .4rem; text-align: center; }
/* A link that looks like the secondary buttons next to it. */
.link-button {
  padding: .55rem .8rem; border-radius: 8px; border: 1px solid var(--control-border);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.link-button:hover { background: var(--room-hover); }
/* Invite to this map: the platform's share icon plus its label (on phones it
   opens the share sheet). As wide as "Invite to this map", its longest text,
   so "Copied!" / "Copy failed" don't resize it. */
.share-button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-width: 10.9em; }
.share-icon { width: 1.15rem; height: 1.15rem; flex: none; }
.share-apple { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share-dots path { fill: none; stroke: currentColor; stroke-width: 1.8; }
.share-dots circle { fill: currentColor; }
:root[data-share-icon="apple"] .share-dots, :root:not([data-share-icon="apple"]) .share-apple { display: none; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; padding: .45rem; }
.icon-button .ctl-svg { width: 1.4rem; height: 1.4rem; }
.icon-button[aria-expanded="true"] { background: var(--ctl-on); color: var(--ctl-on-text); border-color: var(--ctl-on); }
/* Audio settings: a panel under the gear (top set from the bar's height). */
#audio-settings {
  position: fixed; right: 1rem; z-index: 20; width: min(20rem, calc(100vw - 2rem));
  display: flex; flex-direction: column; gap: .45rem; padding: 1rem;
  background: var(--panel); border: 1px solid var(--control-border); border-radius: 10px;
  box-shadow: 0 8px 24px #0008;
}
#audio-settings h2 { font-size: 1rem; margin: 0 0 .3rem; }
#audio-settings label { font-size: .9rem; margin-top: .35rem; }
#speaker-field { display: flex; flex-direction: column; gap: .45rem; }
#audio-settings select { width: 100%; }
#volume { accent-color: var(--accent); padding: 0; border: none; background: none; }
#audio-settings .effects-field { margin-top: .6rem; }
/* Microphone level: green, the "speaking" color, since it shows your voice. */
.level { height: .5rem; border-radius: 999px; background: var(--bg); border: 1px solid var(--control-border); overflow: hidden; }
#mic-level { height: 100%; width: 0; background: var(--speaking); transition: width .08s linear; } /* "Copied!" / "Copy failed" don't resize it */
/* Controls bar: same-size square buttons. Mic, Sound and Share say their
   state in the label (Mic ON / Mic OFF), so it never rests on color alone
   (WCAG 1.4.1): ON is red with black text (7.6:1), OFF black with light text
   (17.6:1). DND is red when on; Chat white while its panel is open. The red
   stands out from the bar (4.7:1); black keeps the light outline (4.0:1). */
#controls {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: .6rem 1rem; background: var(--panel); border-top: 1px solid var(--border);
}
.ctl-group { grid-column: 2; display: flex; gap: .75rem; }
/* Apart from the toggles, at the right, and light red: an action that ends
   the visit, not a setting, so it shouldn't look like one or be hit by mistake. */
#leave { grid-column: 3; justify-self: end; background: var(--leave); border-color: var(--leave); color: var(--on-light); }
#leave:hover { background: var(--leave-hover); border-color: var(--leave-hover); }
/* Phones: five slightly smaller squares in one row, Leave still last. */
@media (max-width: 560px) {
  #status { order: 1; flex-basis: 100%; }
  #controls { display: flex; justify-content: space-between; gap: .4rem; padding: .5rem; }
  .ctl-group { gap: .4rem; }
  #controls .ctl { width: 4rem; height: 4rem; font-size: .72rem; }
  #controls #leave { margin-left: .8rem; } /* a wider gap from the toggles on phones */
}
.ctl {
  position: relative; width: 4.75rem; height: 4.75rem; padding: .3rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
  background: transparent; color: var(--text); border: 1px solid var(--control-border);
  font-size: .8rem; font-weight: 600; line-height: 1.1; white-space: nowrap;
}
/* Drawn icons follow the label's color. */
.ctl-svg { width: 1.5rem; height: 1.5rem; fill: currentColor; }
.ctl-svg .ctl-stroke { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ctl[aria-pressed="true"], .ctl[aria-expanded="true"] {
  background: var(--ctl-on); border-color: var(--ctl-on); color: var(--ctl-on-text);
}
#dnd[aria-pressed="true"] { background: var(--ctl-dnd); border-color: var(--ctl-dnd); }
.ctl[data-on="true"] { background: var(--ctl-dnd); border-color: var(--ctl-dnd); color: #000; }
.ctl[data-on="false"] { background: #000; color: var(--text); }
.ctl:disabled, .ctl[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
/* Wider screens: the bar and its buttons 30% smaller than the sizes above
   (phones keep theirs, set in the max-width: 560px block: finger targets). */
@media (min-width: 561px) {
  #controls { padding: .42rem .7rem; }
  .ctl-group { gap: .53rem; }
  .ctl { width: 3.325rem; height: 3.325rem; padding: .2rem; gap: .18rem; font-size: .56rem; }
  .ctl .ctl-svg { width: 1.05rem; height: 1.05rem; }
  .unread-badge { top: -.35rem; right: -.35rem; min-width: 1rem; height: 1rem; padding: 0 .2rem; font-size: .56rem; border-width: 1.5px; }
}
.workspace { flex: 1; display: flex; min-height: 0; }
/* A size container: the stage below measures its height against this
   column's width (cqw units). */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; container-type: inline-size; }
/* Your own share's preview: the map's lower-right corner, so you can check
   you picked the right window. Hidden, just its bar. */
/* Locked rooms. Inside: a round lock button in the room's corner, white with
   an open padlock, red with a closed one when locked (black on red 7.6:1);
   its edge is the room outline color (3.2:1 or more on the plan's floors).
   Outside: the room's floor and people blurred, a big white padlock on a dark
   rounded square (white on --bg: 15.8:1). */
.lock-button { cursor: pointer; color: var(--plan-text); }
.lock-button circle { fill: #fff; stroke: var(--plan-line); stroke-width: 2; }
.lock-button:hover circle { fill: #e8ebf4; }
.lock-button.is-locked { color: #000; }
.lock-button.is-locked circle { fill: var(--ctl-dnd); stroke: var(--plan-line); }
.lock-button:focus-visible { outline: none; }
.lock-button:focus-visible circle { stroke: var(--focus); stroke-width: 4; }
#map.has-plan .lock-button:focus-visible circle { stroke: var(--plan-focus); }
.padlock .shackle { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.padlock .lock-body { fill: currentColor; }
.lock-button .keyhole { fill: #fff; }
.lock-button.is-locked .keyhole { fill: var(--ctl-dnd); }
.lock-mark { pointer-events: none; color: #fff; }
.lock-mark .mark-bg { fill: var(--bg); }
.lock-mark .keyhole { fill: var(--bg); }
.veils-layer { pointer-events: none; }
.veil-tint { fill: #fff; fill-opacity: .3; }
#map:not(.has-plan) .veil-tint { fill: var(--bg); fill-opacity: .6; }
.avatar.behind-lock { filter: blur(3px); opacity: .85; }
#notice {
  position: absolute; top: .75rem; left: 50%; transform: translateX(-50%); z-index: 3; margin: 0;
  padding: .45rem .9rem; border-radius: 8px; background: var(--panel); color: var(--text);
  border: 1px solid var(--control-border); box-shadow: 0 4px 16px #0006; pointer-events: none;
}
/* For development: the server's commit, small in the map's lower-left corner
   (the presenter preview takes the right). Muted on --bg: 6.3:1. */
#version-tag {
  position: absolute; left: .5rem; bottom: .5rem; z-index: 2; margin: 0;
  padding: .1rem .45rem; border-radius: 4px; background: var(--bg); color: var(--muted);
  font: .75rem ui-monospace, monospace; pointer-events: none;
}
#my-share {
  position: absolute; right: .75rem; bottom: .75rem; z-index: 2;
  width: clamp(220px, 25%, 380px); display: flex; flex-direction: column;
  background: #000; border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
  box-shadow: 0 4px 16px #0006;
}
#my-share .stage-bar { padding: .3rem .5rem; gap: .4rem; }
#my-share h2 { margin-right: auto; }
#my-share .stage-bar button { padding: .25rem .6rem; font-size: .85rem; }
#my-share video { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; }
#my-share.collapsed video { display: none; }
/* The stage: screens shared in your room, above the map (which keeps the
   rest of the height and scrolls as usual). Collapsed, just its title bar. */
/* As tall as a 16:9 picture of the column's width, at most (shared screens
   are landscape: on a portrait phone the map gets the rest), and never more
   than three quarters of the column, so the map keeps room on wide screens. */
#stage { flex: 0 1 auto; max-height: 75%; min-height: 0; display: flex; flex-direction: column; background: #000; border-bottom: 1px solid var(--border); }
#stage.collapsed { flex: none; }
#stage.collapsed #stage-tiles { display: none; }
.stage-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .4rem .75rem; background: var(--panel); }
.stage-bar h2 { font-size: .95rem; margin: 0; }
.stage-bar button, .screen-tile button { padding: .3rem .7rem; font-size: .85rem; }
#stage-tiles { flex: 0 1 auto; height: calc(100cqw * 9 / 16); min-height: 0; display: flex; gap: 2px; }
.screen-tile { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; position: relative; }
.screen-tile figcaption {
  position: absolute; top: .5rem; left: .5rem; right: .5rem; z-index: 1;
  display: flex; justify-content: space-between; align-items: center; gap: .5rem; pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
/* Shown over the picture only when wanted (see addScreen in app.js): on
   hover with a mouse, after a tap, and always while the keyboard is on the
   button (focus is never invisible). Escape hides it while hovering. While
   hidden, a tap can't hit the button by accident. */
@media (hover: hover) {
  .screen-tile:hover figcaption { opacity: 1; }
  .screen-tile:hover figcaption button { pointer-events: auto; }
}
.screen-tile.controls-shown figcaption { opacity: 1; }
.screen-tile.controls-shown figcaption button { pointer-events: auto; }
.screen-tile.controls-dismissed figcaption { opacity: 0; }
.screen-tile.controls-dismissed figcaption button { pointer-events: none; }
.screen-tile:focus-within figcaption { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .screen-tile figcaption { transition: none; } }
.screen-tile figcaption span { background: #000c; color: #fff; padding: .2rem .55rem; border-radius: 6px; font-size: .85rem; }
.screen-tile figcaption button { background: #000c; }
.screen-tile video { flex: 1; min-height: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
/* The map never shrinks below a usable size: on narrow screens it scrolls
   inside its own area instead (WCAG allows 2-D scrolling for maps, 1.4.10).
   This keeps avatars >= 24px tap targets (2.5.8) and lets zoom enlarge the
   map's text (1.4.4); shrinking to fit made both impossible on phones. */
.map-scroll { flex: 1; min-width: 0; min-height: 0; overflow: auto; }
/* 825px: the 1100-unit-wide map at the scale the old 960-unit one had at 720px,
   so avatars and names keep their size on phones. */
#map { display: block; width: 100%; height: 100%; min-width: 825px; min-height: 540px; padding: 1rem; }

/* Chat */
#chat {
  width: 320px; display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--border);
}
#chat h2 { font-size: 1rem; margin: 0; padding: .75rem 1rem; border-bottom: 1px solid var(--border); }
#chat-log { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: .75rem 1rem; display: flex; flex-direction: column; gap: .4rem; }
#chat-log li { overflow-wrap: anywhere; line-height: 1.35; }
#chat-log .time { color: var(--muted); font-size: .75rem; margin-right: .4rem; }
#chat-log .who { font-weight: 600; margin-right: .3rem; }
#chat-log .mine .who { color: var(--accent); }
#chat-log .system { color: var(--muted); font-size: .85rem; font-style: italic; }
/* Links in messages: light blue (7.2:1 on the panel) and underlined, not by color alone. */
#chat-log a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
#chat-log a:hover { text-decoration-thickness: 2px; }
#chat-form { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); }
#chat-input { flex: 1; min-width: 0; }

@media (max-width: 800px) {
  .workspace { flex-direction: column; }
  #chat { width: auto; height: 40vh; border-left: none; border-top: 1px solid var(--border); }
}

.room rect { fill: var(--room); stroke: var(--control-border); stroke-width: 2; rx: 10; cursor: pointer; transition: fill .15s; }
.room:hover rect { fill: var(--room-hover); }
.room.mine rect { fill: var(--room-mine); stroke: var(--accent); }
/* SVG groups: show focus on the shape itself instead of a box outline. */
.room:focus-visible, .avatar:focus-visible { outline: none; }
.room:focus-visible rect { stroke: var(--focus); stroke-width: 4; }
/* Over a floorplan (a light office): clear rooms so the floor shows, dark
   outlines on the plan's walls (square corners), dark names on light halos,
   and avatars outlined so they stand out from light floors. Focus and
   speaking rings use darker colors that read on light floors. The plan
   itself is decoration. */
#map .plan { pointer-events: none; }
#map.has-plan .room rect { fill: var(--plan-line); fill-opacity: 0; stroke: var(--plan-line); rx: 0; }
#map.has-plan .room:hover rect { fill-opacity: .08; }
#map.has-plan .room.mine rect { fill: var(--room-mine); fill-opacity: .22; stroke: var(--plan-line); stroke-width: 3; }
#map.has-plan .room:focus-visible rect, #map.has-plan .room.drop-target rect { stroke: var(--plan-focus); stroke-width: 4; }
#map.has-plan .room-label, #map.has-plan .room-count, #map.has-plan .avatar .name {
  fill: var(--plan-text); paint-order: stroke; stroke: var(--plan-halo); stroke-width: 4px; stroke-linejoin: round;
}
#map.has-plan .avatar.op .name { fill: var(--plan-op); }
#map.has-plan .avatar .body { stroke: var(--plan-text); stroke-width: 1.5; }
#map.has-plan .avatar.me .body { stroke-width: 2.5; }
#map.has-plan .avatar.speaking .body { stroke: var(--plan-speaking); stroke-width: 4; }
#map.has-plan .avatar:focus-visible .body { stroke: var(--plan-focus); stroke-width: 4; }
#map.has-plan .avatar.actionable:hover .body { stroke: var(--plan-op); stroke-width: 3; }
.room-label { fill: var(--text); font-size: 16px; font-weight: 600; pointer-events: none; }
.room-count { fill: var(--text); font-size: 13px; pointer-events: none; }

/* Every avatar takes the pointer, so its tooltip shows on hover (who, audio,
   DND); clicking someone else's acts like clicking their room (see app.js). */
.avatar { cursor: pointer; transition: transform .45s ease, opacity .2s; }
.avatar .body { fill: var(--avatar); stroke: #fff3; stroke-width: 2; }
.avatar.me .body { fill: var(--avatar-me); stroke: #fff; }
.avatar.disconnected { opacity: .35; }
@media (prefers-reduced-motion: reduce) { .avatar { transition: none; } }

/* Do-not-disturb badge (red with a bar; the dark ring keeps it >= 3:1 on
   any room). Nothing is shown when available. */
.badge { display: none; }
.status-dnd .badge { display: inline; }
.badge circle { stroke: var(--bg); stroke-width: 2.5; fill: #ff6b6b; }
.badge .dnd-bar { fill: #fff; }

/* Audio headgear: headphones = listening, + boom microphone = unmuted.
   Shapes, not colors, carry the meaning (WCAG 1.4.1); light strokes over a
   dark underlay stay >= 3:1 on avatars and rooms alike. */
.headgear, .headgear .boom { display: none; }
.avatar.listening .headgear { display: inline; }
.avatar.mic-on .headgear .boom { display: inline; }
.headgear path { fill: none; stroke-linecap: round; }
.headgear .outline { stroke: var(--gear-halo); stroke-width: 6; }
.headgear .line { stroke: var(--gear); stroke-width: 3; }
.headgear .cup { fill: var(--gear); stroke: var(--gear-halo); stroke-width: 1.5; }
.headgear .tip { fill: var(--gear-tip); stroke: var(--gear); stroke-width: 1.5; }
.avatar .initials { fill: var(--on-light); font-size: 15px; font-weight: 700; }
/* An account's picture replaces the initials (see app.js: createAvatar). */
.avatar .photo { display: none; }
.avatar.has-photo .photo { display: inline; }
.avatar.has-photo .initials { display: none; }
.avatar .name { fill: var(--text); font-size: 12px; }
.avatar.speaking .body { stroke: var(--speaking); stroke-width: 4; }
.avatar:focus-visible .body { stroke: var(--focus); stroke-width: 4; }
/* New chat activity while the panel is hidden: a numbered badge on the
   button's corner (dark number on red: 6.35:1; badge vs the bar: 4.7:1). */
.unread-badge {
  position: absolute; top: -.5rem; right: -.5rem;
  min-width: 1.35rem; height: 1.35rem; padding: 0 .3rem;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 2px solid var(--panel);
  background: #ff6b6b; color: var(--on-light);
  font-size: .75rem; font-weight: 700; line-height: 1;
}
.avatar.op .name { fill: var(--op); font-weight: 600; }
/* The op's actions menu on others' avatars. */
.avatar.actionable { cursor: pointer; }
/* Your own avatar can be dragged to another room (rooms stay clickable). */
.avatar.me { cursor: grab; touch-action: none; }
.avatar.me.dragging { cursor: grabbing; transition: none; opacity: .85; }
.room.drop-target rect { stroke: var(--focus); stroke-width: 4; }
.avatar.actionable:hover .body { stroke: var(--op); }

/* Op menu */
#avatar-menu {
  position: fixed; z-index: 10; min-width: 11rem; padding: .5rem;
  display: flex; flex-direction: column; gap: .35rem;
  background: var(--panel); border: 1px solid var(--control-border); border-radius: 10px;
  box-shadow: 0 6px 24px #0008;
}
#avatar-menu[hidden] { display: none; }
#avatar-menu-name { margin: .1rem .3rem .3rem; font-weight: 600; overflow-wrap: anywhere; }
#avatar-menu button { text-align: left; }
button.danger { background: transparent; color: var(--error); border: 1px solid var(--error); font-weight: 500; }

/* Admin dashboard */
.admin-page { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.admin-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding-bottom: .75rem; border-bottom: 1px solid var(--control-border); }
.admin-header h1 { font-size: 1.3rem; margin: 0; }
.admin-header #who { color: var(--muted); flex: 1; }
.admin-page section { margin-top: 1.75rem; }
#delete-avatars { margin-top: .75rem; }
#avatars-usage { margin: .5rem 0; }
.admin-page h2 { font-size: 1.1rem; }
.admin-page .count { color: var(--muted); font-weight: 400; }
.table-wrap { overflow-x: auto; }  /* wide tables scroll inside, not the page */
.admin-page table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-page th, .admin-page td { text-align: left; vertical-align: top; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.admin-page th { color: var(--muted); font-weight: 600; }
.admin-page td button { padding: .25rem .6rem; font-size: .85rem; }
.admin-page .people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.admin-page code.small { font-size: .75rem; color: var(--muted); }
#admin-login form { display: flex; flex-direction: column; gap: .6rem; }
