:root {
  color-scheme: dark;
  --bg: #0c0d0f;
  --panel-bg: #111419;
  --surface: #14171b;
  --surface-2: #1b2027;
  --surface-3: #252b34;
  --control-bg: #202631;
  --control-hover: #2b3340;
  --active-bg: rgba(127, 160, 78, 0.22);
  --message-bg: #1d222b;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3efe4;
  --muted: #a9a397;
  --muted-2: #79818e;
  --accent: #a0c06d;
  --accent-hover: #bdd78b;
  --accent-deep: #3f592a;
  --accent-mid: #7fa04e;
  --accent-ink: #17200f;
  --teal: #8bae53;
  --danger: #ed756b;
  --field-bg: #11151b;
  --field-bg-focus: #151a21;
  --field-placeholder: rgba(169, 163, 151, 0.72);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.34);
  --radius-outer: 4px;
  --radius-inner: 2px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #0c0d0f;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button .lucide {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(390px, 28vw, 460px);
  gap: 12px;
  width: min(1600px, 100%);
  height: 100dvh;
  margin: 0 auto;
  padding: 12px;
}

.stage {
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(320px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brandLogo {
  width: 60px;
  height: 38px;
  flex: 0 0 auto;
  object-fit: contain;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 1.28rem;
  line-height: 1;
  letter-spacing: 0;
}

.brand p,
.presence,
.field span,
.sidePanel header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.channelBar,
.panelTabs {
  display: flex;
  gap: 6px;
  min-width: 0;
}

.channelBar {
  position: relative;
  align-items: center;
}

.channelForm {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.channelForm input {
  display: none;
  width: 132px;
}

.channelForm.editing input {
  display: block;
}

.channelSelect {
  flex: 1;
  min-width: 0;
  height: 38px;
  border: 0;
  border-radius: var(--radius-outer);
  padding: 0 34px 0 12px;
  appearance: none;
  background-color: var(--field-bg);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  color: var(--text);
  outline: none;
}

.channelSelect:focus {
  background-color: var(--field-bg-focus);
}

.channelSelect:hover,
.presence:hover,
.channelForm .iconBtn:hover {
  background-color: var(--control-hover);
}

.panelTab,
.textBtn {
  border: 0;
  border-radius: var(--radius-inner);
  background: var(--surface-2);
  color: var(--muted);
}

.panelTab.active {
  background: var(--active-bg);
  color: var(--accent);
}

.textBtn.active {
  background: var(--active-bg);
  color: var(--accent);
}

.presence {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-outer);
  background: var(--surface-2);
  white-space: nowrap;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}

.dot.live {
  background: var(--teal);
}

.divider {
  width: 1px;
  height: 17px;
  background: var(--line);
}

.playerWrap {
  position: relative;
  display: grid;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #050506;
  box-shadow: none;
}

.playerModule {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 6px;
  min-height: 0;
}

.playerWrap.noVideo .mediaPlayer {
  visibility: hidden;
}

.artPlayer,
.emptyState {
  grid-area: 1 / 1;
}

.artPlayer {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.emptyState {
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.emptyState strong {
  color: var(--text);
  font-size: clamp(1.2rem, 2vw, 1.8rem);
}

.emptyState.hidden {
  display: none;
}

.mediaPlayer {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  background: #050506;
  color: var(--text);
  font-family: inherit;
  --media-primary-color: #fff;
  --media-secondary-color: rgba(255, 255, 255, 0.84);
  --media-control-background: #000;
  --media-control-hover-background: rgba(255, 255, 255, 0.08);
}

.mediaPlayer video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050506;
}

.mediaControlBar {
  align-items: center;
  height: 42px;
  overflow: hidden;
  padding: 0 8px;
  background: #000;
}

media-volume-range {
  width: 72px;
  max-width: 12vw;
}

.segmentTimeDisplay {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 94px;
  height: 34px;
  color: rgba(238, 242, 232, 0.88);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

.segmentTimeRange {
  position: relative;
  flex: 1 1 auto;
  min-width: 80px;
  height: 34px;
  cursor: pointer;
  outline: none;
  touch-action: pan-y;
}

.segmentTimeRange::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  background: rgba(238, 242, 232, 0.28);
}

.segmentTimeFill {
  position: absolute;
  left: 0;
  top: 50%;
  width: var(--segment-progress, 0%);
  height: 4px;
  transform: translateY(-50%);
  background: #fff;
}

.segmentTimeRange::after {
  content: "";
  position: absolute;
  left: var(--segment-progress, 0%);
  top: 50%;
  width: 12px;
  height: 12px;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 50%;
}

.segmentTimeRange:focus-visible::before {
  background: rgba(255, 255, 255, 0.38);
}

.sofaDanmakuLayer {
  position: absolute;
  inset: 0;
  z-index: 90;
  overflow: hidden;
  contain: strict;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: none;
  transition: none !important;
}

.playerWrap:fullscreen,
.mediaPlayer:fullscreen,
.playerWrap:-webkit-full-screen,
.mediaPlayer:-webkit-full-screen {
  position: relative;
  overflow: hidden;
  background: #050506;
}

:fullscreen .sofaDanmakuLayer,
:-webkit-full-screen .sofaDanmakuLayer {
  z-index: 90;
  opacity: 1 !important;
  visibility: visible !important;
}

.sofaDanmakuItem {
  position: absolute;
  left: 100%;
  max-width: 76%;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--danmaku-bg, rgba(7, 9, 8, 0.54));
  color: #fff;
  contain: layout paint style;
  font-size: clamp(0.95rem, 1.6vw, 1.35rem);
  line-height: 1.25;
  text-shadow: none;
  white-space: nowrap;
  will-change: transform;
  animation: sofaDanmakuAcross 12s linear forwards;
}

.sofaDanmakuItem.system {
  background: rgba(160, 192, 109, 0.24);
  color: #eef7dc;
}

@keyframes sofaDanmakuAcross {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(calc(-1 * (var(--sofa-danmaku-track, 100vw) + 100%)), 0, 0);
  }
}

.playlistComposer {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 7px;
  max-height: min(66dvh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 10px 10px;
  border: 0;
  border-radius: var(--radius-outer);
  background: var(--panel-bg);
}

.playlistComposer.hidden {
  display: none;
}

#playlistPanel.composerOpen .playlistComposer {
  max-height: min(70dvh, 600px);
}

.episodeBar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.episodeBar .secondaryBtn {
  min-height: 34px;
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--muted);
}

