/* Footer link styling with theme support and hover effects */
.plain-link {
    color: #60a5fa;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.3s ease, opacity 0.3s ease;
}

.plain-link:hover {
    color: #93c5fd;
    opacity: 0.8;
}

.plain-link:focus {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Light theme footer link colors */
.light-theme .plain-link {
    color: #2563eb;
}

.light-theme .plain-link:hover {
    color: #1d4ed8;
}

.light-theme .plain-link:focus {
    outline-color: #2563eb;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light theme variables */
    --bg-primary: #f5f5f5;
    --bg-secondary: white;
    --bg-tertiary: #f8f9fa;
    --bg-accent: #e9ecef;
    --text-primary: #333;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --border-color: #e0e0e0;
    --border-light: #dee2e6;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    --input-bg: #f8f9fa;
    --input-focus-bg: white;
}

.dark-theme {
    /* Dark theme variables */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --bg-accent: #4a4a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #c0c0c0;
    --text-muted: #a0a0a0;
    --border-color: #4a4a4a;
    --border-light: #5a5a5a;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #3a3a3a 0%, #4a4a4a 100%);
    --input-bg: #3a3a3a;
    --input-focus-bg: #4a4a4a;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: var(--gradient-primary);
    color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 6px var(--shadow);
    margin-bottom: 30px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-text {
    flex: 1;
}

.header-text h1 {
    font-size: 2.5em;
    margin-bottom: 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.hero-subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin-top: 10px;
    margin-bottom: 0;
    line-height: 1.4;
    max-width: 600px;
}

.title-logo {
    height: 2.5em;
    width: auto;
}

.header-text p {
    font-size: 1.2em;
    opacity: 0.9;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.theme-toggle {
    flex-shrink: 0;
}

.header-icon {
    flex-shrink: 0;
}

.header-icon a {
    display: block;
    text-decoration: none;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.header-icon a:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

.korovatron-icon {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: block;
    box-sizing: border-box;
}

.korovatron-icon:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.theme-icon {
    transition: transform 0.3s ease;
}

.theme-toggle-btn:hover .theme-icon {
    transform: rotate(180deg);
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

@media (min-width: 1024px) {
    .main-content {
        grid-template-columns: 1.4fr 1.6fr;
        gap: 30px;
    }
}

/* Wider left column for very wide screens */
@media (min-width: 1400px) {
    .main-content {
        grid-template-columns: 1fr 2fr;
        gap: 30px;
    }
}

.left-panel, .right-panel {
    background: var(--bg-secondary);
    border-radius: 10px;
    box-shadow: 0 2px 10px var(--shadow);
    overflow: hidden;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.database-info, .example-queries, .sql-editor, .results, .exercise-display {
    padding: 20px;
}

.exercise-sections h4 {
    color: var(--text-secondary);
    margin: 20px 0 10px 0;
    font-size: 1.1em;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 5px;
}

.exercise-sections h4:first-child {
    margin-top: 0;
}

.section-group {
    margin-bottom: 15px;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.section-toggle {
    background: var(--gradient-secondary);
    color: var(--text-primary);
    padding: 12px 15px;
    margin: 0;
    cursor: pointer;
    user-select: none;
    font-size: 16px;
    font-weight: 600;
    border: none;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
}

.section-toggle:hover {
    background: var(--gradient-primary);
    color: white;
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.toggle-icon {
    margin-right: 10px;
    font-size: 14px;
    transition: transform 0.3s ease;
    color: #667eea;
    font-weight: bold;
    display: inline-block;
}

.section-toggle.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.section-content {
    padding: 15px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    transition: all 0.3s ease, background-color 0.3s ease;
    max-height: 1000px;
    overflow: hidden;
}

.section-content.collapsed {
    max-height: 0;
    padding: 0 15px;
    opacity: 0;
}

.exercise-display {
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
    transition: background-color 0.3s ease;
}

.exercise-display h3 {
    color: var(--text-secondary);
    margin-bottom: 10px;
    border-bottom: none;
    font-size: 1.2em;
}

.exercise-display p {
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    font-size: 1.1em;
    font-weight: 500;
    background: var(--background-secondary);
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Mobile-first improvements */
.exercise-btn {
    background: var(--gradient-primary);
    border: none;
    color: white;
    padding: 12px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px var(--shadow);
    width: 100%;
    margin-bottom: 8px;
    min-height: 44px; /* iOS minimum touch target */
    display: flex;
    align-items: center;
}

.exercise-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-hover);
}

.exercise-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow);
}

.exercise-btn.selected {
    background: #48bb78;
    box-shadow: 0 2px 4px var(--shadow);
}

.database-info h2, .example-queries h2, .sql-editor h2, .results h2, .exercise-display h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.schema-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.schema-toggle-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-height: 32px;
    min-width: 32px;
    display: none; /* Hidden on desktop */
}

.schema-toggle-btn:hover {
    background: var(--bg-accent);
    color: var(--text-primary);
}

.schema-toggle-icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.schema-toggle-btn.collapsed .schema-toggle-icon {
    transform: rotate(-90deg);
}

.schema-container {
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.schema-container.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* Show schema toggle on mobile */
@media (max-width: 768px) {
    .schema-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .schema-container {
        max-height: 200px;
    }
}

.table-info {
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border-left: 4px solid #667eea;
    transition: background-color 0.3s ease;
}

.table-info h4 {
    color: var(--text-secondary);
    margin-bottom: 15px;
}

/* Schema table styling */
.schema-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.schema-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.85em;
}

.schema-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.schema-table tr:hover {
    background: var(--bg-hover);
}

.column-name {
    font-weight: 600;
    color: var(--text-primary);
}

.column-type {
    color: var(--text-muted);
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.column-constraints {
    line-height: 1.4;
}

/* Constraint badges */
.constraint-badge {
    display: inline-block;
    padding: 2px 6px;
    margin: 1px 2px;
    border-radius: 3px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}

.pk-badge {
    background: #ff6b6b;
    color: white;
    padding: 2px 6px;
    line-height: 1.2;
    vertical-align: top;
    min-height: 16px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

.fk-badge {
    background: #2d8a82;
    color: white;
    font-size: 0.75em;
    text-transform: none;
    padding: 2px 6px;
    line-height: 1.2;
    vertical-align: top;
    min-height: 16px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

.not-null-badge {
    background: #ffe66d;
    color: #333;
}

.default-badge {
    background: #a8e6cf;
    color: #333;
    font-size: 0.7em;
    text-transform: none;
}

.examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 10px;
}

.example-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    font-size: 14px;
}

.example-btn:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#sqlInput {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

#sqlInput:focus {
    outline: none;
    border-color: #667eea;
    background: var(--input-focus-bg);
}

/* CodeMirror Editor Styling */
.CodeMirror {
    height: 200px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Courier New', 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.CodeMirror:focus-within {
    border-color: #667eea;
    background: var(--input-focus-bg);
}

.CodeMirror-focused {
    border-color: #667eea;
}

.CodeMirror-gutters {
    background: var(--input-bg);
    border-right: 1px solid var(--border-color);
}

.CodeMirror-linenumber {
    color: var(--text-secondary);
    background: transparent;
}

.CodeMirror-cursor {
    border-color: var(--text-primary);
}

.CodeMirror-selected {
    background: rgba(102, 126, 234, 0.2);
}

.CodeMirror-line::selection,
.CodeMirror-line > span::selection,
.CodeMirror-line > span > span::selection {
    background: rgba(102, 126, 234, 0.3);
}

/* SQL Syntax Highlighting for Light Theme */
.light-theme .cm-keyword {
    color: #0066cc;
    font-weight: bold;
}

.light-theme .cm-string {
    color: #008000;
}

.light-theme .cm-number {
    color: #d14;
}

.light-theme .cm-comment {
    color: #999988;
    font-style: italic;
}

.light-theme .cm-operator {
    color: #333;
}

.light-theme .cm-variable {
    color: #333;
}

.light-theme .cm-variable-2 {
    color: #0086b3;
}

.light-theme .cm-variable-3 {
    color: #795da3;
}

.light-theme .cm-builtin {
    color: #0066cc;
}

/* SQL Syntax Highlighting for Dark Theme */
.dark-theme .cm-keyword {
    color: #569cd6;
    font-weight: bold;
}

.dark-theme .cm-string {
    color: #ce9178;
}

.dark-theme .cm-number {
    color: #b5cea8;
}

.dark-theme .cm-comment {
    color: #6a9955;
    font-style: italic;
}

.dark-theme .cm-operator {
    color: #d4d4d4;
}

.dark-theme .cm-variable {
    color: #9cdcfe;
}

.dark-theme .cm-variable-2 {
    color: #4ec9b0;
}

.dark-theme .cm-variable-3 {
    color: #dcdcaa;
}

.dark-theme .cm-builtin {
    color: #569cd6;
}

/* CodeMirror Hints/Autocomplete styling */
.CodeMirror-hints {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    max-height: 150px;
    overflow-y: auto;
}

.CodeMirror-hint {
    color: var(--text-primary);
    padding: 4px 8px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.CodeMirror-hint-active {
    background: #667eea;
    color: white;
}

.editor-controls {
    margin-top: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.editor-controls button {
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    min-height: 44px; /* iOS minimum touch target */
    flex: 1;
    min-width: 120px;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#executeBtn {
    background: #667eea;
    border-color: #5a6fd8;
    color: white;
    font-weight: 600;
}

#executeBtn:hover {
    background: #5a6fd8;
    border-color: #4c63d2;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#executeBtn:active {
    background: #4c63d2;
    transform: translateY(0);
}

#clearBtn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

#clearBtn:hover {
    background: var(--bg-accent);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow);
}

#clearBtn:active {
    background: var(--bg-tertiary);
    transform: translateY(0);
}

#resetDbBtn {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

#resetDbBtn:hover {
    background: var(--bg-accent);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow);
}

