/* ==========================================================================
   Modern — a clean, contemporary visual theme for BookStack
   Light & dark palettes driven by BookStack's own CSS variables.
   ========================================================================== */

:root {
    --bs-font: "Inter", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC",
        "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --bs-font-code: "JetBrains Mono", "SF Mono", "Fira Code", ui-monospace,
        "Cascadia Code", Consolas, monospace;

    --bs-bg: #f4f5f7;
    --bs-surface: #ffffff;
    --bs-surface-2: #f8f9fb;
    --bs-surface-3: #eef0f4;
    --bs-border: rgba(16, 24, 40, 0.08);
    --bs-border-strong: rgba(16, 24, 40, 0.16);
    --bs-text: #20293a;
    --bs-text-muted: #63718c;
    --bs-text-faint: #8a94a8;

    --bs-shadow-s: 0 1px 2px rgba(16, 24, 40, 0.05);
    --bs-shadow-m: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.07);
    --bs-shadow-l: 0 4px 12px rgba(16, 24, 40, 0.08), 0 16px 48px rgba(16, 24, 40, 0.12);

    --bs-radius-s: 6px;
    --bs-radius-m: 10px;
    --bs-radius-l: 14px;
    --bs-radius-xl: 20px;

    --bs-header-bg: rgba(255, 255, 255, 0.78);
    --bs-header-text: #3a4358;

    --font-body: var(--bs-font);
    --font-heading: var(--bs-font);
    --font-code: var(--bs-font-code);

    --color-primary: #4c6ef5;
    --color-primary-light: rgba(76, 110, 245, 0.13);
    --color-link: #4361d8;
    --color-page: #4c6ef5;
    --color-page-draft: #845ef7;
    --color-chapter: #e8590c;
    --color-book: #0ca678;
    --color-bookshelf: #e64980;
    --color-positive: #0ca678;
    --color-negative: #e5484d;
    --color-info: #4c6ef5;
    --color-warning: #f08c00;

    --bs-primary: var(--color-primary);
    --bs-primary-soft: var(--color-primary-light);
    --bs-ring: 0 0 0 3px rgba(76, 110, 245, 0.22);
}

html.dark-mode {
    --bs-bg: #0e1116;
    --bs-surface: #161b22;
    --bs-surface-2: #1a2029;
    --bs-surface-3: #212833;
    --bs-border: rgba(255, 255, 255, 0.08);
    --bs-border-strong: rgba(255, 255, 255, 0.16);
    --bs-text: #e4e9f0;
    --bs-text-muted: #97a3b5;
    --bs-text-faint: #6b7688;

    --bs-shadow-s: 0 1px 2px rgba(0, 0, 0, 0.35);
    --bs-shadow-m: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --bs-shadow-l: 0 4px 12px rgba(0, 0, 0, 0.4), 0 16px 48px rgba(0, 0, 0, 0.5);

    --bs-header-bg: rgba(17, 21, 28, 0.78);
    --bs-header-text: #c3cbdb;

    --color-primary: #8a9bff;
    --color-primary-light: rgba(138, 155, 255, 0.16);
    --color-link: #9aabff;
    --color-page: #8a9bff;
    --color-page-draft: #b197fc;
    --color-chapter: #ffa94d;
    --color-book: #38d9a9;
    --color-bookshelf: #faa2c1;
    --color-positive: #38d9a9;
    --color-negative: #ff8787;
    --color-info: #8a9bff;
    --color-warning: #ffd43b;

    --bs-ring: 0 0 0 3px rgba(138, 155, 255, 0.28);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

body {
    background-color: var(--bs-bg);
    color: var(--bs-text);
    font-family: var(--bs-font);
    font-size: 14.5px;
    line-height: 1.65;
    letter-spacing: 0.002em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection {
    background: var(--color-primary);
    color: #fff;
}

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(128, 138, 155, 0.4) transparent;
}
*::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}
*::-webkit-scrollbar-thumb {
    background: rgba(128, 138, 155, 0.35);
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: rgba(128, 138, 155, 0.55);
    background-clip: padding-box;
}
*::-webkit-scrollbar-track {
    background: transparent;
}

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--color-primary);
}

