/* ============================================================
   CoreHelp – primary stylesheet
   Primary colour: hsl(111, 45%, 46%)  (Coretime "apple" green)
   ============================================================ */

:root {
    /* App shell: width of the left nav rail beside `.main-content` (see `.admin-nav`). */
    --app-nav-rail-width: 200px;
    --clr-primary: hsl(111, 45%, 46%);
    --clr-primary-hover: hsl(111, 50%, 38%);
    --clr-primary-light: hsl(111, 45%, 95%);
    --clr-primary-mid: hsl(111, 30%, 60%);
    --clr-text: #1a1a1a;
    --clr-text-muted: #6c757d;
    --clr-border: #dee2e6;
    --clr-bg: #f8f9fa;
    --clr-surface: #ffffff;
    --clr-danger: #dc3545;
    --clr-warning: #ffc107;
    --clr-success: hsl(111, 45%, 46%);
    --sidebar-width: 280px;
    --header-height: 56px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --radius: 4px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow: 0 2px 8px rgba(0,0,0,.12);
}

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

/* Skip link for keyboard/screen reader */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    padding: .5rem 1rem;
    background: var(--clr-primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus {
    left: 0;
    outline: 2px solid var(--clr-primary);
    outline-offset: 2px;
}

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 15px;
    color: var(--clr-text);
    background: var(--clr-bg);
    line-height: 1.6;
}

a { color: var(--clr-primary); text-decoration: none; }
a:hover { color: var(--clr-primary-hover); text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────────── */

.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    height: var(--header-height);
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.app-header .logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--clr-primary);
    white-space: nowrap;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.app-header .logo svg { flex-shrink: 0; }

.header-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: .45rem 1rem .45rem 2.4rem;
    border: 1px solid var(--clr-border);
    border-radius: 20px;
    font-size: .9rem;
    background: var(--clr-bg);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.header-search input:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px hsl(111 45% 46% / .15);
}

.header-search .search-icon {
    position: absolute;
    left: .75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--clr-text-muted);
    pointer-events: none;
}

.header-search {
    position: relative;
}

.header-search-suggestions {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + .35rem);
    max-height: 320px;
    overflow-y: auto;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 200;
    list-style: none;
    margin: 0;
    padding: .35rem 0;
}

.header-search-suggestions:not([hidden]) {
    display: block;
}

.header-search-suggestion-item {
    display: block;
    padding: .5rem 1rem;
    font-size: .875rem;
    color: var(--clr-text);
    text-decoration: none;
    text-align: left;
    border: none;
    width: 100%;
    cursor: pointer;
    background: none;
    line-height: 1.35;
}

.header-search-suggestion-item:hover,
.header-search-suggestion-item:focus {
    background: var(--clr-primary-light);
    color: var(--clr-primary);
    outline: none;
}

.header-search-suggestion-item strong {
    font-weight: 600;
}

.header-search-suggestion-excerpt {
    font-size: .8rem;
    color: var(--clr-text-muted);
    margin-top: .2rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-history {
    position: relative;
    flex-shrink: 0;
}

.header-history-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--clr-border);
    border-radius: 50%;
    background: var(--clr-bg);
    color: var(--clr-text);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.header-history-btn:hover {
    border-color: var(--clr-primary);
    background: var(--clr-primary-light);
}

.header-history-btn:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px hsl(111 45% 46% / .15);
}

.header-history-btn[aria-expanded="true"] {
    border-color: var(--clr-primary);
    background: var(--clr-primary-light);
}

.header-history-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + .35rem);
    min-width: 220px;
    max-width: 320px;
    max-height: 320px;
    overflow-y: auto;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 200;
    padding: .35rem 0;
}

.header-history-dropdown:not([hidden]) {
    display: block;
}

.header-history-list {
    display: flex;
    flex-direction: column;
}

.header-history-item {
    display: block;
    padding: .5rem 1rem;
    font-size: .875rem;
    color: var(--clr-text);
    text-decoration: none;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: none;
    width: 100%;
    cursor: pointer;
    background: none;
}

.header-history-item:hover,
.header-history-item:focus {
    background: var(--clr-primary-light);
    color: var(--clr-primary);
    outline: none;
}

.header-history-empty {
    margin: 0;
    padding: .75rem 1rem;
    font-size: .85rem;
    color: var(--clr-text-muted);
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--clr-surface);
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--clr-text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: .5rem 0;
}

/* ── Admin management nav (Dashboard | Documents | Settings) ────────────────── */

.admin-nav {
    width: var(--app-nav-rail-width);
    flex-shrink: 0;
    background: var(--clr-surface);
    border-right: 1px solid var(--clr-border);
    padding: .75rem 0;
    overflow-y: auto;
}

.admin-nav-header {
    padding: 0 1rem .5rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--clr-text-muted);
}

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

.admin-nav-link {
    display: block;
    padding: .4rem 1rem;
    font-size: .875rem;
    color: var(--clr-text);
    text-decoration: none;
    transition: background .1s;
}

.admin-nav-link:hover {
    background: var(--clr-bg);
}

.admin-nav-link.active {
    background: var(--clr-primary-light);
    color: var(--clr-primary);
    font-weight: 600;
}

.admin-nav-group {
    margin-top: .5rem;
}

.admin-nav-group-title {
    display: block;
    padding: .35rem 1rem;
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--clr-text-muted);
}

.admin-nav-sublist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.admin-nav-sublist .admin-nav-link {
    padding-left: 1.5rem;
    font-size: .82rem;
}

/* ── Version pill (viewer sidebar header) ────────────────── */

.ver-pill-wrap {
    position: relative;
    flex-shrink: 0;
}

.ver-pill {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .2rem .55rem .2rem .42rem;
    border-radius: 999px;
    font-size: .71rem;
    font-weight: 700;
    line-height: 1.4;
    font-family: inherit;
    cursor: pointer;
    user-select: none;
    border: 1.5px solid;
    background: none;
    transition: filter .15s;
    letter-spacing: .01em;
}

.ver-pill:hover  { filter: brightness(.88); }
.ver-pill:focus-visible { outline: 2px solid var(--clr-primary); outline-offset: 2px; }

