/*
 * KT Signal interaction layer
 *
 * This file owns the brand mark and the shared feedback grammar for controls,
 * lists and live-state surfaces. Layout and media-state rules remain in the
 * earlier stylesheets; keeping this layer visual-only prevents future WebRTC
 * fixes from accidentally changing animation or component geometry.
 */

:root {
  --motion-tap: 90ms;
  --motion-fast: 150ms;
  --motion-state: 220ms;
  --motion-panel: 320ms;
  --motion-sequence: 480ms;
  --ease-lock: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-mechanical: cubic-bezier(0.2, 0, 0, 1);
  --signal-glow: 0 0 18px rgba(88, 214, 198, 0.16);
  --accent-glow: 0 0 20px rgba(216, 245, 60, 0.13);
}

@view-transition {
  navigation: auto;
}

::view-transition-group(root) {
  animation-duration: var(--motion-sequence);
  animation-timing-function: var(--ease-lock);
}

html[data-view-transition="room"]::view-transition-image-pair(root) {
  isolation: isolate;
  background: var(--bg-0);
}

html[data-view-transition="room"]::view-transition-old(root) {
  animation: route-view-exit 190ms cubic-bezier(0.4, 0, 1, 1) both;
}

html[data-view-transition="room"]::view-transition-new(root) {
  animation: route-view-enter 440ms 80ms var(--ease-lock) both;
}

/* Brand assets ----------------------------------------------------------- */

.brand-mark {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border: 1px solid rgba(242, 240, 231, 0.28);
  background: #090a08;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 78% 100%, 0 100%);
  box-shadow: inset 0 0 0 3px #090a08;
  transition:
    border-color var(--motion-state) var(--ease-mechanical),
    filter var(--motion-state) var(--ease-mechanical);
}

.brand-mark::after {
  display: none;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-scan {
  position: absolute;
  inset: -30% 0 auto;
  z-index: 2;
  height: 22%;
  opacity: 0;
  background: linear-gradient(180deg, transparent, rgba(88, 214, 198, 0.62), transparent);
  mix-blend-mode: multiply;
  pointer-events: none;
}

body[data-connection="online"] .brand-mark {
  border-color: rgba(88, 214, 198, 0.72);
  filter: drop-shadow(0 0 7px rgba(88, 214, 198, 0.18));
}

body[data-connection="online"] .brand-scan {
  animation: brand-signal-scan 4.8s 900ms linear infinite;
}

.brand-mark.signal-lock {
  animation: brand-signal-lock 420ms var(--ease-lock) both;
}

.entry-brand-seal {
  position: absolute;
  right: clamp(26px, 4vw, 68px);
  bottom: clamp(24px, 5vh, 56px);
  z-index: 2;
  width: 64px;
  height: 64px;
  opacity: 0.72;
  filter: saturate(0.9) contrast(1.08);
  box-shadow: 14px 14px 0 rgba(216, 245, 60, 0.12);
  animation: archive-seal-in 560ms 260ms var(--ease-lock) both;
}

.entry-brand-seal::selection {
  background: transparent;
}

/* Header and connection feedback --------------------------------------- */

.topbar {
  box-shadow: 0 10px 38px rgba(0, 0, 0, 0.24);
}

.brand-block {
  position: relative;
}

.brand-block::after {
  content: "KTLR // SIGNAL 01";
  position: absolute;
  right: 0;
  bottom: -1px;
  color: rgba(242, 240, 231, 0.24);
  font-family: var(--font-mono);
  font-size: 7px;
  pointer-events: none;
}

.connection-pill {
  position: relative;
  overflow: hidden;
  padding-left: 30px;
  transition:
    color var(--motion-state) var(--ease-mechanical),
    border-color var(--motion-state) var(--ease-mechanical),
    background var(--motion-state) var(--ease-mechanical),
    box-shadow var(--motion-state) var(--ease-mechanical);
}

.connection-pill::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 6px;
  height: 6px;
  border: 1px solid currentColor;
  background: transparent;
  transform: translateY(-50%) rotate(45deg);
  transition: background var(--motion-state), box-shadow var(--motion-state);
}

.connection-pill[data-state="online"]::before,
.connection-pill[data-state="在线"]::before {
  background: var(--signal);
  box-shadow: 0 0 0 4px rgba(88, 214, 198, 0.1), 0 0 14px rgba(88, 214, 198, 0.5);
}

