/* One browse-row layout, shared by all category adapters. */
.codex-entry-row.lrow {
  --codex-row-height:72px;
  display:flex;align-items:center;gap:10px;box-sizing:border-box;
  height:var(--codex-row-height);min-height:var(--codex-row-height);max-height:var(--codex-row-height);
  padding:10px 12px;margin:0;width:100%;min-width:0;
  border-radius:12px;background:var(--chart);overflow:hidden;
  font-family:system-ui,-apple-system,"Segoe UI",sans-serif;
  cursor:default;filter:none;opacity:1;
}
.codex-entry-row .codex-row-open {
  display:flex;align-items:center;gap:10px;min-width:0;height:100%;flex:1;
  border:0;background:transparent;padding:0;margin:0;color:inherit;font:inherit;text-align:left;
}
.codex-entry-row .lrow-text {display:flex;flex:1;flex-direction:column;justify-content:center;gap:3px;min-width:0}
.codex-entry-row .lrow-title {font:700 16px/22px system-ui,-apple-system,"Segoe UI",sans-serif;margin:0;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.codex-entry-row .lrow-sub {font:400 14px/21px system-ui,-apple-system,"Segoe UI",sans-serif;margin:0;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}
.codex-entry-row .lrow-end {display:flex;align-items:center;gap:6px;flex:0 1 auto;min-width:0;max-width:45%;margin:0}
.codex-entry-row .chip {font-family:inherit;font-size:14px;font-weight: var(--fw-body);line-height:21px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;flex:0 1 auto}
.codex-entry-row .codex-row-detail {font-size:14px;white-space:nowrap;flex:0 0 auto}
.codex-entry-row :is(.avatar,.codex-thread-marker) {width:44px;height:44px;flex:0 0 44px;min-width:44px;border-radius:9px;overflow:hidden;position:relative;margin:0}
.codex-entry-row .avatar img {width:100%;height:100%;object-fit:cover;display:block}
.codex-entry-row .codex-row-portrait {width:44px;height:44px;flex:0 0 44px;border:0;padding:0}
.codex-entry-row>.codex-row-pin {position:static;transform:none;flex:0 0 44px;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:50%;background:transparent;filter:grayscale(1);opacity:1}
.codex-entry-row>.codex-row-pin.on {background:#e0c57d;filter:none}
.codex-entry-row>.codex-row-pin.on.shared {background:#bedde3;box-shadow:inset 0 0 0 1px #75aeb9;filter:none}
.codex-entry-row .codex-thread-marker {display:grid;place-items:center;background:#e0c57d;color:var(--ink);font-size:18px}
.codex-entry-row.dead-row,.codex-entry-row[data-status="sunk"],.codex-entry-row[data-status="wrecked"],.codex-entry-row[data-status="destroyed"] {background:#d1cec3}
.codex-entry-row[data-status="squibbed"] {background:#e2e0cd}
.codex-entry-row[data-status="retired"] {background:#dedbc9}
.codex-entry-row[data-status="captured"] {background:#e2dcc2}
.codex-entry-row[data-status="missing"] {background:#eadcc3}
.codex-entry-row.codex-entry-item {--codex-row-height:62.4px;padding:8px 12px;border-left-width:4px}
.codex-entry-row.codex-entry-item .lrow-text {gap:1px}
.codex-entry-row :is(button):focus-visible {outline:2px solid var(--teal,#275f5c);outline-offset:-2px;border-radius:8px}
/* Columns respond to the actual available section width, including dashboard panels. */
#codexOverviewBody,#codexOverviewBody .codex-dashboard-grid>section {container-type:inline-size}
#codexOverviewBody :is(.lrow-list,.map-grid,.place-list,.codex-ship-grid) {display:grid;grid-template-columns:minmax(0,1fr);gap:10px;align-items:start}
#codexOverviewBody .lrow-list>.empty {grid-column:1/-1}
@container(min-width:640px) {
  #codexOverviewBody :is(.lrow-list,.map-grid,.place-list,.codex-ship-grid) {grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:460px) {
  .codex-entry-row.lrow {gap:7px;padding-inline:10px}
  .codex-entry-row .codex-row-open {gap:8px}
  .codex-entry-row .lrow-end {gap:4px;max-width:40%}
  .codex-entry-row .chip {padding-inline:7px}
  .codex-entry-row .lrow-day {display:none}
}

/* Keep category rails and section headers stable as list lengths change. */
html {scrollbar-gutter:stable}
#codexOverviewBody {overflow-anchor:none}
#codexOverviewBody>.section-title {display:flex;align-items:center;min-height:44px;box-sizing:border-box}
#codexOverviewBody {min-height:100dvh}

.codex-facet-controls{margin:12px 0 20px;border:1px solid var(--line);border-radius:10px;padding:0 12px;color:var(--muted)}
.codex-facet-controls>summary{padding:12px 0;min-height:44px;cursor:pointer;font-size:var(--ui-meta);font-weight: var(--fw-body)}
.codex-facet-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr));gap:12px;padding-bottom:12px}
.codex-facet-grid>div{min-width:0}.codex-facet-grid label{display:block;margin-bottom:6px;font-size:var(--ui-meta)}
.codex-facet-grid select{width:100%;min-width:0;min-height:44px;font-size:var(--ui-meta)}
.codex-facet-controls>.button{width:100%;margin-bottom:12px}

.codex-facet-controls>summary,.codex-facet-grid label{font-family:inherit;font-weight: var(--fw-body);letter-spacing:normal;text-transform:none;color:#d4c49d}

.codex-facet-controls[hidden]{display:none!important}.codex-filter-heading{padding:12px 0;font-size:14px;font-weight: var(--fw-body)}.codex-global-search #codexFilterToggle{flex:0 0 44px;display:grid;place-items:center;padding:8px;min-width:44px}.codex-global-search #codexFilterToggle.active{background:var(--gold);color:#211b10}
.codex-filter-heading{color:#d4c49d}

.codex-facet-controls .codex-facet-grid{padding-top:12px}

/* Codex browsing controls remain together beneath the campaign header. */
.codex-sticky-tools{position:sticky;top:var(--sticky-offset,0px);z-index:9;background:var(--deck);padding:10px 0 8px;margin-bottom:12px}
body.sticky-header-off .codex-sticky-tools{top:0}
.codex-sticky-tools .codex-type-chips{margin-bottom:0}

/* Campaign header always scrolls; only Codex tools stay pinned. */
.topbar{position:static!important;top:auto!important}
.codex-sticky-tools{top:0}
#codexStickyFilters .codex-facet-controls{margin:8px 0 0;max-height:40dvh;overflow-y:auto;overscroll-behavior:contain}

/* Filters use available width, with the Other category strip spanning the panel. */
.codex-facet-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,140px),1fr));gap:10px}
.codex-entry-kind{grid-column:1/-1}
.codex-filter-label{font-size:var(--ui-meta);font-weight: var(--fw-body);color:#d4c49d;margin-bottom:6px}
.codex-entry-kind-rail{margin:0;flex-wrap:nowrap;overflow-x:auto}
.codex-entry-kind-rail .fchip{flex:0 0 auto}

#codexOtherRail:not(:empty){margin-top:6px}#codexOtherRail .codex-entry-kind-rail{margin:0}#codexOtherRail .codex-entry-kind{min-width:0}#codexStickyFilters .codex-facet-grid:empty{display:none}

.codex-sticky-tools{padding-bottom:4px;margin-bottom:4px}
#codexOverviewBody>.section-title:first-child{margin-top:4px;margin-bottom:8px}

/* Native off-screen rendering: reuse the shared row height, including item rows.
   Unsupported browsers retain the normal layout. No virtualization dependency. */
@supports(content-visibility:auto){
  #codexOverviewBody .codex-entry-row{
    content-visibility:auto;
    contain-intrinsic-block-size:auto var(--codex-row-height);
  }
}
@media print{
  #codexOverviewBody .codex-entry-row{content-visibility:visible}
}

/* Match filter gutters to the shared 10px entry gap. */
#codexStickyFilters .codex-facet-controls{padding:0 10px;margin-top:10px}
#codexStickyFilters .codex-facet-grid{padding-top:10px;padding-bottom:10px;gap:10px}
#screen-codex .status-chips{cursor:grab}
#screen-codex .status-chips.is-mouse-dragging{cursor:grabbing;user-select:none}
#screen-codex .status-chips.is-mouse-dragging *{cursor:grabbing;user-select:none}

.codex-inventory-table{position:static;margin-bottom:10px}
.codex-inventory-table .section-title{margin:0 0 8px!important}
.codex-inventory-table .pitem-matrix{margin-bottom:0}
.codex-global-search #codexOverviewAdd{flex:0 0 44px;min-width:44px}
