/* ────────────────────────────────────────────────────────
   DocPlatform – Core Styles
   ──────────────────────────────────────────────────────── */

:root {
    --bg-body: #f4f5f7;
    --bg-surface: #ffffff;
    --bg-sidebar: #1b1f2e;
    --bg-sidebar-hover: #262b3e;
    --bg-sidebar-active: #323850;
    --bg-topbar: #ffffff;
    --bg-input: #f0f1f4;

    --text-primary: #1a1d28;
    --text-secondary: #5f6577;
    --text-muted: #9298a8;
    --text-sidebar: #c4c9d9;
    --text-sidebar-active: #ffffff;
    --text-sidebar-label: #6e7590;

    --accent: #4361ee;
    --accent-hover: #3651d4;
    --accent-light: #eef1fd;
    --accent-subtle: #dce3fb;

    --border: #e2e4ea;
    --border-light: #edeef2;

    --danger: #e63946;
    --danger-light: #fdeced;
    --success: #2a9d5c;
    --success-light: #e8f7ef;
    --warning: #e8a317;
    --warning-light: #fef7e6;

    --radius: 8px;
    --radius-sm: 5px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);

    --sidebar-width: 280px;
    --topbar-height: 56px;

    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'IBM Plex Mono', 'Menlo', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.wiki-link-new {
    color: #ba3925;
    border-bottom: 1px dashed #ba3925;
    text-decoration: none;
}

.wiki-link-new:hover {
    color: #8b1a1a;
    border-bottom-color: #8b1a1a;
}

/* ── Top Bar ── */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    z-index: 100;
    gap: 1rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 220px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
}
.sidebar-toggle:hover { background: var(--bg-input); }

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}
.topbar-brand i { color: var(--accent); font-size: 1.3rem; }
.topbar-brand-icon { min-width: 1.3rem; text-align: center; }
img.topbar-brand-icon { min-width: 0; max-height: 28px; width: auto; }

.topbar-center { flex: 1; max-width: 520px; }

.search-form {
    position: relative;
    width: 100%;
}
.search-form input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: border-color 0.2s, background 0.2s;
}
.search-form input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.search-form input::placeholder { color: var(--text-muted); }
.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.topbar-link {
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 1.15rem;
    display: flex;
    align-items: center;
}
.topbar-link:hover { background: var(--bg-input); color: var(--text-primary); }

.user-menu { position: relative; }

.user-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 200;
    overflow: hidden;
}
.user-dropdown.open { display: block; }

.dropdown-header {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-light);
    font-weight: 500;
}
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
}
.dropdown-item:hover { background: var(--bg-input); }

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 90;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    scrollbar-width: thin;
    scrollbar-color: var(--bg-sidebar-active) transparent;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--bg-sidebar-active); border-radius: 3px; }

.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-nav { padding: 0.75rem 0; }

.nav-section-label {
    padding: 0.6rem 1.25rem 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-sidebar-label);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1.25rem;
    color: var(--text-sidebar);
    font-size: 0.88rem;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font-sans);
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }
.nav-item.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 500;
}
.nav-item i { font-size: 1rem; opacity: 0.7; flex-shrink: 0; }
.nav-item span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-home { margin-bottom: 0.25rem; }

.nav-action { color: var(--accent); }
.nav-action:hover { color: #fff; }
.nav-action i { opacity: 1; }

/* Category toggles */
.nav-category-header {
    display: flex;
    align-items: center;
}

.nav-category-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1.25rem;
    color: var(--text-sidebar);
    font-size: 0.88rem;
    font-family: var(--font-sans);
    transition: background 0.15s, color 0.15s;
    flex: 1;
}
.nav-category-link:hover,
.nav-category-link.active { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }

.nav-category-toggle {
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-sidebar);
    width: 2.5rem;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.nav-category-toggle:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }

.nav-category-link .category-icon { font-size: 1rem; opacity: 0.7; flex-shrink: 0; }
.nav-category-link span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
.toggle-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s;
    opacity: 0.5;
}
.nav-category-toggle.expanded .toggle-arrow { transform: rotate(90deg); }

.nav-category-children {
    display: none;
    padding-left: 0.75rem;
    margin-left: 0.75rem;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.nav-category-children.open { display: block; }

.nav-page { padding-left: 2rem; font-size: 0.85rem; }
.nav-page i { font-size: 0.85rem; }

.nav-category .nav-category-link { padding-left: 1rem; }
.nav-category .nav-category .nav-category-link { font-size: 0.84rem; }
.nav-category .nav-category .nav-category-toggle { width: 2.25rem; }

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--topbar-height);
    padding: 2rem max(2rem, calc((100vw - var(--sidebar-width) - 2560px) / 2));
    min-height: calc(100vh - var(--topbar-height));
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-content.expanded {
    margin-left: 0;
    padding-left: max(2rem, calc((100vw - 1600px) / 2));
    padding-right: max(2rem, calc((100vw - 1600px) / 2));
}

.site-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.site-footer-build {
    font-family: var(--font-mono);
    opacity: 0.7;
}

.auth-footer,
.public-footer {
    margin-top: 1rem;
    padding-top: 0;
    border-top: 0;
}