.connection-pill[data-state="connecting"]::before,
.connection-pill[data-state="reconnecting"]::before,
.connection-pill[data-state="连接中"]::before,
.connection-pill[data-state="重连中"]::before {
  animation: connection-search 1.2s ease-in-out infinite;
}

.connection-pill > svg {
  display: none;
}

/* Shared control grammar ------------------------------------------------ */

.primary-button,
.ghost-button,
.danger-button,
.icon-button,
.inspector-button,
.segmented button,
.view-toggle button,
.mobile-switcher button,
.unread-button,
.tile-audio-button {
  isolation: isolate;
  will-change: auto;
}

/* Button categories own their feedback. The previous shared corner/sweep
   pseudo-elements made every control react identically and fought the active
   indicator used by segmented controls. */
.primary-button::before,
.ghost-button::before,
.danger-button::before,
.icon-button::before,
.inspector-button::before,
.segmented button::before,
.view-toggle button::before,
.mobile-switcher button::before,
.unread-button::before,
.tile-audio-button::before {
  content: none;
}

.primary-button::after,
.ghost-button::after,
.danger-button::after,
.icon-button::after,
.inspector-button::after,
.segmented button::after,
.view-toggle button::after,
.mobile-switcher button::after {
  content: none;
}

button > svg,
button > span,
.inspector-button > * {
  position: relative;
  z-index: 1;
}

button > svg {
  transition: transform var(--motion-state) var(--ease-lock);
}

.primary-button.is-pressing:not(:disabled),
.primary-button:active:not(:disabled),
.ghost-button.is-pressing:not(:disabled),
.ghost-button:active:not(:disabled),
.danger-button.is-pressing:not(:disabled),
.danger-button:active:not(:disabled),
.icon-button.is-pressing:not(:disabled),
.icon-button:active:not(:disabled),
.inspector-button.is-pressing:not(:disabled),
.inspector-button:active:not(:disabled),
.tile-audio-button.is-pressing:not(:disabled),
.tile-audio-button:active:not(:disabled) {
  transform: translateY(1px);
  transition-duration: var(--motion-tap);
}

.segmented button.is-pressing:not(:disabled),
.segmented button:active:not(:disabled),
.view-toggle button.is-pressing:not(:disabled),
.view-toggle button:active:not(:disabled),
.mobile-switcher button.is-pressing:not(:disabled),
.mobile-switcher button:active:not(:disabled) {
  opacity: 0.62;
}

button:disabled {
  opacity: 0.42;
  filter: saturate(0.45);
}

.primary-button {
  box-shadow: inset 0 -3px 0 rgba(9, 10, 8, 0.24), var(--accent-glow);
}

.primary-button:not(:disabled):hover {
  color: var(--bg-0);
  background: #efffa0;
  border-color: #f7ffd2;
  box-shadow: inset 0 -3px 0 rgba(9, 10, 8, 0.28), 0 0 0 1px rgba(216, 245, 60, 0.42);
}

.primary-button:not(:disabled):hover > svg {
  transform: scale(1.04);
}

.share-command:not(:disabled):hover > svg {
  transform: translateY(-2px);
}

.send-button:not(:disabled):hover > svg {
  transform: translate(2px, -1px);
}

#shareConfirmButton:not(:disabled):hover > svg {
  transform: scale(1.08);
}

.ghost-button:not(:disabled):hover {
  color: var(--ink-strong);
  background: rgba(242, 240, 231, 0.055);
  border-color: rgba(242, 240, 231, 0.42);
}

.icon-button:not(:disabled):hover {
  color: var(--signal);
  background: rgba(88, 214, 198, 0.08);
  border-color: rgba(88, 214, 198, 0.52);
}

.icon-button:not(:disabled):hover > svg {
  transform: scale(0.92);
}

.inspector-button:not(:disabled):hover {
  color: var(--ink-strong);
  background: rgba(216, 245, 60, 0.055);
  border-color: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(216, 245, 60, 0.22);
}

.inspector-button:not(:disabled):hover .inspector-chevron {
  transform: translateY(-2px);
}

