/* Chapter Page Styles - Claude Theme */

/* Page transition animation */
body {
    opacity: 1;
    transition: opacity 0.6s ease-in-out, transform 0.6s ease-in-out;
    transform: scale(1);
}

body.page-transitioning {
    opacity: 0;
    transform: scale(0.98);
}

.chapter-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 32px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 80px);
}

/* Sidebar */
.chapter-sidebar {
    position: sticky;
    top: 90px;
    height: fit-content;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.chapter-sidebar h3 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-orange);
}

.chapter-nav {
    list-style: none;
}

.chapter-nav li {
    margin-bottom: 4px;
}

.chapter-nav a {
    display: block;
    padding: 8px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s;
}

.chapter-nav a:hover,
.chapter-nav a.active {
    background-color: var(--bg-tertiary);
    color: var(--primary-orange);
}

.chapter-progress {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.chapter-progress h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-orange);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Main Content */
.chapter-content {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 40px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    max-width: 1000px;
    margin: 0 auto;
}

.chapter-header {
    margin-bottom: 48px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
}

.chapter-label {
    display: inline-block;
    background-color: var(--primary-orange);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.chapter-header h1 {
    font-size: 40px;
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 700;
}

.chapter-description {
    font-size: 18px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Content Sections */
.content-section {
    margin-bottom: 48px;
    scroll-margin-top: 100px;
}

.content-section h2 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-section h3 {
    font-size: 22px;
    color: var(--text-primary);
    margin: 24px 0 16px;
    font-weight: 600;
}

.content-section h4 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 20px 0 12px;
    font-weight: 600;
}

.content-section p {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 16px;
}

.content-section ul,
.content-section ol {
    margin: 16px 0;
    padding-left: 24px;
}

.content-section li {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 8px;
}

/* Info Boxes */
.info-box {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    border-left: 4px solid var(--primary-orange);
    padding: 20px;
    border-radius: 8px;
    margin: 24px 0;
}

.info-box p {
    margin-bottom: 12px;
}

.info-box p:last-child {
    margin-bottom: 0;
}

.behind-scenes-box {
    background-color: var(--bg-tertiary);
    border: 2px solid var(--primary-orange);
    padding: 24px;
    border-radius: 12px;
    margin: 24px 0;
}

.behind-scenes-box h3 {
    color: var(--primary-orange);
    margin-top: 0;
}

.example-box {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 20px;
    border-radius: 8px;
    margin: 24px 0;
    border: 1px solid var(--border-color);
}

.try-it-box {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 24px;
    border-radius: 12px;
    margin: 24px 0;
    border: 2px dashed var(--primary-orange);
}

.exercise-box {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    padding: 24px;
    border-radius: 12px;
    margin: 24px 0;
    border-left: 4px solid var(--primary-orange);
}

.exercise-intro {
    background-color: var(--bg-tertiary);
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    border-left: 3px solid var(--primary-orange);
}

.exercise-intro p {
    margin: 8px 0;
    font-size: 14px;
}

.exercise-box h4 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 24px 0 12px 0;
}

/* Legacy exercise box table styles removed to prevent conflict with result-table */

/* Code Elements */
code {
    background-color: var(--code-bg);
    color: var(--primary-orange);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
}

pre {
    background-color: var(--code-bg);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    position: relative;
}

pre code {
    background: none;
    padding: 0;
    color: var(--code-text);
}

/* Inline Code Editor */
.code-editor-inline {
    position: relative;
    margin: 16px 0;
}

.mini-editor {
    width: 100%;
    min-height: 40px;
    padding: 16px;
    background-color: var(--code-bg);
    color: var(--code-text);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: vertical;
    outline: none;
    overflow-y: auto;
    box-sizing: border-box;
}

.run-btn-mini {
    margin-top: 8px;
    background-color: var(--primary-orange);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
}

.run-btn-mini:hover {
    background-color: var(--primary-orange-hover);
    transform: translateY(-1px);
}

.output-box {
    background-color: var(--code-bg);
    color: var(--text-secondary);
    padding: 16px;
    border-radius: 8px;
    margin-top: 12px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    line-height: 1.6;
    min-height: 60px;
    white-space: pre-wrap;
    border: 1px solid var(--border-color);
}