h1, h2, h3, h4, h5, h6,
.list-heading, .page-title, .card-title {
    font-family: var(--bs-font);
    letter-spacing: -0.015em;
    color: var(--bs-text);
}

hr {
    border: 0;
    border-top: 1px solid var(--bs-border);
    margin: 24px 0;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

#header {
    background: var(--bs-header-bg) !important;
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid var(--bs-border);
    box-shadow: none;
    color: var(--bs-header-text);
}

#header .logo .logo-text {
    color: var(--bs-text);
    font-weight: 700;
    letter-spacing: -0.01em;
}
#header .logo .logo-image {
    border-radius: var(--bs-radius-s);
}
/* Default logo is white and invisible on the light header — tint it indigo.
   .logo-image-default is only added when no custom logo is uploaded,
   so user-provided brand logos keep their original colors. */
#header .logo .logo-image-default {
    filter: invert(36%) sepia(85%) saturate(2200%) hue-rotate(218deg) brightness(96%) contrast(92%);
}
html.dark-mode #header .logo .logo-image-default {
    filter: none;
}

#header .header-links a,
#header .links a,
#header .links > a {
    color: var(--bs-header-text);
    font-weight: 500;
    border-radius: var(--bs-radius-s);
    padding: 6px 10px;
    transition: background-color 0.15s ease, color 0.15s ease;
}
#header .header-links a:hover,
#header .links a:hover {
    background: var(--bs-surface-3);
    color: var(--bs-text);
}
#header .mobile-menu-toggle {
    color: var(--bs-header-text);
}

#header .header-user-menu .avatar,
#header .avatar {
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--bs-surface), 0 0 0 4px var(--bs-border);
}

/* Header search — pill */
#header .search-box {
    border-radius: 999px;
    overflow: visible;
}
#header .contained-search-box,
#header .search-box {
    background: var(--bs-surface-3);
    border: 1px solid transparent;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
#header .search-box:focus-within {
    background: var(--bs-surface);
    border-color: var(--color-primary);
    box-shadow: var(--bs-ring);
}
#header #header-search-box-input {
    background: transparent;
    color: var(--bs-text);
    border-radius: 999px;
}
#header #header-search-box-input::placeholder {
    color: var(--bs-text-faint);
}
#header #header-search-box-button {
    color: var(--bs-text-muted);
    background: transparent;
}
#header #header-search-box-button:hover {
    color: var(--bs-text);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.button,
button.button,
input[type="submit"].button {
    border-radius: var(--bs-radius-m);
    font-family: var(--bs-font);
    font-weight: 600;
    font-size: 0.92em;
    letter-spacing: 0.005em;
    padding: 9px 18px;
    border: 1px solid transparent;
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--bs-shadow-s);
    transition: transform 0.12s ease, box-shadow 0.15s ease,
        background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.button:hover {
    filter: brightness(1.06);
    box-shadow: var(--bs-shadow-m);
    transform: translateY(-1px);
    color: #fff;
}
.button:active {
    transform: translateY(0);
    box-shadow: var(--bs-shadow-s);
}
.button:focus-visible {
    box-shadow: var(--bs-ring);
    outline: none;
}

.button.outline,
.button.outline.svg {
    background: var(--bs-surface);
    border-color: var(--bs-border-strong);
    color: var(--bs-text);
    box-shadow: none;
}
.button.outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--bs-surface);
    box-shadow: var(--bs-shadow-s);
}

.text-button,
button.text-button {
    color: var(--color-primary);
    font-weight: 600;
    border-radius: var(--bs-radius-s);
    transition: color 0.15s ease, background-color 0.15s ease;
}
.text-button:hover {
    color: var(--color-primary);
    text-decoration: none;
    filter: brightness(1.1);
}

.icon-button {
    border-radius: var(--bs-radius-s);
    color: var(--bs-text-muted);
    transition: background-color 0.15s ease, color 0.15s ease;
}
.icon-button:hover {
    background: var(--bs-surface-3);
    color: var(--bs-text);
}

