/* ==========================================================================
   ML Formation Styles
   Following Sotis AI Design System
   ========================================================================== */

/* Container */
.mlformation-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: var(--space-md);
    overflow-x: hidden;
}

/* Header uses global .page-header from style.css */

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Sync YAML Button - Fixed position bottom right (same as portfolio) */
.sync-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    color: var(--violet-dark);
    border: 1px solid var(--violet-dark);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
    z-index: 100;
    opacity: 0.7;
}

.sync-btn:hover {
    background: var(--violet-dark);
    color: white;
    opacity: 1;
}

.sync-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.sync-result {
    position: fixed;
    bottom: 4.5rem;
    right: 2rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: none;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.sync-result.success {
    display: block;
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.sync-result.error {
    display: block;
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

/* Filters Section */
.filters-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    max-width: 100%;
    overflow-x: hidden;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-xs);
    max-width: 100%;
}

.filter-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: var(--space-xs);
    min-width: 80px;
}

.filter-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--violet-light);
    border-color: var(--violet-primary);
}

.filter-btn.active {
    background: var(--violet-dark);
    color: var(--white);
    border-color: var(--violet-dark);
}

/* Modules Grid */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-md);
}

.module-card {
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition-base);
}

.module-card:hover {
    border-color: var(--violet-primary);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.module-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.module-category {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.module-title {
    margin: 0 0 var(--space-xs);
    font-size: 1.2rem;
    color: var(--violet-dark);
}

.module-description {
    flex: 1;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: var(--space-sm);
}

.module-meta {
    display: flex;
    gap: var(--space-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.no-modules {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-lg);
    color: var(--text-secondary);
}

/* Difficulty Badges */
.module-difficulty,
.difficulty-beginner,
.difficulty-intermediate,
.difficulty-advanced {
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.difficulty-beginner {
    background: #d4edda;
    color: #155724;
}

.difficulty-intermediate {
    background: #fff3cd;
    color: #856404;
}

.difficulty-advanced {
    background: #f8d7da;
    color: #721c24;
}

/* Module Detail Header - Style Portfolio */
.module-header {
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--violet-dark);
    border-radius: var(--radius-md);
    position: static;
    box-shadow: none;
}

.module-header h1 {
    font-size: 2.2rem;
    color: var(--white);
    margin-bottom: var(--space-xs);
    line-height: 1.2;
}

.module-header .module-description {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    margin-bottom: var(--space-sm);
}

.module-breadcrumb {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: var(--space-sm);
}

.module-breadcrumb a {
    color: var(--white);
    text-decoration: none;
}

.module-breadcrumb a:hover {
    text-decoration: underline;
}

.module-breadcrumb span {
    color: rgba(255, 255, 255, 0.6);
}

.module-meta-header {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin: var(--space-sm) 0;
    align-items: center;
}

.module-duration,
.module-sections-count {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Downloads - on violet background */
.module-downloads {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.btn-download:hover {
    background: var(--white);
    color: var(--violet-dark);
    border-color: var(--white);
}

/* Learning Objectives & Prerequisites */
.learning-objectives,
.prerequisites {
    background: var(--card-bg);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border-color);
}

.learning-objectives h2,
.prerequisites h2 {
    font-size: 1.1rem;
    color: var(--violet-dark);
    margin-bottom: var(--space-sm);
}

.objectives-content {
    color: var(--text-secondary);
}

/* Notebook Cells */
.notebook-cells {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.cell {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.cell-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.cell-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
}

.cell-type-badge {
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cell-type-badge.theory {
    background: var(--violet-light);
    color: var(--violet-dark);
}

.cell-type-badge.code {
    background: #e3f2fd;
    color: #1565c0;
}

.cell-type-badge.exercise {
    background: #fff3cd;
    color: #856404;
}

.cell-type-badge.advanced {
    background: #f3e5f5;
    color: #7b1fa2;
}

.cell-content {
    padding: var(--space-md);
    line-height: 1.7;
}

/* ==========================================================================
   Markdown Content Styles
   ========================================================================== */

.markdown-content {
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.markdown-content p {
    margin: 0 0 1em;
    color: var(--text-primary);
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

/* Subheaders (lines ending with :) */
.markdown-content .md-subheader {
    font-weight: 600;
    color: var(--violet-dark);
    margin: 1.5em 0 0.5em;
    font-size: 1.05em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
}

.markdown-content .md-subheader:first-child {
    margin-top: 0;
}

/* Bold text */
.markdown-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Lists */
.markdown-content .md-list {
    margin: 0.5em 0 1em;
    padding-left: 1.5em;
}

.markdown-content .md-list li {
    margin: 0.4em 0;
    color: var(--text-primary);
    position: relative;
}

.markdown-content ul.md-list {
    list-style: none;
}

.markdown-content ul.md-list li::before {
    content: '';
    position: absolute;
    left: -1.2em;
    top: 0.55em;
    width: 6px;
    height: 6px;
    background: var(--violet-dark);
    border-radius: 50%;
}

.markdown-content ol.md-list {
    list-style: decimal;
}

.markdown-content ol.md-list li::marker {
    color: var(--violet-dark);
    font-weight: 600;
}

/* Markdown Tables - Responsive wrapper */
.markdown-content .md-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 1em 0;
    -webkit-overflow-scrolling: touch;
}

.markdown-content .md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    margin: 0;
}

.markdown-content .md-table th,
.markdown-content .md-table td {
    padding: 0.75em 1em;
    text-align: left;
    border: 1px solid var(--border-color);
}

.markdown-content .md-table th {
    background: var(--violet-light);
    color: var(--violet-dark);
    font-weight: 600;
}

.markdown-content .md-table tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.markdown-content .md-table tbody tr:hover {
    background: rgba(192, 156, 240, 0.1);
}

/* Dark mode table adjustments */
[data-theme="dark"] .markdown-content .md-table th {
    background: rgba(155, 122, 196, 0.3);
    color: var(--violet-light);
}

[data-theme="dark"] .markdown-content .md-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .markdown-content .md-table tbody tr:hover {
    background: rgba(192, 156, 240, 0.15);
}

/* Horizontal separator */
.markdown-content .md-separator {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--violet-primary), transparent);
    margin: var(--space-md) 0;
    opacity: 0.6;
}

.overview-tab-panel .md-separator {
    margin: var(--space-sm) 0;
}

/* Inline code */
.markdown-content .md-inline-code {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.9em;
    color: var(--violet-dark);
}

/* Dark mode adjustments */
[data-theme="dark"] .markdown-content .md-inline-code {
    background: #2d2d2d;
    border-color: #444;
}

/* Code blocks (inline code examples in theory) */
.markdown-content .md-code-block {
    background: #1e1e1e;
    border: 1px solid #3a3a3a;
    border-radius: var(--radius-sm);
    padding: 1em 1.5em;
    margin: 1em 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9em;
    line-height: 1.5;
    color: #d4d4d4;
    white-space: pre;
    tab-size: 4;
}

.markdown-content .md-code-block code {
    background: transparent;
    border: none;
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    white-space: pre;
    display: block;
}

/* Light mode code blocks */
[data-theme="light"] .markdown-content .md-code-block {
    background: #f5f5f5;
    border-color: #ddd;
    color: #333;
}

/* KaTeX Math Formulas */
.markdown-content .katex-display {
    margin: 1em 0;
    padding: 0.5em;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.markdown-content .katex {
    font-size: 1.1em;
}

/* ==========================================================================
   Mermaid Diagrams
   ========================================================================== */

.mermaid {
    display: block;
    margin: 1.5em 0;
    padding: 1em;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    max-width: 100%;
}

/* Dark theme adjustments for Mermaid */
[data-theme="dark"] .mermaid {
    background: #2d2d2d;
}

/* Ensure Mermaid SVG scales properly */
.mermaid svg {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Mermaid node text styling */
.mermaid .nodeLabel {
    font-family: inherit;
}

/* Mermaid edge labels */
.mermaid .edgeLabel {
    background: var(--card-bg);
    padding: 0.2em 0.4em;
    border-radius: 4px;
}

/* Hide empty edge labels (arrows without text) */
.mermaid .edgeLabel:empty,
.mermaid .edgeLabel span:empty {
    display: none;
}

/* Code Editor */
.code-cell {
    display: flex;
    flex-direction: column;
}

.code-editor {
    position: relative;
    background: #1e1e1e;
}

/* ContentEditable Code Editor */
.code-editable {
    width: 100%;
    min-height: 150px;
    max-height: 300px;
    box-sizing: border-box;
    margin: 0;
    padding: 12px;
    border: none;
    background: transparent;
    color: #d4d4d4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
    -moz-tab-size: 4;
    overflow: auto;
    caret-color: #fff;
}

.code-editable::selection {
    background: rgba(192, 156, 240, 0.4);
}

.code-editable:focus {
    outline: 2px solid var(--violet-primary);
    outline-offset: -2px;
}

/* Expanded state */
.code-editable.expanded {
    max-height: none;
}

/* Ensure Highlight.js spans don't break the layout */
.code-editable span {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Code Toolbar - contains copy and expand buttons */
.code-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--transition-fast);
    z-index: 10;
}

.code-editor:hover .code-toolbar {
    opacity: 1;
}

.code-toolbar-btn {
    padding: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.code-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border-color: rgba(255, 255, 255, 0.4);
}

.code-toolbar-btn.copied {
    background: #155724;
    border-color: #155724;
    color: var(--white);
}

.code-toolbar-btn svg {
    display: block;
}

/* Expand button active state */
.expand-icon.expanded {
    background: var(--violet-dark);
    border-color: var(--violet-dark);
    color: var(--white);
}

/* Legacy Copy Icon - for solution wrapper */
.copy-icon:not(.code-toolbar-btn) {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    opacity: 0;
    transition: var(--transition-fast);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.solution-wrapper:hover .copy-icon:not(.code-toolbar-btn) {
    opacity: 1;
}

.copy-icon:not(.code-toolbar-btn):hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border-color: rgba(255, 255, 255, 0.4);
}

.copy-icon:not(.code-toolbar-btn).copied {
    background: #155724;
    border-color: #155724;
    color: var(--white);
}

.copy-icon:not(.code-toolbar-btn) svg {
    display: block;
}


.code-actions {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.btn-run,
.btn-reset,
.btn-copy {
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-run {
    background: var(--violet-dark);
    color: var(--white);
    border: none;
    font-weight: 500;
}

.btn-run:hover {
    background: var(--violet-primary);
}

.btn-reset,
.btn-copy {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-reset:hover,
.btn-copy:hover {
    background: var(--bg-secondary);
    border-color: var(--violet-primary);
    color: var(--violet-dark);
}

/* Code Output */
.code-output {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    min-height: 50px;
}

.output-placeholder {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
}

.code-output pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9rem;
    line-height: 1.5;
}

.code-output .stdout {
    color: var(--text-primary);
    background: #f5f5f5;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
}

[data-theme="dark"] .code-output .stdout {
    background: #2d2d2d;
}

.code-output .error {
    color: #dc3545;
    background: #fff5f5;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    border-left: 3px solid #dc3545;
}

[data-theme="dark"] .code-output .error {
    background: #3d2020;
}

.code-output .figures {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.code-output .figures img {
    max-width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--white);
}

.exec-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: var(--space-xs);
}

.no-output {
    color: var(--text-secondary);
    font-style: italic;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--violet-dark);
    font-weight: 500;
}

.loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--violet-light);
    border-top-color: var(--violet-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Advanced (Collapsible) Section */
.advanced-section {
    background: var(--card-bg);
    border: 1px dashed var(--violet-light);
    border-radius: var(--radius-md);
}

.advanced-section summary {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 500;
    list-style: none;
}

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

.advanced-section summary::before {
    content: '+';
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--violet-dark);
    margin-right: var(--space-xs);
}

.advanced-section[open] summary::before {
    content: '-';
}

.advanced-section summary:hover {
    background: var(--violet-dark);
}

.advanced-section summary:hover::before {
    color: var(--violet-light);
}

.advanced-section .cell-content {
    border-top: 1px solid var(--border-color);
}

/* Exercise Hint - Fixed colors (no theme change) */
.exercise-hint {
    padding: var(--space-xs) var(--space-sm);
    background: #fff3cd;
    border-top: 1px solid #ffc107;
}

.exercise-hint summary {
    cursor: pointer;
    color: #856404;
    font-weight: 500;
    font-size: 0.9rem;
}

.exercise-hint p {
    margin: var(--space-xs) 0 0;
    color: #664d03;
}

/* Exercise Solution - Fixed colors (no theme change) */
.exercise-solution {
    padding: var(--space-xs) var(--space-sm);
    background: #d4edda;
    border-top: 1px solid #28a745;
}

.exercise-solution summary {
    cursor: pointer;
    color: #155724;
    font-weight: 500;
    font-size: 0.9rem;
}

.exercise-solution .solution-wrapper {
    position: relative;
    margin: var(--space-xs) 0 0;
}

.exercise-solution .solution-code {
    margin: 0;
    padding: var(--space-sm);
    padding-right: 40px;
    background: #1e1e1e;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.exercise-solution .solution-code code {
    color: #d4d4d4;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre;
}

/* Module Navigation */
.module-nav {
    margin-top: var(--space-lg);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.nav-back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--violet-dark);
    text-decoration: none;
    font-weight: 500;
}

.nav-back:hover {
    text-decoration: underline;
}

.nav-back::before {
    content: '<-';
}

/* ==========================================================================
   DataFrame Tables (from display() function)
   ========================================================================== */

.dataframe-container {
    margin-bottom: var(--space-sm);
    overflow-x: auto;
}

.dataframe-title {
    font-weight: 600;
    color: var(--violet-dark);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    border-left: 3px solid var(--violet-primary);
}

.dataframe-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.dataframe-shape {
    background: var(--bg-secondary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
}

.dataframe-truncated {
    color: var(--gray-medium);
    font-style: italic;
}

/* DataFrame HTML Table Styling */
.dataframe-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.dataframe-table thead {
    background: var(--violet-light);
}

.dataframe-table th {
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 600;
    color: var(--violet-dark);
    border-bottom: 2px solid var(--violet-primary);
    white-space: nowrap;
}

.dataframe-table td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    white-space: nowrap;
}

/* Index column styling (first column) */
.dataframe-table th:first-child,
.dataframe-table td:first-child {
    background: var(--bg-secondary);
    font-weight: 500;
    color: var(--text-secondary);
    border-right: 1px solid var(--border-color);
    position: sticky;
    left: 0;
    z-index: 1;
}

/* Alternating row colors */
.dataframe-table tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.dataframe-table tbody tr:nth-child(even) td:first-child {
    background: var(--bg-primary);
}

/* Row hover effect */
.dataframe-table tbody tr:hover {
    background: rgba(192, 156, 240, 0.1);
}

.dataframe-table tbody tr:hover td:first-child {
    background: rgba(192, 156, 240, 0.15);
}

/* Numeric values alignment */
.dataframe-table td:not(:first-child) {
    text-align: right;
}

/* Dark mode adjustments */
[data-theme="dark"] .dataframe-table {
    background: #2d2d2d;
}

[data-theme="dark"] .dataframe-table thead {
    background: rgba(155, 122, 196, 0.3);
}

[data-theme="dark"] .dataframe-table th {
    color: var(--violet-light);
    border-bottom-color: var(--violet-dark);
}

[data-theme="dark"] .dataframe-table th:first-child,
[data-theme="dark"] .dataframe-table td:first-child {
    background: #252525;
}

[data-theme="dark"] .dataframe-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .dataframe-table tbody tr:nth-child(even) td:first-child {
    background: #202020;
}

[data-theme="dark"] .dataframe-table tbody tr:hover {
    background: rgba(192, 156, 240, 0.15);
}

[data-theme="dark"] .dataframe-table tbody tr:hover td:first-child {
    background: rgba(192, 156, 240, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .mlformation-container {
        padding: var(--space-sm);
    }

    /* Page header responsive handled in global style.css */

    .module-header {
        padding: var(--space-sm);
    }

    .module-header h1 {
        font-size: 1.6rem;
    }

    .filters-section {
        padding: var(--space-sm);
    }

    .filter-label {
        width: 100%;
        margin-bottom: var(--space-xs);
    }

    .modules-grid {
        grid-template-columns: 1fr;
    }

    .module-meta-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .code-editable {
        font-size: 12px;
        min-height: 120px;
        max-height: 250px;
    }

    .code-actions {
        flex-wrap: wrap;
    }

    .module-downloads {
        flex-direction: column;
    }

    .btn-download {
        justify-content: center;
    }

    /* Mermaid diagrams - smaller padding on mobile */
    .mermaid {
        padding: 0.5em;
        margin: 1em 0;
    }

    .overview-diagram .mermaid {
        padding: 0.5em;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .mlformation-container {
        padding: 0;
    }

    .filters-section {
        padding: var(--space-xs);
        border-radius: var(--radius-sm);
    }

    .overview-content {
        padding: var(--space-xs);
    }

    .cell-content {
        padding: var(--space-sm);
    }

    .filter-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    .filter-label {
        min-width: auto;
        font-size: 0.8rem;
    }

    .module-card {
        padding: var(--space-sm);
    }
}

/* ==========================================================================
   Category Overview Panel
   ========================================================================== */

.category-overview {
    margin-bottom: var(--space-md);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition-base);
    max-width: 100%;
}

.category-overview:hover {
    border-color: var(--violet-primary);
}

.category-overview[open] {
    border-color: var(--violet-primary);
    box-shadow: var(--shadow-md);
}

.overview-summary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    cursor: pointer;
    background: linear-gradient(135deg, var(--violet-light) 0%, var(--bg-secondary) 100%);
    transition: var(--transition-fast);
    list-style: none;
}

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

.overview-summary::after {
    content: '+';
    margin-left: auto;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--violet-dark);
    transition: var(--transition-fast);
}

.category-overview[open] .overview-summary::after {
    content: '-';
}

.overview-summary:hover {
    background: linear-gradient(135deg, var(--violet-primary) 0%, var(--violet-light) 100%);
}

.overview-icon {
    font-size: 1.5rem;
}

.overview-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--violet-dark);
}

