/* ------------------------------------------------------------------ *
 * Tokens
 * ------------------------------------------------------------------ */
:root {
  --void:      #12131c;
  --surface:   #1b1d2b;
  --surface-2: #242739;
  --line:      #32364d;
  --ink:       #e8e6f0;
  --mute:      #8f92ad;

  --lamp:      #ffb454;   /* action */
  --lamp-dim:  #a8763a;
  --sync:      #5fd4c4;   /* in sync / present */
  --off:       #ff6b6b;   /* drifted / error */

  --rail-w: 360px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --ui: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'Inter', ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--void);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 2px;
  border-radius: 3px;
}

[hidden] { display: none !important; }

code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: .92em;
  color: var(--ink);
}

/* ------------------------------------------------------------------ *
 * Shared controls
 * ------------------------------------------------------------------ */
.input {
  width: 100%;
  padding: 11px 13px;
  background: var(--void);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink);
  font: inherit;
}
.input::placeholder { color: #6a6d85; }
.input:focus {
  border-color: var(--lamp-dim);
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 180, 84, .12);
}

.input--code {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .22em;
  text-align: center;
  text-transform: uppercase;
  padding: 9px 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.btn:hover:not(:disabled) { background: #2e3248; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn--primary { background: var(--lamp); color: #241704; font-weight: 600; }
.btn--primary:hover:not(:disabled) { background: #ffc270; }

.btn--ghost { background: transparent; border-color: var(--line); }
.btn--quiet { background: transparent; color: var(--mute); padding: 8px 11px; }
.btn--quiet:hover { background: var(--surface-2); color: var(--ink); }

.btn--block { width: 100%; }

.btn--icon {
  padding: 8px;
  width: 34px;
  height: 34px;
  background: transparent;
  color: var(--ink);
  border-radius: var(--r-sm);
}
.btn--icon:hover:not(:disabled) { background: var(--surface-2); }

.error {
  margin: 4px 0 0;
  color: var(--off);
  font-size: 13px;
}

/* ------------------------------------------------------------------ *
 * Landing
 * ------------------------------------------------------------------ */
.landing {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 40px 22px;
  text-align: center;
}

.marquee { position: relative; }

.marquee__bulbs {
  position: absolute;
  inset: -18px -30px auto -30px;
  height: 3px;
  background:
    radial-gradient(circle, var(--lamp) 1.4px, transparent 1.6px) repeat-x;
  background-size: 17px 3px;
  opacity: .55;
}

.marquee__word {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(58px, 13vw, 104px);
  font-weight: 700;
  letter-spacing: -.045em;
  line-height: .92;
  color: var(--lamp);
  text-shadow: 0 0 46px rgba(255, 180, 84, .3);
}

.marquee__sub {
  margin: 12px auto 0;
  max-width: 34ch;
  color: var(--mute);
  font-size: 15px;
}

.panel {
  width: 100%;
  max-width: 380px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  text-align: left;
}

.field { display: block; margin-bottom: 16px; }
.field__label {
  display: block;
  margin-bottom: 7px;
  color: var(--mute);
  font-size: 13px;
}

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: var(--mute);
  font-size: 12px;
}
.or::before, .or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.joinrow { display: flex; gap: 9px; }
.joinrow .input { flex: 1; min-width: 0; }

.footnote {
  max-width: 46ch;
  margin: 0;
  color: var(--mute);
  font-size: 12.5px;
  line-height: 1.65;
}

/* ------------------------------------------------------------------ *
 * Room shell
 * ------------------------------------------------------------------ */
.room {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr var(--rail-w);
  grid-template-rows: 52px 1fr;
  grid-template-areas:
    'top  top'
    'main rail';
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar__spacer { flex: 1; }

.topbar__mark {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--lamp);
  margin-right: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
}

.chip--code {
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .13em;
}
.chip--code:hover { border-color: var(--lamp-dim); color: var(--lamp); }

.chip--sync { color: var(--mute); }
.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.chip--sync[data-state='live']       { color: var(--sync); border-color: rgba(95, 212, 196, .35); }
.chip--sync[data-state='drifting']   { color: var(--lamp); border-color: var(--lamp-dim); }
.chip--sync[data-state='connecting'],
.chip--sync[data-state='offline']    { color: var(--off); border-color: rgba(255, 107, 107, .3); }

/* ------------------------------------------------------------------ *
 * Stage
 * ------------------------------------------------------------------ */
.stage {
  grid-area: main;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.theater {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: #000;
}
.theater:fullscreen { background: #000; }
.theater:fullscreen .screen { flex: 1; aspect-ratio: auto; }
.theater:fullscreen .controls {
  background: rgba(12, 13, 19, .92);
  border-bottom: 0;
}

.screen {
  position: relative;
  flex: 1;
  min-height: 220px;
  background: #000;
  overflow: hidden;
}

.screen__mount { position: absolute; inset: 0; }
.screen__mount video,
.screen__mount iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

.screen__shield { position: absolute; inset: 0; cursor: default; }
.screen__shield.is-clickable { cursor: pointer; }

.screen__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 5px;
  text-align: center;
  padding: 20px;
  background:
    radial-gradient(120% 90% at 50% 0%, #1a1c29 0%, #0b0c12 70%);
}
.screen__emptyTitle {
  margin: 0;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 500;
}
.screen__emptyBody { margin: 0; color: var(--mute); }

.screen__gesture {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  border: 0;
  border-radius: 100px;
  background: var(--lamp);
  color: #241704;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}

.screen__toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 100px;
  background: rgba(12, 13, 19, .88);
  border: 1px solid var(--line);
  font-size: 12.5px;
  white-space: nowrap;
  pointer-events: none;
}

.screen__reactions { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floater {
  position: absolute;
  bottom: 8%;
  font-size: 30px;
  animation: rise 2.6s ease-out forwards;
}
@keyframes rise {
  0%   { opacity: 0; transform: translateY(20px) scale(.6); }
  14%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-190px) scale(1.05); }
}
@media (prefers-reduced-motion: reduce) {
  .floater { animation-duration: 1.4s; }
  @keyframes rise { 0% { opacity: 0; } 20% { opacity: 1; } 100% { opacity: 0; } }
}

/* Controls */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.controls__time {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  min-width: 44px;
}
.controls__time--dim { color: var(--mute); text-align: right; }

.scrub {
  flex: 1;
  min-width: 0;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--line);
  border-radius: 100px;
  cursor: pointer;
}
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--lamp);
  border: 0;
}
.scrub::-moz-range-thumb {
  width: 13px; height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--lamp);
}
.scrub:disabled { cursor: not-allowed; opacity: .5; }
.scrub:disabled::-webkit-slider-thumb { background: var(--mute); }
.scrub--vol { flex: none; width: 74px; }

