/* =========================================================
   FRELODY Documentation — Theme
   Mobile-first, responsive, light + dark.
   Theme is driven by [data-bs-theme="light"|"dark"] on <html>,
   matching the main FRELODY app.
   ========================================================= */

:root,
[data-bs-theme="light"] {
    /* Brand */
    --brand-1: #667eea;
    --brand-2: #764ba2;
    --brand-grad: linear-gradient(135deg, #667eea, #764ba2);

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef2ff;
    --accent-soft-text: #3730a3;

    /* Premium */
    --gold: #d4af37;
    --gold-soft: #fbf3d6;
    --gold-text: #6b4e0e;

    /* Light theme defaults */
    --bg: #ffffff;
    --bg-elevated: #ffffff;
    --bg-subtle: #f7f8fb;
    --bg-muted: #eef2f7;
    --bg-sidebar: #fafbfd;
    --bg-topbar: rgba(255, 255, 255, 0.85);

    --text: #1f2430;
    --text-muted: #5b6678;
    --text-subtle: #8a94a6;
    --text-inverted: #ffffff;

    --border: #e5e7eb;
    --border-strong: #cdd5e0;

    --link: var(--accent);
    --link-hover: var(--accent-hover);

    --code-bg: #f3f5f9;
    --code-text: #2c3142;

    /* Sidebar / nav active state — theme-aware so scoped component CSS
       does not need to know which theme is active. */
    --nav-active-bg: rgba(79, 70, 229, 0.10);
    --nav-active-bg-hover: rgba(79, 70, 229, 0.16);
    --nav-active-fg: var(--accent);
    --nav-active-bar: var(--accent);
    --nav-active-dot: var(--accent);

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, 0.18);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --font-sans: 'Kanit', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --topbar-height: 60px;
    --sidebar-width: 300px;
    --content-max: 880px;

    --transition: 180ms ease;
}

[data-bs-theme="dark"] {
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #1e1b4b;
    --accent-soft-text: #c7d2fe;

    --gold: #f5c84c;
    --gold-soft: rgba(245, 200, 76, 0.14);
    --gold-text: #f5c84c;

    --bg: #0e131c;
    --bg-elevated: #1f2937;
    --bg-subtle: #131a26;
    --bg-muted: #1c2433;
    --bg-sidebar: #111827;
    --bg-topbar: rgba(14, 19, 28, 0.85);

    --text: #f3f4f6;
    --text-muted: #aeb6c4;
    --text-subtle: #7a8597;
    --text-inverted: #0e131c;

    --border: #2a3342;
    --border-strong: #3a4456;

    --link: var(--accent);
    --link-hover: var(--accent-hover);

    --code-bg: #1a2230;
    --code-text: #d6dfee;

    --nav-active-bg: rgba(129, 140, 248, 0.20);
    --nav-active-bg-hover: rgba(129, 140, 248, 0.30);
    --nav-active-fg: #ffffff;
    --nav-active-bar: var(--accent);
    --nav-active-dot: var(--accent);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

html {
    font-family: var(--font-sans);
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    color-scheme: light dark;
}

body {
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--link); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--link-hover); text-decoration: underline; }

