/* Greens Guide Portal */

:root {
    --sidebar-width: 280px;
    --header-height: 56px;
    --green-primary: #1a6b3c;
    --green-dark: #134d2b;
    --green-light: #e8f5ee;
    --green-accent: #2d9254;
    --text-primary: #1a1a1a;
    --text-secondary: #555;
    --text-muted: #888;
    --border-color: #e2e8f0;
    --bg-sidebar: #f8faf9;
    --bg-main: #ffffff;
    --bg-hover: #f0f7f3;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-primary);
    background: var(--bg-main);
    line-height: 1.55;
    font-size: 14.5px;
    /* Backstop: any inner element forced wider than the viewport (KB inline
       widths, runaway tables, long URLs) will horizontally scroll inside its
       own container instead of dragging the whole page wide. */
    overflow-x: hidden;
}

/* Visually hidden — for landmark headings that don't need to render visibly. */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* Skip link — visible only on keyboard focus */
.skip-link {
    position: absolute;
    top: -40px;
    left: 8px;
    background: var(--green-primary);
    color: #fff;
    padding: 8px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 600;
    z-index: 200;
    transition: top .15s;
}
.skip-link:focus { top: 8px; outline: 2px solid #fff; outline-offset: 2px; }

/* Global :focus-visible for interactive elements that don't define their own */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--green-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ── Header ── */
.portal-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: #eef0ef;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.portal-header .logo {
    flex-shrink: 0;
}

.portal-header .logo a {
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--header-height);  /* match header so children flex-center cleanly */
    color: var(--text-primary);
    text-decoration: none;
    line-height: 1;
}

.portal-header .logo-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;  /* avoid phantom line-height pushing the image off-center */
}

.portal-header .logo-img {
    display: block;
    height: 28px;
    width: auto;
    max-width: 144px;
    object-fit: contain;
}

.portal-header .logo-divider {
    display: block;
    width: 1px;
    height: 28px;  /* match image height so the row has a uniform visual frame */
    background: rgba(0,0,0,.15);
}

.portal-header .logo-text {
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: .01em;
    color: var(--text-secondary);
}

/* Header search */
.header-search {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0 8px;
    transition: all .2s;
    max-width: 320px;
    width: 100%;
    margin-left: 24px;
    min-width: 0;
}

.header-search:focus-within {
    border-color: var(--green-primary);
    box-shadow: 0 0 0 2px rgba(26,107,60,.12);
}

.header-search input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: .875rem;
    padding: 6px 4px;
    width: 100%;
    min-width: 0;
}

.header-search input::placeholder {
    color: var(--text-muted);
}

.header-search button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 32px;
    min-height: 32px;
    border-radius: 4px;
}

.header-search button:hover {
    color: var(--text-primary);
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 12px 0;
    z-index: 50;
}

.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.sidebar-filter {
    padding: 4px 16px 10px;
    position: sticky;
    top: 0;
    background: var(--bg-sidebar);
    z-index: 1;
}

.sidebar-filter-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: .82rem;
    background: #fff;
    color: var(--text-primary);
    outline: none;
}

.sidebar-filter-input:focus {
    border-color: var(--green-primary);
    box-shadow: 0 0 0 2px rgba(0,128,0,.1);
}
.sidebar-filter-input:focus-visible {
    outline: 2px solid var(--green-primary);
    outline-offset: 1px;
}

/* Filter mode: nav items hide unless they (or a descendant) matches.
   JS adds .filter-match to matching items and .filter-has-match to their
   ancestor groups + section titles. */
.sidebar.filtering .nav-item:not(.filter-match) { display: none; }
.sidebar.filtering .nav-section-title { display: none; }
.sidebar.filtering .nav-section-title.filter-has-match { display: block; }
.sidebar.filtering .nav-parent-group:not(.filter-has-match):not(.filter-match) { display: none; }
/* Show the parent group's own link as context, even if the parent's title
   didn't match — descendants did. */
.sidebar.filtering .nav-parent-group.filter-has-match > .nav-item { display: block; }
/* Force-expand parents whose descendants matched, regardless of prior state */
.sidebar.filtering .nav-parent-group.filter-has-match.collapsed > .nav-children { display: block; }
.sidebar-filter-empty {
    padding: 12px 20px;
    color: var(--text-muted);
    font-size: .82rem;
    font-style: italic;
}

.nav-section-title {
    padding: 8px 20px 4px;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    margin-top: 8px;
}

.nav-section-title:first-child { margin-top: 0; }

.nav-item {
    display: block;
    padding: 8px 36px 8px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .88rem;
    font-weight: 500;
    line-height: 1.4;
    border-left: 4px solid transparent;
    transition: background .12s, color .12s;
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--green-light);
    color: var(--green-primary);
    border-left-color: var(--green-primary);
    font-weight: 700;
}

.nav-item.active:hover {
    background: var(--green-light);
    color: var(--green-primary);
}