/* --------------------------------------------------------------------------
   Cards & entity lists
   -------------------------------------------------------------------------- */

.card,
.content-wrap.card {
    background: var(--bs-surface);
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius-l);
    box-shadow: var(--bs-shadow-s);
}

.grid-card,
.card.grid-card {
    border-radius: var(--bs-radius-l);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
    box-shadow: var(--bs-shadow-s);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.grid-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--bs-shadow-m);
    border-color: var(--bs-border-strong);
}
.grid-card .featured-image-container-wrap,
.grid-card .featured-image-container {
    border-radius: 0;
}
.grid-card .grid-card-content,
.grid-card h2 {
    letter-spacing: -0.01em;
}

.entity-list-item {
    border-radius: var(--bs-radius-m);
    transition: background-color 0.13s ease, transform 0.13s ease;
}
.entity-list-item:hover {
    background: var(--bs-surface-2);
}
.entity-list-item.selected,
.entity-list-item.selected:hover {
    background: var(--bs-primary-soft);
}
.entity-list-item h4 a,
.entity-list-item .entity-list-item-name {
    font-weight: 600;
    letter-spacing: -0.005em;
}

.sub-card {
    border-radius: var(--bs-radius-m);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface-2);
}

.card-footer-link,
button.card-footer-link {
    color: var(--color-primary);
    font-weight: 600;
}
.card-footer-link:hover {
    filter: brightness(1.1);
}

.list-heading,
.card h1.list-heading {
    font-size: 1.35em;
    font-weight: 700;
}

/* Bookshelf / book listing cards */
.book-grid-item,
.featured-image-container {
    border-radius: var(--bs-radius-m);
    overflow: hidden;
}
.featured-image-container-wrap .svg-icon {
    opacity: 0.85;
}

/* Book tree (left sidebar navigation) */
.book-tree .sidebar-page-list .entity-list-item {
    border-radius: var(--bs-radius-s);
    padding: 4px 10px;
    gap: 0;
}
.book-tree .entity-list-item .icon {
    display: none;
}
.book-tree .entity-list-item .content {
    padding-top: 2px;
    padding-bottom: 2px;
    max-width: 100%;
}
.book-tree .entity-list-item-name {
    font-size: 0.93em;
    font-weight: 500;
    color: var(--bs-text-muted);
}
.book-tree .entity-list-item:hover {
    background: var(--bs-surface-3);
}
.book-tree .entity-list-item:hover .entity-list-item-name {
    color: var(--bs-text);
}
.book-tree .entity-list-item.selected {
    background: var(--bs-primary-soft);
}
.book-tree .entity-list-item.selected .entity-list-item-name {
    color: var(--color-primary);
    font-weight: 600;
}
.book-tree .list-item-book > .entity-list-item .entity-list-item-name,
.book-tree .list-item-chapter > .entity-list-item .entity-list-item-name {
    color: var(--bs-text);
    font-weight: 600;
}
.book-tree .list-item-book > .entity-list-item .entity-list-item-name {
    font-weight: 700;
}
.book-tree .list-item-chapter > .entity-list-item.selected .entity-list-item-name,
.book-tree .list-item-book > .entity-list-item.selected .entity-list-item-name {
    color: var(--color-primary);
}
.book-tree .entity-list-item.no-hover {
    padding-top: 0;
    padding-bottom: 0;
}
.book-tree .chapter-contents-toggle {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    border-radius: var(--bs-radius-s);
    color: var(--bs-text-faint);
    font-size: 0.78em;
    font-weight: 500;
    padding: 3px 8px 3px 2px;
    transition: color 0.13s ease, background-color 0.13s ease;
}
.book-tree .chapter-contents-toggle:hover {
    color: var(--bs-text);
    background: var(--bs-surface-3);
}
.book-tree .chapter-contents-toggle svg {
    transition: transform 0.15s ease;
}
.book-tree .chapter-contents-toggle svg:not(:first-child) {
    display: none;
}
.book-tree .chapter-contents-toggle.open svg:first-child {
    transform: rotate(90deg);
}
.book-tree .sidebar-page-list ul.sub-menu {
    border-left: 1px solid var(--bs-border);
    padding-inline-start: 10px;
    margin-inline-start: 8px;
    margin-bottom: 2px;
}
.book-tree h5 {
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bs-text-faint);
}