/* Source bar */
.source {
  padding: 13px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.source__form { display: flex; gap: 9px; }
.source__form .input { flex: 1; min-width: 0; }

.source__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 9px;
  flex-wrap: wrap;
}
.source__title {
  color: var(--mute);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--mute);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.toggle input { accent-color: var(--lamp); width: 15px; height: 15px; }

/* ------------------------------------------------------------------ *
 * Rail
 * ------------------------------------------------------------------ */
.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--surface);
}

.rail__tabs { display: flex; border-bottom: 1px solid var(--line); }
.rail__tab {
  flex: 1;
  padding: 12px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--mute);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.rail__tab.is-active { color: var(--ink); border-bottom-color: var(--lamp); }

.count {
  display: inline-block;
  margin-left: 3px;
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--surface-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.rail__pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.rail__hint {
  margin: 0;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--mute);
  font-size: 12.5px;
}

/* Messages */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}

.msg { display: flex; gap: 9px; }
.msg__avatar {
  flex: none;
  width: 27px; height: 27px;
  margin-top: 2px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #16171f;
}
.msg__body { min-width: 0; flex: 1; }
.msg__head { display: flex; align-items: baseline; gap: 7px; }
.msg__name { font-weight: 600; font-size: 13px; }
.msg__time { color: var(--mute); font-size: 11px; font-variant-numeric: tabular-nums; }
.msg__text { margin: 1px 0 0; word-wrap: break-word; overflow-wrap: anywhere; }
.msg__text a { color: var(--lamp); }

.msg--system {
  color: var(--mute);
  font-size: 12.5px;
  padding-left: 4px;
}

.typing {
  margin: 0;
  padding: 0 14px 6px;
  height: 18px;
  color: var(--mute);
  font-size: 12px;
}

