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

:root {
    /* Codility-inspired color palette */
    --codility-blue: #0d47a1;
    --codility-teal: #00acc1;
    --codility-green: #00c853;
    --codility-orange: #ff6d00;
    --codility-red: #d32f2f;

    /* Neutral colors */
    --white: #ffffff;
    --gray-50: #fafafa;
    --gray-100: #f5f5f5;
    --gray-200: #eeeeee;
    --gray-300: #e0e0e0;
    --gray-400: #bdbdbd;
    --gray-500: #9e9e9e;
    --gray-600: #757575;
    --gray-700: #616161;
    --gray-800: #424242;
    --gray-900: #212121;

    /* Semantic colors */
    --primary: var(--codility-blue);
    --secondary: var(--codility-teal);
    --success: var(--codility-green);
    --warning: var(--codility-orange);
    --danger: var(--codility-red);

    /* Light mode colors (default) */
    --bg-main: #f8f9fa;
    --bg-card: var(--white);
    --bg-hover: var(--gray-100);
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-700);
    --text-muted: var(--gray-600);
    --border-color: var(--gray-300);
    --border-light: var(--gray-200);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
}

/* Dark mode colors */
body.dark-mode {
    --bg-main: #1a1a1a;
    --bg-card: #242424;
    --bg-hover: #2d2d2d;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --border-color: #3a3a3a;
    --border-light: #2d2d2d;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
}

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

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Navbar - Codility style */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s ease;
}

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

.nav-link.active {
    color: var(--primary);
    background: #e3f2fd;
}

.nav-user {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
    background: var(--bg-hover);
    border-radius: 4px;
}

/* Flash Messages */
.flash-messages {
    margin: 24px 0;
}

.flash-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    animation: slideIn 0.3s ease;
}

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

.flash-success {
    background: rgba(0, 200, 83, 0.1);
    color: var(--success);
    border: 1px solid rgba(0, 200, 83, 0.3);
}

.flash-error {
    background: rgba(211, 47, 47, 0.1);
    color: var(--danger);
    border: 1px solid rgba(211, 47, 47, 0.3);
}

.flash-info {
    background: rgba(13, 71, 161, 0.1);
    color: var(--primary);
    border: 1px solid rgba(13, 71, 161, 0.3);
}

.flash-warning {
    background: rgba(255, 109, 0, 0.1);
    color: var(--warning);
    border: 1px solid rgba(255, 109, 0, 0.3);
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.flash-close:hover {
    opacity: 1;
}

/* Dashboard */
.dashboard {
    padding: 32px 0;
}

.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.page-header p {
    font-size: 16px;
    color: var(--text-secondary);
}

.stats-section {
    margin-bottom: 48px;
}

.stats-section h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--secondary);
}

.stat-number {
    font-size: 48px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-total {
    font-size: 12px;
    color: var(--text-muted);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--codility-green));
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* Weeks Grid */
.weeks-section h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.weeks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.week-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    transition: all 0.2s ease;
}

.week-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.week-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.week-header h3 {
    color: var(--primary);
    font-size: 18px;
    font-weight: 600;
}

.week-emoji {
    font-size: 24px;
}

.week-card h4 {
    color: var(--text-primary);
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 600;
}

.week-focus {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.week-days {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 13px;
}

/* Buttons - Codility style */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #0b3d91;
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #00889b;
}

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

.btn-outline-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Tips Section */
.tips-section {
    background: #e3f2fd;
    padding: 24px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary);
    margin-bottom: 32px;
}

.tips-section h2 {
    color: var(--primary);
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

.tips-list {
    list-style: none;
}

.tips-list li {
    margin-bottom: 8px;
    padding-left: 24px;
    position: relative;
    color: var(--text-secondary);
    font-size: 14px;
}

.tips-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--secondary);
    font-weight: bold;
}

/* Week View */
.week-view {
    padding: 32px 0;
}

.week-header-section {
    margin-bottom: 32px;
}