/* Folder rows: stronger weight so they read as section headers */
.nav-parent > .nav-item { font-weight: 600; color: var(--text-primary); }
.nav-parent > .nav-item.active { color: var(--green-primary); font-weight: 700; }

/* When a section contains the active article, hint at it on the parent row */
.nav-parent-group:not(.collapsed) > .nav-item:not(.active) { color: var(--green-primary); }

/* Nested levels — indent only, no font shrink */
.nav-item[data-depth="1"] { padding-left: 32px; }
.nav-item[data-depth="2"] { padding-left: 48px; }
.nav-item[data-depth="3"] { padding-left: 64px; }
.nav-item[data-depth="4"] { padding-left: 80px; }

/* Right-side toggle chevron — pointing down when expanded, right when collapsed.
   The hit area is intentionally 44×44 (well above the 20×20 visible glyph) so
   touch users can reliably expand the tree without accidentally hitting the
   parent link. The visible chevron stays small via inner contents; the span
   itself reserves the larger tap target via padding. */
.nav-parent .toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);  /* expanded → chevron points DOWN */
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    transition: transform .2s, background .12s;
    user-select: none;
    border-radius: 3px;
}

.nav-parent .toggle:hover { background: rgba(0,0,0,.08); color: var(--text-primary); }
.nav-parent .toggle:active { background: rgba(0,0,0,.12); }
.nav-item.active.nav-parent .toggle { color: var(--green-primary); }
.nav-item.active.nav-parent .toggle:hover { background: rgba(26,107,60,.12); color: var(--green-dark); }

/* Reserve room on the right for the larger tap region so titles don't tuck
   under the chevron when expanded. */
.nav-item.nav-parent { padding-right: 48px; }

/* Collapsed → no rotation; chevron base glyph points RIGHT naturally */
.nav-parent-group.collapsed > .nav-item .toggle { transform: translateY(-50%) rotate(0); }
.nav-parent-group.collapsed > .nav-children { display: none; }

/* Sidebar utility links (bottom of nav) */
.sidebar-footer {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.nav-utility {
    display: block;
    padding: 8px 36px 8px 20px;
    font-size: .88rem;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: background .12s, color .12s;
}

.nav-utility:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-utility.active {
    background: var(--green-light);
    color: var(--green-primary);
    border-left-color: var(--green-primary);
    font-weight: 700;
}

/* ── "Signed in as" block + sign-out link in sidebar footer ── */
.sidebar-signed-in {
    margin-top: 12px;
    padding: 10px 20px 4px;
    border-top: 1px dashed var(--border-color);
    font-size: .78rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.sidebar-signed-in span { display: block; }
.sidebar-signed-in strong { color: var(--text-primary); font-weight: 600; }
.sidebar-signed-in a {
    display: inline-block;
    margin-top: 2px;
    color: var(--green-primary);
    text-decoration: none;
    font-weight: 500;
}
.sidebar-signed-in a:hover { text-decoration: underline; }

/* ── Sign-in page (standalone, no main layout) ── */
.signin-body {
    /* dvh respects the visual viewport (soft keyboard, browser chrome) so the
       submit button stays reachable when the on-screen keyboard opens. */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--green-primary) 0%, var(--green-dark) 100%);
    padding: 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.signin-card {
    background: #fff;
    border-radius: 10px;
    padding: 36px 36px 28px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
}

.signin-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    color: var(--text-primary);
}
.signin-brand .logo-pill {
    background: var(--green-primary);
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    line-height: 0;
}
.signin-brand .logo-img { height: 22px; width: auto; max-width: 120px; object-fit: contain; filter: brightness(0) invert(1); }
.signin-brand .logo-divider { display: inline-block; width: 1px; height: 20px; background: var(--border-color); }
.signin-brand .logo-text { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

.signin-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.signin-help {
    font-size: .88rem;
    color: var(--text-secondary);
    margin-bottom: 18px;
    line-height: 1.5;
}

.signin-error {
    background: #fdecec;
    color: #842029;
    border: 1px solid #f5c2c7;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: .85rem;
    margin-bottom: 14px;
}

/* Microsoft SSO button (sign-in page) */
.signin-card .ms-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    background: #fff;
    color: #444;
    border: 1px solid #bbb;
    border-radius: 6px;
    font-size: .92rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .12s, border-color .12s;
}
.signin-card .ms-btn:hover {
    background: #f5f5f5;
    border-color: #888;
    color: #222;
}
.signin-card .ms-logo {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.signin-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px 0;
    color: var(--text-muted);
    font-size: .78rem;
}
.signin-divider::before,
.signin-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.signin-card form label {
    display: block;
    margin-bottom: 12px;
}
.signin-card form label span {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    letter-spacing: .02em;
}
.signin-card form input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: .95rem;
    transition: border-color .12s, box-shadow .12s;
}
.signin-card form input:focus {
    outline: none;
    border-color: var(--green-primary);
    box-shadow: 0 0 0 3px rgba(26,107,60,.18);
}
.signin-card form button {
    width: 100%;
    padding: 10px 14px;
    margin-top: 6px;
    background: var(--green-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s;
}
.signin-card form button:hover { background: var(--green-dark); }

.signin-footnote {
    margin-top: 18px;
    font-size: .78rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height) - 40px);
    padding: 32px 48px 40px;
    max-width: 900px;
}

