:root {
  --bg: #0d0f14;
  --bg-2: #14171f;
  --surface: #181b24;
  --surface-2: #1f2330;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --text: #e7e9ee;
  --muted: #8b909e;
  --accent: #ff3b54;
  --accent-soft: rgba(255, 59, 84, .14);
  --radius: 14px;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 22px;
  background: rgba(13, 15, 20, .82);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 19px; letter-spacing: -.02em;
}
.brand .tld { color: var(--muted); font-weight: 600; }
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.nav { display: flex; align-items: center; gap: 16px; }
.inline { margin: 0; }
.link {
  color: var(--muted); font-size: 14px; font-weight: 500;
  background: none; border: 0; cursor: pointer; padding: 6px 2px;
  transition: color .15s;
}
.link:hover { color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 38px; padding: 0 18px; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
  border: 0; cursor: pointer; letter-spacing: -.01em;
  transition: transform .12s, filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn-ghost {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line-2);
}
.btn-wide { width: 100%; height: 44px; font-size: 15px; }

/* ---------- layout ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 30px 22px 64px; }
.foot {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 28px; border-top: 1px solid var(--line);
}

.hero { margin: 6px 0 26px; }
.hero h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.03em; }
.hero p { margin: 0; color: var(--muted); font-size: 15px; }
.section-h { margin: 40px 0 14px; font-size: 16px; color: var(--muted); font-weight: 600; }

/* ---------- grid of channels ---------- */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  transition: transform .14s, border-color .14s, box-shadow .14s;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--line-2);
  box-shadow: var(--shadow);
}
.thumb {
  position: relative; aspect-ratio: 16 / 9;
  display: grid; place-items: center;
  background:
    radial-gradient(120% 120% at 30% 20%, hsl(var(--h) 38% 24%), hsl(var(--h) 42% 12%));
}
.thumb-letter {
  font-size: 52px; font-weight: 800; color: hsl(var(--h) 50% 78%);
  opacity: .55; letter-spacing: -.04em;
}
.live-badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  padding: 3px 7px; border-radius: 5px;
}
.viewers {
  position: absolute; top: 10px; right: 10px;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 12px; font-weight: 600;
  padding: 3px 8px; border-radius: 5px;
}
.viewers::first-letter { color: var(--accent); }
.card-body { padding: 12px 14px 15px; }
.card-title {
  font-weight: 600; font-size: 15px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-slug { color: var(--muted); font-size: 13px; margin-top: 3px; }

/* ---------- offline chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; color: var(--muted);
  transition: border-color .14s, color .14s;
}
.chip:hover { border-color: var(--line-2); color: var(--text); }
.chip-off { width: 7px; height: 7px; border-radius: 50%; background: #4b5160; }

/* ---------- empty state ---------- */
.empty {
  text-align: center; padding: 56px 20px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px;
}
.empty h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.02em; }
.empty p { margin: 0 0 20px; color: var(--muted); }
.empty-icon {
  width: 46px; height: 46px; margin: 0 auto 16px; border-radius: 12px;
  border: 2px solid var(--line-2);
  background: var(--accent-soft);
}

/* ---------- watch ---------- */
.watch { max-width: 960px; margin: 0 auto; }
.player-shell {
  position: relative; aspect-ratio: 16 / 9;
  background: #000; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
}
#player { width: 100%; height: 100%; display: block; background: #000; }
.offline-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 20px;
  background: radial-gradient(120% 90% at 50% 30%, var(--bg-2), #000);
}
.offline-overlay.hidden { display: none; }
.offline-overlay h2 { margin: 8px 0 0; font-size: 19px; }
.offline-overlay p { margin: 0; color: var(--muted); font-size: 14px; max-width: 360px; }
.offline-pulse {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 30px; font-weight: 800; color: hsl(var(--h) 55% 80%);
  background: hsl(var(--h) 40% 18%);
  box-shadow: 0 0 0 0 hsl(var(--h) 60% 40% / .5);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 hsl(0 0% 60% / .28); }
  100% { box-shadow: 0 0 0 26px hsl(0 0% 60% / 0); }
}
.watch-meta {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-top: 16px;
}
.watch-meta h1 { margin: 0 0 4px; font-size: 21px; letter-spacing: -.02em; }
.status { display: flex; align-items: center; gap: 10px; }
.status .viewers { position: static; }
.hidden { display: none !important; }

/* ---------- auth ---------- */
.auth {
  max-width: 400px; margin: 30px auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 30px 28px;
}
.auth h1 { margin: 0 0 4px; font-size: 23px; letter-spacing: -.02em; }
.auth-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.auth-alt { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 14px; }
.auth-alt a { color: var(--accent); font-weight: 600; }
.form { display: flex; flex-direction: column; gap: 15px; }
.form label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 7px; }
.form input {
  height: 44px; padding: 0 13px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text);
  font-size: 15px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-prefix {
  display: flex; align-items: center;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px;
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.field-prefix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field-prefix span { padding: 0 2px 0 13px; color: var(--muted); font-size: 14px; white-space: nowrap; }
.field-prefix input { border: 0; background: none; box-shadow: none !important; flex: 1; padding-left: 2px; }
.alert {
  background: var(--accent-soft); border: 1px solid rgba(255, 59, 84, .3);
  color: #ffb3bd; padding: 11px 14px; border-radius: 10px;
  font-size: 14px; margin-bottom: 16px;
}

/* ---------- dashboard ---------- */
.dash { max-width: 620px; margin: 0 auto; }
.dash-head { display: flex; align-items: center; gap: 12px; }
.dash-head h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.dash-head .live-badge { position: static; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; margin-top: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.hint.danger { color: #d98a93; margin: 16px 0 0; }
.copy-row { display: block; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.copy-field {
  display: flex; align-items: stretch; gap: 8px; margin-top: 7px;
}
.copy-field code {
  flex: 1; min-width: 0; padding: 11px 13px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  color: var(--text); overflow-x: auto; white-space: nowrap;
}
.copy {
  flex: none; padding: 0 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line-2);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.copy:hover { background: #272c3a; }
.copy.done { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps ol { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.7; font-size: 14px; }
.steps b { color: var(--text); }
.steps a, .panel a, .card-slug a { color: var(--accent); }

@media (max-width: 560px) {
  .topbar { padding: 0 16px; }
  .nav { gap: 10px; }
  .wrap { padding: 22px 16px 48px; }
  .hero h1 { font-size: 24px; }
}