img { max-width: 100%; display: block; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Initial loader ---------- */
.initial-loader {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100vh; gap: 1rem; color: var(--text-muted);
}
.initial-loader-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- App shell ---------- */
.app-shell {
    display: grid;
    grid-template-rows: var(--topbar-height) 1fr;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

.app-topbar {
    grid-row: 1; grid-column: 1;
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0 1rem;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }

.icon-btn {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
    color: var(--text); cursor: pointer; transition: background var(--transition), border-color var(--transition);
}
.icon-btn:hover { background: var(--bg-muted); }
.icon-btn svg { width: 20px; height: 20px; }

.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--brand-grad);
    display: inline-flex; align-items: center; justify-content: center;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    flex: none;
}
.brand-mark img, .brand-mark svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-title { font-weight: 700; font-size: 1rem; letter-spacing: 0.04em; }
.brand-sub { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* ---------- Sidebar ---------- */
.sidebar-backdrop {
    position: fixed; inset: 0; top: var(--topbar-height);
    background: rgba(15, 23, 42, 0.45);
    opacity: 0; pointer-events: none; transition: opacity var(--transition); z-index: 20;
}
.sidebar-backdrop.is-visible { opacity: 1; pointer-events: auto; }

.app-sidebar {
    position: fixed; top: var(--topbar-height); bottom: 0; left: 0;
    width: min(86vw, var(--sidebar-width));
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform var(--transition);
    overflow-y: auto;
    z-index: 25;
}
.app-sidebar.is-open { transform: translateX(0); }

/* ---------- Main ---------- */
.app-main {
    grid-row: 2; grid-column: 1;
    min-width: 0;
    display: flex; flex-direction: column;
}

.page-container {
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 1.25rem 1rem 2rem;
}

/* ---------- Footer ---------- */
.app-footer { margin-top: auto; padding: 2rem 1rem; border-top: 1px solid var(--border); background: var(--bg-subtle); }
.footer-inner { max-width: var(--content-max); margin: 0 auto; color: var(--text-muted); font-size: 0.85rem; }
.footer-inner p { margin: 0.2rem 0; }
.footer-inner .muted { color: var(--text-subtle); }

/* ---------- Desktop layout ---------- */
@media (min-width: 960px) {
    .app-shell {
        grid-template-columns: var(--sidebar-width) 1fr;
        grid-template-rows: var(--topbar-height) 1fr;
    }
    .app-topbar { grid-column: 1 / -1; }
    .topbar-menu-btn { display: none; }
    .app-sidebar {
        position: sticky; top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
        transform: none; grid-row: 2; grid-column: 1;
        z-index: 5;
    }
    .sidebar-backdrop { display: none; }
    .app-main { grid-row: 2; grid-column: 2; }
    .page-container { padding: 2rem 2rem 3rem; }
}

/* ---------- Nav menu ---------- */
/* The .navmenu / .nav-group / .nav-children rules live in scoped CSS.
   The .nav-link rules MUST stay global because <NavLink> is a child component:
   the <a> it renders does not receive the parent component's scope attribute. */

a.nav-link {
    --depth: 0;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    padding-left: calc(0.75rem + var(--depth) * 0.85rem - 3px);
    background: transparent;
    border: 0;
    border-left: 3px solid transparent; /* reserved for active indicator */
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

a.nav-link:hover {
    background: var(--bg-muted);
    color: var(--text);
    text-decoration: none;
}

a.nav-link.is-active {
    background: var(--nav-active-bg);
    color: var(--nav-active-fg);
    font-weight: 600;
    border-left-color: var(--nav-active-bar);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

a.nav-link.is-active:hover {
    background: var(--nav-active-bg-hover);
    color: var(--nav-active-fg);
}

a.nav-link.is-active .nav-link-dot { background: var(--nav-active-dot); }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { margin: 0 0 1.25rem; }
.breadcrumb-list {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem;
    font-size: 0.85rem; color: var(--text-muted);
}
.breadcrumb-link {
    display: inline-flex; align-items: center; gap: 0.3rem;
    color: var(--text-muted); padding: 0.15rem 0.35rem; border-radius: 4px;
}
.breadcrumb-link:hover { color: var(--link); background: var(--bg-muted); text-decoration: none; }
.breadcrumb-icon { width: 14px; height: 14px; }
.breadcrumb-sep { display: inline-flex; color: var(--text-subtle); }
.breadcrumb-sep svg { width: 12px; height: 12px; }
.breadcrumb-current { color: var(--text); font-weight: 600; }

/* ---------- Doc article ---------- */
.doc-article { color: var(--text); }
.doc-article h1, .doc-article h2, .doc-article h3, .doc-article h4 { color: var(--text); line-height: 1.25; margin-top: 2rem; margin-bottom: 0.75rem; }
.doc-article h1 { font-size: clamp(1.7rem, 1.4rem + 1.5vw, 2.25rem); margin-top: 0; letter-spacing: -0.01em; }
.doc-article h2 { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.6rem); border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.doc-article h3 { font-size: 1.15rem; }
.doc-article h4 { font-size: 1rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.doc-article p { margin: 0.85rem 0; }
.doc-article ul, .doc-article ol { padding-left: 1.4rem; margin: 0.85rem 0; }
.doc-article li { margin: 0.3rem 0; }
.doc-article blockquote {
    margin: 1rem 0; padding: 0.6rem 1rem;
    border-left: 4px solid var(--accent);
    background: var(--accent-soft);
    color: var(--text);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.doc-article code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
}
.doc-article pre {
    background: var(--code-bg); color: var(--code-text);
    padding: 1rem; border-radius: var(--radius-md);
    overflow-x: auto; font-size: 0.875em;
    border: 1px solid var(--border);
}
.doc-article pre code { background: transparent; padding: 0; }
.doc-article table {
    width: 100%; border-collapse: collapse; margin: 1rem 0;
    border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden;
}
.doc-article th, .doc-article td { padding: 0.6rem 0.8rem; text-align: left; border-bottom: 1px solid var(--border); }
.doc-article th { background: var(--bg-subtle); font-weight: 600; }
.doc-article tr:last-child td { border-bottom: 0; }
.doc-article hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.lead { font-size: 1.1rem; color: var(--text-muted); }

/* ---------- Video embed (YouTube walkthroughs) ---------- */
.video-embed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 1.25rem 0;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.video-embed > iframe {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    border: 0; display: block;
}
.video-embed-caption { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text-muted); }

/* ---------- Page nav (prev/next) ---------- */
.page-nav {
    display: grid; grid-template-columns: 1fr; gap: 0.75rem;
    margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}
@media (min-width: 640px) { .page-nav { grid-template-columns: 1fr 1fr; } }
.page-nav-link {
    display: flex; flex-direction: column; gap: 0.25rem;
    padding: 0.85rem 1rem;
    background: var(--bg-subtle); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text);
    transition: border-color var(--transition), background var(--transition);
}
.page-nav-link:hover { border-color: var(--accent); text-decoration: none; }
.page-nav-link.is-next { text-align: right; }
.page-nav-direction { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.page-nav-title { font-weight: 600; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    border-radius: var(--radius-md);
    font-weight: 600; font-size: 0.95rem;
    cursor: pointer; border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn-primary { background: var(--accent); color: #ffffff; }
.btn-primary:hover { background: var(--accent-hover); color: #ffffff; text-decoration: none; }
.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); text-decoration: none; }

/* ---------- Hero / quick cards / sections ---------- */
.hero { padding: 1rem 0 1.5rem; }
.hero-eyebrow { color: var(--text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.12em; margin: 0; }
.hero-title {
    font-size: clamp(2rem, 1.5rem + 2.5vw, 3rem); margin: 0.4rem 0 0.6rem; letter-spacing: -0.02em;
    background: var(--brand-grad);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent; color: transparent;
}
.hero-lead { font-size: 1.05rem; color: var(--text-muted); max-width: 70ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }

.quick-cards {
    display: grid; gap: 0.85rem;
    grid-template-columns: 1fr;
    margin: 1.5rem 0 2rem;
}
@media (min-width: 640px) { .quick-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .quick-cards { grid-template-columns: repeat(3, 1fr); } }

.quick-card {
    display: block; padding: 1rem 1.1rem;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
    color: var(--text); box-shadow: var(--shadow-sm);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}
.quick-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow-md); text-decoration: none; }
.quick-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; color: var(--text); }
.quick-card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }

.sections-grid { margin-top: 2rem; }
.sections-grid h2 { font-size: 1.4rem; margin-bottom: 1rem; }
.sections-list { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .sections-list { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .sections-list { grid-template-columns: repeat(3, 1fr); } }

.section-card {
    padding: 1rem 1.1rem;
    background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-md);
}
.section-card h3 { margin: 0 0 0.6rem; font-size: 1rem; color: var(--text); }
.section-card ul { list-style: none; padding: 0; margin: 0; }
.section-card li { padding: 0.2rem 0; font-size: 0.9rem; }
.section-card a { color: var(--text-muted); }
.section-card a:hover { color: var(--link); }
.section-subgroup { margin-top: 0.4rem; }
.section-subgroup-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-subtle); }
.section-subgroup ul { padding-left: 0.6rem; border-left: 1px dashed var(--border); margin-top: 0.2rem; }

