/* ==========================================================================
   Live podcast (js/live/). Reads css/tokens.css only; red (--danger) is the
   section's "live" colour, amber stays the action colour, mention blue
   --info (was #8FB6FF) marks @mentions and the Email tag. Comments and names use
   IBM Plex Sans Arabic so Arabic renders well next to English.
   ========================================================================== */

:root {
  --live-mention: var(--info);
  --live-mention-bg: var(--info-soft);
  --live-mention-border: color-mix(in srgb, var(--info) 35%, var(--line));
  --live-guide: var(--brand);
  --font-comments: var(--font-sans);
}

/* ---- entry points (header menu, Home) ---- */

.menu-icon-live { color: var(--danger); }

.home-card-icon-live {
  border-radius: var(--radius-lg);
  background: var(--danger);
  color: var(--ink-inverse);
}

.home-card-icon-live svg { width: 28px; height: 28px; }

/* ---- section shell ---- */

.live-page {
  min-height: calc(100vh - 65px);
  padding: 24px;
  color: var(--text);
}

.live-page .btn-small {
  width: auto;
  margin-top: 0;
}

.live-page .icon { flex-shrink: 0; }

.live-viewer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  margin: -24px -24px 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
  font-weight: 600;
}

.live-viewer-bar[hidden] { display: none; }

/* Public viewer pages: no studio header, no Files/Tools. */
body.live-viewer .topbar { display: none; }
body.live-viewer .live-page { min-height: 100vh; }

.mono { font-family: var(--font-mono); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.live-kicker {
  margin: 0 0 6px;
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.live-page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}

.live-page-title:focus { outline: none; }

.live-page-sub {
  max-width: 640px;
  margin: 6px 0 0;
  color: var(--muted);
}

.live-hint {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.live-label {
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}

.live-card {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  box-shadow: var(--shadow-panel);
}

.live-card + .live-card { margin-top: 16px; }

.live-card-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
}

.live-field { margin-top: 14px; }
.live-field:first-of-type { margin-top: 0; }

.live-field > label,
.live-field > .live-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
}

.live-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.live-row > .live-input { flex: 1 1 200px; min-width: 0; }
.live-row-between { justify-content: space-between; }

.live-input,
.live-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-4);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.live-select { width: auto; }

.live-input:focus-visible,
.live-select:focus-visible,
.live-c-input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent);
  outline-offset: 0;
}

.live-input[aria-invalid="true"] { border-color: var(--danger); }

.live-field-error {
  margin: 6px 0 0;
  color: var(--danger-text);
  font-size: 12.5px;
}

.live-page :focus-visible,
.live-end-dialog :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.live-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.live-icon-btn:hover { border-color: var(--border-strong); color: var(--text); }

.live-link-btn {
  margin-top: 12px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  text-decoration: underline;
  cursor: pointer;
}

.live-segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.live-segmented button { flex: 1 1 auto; padding: 8px 12px; white-space: nowrap; }
.live-segmented button:disabled { opacity: 0.4; cursor: not-allowed; }

.live-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.live-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Switch rows (Set up) */

.live-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
}

.live-card-title + .live-switch-row { border-top: 0; padding-top: 0; }
.live-switch-text { display: flex; flex-direction: column; }
.live-switch-label { font-size: 14px; }
.live-switch { position: relative; flex-shrink: 0; width: 38px; height: 22px; }

.live-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.live-switch-track {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: var(--border-strong);
  transition: background 0.15s;
  pointer-events: none;
}

.live-switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text);
  content: "";
  transition: transform 0.15s;
}

.live-switch input:checked + .live-switch-track { background: var(--accent); }
.live-switch input:checked + .live-switch-track::after { background: var(--accent-ink); transform: translateX(16px); }
.live-switch input:focus-visible + .live-switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.live-sub {
  margin-top: 4px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
}

.live-sub[hidden] { display: none; }

/* ---- Set up ---- */

.live-setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
}

.live-page-head { margin-bottom: 20px; }

.live-setup-aside {
  position: sticky;
  top: 89px;
  align-self: start;
}

.live-summary {
  margin: 0;
  padding-left: 18px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.5;
}

.live-summary li + li { margin-top: 6px; }