.overview-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

.overview-content {
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
    overflow-x: hidden;
    max-width: 100%;
}

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

/* Overview Text Styling */
.overview-text {
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.overview-text p {
    margin-bottom: 1em;
}

.overview-text strong {
    color: var(--violet-dark);
}

/* Overview Tables - Responsive wrapper */
.overview-text .table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin: 1.5em 0;
    -webkit-overflow-scrolling: touch;
}

.overview-text table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin: 0;
}

.overview-text th,
.overview-text td {
    padding: 0.75em 1em;
    text-align: left;
    border: 1px solid var(--border-color);
}

.overview-text th {
    background: var(--violet-light);
    color: var(--violet-dark);
    font-weight: 600;
}

.overview-text tbody tr:nth-child(even) {
    background: var(--bg-secondary);
}

.overview-text tbody tr:hover {
    background: rgba(192, 156, 240, 0.1);
}

/* Overview Lists */
.overview-text ul,
.overview-text ol {
    margin: 1em 0;
    padding-left: 1.5em;
}

.overview-text li {
    margin: 0.5em 0;
    position: relative;
}

.overview-text ul {
    list-style: none;
}

.overview-text ul li::before {
    content: '';
    position: absolute;
    left: -1.2em;
    top: 0.6em;
    width: 6px;
    height: 6px;
    background: var(--violet-dark);
    border-radius: 50%;
}

