/* 课程目录统一布局：触控、键盘操作与章节快速切换。 */

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

:is(
    .top-nav a,
    .top-nav button,
    .chapter-card,
    .tool-card,
    .subject-home-bottom-link,
    .course-page-step
):focus-visible {
    outline: 3px solid #7dd3fc;
    outline-offset: 3px;
}

/* 721–900px 仍保留双列，避免平板页面变成过长的单列。 */
@media (min-width: 721px) and (max-width: 900px) {
    .main-content.full-width .chapter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .main-content.full-width .chapter-grid {
        grid-template-columns: 1fr;
    }
}

/* Compact chapter directory, scoped to course pages. */
.course-directory .main-content.full-width {
    max-width: 960px;
    padding: 4px .65rem .4rem;
}
.course-directory .main-content.full-width > .content-body > .home-section {
    margin: 0;
    padding: 0;
}
.course-directory .main-content.full-width .phase-label {
    display: flex;
    width: 100%;
    min-height: 0;
    gap: .6rem;
    margin: .45rem 0 .2rem;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    background: none !important;
    color: var(--theme-muted, #94a3b8) !important;
    font-size: .68rem;
    font-weight: 500;
    line-height: 1.4;
}
.course-directory .phase-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--theme-border, #334155);
}
.course-directory .main-content.full-width .chapter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 .2rem;
    margin: 0;
    padding: 0;
    border: 1px solid var(--theme-border, #334155);
    border-radius: 8px;
    background: var(--theme-surface, #1e293b);
}
.course-directory .main-content.full-width .chapter-card {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 44px;
    gap: .25rem;
    padding: .2rem .35rem;
    border: 0 !important;
    border-radius: 4px;
    background: transparent !important;
    box-shadow: none !important;
    transform: none;
}
.course-directory .main-content.full-width .chapter-card:nth-child(n + 3) {
    border-top: 1px solid rgba(148, 163, 184, .12) !important;
}
.course-directory .main-content.full-width .chapter-card:hover {
    background: rgba(56, 189, 248, .1) !important;
}
.course-directory .chapter-card:focus-visible { outline-offset: -3px; }
.course-directory .main-content.full-width .chapter-card .ch-body { flex: 1; min-width: 0; }
.course-directory .main-content.full-width .chapter-card .ch-num {
    flex: 0 0 18px;
    width: 18px;
    height: auto;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: #7dd3fc !important;
    font-size: .72rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.course-directory .main-content.full-width .chapter-card h3 {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: .78rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0;
}
.course-directory .chapter-card p { display: none; }
.course-directory .main-content.full-width > .content-body > .course-tools {
    margin-top: .7rem;
    padding-top: .4rem;
    border-top: 1px solid var(--theme-border, #334155);
}
.course-tools > summary, .course-sidebar-tools > summary {
    min-height: 44px;
    padding: .5rem 0;
    cursor: pointer;
    font-size: .78rem;
    color: var(--theme-muted, #94a3b8);
}
.course-tools > summary span { margin-left: .4rem; font-size: .7rem; }
.course-directory .main-content.full-width .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
}
.course-directory .main-content.full-width .tool-card { min-height: 44px; padding: .5rem .6rem; gap: .4rem; }
.course-directory .main-content.full-width .tool-icon { font-size: 1rem; }
.course-directory .main-content.full-width .tool-name { font-size: .78rem; }
.course-directory .tool-desc { display: none; }

/* Course heading and direct chapter paging share one compact header row. */
.course-module .top-nav .course-brand-back {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
    min-height: 44px;
}
.course-brand-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.course-back-arrow { flex-shrink: 0; font-size: 1rem; font-weight: 400; }
.course-module .course-reading-nav { gap: .7rem; }
.course-reader-heading { display: flex; align-items: center; gap: .4rem; flex: 1; min-width: 0; }
.course-module .course-reading-nav .course-brand-back { font-size: 1rem; }
.course-current-chapter {
    flex-shrink: 0;
    padding: .15rem .35rem;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 5px;
    background: rgba(255, 255, 255, .08);
    color: #dbeafe;
    font-size: .65rem;
    font-weight: 400;
    line-height: 1.4;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.course-page-controls {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 7px;
    background: rgba(15, 23, 42, .08);
}
.course-module .course-page-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 .55rem;
    color: #f1f5f9;
    font-size: .73rem;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
}
.course-page-step + .course-page-step { border-left: 1px solid rgba(255, 255, 255, .16); }
.course-module a.course-page-step:hover { background: rgba(255, 255, 255, .15); color: white; }
.course-module .course-page-step.is-disabled { color: rgba(241, 245, 249, .35); }
.course-module .course-page-step:focus-visible { outline-offset: -3px; }
@media (max-width: 600px) {
    .course-module .course-reading-nav { gap: .4rem; padding: 0 .65rem; }
    .course-module .course-reading-nav .course-brand-back { font-size: .92rem; gap: .3rem; }
    .course-reader-heading { gap: .3rem; }
    .course-module .course-page-step { padding: 0 .45rem; font-size: .7rem; }
}
/* The reading introduction contains only its title and useful summary. */
.course-module .course-article-heading {
    padding: .8rem 1.2rem .65rem;
}
.course-module .course-article-heading h1 {
    margin: 0;
    font-size: clamp(1.25rem, 2.5vw, 1.6rem);
    line-height: 1.35;
}
.course-module .course-article-heading :is(.subtitle, .hero-sub, .page-hero-sub) {
    margin: .35rem 0 0;
    font-size: .88rem;
    line-height: 1.6;
}
@media (max-width: 600px) {
    .course-module .course-article-heading { padding: .75rem 1rem .65rem; }
    .course-module .course-article-heading :is(.subtitle, .hero-sub, .page-hero-sub) { font-size: .84rem; }
}
@media (min-width: 901px) {
    .course-directory .main-content.full-width { padding: .5rem 1.5rem 1rem; }
    .course-directory .main-content.full-width .chapter-card { min-height: 48px; }
}
/* Short phone viewports keep all 24 entries close together without clipping. */
@media (max-width: 720px) and (max-height: 700px) {
    .course-directory .main-content.full-width .phase-label {
        margin: .15rem 0 .1rem;
        font-size: .65rem;
        line-height: 1.3;
    }
    .course-directory .main-content.full-width .chapter-card {
        min-height: 36px;
        padding: .1rem .35rem;
    }
    .course-directory .main-content.full-width .chapter-card h3 {
        font-size: .75rem;
        line-height: 1.25;
    }
}
@media (prefers-reduced-motion: reduce) {
    .course-directory .chapter-card { transition: none; }
}

/* Reading navigation stays side by side, including narrow phone screens. */
.course-module .chapter-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: .5rem;
    margin-top: 1.2rem;
    padding-top: .75rem;
    border-top: 1px solid var(--gray-200, #d1d5db);
}
.course-module .chapter-nav > a {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .4rem;
    width: auto;
    min-width: 0;
    max-width: none;
    min-height: 52px;
    margin: 0;
    padding: .5rem .65rem;
    border: 1px solid var(--gray-200, #d1d5db);
    border-radius: 8px;
    background: var(--gray-50, #f8fafc);
    box-shadow: none;
    color: var(--primary, #2563eb);
    font-size: .8rem;
    line-height: 1.45;
    text-decoration: none;
}
.course-module .chapter-nav > a.next {
    grid-column: 2;
    justify-content: flex-end;
    text-align: right;
    margin-left: 0;
}
.course-module .chapter-nav > a > div,
.course-module .chapter-nav > a > span:has(.nav-label) {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.course-module .chapter-nav .nav-label {
    display: block;
    margin: 0 0 .1rem;
    color: var(--gray-500, #64748b);
    font-size: .68rem;
    font-weight: 400;
}
.course-module .chapter-nav > a:hover {
    border-color: var(--primary, #2563eb);
    background: var(--primary-light, #eff6ff);
    box-shadow: none;
}
.course-module .chapter-nav > a:focus-visible,
.course-module .course-resource-return a:focus-visible {
    outline: 2px solid var(--primary, #2563eb);
    outline-offset: 3px;
}
/* Resource pages return to the library instead of suggesting an arbitrary next tool. */
.course-module .course-resource-return {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    max-width: 960px;
    margin: 1rem auto 0;
    padding: .4rem 1rem;
    border-top: 1px solid var(--gray-200, #d1d5db);
}
.course-module .course-resource-return a {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    min-height: 44px;
    padding: .25rem .35rem;
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    color: var(--primary, #2563eb);
    font-size: .8rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.course-module .course-resource-return a:hover {
    background: var(--primary-light, #eff6ff);
}
.course-resource-page .main-content { padding-bottom: .5rem; margin-bottom: .5rem; }
.course-module:not(.course-directory) .site-footer {
    margin-top: .5rem;
    padding: .65rem 1rem;
    border: 0;
    background: transparent;
    font-size: .7rem;
    line-height: 1.5;
    text-align: center;
    color: var(--gray-500, #64748b);
}
.course-module:not(.course-directory) .site-footer p { margin: 0; }
.course-directory .main-content.full-width > .content-body > details.home-section {
    margin: .7rem 0 0;
    padding: .4rem 0 0;
    border-top: 1px solid var(--theme-border, #334155);
}
.course-directory details.home-section > summary {
    min-height: 44px;
    padding: .5rem 0;
    color: var(--theme-muted, #94a3b8);
    font-size: .78rem;
    cursor: pointer;
}
.course-directory details.home-section > summary span { margin-left: .4rem; font-size: .7rem; }
.course-directory summary:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 2px; }
.course-directory .main-content.full-width .chapter-card .ch-num { align-self: center; line-height: 1.35; }
.course-directory .main-content.full-width .chapter-card h3 { overflow-wrap: anywhere; }
.course-directory .phase-label { scroll-margin-top: 110px; }
.course-nav-actions { display: flex; align-items: center; flex-shrink: 0; }
.course-mobile-resources { display: none; align-items: center; justify-content: center; min-height: 44px; padding: 0 .5rem; font-size: .75rem; color: #bae6fd; text-decoration: none; }
.course-header-quiz { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 .5rem; font-size: .75rem; color: #bae6fd; text-decoration: none; }
.course-directory .course-nav-actions a:hover { color: white; background: rgba(255, 255, 255, .1); border-radius: 6px; }
.tcm-course .site-footer { margin-top: 1rem; padding: .6rem .8rem; font-size: .7rem; color: var(--gray-500); }
.tcm-course .chapter-practice { margin: 1.4rem 0 1rem; border-top: 1px solid var(--gray-200); border-bottom: 1px solid var(--gray-200); }
.tcm-course .chapter-practice > summary { min-height: 44px; padding: .6rem 0; font-weight: 600; cursor: pointer; scroll-margin-top: 60px; }
.tcm-course .chapter-practice > summary:focus-visible { outline: 2px solid #38bdf8; outline-offset: 2px; }
.tcm-course.course-directory .site-footer { color: #94a3b8; }
.course-directory .site-footer { margin-top: .35rem; padding: .4rem .8rem; font-size: .65rem; }
.course-directory .site-footer p { margin: 0; }
.course-module .course-nav-actions { display: flex; }
.course-module .course-mobile-resources { display: inline-flex; }
@media print {
    .course-module .course-page-controls { display: none; }
    .course-module .chapter-nav, .course-module .course-resource-return { display: none; }
    .course-directory .chapter-grid, .course-directory .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Visitors can inspect every chapter; only selected trials are open to read. */
.course-access-mark{display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;line-height:1.3}
.course-access-mark.is-trial{padding:2px 4px;border-radius:4px;background:rgba(45,212,191,.12);color:#5eead4;font-size:.58rem;white-space:nowrap}
.course-access-mark.is-locked{width:12px;color:var(--theme-muted,#94a3b8)}
.course-access-mark svg{width:12px;height:12px}
.course-directory .main-content.full-width .chapter-card:has(.is-trial){background:rgba(45,212,191,.05)!important}
.course-trial-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:.65rem;padding-top:.35rem;border-top:1px solid var(--gray-200,#e2e8f0);font-size:.72rem;line-height:1.4}
.course-trial-bar>span{color:var(--primary,#2563eb);white-space:nowrap}
.course-trial-bar button{min-height:32px;padding:.25rem 0;border:0;background:transparent;color:var(--primary,#2563eb);font:inherit;font-weight:600;cursor:pointer;white-space:nowrap}
.course-trial-bar button:focus-visible{outline:2px solid var(--primary,#2563eb);outline-offset:3px}