body[data-settings-open="true"] .inspector-button,
body[data-settings-open="true"] .inspector-button:hover {
  color: var(--ink-strong);
  border-color: var(--accent);
  background: rgba(216, 245, 60, 0.075);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.danger-button:not(:disabled):hover {
  color: #ffb5aa;
  background: rgba(255, 90, 71, 0.09);
  border-color: rgba(255, 90, 71, 0.58);
  box-shadow: inset 3px 0 0 rgba(255, 90, 71, 0.82);
}

.danger-button:not(:disabled):hover > svg {
  transform: scale(0.9);
}

.unread-button:not(:disabled):hover {
  color: var(--bg-0);
  background: #ffe46a;
  border-color: #fff0a1;
  transform: translate(-50%, -1px);
  box-shadow: 0 8px 24px rgba(255, 204, 51, 0.2);
}

.unread-button:not(:disabled):hover > svg {
  transform: translateY(2px);
}

.tile-audio-button:not(:disabled):hover {
  color: var(--accent);
  background: rgba(216, 245, 60, 0.08);
  border-color: var(--accent);
}

.tile-audio-button:not(:disabled):hover > svg {
  transform: scale(1.08);
}

.segmented,
.view-toggle {
  --selected-index: 0;
  --segment-count: 3;
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.view-toggle {
  --segment-count: 2;
}

.segmented::before,
.view-toggle::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--segment-count));
  background: var(--paper);
  box-shadow: inset 0 -3px 0 rgba(9, 10, 8, 0.28);
  transform: translateX(calc(var(--selected-index) * 100%));
  transition: transform var(--motion-panel) var(--ease-lock), background var(--motion-state) var(--ease-mechanical);
  pointer-events: none;
}

.view-toggle::before {
  background: var(--accent);
}

.segmented button,
.view-toggle button {
  position: relative;
  z-index: 1;
  color: var(--muted);
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  transition: color var(--motion-fast) var(--ease-mechanical), opacity var(--motion-fast) var(--ease-mechanical);
}

.segmented button:not(:disabled):not(.active):hover,
.view-toggle button:not(:disabled):not(.active):hover {
  color: var(--ink-strong);
}

.segmented button.active,
.view-toggle button.active {
  color: var(--bg-0);
  background: transparent !important;
}

.mobile-switcher {
  --selected-index: 0;
  --segment-count: 3;
  isolation: isolate;
}

.mobile-switcher::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  left: 6px;
  width: calc((100% - 12px) / var(--segment-count));
  background: var(--accent);
  box-shadow: inset 0 -3px 0 rgba(9, 10, 8, 0.3);
  transform: translateX(calc(var(--selected-index) * 100%));
  transition: transform var(--motion-panel) var(--ease-lock);
  pointer-events: none;
}

.mobile-switcher button {
  position: relative;
  z-index: 1;
  color: var(--muted);
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  transition: color var(--motion-fast) var(--ease-mechanical), opacity var(--motion-fast) var(--ease-mechanical);
}

.mobile-switcher button.active {
  color: var(--bg-0);
  background: transparent !important;
}

/* Scrim opacity has one owner in ui-motion.js so switching between two open
   drawers cannot restart a competing CSS animation. */
.panel-scrim {
  animation: none;
}

.switch-row {
  position: relative;
  overflow: hidden;
  transition:
    color var(--motion-fast) var(--ease-mechanical),
    border-color var(--motion-fast) var(--ease-mechanical),
    background var(--motion-fast) var(--ease-mechanical);
}

.switch-row::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  opacity: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: opacity var(--motion-fast), transform var(--motion-state) var(--ease-lock);
}

.switch-row:has(input:checked)::after {
  opacity: 0.8;
  transform: scaleX(1);
}

.switch-row.toggle-confirm {
  animation: toggle-signal-confirm 300ms var(--ease-lock) both;
}

.switch-track span {
  box-shadow: 0 0 0 1px rgba(242, 240, 231, 0.08);
}

.switch-row input:checked + .switch-track span {
  box-shadow: 0 0 10px rgba(216, 245, 60, 0.42);
}

/* Members and messages -------------------------------------------------- */

.member-list {
  counter-reset: crew-index;
}

.member-item {
  counter-increment: crew-index;
  isolation: isolate;
  overflow: hidden;
  transition:
    background var(--motion-state) var(--ease-mechanical),
    border-color var(--motion-state) var(--ease-mechanical),
    box-shadow var(--motion-state) var(--ease-mechanical);
}

.member-item::before {
  content: counter(crew-index, decimal-leading-zero);
  position: absolute;
  right: 6px;
  bottom: 3px;
  z-index: -1;
  color: rgba(242, 240, 231, 0.18);
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1;
  pointer-events: none;
}

.member-item:hover {
  transform: none;
  border-left-color: var(--accent);
  box-shadow: inset 3px 0 0 rgba(216, 245, 60, 0.58);
}

