:root {
    color-scheme: light;
    --background: #f5f5f7;
    --surface: #ffffff;
    --surface-subtle: #fbfbfd;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --separator: #d2d2d7;
    --accent: #0071e3;
    --accent-soft: rgba(0, 113, 227, 0.1);
    --code-background: #f0f0f2;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.06);
    --sidebar-width: 292px;
    --topbar-height: 64px;
    --radius: 16px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --background: #000000;
        --surface: #1c1c1e;
        --surface-subtle: #101012;
        --text: #f5f5f7;
        --text-secondary: #98989d;
        --separator: #38383a;
        --accent: #2997ff;
        --accent-soft: rgba(41, 151, 255, 0.16);
        --code-background: #2c2c2e;
        --shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --background: #000000;
    --surface: #1c1c1e;
    --surface-subtle: #101012;
    --text: #f5f5f7;
    --text-secondary: #98989d;
    --separator: #38383a;
    --accent: #2997ff;
    --accent-soft: rgba(41, 151, 255, 0.16);
    --code-background: #2c2c2e;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    overflow-x: hidden;
    background: var(--background);
    color: var(--text);
    font-family:
        -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "Helvetica Neue", Arial, sans-serif;
    font-size: 17px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

button,
a {
    font: inherit;
}

button {
    color: inherit;
}

a {
    color: var(--accent);
}

.app-shell {
    min-height: 100vh;
    padding-top: var(--topbar-height);
}

.topbar {
    position: fixed;
    z-index: 60;
    right: 0;
    top: 0;
    left: 0;
    display: flex;
    height: var(--topbar-height);
    width: 100%;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid
        color-mix(in srgb, var(--separator) 70%, transparent);
    background: color-mix(in srgb, var(--background) 86%, transparent);
    backdrop-filter: saturate(180%) blur(20px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.brand-mark,
.empty-symbol {
    color: var(--accent);
    font-size: 25px;
    line-height: 1;
}

.theme-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.theme-button {
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
}

.theme-button:hover,
.theme-button:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
    background: var(--accent-soft);
    color: var(--accent);
    outline: none;
}

.theme-symbol {
    font-size: 18px;
    line-height: 1;
}

.sidebar-toggle {
    display: inline-flex;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 10px;
    font-size: 20px;
    line-height: 1;
}

.sidebar-toggle > span {
    display: block;
    line-height: 1;
    transform: translateY(-1px);
}

.layout {
    display: block;
}

.sidebar {
    position: fixed;
    z-index: 20;
    left: 0;
    top: var(--topbar-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 18px 48px;
    border-right: 1px solid var(--separator);
    transition: transform 0.2s ease;
}

.main-content {
    min-width: 0;
    margin-left: var(--sidebar-width);
    overflow-x: hidden;
    padding: 64px clamp(24px, 5vw, 80px) 96px;
    transition: margin-left 0.2s ease;
}

.app-shell.sidebar-collapsed .sidebar {
    transform: translateX(-102%);
}

.app-shell.sidebar-collapsed .main-content {
    margin-left: 0;
}

.sidebar-heading,
.section-heading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
}

.sidebar-heading {
    padding: 0 12px 14px;
}

.eyebrow {
    margin: 0;
    color: var(--text-secondary);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.lecture-count {
    color: var(--text-secondary);
    font-size: 12px;
}

.lecture-nav {
    display: grid;
    gap: 22px;
    min-width: 0;
}

.subject-group {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.subject-title {
    min-width: 0;
    overflow: hidden;
    padding: 0 12px 4px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lecture-nav-item {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 9px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
}

.lecture-nav-item:hover,
.lecture-nav-item:focus-visible {
    background: var(--surface);
    outline: none;
}

.lecture-nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.lecture-nav-title {
    display: block;
    overflow-wrap: anywhere;
    font-size: 14px;
    line-height: 1.35;
}

.lecture-nav-description {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content-wrap {
    max-width: 940px;
    margin: 0 auto;
}

.empty-state,
.error-state {
    max-width: 620px;
    padding-top: 14vh;
}

.empty-symbol {
    margin-bottom: 24px;
    font-size: 42px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    max-width: 820px;
    margin-bottom: 18px;
    font-size: clamp(34px, 5vw, 54px);
    font-weight: 700;
    letter-spacing: -0.045em;
    line-height: 1.07;
}

h2 {
    margin-bottom: 0;
    font-size: 22px;
    font-weight: 650;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.empty-state > p:last-child,
.error-state > p:last-child {
    max-width: 470px;
    color: var(--text-secondary);
    font-size: 19px;
    line-height: 1.45;
}

.lecture-header {
    margin-bottom: 48px;
}

.lecture-header .eyebrow {
    margin-bottom: 14px;
}

.lecture-description {
    max-width: 680px;
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 19px;
    line-height: 1.45;
}

.pdf-card {
    margin-bottom: 64px;
    padding: 20px;
    border: 1px solid var(--separator);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.section-heading {
    padding: 4px 4px 18px;
}

.section-heading .eyebrow {
    margin-bottom: 6px;
}

.text-link {
    flex: 0 0 auto;
    font-size: 14px;
    text-decoration: none;
}

.text-link:hover,
.text-link:focus-visible {
    text-decoration: underline;
}

.pdf-frame {
    overflow: hidden;
    aspect-ratio: 16 / 10;
    border-radius: 10px;
    background: #fff;
}

.pdf-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.markdown-content {
    overflow-wrap: anywhere;
    font-size: 17px;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    margin-top: 2.2em;
    margin-bottom: 0.7em;
    letter-spacing: -0.025em;
    line-height: 1.2;
}

.markdown-content h1 {
    font-size: 32px;
}
.markdown-content h2 {
    font-size: 26px;
}
.markdown-content h3 {
    font-size: 21px;
}
.markdown-content h4 {
    font-size: 18px;
}

.markdown-content p,
.markdown-content ul,
.markdown-content ol,
.markdown-content blockquote,
.markdown-content table {
    margin-bottom: 1.2em;
}

.markdown-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 24px auto;
    border-radius: 10px;
}

.markdown-content li + li {
    margin-top: 0.35em;
}

.markdown-content blockquote {
    margin-left: 0;
    padding: 4px 0 4px 18px;
    border-left: 3px solid var(--accent);
    color: var(--text-secondary);
}

.markdown-content code {
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--code-background);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
}

.markdown-content pre {
    overflow-x: auto;
    padding: 16px;
    border-radius: 10px;
    background: var(--code-background);
}

.markdown-content pre code {
    padding: 0;
    background: transparent;
}

.markdown-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.markdown-content th,
.markdown-content td {
    padding: 9px 12px;
    border: 1px solid var(--separator);
    text-align: left;
}

.markdown-content hr {
    margin: 40px 0;
    border: 0;
    border-top: 1px solid var(--separator);
}

[hidden] {
    display: none !important;
}

.sidebar-backdrop {
    display: none;
}

@media (max-width: 760px) {
    .topbar {
        padding: 0 16px;
    }

    .sidebar-toggle {
        flex: 0 0 36px;
    }

    .theme-label {
        display: none;
    }

    .layout {
        display: block;
    }

    .sidebar {
        position: fixed;
        z-index: 50;
        top: var(--topbar-height);
        bottom: 0;
        left: 0;
        width: min(88vw, 340px);
        height: auto;
        border-right: 1px solid var(--separator);
        background: var(--background);
        transform: translateX(-102%);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .app-shell.sidebar-collapsed .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 40;
        inset: var(--topbar-height) 0 0;
        border: 0;
        background: rgba(0, 0, 0, 0.35);
    }

    .sidebar-backdrop.is-visible {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 40px 20px 72px;
    }

    .lecture-header {
        margin-bottom: 34px;
    }

    .lecture-description,
    .empty-state > p:last-child,
    .error-state > p:last-child {
        font-size: 17px;
    }

    .pdf-card {
        margin-right: -4px;
        margin-bottom: 48px;
        margin-left: -4px;
        padding: 12px;
        border-radius: 14px;
    }

    .section-heading {
        align-items: center;
        padding: 6px 4px 14px;
    }

    .section-heading h2 {
        font-size: 19px;
    }

    .pdf-frame {
        aspect-ratio: 4 / 3;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