.ver-pill--latest {
    background: hsl(145 55% 91%);
    border-color: hsl(145 40% 62%);
    color: hsl(145 50% 25%);
}

.ver-pill--past {
    background: hsl(38 80% 91%);
    border-color: hsl(38 60% 60%);
    color: hsl(32 75% 28%);
}

.ver-pill__icon  { flex-shrink: 0; }
.ver-pill__label { white-space: nowrap; }
.ver-pill__caret {
    flex-shrink: 0;
    opacity: .65;
    transition: transform .18s ease;
}
.ver-pill-wrap.open .ver-pill__caret { transform: rotate(180deg); }

.ver-dropdown {
    position: absolute;
    top: calc(100% + .4rem);
    right: 0;
    min-width: 148px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    box-shadow: 0 6px 22px rgba(0,0,0,.13);
    z-index: 300;
    overflow: hidden;
    padding: .3rem 0;
}

.ver-dropdown__item {
    display: flex;
    align-items: center;
    gap: .45rem;
    width: 100%;
    padding: .42rem .9rem;
    font-size: .8rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--clr-text);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background .1s;
}

.ver-dropdown__item:hover { background: var(--clr-border); }

.ver-dropdown__item--active {
    color: var(--clr-primary);
    font-weight: 700;
}

.ver-dropdown__hint {
    margin-left: auto;
    font-size: .7rem;
    opacity: .55;
    font-weight: 400;
}

/* ── Tree ─────────────────────────────────────────────────── */

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

.tree-item { position: relative; }

.tree-row {
    display: flex;
    align-items: center;
    gap: 0;
    padding: .3rem .5rem;
    cursor: pointer;
    border-radius: var(--radius);
    margin: 1px .25rem;
    user-select: none;
    position: relative;
}

.tree-row:hover { background: var(--clr-primary-light); }
.tree-row.active { background: var(--clr-primary-light); color: var(--clr-primary); font-weight: 500; }

.tree-toggle {
    width: 1.2rem;
    height: 1.2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--clr-text-muted);
    transition: transform .15s;
    cursor: pointer;
}

.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.leaf { pointer-events: none; color: transparent; cursor: default; }

.tree-icon {
    width: 1.1rem;
    height: 1.1rem;
    flex-shrink: 0;
    margin-right: .35rem;
    color: var(--clr-text-muted);
}

.tree-icon.folder { color: hsl(40, 80%, 50%); cursor: pointer; }
.tree-icon.document { color: var(--clr-primary-mid); }

.tree-label {
    flex: 1;
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: inherit;
    text-decoration: none;
}

/* Folder labels (span, not a) are clickable to toggle */
span.tree-label { cursor: pointer; }

.tree-actions {
    display: none;
    gap: .1rem;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.tree-row:hover .tree-actions,
.tree-row.active .tree-actions { display: flex; }

/* Viewer: site PDF — always visible on root row (not hover-only) */
.tree-viewer-pdf-wrap {
    display: flex;
    align-items: center;
    margin-left: auto;
    flex-shrink: 0;
}

.tree-viewer-pdf-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    text-decoration: none !important;
    color: var(--clr-primary-hover) !important;
    background: linear-gradient(180deg, hsl(111 48% 97%) 0%, hsl(111 40% 92%) 100%);
    border: 1px solid hsl(111 35% 72%);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    line-height: 1;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s, color 0.12s;
}

.tree-viewer-pdf-btn svg {
    flex-shrink: 0;
    width: 0.95rem;
    height: 0.95rem;
    color: var(--clr-primary);
}

.tree-viewer-pdf-btn:hover {
    background: linear-gradient(180deg, hsl(111 50% 94%) 0%, hsl(111 42% 88%) 100%);
    border-color: var(--clr-primary-mid);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    color: var(--clr-primary-hover) !important;
    text-decoration: none !important;
}

.tree-viewer-pdf-btn--unavailable {
    opacity: 0.55;
    cursor: help;
    pointer-events: auto;
}

.tree-viewer-pdf-label {
    position: relative;
    top: 0.5px;
}

.tree-action-btn {
    width: 1.4rem;
    height: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--clr-text-muted);
    padding: 0;
    transition: background .1s, color .1s;
}

.tree-action-btn:hover { background: rgba(0,0,0,.07); color: var(--clr-text); }
.tree-action-btn.danger:hover { background: hsl(0 70% 95%); color: var(--clr-danger); }

.tree-children { padding-left: 1.1rem; }

/* Admin tree: right-click context menu */
/* Move-node folder picker (admin modal) */
.move-folder-picker .tree-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
}
.move-folder-picker .move-parent-radio {
    flex-shrink: 0;
    margin: 0;
}
.move-folder-picker label.tree-label {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.tree-context-menu {
    position: fixed;
    z-index: 10050;
    min-width: 11rem;
    padding: .3rem 0;
    margin: 0;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    box-shadow: 0 6px 28px rgba(0, 0, 0, .14);
}

.tree-context-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: .45rem 1rem;
    font-size: .85rem;
    line-height: 1.3;
    cursor: pointer;
    color: var(--clr-text);
    font-family: inherit;
}

.tree-context-menu-item:hover {
    background: var(--clr-primary-light);
}

.tree-context-menu-item--danger:hover {
    background: hsl(0 70% 95%);
    color: var(--clr-danger);
}

.tree-draft-badge {
    font-size: .65rem;
    padding: .1rem .35rem;
    background: var(--clr-warning);
    color: #6b4800;
    border-radius: 10px;
    flex-shrink: 0;
    margin-right: .25rem;
}

/* ── Recycle bin rows ────────────────────────────────────── */

.recycle-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .65rem;
    border-bottom: 1px solid var(--clr-border);
    font-size: .875rem;
}