.live-setup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.live-btn-live {
  border-color: var(--danger);
  background: var(--danger);
  color: var(--ink-inverse);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.live-btn-live:hover:not(:disabled) { border-color: color-mix(in srgb, var(--danger) 85%, var(--ink)); background: color-mix(in srgb, var(--danger) 85%, var(--ink)); }
.live-setup-actions .btn { width: 100%; min-height: 44px; }

.live-btn-end {
  border-color: var(--danger-border);
  background: var(--danger-soft-bg);
  color: var(--danger-text);
}

.live-btn-end:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }

.live-choice-group { display: grid; gap: 8px; }

.live-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.live-choice[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft-bg); }

.live-choice-dot {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
}

.live-choice[aria-checked="true"] .live-choice-dot { border: 5px solid var(--accent); }
.live-choice-text { display: flex; flex-direction: column; }
.live-choice-label { font-weight: 600; }
.live-cover-preview { display: grid; gap: 8px; }
.live-cover-preview img { width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--radius-md); }

.live-table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 13.5px;
}

.live-table th {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

.live-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.live-table td:last-child { width: 40px; text-align: right; }
.live-email { font-family: var(--font-mono); font-size: 12.5px; word-break: break-all; }

/* ---- Studio ---- */

.live-studio,
.live-watch {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1480px;
  margin: 0 auto;
}

.live-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.live-badge-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-pill);
  background: var(--danger-soft-bg);
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.live-badge-live.is-test { border-color: var(--accent-soft-border); background: var(--accent-soft-bg); color: var(--accent); }
.live-badge-live.is-test .live-dot { background: var(--accent); box-shadow: none; animation: none; }

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: live-pulse 1.6s ease-in-out infinite;
}

@keyframes live-pulse { 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

.live-timer { color: var(--text); font-weight: 600; }

.live-bar-title {
  display: flex;
  flex: 1 1 200px;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.live-bar-name {
  overflow: hidden;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-bar-counts { display: flex; flex-direction: column; font-size: 13px; }
.live-count { font-weight: 600; }
.live-count-sub { color: var(--muted); font-size: 12px; }

.live-rec-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.live-rec-chip[hidden] { display: none; }

.live-rec-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.live-test-banner {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-md);
  background: var(--accent-soft-bg);
  color: var(--accent);
  font-size: 13px;
}

.live-studio-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.live-studio-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.live-stage-view, .live-board-view { display: flex; flex-direction: column; gap: 12px; }
.live-stage-view[hidden], .live-board-view[hidden] { display: none; }

.live-stage {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.live-stage-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.live-stage-quality { color: var(--muted); font-size: 11.5px; }

.live-stage-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  box-shadow: var(--shadow-stage);
}

.live-stage-canvas,
.live-watch-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.live-stage-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.live-stage-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.live-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.live-tb-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 68px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.live-tb-btn:hover { border-color: var(--border-strong); background: var(--raised); }
.live-tb-btn.is-toggle[aria-pressed="false"] { color: var(--danger-text); }
.live-tb-btn.is-toggle[aria-pressed="false"] .icon { opacity: 0.6; }

.live-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 89px;
  max-height: calc(100vh - 110px);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

body.live-viewer .live-side { top: 16px; max-height: calc(100vh - 110px); }

.live-side-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.live-side-head .live-card-title { margin: 0; }

.live-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.live-tab {
  padding: 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.live-tab[aria-selected="true"] { background: var(--border); color: var(--text); font-weight: 600; }
.live-tabpanel { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.live-tabpanel[hidden] { display: none; }
.live-mini { display: grid; gap: 6px; }
.live-mini[hidden] { display: none; }
.live-mini-canvas { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius-md); background: #fff; }

/* Drawer holding the Recorder's own panels */

.live-drawer {
  position: fixed;
  top: 80px;
  right: 16px;
  bottom: 16px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface-1);
  box-shadow: var(--shadow-popover);
}

.live-drawer[hidden] { display: none; }

.live-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 0;
}

.live-drawer-head .live-card-title { margin: 0; }

.live-drawer-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 14px 16px 16px;
}

.live-drawer-body .sound-section { margin: 0; }

/* ---- Comments ---- */

.live-comments {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  font-family: var(--font-comments);
}

.live-c-scroll {
  flex: 1;
  min-height: 160px;
  max-height: 56vh;
  overflow-y: auto;
  padding-right: 2px;
}

.live-comments.is-compact .live-c-scroll { max-height: 40vh; }
.live-c-empty { margin: 16px 0; color: var(--muted); font-size: 13px; text-align: center; list-style: none; }
.live-c-thread + .live-c-thread { margin-top: 10px; }

.live-c {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-3);
}

