/* ReyTV operate surfaces (T2): player, chat, moderation, admin, account.
   Mode: Operate. Motion is colour, the live ring and the broadcast wave only.
   Tokens only (var(--rf-*) and the style.css aliases); #000 stays behind video.
   Logical properties throughout, so fa (rtl) mirrors without overrides. */

/* ---------- Shared bits ---------- */
.op-tile {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px;
  border-radius: var(--rf-radius-sm);
  background: var(--rf-accent-dim);
  color: var(--rf-accent-text);
}
.op-tile .rf-icon { width: 20px; height: 20px; }

.op-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2) var(--sp-3);
  margin-block-end: var(--sp-4);
}
.op-head h1 {
  margin: 0; font-size: var(--rf-fs-xl); line-height: var(--rf-lh-tight);
  min-width: 0; overflow-wrap: anywhere;
}
.op-head__end { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-2); }

.op-iconbtn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  min-width: 40px; height: 40px; padding: 0;
  background: transparent; color: var(--rf-text);
  border: 1px solid var(--rf-line-strong); border-radius: var(--rf-radius-sm);
  cursor: pointer; font: inherit;
  transition: background-color var(--rf-dur-2) var(--rf-ease-out), border-color var(--rf-dur-2) var(--rf-ease-out), color var(--rf-dur-2) var(--rf-ease-out);
}
@media (pointer: coarse) { .op-iconbtn { min-width: 44px; height: 44px; } }
@media (hover: hover) { .op-iconbtn:hover:not(:disabled) { background: var(--rf-hover); border-color: var(--rf-accent); } }
.op-iconbtn:focus-visible { outline: 2px solid var(--rf-accent); outline-offset: 2px; }
.op-iconbtn:disabled { opacity: .4; cursor: not-allowed; }
.op-iconbtn--danger { color: var(--rf-danger); }
.op-iconbtn .rf-icon { width: 18px; height: 18px; }

.op-mono { font-family: var(--rf-font-mono); font-variant-numeric: tabular-nums; }
.op-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Broadcast wave: 5 bars, scaleY keyframes. Static heights by default and under reduced motion. */
.pl-wave { display: none; align-items: center; gap: 3px; height: 18px; }
.pl-wave span {
  width: 3px; height: 100%; border-radius: 2px;
  background: var(--rf-live);
  transform: scaleY(.4); transform-origin: center;
}
.pl-wave span:nth-child(2) { transform: scaleY(.75); }
.pl-wave span:nth-child(3) { transform: scaleY(1); }
.pl-wave span:nth-child(4) { transform: scaleY(.6); }
.pl-wave span:nth-child(5) { transform: scaleY(.3); }
[data-live="true"] .pl-wave { display: inline-flex; }
@keyframes pl-wave {
  0%, 100% { transform: scaleY(.3); }
  50% { transform: scaleY(1); }
}
@media (prefers-reduced-motion: no-preference) {
  [data-live="true"] .pl-wave span { animation: pl-wave 1.1s var(--rf-ease-in-out) infinite; }
  .pl-wave span:nth-child(2) { animation-delay: -.2s !important; }
  .pl-wave span:nth-child(3) { animation-delay: -.45s !important; }
  .pl-wave span:nth-child(4) { animation-delay: -.7s !important; }
  .pl-wave span:nth-child(5) { animation-delay: -.9s !important; }
}

/* ==========================================================================
   Player
   ========================================================================== */
.pl-wrap { padding-block: var(--sp-4) var(--sp-6); }

.pl {
  --pl-bar-h: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-3);
  align-items: start;
}
.pl-main { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; }