.recycle-row:last-child { border-bottom: none; }
.recycle-icon { flex-shrink: 0; }
.recycle-row > .recycle-title { flex: 1; min-width: 0; }
.recycle-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.recycle-info .recycle-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recycle-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recycle-meta { font-size: .75rem; color: var(--clr-text-muted); white-space: nowrap; }
.recycle-date { font-size: .75rem; color: var(--clr-text-muted); white-space: nowrap; flex-shrink: 0; }
.recycle-actions-wrap { position: relative; flex-shrink: 0; }
.recycle-actions-btn { white-space: nowrap; }
.recycle-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 2px;
    min-width: 10rem;
    background: var(--clr-bg, #fff);
    border: 1px solid var(--clr-border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    z-index: 10001;
    padding: .25rem 0;
}
.recycle-dropdown.open { display: block; }
.recycle-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: .4rem .75rem;
    border: none;
    background: none;
    font-size: .875rem;
    cursor: pointer;
    color: var(--clr-text);
}
.recycle-dropdown button:hover { background: var(--clr-bg-hover, #f0f0f0); }
.recycle-dropdown .recycle-dropdown-danger { color: var(--clr-danger); }
.recycle-dropdown .recycle-dropdown-danger:hover { background: rgba(220, 53, 69, .08); }

/* ── Main content ─────────────────────────────────────────── */

.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
    min-width: 0;
}

/**
 * Constrain and centre page content in the main pane (the area to the right of the app nav),
 * not the full viewport — so horizontal centre matches the content column after the sidebar.
 * Below 1440px viewport width the main column fills the pane (no max-width cap). From 1440px up,
 * width is capped at `--lic-main-content-max` (default 1440px) and centred with auto margins.
 *
 * Usage: <main class="main-content main-content--centered-max" id="main-content">
 */
.main-content.centered-max {
    --lic-main-content-max: 1440px;
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 1440px) {
    .main-content.centered-max {
        max-width: var(--lic-main-content-max);
    }
}

.main-content-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.main-content-layout .md-body {
    flex: 1;
    min-width: 0;
}

/* ── Shared Markdown Editor (Monaco + preview) ───────────── */

.editor-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.editor-pane {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.editor-pane + .editor-pane {
    border-left: 1px solid var(--clr-border);
}

.pane-header {
    padding: .4rem .75rem;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--clr-text-muted);
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-bg);
    flex-shrink: 0;
}

.markdown-editor-monaco {
    flex: 1;
    overflow: hidden;
}

.markdown-editor-monaco.monaco-drop-target {
    cursor: copy;
}

.preview-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}

.editor-md-toolbar {
    padding: .35rem .75rem;
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    gap: .25rem;
    flex-shrink: 0;
    background: var(--clr-bg);
}

.md-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .25rem .45rem;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
    font-size: .78rem;
    font-family: monospace;
    color: var(--clr-text);
    line-height: 1;
    transition: background .1s;
}

.md-toolbar-btn:hover {
    background: var(--clr-border);
    border-color: var(--clr-border);
}

.md-toolbar-sep {
    width: 1px;
    height: 1.2rem;
    background: var(--clr-border);
    margin: 0 .2rem;
}

/* ── Reusable Gallery (images / snippets) ─────────────────── */

.gallery-shell {
    padding: 1.5rem 2rem;
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.gallery-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gallery-card-thumb {
    aspect-ratio: 16/10;
    background: var(--clr-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .5rem;
}

.gallery-card-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gallery-card-thumb-snippet {
    aspect-ratio: 16/10;
    background: var(--clr-bg);
    padding: .5rem;
    overflow: hidden;
    font-size: .7rem;
    line-height: 1.3;
}

.gallery-card-thumb-snippet.md-body {
    max-height: 6rem;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.gallery-card-body {
    padding: .6rem .75rem;
    font-size: .82rem;
}

.gallery-card-name {
    font-weight: 600;
    word-break: break-all;
    margin-bottom: .25rem;
}

.gallery-card-meta {
    color: var(--clr-text-muted);
    font-size: .75rem;
    margin-bottom: .4rem;
}

.gallery-card-docs {
    margin-top: .4rem;
    border-top: 1px solid var(--clr-border);
    padding-top: .4rem;
}

.gallery-card-docs-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--clr-text-muted);
    margin-bottom: .25rem;
}

.gallery-card-docs-list {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.gallery-card-docs-list a {
    font-size: .78rem;
    color: var(--clr-primary);
    text-decoration: none;
}

.gallery-card-docs-list a:hover {
    text-decoration: underline;
}

.gallery-card-orphaned {
    border-color: hsl(38 50% 75%);
    background: hsl(38 40% 98%);
}

.gallery-card-orphaned .gallery-card-docs-title {
    color: hsl(38 45% 45%);
}

.gallery-card-wrap {
    position: relative;
}

.gallery-card-thumb-wrap {
    position: relative;
}

.gallery-card-actions {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.28);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    opacity: 0;
    transition: opacity .2s;
    border-radius: 8px;
}

.gallery-card-wrap:hover .gallery-card-actions,
.gallery-card-thumb-wrap:hover .gallery-card-actions {
    opacity: 1;
}

.gallery-card-actions .btn {
    font-size: .78rem;
}

.gallery-empty {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--clr-text-muted);
}

.gallery-upload-wrap {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.gallery-upload-wrap input[type="file"] {
    display: none;
}

/* ── Batch publish / Publishing page ──────────────────────── */

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

.publishing-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.publishing-main .batch-table-wrap {
    max-height: min(70vh, 520px);
    overflow-y: auto;
}

.publishing-panel {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    flex-shrink: 0;
    border-left: 1px solid var(--clr-border);
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.publishing-panel .batch-version-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.batch-version-options {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    font-size: .85rem;
}

.batch-version-option {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    cursor: pointer;
}

.batch-version-option input[type="radio"] {
    flex-shrink: 0;
    width: 1.125rem;
    height: 1.125rem;
    margin-top: .15em;
}

.batch-version-option .batch-version-option-content {
    flex: 1;
    min-width: 0;
}

.batch-version-option-content .form-control {
    vertical-align: middle;
}

.batch-confirm-summary {
    margin: 0 0 .75rem;
    line-height: 1.5;
    font-size: .9rem;
}

.modal-batch-confirm {
    max-width: 520px;
    width: 95vw;
    display: flex;
    flex-direction: column;
    max-height: min(82vh, 560px);
    min-height: 0;
}

.modal-batch-confirm .modal-body.modal-batch-confirm-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.batch-confirm-table-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--clr-border);
    border-radius: 4px;
}

.batch-confirm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}

.batch-confirm-table thead th {
    position: sticky;
    top: 0;
    background: var(--clr-surface);
    padding: .4rem .6rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--clr-border);
    white-space: nowrap;
}