/* Book contents list (book detail page) */
.book-contents .entity-list-item {
    padding: 10px 12px;
    border-radius: var(--bs-radius-m);
    gap: 12px;
    align-items: flex-start;
}
.book-contents .entity-list-item .icon {
    width: auto;
    height: auto;
    flex: none;
    align-self: flex-start;
    margin-inline-end: 0;
    padding-top: 4px;
    border-radius: 0;
    background: none;
}
.book-contents .entity-list-item .icon:before,
.book-contents .entity-list-item .icon:after {
    display: none;
}
.book-contents .entity-list-item .icon svg {
    display: block;
    width: 18px;
    height: 18px;
    opacity: 0.75;
}
.book-contents .entity-list-item .entity-list-item-name {
    font-weight: 500;
}
.book-contents .entity-list-item.chapter .entity-list-item-name {
    font-size: 1.05em;
    font-weight: 600;
}
.book-contents .entity-item-snippet p {
    font-size: 0.85em;
    color: var(--bs-text-faint);
    margin-top: 3px;
    line-height: 1.45;
}
.book-contents .entity-list-item.has-children {
    padding-bottom: 4px;
}
.book-contents > .entity-list-item:not(.chapter.has-children),
.book-contents > .chapter-expansion {
    border-bottom: 1px solid var(--bs-border);
    margin-bottom: 6px;
    padding-bottom: 10px;
}
.book-contents > .entity-list-item:last-child,
.book-contents > .chapter-expansion:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.book-contents .entity-list-item.chapter.has-children {
    padding-bottom: 4px;
}
.book-contents .chapter-expansion {
    padding: 0 12px 8px 12px;
    margin-top: -4px;
}
.book-contents .chapter-expansion > .icon {
    display: none;
}
.book-contents .chapter-expansion > .content {
    min-width: 0;
}
.book-contents .chapter-contents-toggle {
    display: block;
    width: 100%;
    text-align: start;
    color: var(--bs-text-faint);
    font-size: 0.8em;
    font-weight: 500;
    padding: 2px 6px 2px 30px;
    border-radius: var(--bs-radius-s);
    transition: color 0.13s ease, background-color 0.13s ease;
}
.book-contents .chapter-contents-toggle:hover {
    color: var(--bs-text);
    background: var(--bs-surface-3);
}
.book-contents .chapter-contents-toggle svg:first-child {
    transition: transform 0.15s ease;
}
.book-contents .chapter-contents-toggle[aria-expanded="true"] svg:first-child {
    transform: rotate(90deg);
}
.book-contents .chapter-contents-list {
    border-left: 1px solid var(--bs-border);
    margin-inline-start: 9px;
    padding-inline-start: 21px;
    margin-top: 4px;
}
.book-contents .entity-list-item-children .entity-list-item {
    padding: 7px 10px;
}
.book-contents .entity-list-item-children .entity-list-item .icon svg {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

/* Page navigation TOC (right sidebar) */
.sidebar-page-nav:after {
    width: 1px;
    background: var(--bs-border);
    top: 8px;
    bottom: 8px;
}
.sidebar-page-nav .sidebar-page-nav-bullet {
    display: none;
}
.sidebar-page-nav li {
    border-radius: var(--bs-radius-s);
    font-size: 0.88em;
    margin-bottom: 1px;
}
.sidebar-page-nav a {
    color: var(--bs-text-muted);
    border-radius: var(--bs-radius-s);
    padding: 4px 8px;
    line-height: 1.45;
    transition: color 0.13s ease, background-color 0.13s ease;
}
.sidebar-page-nav a:hover {
    color: var(--bs-text);
    background: var(--bs-surface-3);
}
.sidebar-page-nav li.current-heading a,
.sidebar-page-nav li.active a,
.sidebar-page-nav a.active {
    color: var(--color-primary);
    font-weight: 600;
}
.sidebar-page-nav li.current-heading:before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 2px;
    border-radius: 1px;
    background: var(--color-primary);
    z-index: 2;
}
/* BookStack marks every in-viewport heading as current-heading;
   only the first one should look active */
