:root {
    /* Modern Slate/Blue Theme */
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --accent-color: #f43f5e;
    --success-color: #22c55e;
    --border-color: #334155;
    --nav-height: 64px;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Missing Variables Fix */
    --text-primary: var(--text-color);
    --text-secondary: var(--text-muted);
    --accent-primary: var(--primary-color);
    --accent-secondary: #60a5fa;
    /* Lighter blue */
    --success: var(--success-color);
}

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

.hidden {
    display: none !important;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.no-scroll {
    overflow: hidden;
    /* Prevent body scroll only on specific pages */
}

/* Ensure links and other text elements inherit color or use variables */
a {
    color: var(--primary-color);
    text-decoration: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-color);
}

/* Navbar */
.navbar {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: block;
    /* Default to block for content */
}

.container-fluid {
    width: 100%;
    padding: 0 1.5rem;
    display: block;
    /* Default to block for content */
}

/* Navbar specific container overrides */
.navbar .container,
.navbar .container-fluid {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    /* Ensure full height of navbar */
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    height: 40px;
    /* Bigger logo */
    width: auto;
    object-fit: contain;
}

.logo-img-placeholder {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    /* Prepare for border */
}

.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
}

/* Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
}

.hamburger span {
    width: 100%;
    height: 3px;
    background-color: var(--text-color);
    border-radius: 3px;
    transition: all 0.3s ease;
}

/* Mobile Menu Active State */
.nav-links.active {
    display: flex;
}

/* Hamburger Animation */
.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Hero Section */
.hero-section {
    height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
    padding-bottom: 20vh;
}

.hero-container {
    max-width: 800px;
    padding: 2rem;
}

.hero-logo {
    max-width: 250px;
    height: auto;
    margin-bottom: 0.5rem;
}

.hero-title {
    font-size: 4rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
    line-height: 1.6;
}

.hero-section .hero-btn {
    display: inline-flex;
    font-size: 1.25rem;
    padding: 1rem 2.5rem;
    border-radius: 999px;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.hero-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
}

/* Views */
.view-section {
    display: block;
    animation: fadeIn 0.3s ease;
}

.view-section.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.stat-card h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.success {
    color: var(--success-color);
}

.stat-value.warning {
    color: var(--warning-color);
}

.progress-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
}

.progress-bar-bg.large {
    height: 12px;
    margin: 1.5rem 0 1rem;
}

.progress-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* About */
.about-content {
    padding: 2rem;
    line-height: 1.8;
    max-width: 800px;
    margin: 0 auto;
}

.about-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-primary);
}

.about-content ul {
    padding-left: 1.5rem;
}

.about-content li {
    margin-bottom: 0.5rem;
}

/* Dashboard */
.dashboard-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.dashboard-container.wide {
    max-width: 1400px;
}

.dashboard-header {
    text-align: center;
    padding: 3rem 0;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--accent-primary), var(--accent-secondary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

/* Tabs */
.tabs-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem 1.5rem;
    border-radius: 999px;
    cursor: pointer;
    font-family: var(--font-main);
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #0f172a;
}

.filter-tabs {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-radius: 4px;
}

.filter-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Grid */
.patterns-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding-bottom: 4rem;
    justify-content: center;
    /* Center grid items */
}

.pattern-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: transform 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
}

.pattern-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.pattern-card.hidden {
    display: none;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.badge {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.6rem;
    border-radius: 6px;
    transition: background 0.2s;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.02);
}

.file-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.mark-done-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.mark-done-toggle:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mark-done-toggle.done {
    background: var(--success);
    border-color: var(--success);
    color: #0f172a;
}

/* Cool Lines - Visual Connectors */
.patterns-grid {
    position: relative;
}

.pattern-card {
    position: relative;
    z-index: 1;
}

.pattern-card::after {
    display: none;
}

.pattern-card:last-child::after {
    display: none;
}

/* Hide connectors on mobile or when grid wraps */
@media (max-width: 1000px) {
    .pattern-card::after {
        display: none;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 0;
    color: var(--text-secondary);
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

/* Practice View */
.practice-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--nav-height));
    overflow: hidden;
}

.practice-header {
    flex-shrink: 0;
    /* Don't shrink header */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
}

.breadcrumbs .back-link {
    font-weight: 600;
    color: var(--accent-primary);
    margin-right: 0.5rem;
}

.breadcrumbs .current-file {
    color: var(--text-primary);
    font-weight: 600;
}

.actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn.primary {
    background: var(--accent-primary);
    color: #0f172a;
}

.btn.secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn.success {
    background: var(--success);
    color: #0f172a;
}

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

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

.btn.text:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn.small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.btn.large {
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
}

