:root {
  --bg: #0e0e10;
  --bg-2: #18181b;
  --bg-3: #1f1f23;
  --bg-4: #26262c;
  --line: #303036;
  --fg: #efeff1;
  --fg-dim: #adadb8;
  --fg-muted: #7c7c8a;
  --brand: #9147ff;
  --brand-2: #772ce8;
  --brand-soft: rgba(145, 71, 255, 0.16);
  --live: #eb0400;
  --ok: #00c78a;
  --warn: #ffb31a;
  --danger: #ff4d4d;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--brand); }
button { font: inherit; }
img { max-width: 100%; }
code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 100; background: var(--brand); color: #fff; padding: 8px 12px; border-radius: 6px; }

.dim { color: var(--fg-dim); }
.warn { color: var(--warn); }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  height: 50px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -0.5px; font-size: 18px; }
.brand-mark {
  width: 20px; height: 20px; border-radius: 5px;
  background: linear-gradient(135deg, var(--brand), #5c16c5);
  box-shadow: 0 0 0 2px rgba(145,71,255,.25);
}
.brand-name span { color: var(--brand); }
.mainnav { display: flex; gap: 4px; }
.mainnav a { padding: 6px 10px; border-radius: 6px; font-weight: 600; color: var(--fg); }
.mainnav a:hover { background: var(--bg-3); color: var(--fg); }
.search { flex: 1; max-width: 420px; margin-left: auto; }
.search input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 20px;
  padding: 7px 14px;
  outline: none;
}
.search input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.nav-user { display: flex; align-items: center; gap: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-4); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-3); }
.btn.danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn[aria-pressed="true"].follow { background: var(--bg-4); color: var(--fg-dim); }
.linklike { background: none; border: 0; color: inherit; cursor: pointer; text-align: left; padding: 0; }

/* ---------- avatar & menu ---------- */
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--c, var(--brand));
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; cursor: pointer; list-style: none;
  user-select: none;
}
.avatar.big { width: 88px; height: 88px; font-size: 36px; }
.avatar::-webkit-details-marker { display: none; }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: 42px; min-width: 200px;
  background: var(--bg-3); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.menu-pop a, .menu-pop button { padding: 8px 10px; border-radius: 6px; display: block; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg-4); color: var(--fg); }

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 20px 16px 40px; }
.sect { margin-bottom: 28px; }
.sect.narrow { max-width: 820px; margin: 0 auto; }
.sect.tight { margin-top: 18px; }
.sect-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
h1 { font-size: 22px; margin: 0 0 12px; letter-spacing: -0.4px; }
h2 { font-size: 16px; margin: 0 0 10px; }
h2.sub { font-size: 14px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .6px; margin: 18px 0 10px; }

.foot {
  display: flex; gap: 18px; flex-wrap: wrap;
  padding: 18px 16px 28px; color: var(--fg-muted); font-size: 12px;
  border-top: 1px solid var(--line);
}
.foot a:hover { color: var(--fg); }