.sidebar-page-nav li.current-heading ~ li.current-heading a {
    color: var(--bs-text-muted);
    font-weight: 400;
}
.sidebar-page-nav li.current-heading ~ li.current-heading:before {
    display: none;
}
#page-navigation h5 {
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bs-text-faint);
}

/* Floating toolbox / actions */
.floating-toolbox {
    border-radius: var(--bs-radius-l);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
    box-shadow: var(--bs-shadow-m);
}
.floating-toolbox .tabs {
    border-bottom: 1px solid var(--bs-border);
}
.floating-toolbox .tabs button {
    color: var(--bs-text-muted);
    font-weight: 500;
}
.floating-toolbox .tabs button.active {
    color: var(--color-primary);
    box-shadow: inset 0 -2px 0 var(--color-primary);
}
.floating-toolbox button[role="tab"] {
    border-radius: 0;
}

.actions .icon-list-item,
.icon-list-item {
    border-radius: var(--bs-radius-s);
    transition: background-color 0.13s ease;
}
.icon-list-item:hover {
    background: var(--bs-surface-3);
}
.action-favourite,
.action-unfavourite {
    color: var(--bs-text-muted);
}

/* --------------------------------------------------------------------------
   Forms & inputs
   -------------------------------------------------------------------------- */

.input-base,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
select,
textarea,
.description-input {
    border-radius: var(--bs-radius-m);
    border: 1px solid var(--bs-border-strong);
    background: var(--bs-surface);
    color: var(--bs-text);
    font-family: var(--bs-font);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-base:focus,
input:focus,
select:focus,
textarea:focus,
.description-input:focus {
    border-color: var(--color-primary);
    box-shadow: var(--bs-ring);
    outline: none;
}
input::placeholder,
textarea::placeholder {
    color: var(--bs-text-faint);
}
input[disabled],
input.disabled {
    background: var(--bs-surface-3);
}

label,
.form-group label {
    font-weight: 600;
    font-size: 0.92em;
    color: var(--bs-text);
    letter-spacing: 0.002em;
}

.contained-search-box {
    border-radius: 999px;
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.contained-search-box:focus-within,
.contained-search-box.floating {
    border-color: var(--color-primary);
    box-shadow: var(--bs-ring);
}
.contained-search-box input {
    border: 0;
    background: transparent;
    box-shadow: none;
}
.contained-search-box button {
    color: var(--bs-text-muted);
}

.toggle-switch {
    border-radius: 999px;
}

/* --------------------------------------------------------------------------
   Tabs, breadcrumbs, dropdowns, sort bar
   -------------------------------------------------------------------------- */

.tab-container.bordered {
    border-radius: var(--bs-radius-l);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
    overflow: hidden;
}
.tab-container .tabs,
.tabs {
    border-bottom: 1px solid var(--bs-border);
}
.tab-container .tab-item,
.tabs .tab-item,
.tab-container .tabs button {
    color: var(--bs-text-muted);
    font-weight: 500;
    border-radius: var(--bs-radius-s) var(--bs-radius-s) 0 0;
    transition: color 0.13s ease;
}
.tab-container .tab-item.selected,
.tab-container .tab-item.active,
.tabs .tab-item.selected {
    color: var(--color-primary);
    box-shadow: inset 0 -2px 0 var(--color-primary);
}

.breadcrumbs {
    color: var(--bs-text-faint);
}
.breadcrumbs a,
.breadcrumbs .text-muted {
    color: var(--bs-text-muted);
    font-weight: 500;
}
.breadcrumbs a:hover {
    color: var(--color-primary);
}
.breadcrumbs .separator,
.breadcrumbs svg {
    color: var(--bs-text-faint);
    opacity: 0.7;
}

.dropdown-menu {
    border-radius: var(--bs-radius-l);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
    box-shadow: var(--bs-shadow-l);
    padding: 6px;
}
.dropdown-menu a,
.dropdown-menu button,
.dropdown-menu .icon-item,
.dropdown-menu .text-item {
    border-radius: var(--bs-radius-s);
    color: var(--bs-text);
    font-weight: 500;
}
.dropdown-menu a:hover,
.dropdown-menu button:hover,
.dropdown-menu .icon-item:hover {
    background: var(--bs-surface-3);
    color: var(--bs-text);
}
.dropdown-menu .label-item {
    color: var(--bs-text-faint);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.dropdown-search-dropdown {
    border-radius: var(--bs-radius-l);
    border: 1px solid var(--bs-border);
    box-shadow: var(--bs-shadow-l);
}
.dropdown-search-item {
    border-radius: var(--bs-radius-s);
}
.dropdown-search-item:hover {
    background: var(--bs-surface-3);
}

.list-sort-container .list-sort,
.list-sort-container .list-sort-dir {
    border-radius: var(--bs-radius-s);
}
.list-sort-label,
.list-sort-toggle {
    color: var(--bs-text-muted);
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   Content pages
   -------------------------------------------------------------------------- */

.content-wrap {
    border-radius: var(--bs-radius-l);
}

.page-content,
.mce-content-body {
    font-size: 1.02rem;
    line-height: 1.75;
    color: var(--bs-text);
    letter-spacing: 0.001em;
}
.page-content h1, .page-content h2, .page-content h3,
.page-content h4, .page-content h5, .page-content h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.35;
}
.page-content h1 { font-size: 1.9em; }
.page-content h2 { font-size: 1.55em; }
.page-content h3 { font-size: 1.28em; }
.page-content p {
    margin-bottom: 1.05em;
}
.page-content img {
    border-radius: var(--bs-radius-m);
}
.page-content blockquote {
    border-left: 3px solid var(--color-primary);
    background: var(--bs-primary-soft);
    border-radius: 0 var(--bs-radius-m) var(--bs-radius-m) 0;
    padding: 12px 18px 12px 44px;
    color: var(--bs-text);
    margin: 1.2em 0;
}
.page-content table {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius-m);
    overflow: hidden;
}
@media (max-width: 720px) {
    .page-content table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }
    .page-content table th {
        white-space: nowrap;
    }
    .page-content table th,
    .page-content table td {
        min-width: 96px;
    }
}
.page-content table th {
    background: var(--bs-surface-3);
    font-weight: 600;
}
.page-content table th,
.page-content table td {
    border: 0;
    border-bottom: 1px solid var(--bs-border);
    padding: 9px 14px;
}
.page-content table tr:last-child td {
    border-bottom: 0;
}
.page-content details {
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius-m);
    background: var(--bs-surface);
    padding: 10px 16px;
}