/* Frame: video plus its control dock share one bordered card. The ring lives on the frame. */
.pl-frame {
  position: relative;
  border: 1px solid var(--rf-line-strong);
  border-radius: var(--rf-radius-md);
  background: var(--rf-panel);
  transition: border-color var(--rf-dur-3) var(--rf-ease-out);
}
[data-live="true"] .pl-frame { border-color: var(--rf-accent); }
@keyframes pl-ring {
  0%   { box-shadow: 0 0 0 0 var(--rf-accent-glow), 0 0 0 0 var(--rf-accent-glow); }
  70%  { box-shadow: 0 0 0 7px transparent, 0 0 0 0 var(--rf-accent-glow); }
  100% { box-shadow: 0 0 0 7px transparent, 0 0 0 16px transparent; }
}
@media (prefers-reduced-motion: no-preference) {
  [data-live="true"] .pl-frame { animation: pl-ring 2.4s var(--rf-ease-out) infinite; }
}

.video-stage {
  position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  border-radius: calc(var(--rf-radius-md) - 1px) calc(var(--rf-radius-md) - 1px) 0 0;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
.video-element { width: 100%; height: 100%; object-fit: contain; background: #000; }

.offline-state, .loading-state {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--rf-bg) 94%, transparent);
  color: var(--rf-text);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-1); padding: var(--sp-4) var(--sp-3); text-align: center;
}
.offline-state > * { margin: 0; }
.offline-icon {
  width: 64px; height: 64px; border-radius: 50%; border: 1px solid var(--rf-line-strong);
  display: flex; align-items: center; justify-content: center; color: var(--rf-faint);
  margin-block-end: var(--sp-1);
}
.offline-icon .rf-icon { width: 28px; height: 28px; }
.offline-state h2 { font-size: var(--rf-fs-lg); line-height: var(--rf-lh-tight); }
.offline-state p { color: var(--rf-muted); font-size: var(--rf-fs-sm); line-height: 1.5; }
.loading-pulse { display: flex; gap: 6px; margin-block-start: var(--sp-1); }
.loading-pulse span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--rf-accent); opacity: .5;
}
@keyframes pulse-dot {
  0%, 80%, 100% { transform: scale(.4); opacity: .4; }
  40% { transform: scale(1); opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: no-preference) {
  .loading-pulse span { animation: pulse-dot 1.4s infinite ease-in-out both; }
  .loading-pulse span:nth-child(1) { animation-delay: -.32s; }
  .loading-pulse span:nth-child(2) { animation-delay: -.16s; }
  .spinner-ring { animation: spin .9s linear infinite; }
}
.loading-state p { margin: 0; color: var(--rf-muted); font-size: var(--rf-fs-sm); }
.spinner-ring {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--rf-accent-dim); border-top-color: var(--rf-accent);
}
@media (max-width: 479px) {
  .offline-icon { width: 44px; height: 44px; margin-block-end: 0; }
  .offline-icon .rf-icon { width: 20px; height: 20px; }
  .offline-state { padding-block: var(--sp-2); gap: 4px; }
  .loading-pulse { display: none; }
}

/* Connection toast sits top-start so it never touches the offline copy. */
.connection-toast, .unmute-hint {
  position: absolute; inset-block-start: var(--sp-2); inset-inline-start: var(--sp-2);
  display: flex; align-items: center; gap: 6px;
  max-width: calc(100% - 2 * var(--sp-2));
  padding: 6px 12px;
  background: color-mix(in srgb, var(--rf-bg) 88%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--rf-line-strong); border-radius: var(--rf-radius-pill);
  font-size: var(--rf-fs-xs); color: var(--rf-muted);
  transition: opacity var(--rf-dur-2) var(--rf-ease-out);
  z-index: 10;
}
.unmute-hint {
  inset-inline-start: 50%; translate: -50% 0;
  border-color: var(--rf-accent); color: var(--rf-accent-text); pointer-events: none;
}
[dir="rtl"] .unmute-hint { translate: 50% 0; }
.unmute-hint.hidden { opacity: 0; }
.connection-toast.hidden { opacity: 0; pointer-events: none; }
.connection-toast.success { border-color: var(--rf-accent); color: var(--rf-accent-text); }
.connection-toast.error { border-color: var(--rf-danger); color: var(--rf-danger); }
.connection-toast.offline { color: var(--rf-faint); }
/* The overlay already says "Stream offline"; hide the duplicate pill. */
[data-live="false"] .connection-toast.offline { display: none; }
/* Live state is bound to data-live alone: no offline overlay or chip while live. */
[data-live="true"] .offline-state, [data-live="true"] .connection-toast.offline { display: none; }

