:root {
    --bg: #030304;
    --surface-2: #131318;
    --border: #1f1f26;
    --text: #f2f3f8;
    --text-dim: #8e93a8;
    --twitch: #9146ff;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

html {
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #2a2c38 var(--bg);
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: var(--bg); }

::-webkit-scrollbar-thumb {
    background: #2a2c38;
    border-radius: 999px;
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover { background: #3a3d4d; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

.bg-grid {
    position: fixed;
    inset: -84px;
    z-index: -2;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 42px 42px;
    animation: gridDrift 60s linear infinite;
    will-change: transform;
}

@keyframes gridDrift {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-84px, -84px, 0); }
}

.twinkle {
    position: fixed;
    top: var(--top);
    left: var(--left);
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    background: #fff;
    opacity: 0;
    z-index: -1;
    pointer-events: none;
    box-shadow: 0 0 4px 1px rgba(255, 255, 255, 0.5);
    animation: twinkle var(--duration) ease-in-out infinite;
    animation-delay: var(--delay);
}

@keyframes twinkle {
    0%, 100% { opacity: 0; }
    50% { opacity: var(--peak); }
}

a { color: inherit; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 24px; }

header.site {
    padding: 24px 0;
    position: relative;
    z-index: 2;
}

.banner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(4, 4, 6, 0.96);
    border: 1px solid var(--border);
    backdrop-filter: blur(14px);
    border-radius: 28px;
    padding: 10px 22px;
}

.brand {
    display: flex;
    align-items: center;
    height: 48px;
    padding-right: 20px;
    margin-right: 4px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}

.brand img {
    height: 48px;
    width: auto;
    display: block;
    filter: drop-shadow(0 0 10px rgba(94, 231, 208, 0.3)) drop-shadow(0 0 22px rgba(94, 231, 208, 0.12));
    transition: transform 0.3s ease;
}

.brand:hover img {
    transform: scale(1.1);
}

.user-area {
    display: flex;
    align-items: center;
    height: 48px;
    flex-shrink: 0;
    margin-left: 4px;
    padding-left: 20px;
    border-left: 1px solid var(--border);
}

.user-menu { position: relative; }

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 16px 4px 4px;
    border-radius: 999px;
    border: none;
    background: transparent;
    font: inherit;
    cursor: pointer;
    color: var(--text);
}

.user-menu:hover .user-chip { background: var(--surface-2); }

.user-chip img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: block;
    border: 2px solid var(--twitch);
}

.user-chip .name {
    font-weight: 700;
    font-size: 0.92rem;
    color: #c4a6ff;
}

.dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    padding-top: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.user-menu:hover .dropdown,
.user-menu:focus-within .dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown a {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 10px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
}

.dropdown a:first-child { border-radius: 12px 12px 0 0; }
.dropdown a:last-child { border-radius: 0 0 12px 12px; }
.dropdown a:only-child { border-radius: 12px; }
.dropdown a + a { border-top: none; }

.dropdown a:hover { color: var(--text); background: #1a1c26; }

.twitch-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    background: var(--twitch);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
}

.twitch-btn:hover { background: #7c34e6; }

.twitch-btn svg { width: 16px; height: 16px; fill: currentColor; }

.spotify-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    background: #1db954;
    color: #06110a;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
}

.spotify-btn:hover { background: #1ed760; }

.spotify-btn svg { width: 18px; height: 18px; }

.valorant-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    background: #ff4655;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.valorant-btn:hover { background: #ff5f6c; }

.valorant-btn svg { width: 16px; height: 16px; fill: currentColor; }

.valorant-btn-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #fff;
    animation: valorantPulse 1.6s ease-in-out infinite;
}

@keyframes valorantPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.now-playing {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 48px;
    padding: 0 6px 0 0;
    border-radius: 12px;
    background: transparent;
    border: none;
    text-decoration: none;
    color: var(--text);
    width: 380px;
    overflow: hidden;
    transition: background 0.15s ease;
}

a.now-playing:hover { background: rgba(255, 255, 255, 0.05); }

.now-playing-cover {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    overflow: hidden;
    background: #191b1f;
    flex-shrink: 0;
}