.episodeBar span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.videoForm,
.chatForm {
  display: flex;
  gap: 10px;
}

.videoForm {
  display: grid;
  align-items: stretch;
  gap: 8px;
}

.videoActions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
  gap: 5px;
}

.clipEditor {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
  min-height: 0;
}

.clipHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 24px;
  color: var(--muted);
  font-size: 0.78rem;
}

.clipTrack {
  position: relative;
  height: 46px;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-inner);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px) 0 0 / 40px 100%,
    var(--field-bg);
  outline: none;
}

.clipTrack:focus {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 40px 100%,
    var(--field-bg-focus);
}

.clipTrackEmpty {
  position: absolute;
  inset: 10px 12px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-inner);
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted-2);
  font-size: 0.78rem;
}

.clipPart {
  position: absolute;
  top: 8px;
  bottom: 8px;
  display: grid;
  min-width: 12px;
  place-items: center;
  overflow: hidden;
  border-inline: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(160, 192, 109, 0.36);
  color: #eef7dc;
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clipPart.removed {
  background: rgba(237, 117, 107, 0.18);
  color: rgba(255, 255, 255, 0.55);
  text-decoration: line-through;
}

.clipBreakpoint {
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
  transform: translateX(-9px);
  touch-action: none;
}

.clipBreakpoint::before {
  content: "";
  position: absolute;
  inset: 0 7px;
  border-radius: 999px;
  background: var(--accent-hover);
  box-shadow: 0 0 0 2px rgba(12, 13, 15, 0.9);
}

.clipBreakpoint::after {
  content: "";
  position: absolute;
  inset: 13px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.clipSegments {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 2px;
}

.clipSegment {
  display: grid;
  gap: 7px;
  padding: 8px;
  border-radius: var(--radius-inner);
  background: rgba(255, 255, 255, 0.035);
}

.clipSegment.removed {
  opacity: 0.62;
}

.clipSegmentHead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 34px;
  gap: 6px;
  align-items: center;
  min-height: 32px;
}

.clipSegmentLabel,
.clipSegmentRange {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clipSegmentLabel {
  color: var(--text);
  font-size: 0.82rem;
}

.clipSegmentRange {
  color: var(--muted-2);
  font-size: 0.76rem;
}

.clipSegmentFields {
  display: grid;
  grid-template-columns: minmax(120px, 1.5fr) repeat(3, minmax(74px, 0.7fr));
  gap: 6px;
}

.clipField {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.clipField span {
  color: var(--muted-2);
  font-size: 0.72rem;
}

.clipSegment input {
  height: 34px;
  padding: 0 9px;
  font-size: 0.82rem;
}

.clipSegment input:disabled {
  color: var(--muted-2);
  background: rgba(255, 255, 255, 0.035);
}

.clipRemove {
  width: 34px;
  height: 32px;
  padding: 0;
}

.clipRemove span {
  display: none;
}

.field {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
}

.urlField {
  flex: 1.6;
}

input,
select,
textarea {
  width: 100%;
  border: 0;
  border-radius: var(--radius-inner);
  background: var(--field-bg);
  color: var(--text);
  outline: none;
  transition: background 140ms ease, color 140ms ease;
}

input,
select {
  height: 40px;
  padding: 0 12px;
}

textarea {
  height: 72px;
  resize: none;
  padding: 10px 12px;
  line-height: 1.35;
}

.playlistComposer textarea {
  height: 56px;
  padding: 9px 10px;
  background: var(--field-bg);
  color: var(--text);
  font-size: 0.9rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--field-placeholder);
}

input:focus,
select:focus,
textarea:focus {
  background: var(--field-bg-focus);
}

.primaryBtn,
.secondaryBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  border: 0;
  border-radius: var(--radius-outer);
  padding: 0 14px;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 760;
  white-space: nowrap;
}

.iconBtn {
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.channelForm .iconBtn {
  border: 0;
  background: var(--surface-2);
}

.secondaryBtn,
.textBtn {
  color: var(--text);
  background: var(--control-bg);
}

.sidePanel {
  display: grid;
  grid-template-rows: 54px 42px minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-outer);
  background: var(--surface);
  box-shadow: none;
}

.sidePanel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
}

