@font-face {
    font-family: "Noto Sans Thai";
    src: url("assets/noto-sans-thai-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
    font-family: "Noto Sans Thai";
    src: url("assets/noto-sans-thai-thai-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0E01-0E5B,U+200C-200D,U+25CC;
}

@font-face {
    font-family: "Noto Serif Thai";
    src: url("assets/noto-serif-thai-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0000-00FF,U+2000-206F;
}

@font-face {
    font-family: "Noto Serif Thai";
    src: url("assets/noto-serif-thai-thai-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
    unicode-range: U+0E01-0E5B,U+200C-200D,U+25CC;
}

:root {
    color-scheme: light;
    font-family: "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
    color: #22304a;
    background: #f5f1e8;
    --ink: #182642;
    --muted: #566279;
    --accent: #294f87;
    --line: #dedbd1;
    --soft: #e8edf6;
    --header: 64px;
    --navy: #142443;
    --paper: #fffdf8;
    --peach: #ffad8b;
    --display: "Noto Serif Thai", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input { font: inherit; }
:focus-visible { outline: 2px solid #3f62a0; outline-offset: 3px; }
button { cursor: pointer; }

.visually-hidden, .skip:not(:focus) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip:focus {
    position: fixed;
    z-index: 4;
    top: 12px;
    left: 12px;
    padding: 10px 16px;
    background: white;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    min-height: var(--header);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 26px;
    color: #f9faf5;
    background: #142443;
}

.brand, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.brand { font-size: 18px; font-weight: 700; }
.brand small { margin-inline-start: 10px; color: #d2e0d2; font-size: 13px; font-weight: 400; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 1px solid #657493;
    border-radius: 8px;
    color: #e2ebde;
    font: 600 15px/1 Georgia, serif;
    letter-spacing: .04em;
}

.topbar button {
    padding: 6px 11px;
    border: 1px solid #607194;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font-size: 14px;
    white-space: nowrap;
}
.topbar button:hover, .topbar button[aria-expanded="true"] { background: #2d4064; }
.topbar button:focus-visible { outline-color: #ffad8b; }
#subjects-toggle { display: none; }

.layout {
    max-width: 1600px;
    min-height: calc(100vh - var(--header));
    margin-inline: auto;
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
}

.subjects {
    position: sticky;
    top: var(--header);
    align-self: start;
    min-height: calc(100dvh - var(--header));
    max-height: calc(100dvh - var(--header));
    overflow-y: auto;
    padding: 27px 16px 22px;
    border-inline-end: 1px solid var(--line);
    background: #ede9df;
}
.subjects-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding-inline: 5px; }
.course-count { margin-inline-start: auto; color: var(--muted); font-size: 12px; font-weight: 400; }
#course-search {
    width: 100%;
    margin-block: 12px 18px;
    padding: 9px 10px;
    border: 1px solid #ccc8bd;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
}
#course-search::placeholder { color: var(--muted); }
#course-list details + details { margin-top: 4px; }
summary { cursor: pointer; }
#course-list summary, .contents summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    color: var(--ink);
    font-weight: 700;
    list-style: none;
}
summary::-webkit-details-marker { display: none; }
#course-list summary::before, .contents summary::before {
    content: "";
    width: 6px;
    height: 6px;
    border-inline-end: 1.5px solid currentColor;
    border-block-start: 1.5px solid currentColor;
    transform: rotate(45deg);
}
details[open] > summary::before { rotate: 90deg; }
#course-list summary:hover, .contents summary:hover { background: var(--soft); }
.course-link {
    display: block;
    margin: 3px 0 3px 10px;
    padding: 7px 10px;
    border-inline-start: 2px solid transparent;
    border-radius: 5px;
    color: #35445e;
    font-size: 14px;
    line-height: 1.4;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.course-code {
    display: block;
    margin-bottom: 2px;
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .035em;
}
.course-link:hover { background: var(--soft); }
.course-link[aria-current] { background: #e1e8f2; border-inline-start-color: #4567a1; color: var(--ink); font-weight: 700; }
.no-results { color: var(--muted); font-size: 14px; padding-inline: 5px; }

.workspace {
    display: grid;
    grid-template-areas: "meta toc" "article toc";
    grid-template-columns: minmax(0, 1fr) 218px;
    grid-template-rows: auto 1fr;
    column-gap: clamp(24px, 3vw, 48px);
    align-content: start;
    padding: 35px clamp(24px, 3.4vw, 54px) 70px;
    outline: none;
}
.document-meta {
    grid-area: meta;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px 14px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 13px;
}
#course-label { margin-inline-start: 9px; font-weight: 700; color: var(--accent); }
#course-label::before { content: "/"; margin-inline-end: 9px; color: var(--muted); font-weight: 400; }
#source-link { text-decoration: underline; text-underline-offset: 3px; }

.contents {
    grid-area: toc;
    position: sticky;
    top: calc(var(--header) + 20px);
    align-self: start;
    padding-inline-start: 13px;
    border-inline-start: 1px solid var(--line);
}
.contents summary { font-size: 14px; }
#contents-list { max-height: calc(100dvh - var(--header) - 78px); overflow: auto; padding: 4px 5px 8px; }
.topic-link {
    display: block;
    padding: 5px 4px 5px 8px;
    border-inline-start: 2px solid transparent;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
    text-decoration: none;
    overflow-wrap: anywhere;
}
.topic-link.depth-0 { font-weight: 700; color: #304767; }
.topic-link.depth-1 { padding-inline-start: 15px; }
.topic-link.depth-2 { padding-inline-start: 21px; }
.topic-link.depth-3 { padding-inline-start: 27px; }
.topic-link:hover, .topic-link[aria-current] { background: var(--soft); color: var(--accent); }
.topic-link[aria-current] { border-inline-start-color: #4567a1; }

.message { grid-area: 1 / 1 / -1 / -1; padding-block: 24px; align-self: start; }
.message h1 { font-size: 27px; color: var(--ink); }
.message p { color: var(--muted); }
.message button {
    padding: 9px 15px;
    border: 0;
    border-radius: 6px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}
.message button:hover { background: #1d3a68; }

.markdown { grid-area: article; min-width: 0; font-size: 17px; line-height: 1.78; overflow-wrap: break-word; }
.markdown :is(h1, h2, h3, h4, h5, h6) { color: var(--ink); line-height: 1.34; scroll-margin-top: calc(var(--header) + 24px); }
.markdown :is(h1, h2, h3, h4, h5, h6):focus { outline: none; }
.markdown h1 { margin: 1.5em 0 .6em; font-size: clamp(28px, 2.65vw, 41px); line-height: 1.26; }
.markdown > h1:first-child { margin-top: 0; margin-bottom: .85em; }
.markdown h2 { margin: 1.65em 0 .65em; font-size: clamp(23px, 1.85vw, 29px); }
.markdown h3 { margin: 1.5em 0 .5em; font-size: 21px; }
.markdown h4 { margin: 1.35em 0 .45em; font-size: 18px; }
.markdown p { margin: .65em 0 1em; }
.markdown strong { color: var(--ink); }
.markdown a { text-decoration-thickness: 1px; text-underline-offset: 3px; overflow-wrap: anywhere; }
.markdown a:hover { color: #152d58; }
.markdown :is(ul, ol) { margin: .55em 0 .95em; padding-inline-start: 1.65em; }
.markdown li { margin-block: .27em; }
.markdown li > :is(ul, ol) { margin-block: .2em .55em; }
.markdown li::marker { color: #5273a5; }
.markdown blockquote {
    margin: 1.25em 0;
    padding: .12em 1em;
    border-inline-start: 3px solid #8ba0c5;
    border-radius: 0 5px 5px 0;
    background: #eef1f7;
    color: #3c4b64;
    font-size: .94em;
}
.markdown blockquote :is(p, ul, ol) { margin-block: .55em; }
.markdown .references { margin: 1em 0; }
.markdown .references summary { width: fit-content; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-size: 15px; }
.markdown hr { margin: 1.8em 0; height: 1px; border: 0; background: var(--line); }
.markdown code { padding: .12em .3em; border-radius: 4px; background: #eceff6; font: .9em ui-monospace, Consolas, monospace; }
.markdown pre { padding: 12px 15px; overflow: auto; background: #eceff6; border-radius: 6px; }
.markdown pre code { padding: 0; }
.markdown img { max-width: 100%; height: auto; }
.markdown .katex { display: inline-block; max-inline-size: 100%; overflow-x: auto; vertical-align: middle; }
.display-math { display: block; overflow-x: auto; padding-block: .3em; }
.table-wrap { margin: 1.15em 0 1.5em; overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.markdown table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: .91em; line-height: 1.55; }
.markdown :is(th, td) { padding: 9px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
.markdown th { min-width: 8ch; color: var(--ink); background: #e5ebf6; text-align: start; }
.markdown td { min-width: 9ch; }
.markdown tbody tr:nth-child(even) { background: #f3f5fa; }
.markdown tbody tr:last-child td { border-bottom: 0; }

@media (max-width: 1100px) {
    .workspace { grid-template-areas: "meta" "toc" "article"; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
    .contents { position: static; margin-bottom: 16px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px; }
    #contents-list { max-height: 260px; }
}

@media (max-width: 760px) {
    :root { --header: 58px; }
    .topbar { padding: 9px 14px; }
    .brand, .topbar-actions { gap: 7px; }
    .brand { font-size: 16px; }
    .brand small { display: none; }
    .brand-mark { width: 30px; height: 30px; }
    .topbar button { padding-inline: 8px; font-size: 13px; }
    #subjects-toggle { display: block; }
    .layout { display: block; }
    .subjects {
        display: none;
        position: fixed;
        z-index: 2;
        inset: var(--header) 0 auto;
        min-height: 0;
        max-height: calc(100dvh - var(--header));
        padding: 17px;
        border: 0;
        border-bottom: 1px solid var(--line);
        box-shadow: 0 10px 20px #24382a20;
    }
    .subjects.open { display: block; }
    .workspace { padding: 23px 17px 54px; }
    .markdown { font-size: 16px; }
    .markdown h1 { font-size: 28px; }
    .markdown h3 { font-size: 19px; }
}

.quiz-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 5px 12px;
    border: 1px solid #657493;
    border-radius: 8px;
    color: #f9faf5;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.quiz-switch:hover { background: #304568; }
.quiz-switch:focus-visible { outline-color: #ffad8b; }
.in-quiz :is(#subjects-toggle, #pick-folder, #reload) { display: none; }

.quiz { max-width: 880px; margin: auto; padding: 26px 22px 48px; color: var(--ink); }
.quiz:focus { outline: none; }
.quiz-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.quiz-header h1 { margin: 0; font-size: clamp(24px, 4.5vw, 34px); line-height: 1.2; }
.quiz-header label { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.quiz-header select, .quiz button {
    min-height: 40px;
    padding: 6px 12px;
    border: 1px solid #ccd1df;
    border-radius: 8px;
    background: white;
    color: var(--ink);
    font: inherit;
}
.quiz button:hover:enabled { border-color: var(--accent); }
.quiz button:disabled { opacity: .55; cursor: default; }
.quiz-score { margin: 20px 0 3px; color: var(--muted); font-variant-numeric: tabular-nums; }
.quiz progress { display: block; width: 100%; height: .45rem; accent-color: var(--accent); }
.quiz-card {
    margin-top: 18px;
    padding: clamp(14px, 3vw, 27px);
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    overflow-wrap: anywhere;
}
.quiz-position { margin: 0 0 8px; color: var(--muted); font-size: .9rem; font-weight: 650; }
#quiz-case { margin: 0 0 20px; }
#quiz-case h2 {
    margin: 4px 0 12px;
    font-size: clamp(1.2rem, 3vw, 1.65rem);
    line-height: 1.25;
    scroll-margin-top: calc(var(--header) + 18px);
}
#quiz-case :is(details, .patient-current) {
    padding: 11px 13px;
    border-radius: 8px;
    background: #f4f7f3;
}
#quiz-case details { margin: 6px 0; border: 1px solid var(--line); }
#quiz-case summary { cursor: pointer; color: var(--accent); font-weight: 600; }
#quiz-case .patient-current { margin-top: 8px; border-left: 3px solid #8ba2ca; }
#quiz-case h3 { margin: 0; font-size: 1rem; }
#quiz-case p { margin: 7px 0 0; line-height: 1.65; }
#quiz-case figure { margin: 12px 0 0; }
#quiz-case img {
    display: block;
    width: 100%;
    max-width: 720px;
    height: auto;
    border-radius: 5px;
    border: 1px solid var(--line);
    background: white;
}
#quiz-case figcaption, .quiz-unlock { margin: 7px 0 0; color: var(--muted); font-size: .9rem; }
#quiz-extra-references { margin: 5px 0 0; padding-left: 20px; }
.quiz-card fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.quiz-card legend {
    padding: 0;
    font-size: 1.15rem;
    font-weight: 650;
    line-height: 1.55;
    scroll-margin-top: calc(var(--header) + 18px);
}
#quiz-options { display: grid; gap: 8px; margin: 16px 0; }
#quiz-options label {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    line-height: 1.5;
}
#quiz-options label:has(input:enabled) { cursor: pointer; }
#quiz-options label:has(input:enabled:hover), #quiz-options label:has(input:enabled:checked) {
    border-color: var(--accent);
    background: var(--soft);
}
#quiz-options input { flex: 0 0 auto; margin: 0; accent-color: var(--accent); }
.quiz button.quiz-primary { color: white; background: var(--accent); font-weight: 700; }
#quiz-feedback { border-top: 1px solid var(--line); padding-top: 16px; }
#quiz-result { margin: 0; font-size: 1.25rem; scroll-margin-top: calc(var(--header) + 18px); }
#quiz-result[data-state="correct"] { color: #215940; }
#quiz-result[data-state="incorrect"] { color: #913b34; }
#quiz-rationales { display: grid; gap: 8px; padding: 0; list-style: none; }
#quiz-rationales li { padding: 10px 12px; background: #f6f7f6; border-left: 3px solid var(--line); }
#quiz-rationales p { margin: 4px 0 0; line-height: 1.55; }
.quiz-option-status { display: block; color: var(--muted); font-size: .84rem; }
.quiz :is(#quiz-options label, #quiz-rationales li, .quiz-grid button)[data-state="correct"] {
    border-color: #83a995;
    background: #e7f3ea;
}
.quiz :is(#quiz-options label, #quiz-rationales li, .quiz-grid button)[data-state="incorrect"] {
    border-color: #c9918a;
    background: #fff0ed;
}
.quiz-navigation { display: flex; justify-content: space-between; gap: 8px; margin: 14px 0; }
.quiz-overview { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.quiz-overview summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.quiz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; margin: 12px 0; }
.quiz-grid button { padding-inline: 0; font-variant-numeric: tabular-nums; }
.quiz-grid [aria-current] { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.case-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 232px), 1fr)); }
.case-grid section { padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
.case-grid h3 { margin: 0 0 6px; font-size: .92rem; }
.case-grid-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }

@media (max-width: 480px) {
    .quiz { padding: 18px 12px 32px; }
    .quiz-header h1 { width: 100%; }
    .quiz-switch { padding-inline: 10px; }
    body:not(.in-quiz) .brand small { display: none; }
    #quiz-case :is(details, .patient-current) { padding-inline: 9px; }
}

#contents-toggle { display: none; }
.brand { width: fit-content; color: #fff4e4; text-decoration: none; line-height: 1; }
.brand-name { font-weight: 500; color: #d3d9e6; }
.brand-mark { color: var(--peach); background: #27395d; font: 650 27px/1 system-ui, sans-serif; }
.brand:focus-visible, .topbar button:focus-visible, .quiz-switch:focus-visible { outline-color: var(--peach); }
.topbar-actions { gap: 8px; }
.topbar button { min-height: 38px; }
.topbar .quiz-switch {
    min-height: 38px;
    border-color: var(--peach);
    border-radius: 999px;
    background: var(--peach);
    color: var(--navy);
    padding-inline: 16px;
}
.topbar .quiz-switch:hover, .library-actions button:hover { background: #ffd0bb; border-color: #ffd0bb; }
.in-quiz .topbar .quiz-switch { color: #fff4e4; background: transparent; border-color: #66758f; }
.in-quiz #contents-toggle, .in-quiz .reading-progress { display: none !important; }

.reading-progress {
    appearance: none;
    position: absolute;
    inset: auto 0 0;
    width: 100%;
    height: 3px;
    border: 0;
    background: transparent;
    color: var(--peach);
}
.reading-progress::-webkit-progress-bar { background: transparent; }
.reading-progress::-webkit-progress-value { background: var(--peach); }
.reading-progress::-moz-progress-bar { background: var(--peach); }

.subjects-header { padding-block: 1px 3px; color: var(--ink); }
#course-list { margin-top: 6px; }
.course-link, #course-list summary { font-weight: 590; }
.course-link[aria-current] { background: #e1e8f2; }
.course-code, .library-code { font-variant-numeric: tabular-nums; }
.document-meta > div { display: flex; align-items: center; flex-wrap: wrap; gap: 0 9px; }
.library-return { text-underline-offset: 3px; }
#course-label { margin-inline-start: 0; }
#block-label::before { content: "/"; margin-inline-end: 9px; }
#topic-search, #library-search {
    width: 100%;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: var(--paper);
    font: inherit;
    font-size: 14px;
}
#topic-search { margin: 6px 0 8px; }
#contents-list { max-height: calc(100dvh - var(--header) - 125px); }
.markdown > h1:first-child {
    font-family: var(--display);
    letter-spacing: -.022em;
    text-wrap: pretty;
}
.markdown .references { padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; }
.quiz-header h1 { font-family: var(--display); font-size: clamp(26px, 4.5vw, 40px); }
.quiz-card, .quiz-overview { background: var(--paper); }
#quiz-case :is(details, .patient-current) { background: #f0f3f8; }
#quiz-case .patient-current { border-inline-start-color: #89a2cd; }

.in-library .workspace { grid-template: "library" auto / minmax(0, 1fr); }
.library { grid-area: library; min-width: 0; width: min(100%, 1120px); margin-inline: auto; }
.library-hero {
    isolation: isolate;
    position: relative;
    overflow: hidden;
    display: grid;
    align-items: center;
    min-height: 361px;
    padding: clamp(30px, 4vw, 58px);
    border: 1px solid #304367;
    border-radius: 20px 20px 20px 4px;
    background: #142443;
    color: #fff4e4;
    box-shadow: 0 14px 35px #17274a1c;
}
.library-hero::after {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    background:
        linear-gradient(90deg, #142443 15%, #142443eb 33%, #14244360 58%, #14244300 86%),
        url("assets/library-atlas.webp") center right / auto 115% no-repeat;
}
.library-intro { max-width: 540px; }
.library-count {
    margin: 0 0 13px;
    font-size: .83rem;
    font-weight: 650;
    letter-spacing: .07em;
    color: var(--peach);
}
.library-hero h1 {
    margin: 0;
    font: 740 clamp(47px, 5.5vw, 77px)/1.17 var(--display);
    letter-spacing: -.035em;
    color: #fff5e7;
    outline: none;
}
.library-description { margin: 15px 0 23px; color: #e6eaf3; font-size: 1rem; line-height: 1.6; }
.library-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.library-actions :is(button, a) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 7px 16px;
    border-radius: 50rem;
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
}
.library-actions :is(button, a):focus-visible { outline-color: var(--peach); }
.library-actions button { border: 1px solid var(--peach); background: var(--peach); color: var(--navy); }
.library-secondary { border: 1px solid #8e9bb1; background: #1f3052a3; color: #fff5e7; }
.library-secondary:hover { background: #37486a; }
.library-section { margin-top: 38px; scroll-margin-top: calc(var(--header) + 16px); }
.library-section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.library-section-header h2 { margin: 0; font-family: var(--display); font-size: 30px; line-height: 1.15; }
#library-search { width: min(100%, 255px); }
.library-blocks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.library-block {
    min-width: 0;
    padding: 17px 17px 9px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--paper);
}
.library-block h3 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 11px;
    margin: 0 0 12px;
    padding: 0 3px;
    color: var(--ink);
    font-size: 1rem;
}
.block-number {
    padding: 3px 9px;
    border-radius: 5px;
    background: #e6ebf6;
    color: #294a7e;
    font-size: 11px;
    font-weight: 740;
    letter-spacing: .055em;
    white-space: nowrap;
}
.library-block ul { padding: 0; margin: 0; list-style: none; }
.library-block li { border-top: 1px solid var(--line); }
.library-course {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 18px;
    align-items: center;
    gap: 11px;
    padding: 10px 3px;
    border-radius: 4px;
    text-decoration: none;
    line-height: 1.42;
    color: var(--ink);
}
.library-course:hover { background: #f2f4f8; }
.library-code {
    padding: 5px 0;
    border: 1px solid #d7deec;
    border-radius: 6px;
    color: #294a7e;
    text-align: center;
    font-size: .77rem;
    font-weight: 680;
}
.library-course strong { display: block; font-size: .91rem; overflow-wrap: anywhere; }
.library-course small { display: block; margin-top: 2px; color: var(--muted); font-size: .72rem; }
.library-arrow { color: #446299; text-align: end; }

@media (min-width: 761px) and (max-width: 950px) {
    .library-blocks { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1100px) {
    .in-document #contents-toggle { display: block; }
    #contents-list { max-height: 260px; }
    .contents { scroll-margin-top: calc(var(--header) + 12px); }
}
@media (max-width: 760px) {
    .topbar { padding-inline: 12px; }
    .topbar-actions { gap: 5px; }
    .topbar button, .topbar .quiz-switch { min-height: 36px; }
    .topbar button { padding-inline: 8px; }
    .topbar .quiz-switch { padding-inline: 12px; }
    #reload, #pick-folder { display: none; }
    .library { padding-bottom: 8px; }
    .library-hero { min-height: 316px; padding: 27px 22px; border-radius: 16px 16px 16px 4px; }
    .library-hero::after {
        background:
            linear-gradient(90deg, #142443 0%, #142443e8 30%, #1424436b 86%),
            url("assets/library-atlas.webp") 76% center / cover no-repeat;
    }
    .library-hero h1 { font-size: clamp(42px, 9vw, 59px); }
    .library-description { max-width: 240px; margin: 12px 0 18px; font-size: .9rem; }
    .library-actions :is(button, a) { padding-inline: 12px; font-size: .84rem; }
    .library-section { margin-top: 27px; }
    .library-section-header h2 { font-size: 24px; }
    #library-search { width: min(100%, 195px); }
}
@media (max-width: 580px) {
    .library-blocks { grid-template-columns: minmax(0, 1fr); gap: 13px; }
}
@media (max-width: 350px) {
    .topbar { padding-inline: 8px; }
    .topbar-actions { gap: 4px; }
    .brand { font-size: 14px; }
    .brand-mark { width: 26px; height: 26px; font-size: 23px; }
    .topbar button, .topbar .quiz-switch { padding-inline: 7px; }
    .library-section-header { align-items: start; flex-direction: column; }
    #library-search { width: 100%; }
}

@media print {
    .topbar, .subjects, .contents, .skip, #source-link { display: none !important; }
    .layout, .workspace { display: block; padding: 0; }
    :root { color: #000; background: #fff; }
    .markdown { font-size: 11pt; }
    .markdown :is(h1, h2, h3, h4) { break-after: avoid; }
    .table-wrap { overflow: visible; }
    .markdown table { min-width: 0; }
}