.now-playing-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.now-playing-idle-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.now-playing-idle-icon svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-dim);
    fill: none;
    stroke-width: 1.6;
}

.now-playing-idle-icon svg circle:last-child {
    fill: var(--text-dim);
    stroke: none;
}

.now-playing-body {
    min-width: 0;
    flex: 1;
    max-height: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    overflow: hidden;
}

.now-playing-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.6rem;
    font-weight: 800;
    line-height: 1.25;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #1db954;
}

.now-playing-icon {
    width: 12px;
    height: 12px;
    fill: #1db954;
    flex-shrink: 0;
}

.now-playing-icon rect {
    transform-box: fill-box;
    transform-origin: bottom;
    animation: nowPlayingEq 1s ease-in-out infinite;
}

.now-playing-icon rect:nth-child(2) { animation-delay: 0.2s; }
.now-playing-icon rect:nth-child(3) { animation-delay: 0.4s; }

@keyframes nowPlayingEq {
    0%, 100% { transform: scaleY(0.45); }
    50% { transform: scaleY(1); }
}

.now-playing-track {
    display: block;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-idle-text {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.now-playing-sep { color: var(--text-dim); margin: 0 4px; font-weight: 400; }
.now-playing-artist { color: var(--text-dim); font-weight: 700; }

.now-playing-progress {
    display: flex;
    align-items: center;
    gap: 7px;
    line-height: 1.25;
}

.now-playing-time {
    font-size: 0.64rem;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-dim);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.now-playing-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    overflow: hidden;
}

.now-playing-bar-fill {
    display: block;
    height: 100%;
    background: #1db954;
    border-radius: 999px;
}

@media (max-width: 760px) {
    .now-playing { width: 220px; }
    .now-playing-progress { display: none; }
}

.alert-bar {
    max-width: 1180px;
    margin: 0 auto 0;
    padding: 12px 24px;
    position: relative;
    z-index: 2;
}

.alert-bar .box {
    background: rgba(255, 92, 92, 0.1);
    border: 1px solid rgba(255, 92, 92, 0.3);
    color: #ff8b8b;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.9rem;
}

.alert-bar .box.success {
    background: rgba(94, 231, 208, 0.1);
    border-color: rgba(94, 231, 208, 0.3);
    color: #5ee7d0;
}

footer {
    padding: 32px 0;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

@media (max-width: 720px) {
    .brand { padding-right: 12px; }
    .brand img { height: 38px; }
    .banner { flex-wrap: wrap; row-gap: 10px; }
}

.error-list {
    background: rgba(255, 92, 92, 0.1);
    border: 1px solid rgba(255, 92, 92, 0.3);
    color: #ff8b8b;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 0.88rem;
}

.error-list ul { margin: 0; padding-left: 18px; }

.settings-shell {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 24px;
}

.settings-nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}

.settings-nav button svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.settings-nav button:hover { color: var(--text); background: var(--surface-2); }

.settings-nav button.active {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border);
}

.settings-section { display: none; }
.settings-section.active { display: block; }

.card {
    background: rgba(10, 10, 13, 0.9);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 20px;
}

.card h2 {
    margin: 0 0 6px;
    font-size: 1.15rem;
}

.card .hint {
    margin: 0 0 22px;
    color: var(--text-dim);
    font-size: 0.87rem;
    line-height: 1.65;
    max-width: 56ch;
}

.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.field input[type="text"] {
    width: 100%;
    padding: 11px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
}

.field input:focus {
    outline: 2px solid var(--twitch);
    outline-offset: 1px;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 999px;
    border: none;
    background: var(--twitch);
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary:hover { background: #7c34e6; }

.btn-outline {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}

.btn-outline:hover { background: var(--surface-2); }

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #101114;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 13px 18px;
    border-radius: 12px;
    font-size: 0.87rem;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
    max-width: 320px;
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1db954;
    flex-shrink: 0;
}

.toast.error .dot { background: #ff5c5c; }

@media (max-width: 760px) {
    .settings-shell { grid-template-columns: 1fr; }
    .settings-nav { flex-direction: row; position: static; overflow-x: auto; }
}