/* Smooth anchor scroll site-wide; offset for fixed header */
html { scroll-behavior: smooth; }
.article-body :is(h1, h2, h3, h4, h5, h6, [id]) {
    scroll-margin-top: calc(var(--header-height) + 16px);
}

/* ── Inline article TOC + meta (shown only when the right rail is hidden) ──
   On narrow screens the right-rail TOC disappears (#7). This collapsible
   replacement renders inline above the article body and is hidden on wide
   viewports where the rail provides the same affordances. */
.article-toc-mobile {
    display: none;
    margin: 0 0 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-sidebar);
    overflow: hidden;
}
.article-toc-mobile > summary {
    cursor: pointer;
    list-style: none;
    padding: 10px 14px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .06em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
}
.article-toc-mobile > summary::-webkit-details-marker { display: none; }
.article-toc-mobile > summary::after {
    content: "›";
    font-size: 1.3rem;
    color: var(--text-muted);
    transform: rotate(90deg);
    transition: transform .15s;
}
.article-toc-mobile[open] > summary::after { transform: rotate(-90deg); }
.article-toc-mobile nav { padding: 4px 14px 12px; background: #fff; }
.article-toc-mobile nav a {
    display: block;
    padding: 8px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .85rem;
    line-height: 1.4;
    border-left: 2px solid transparent;
    border-radius: 3px;
    min-height: 36px;
}
.article-toc-mobile nav a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
.article-toc-mobile nav a[data-level="3"] { padding-left: 24px; font-size: .8rem; }
.article-toc-mobile .article-toc-meta {
    padding: 10px 14px 12px;
    background: #fff;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: .78rem;
    color: var(--text-muted);
}
.article-toc-mobile .article-toc-meta strong {
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 4px;
}
@media (max-width: 1199px) {
    .article-toc-mobile { display: block; }
}

/* ── Right rail: "On this page" + meta + print ──
   Docked to the right edge of the article column (sidebar + main-content max-width
   + a small gutter), so it doesn't drift to the viewport edge on wide screens. */
.page-toc {
    position: fixed;
    top: calc(var(--header-height) + 32px);
    left: calc(var(--sidebar-width) + 900px + 40px);
    width: 220px;
    max-height: calc(100vh - var(--header-height) - 64px);
    overflow-y: auto;
    z-index: 30;
}

.page-toc-title {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-left: 12px;
}

.page-toc nav {
    border-left: 1px solid var(--border-color);
}

.page-toc nav a {
    display: block;
    padding: 5px 0 5px 12px;
    margin-left: -1px;
    font-size: .82rem;
    color: var(--text-secondary);
    text-decoration: none;
    line-height: 1.4;
    border-left: 2px solid transparent;
    transition: color .12s, border-color .12s;
}

.page-toc nav a:hover {
    color: var(--text-primary);
}

.page-toc nav a.active {
    color: var(--green-primary);
    border-left-color: var(--green-primary);
    font-weight: 600;
}

.page-toc nav a[data-level="3"] {
    padding-left: 28px;
    font-size: .78rem;
}

.page-toc-divider {
    margin: 16px 12px;
    border-top: 1px solid var(--border-color);
}

.page-toc-meta {
    padding-left: 12px;
    margin-bottom: 12px;
}

.page-toc-meta-label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.page-toc-meta-value {
    font-size: .82rem;
    color: var(--text-secondary);
}

.page-toc-print {
    margin-left: 12px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: .78rem;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color .12s, border-color .12s, background .12s;
}

.page-toc-print:hover {
    color: var(--text-primary);
    border-color: #bbb;
    background: #fafafa;
}

/* Hide right rail on narrower viewports — fall back to inline meta.
   Threshold tuned for typical 1280-1366px laptops (sidebar 280 + article
   ~700 + gutter + TOC 220 fits comfortably above this). */
@media (max-width: 1199px) {
    .page-toc { display: none; }
}

/* ── Breadcrumbs ── */
.breadcrumbs {
    font-size: .85rem;
    margin-bottom: 20px;
    color: var(--text-muted);
    padding: 8px 14px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.breadcrumbs a {
    color: var(--green-accent);
    text-decoration: none;
    /* Larger vertical tap region without changing the inline visual flow */
    display: inline-block;
    padding: 4px 2px;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs .sep {
    margin: 0 8px;
    color: #ccc;
}

.breadcrumbs .current {
    color: var(--text-secondary);
}

/* ── Article content styling ── */
.article-header {
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.article-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
}

.article-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 6px;
}

.article-meta {
    font-size: .8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 12px;
}

/* When the right rail is visible (≥1200px), it owns the meta + print button.
   Hide the inline article-meta line and any element marked .narrow-only. */
@media (min-width: 1200px) {
    .article-meta { display: none; }
    .narrow-only { display: none !important; }
}

.article-id {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: .7rem;
    color: #aaa;
    background: #f5f5f5;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: .02em;
}

/* Print button */
.print-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 12px;
    font-size: .78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.print-btn:hover {
    color: var(--text-primary);
    border-color: #bbb;
    background: #fafafa;
}

.article-body h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--green-dark);
    margin: 28px 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green-light);
}