/* Overview Diagram Section */
.overview-diagram {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px dashed var(--border-color);
}

.overview-diagram h4 {
    margin: 0 0 var(--space-sm);
    color: var(--violet-dark);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.overview-diagram h4::before {
    content: '🗺️';
}

.overview-diagram .mermaid {
    margin: 0;
    padding: var(--space-md);
    background: var(--bg-secondary);
}

/* Dark mode adjustments */
[data-theme="dark"] .overview-summary {
    background: linear-gradient(135deg, rgba(155, 122, 196, 0.2) 0%, var(--bg-secondary) 100%);
}

[data-theme="dark"] .overview-summary:hover {
    background: linear-gradient(135deg, rgba(155, 122, 196, 0.4) 0%, rgba(155, 122, 196, 0.2) 100%);
}

[data-theme="dark"] .overview-title {
    color: var(--violet-light);
}

[data-theme="dark"] .overview-text th {
    background: rgba(155, 122, 196, 0.3);
    color: var(--violet-light);
}

[data-theme="dark"] .overview-text tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .overview-text tbody tr:hover {
    background: rgba(192, 156, 240, 0.15);
}

[data-theme="dark"] .overview-diagram h4 {
    color: var(--violet-light);
}

/* Responsive */
@media (max-width: 768px) {
    .overview-summary {
        flex-wrap: wrap;
        padding: var(--space-sm);
    }

    .overview-hint {
        width: 100%;
        margin-top: var(--space-xs);
    }

    .overview-content {
        padding: var(--space-sm);
    }

    .overview-text table {
        font-size: 0.8rem;
    }

    .overview-text th,
    .overview-text td {
        padding: 0.5em;
    }
}

/* ==========================================================================
   Overview Tabs Component
   ========================================================================== */

.overview-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: var(--space-md);
    padding: 0 var(--space-xs);
}

