/*
 * Visual system for the new wiki.
 *
 * The stylesheet borrows the main site's design DNA instead of copying its
 * full application CSS: soft neutral background, deep indigo brand color,
 * warm gold interactive accents, card surfaces and concise typography.
 */

:root {
    color-scheme: light;
    --neutral-primary: #f4f6fa;
    --neutral-secondary: #e1e4eb;
    --neutral-light: #ffffff;
    --neutral-tint: #eef1f7;
    --text-primary: #2c2e61;
    --text-secondary: #6c757d;
    --text-muted: #98a2b3;
    --border-light: #e5e5e5;
    --border-medium: #e3e5e9;
    --brand-primary: #2c2e61;
    --brand-primary-light: #4a4d9b;
    --brand-primary-dark: #1c1e40;
    --interactive-bg: #d6b56c;
    --interactive-hover: #c7a450;
    --accent-primary: #e2954b;
    --accent-primary-strong: #c97a31;
    --surface-raised: #ffffff;
    --surface-sunken: #f7f8fb;
    --surface-tint: rgba(44, 46, 97, 0.06);
    --topbar-surface: rgba(255, 255, 255, 0.94);
    --topbar-border: rgba(44, 46, 97, 0.1);
    --logo-frame-surface: var(--topbar-surface);
    --logo-frame-border: transparent;
    --search-surface: var(--neutral-primary);
    --search-inset-shadow: none;
    --nav-hover-surface: transparent;
    --nav-active-surface: transparent;
    --nav-active-shadow: inset 0 -2px 0 var(--interactive-bg);
    --nav-active-text: var(--text-primary);
    --soft-brand-surface: rgba(44, 46, 97, 0.05);
    --soft-brand-surface-strong: rgba(44, 46, 97, 0.08);
    --soft-brand-border: rgba(44, 46, 97, 0.14);
    --soft-brand-border-strong: rgba(44, 46, 97, 0.22);
    --content-code-bg: #f7f9fc;
    --content-code-border: #e3e8ef;
    --content-inline-code-bg: rgba(45, 77, 159, 0.06);
    --content-inline-code-text: #243b79;
    --content-table-head-bg: #f3f5f8;
    --content-table-row-alt: #fafbfd;
    --content-callout-bg: #f8f9fa;
    --content-warning-bg: rgba(195, 179, 154, 0.12);
    --content-warning-border: rgba(159, 140, 106, 0.26);
    --content-blockquote-border: rgba(45, 77, 159, 0.2);
    --preview-body-surface: var(--surface-sunken);
    --editor-table-head-bg: #f3f5f8;
    --editor-table-row-alt: #fafbfd;
    --editor-table-hover-bg: rgba(45, 77, 159, 0.035);
    --transfer-preview-surface: rgba(255, 255, 255, 0.72);
    --transfer-preview-border: var(--border-light);
    --back-to-top-bg: var(--interactive-bg);
    --back-to-top-text: var(--interactive-text-on-accent);
    --back-to-top-shadow: 0 8px 16px rgba(32, 33, 34, 0.1);
    --logo-wordmark-color: var(--brand-primary);
    --logo-tagline-color: var(--text-secondary);
    --logo-suffix-color: var(--text-secondary);
    --focus-ring-outline: hsla(41, 56%, 63%, 0.35);
    --focus-ring-border: hsla(41, 56%, 63%, 0.45);
    --focus-ring-shadow: 0 0 0 3px hsla(41, 56%, 63%, 0.35);
    --interactive-text-on-accent: var(--brand-primary-dark);
    --shadow-sm: 0 2px 4px rgba(44, 46, 97, 0.08);
    --shadow-md: 0 4px 12px rgba(44, 46, 97, 0.12);
    --shadow-lg: 0 8px 24px rgba(44, 46, 97, 0.15);
    --shadow-glow: 0 8px 18px rgba(214, 181, 108, 0.16);
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 999px;
    --content-width: 1400px;
    /* Modern browsers can now use a higher-quality WebP background while the
       existing PNG stays in place as a conservative fallback for older stacks. */
    --page-background-image: image-set(
        url('../../images/backgrounds/devwiki_light_tile_bg.webp') type('image/webp') 1x,
        url('../../images/backgrounds/devwiki_light_tile_bg.png') type('image/png') 1x
    );
    --page-background-overlay: linear-gradient(180deg, rgba(244, 246, 250, 0.14), rgba(244, 246, 250, 0.22));
    --page-background-size: 500px auto;
    --page-background-repeat: repeat;
    --page-background-position: left top;
    /* The artwork already lives on a fixed pseudo-layer below, so forcing the
       texture itself to stay `fixed` only increases repaint cost on first paint
       and during scroll without improving the visual result. */
    --page-background-attachment: scroll;
    --page-background-opacity: 0.56;
}

/* The dark tokens mirror the main MarketPawns application palette so the wiki
   feels like the same product family instead of a separate generic dark skin. */