.article-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 22px 0 8px;
}

.article-body h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 18px 0 6px;
}

.article-body p {
    margin: 0 0 14px;
    color: var(--text-primary);
}

.article-body ul, .article-body ol {
    margin: 0 0 14px;
    padding-left: 24px;
}

.article-body li {
    margin-bottom: 4px;
}

/* Article body uses break-word as a safety net so long URLs / kb-topic slugs
   in prose don't drag the layout wider than the viewport on phones. */
.article-body {
    overflow-wrap: break-word;
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: .9rem;
}

.article-body thead th {
    background: var(--green-light);
    color: var(--green-dark);
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
}

.article-body td {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    overflow-wrap: anywhere;
}

.article-body tbody tr:nth-child(even) { background: #fafbfc; }

/* Code & preformatted blocks: the KB body comes from migrated authored HTML
   that may contain long unbroken lines (shell commands, paths). Without these
   rules a single wide line drags the whole page horizontally on phones. */
.article-body pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: pre;
    background: #f6f8fa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 14px;
    font-size: .85rem;
    line-height: 1.5;
    margin: 14px 0;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
}
.article-body code {
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: .9em;
    background: #f6f8fa;
    padding: 1px 5px;
    border-radius: 3px;
    overflow-wrap: anywhere;
}
.article-body pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
}

/* Embeds & media — KB authors paste YouTube/Loom/SharePoint embeds with
   fixed widths; clamp to the article column. */
.article-body iframe,
.article-body video,
.article-body embed,
.article-body object {
    max-width: 100%;
    border: 0;
}
.article-body iframe {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
}
.article-body figure {
    max-width: 100%;
    margin: 12px 0;
}

.article-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 12px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.article-body a {
    color: var(--green-accent);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.article-body a:hover {
    text-decoration: underline;
}

.article-body mark {
    background: #fff3cd;
    padding: 1px 4px;
    border-radius: 3px;
}

.article-body strong {
    font-weight: 600;
}

/* ── Welcome / landing state ── */
.welcome {
    max-width: 880px;
    margin: 0 auto;
    padding: 40px 8px;
    color: var(--text-secondary);
}

.welcome-hero {
    text-align: center;
    margin-bottom: 36px;
}

.welcome h1,
.welcome h2 {
    font-size: 1.85rem;
    color: var(--text-primary);
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: -.015em;
}
.welcome h2 { font-size: 1.65rem; margin-bottom: 12px; }

.welcome-hero p {
    font-size: 1rem;
    max-width: 540px;
    margin: 0 auto;
    line-height: 1.6;
}

.welcome-block {
    margin-bottom: 36px;
}

.welcome-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 36px;
}

.welcome-stats-2col {
    grid-template-columns: repeat(2, 1fr);
}

/* Two-up popular row: side-by-side on wider viewports, stacks on narrow. */
.welcome-popular-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 36px;
}
.welcome-popular-row .welcome-block { margin-bottom: 0; }

.welcome-stat {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 18px 16px;
    text-align: center;
}

.welcome-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--green-primary);
    line-height: 1.1;
    margin-bottom: 6px;
}

.welcome-stat-label {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    /* Scoped to the default 3-up case — the .welcome-stats-2col variant
       overrides at line 830 should win on phones too. */
    .welcome-stats:not(.welcome-stats-2col) { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .welcome-stats-2col { gap: 8px; }
    .welcome-stat { padding: 14px 8px; }
    .welcome-stat-value { font-size: 1.3rem; }
}

.welcome-block-title {
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin: 0 0 14px;
}

.welcome-block-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 14px;
}
.welcome-block-head .welcome-block-title { margin: 0; }
.welcome-block-link {
    color: var(--green-primary);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
}
.welcome-block-link:hover { text-decoration: underline; }

/* Section card grid: top-level published articles */
.welcome-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.welcome-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px 18px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: .98rem;
    min-height: 56px;
    transition: border-color .15s, transform .15s, box-shadow .15s;
}
.welcome-card-title { overflow-wrap: anywhere; min-width: 0; }

.welcome-card:hover {
    border-color: var(--green-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.welcome-card-arrow {
    color: var(--text-muted);
    font-size: 1.3rem;
    line-height: 1;
}

/* Popular list — ordered with subtle rank numbers + reader count */
.welcome-popular {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: popular;
    border-top: 1px solid var(--border-color);
}

.welcome-popular li {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 14px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-color);
    counter-increment: popular;
}

.welcome-popular li::before {
    content: counter(popular);
    flex-shrink: 0;
    width: 22px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .85rem;
    text-align: center;
}

.welcome-popular a {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    overflow-wrap: anywhere;
    /* Generous tap region inside the row */
    display: inline-block;
    padding: 4px 0;
}

.welcome-popular a:hover {
    color: var(--green-primary);
    text-decoration: underline;
}

.welcome-popular-count {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: .8rem;
    white-space: nowrap;
}

/* Recently-updated list */
.welcome-recent {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--border-color);
}