.back-link {
    color: var(--secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 14px;
    transition: gap 0.2s ease;
}

.back-link:hover {
    gap: 8px;
}

.week-header-section h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Day Cards */
.days-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.day-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    position: relative;
}

.day-card.completed {
    border-left: 4px solid var(--success);
    background: #f1f8f4;
}

.day-header {
    margin-bottom: 20px;
}

.day-title-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.day-title-section h3 {
    color: var(--primary);
    font-size: 20px;
    font-weight: 600;
}

/* Checkbox Styling - Codility style */
.checkbox-container {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    position: relative;
    padding: 8px 16px;
    background: var(--bg-hover);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.checkbox-container:hover {
    background: #e3f2fd;
}

.checkbox-container input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    height: 20px;
    width: 20px;
    background-color: var(--white);
    border: 2px solid var(--border-color);
    border-radius: 3px;
    margin-right: 8px;
    transition: all 0.2s ease;
    position: relative;
}

.checkbox-container:hover .checkmark {
    border-color: var(--secondary);
}

.checkbox-container input[type="checkbox"]:checked ~ .checkmark {
    background: var(--secondary);
    border-color: var(--secondary);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-container input[type="checkbox"]:checked ~ .checkmark:after {
    display: block;
}

.checkbox-label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* Topics and Tasks */
.topics-section,
.tasks-section {
    margin-bottom: 20px;
}

.topics-section h4,
.tasks-section h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 15px;
}

.topics-section ul {
    list-style: none;
}

.topics-section li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
    color: var(--text-secondary);
    font-size: 14px;
}

.topics-section li::before {
    content: '•';
    position: absolute;
    left: 8px;
    color: var(--secondary);
    font-weight: bold;
}

.tasks-list {
    list-style: none;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.task-item:hover {
    background: #e3f2fd;
    border-color: var(--secondary);
}

.task-name {
    color: var(--text-primary);
    flex-grow: 1;
    font-weight: 500;
    font-size: 14px;
}

.score-input {
    width: 80px;
    padding: 6px 12px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    margin-left: 16px;
    transition: all 0.2s ease;
}

.score-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 2px rgba(0, 172, 193, 0.1);
}

/* Notes Section */
.notes-section {
    margin-top: 20px;
}

.notes-section h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 15px;
}

.notes-textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.notes-textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 2px rgba(0, 172, 193, 0.1);
}

/* Lessons Page - Codility style */
.lessons-page {
    padding: 32px 0;
}

.lessons-page h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.text-muted {
    color: var(--text-muted);
    font-size: 16px;
    margin-bottom: 32px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s ease;
    overflow: hidden;
}

.card.border-primary {
    border-left: 4px solid var(--codility-orange);
    background: #fff8f0;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-body {
    padding: 24px;
}

.card-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-text {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-right: 8px;
}

.bg-primary {
    background: var(--primary);
    color: white;
}

.bi-star-fill {
    color: var(--codility-orange);
    font-size: 20px;
}

.bi-book-fill::before {
    content: '📖';
}

.bi-arrow-left::before {
    content: '←';
}

/* Lesson View - Codility reading style */
.lesson-view {
    padding: 32px 0;
}

.lesson-header {
    margin-bottom: 32px;
}

.lesson-header h1 {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 32px;
    margin-bottom: 8px;
}

.lesson-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px;
    background: var(--white);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.lesson-content h1 {
    color: var(--text-primary);
    border-bottom: 3px solid var(--primary);
    padding-bottom: 12px;
    margin-bottom: 24px;
    font-weight: 700;
    font-size: 28px;
}

.lesson-content h2 {
    color: var(--text-primary);
    margin-top: 40px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
    font-weight: 600;
    font-size: 24px;
}

.lesson-content h3 {
    color: var(--primary);
    margin-top: 28px;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 20px;
}

.lesson-content h4 {
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 16px;
}

.lesson-content code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d32f2f;
    border: 1px solid var(--gray-300);
}

