/* twilight melancholia: low contrast slate, fog, one warm lamp accent */
:root {
  --bg: #0a0b10;
  --slate: #10121a;
  --surface: rgba(255, 255, 255, .035);
  --surface-hi: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .08);
  --text: #c7c9d6;
  --dim: #6d7188;
  --cyan: #95c2a6;
  --lav: #8f8ab8;
  --amber: #d99b66;
  --bad: #c48a8a;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, Menlo, Consolas, monospace;
  --sans: Inter, Outfit, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* fog: two slow drifting washes and a little grain, behind everything */
body::before, body::after { content: ""; position: fixed; inset: -20%; pointer-events: none; z-index: 0; }
body::before {
  background:
    radial-gradient(40% 35% at 18% 12%, rgba(143, 138, 184, .13), transparent 70%),
    radial-gradient(45% 40% at 85% 92%, rgba(149, 194, 166, .08), transparent 70%);
  animation: drift 40s ease-in-out infinite alternate;
}
body::after {
  inset: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .06 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}
@keyframes drift { to { transform: translate3d(3%, 2%, 0) scale(1.06); } }
@media (prefers-reduced-motion: reduce) { body::before { animation: none; } }

#app, .screen { position: relative; z-index: 1; height: 100%; }
.hidden { display: none !important; }
.dim { color: var(--dim); }
.bad { color: var(--bad); }
.mono { font-family: var(--mono); }
.label { font: 11px/1 var(--mono); letter-spacing: .18em; color: var(--dim); text-transform: lowercase; }

h1 { font-weight: 300; letter-spacing: .02em; margin: 0; }
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 18px; cursor: pointer; transition: border-color .2s, background .2s, color .2s;
}
button:hover:not(:disabled) { border-color: rgba(149, 194, 166, .5); background: var(--surface-hi); }
button:disabled { opacity: .35; cursor: default; }
button.main { background: rgba(217, 155, 102, .14); border-color: rgba(217, 155, 102, .45); color: #ecc9a3; padding: 12px 28px; }
button.main:hover:not(:disabled) { background: rgba(217, 155, 102, .22); border-color: var(--amber); }
button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface); border-color: transparent; }
:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
select, input[type=text], input:not([type]) {
  background: var(--slate); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0;
}
select:focus, input:focus { border-color: rgba(149, 194, 166, .5); outline: none; }

/* ---------- viewer entrance ---------- */
.enter { height: 100%; display: grid; place-items: center; padding: 24px; }
.enter .box { width: min(440px, 100%); }
.mark { font: 12px/1 var(--mono); letter-spacing: .3em; color: var(--dim); margin-bottom: 36px; }
.mark b { color: var(--amber); font-weight: 400; }
.enter h1 { font-size: clamp(30px, 6vw, 44px); line-height: 1.1; margin-bottom: 14px; }
.enter p { margin: 0 0 32px; color: var(--dim); max-width: 36ch; }
.nickform { display: flex; align-items: flex-end; gap: 14px; border-bottom: 1px solid var(--line); padding-bottom: 6px; transition: border-color .2s; }
.nickform:focus-within { border-color: rgba(149, 194, 166, .55); }
.nickform input { flex: 1; background: none; border: none; padding: 8px 0; font-size: 22px; font-weight: 300; }
.nickform input::placeholder { color: #4a4d60; text-transform: lowercase; opacity: 1; }
.nickform button { border: none; background: none; color: var(--cyan); padding: 8px 0; font: 12px var(--mono); letter-spacing: .2em; }
.err { min-height: 1.5em; margin-top: 12px; color: var(--bad); font-size: 13px; }
.console .err { margin: -28px 0 24px; }

.thin { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; margin: 22px 0 8px; }
.thin i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--lav), var(--cyan)); transition: width .5s ease; }

/* ---------- stage (player) ---------- */
.stage { position: relative; height: 100%; min-height: 0; background: #000; overflow: hidden; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage video::cue { background: rgba(10, 11, 16, .72); color: #e6e7ee; font: 22px/1.35 var(--sans); }
.hud { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: 14px 18px; transition: opacity .35s; z-index: 3; }
.hud.top { top: 0; background: linear-gradient(rgba(10, 11, 16, .75), transparent); }
.hud.bottom { bottom: 0; padding-top: 34px; background: linear-gradient(transparent, rgba(10, 11, 16, .82)); }
.stage.idle:not(.paused) .hud { opacity: 0; }
.stage.idle:not(.paused) { cursor: none; }
.hud .title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 300; letter-spacing: .02em; }
.pill { font: 11px var(--mono); letter-spacing: .12em; padding: 6px 12px; border-radius: 999px; background: rgba(10, 11, 16, .6); border: 1px solid var(--line); white-space: nowrap; }
.hud button { background: rgba(10, 11, 16, .6); padding: 7px 14px; font-size: 13px; }
.hud .icon { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%; }
.hud .icon svg { width: 18px; height: 18px; }
.pill.warn { color: var(--amber); border-color: rgba(217, 155, 102, .4); }
.pill.off { color: var(--dim); }
.clock { font: 12px var(--mono); color: var(--dim); white-space: nowrap; min-width: 8.5ch; text-align: right; }
.seek { position: relative; flex: 1; height: 22px; display: flex; align-items: center; cursor: default; touch-action: none; }
.seek.live { cursor: pointer; }
.seek .rail, .seek .buf, .seek .pos { position: absolute; left: 0; height: 3px; border-radius: 3px; transition: height .15s; }
.seek .rail { right: 0; background: rgba(255, 255, 255, .14); }
.seek .buf { background: rgba(255, 255, 255, .22); width: 0; }
.seek .pos { background: var(--cyan); width: 0; }
.seek.live:hover .rail, .seek.live:hover .buf, .seek.live:hover .pos { height: 5px; }
.seek .knob { position: absolute; width: 11px; height: 11px; margin-left: -5px; border-radius: 50%; background: #dff0e6; opacity: 0; transition: opacity .15s; }
.seek.live:hover .knob { opacity: 1; }
.vol { width: 84px; accent-color: var(--cyan); }

.cover { position: absolute; inset: 0; display: grid; place-items: center; z-index: 4; text-align: center; padding: 24px; }
.cover.dark { background: rgba(10, 11, 16, .85); }
.cover.soft { pointer-events: none; }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .12); border-top-color: var(--cyan); animation: spin 1s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }
.cover h1 { font-size: 26px; margin-bottom: 14px; }
.cover p { max-width: 42ch; margin: 0 auto 18px; }