/* LIVE / OFFLINE badge pair: data-live picks which one shows. */
.pl-badges { display: inline-flex; }
.pl-b-live { display: none; }
[data-live="true"] .pl-b-live { display: inline-flex; }
[data-live="true"] .pl-b-off { display: none; }

/* Control dock */
.controls-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px var(--sp-2);
  border-top: 1px solid var(--rf-line);
}
.controls-spacer { flex: 1; }
.control-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; padding: 0;
  background: transparent; color: var(--rf-text);
  border: 0; border-radius: var(--rf-radius-sm); cursor: pointer;
  transition: background-color var(--rf-dur-2) var(--rf-ease-out), color var(--rf-dur-2) var(--rf-ease-out), transform var(--rf-dur-1) var(--rf-ease-out);
}
@media (hover: hover) { .control-btn:hover:not(:disabled) { background: var(--rf-hover); color: var(--rf-accent-text); } }
.control-btn:active:not(:disabled) { transform: scale(.94); }
.control-btn:focus-visible { outline: 2px solid var(--rf-accent); outline-offset: -2px; }
.control-btn:disabled { opacity: .35; cursor: not-allowed; }
.control-btn .rf-icon { width: 20px; height: 20px; }
.volume-slider { width: 96px; }
.volume-slider input[type="range"] {
  width: 100%; height: 4px; margin: 0; padding: 0;
  background: var(--rf-line-strong); border-radius: 2px; outline: none; -webkit-appearance: none; appearance: none;
}
.volume-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; background: var(--rf-accent); border-radius: 50%; cursor: pointer;
}
.volume-slider input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--rf-accent); border: 0; border-radius: 50%; cursor: pointer; }
.volume-slider input[type="range"]:focus-visible { outline: 2px solid var(--rf-accent); outline-offset: 6px; }
/* Volume has no effect on iOS and is crowded on phones: the mute button stays. */
@media (max-width: 767px) { .volume-slider { display: none; } }