.lesson-content pre {
    background: #263238;
    color: #aed581;
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 20px 0;
    border: 1px solid var(--gray-300);
    line-height: 1.5;
}

.lesson-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    border: none;
    font-size: 14px;
    line-height: 1.6;
}

.lesson-content ul,
.lesson-content ol {
    margin: 16px 0;
    padding-left: 28px;
    color: var(--text-secondary);
}

.lesson-content li {
    margin: 8px 0;
    line-height: 1.7;
}

.lesson-content li::marker {
    color: var(--secondary);
}

.lesson-content blockquote {
    border-left: 4px solid var(--secondary);
    padding: 12px 20px;
    margin: 20px 0;
    background: #e3f2fd;
    border-radius: 0 4px 4px 0;
    color: var(--text-secondary);
}

.lesson-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.lesson-content table th,
.lesson-content table td {
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    text-align: left;
}

.lesson-content table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.lesson-content table tr:nth-child(even) {
    background: var(--gray-100);
}

.lesson-content table tr:hover {
    background: #e3f2fd;
}

.lesson-content p {
    line-height: 1.8;
    margin: 16px 0;
    color: var(--text-secondary);
    font-size: 15px;
}

.lesson-content a {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.lesson-content a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.lesson-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.lesson-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 24px auto;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.lesson-content img:hover {
    box-shadow: var(--shadow-lg);
    transition: box-shadow 0.3s ease;
}

/* Syntax highlighting - Codility terminal style */
.codehilite {
    background: #263238;
    border-radius: 6px;
}

.codehilite .k {
    color: #89ddff;
}

/* keyword */
.codehilite .s {
    color: #c3e88d;
}

/* string */
.codehilite .c {
    color: #546e7a;
}

/* comment */
.codehilite .n {
    color: #eeffff;
}

/* name */
.codehilite .o {
    color: #89ddff;
}

/* operator */

/* Footer - Codility style */
footer {
    background: var(--white);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    margin-top: 64px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .navbar .container {
        flex-direction: column;
        height: auto;
        padding: 16px 24px;
        gap: 12px;
    }

    .stats-grid,
    .weeks-grid {
        grid-template-columns: 1fr;
    }

    .day-title-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .task-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .score-input {
        margin-left: 0;
        width: 100%;
    }

    .lesson-content {
        padding: 24px 16px;
    }

    .page-header h1,
    .lesson-header h1 {
        font-size: 24px;
    }

    .lesson-content h1 {
        font-size: 24px;
    }

    .lesson-content h2 {
        font-size: 20px;
    }
}

/* Utility classes */
.mt-4 {
    margin-top: 32px;
}

.mb-3 {
    margin-bottom: 24px;
}

.mb-4 {
    margin-bottom: 32px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: -8px;
}

.col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 8px;
}

@media (max-width: 768px) {
    .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Score badges */
.score-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 600;
}

.score-badge.high {
    background: #c8e6c9;
    color: #2e7d32;
}

.score-badge.medium {
    background: #fff9c4;
    color: #f57f17;
}

.score-badge.low {
    background: #ffcdd2;
    color: #c62828;
}

/* Dark Mode Toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--secondary);
}

.theme-toggle-icon {
    font-size: 16px;
}

/* Reading Progress Bar */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--secondary), var(--codility-green));
    z-index: 1000;
    transition: width 0.1s ease;
}

/* Copy Code Button */
.code-block-wrapper {
    position: relative;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e0e0e0;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.copy-code-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* Lesson Navigation */
.lesson-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
    gap: 16px;
}

