/* Рубка. A dark console: hairlines instead of cards, square faces, mono for readouts,
   and one signal colour reserved for what is on air. */

:root {
  --font: 'Golos Text', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --rail-width: 268px;
  --people-width: 224px;
  --panel-width: 340px;
  --row: 30px;
  --radius: 6px;

  --catalog-control-radius: var(--radius);
  --catalog-radius: 10px;
  --action-fill: var(--ink);
  --action-ink: var(--bg);
  --hmi-accent-contrast: var(--bg);
  --catalog-bg: var(--bg);
  --catalog-surface: var(--raised);
  --catalog-surface-soft: var(--tint);
  --catalog-surface-hover: var(--tint-strong);
  --catalog-text: var(--ink);
  --catalog-text-secondary: var(--ink-2);
  --catalog-text-muted: var(--ink-3);
  --catalog-border: var(--line);
  --catalog-border-strong: var(--line-strong);
  --catalog-accent: var(--signal);
  --catalog-danger: var(--alert);
  --hmi-surface-floating: var(--raised);
  --ui-inverse-text: var(--bg);
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0c0d0e;
  --panel: #111214;
  --raised: #17181b;
  --tint: #ffffff0a;
  --tint-strong: #ffffff14;
  --line: #222428;
  --line-strong: #34363c;
  --ink: #ececed;
  --ink-2: #a9abb1;
  --ink-3: #74767d;
  --signal: #ff6a1f;
  --signal-soft: #ff6a1f26;
  --good: #63d98a;
  --alert: #ff5a52;
  --alert-soft: #ff5a5224;
  --face-l: 34%;
  --name-l: 72%;
  --tile: #141517;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f3f2ee;
  --panel: #eae9e4;
  --raised: #fbfaf8;
  --tint: #0000000a;
  --tint-strong: #00000012;
  --line: #d8d6cf;
  --line-strong: #bfbdb5;
  --ink: #16171a;
  --ink-2: #4c4e54;
  --ink-3: #6b6d73;
  --signal: #d94e08;
  --signal-soft: #d94e081f;
  --good: #1c8a4a;
  --alert: #c8281f;
  --alert-soft: #c8281f1a;
  --face-l: 42%;
  --name-l: 32%;
  --tile: #e4e2dc;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, p, ul, figure { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.fatal { padding: 32px; color: var(--ink-2); }

/* ---------- Faces and lamps ---------- */

.face {
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: none;
  place-items: center;
  border-radius: 7px;
  background: hsl(var(--hue, 30) 32% var(--face-l));
  color: #fff;
  font: 500 12px/1 var(--mono);
  letter-spacing: -0.02em;
  transition: box-shadow var(--motion-fast);
}

.face.is-speaking { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--signal); }

.lamp {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 2px;
  background: var(--line-strong);
  transition: background 90ms linear, box-shadow 90ms linear;
}

.is-speaking > .lamp { background: var(--signal); box-shadow: 0 0 8px var(--signal); }

/* Segmented LED bar: the same stripes twice, the lit copy clipped to the level. */
.meter {
  --stripes: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 5px);
  position: relative;
  display: block;
  height: 6px;
  color: var(--line-strong);
  background: var(--stripes);
}

.meter::after {
  content: '';
  position: absolute;
  inset: 0;
  color: var(--good);
  background: var(--stripes);
  clip-path: inset(0 calc(100% - var(--level, 0%)) 0 0);
  transition: clip-path 60ms linear;
}

/* ---------- Door ---------- */

.door {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  height: 100dvh;
  overflow: auto;
}

.door__brand {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: flex-end;
  gap: 18px;
  padding: clamp(24px, 5vw, 64px);
  overflow: hidden;
}

.door__mark {
  display: flex;
  height: 40px;
  align-items: center;
  gap: 6px;
}

.door__mark i { display: block; width: 8px; background: var(--ink); }
.door__mark i:nth-child(1) { height: 12px; background: var(--signal); }
.door__mark i:nth-child(2) { height: 26px; background: var(--signal); }
.door__mark i:nth-child(3) { height: 40px; }
.door__mark i:nth-child(4) { height: 18px; }