/* Inline & block code */
code,
span.code,
.code-base {
    font-family: var(--bs-font-code);
    font-size: 0.88em;
}
.page-content code,
.code-base {
    background: var(--bs-surface-3);
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius-s);
    padding: 2px 6px;
    color: var(--bs-text);
}
pre,
.page-content pre {
    background: #1d2330;
    color: #dbe2ee;
    border-radius: var(--bs-radius-m);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 16px 20px;
    box-shadow: var(--bs-shadow-s);
}
pre code,
.page-content pre code {
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
}
html.dark-mode pre,
html.dark-mode .page-content pre {
    background: #0a0d13;
    border-color: var(--bs-border);
}

/* Callouts */
.callout {
    border-radius: var(--bs-radius-m);
    border: 1px solid var(--bs-border);
    border-left: 3.5px solid var(--color-info);
    padding: 8px 14px 8px 36px;
    padding-inline-start: 36px;
    margin: 10px 0;
    line-height: 1.55;
}
.callout.info {
    background: rgba(76, 110, 245, 0.08);
    border-left-color: var(--color-info);
}
.callout.success {
    background: rgba(12, 166, 120, 0.09);
    border-left-color: var(--color-positive);
}
.callout.warning {
    background: rgba(240, 140, 0, 0.09);
    border-left-color: var(--color-warning);
}
.callout.danger {
    background: rgba(229, 72, 77, 0.09);
    border-left-color: var(--color-negative);
}
html.dark-mode .callout {
    background: var(--bs-surface-2);
    border-color: var(--bs-border);
    color: var(--bs-text);
}
html.dark-mode .callout.info {
    background: rgba(138, 155, 255, 0.12);
    border-left-color: var(--color-info);
}
html.dark-mode .callout.success {
    background: rgba(56, 217, 169, 0.1);
    border-left-color: var(--color-positive);
}
html.dark-mode .callout.warning {
    background: rgba(255, 212, 59, 0.1);
    border-left-color: var(--color-warning);
}
html.dark-mode .callout.danger {
    background: rgba(255, 135, 135, 0.1);
    border-left-color: var(--color-negative);
}

