:root {
    --bg-1: #070A0F;
    --bg-2: #04050A;
    --surface: #111822;
    --elev: #18212D;
    --mint: #75F0B7;
    --cyan: #74C7F8;
    --amber: #F8C96B;
    --rose: #F08A9B;
    --violet: #A78BFA;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.72);
    --text-tertiary: rgba(255, 255, 255, 0.48);
    --hair: rgba(255, 255, 255, 0.10);
    --radius: 14px;
}

* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    font-family: Inter, -apple-system, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
    -webkit-font-smoothing: antialiased;
    background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
    color: var(--text-primary);
    padding: 20px 16px;
}

.app {
    max-width: 980px;
    margin: 0 auto
}

/* ambient glow */
body::before {
    content: '';
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 40vh;
    pointer-events: none;
    background: radial-gradient(800px 200px at 50% 10%, rgba(117, 240, 183, 0.06), rgba(116, 199, 248, 0.04), transparent 40%);
    mix-blend-mode: screen;
    z-index: 0
}

.app-header {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 8px 20px;
    position: relative;
    z-index: 2
}

.app-title h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0.4px
}

.subtitle {
    margin: 2px 0 0;
    color: var(--text-secondary);
    font-size: 13px
}

.intro {
    margin: 8px 0 0;
    color: var(--text-tertiary);
    font-size: 13px
}

.header-controls {
    display: flex;
    flex-direction: column;
    gap: 8px
}

/* learning mode */
.learning-mode {
    position: relative;
    display: inline-block
}

.mode-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid var(--hair);
    padding: 8px 10px;
    border-radius: 999px;
    color: var(--text-primary);
    backdrop-filter: blur(6px)
}

.mode-button .icon {
    opacity: 0.95
}

.mode-menu {
    display: none;
    position: absolute;
    right: 0;
    margin-top: 8px;
    background: var(--surface);
    border: 1px solid var(--hair);
    padding: 6px;
    border-radius: 10px;
    min-width: 160px
}

.mode-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px;
    border: 0;
    background: transparent;
    color: var(--text-primary)
}

.mode-menu button:hover {
    background: rgba(255, 255, 255, 0.02)
}

.learning-mode.open .mode-menu {
    display: block
}

/* stage rail */
.stage-rail {
    display: flex;
    gap: 8px;
    overflow: auto;
    padding: 10px 6px;
    margin: 8px 0 14px
}

.stage-chip {
    flex: 0 0 auto;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--hair);
    color: var(--text-primary);
    font-weight: 600
}

.stage-chip:active {
    transform: scale(.98)
}

/* timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-bottom: 36px
}

.stage-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--hair);
    border-radius: var(--radius);
    padding: 12px;
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.6);
    transition: transform .18s ease, box-shadow .18s ease
}

.stage-card:hover {
    transform: translateY(-6px)
}

.stage-header {
    display: flex;
    align-items: center;
    gap: 12px
}

.stage-badge {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    border: 1px solid rgba(255, 255, 255, 0.04);
    font-weight: 700
}

.stage-badge .num {
    font-size: 15px
}

.stage-meta h2 {
    margin: 0;
    font-size: 16px
}

.stage-sub {
    color: var(--text-secondary);
    font-size: 13px
}

.stage-toggle {
    margin-left: auto;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: 8px
}

.stage-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.06)
}

.stage-content {
    overflow: hidden;
    max-height: 0;
    transition: max-height .36s ease;
    padding-top: 0
}

.stage-card.expanded .stage-content {
    padding-top: 12px
}

.section {
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.02)
}

.section-head {
    display: flex;
    gap: 12px;
    align-items: center
}

.s-icon {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #071018;
    font-weight: 700
}

.section-body {
    margin-top: 8px;
    color: var(--text-secondary)
}

.media-placeholder {
    height: 140px;
    border-radius: 10px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary)
}

.env-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 8px;
    margin-top: 10px
}

.env-card {
    background: rgba(255, 255, 255, 0.02);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 6px
}

.env-icon {
    font-weight: 700
}

.env-name {
    font-weight: 600
}

.env-range {
    color: var(--text-tertiary);
    font-size: 13px
}

progress {
    height: 6px;
    border-radius: 6px;
    appearance: none
}

progress::-webkit-progress-bar {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px
}

progress::-webkit-progress-value {
    background: linear-gradient(90deg, var(--mint), var(--cyan));
    border-radius: 6px
}

.app-footer {
    position: sticky;
    bottom: 12px;
    padding-top: 12px
}

.mini-nav {
    display: flex;
    gap: 8px;
    justify-content: center
}

.mini-nav button {
    background: transparent;
    border: 1px solid var(--hair);
    padding: 8px 10px;
    border-radius: 999px;
    color: var(--text-primary)
}

/* mode-aware visibility */
body[data-mode='beginner'] .section[data-depth='intermediate'],
body[data-mode='beginner'] .section[data-depth='advanced'] {
    display: none
}

body[data-mode='intermediate'] .section[data-depth='advanced'] {
    display: none
}

@media(min-width:900px) {
    body {
        padding: 28px
    }

    .app {
        max-width: 1100px
    }

    .env-grid {
        grid-template-columns: repeat(2, 1fr)
    }
}