.sidePanel h2 {
  font-size: 1rem;
}

.panelTabs {
  padding: 0 8px 8px;
  background: var(--panel-bg);
}

.panelTab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  height: 32px;
  font-size: 0.84rem;
}

.panelBody {
  display: none;
  min-height: 0;
  overflow: hidden;
}

.panelBody.active {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

#chatPanel.active {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  overflow: hidden;
}

.panelToolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.toolbarActions {
  display: flex;
  gap: 5px;
  min-width: 0;
}

.textBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 9px;
  font-size: 0.82rem;
}

.panelToolbar .textBtn,
.playlistComposer .primaryBtn,
.playlistComposer .secondaryBtn,
.playlistComposer .textBtn {
  min-height: 34px;
  height: 34px;
  border-radius: var(--radius-outer);
  padding: 0 10px;
  font-size: 0.84rem;
  font-weight: 680;
}

.playlistComposer .primaryBtn {
  background: rgba(160, 192, 109, 0.86);
  color: var(--accent-ink);
}

.playlistComposer .secondaryBtn,
.playlistComposer .textBtn,
.panelToolbar .textBtn {
  background: var(--control-bg);
  color: #d7d2c7;
}

.playlistComposer .textBtn {
  width: 38px;
  padding: 0;
}

.playlistComposer .textBtn span {
  display: none;
}

.playlistComposer .primaryBtn span,
.playlistComposer .secondaryBtn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.videoList,
.messages {
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.videoList {
  display: grid;
  align-content: start;
  gap: 8px;
}

.videoItem {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px 30px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-outer);
  background: var(--surface-2);
}

.videoItem.current {
  background: rgba(127, 160, 78, 0.2);
}

.videoTitle {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 760;
}

.videoItem > button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-outer);
  background: var(--control-bg);
  color: var(--text);
}

.videoItem > button:hover,
.secondaryBtn:hover,
.textBtn:hover,
.panelTab:hover {
  background: var(--control-hover);
}

.primaryBtn:hover {
  background: var(--accent-hover);
}