.member-copy,
.member-status,
.live-badge {
  transition:
    transform var(--motion-state) var(--ease-lock),
    color var(--motion-fast),
    background var(--motion-fast);
}

.member-item:hover .member-copy {
  transform: translateX(3px);
}

.avatar {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transition:
    color var(--motion-state),
    border-color var(--motion-state),
    background var(--motion-state),
    box-shadow var(--motion-state),
    transform var(--motion-state) var(--ease-lock);
}

.avatar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0;
  background: linear-gradient(135deg, transparent 35%, rgba(216, 245, 60, 0.22) 50%, transparent 65%);
  transform: translateX(-120%);
}

.member-item:hover .avatar {
  border-color: var(--accent);
  color: var(--paper);
  transform: translateY(-1px);
  box-shadow: 4px 4px 0 rgba(216, 245, 60, 0.1);
}

.member-item:hover .avatar::after {
  opacity: 1;
  animation: avatar-signal-pass 520ms var(--ease-lock) both;
}

.member-item.streaming {
  box-shadow: inset 3px 0 0 rgba(255, 90, 71, 0.64);
}

.member-item.streaming .avatar {
  border-color: rgba(255, 90, 71, 0.72);
  box-shadow: 0 0 0 3px rgba(255, 90, 71, 0.06);
}

.live-badge {
  gap: 5px;
}

.live-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  background: currentColor;
  animation: live-signal-dot 1.8s ease-in-out infinite;
}

.message-bubble {
  position: relative;
  isolation: isolate;
  transition:
    color var(--motion-state),
    background var(--motion-state),
    border-color var(--motion-state),
    transform var(--motion-state) var(--ease-lock),
    box-shadow var(--motion-state);
}

.message-bubble::before {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  border-top: 1px solid var(--line-strong);
  border-right: 1px solid var(--line-strong);
  opacity: 0.5;
  transition: width var(--motion-state) var(--ease-lock), height var(--motion-state) var(--ease-lock), border-color var(--motion-state);
}

.message:hover .message-bubble {
  transform: translateX(3px);
  border-color: rgba(216, 245, 60, 0.28);
  box-shadow: -4px 0 0 rgba(216, 245, 60, 0.07);
}

.message.mine:hover .message-bubble {
  transform: translateX(-3px);
  box-shadow: 4px 0 0 rgba(88, 214, 198, 0.08);
}

.message:hover .message-bubble::before {
  width: 16px;
  height: 16px;
  border-color: var(--accent);
}

.system-message {
  opacity: 0.84;
}

.system-message::before,
.system-message::after {
  transition: width var(--motion-state) var(--ease-lock), opacity var(--motion-state);
}

.system-message:hover::before,
.system-message:hover::after {
  width: 28px;
  opacity: 0.8;
}

/* Stage and live-state details ----------------------------------------- */

.stage-toolbar,
.control-bar {
  isolation: isolate;
}

.stage-toolbar::after,
.control-bar::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  z-index: 0;
  height: 1px;
  opacity: 0.34;
  background: linear-gradient(90deg, transparent 0, var(--signal) 24%, transparent 56%);
  transform: none;
  pointer-events: none;
}

.control-bar::after {
  inset: 0 0 auto;
}

.video-tile {
  isolation: isolate;
  transition:
    border-color var(--motion-state) var(--ease-mechanical),
    box-shadow var(--motion-state) var(--ease-mechanical),
    opacity var(--motion-state) var(--ease-mechanical);
}

.video-tile video {
  opacity: 0;
  animation: none;
}

.video-tile video.frame-ready {
  opacity: 1;
  animation: video-signal-ready 320ms var(--ease-lock) both;
}

.video-tile:hover,
.video-tile:focus-visible,
.video-tile.active {
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 1px rgba(216, 245, 60, 0.2), var(--accent-glow);
}

.video-tile:hover::before,
.video-tile:hover::after,
.video-tile:focus-visible::before,
.video-tile:focus-visible::after,
.video-tile.active::before,
.video-tile.active::after {
  width: 38px;
  height: 38px;
}

.video-tile.tile-lock {
  animation: tile-signal-lock 360ms var(--ease-lock) both;
}

.pending-video {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.pending-video::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -20%;
  height: 18%;
  opacity: 0.38;
  background: linear-gradient(180deg, transparent, rgba(88, 214, 198, 0.38), transparent);
  animation: pending-signal-scan 2.8s linear infinite;
  pointer-events: none;
}

