:root {
    --bg-color: #050505;
    --panel-bg: rgba(14, 14, 20, 0.78);
    --panel-border: rgba(255, 255, 255, 0.08);
    --accent-cyan: #00f3ff;
    --accent-gold: #ffca5f;
    --text-main: #f0f3f6;
    --text-dim: #8f98a3;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: 'Rajdhani', 'Noto Sans SC', sans-serif;
    overflow: hidden;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(rgba(0, 243, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 243, 255, 0.03) 1px, transparent 1px);
    background-size: 56px 56px;
    transform: perspective(600px) rotateX(60deg) translateY(-120px) translateZ(-220px);
    z-index: -2;
    animation: grid-move 18s linear infinite;
}

@keyframes grid-move {
    0% { transform: perspective(600px) rotateX(60deg) translateY(0) translateZ(-220px); }
    100% { transform: perspective(600px) rotateX(60deg) translateY(64px) translateZ(-220px); }
}

.scanline {
    position: fixed;
    inset: 0;
    background: linear-gradient(to bottom, transparent 50%, rgba(0, 0, 0, 0.35) 51%);
    background-size: 100% 4px;
    pointer-events: none;
    opacity: 0.15;
    z-index: 10;
}

.course-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    width: min(1680px, calc(100vw - 32px));
    height: calc(100vh - 32px);
    margin: 16px auto;
}

.course-sidebar,
.course-stage {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(14px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.34);
}

.course-sidebar {
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.sidebar-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-cyan);
    text-decoration: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
}

.sidebar-header {
    margin-top: 18px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border: 1px solid rgba(0, 243, 255, 0.2);
    background: rgba(0, 243, 255, 0.06);
    color: var(--accent-cyan);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.08em;
}

.sidebar-header h1,
.stage-header h2 {
    margin: 14px 0 10px;
}

.sidebar-header p,
.stage-header p {
    margin: 0;
    color: var(--text-dim);
    line-height: 1.6;
}

.course-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    overflow: auto;
    padding-right: 4px;
}

.chapter-link {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    width: 100%;
    padding: 14px 14px 14px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: 0.22s ease;
}

.chapter-link:hover,
.chapter-link.active {
    border-color: rgba(0, 243, 255, 0.26);
    background: rgba(0, 243, 255, 0.08);
    transform: translateY(-1px);
}

.chapter-index {
    color: var(--accent-gold);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.chapter-copy strong {
    display: block;
    font-size: 1.05rem;
}

.chapter-copy small {
    display: block;
    margin-top: 6px;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.5;
}

.course-stage {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: 22px;
}

.stage-header {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: start;
    margin-bottom: 18px;
}

#stage-hint {
    max-width: 420px;
}

.stage-frame-shell {
    min-height: 0;
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.24);
    overflow: hidden;
}

#stage-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
}

@media (max-width: 1100px) {
    body {
        overflow: auto;
    }

    .course-shell {
        grid-template-columns: 1fr;
        height: auto;
    }

    .course-stage {
        min-height: 72vh;
    }

    .stage-header {
        flex-direction: column;
    }

    #stage-hint {
        max-width: none;
    }
}