.emptyList {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted-2);
  border: 0;
  border-radius: var(--radius-inner);
  background: var(--surface-2);
}

.messages {
  display: flex;
  height: 100%;
  align-content: flex-start;
  flex-direction: column;
  gap: 6px;
  padding-top: 10px;
}

.message,
.systemMessage {
  flex: 0 0 auto;
  border-radius: var(--radius-inner);
  padding: 8px 10px;
  background: var(--message-bg);
}

.message {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.message strong {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 38%;
  overflow: hidden;
  color: var(--accent-hover);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message p,
.systemMessage {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.systemMessage {
  color: var(--muted);
  font-size: 0.86rem;
  background: rgba(255, 255, 255, 0.025);
}

.chatForm {
  padding: 10px;
  background: var(--panel-bg);
}

.chatOverlayBar,
.chatOverlayBackdrop {
  display: none;
}

.chatNameField {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px 0;
  background: var(--panel-bg);
}

.chatNameField input {
  height: 34px;
}

.chatForm input {
  flex: 1;
}

:where(button, input, select, textarea, [tabindex]):focus,
:where(button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: none;
}

:where(input, select, textarea):focus,
:where(input, select, textarea):focus-visible {
  background-color: var(--surface-2) !important;
}

:where(button, .panelTab, .textBtn, .secondaryBtn, .primaryBtn):focus,
:where(button, .panelTab, .textBtn, .secondaryBtn, .primaryBtn):focus-visible {
  background-color: var(--control-hover);
}

.primaryBtn:focus,
.primaryBtn:focus-visible {
  color: var(--accent-ink);
  background-color: var(--accent-hover);
}

@media (max-width: 980px) {
  body {
    overflow: hidden;
  }

  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(260px, 1fr);
    gap: 8px;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 8px;
  }

  .stage {
    grid-template-rows: auto auto;
    min-height: 0;
    overflow: hidden;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .brand {
    grid-column: 1 / 2;
    grid-row: 1;
    gap: 9px;
    min-width: 0;
  }

  .brandLogo {
    width: 50px;
    height: 32px;
  }

  h1 {
    font-size: 1.12rem;
  }

  .channelBar {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
    align-items: center;
    gap: 6px;
  }

  .channelForm {
    display: contents;
  }

  .channelSelect {
    grid-column: 1 / 2;
    height: 40px;
  }

  .channelForm .iconBtn {
    grid-column: 2 / 3;
    width: 40px;
    min-height: 40px;
  }

  .channelForm.editing input {
    display: block;
    grid-column: 1 / 2;
    grid-row: 2;
    width: 100%;
    min-width: 0;
  }

  .presence {
    grid-column: 2 / 3;
    grid-row: 1;
    justify-self: end;
    align-self: center;
    height: 32px;
    padding: 0 10px;
  }

  .playerWrap {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    min-height: 0;
  }

  .playerModule {
    align-self: start;
    grid-template-rows: auto auto;
    min-height: 0;
  }

  .mediaControlBar {
    height: 38px;
    padding: 0 6px;
  }

  media-play-button,
  media-mute-button,
  media-fullscreen-button {
    width: 34px;
  }

  media-volume-range {
    display: none;
  }

  .segmentTimeDisplay {
    min-width: 72px;
    font-size: 11px;
  }

  .segmentTimeRange {
    min-width: 70px;
    height: 34px;
  }

  .sidePanel {
    display: grid;
    grid-template-rows: 44px 40px minmax(0, 1fr);
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .sidePanel.chatOverlayOpen {
    overflow: visible;
  }

  .sidePanel.chatOverlayOpen .chatOverlayBackdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    border: 0;
    border-radius: 0;
    padding: 0;
    background: rgba(5, 6, 7, 0.66);
  }

  .sidePanel header {
    padding: 0 10px;
  }

  .panelTabs {
    padding: 0 8px 8px;
  }

  .panelBody.active {
    min-height: 0;
  }

  .sidePanel.chatOverlayOpen #chatPanel.active {
    position: fixed;
    bottom: calc(var(--visual-viewport-bottom, 0px) + max(8px, env(safe-area-inset-bottom)));
    right: max(8px, env(safe-area-inset-right));
    left: max(8px, env(safe-area-inset-left));
    z-index: 80;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    height: min(78dvh, calc(var(--visual-viewport-height, 100dvh) - 16px));
    max-height: calc(var(--visual-viewport-height, 100dvh) - 16px);
    min-height: 0;
    overflow: hidden;
    border-radius: var(--radius-outer);
    background: var(--panel-bg);
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.52);
  }

  .sidePanel.chatOverlayOpen .chatOverlayBar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    padding: 0 10px 0 12px;
    border-bottom: 1px solid var(--line);
  }

  .chatOverlayBar strong {
    min-width: 0;
    overflow: hidden;
    font-size: 0.95rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chatOverlayBar .textBtn {
    width: 34px;
    height: 34px;
    padding: 0;
  }

  .chatOverlayBar .textBtn span {
    display: none;
  }

  .sidePanel.chatOverlayOpen .chatNameField {
    padding: 8px 10px 0;
  }

  .sidePanel.chatOverlayOpen .messages {
    padding: 10px;
  }

  .sidePanel.chatOverlayOpen .chatForm {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  }

  #playlistPanel.active {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  #playlistPanel.composerOpen {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  #playlistPanel.composerOpen::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(5, 6, 7, 0.68);
  }

  #playlistPanel.composerOpen .playlistComposer {
    position: fixed;
    right: 8px;
    bottom: calc(var(--visual-viewport-bottom, 0px) + 8px);
    left: 8px;
    z-index: 80;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    max-height: calc(100dvh - 32px);
    height: min(72dvh, 620px);
    min-height: 0;
    padding: 10px;
    overflow: hidden;
    border-radius: var(--radius-outer);
    background: var(--panel-bg);
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.48);
  }

  .videoForm {
    display: grid;
    grid-template-columns: 1fr;
    gap: 7px;
    min-height: 0;
  }

  .videoActions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 38px;
    gap: 5px;
  }

  .playlistComposer .primaryBtn,
  .playlistComposer .secondaryBtn,
  .playlistComposer .textBtn {
    min-width: 0;
    padding: 0 8px;
  }

  .playlistComposer textarea {
    height: 64px;
    min-height: 64px;
  }

  #playlistPanel.composerOpen .playlistComposer .field {
    flex: 0 0 auto;
  }

  .clipEditor {
    overflow: hidden;
    min-height: 0;
  }

  .clipTrack {
    height: 42px;
  }

  .clipSegmentFields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .clipTitleField {
    grid-column: 1 / -1;
  }

  .clipSegments {
    max-height: none;
    min-height: 0;
    overflow-y: auto;
  }

  textarea {
    height: 58px;
  }

  .episodeBar {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .iconCollapse {
    width: 40px;
    min-width: 40px;
    padding: 0;
  }

  .iconCollapse span {
    display: none;
  }
}