.tile-live {
  gap: 6px;
}

.tile-live::before {
  content: "";
  flex: 0 0 auto;
  width: 5px;
  height: 5px;
  border: 1px solid currentColor;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: live-signal-dot 1.8s ease-in-out infinite;
}

.tile-label,
.tile-meta,
.tile-stats,
.tile-audio-button {
  backdrop-filter: none;
}

.tile-label {
  border-left: 2px solid var(--accent);
}

.tile-stats {
  border-top-color: rgba(88, 214, 198, 0.34);
}

.broadcast-aperture {
  filter: drop-shadow(0 0 16px rgba(88, 214, 198, 0.08));
}

.aperture-core {
  animation: aperture-core-signal 2.6s ease-in-out infinite;
}

.empty-state::after {
  content: "SIGNAL STANDBY // 01";
  position: absolute;
  left: 18px;
  bottom: 14px;
  color: rgba(242, 240, 231, 0.2);
  font-family: var(--font-mono);
  font-size: 8px;
  pointer-events: none;
}

/* Overlays and mobile --------------------------------------------------- */

.control-inspector:not([hidden]) {
  transform-origin: right bottom;
}

.share-modal {
  box-shadow: 16px 16px 0 rgba(216, 245, 60, 0.06), var(--shadow-overlay);
}

.share-summary {
  position: relative;
  overflow: hidden;
}

.share-summary::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--signal), transparent 72%);
  transform-origin: left;
  animation: summary-signal-in 520ms 100ms var(--ease-lock) both;
}

.toast.show {
  animation: toast-signal-enter 320ms var(--ease-lock) both;
}

.update-banner:not([hidden]) {
  animation: update-banner-enter 320ms var(--ease-lock) both;
}

.toast::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: currentColor;
  opacity: 0.42;
  transform-origin: left;
  animation: toast-signal-life 3.2s linear both;
}

.unread-button {
  animation: unread-signal-arrive 320ms var(--ease-lock);
}

.mobile-switcher button.active > svg {
  animation: mobile-tab-lock 300ms var(--ease-lock) both;
}

/* Keyframes ------------------------------------------------------------- */

@keyframes brand-signal-scan {
  0%, 78% { opacity: 0; transform: translateY(-20%); }
  82% { opacity: 0.62; }
  96% { opacity: 0.2; }
  100% { opacity: 0; transform: translateY(650%); }
}

@keyframes brand-signal-lock {
  0% { transform: scale(0.92); opacity: 0.54; }
  54% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes archive-seal-in {
  from { opacity: 0; transform: translate(12px, 12px); clip-path: inset(0 100% 0 0); }
  to { opacity: 0.72; transform: translate(0, 0); clip-path: inset(0 0 0 0); }
}

@keyframes connection-search {
  0%, 100% { opacity: 0.35; transform: translateY(-50%) rotate(45deg) scale(0.76); }
  50% { opacity: 1; transform: translateY(-50%) rotate(45deg) scale(1.08); }
}

@keyframes route-view-exit {
  from { opacity: 1; transform: translateY(0) scale(1); clip-path: inset(0 0 0 0); }
  to { opacity: 0; transform: translateY(-8px) scale(0.992); clip-path: inset(0 0 100% 0); }
}

@keyframes route-view-enter {
  from { opacity: 0; transform: translateY(14px) scale(1.006); clip-path: polygon(0 12%, 100% 4%, 100% 100%, 0 100%); }
  64% { opacity: 1; }
  to { opacity: 1; transform: translateY(0) scale(1); clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); }
}

@keyframes toggle-signal-confirm {
  0% { box-shadow: inset 0 0 0 rgba(216, 245, 60, 0); }
  48% { box-shadow: inset 0 -3px 0 rgba(216, 245, 60, 0.42); }
  100% { box-shadow: inset 0 -1px 0 rgba(216, 245, 60, 0.18); }
}

@keyframes avatar-signal-pass {
  from { transform: translateX(-120%); }
  to { transform: translateX(120%); }
}

@keyframes live-signal-dot {
  0%, 100% { opacity: 0.48; transform: scale(0.78); }
  45% { opacity: 1; transform: scale(1); }
}

@keyframes pending-signal-scan {
  from { transform: translateY(-120%); }
  to { transform: translateY(760%); }
}