.live-c-replies {
  display: grid;
  gap: 6px;
  margin: 6px 0 0 16px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
}

.live-c.is-pending { opacity: 0.55; border-style: dashed; }
.live-c.is-hidden { opacity: 0.45; }
.live-c.is-featured { border-color: var(--accent-soft-border); }
.live-c.is-pinned { border-color: var(--border-strong); }

.live-c-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.live-c-name { font-size: 13px; font-weight: 600; unicode-bidi: isolate; }
.live-c-time { margin-left: auto; color: var(--muted); font-size: 11px; }
.live-c-flag { display: inline-flex; color: var(--muted); }
.live-c-flag.is-screen { padding: 1px 6px; border-radius: var(--radius-pill); background: var(--accent-soft-bg); color: var(--accent); font-size: 10.5px; font-weight: 600; }

.live-c-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
  text-align: start;
}

.live-mention {
  color: var(--live-mention);
  font-weight: 600;
  unicode-bidi: isolate;
}

.live-c-wait { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-style: italic; }

.live-c-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.live-c-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.live-c-action:hover { border-color: var(--border-strong); color: var(--text); }
.live-c-action[aria-pressed="true"] { color: var(--accent); }
.live-c-approve { border-color: var(--success); color: var(--success); }

.live-c-pinned,
.live-c-queue {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.live-c-pinned[hidden], .live-c-queue[hidden] { display: none; }
.live-c-queue { display: grid; gap: 6px; max-height: 30vh; overflow-y: auto; border-color: var(--accent-soft-border); }

.live-c-kicker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 6px;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.live-tag {
  padding: 1px 7px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
}

.live-tag-host { border-color: var(--danger-border); background: var(--danger-soft-bg); color: var(--danger-text); }
.live-tag-email { border-color: var(--live-mention-border); background: var(--live-mention-bg); color: var(--live-mention); }

.live-c-composer {
  display: grid;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.live-c-composer[hidden] { display: none; }

.live-c-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 4px 2px 10px;
  border: 1px solid var(--live-mention-border);
  border-radius: var(--radius-pill);
  background: var(--live-mention-bg);
  font-size: 12.5px;
}

.live-c-chip[hidden] { display: none; }

.live-c-field {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-4);
}

.live-c-field:focus-within { border-color: var(--accent); }
.live-c-prefix { padding-top: 1px; white-space: nowrap; user-select: none; }
.live-c-prefix[hidden] { display: none; }

.live-c-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
}

.live-c-composer-foot { display: flex; align-items: center; justify-content: space-between; }
.live-c-counter { color: var(--muted); font-size: 11px; }
.live-c-send { min-height: 34px; padding: 6px 16px; }
.live-c-error { margin: 0; color: var(--danger-text); font-size: 12.5px; }
.live-c-off { text-align: center; }

/* ---- Audience ---- */

.live-audience { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; }