.overview-tab {
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.overview-tab:hover {
    color: var(--violet-dark);
    background: rgba(192, 156, 240, 0.1);
}

.overview-tab.active {
    color: var(--violet-dark);
    border-bottom-color: var(--violet-dark);
    background: rgba(192, 156, 240, 0.15);
}

.overview-tab-icon {
    font-size: 1rem;
}

.overview-tab-panels {
    position: relative;
    max-width: 100%;
    overflow-x: hidden;
}

.overview-tab-panel {
    display: none;
    animation: fadeIn 0.3s ease;
    max-width: 100%;
    overflow-x: hidden;
}

.overview-tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tab panel content spacing */
.overview-tab-panel .overview-text {
    margin-bottom: var(--space-md);
}

.overview-tab-panel .overview-diagram {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

/* Section headers in tabs */
.overview-tab-panel h2 {
    font-size: 1.3rem;
    color: var(--violet-dark);
    margin: var(--space-md) 0 var(--space-sm);
    padding-bottom: var(--space-xs);
    border-bottom: 2px solid var(--violet-light);
}

.overview-tab-panel h2:first-child {
    margin-top: 0;
}

.overview-tab-panel h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: var(--space-sm) 0 var(--space-xs);
}

.overview-tab-panel h4 {
    font-size: 1rem;
    color: var(--violet-dark);
    margin: var(--space-sm) 0 var(--space-xs);
}

/* Blockquotes in tabs */
.overview-tab-panel blockquote {
    margin: var(--space-sm) 0;
    padding: var(--space-sm) var(--space-md);
    border-left: 4px solid var(--violet-primary);
    background: rgba(192, 156, 240, 0.1);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.overview-tab-panel blockquote p {
    margin: 0;
    font-style: italic;
    color: var(--text-primary);
}

/* Code blocks in tabs */
.overview-tab-panel code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85em;
}

.overview-tab-panel pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: var(--space-sm) 0;
}