.batch-confirm-table tbody td {
    padding: .35rem .6rem;
    border-bottom: 1px solid var(--clr-border);
}

.batch-confirm-table tbody tr:last-child td {
    border-bottom: none;
}

.modal-batch-confirm-footer {
    flex-shrink: 0;
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
}

/* Broken link fix form (used in Fix link dialog on Broken Links page) */
.broken-link-fix-panel-inner {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.broken-link-fix-label {
    font-size: .8rem;
    font-weight: 600;
    margin-top: .4rem;
}

.broken-link-fix-label:first-child {
    margin-top: 0;
}

.broken-link-fix-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--clr-border);
    border-radius: 4px;
    background: var(--clr-bg);
}

.broken-link-fix-prefix {
    padding: .35rem .5rem;
    font-size: .875rem;
    color: var(--clr-text-muted);
    flex-shrink: 0;
}

.broken-link-fix-input {
    border: none;
    background: transparent;
    flex: 1;
    min-width: 0;
    padding: .35rem .5rem;
    font-size: .875rem;
}

.broken-link-typeahead {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 4px;
    box-shadow: var(--shadow);
    z-index: 10;
}

.broken-link-typeahead li {
    padding: .4rem .65rem;
    font-size: .85rem;
    cursor: pointer;
}

.broken-link-typeahead li:hover {
    background: var(--clr-bg);
}

.broken-link-fix-check-wrap {
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .25rem;
    cursor: pointer;
}

.broken-link-fix-actions {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
}

.publishing-panel .batch-actions {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex-direction: column;
    align-items: stretch;
}

.publishing-panel #batch-status {
    margin-left: 0;
    margin-top: 0.25rem;
}

@media (max-width: 768px) {
    .publishing-layout {
        flex-direction: column;
    }
    .publishing-main .batch-table-wrap {
        max-height: 420px;
    }
    .publishing-panel {
        width: 100%;
        min-width: 0;
        max-width: none;
        border-left: none;
        border-top: 1px solid var(--clr-border);
        padding-left: 0;
        padding-top: 1rem;
    }
}

.batch-filters {
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

.batch-table-wrap {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--clr-border);
    border-radius: 4px;
}

.batch-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.batch-table thead th {
    position: sticky;
    top: 0;
    background: var(--clr-surface);
    padding: .45rem .65rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--clr-border);
}

.batch-table tbody td {
    padding: .4rem .65rem;
    border-bottom: 1px solid var(--clr-border);
}

.batch-table tbody tr:last-child td {
    border-bottom: none;
}

.batch-table tbody tr:hover {
    background: var(--clr-bg);
}

.batch-table input[type=checkbox] {
    cursor: pointer;
}

.batch-table tbody tr.batch-row-selected {
    background: var(--clr-primary-subtle, rgba(37, 99, 235, 0.08));
}

.batch-preview-modal .modal-body { min-height: 0; }
.batch-preview-content { max-width: 48rem; margin: 0 auto; line-height: 1.6; }
.batch-preview-content h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
.batch-preview-content h2 { font-size: 1.25rem; margin: 1rem 0 0.5rem; }
.batch-preview-content h3 { font-size: 1.1rem; margin: 0.75rem 0 0.4rem; }
.batch-preview-content p { margin: 0 0 0.75rem; }
.batch-preview-content ul, .batch-preview-content ol { margin: 0 0 0.75rem; padding-left: 1.5rem; }
.batch-preview-content pre, .batch-preview-content code { font-family: var(--font-mono, monospace); font-size: 0.9em; }
.batch-preview-content pre { background: var(--clr-bg); padding: 0.75rem; border-radius: 4px; overflow-x: auto; margin: 0 0 0.75rem; }

.batch-actions {
    display: flex;
    gap: .5rem;
    align-items: center;
    padding-top: .75rem;
    border-top: 1px solid var(--clr-border);
    margin-top: .75rem;
}

.batch-version-section {
    padding: .65rem 0 0;
    border-top: 1px solid var(--clr-border);
    margin-top: .5rem;
}

#batch-status {
    font-size: .82rem;
    color: var(--clr-text-muted);
    margin-left: auto;
}

/* ── On this page TOC ─────────────────────────────────────── */

.on-this-page {
    flex-shrink: 0;
    width: 200px;
    position: sticky;
    top: 1rem;
    padding: .75rem 0;
    border-left: 1px solid var(--clr-border);
    padding-left: 1.25rem;
}

.on-this-page-title {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--clr-text-muted);
    margin-bottom: .6rem;
}

.on-this-page-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: .85rem;
}

.on-this-page-item {
    margin: .25rem 0;
}

.on-this-page-item a {
    color: var(--clr-text-muted);
    text-decoration: none;
}

.on-this-page-item a:hover {
    color: var(--clr-primary);
}

.on-this-page-level-3 {
    padding-left: .75rem;
}

.on-this-page-level-4,
.on-this-page-level-5,
.on-this-page-level-6 {
    padding-left: 1.25rem;
}

.content-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--clr-border);
}

.content-header-title-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.content-header-title-row h1 {
    flex: 1;
    min-width: 0;
}

.doc-edit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border: 1px solid var(--clr-border);
    border-radius: 50%;
    background: var(--clr-bg);
    color: var(--clr-text);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.doc-edit-btn:hover {
    border-color: var(--clr-primary);
    background: var(--clr-primary-light);
    color: var(--clr-primary);
}

.doc-edit-btn:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px hsl(111 45% 46% / .15);
}

.content-header h1 { font-size: 1.75rem; font-weight: 700; }
.content-header .meta { font-size: .85rem; color: var(--clr-text-muted); margin-top: .25rem; }

/* Form pages: row 1 = title + primary actions; row 2 = intro/meta full width.
   Markup: .content-header-form-head > h1|h2, .lic-form-actions, p.meta (in that order). */
.content-header-form-head {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 1rem;
    row-gap: .5rem;
    align-items: center;
}

.content-header-form-head > h1,
.content-header-form-head > h2 {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
}

.content-header-form-head > h2 {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.25;
}

.content-header-form-head > .lic-form-actions {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: center;
}