[data-theme='dark'] {
    color-scheme: dark;
    --neutral-primary: #13151c;
    --neutral-secondary: #1b1e28;
    --neutral-light: #22252f;
    --neutral-tint: #1a1d26;
    --text-primary: #e8eaf0;
    --text-secondary: #a8afbd;
    --text-muted: #7a8194;
    --border-light: #2b2e3a;
    --border-medium: #353948;
    --brand-primary: #8c90e8;
    --brand-primary-light: #b1b4ef;
    --brand-primary-dark: #5d61c9;
    --interactive-bg: #d6b56c;
    --interactive-hover: #e0c079;
    --accent-primary: #f0a060;
    --accent-primary-strong: #e58a3d;
    --surface-raised: #22252f;
    --surface-sunken: #1b1e28;
    --surface-tint: rgba(140, 144, 232, 0.08);
    --topbar-surface: rgba(19, 27, 44, 0.94);
    --topbar-border: rgba(140, 144, 232, 0.18);
    /* The logo container intentionally reuses the exact topbar surface color
       so the dark square inside the asset visually melts into the header. */
    --logo-frame-surface: var(--topbar-surface);
    --logo-frame-border: transparent;
    --search-surface: var(--neutral-secondary);
    --search-inset-shadow: none;
    --nav-hover-surface: transparent;
    --nav-active-surface: transparent;
    --nav-active-shadow: inset 0 -2px 0 var(--interactive-bg);
    --nav-active-text: var(--text-primary);
    --soft-brand-surface: rgba(140, 144, 232, 0.12);
    --soft-brand-surface-strong: rgba(140, 144, 232, 0.18);
    --soft-brand-border: rgba(140, 144, 232, 0.24);
    --soft-brand-border-strong: rgba(140, 144, 232, 0.34);
    --content-code-bg: #1a1d26;
    --content-code-border: #353948;
    --content-inline-code-bg: rgba(140, 144, 232, 0.12);
    --content-inline-code-text: #d8dbff;
    --content-table-head-bg: #1b1e28;
    --content-table-row-alt: #1d2029;
    --content-callout-bg: #1a1d26;
    --content-warning-bg: rgba(214, 181, 108, 0.12);
    --content-warning-border: rgba(214, 181, 108, 0.28);
    --content-blockquote-border: rgba(140, 144, 232, 0.28);
    --preview-body-surface: #1a1d26;
    --editor-table-head-bg: #1b1e28;
    --editor-table-row-alt: #1d2029;
    --editor-table-hover-bg: rgba(140, 144, 232, 0.06);
    --transfer-preview-surface: rgba(34, 37, 47, 0.78);
    --transfer-preview-border: #353948;
    --back-to-top-bg: #d6b56c;
    --back-to-top-text: #1a1d26;
    --back-to-top-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
    --logo-wordmark-color: var(--text-primary);
    --logo-tagline-color: var(--text-secondary);
    --logo-suffix-color: rgba(255, 255, 255, 0.88);
    --focus-ring-outline: hsla(41, 56%, 63%, 0.45);
    --focus-ring-border: hsla(41, 56%, 63%, 0.55);
    --focus-ring-shadow: 0 0 0 3px hsla(41, 56%, 63%, 0.55);
    --interactive-text-on-accent: #1a1d26;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 8px 18px rgba(214, 181, 108, 0.18);
    /* Dark theme uses the same dual-source strategy so it can keep a crisper
       decorative texture without pulling the old heavy PNG in modern browsers. */
    --page-background-image: image-set(
        url('../../images/backgrounds/devwiki_dark_tile_bg.webp') type('image/webp') 1x,
        url('../../images/backgrounds/devwiki_dark_tile_bg.png') type('image/png') 1x
    );
    --page-background-overlay: linear-gradient(180deg, rgba(19, 21, 28, 0.1), rgba(19, 21, 28, 0.1));
    --page-background-size: 440px auto;
    --page-background-repeat: repeat;
    --page-background-position: left top;
    /* Matching the light theme here avoids the extra fixed-background cost on
       devices where scroll + paint for large textured layers is expensive. */
    --page-background-attachment: scroll;
    --page-background-opacity: 0.5;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    background-color: var(--neutral-primary);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    /* The artwork now lives on a dedicated page layer, so the texture stays
       visible across the viewport instead of being visually flattened by the
       body background paint underneath large content surfaces. */
    background-image: var(--page-background-overlay), var(--page-background-image);
    background-repeat: no-repeat, var(--page-background-repeat);
    background-position: center top, var(--page-background-position);
    background-size: auto, var(--page-background-size);
    background-attachment: scroll, var(--page-background-attachment);
    opacity: var(--page-background-opacity);
}

.kb-shell {
    position: relative;
    z-index: 1;
}

.kb-skip-link {
    position: absolute;
    top: -48px;
    left: 20px;
    z-index: 100;
    padding: 10px 14px;
    background: var(--surface-raised);
    color: var(--brand-primary-dark);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.kb-skip-link:focus {
    top: 16px;
}

.kb-page {
    text-rendering: optimizeLegibility;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
}

a:hover {
    color: var(--brand-primary-light);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--focus-ring-outline);
    outline-offset: 2px;
}

p,
li {
    font-size: 1.02rem;
    line-height: 1.7;
}

h1,
h2,
h3 {
    margin: 0 0 0.8rem;
    line-height: 1.16;
}

img {
    display: block;
    max-width: 100%;
}

.kb-shell {
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 24px 28px 56px;
}

/* The editor is a workspace rather than a reading layout, so it should use
   the available viewport width instead of inheriting the narrower docs shell. */
.kb-page--editor .kb-shell {
    max-width: none;
    width: 100%;
    margin: 0;
    padding-left: 18px;
    padding-right: 18px;
}