.overview-tab-panel pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* Dark mode for tabs */
[data-theme="dark"] .overview-tab:hover {
    color: var(--violet-light);
    background: rgba(192, 156, 240, 0.15);
}

[data-theme="dark"] .overview-tab.active {
    color: var(--violet-light);
    border-bottom-color: var(--violet-light);
    background: rgba(192, 156, 240, 0.2);
}

[data-theme="dark"] .overview-tab-panel h2 {
    color: var(--violet-light);
    border-bottom-color: rgba(192, 156, 240, 0.3);
}

[data-theme="dark"] .overview-tab-panel h4 {
    color: var(--violet-light);
}

[data-theme="dark"] .overview-tab-panel blockquote {
    background: rgba(192, 156, 240, 0.15);
}

[data-theme="dark"] .overview-tab-panel code {
    background: rgba(255, 255, 255, 0.1);
}

/* Responsive tabs */
@media (max-width: 768px) {
    .overview-tabs {
        gap: 0;
        padding: 0;
    }

    .overview-tab {
        padding: var(--space-xs) var(--space-sm);
        font-size: 0.8rem;
        flex: 1;
        justify-content: center;
        text-align: center;
    }

    .overview-tab-icon {
        display: none;
    }
}

@media (max-width: 480px) {
    .overview-tabs {
        flex-direction: column;
        border-bottom: none;
    }

    .overview-tab {
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 0;
        justify-content: flex-start;
    }

    .overview-tab.active {
        background: var(--violet-light);
        border-bottom-color: var(--border-color);
    }

    .overview-tab-icon {
        display: inline;
    }
}

