/* 解剖学首页局部优化：触控、键盘可访问性与平板布局。 */

.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;
}

.nav-hamburger {
    width: 44px;
    height: 44px;
    margin-left: 4px;
    padding: 12px 9px;
    border-radius: 8px;
}

.nav-hamburger:hover {
    background: rgba(255, 255, 255, .1);
}

.sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 8px;
}

.home-section-header .subject-quiz-shortcut {
    min-height: 44px;
    padding: .55rem .72rem;
    font-size: .8rem;
}

:is(
    .top-nav a,
    .top-nav button,
    .chapter-card,
    .tool-card,
    .subject-home-bottom-link,
    .sidebar-link,
    .sidebar-close
):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 anatomy. */
.anatomy-directory .main-content.full-width {
    max-width: 960px;
    padding: 4px .8rem 1rem;
}
.anatomy-directory .main-content.full-width > .content-body > .home-section {
    margin: 0;
}
.anatomy-directory .home-section-header.has-subject-quiz-shortcut {
    margin: 0 0 .4rem !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0;
    background: transparent;
}
.anatomy-directory .home-section-header::after { display: none; }
.anatomy-directory .home-section-header.has-subject-quiz-shortcut h2 {
    font-size: .82rem !important;
    font-weight: 600;
    color: var(--theme-muted, #94a3b8) !important;
}
.anatomy-chapter-count { margin-left: .3rem; font-size: .7rem; font-weight: 500; }
.anatomy-directory .subject-quiz-shortcut {
    min-height: 44px;
    padding: .35rem .55rem;
    font-size: .73rem;
    border: 0;
    background: transparent;
}
.anatomy-directory .main-content.full-width .phase-label {
    display: flex;
    width: 100%;
    min-height: 0;
    gap: .6rem;
    margin: .6rem 0 .35rem;
    padding: 0;
    border: 0 !important;
    border-radius: 0;
    background: none !important;
    color: var(--theme-muted, #94a3b8) !important;
    font-size: .7rem;
    font-weight: 500;
    line-height: 1.4;
}
.anatomy-directory .phase-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--theme-border, #334155);
}
.anatomy-directory .main-content.full-width .chapter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
    margin: 0;
}
.anatomy-directory .main-content.full-width .chapter-card {
    min-height: 44px;
    gap: .4rem;
    padding: .5rem .55rem;
    border: 1px solid var(--theme-border, #334155) !important;
    border-radius: 9px;
    background: var(--theme-surface, #1e293b) !important;
    box-shadow: none !important;
    transform: none;
}
.anatomy-directory .main-content.full-width .chapter-card:hover {
    border-color: #7dd3fc !important;
}
.anatomy-directory .main-content.full-width .chapter-card .ch-num {
    width: 22px;
    height: auto;
    border: 0;
    border-radius: 0;
    background: transparent !important;
    color: #7dd3fc !important;
    font-size: .72rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.anatomy-directory .main-content.full-width .chapter-card h3 {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: .83rem;
    font-weight: 600;
    line-height: 1.4;
}
.anatomy-directory .chapter-card p { display: none; }
.anatomy-directory .main-content.full-width > .content-body > .anatomy-tools {
    margin-top: .7rem;
    padding-top: .4rem;
    border-top: 1px solid var(--theme-border, #334155);
}
.anatomy-tools > summary, .anatomy-sidebar-tools > summary {
    min-height: 44px;
    padding: .5rem 0;
    cursor: pointer;
    font-size: .78rem;
    color: var(--theme-muted, #94a3b8);
}
.anatomy-tools > summary span { margin-left: .4rem; font-size: .7rem; }
.anatomy-directory .main-content.full-width .tools-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
}
.anatomy-directory .main-content.full-width .tool-card { min-height: 44px; padding: .5rem .6rem; gap: .4rem; }
.anatomy-directory .main-content.full-width .tool-icon { font-size: 1rem; }
.anatomy-directory .main-content.full-width .tool-name { font-size: .78rem; }
.anatomy-directory .tool-desc { display: none; }

/* A labelled chapter button and two-column switcher on reading pages. */
.anatomy-module .nav-hamburger {
    width: auto;
    min-height: 44px;
    height: auto;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: 0 .6rem;
    color: white;
    font: inherit;
    font-size: .8rem;
    font-weight: 600;
}
.anatomy-module .nav-hamburger .anatomy-menu-icon { height: auto; background: none; }
.anatomy-module .nav-sidebar {
    width: min(100%, 440px);
    right: -100%;
    height: 100vh;
    height: 100dvh;
    z-index: 10000;
    background: var(--theme-bg, #0f172a);
}
.anatomy-module .nav-sidebar.open { right: 0; }
.anatomy-module .nav-sidebar[hidden] { display: none !important; }
.anatomy-module .nav-overlay { z-index: 9999; }
.anatomy-module .sidebar-header { height: 48px; padding: 0 .8rem; }
.anatomy-module .sidebar-body { padding: .4rem .8rem 1rem; }
.anatomy-module .sidebar-body > .sidebar-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: calc(100% / 3);
    min-height: 44px;
    padding: .35rem .15rem !important;
    margin: 0 !important;
    border: 0 !important;
    color: var(--theme-muted, #94a3b8);
    background: transparent;
    font-size: .7rem !important;
}
.anatomy-module .sidebar-body > .sidebar-link:hover {
    color: #f1f5f9;
    background: #1e293b;
}
.anatomy-module .sidebar-section {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 0;
    margin: .6rem 0 .35rem;
    font-size: .7rem;
    color: var(--theme-muted, #94a3b8);
}
.anatomy-module .sidebar-section::after { content: ''; flex: 1; height: 1px; background: var(--theme-border, #334155); }
.anatomy-sidebar-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.anatomy-module .anatomy-sidebar-grid .sidebar-link {
    display: flex;
    align-items: center;
    gap: .4rem;
    min-height: 44px;
    padding: .4rem .5rem;
    border: 1px solid var(--theme-border, #334155);
    border-radius: 8px;
    color: var(--theme-text, #f1f5f9);
    background: var(--theme-surface, #1e293b);
    font-size: .8rem;
    line-height: 1.4;
}
.anatomy-module .anatomy-sidebar-grid .sidebar-link.active {
    border-color: #7dd3fc;
    background: #17374a;
    color: #e0f2fe;
}
.anatomy-nav-number { flex-shrink: 0; color: #7dd3fc; font-size: .7rem; font-variant-numeric: tabular-nums; }
.anatomy-sidebar-tools { margin-top: .7rem; border-top: 1px solid var(--theme-border, #334155); }
.anatomy-tools summary:focus-visible, .anatomy-sidebar-tools summary:focus-visible { outline: 2px solid #7dd3fc; outline-offset: 2px; }
@media (min-width: 901px) {
    .anatomy-directory .main-content.full-width { padding: .5rem 1.5rem 1rem; }
    .anatomy-directory .main-content.full-width .chapter-card { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
    .anatomy-module .nav-sidebar { transition: none; }
    .anatomy-directory .chapter-card { transition: none; }
}