.nav-lesson {
    flex: 1;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-lesson:hover {
    border-color: var(--secondary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.nav-lesson.prev {
    text-align: left;
}

.nav-lesson.next {
    text-align: right;
}

.nav-lesson-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.nav-lesson-title {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Lesson Completion Checkbox */
.lesson-complete-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-hover);
    border-radius: 8px;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}

.lesson-complete-wrapper:hover {
    background: #e3f2fd;
}

.lesson-complete-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Table of Contents */
.toc-wrapper {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 24px;
}

.toc-wrapper h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toc-wrapper ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-wrapper li {
    margin: 0;
    padding: 0;
}

.toc-wrapper a {
    display: block;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toc-wrapper a:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

.toc-wrapper a.active {
    background: #e3f2fd;
    color: var(--primary);
    font-weight: 500;
}

/* Lesson completion badge */
.lesson-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.lesson-status.completed {
    background: #c8e6c9;
    color: #2e7d32;
}

.lesson-status.in-progress {
    background: #fff9c4;
    color: #f57f17;
}

/* Smooth transitions */
body {
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark mode code block adjustments */
body.dark-mode .lesson-content code {
    background: #2d2d2d;
    border-color: var(--border-color);
    color: #ff6b6b;
}

body.dark-mode .lesson-content pre {
    background: #1a1a1a;
    border-color: var(--border-color);
}

/* Mobile responsive for new features */
@media (max-width: 768px) {
    .lesson-navigation {
        flex-direction: column;
    }

    .nav-lesson.prev,
    .nav-lesson.next {
        text-align: left;
        width: 100%;
    }

    .toc-wrapper {
        position: static;
        max-height: none;
    }
}

/* TypeScript Playground */
.playground-page {
    padding: 32px 0;
}

.playground-header {
    margin-bottom: 24px;
}

.playground-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.playground-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.template-select {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-select:hover {
    border-color: var(--secondary);
}

.template-select:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 2px rgba(0, 172, 193, 0.1);
}

.playground-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
    height: 600px;
}

.editor-panel,
.output-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-card);
}

.code-editor {
    flex: 1;
    overflow: hidden;
}

.code-output {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-placeholder {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 40px 20px;
}

.output-success {
    color: var(--success);
    background: rgba(0, 200, 83, 0.1);
    padding: 12px;
    border-radius: 4px;
    border-left: 3px solid var(--success);
}

.output-error {
    color: var(--danger);
    background: rgba(211, 47, 47, 0.1);
    padding: 12px;
    border-radius: 4px;
    border-left: 3px solid var(--danger);
}

.output-info {
    color: var(--secondary);
    background: rgba(0, 172, 193, 0.1);
    padding: 12px;
    border-radius: 4px;
    border-left: 3px solid var(--secondary);
}

.playground-tips {
    background: #e3f2fd;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--secondary);
}

.playground-tips h3 {
    color: var(--primary);
    margin-bottom: 12px;
    font-size: 16px;
    font-weight: 600;
}

.playground-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.playground-tips li {
    margin-bottom: 8px;
    padding-left: 24px;
    position: relative;
    color: var(--text-secondary);
    font-size: 14px;
}

.playground-tips li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--secondary);
    font-weight: bold;
}

.playground-tips code {
    background: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    color: var(--danger);
    border: 1px solid var(--border-light);
}

.playground-tips kbd {
    background: var(--gray-800);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: monospace;
    border: 1px solid var(--gray-700);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Dark mode playground adjustments */
body.dark-mode .playground-tips {
    background: #1a3a4a;
    border-left-color: var(--secondary);
}

body.dark-mode .playground-tips code {
    background: #2d2d2d;
    border-color: var(--border-color);
}

/* Responsive playground */
@media (max-width: 968px) {
    .playground-container {
        grid-template-columns: 1fr;
        height: auto;
    }

    .editor-panel,
    .output-panel {
        height: 400px;
    }

    .playground-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
}

/* Sidebar Playground in Lessons */
.toggle-playground-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 20px;
}

.toggle-playground-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.toggle-playground-btn.active {
    background: var(--danger);
}

.toggle-text {
    font-size: 9px;
    font-weight: 600;
    margin-top: 2px;
}

/* Edit Button */
.toggle-edit-btn {
    position: fixed;
    bottom: 24px;
    right: 96px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--warning) 0%, var(--danger) 100%);
    border: none;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 20px;
}