.content-header-form-head > .meta {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 0;
    margin-bottom: 0;
    max-width: none;
    font-size: .85rem;
    color: var(--clr-text-muted);
}

@media (max-width: 36rem) {
    .content-header-form-head {
        grid-template-columns: 1fr;
    }

    .content-header-form-head > h1,
    .content-header-form-head > h2 {
        grid-column: 1;
        grid-row: 1;
    }

    .content-header-form-head > .lic-form-actions {
        grid-column: 1;
        grid-row: 2;
        justify-self: start;
    }

    .content-header-form-head > .meta {
        grid-column: 1;
        grid-row: 3;
    }
}

/* ── Markdown rendered output ─────────────────────────────── */

.md-body h1, .md-body h2, .md-body h3,
.md-body h4, .md-body h5, .md-body h6 {
    margin: 1.5em 0 .5em;
    line-height: 1.25;
    font-weight: 600;
}

.md-body h1 { font-size: 1.75rem; }
.md-body h2 { font-size: 1.4rem; border-bottom: 1px solid var(--clr-border); padding-bottom: .3rem; }
.md-body h3 { font-size: 1.15rem; }

.md-body p { margin: .75rem 0; }

.md-body ul, .md-body ol {
    margin: .75rem 0;
    padding-left: 1.75rem;
}

.md-body li { margin: .25rem 0; }

.md-body code {
    background: #f0f0f0;
    padding: .15em .4em;
    border-radius: 3px;
    font-size: .875em;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

.md-body pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1rem 0;
    font-size: .875rem;
}

.md-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.md-body blockquote {
    border-left: 3px solid var(--clr-primary-mid);
    padding: .5rem 1rem;
    background: var(--clr-primary-light);
    margin: 1rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.md-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    font-size: .9rem;
}

.md-body th, .md-body td {
    border: 1px solid var(--clr-border);
    padding: .5rem .75rem;
    text-align: left;
}

.md-body th { background: var(--clr-bg); font-weight: 600; }
.md-body tr:nth-child(even) td { background: var(--clr-bg); }

.md-body img { max-width: 100%; border-radius: var(--radius); }

.md-body a { color: var(--clr-primary); }

.md-body hr {
    border: none;
    border-top: 1px solid var(--clr-border);
    margin: 1.5rem 0;
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font);
}

.btn-primary { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); }
.btn-primary:hover { background: var(--clr-primary-hover); border-color: var(--clr-primary-hover); color: #fff; text-decoration: none; }

.btn-secondary { background: var(--clr-surface); color: var(--clr-text); border-color: var(--clr-border); }
.btn-secondary:hover { background: var(--clr-bg); text-decoration: none; }

.btn-danger { background: var(--clr-danger); color: #fff; border-color: var(--clr-danger); }
.btn-danger:hover { background: hsl(354 70% 45%); text-decoration: none; color: #fff; }

.btn-ghost { background: transparent; color: var(--clr-text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--clr-bg); color: var(--clr-text); text-decoration: none; }

.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

.btn:disabled,
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: auto;
}

/* ── Forms ─────────────────────────────────────────────────── */

.form-group { margin-bottom: 1.1rem; }

.form-label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: .35rem;
}

.form-control {
    width: 100%;
    padding: .5rem .75rem;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: var(--font);
    background: var(--clr-surface);
    color: var(--clr-text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px hsl(111 45% 46% / .15);
}

.form-control.is-invalid { border-color: var(--clr-danger); }
.field-validation-error { font-size: .8rem; color: var(--clr-danger); margin-top: .25rem; display: block; }

select.form-control { appearance: auto; }

/* ── Alerts ─────────────────────────────────────────────────── */

.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .9rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert-danger { background: hsl(0 70% 96%); border-color: hsl(0 60% 85%); color: hsl(0 60% 35%); }
.alert-success { background: var(--clr-primary-light); border-color: hsl(111 40% 75%); color: hsl(111 45% 30%); }
.alert-info { background: hsl(210 60% 96%); border-color: hsl(210 50% 80%); color: hsl(210 50% 35%); }
.alert-warning { background: hsl(45 90% 94%); border-color: hsl(45 70% 75%); color: hsl(30 55% 28%); }

/* Snippet editor: main + referencing-docs sidebar */
.snippet-edit-layout {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    flex-wrap: wrap;
}
.snippet-edit-main {
    flex: 1;
    min-width: min(100%, 280px);
}
.snippet-ref-sidebar {
    width: 280px;
    max-width: 100%;
    flex-shrink: 0;
    position: sticky;
    top: 1rem;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    background: var(--clr-surface);
    padding: 1rem;
    max-height: calc(100vh - 6rem);
    overflow: auto;
}
.snippet-ref-sidebar h2 {
    font-size: 0.95rem;
    margin: 0 0 0.75rem 0;
    font-weight: 600;
}
.snippet-ref-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.snippet-ref-list li {
    margin-bottom: 0.85rem;
}
.snippet-ref-list li:last-child {
    margin-bottom: 0;
}
.snippet-ref-list a {
    font-weight: 500;
    text-decoration: none;
}
.snippet-ref-list a:hover {
    text-decoration: underline;
}
.snippet-ref-meta {
    font-size: 0.78rem;
    color: var(--clr-text-muted);
    margin-top: 0.15rem;
}
.snippet-ref-sidebar .alert {
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}
.snippet-ref-sidebar--muted {
    color: var(--clr-text-muted);
    font-size: 0.88rem;
}
.snippet-ref-sidebar--muted p {
    margin: 0;
}

/* ── Badge ─────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .55rem;
    border-radius: 10px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-success { background: hsl(111 45% 88%); color: hsl(111 45% 28%); }
.badge-warning { background: hsl(45 90% 88%); color: hsl(40 80% 30%); }
.badge-muted { background: var(--clr-bg); color: var(--clr-text-muted); border: 1px solid var(--clr-border); }

/* ── Login page ──────────────────────────────────────────── */

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--clr-bg);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: 8px;
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-logo .brand {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--clr-primary);
}

.login-logo .sub {
    font-size: .82rem;
    color: var(--clr-text-muted);
    margin-top: .15rem;
}