/* Info bar: 56px, name, state, viewers, overflow */
.pl-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: var(--pl-bar-h);
  padding-inline: var(--sp-2);
}
.pl-avatar {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  object-fit: cover; background: var(--rf-panel-2); color: var(--rf-muted);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rf-line);
}
/* Live ring on the avatar, only while live and motion is allowed. */
@keyframes pl-avatar-ring {
  0%   { box-shadow: 0 0 0 2px var(--rf-panel), 0 0 0 4px var(--rf-accent), 0 0 0 4px var(--rf-accent); }
  70%  { box-shadow: 0 0 0 2px var(--rf-panel), 0 0 0 4px var(--rf-accent), 0 0 0 12px transparent; }
  100% { box-shadow: 0 0 0 2px var(--rf-panel), 0 0 0 4px var(--rf-accent), 0 0 0 12px transparent; }
}
[data-live="true"] .pl-avatar { border-color: var(--rf-accent); box-shadow: 0 0 0 2px var(--rf-panel), 0 0 0 4px var(--rf-accent); }
@media (prefers-reduced-motion: no-preference) {
  [data-live="true"] .pl-avatar { animation: pl-avatar-ring 2.4s var(--rf-ease-out) infinite; }
}
.pl-avatar--lg { width: 56px; height: 56px; }
.pl-avatar--lg .rf-icon { width: 24px; height: 24px; }
.pl-chan { display: none; align-items: center; gap: var(--sp-2); }
.pl-chan__name { font-size: var(--rf-fs-lg); font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-chan .pl-id { flex: 1 1 auto; }
.pl-id { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.25; }
.pl-name {
  margin: 0; font-size: var(--rf-fs-base); font-weight: 600; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-handle { font-size: var(--rf-fs-xs); color: var(--rf-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl-state { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.viewer-count {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-family: var(--rf-font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--rf-fs-sm); color: var(--rf-muted);
}
.viewer-count .rf-icon { width: 16px; height: 16px; color: var(--rf-accent-text); }
.pl-actions { display: none; align-items: center; gap: var(--sp-1); flex: none; }
.pl-more { display: inline-flex; }
@media (max-width: 479px) {
  .viewer-count .pl-lbl { display: none; }
  .pl-bar { gap: 8px; padding-inline: 12px; }
}
@media (min-width: 768px) {
  /* The channel card below carries avatar, name and handle on desktop; the bar keeps the h1 for headings only. */
  .pl-bar > .pl-avatar { display: none; }
  .pl-bar .pl-id { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .pl-bar .pl-state { margin-inline-end: auto; }
  .pl-actions { display: inline-flex; }
  .pl-more { display: none; }
}
@media (max-width: 767px) { .pl-handle { display: none; } }

/* Side column: Chat and Info tabs */
.pl-side {
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--rf-panel); border: 1px solid var(--rf-line); border-radius: var(--rf-radius-md);
  height: min(70dvh, 560px);
}
.pl-tabs { display: flex; flex: none; border-bottom: 1px solid var(--rf-line); }
.pl-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 var(--sp-2);
  background: transparent; color: var(--rf-muted);
  border: 0; border-block-end: 2px solid transparent; margin-block-end: -1px;
  font: inherit; font-size: var(--rf-fs-sm); font-weight: 600; cursor: pointer;
  transition: color var(--rf-dur-2) var(--rf-ease-out), border-color var(--rf-dur-2) var(--rf-ease-out), background-color var(--rf-dur-2) var(--rf-ease-out);
}
@media (hover: hover) { .pl-tab:hover { color: var(--rf-text); background: var(--rf-hover); } }
.pl-tab[aria-selected="true"] { color: var(--rf-text); border-block-end-color: var(--rf-accent); }
.pl-tab:focus-visible { outline: 2px solid var(--rf-accent); outline-offset: -2px; }
.pl-tab .rf-icon { width: 16px; height: 16px; }
.pl-panel { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.pl-panel[hidden] { display: none; }

.chat-messages {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: var(--sp-2); display: flex; flex-direction: column; gap: var(--sp-1);
}
.chat-message { font-size: var(--rf-fs-sm); line-height: 1.5; }
.chat-author { color: var(--rf-accent-text); font-weight: 600; margin-inline-end: .4rem; }
.chat-time { color: var(--rf-faint); font-size: var(--rf-fs-xs); font-family: var(--rf-font-mono); }
.chat-body { color: var(--rf-text); overflow-wrap: anywhere; }
.chat-message-guest .chat-author { color: var(--rf-muted); }
.chat-empty { color: var(--rf-faint); font-size: var(--rf-fs-sm); text-align: center; padding: var(--sp-4) 0; margin: 0; }
.chat-empty[hidden] { display: none; }
.chat-form { display: flex; gap: var(--sp-1); padding: var(--sp-2); border-top: 1px solid var(--rf-line); flex: none; }
.chat-form .rf-input { flex: 1; min-width: 0; }
.chat-send { width: 48px; height: 48px; flex: none; }
.chat-send:disabled { opacity: .4; }
.chat-login-cta { padding: var(--sp-4); text-align: center; color: var(--rf-muted); font-size: var(--rf-fs-sm); line-height: 1.8; }
.chat-guest-note { padding: 0 var(--sp-2) var(--sp-2); margin: 0; color: var(--rf-muted); font-size: var(--rf-fs-xs); }

/* Skeleton: chat rows while history loads */
.pl-skel { display: flex; flex-direction: column; gap: var(--sp-2); }
.pl-skel[hidden] { display: none; }
.pl-skel i {
  display: block; height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, var(--rf-panel-2) 25%, var(--rf-hover) 50%, var(--rf-panel-2) 75%);
  background-size: 200% 100%;
}
.pl-skel i:nth-child(odd) { width: 78%; }
.pl-skel i:nth-child(even) { width: 52%; }
.pl-skel i:nth-child(3n) { width: 90%; }
@keyframes pl-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: no-preference) { .pl-skel i { animation: pl-shimmer 1.4s linear infinite; } }

/* Info tab */
.pl-info { overflow-y: auto; padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); margin: 0; }
.info-item { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-2); background: var(--rf-panel-2); border-radius: var(--rf-radius-sm); min-width: 0; }
.info-item dt { display: flex; align-items: center; gap: 6px; font-size: var(--rf-fs-xs); color: var(--rf-faint); }
.info-item dt .rf-icon { width: 14px; height: 14px; color: var(--rf-accent-text); }
.info-item dd { margin: 0; font-family: var(--rf-font-mono); font-variant-numeric: tabular-nums; font-size: var(--rf-fs-sm); overflow-wrap: anywhere; }
.stream-bio { margin: 0; color: var(--rf-muted); font-size: var(--rf-fs-sm); line-height: 1.7; overflow-wrap: anywhere; }
.social-links { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.social-links a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px;
  border: 1px solid var(--rf-line-strong); border-radius: var(--rf-radius-sm);
  color: var(--rf-muted); font-size: var(--rf-fs-sm); text-decoration: none; max-width: 100%;
  transition: color var(--rf-dur-2) var(--rf-ease-out), border-color var(--rf-dur-2) var(--rf-ease-out);
}
.social-links a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (hover: hover) { .social-links a:hover { color: var(--rf-accent-text); border-color: var(--rf-accent); } }
.social-links a:focus-visible { outline: 2px solid var(--rf-accent); outline-offset: 2px; }

/* Locked private stream */
.pl-lock {
  max-width: 480px; margin: var(--sp-5) auto; padding: var(--sp-4);
  background: var(--rf-panel); border: 1px solid var(--rf-line-strong); border-radius: var(--rf-radius-md);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.pl-lock h1 { margin: 0; font-size: var(--rf-fs-lg); }
.pl-lock p { margin: 0; color: var(--rf-muted); font-size: var(--rf-fs-sm); line-height: 1.7; }
.pl-lock form { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.pl-lock .rf-input { flex: 1 1 200px; }

/* Overflow sheet and report dialog contents: 48px rows */
.pl-sheet-list { display: flex; flex-direction: column; gap: var(--sp-1); }
.pl-sheet-list .rf-btn { width: 100%; min-height: 48px; justify-content: flex-start; gap: var(--sp-1); }
.pl-form { display: flex; flex-direction: column; gap: var(--sp-2); }
.pl-form label { display: block; margin-block-end: 6px; font-size: var(--rf-fs-sm); color: var(--rf-muted); }
.pl-form .help-text { margin: 0; color: var(--rf-muted); font-size: var(--rf-fs-xs); line-height: 1.7; }
.pl-form .rf-select, .pl-form .rf-input { width: 100%; }

/* Phone: video, 56px bar, tabs; chat takes the rest of the screen. No gutter around the video. */
@media (max-width: 767px) {
  .pl-wrap { padding-block: 0 var(--sp-4); padding-inline: 0; }
  .pl { gap: 0; }
  .pl-main { gap: 0; }
  .pl-frame { border-radius: 0; border-inline: 0; }
  .video-stage { border-radius: 0; }
  .pl-side { border-radius: 0; border-inline: 0; border-block-end: 0; height: max(320px, calc(100dvh - var(--rf-header-h) - 32px - 57px - 56.25vw - var(--pl-bar-h))); }
  .pl-lock { margin-inline: var(--rf-gutter); }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .pl-side { height: min(60dvh, 520px); }
}
@media (min-width: 1024px) {
  /* Two columns at the same top: video + channel card (inline-start), chat at full height (inline-end).
     .pl-side dissolves so the chat panel and the info panel become grid items; tabs are not needed. */
  .pl { grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto 1fr; gap: var(--sp-3) var(--sp-4); }
  .pl-main { grid-column: 1; grid-row: 1; }
  .pl-side { display: contents; }
  .pl-tabs { display: none; }
  #plPanelChat {
    grid-column: 2; grid-row: 1 / span 2; align-self: start;
    position: sticky; inset-block-start: calc(var(--rf-header-h) + var(--sp-3));
    height: calc(100dvh - var(--rf-header-h) - 2 * var(--sp-3)); max-height: 760px;
    background: var(--rf-panel); border: 1px solid var(--rf-line); border-radius: var(--rf-radius-md); overflow: hidden;
  }
  #plPanelChat[hidden], .pl-info[hidden] { display: flex; }
  .pl-info {
    grid-column: 1; grid-row: 2; align-self: start; overflow: visible;
    background: var(--rf-panel); border: 1px solid var(--rf-line); border-radius: var(--rf-radius-md);
  }
  .pl-chan { display: flex; }
  .info-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ==========================================================================
   Moderation (/live/:username/moderate)
   ========================================================================== */
.mod-shell {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); align-items: start;
}
@media (min-width: 1024px) {
  .mod-shell { grid-template-columns: minmax(0, 1fr) 380px; gap: var(--sp-4); }
  /* Chat column: flex column with a definite height, so the list fills it. */
  .mod-shell .mod-log {
    display: flex; flex-direction: column; min-height: 0;
    position: sticky; inset-block-start: calc(var(--rf-header-h) + var(--sp-3));
    height: calc(100dvh - var(--rf-header-h) - 2 * var(--sp-3));
  }
  .mod-shell .mod-log .chat-messages { flex: 1; min-height: 0; }
}
.mod-main { display: grid; gap: var(--sp-3); min-width: 0; }
.mod-tools { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
@media (min-width: 768px) { .mod-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); } .mod-tools > .mod-card--wide { grid-column: 1 / -1; } }

.mod-card {
  background: var(--rf-panel); border: 1px solid var(--rf-line); border-radius: var(--rf-radius-md);
  padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0;
}
.mod-card > header { display: flex; align-items: center; gap: var(--sp-2); }
.mod-card h2 { margin: 0; font-size: var(--rf-fs-base); line-height: var(--rf-lh-tight); }
.mod-card .op-tile { width: 32px; height: 32px; }
.mod-card .op-tile .rf-icon { width: 16px; height: 16px; }
.mod-card form { display: flex; flex-direction: column; gap: var(--sp-2); }
.mod-card .field label, .mod-card label.op-label { display: block; margin-block-end: 6px; font-size: var(--rf-fs-sm); color: var(--rf-muted); }
.mod-card .help-text, .op-help { margin: 0; color: var(--rf-muted); font-size: var(--rf-fs-xs); line-height: 1.7; }
.mod-card .rf-input { width: 100%; }
.mod-row { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.mod-row .rf-input { flex: 1 1 160px; }
.mod-card .rf-btn { align-self: flex-start; }
.mod-row .rf-btn { align-self: auto; }

.mod-list { display: flex; flex-direction: column; gap: 6px; list-style: none; padding: 0; margin: 0; }
.mod-list li {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: 6px 6px 6px 12px; padding-inline: 12px 6px;
  background: var(--rf-panel-2); border-radius: var(--rf-radius-sm);
  font-size: var(--rf-fs-sm); min-width: 0;
}
.mod-list li > span { min-width: 0; overflow-wrap: anywhere; }
.mod-list li.mod-list__empty { color: var(--rf-faint); justify-content: flex-start; padding-inline: 12px; }
.mod-list .help-text { display: block; }
.mod-list form { display: block; }

.mod-notice {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--rf-danger); border-radius: var(--rf-radius-sm);
  color: var(--rf-danger); font-size: var(--rf-fs-sm);
}

/* Toggle row (switch styles come from style.css) */
.mod-card .toggle-row { padding: 0; }

.mod-log { display: flex; flex-direction: column; min-width: 0; overflow: hidden;
  background: var(--rf-panel); border: 1px solid var(--rf-line); border-radius: var(--rf-radius-md); }
.mod-log > header { display: flex; align-items: center; gap: var(--sp-1); padding: 0 var(--sp-3); min-height: 48px; border-bottom: 1px solid var(--rf-line); flex: none; }
.mod-log h2 { margin: 0; font-size: var(--rf-fs-base); }
.mod-log .chat-messages { max-height: 60dvh; }
@media (min-width: 1024px) { .mod-log .chat-messages { max-height: none; } }
.mod-log .chat-message { padding: 8px 10px; background: var(--rf-panel-2); border-radius: var(--rf-radius-sm); }
.mod-msg-actions { display: flex; gap: 6px; margin-block-start: 6px; }
.mod-msg-actions form { display: block; }

/* ==========================================================================
   Account handoff
   ========================================================================== */
.op-handoff {
  max-width: 560px; margin: var(--sp-5) auto 0; padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-3);
  background: var(--rf-panel); border: 1px solid var(--rf-line-strong); border-radius: var(--rf-radius-lg);
}
.op-handoff__marks { display: flex; align-items: center; gap: var(--sp-2); color: var(--rf-faint); }
.op-handoff__marks .rf-tile { --tile: var(--rf-panel-2); }
.op-handoff h1 { margin: 0; font-size: var(--rf-fs-xl); line-height: var(--rf-lh-tight); }
.op-handoff p { margin: 0; color: var(--rf-muted); font-size: var(--rf-fs-base); line-height: 1.8; }
.op-handoff .rf-btn { align-self: flex-start; }
.op-notice { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--rf-radius-sm); border: 1px solid var(--rf-accent); background: var(--rf-accent-dim); font-size: var(--rf-fs-sm); line-height: 1.7; max-width: 560px; margin-inline: auto; margin-block-start: var(--sp-3); }
.op-notice .rf-icon { margin-block-start: 3px; color: var(--rf-accent-text); }
.op-notice a { color: var(--rf-accent-text); }