.welcome-recent li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border-color);
}

.welcome-recent a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}

.welcome-recent a:hover {
    color: var(--green-primary);
    text-decoration: underline;
}

.welcome-recent-date {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: .82rem;
    white-space: nowrap;
}

.welcome-cta {
    color: var(--text-muted);
    font-size: .9rem;
    text-align: center;
    margin-top: 12px;
}

.welcome-cta a {
    color: var(--text-secondary);
}

/* ── What's New / changelog ── */
.changelog-header {
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}
.changelog-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.changelog-header p {
    color: var(--text-secondary);
    font-size: .9rem;
}

.changelog-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.changelog-date {
    margin-top: 18px;
    margin-bottom: 8px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}
.changelog-date:first-child { margin-top: 0; }

.changelog-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border-color);
}

.changelog-badge {
    flex-shrink: 0;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 8px;
    border-radius: 10px;
    color: #fff;
    min-width: 78px;
    text-align: center;
}
.changelog-badge-published { background: var(--green-primary); }
.changelog-badge-edited    { background: #5a6b80; }
.changelog-badge-created   { background: #3071a9; }
.changelog-badge-renamed   { background: #8a6f1d; }
.changelog-badge-restored  { background: #6b4a8a; }

.changelog-title {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
}
.changelog-title:hover {
    color: var(--green-primary);
    text-decoration: underline;
}

.changelog-summary {
    color: var(--text-muted);
    font-size: .85rem;
    flex: 1;
}

.changelog-version {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: .75rem;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
}

@media (max-width: 600px) {
    /* Compact, single-line rows: badge + title + date. The summary text
       duplicates the badge ("PUBLISHED" + "Published (from draft)"), so
       hide it on phones to keep each row to one line. */
    .changelog-row { flex-wrap: wrap; gap: 6px 10px; padding: 6px 4px; align-items: center; }
    .changelog-badge { min-width: 0; padding: 2px 8px; font-size: .65rem; }
    .changelog-title { flex: 1 1 auto; min-width: 0; }
    .changelog-summary { display: none; }
    .changelog-version { font-size: .7rem; flex-shrink: 0; margin-left: auto; }
}

/* ── Sitemap (home page) ── */
.sitemap-header {
    margin-bottom: 28px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.sitemap-header h1 {
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.sitemap-header p {
    color: var(--text-secondary);
    font-size: .95rem;
}

.sitemap-section {
    margin-bottom: 28px;
}

.sitemap-section > h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--green-dark);
    margin: 0 0 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green-light);
}

.sitemap-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.sitemap-list .sitemap-list {
    padding-left: 20px;
    margin-top: 4px;
    border-left: 1px solid var(--border-color);
    margin-left: 6px;
}

.sitemap-list li {
    margin: 4px 0;
    line-height: 1.5;
}

.sitemap-list a {
    text-decoration: none;
    color: var(--green-accent);
    padding: 4px 6px;
    border-radius: 3px;
    display: inline-block;
}

.sitemap-list a:hover {
    background: var(--green-light);
    color: var(--green-dark);
}

.sitemap-folder > a,
.sitemap-folder > details > summary > a {
    color: var(--text-primary);
    font-weight: 600;
}

.sitemap-folder > a::before,
.sitemap-folder > details > summary > a::before {
    content: "▸ ";
    color: var(--text-muted);
    font-size: .85em;
}

/* Top-level sitemap folders are wrapped in <details> for one-tap collapse on
   phones (the full flat list is overwhelming on a 360px screen). Default open
   so deep-linkers still see the full tree on landing. */
.sitemap-folder > details > summary {
    list-style: none;
    cursor: pointer;
    padding: 4px 0;
    min-height: 36px;
    display: flex;
    align-items: center;
}
.sitemap-folder > details > summary::-webkit-details-marker { display: none; }
.sitemap-folder > details[open] > summary > a::before { content: "▾ "; }

.sitemap-empty {
    color: var(--text-muted);
    padding: 40px 0;
    text-align: center;
}

/* ── Search results ── */
.search-results-heading,
.search-results h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.search-count {
    font-size: .85rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.search-result {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
    text-decoration: none;
    transition: all .15s;
}

.search-result:hover {
    border-color: var(--green-accent);
    background: var(--green-light);
}

.search-result-title {
    font-weight: 600;
    color: var(--green-primary);
    font-size: .95rem;
    margin-bottom: 4px;
}

.search-result-snippet {
    font-size: .85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.search-result-snippet mark {
    background: #fff3cd;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-meta {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.search-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}
.search-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--green-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
    min-height: 44px;
    background: #fff;
}
.search-page-btn:hover { background: var(--green-light); border-color: var(--green-accent); }
.search-page-btn-disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    background: #f5f5f5;
}
.search-page-info { color: var(--text-muted); font-size: .85rem; }

/* ── Prev / Next nav ── */
.article-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    gap: 12px;
}

.article-nav a {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-decoration: none;
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all .15s;
    max-width: 45%;
    min-height: 56px;
}

.article-nav a:hover {
    border-color: var(--green-accent);
    background: var(--green-light);
}

.article-nav .label {
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 1px;
}

.article-nav .title {
    font-size: .8rem;
    font-weight: 600;
    color: var(--green-primary);
    line-height: 1.3;
}

.article-nav .nav-next {
    text-align: right;
    margin-left: auto;
}

/* ── Child TOC (folder section listing) ── */
.child-toc {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
}

.child-toc li {
    padding: 0;
    margin: 0;
}

.child-toc li a {
    display: block;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all .15s;
}

.child-toc li a:hover {
    border-color: var(--green-accent);
    background: var(--green-light);
    color: var(--green-primary);
}

/* ── Footer ── */
.portal-footer {
    margin-left: var(--sidebar-width);
    padding: 16px 48px;
    font-size: .75rem;
    color: #aaa;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

/* Print-only brand header — hidden on screen, revealed in print */
.print-header { display: none; }

/* ── Print styles ── */
@media print {
    .portal-header,
    .sidebar,
    .portal-footer,
    .article-nav,
    .breadcrumbs,
    .print-btn,
    .page-toc,
    .header-search {
        display: none !important;
    }

    .print-header {
        display: flex !important;
        align-items: center;
        gap: 14px;
        padding: 0 0 12px;
        margin: 0 0 20px;
        border-bottom: 1px solid #999;
    }

    .print-header .print-logo {
        height: 30px;
        width: auto;
        max-width: 160px;
        object-fit: contain;
    }

    .print-header .print-divider {
        display: inline-block;
        width: 1px;
        height: 22px;
        background: #999;
    }

    .print-header .print-brand {
        font-size: 13pt;
        font-weight: 600;
        color: #333;
        letter-spacing: .01em;
    }

    .main-content {
        margin: 0 !important;
        padding: 20px !important;
        max-width: 100% !important;
    }

    .article-header {
        border-bottom: 2px solid #333;
    }

    .article-header h1 {
        font-size: 1.5rem;
    }

    .article-body img {
        box-shadow: none;
        max-width: 80%;
    }

    .article-body a {
        color: #333;
    }

    .article-body a::after {
        content: " (" attr(href) ")";
        font-size: .75em;
        color: #666;
    }

    .article-body a[href^="#"]::after,
    .article-body a[href^="kb://"]::after {
        content: none;
    }

    .print-footer {
        display: flex !important;
        justify-content: space-between;
        margin-top: 40px;
        padding-top: 10px;
        border-top: 1px solid #ccc;
        font-size: 8pt;
        color: #999;
    }

    body {
        font-size: 11pt;
        line-height: 1.5;
    }

    /* Tables in printed SOPs: keep them readable when content is wider than
       the page. Repeat thead on every page break, prevent rows from splitting
       across pages, and shrink-to-fit overflowing content. */
    .article-body table {
        width: 100%;
        max-width: 100%;
        border-collapse: collapse;
        font-size: 9pt;
        page-break-inside: auto;
        margin: 8pt 0;
    }
    .article-body thead {
        display: table-header-group;  /* repeat on every page */
    }
    .article-body tfoot {
        display: table-footer-group;
    }
    .article-body tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
    .article-body th,
    .article-body td {
        padding: 4pt 6pt;
        border: 1px solid #888;
        word-wrap: break-word;
        overflow-wrap: anywhere;
        vertical-align: top;
    }
    .article-body th {
        background: #eee;
        font-weight: 600;
    }
}

/* Back-to-top: appears after scrolling. Pinned bottom-right; tap to scroll.
   Sized at 48×48 (≥44 tap target) and offset clear of the iOS home-indicator
   gesture zone via env(safe-area-inset-*). */
.back-to-top {
    position: fixed;
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 16px));
    right: max(16px, calc(env(safe-area-inset-right) + 8px));
    width: 48px;
    height: 48px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-secondary);
    box-shadow: 0 2px 6px rgba(0,0,0,.12);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .15s, transform .15s, background .15s, color .15s, border-color .15s;
    z-index: 70;
}
.back-to-top:not([hidden]) {
    opacity: 1;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--green-primary);
    color: #fff;
    border-color: var(--green-primary);
}
.back-to-top:focus-visible {
    outline: 2px solid var(--green-primary);
    outline-offset: 2px;
}
@media print {
    .back-to-top { display: none !important; }
}