/* ---------- Image placeholder ---------- */
.img-frame {
    position: relative; display: block;
    width: 100%; margin: 1.25rem 0;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.img-frame > img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: cover; object-position: center;
    display: block;
}
.img-frame-placeholder {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.5rem; color: var(--text-subtle);
    background:
        repeating-linear-gradient(45deg,
            transparent 0 12px,
            rgba(125, 138, 160, 0.08) 12px 24px);
}
.img-frame-placeholder svg { width: 40px; height: 40px; opacity: 0.7; }
.img-frame-caption { font-size: 0.85rem; }
.img-frame-figcaption {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 0.4rem 0.75rem;
    background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
    color: #fff; font-size: 0.8rem;
}

/* ---------- Skeletons ---------- */
.page-loading { padding: 1rem 0; }
.skeleton { background: linear-gradient(90deg, var(--bg-muted), var(--bg-subtle), var(--bg-muted)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-title { height: 32px; width: 60%; margin-bottom: 1rem; }
.skeleton-line { height: 14px; width: 100%; margin-bottom: 0.6rem; }
.skeleton-line.short { width: 65%; }

/* ---------- Misc ---------- */
.not-found { padding: 3rem 1rem; text-align: center; }
.not-found h1 { margin-bottom: 0.5rem; }

#blazor-error-ui {
    background: #fff3cd; color: #1a2233;
    bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none; left: 0; padding: 0.6rem 1rem; position: fixed;
    width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* =========================================================
   Audience gating — sign-in, top-bar user, lock badges, access gate
   ========================================================= */

.topbar-signin { margin-right: 0.4rem; }
.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 0.4rem;
    padding: 0.2rem 0.4rem 0.2rem 0.6rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text);
}
.topbar-user-name { font-weight: 600; }
.topbar-user-badge {
    background: var(--accent);
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
}
.topbar-user-badge-premium { background: var(--gold); color: #2a2207; }
.btn-sm { padding: 0.25rem 0.65rem; font-size: 0.8rem; }

/* Generic small button helpers reused by access gate + overlay */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem 0.95rem;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--bg-muted); }
.btn-ghost:disabled { opacity: 0.6; cursor: not-allowed; }