#resetDbBtn:active {
    background: var(--bg-tertiary);
    transform: translateY(0);
}

#results {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 15px;
    min-height: 200px;
    max-height: 400px;
    overflow: auto;
    transition: background-color 0.3s ease;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: var(--bg-secondary);
    box-shadow: 0 1px 3px var(--shadow);
    transition: background-color 0.3s ease;
}

.result-table th,
.result-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.result-table th {
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
    border-bottom: 2px solid var(--border-light);
}

.result-table tr:hover {
    background: var(--bg-accent);
}

.error {
    color: #e53e3e;
    background: #fed7d7;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #e53e3e;
}

.success {
    color: #38a169;
    background: #c6f6d5;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #38a169;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #667eea;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #2d3748;
    color: white;
    border-radius: 10px;
    margin-top: 30px;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        padding: 15px;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .header-text h1 {
        font-size: 1.8em;
        line-height: 1.2;
    }
    
    .hero-subtitle {
        font-size: 1em;
        margin-top: 8px;
    }
    
    .title-logo {
        height: 2.2em;
    }
    
    .header-text p {
        font-size: 1em;
    }
    
    .theme-toggle-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1em;
    }
    
    /* Footer responsive layout */
    footer {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    /* Make sections more touch-friendly */
    .section-toggle {
        padding: 15px;
        font-size: 15px;
    }
    
    .toggle-icon {
        font-size: 16px;
        margin-right: 12px;
    }
    
    /* Improve exercise buttons for touch */
    .exercise-btn {
        padding: 15px;
        font-size: 15px;
        margin-bottom: 10px;
        min-height: 50px;
        display: flex;
        align-items: center;
    }
    
    /* Stack exercise buttons in single column on mobile */
    .examples {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    /* Improve SQL editor for mobile */
    #sqlInput {
        height: 150px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    .editor-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .editor-controls button {
        width: 100%;
        padding: 15px 20px;
        font-size: 16px;
        min-height: 50px;
    }
    
    /* Improve results display */
    #results {
        max-height: 300px;
        font-size: 14px;
    }
    
    .result-table {
        font-size: 13px;
    }
    
    .result-table th,
    .result-table td {
        padding: 8px 6px;
        word-wrap: break-word;
        max-width: 120px;
    }
    
    /* Improve table info display */
    .table-info {
        padding: 12px;
    }
    
    .table-info h4 {
        font-size: 1em;
    }
    
    .schema-table {
        font-size: 0.8em;
    }
    
    .schema-table th,
    .schema-table td {
        padding: 6px 8px;
    }
    
    .constraint-badge {
        font-size: 0.65em;
        padding: 1px 4px;
        margin: 1px;
    }
    
    .fk-badge,
    .default-badge {
        font-size: 0.6em;
    }
    
    /* Exercise display improvements */
    .exercise-display {
        padding: 15px;
    }
    
    .exercise-display h3 {
        font-size: 1.1em;
    }
    
    .exercise-display p {
        font-size: 1em;
        line-height: 1.5;
        padding: 12px;
    }
}

