/* Shared admin layout and controls. Tabler supplies the base components. */
.stat-card { background: #fff; border-radius: 8px; padding: 1.25rem 1rem; text-align: left; box-shadow: none; border: 1px solid var(--admin-line); }
.stat-card h3 { margin: 0; font-size: 1.6rem; font-weight: 700; color: var(--admin-ink); font-variant-numeric: tabular-nums; }
.stat-card p { margin: 0.375rem 0 0; color: var(--admin-muted); font-size: .8125rem; font-weight: 500; text-transform: none; letter-spacing: normal; }
.stat-card-highlight { background: #f0fdf4; }
.stat-card-highlight h3 { color: #166534; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #a16207; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #dbeafe; color: #2563eb; }
.badge-secondary { background: #f1f5f9; color: #64748b; }
.truncate { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.truncate-wide { max-width: 300px; }
.text-positive { color: #15803d; }
.text-negative { color: #dc2626; }
.muted-note { color: var(--tblr-secondary); }
.flash { border: 1px solid var(--tblr-border-color); margin-bottom: 1rem; }
.flash-ok { border-color: #16a34a; }
.flash-error { border-color: #dc2626; }
.grid-auto-fit-180 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.grid-two-auto-end { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.inline-form { display: inline-flex; margin: 0; }
.form-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.compact-field { margin: 0 !important; }
.input-wide { min-width: 220px; }
.form-gap-md { margin: 16px 0; }
.field-stack { display: flex; flex-direction: column; gap: 0.5rem; }
.flag-stack { display: flex; flex-direction: column; gap: 0.35rem; }
.filters { display: flex; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: flex-end; }
.filters > * { margin-bottom: 0; }
.section-header-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-header-row > * { margin: 0; }
.page-title-row { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-title-row h1 { margin: 0; }
.page-section,
        .editor-row,
        [id$="-section"],
        [id$="-list"] { scroll-margin-top: 1rem; }
.row-actions-cell { white-space: nowrap; width: 1%; vertical-align: top; }
.row-editor-form { margin: 0; display: inline-flex; align-items: flex-start; justify-content: flex-end; flex-wrap: wrap; }
.editor-table table td { vertical-align: top; }
.editor-table table td > code { white-space: nowrap; }
.switch-inline { display: flex; align-items: center; gap: 0.5rem; }
.avatar-fallback { display: inline-flex; align-items: center; justify-content: center; background: #cbd5e1; color: #334155; font-weight: 600; }
.avatar-lg { width: 64px; height: 64px; margin-right: 1rem; vertical-align: middle; }
.inline-title { display: inline; vertical-align: middle; }
.icon-inline { width: 12px; height: 12px; display: inline; vertical-align: -1px; }
.icon-inline-sm { width: 14px; height: 14px; display: inline; vertical-align: -2px; }
.icon-inline-md { width: 18px; height: 18px; }
.icon-inline-lg { width: 20px; height: 20px; }
.btn-compact { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.actions { display: flex; gap: 0.375rem; align-items: center; }
.actions button, .actions a { padding: 0.25rem 0.625rem; font-size: 0.75rem; }
.pagination { gap: 0.5rem; justify-content: center; margin-top: 1.25rem; }
.lang-toggle { display: flex; gap: 0.375rem; background: rgba(255,255,255,0.08); border-radius: 6px; padding: 0.25rem; }
.lang-toggle a { flex: 1; padding: 0.3125rem 0; border-radius: 4px; font-size: .75rem; font-weight: 600; text-decoration: none; color: #c3cedc; transition: background .15s ease, color .15s ease; text-align: left; min-height: 32px; display: flex; align-items: center; justify-content: center; }
.lang-toggle a:hover { background: rgba(255,255,255,0.1); color: #e2e8f0; }
.lang-toggle a.active-lang { background: var(--tblr-primary); color: #fff; box-shadow: none; }
.i18n-field-group { display: flex; align-items: flex-start; gap: 6px; margin-bottom: 4px; }
.i18n-label { display: inline-block; min-width: 24px; padding: 4px 0; font-size: 11px; font-weight: 600; color: #6c757d; text-transform: uppercase; flex-shrink: 0; }
.i18n-other summary { cursor: pointer; font-size: 12px; color: #6c757d; padding: 2px 0; }
.i18n-other summary:hover { color: #495057; }
.uuid-short { cursor: help; font-family: monospace; font-size: 0.8125rem; }
.section-collapse { border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 1rem; background: #fff; overflow: hidden; }
.section-collapse-header { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; cursor: pointer; user-select: none; transition: background 0.15s ease; min-height: 48px; }
.section-collapse-header:hover { background: #f1f5f9; }
.section-collapse-header h3 { margin: 0; font-size: 0.9375rem; font-weight: 600; }
.section-collapse-chevron { transition: transform 0.2s ease; color: #94a3b8; }
.section-collapse.collapsed .section-collapse-chevron { transform: rotate(-90deg); }
.section-collapse.collapsed .section-collapse-body { display: none; }
.section-collapse-body { padding: 0; }
.section-collapse-body > .row,
        .section-collapse-body > .card,
        .section-collapse-body > .table-responsive,
        .section-collapse-body > .btn-list,
        .section-collapse-body > p { margin: 1rem; }
.section-collapse-body > .table-responsive { margin: 0; }
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none; max-width: calc(100vw - 2rem); }
.toast-item { pointer-events: auto; min-width: 0; max-width: 100%; padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.8125rem; font-weight: 400; box-shadow: 0 4px 12px rgba(0,0,0,0.12); display: flex; align-items: flex-start; gap: 0.5rem; width: 360px; overflow-wrap: anywhere; }
.toast-item.toast-ok { background: #dcfce7; color: #15803d; }
.toast-item.toast-error { background: #fee2e2; color: #dc2626; }
.btn-saving { pointer-events: none; opacity: .65; }
.badge.bg-azure { background: #0369a1 !important; color: #fff !important; }
.badge.bg-purple { background: #7c3aed !important; color: #fff !important; }
.badge-source { background: #e0f2fe; color: #075985; }
.badge-signal-count { background: #f1f5f9; color: #475569; }
:root { --admin-ink: #263348; --admin-muted: #526176; --admin-line: #dbe2ea; --admin-surface: #f5f7fa; --admin-focus: #206bc4; }
body { color: var(--admin-ink); background: var(--admin-surface); font-size: .875rem; }
[hidden] { display: none !important; }
::selection { background: #dce9fb; color: #173d73; }
a { text-underline-offset: .18em; }
input, textarea { caret-color: var(--admin-focus); }
:focus-visible { outline: 2px solid var(--admin-focus); outline-offset: 3px; }
.form-control::placeholder { color: var(--admin-muted); opacity: 1; }
.page-title { font-size: 1.5rem; line-height: 1.3; font-weight: 650; }
.page-body { margin-top: 1.5rem; }
.card { box-shadow: none; border-color: var(--admin-line); }
.admin-sidebar .navbar-brand { justify-content: flex-start; gap: .625rem; padding: 1.5rem 1.25rem; font-size: 1.125rem; text-align: left; line-height: 1.3; }
.admin-sidebar .navbar-brand svg { width: 30px; height: 30px; flex-shrink: 0; }
.admin-sidebar .navbar-brand small { display: block; font-size: .75rem; font-weight: 400; color: #b5c2d3; margin-top: .125rem; }
.admin-navigation { width: 100%; padding: 0 .75rem; }
.nav-search { margin-bottom: .875rem; font-size: .8125rem; }
.nav-search::placeholder { color: #b5c2d3; }
.nav-group { margin-bottom: .375rem; }
.nav-group summary { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .625rem .5rem; color: #b5c2d3; cursor: pointer; font-size: .75rem; font-weight: 600; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary svg { width: 14px; height: 14px; transition: transform .15s ease; }
.nav-group:not([open]) summary svg { transform: rotate(-90deg); }
.admin-sidebar .nav-link { padding: .625rem .75rem !important; border-radius: 6px; gap: .625rem; min-height: 40px; font-size: .8125rem; color: #d6dfec; }
.admin-sidebar .nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.admin-sidebar .nav-link.active { color: #fff; background: #2b4261; font-weight: 600; }
.admin-sidebar .nav-link:hover { color: #fff; background: #29384d; }
.admin-sidebar .nav-link.active:hover { background: #2b4261; }
.sidebar-footer { width: 100%; padding: 1rem 1.25rem; }
.nav-empty { color: #c3cedc; padding: .5rem; }
.skip-link { position: fixed; top: .5rem; left: .5rem; transform: translateY(-200%); padding: .75rem; background: #fff; z-index: 10000; }
.skip-link:focus { transform: none; }
.table { font-variant-numeric: tabular-nums; }
.table thead th { color: var(--admin-muted); font-size: .75rem; letter-spacing: normal; text-transform: none; }
.table td { padding-top: .875rem; padding-bottom: .875rem; }
.table tbody tr:hover { background: #f8fafc; }
.table tbody .btn-list { display: table-cell; white-space: nowrap; }
.table td[colspan] { color: var(--admin-muted); font-style: normal; padding: 2.5rem 1rem; }
.editor-table .table td { min-width: 100px; }
.editor-table .row-actions-cell { position: sticky; right: 0; background: #fff; min-width: 120px; }
.editor-table .is-dirty .row-actions-cell { background: #eff6ff; }
.editor-table .form-feedback { max-width: 150px; }
.form-feedback { display: block; flex-basis: 100%; font-size: .8125rem; margin-top: .5rem; overflow-wrap: anywhere; max-width: 100%; }
.toast-close { margin-left: auto; background: transparent; border: 0; color: inherit; min-width: 28px; min-height: 28px; font-size: .75rem; }
.section-collapse-header:focus-visible { outline-offset: -3px; }
.filters .form-control, .filters .form-select { width: auto; min-width: 160px; }
@media (min-width: 992px) {
.admin-sidebar .container-fluid { height: 100%; flex-wrap: nowrap; }
    .admin-sidebar #sidebar-menu { min-height: 0; flex: 1; overflow-y: auto; width: 100%; }
    .admin-sidebar { height: 100vh; height: 100dvh; }
}
@media (max-width: 991px) {
.admin-sidebar .navbar-brand { padding: .875rem .25rem; }
    .admin-sidebar #sidebar-menu { max-height: 75vh; overflow-y: auto; }
    .page-body { margin-top: 1rem; }
}
@media (max-width: 575px) {
.grid-two-auto-end { grid-template-columns: 1fr; }
    .grid-auto-fit-180 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .section-header-row { align-items: flex-start; flex-wrap: wrap; }
    .input-wide { min-width: 180px; }
    .filters > .form-control, .filters > .form-select { width: 100%; max-width: none !important; }
    .btn { min-height: 36px; }
    .actions { flex-wrap: wrap; }
    .stat-card { padding: 1rem; }
    .pagination { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* User inventory. */
.inv-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:12px; margin-bottom:16px; }
.inv-card { border:1px solid var(--tblr-border-color,#e6e7e9); border-radius:10px; padding:12px; display:flex; flex-direction:column; gap:8px; background:var(--tblr-bg-surface,#fff);  }
.inv-card-head { display:flex; gap:10px; align-items:flex-start; }
.inv-card-icon { width:48px; height:48px; flex-shrink:0; background:#f4f5f7; border-radius:8px; display:flex; align-items:center; justify-content:center; overflow:hidden; }
.inv-card-icon img { width:100%; height:100%; object-fit:contain; padding:4px; }
.inv-card-icon-empty { color:#526176; font-size:10px; }
.inv-card-title { font-weight:600; font-size:13px; line-height:1.25; margin:0; }
.inv-card-meta { font-size:11px; color:var(--tblr-muted,#8a929d); margin-top:2px; }
.inv-rarity { text-transform:capitalize; }
.inv-rarity-common    { color:#6c757d; }
.inv-rarity-rare      { color:#3055c8; }
.inv-rarity-epic      { color:#8e44ad; }
.inv-rarity-legendary { color:#99510f; }
.inv-rarity-mythic    { color:#d63384; }
.inv-rarity-relic     { color:#c0392b; }
.inv-stats { display:flex; flex-wrap:wrap; gap:4px; font-size:11px; }
.inv-stat  { padding:2px 6px; border-radius:4px; background:#f0f1f3; color:#404750; }
.inv-stat.pathos  { background:#ffe9e2; color:#c0392b; }
.inv-stat.reason  { background:#e3ecff; color:#2255bb; }
.inv-stat.voice   { background:#e0f8eb; color:#2d7d4a; }
.inv-stat.price-q { background:#f0f3f7; color:#5a6672; }
.inv-stat.price-e { background:#fbf3d6; color:#7a5b00; }
.inv-card-footer { display:flex; justify-content:space-between; align-items:center; border-top:1px solid #eef; padding-top:6px; margin-top:auto; }

/* Compact controls still have a comfortable click target. */
.btn-sm, .btn-compact, .actions button, .actions a { padding: .375rem .625rem; min-height: 32px; font-size: .8125rem; }
.pagination { align-items: center; }
.user-search-field { width: min(100%, 32rem); }
.user-search-field .form-control { width: 100%; }
.badge.bg-success, .badge.bg-green { background: #dcfce7 !important; color: #166534 !important; }
.badge.bg-info, .badge.bg-blue, .badge.bg-primary { background: #dbeafe !important; color: #1e40af !important; }
.badge.bg-warning, .badge.bg-orange { background: #fef3c7 !important; color: #854d0e !important; }
.badge.bg-danger, .badge.bg-red { background: #fee2e2 !important; color: #991b1b !important; }
.badge.bg-secondary, .badge-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.pagination .disabled .page-link { color: var(--admin-muted); }
.table-responsive:focus-visible { outline-offset: -2px; }

/* Content editors (Expedition routes first; Archive and Portals reuse these). */
.back-link { display: inline-flex; align-items: center; gap: .25rem; color: var(--admin-muted); font-size: .8125rem; margin-bottom: .25rem; text-decoration: none; }
.back-link:hover { color: var(--admin-focus); }
.back-link svg { width: 14px; height: 14px; }
.page-subtitle { margin: .25rem 0 0; color: var(--admin-muted); }
.btn svg { width: 16px; height: 16px; margin-right: .25rem; }
.btn-icon svg { margin-right: 0; }
.lang-tag { display: inline-block; padding: 0 .3rem; border-radius: 4px; background: var(--admin-surface); border: 1px solid var(--admin-line); color: var(--admin-muted); font-size: .6875rem; font-weight: 600; letter-spacing: .02em; vertical-align: 1px; }
.form-hint { color: var(--admin-muted); font-size: .8125rem; margin-top: .25rem; max-width: 70ch; }
.card-header .card-title { font-size: 1rem; font-weight: 650; margin: 0; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filter-bar .form-select { width: auto; min-width: 10rem; }
.filter-bar input[type="date"] { width: auto; }
.filter-search { flex: 1 1 14rem; max-width: 22rem; }
.filter-bar.is-autosubmit .filter-submit { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tabular { font-variant-numeric: tabular-nums; }
.routes-table td, .routes-table th { white-space: nowrap; }
.routes-table .route-name { white-space: normal; min-width: 12rem; font-weight: 600; }
.tier-facts { max-width: 46rem; }
.tier-facts caption { color: var(--admin-muted); font-size: .8125rem; padding-top: 0; }
.tier-facts th, .tier-facts td { padding: .375rem .625rem; }
.tier-facts tr.is-current > * { background: #eef4fc; font-weight: 600; }
.loot-table { max-width: 40rem; }
.loot-table th, .loot-table td { padding: .375rem .625rem; vertical-align: middle; }
.loot-table .loot-weight { min-width: 5.5rem; max-width: 8rem; }
.loot-table .form-select { min-width: 14rem; }
.loot-chance { color: var(--admin-muted); font-variant-numeric: tabular-nums; min-width: 4rem; }
.loot-ignored-note { display: block; color: var(--admin-muted); font-size: .75rem; font-weight: 400; }
tr.is-ignored th, tr.is-ignored .loot-chance { color: var(--admin-muted); }
.loot-weight[readonly] { background: var(--admin-surface); color: var(--admin-muted); }
.form-actions-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; justify-content: space-between; padding: .75rem 1rem; margin: 0 -1rem; background: rgba(245, 247, 250, .96); border-top: 1px solid var(--admin-line); backdrop-filter: blur(4px); }
.form-actions-note { flex: 1 1 18rem; max-width: 36rem; }
.form-actions-note .form-label { margin-bottom: .25rem; font-size: .8125rem; }
.form-actions-buttons { display: flex; gap: .5rem; align-items: center; }
.hotkey-hint { margin-left: .5rem; padding: 0 .3rem; border-radius: 4px; background: rgba(255,255,255,.18); color: inherit; font-size: .6875rem; box-shadow: none; }
.history-when { white-space: nowrap; color: var(--admin-muted); font-variant-numeric: tabular-nums; }
.history-number { color: var(--admin-ink); font-weight: 600; margin-right: .25rem; }
.history-value { min-width: 9rem; max-width: 18rem; overflow-wrap: anywhere; }
.history-note { color: var(--admin-muted); max-width: 14rem; }
.history-revert { white-space: nowrap; }
.toast-close { font-size: 1.125rem; line-height: 1; white-space: nowrap; }
@media (max-width: 575.98px) {
    .filter-bar .form-select, .filter-search { flex: 1 1 100%; max-width: none; }
    .form-actions-bar { position: static; margin: 0 0 1rem; padding: .75rem 0; background: transparent; backdrop-filter: none; }
    .form-actions-buttons { width: 100%; justify-content: flex-end; }
    .hotkey-hint { display: none; }
}

/* Archive */
.archive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 1rem; }
.archive-chapter .card-title a { color: inherit; text-decoration: none; }
.archive-chapter .card-title a:hover { color: var(--admin-focus); }
.archive-theories { list-style: none; margin: 0; padding: .25rem 0; }
.archive-theories li { display: grid; grid-template-columns: 1fr auto; gap: 0 .75rem; padding: .5rem 1rem; border-top: 1px solid var(--admin-line); }
.archive-theories li:first-child { border-top: 0; }
.archive-theory-link { font-weight: 600; }
.archive-theory-meta { grid-column: 1; color: var(--admin-muted); font-size: .8125rem; }
.archive-counts { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--admin-muted); font-size: .8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.archive-counts .is-short { color: #b45309; font-weight: 600; }
.archive-table td, .archive-table th { vertical-align: top; }
.archive-row-meta { width: 12rem; min-width: 10rem; font-weight: 400; }
.archive-row-label { display: block; font-weight: 600; color: var(--admin-ink); }
.archive-row-hint { display: block; color: var(--admin-muted); font-size: .75rem; margin-top: .125rem; white-space: pre-line; }
.archive-row-link { display: inline-block; margin-top: .25rem; font-size: .8125rem; }
.archive-text { min-width: 18rem; line-height: 1.45; resize: vertical; overflow: hidden; }
.archive-current { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1rem; }
.archive-current p { margin: .25rem 0 0; white-space: pre-wrap; }
@media (max-width: 767.98px) {
    .archive-table thead { display: none; }
    .archive-table tr { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--admin-line); }
    .archive-table td, .archive-table th { display: block; width: auto; padding: .25rem 0; border: 0; }
    .archive-text { min-width: 0; }
    .editor-table.archive-table .row-actions-cell { position: static; }
}
.history-value del { background: #fde8e8; color: #9b1c1c; text-decoration: line-through; }
.history-value ins { background: #def7ec; color: #03543f; text-decoration: none; }

/* Story editor */
.story-head { align-items: flex-end; }
.story-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.story-status { color: var(--admin-muted); font-size: .8125rem; min-width: 14rem; text-align: right; }
.story-status[data-kind="error"] { color: #b91c1c; }
.story-status[data-kind="busy"] { color: var(--admin-focus); }
.story-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(24rem, 34rem); gap: 1rem; align-items: start; }
.story-graph-card { position: sticky; top: .75rem; }
.story-toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .5rem .75rem; border-bottom: 1px solid var(--admin-line); }
.story-toolbar input[type="search"] { flex: 1 1 14rem; max-width: 22rem; }
.story-toolbar select { width: auto; }
.story-graph { height: calc(100vh - 15rem); min-height: 28rem; background: #f8fafc; }
.story-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; margin: 0; padding: .5rem .75rem; border-top: 1px solid var(--admin-line); font-size: .75rem; color: var(--admin-muted); }
.legend-swatch { display: inline-block; width: 1.25rem; height: .75rem; margin-right: .35rem; vertical-align: -1px; border: 1px solid #94a3b8; border-radius: 3px; background: #fff; }
.legend-swatch.is-start { border: 2px solid #206bc4; }
.legend-swatch.is-end { background: #dcfce7; border-color: #16a34a; }
.legend-swatch.has-error { border: 2px solid #dc2626; background: #fff5f5; }
.legend-swatch.has-warning { border: 2px solid #d97706; }
.legend-swatch.has-conditions { border-style: dashed; }
.legend-swatch.has-dispute { clip-path: polygon(20% 0, 80% 0, 100% 50%, 80% 100%, 20% 100%, 0 50%); background: #cbd5e1; }
.story-side { background: #fff; border: 1px solid var(--admin-line); border-radius: 8px; max-height: calc(100vh - 6rem); display: flex; flex-direction: column; }
.story-tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--admin-line); }
.story-tabs button { flex: 1 1 auto; padding: .5rem .75rem; border: 0; background: transparent; color: var(--admin-muted); font-size: .8125rem; border-bottom: 2px solid transparent; }
.story-tabs button[aria-selected="true"] { color: var(--admin-ink); border-bottom-color: var(--admin-focus); font-weight: 600; }
.story-panel { padding: .75rem 1rem 1.5rem; overflow-y: auto; }
.story-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.story-pair .form-label { font-size: .75rem; margin-bottom: .125rem; }
.story-text { line-height: 1.4; resize: vertical; overflow: hidden; }
.story-choice { border: 1px solid var(--admin-line); border-radius: 8px; padding: .5rem .75rem .25rem; margin: .75rem 0; }
.story-choice > legend, .story-outcome > legend { float: none; width: auto; font-size: .8125rem; font-weight: 600; padding: 0 .25rem; margin: 0; }
.story-outcome { border-left: 3px solid #e2e8f0; padding: .25rem 0 .25rem .75rem; margin: .5rem 0; }
.story-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .5rem; }
.story-field { flex: 1 1 7rem; }
.story-field .form-label { font-size: .75rem; margin-bottom: .125rem; }
.story-field-wide { flex-basis: 100%; margin-bottom: .5rem; }
.story-json-small { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; }
.story-form-list { margin: .25rem 0 .5rem; }
.story-form-title { font-size: .75rem; font-weight: 600; color: var(--tblr-secondary, #64748b); margin-bottom: .25rem; }
.story-form-row { display: flex; align-items: flex-end; gap: .25rem; padding: .25rem 0; border-bottom: 1px dashed var(--admin-line); }
.story-form-fields { display: flex; flex-wrap: wrap; gap: .5rem; flex: 1 1 auto; min-width: 0; }
.story-form-field { flex: 1 1 8rem; min-width: 0; }
.story-form-field .form-label { font-size: .75rem; margin-bottom: .125rem; }
.story-form-wide { flex-basis: 100%; }
.story-form-remove { flex: none; line-height: 1; }
.story-form-list > .btn { margin-top: .25rem; }
.story-structure { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; margin: .25rem 0 .5rem; }
.story-key { flex: 1 1 12rem; max-width: 20rem; }
.story-key .form-label { font-size: .75rem; margin-bottom: .125rem; }
.story-key .form-control { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.story-key-error { font-size: .75rem; color: #b91c1c; min-height: 0; }
.story-key-error:empty { display: none; }
.story-structure-actions { display: flex; flex-wrap: wrap; gap: .25rem; }
.story-refs { flex-basis: 100%; font-size: .8125rem; color: #b91c1c; }
.story-refs:empty { display: none; }
.story-link-hint { font-size: .8125rem; color: #206bc4; }
.story-replay-fact { display: flex; align-items: center; gap: .375rem; }
.story-replay-fact .form-control { width: 14rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
[data-action="link"].active { color: #fff; }
.story-graph-wrap { position: relative; }
.story-minimap { position: absolute; right: .5rem; bottom: .5rem; width: 180px; height: 120px; background: #fff; border: 1px solid var(--admin-line); border-radius: 6px; overflow: hidden; cursor: crosshair; box-shadow: 0 2px 8px rgba(15, 23, 42, .12); touch-action: none; }
.story-minimap img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.story-minimap-view { position: absolute; border: 2px solid #206bc4; background: rgba(32, 107, 196, .08); pointer-events: none; }
.story-en-filter { font-size: .8125rem; white-space: nowrap; }
.story-json { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; min-height: 60vh; }
.story-issues, .story-issue-list { list-style: none; padding: 0; margin: .5rem 0; font-size: .8125rem; }
.story-issues li, .story-issue-list li { padding: .25rem 0; border-bottom: 1px dashed var(--admin-line); }
.story-issues .is-error, .story-issue-list .is-error { color: #b91c1c; }
.story-issues .is-warning { color: #92400e; }
.story-scene-list, .story-version-list { list-style: none; padding: 0; margin: 0; }
.story-scene-list li, .story-version-list li { padding: .25rem 0; border-bottom: 1px solid var(--admin-line); }
.story-en-badge:empty { display: none; }
@media (max-width: 1199.98px) {
    .story-layout { grid-template-columns: 1fr; }
    .story-graph-card { position: static; }
    .story-graph { height: 55vh; min-height: 20rem; }
    .story-side { max-height: none; }
    .story-pair { grid-template-columns: 1fr; }
}

/* Stories: section tabs and the opponent script buttons */
.stories-nav { display: flex; gap: .25rem; margin: 0 0 1rem; border-bottom: 1px solid var(--admin-line); }
.stories-nav a { padding: .5rem .75rem; color: inherit; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.stories-nav a:hover { color: #206bc4; }
.stories-nav a.active { border-bottom-color: #206bc4; color: #206bc4; font-weight: 600; }
.stories-dogma-buttons { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .375rem; }
.story-import-field { font-size: .8125rem; margin-bottom: .25rem; overflow-wrap: anywhere; }
.story-import-label { font-weight: 600; margin-right: .375rem; }
.story-import-table tr.is-skipped { color: var(--tblr-secondary, #64748b); }
.story-key .form-control.is-pending { border-color: #d97706; }

/* Currency emblems of the game (as in the app): an amount is the icon and a
   number, never a star or a letter. The glyph is a mask, so it takes a colour. */
.currency-icon { display: inline-block; width: 1.05em; height: 1.05em; vertical-align: -.17em; background-color: currentColor; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.currency-etalon { color: #a16207; -webkit-mask-image: url(/admin/static/currency-etalon.png); mask-image: url(/admin/static/currency-etalon.png); }
.currency-quantum { color: #0e7490; -webkit-mask-image: url(/admin/static/currency-quantum.png); mask-image: url(/admin/static/currency-quantum.png); }

/* The focus ring on the dark sidebar: the blue ring reads below 3:1 there. */
.admin-sidebar :focus-visible { outline-color: #fff; }

/* Combined forms of the user card (balance, path levels). */
.balance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); gap: .75rem 1rem; align-items: start; max-width: 48rem; }
.balance-submit { align-self: start; padding-top: 1.75rem; }
.id-line { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.id-line code { font-size: .8125rem; overflow-wrap: anywhere; }
form.is-autosave .autosave-submit { display: none; }
@media (max-width: 575.98px) { .balance-submit { padding-top: 0; } }

/* «Доступ в приложении»: collapsed card, one switch per row that saves at once. */
.feature-toggles > summary { display: flex; align-items: center; gap: .75rem; cursor: pointer; list-style: none; }
.feature-toggles > summary::-webkit-details-marker { display: none; }
.feature-toggles > summary .card-title { margin-right: auto; }
.feature-toggles-chevron { width: 16px; height: 16px; color: var(--admin-muted); transition: transform .15s ease; }
.feature-toggles:not([open]) .feature-toggles-chevron { transform: rotate(-90deg); }
.feature-toggles:not([open]) > summary { border-bottom: 0; }
.toggle-list { list-style: none; margin: 0 0 .75rem; padding: 0; }
.toggle-row { border-top: 1px solid var(--admin-line); padding: .5rem 0; scroll-margin-top: 1rem; }
.toggle-row:first-child { border-top: 0; }
.toggle-row form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 0; }
.toggle-row .form-check { flex: 1 1 18rem; }
.toggle-row .form-feedback { flex-basis: auto; margin-top: 0; }

/* Regalia bonus rows (stat · kind · value). */
.bonus-editor { display: flex; flex-direction: column; gap: .375rem; min-width: 12.5rem; }
.bonus-rows { display: flex; flex-direction: column; gap: .375rem; }
.bonus-row { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem; align-items: center; }
.bonus-row > input { grid-column: 1; }
.bonus-row > button { grid-column: 2; justify-self: start; }
.bonus-row + .bonus-row { border-top: 1px dashed var(--admin-line); padding-top: .375rem; }
.bonus-empty { margin: 0; color: var(--admin-muted); font-size: .8125rem; }
.bonus-editor > .btn { align-self: flex-start; }
.input-narrow { max-width: 10rem; }
.icon-preview { width: 72px; height: 72px; object-fit: contain; background: #f5f5f5; border: 1px solid var(--admin-line); border-radius: 6px; padding: 4px; }

/* RU/EN pairs: both fields visible, RU first, each with its language tag. */
.i18n-field-group > .lang-tag { flex-shrink: 0; min-width: 1.9rem; margin-top: .45rem; text-align: center; }
.i18n-field-group > .form-control { flex: 1 1 auto; }

/* History: «Вернуть» keeps its caption; the old value wraps under it. */
.history-table td:last-child { min-width: 10rem; }
.history-revert { white-space: normal; text-align: left; display: inline-flex; align-items: center; gap: .25rem; max-width: 16rem; }
/* Admin review 2026-10-15. Disputes: the sides column wraps names instead of
   stretching the table. */
.battles-table .battle-sides { min-width: 16rem; }
.battles-table .battle-vs { margin: 0 .375rem; }

/* Inline editors (Regalia, Conclave regalia, Push templates, Onboarding steps,
   Capabilities): fields keep a minimum width on the desktop, and below 768px
   every row is one card: the column heading above each field comes from
   data-label (admin.js) and the Save cell stops floating. */
.editor-table .form-control, .editor-table .form-select { min-width: 7rem; }
.editor-table .form-control.input-narrow { min-width: 4.5rem; max-width: 6rem; }
.editor-table .field-stack .form-label { margin-bottom: 0; font-size: .75rem; color: var(--admin-muted); }
@media (max-width: 767.98px) {
    .editor-table thead { display: none; }
    .editor-table tbody tr { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--admin-line); }
    .editor-table tbody td { display: block; width: auto; min-width: 0; padding: .25rem 0; border: 0; }
    .editor-table tbody td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--admin-muted); margin-bottom: .125rem; }
    .editor-table .row-actions-cell { position: static; background: transparent; width: auto; padding-top: .5rem; }
    .editor-table .is-dirty .row-actions-cell { background: transparent; }
    .editor-table .form-control, .editor-table .form-select, .editor-table .input-wide { min-width: 0; width: 100%; }
    .editor-table .form-control.input-narrow { max-width: 8rem; }
    .editor-table .i18n-field-group { align-items: center; }
}
/* Bonus rows sit in a narrow cell: their controls do not take the inline
   editors' minimum field width. */
.editor-table .bonus-row .form-control, .editor-table .bonus-row .form-select { min-width: 0; }
.editor-table .bonus-editor { min-width: 11rem; max-width: 14rem; }
@media (max-width: 767.98px) { .editor-table .bonus-editor { max-width: none; } }

/* Post page and comment moderation */
.post-content { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 70ch; }
.post-image { display: block; max-width: min(24rem, 100%); border-radius: 8px; margin-top: .75rem; }
.comment-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 14rem; max-width: 60ch; }

/* Архив: включение глав и фрагментов (2026-10-19). */
.archive-chapter-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.archive-switches { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; }
.archive-chapter-switch { display: inline-flex; align-items: center; gap: .5rem; }
.archive-switch { display: inline-flex; align-items: center; gap: .5rem; margin: 0; }
.archive-row-meta .archive-switch { margin-top: .375rem; }
.archive-row-off td:not(.row-actions-cell), .archive-row-off .archive-row-label, .archive-row-off .archive-row-hint { opacity: .55; }

/* Archive: year, level headings, post fields */
.archive-year { margin-left: .5rem; color: var(--admin-muted); font-size: .875rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.archive-open-note { margin: 0; padding: .25rem 1rem; }
.archive-level-row th { background: var(--admin-surface); font-size: .8125rem; font-weight: 600; letter-spacing: .02em; padding: .5rem 1rem; border-top: 1px solid var(--admin-line); }
.archive-meta { margin-top: .375rem; font-size: .8125rem; }
.archive-meta summary { cursor: pointer; color: var(--admin-muted); font-variant-numeric: tabular-nums; }
.archive-meta-form { display: grid; gap: .25rem; margin-top: .375rem; }
.archive-meta-form label { color: var(--admin-muted); font-size: .75rem; margin-top: .25rem; }
.archive-meta-form .btn { justify-self: start; margin-top: .375rem; }