/* ==========================================================================
   Scratch Pad (Python Brouillon)
   ========================================================================== */

/* Python Console Button - Fixed position bottom right */
.python-console-btn {
    position: fixed;
    bottom: 5rem;  /* Above sync-btn when both are present */
    right: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--bg-secondary);
    color: var(--violet-dark);
    border: 1px solid var(--violet-dark);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-md);
    z-index: 100;
    opacity: 0.85;
}

.python-console-btn:hover {
    background: var(--violet-dark);
    color: white;
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.python-console-btn.active {
    background: var(--violet-dark);
    color: white;
    opacity: 1;
}

.python-console-btn svg {
    width: 20px;
    height: 20px;
}

/* Scratch Pad Overlay */
.scratch-pad-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-fast);
}

.scratch-pad-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* Scratch Pad Modal */
.scratch-pad-modal {
    position: relative;
    width: min(90%, 800px);
    min-width: 250px;
    min-height: 200px;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--violet-primary);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base), opacity var(--transition-base);
    overflow: hidden;
}

.scratch-pad-overlay.open .scratch-pad-modal {
    transform: scale(1) translateY(0);
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    z-index: 10;
}

/* Vertical edge handles (top/bottom) */
.resize-handle-n,
.resize-handle-s {
    left: 16px;
    right: 16px;
    height: 10px;
    cursor: ns-resize;
}

/* Horizontal edge handles (left/right) */
.resize-handle-e,
.resize-handle-w {
    top: 16px;
    bottom: 16px;
    width: 10px;
    cursor: ew-resize;
}