.reactions {
  display: flex;
  gap: 5px;
  padding: 0 14px 9px;
}
.reactbtn {
  width: 32px; height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 15px;
  cursor: pointer;
  line-height: 1;
}
.reactbtn:hover { background: var(--surface-2); }

.composer {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.composer .input { flex: 1; min-width: 0; }

/* People */
.people {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 8px;
  list-style: none;
}
.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
}
.person:hover { background: var(--surface-2); }
.person__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.person__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person__tag {
  color: var(--mute);
  font-size: 11.5px;
  border: 1px solid var(--line);
  padding: 1px 7px;
  border-radius: 100px;
}
.person__tag--buffering { color: var(--lamp); border-color: var(--lamp-dim); }
.person__promote {
  border: 0;
  background: transparent;
  color: var(--mute);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 2px;
}
.person__promote:hover { color: var(--lamp); }

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */
@media (max-width: 900px) {
  .room {
    grid-template-columns: 1fr;
    grid-template-rows: 52px 1fr;
    grid-template-areas: 'top' 'main';
  }
  .rail {
    position: fixed;
    inset: 52px 0 0 0;
    z-index: 20;
    border-left: 0;
    transform: translateY(100%);
    transition: transform .22s ease;
  }
  .rail.is-open { transform: translateY(0); }
  .screen { min-height: 200px; flex: none; aspect-ratio: 16 / 9; }
}
@media (min-width: 901px) {
  #railToggle { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .rail { transition: none; }
}

/* ------------------------------------------------------------------ *
 * Plex library drawer
 * ------------------------------------------------------------------ */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(7, 8, 12, .72);
}

.drawer__sheet {
  width: min(1040px, 100%);
  height: min(760px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.drawer__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer__title {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select {
  padding: 8px 11px;
  background: var(--void);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  max-width: 220px;
}

/* Sign-in */
.linkpane {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 30px;
  text-align: center;
}
.linkpane__lead {
  max-width: 52ch;
  margin: 0;
  color: var(--mute);
  line-height: 1.7;
}

.codebox {
  padding: 20px 30px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--void);
}
.codebox__lead { margin: 0; color: var(--mute); font-size: 13px; }
.codebox__code {
  margin: 8px 0;
  font-family: var(--display);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--lamp);
}
.codebox__status { margin: 0; color: var(--mute); font-size: 13px; }
.codebox__again { display: inline-block; margin-top: 10px; color: var(--lamp); font-size: 13px; }

/* Browse */
.browse { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.browse__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.browse__bar .input { flex: 1; min-width: 160px; }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.seg__btn {
  padding: 8px 15px;
  border: 0;
  background: transparent;
  color: var(--mute);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.seg__btn.is-active { background: var(--surface-2); color: var(--ink); }

.browse__crumb { margin: 0; padding: 11px 14px 0; color: var(--mute); font-size: 13px; }

.grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 15px;
  padding: 15px;
  align-content: start;
}

.card {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.card__art {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-sm);
  background: var(--void) center/cover no-repeat;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: #55586e;
  font-size: 11px;
  padding: 8px;
  text-align: center;
  overflow: hidden;
}
.card:hover .card__art, .card:focus-visible .card__art { border-color: var(--lamp-dim); }
.card__title {
  margin: 7px 0 0;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card__meta { margin: 1px 0 0; color: var(--mute); font-size: 12px; }

/* Season / episode rows */
.eplist {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin: 0;
  padding: 10px 14px;
  list-style: none;
}
.eprow {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.eprow:hover { background: var(--surface-2); }
.eprow__num {
  flex: none;
  width: 52px;
  color: var(--mute);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.eprow__body { flex: 1; min-width: 0; }
.eprow__title { display: block; font-weight: 500; }
.eprow__sum {
  display: block;
  margin-top: 2px;
  color: var(--mute);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eprow__len { flex: none; color: var(--mute); font-size: 12.5px; }

.browse__foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
}
.browse__status { margin: 0; color: var(--mute); font-size: 12.5px; }

.empty {
  grid-column: 1 / -1;
  padding: 40px 10px;
  text-align: center;
  color: var(--mute);
}

@media (max-width: 700px) {
  .drawer { padding: 0; }
  .drawer__sheet { height: 100%; border: 0; border-radius: 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 11px; }
}