.kb-topbar {
    display: grid;
    grid-template-columns: minmax(380px, 1fr) minmax(0, 1.25fr);
    gap: 22px;
    align-items: center;
    padding: 17px 20px;
    margin-bottom: 24px;
    position: sticky;
    top: 12px;
    z-index: 40;
    background: var(--topbar-surface);
    border: 1px solid var(--topbar-border);
    border-radius: 18px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.kb-topbar__brand {
    min-width: 0;
    display: flex;
    align-items: center;
    /* A small inset keeps the mark from hugging the rounded left edge of the
       topbar while preserving the compact relationship between icon and text. */
    padding-left: 8px;
}

.kb-topbar__mobile-bar {
    display: none;
}

.kb-topbar__burger {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--surface-raised);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.94rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.kb-topbar__burger-lines {
    display: inline-grid;
    gap: 4px;
}

.kb-topbar__burger-lines span {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
}

.kb-topbar.is-open .kb-topbar__burger-lines span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.kb-topbar.is-open .kb-topbar__burger-lines span:nth-child(2) {
    opacity: 0;
}

.kb-topbar.is-open .kb-topbar__burger-lines span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.kb-topbar__burger-lines span {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.kb-topbar__burger:hover,
.kb-topbar__burger:focus-visible {
    color: var(--accent-primary);
    outline: none;
}

.kb-logo-link {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 112px;
    padding: 0;
    border-radius: 18px;
    transition: transform 0.2s ease;
}

.kb-logo-link:hover {
    transform: translateY(-1px);
}

.kb-logo-frame {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 110px;
    height: 110px;
    flex: 0 0 110px;
    padding: 8px;
    background: var(--logo-frame-surface);
    border: 1px solid var(--logo-frame-border);
    border-radius: 18px;
    position: relative;
    overflow: hidden;
}

.kb-logo {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    transform: none;
}

.kb-logo--dark {
    display: none;
}

[data-theme='dark'] .kb-logo--light {
    display: none;
}

[data-theme='dark'] .kb-logo--dark {
    display: block;
}

.kb-brand-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
}

.kb-logo-link strong,
.kb-footer strong {
    display: block;
    font-size: 1.76rem;
    line-height: 1;
    /* The new wiki-specific logo uses a deeper indigo body, so the adjacent
       product name is tinted toward the same darker family to keep the mark
       and wordmark visually tied together inside the light header shell. */
    color: var(--logo-wordmark-color);
}

/* The header uses a compact two-line product wordmark so the full brand stays
   readable without forcing the topbar to grow vertically. */
.kb-brand-wordmark--marketpawns {
    display: inline-grid;
    gap: 3px;
    align-items: start;
    line-height: 0.96;
    letter-spacing: 0.01em;
}

.kb-brand-wordmark__title,
.kb-brand-wordmark__suffix {
    display: block;
    color: inherit;
}

.kb-brand-wordmark--marketpawns .kb-brand-wordmark__title {
    font-size: 1em;
    font-weight: 800;
    text-transform: none;
}

.kb-brand-wordmark--marketpawns .kb-brand-wordmark__suffix {
    font-size: 0.64em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.kb-brand-wordmark--marketpawns .kb-brand-wordmark__suffix {
    color: var(--logo-suffix-color);
}

.kb-logo-link small {
    display: block;
    margin-top: 0;
    color: var(--logo-tagline-color);
    font-size: 0.95rem;
    line-height: 1.4;
    max-width: 34ch;
}

.kb-topbar__actions {
    display: grid;
    gap: 10px;
    justify-items: stretch;
    min-width: 0;
    align-self: center;
}

.kb-search-region,
.kb-home-search-region {
    display: block;
}

.kb-topbar__nav {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    padding: 0;
    flex-wrap: wrap;
    min-height: 38px;
}

.kb-topbar__nav a {
    position: relative;
    padding: 8px 12px 10px;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 600;
    transition: color 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.kb-topbar__nav a:hover {
    color: var(--accent-primary);
    transform: translateY(-1px);
}

.kb-topbar__nav a.is-active {
    color: var(--nav-active-text);
    box-shadow: var(--nav-active-shadow);
}

.kb-topbar__nav-form {
    margin: 0;
}

.kb-topbar__nav-button {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px 2px;
    border: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    white-space: nowrap;
}

.kb-topbar__nav-button:hover,
.kb-topbar__nav-button:focus-visible {
    color: var(--accent-primary);
    transform: translateY(-1px);
    outline: none;
}

/* The theme toggle stays visually close to the rest of the nav, but keeps a
   compact bordered control treatment so the mode switch remains easy to spot. */
.kb-theme-toggle {
    border: 1px solid var(--border-light);
    border-bottom-width: 1px;
    border-radius: 999px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);
}

.kb-topbar__status {
    display: inline-grid;
    gap: 2px;
    justify-items: end;
}

.kb-topbar__status strong {
    font-size: 0.92rem;
}

.kb-topbar__status span {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.kb-search {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}

.kb-search__input {
    min-width: 0;
    width: 100%;
    max-width: 520px;
    padding: 12px 15px;
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    background: var(--search-surface);
    color: var(--text-primary);
    box-shadow: var(--search-inset-shadow);
    font-size: 0.94rem;
}

.kb-search__input:focus {
    outline: none;
    border-color: var(--focus-ring-border);
    box-shadow: var(--focus-ring-shadow);
}

.kb-search__input::placeholder,
.kb-home-search__input::placeholder,
.kb-admin-input::placeholder,
.kb-create-article-form__textarea::placeholder,
.kb-inline-editor__textarea::placeholder,
.kb-inline-editor-help__search-input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.kb-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius-pill);
    font-weight: 700;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease, color 0.18s ease;
    cursor: pointer;
}

.kb-button--primary {
    background: var(--interactive-bg);
    color: var(--interactive-text-on-accent);
    box-shadow: none;
}

.kb-button--primary:hover {
    background: var(--interactive-hover);
    color: var(--interactive-text-on-accent);
    transform: translateY(-2px);
}

.kb-button--secondary {
    background: var(--neutral-tint);
    color: var(--brand-primary);
    border: 1px solid var(--border-light);
}

.kb-button--secondary:hover {
    background: var(--surface-raised);
    border-color: var(--soft-brand-border);
    transform: translateY(-1px);
}

.kb-layout {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.kb-sidebar {
    position: sticky;
    top: 110px;
    display: grid;
    gap: 16px;
}

.kb-panel,
.kb-article,
.kb-home-section-card,
.kb-meta-card,
.kb-footer,
.kb-hero {
    background: var(--neutral-light);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.kb-panel,
.kb-home-section-card,
.kb-footer {
    border-radius: var(--radius-lg);
    padding: 20px 20px 18px;
}

.kb-panel--wide {
    margin-top: 24px;
}

.kb-panel__eyebrow,
.kb-callout__eyebrow,
.kb-hero__eyebrow {
    margin: 0 0 10px;
    color: var(--accent-primary);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.kb-panel h2,
.kb-home-section-card h2,
.kb-footer h2 {
    font-size: 1rem;
}

.kb-section-list,
.kb-search-results,
.kb-home-links,
.kb-related-grid,
.kb-footer__catalog {
    display: grid;
    gap: 12px;
}

/* The sidebar needs quiet but explicit structure: stronger list rhythm and
   clearer link targets improve scanability without changing the overall style. */
.kb-section-item {
    padding: 16px;
    border-radius: 10px;
    background: var(--neutral-tint);
    border: 1px solid var(--border-light);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kb-section-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--soft-brand-border);
}

.kb-section-item.is-active {
    border-color: var(--soft-brand-border-strong);
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);
}

.kb-section-item h3 {
    margin-bottom: 8px;
    font-size: 0.98rem;
}

.kb-section-item p,
.kb-muted,
.kb-result-link span,
.kb-home-link span,
.kb-related-card span,
.kb-footer p {
    color: var(--text-secondary);
}

.kb-mini-link,
.kb-result-link,
.kb-home-link,
.kb-related-card,
.kb-footer__catalog a,
.kb-toc a {
    display: block;
}

.kb-mini-link,
.kb-footer__catalog a {
    margin-top: 6px;
    padding: 5px 0;
    font-size: 0.94rem;
    color: var(--brand-primary);
    border-radius: 6px;
}

.kb-mini-link.is-active {
    font-weight: 700;
    color: var(--brand-primary-dark);
}

.kb-result-link,
.kb-home-link,
.kb-related-card {
    padding: 15px 16px;
    border-radius: 10px;
    background: var(--neutral-tint);
    border: 1px solid var(--border-light);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kb-result-link:hover,
.kb-home-link:hover,
.kb-related-card:hover {
    transform: translateY(-1px);
    border-color: var(--soft-brand-border);
    box-shadow: var(--shadow-sm);
}

.kb-toc a {
    padding: 11px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.94rem;
}

.kb-toc a:hover {
    color: var(--brand-primary);
}

.kb-main {
    min-width: 0;
}

.kb-layout--editor {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
}

.kb-layout--auth {
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: start;
}

.kb-main--auth {
    grid-column: 1 / -1;
    max-width: 980px;
    width: 100%;
    margin: 0 auto;
}

.kb-sidebar--editor {
    top: 96px;
}

.kb-hero--auth {
    grid-template-columns: 1fr;
}

.kb-auth-status-list {
    display: grid;
    gap: 10px;
}

.kb-auth-status-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-light);
}

.kb-auth-status-item strong {
    font-size: 0.94rem;
}

.kb-auth-status-item span {
    color: var(--text-secondary);
    text-align: right;
}

.kb-auth-status-ok {
    color: #2f6f4f;
    font-weight: 700;
}

.kb-auth-status-error {
    color: #995252;
    font-weight: 700;
}

.kb-auth-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.kb-auth-checklist span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--neutral-tint);
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 600;
}