/* Additional responsive breakpoint for small phones */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    header {
        padding: 12px;
    }
    
    .header-text h1 {
        font-size: 1.5em;
    }
    
    .hero-subtitle {
        font-size: 0.9em;
        margin-top: 6px;
    }
    
    .title-logo {
        height: 1.8em;
    }
    
    .section-toggle {
        padding: 12px;
        font-size: 14px;
    }
    
    .exercise-btn {
        padding: 12px;
        font-size: 14px;
        min-height: 45px;
    }
    
    #sqlInput {
        height: 120px;
        font-size: 16px;
        padding: 10px;
    }
    
    .editor-controls button {
        padding: 12px 15px;
        min-height: 45px;
    }
    
    .result-table th,
    .result-table td {
        padding: 6px 4px;
        font-size: 12px;
        max-width: 100px;
    }
}

/* iOS and Mobile CodeMirror Fixes */
@media screen and (max-width: 768px) {
    /* Prevent iOS zoom on focus */
    .CodeMirror {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
        -webkit-user-select: text;
        user-select: text;
        -webkit-touch-callout: none;
    }
    
    .CodeMirror-scroll {
        -webkit-overflow-scrolling: touch;
    }
    
    .CodeMirror-focused {
        outline: none;
    }
    
    /* Better mobile textarea sizing */
    .CodeMirror {
        height: 150px !important;
        min-height: 150px !important;
    }
    
    /* Improve touch targets */
    .CodeMirror-line {
        padding: 2px 0;
        line-height: 1.4;
    }
    
    /* Prevent horizontal scrolling issues */
    .CodeMirror-hscrollbar {
        display: none !important;
    }
    
    .CodeMirror-simplescroll-horizontal {
        display: none !important;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .CodeMirror {
        font-size: 16px !important;
        -webkit-text-size-adjust: none;
        -webkit-overflow-scrolling: touch;
        /* Prevent layout shifts that cause scroll jumping */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
    
    .CodeMirror-focused {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* Stabilize the layout during focus events */
    .CodeMirror-wrap {
        min-height: 120px;
    }
    
    /* Prevent any sudden layout changes */
    .CodeMirror-scroll {
        padding-bottom: 0 !important;
    }
}

/* ===============================
   PROGRESS TRACKING STYLES
   =============================== */

/* Exercises header with reset button */
.exercises-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Progress instruction text */
.progress-instruction {
    font-size: 0.85em;
    color: var(--text-muted);
    margin: 8px 0 16px 0;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-left: 3px solid #60a5fa;
    border-radius: 4px;
    line-height: 1.4;
}

.dark-theme .progress-instruction {
    border-left-color: #60a5fa;
}

.reset-progress-btn-small {
    background: var(--bg-accent);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.reset-progress-btn-small:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    transform: scale(1.05);
}

.reset-progress-btn-small:active {
    transform: scale(0.95);
}

/* Module progress indicators */
.module-progress {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 1px solid;
    flex-shrink: 0;
}

/* Module title container for left alignment */
.module-title-container {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

/* Module progress badge states */
.module-progress.none {
    background-color: #fecaca;
    border-color: #f87171;
    color: #dc2626;
}

.module-progress.partial {
    background-color: #fed7aa;
    border-color: #fb923c;
    color: #ea580c;
}

.module-progress.completed {
    background-color: #bbf7d0;
    border-color: #34d399;
    color: #059669;
}

/* Dark theme module progress adjustments */
.dark-theme .module-progress.none {
    background-color: rgba(220, 38, 38, 0.2);
    border-color: #ef4444;
    color: #fca5a5;
}

.dark-theme .module-progress.partial {
    background-color: rgba(234, 88, 12, 0.2);
    border-color: #f97316;
    color: #fdba74;
}

.dark-theme .module-progress.completed {
    background-color: rgba(5, 150, 105, 0.2);
    border-color: #10b981;
    color: #6ee7b7;
}

/* Exercise checkbox styling */
.exercise-checkbox {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
    cursor: pointer;
    position: relative;
}

.exercise-progress-checkbox {
    display: none; /* Hide the actual checkbox */
}

.exercise-checkbox label {
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    padding: 2px;
    border-radius: 50%;
    position: relative;
}

.exercise-checkbox label:hover {
    transform: scale(1.1);
    background-color: rgba(96, 165, 250, 0.1);
}

.exercise-checkbox label:active {
    transform: scale(0.95);
}

/* Add a subtle ring to indicate clickability */
.exercise-checkbox label::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 1px solid transparent;
    border-radius: 50%;
    transition: border-color 0.2s ease;
}

.exercise-checkbox label:hover::before {
    border-color: rgba(96, 165, 250, 0.3);
}

/* Exercise button with completion state */
.exercise-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 12px;
    margin: 4px 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9em;
    text-align: left;
    transition: all 0.3s ease;
}

.exercise-btn:hover {
    background: var(--bg-accent);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.exercise-btn.completed {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(52, 211, 153, 0.1));
    border-color: #10b981;
}

.exercise-btn.completed:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(52, 211, 153, 0.15));
}