.live-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.live-stat {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.live-stat-value { font-size: 18px; font-weight: 600; }
.live-stat-label { color: var(--muted); font-size: 11.5px; }

.live-search { position: relative; display: block; }
.live-search-icon { position: absolute; top: 50%; left: 10px; color: var(--muted); transform: translateY(-50%); display: inline-flex; }
.live-search .live-input { padding-left: 32px; }

.live-aud-list, .live-aud-log { margin: 0; padding: 0; list-style: none; }

.live-aud-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.live-aud-main { display: flex; flex: 1; flex-direction: column; min-width: 0; }
.live-aud-main .live-hint { margin: 0; }
.live-aud-label { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.live-aud-time { color: var(--muted); font-size: 11px; }

.live-badge {
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  font-size: 11.5px;
}

.live-badge.is-full { border-color: var(--accent-soft-border); color: var(--accent); }

.live-aud-log-line {
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  color: var(--danger-text);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* ---- Board ---- */

.live-board {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
}

.live-board-tools {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.live-tool-group { display: flex; flex-direction: column; gap: 4px; }
.live-tool-row { display: flex; gap: 2px; }

.live-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
}

.live-tool:hover { border-color: var(--border-strong); }
.live-tool[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft-bg); color: var(--accent); }
.live-tool-mini { width: 19px; height: 24px; font-size: 13px; }
.live-tool-mini[aria-pressed="false"] { color: var(--muted); }
.live-tool-danger:hover { color: var(--danger-text); }

.live-swatches { flex-direction: row; flex-wrap: wrap; justify-content: center; width: 44px; gap: 4px; }

.live-swatch {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
}

.live-swatch[aria-checked="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }

.live-board-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.live-board-surface {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.live-board-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.live-board-canvas[data-tool="select"] { cursor: default; }
.live-board-canvas[data-tool="text"] { cursor: text; }
.live-board-canvas[data-tool="laser"] { cursor: none; }
.live-board-canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.live-board-field {
  position: absolute;
  min-width: 120px;
  padding: 2px 4px;
  border: 1px dashed var(--accent);
  background: rgba(255, 255, 255, 0.9);
  font-family: var(--font-comments);
  resize: none;
  outline: none;
}

.live-board-field.is-sticky { background: #FFE58A; border-style: solid; }

.live-board-cam {
  position: absolute;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-md);
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  cursor: grab;
  touch-action: none;
}

.live-board-cam[hidden] { display: none; }
.live-board-cam:active { cursor: grabbing; }
.live-board-cam:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.live-board-cam-canvas { display: block; width: 100%; height: 100%; }

.live-board-cam-label {
  position: absolute;
  bottom: 4px;
  left: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 10.5px;
}

.live-board-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.live-pages { display: flex; flex-wrap: wrap; gap: 4px; }

.live-page-tab {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  cursor: pointer;
}

.live-page-tab[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }
.live-page-add { display: inline-flex; align-items: center; justify-content: center; }

/* ---- Join ---- */

.live-join { display: flex; justify-content: center; }

.live-join-card {
  width: min(520px, 100%);
  padding: 0 0 22px;
  overflow: hidden;
}

.live-join-cover {
  position: relative;
  aspect-ratio: 16 / 7;
  background: var(--gradient-deep); /* prestige ground: the viewer's first screen */
}

.live-join-cover img { width: 100%; height: 100%; object-fit: cover; }

.live-join-cover-blank {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--gold);
}

.live-join-cover-blank .icon { width: 48px; height: 48px; }
.live-join-badge { position: absolute; top: 12px; left: 12px; }
.live-join-head, .live-join-form, .live-join-state { padding: 0 22px; }
.live-join-head { margin: 18px 0 16px; }
.live-join-meta { margin: 6px 0 0; color: var(--text-2); font-size: 13px; }
.live-join-meta[hidden] { display: none; }
.live-join-form .live-field { margin-top: 14px; }
.live-join-submit { width: 100%; margin-top: 18px; }
.live-join-state h2 { margin: 0 0 6px; font-size: 18px; }

.live-join-error {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  background: var(--danger-soft-bg);
  color: var(--danger-text);
  font-size: 13.5px;
}

.live-join-error[hidden] { display: none; }
.live-join-error p { margin: 0 0 6px; }
.live-join-error-title { color: var(--text); font-weight: 600; }
.live-join-error .live-row { margin-top: 10px; }
.live-device-list { margin: 6px 0; padding-left: 18px; color: var(--text-2); }

/* ---- Watch ---- */

.live-watch-frame.is-ended { opacity: 0.5; }

.live-watch-status {
  position: absolute;
  left: 50%;
  bottom: 14px;
  max-width: 90%;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 13px;
  transform: translateX(-50%);
}

.live-watch-status[hidden] { display: none; }

.live-watch-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-1);
}

.live-inline-field { display: inline-flex; align-items: center; gap: 8px; }

.live-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  background: var(--danger-soft-bg);
  color: var(--danger-text);
  font-size: 13px;
}

.live-watch-ended {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  text-align: center;
}

.live-watch-ended[hidden] { display: none; }
.live-watch-ended h2 { margin: 0 0 4px; }
.live-empty { color: var(--muted); }

/* ---- Record page (server Web Egress) ---- */

body.live-record .topbar,
body.live-record .live-viewer-bar { display: none; }
body.live-record .live-page { min-height: 0; padding: 0; }

.live-record {
  position: fixed;
  inset: 0;
  background: #000;
}

.live-record-video { width: 100%; height: 100%; object-fit: contain; }

/* ---- responsive ---- */

@media (max-width: 1100px) {
  .live-setup, .live-studio-body { grid-template-columns: minmax(0, 1fr); }
  .live-setup-aside, .live-side { position: static; max-height: none; }
}

@media (max-width: 640px) {
  .live-page { padding: 16px; }
  .live-viewer-bar { margin: -16px -16px 16px; }
  .live-board { grid-template-columns: minmax(0, 1fr); }
  .live-board-tools { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .live-tool-group { flex-direction: row; flex-wrap: wrap; }
  .live-swatches { width: auto; }
}