/* ---------- watch layout: picture and a docked chat, no overlays ---------- */
.watch { display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; background: #000; }
.watch.chat-open { grid-template-columns: minmax(0, 1fr) 330px; }
.chat { display: none; flex-direction: column; min-width: 0; min-height: 0; background: var(--slate); border-left: 1px solid var(--line); }
.watch.chat-open .chat { display: flex; }
.chat header { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.chat header .icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: transparent; border-color: transparent; color: var(--dim); }
.chat header .icon:hover { color: var(--text); background: var(--surface-hi); }
.chat header .icon svg { width: 16px; height: 16px; }
.chat .log { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; scrollbar-color: #2a2d3b transparent; overscroll-behavior: contain; }
.msg .head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.msg .head b { font: 11px var(--mono); letter-spacing: .08em; color: var(--lav); font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.msg.mine .head b { color: var(--cyan); }
.msg .head time { font: 10px var(--mono); color: #4d5066; }
.msg .text { font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap; }
.chat form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat form input { flex: 1; border-radius: 999px; padding: 9px 14px; }
.chat form button { padding: 8px 14px; }
.badge { display: inline-block; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 6px; border-radius: 8px; background: var(--amber); color: #1a1208; font: 10px/16px var(--mono); text-align: center; }
#chatbtn .badge { position: absolute; top: -3px; right: -3px; margin: 0; }
#chatbtn { position: relative; }

/* ---------- host console ---------- */
.console { height: 100%; overflow-y: auto; padding: clamp(20px, 4vw, 56px); }
.console .inner { max-width: 880px; margin: 0 auto; }
.console header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 44px; }
.console h1 { font-size: clamp(28px, 4.5vw, 40px); margin-bottom: 8px; }
.steps { display: grid; gap: 18px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; transition: border-color .3s, opacity .3s; }
.step.done { border-color: rgba(149, 194, 166, .28); }
.step.wait { opacity: .55; }
.step .head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.step .num { font: 12px var(--mono); color: var(--amber); letter-spacing: .1em; }
.step h2 { margin: 0; font-size: 17px; font-weight: 400; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 10px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; transition: all .2s; }
.chip.off { opacity: .45; cursor: default; }
.chip.sel { border-color: var(--cyan); background: rgba(149, 194, 166, .1); }
.empty { color: var(--dim); }
.empty code { font: 13px var(--mono); color: var(--lav); }
.pickbtn { width: 100%; padding: 26px 18px; border-radius: 14px; border: 1px dashed rgba(255, 255, 255, .16); background: transparent; color: var(--dim); font-size: 15px; }
.pickbtn:hover:not(:disabled) { border-color: var(--amber); color: var(--text); background: rgba(217, 155, 102, .05); }
.filecard { margin-top: 16px; display: grid; gap: 4px; }
.filecard .name { font-size: 17px; font-weight: 300; word-break: break-all; }
.meta { font: 12px var(--mono); color: var(--dim); letter-spacing: .04em; }
.opts { display: grid; grid-template-columns: 90px 1fr; gap: 10px 14px; align-items: center; margin-top: 18px; }
.opts .label { align-self: center; }
.go { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.note { color: var(--dim); font-size: 13px; margin-top: 12px; }

@media (max-width: 760px) {
  .hud { padding: 10px 12px; gap: 8px; }
  .vol { display: none; }
  .watch.chat-open { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 42%; }
  .chat { border-left: 0; border-top: 1px solid var(--line); }
  .opts { grid-template-columns: 1fr; }
}

/* settings popover */
.setmenu { position: absolute; right: 14px; bottom: 70px; width: min(300px, calc(100% - 28px)); max-height: 60%; overflow-y: auto; z-index: 6; display: none;
  background: rgba(16, 18, 26, .97); border: 1px solid var(--line); border-radius: 16px; padding: 10px; scrollbar-width: thin; scrollbar-color: #2a2d3b transparent; }
.setmenu.open { display: block; }
.setmenu .label { padding: 10px 10px 6px; }
.setmenu .row { display: block; width: 100%; text-align: left; background: transparent; border: none; border-radius: 8px; padding: 8px 10px; font-size: 14px; color: var(--text); }
.setmenu .row:hover { background: var(--surface-hi); }
.setmenu .row.on { color: var(--cyan); }
.setmenu .row.on::after { content: "✓"; float: right; }