/* ── Modal ─────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
    background: var(--clr-surface);
    border-radius: 8px;
    width: 100%;
    max-width: 440px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transform: translateY(-12px);
    transition: transform .15s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.modal-title { font-size: 1.05rem; font-weight: 600; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--clr-border);
}

/* Markdown table designer (admin editor toolbar) */
.md-table-designer-modal {
    max-width: 720px;
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.md-table-designer-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}

.md-table-designer-cols {
    margin-bottom: 0;
}

.md-table-designer-cols .form-control {
    max-width: 6rem;
}

.md-table-designer-hint {
    margin: 0 !important;
}

.md-table-designer-header-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: .5rem;
}

.md-table-designer-cell {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.md-table-designer-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--clr-text-muted);
}

.md-table-designer-rows-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-top: .25rem;
}

.md-table-designer-rows-scroll {
    flex: 1;
    min-height: 120px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--clr-border);
    border-radius: 6px;
    padding: .5rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    background: var(--clr-bg);
}

.md-table-designer-row {
    display: flex;
    align-items: flex-start;
    gap: .35rem;
}

.md-table-designer-row-cells {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: .35rem;
}

.md-table-designer-row-actions {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: .1rem;
}

.md-table-designer-row-actions .btn {
    min-width: 2rem;
    padding: .15rem .25rem;
    line-height: 1.1;
}

.md-table-designer-kb {
    margin: 0 !important;
    font-size: .78rem !important;
}

.md-table-designer-kb kbd {
    display: inline-block;
    padding: .08rem .35rem;
    font-size: .72rem;
    font-family: inherit;
    border: 1px solid var(--clr-border);
    border-radius: 3px;
    background: var(--clr-surface);
    box-shadow: 0 1px 0 var(--clr-border);
}

/* Diff modal — almost full page, Monaco diff editor */
.diff-modal-overlay {
    align-items: stretch;
    padding: 1.5rem;
}

.diff-modal-overlay .diff-modal {
    max-width: none;
    width: 100%;
    height: 100%;
    min-height: 70vh;
    max-height: calc(100vh - 3rem);
    display: flex;
    flex-direction: column;
    padding: 0;
    transform: none;
}

.diff-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--clr-border);
    flex-shrink: 0;
}

.diff-modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.diff-editor-container {
    flex: 1;
    min-height: 400px;
}

.app-dialog .app-dialog-message { margin: 0 0 .75rem; white-space: pre-wrap; }
.app-dialog-input-wrap { margin-top: .75rem; }
.app-dialog-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .25rem; }
.app-dialog-footer { flex-wrap: wrap; }

/* ── Admin toolbar ──────────────────────────────────────── */

.admin-bar {
    background: hsl(111 20% 22%);
    color: hsl(111 10% 85%);
    font-size: .8rem;
    padding: .35rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.admin-bar a { color: hsl(111 30% 75%); }
.admin-bar a:hover { color: #fff; text-decoration: none; }
.admin-bar .admin-label { font-weight: 600; color: var(--clr-primary); }

/* ── Search results page ────────────────────────────────── */

.search-result {
    padding: 1rem 0;
    border-bottom: 1px solid var(--clr-border);
}

.search-result:last-child { border-bottom: none; }
.search-result h3 { font-size: 1rem; margin-bottom: .25rem; }
.search-result .excerpt { font-size: .875rem; color: var(--clr-text-muted); }
.search-result .path { font-size: .78rem; color: var(--clr-primary); margin-top: .2rem; }
.search-result .version-badge {
    display: inline-block;
    margin-left: .4rem;
    padding: .05rem .35rem;
    font-size: .7rem;
    font-weight: 600;
    border-radius: 3px;
    background: var(--clr-primary);
    color: #fff;
    vertical-align: middle;
}

/* ── Markdown tab panels (Markdig tab blocks; see md-help-tabs.js) ──
   Adapted from stencil tab styles; class names use no "ai-" prefix. */

.md-help-tabs {
    margin: 1rem 0;
}

.md-help-tabs .tab-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid var(--clr-border);
    margin-bottom: 0;
}

.md-help-tabs .tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--clr-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.15s, border-color 0.15s;
}

.md-help-tabs .tab-btn:hover {
    color: var(--clr-text);
}

.md-help-tabs .tab-btn.active {
    color: var(--clr-primary);
    border-bottom-color: var(--clr-primary);
}

.md-help-tabs .tab-beta-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: color-mix(in srgb, var(--clr-primary) 15%, transparent);
    color: var(--clr-primary);
    padding: 0.1em 0.45em;
    border-radius: 4px;
}

.md-help-tabs .tab-panel {
    display: none;
    padding-top: 0.75rem;
    min-height: 0;
    border-bottom: 1px solid var(--clr-border);
    padding-bottom: 1rem;
}

.md-help-tabs .tab-panel.active {
    display: block;
}

/* ── Print ─────────────────────────────────────────────── */

@media print {
    .app-header,
    .sidebar,
    .admin-bar,
    .on-this-page,
    .btn,
    .header-search,
    .header-actions,
    .ver-pill-wrap,
    .modal-overlay {
        display: none !important;
    }

    .app-shell,
    .app-body,
    .main-content {
        overflow: visible !important;
        height: auto !important;
    }

    .main-content {
        padding: 0;
        max-width: none;
    }

    .main-content-layout {
        display: block;
    }

    body {
        background: #fff;
        color: #1a1a1a;
    }

    .content-header {
        border-bottom-color: #ccc;
    }

    .md-body a {
        color: #1a1a1a;
    }

    .md-body a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #666;
    }

    /* Tab blocks: linear print layout — tab strip hidden; every panel shown with title as heading (see data-tab-label on .tab-panel). */
    .md-help-tabs .tab-nav {
        display: none !important;
    }

    .md-help-tabs .tab-panel {
        display: block !important;
        break-inside: avoid;
        page-break-inside: avoid;
        margin-top: 1.25rem;
        padding-top: 0;
        padding-bottom: 1rem;
        border-bottom: 1px solid #ccc;
    }

    .md-help-tabs .tab-panel:first-of-type {
        margin-top: 0;
    }

    .md-help-tabs .tab-panel:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .md-help-tabs .tab-panel::before {
        content: attr(data-tab-label);
        display: block;
        font-size: 1.35rem;
        font-weight: 600;
        line-height: 1.25;
        margin-bottom: 0.65rem;
        color: #1a1a1a;
    }
}