/* Editor Layout */
.editor-layout {
    display: flex;
    gap: 1rem;
    padding-bottom: 1rem;
    /* Add some bottom padding */
    height: 100%;
    overflow: hidden;
    min-height: 0;
    /* Critical for nested flex scrolling */
}

.panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: flex 0.3s;
    min-width: 0;
    height: 100%;
    /* Ensure panel takes full height */
}

.panel.hidden {
    display: none;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.code-viewer-container,
.practice-container {
    display: flex;
    flex: 1;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
    /* Prevent scroll on container */
    min-height: 0;
    /* Critical for nested flex scrolling */
}

.editor-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* Critical */
}

.reference-editor-wrapper {
    height: 100%;
    flex: 1;
    overflow: hidden;
    transition: filter 0.3s;
}

.blurred-content {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
}

.code-viewer-container pre,
.editor-container .CodeMirror {
    width: 100%;
    height: 100%;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    background: transparent;
    color: var(--text-primary);
    border: none;
}

.code-viewer-container pre {
    padding: 1rem;
    overflow: auto;
}

/* CodeMirror Customization */
.CodeMirror {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
    height: 100% !important;
}

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

.blur-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: opacity 0.3s;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

.modal-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
    color: var(--text-secondary);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.icon-btn:hover {
    color: var(--text-primary);
}

.blur-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    color: var(--text-secondary);
}

.lock-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* Start Practice Hero */
.start-practice-hero {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.5));
}

.hero-content {
    max-width: 400px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 1rem;
}

.hero-content h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.hero-content p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

#practice-editor-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

#practice-editor-wrapper.hidden {
    display: none;
}

/* Console */
.console-container {
    height: 150px;
    border-top: 1px solid var(--border-color);
    background: #000;
    display: flex;
    flex-direction: column;
}

.console-header {
    padding: 0.25rem 1rem;
    background: #111;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.console-output {
    flex: 1;
    padding: 0.5rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    overflow-y: auto;
    color: #ccc;
    white-space: pre-wrap;
}

.console-output .error {
    color: #ef4444;
}

.console-output .success {
    color: #4ade80;
}

/* Parrot Meter */
.parrot-meter-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    margin-right: 1rem;
    min-width: 200px;
}

.parrot-meter-container.hidden {
    display: none;
}

.parrot-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
}

.parrot-bar-bg {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.parrot-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
    width: 0%;
    transition: width 0.5s ease-out;
}

.parrot-score {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 0.9rem;
    min-width: 3ch;
    text-align: right;
}

/* Mobile Responsiveness */
/* Mobile Responsiveness */
/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    /* Navbar Mobile */
    .hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links a {
        padding: 1rem;
        text-align: center;
        width: 100%;
    }

    .logo-text {
        font-size: 0.9rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }

    /* Hero Section Mobile Fixes */
    .hero-section {
        height: auto;
        min-height: 80vh;
        padding-top: 4rem;
        /* Push content down */
        padding-bottom: 4rem;
    }

    .hero-logo {
        max-width: 150px;
        /* Smaller logo on mobile */
    }

    .hero-title {
        font-size: 2.5rem;
    }

    /* Practice View Mobile Scrolling Fix */
    .practice-container {
        height: auto;
        overflow: visible;
        min-height: calc(100vh - var(--nav-height));
    }

    .editor-layout {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .panel {
        min-height: 500px;
        /* Give panels enough height */
        height: auto;
        overflow: visible;
        margin-bottom: 1rem;
    }

    .code-viewer-container,
    .editor-container {
        min-height: 400px;
        /* Ensure editor has height */
    }

    /* Ensure body scrolls */
    body.practice-mode {
        overflow: auto;
    }

    .practice-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .parrot-meter-container {
        width: 100%;
        margin-right: 0;
        margin-bottom: 0.5rem;
        order: -1;
    }

    .breadcrumbs {
        font-size: 0.9rem;
        flex-wrap: wrap;
    }
}

/* Markdown Styles */
.markdown-body {
    color: var(--text-primary);
    line-height: 1.6;
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    color: var(--text-primary);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

.markdown-body p {
    margin-bottom: 1em;
}

.markdown-body pre {
    background-color: #1e293b;
    /* Darker slate */
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    border: 1px solid #334155;
    margin-bottom: 1em;
}

.markdown-body code {
    font-family: 'Fira Code', monospace;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.9em;
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    color: #e2e8f0;
}

/* Footer Actions */
.footer-actions {
    display: flex;
    justify-content: center;
    margin-top: 4rem;
    margin-bottom: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

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

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

.btn.danger.outline:hover {
    background: rgba(244, 63, 94, 0.1);
}