/* ---------- grids & tiles ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px 16px;
}
.tile { display: block; color: var(--fg); }
.tile:hover { color: var(--fg); }
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background-color: hsl(var(--h, 270) 45% 24%);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  transition: transform .18s ease, box-shadow .18s ease;
}
.tile:hover .thumb { transform: translateY(-2px); box-shadow: var(--shadow); }
.thumb .thumb-fallback { font-size: 40px; font-weight: 800; color: rgba(255,255,255,.22); }
.thumb.offline { filter: saturate(.45) brightness(.8); }
.badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.72); color: #fff;
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px;
}
.badge.live { background: var(--live); text-transform: uppercase; letter-spacing: .5px; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
.badge.warn { background: var(--warn); color: #000; position: static; margin-top: 6px; }
@keyframes pulse { 50% { opacity: .35; } }
.viewers {
  position: absolute; bottom: 8px; left: 8px;
  background: rgba(0,0,0,.7); color: #fff;
  padding: 1px 7px; border-radius: 4px; font-size: 12px; font-weight: 600;
}
.viewers::before { content: "● "; color: var(--live); font-size: 9px; vertical-align: 1px; }
.dur {
  position: absolute; bottom: 8px; right: 8px;
  background: rgba(0,0,0,.8); color: #fff; padding: 1px 6px; border-radius: 4px; font-size: 12px;
}
.mature {
  position: absolute; top: 8px; right: 8px;
  background: rgba(0,0,0,.72); color: var(--warn); border: 1px solid var(--warn);
  padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 700;
}
.tile-meta { display: flex; gap: 10px; margin-top: 9px; }
.tile-meta .av { width: 40px; height: 40px; border-radius: 50%; flex: none; background: var(--bg-3); }
.tile-text { min-width: 0; }
.tile-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { color: var(--fg-dim); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vod-cell { position: relative; }

/* ---------- chips / filters ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 18px; }
.chip {
  background: var(--bg-3); border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px; font-size: 13px; font-weight: 600;
}
.chip span { color: var(--fg-muted); font-weight: 500; }
.chip:hover, .chip.on { border-color: var(--brand); background: var(--brand-soft); }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }

/* ---------- cards & forms ---------- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.form { display: flex; flex-direction: column; gap: 12px; max-width: 640px; }
.form.inline { flex-direction: row; align-items: flex-end; flex-wrap: wrap; max-width: none; }
.f { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 200px; }
.f.inline { flex-direction: row; align-items: center; gap: 8px; }
.f > span { font-size: 12px; font-weight: 600; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .5px; }
.f input, .f select, .f textarea {
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  outline: none;
  width: 100%;
}
.f input:focus, .f select:focus, .f textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.f input[type="color"] { padding: 2px; height: 36px; }
.row2 { display: flex; gap: 12px; flex-wrap: wrap; }
.row3 { display: flex; gap: 12px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.hint { font-size: 12px; color: var(--fg-muted); margin: 4px 0 0; }
.msg { font-size: 13px; color: var(--fg-dim); min-height: 0; margin: 0; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }

/* ---------- watch page ---------- */
.watch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 1000px) { .watch { grid-template-columns: 1fr; } }
.watch-main { min-width: 0; }
.player {
  position: relative;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
}
.player .video { width: 100%; height: 100%; background: #000; display: block; object-fit: contain; }
.player.offline-player { background: hsl(var(--h, 270) 35% 14%); }
.offline-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center; padding: 20px;
}
.offline-inner h3 { margin: 0; font-size: 17px; }
.offline-inner p { margin: 0; color: var(--fg-dim); font-size: 13px; }
.offline-av {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--c, var(--brand)); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; margin-bottom: 6px;
}
.watch-head { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.watch-title { min-width: 0; flex: 1; }
.watch-title h1 { font-size: 18px; margin: 0 0 6px; }
.watch-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--fg-dim); }
.chan-link { display: inline-flex; align-items: center; gap: 8px; color: var(--fg); }
.dotsep { color: var(--fg-muted); }
.channel-strip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 14px;
}
.channel-strip .who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 200px; }
.channel-strip .who img { width: 48px; height: 48px; border-radius: 50%; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.tag { background: var(--bg-3); border-radius: 20px; padding: 3px 10px; font-size: 12px; color: var(--fg-dim); }
.about-card { margin-top: 16px; }
.about-card .bio { color: var(--fg-dim); font-size: 13px; }

/* ---------- chat ---------- */
.chat {
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius);
  height: calc(100vh - 110px); min-height: 420px;
  position: sticky; top: 60px;
}
.chat-head { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--fg-dim); }
.chat-list, .chat-log { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; }
.chat-msg { font-size: 13px; line-height: 1.4; word-wrap: break-word; overflow-wrap: anywhere; }
.chat-msg .who { font-weight: 700; }
.chat-msg.system, .chat-msg.sub, .chat-msg.gift, .chat-msg.announce { background: var(--brand-soft); border-radius: 6px; padding: 4px 8px; }
.chat-msg.announce { border-left: 3px solid var(--brand); }
.chat-msg.gift { background: rgba(255,179,26,.12); }
.chat-msg.deleted { opacity: .45; text-decoration: line-through; }
.chat-msg .emte { height: 22px; vertical-align: middle; }
.badge-i svg { width: 16px; height: 16px; vertical-align: -3px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-banned { padding: 10px 12px; font-size: 12px; color: var(--danger); border-top: 1px solid var(--line); }
.chat-login { display: block; text-align: center; padding: 10px; border-top: 1px solid var(--line); color: var(--brand); font-weight: 600; }
.subs-strip { margin-top: 16px; }
.subs-strip h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--fg-dim); margin: 0 0 8px; }
.sub-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.sub-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.sub-card h4 { margin: 0; font-size: 14px; }
.sub-card .price { font-size: 20px; font-weight: 800; letter-spacing: -0.5px; }
.sub-card p { margin: 0; font-size: 12px; color: var(--fg-dim); }
.vcount { color: var(--fg-dim); font-size: 13px; }
.player-overlay { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.gear-link { background: rgba(0,0,0,.65); color: #fff; padding: 4px 9px; border-radius: 4px; font-size: 12px; }
.modal { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); color: var(--fg); padding: 0; max-width: 420px; width: calc(100% - 24px); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(0,0,0,.6); }
.modal-inner { display: flex; flex-direction: column; gap: 12px; padding: 18px; }
.modal-inner h2 { margin: 0; }
.sub-badge { display: inline-flex; align-items: center; gap: 6px; }
.chat-form input { flex: 1; background: var(--bg-3); border: 1px solid var(--line); color: var(--fg); border-radius: var(--radius-sm); padding: 8px 10px; outline: none; }
.chat-form input:focus { border-color: var(--brand); }
.chat-notice { padding: 8px 12px; font-size: 12px; color: var(--fg-muted); border-top: 1px solid var(--line); }
.chat-notice a { color: var(--brand); }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .dash { grid-template-columns: 1fr; } .dash-nav { position: static; flex-direction: row; overflow-x: auto; } }
.dash-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 66px; }
.dash-nav h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--fg-muted); margin: 0 0 6px 8px; }
.dash-nav a { padding: 8px 10px; border-radius: 6px; color: var(--fg-dim); font-weight: 600; white-space: nowrap; }
.dash-nav a:hover { background: var(--bg-3); color: var(--fg); }
.dash-nav a.on { background: var(--brand-soft); color: var(--fg); }
.dash-nav a.back { margin-top: 12px; color: var(--fg-muted); font-weight: 500; }
.dash-main { min-width: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat span { display: block; font-size: 12px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .5px; }
.stat strong { display: block; font-size: 24px; margin-top: 4px; letter-spacing: -0.5px; }
.stat em { font-style: normal; font-size: 12px; color: var(--fg-muted); }
.live-card { border-left: 3px solid var(--line); }
.live-card.is-live { border-left-color: var(--live); }
.live-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.ingest { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.ingest .f { flex-direction: row; align-items: center; gap: 8px; }
.ingest .f > span { flex: 0 0 110px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--fg-muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid rgba(48,48,54,.6); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.tier-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }

/* ---------- profile, prose, empty ---------- */
.profile-head { display: flex; gap: 18px; align-items: center; margin-bottom: 18px; }
.profile-head h1 { margin: 0 0 2px; }
.prose { max-width: 760px; color: var(--fg-dim); }
.prose h1, .prose h2 { color: var(--fg); }
.prose h2 { margin-top: 22px; }
.empty {
  background: var(--bg-2); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 36px 20px; text-align: center; color: var(--fg-dim);
}
.empty h3 { margin: 0 0 6px; color: var(--fg); font-size: 16px; }
.empty p { margin: 0 0 14px; }
.sim-card { border-color: var(--warn); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 8px 12px; border-bottom: 2px solid transparent; color: var(--fg-dim); font-weight: 600; }
.tabs a.on { color: var(--fg); border-bottom-color: var(--brand); }
.emote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.emote-cell { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; text-align: center; }
.emote-cell img { height: 48px; display: block; margin: 0 auto 6px; }
.vod-wrap { max-width: 1100px; }

/* ---------- embeds ---------- */
.embed-body { background: #000; padding: 0; margin: 0; overflow: hidden; }
.embed-body .player { border-radius: 0; height: 100vh; aspect-ratio: auto; }
.embed-brand { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }

@media (max-width: 640px) {
  .mainnav { display: none; }
  .search { max-width: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px 10px; }
  .thumb .thumb-fallback { font-size: 28px; }
  main { padding: 12px 10px 30px; }
  .topbar { gap: 10px; padding: 0 10px; }
  .brand { font-size: 16px; }
}