/* ── Utilities ─────────────────────────────────────────── */

.text-muted { color: var(--clr-text-muted); }
.text-sm { font-size: .875rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.form-check-label {
    cursor: pointer;
    font-size: .92rem;
    margin: 0;
}
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.ms-auto { margin-left: auto; }
.w-100 { width: 100%; }

/* ── Coretime Licensing (customers & forms) ─────────────── */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.lic-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: space-between;
    margin-top: 1.25rem;
}

.lic-search-form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    flex: 1;
    min-width: min(100%, 18rem);
    max-width: 28rem;
}

.lic-search-form .form-control {
    flex: 1;
    min-width: 10rem;
}

.lic-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    background: var(--clr-surface);
}

.lic-table-scroll-x .lic-data-table {
    min-width: 72rem;
}

.lic-data-table-compact thead th,
.lic-data-table-compact tbody td {
    padding: .45rem .5rem;
    font-size: .78rem;
}

.lic-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.lic-data-table thead th {
    text-align: left;
    padding: .65rem .85rem;
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--clr-text-muted);
    border-bottom: 1px solid var(--clr-border);
    background: var(--clr-bg);
}

.lic-data-table tbody td {
    padding: .6rem .85rem;
    border-bottom: 1px solid var(--clr-border);
    vertical-align: middle;
}

.lic-data-table tbody tr:last-child td {
    border-bottom: none;
}

.lic-data-table tbody tr:hover td {
    background: var(--clr-bg-hover, rgba(0, 0, 0, .03));
}

.lic-table-empty {
    text-align: center;
    color: var(--clr-text-muted);
    padding: 2rem 1rem !important;
}

.lic-col-actions {
    width: 1%;
    white-space: nowrap;
}

.lic-row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .25rem;
}

.lic-inline-form {
    display: inline;
    margin: 0;
}

.lic-inline-form button {
    margin: 0;
}

.lic-form-page {
    margin-top: 1.5rem;
}

.lic-readonly-summary {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem 1.5rem;
    margin: 1rem 0 1.5rem;
    font-size: .92rem;
    line-height: 1.4;
}

.lic-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem 1.5rem;
    margin-top: .5rem;
}

/* Issue licence — fixed 3-column layout; explicit placement so hiding Lite-only fields (display:none) leaves gaps, not reflow */
.lic-licence-fields-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem 1.5rem;
    margin-top: .5rem;
    align-items: stretch;
}

.lic-licence-fields-grid > .form-group {
    margin-bottom: 0;
}

/* Row 1: two-column grid so description hint does not push licence type input down */
.lic-lf-row--top {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    gap: .35rem 1.5rem;
    align-items: start;
    margin: 0;
}

.lic-lf-top-label--desc {
    grid-column: 1;
    grid-row: 1;
}

.lic-lf-top-label--type {
    grid-column: 2;
    grid-row: 1;
}

.lic-lf-top-input-desc {
    grid-column: 1;
    grid-row: 2;
}

.lic-lf-top-select {
    grid-column: 2;
    grid-row: 2;
}

.lic-lf-top-desc-foot {
    grid-column: 1;
    grid-row: 3;
    min-width: 0;
}

.lic-lf-top-desc-foot .form-hint {
    margin: 0 0 .15rem;
}

.lic-licence-fields-grid .lic-lf-top-label {
    flex: 0 0 auto;
    min-height: 2.625rem;
    display: flex;
    align-items: center;
    margin: 0;
    font-size: .875rem;
    font-weight: 500;
}

/* Uniform label band + control height so MAC / expiry / users (and similar rows) line up */
.lic-licence-fields-grid .lic-lf-mac,
.lic-licence-fields-grid .lic-lf-expiry,
.lic-licence-fields-grid .lic-lf-licenced-users,
.lic-licence-fields-grid .lic-lf-version,
.lic-licence-fields-grid .lic-lf-super,
.lic-licence-fields-grid .lic-lf-standard {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.lic-licence-fields-grid .lic-lf-mac > .form-label,
.lic-licence-fields-grid .lic-lf-licenced-users > .form-label,
.lic-licence-fields-grid .lic-lf-version > .form-label,
.lic-licence-fields-grid .lic-lf-super > .form-label,
.lic-licence-fields-grid .lic-lf-standard > .form-label {
    flex: 0 0 auto;
    min-height: 2.625rem;
    display: flex;
    align-items: center;
    margin-bottom: .35rem;
}

.lic-licence-fields-grid .lic-lf-expiry .lic-lf-label-row {
    flex: 0 0 auto;
    min-height: 2.625rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .35rem .5rem;
    margin-bottom: .35rem;
}

.lic-licence-fields-grid .lic-lf-expiry .lic-lf-label-text {
    margin-bottom: 0;
    font-size: .875rem;
    font-weight: 500;
}

.lic-licence-fields-grid .lic-lf-expiry-add-year {
    flex-shrink: 0;
    margin: 0;
    padding: .2rem .45rem;
    font-size: .78rem;
    line-height: 1.2;
}

/* Match text, number, select, and date controls (calendar control can otherwise change height) */
.lic-licence-fields-grid .form-control {
    box-sizing: border-box;
    min-height: 2.5rem;
    line-height: 1.35;
}

.lic-licence-fields-grid input[type="date"].form-control {
    padding-top: .45rem;
    padding-bottom: .45rem;
}

.lic-licence-fields-grid input[type="date"].form-control::-webkit-calendar-picker-indicator {
    margin: 0;
    padding: 0 .15rem;
    cursor: pointer;
    opacity: 0.9;
}

.lic-licence-fields-grid .lic-lf-mac {
    grid-row: 2;
    grid-column: 1;
}

.lic-licence-fields-grid .lic-lf-expiry {
    grid-row: 2;
    grid-column: 2;
}

.lic-licence-fields-grid .lic-lf-licenced-users {
    grid-row: 2;
    grid-column: 3;
}

.lic-licence-fields-grid .lic-lf-version {
    grid-row: 3;
    grid-column: 1;
}

.lic-licence-fields-grid .lic-lf-spacer-mid {
    grid-row: 3;
    grid-column: 2;
    min-height: 0;
    align-self: stretch;
}

.lic-licence-fields-grid .lic-lf-super {
    grid-row: 3;
    grid-column: 3;
}

.lic-licence-fields-grid .lic-lf-spacer-bottom {
    grid-row: 4;
    grid-column: 1 / span 2;
    min-height: 0;
}

.lic-licence-fields-grid .lic-lf-standard {
    grid-row: 4;
    grid-column: 3;
}

@media (max-width: 720px) {
    .lic-licence-fields-grid {
        grid-template-columns: 1fr;
    }

    .lic-lf-row--top {
        display: flex;
        flex-direction: column;
        gap: .35rem;
    }

    .lic-lf-top-label--desc,
    .lic-lf-top-input-desc,
    .lic-lf-top-desc-foot,
    .lic-lf-top-label--type,
    .lic-lf-top-select {
        grid-column: unset;
        grid-row: unset;
    }

    .lic-lf-top-label--desc {
        order: 1;
    }

    .lic-lf-top-input-desc {
        order: 2;
    }

    .lic-lf-top-desc-foot {
        order: 3;
    }

    .lic-lf-top-label--type {
        order: 4;
    }

    .lic-lf-top-select {
        order: 5;
    }

    .lic-licence-fields-grid .lic-lf-mac,
    .lic-licence-fields-grid .lic-lf-expiry,
    .lic-licence-fields-grid .lic-lf-licenced-users,
    .lic-licence-fields-grid .lic-lf-version,
    .lic-licence-fields-grid .lic-lf-super,
    .lic-licence-fields-grid .lic-lf-standard {
        grid-row: auto;
        grid-column: 1 / -1;
    }

    .lic-licence-fields-grid .lic-lf-spacer-mid,
    .lic-licence-fields-grid .lic-lf-spacer-bottom {
        display: none;
    }
}

.lic-form-checkbox {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
    padding-top: 1.75rem;
}

.lic-form-checkbox .form-check-input {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    cursor: pointer;
}

.lic-form-checkbox .form-check-label {
    font-weight: 600;
    cursor: pointer;
}

.form-hint {
    font-size: .78rem;
    color: var(--clr-text-muted);
    margin: .25rem 0 0;
    line-height: 1.35;
}

.lic-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.text-danger { color: var(--clr-danger); }

/* ── Licence issue / view ───────────────────────────────── */

.lic-section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 1.5rem 0 .75rem;
    padding-bottom: .35rem;
    border-bottom: 1px solid var(--clr-border);
}

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

