/* Twitch-flavoured dark UI shared by the public site and the studio. */
:root {
  --bg: #0e0e10;
  --surface: #18181b;
  --surface-2: #1f1f23;
  --surface-3: #26262c;
  --hover: rgba(83, 83, 95, 0.38);
  --border: rgba(83, 83, 95, 0.48);
  --text: #efeff1;
  --muted: #adadb8;
  --faint: #7a7a85;
  --accent: #9147ff;
  --accent-hover: #772ce8;
  --accent-soft: rgba(145, 71, 255, 0.18);
  --live: #eb0400;
  --ok: #00c96b;
  --warn: #ffb31a;
  --danger: #f23f42;
  --radius: 6px;
  --nav-h: 50px;
  --chat-w: 340px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 Inter, "Roobert", "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { display: block; }
.hidden { display: none !important; }

/* ---------- top nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 2px rgba(0,0,0,.9);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; min-width: 0; }
.brand img { width: 30px; height: 30px; border-radius: 50%; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--muted); font-weight: 600; }
.nav .spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 0; border-radius: 4px; cursor: pointer;
  font-weight: 600; font-size: 13px; white-space: nowrap;
  background: rgba(83, 83, 95, .38); color: var(--text); transition: background .1s;
}
.btn:hover { background: rgba(83, 83, 95, .55); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: transparent; color: var(--danger); box-shadow: inset 0 0 0 1px rgba(242,63,66,.55); }
.btn.danger:hover { background: rgba(242,63,66,.12); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.big { height: 38px; padding: 0 18px; font-size: 14px; }
.btn svg { width: 16px; height: 16px; fill: currentColor; }

.live-pill {
  display: inline-flex; align-items: center; background: var(--live); color: #fff;
  font-size: 12px; font-weight: 700; letter-spacing: .02em; padding: 0 5px; border-radius: 4px; height: 20px;
  text-transform: uppercase;
}
.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); white-space: nowrap;
}
.pill.accent { background: var(--accent-soft); color: #bf94ff; }
.pill.ok { background: rgba(0,201,107,.14); color: #3ddc97; }
.pill.warn { background: rgba(255,179,26,.14); color: var(--warn); }
.pill.bad { background: rgba(242,63,66,.14); color: #ff6b6e; }
.pill.live { background: var(--live); color: #fff; }
.tag {
  display: inline-block; padding: 0 8px; border-radius: 9px; background: var(--surface-3);
  color: var(--muted); font-size: 12px; font-weight: 600; line-height: 20px; white-space: nowrap;
}
a.tag:hover { background: var(--hover); color: var(--text); }

/* ---------- channel page ---------- */
.page { max-width: 1600px; margin: 0 auto; }
.banner { height: 190px; background: var(--surface-2) center/cover no-repeat; position: relative; }
.banner::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14,14,16,0) 40%, var(--bg)); }
.chan-head { display: flex; gap: 16px; align-items: center; padding: 0 30px; margin-top: -34px; position: relative; z-index: 1; }
.avatar-ring { width: 84px; height: 84px; border-radius: 50%; padding: 3px; background: var(--bg); flex: none; position: relative; }
.avatar-ring img { width: 100%; height: 100%; border-radius: 50%; }
.avatar-ring.live { background: var(--live); }
.avatar-ring .live-pill { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); border: 2px solid var(--bg); }
.chan-meta h1 { margin: 26px 0 2px; font-size: 22px; line-height: 1.2; display: flex; align-items: center; gap: 8px; }
.chan-meta p { margin: 0; color: var(--muted); }
.chan-head .spacer { flex: 1; }
.live-card {
  display: flex; gap: 12px; align-items: center; margin: 20px 30px 0; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.live-card .t { flex: 1; min-width: 0; }
.live-card .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-card .t span { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 22px; padding: 0 30px; margin-top: 22px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 8px 0 10px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: #bf94ff; border-color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 16px 30px 6px; }
.toolbar .label { color: var(--muted); font-size: 13px; font-weight: 600; margin-right: 4px; }
.chip {
  height: 28px; padding: 0 12px; border-radius: 14px; border: 0; cursor: pointer; font-weight: 600; font-size: 13px;
  background: var(--surface-3); color: var(--text);
}
.chip:hover { background: var(--hover); }
.chip.on { background: var(--text); color: var(--bg); }
select.chip { appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 14px) 12px, calc(100% - 10px) 12px; background-size: 4px 4px; background-repeat: no-repeat; }

/* ---------- video cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 30px 16px; padding: 14px 30px 60px; }
.card { min-width: 0; }
.thumb-wrap { position: relative; display: block; }
.thumb-wrap::before { /* Twitch's offset purple slab revealed on hover */
  content: ""; position: absolute; inset: 0; background: var(--accent); transform: scale(1, 1); transition: transform .1s ease;
}
.thumb {
  position: relative; aspect-ratio: 16 / 9; background: var(--surface-2); overflow: hidden;
  transition: transform .1s ease;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.card:hover .thumb { transform: translate(6px, -6px); }
.card:hover .thumb-wrap::before { transform: none; }
.thumb .ov { position: absolute; background: rgba(0,0,0,.72); color: #fff; font-size: 13px; padding: 0 4px; border-radius: 2px; line-height: 20px; }
.thumb .tl { top: 10px; left: 10px; } .thumb .bl { bottom: 10px; left: 10px; } .thumb .br { bottom: 10px; right: 10px; }
.thumb .yt { top: 10px; right: 10px; background: #f00; font-weight: 700; }
.card-info { display: flex; gap: 10px; margin-top: 10px; }
.card-info img { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.card-info .txt { min-width: 0; flex: 1; }
.card-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card:hover .card-title { color: #bf94ff; }
.card-sub { color: var(--muted); font-size: 13px; margin: 1px 0 5px; }
.card-tags { display: flex; gap: 5px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 60px 30px; text-align: center; }
.empty h3 { color: var(--text); margin: 0 0 6px; }

/* ---------- VOD page ---------- */
.watch { display: flex; height: calc(100vh - var(--nav-h)); }
.watch-main { flex: 1; min-width: 0; overflow-y: auto; }
.watch-chat { width: var(--chat-w); flex: none; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.info { padding: 14px 20px 30px; display: flex; gap: 14px; }
.info .avatar-ring { width: 68px; height: 68px; }
.info h2 { margin: 0; font-size: 18px; }
.info h1 { margin: 2px 0 6px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.info .meta { color: var(--muted); font-size: 13px; display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; }
.info .actions { display: flex; gap: 8px; margin-left: auto; align-items: flex-start; flex-wrap: wrap; justify-content: flex-end; }
.chapters { padding: 0 20px 40px; }
.chapters h3 { font-size: 15px; margin: 0 0 10px; }
.chapter-list { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.chapter {
  flex: none; display: flex; flex-direction: column; gap: 2px; width: 200px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); cursor: pointer; text-align: left;
}
.chapter:hover, .chapter.on { border-color: var(--accent); }
.chapter b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter span { color: var(--muted); font-size: 12px; }
body.theater .nav, body.theater .info, body.theater .chapters { display: none; }
body.theater .watch { height: 100vh; }
body.theater .player { height: 100vh; aspect-ratio: auto; }

/* ---------- chat replay ---------- */
.chat-head { height: 50px; flex: none; display: flex; align-items: center; justify-content: center; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; position: relative; }
.chat-head .btn { position: absolute; right: 8px; }
.chat-log { flex: 1; overflow-y: auto; padding: 8px 0 10px; overscroll-behavior: contain; font-size: 13px; line-height: 20px; }
.chat-log::-webkit-scrollbar { width: 6px; } .chat-log::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
.msg { padding: 5px 20px 5px 14px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg:hover { background: rgba(255,255,255,.04); }
.msg .ts { color: var(--faint); font-size: 12px; margin-right: 5px; font-variant-numeric: tabular-nums; }
.msg .badge { display: inline-block; width: 18px; height: 18px; vertical-align: middle; margin: -2px 3px 0 0; }
.msg .name { font-weight: 700; }
.msg .reply { display: block; color: var(--faint); font-size: 12px; line-height: 16px; margin-bottom: 1px; }
.msg.action .body { font-style: italic; }
.msg .mention { font-weight: 700; }
.msg .body a { color: #bf94ff; text-decoration: underline; }
.emote { display: inline-grid; vertical-align: middle; margin: -5px 0; }
.emote > img { grid-area: 1 / 1; height: 28px; width: auto; max-width: none; align-self: center; justify-self: center; }
.emote > img.zw { pointer-events: none; }
.notice { margin: 4px 0; padding: 6px 14px; border-left: 4px solid var(--accent); background: rgba(145,71,255,.08); }
.notice .sys { display: block; color: var(--text); font-weight: 600; }
.notice.raid { border-color: #00c8af; background: rgba(0,200,175,.08); }
.chat-paused {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 2;
  background: rgba(0,0,0,.85); border-radius: 4px; padding: 6px 12px; font-weight: 600; font-size: 13px; cursor: pointer; border: 0; color: var(--text);
}
.chat-body { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-note { color: var(--muted); text-align: center; padding: 30px 20px; }

/* ---------- player ---------- */
.player { position: relative; background: #000; width: 100%; aspect-ratio: 16 / 9; max-height: calc(100vh - var(--nav-h) - 110px); user-select: none; overflow: hidden; }
.player video { width: 100%; height: 100%; display: block; background: #000; }
.player .big-play { position: absolute; inset: 0; margin: auto; width: 76px; height: 76px; border-radius: 50%; background: rgba(0,0,0,.55); border: 0; cursor: pointer; display: grid; place-items: center; }
.player .big-play svg { width: 36px; fill: #fff; margin-left: 4px; }
.player .spinner { position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.controls {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 12px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.8)); transition: opacity .2s; opacity: 1;
}
.player.idle .controls { opacity: 0; }
.player.idle { cursor: none; }
.seek { position: relative; height: 16px; cursor: pointer; display: flex; align-items: center; margin-bottom: 4px; }
.seek .rail { position: relative; flex: 1; height: 4px; display: flex; gap: 3px; transition: height .1s; }
.seek:hover .rail { height: 7px; }
.seek .seg { position: relative; height: 100%; background: rgba(255,255,255,.3); overflow: hidden; }
.seek .seg .buf { position: absolute; inset: 0 auto 0 0; background: rgba(255,255,255,.35); }
.seek .seg .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.seek .knob { position: absolute; top: 50%; width: 13px; height: 13px; margin: -6.5px 0 0 -6.5px; border-radius: 50%; background: var(--accent); transform: scale(0); transition: transform .1s; pointer-events: none; }
.seek:hover .knob { transform: scale(1); }
.seek .trim { position: absolute; top: -3px; bottom: -3px; border: 2px solid var(--warn); border-radius: 3px; pointer-events: none; }
.seek .tip { position: absolute; bottom: 20px; transform: translateX(-50%); background: rgba(0,0,0,.9); padding: 4px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; pointer-events: none; display: none; text-align: center; }
.seek .tip b { display: block; font-weight: 600; }
.seek:hover .tip { display: block; }
.ctrl-row { display: flex; align-items: center; gap: 4px; }
.ctrl-row .grow { flex: 1; }
.cbtn { width: 34px; height: 34px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; display: grid; place-items: center; }
.cbtn:hover { background: rgba(255,255,255,.14); }
.cbtn svg { width: 20px; height: 20px; fill: #fff; }
.vol { width: 0; overflow: hidden; transition: width .15s; display: flex; align-items: center; }
.vol-wrap:hover .vol, .vol:focus-within { width: 80px; }
.vol-wrap { display: flex; align-items: center; }
.vol input { width: 72px; accent-color: #fff; margin: 0 4px; }
.clock { font-size: 13px; font-variant-numeric: tabular-nums; margin-left: 6px; color: #fff; text-shadow: 0 0 2px #000; }
.menu { position: absolute; right: 12px; bottom: 58px; background: var(--surface); border-radius: var(--radius); padding: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.6); min-width: 150px; }
.menu button { display: flex; width: 100%; justify-content: space-between; padding: 6px 10px; border: 0; background: transparent; border-radius: 4px; cursor: pointer; font-size: 13px; }
.menu button:hover { background: var(--hover); }
.menu button.on::after { content: "✓"; color: #bf94ff; }
.menu .mh { color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 10px; text-transform: uppercase; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--surface-3); padding: 10px 16px; border-radius: var(--radius); font-weight: 600; z-index: 200; box-shadow: 0 4px 14px rgba(0,0,0,.6); }

@media (max-width: 900px) {
  .watch { flex-direction: column; height: auto; }
  .watch-main { overflow: visible; }
  .watch-chat { width: auto; height: 60vh; border-left: 0; border-top: 1px solid var(--border); }
  .player { max-height: none; }
  .cbtn[title^="Theater"] { display: none; }
  .info { flex-wrap: wrap; padding: 12px 16px 20px; }
  .info .actions { margin-left: 0; justify-content: flex-start; }
  .chapters { padding: 0 16px 20px; }
}
@media (max-width: 640px) {
  .grid, .toolbar, .tabs { padding-left: 16px; padding-right: 16px; }
  .chan-head { padding: 0 16px; } .live-card { margin: 16px 16px 0; flex-wrap: wrap; }
  .banner { height: 120px; }
  .grid { grid-template-columns: 1fr; }
  .brand small { display: none; }
}