@keyframes tile-signal-lock {
  0% { opacity: 0.72; transform: scale(0.996); }
  58% { opacity: 1; transform: scale(1.002); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes aperture-core-signal {
  0%, 100% { opacity: 0.62; transform: translate(-50%, -50%) scale(0.82); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
}

@keyframes video-signal-ready {
  from { opacity: 0; transform: scale(1.006); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes summary-signal-in {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes toast-signal-enter {
  from { opacity: 0; transform: translate(16px, 6px); }
  to { opacity: 1; transform: translate(0, 0); }
}

@keyframes update-banner-enter {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-signal-life {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@keyframes unread-signal-arrive {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes mobile-tab-lock {
  0% { transform: translateY(2px) scale(0.86); }
  65% { transform: translateY(-2px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}

@media (max-width: 899px) {
  .brand-block::after {
    display: none;
  }

  .entry-brand-seal {
    right: 20px;
    bottom: 22px;
    width: 50px;
    height: 50px;
    box-shadow: 9px 9px 0 rgba(216, 245, 60, 0.1);
  }

  .member-item:hover .member-copy,
  .message:hover .message-bubble,
  .message.mine:hover .message-bubble {
    transform: none;
  }

  #mobileMembersButton,
  #mobileChatButton {
    display: none !important;
  }
}

@media (max-width: 599px) {
  .drawer {
    width: 100vw;
    max-width: none;
  }
}

@media (max-width: 1199px) and (min-width: 900px) {
  .workspace {
    /* Preserve readable identity/status metadata without taking space from the stage. */
    grid-template-columns: 216px minmax(0, 1fr) 250px;
  }

  .side-panel .section-head > div:first-child {
    display: block;
  }

  .side-panel .meter-text {
    display: inline-flex;
  }

  .side-panel .member-copy {
    display: grid;
  }

  .side-panel .member-status {
    display: block;
  }

  .side-panel .live-badge {
    display: inline-flex;
  }

  .side-panel .section-head {
    justify-content: space-between;
    padding-inline: 12px;
  }

  .member-item {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    justify-content: stretch;
    padding: 10px 11px;
  }

  .member-item .avatar {
    width: 40px;
    height: 40px;
  }
}

@media (min-width: 900px) and (max-height: 619px) {
  /* Short desktop windows must keep the broadcast controls inside the viewport. */
  .app-shell {
    min-height: 0;
  }
}

@media (orientation: landscape) and (max-height: 499px) and (max-width: 899px) {
  :root {
    --topbar-height: 44px;
    --mobile-nav-height: 52px;
  }

  /* Keep the optional update row in normal flow. Fixed offsets previously
     consumed the stage row twice and collapsed the video area to zero height. */
  .app-shell {
    min-height: 0;
    padding: 0 var(--mobile-nav-height) 0 0;
    grid-template-rows: auto var(--topbar-height) minmax(0, 1fr);
  }

  .topbar {
    position: relative;
    inset: auto;
    height: var(--topbar-height);
  }

  .workspace,
  .entry-panel {
    margin-top: 0;
  }

  .stage-panel {
    grid-template-rows: 48px minmax(0, 1fr) 54px;
  }

  .control-bar {
    min-height: 0;
    grid-template-columns: auto minmax(180px, 1fr) auto auto;
    grid-template-rows: 40px;
    padding-block: 6px;
  }

  .stream-actions,
  .quality-group,
  .audio-switch,
  .inspector-button {
    grid-column: auto;
    grid-row: 1;
  }

  .mobile-switcher::before {
    top: 4px;
    right: 4px;
    bottom: auto;
    left: 4px;
    width: auto;
    height: calc((100% - 8px) / var(--segment-count));
    transform: translateY(calc(var(--selected-index) * 100%));
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
  }

  .segmented::before,
  .view-toggle::before,
  .mobile-switcher::before {
    transition: none !important;
  }

  .brand-scan,
  .entry-brand-seal,
  .connection-pill::before,
  .live-badge::before,
  .tile-live::before,
  .stage-toolbar::after,
  .control-bar::after,
  .pending-video::after,
  .aperture-core,
  .share-summary::after,
  .toast::after,
  .mobile-switcher button.active > svg {
    animation: none !important;
  }

  /* This transform is layout, not motion: removing it shifts the centered
     unread command to the right edge in reduced-motion mode. */
  .unread-button,
  .unread-button.is-pressing,
  .unread-button:active {
    transform: translateX(-50%) !important;
  }

  button > svg,
  .member-copy,
  .message-bubble,
  .avatar {
    transform: none !important;
  }
}