/* Customer merge (pair) */
.lic-merge-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
    margin-top: .5rem;
}

@media (max-width: 52rem) {
    .lic-merge-panels {
        grid-template-columns: 1fr;
    }
}

.lic-merge-panel-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 .35rem;
    line-height: 1.25;
}

.lic-merge-panel-hint {
    margin: 0 0 .75rem;
}

.lic-merge-card {
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    background: var(--clr-bg);
}

.lic-merge-dl {
    margin: 0;
    display: grid;
    gap: .65rem 1rem;
    font-size: .92rem;
}

.lic-merge-dl > div {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: .5rem;
    align-items: baseline;
}

.lic-merge-dl dt {
    margin: 0;
    font-weight: 600;
    color: var(--clr-text-muted);
}

.lic-merge-dl dd {
    margin: 0;
    word-break: break-word;
}

.lic-merge-search-form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-bottom: .75rem;
}

.lic-merge-search-form .form-control {
    flex: 1;
    min-width: 12rem;
}

.lic-merge-search-results {
    list-style: none;
    padding: 0;
    margin: .25rem 0 0;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    max-height: 16rem;
    overflow-y: auto;
}

.lic-merge-search-results li {
    border-bottom: 1px solid var(--clr-border);
}

.lic-merge-search-results li:last-child {
    border-bottom: 0;
}

.lic-merge-search-hit {
    display: block;
    padding: .5rem .75rem;
    color: var(--clr-text);
    text-decoration: none;
}

.lic-merge-search-hit:hover {
    background: var(--clr-primary-light);
    color: var(--clr-primary);
}

.lic-merge-radio-row {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    margin-top: .5rem;
}

.lic-merge-radio {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    cursor: pointer;
    font-size: .95rem;
}

.lic-merge-radio input {
    margin-top: .2rem;
    flex-shrink: 0;
}

/* Full-width dividers: same weight as .lic-section-title border-bottom */
.main-content hr {
    border: 0;
    clear: both;
    height: 1px;
    margin: 1.25rem 0;
    padding: 0;
    background-color: var(--clr-border);
}

.lic-licence-layout {
    display: grid;
    grid-template-columns: 1fr minmax(220px, 280px);
    gap: 2rem;
    align-items: start;
    margin-top: .5rem;
}

@media (max-width: 900px) {
    .lic-licence-layout {
        grid-template-columns: 1fr;
    }
}

.lic-licence-side {
    padding: 1rem;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    background: var(--clr-bg);
}

.lic-ent-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.lic-ent-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
    cursor: pointer;
}

.lic-ent-readonly {
    margin: 0;
    padding-left: 1.1rem;
    font-size: .875rem;
    line-height: 1.6;
    color: var(--clr-text-muted);
}

.lic-customer-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

.lic-customer-row .form-control {
    flex: 1;
    min-width: 12rem;
}

.lic-hidden-when-standard {
    display: none !important;
}

.lic-dialog {
    border: none;
    padding: 0;
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
    max-width: min(100vw - 2rem, 420px);
}

.lic-dialog::backdrop {
    background: rgba(0, 0, 0, .45);
}

.lic-dialog-panel {
    padding: 1.5rem;
    background: var(--clr-surface);
}

.lic-dialog-title {
    margin: 0 0 .5rem;
    font-size: 1.15rem;
}

.lic-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: 1.25rem;
    justify-content: flex-end;
}

.lic-licence-string-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: flex-start;
}

.lic-licence-string {
    flex: 1;
    min-width: 0;
    word-break: break-all;
    font-size: .75rem;
    padding: .5rem .65rem;
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: calc(var(--radius) - 2px);
}

.btn.disabled {
    pointer-events: none;
    opacity: .55;
}
