:root {
    --bg: #0a0e17;
    --bg-card: rgba(14, 20, 35, 0.85);
    --fg: #e0e8f0;
    --fg-dim: #7a8ba8;
    --accent: #00ffaa;
    --accent2: #00ccff;
    --accent3: #ff4466;
    --border: rgba(0, 255, 170, 0.12);
    --glow: 0 0 20px rgba(0, 255, 170, 0.15);
    --font-body: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--font-body);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

#bg-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

.scanline {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 170, 0.008) 2px,
        rgba(0, 255, 170, 0.008) 4px
    );
}

.container {
    position: relative;
    z-index: 2;
    max-width: 780px;
    margin: 0 auto;
    padding: 24px 24px 48px;
}

/* ─── Top Bar ─── */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0 32px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 40px;
}

.logo {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 2px;
    text-shadow: 0 0 12px rgba(0, 255, 170, 0.4);
}

.logo-bracket { color: var(--fg-dim); font-weight: 300; }

.top-actions { display: flex; gap: 10px; }

.btn-glow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(0, 255, 170, 0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
}

.btn-glow:hover {
    background: rgba(0, 255, 170, 0.12);
    border-color: var(--accent);
    box-shadow: var(--glow);
    transform: translateY(-1px);
}

.btn-glow.success {
    border-color: var(--accent);
    background: rgba(0, 255, 170, 0.15);
}

/* ─── Markdown Content ─── */
.md-content {
    min-height: 300px;
    padding: 0 4px;
}

.md-content .loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 80px 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--fg-dim);
}

.loading-bar {
    width: 200px;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar::after {
    content: '';
    position: absolute;
    top: 0; left: -50%;
    width: 50%; height: 100%;
    background: var(--accent);
    animation: loadSlide 1.2s ease infinite;
    border-radius: 2px;
}

@keyframes loadSlide {
    0% { left: -50%; }
    100% { left: 100%; }
}

.md-content h1 {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 8px;
    text-shadow: 0 0 30px rgba(0, 255, 170, 0.2);
    position: relative;
}

.md-content h1::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    margin-top: 12px;
    border-radius: 2px;
}

.md-content blockquote {
    border-left: 3px solid var(--accent);
    padding: 4px 0 4px 20px;
    margin: 16px 0 24px;
    color: var(--fg-dim);
    font-size: 1.05rem;
    font-style: italic;
}

.md-content hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), var(--accent), var(--border), transparent);
    margin: 40px 0;
}

.md-content h2 {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent2);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin: 40px 0 20px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    opacity: 0;
    transform: translateX(-10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.md-content h2.visible {
    opacity: 1;
    transform: translateX(0);
}

.md-content h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--fg);
    margin: 24px 0 8px;
}

.md-content h3 a {
    color: var(--accent);
    text-decoration: none;
    transition: all 0.2s ease;
}

.md-content h3 a:hover {
    color: var(--accent2);
    text-shadow: 0 0 12px rgba(0, 204, 255, 0.4);
}

.md-content p {
    margin: 8px 0;
    color: var(--fg-dim);
    line-height: 1.8;
}

.md-content ul {
    margin: 8px 0 8px 20px;
    list-style: none;
}

.md-content ul li {
    position: relative;
    padding-left: 20px;
    margin: 6px 0;
    color: var(--fg-dim);
}

.md-content ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: var(--accent);
    font-size: 0.8rem;
}

.md-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.md-content a:hover {
    border-bottom-color: var(--accent);
    text-shadow: 0 0 8px rgba(0, 255, 170, 0.3);
}

.md-content em:last-child {
    display: block;
    margin-top: 40px;
    font-size: 0.8rem;
    color: var(--fg-dim);
    opacity: 0.6;
}

/* ─── Music Panel ─── */
.music-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 340px;
    background: rgba(10, 14, 23, 0.95);
    border: 1px solid var(--border);
    border-radius: 12px;
    backdrop-filter: blur(20px);
    z-index: 100;
    overflow: hidden;
    transition: all 0.4s ease;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), var(--glow);
}

.music-panel.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.music-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.music-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent);
    letter-spacing: 2px;
}

.btn-small {
    background: none;
    border: none;
    color: var(--fg-dim);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.2s ease;
}

.btn-small:hover { color: var(--accent); }

.music-tracks {
    padding: 16px;
}

.track-info {
    margin-bottom: 12px;
}

.track-info span {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--fg);
}

.music-controls {
    display: flex;
    gap: 8px;
}

.strudel-code {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    max-height: 200px;
    overflow-y: auto;
    transition: all 0.3s ease;
}

.strudel-code.hidden { display: none; }

.strudel-code pre {
    margin: 0;
}

.strudel-code code {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.6;
    color: var(--accent);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ─── Footer ─── */
.footer {
    text-align: center;
    margin-top: 60px;
    padding: 24px 0;
}

.footer-line {
    display: block;
    color: var(--border);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    margin-bottom: 12px;
    letter-spacing: 4px;
}

.footer-text {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--fg-dim);
    opacity: 0.5;
    letter-spacing: 0.5px;
}

.footer-text a {
    color: var(--accent);
    text-decoration: none;
    opacity: 0.7;
}

.footer-text a:hover { opacity: 1; }

/* ─── Responsive ─── */
@media (max-width: 600px) {
    .container { padding: 16px 16px 32px; }
    .md-content h1 { font-size: 1.7rem; }
    .music-panel { right: 12px; bottom: 12px; width: calc(100% - 24px); }
    .top-actions { gap: 6px; }
    .btn-glow { padding: 6px 10px; font-size: 0.65rem; }
    .btn-glow span { display: none; }
}

/* ─── Selection ─── */
::selection {
    background: rgba(0, 255, 170, 0.2);
    color: var(--accent);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(0, 255, 170, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 255, 170, 0.4); }