.kb-auth-alert {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--neutral-tint);
    line-height: 1.6;
}

.kb-auth-alert--success {
    color: #2f6f4f;
    background: rgba(88, 144, 108, 0.08);
    border-color: rgba(88, 144, 108, 0.22);
}

.kb-auth-alert--error {
    color: #995252;
    background: rgba(176, 84, 84, 0.08);
    border-color: rgba(176, 84, 84, 0.22);
}

.kb-auth-alert--warning {
    color: #7c5a1f;
    background: rgba(168, 121, 51, 0.08);
    border-color: rgba(168, 121, 51, 0.22);
}

.kb-auth-inline-link {
    color: var(--brand-primary);
    font-weight: 700;
    text-decoration: none;
}

.kb-auth-inline-link:hover {
    text-decoration: underline;
}

.kb-auth-form {
    display: grid;
    gap: 18px;
}

.kb-auth-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.kb-auth-field {
    display: grid;
    gap: 8px;
}

.kb-auth-field label {
    font-size: 0.92rem;
    font-weight: 700;
}

.kb-auth-field input {
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text-primary);
    font: inherit;
}

.kb-auth-field input:focus {
    outline: none;
    border-color: var(--focus-ring-border);
    box-shadow: var(--focus-ring-shadow);
}

.kb-auth-field small,
.kb-auth-footnote {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
}

.kb-auth-field-error {
    margin: 0;
    color: #995252;
    font-size: 0.88rem;
    line-height: 1.5;
}

.kb-auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
}

.kb-admin-form {
    display: grid;
    gap: 10px;
}

.kb-admin-form__row,
.kb-admin-form__stack {
    display: grid;
    gap: 10px;
}

.kb-admin-search-region {
    display: block;
    margin-bottom: 18px;
}

.kb-admin-toolbar,
.kb-admin-bulk-bar {
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--neutral-tint);
}

.kb-admin-toolbar__grid {
    display: grid;
    grid-template-columns: minmax(240px, 1.4fr) repeat(6, minmax(140px, 0.72fr)) auto;
    gap: 12px;
    align-items: end;
}

.kb-admin-toolbar__field {
    display: grid;
    gap: 8px;
}

.kb-admin-toolbar__field label {
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 700;
}

.kb-admin-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.kb-create-article-form {
    display: grid;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--neutral-tint);
}

.kb-create-article-form__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.kb-create-article-form__field {
    display: grid;
    gap: 8px;
}

.kb-create-article-form__field--wide {
    grid-column: 1 / -1;
}

.kb-create-article-form__field label {
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 700;
}

.kb-create-article-form__hint {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.kb-create-article-form__textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text-primary);
    font: inherit;
    resize: vertical;
}

.kb-create-article-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.kb-admin-toolbar__meta {
    margin: 10px 0 18px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.kb-admin-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.kb-admin-preset {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--surface-raised);
    color: var(--brand-primary);
    font-size: 0.88rem;
    font-weight: 700;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.kb-admin-preset:hover {
    background: var(--soft-brand-surface);
    border-color: var(--soft-brand-border);
    transform: translateY(-1px);
}

.kb-admin-preset.is-active {
    background: var(--soft-brand-surface-strong);
    border-color: var(--soft-brand-border-strong);
    color: var(--brand-primary-dark);
}

.kb-admin-pagination {
    display: flex;
    justify-content: center;
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.kb-admin-pagination__list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
    list-style: none;
    margin: 0;
    padding: 0;
}

.kb-admin-pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--brand-primary);
    font-size: 0.9rem;
    font-weight: 700;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.kb-admin-pagination__link:hover {
    background: var(--soft-brand-surface);
    border-color: var(--soft-brand-border);
    transform: translateY(-1px);
}

.kb-admin-pagination__link[aria-current="page"] {
    background: var(--soft-brand-surface-strong);
    border-color: var(--soft-brand-border-strong);
    color: var(--brand-primary-dark);
}

.kb-admin-pagination__link.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.kb-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;
}

.kb-admin-input,
.kb-admin-select,
.kb-create-article-form__textarea {
    min-height: 40px;
    width: 100%;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text-primary);
    font: inherit;
}

.kb-admin-input,
.kb-admin-select {
    padding: 0 12px;
}

.kb-admin-input:focus,
.kb-admin-select:focus,
.kb-create-article-form__textarea:focus {
    outline: none;
    border-color: var(--focus-ring-border);
    box-shadow: var(--focus-ring-shadow);
}

.kb-admin-bulk-bar {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.kb-admin-bulk-bar__summary {
    display: grid;
    gap: 4px;
}

.kb-admin-bulk-bar__summary strong {
    font-size: 0.95rem;
}

.kb-admin-bulk-bar__summary span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.kb-admin-bulk-bar__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.kb-editor-hero {
    margin-bottom: 20px;
    padding: 28px 30px;
    border-radius: 18px;
    background: var(--surface-raised);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.kb-editor-hero-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.kb-editor-panel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 18px;
}

.kb-editor-summary-list {
    display: grid;
    gap: 10px;
}

.kb-editor-summary-list--users {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-bottom: 18px;
}

.kb-editor-summary-item,
.kb-editor-section-item,
.kb-editor-alert {
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--neutral-tint);
    border: 1px solid var(--border-light);
}

.kb-editor-summary-item strong,
.kb-editor-section-item strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.kb-editor-summary-item span,
.kb-editor-section-item span {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.kb-editor-section-item--managed {
    display: grid;
    gap: 12px;
}

.kb-editor-section-item__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.kb-section-manage-form {
    display: grid;
    gap: 12px;
}

.kb-section-manage-form__grid {
    display: grid;
    gap: 12px;
}

.kb-section-manage-form__field {
    display: grid;
    gap: 8px;
}

.kb-section-manage-form__field label {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
}

.kb-section-manage-form__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.kb-section-manage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.kb-section-manage-actions form {
    margin: 0;
}

.kb-section-transfer-form {
    display: grid;
    gap: 10px;
    min-width: min(100%, 240px);
}

.kb-section-transfer-form__field {
    display: grid;
    gap: 8px;
}

.kb-section-transfer-form__field label {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
}

.kb-section-transfer-preview {
    display: grid;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--transfer-preview-border);
    border-radius: 10px;
    background: var(--transfer-preview-surface);
}

.kb-section-transfer-preview summary {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    cursor: pointer;
    font-weight: 700;
    color: var(--text-primary);
}

.kb-section-transfer-preview summary span {
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 600;
}

.kb-section-transfer-preview__group {
    display: grid;
    gap: 8px;
}

.kb-section-transfer-preview__group strong {
    font-size: 0.84rem;
}