/* Hamburger lives in the header but is only visible at small viewports */
.sidebar-toggle {
    display: none;
    background: none;
    border: 0;
    color: var(--text-primary);
    padding: 6px;
    margin-right: 8px;
    cursor: pointer;
    border-radius: 4px;
}
.sidebar-toggle:hover { background: rgba(0,0,0,.06); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--green-primary); outline-offset: 1px; }

.sidebar-scrim {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 80;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}
.sidebar-scrim.open { opacity: 1; pointer-events: auto; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    /* Tablet portrait & landscape phones: hamburger drawer takes over a bit
       earlier than 768 so a 932px iPhone Pro Max landscape doesn't get a
       pinned 280px sidebar competing with content. */
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    /* Off-canvas drawer: slide in from the left when .open is set */
    .sidebar {
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 90;
        box-shadow: 2px 0 8px rgba(0,0,0,.18);
        width: min(280px, 86vw);
    }
    .sidebar.open { transform: translateX(0); }
    .main-content {
        margin-left: 0;
    }
    .portal-footer {
        margin-left: 0;
    }
    /* Body scroll lock while drawer is open */
    body.sidebar-open { overflow: hidden; }
}

/* Tap targets: ≥44px hit area for nav rows, raise input font-size to 16px
   to suppress iOS Safari's auto-zoom on focus. */