.resize-handle-n { top: -5px; }
.resize-handle-s { bottom: -5px; }
.resize-handle-e { right: -5px; }
.resize-handle-w { left: -5px; }

/* Corner handles */
.resize-handle-nw,
.resize-handle-ne,
.resize-handle-sw,
.resize-handle-se {
    width: 16px;
    height: 16px;
}

.resize-handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.resize-handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }

/* Visual indicator on horizontal edge handles */
.resize-handle-e::after,
.resize-handle-w::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 30px;
    background: var(--violet-primary);
    border-radius: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.resize-handle-e::after { right: 2px; }
.resize-handle-w::after { left: 2px; }

.resize-handle-e:hover::after,
.resize-handle-w:hover::after {
    opacity: 0.6;
}

/* Visual indicator on vertical edge handles */
.resize-handle-n::after,
.resize-handle-s::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    height: 3px;
    width: 30px;
    background: var(--violet-primary);
    border-radius: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.resize-handle-n::after { top: 2px; }
.resize-handle-s::after { bottom: 2px; }

.resize-handle-n:hover::after,
.resize-handle-s:hover::after {
    opacity: 0.6;
}

/* Visual indicator on corner handles */
.resize-handle-se::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--violet-primary);
    border-bottom: 2px solid var(--violet-primary);
    opacity: 0.4;
    transition: opacity var(--transition-fast);
}

.resize-handle-se:hover::after {
    opacity: 1;
}

.resize-handle-nw::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    border-left: 2px solid var(--violet-primary);
    border-top: 2px solid var(--violet-primary);
    opacity: 0.4;
    transition: opacity var(--transition-fast);
}

.resize-handle-nw:hover::after {
    opacity: 1;
}

/* Disable text selection during resize */
.scratch-pad-modal.resizing {
    user-select: none;
}

.scratch-pad-modal.resizing * {
    pointer-events: none;
}

/* Scratch Pad Header - Draggable */
.scratch-pad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--violet-dark);
    color: white;
    cursor: move;
    user-select: none;
}

.scratch-pad-header:active {
    cursor: grabbing;
}

/* When modal is being dragged */
.scratch-pad-modal.dragging {
    transition: none !important;
}

.scratch-pad-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.scratch-icon {
    font-size: 1.2rem;
}

.scratch-pad-actions {
    display: flex;
    gap: 0.5rem;
}

.scratch-action-btn {
    padding: 0.4rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.scratch-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

.scratch-action-btn svg {
    display: block;
}

/* Scratch Pad Body */
.scratch-pad-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Scratch Code Editor - ContentEditable with syntax highlighting */
.scratch-code-editor {
    background: #1e1e1e;
    flex: 1 1 50%;
    min-height: 40px;
    overflow: auto;
}

.scratch-editable {
    width: 100%;
    height: 100%;
    min-height: 40px;
    box-sizing: border-box;
    margin: 0;
    padding: 12px;
    border: none;
    background: transparent;
    color: #d4d4d4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
    -moz-tab-size: 4;
    overflow: auto;
    caret-color: #fff;
}

.scratch-editable::selection {
    background: rgba(192, 156, 240, 0.4);
}

.scratch-editable:focus {
    outline: 2px solid var(--violet-primary);
    outline-offset: -2px;
}

/* Placeholder for empty contenteditable */
.scratch-editable:empty::before {
    content: attr(data-placeholder);
    color: rgba(212, 212, 212, 0.4);
    pointer-events: none;
}

/* Ensure Highlight.js spans don't break the layout */
.scratch-editable span {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Scratch Code Actions */
.scratch-code-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.scratch-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Shortcuts Help Tooltip */
.shortcuts-help {
    position: relative;
    display: inline-block;
}

.shortcuts-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: var(--space-sm);
    min-width: 220px;
    z-index: 1000;
}

.shortcuts-help:focus-within .shortcuts-tooltip,
.shortcuts-help:hover .shortcuts-tooltip {
    display: block;
}

.shortcuts-title {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--violet-dark);
    margin-bottom: var(--space-xs);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-color);
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 4px 0;
}

.shortcut-item kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

/* Splitter between code and output */
.scratch-splitter {
    flex: 0 0 8px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    cursor: row-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast);
}

.scratch-splitter:hover {
    background: var(--violet-light);
}

.scratch-splitter::before {
    content: '';
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    transition: background var(--transition-fast);
}

.scratch-splitter:hover::before {
    background: var(--violet-dark);
}