.kb-section-transfer-preview__list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 18px;
}

.kb-section-transfer-preview__list li {
    color: var(--text-secondary);
}

.kb-section-transfer-preview__list li span {
    color: var(--text-primary);
}

.kb-section-transfer-preview__list code {
    display: inline-block;
    margin-left: 8px;
}

.kb-editor-validation {
    margin: 0 0 12px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
}

.kb-editor-validation--ok {
    background: rgba(88, 144, 108, 0.08);
    border-color: rgba(88, 144, 108, 0.22);
}

.kb-editor-validation--error {
    background: rgba(176, 84, 84, 0.08);
    border-color: rgba(176, 84, 84, 0.22);
}

.kb-editor-alert-list,
.kb-editor-section-list {
    display: grid;
    gap: 10px;
}

.kb-editor-table-wrap {
    overflow-x: auto;
}

.kb-editor-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1160px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-raised);
}

.kb-editor-table-caption {
    margin-bottom: 14px;
    color: var(--text-secondary);
    text-align: left;
    font-size: 0.94rem;
}

.kb-editor-table th,
.kb-editor-table td {
    padding: 16px 14px;
    vertical-align: top;
    border-top: 1px solid var(--border-light);
    text-align: left;
}

.kb-editor-table thead th {
    padding-top: 0;
    border-top: none;
    background: var(--editor-table-head-bg);
    color: var(--text-secondary);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.kb-editor-table tbody tr:nth-child(even) {
    background: var(--editor-table-row-alt);
}

.kb-editor-table tbody tr:hover {
    background: var(--editor-table-hover-bg);
}

.kb-editor-table th:last-child,
.kb-editor-table td:last-child {
    width: 128px;
}

.kb-editor-cell-title strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 3px;
}

.kb-editor-cell-title span,
.kb-editor-meta-line {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.kb-editor-cell-summary {
    margin: 8px 0 10px;
    color: var(--text-secondary);
    line-height: 1.55;
}

.kb-inline-editor {
    margin-top: 12px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--surface-raised);
}

.kb-inline-editor summary {
    cursor: pointer;
    padding: 12px 14px;
    color: var(--brand-primary);
    font-size: 0.92rem;
    font-weight: 700;
}

.kb-inline-editor[open] summary {
    border-bottom: 1px solid var(--border-light);
}

.kb-inline-editor__form {
    display: grid;
    gap: 12px;
    padding: 14px;
}

.kb-inline-editor__workspace {
    display: grid;
    grid-template-columns: minmax(420px, 1.05fr) minmax(320px, 0.95fr);
    gap: 16px;
    align-items: start;
}

.kb-inline-preview,
.kb-inline-editor__pane {
    min-width: 0;
}

.kb-inline-preview {
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--neutral-tint);
    overflow: hidden;
}

.kb-inline-preview__header {
    padding: 14px 16px 12px;
    background: var(--surface-raised);
    border-bottom: 1px solid var(--border-light);
}

.kb-inline-preview__header h3 {
    margin-bottom: 6px;
    font-size: 1rem;
}

.kb-inline-preview__meta {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
}

.kb-inline-preview__body {
    max-height: 760px;
    overflow: auto;
    padding: 16px;
    background: var(--preview-body-surface);
}

.kb-inline-preview__article {
    color: var(--text-primary);
}

.kb-inline-preview__article > *:first-child {
    margin-top: 0;
}

.kb-inline-preview__article section + section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.kb-inline-preview__article h2 {
    margin-bottom: 0.7rem;
    font-size: 1.18rem;
}

.kb-inline-preview__article h3 {
    margin-top: 16px;
    margin-bottom: 0.55rem;
    font-size: 1rem;
}

.kb-inline-preview__article p,
.kb-inline-preview__article li {
    font-size: 0.95rem;
    line-height: 1.66;
}

.kb-inline-preview__article ul,
.kb-inline-preview__article ol {
    padding-left: 1.3rem;
}

.kb-inline-preview__article .kb-formula,
.kb-inline-preview__article .kb-callout {
    margin: 14px 0;
}

.kb-inline-editor__label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.kb-inline-editor__pane {
    display: grid;
    gap: 14px;
}

.kb-inline-editor__toolbar {
    position: sticky;
    top: 84px;
    z-index: 3;
    display: grid;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--surface-raised);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.kb-inline-editor__toolbar-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.kb-inline-editor__toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.kb-inline-editor__toolbar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--soft-brand-border);
    border-radius: 999px;
    background: var(--soft-brand-surface);
    color: var(--brand-primary);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.kb-inline-editor__toolbar-button:hover,
.kb-inline-editor__toolbar-button:focus-visible {
    background: var(--soft-brand-surface-strong);
    border-color: var(--soft-brand-border-strong);
    transform: translateY(-1px);
    outline: none;
}

.kb-inline-editor__textarea {
    width: 100%;
    min-height: 420px;
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--neutral-tint);
    color: var(--text-primary);
    font: 0.88rem/1.6 Consolas, "SFMono-Regular", Monaco, monospace;
    resize: vertical;
}

.kb-inline-editor__textarea:focus {
    outline: none;
    border-color: var(--focus-ring-border);
    box-shadow: var(--focus-ring-shadow);
}

.kb-inline-editor-help {
    padding: 16px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--neutral-tint);
}

.kb-inline-editor-help__header h3 {
    margin-bottom: 6px;
    font-size: 1rem;
}

.kb-inline-editor-help__summary {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}

.kb-inline-editor-help__search {
    display: grid;
    gap: 6px;
    margin-top: 14px;
}

.kb-inline-editor-help__search-label {
    color: var(--text-secondary);
    font-size: 0.83rem;
    font-weight: 600;
}

.kb-inline-editor-help__search-input {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-raised);
    color: var(--text-primary);
    font: inherit;
}

.kb-inline-editor-help__search-input:focus {
    outline: none;
    border-color: var(--focus-ring-border);
    box-shadow: var(--focus-ring-shadow);
}

.kb-inline-editor-help__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.kb-inline-editor-help__card {
    padding: 12px 13px;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-raised);
}

.kb-inline-editor-help__card strong {
    display: block;
    margin-bottom: 6px;
    font-size: 0.94rem;
}

.kb-inline-editor-help__card p {
    margin: 0 0 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
}

.kb-inline-editor-help__card code {
    display: inline-block;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: normal;
}

.kb-inline-editor-help__preview {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--surface-raised);
}

.kb-inline-editor-help__preview-head {
    display: grid;
    gap: 4px;
}

.kb-inline-editor-help__preview-head strong {
    font-size: 0.94rem;
}

.kb-inline-editor-help__preview-head p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.55;
}

