@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/assets/fonts/inter-var.woff2') format('woff2');
}

:root {
    --bg: #0f0e13;
    --bg-elevated: #17151d;
    --card: #1c1a24;
    --card-hover: #221f2b;
    --border: #2e2b38;
    --text: #f2f0f5;
    --muted: #a6a2b3;
    --accent: #a970ff;
    --accent-2: #ff9d5c;
    --accent-grad: linear-gradient(135deg, #a970ff 0%, #7c5cff 55%, #5c8dff 100%);
    --danger: #ff6b6b;
    --success: #4ade80;
    --live: #ff4757;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    background-image: radial-gradient(ellipse 900px 500px at 15% -10%, rgba(169, 112, 255, 0.16), transparent 60%),
                       radial-gradient(ellipse 700px 500px at 100% 0%, rgba(255, 157, 92, 0.08), transparent 55%);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.2rem; }

/* ---------- Navigation ---------- */
.topnav {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 28px;
    background: rgba(23, 21, 29, 0.75);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topnav .brand {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.topnav a:not(.brand) { color: var(--muted); font-weight: 500; font-size: 0.92rem; }
.topnav a:not(.brand):hover { color: var(--text); text-decoration: none; }
.topnav .spacer { flex: 1; }
.topnav .avatar-chip { display: flex; align-items: center; gap: 8px; }

/* ---------- Layout ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }
.container.narrow { max-width: 680px; }
.centered { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.page-header { margin-bottom: 28px; }
.page-header p { margin: 4px 0 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    max-width: 440px;
    box-shadow: var(--shadow);
}
.container .card, .container.narrow .card { max-width: none; }
.card.highlight { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(169, 112, 255, 0.3), var(--shadow); }

h2 { margin-top: 0; }
.muted { color: var(--muted); }
.error { color: var(--danger); background: rgba(255, 107, 107, 0.1); border: 1px solid rgba(255, 107, 107, 0.3); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; }
.success { color: var(--success); background: rgba(74, 222, 128, 0.1); border: 1px solid rgba(74, 222, 128, 0.3); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; }
.small-print { font-size: 0.82rem; margin-top: 18px; text-align: center; }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: 14px; font-size: 0.88rem; font-weight: 500; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=color] {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.15s;
}
input:focus { outline: none; border-color: var(--accent); }
input.color-input { width: 60px; height: 40px; padding: 4px; cursor: pointer; }

button {
    background: var(--accent-grad);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.92rem;
    transition: transform 0.1s, opacity 0.15s;
}
button:hover { opacity: 0.92; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: default; }
.btn-block { width: 100%; }
.btn-secondary { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); padding: 6px 12px; font-size: 0.85rem; }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-danger { background: var(--danger); }

.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 0.85rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

code {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
    word-break: break-all;
    font-size: 0.88em;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.badge {
    background: var(--live);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 4px;
    vertical-align: middle;
    letter-spacing: 0.03em;
}
.pill { display: inline-block; background: var(--bg-elevated); border: 1px solid var(--border); color: var(--muted); font-size: 0.78rem; padding: 3px 10px; border-radius: 999px; }

/* ---------- Auth pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo { font-size: 2.4rem; margin-bottom: 8px; }
.auth-brand h1 { margin: 0 0 4px; }
.auth-card { max-width: none; width: 100%; }

/* ---------- Homepage ---------- */
.hero {
    padding: 8px 0 32px;
}
.hero h1 { font-size: 2rem; margin-bottom: 4px; }
.hero p { color: var(--muted); font-size: 1rem; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 36px 0 16px; }
.section-title h2 { margin: 0; }
.section-title .count { color: var(--muted); font-size: 0.85rem; font-weight: 500; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }

.channel-card {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--text);
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.channel-card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.channel-card .thumb {
    height: 130px;
    background: linear-gradient(135deg, #2a2438, #1a1722);
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.channel-card .thumb .pulse {
    width: 14px; height: 14px; border-radius: 50%; background: var(--live);
    box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.6);
    animation: pulse 1.8s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.5); }
    70% { box-shadow: 0 0 0 14px rgba(255, 71, 87, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}
.channel-card .thumb .badge { position: absolute; top: 10px; left: 10px; }
.channel-card .meta { padding: 14px; display: flex; gap: 12px; align-items: center; }
.channel-card .meta-text { display: flex; flex-direction: column; min-width: 0; }
.channel-card .meta-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-card .meta-text span { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white; font-size: 0.95rem;
    flex-shrink: 0;
}
.avatar.small { width: 28px; height: 28px; font-size: 0.75rem; }

.empty-state {
    background: var(--card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
}

.userlist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.userlist li {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    transition: background 0.1s;
}
.userlist li:hover { background: var(--card); }
.userlist .user-meta { display: flex; flex-direction: column; }
.userlist .user-meta span.tag { font-size: 0.78rem; }

/* ---------- Watch page ---------- */
.watch-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; padding: 24px; max-width: 1500px; margin: 0 auto; }
.player-col video { width: 100%; background: #000; border-radius: var(--radius); box-shadow: var(--shadow); }
.stream-title-row { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; }
.offline-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 70px 20px;
    text-align: center;
    color: var(--muted);
}
.offline-box .icon { font-size: 2.2rem; margin-bottom: 10px; }
.chat-col {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    height: 78vh;
    overflow: hidden;
}
.chat-header { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 0.9rem; }
.chat-box { flex: 1; overflow-y: auto; padding: 12px 16px; font-size: 0.88rem; display: flex; flex-direction: column; gap: 6px; }
.chat-box .msg { word-wrap: break-word; line-height: 1.4; }
.chat-box .msg .user { font-weight: 700; color: var(--accent); }
#chat-form { display: flex; border-top: 1px solid var(--border); padding: 10px; gap: 8px; }
#chat-form input { flex: 1; margin: 0; }
#chat-form button { padding: 10px 16px; }

/* ---------- Security / settings ---------- */
.qr-box { background: white; padding: 16px; border-radius: var(--radius-sm); display: inline-block; margin: 12px 0; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }
.recovery-codes code { text-align: center; padding: 8px; }

@media (max-width: 900px) {
    .watch-layout { grid-template-columns: 1fr; padding: 16px; }
    .chat-col { height: 420px; }
    .topnav { padding: 12px 16px; gap: 12px; }
    .container { padding: 20px 16px 48px; }
}
