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

:root {
    --bg-dark: #0d1117;
    --bg-card: #161b22;
    --bg-hover: #21262d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-green: #3fb950;
    --accent-orange: #d29922;
    --border: #30363d;
    --code-bg: #0d1117;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-brand h1 span {
    color: var(--accent);
}

.tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Layout */
.page-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* Sidebar */
#sidebar-nav {
    width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    overflow-y: auto;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
}

.nav-part {
    margin-bottom: 24px;
}

.nav-part-title {
    padding: 8px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-section {
    display: block;
    padding: 10px 20px 10px 32px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 2px solid transparent;
    transition: all 0.15s;
}

.nav-section:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-section.active {
    background: var(--bg-hover);
    color: var(--accent);
    border-left-color: var(--accent);
}

.nav-section.completed {
    color: var(--accent-green);
}

.nav-section.locked {
    color: var(--text-muted);
    cursor: not-allowed;
}

.nav-section .icon {
    margin-right: 8px;
}

/* Main content */
main {
    flex: 1;
    padding: 40px;
    max-width: 900px;
}

/* Sections */
section {
    display: none;
}

section.active {
    display: block;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.card h2 {
    font-size: 1.5rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.card h2 .icon {
    font-size: 1.25rem;
}

/* Lesson content */
.lesson-intro {
    margin-bottom: 24px;
}

.lesson-intro p {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.lesson-intro strong {
    color: var(--text-primary);
}

.lesson-intro code {
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

/* Code blocks */
pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 16px 0;
}

pre code {
    background: none;
    padding: 0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Info boxes */
.info-box {
    background: rgba(88, 166, 255, 0.1);
    border: 1px solid rgba(88, 166, 255, 0.3);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.info-box strong {
    color: var(--accent);
}

.warning-box {
    background: rgba(210, 153, 34, 0.1);
    border: 1px solid rgba(210, 153, 34, 0.3);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.warning-box strong {
    color: var(--accent-orange);
}

/* Interactive widgets */
.widget {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin: 24px 0;
}

.widget-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Request inspector widget */
.request-input {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.request-input input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 1rem;
}

.request-input input:focus {
    outline: none;
    border-color: var(--accent);
}

.request-input button {
    background: var(--accent);
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    color: #fff;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.request-input button:hover {
    opacity: 0.9;
}

.request-output {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.request-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.request-panel-header {
    background: var(--bg-hover);
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.request-panel-body {
    padding: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

/* Quiz */
.quiz {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.quiz-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.quiz-question {
    margin-bottom: 24px;
}

.quiz-question p {
    margin-bottom: 12px;
    color: var(--text-primary);
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.quiz-option:hover {
    border-color: var(--accent);
}

.quiz-option.selected {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.1);
}

.quiz-option.correct {
    border-color: var(--accent-green);
    background: rgba(63, 185, 80, 0.1);
}

.quiz-option.incorrect {
    border-color: #f85149;
    background: rgba(248, 81, 73, 0.1);
}

.quiz-option input {
    display: none;
}

.quiz-check {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-option.selected .quiz-check {
    border-color: var(--accent);
    background: var(--accent);
}

.quiz-submit {
    margin-top: 16px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    padding: 12px 24px;
    color: #fff;
    font-weight: 500;
    cursor: pointer;
}

.quiz-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Page timing */
#page-timing {
    position: fixed;
    bottom: 8px;
    right: 8px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: monospace;
}

/* Expandable sections */
.expand-section {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
}

.expand-section summary {
    padding: 14px 18px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: color 0.15s;
}

.expand-section summary::-webkit-details-marker {
    display: none;
}

.expand-section summary::before {
    content: '▶';
    font-size: 0.7em;
    transition: transform 0.15s;
}

.expand-section[open] summary::before {
    transform: rotate(90deg);
}

.expand-section summary:hover {
    color: var(--text-primary);
}

.expand-content {
    padding: 0 18px 18px 18px;
    color: var(--text-secondary);
}

.expand-content p {
    margin-bottom: 12px;
}

.expand-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.expand-content li {
    margin-bottom: 6px;
}

.expand-content code {
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

/* Step detail panel */
.step-detail {
    background: var(--bg-dark);
    border: 2px solid var(--accent);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.step-detail-header span {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--accent);
}

#step-detail-content {
    color: var(--text-secondary);
    line-height: 1.7;
}

#step-detail-content code {
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: var(--accent);
}

#step-detail-content pre {
    margin: 12px 0;
}

/* Responsive */
@media (max-width: 900px) {
    .page-layout {
        flex-direction: column;
    }

    #sidebar-nav {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
    }

    main {
        padding: 20px;
    }

    .request-output {
        grid-template-columns: 1fr;
    }
}