.hint-btn {
    margin-top: 12px;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.hint-btn:hover {
    background-color: var(--primary-orange);
    color: white;
    border-color: var(--primary-orange);
}

.solution {
    margin-top: 12px;
    padding: 16px;
    background-color: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

/* Cards and Grids */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.info-card {
    background-color: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.info-card:hover {
    border-color: var(--primary-orange);
    box-shadow: var(--shadow-md);
}

.info-card h3 {
    margin-top: 0;
    font-size: 16px;
    color: var(--text-primary);
}

.info-card p {
    font-size: 14px;
    margin-bottom: 0;
}

/* Lists */
.feature-list li {
    padding-left: 24px;
    position: relative;
}

.feature-list li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary-orange);
    font-weight: bold;
}

.numbered-list {
    counter-reset: item;
    list-style: none;
    padding-left: 0;
}

.numbered-list li {
    counter-increment: item;
    padding-left: 36px;
    position: relative;
    margin-bottom: 16px;
}

.numbered-list li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 0;
    background-color: var(--primary-orange);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}

/* Execution Diagram */
.execution-diagram {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 24px 0;
}

.execution-step {
    background-color: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    position: relative;
}

.step-number {
    position: absolute;
    top: -12px;
    left: 20px;
    background-color: var(--primary-orange);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.execution-step h4 {
    margin-top: 8px;
    color: var(--text-primary);
}

.arrow {
    text-align: center;
    font-size: 24px;
    color: var(--primary-orange);
}

.code-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

.note {
    font-style: italic;
    color: var(--text-tertiary);
    font-size: 13px;
    margin-top: 12px;
}

/* Navigation */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 64px;
    padding-top: 32px;
    border-top: 2px solid var(--border-color);
}

.nav-btn {
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.prev-btn {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.next-btn {
    background-color: var(--primary-orange);
    color: white;
}

.prev-btn:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--primary-orange);
}

.next-btn:hover {
    background-color: var(--primary-orange-hover);
    transform: translateX(4px);
}

/* Video Resources - Minimalistic */
.video-list {
    margin: 24px 0;
}

.video-item {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
}

.video-item:last-child {
    border-bottom: none;
}

.video-content h4 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 6px 0;
}

.video-meta {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0 0 10px 0;
    font-style: italic;
}

.video-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 12px 0;
}

.video-link {
    color: var(--primary-orange);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.video-link:hover {
    color: var(--primary-orange-hover);
    text-decoration: underline;
}

/* AI Assistant Buttons - Dynamically Added to Code Blocks */
.ai-assistant-buttons {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

pre:hover .ai-assistant-buttons {
    opacity: 1;
}

.ai-quick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid;
    min-width: 36px;
    min-height: 36px;
}

/* All AI buttons - Consistent black and white theme */
.chatgpt-btn,
.claude-btn,
.google-btn {
    background: #000000;
    color: white;
    border-color: #333333;
}

.chatgpt-btn:hover,
.claude-btn:hover,
.google-btn:hover {
    background: #333333;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    text-decoration: none;
}

/* Make sure icons are white */
.ai-quick-btn svg,
.ai-quick-btn img {
    filter: brightness(0) invert(1);
}

.ai-quick-btn svg {
    flex-shrink: 0;
}

/* Dark theme adjustments for AI buttons */
[data-theme="dark"] .chatgpt-btn,
[data-theme="dark"] .claude-btn,
[data-theme="dark"] .google-btn {
    background: #FFFFFF;
    color: #000000;
    border-color: #CCCCCC;
}

[data-theme="dark"] .chatgpt-btn:hover,
[data-theme="dark"] .claude-btn:hover,
[data-theme="dark"] .google-btn:hover {
    background: #CCCCCC;
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .ai-quick-btn svg,
[data-theme="dark"] .ai-quick-btn img {
    filter: none;
}

/* Copy button for code blocks */
.copy-btn {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    z-index: 10;
}

pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--primary-orange);
    color: white;
    border-color: var(--primary-orange);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.copy-btn.copied {
    background: #27ae60;
    color: white;
}

.copy-btn svg {
    flex-shrink: 0;
}

/* Quiz Styles */
.quiz-container {
    margin: 2rem 0;
    padding: 0;
}

.quiz-question {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--text-tertiary);
    transition: border-color 0.3s ease;
}

.question-header {
    margin-bottom: 0.75rem;
}