/* Lock icon next to gated nav items */
.nav-lock {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    color: var(--text-subtle);
    opacity: 0.85;
}
.nav-lock svg { width: 0.85rem; height: 0.85rem; }
.nav-link .nav-lock { margin-left: auto; }
.nav-lock-premium { color: var(--gold); opacity: 1; }
.nav-lock-admin { color: var(--accent); opacity: 1; }

/* Access gate (page-level block) */
.access-gate {
    display: flex;
    justify-content: center;
    padding: 2.5rem 0;
}
.access-gate-card {
    max-width: 560px;
    width: 100%;
    text-align: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem 1.75rem;
    box-shadow: var(--shadow-md);
}
.access-gate-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
}
.access-gate-icon svg { width: 28px; height: 28px; }
.access-gate-title { margin: 0 0 0.4rem; font-size: 1.25rem; }
.access-gate-body { margin: 0 0 1.1rem; color: var(--text-muted); }
.access-gate-note { font-size: 0.85rem; }

/* =========================================================
   PDF export — page action button, hero button, progress overlay, print
   ========================================================= */

.page-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.page-header-row > .breadcrumbs { flex: 1 1 auto; min-width: 0; }

.page-actions { display: inline-flex; gap: 0.4rem; flex: 0 0 auto; }
.page-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--border-strong);
    background: var(--bg-elevated);
    color: var(--text);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.page-action-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.page-action-btn svg { width: 1rem; height: 1rem; }
