:root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-soft: #f9fafb;
    --border: #e5e7eb;
    --ink: #111827;
    --muted: #6b7280;
    --accent: #111827;
    --accent-strong: #000000;
    --accent-soft: #f3f4f6;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --radius-lg: 8px;
    --radius-md: 6px;
    --code-bg: #f3f4f6;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #09090b;
    --surface: #09090b;
    --surface-soft: #18181b;
    --border: #27272a;
    --ink: #f4f4f5;
    --muted: #a1a1aa;
    --accent: #ffffff;
    --accent-strong: #ffffff;
    --accent-soft: #27272a;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --code-bg: #27272a;
}

* {
    box-sizing: border-box;
}

/* Toegankelijkheid: duidelijke rand bij toetsenbord-navigatie */
:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
    border-radius: 4px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--ink);
    background: var(--bg);
    transition: background 0.4s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
    border: 2px solid var(--surface-soft);
}

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.topbar.card {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--surface);
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    z-index: 10;
}

.topbar-copy .eyebrow {
    display: inline-block;
    background: var(--ink);
    color: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.topbar-copy h1 {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 600;
}

.topbar-copy p {
    display: none;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
    gap: 6px;
}

.button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.button-primary {
    background: var(--ink);
    color: var(--bg);
}
.button-primary:hover {
    opacity: 0.85;
}

.button-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--ink);
}
.button-ghost:hover {
    background: var(--surface-soft);
}

.button-compact {
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.8rem;
}

.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    margin: 0;
}

.sidebar {
    width: 320px;
    flex-shrink: 0;
    background: var(--surface-soft);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 36px;
}

.panel {
    padding: 0;
}

.panel.card {
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.panel h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.panel p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.4;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chapter-nav {
    margin-top: 12px;
    display: grid;
    gap: 4px;
}

.chapter-button {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    text-align: left;
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chapter-button:hover {
    background: var(--surface);
    color: var(--ink);
}

.chapter-button.active {
    background: var(--ink);
    color: var(--bg);
    font-weight: 500;
}

.chapter-button small {
    opacity: 0.6;
}

.search-label {
    display: block;
    margin: 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 18px;
    height: 18px;
    color: var(--muted);
    pointer-events: none;
}

.search-row {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

#searchInput {
    width: 100%;
    min-height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    padding: 0 12px 0 38px;
    font-size: 0.95rem;
    box-shadow: var(--shadow);
}

#searchInput:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 1px var(--ink);
}

.search-hint {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.active-filter-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 12px;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--ink);
    font-size: 0.85rem;
}

.keyword-bank {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 260px;
    overflow: auto;
    padding-right: 2px;
}

.keyword-bank.is-hidden {
    display: none;
}

.keyword-pill {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--radius-md);
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}

.keyword-pill:hover {
    border-color: var(--ink);
}

.keyword-pill.active {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 48px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.content > * {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

.chapter-hero.card {
    padding: 0 0 32px 0;
    border: none;
    background: transparent;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.chapter-hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.chapter-hero h2 {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.chapter-hero p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.5;
}

.chapter-pill {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 500;
}

.chapter-bullets {
    margin: 20px 0 0;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.6;
}

.pdf-study.card {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.pdf-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.pdf-head h2 {
    margin: 0;
    font-size: 1.25rem;
}

.pdf-head p {
    margin: 8px 0 0;
    color: var(--muted);
}

.main-pdf-frame {
    width: 100%;
    min-height: clamp(520px, 72vh, 920px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: #ffffff;
}

:root[data-theme="dark"] .main-pdf-frame {
    background: #f6f6f6;
}

.lesson-jump.card {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0 0 32px 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.lesson-jump h2 {
    margin: 0;
    font-size: 1.25rem;
}

.lesson-jump-links {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lesson-jump-link {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.lesson-jump-link:hover {
    border-color: var(--ink);
}

.lesson-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 24px;
}

.lesson-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.lesson-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.lesson-code {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    padding: 2px 8px;
    font-weight: 600;
}

.lesson-meta {
    font-size: 0.85rem;
    color: var(--muted);
}

.lesson-card h3 {
    margin: 16px 0 0;
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.lesson-summary {
    margin: 10px 0 0;
    color: var(--ink);
    line-height: 1.6;
    font-size: 0.95rem;
}

.lesson-explain-list {
    margin: 16px 0 0;
    padding-left: 20px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.lesson-tags {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lesson-tag {
    background: var(--surface-soft);
    color: var(--muted);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    padding: 2px 8px;
}

.lesson-actions {
    margin-top: auto;
    padding-top: 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-state {
    padding: 40px;
    text-align: center;
    border: 1px dashed var(--border);
    background: transparent;
    box-shadow: none;
    border-radius: var(--radius-lg);
}

.empty-state h2 {
    margin: 0;
    font-size: 1.2rem;
}

.empty-state p {
    margin: 8px 0 0;
    color: var(--muted);
}

code {
    border-radius: 0.4rem;
    background: var(--code-bg);
    padding: 0.08rem 0.3rem;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.85em;
}

/* ==========================================================================
   6. Responsive Design (Mobiel / Tablet)
   ========================================================================== */
@media (max-width: 980px) {
    html, body {
        overflow: auto; /* Zet scroll terug op body voor mobiel */
    }

    .app-shell {
        height: auto;
    }

    .workspace {
        flex-direction: column;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 24px;
    }

    .content {
        overflow: visible;
        padding: 24px;
        gap: 32px;
    }

    .main-pdf-frame {
        min-height: 60vh;
    }
}
