:root {
    --gutter: 10px;
    --titlebar-offset: 10px;
    --topnav-height: 44px;
    --bs-gutter-x: 10px;
    --bs-gutter-y: 10px;
}

/* Thin scrollbars — 3px indicators, not drag targets */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }
* { scrollbar-width: thin; scrollbar-color: #30363d transparent; }

html, body {
    font-family: 'Outfit', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #0d1117;
    color: #e6edf3;
}

/* Standardize all Bootstrap spacing utilities to 10px gutter */
.g-2, .g-3, .gx-2, .gx-3 { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }
.row { --bs-gutter-x: 10px; --bs-gutter-y: 10px; }
.gap-1, .gap-2, .gap-3 { gap: 10px !important; }
.mb-1, .mb-2, .mb-3, .my-1, .my-2, .my-3 { margin-bottom: 10px !important; }
.mt-1, .mt-2, .mt-3 { margin-top: 10px !important; }
.mx-1, .mx-2, .mx-3 { margin-left: 10px !important; margin-right: 10px !important; }
.p-1, .p-2, .p-3 { padding: 10px !important; }
.px-1, .px-2, .px-3 { padding-left: 10px !important; padding-right: 10px !important; }
.py-1, .py-2, .py-3 { padding-top: 10px !important; padding-bottom: 10px !important; }
.card-body { padding: 10px; }
.card-header { padding: 10px; }

/* Icon gutter inside buttons — skip icon-only buttons */
.btn i.bi { margin-right: 5px; }
.btn i.bi:only-child, .btn-sq i.bi, .tb i.bi { margin-right: 0; }

/* Right-align action button columns */
.d-flex.justify-content-between .d-flex.gap-2:last-child,
.d-flex.justify-content-end { margin-left: auto; }

/* Standard 32px button height, square buttons 32x32 */
.btn { height: 32px; padding-top: 0; padding-bottom: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-sm { height: 32px; }
.input-group .btn { height: auto; }
.form-control { height: 32px; }
.form-select { height: 32px; }
.btn-group .btn { height: 32px; }
.dropdown-toggle { height: 32px; }
.btn-sq, .tb { width: 32px; height: 32px; padding: 0; }

/* Dictionary editors: all fields full width, textareas auto-height */
.dict-editor .row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
.dict-editor textarea,
.dict-editor .auto-grow {
    min-height: 40px;
    height: auto;
    overflow: hidden;
    resize: none;
    field-sizing: content;
}

/* Dark theme overrides */
.app-shell { width: 100%; height: 100vh; display: flex; flex-direction: column; background-color: #0d1117; overflow: hidden; }

/* ── Top nav ─────────────────────────────────────────────────────── */
.topnav {
    padding: 0 12px;
    min-height: var(--topnav-height);
    background: #161b22;
    border-bottom: 1px solid #30363d;
    flex-shrink: 0;
    position: relative;
    z-index: 1050;
    gap: 2px;
}
@media (min-width: 768px) {
    .topnav { height: var(--topnav-height); }
}
.topnav-main {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    min-height: 0;
}
.topnav-brand {
    color: #dc3545 !important;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    padding: 0 6px 0 0;
    flex-shrink: 0;
    white-space: nowrap;
}
.topnav-brand:hover { color: #ff6b6b !important; }
.topnav-toggler {
    background: none !important;
    border: 1px solid #30363d !important;
    color: #c9d1d9 !important;
    padding: 2px 7px !important;
    border-radius: 4px;
    line-height: 1;
    margin-left: auto;
}
.topnav-toggler:focus { box-shadow: none !important; }
.topnav-toggler .bi { font-size: 1.1rem; vertical-align: middle; }
/* Breadcrumb in topnav */
.topnav-left {
    gap: 5px;
    font-size: 0.78rem;
    overflow: hidden;
    flex-shrink: 1;
    min-width: 0;
    color: #8b949e;
    white-space: nowrap;
}
.topnav-crumb-icon-link { color: inherit; text-decoration: none; line-height: 1; }
.topnav-crumb-icon-link:hover .topnav-crumb-icon { color: #e6edf3; }
.topnav-crumb-sep { color: #8b949e; flex-shrink: 0; }
.topnav-crumb-link { color: #8b949e; text-decoration: none; flex-shrink: 0; }
.topnav-crumb-link:hover { color: #e6edf3; }
.topnav-crumb-current { color: #e6edf3; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
/* Search in topnav */
.topnav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    flex-shrink: 0;
}
.topnav-search-wrap { display: flex; align-items: center; }
.topnav-search {
    background: #0d1117;
    border: 1px solid #30363d;
    color: #e6edf3;
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.82rem;
    height: 28px;
    width: 280px;
    outline: none;
    transition: border-color 0.15s;
}
.topnav-search:focus { border-color: #dc3545; }
.topnav-search::placeholder { color: #484f58; }
.topnav-search::-webkit-search-cancel-button,
.topnav-search::-ms-clear { display: none; }
.topnav-username { font-size: 0.78rem; }
.topnav-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; border: 1px solid #30363d; }
/* Profile page */
.profile-avatar-lg { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid #30363d; display: block; }
.profile-avatar-empty-lg { width: 64px; height: 64px; border-radius: 50%; background: #21262d; border: 2px solid #30363d; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: #8b949e; }
.profile-canvas-preview { display: block; border-radius: 50%; border: 2px solid #30363d; width: 128px; height: 128px; }
.topnav-link {
    color: #c9d1d9 !important;
    text-decoration: none;
    font-size: 0.82rem;
    padding: 4px 8px;
    border-radius: 4px;
    border: none;
    background: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    flex-shrink: 0;
    white-space: nowrap;
}
.topnav-link:hover { background: #21262d; color: #e6edf3 !important; }
.topnav-link:focus, .topnav-link:active, .topnav-link.show { outline: none !important; box-shadow: none !important; border-color: transparent !important; background: #21262d; }
.topnav-link.active { color: #dc3545 !important; background: none; }
.topnav-link.dropdown-toggle::after { margin-left: 3px; }
.topnav-drop-menu {
    background: #161b22 !important;
    border: 1px solid #30363d !important;
    border-radius: 6px !important;
    padding: 4px 0 !important;
    min-width: 200px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
}
.topnav-drop-item {
    color: #c9d1d9 !important;
    font-size: 0.82rem;
    padding: 5px 12px !important;
    display: flex;
    align-items: center;
    gap: 8px;
}
.topnav-drop-item:hover { background: #21262d !important; color: #e6edf3 !important; }
.topnav-drop-item.active { background: #21262d !important; color: #dc3545 !important; }
.topnav-drop-icon { width: 14px; flex-shrink: 0; opacity: 0.7; }
/* Button label wrapper — ensures icon and label are both DOM elements, not text nodes */
.btn-lbl { display: inline-block; }
/* Breadcrumb icon styles (used on mobile) */
.topnav-crumb-icon { font-size: 0.88rem; color: #8b949e; }
.topnav-crumb-icon-cur { color: #e6edf3; }

/* Mobile nav — single slim row, search/controls in bottom FAB drawer */
@media (max-width: 767.98px) {
    .topnav { padding: 0 10px; height: var(--topnav-height) !important; }
    .topnav .navbar-collapse { display: none !important; }
    .topnav-left { padding: 0; white-space: nowrap; overflow: visible; }
    /* Mobile nav drawer (search + controls) */
    .topnav-mobile-drawer {
        position: fixed; bottom: 0; left: 0; right: 0;
        background: #0d1117; border-top: 1px solid #30363d;
        border-radius: 14px 14px 0 0; z-index: 1045;
        transform: translateY(100%);
        transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
        padding: 14px 16px 20px;
    }
    body.nav-mobile-open .topnav-mobile-drawer { transform: translateY(0); }
    .topnav-mobile-inner { display: flex; flex-direction: column; gap: 10px; }
    /* Nav FAB — hamburger that opens the drawer */
    .nav-mobile-fab {
        position: fixed; bottom: 16px; right: 16px;
        width: 44px; height: 44px; border-radius: 50%;
        background: #21262d; border: 1px solid #30363d;
        color: #c9d1d9; font-size: 1.1rem; cursor: pointer;
        z-index: 1060; display: flex; align-items: center; justify-content: center;
        box-shadow: 0 4px 16px rgba(0,0,0,0.5); transition: background 0.15s, color 0.15s;
    }
    body.nav-mobile-open .nav-mobile-fab { background: #dc3545; color: #fff; border-color: #dc3545; }
    /* Backdrop */
    .nav-mobile-backdrop {
        display: none; position: fixed; inset: 0;
        background: rgba(0,0,0,0.45); z-index: 1044;
    }
    body.nav-mobile-open .nav-mobile-backdrop { display: block; }
}
@media (min-width: 768px) {
    .nav-mobile-fab, .nav-mobile-backdrop, .topnav-mobile-drawer { display: none !important; }
    .topnav-username { font-size: 0.78rem; }
}

/* Fix label visibility — Bootstrap text-muted is invisible on dark backgrounds */
.form-label { color: #9ca3af !important; font-weight: 500; }
.form-label.text-muted { color: #9ca3af !important; }
.form-label.text-danger { color: #dc3545 !important; }
.text-muted { color: #8b949e !important; }
.card-header.text-muted { color: #9ca3af !important; font-weight: 600; }
.nav-header { color: #8b949e !important; }
small.text-muted { color: #8b949e !important; }

/* Form controls on dark backgrounds */
.form-control::placeholder { color: #484f58 !important; }
.form-select { color: #e6edf3 !important; }

/* Story preview styling */
.story-preview h1, .story-preview h2, .story-preview h3 { color: #dc3545; margin-top: 1.5rem; }
.story-preview p { margin-bottom: 1rem; }
.story-preview .facet-tag { padding: 1px 6px; border-radius: 3px; font-size: 0.75rem; }
.story-preview blockquote { border-left: 3px solid #6c757d; padding-left: 1rem; color: #8b949e; font-style: italic; }
.story-preview code { color: #e06c75; background: #21262d; padding: 2px 6px; border-radius: 3px; }

/* Print preview — hr = page break */
.story-preview-print hr {
    border: none;
    page-break-after: always;
    break-after: page;
    margin: 0;
    height: 0;
}
@media print {
    .story-preview-print hr { page-break-after: always; break-after: page; }
}

/* Analysis panel */
.analysis-panel { border-color: #0dcaf0 !important; }

/* Table hover */
.table-dark.table-hover tbody tr:hover { background-color: #21262d; }

/* Custom badge for factions */
.bg-purple { background-color: #6f42c1 !important; }

/* Graph page */
.list-group-item.active { background-color: #21262d !important; border-color: #dc3545 !important; }

/* Audio player */
.audio-player { animation: fadeIn 0.2s ease-in; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Scrollbar dark styling */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #0d1117; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 10px;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ── XRef Links ─────────────────────────────────────────────────── */
.xref-link {
    color: #58a6ff;
    text-decoration: none;
    border-bottom: 1px dotted rgba(88,166,255,0.4);
    transition: color 0.1s, border-color 0.1s;
}
.xref-link:hover { color: #79c0ff; border-bottom-color: #79c0ff; text-decoration: none; }
.xref-link.xref-character  { color: #79c0ff; }
.xref-link.xref-synthetic  { color: #d2a8ff; }
.xref-link.xref-place      { color: #7ee787; }
.xref-link.xref-faction    { color: #ffa657; }
.xref-link.xref-corponation { color: #f85149; }
.xref-link.xref-technology { color: #56d364; }
.xref-link.xref-vocabulary { color: #e3b341; border-bottom-style: dashed; }
.xref-link.xref-weapon     { color: #ff7b72; }
.xref-link.xref-equipment  { color: #aac8f5; }
.xref-link.xref-cyberware  { color: #d2a8ff; }

/* ── Entity Type Badges ──────────────────────────────────────────── */
.entity-detail-type-badge,
.search-result-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.badge-character  { background: rgba(88,166,255,0.15);  color: #79c0ff;  border: 1px solid rgba(88,166,255,0.3); }
.badge-synthetic  { background: rgba(210,168,255,0.15); color: #d2a8ff;  border: 1px solid rgba(210,168,255,0.3); }
.badge-place      { background: rgba(126,231,135,0.15); color: #7ee787;  border: 1px solid rgba(126,231,135,0.3); }
.badge-faction    { background: rgba(255,166,87,0.15);  color: #ffa657;  border: 1px solid rgba(255,166,87,0.3); }
.badge-corponation { background: rgba(248,81,73,0.15);  color: #f85149;  border: 1px solid rgba(248,81,73,0.3); }
.badge-technology { background: rgba(86,211,100,0.15);  color: #56d364;  border: 1px solid rgba(86,211,100,0.3); }
.badge-vocabulary { background: rgba(227,179,65,0.15);  color: #e3b341;  border: 1px solid rgba(227,179,65,0.3); }
.badge-weapon     { background: rgba(255,123,114,0.15); color: #ff7b72;  border: 1px solid rgba(255,123,114,0.3); }
.badge-equipment  { background: rgba(170,200,245,0.15); color: #aac8f5;  border: 1px solid rgba(170,200,245,0.3); }
.badge-cyberware  { background: rgba(210,168,255,0.15); color: #d2a8ff;  border: 1px solid rgba(210,168,255,0.3); }
.badge-document   { background: rgba(139,148,158,0.15); color: #8b949e;  border: 1px solid rgba(139,148,158,0.3); }

/* ── XRef Chips ──────────────────────────────────────────────────── */
.xref-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.xref-chip {
    display: inline-block; padding: 2px 10px; border-radius: 12px;
    font-size: 0.75rem; text-decoration: none;
    color: #58a6ff; background: rgba(88,166,255,0.08);
    border: 1px solid rgba(88,166,255,0.3);
    transition: background 0.1s;
}
.xref-chip:hover { background: rgba(88,166,255,0.18); text-decoration: none; color: #79c0ff; }
.xref-chip.xref-character { color: #79c0ff; border-color: rgba(121,192,255,0.3); background: rgba(121,192,255,0.08); }
.xref-chip.xref-synthetic { color: #d2a8ff; border-color: rgba(210,168,255,0.3); background: rgba(210,168,255,0.08); }
.xref-chip.xref-place     { color: #7ee787; border-color: rgba(126,231,135,0.3); background: rgba(126,231,135,0.08); }
.xref-chip.xref-faction   { color: #ffa657; border-color: rgba(255,166,87,0.3);  background: rgba(255,166,87,0.08); }
.xref-chip.xref-unknown   { color: #8b949e; border-color: rgba(139,148,158,0.3); background: rgba(139,148,158,0.08); }

/* ── Entity Detail Page ──────────────────────────────────────────── */
.entity-detail-page { max-width: 860px; padding-bottom: 40px; }
.entity-detail-header {
    padding-bottom: 16px; margin-bottom: 20px;
    border-bottom: 1px solid #21262d;
    display: flex; flex-direction: column; gap: 6px;
}
.entity-detail-nav { margin-bottom: 4px; }
.entity-detail-name { font-size: 1.6rem; font-weight: 700; margin: 0; color: #e6edf3; }
.entity-detail-subtitle { font-size: 0.85rem; margin-top: 2px; }
.entity-detail-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.entity-tag {
    font-size: 0.65rem; padding: 1px 7px;
    background: #21262d; border-radius: 3px;
    color: #8b949e; border: 1px solid #30363d;
    text-decoration: none;
}
a.entity-tag-link:hover { background: #30363d; color: #e6edf3; border-color: #58a6ff; text-decoration: none; }
.ev-tag-link { text-decoration: none; }
.ev-tag-link:hover { background: #30363d !important; color: #e6edf3 !important; border-color: #58a6ff !important; }
/* EditViewToggle header */
.ev-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; border-bottom: 1px solid #30363d; padding: 4px 0 10px; }
.ev-header-title { flex-grow: 1; margin: 0; padding: 2px 0; color: #dc3545; font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-detail-body { display: flex; flex-direction: column; gap: 20px; }
.entity-section { display: flex; flex-direction: column; gap: 6px; }
.entity-section-label {
    font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; color: #8b949e;
}
.entity-section p { margin-bottom: 0.6rem; line-height: 1.65; }
.entity-meta-row {
    display: flex; flex-wrap: wrap; gap: 16px;
    padding: 10px 0;
    border-top: 1px solid #21262d; border-bottom: 1px solid #21262d;
}
.entity-meta-item { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; }
.entity-meta-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.06em; color: #8b949e; }
.entity-list { padding-left: 1.2rem; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.entity-list li { line-height: 1.5; }
.entity-relationship {
    padding: 8px 0; border-bottom: 1px solid #21262d;
    display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline;
}
.entity-relationship:last-child { border-bottom: none; }
.entity-rel-name { font-weight: 600; }
.entity-rel-type { font-size: 0.75rem; }
.entity-rel-desc { width: 100%; font-size: 0.85rem; margin-top: 2px; }
.entity-notable-loc {
    padding: 8px 10px; background: #161b22;
    border: 1px solid #21262d; border-radius: 4px; margin-bottom: 6px;
}
.entity-example {
    border-left: 3px solid #30363d; padding-left: 12px;
    color: #8b949e; font-style: italic; margin: 0;
}

/* ── Search Overlay ──────────────────────────────────────────────── */
.search-overlay-backdrop {
    position: fixed; inset: 0;
    background: rgba(1,4,9,0.75);
    backdrop-filter: blur(2px);
    z-index: 9998;
}
.search-overlay-panel {
    position: fixed; top: 15vh; left: 50%; transform: translateX(-50%);
    width: min(640px, 90vw); background: #161b22;
    border: 1px solid #30363d; border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    z-index: 9999; overflow: hidden;
}
.search-overlay-input-row {
    display: flex; align-items: center;
    padding: 12px 16px; gap: 10px;
    border-bottom: 1px solid #21262d;
}
.search-overlay-icon { color: #8b949e; font-size: 1rem; flex-shrink: 0; }
.search-overlay-input {
    flex: 1; background: none; border: none; outline: none;
    color: #e6edf3; font-size: 1rem; font-family: inherit;
}
.search-overlay-input::placeholder { color: #484f58; }
.search-overlay-clear {
    background: none; border: none; color: #8b949e;
    cursor: pointer; padding: 0; line-height: 1; font-size: 1rem; display: flex;
}
.search-overlay-clear:hover { color: #e6edf3; }
.search-overlay-results { max-height: 420px; overflow-y: auto; }
.search-overlay-result {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 10px 16px; cursor: pointer; gap: 12px;
    transition: background 0.05s;
}
.search-overlay-result:hover, .search-overlay-result.selected { background: #21262d; }
.search-result-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.search-result-name {
    font-size: 0.9rem; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; color: #e6edf3;
}
.search-result-sub {
    font-size: 0.75rem; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
    flex-shrink: 0; max-width: 220px;
}
.search-overlay-footer {
    padding: 8px 16px; border-top: 1px solid #21262d; font-size: 0.75rem;
}
.search-overlay-footer kbd {
    background: #21262d; border: 1px solid #30363d;
    border-radius: 3px; padding: 0 4px;
    font-size: 0.7rem; color: #8b949e;
}
.search-overlay-empty, .search-overlay-hint {
    padding: 24px 16px; text-align: center; font-size: 0.85rem;
}

/* ── Entity links in rich editor ─────────────────────── */
.entity-link {
    cursor: pointer;
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 500;
    transition: background 0.15s, filter 0.15s;
}
.entity-link:hover { filter: brightness(1.4); text-decoration: underline; }
.hide-links .entity-link { color: inherit; background: none; cursor: text; pointer-events: none; }
.hide-links .entity-link:hover { filter: none; text-decoration: none; }
.entity-character    { color: #17a2b8; background: rgba(23,162,184,0.12); }
.entity-organization { color: #ffc107; background: rgba(255,193,7,0.12); }
.entity-place        { color: #28a745; background: rgba(40,167,69,0.12); }
.entity-faction      { color: #6f42c1; background: rgba(111,66,193,0.12); }
.entity-weapon       { color: #dc3545; background: rgba(220,53,69,0.12); }
.entity-equipment    { color: #0d6efd; background: rgba(13,110,253,0.12); }
.entity-technology   { color: #0dcaf0; background: rgba(13,202,240,0.12); }
.entity-unknown      { color: #6c757d; background: rgba(108,117,125,0.12); }

/* ── Chapter breaks in rich editor ───────────────────── */
.chapter-break {
    user-select: none;
    margin: 1.5rem 0;
}
.chapter-break .chapter-title {
    font-family: Georgia, serif;
    letter-spacing: 0.05em;
}

/* ── Rich editor surface ─────────────────────────────── */
.rich-editor {
    font-family: Georgia, serif;
    font-size: 16px;
    line-height: 1.8;
    outline: none;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}
.rich-editor:focus, .form-control.rich-editor:focus { box-shadow: none; outline: none; }
.rich-editor p { margin-bottom: 1em; }
.rich-editor h1, .rich-editor h2, .rich-editor h3 { color: #f8f9fa !important; margin-top: 1.5em; margin-bottom: 0.5em; }
.rich-editor h1 { font-size: 1.4rem; color: #dc3545 !important; }
.rich-editor h2 { font-size: 1.15rem; }
.rich-editor h3 { font-size: 1rem; }
.rich-editor hr {
    border: none;
    text-align: center;
    margin: 1.5em 0;
    page-break-after: avoid;
    break-after: avoid;
}
.rich-editor hr::after {
    content: "* * *";
    color: #ff8c00;
    font-size: 0.9rem;
    letter-spacing: 0.3em;
}
.rich-editor span[style], .rich-editor h2 span[style] {
    background-color: transparent !important;
    color: inherit !important;
    font-size: inherit !important;
}

/* ── Entity popover ──────────────────────────────────── */
.entity-popover {
    position: fixed;
    z-index: 1060;
    max-width: 400px;
    max-height: 300px;
    overflow-y: auto;
    animation: fadeIn 0.15s ease-in;
}

/* ── View mode tabs ──────────────────────────────────── */
.view-tabs .btn.active { background-color: #21262d !important; border-color: #dc3545 !important; }

/* ── Standard 32x32 toolbar buttons ──────────────────── */
.tb {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.bg-cyan { background-color: #0dcaf0 !important; }

/* ── 3-pane dictionary layout ────────────────────────── */
.dict-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - var(--topnav-height) - var(--gutter) - 56px);
}
.dict-nav {
    width: 180px;
    flex-shrink: 0;
    overflow-y: auto;
}
.dict-list {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dict-controls,
.dict-list > .card {
    flex: 0 0 auto !important;
}
.dict-list > .card { padding: 4px 6px !important; }
.dict-items {
    flex: 1;
    overflow-y: auto;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
}
.dict-editor {
    flex: 1;
    padding: 0 10px;
    overflow-y: auto;
}
.dict-editor textarea,
textarea.auto-grow {
    resize: none !important;
    overflow: hidden;
    min-height: 2.5rem;
    height: auto;
}
.dict-editor .field-label {
    color: #9ca3af;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}
.dict-list .list-item {
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #21262d;
    border-left: 3px solid transparent;
    transition: background 0.1s;
}
.dict-list .list-item:hover { background: #21262d; }
.dict-list .list-item.active { background: #21262d; border-left-color: #dc3545; }
/* ── Mobile: dict list becomes a swipe-up drawer with visible tab ── */
@media (max-width: 767.98px) {
    .dict-layout { flex-direction: column !important; height: calc(100vh - var(--topnav-height) - var(--gutter)) !important; }
    .dict-list {
        position: fixed !important; bottom: 0; left: 0; right: 0; width: auto !important;
        height: 65vh; z-index: 1040; background: #0d1117;
        border-top: 2px solid #30363d; border-radius: 14px 14px 0 0;
        /* Show 40px tab even when closed so user sees the handle */
        transform: translateY(calc(100% - 40px));
        transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
        padding: 0 10px 10px; overflow: hidden;
        cursor: pointer;
    }
    /* Tab handle area — always visible */
    .dict-list::before {
        content: ''; display: block; width: 40px; height: 4px;
        background: #484f58; border-radius: 2px; margin: 10px auto 6px;
        flex-shrink: 0; transition: background 0.15s;
    }
    .dict-list:hover::before { background: #8b949e; }
    .dict-list.dict-list-open { transform: translateY(0); cursor: default; }
    /* Hide subtitle/role text in list items on mobile — names only */
    .dict-list .list-item .text-muted { display: none; }
    .dict-editor { flex: 1; overflow-y: auto; padding: 0 0 56px !important; }
}
@media (min-width: 768px) { .dict-drawer-fab { display: none !important; } }

/* ReadOnly mode: hide New buttons and export buttons across all dictionary pages */
.readonly-mode .dict-list .btn-outline-danger { display: none !important; }
/* ── GeoMap entity detail map ─────────────────────────────────────────── */
.geo-map-container {
    width: 100%;
    border-radius: 6px;
    border: 1px solid #30363d;
    overflow: hidden;
    margin-bottom: 0.25rem;
}
.geo-map-placeholder {
    padding: 10px 12px;
    border: 1px solid #30363d;
    border-radius: 6px;
    background: #161b22;
}

/* ── Search results ──────────────────────────────────────────────────────── */
.search-result-card:hover .card { border-color: #6c757d !important; }
.search-snippet { white-space: pre-wrap; max-height: 3.2em; overflow: hidden; }
.search-tag-pill {
    background: #21262d;
    color: #8b949e;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 0.65rem;
    transition: background 0.1s, color 0.1s;
}
.search-tag-pill:hover { background: #dc3545; color: #fff; }

/* ── Blazored.Toast dark theme overrides ─────────────────────────────────── */
.blazored-toast-container {
    z-index: 10000;
}
.blazored-toast {
    background: #161b22 !important;
    border: 1px solid #30363d !important;
    border-radius: 6px !important;
    color: #e6edf3 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6) !important;
    font-family: inherit !important;
    padding: 0.75rem 1rem !important;
}
.blazored-toast.blazored-toast-warning {
    border-left: 4px solid #e3b341 !important;
}
.blazored-toast.blazored-toast-error {
    border-left: 4px solid #dc3545 !important;
}
.blazored-toast.blazored-toast-info {
    border-left: 4px solid #388bfd !important;
}
.blazored-toast.blazored-toast-success {
    border-left: 4px solid #3fb950 !important;
}
.blazored-toast .blazored-toast-close {
    color: #8b949e !important;
    opacity: 1 !important;
}
.blazored-toast .blazored-toast-close:hover {
    color: #e6edf3 !important;
}
.blazored-toast .blazored-toast-title {
    color: #e6edf3 !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
}
.blazored-toast .blazored-toast-message {
    color: #8b949e !important;
    font-size: 0.8rem !important;
}

/* ── Category board tiles ──────────────────────────────────────────────── */
.board-grid { display: flex; flex-wrap: wrap; gap: 16px; padding: 4px 0 24px; }
.board-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 140px; height: 120px; background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 16px 12px 20px; text-decoration: none; color: #e6edf3; gap: 8px; transition: background 0.12s, border-color 0.12s; position: relative; }
.board-tile:hover { background: #1c2128; border-color: #dc3545; color: #fff; text-decoration: none; }
.board-tile-icon { font-size: 2rem; color: #dc3545; }
.board-tile-name { font-size: 0.8rem; font-weight: 500; text-align: center; line-height: 1.3; }
.board-tile-count { position: absolute; bottom: 7px; right: 10px; font-size: 0.65rem; color: #8b949e; }

/* ── Topnav split dropdown (label = board link, caret = toggle) ─────────── */
.topnav-split-drop { display: inline-flex; align-items: stretch; }
.topnav-split-caret { padding: 0 5px !important; min-width: unset !important; }
.topnav-split-caret::after { margin-left: 0; vertical-align: 0.15em; }

/* ── Topnav category icon ──────────────────────────────────────────────── */
.topnav-cat-icon { font-size: 0.75rem; margin-right: 4px; opacity: 0.8; }