.question-number {
    display: inline-block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quiz-question.correct {
    border-left-color: #10b981;
    background: var(--bg-secondary);
}

.quiz-question.incorrect {
    border-left-color: #ef4444;
    background: var(--bg-secondary);
}

.question-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

.quiz-option {
    display: flex;
    align-items: center;
    padding: 0.875rem 1.25rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-subtle);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quiz-option:hover {
    border-color: var(--primary-orange);
    transform: translateX(4px);
}

.quiz-option input[type="radio"] {
    margin-right: 0.75rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--primary-orange);
}

.quiz-option input[type="radio"]:disabled {
    cursor: not-allowed;
}

/* Highlight the selected option when correct */
.quiz-question.correct .quiz-option input[type="radio"]:checked {
    accent-color: #10b981;
    transform: scale(1.2);
}

.quiz-question.correct .quiz-option:has(input[type="radio"]:checked) {
    background: rgba(16, 185, 129, 0.15);
    border-color: #10b981;
}

.quiz-question.correct .quiz-option:has(input[type="radio"]:checked) .option-text {
    color: #10b981;
    font-weight: 600;
}

.option-text {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.quiz-feedback {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 6px;
    border: 1px solid;
}

.quiz-feedback.correct {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.quiz-feedback.incorrect {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.feedback-text {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9375rem;
}

.feedback-text.correct {
    color: #10b981;
}

.feedback-text.incorrect {
    color: #ef4444;
}

.explanation {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-style: italic;
    margin: 0;
    line-height: 1.6;
}

.quiz-results {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 968px) {
    .chapter-container {
        grid-template-columns: 1fr;
    }

    .chapter-sidebar {
        position: relative;
        top: 0;
    }

    .code-comparison {
        grid-template-columns: 1fr;
    }

    .chapter-navigation {
        flex-direction: column;
        gap: 12px;
    }

    .prompt-actions {
        flex-wrap: wrap;
    }

    .action-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 100px;
    }
}

/* OneNote-Style Curriculum Sidebar */
.curriculum-sidebar-chapter {
    position: sticky;
    top: 90px;
    width: 60px;
    height: fit-content;
    max-height: calc(100vh - 110px);
    overflow: visible;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.curriculum-sidebar-chapter:hover {
    width: 280px;
}

.curriculum-sidebar-chapter h3 {
    opacity: 0;
    height: 0;
    overflow: hidden;
    transition: opacity 0.3s;
}

.curriculum-sidebar-chapter:hover h3 {
    opacity: 1;
    height: auto;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    padding: 0 8px 12px;
    border-bottom: 2px solid var(--primary-orange);
}

.curriculum-chapters {
    list-style: none;
}

.curriculum-chapters>li {
    margin-bottom: 4px;
    position: relative;
}

.chapter-item-header {
    display: flex;
    align-items: center;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    text-decoration: none;
    overflow: hidden;
    position: relative;
}

.chapter-item-header:hover {
    background: var(--bg-primary);
    color: var(--primary-orange);
}

.chapter-item-header.active {
    background: var(--primary-orange);
    color: white;
}

.chapter-item-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chapter-item-num {
    background: var(--primary-orange);
    color: white;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 6px;
    min-width: 42px;
    text-align: center;
    flex-shrink: 0;
    transition: all 0.3s;
}

.chapter-item-header.active .chapter-item-num {
    background: white;
    color: var(--primary-orange);
}

.chapter-item-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.curriculum-sidebar-chapter:hover .chapter-item-name {
    opacity: 1;
    transform: translateX(0);
}

.chapter-expand-icon {
    font-size: 12px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-left: auto;
}

.curriculum-sidebar-chapter:hover .chapter-expand-icon {
    opacity: 1;
    transform: translateX(0);
}

.chapter-item-header.expanded .chapter-expand-icon {
    transform: rotate(180deg);
}

.chapter-subnav {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), padding 0.5s;
    padding-left: 0;
    margin-left: 10px;
}

.chapter-subnav.expanded {
    max-height: 1000px;
    padding-top: 12px;
}

.chapter-subnav li {
    margin-bottom: 3px;
    opacity: 0;
    transform: translateY(-5px);
    animation: slideIn 0.4s ease forwards;
}

.chapter-subnav.expanded li:nth-child(1) {
    animation-delay: 0.05s;
}

.chapter-subnav.expanded li:nth-child(2) {
    animation-delay: 0.1s;
}

.chapter-subnav.expanded li:nth-child(3) {
    animation-delay: 0.15s;
}

.chapter-subnav.expanded li:nth-child(4) {
    animation-delay: 0.2s;
}

.chapter-subnav.expanded li:nth-child(5) {
    animation-delay: 0.25s;
}

.chapter-subnav.expanded li:nth-child(6) {
    animation-delay: 0.3s;
}

.chapter-subnav.expanded li:nth-child(7) {
    animation-delay: 0.35s;
}

.chapter-subnav.expanded li:nth-child(8) {
    animation-delay: 0.4s;
}

.chapter-subnav.expanded li:nth-child(9) {
    animation-delay: 0.45s;
}

.chapter-subnav.expanded li:nth-child(10) {
    animation-delay: 0.5s;
}

@keyframes slideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chapter-subnav a {
    display: block;
    padding: 9px 12px 9px 50px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border-left: 3px solid transparent;
}

.chapter-subnav a::before {
    content: '';
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 5px;
    height: 5px;
    background: var(--text-secondary);
    border-radius: 50%;
    opacity: 0.5;
    transition: all 0.3s;
}

.chapter-subnav a:hover {
    background: var(--bg-tertiary);
    color: var(--primary-orange);
    border-left-color: var(--primary-orange);
    padding-left: 54px;
}

.chapter-subnav a:hover::before {
    background: var(--primary-orange);
    opacity: 1;
    width: 7px;
    height: 7px;
}

.chapter-subnav a.active {
    background: linear-gradient(90deg, var(--bg-tertiary) 0%, transparent 100%);
    color: var(--primary-orange);
    font-weight: 600;
    border-left-color: var(--primary-orange);
}

.chapter-subnav a.active::before {
    background: var(--primary-orange);
    opacity: 1;
    width: 7px;
    height: 7px;
}

/* Update chapter container */
.chapter-container-with-curriculum {
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 32px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 80px);
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-container-with-curriculum:has(.curriculum-sidebar-chapter:hover) {
    grid-template-columns: 280px 1fr;
}

@media (max-width: 1200px) {
    .curriculum-sidebar-chapter {
        width: 50px;
    }

    .curriculum-sidebar-chapter:hover {
        width: 240px;
    }

    .chapter-container-with-curriculum:has(.curriculum-sidebar-chapter:hover) {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 968px) {
    .curriculum-sidebar-chapter {
        width: 100%;
        position: relative;
        top: 0;
        max-height: none;
    }

    .curriculum-sidebar-chapter h3 {
        opacity: 1;
        height: auto;
    }

    .chapter-item-name,
    .chapter-expand-icon {
        opacity: 1;
        transform: translateX(0);
    }

    .chapter-container-with-curriculum {
        grid-template-columns: 1fr;
    }
}

/* Unified Sidebar Layout */
.chapter-container-unified {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 32px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 80px);
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-container-unified:has(.unified-sidebar:hover) {
    grid-template-columns: 350px 1fr;
}

.unified-sidebar {
    position: sticky;
    top: 90px;
    height: calc(100vh - 120px);
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    overflow: hidden;
    width: 80px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
}

.unified-sidebar:hover {
    width: 350px;
}

/* Sidebar Strip (Left Column) */
.sidebar-strip {
    width: 80px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    gap: 12px;
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: none;
    /* Hide scrollbar for clean look */
}

.sidebar-strip::-webkit-scrollbar {
    display: none;
}

.strip-item {
    width: 50px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s;
}

.strip-item:hover {
    background-color: var(--bg-primary);
    color: var(--primary-orange);
    transform: scale(1.05);
}

.strip-item.active {
    background-color: var(--primary-orange);
    color: white;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

/* Sidebar Panel (Right Column) */
.sidebar-panel {
    flex: 1;
    min-width: 270px;
    padding: 24px;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s 0.1s;
    /* Delay to wait for expansion start */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.unified-sidebar:hover .sidebar-panel {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-panel h3 {
    white-space: nowrap;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-orange);
}

.sidebar-panel .chapter-nav {
    margin-bottom: auto;
    /* Push progress to bottom if plenty of space */
}

/* Responsive adjustments */
@media (max-width: 968px) {
    .chapter-container-unified {
        grid-template-columns: 1fr;
    }

    .unified-sidebar {
        display: none;
        /* Mobile handling might need different approach or burger menu */
    }
}

/* Hybrid Layout (3 Columns: Curriculum | Chapter Nav | Content) */
.chapter-container-hybrid {
    display: grid;
    grid-template-columns: 60px 250px minmax(0, 1fr);
    /* Fix: content containment */
    gap: 32px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 80px);
    transition: grid-template-columns 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chapter-container-hybrid:has(.curriculum-sidebar-chapter:hover) {
    grid-template-columns: 280px minmax(0, 1fr);
    /* Fix: content containment */
}

/* Hide chapter sidebar when curriculum is hovered */
.chapter-container-hybrid:has(.curriculum-sidebar-chapter:hover) .chapter-sidebar {
    display: none;
}

@media (max-width: 1200px) {
    .chapter-container-hybrid {
        grid-template-columns: 50px 200px minmax(0, 1fr);
    }

    .chapter-container-hybrid:has(.curriculum-sidebar-chapter:hover) {
        grid-template-columns: 240px 200px minmax(0, 1fr);
    }
}

@media (max-width: 968px) {}

/* Wrapper Layout (Single Header Hybrid) */
/* Wrapper Layout (Single Header Hybrid) */
.chapter-container-wrapper {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    /* Fix: Allows content to shrink and scroll */
    /* Fixed sidebar width to prevent jumping */
    gap: 32px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 80px);
}

.sidebar-wrapper {
    position: sticky;
    top: 90px;
    height: fit-content;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 10;
}

.sidebar-wrapper h3 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-orange);
}

.sidebar-content-row {
    display: flex;
    gap: 16px;
    position: relative;
    min-height: 400px;
    /* Ensure space for content */
}

/* Adjust components inside wrapper */
.sidebar-wrapper .curriculum-sidebar-chapter {
    position: static;
    top: auto;
    height: auto;
    max-height: calc(100vh - 200px);
    border: none;
    background: transparent;
    padding: 0;
    box-shadow: none;
    flex-shrink: 0;
}

.chapter-nav-panel {
    width: 200px;
    transition: opacity 0.3s, transform 0.3s;
    flex-shrink: 0;
}

/* Hide Nav Panel when Curriculum expands */
.sidebar-wrapper:has(.curriculum-sidebar-chapter:hover) .chapter-nav-panel {
    opacity: 0;
    transform: translateX(10px);
    pointer-events: none;
}

/* Responsive */
@media (max-width: 1100px) {
    .chapter-container-wrapper {
        grid-template-columns: 80px minmax(0, 1fr);
    }

    .sidebar-wrapper {
        padding: 12px;
        width: 80px;
        overflow: hidden;
    }

    .sidebar-wrapper:hover {
        width: 350px;
        overflow: visible;
    }

    .chapter-nav-panel {
        display: none;
        /* Hide nav on smaller screens or handle differently */
    }
}

/* Result Table Styles */
.output-box.table-mode {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    overflow: hidden;
    line-height: 0;
    /* Kill ghost space */
    font-size: 0;
    /* Kill ghost space */
}

.result-table-wrapper {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    margin-top: 0;
    /* Prevent layout expansion */
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Scroll container for the table */
.table-scroll-container {
    overflow: auto;
    width: 100%;
    max-height: 450px;
    position: relative;
    scrollbar-color: var(--primary-orange) var(--bg-primary);
}

.table-scroll-container::-webkit-scrollbar-corner {
    background-color: var(--bg-primary);
}

.result-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
    line-height: 1.5;
    /* Restore readable line height */
    margin-bottom: 0;
}

.result-table th,
.result-table td {
    padding: 6px 12px;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

/* Sticky Header */
.result-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--bg-tertiary);
    /* Needs opacity to cover scrolling content */
    border-top: none;
    /* Container has border */
    box-shadow: 0 1px 0 var(--border-color);
    /* Separator line that sticks */
}

/* Sticky Footer (Result Info) */
.result-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    padding: 0;
    /* Let inner div handle padding if needed, or keep it here */
}

/* Remove side borders for first/last cells */
.result-table tr th:first-child,
.result-table tr td:first-child {
    border-left: none;
}

.result-table tr th:last-child,
.result-table tr td:last-child {
    border-right: none;
}

.result-table th {
    color: var(--primary-orange);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.result-table td {
    color: var(--text-secondary);
}

.result-table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

.result-table tbody tr:hover {
    background-color: rgba(255, 107, 53, 0.05);
}

.null-value {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 12px;
}

.result-info {
    font-size: 12px;
    color: var(--text-tertiary);
    text-align: left;
    padding: 8px 12px;
    font-style: italic;
    width: 100%;
    /* Ensure it spans */
    box-sizing: border-box;
    position: sticky;
    /* Double stickyness for safety */
    left: 0;
}

.success-message {
    color: #10b981;
    font-weight: 500;
    padding: 16px;
}