.exercise-btn.selected {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

.exercise-btn.selected .exercise-checkbox label {
    filter: brightness(1.2);
}

/* Fix for completed and selected exercise buttons in light theme */
.light-theme .exercise-btn.completed.selected {
    color: white !important;
}

.light-theme .exercise-btn.completed.selected:hover {
    color: #1f2937 !important; /* Dark text for visibility on green background */
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(52, 211, 153, 0.2)) !important;
}

/* Additional specificity for the text content */
.light-theme .exercise-btn.completed.selected:hover * {
    color: #1f2937 !important;
}

/* Responsive progress adjustments */
@media (max-width: 768px) {
    .exercises-header-container {
        gap: 8px;
    }
    
    .progress-instruction {
        font-size: 0.8em;
        margin: 6px 0 12px 0;
        padding: 6px 10px;
    }
    
    .reset-progress-btn-small {
        min-width: 28px;
        height: 28px;
        font-size: 0.9em;
        padding: 4px 6px;
    }
    
    .module-progress {
        font-size: 0.7em;
        padding: 2px 6px;
    }
    
    .exercise-checkbox label {
        font-size: 1.1em;
    }
}

/* Dark theme progress adjustments */
.dark-theme .reset-progress-btn-small {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.dark-theme .reset-progress-btn-small:hover {
    background: var(--bg-accent);
    border-color: var(--border-light);
}

/* Animation for progress changes */
@keyframes progressUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.progress-fill {
    animation: progressUpdate 0.6s ease when width changes;
}

.exercise-checkbox label {
    animation: progressUpdate 0.3s ease when content changes;
}