.scratch-splitter.dragging {
    background: var(--violet-light);
}

/* Scratch Code Output */
.scratch-code-output {
    flex: 1 1 50%;
    min-height: 40px;
    overflow-y: auto;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-primary);
}

.scratch-code-output pre {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.85rem;
    line-height: 1.5;
}

.scratch-code-output .stdout {
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
}

.scratch-code-output .error {
    color: #dc3545;
    background: #fff5f5;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    border-left: 3px solid #dc3545;
}

[data-theme="dark"] .scratch-code-output .error {
    background: #3d2020;
}

.scratch-code-output .figures {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.scratch-code-output .figures img {
    max-width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--white);
}

.scratch-code-output .dataframe-container {
    margin-bottom: var(--space-sm);
}

.scratch-code-output .exec-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: right;
    margin-top: var(--space-xs);
}

.scratch-code-output .no-output {
    color: var(--text-secondary);
    font-style: italic;
}

.scratch-code-output .loading {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--violet-dark);
    font-weight: 500;
}

/* Responsive adjustments for scratch pad */
@media (max-width: 768px) {
    .python-console-btn {
        bottom: 4rem;
        right: 1rem;
        width: 40px;
        height: 40px;
    }

    .python-console-btn svg {
        width: 18px;
        height: 18px;
    }

    .scratch-pad-modal {
        width: 95%;
        max-height: 90vh;
    }

    .scratch-code-editor {
        min-height: 150px;
        max-height: 200px;
    }

    .scratch-editable {
        font-size: 12px;
        min-height: 150px;
        max-height: 200px;
    }

    .scratch-code-output {
        max-height: 200px;
    }
}

/* ==========================================================================
   Locked Content Cell (for anonymous users)
   Styled as a special notebook cell to match the learning flow
   ========================================================================== */

.cell-locked {
    border: 2px solid var(--violet-primary);
    background: var(--card-bg);
    position: relative;
    overflow: hidden;
    margin-top: var(--space-md);
}

.cell-locked::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--violet-primary), var(--yellow-primary), var(--violet-primary));
    background-size: 200% 100%;
    animation: gradient-shift 3s ease infinite;
}

@keyframes gradient-shift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.cell-locked .cell-header {
    background: linear-gradient(135deg, var(--violet-light) 0%, var(--bg-secondary) 100%);
    justify-content: space-between;
}

[data-theme="dark"] .cell-locked .cell-header {
    background: linear-gradient(135deg, rgba(155, 122, 196, 0.2) 0%, var(--bg-secondary) 100%);
}

.cell-type-badge.locked {
    background: var(--violet-dark);
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.cell-type-badge.locked svg {
    stroke: var(--white);
}

.sections-remaining {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.locked-content {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-lg);
}

/* Progress Ring */
.progress-ring-container {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.progress-ring-fill {
    fill: none;
    stroke: var(--violet-primary);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    line-height: 1;
}

.progress-current {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--violet-dark);
}

.progress-separator {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 2px;
}

.progress-total {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Message */
.locked-message {
    flex: 1;
}

.locked-message h3 {
    font-size: 1.35rem;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    font-weight: 600;
}

.locked-message p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-md);
    font-size: 0.95rem;
}

.locked-message p strong {
    color: var(--violet-dark);
}

/* Actions */
.locked-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.btn-unlock {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--violet-dark);
    color: var(--white);
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.btn-unlock:hover {
    background: var(--violet-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--white);
}

.btn-unlock svg {
    stroke: currentColor;
}

.or-separator {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.btn-register-link {
    color: var(--violet-dark);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-fast);
    border-bottom: 1px dashed var(--violet-primary);
    padding-bottom: 2px;
}

.btn-register-link:hover {
    color: var(--violet-primary);
    border-bottom-style: solid;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .locked-content {
        flex-direction: column;
        text-align: center;
        padding: var(--space-md);
    }

    .progress-ring-container {
        width: 100px;
        height: 100px;
    }

    .progress-current {
        font-size: 1.5rem;
    }

    .progress-total {
        font-size: 1rem;
    }

    .locked-message h3 {
        font-size: 1.2rem;
    }

    .locked-actions {
        justify-content: center;
        flex-direction: column;
        gap: var(--space-xs);
    }

    .btn-unlock {
        width: 100%;
        justify-content: center;
    }

    .or-separator {
        display: none;
    }

    .btn-register-link {
        margin-top: var(--space-xs);
    }

    .sections-remaining {
        font-size: 0.75rem;
    }
}