/* ── Cards / Panels ── */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Collapsible Category Sections ── */
.category-section-header {
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.category-section-header:hover {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}

.category-section-chevron {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.category-section-header[aria-expanded="true"] .category-section-chevron {
    transform: rotate(90deg);
}

.category-section-body {
    display: none;
}

.category-section-body.open {
    display: block;
}

/* ── Page Content ── */
.page-header {
    margin-bottom: 1.5rem;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

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

.breadcrumbs a:hover {
    color: var(--accent);
}

.breadcrumbs .current {
    color: var(--text-primary);
    font-weight: 600;
}

.breadcrumbs-separator {
    color: var(--text-muted);
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1.3;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.page-meta span { display: flex; align-items: center; gap: 0.3rem; }

.page-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.page-body {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    line-height: 1.75;
    font-size: 0.95rem;
    flex: 1;
    overflow-y: auto;
}

.page-body h1, .page-body h2, .page-body h3, .page-body h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
}
.page-body h1 { font-size: 1.6rem; }
.page-body h2 { font-size: 1.35rem; border-bottom: 1px solid var(--border-light); padding-bottom: 0.4em; }
.page-body h3 { font-size: 1.15rem; }
.page-body h4 { font-size: 1rem; }
.page-body p { margin-bottom: 1em; }
.page-body ul, .page-body ol { margin-bottom: 1em; padding-left: 1.5em; }
.page-body li { margin-bottom: 0.3em; }
.page-body code {
    font-family: var(--font-mono);
    background: var(--bg-input);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.88em;
}
.page-body pre {
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1em;
    font-size: 0.85rem;
    line-height: 1.6;
}
.page-body pre code { background: none; padding: 0; color: inherit; }
.page-body pre[class*="language-"],
.page-body code[class*="language-"] {
    font-family: var(--font-mono);
    text-shadow: none;
}
.page-body pre[class*="language-"] {
    padding: 1rem 1.25rem;
}
.page-body :not(pre) > code[class*="language-"] {
    padding: 0.15em 0.4em;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-primary);
}
.page-body div.code-toolbar {
    position: relative;
    margin-bottom: 1em;
}
.page-body div.code-toolbar > pre,
.page-body div.code-toolbar > .line-numbers-rows {
    margin-bottom: 0;
}
.page-body div.code-toolbar > .toolbar {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}
.page-body div.code-toolbar:hover > .toolbar,
.page-body div.code-toolbar:focus-within > .toolbar {
    opacity: 1;
}
.page-body div.code-toolbar > .toolbar > .toolbar-item > button,
.page-body div.code-toolbar > .toolbar > .toolbar-item > a,
.page-body div.code-toolbar > .toolbar > .toolbar-item > span {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    line-height: 1.2;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: rgba(0, 0, 0, 0.06);
    color: #555;
    box-shadow: none;
    text-decoration: none;
}
.page-body div.code-toolbar > .toolbar > .toolbar-item > button {
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.page-body div.code-toolbar > .toolbar > .toolbar-item > button:hover,
.page-body div.code-toolbar > .toolbar > .toolbar-item > a:hover {
    background: rgba(0, 0, 0, 0.12);
    color: #222;
    border-color: rgba(0, 0, 0, 0.22);
}
.page-body div.code-toolbar > .toolbar > .toolbar-item > span {
    background: var(--success);
    border-color: transparent;
    color: #ffffff;
}
.page-body pre.line-numbers {
    padding-left: 3.8em;
}
.page-body pre.line-numbers .line-numbers-rows {
    border-right-color: rgba(0, 0, 0, 0.12);
}
.page-body pre.line-numbers .line-numbers-rows > span:before {
    color: rgba(0, 0, 0, 0.3);
}
.page-body blockquote {
    border-left: 3px solid var(--accent);
    padding: 0.75rem 1rem;
    margin: 1em 0;
    background: var(--accent-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}
.page-body .doc-callout {
    margin: 1.25rem 0;
    padding: 1rem 1.125rem;
    border: 1px solid var(--accent-subtle);
    border-left-width: 4px;
    border-radius: var(--radius);
    background: #f7f9ff;
    color: var(--text-primary);
}
.page-body .doc-callout > :last-child { margin-bottom: 0; }
.page-body .doc-callout-title {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}
.page-body .doc-callout-info {
    border-color: #cfe1ff;
    border-left-color: var(--accent);
    background: #eef4ff;
}
.page-body .doc-callout-info .doc-callout-title { color: #2745bf; }
.page-body .doc-callout-warning {
    border-color: #f6df9b;
    border-left-color: var(--warning);
    background: #fff8e3;
}
.page-body .doc-callout-warning .doc-callout-title { color: #9f6500; }
.page-body .doc-callout-tip {
    border-color: #bce8cf;
    border-left-color: var(--success);
    background: #eefaf3;
}
.page-body .doc-callout-tip .doc-callout-title { color: #1f7c47; }
.page-body .doc-callout-danger {
    border-color: #f6c4c9;
    border-left-color: var(--danger);
    background: #fff1f2;
}
.page-body .doc-callout-danger .doc-callout-title { color: #b42330; }
.page-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}
.page-body th, .page-body td {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    text-align: left;
}
.page-body th { background: var(--bg-input); font-weight: 600; font-size: 0.88rem; }
.page-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.page-body img.page-body-image-zoomable {
    cursor: zoom-in;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.page-body img.page-body-image-zoomable:hover,
.page-body img.page-body-image-zoomable:focus-visible {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.page-body h2[id],
.page-body h3[id] {
    scroll-margin-top: 1rem; /* topbar offset no longer needed */
}

/* Lock the page from scrolling on page view */
body:has(.page-view-layout) {
    overflow: hidden;
}

body:has(.page-view-layout) .main-content {
    padding-left: max(2rem, calc((100vw - var(--sidebar-width) - 2000px) / 2));
    padding-right: max(2rem, calc((100vw - var(--sidebar-width) - 2000px) / 2));
    padding-bottom: 0;
    height: calc(100vh - var(--topbar-height));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.page-view-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
    align-items: start;
    flex: 1;
    min-height: 0; /* critical — prevents flex children from overflowing */
}

.page-view-main {
    min-width: 0;
    max-width: 2560px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.page-view-sidebar {
    position: sticky;
    top: calc(var(--topbar-height) + 2rem);
    max-height: calc(100vh - var(--topbar-height) - 4rem);
    overflow-y: auto;
}

.page-view-sidebar .sidebar-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.page-view-sidebar .sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.page-view-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.page-view-actions .btn {
    width: 100%;
    justify-content: flex-start;
}

.page-toc a {
    display: block;
    padding: 0.25rem 0;
    padding-left: 0.75rem;
    font-size: 0.84rem;
    color: var(--text-secondary);
    border-left: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.page-toc a:hover,
.page-toc a.active {
    color: var(--accent);
    border-left-color: var(--accent);
}

.page-toc a[data-level="3"] {
    padding-left: 1.5rem;
    font-size: 0.8rem;
}

.page-toc a[data-level="4"] {
    padding-left: 2.25rem;
    font-size: 0.78rem;
}

.page-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    background: var(--accent-light);
    color: var(--accent);
    transition: background 0.15s;
}

.tag-badge:hover {
    background: rgba(67, 97, 238, 0.18);
    color: var(--accent);
}

/* ── Tag Input Component ── */
.tag-input-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    padding: 0.35rem 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    cursor: text;
    min-height: 38px;
    position: relative;
    transition: border-color 0.15s;
}

.tag-input-wrap:focus-within {
    border-color: var(--accent);
    outline: none;
}

.tag-input-wrap .tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    background: var(--accent-light);
    color: var(--accent);
    white-space: nowrap;
    line-height: 1.4;
}

.tag-input-wrap .tag-pill .tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: none;
    background: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    border-radius: 50%;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.tag-input-wrap .tag-pill .tag-remove:hover {
    opacity: 1;
    background: rgba(67, 97, 238, 0.15);
}

.tag-input-wrap .tag-text-input {
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-primary);
    flex: 1;
    min-width: 80px;
    padding: 0.1rem 0;
}

.tag-input-wrap .tag-text-input::placeholder {
    color: var(--text-muted);
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 50;
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
    display: none;
}

.tag-suggestions.open {
    display: block;
}

.tag-suggestion-item {
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.1s;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

.page-view-sidebar::-webkit-scrollbar {
    width: 4px;
}

.page-view-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.page-view-sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

@media (max-width: 1024px) {
    .page-view-layout {
        grid-template-columns: 1fr;
    }

    .page-view-sidebar {
        display: none;
    }
}

body.image-viewer-open {
    overflow: hidden;
}

.page-image-viewer {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem;
    background: rgba(12, 15, 24, 0.88);
    z-index: 1000;
}

.page-image-viewer.open {
    display: flex;
}

.page-image-viewer-media {
    max-width: min(92vw, 1600px);
    max-height: 84vh;
    width: auto;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    background: var(--bg-surface);
}

.page-image-viewer-caption {
    max-width: min(92vw, 900px);
    color: #f8f9fc;
    text-align: center;
    font-size: 0.9rem;
}

.page-image-viewer-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.75rem;
    height: 2.75rem;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.page-image-viewer-close:hover,
.page-image-viewer-close:focus-visible {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .page-image-viewer {
        padding: 1rem;
    }

    .page-image-viewer-media {
        max-width: 100%;
        max-height: 78vh;
    }
}

/* ── Tag Create Modal ── */
.create-tag-modal {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(520px, calc(100vw - 2rem));
    max-width: 100%;
    border: 0;
    border-radius: var(--radius-lg);
    padding: 0;
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
}

.create-tag-modal::backdrop {
    background: rgba(15, 20, 32, 0.55);
}

.create-tag-modal-form {
    padding: 1.25rem 1.25rem 1rem;
}

.create-tag-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.create-tag-modal-header h2 {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

.create-tag-modal-close {
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.create-tag-modal-close:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .create-tag-modal {
        width: calc(100vw - 1rem);
    }

    .create-tag-modal-form {
        padding: 1rem;
    }
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-secondary { background: var(--bg-input); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c5303c; color: #fff; }

.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-light); }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.88rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-surface);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6577' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.form-check input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.validation-message, .field-validation-error {
    color: var(--danger);
    font-size: 0.82rem;
    margin-top: 0.25rem;
}

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
}
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #c3e6cb; }
.alert-warning { background: var(--warning-light); color: #856404; border: 1px solid #ffeeba; }

/* ── Tables ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th, .data-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
.data-table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    background: var(--bg-input);
}
.activity-log-table-scroll {
    max-height: 65vh;
    overflow: auto;
}
.activity-log-table-scroll .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-input);
    box-shadow: inset 0 -1px 0 var(--border-light);
}
.data-table tr:hover td { background: #f8f9fb; }
.data-table .actions { white-space: nowrap; }

.all-pages-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.all-pages-search {
    flex: 1 1 360px;
    max-width: 640px;
}

.all-pages-search-input {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.all-pages-search-input .bi-search {
    position: absolute;
    left: 0.85rem;
    color: var(--text-muted);
    pointer-events: none;
}

.all-pages-search-input .form-control {
    flex: 1 1 auto;
    padding-left: 2.4rem;
}

.all-pages-summary {
    white-space: nowrap;
}

.all-pages-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 1.5rem;
    color: var(--text-muted);
}

.all-pages-empty-state i {
    font-size: 1rem;
}

.admin-category-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-tree-toggle {
    width: 1.35rem;
    height: 1.35rem;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.admin-tree-toggle:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.admin-category-branch {
    color: var(--text-muted);
    font-size: 0.75rem;
    width: 1.35rem;
    display: inline-flex;
    justify-content: center;
}

.admin-category-branch-placeholder {
    visibility: hidden;
}

.tree-toolbar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.tree-toolbar .form-control {
    min-width: min(100%, 320px);
    flex: 1;
}

.tree-impact-list {
    margin: 0;
    padding-left: 1.25rem;
}

.actions .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-manager { background: #ffedd5; color: #c2410c; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--bg-input); color: var(--text-muted); }

/* ── Stat Cards ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.3rem;
}
.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

/* ── Home Page ── */
.home-hero {
    text-align: center;
    padding: 1.5rem 0 2rem;
}

.home-hero h1 {
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.home-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.1rem;
}

.home-search {
    position: relative;
    width: min(100%, 600px);
    margin: 0 auto;
}

.home-search input {
    width: 100%;
    height: 52px;
    padding: 0.65rem 1rem 0.65rem 2.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-surface);
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.home-search input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.home-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    pointer-events: none;
}

/* was: display:grid / auto-fill */
.category-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* give cards a consistent width so they centre cleanly */
.category-card {
    flex: 0 1 280px;
    min-width: 220px;
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

/* new muted pill for subcategory count */
.category-card-subcategory {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-subtle);
    color: var(--text-primary);
}

.category-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.category-card-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 1rem;
}

.category-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.category-card-description {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.category-card-count {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
}

.home-page-title {
    font-weight: 600;
}

.page-summary-line {
    margin-top: 0.2rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    max-width: 420px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Auth Pages ── */
.auth-page {
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.auth-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-brand i { font-size: 2.5rem; color: var(--accent); }
.auth-brand-logo { max-height: 42px; width: auto; }
.auth-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 0.5rem;
    letter-spacing: -0.03em;
}
.auth-brand p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.branding-theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.branding-color-input {
    min-height: 48px;
    padding: 0.35rem;
    cursor: pointer;
}

.branding-preview {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-body);
}

.branding-preview-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border-light);
}

.branding-preview-brand {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-weight: 700;
}

.branding-preview-brand i {
    color: var(--accent);
    font-size: 1.1rem;
}

.branding-preview-logo {
    height: 22px;
    width: auto;
    border-radius: 4px;
}

.branding-preview-body {
    display: grid;
    grid-template-columns: 200px 1fr;
    min-height: 220px;
}

.branding-preview-sidebar {
    padding: 1rem 0;
    background: var(--bg-sidebar);
}

.branding-preview-nav-item {
    padding: 0.6rem 1rem;
    color: var(--text-sidebar);
    font-size: 0.88rem;
}

.branding-preview-nav-item.active {
    color: var(--text-sidebar-active);
    font-weight: 600;
}

.branding-preview-content {
    padding: 1rem;
    background: var(--bg-body);
}

.branding-preview-card {
    max-width: 340px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

/* ── Category Page ── */
.category-header { margin-bottom: 1.5rem; }
.category-header h1 { font-size: 1.75rem; font-weight: 700; }
.category-header p { color: var(--text-secondary); margin-top: 0.25rem; }

/* ── Category Page: Sub-category Grid ── */
.subcategory-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-list { list-style: none; }
.page-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}
.page-list-item:hover { background: #f8f9fb; }
.page-list-item:last-child { border-bottom: none; }
.page-list-item i { color: var(--accent); font-size: 1.1rem; flex-shrink: 0; }
.page-list-item a { font-weight: 500; flex: 1; }
.page-list-item .page-summary {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ── Search Results ── */
.search-result {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
}
.search-result:last-child { border-bottom: none; }
.search-result h3 { font-size: 1.05rem; margin-bottom: 0.2rem; }
.search-result .search-cat {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.search-result p { font-size: 0.9rem; color: var(--text-secondary); margin-top: 0.3rem; }

/* ── Revision History ── */
.revision-list { list-style: none; }
.revision-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}
.revision-item:last-child { border-bottom: none; }
.revision-main {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 1rem;
    min-width: 280px;
}
.revision-date { color: var(--text-muted); min-width: 160px; font-family: var(--font-mono); font-size: 0.82rem; }
.revision-author { font-weight: 500; min-width: 140px; }
.revision-note { color: var(--text-secondary); }
.revision-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}
.revision-actions form { display: inline-flex; }
.revision-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid #f2d58c;
    border-left: 4px solid var(--warning);
    border-radius: var(--radius-lg);
    background: var(--warning-light);
    color: #6b4c06;
}
.revision-summary {
    margin-top: -0.35rem;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ── Diffs ── */
.diff-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.diff-meta-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}
.diff-meta-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.diff-section-card { padding: 0; overflow: hidden; }
.diff-section-card .card-header { padding: 1.25rem 1.5rem 0.75rem; margin-bottom: 0; }
.diff-container { overflow-x: auto; }
.diff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.diff-table th,
.diff-table td {
    border-top: 1px solid var(--border-light);
    vertical-align: top;
}
.diff-table th {
    padding: 0.75rem;
    background: var(--bg-input);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.75rem;
}
.diff-line-number {
    width: 52px;
    padding: 0.55rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.02);
}
.diff-line-text {
    width: calc(50% - 52px);
    padding: 0.55rem 0.75rem;
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-word;
}
.diff-added .diff-line-text,
.diff-added .diff-line-number { background: #edf9f1; }
.diff-removed .diff-line-text,
.diff-removed .diff-line-number { background: #fff1f2; }
.diff-modified .diff-line-text,
.diff-modified .diff-line-number { background: #fff8e3; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; padding: 1.25rem !important; }
    .topbar-left { min-width: auto; }
    .topbar-brand span { display: none; }
    .topbar-center { max-width: none; }
    .page-body { padding: 1.25rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
    .home-hero h1 { font-size: 1.65rem; }
    .home-search input { height: 48px; font-size: 0.95rem; }
    .category-grid { grid-template-columns: minmax(0, 1fr); }
    .page-summary-line { max-width: 240px; }
    .branding-preview-body { grid-template-columns: 1fr; }
    .revision-main { min-width: 0; }
    .revision-date,
    .revision-author { min-width: 0; }
    .diff-line-text { min-width: 220px; }
    .all-pages-toolbar { align-items: stretch; }
    .all-pages-search { max-width: none; }
    .all-pages-search-input { flex-wrap: wrap; }
    .all-pages-search-input .form-control { min-width: 0; }
    .all-pages-summary { white-space: normal; }
}

/* ── Utility ── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.fw-600 { font-weight: 600; }

/* ── Editor Sidebar Layout ──
   Used on Create and Edit page views to put metadata
   fields in a sticky right sidebar with the editor taking
   the remaining width.
   ──────────────────────────────────────────────────────── */

.editor-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.editor-main {
    flex: 1;
    min-width: 0; /* prevent flex blowout */
}

.editor-sidebar {
    width: 300px;
    flex-shrink: 0;
}

.editor-sidebar-inner {
    position: sticky;
    top: calc(var(--topbar-height) + 1.5rem);
    max-height: calc(100vh - var(--topbar-height) - 3rem);
    overflow-y: auto;
}

/* Slim scrollbar for the sidebar when content overflows */
.editor-sidebar-inner::-webkit-scrollbar { width: 4px; }
.editor-sidebar-inner::-webkit-scrollbar-track { background: transparent; }
.editor-sidebar-inner::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}
.editor-sidebar-inner::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Widen editor pages so the layout can breathe */
body:has(.editor-layout) .main-content {
    padding-left: max(2rem, calc((100vw - var(--sidebar-width) - 1800px) / 2));
    padding-right: max(2rem, calc((100vw - var(--sidebar-width) - 1800px) / 2));
}

/* Responsive: stack on smaller screens */
@media (max-width: 960px) {
    .editor-layout {
        flex-direction: column;
    }
    .editor-sidebar {
        width: 100%;
        order: -1; /* move settings above editor on mobile */
    }
    .editor-sidebar-inner {
        position: static;
        max-height: none;
    }
}



/* ── Print Styles ── */
@media print {
    .topbar,
    .sidebar,
    .page-view-sidebar,
    .page-actions,
    .breadcrumbs,
    .site-footer,
    #sidebarToggle {
        display: none !important;
    }

    body:has(.page-view-layout) {
        overflow: visible !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        max-width: none !important;
        height: auto !important;
        overflow: visible !important;
    }

    .page-view-layout {
        display: block !important;
    }

    .page-view-main {
        height: auto !important;
        overflow: visible !important;
    }

    .page-header h1 {
        font-size: 24pt;
        margin-bottom: 0.25rem;
    }

    .page-meta {
        font-size: 9pt;
        color: #666;
        margin-bottom: 1rem;
        border-bottom: 1px solid #ccc;
        padding-bottom: 0.5rem;
    }

    .page-body {
        font-size: 11pt;
        line-height: 1.6;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    .page-body h2 {
        font-size: 16pt;
        margin-top: 1.5rem;
        page-break-after: avoid;
    }

    .page-body h3 {
        font-size: 13pt;
        page-break-after: avoid;
    }

    .page-body table {
        border-collapse: collapse;
        width: 100%;
    }

    .page-body table th,
    .page-body table td {
        border: 1px solid #999;
        padding: 4pt 8pt;
        font-size: 10pt;
    }

    .page-body pre {
        border: 1px solid #ccc;
        padding: 8pt;
        font-size: 9pt;
        white-space: pre-wrap;
        word-break: break-word;
        page-break-inside: avoid;
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    .page-body img {
        max-width: 100%;
        page-break-inside: avoid;
    }

    h2,
    h3,
    h4 {
        page-break-after: avoid;
    }

    p,
    li {
        orphans: 3;
        widows: 3;
    }

    .page-body a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 9pt;
        color: #666;
        word-break: break-all;
    }

    .page-body a[href^="/"]::after {
        content: none;
    }
}

/* ── Category Actions Dropdown ── */
.category-actions-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    z-index: 200;
    overflow: hidden;
}
.category-actions-dropdown.open { display: block; }
.dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0.25rem 0;
}