@media (max-width: 768px) {
    .main-content {
        padding: 24px 16px 40px;
    }
    /* Header: tighter padding, allow search to flex/shrink, drop hard
       margin so the 200px max-width doesn't push everything wide on 360px. */
    .portal-header { padding: 0 12px; }
    .sidebar-toggle { margin-right: 4px; min-width: 44px; min-height: 44px; padding: 8px; }
    .header-search {
        flex: 1 1 auto;
        max-width: 240px;
        margin-left: 8px;
    }
    .header-search input { font-size: 16px; padding: 8px 4px; }
    .header-search button { min-width: 44px; min-height: 44px; }

    /* Sidebar tap targets */
    .sidebar-filter-input { font-size: 16px; min-height: 44px; }
    .nav-item, .nav-utility { padding-top: 12px; padding-bottom: 12px; min-height: 44px; }
    .nav-item.nav-parent { padding-right: 52px; }

    /* Sidebar division widget — bigger Apply / Show all / Change buttons */
    .sidebar-division-apply,
    .sidebar-division-all { padding: 11px 12px; font-size: .85rem; min-height: 44px; }
    .sidebar-division-change { padding: 10px 12px; font-size: .82rem; min-height: 44px; }
    .sidebar-division-summary { flex-wrap: wrap; gap: 4px 8px; }

    /* Sign-in form input bumped to ≥16px to avoid iOS focus-zoom. */
    .signin-card form input { font-size: 16px; padding: 11px 12px; min-height: 44px; }
    .signin-card form button { padding: 12px 14px; min-height: 48px; font-size: 1rem; }

    /* Article header: H1 slightly tighter so a long title doesn't wrap to 5
       lines at 360px. */
    .article-header h1 { font-size: 1.5rem; }

    /* Stack prev/next so each title gets full width on a phone. */
    .article-nav { flex-direction: column; gap: 10px; }
    .article-nav a { max-width: 100%; }
    .article-nav .nav-next { text-align: left; margin-left: 0; }
}

@media (max-width: 600px) {
    /* Sticky-ish: sign-in form layout — keep the brand visible above the
       fold so the user gets context before the keyboard opens. */
    .signin-body { align-items: flex-start; padding-top: 32px; }

    /* Welcome cards: drop minmax floor and full-bleed so titles get the room. */
    .welcome-cards { grid-template-columns: 1fr; gap: 10px; }
    .welcome-card { padding: 14px 16px; font-size: .94rem; }

    /* Welcome hero: scale the heading down so it fits on one line on phones. */
    .welcome h1 { font-size: 1.5rem; }
    .welcome-hero p { font-size: .95rem; }

    /* Header: drop the "Guide" label + divider on phones (≤600px covers
       every modern phone, not just iPhone SE), and let the search input
       claim the freed-up space. */
    .portal-header { padding: 0 8px; }
    .portal-header .logo-text { display: none; }
    .portal-header .logo-divider { display: none; }
    .header-search { max-width: none; margin-left: 6px; }

    /* Sitemap: shallower nesting indent so deep paths still fit. */
    .sitemap-list .sitemap-list { padding-left: 12px; margin-left: 0; }

    /* Division prompt card: roomy desktop padding cripples 360px readers. */
    .division-prompt-card { padding: 22px 18px; }
    .division-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .division-tile { padding: 14px 8px; }
    /* Order: stack with the secondary "Show all" first so a stuck reader has
       an obvious escape, then primary below. column-reverse on the wrap. */
    .division-prompt-actions { flex-direction: column-reverse; gap: 8px; }
    .division-btn-primary,
    .division-btn-secondary { min-width: 0; width: 100%; min-height: 48px; }

    /* Hide the print-btn on phones — window.print() rarely matches the
       expected user intent and the button steals room next to the H1.
       The right-rail print-btn already has its own .narrow-only/print-only
       handling; this just suppresses the inline one on small phones. */
    .print-btn { display: none; }

    /* Right-rail TOC stays hidden (existing rule at 1199px) — but the inline
       mobile TOC (.article-toc-mobile) takes over via its own breakpoint. */
}