.toggle-edit-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.toggle-edit-btn.active {
    background: var(--success);
}

.edit-text {
    font-size: 9px;
    font-weight: 600;
    margin-top: 2px;
}

/* Lesson Editor */
.lesson-editor-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
    padding-top: 16px;
    margin: 24px 0;
    position: relative;
}

.editor-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    padding-top: 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow 0.2s ease;
}

.editor-toolbar.scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-bottom: 2px solid var(--primary);
}

.lesson-markdown-editor {
    width: 100%;
    min-height: 600px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    transition: all 0.2s ease;
}

.lesson-markdown-editor:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.1);
}

.editor-help {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-muted);
}

.save-status {
    margin-left: auto;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 4px;
}

.save-status.saving {
    color: var(--primary);
    background: rgba(13, 71, 161, 0.1);
}

/* Image upload toolbar styles */
.toolbar-divider {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    margin: 0 4px;
}

.btn-icon {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-icon:active {
    transform: translateY(1px);
}

/* Drag and drop visual feedback */
.lesson-markdown-editor.drag-over {
    border-color: var(--primary);
    background: rgba(13, 71, 161, 0.05);
    box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.1);
}

/* Dark mode adjustments for image buttons */
body.dark-mode .btn-icon {
    background: var(--bg-card);
    border-color: var(--border-color);
}

body.dark-mode .btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.save-status.success {
    color: var(--success);
    background: rgba(0, 200, 83, 0.1);
}

.save-status.error {
    color: var(--danger);
    background: rgba(211, 47, 47, 0.1);
}

.lesson-with-playground {
    display: flex;
    gap: 0;
    position: relative;
}

.lesson-view {
    flex: 1;
    transition: margin-right 0.3s ease;
}

.lesson-view.with-sidebar {
    margin-right: 480px;
}

.sidebar-playground {
    position: fixed;
    top: 64px;
    right: -480px;
    width: 480px;
    height: calc(100vh - 64px);
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 998;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-playground.open {
    right: 0;
}

.playground-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
}

.playground-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.close-playground-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close-playground-btn:hover {
    background: var(--bg-card);
    color: var(--danger);
}

.sidebar-playground-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.playground-toolbar-mini {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
}

.template-select-mini {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    cursor: pointer;
}

.btn-mini {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary-mini {
    background: var(--primary);
    color: white;
}

.btn-primary-mini:hover:not(:disabled) {
    background: var(--primary-blue-dark);
}

.btn-primary-mini:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.code-editor-mini {
    flex: 1;
    min-height: 300px;
    border-bottom: 1px solid var(--border-color);
}

.output-section-mini {
    height: 200px;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
}

.output-header-mini {
    padding: 8px 12px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.code-output-mini {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.output-success-mini {
    color: var(--success);
    background: rgba(0, 200, 83, 0.1);
    padding: 8px;
    border-radius: 4px;
    border-left: 2px solid var(--success);
}

.output-error-mini {
    color: var(--danger);
    background: rgba(211, 47, 47, 0.1);
    padding: 8px;
    border-radius: 4px;
    border-left: 2px solid var(--danger);
}

.output-info-mini {
    color: var(--secondary);
    background: rgba(0, 172, 193, 0.1);
    padding: 8px;
    border-radius: 4px;
    border-left: 2px solid var(--secondary);
}

/* Responsive sidebar playground */
@media (max-width: 1200px) {
    .sidebar-playground {
        width: 400px;
        right: -400px;
    }

    .lesson-view.with-sidebar {
        margin-right: 400px;
    }
}

@media (max-width: 968px) {
    .sidebar-playground {
        width: 100%;
        right: -100%;
        top: 0;
        height: 100vh;
    }

    .lesson-view.with-sidebar {
        margin-right: 0;
    }

    .toggle-playground-btn {
        bottom: 24px;
        right: 24px;
    }

    .toggle-edit-btn {
        bottom: 96px;
        right: 24px;
    }
}