input:focus,
input:focus-visible,
input.softFocus,
select:focus,
select:focus-visible,
select.softFocus,
textarea:focus,
textarea:focus-visible,
textarea.softFocus,
.channelSelect:focus,
.channelSelect:focus-visible,
.channelSelect.softFocus {
  outline: none !important;
  box-shadow: none !important;
  background-color: var(--surface-2) !important;
}

button:focus,
button:focus-visible,
button.softFocus,
[tabindex]:focus,
[tabindex]:focus-visible,
[tabindex].softFocus {
  outline: none !important;
  box-shadow: none !important;
}

button:focus,
button:focus-visible,
.panelTab:focus,
.panelTab:focus-visible,
.textBtn:focus,
.textBtn:focus-visible,
.secondaryBtn:focus,
.secondaryBtn:focus-visible,
button.softFocus,
.panelTab.softFocus,
.textBtn.softFocus,
.secondaryBtn.softFocus {
  background-color: var(--control-hover) !important;
}

.primaryBtn:focus,
.primaryBtn:focus-visible,
.primaryBtn.softFocus {
  color: var(--accent-ink);
  background-color: var(--accent-hover) !important;
}

.segmentTimeRange:focus-visible::before {
  background: rgba(255, 255, 255, 0.38) !important;
  box-shadow: none !important;
}

.clipTrack:focus,
.clipTrack:focus-visible {
  box-shadow: none !important;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 40px 100%,
    var(--field-bg-focus) !important;
}