/* Tags */
.entity-item-tags .tag,
.tag {
    border-radius: 999px;
    background: var(--bs-surface-3);
    border: 1px solid var(--bs-border);
    font-weight: 500;
    padding: 2px 12px;
    font-size: 0.85em;
}

/* Meta / details blocks */
.entity-meta-item,
.meta {
    color: var(--bs-text-muted);
}

/* --------------------------------------------------------------------------
   Layout polish
   -------------------------------------------------------------------------- */

.tri-layout-left,
.tri-layout-right {
    scrollbar-width: thin;
}
.tri-layout-middle-contents {
    max-width: 960px;
}
.sticky-sidebar-header {
    color: var(--bs-text-faint);
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.footer,
footer {
    color: var(--bs-text-faint);
}
.footer a {
    color: var(--bs-text-muted);
}

/* Scroll fade hints */
.scroll-away-from-top,
.scroll-away-from-bottom {
    border-radius: var(--bs-radius-s);
}

/* --------------------------------------------------------------------------
   Overlays, popups, notifications, comments
   -------------------------------------------------------------------------- */

.popup-background {
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    background: rgba(15, 20, 30, 0.45);
}
.popup-body,
.popup-content {
    border-radius: var(--bs-radius-xl);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
    box-shadow: var(--bs-shadow-l);
}

.notification {
    border-radius: var(--bs-radius-m);
    box-shadow: var(--bs-shadow-l);
    border: 1px solid var(--bs-border-strong);
    border-inline-start-width: 4px;
    background: var(--bs-surface);
    color: var(--bs-text);
    font-weight: 500;
    line-height: 1.45;
}
.notification.pos {
    border-inline-start-color: var(--color-positive);
}
.notification.neg {
    border-inline-start-color: var(--color-negative);
}
.notification.warning {
    border-inline-start-color: var(--color-warning);
}
.notification.pos > svg {
    color: var(--color-positive);
}
.notification.neg > svg {
    color: var(--color-negative);
}
.notification.warning > svg {
    color: var(--color-warning);
}
.notification > span {
    background: transparent;
    color: var(--bs-text);
}
.notification .dismiss,
.notification .dismiss svg {
    color: var(--bs-text-faint);
}
.notification .dismiss:hover,
.notification .dismiss:hover svg {
    color: var(--bs-text);
}
html.dark-mode .notification {
    background: var(--bs-surface-2);
    color: var(--bs-text);
}

.comment-box {
    border-radius: var(--bs-radius-m);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
    box-shadow: var(--bs-shadow-s);
}
.comment-box .header {
    color: var(--bs-text-muted);
}
.comment-editor-container,
.basic-editor-container {
    border-radius: var(--bs-radius-m);
    border: 1px solid var(--bs-border-strong);
}
.content-comment-window {
    border-radius: var(--bs-radius-m);
    border: 1px solid var(--bs-border);
    box-shadow: var(--bs-shadow-m);
}

/* --------------------------------------------------------------------------
   Editor
   -------------------------------------------------------------------------- */

.editor-toolbar {
    border-radius: var(--bs-radius-m) var(--bs-radius-m) 0 0;
    border: 1px solid var(--bs-border);
    border-bottom: 0;
    background: var(--bs-surface-2);
}
.editor-toolbar button:hover,
.editor-toolbar .buttons button:hover {
    background: var(--bs-surface-3);
    border-radius: var(--bs-radius-s);
}
.editor-container {
    border-radius: 0 0 var(--bs-radius-m) var(--bs-radius-m);
    border: 1px solid var(--bs-border);
    background: var(--bs-surface);
}
.markdown-editor-wrap {
    border-radius: var(--bs-radius-m);
}
.cm-editor {
    border-radius: var(--bs-radius-m);
}
.cm-copy-button {
    border-radius: var(--bs-radius-s);
}
.editor-modal {
    border-radius: var(--bs-radius-l);
    border: 1px solid var(--bs-border);
    box-shadow: var(--bs-shadow-l);
}
.editor-form-action-primary {
    border-radius: var(--bs-radius-s);
}
.editor-form-action-secondary {
    border-radius: var(--bs-radius-s);
}

/* --------------------------------------------------------------------------
   Login / simple pages
   -------------------------------------------------------------------------- */

body:has(.container.very-small) {
    background:
        radial-gradient(1000px 480px at 15% -10%, rgba(76, 110, 245, 0.16), transparent 60%),
        radial-gradient(900px 420px at 90% 110%, rgba(132, 94, 247, 0.14), transparent 60%),
        var(--bs-bg);
}
html.dark-mode body:has(.container.very-small) {
    background:
        radial-gradient(1000px 480px at 15% -10%, rgba(138, 155, 255, 0.12), transparent 60%),
        radial-gradient(900px 420px at 90% 110%, rgba(177, 151, 252, 0.1), transparent 60%),
        var(--bs-bg);
}
.container.very-small .card {
    border-radius: var(--bs-radius-xl);
    box-shadow: var(--bs-shadow-l);
    border: 1px solid var(--bs-border);
}
.container.very-small .list-heading {
    font-size: 1.5em;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* --------------------------------------------------------------------------
   Misc polish
   -------------------------------------------------------------------------- */

.item-list-row {
    border-radius: var(--bs-radius-s);
}
.item-list-row:hover {
    background: var(--bs-surface-2);
}

.pointer,
.pointer .button,
.pointer .text-button,
.pointer input {
    border-radius: var(--bs-radius-s);
}

.setting-list-label {
    color: var(--bs-text);
    font-weight: 600;
}

.search-box button {
    border-radius: var(--bs-radius-s);
}

.global-search-suggestions.card {
    border-radius: var(--bs-radius-l);
    box-shadow: var(--bs-shadow-l);
    border: 1px solid var(--bs-border);
}

.entity-selector {
    border-radius: var(--bs-radius-m);
}
.entity-selector .entity-list-item.selected {
    background: var(--bs-primary-soft);
}

.image-manager-list .image {
    border-radius: var(--bs-radius-s);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.image-manager-list .image:hover {
    transform: scale(1.02);
    box-shadow: var(--bs-shadow-m);
}

.fade-in-when-active {
    transition: opacity 0.2s ease;
}

/* Active nav link accents */
.active-link-list a {
    border-radius: var(--bs-radius-s);
}
.active-link-list.in-sidebar a.active {
    color: var(--color-primary);
    font-weight: 600;
    background: var(--bs-primary-soft);
}

/* Smooth theme transitions */
body, .card, .grid-card, .button, .entity-list-item, input, select, textarea {
    transition-property: background-color, border-color, color, box-shadow, transform;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* Print stays clean */
@media print {
    #header, .floating-toolbox {
        display: none;
    }
    .card, .content-wrap {
        box-shadow: none;
        border: none;
    }
}