.door__name {
  font-size: clamp(72px, 15vw, 208px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
}

.door__line {
  max-width: 34ch;
  color: var(--ink-2);
  font-size: 17px;
}

.door__panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 32px clamp(24px, 4vw, 48px);
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.door__form { display: flex; flex-direction: column; gap: 16px; }

.door__code {
  height: auto;
  min-height: 104px;
  padding: 10px 12px;
  font: 400 12.5px/1.55 var(--mono);
  letter-spacing: 0.01em;
  word-break: break-all;
  resize: none;
}

.door__count { color: var(--ink-3); font: 400 12px var(--mono); }
.door__count[data-complete='true'] { color: var(--good); }

.door__status { margin-top: 6px; color: var(--ink-3); font-size: 12.5px; }
.door__status[data-state='valid'] { color: var(--good); }
.door__status[data-state='invalid'], .door__status[data-state='error'] { color: var(--alert); }

.door__error {
  padding: 8px 12px;
  border-left: 2px solid var(--alert);
  background: var(--alert-soft);
  color: var(--ink);
  font-size: 13px;
}

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr) var(--people-width);
  height: 100dvh;
}

.app[data-mode='voice'] { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
.app[data-mode='voice'] .people { display: none; }

.rail {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.rail__head {
  display: flex;
  height: 52px;
  flex: none;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid var(--line);
}

.rail__mark { display: inline-flex; align-items: center; gap: 2px; height: 16px; }
.rail__mark i { display: block; width: 3px; background: var(--ink); }
.rail__mark i:nth-child(1) { height: 7px; background: var(--signal); }
.rail__mark i:nth-child(2) { height: 16px; background: var(--signal); }
.rail__mark i:nth-child(3) { height: 11px; }

.rail__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scrim { display: none; }

.main {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.view {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
}

.view[data-mode='voice'][data-panel='true'] { grid-template-columns: minmax(0, 1fr) var(--panel-width); }
.view[data-mode='voice'] .chat { border-left: 1px solid var(--line); background: var(--panel); }

.top {
  display: flex;
  height: 52px;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
}

.top__menu { display: none; }
.top__icon { display: inline-flex; color: var(--ink-3); }
.top__name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }

.top__topic {
  min-width: 0;
  overflow: hidden;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
  color: var(--ink-3);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top__gap { flex: 1; }

.banner {
  padding: 6px 16px;
  background: var(--signal-soft);
  color: var(--ink);
  font-size: 13px;
}

/* ---------- Tree ---------- */

.tree {
  flex: 1;
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.tree__group + .tree__group { margin-top: 14px; }

.tree__title {
  display: flex;
  height: 26px;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 8px;
  color: var(--ink-3);
  font: 500 11.5px var(--mono);
}

.tree__title button {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}

.tree__title button:hover { background: var(--tint-strong); color: var(--ink); }

.row {
  display: flex;
  min-height: var(--row);
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  border-radius: 5px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.row .icon { color: var(--ink-3); }
.row:hover { background: var(--tint); color: var(--ink); }
.row.is-active { background: var(--tint-strong); color: var(--ink); }
.row.is-unread { color: var(--ink); font-weight: 600; }
.row.is-connected .icon { color: var(--signal); }

.row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__dot { width: 7px; height: 7px; flex: none; border-radius: 2px; background: var(--signal); }
.row__count { color: var(--ink-3); font: 400 11.5px var(--mono); }

/* Users hang off their channel on a rule, the way the tree of a voice server always looked. */
.members {
  position: relative;
  margin: 1px 0 4px 15px;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
}

.member {
  display: flex;
  height: 26px;
  align-items: center;
  gap: 8px;
  padding: 0 6px 0 2px;
  color: var(--ink-2);
  font-size: 13px;
}

.member.is-self .member__name { color: var(--ink); }
.member.is-speaking .member__name { color: var(--ink); }
.member__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member__flags { display: inline-flex; gap: 5px; color: var(--ink-3); }
.member__flags .icon { width: 13px; height: 13px; }
.member__flags .is-off { color: var(--alert); }

/* ---------- Dash ---------- */

.dash { flex: none; border-top: 1px solid var(--line); }

.callbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 8px 12px;
  border-bottom: 1px solid var(--line);
}

.callbar__info { flex: 1; min-width: 0; }

.callbar__info strong {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font: 500 12px var(--mono);
  white-space: nowrap;
}

.callbar__info span {
  display: block;
  overflow: hidden;
  color: var(--ink-3);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.callbar .lamp { background: var(--ink-3); }
.callbar[data-tone='good'] .lamp { background: var(--good); box-shadow: 0 0 6px var(--good); }
.callbar[data-tone='wait'] .lamp { background: var(--signal); }
.callbar[data-tone='bad'] .lamp { background: var(--alert); }

.me {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 8px 8px 10px;
}

.me .face { margin-right: 8px; }
.me__text { flex: 1; min-width: 0; line-height: 1.25; }
.me__text strong { display: block; overflow: hidden; font-size: 13px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.me__text small { color: var(--ink-3); font-size: 11.5px; }
.me .icon-btn.is-off { color: var(--alert); }
.dash__meter { margin: 0 10px 8px; }

/* ---------- People ---------- */

.people {
  min-height: 0;
  padding: 8px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  scrollbar-width: thin;
}

.people__list { margin-bottom: 12px; }

.person {
  display: flex;
  height: 38px;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--ink);
}

.person .face { width: 26px; height: 26px; font-size: 10.5px; border-radius: 6px; }
.person.is-away { color: var(--ink-3); }
.person.is-away .face { opacity: 0.45; }
.person__name { flex: 1; min-width: 0; overflow: hidden; font-size: 13.5px; text-overflow: ellipsis; white-space: nowrap; }
.person__role { display: inline-flex; color: var(--signal); }
.person__role .icon { width: 13px; height: 13px; }

/* ---------- Chat ---------- */

.chat {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
}

.log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  outline: none;
}

.log__inner {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 0 8px;
}

.log__more { padding: 12px 20px; color: var(--ink-3); font-size: 13px; text-align: center; }

.log__start { padding: 24px 20px 20px; }
.log__start .icon { width: 28px; height: 28px; color: var(--ink-3); }
.log__start h3 { margin-top: 8px; font-size: 22px; font-weight: 600; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.log__start p { color: var(--ink-3); }

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 20px 6px;
  color: var(--ink-3);
  font: 400 11.5px var(--mono);
}

.divider::before, .divider::after { content: ''; height: 1px; flex: 1; background: var(--line); }
.divider--new { color: var(--signal); }
.divider--new::before, .divider--new::after { background: var(--signal); opacity: 0.5; }

.msg {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  padding: 1px 20px;
}

.msg--head { margin-top: 12px; padding-top: 2px; }
.msg:hover { background: var(--tint); }
.msg--mention { background: var(--signal-soft); box-shadow: inset 2px 0 var(--signal); }
.msg.is-pending .msg__body { color: var(--ink-3); }

.msg .face { width: 34px; height: 34px; }

.msg__stamp {
  align-self: baseline;
  color: transparent;
  font: 400 10.5px/21px var(--mono);
  text-align: right;
}

.msg:hover .msg__stamp { color: var(--ink-3); }
.msg__head { display: flex; align-items: baseline; gap: 8px; }
.msg__head strong { color: hsl(var(--hue, 30) 45% var(--name-l)); font-size: 14px; font-weight: 600; }
.msg__head time { color: var(--ink-3); font: 400 11px var(--mono); }

.msg__body {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  line-height: 1.5;
}

.msg__body a { color: var(--signal); text-decoration: underline; text-underline-offset: 2px; }
.msg__body small { color: var(--ink-3); font-size: 11px; }
.msg__body code { padding: 1px 5px; border-radius: 4px; background: var(--tint-strong); font: 400 0.9em var(--mono); }
.mention { padding: 0 3px; border-radius: 3px; background: var(--signal-soft); color: var(--signal); font-weight: 500; }

.msg__previews {
  display: flex;
  max-width: 520px;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 4px;
}

.shot { align-self: flex-start; line-height: 0; }

.shot img {
  max-width: 100%;
  max-height: 340px;
  width: auto;
  height: auto;
  border-radius: 6px;
}

.card {
  display: grid;
  gap: 10px;
  padding: 10px 12px;
  overflow: hidden;
  border-left: 2px solid var(--line-strong);
  border-radius: 0 6px 6px 0;
  background: var(--tint);
  color: inherit;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}

.card:hover { border-left-color: var(--signal); background: var(--tint-strong); }
.card--side { grid-template-columns: minmax(0, 1fr) 84px; align-items: start; }
.card__text { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.card__text small { color: var(--ink-3); font: 400 11.5px var(--mono); overflow-wrap: anywhere; }
.card__text strong { font-size: 14px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }

.card__text span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card img { display: block; width: 100%; height: auto; border-radius: 4px; }
.card--wide img { max-height: 280px; object-fit: cover; }
.card--side img { height: 84px; object-fit: cover; }

.msg__tools {
  position: absolute;
  top: -8px;
  right: 16px;
  display: none;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--raised);
}

.msg:hover .msg__tools, .msg:focus-within .msg__tools { display: inline-flex; }

.msg__tools button {
  display: grid;
  width: 28px;
  height: 26px;
  place-items: center;
  border: 0;
  background: none;
  color: var(--ink-2);
  cursor: pointer;
}

.msg__tools button:hover { color: var(--ink); }
.msg__tools .icon { width: 14px; height: 14px; }

.jump {
  position: absolute;
  bottom: 88px;
  left: 50%;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--raised);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
  transform: translateX(-50%);
}

.dock { flex: none; padding: 0 16px 14px; }
.typing { height: 20px; padding: 0 4px; color: var(--ink-3); font-size: 12.5px; line-height: 20px; }

.composer {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--raised);
}

.composer:focus-within { border-color: var(--ink-3); }

.composer__editing {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--signal);
  font-size: 12.5px;
}

.link { border: 0; background: none; color: var(--ink-2); cursor: pointer; text-decoration: underline; }
.composer__row { display: flex; align-items: flex-end; }

.composer textarea {
  flex: 1;
  min-width: 0;
  max-height: 200px;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  outline: none;
  resize: none;
}

.composer textarea::placeholder { color: var(--ink-3); }

.composer__send {
  display: grid;
  width: 40px;
  height: 40px;
  flex: none;
  place-items: center;
  border: 0;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}

.composer__send:hover { color: var(--signal); }

/* ---------- Stage ---------- */

.stage {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}

.lobby {
  display: flex;
  height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.lobby__title { font-size: clamp(32px, 5vw, 56px); font-weight: 600; letter-spacing: -0.03em; overflow-wrap: anywhere; }
.lobby__meta { color: var(--ink-2); font: 400 13px var(--mono); }
.lobby__faces { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0; }
.lobby__faces .face { width: 44px; height: 44px; font-size: 15px; }
.lobby .btn { margin-top: 14px; min-width: 200px; }
.lobby__hint { color: var(--ink-3); font-size: 13px; }

/* Tiles keep 16:9 and grow until the width or the height of the stage runs out. */
.tiles-box {
  min-height: 0;
  flex: 1;
  container-type: size;
}

.tiles {
  --gap: 8px;
  --by-width: calc((100cqw - (var(--columns, 1) - 1) * var(--gap)) / var(--columns, 1));
  --by-height: calc((100cqh - (var(--rows, 1) - 1) * var(--gap)) / var(--rows, 1) * 16 / 9);
  --tile-width: min(var(--by-width), var(--by-height));

  display: grid;
  height: 100%;
  grid-template-columns: repeat(var(--columns, 1), var(--tile-width));
  grid-auto-rows: calc(var(--tile-width) * 9 / 16);
  place-content: center;
  gap: var(--gap);
}

.tiles--focus {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) 136px;
  grid-auto-rows: auto;
  place-content: stretch;
}

.tiles__main { display: grid; min-height: 0; }

.tiles__strip {
  display: flex;
  min-height: 0;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tiles__strip:empty { display: none; }
.tiles--focus:has(.tiles__strip:empty) { grid-template-rows: minmax(0, 1fr); }
.tiles__strip .tile { width: 216px; flex: none; }

.tile {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: var(--tile);
  box-shadow: inset 0 0 0 1px var(--line);
}

.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px var(--signal);
  opacity: 0;
  pointer-events: none;
  transition: opacity 90ms linear;
}

.tile.is-speaking::after { opacity: 1; }
.tile:fullscreen { border-radius: 0; background: #000; }

.tile video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.tile.is-screen video { object-fit: contain; }
.tile:fullscreen video { object-fit: contain; }
.tile video.mirror { transform: scaleX(-1); }

.tile__face {
  width: clamp(56px, 22%, 112px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 14px;
  font-size: clamp(18px, 3vw, 34px);
}

.tile__plate {
  position: absolute;
  bottom: 6px;
  left: 6px;
  display: flex;
  max-width: calc(100% - 12px);
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  border-radius: 5px;
  background: #000000a8;
  color: #fff;
  font-size: 12.5px;
}

.tile__name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__flags { display: inline-flex; gap: 4px; color: #ff8078; }
.tile__flags .icon { width: 13px; height: 13px; }
.tile__route { flex: none; color: #ffffffa0; font: 400 10.5px var(--mono); }

.tile__tools {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: #000000a8;
  color: #fff;
  opacity: 0;
  transition: opacity var(--motion-fast);
}

.tile:hover .tile__tools, .tile:focus-within .tile__tools { opacity: 1; }

.tile__tools button {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  cursor: pointer;
}

.tile__tools button:hover { background: #ffffff26; }
.tile__tools button[aria-pressed='true'] { color: var(--signal); }
.tile__tools .icon { width: 14px; height: 14px; }
.tile__volume { display: inline-flex; align-items: center; gap: 4px; padding: 0 4px; }
.tile__volume input { width: 72px; height: 14px; margin: 0; accent-color: var(--signal); }

.deck {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

/* A stream button and its quality menu read as one control. */
.deck__split { display: inline-flex; flex: none; }
.deck__split .deck__button { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }

.deck__more {
  display: grid;
  width: 26px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--raised);
  color: var(--ink-3);
  cursor: pointer;
}

.deck__more:hover { background: var(--tint-strong); color: var(--ink); }
.deck__more .icon { width: 14px; height: 14px; }

.quality-menu {
  position: fixed;
  inset: auto;
  width: 260px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--raised);
  color: var(--ink);
  box-shadow: var(--hmi-shadow-float);
}

.quality-menu__title { padding: 4px 8px 6px; color: var(--ink-3); font: 500 11.5px var(--mono); }
.quality-menu__actual { margin-top: 4px; padding: 6px 8px 2px; border-top: 1px solid var(--line); color: var(--ink-3); font: 400 11.5px var(--mono); }

.quality-menu button {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.quality-menu button:hover { background: var(--tint-strong); }
.quality-menu strong { display: block; font-size: 13px; font-weight: 500; }
.quality-menu small { display: block; color: var(--ink-3); font-size: 11.5px; }
.quality-menu .icon { color: var(--signal); }

/* The deck follows the room it has, not the window: the chat panel takes part of it. */
.stage { container: stage / inline-size; }

@container stage (max-width: 640px) {
  .deck__button span { display: none; }
}

.deck__gap { flex: 1; }

.deck__button {
  display: inline-flex;
  height: 44px;
  flex: none;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--motion-fast), border-color var(--motion-fast);
}

.deck__button .icon { width: 18px; height: 18px; }
.deck__button:hover { background: var(--tint-strong); }
.deck__button.is-on { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.deck__button.is-danger { border-color: transparent; background: var(--alert-soft); color: var(--alert); }
.deck__button--wide.is-danger { background: var(--alert); color: #fff; }

/* ---------- Dialogs ---------- */

.sheet {
  --modal-width: 520px;
  max-height: min(84dvh, 760px);
  overflow: hidden;
}

.sheet[open] { display: flex; flex-direction: column; }
.sheet--wide { --modal-width: 680px; }
.sheet--small { --modal-width: 380px; }

.sheet__head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.sheet__head h2 { font-size: 15px; font-weight: 600; }
.sheet__body { padding: 16px 20px 20px; overflow-y: auto; }
.sheet__pane { margin-top: 14px; }

.sheet__section { display: flex; flex-direction: column; gap: 12px; }
.sheet__section + .sheet__section { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.sheet__section h3 { color: var(--ink-3); font: 500 11.5px var(--mono); }
.sheet__note { color: var(--ink-2); }
.sheet__form { display: flex; flex-direction: column; gap: 12px; }
.sheet__form .btn { align-self: flex-start; }
.sheet__form .btn--block { align-self: stretch; }

/* A dialog of many switches reads as a list, not a stack of highlighted cards. */
.sheet .switch-field, .sheet .switch-field:has(input:checked) {
  padding: 4px 0;
  border: 0;
  background: none;
}

.sheet .switch-field .choice__label { font-weight: 500; }

.gate { position: relative; height: 24px; }
.gate .meter { position: absolute; top: 9px; right: 0; left: 0; }

.gate input {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  background: none;
  accent-color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}

.gate input::-webkit-slider-thumb {
  width: 4px;
  height: 22px;
  border-radius: 1px;
  background: var(--ink);
  -webkit-appearance: none;
  cursor: ew-resize;
}

.gate input::-moz-range-thumb { width: 4px; height: 22px; border: 0; border-radius: 1px; background: var(--ink); cursor: ew-resize; }

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 72px 112px auto;
  align-items: end;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-form[data-channel-form] { grid-template-columns: minmax(0, 1fr) 140px auto; }
.inline-form .field__error { display: none; }

.table { border-top: 1px solid var(--line); }

.table__title { margin: 14px 0 6px; color: var(--ink-3); font: 500 11.5px var(--mono); }

.table__row {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.table__main { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.table__main strong { font-weight: 500; }
.table__main small { color: var(--ink-3); font-size: 12px; }
.table__empty { padding: 16px 0; color: var(--ink-3); }
.table__limit { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12.5px; }
.table__limit input { width: 62px; }

.fresh {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--signal);
  border-radius: 8px;
  background: var(--signal-soft);
}

.fresh__title { font-size: 13px; }

.fresh__code {
  padding: 10px;
  border-radius: 6px;
  background: var(--bg);
  font: 400 12px/1.55 var(--mono);
  word-break: break-all;
  user-select: all;
}

.fresh__tools { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Narrow screens ---------- */

@media (max-width: 1180px) {
  .app { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  .people { display: none; }
  .view[data-mode='voice'][data-panel='true'] { grid-template-columns: minmax(0, 1fr) 300px; }
}

@media (max-width: 760px) {
  .door { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; height: auto; min-height: 100dvh; }
  body:has(.door) { overflow: auto; }
  .door__brand { padding: 24px 20px 16px; }
  .door__name { font-size: clamp(56px, 20vw, 96px); }
  .door__line { font-size: 15px; }
  .door__panel { justify-content: flex-start; padding: 20px; border-top: 1px solid var(--line); border-left: 0; }

  .app, .app[data-mode='voice'] { grid-template-columns: minmax(0, 1fr); }

  .rail {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    width: min(300px, 84vw);
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateX(-102%);
    transition: transform var(--motion-standard);
  }

  .app[data-rail='open'] .rail { transform: none; }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: none;
    border: 0;
    background: #00000080;
  }

  .app[data-rail='open'] .scrim { display: block; }
  .top { padding: 0 12px 0 4px; }
  .top__menu { display: inline-grid; }
  .top__topic { display: none; }
  .view[data-mode='voice'][data-panel='true'] { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 42%); }
  .view[data-mode='voice'] .chat { border-top: 1px solid var(--line); border-left: 0; }
  .dock { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  .msg { padding-right: 12px; padding-left: 12px; }
  .stage { padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .deck__button { padding: 0 12px; }
  .tiles--focus { grid-template-rows: minmax(0, 1fr) 96px; }
  .tiles__strip .tile { width: 150px; }
  .inline-form, .inline-form[data-channel-form] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form > :first-child { grid-column: 1 / -1; }
  .inline-form .btn { grid-column: 1 / -1; }
  .table__row { flex-wrap: wrap; }
  .table__main { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
