:root {
  --bg: #0e0e12;
  --bg-2: #14141b;
  --surface: #17171f;
  --surface-2: #1e1e28;
  --surface-3: #262633;
  --text: #efeff5;
  --muted: #a0a0b0;
  --faint: #6c6c7c;
  --accent: #9147ff;          /* twitch-ish purple */
  --accent-2: #a970ff;
  --accent-ink: #ffffff;
  --danger: #ff5566;
  --ok: #38d39f;
  --live: #ff2d55;
  --border: #2a2a37;
  --border-2: #35354a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1100px 560px at 78% -8%, #241634 0%, rgba(14,14,18,0) 55%) no-repeat,
    radial-gradient(900px 500px at 5% 110%, #171033 0%, rgba(14,14,18,0) 50%) no-repeat,
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Sticky footer: main grows to fill the viewport so pages never look
   "cut off" in the middle on short content. */
.container { flex: 1 0 auto; width: 100%; }
.footer { flex-shrink: 0; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--text); }

/* ── Top nav ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 60px;
  background: rgba(20,20,27,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 21px; color: var(--text); letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand::before {
  content: ""; width: 12px; height: 12px; border-radius: 3px;
  background: var(--live); box-shadow: 0 0 12px var(--live);
}
.brand span { color: var(--accent-2); }
.topbar nav { display: flex; align-items: center; gap: 6px; }
.navlink {
  color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 8px;
}
.navlink:hover { color: var(--text); background: var(--surface-2); }
.navlink.active { color: var(--text); background: var(--surface-2); }
.nav-user {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text); font-weight: 700; font-size: 14px;
  padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.nav-user:hover { border-color: var(--accent); color: var(--text); }
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}
.link-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; font: inherit; font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 8px;
}
.link-btn:hover { color: var(--text); background: var(--surface-2); }

.container { max-width: 1160px; margin: 0 auto; padding: 28px 22px 72px; }

/* ── Typography / headers ────────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
h1 { font-size: 28px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -.01em; }
.subtitle { color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.section { margin-top: 34px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card.narrow { max-width: 440px; margin: 8vh auto 0; }
.card h1 { margin-bottom: 6px; }

/* ── Auth screens ────────────────────────────────────────── */
.auth-logo { font-weight: 800; font-size: 24px; text-align: center; margin-bottom: 4px; }
.auth-logo span { color: var(--accent-2); }

/* ── Forms ───────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 15px; }
label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stack label { display: flex; flex-direction: column; gap: 7px; }
input, textarea, select {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 15px;
  width: 100%;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 90px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(145,71,255,.25);
}
.field { margin: 16px 0; }
.field > label { display: block; margin-bottom: 7px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.mt { margin-top: 18px; }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row > * { flex: 0 0 auto; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: transform .04s ease, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { border-color: rgba(255,85,102,.5); color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger); color: #1a0b0d; border-color: var(--danger); }
.btn.small { padding: 7px 11px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Alerts / toasts ─────────────────────────────────────── */
.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.alert.error { background: rgba(255,85,102,.12); color: #ff8a95; border: 1px solid rgba(255,85,102,.4); }
.alert.ok { background: rgba(56,211,159,.12); color: var(--ok); border: 1px solid rgba(56,211,159,.4); }
.alert.info { background: rgba(145,71,255,.12); color: var(--accent-2); border: 1px solid rgba(145,71,255,.4); }

/* ── Announcement board ──────────────────────────────────── */
.board { display: flex; flex-direction: column; gap: 12px; }
.announcement {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.announcement h3 { margin: 0 0 6px; font-size: 16px; }
.announcement .meta { color: var(--faint); font-size: 12px; margin-top: 10px; }
.announcement .body { color: var(--muted); white-space: pre-wrap; }
.announcement .adm { display: flex; gap: 8px; margin-top: 12px; }

/* ── Live grid ───────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
.stream-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden; color: var(--text);
  transition: transform .1s ease, border-color .15s;
}
.stream-card:hover { border-color: var(--accent); transform: translateY(-3px); color: var(--text); }
.thumb {
  position: relative; aspect-ratio: 16 / 9;
  background:
    radial-gradient(120px 80px at 30% 30%, rgba(145,71,255,.25), transparent),
    linear-gradient(135deg, #241b34, #12121a);
  display: flex; align-items: center; justify-content: center;
}
.thumb .play {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2);
  display: grid; place-items: center; color: #fff;
}
.live-badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--live); color: #fff; font-size: 11px; font-weight: 800;
  padding: 3px 9px; border-radius: 5px; letter-spacing: .6px;
  display: inline-flex; align-items: center; gap: 6px;
}
.live-badge::before { content:""; width:6px; height:6px; border-radius:50%; background:#fff; }
.viewers { position: absolute; bottom: 10px; left: 10px; background: rgba(0,0,0,.6); color:#fff; font-size:12px; padding:2px 8px; border-radius:5px; }
.stream-meta { padding: 13px 15px; display: flex; align-items: center; gap: 11px; }
.stream-meta .avatar { width: 34px; height: 34px; font-size: 14px; }
.stream-meta strong { display:block; }
.stream-meta .sub { color: var(--faint); font-size: 13px; }

/* ── Empty state ─────────────────────────────────────────── */
.empty {
  text-align: center; padding: 56px 24px;
  border: 1px dashed var(--border-2); border-radius: var(--radius);
  background: var(--surface);
}
.empty .emoji { font-size: 40px; }
.empty h3 { margin: 12px 0 6px; font-size: 18px; }
.empty p { color: var(--muted); margin: 0; }

/* ── Watch page (Twitch/Kick-style: player + chat sidebar) ─── */
.watch-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
  align-items: start;
}
.watch-main { min-width: 0; }
.player-wrap { position: relative; }
#player {
  width: 100%; aspect-ratio: 16 / 9; background: #000;
  border-radius: var(--radius); border: 1px solid var(--border);
  display: block;
}
.player-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(600px 300px at 50% 40%, #1d1530, #0b0b10);
  border-radius: var(--radius); border: 1px solid var(--border);
}
.offline-card { text-align: center; }
.offline-card .emoji { font-size: 44px; }
.offline-card h3 { margin: 10px 0 4px; }

.channel-bar {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.avatar.lg { width: 52px; height: 52px; font-size: 20px; flex: 0 0 auto; }
.channel-info { flex: 1 1 auto; min-width: 0; }
.channel-title { display: flex; align-items: center; gap: 10px; }
.channel-title h1 { margin: 0; font-size: 22px; }
.channel-meta { display: flex; gap: 8px; margin-top: 6px; }
.meta-pill {
  font-size: 12px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 3px 9px; border-radius: 999px;
}
.channel-actions { flex: 0 0 auto; }

.badge { font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 6px; letter-spacing: .6px; }
.badge.on { background: var(--live); color: #fff; }
.badge.off { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* Chat sidebar */
.watch-side {
  display: flex; flex-direction: column;
  height: calc((100vw - 380px) * 0.5625 + 82px);
  max-height: 78vh; min-height: 420px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.chat-head { padding: 13px 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.chat-body { flex: 1 1 auto; overflow-y: auto; padding: 14px; }
.chat-soon { text-align: center; color: var(--muted); margin-top: 30%; }
.chat-soon .emoji { font-size: 34px; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input input { flex: 1 1 auto; }

@media (max-width: 900px) {
  .watch-layout { grid-template-columns: 1fr; }
  .watch-side { height: auto; min-height: 260px; max-height: 50vh; }
}

/* ── Tabs (admin) ────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tab {
  background: none; border: none; color: var(--muted);
  font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
  padding: 12px 16px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.panel { display: none; }
.panel.active { display: block; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
code { background: var(--surface-2); padding: 3px 7px; border-radius: 5px; font-size: 13px; font-family: ui-monospace, Menlo, monospace; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border-2); text-transform: uppercase; letter-spacing: .03em; }
.tag.ok { color: var(--ok); border-color: rgba(56,211,159,.4); background: rgba(56,211,159,.08); }
.tag.bad { color: var(--danger); border-color: rgba(255,85,102,.4); background: rgba(255,85,102,.08); }
.row-actions { display: flex; gap: 8px; }

/* Inline user editor (Staff > Users > Edit) */
.editor-row td { background: var(--surface-2); }
.user-editor { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; padding: 6px 2px; }
.ue-field { display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
.ue-field label { font-size: 12px; }
.ue-actions { display: flex; gap: 8px; margin-left: auto; }
.ue-role select { padding: 8px 10px; }

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  color: var(--faint); font-size: 13px;
  padding: 22px; text-align: center;
}
.footer .hovixa {
  color: var(--accent-2); font-weight: 700; position: relative;
}
.footer .hovixa:hover { color: var(--text); }
.footer .hovixa::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
}
.footer .hovixa:hover::after { transform: scaleX(1); }

/* ── Utilities ───────────────────────────────────────────── */
.hidden, [hidden] { display: none !important; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite; margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  0%   { opacity: 0; transform: scale(.96) translateY(10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes livePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,45,85,.55); }
  70%      { box-shadow: 0 0 0 7px rgba(255,45,85,0); }
}
@keyframes brandGlow {
  0%, 100% { box-shadow: 0 0 10px var(--live); }
  50%      { box-shadow: 0 0 18px var(--live); }
}

/* Page entrance */
h1, .page-head { animation: fadeUp .4s ease both; }
.card { animation: fadeUp .45s ease both; }
.announcement { animation: fadeUp .4s ease both; }
.empty { animation: popIn .5s ease both; }
.panel.active { animation: fadeIn .3s ease both; }

/* Live/brand pulse */
.brand::before { animation: brandGlow 2.4s ease-in-out infinite; }
.live-badge::before { animation: livePulse 1.6s ease-in-out infinite; }

/* Stream cards fade/slide in; new ones added by polling get .enter */
.stream-card { animation: fadeUp .4s ease both; }
.stream-card.enter { animation: popIn .45s cubic-bezier(.2,.7,.3,1) both; }

/* Nav hover micro-interaction */
.navlink, .nav-user, .btn { transition: transform .05s ease, background .15s, border-color .15s, color .15s, filter .15s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 640px) {
  .topbar { padding: 0 14px; }
  .navlink { padding: 8px 9px; }
  .container { padding: 20px 14px 60px; }
  h1 { font-size: 24px; }
}