@media (max-width: 480px) {
    /* Welcome popular: counters can collapse — let the count fall below the
       title rather than fighting for inline space. */
    .welcome-popular-count { width: 100%; padding-left: 36px; }

    /* Article H1 even smaller on phones to keep a single-line readability
       budget for typical 4-7 word titles. */
    .article-header h1 { font-size: 1.35rem; }

    /* Breadcrumbs more compact */
    .breadcrumbs { padding: 6px 10px; font-size: .82rem; }
}

/* Hide the back-to-top on the standalone sign-in & division-prompt bodies
   (it shouldn't render there at all — these pages exit() before it's printed —
   but harden anyway in case of future refactors that share the layout). */
.signin-body .back-to-top,
.division-prompt-body .back-to-top { display: none !important; }

/* ── Division filter: first-visit prompt (full-page interstitial) ── */
.division-prompt-body {
    background: var(--bg-sidebar);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.division-prompt-card {
    width: 100%;
    max-width: 720px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 36px 40px;
    box-shadow: 0 8px 30px rgba(0,0,0,.06);
}

.division-prompt-card .signin-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.division-prompt-card h1 {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.division-prompt-help {
    color: var(--text-secondary);
    font-size: .92rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.division-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.division-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 10px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: border-color .12s, background .12s, transform .08s;
    text-align: center;
}

.division-tile:hover {
    border-color: var(--green-accent);
    background: var(--bg-hover);
}

.division-tile input[type="checkbox"] {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    accent-color: var(--green-primary);
    cursor: pointer;
}

.division-tile:has(input:checked) {
    border-color: var(--green-primary);
    background: var(--green-light);
}
.division-tile:focus-within {
    outline: 2px solid var(--green-primary);
    outline-offset: 2px;
}

.division-tile-icon {
    font-size: 1.6rem;
    color: var(--green-primary);
    line-height: 1;
}

.division-tile-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.division-prompt-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.division-btn-primary,
.division-btn-secondary {
    flex: 1;
    min-width: 180px;
    padding: 10px 18px;
    border-radius: 6px;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s;
}

.division-btn-primary {
    background: var(--green-primary);
    color: #fff;
}

.division-btn-primary:hover:not(:disabled) {
    background: var(--green-dark);
}

.division-btn-primary:disabled {
    background: #cfd6d2;
    cursor: not-allowed;
}

.division-btn-secondary {
    background: #fff;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.division-btn-secondary:hover {
    border-color: var(--green-primary);
    color: var(--green-primary);
}

.division-prompt-footnote {
    color: var(--text-muted);
    font-size: .8rem;
    text-align: center;
}

/* ── Division filter: sidebar widget ── */
.sidebar-division-filter {
    padding: 8px 16px 6px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
    background: var(--bg-sidebar);
}

.sidebar-division-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: space-between;
}

.sidebar-division-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: .78rem;
    min-width: 0;
}

.sidebar-division-label i {
    color: var(--green-primary);
    flex-shrink: 0;
}

.sidebar-division-text {
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* On phones, allow the summary to wrap to a second line so users with 3+
   selected divisions can see the full list without a hover tooltip
   (which doesn't exist on touch). */
@media (max-width: 768px) {
    .sidebar-division-text {
        white-space: normal;
        overflow-wrap: anywhere;
    }
}

.sidebar-division-change {
    background: none;
    border: none;
    color: var(--green-accent);
    font-size: .76rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    flex-shrink: 0;
}

.sidebar-division-change:hover {
    color: var(--green-primary);
    text-decoration: underline;
}

.sidebar-division-panel {
    margin-top: 8px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.sidebar-division-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.sidebar-division-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: .82rem;
    color: var(--text-primary);
}

.sidebar-division-option:hover {
    background: var(--bg-hover);
}

.sidebar-division-option input[type="checkbox"] {
    accent-color: var(--green-primary);
    cursor: pointer;
}

.sidebar-division-option i {
    color: var(--text-muted);
    width: 16px;
    text-align: center;
}

.sidebar-division-actions {
    display: flex;
    gap: 6px;
}

.sidebar-division-apply,
.sidebar-division-all {
    flex: 1;
    padding: 5px 8px;
    border-radius: 4px;
    font-size: .76rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
}

.sidebar-division-apply {
    background: var(--green-primary);
    color: #fff;
}

.sidebar-division-apply:hover {
    background: var(--green-dark);
}

.sidebar-division-all {
    background: #fff;
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.sidebar-division-all:hover {
    border-color: var(--green-primary);
    color: var(--green-primary);
}

/* ── Division pills (right-rail metadata tile) ── */
.page-toc-divisions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.division-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--green-light);
    color: var(--green-dark);
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 600;
    border: 1px solid rgba(26,107,60,.15);
}

.division-pill i {
    font-size: .78rem;
}