.page-action-label { font-size: 0.82rem; }

.page-action-btn.page-action-btn-stack {
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.35rem 0.55rem;
    line-height: 1;
}
.page-action-btn.page-action-btn-stack svg { width: 1.2rem; height: 1.2rem; }
.page-action-btn.page-action-btn-stack .page-action-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.hero-pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}
.hero-pdf-btn svg { width: 1rem; height: 1rem; }

.pdf-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 17, 38, 0.55);
    backdrop-filter: blur(2px);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pdf-overlay-card {
    width: min(380px, calc(100vw - 2rem));
    background: var(--bg-elevated);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem 1.5rem 1.25rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.pdf-overlay-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--accent-soft);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 0.9rem;
    animation: pdf-spin 0.9s linear infinite;
}
@keyframes pdf-spin { to { transform: rotate(360deg); } }
.pdf-overlay-title { margin: 0 0 0.3rem; font-size: 1.1rem; color: var(--accent); }
.pdf-overlay-status { margin: 0 0 1rem; color: var(--text-muted); font-size: 0.9rem; }
.pdf-overlay-bar {
    height: 8px;
    background: var(--bg-muted);
    border-radius: 999px;
    overflow: hidden;
    margin: 0 0 0.5rem;
    position: relative;
}
.pdf-overlay-bar-fill {
    height: 100%;
    background: var(--brand-grad);
    width: 0;
    border-radius: 999px;
    transition: width 0.3s ease;
}
.pdf-overlay-bar-indet .pdf-overlay-bar-fill {
    width: 35%;
    animation: pdf-indet 1.2s ease-in-out infinite;
}
@keyframes pdf-indet {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(285%); }
}
.pdf-overlay-count { font-size: 0.78rem; margin: 0 0 1rem; }

/* Print mode — when the user uses Ctrl+P directly on a doc page */
@media print {
    .app-topbar,
    .app-sidebar,
    .sidebar-backdrop,
    .app-footer,
    .page-nav,
    .page-actions,
    .video-embed,
    .pdf-overlay { display: none !important; }
    .app-shell { display: block !important; }
    .app-main { margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
    .doc-article { color: #1a2233 !important; }
    .doc-article a { color: #4f46e5 !important; }
    .doc-article h1, .doc-article h2, .doc-article h3 { color: #4338ca !important; page-break-after: avoid; }
    .doc-article pre, .doc-article table, .doc-article .img-frame { page-break-inside: avoid; }
}

/* =========================================================
   Reusable CSS tooltip (data-tooltip attribute).
   ========================================================= */
.has-tooltip { position: relative; }
.has-tooltip::after,
.has-tooltip::before {
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    position: absolute;
    z-index: 1200;
}
.has-tooltip::after {
    content: attr(data-tooltip);
    background: #1a2233;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
    white-space: nowrap;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, 4px);
}
.has-tooltip::before {
    content: "";
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-top-color: #1a2233;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translate(-50%, 4px);
}
.has-tooltip:hover::after,
.has-tooltip:hover::before,
.has-tooltip:focus-visible::after,
.has-tooltip:focus-visible::before {
    opacity: 1;
    transform: translate(-50%, 0);
}

.has-tooltip.tooltip-left::after {
    bottom: 50%;
    left: auto;
    right: calc(100% + 8px);
    transform: translate(4px, 50%);
}
.has-tooltip.tooltip-left::before {
    bottom: 50%;
    left: auto;
    right: calc(100% + 3px);
    border-top-color: transparent;
    border-left-color: #1a2233;
    transform: translate(4px, 50%);
}
.has-tooltip.tooltip-left:hover::after,
.has-tooltip.tooltip-left:focus-visible::after { transform: translate(0, 50%); }
.has-tooltip.tooltip-left:hover::before,
.has-tooltip.tooltip-left:focus-visible::before { transform: translate(0, 50%); }

@media print {
    .has-tooltip::after,
    .has-tooltip::before { display: none !important; }
}