/* ---------- v3 (Direction B) player overrides ---------- */
.pl-wrap { max-width: 1488px; padding-block: 16px 64px; }
.pl-frame { border-radius: 18px; overflow: hidden; border-color: var(--rf-line-strong); }
.pl[data-live="true"] .pl-frame { border-color: var(--rf-accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--rf-accent) 35%, transparent), 0 24px 80px -24px var(--rf-accent-glow); }
.pl:not([data-live="true"]) .pl-frame { background: var(--rf-p-ink-1, var(--rf-panel)); }
.controls-bar { background: rgb(14 19 27 / .82); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); }
.offline-state { background: radial-gradient(60% 70% at 50% 40%, color-mix(in srgb, var(--rf-accent) 14%, transparent), transparent 70%), var(--rf-p-ink-0, #06080c); }
.offline-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--rf-accent-dim); color: var(--rf-accent-text); }
.pl-side { border-radius: 18px; border-color: var(--rf-line-strong); background: color-mix(in srgb, var(--rf-panel) 90%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.chat-message { padding: 6px 8px; border-radius: 10px; transition: background var(--rf-dur-2) var(--rf-ease-out); }
@media (hover: hover) { .chat-message:hover { background: rgb(255 255 255 / .04); } }
.chat-form { background: rgb(255 255 255 / .02); }
.pl-bar { border-radius: 14px; }
.pl-tab { transition: color var(--rf-dur-2) var(--rf-ease-out), border-color var(--rf-dur-2) var(--rf-ease-out); }
@media (min-width: 1024px) { .pl-side { height: auto; min-height: 520px; max-height: 78dvh; } }
@media (prefers-reduced-motion: reduce) { .pl-frame, .chat-message, .pl-tab { transition: none; } }
.chat-send { flex: none; min-width: 48px; width: 48px; padding: 0; display: inline-grid; place-items: center; }
.chat-send .rf-icon { width: 20px; height: 20px; }