.kb-inline-editor-help__preview-code {
    margin: 0;
    padding: 12px 13px;
    overflow: auto;
    border-radius: 10px;
    background: var(--content-code-bg);
    border: 1px solid var(--content-code-border);
    color: var(--text-primary);
    font-size: 0.84rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

.kb-inline-editor-help__groups {
    display: grid;
    gap: 14px;
    margin-top: 14px;
}

.kb-inline-editor-help__group {
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    background: var(--surface-raised);
}

.kb-inline-editor-help__group-head {
    display: grid;
    gap: 4px;
    margin-bottom: 12px;
}

.kb-inline-editor-help__group-head strong {
    font-size: 0.94rem;
}

.kb-inline-editor-help__group-head span {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.kb-inline-editor-help__templates {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.kb-inline-editor-help__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 999px;
    background: var(--surface-raised);
    color: var(--brand-primary);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.kb-inline-editor-help__button:hover {
    background: var(--soft-brand-surface);
    border-color: var(--soft-brand-border);
    transform: translateY(-1px);
}

.kb-inline-editor-help__empty {
    margin: 14px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.kb-inline-editor__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.kb-inline-editor__status {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.kb-inline-editor__status[data-state="pending"],
.kb-inline-editor__status[data-state="loading"] {
    color: var(--brand-primary);
}

.kb-inline-editor__status[data-state="ready"] {
    color: #2f6f4f;
}

.kb-inline-editor__status[data-state="error"] {
    color: #995252;
}

[data-theme='dark'] .kb-inline-editor__status[data-state="ready"] {
    color: #8edda0;
}

[data-theme='dark'] .kb-inline-editor__status[data-state="error"] {
    color: #ffb0b0;
}

.kb-editor-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.kb-status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--neutral-tint);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kb-status-badge--full,
.kb-status-badge--valid,
.kb-status-badge--linked {
    color: #2f6f4f;
    background: rgba(88, 144, 108, 0.08);
    border-color: rgba(88, 144, 108, 0.2);
}

.kb-status-badge--condensed,
.kb-status-badge--partial,
.kb-status-badge--group,
.kb-status-badge--featured {
    color: var(--accent-primary);
    background: rgba(168, 121, 51, 0.09);
    border-color: rgba(168, 121, 51, 0.2);
}

.kb-status-badge--draft,
.kb-status-badge--invalid,
.kb-status-badge--orphan {
    color: #995252;
    background: rgba(176, 84, 84, 0.08);
    border-color: rgba(176, 84, 84, 0.2);
}

.kb-status-badge--muted {
    color: var(--text-muted);
}

/* Dark mode needs slightly brighter semantic state colors than the light
   version; otherwise success/error/warning badges fade too far into the darker
   card surfaces and become harder to scan in editor-heavy screens. */
[data-theme='dark'] .kb-auth-alert--success,
[data-theme='dark'] .kb-editor-validation--ok,
[data-theme='dark'] .kb-status-badge--full,
[data-theme='dark'] .kb-status-badge--valid,
[data-theme='dark'] .kb-status-badge--linked {
    color: #8edda0;
    background: rgba(52, 199, 89, 0.12);
    border-color: rgba(52, 199, 89, 0.28);
}

[data-theme='dark'] .kb-auth-alert--error,
[data-theme='dark'] .kb-editor-validation--error,
[data-theme='dark'] .kb-status-badge--draft,
[data-theme='dark'] .kb-status-badge--invalid,
[data-theme='dark'] .kb-status-badge--orphan {
    color: #ffb0b0;
    background: rgba(255, 107, 107, 0.12);
    border-color: rgba(255, 107, 107, 0.28);
}

[data-theme='dark'] .kb-auth-alert--warning,
[data-theme='dark'] .kb-status-badge--condensed,
[data-theme='dark'] .kb-status-badge--partial,
[data-theme='dark'] .kb-status-badge--group,
[data-theme='dark'] .kb-status-badge--featured {
    color: #f0c882;
    background: rgba(214, 181, 108, 0.12);
    border-color: rgba(214, 181, 108, 0.28);
}

.kb-editor-errors summary {
    cursor: pointer;
    color: var(--brand-primary);
    font-weight: 600;
}

.kb-editor-errors ul {
    margin: 10px 0 0;
    padding-left: 1.1rem;
}

.kb-editor-errors li {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.kb-editor-links {
    display: grid;
    gap: 8px;
}

.kb-editor-links--stacked a {
    width: 100%;
}

.kb-editor-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    background: var(--neutral-tint);
    border: 1px solid var(--border-light);
    font-weight: 600;
    white-space: nowrap;
}

.kb-editor-links a:hover {
    border-color: var(--soft-brand-border);
    background: var(--surface-raised);
}

.kb-editor-table--users td {
    vertical-align: top;
}

.kb-editor-table--users th:first-child,
.kb-editor-table--users td:first-child {
    width: 74px;
    text-align: center;
}

.kb-admin-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.kb-admin-select-all label {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
}

.kb-admin-checkbox__input {
    width: 18px;
    height: 18px;
    accent-color: var(--brand-primary);
    cursor: pointer;
}

.kb-editor-empty-state {
    padding: 8px 4px;
}

.kb-editor-empty-state strong {
    display: block;
    margin-bottom: 6px;
    font-size: 1rem;
}

.kb-editor-empty-state p {
    margin: 0;
    color: var(--text-secondary);
}

.kb-home-hero {
    margin-bottom: 20px;
    padding: 32px;
    border-radius: 18px;
    background: var(--surface-raised);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.kb-home-hero h1 {
    font-size: clamp(2.4rem, 4vw, 3.4rem);
    line-height: 1.02;
    letter-spacing: -0.03em;
    margin-bottom: 0.75rem;
}

.kb-home-hero__summary {
    max-width: 62ch;
    margin: 0;
    color: var(--text-secondary);
    font-size: 1.06rem;
    line-height: 1.7;
}

.kb-home-search {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 22px;
}

.kb-home-search__input {
    width: 100%;
    min-width: 0;
    padding: 16px 18px;
    border: 1px solid var(--border-light);
    border-radius: 14px;
    background: var(--surface-raised);
    color: var(--text-primary);
    font-size: 1rem;
    box-shadow: none;
}

.kb-home-search__input:focus {
    outline: none;
    border-color: var(--focus-ring-border);
    box-shadow: var(--focus-ring-shadow);
}

.kb-home-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.kb-chip-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--neutral-tint);
    color: var(--brand-primary);
    font-size: 0.92rem;
    font-weight: 600;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.kb-chip-link:hover {
    transform: translateY(-1px);
    background: var(--surface-raised);
    border-color: var(--soft-brand-border);
}

/* Polish pass: the hero now uses slightly tighter internal rhythm so the
   summary, actions and metadata feel like one system rather than two blocks. */
.kb-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 20px;
    padding: 26px;
    border-radius: 18px;
    margin-bottom: 20px;
    background: var(--surface-raised);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.kb-hero::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--brand-primary), #5b7bd5);
}

.kb-hero__content {
    position: relative;
    z-index: 1;
    padding-left: 14px;
}

.kb-hero h1 {
    font-family: 'Inter', sans-serif;
    font-size: clamp(2.2rem, 3.4vw, 3.1rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.02;
    max-width: 12ch;
    margin-bottom: 0.65rem;
}

.kb-hero__summary {
    max-width: 62ch;
    margin: 0;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.66;
}

.kb-meta-card {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-sunken);
    color: var(--text-primary);
    position: relative;
    z-index: 1;
    border: 1px solid var(--border-light);
    box-shadow: none;
    align-self: start;
}

.kb-meta-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: baseline;
    padding: 11px 0;
    border-bottom: 1px solid var(--border-light);
}

.kb-meta-row span {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.kb-meta-row strong {
    font-size: 0.98rem;
    text-align: right;
}

.kb-home-sections {
    display: grid;
    gap: 16px;
    margin-bottom: 20px;
}

.kb-article {
    border-radius: 18px;
    padding: 30px;
    background: var(--surface-raised);
}

.kb-article::after,
.kb-inline-preview__article::after {
    content: "";
    display: block;
    clear: both;
}

.kb-article--home {
    margin-top: 4px;
}

.kb-article > *:first-child {
    margin-top: 0;
}

.kb-article section + section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.kb-article h1,
.kb-inline-preview__article h1 {
    margin: 0 0 18px;
    font-size: clamp(1.5rem, 2vw + 1rem, 2.15rem);
    line-height: 1.2;
}

.kb-article h2 {
    font-size: 1.32rem;
}

.kb-article h3 {
    margin-top: 18px;
    font-size: 1.12rem;
}

.kb-article h2,
.kb-article h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kb-article h4,
.kb-inline-preview__article h4 {
    margin-top: 18px;
    margin-bottom: 10px;
    font-size: 1rem;
}

.kb-article p,
.kb-article li,
.kb-inline-preview__article p,
.kb-inline-preview__article li {
    line-height: 1.72;
}

.kb-article p,
.kb-inline-preview__article p {
    margin: 0 0 1rem;
}

.kb-heading-anchor {
    opacity: 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    transition: opacity 0.18s ease, color 0.18s ease;
}

.kb-article h2:hover .kb-heading-anchor,
.kb-article h3:hover .kb-heading-anchor,
.kb-heading-anchor:focus-visible {
    opacity: 1;
}

.kb-heading-anchor:hover,
.kb-heading-anchor:focus-visible {
    color: var(--brand-primary);
}

.kb-article ul,
.kb-article ol {
    padding-left: 1.4rem;
    margin: 0 0 1rem;
}

.kb-article li + li {
    margin-top: 0.45rem;
}

.kb-article ul ul,
.kb-article ul ol,
.kb-article ol ul,
.kb-article ol ol,
.kb-inline-preview__article ul ul,
.kb-inline-preview__article ul ol,
.kb-inline-preview__article ol ul,
.kb-inline-preview__article ol ol {
    margin-top: 0.55rem;
    margin-bottom: 0.2rem;
}

.kb-article a,
.kb-inline-preview__article a {
    overflow-wrap: anywhere;
    text-underline-offset: 0.16em;
}

.kb-article a.external,
.kb-article a.external.text,
.kb-inline-preview__article a.external,
.kb-inline-preview__article a.external.text {
    color: var(--brand-primary);
}

.kb-article a.external::after,
.kb-article a.external.text::after,
.kb-inline-preview__article a.external::after,
.kb-inline-preview__article a.external.text::after {
    content: " ↗";
    font-size: 0.9em;
    white-space: nowrap;
}

/* Article content needs its own theme-aware surfaces so dark mode remains
   readable for structured docs blocks instead of only recoloring the shell. */
.kb-article pre,
.kb-inline-preview__article pre {
    margin: 18px 0;
    padding: 14px 16px;
    overflow: auto;
    border-radius: 12px;
    background: var(--content-code-bg);
    border: 1px solid var(--content-code-border);
    color: var(--text-primary);
    font: 0.88rem/1.65 Consolas, "SFMono-Regular", Monaco, monospace;
}

.kb-article code,
.kb-inline-preview__article code,
.kb-section-transfer-preview__list code {
    padding: 0.14rem 0.42rem;
    border-radius: 6px;
    background: var(--content-inline-code-bg);
    color: var(--content-inline-code-text);
    font: 0.84em/1.4 Consolas, "SFMono-Regular", Monaco, monospace;
}

.kb-article pre code,
.kb-inline-preview__article pre code {
    padding: 0;
    background: transparent;
    border-radius: 0;
    color: inherit;
    font: inherit;
}

.kb-article blockquote,
.kb-inline-preview__article blockquote {
    margin: 18px 0;
    padding: 8px 0 8px 16px;
    border-left: 3px solid var(--content-blockquote-border);
    color: var(--text-secondary);
}

.kb-article table,
.kb-inline-preview__article table {
    width: 100%;
    margin: 18px 0;
    border-collapse: collapse;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-raised);
}

.kb-article th,
.kb-article td,
.kb-inline-preview__article th,
.kb-inline-preview__article td {
    padding: 11px 12px;
    border-top: 1px solid var(--border-light);
    text-align: left;
    vertical-align: top;
}

.kb-article thead th,
.kb-inline-preview__article thead th {
    border-top: none;
    background: var(--content-table-head-bg);
    color: var(--text-primary);
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kb-article tbody tr:nth-child(even),
.kb-inline-preview__article tbody tr:nth-child(even) {
    background: var(--content-table-row-alt);
}

/* Imported MediaWiki content often ships with thumbnail wrappers and floated
   screenshots. These rules keep those graph materials readable inside the new
   article layout without depending on MediaWiki's original stylesheet. */
.kb-article .thumb,
.kb-inline-preview__article .thumb {
    margin: 18px 0;
}

.kb-article .thumb.tnone,
.kb-inline-preview__article .thumb.tnone {
    clear: both;
    text-align: center;
}

.kb-article .thumb.tright,
.kb-inline-preview__article .thumb.tright {
    float: right;
    max-width: min(46%, 360px);
    margin: 6px 0 18px 22px;
}

.kb-article .thumb.tleft,
.kb-inline-preview__article .thumb.tleft {
    float: left;
    max-width: min(46%, 360px);
    margin: 6px 22px 18px 0;
}

.kb-article .thumbinner,
.kb-inline-preview__article .thumbinner {
    display: inline-block;
    width: auto !important;
    max-width: 100%;
    padding: 12px;
    box-sizing: border-box;
    border-radius: 14px;
    border: 1px solid var(--border-light);
    background: var(--surface-subtle);
    box-shadow: var(--shadow-sm);
    text-align: left;
}

.kb-article .thumb a.image,
.kb-inline-preview__article .thumb a.image {
    display: inline-block;
    max-width: 100%;
}

.kb-article .thumbcaption,
.kb-inline-preview__article .thumbcaption {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.55;
}

.kb-article .thumbcaption p:last-child,
.kb-inline-preview__article .thumbcaption p:last-child {
    margin-bottom: 0;
}

.kb-article .magnify,
.kb-inline-preview__article .magnify {
    display: none;
}

.kb-article .kb-article-image,
.kb-inline-preview__article .kb-article-image,
.kb-article .kb-imported-image,
.kb-inline-preview__article .kb-imported-image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

@media (max-width: 820px) {
    .kb-article .thumb.tright,
    .kb-article .thumb.tleft,
    .kb-inline-preview__article .thumb.tright,
    .kb-inline-preview__article .thumb.tleft {
        float: none;
        max-width: 100%;
        margin: 18px 0;
    }

    .kb-article .thumbinner,
    .kb-inline-preview__article .thumbinner {
        display: block;
    }
}

.kb-callout,
.kb-formula,
.kb-feature-card {
    border-radius: 10px;
}

.kb-callout {
    padding: 15px 17px;
    margin-bottom: 18px;
    background: var(--content-callout-bg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.kb-callout--warning {
    background: var(--content-warning-bg);
    border-color: var(--content-warning-border);
}

.kb-callout p:last-child {
    margin-bottom: 0;
}

.kb-feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.kb-feature-card {
    padding: 15px;
    background: var(--neutral-tint);
    border: 1px solid var(--border-light);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kb-feature-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    border-color: var(--soft-brand-border);
}

.kb-formula {
    margin: 16px 0;
    padding: 14px 16px;
    background: var(--surface-sunken);
    border: 1px solid var(--border-light);
    color: var(--brand-primary);
    font-weight: 700;
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.kb-related-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kb-footer {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    margin-top: 24px;
    background: var(--surface-raised);
}

.kb-footer__catalog {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.kb-home-section-card h2,
.kb-panel h2,
.kb-footer h2,
.kb-related-card strong,
.kb-home-link strong,
.kb-result-link strong {
    letter-spacing: -0.01em;
}

/* A dedicated floating action improves long-page navigation and follows the
   documentation landing recommendations from ui-ux-pro. */
.kb-back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 46px;
    height: 46px;
    border: none;
    border-radius: 50%;
    background: var(--back-to-top-bg);
    color: var(--back-to-top-text);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: var(--back-to-top-shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.96);
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 50;
}

.kb-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.kb-back-to-top:hover {
    transform: translateY(-3px) scale(1.05);
}

.kb-back-to-top:focus-visible {
    outline: none;
    box-shadow: var(--back-to-top-shadow), var(--focus-ring-shadow);
}

@media (max-width: 1120px) {
    .kb-layout,
    .kb-hero,
    .kb-footer {
        grid-template-columns: 1fr;
    }

    .kb-topbar {
        grid-template-columns: 1fr;
    }

    .kb-sidebar {
        position: static;
    }

    .kb-topbar__nav {
        justify-content: flex-start;
    }

    .kb-topbar__status {
        justify-items: start;
    }

    .kb-topbar__brand {
        padding-left: 4px;
    }

    .kb-search {
        width: 100%;
        justify-content: flex-start;
    }

    .kb-home-search {
        width: 100%;
    }

    .kb-search__input {
        max-width: none;
    }

    .kb-feature-grid,
    .kb-related-grid,
    .kb-footer__catalog {
        grid-template-columns: 1fr;
    }

    .kb-editor-panel-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .kb-editor-section-item__head,
    .kb-section-manage-actions,
    .kb-section-manage-form__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .kb-admin-toolbar__grid,
    .kb-create-article-form__grid,
    .kb-admin-bulk-bar {
        grid-template-columns: 1fr;
        display: grid;
    }

    .kb-admin-bulk-bar__controls {
        justify-content: flex-start;
    }

    .kb-editor-hero-metrics {
        align-items: flex-start;
    }

    .kb-inline-editor__workspace {
        grid-template-columns: 1fr;
    }

    .kb-inline-editor__toolbar {
        position: static;
    }

    .kb-inline-editor-help__grid {
        grid-template-columns: 1fr;
    }

    .kb-inline-editor-help__group {
        padding: 12px;
    }

    .kb-inline-preview__body {
        max-height: none;
    }

    .kb-hero__content {
        padding-left: 0;
    }
}

@media (max-width: 820px) {
    .kb-topbar {
        gap: 14px;
    }

    .kb-topbar__mobile-bar {
        display: flex;
        justify-content: flex-end;
    }

    .kb-topbar__burger {
        display: inline-flex;
    }

    /* The brand is intentionally hidden on mobile because the stacked logo +
       wordmark block was consuming a large part of the first viewport. */
    .kb-topbar__brand {
        display: none;
    }

    .kb-topbar__actions {
        display: none;
        width: 100%;
        gap: 14px;
        padding-top: 4px;
    }

    .kb-topbar.is-open .kb-topbar__actions {
        display: grid;
    }

    .kb-topbar__nav {
        display: grid;
        justify-content: stretch;
        gap: 4px;
    }

    .kb-topbar__nav a,
    .kb-topbar__nav-button,
    .kb-topbar__nav-form {
        width: 100%;
    }

    .kb-topbar__nav a,
    .kb-topbar__nav-button {
        justify-content: flex-start;
        padding-left: 0;
        padding-right: 0;
    }

    .kb-topbar__status {
        justify-items: start;
    }

    .kb-search {
        flex-direction: column;
        align-items: stretch;
    }
}

@media (max-width: 720px) {
    .kb-shell {
        padding: 16px 14px 40px;
    }

    .kb-topbar,
    .kb-panel,
    .kb-home-section-card,
    .kb-footer,
    .kb-article,
    .kb-hero {
        padding: 16px;
    }

    .kb-topbar__brand {
        padding-left: 0;
    }

    .kb-search {
        flex-direction: column;
        align-items: stretch;
    }

    .kb-auth-field-grid {
        grid-template-columns: 1fr;
    }

    .kb-auth-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .kb-admin-toolbar__actions,
    .kb-admin-bulk-bar__controls,
    .kb-create-article-form__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .kb-admin-presets {
        flex-direction: column;
    }

    .kb-home-search {
        flex-direction: column;
        align-items: stretch;
    }

    .kb-button {
        width: 100%;
    }

    .kb-topbar__nav-button {
        width: 100%;
        justify-content: flex-start;
        background: transparent;
    }

    .kb-hero h1 {
        max-width: none;
    }

    .kb-back-to-top {
        right: 16px;
        bottom: 16px;
        width: 46px;
        height: 46px;
    }
}
