/* PuhBar Stream — улучшенная тёмная тема */
:root {
    --bg: #0c0c0f;
    --bg-elevated: #12121a;
    --bg-card: #16161d;
    --bg-card-hover: #1a1a24;
    --border: #252530;
    --border-focus: #9147ff;
    --text: #efeff1;
    --text-secondary: #adadb8;
    --text-muted: #6b6b7b;
    --accent: #9147ff;
    --accent-hover: #a970ff;
    --accent-subtle: rgba(145, 71, 255, 0.15);
    --danger: #eb0400;
    --danger-subtle: rgba(235, 4, 0, 0.15);
    --twitch: #6441a5;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    --transition: 0.2s ease;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-size: 15px;
}

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 480px; }

/* Header */
.header {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 0;
    flex-shrink: 0;
}
.header-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.2rem;
    transition: color var(--transition);
}
.logo:hover { color: var(--accent); }
.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #b794f6);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}
.nav { display: flex; align-items: center; gap: 12px; }
.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 999px;
    border: 1px solid var(--border);
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #b794f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}
.user-name { font-size: 0.9rem; color: var(--text-secondary); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-go-live { padding: 10px 20px; font-weight: 600; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-subtle); color: var(--danger); }
.btn-block { width: 100%; }

/* Main */
.main { flex: 1; padding: 32px 0 48px; }
.hero { margin-bottom: 40px; }
.hero h1 { margin: 0 0 8px 0; font-size: 1.75rem; font-weight: 700; }
.lead { margin: 0; color: var(--text-secondary); font-size: 1.05rem; }

/* Sections */
.section { margin-bottom: 40px; }
.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 20px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
}
.section-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.section-dot-live { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.section-dot-twitch { background: var(--twitch); }
.section-hint { margin: 12px 0 0 0; color: var(--text-muted); font-size: 0.9rem; }

/* Stream grid */
.stream-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.stream-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
    position: relative;
}
.stream-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.stream-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    z-index: 1;
}
.stream-badge-live { background: var(--danger); }
.stream-badge-twitch { background: var(--twitch); }
.stream-thumb {
    height: 160px;
    background: linear-gradient(145deg, #1c1c24 0%, #252530 100%);
    position: relative;
}
.stream-viewers {
    position: absolute;
    bottom: 8px;
    left: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(0,0,0,0.6);
    padding: 4px 8px;
    border-radius: 4px;
}
.stream-info { padding: 14px; }
.stream-title { display: block; margin-bottom: 4px; font-size: 0.95rem; font-weight: 600; line-height: 1.3; }
.stream-meta { font-size: 0.85rem; color: var(--text-muted); }

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 24px;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.7; }
.empty-state p { margin: 0 0 20px 0; color: var(--text-secondary); }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.card-info { margin-bottom: 24px; }
.card-info strong { display: block; margin-bottom: 8px; }
.card-info p { margin: 0 0 16px 0; color: var(--text-secondary); font-size: 0.95rem; }
.card-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Forms */
.broadcast-form .field { display: block; margin-bottom: 20px; }
.field-label { display: block; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-secondary); font-weight: 500; }
.broadcast-form input {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition);
}
.broadcast-form input:focus {
    outline: none;
    border-color: var(--accent);
}
.broadcast-form input::placeholder { color: var(--text-muted); }
.broadcast-form button { margin-top: 8px; }

.broadcast-obs { margin-top: 20px; }
.broadcast-obs-title { display: block; margin-bottom: 8px; }
.broadcast-obs-desc { margin: 0 0 16px 0; color: var(--text-secondary); font-size: 0.95rem; }
.broadcast-obs-fields .field { margin-bottom: 14px; }
.broadcast-obs-fields .field:last-child { margin-bottom: 0; }
.broadcast-obs-input { font-family: monospace; font-size: 0.9rem; }
.broadcast-obs-hint { margin: 14px 0 0 0; color: var(--text-muted); font-size: 0.9rem; }

/* Auth (login/register) */
.auth-form .field { display: block; margin-bottom: 18px; }
.auth-form .field:last-of-type { margin-bottom: 20px; }
.auth-form input,
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.auth-form input:hover { border-color: var(--text-muted); }
.auth-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}
.auth-form input::placeholder { color: var(--text-muted); }
.auth-form .btn-block { margin-top: 4px; padding: 12px 16px; font-weight: 600; }
.auth-switch { margin-top: 20px; text-align: center; color: var(--text-secondary); font-size: 0.95rem; }
.auth-switch a { color: var(--accent); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* Watch page */
.watch-container { max-width: 900px; }
.watch-player {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
    position: relative;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
}
.watch-player .stream-badge { top: 16px; left: 16px; }
.watch-player-inner { padding: 24px; text-align: center; }
.watch-player-embed {
    position: absolute;
    inset: 0;
    padding: 0;
}
.watch-player-embed iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: none;
}
.watch-player-hls .watch-hls-video {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
}
.watch-player-hls .watch-hls-fallback { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; }
.watch-placeholder { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.watch-info h1 { margin: 0 0 8px 0; font-size: 1.35rem; font-weight: 600; }
.watch-meta { margin: 0 0 20px 0; color: var(--text-secondary); font-size: 0.95rem; }
.watch-sep { margin: 0 8px; color: var(--text-muted); }
.watch-share { margin-top: 24px; }
.watch-share-label { display: block; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-secondary); }
.watch-share-row { display: flex; gap: 12px; align-items: center; }
.watch-share-row input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}

/* Utility */
.error { color: var(--danger); margin-bottom: 16px; padding: 12px; background: var(--danger-subtle); border-radius: var(--radius-sm); }

/* Footer */
.footer {
    margin-top: auto;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.9rem;
    flex-shrink: 0;
}
.footer-logo { font-weight: 600; color: var(--text-secondary); }
.footer-text { margin-left: 8px; }

/* Responsive */
@media (max-width: 640px) {
    .container { padding: 0 16px; }
    .stream-grid { grid-template-columns: 1fr; gap: 16px; }
    .nav .user-name { display: none; }
    .watch-share-row { flex-direction: column; align-items: stretch; }
    .watch-share-row input { width: 100%; }
}
