/* Dashboard tokens on top of Tabler. Chart colours come from the validated dataviz palette; Tabler's
   surfaces are pointed at the same values so cards and chart canvases match exactly. */
:root {
  color-scheme: light;
  --page: #f6f6f4;
  --surface-1: #fcfcfb;
  --surface-2: #f1f0ec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent-wash: rgba(42, 120, 214, 0.10);
  --series-1: #2a78d6;  /* low class  */
  --series-2: #eb6834;  /* high class */
  --series-3: #1baf7a;  /* other      */
  /* Slots 4-8 continue the same validated categorical order (years in the trend chart). */
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --trend-up: #1a7f37; --trend-down: #c62828; --trend-flat: #9a6700;
  --dot-empty: #d6d5ce;
  --seq: #cde2fb, #9ec5f4, #6da7ec, #3987e5, #256abf, #184f95, #0d366b;

  --tblr-body-bg: var(--page);
  --tblr-bg-surface: var(--surface-1);
  --tblr-bg-surface-secondary: var(--surface-2);
  --tblr-border-color: #e3e2dc;
  --tblr-primary: #2a78d6;
  --tblr-primary-rgb: 42, 120, 214;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent-wash: rgba(57, 135, 229, 0.16);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  --trend-up: #3fb950; --trend-down: #f85149; --trend-flat: #d29922;
    --dot-empty: #33332f;
    --seq: #104281, #184f95, #256abf, #2a78d6, #5598e7, #86b6ef, #cde2fb;
    --tblr-border-color: #2c2c2a;
    --tblr-primary: #3987e5;
    --tblr-primary-rgb: 57, 135, 229;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent-wash: rgba(57, 135, 229, 0.16);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --trend-up: #3fb950; --trend-down: #f85149; --trend-flat: #d29922;
  --dot-empty: #33332f;
  --seq: #104281, #184f95, #256abf, #2a78d6, #5598e7, #86b6ef, #cde2fb;
  --tblr-body-bg: var(--page);
  --tblr-bg-surface: var(--surface-1);
  --tblr-bg-surface-secondary: var(--surface-2);
  --tblr-border-color: #2c2c2a;
  --tblr-primary: #3987e5;
  --tblr-primary-rgb: 57, 135, 229;
}

/* ------------------------------------------------------------- header */

.topbar { z-index: 1030; background: var(--surface-1); border-bottom: 1px solid var(--tblr-border-color); }
.topbar .navbar { background: transparent; border: 0; min-height: 3.5rem; padding: .375rem 0; }
.brand-mark { color: var(--series-1); flex: none; }
.brand-name { font-weight: 650; font-size: 1rem; letter-spacing: -0.01em; }
.brand-sub { font-size: .75rem; color: var(--text-muted); font-weight: 400; margin-top: 3px; }
.filterbar { border-top: 1px solid var(--tblr-border-color); padding: .5rem 0; }

.search-box { width: min(22rem, 42vw); }
.search-results { width: 100%; max-height: 22rem; overflow: auto; margin-top: .25rem; }
.search-results.show { display: block; }
.search-results .dropdown-item { gap: .5rem; }
.search-results .dropdown-item.active { background: var(--accent-wash); color: inherit; }
.search-results .meta { margin-left: auto; color: var(--text-muted); font-size: .75rem; white-space: nowrap; }

#themeBtn .icon-sun { display: none; }
:root[data-theme="dark"] #themeBtn .icon-sun { display: inline; }
:root[data-theme="dark"] #themeBtn .icon-moon { display: none; }

/* Selected segment in every button group. */
.btn-group > .btn.active,
.btn-group > .btn[aria-pressed="true"] {
  background: var(--tblr-primary); border-color: var(--tblr-primary); color: #fff; z-index: 1;
}
.btn-group > .btn.active .dot { box-shadow: 0 0 0 1.5px #fff; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.dot-low { background: var(--series-1); }
.dot-high { background: var(--series-2); }
.dot-other { background: var(--series-3); }

.filter-menu { width: 22rem; }
.range-btn { gap: .35rem; }
.range-btn::after { display: none; }  /* no caret: the calendar icon says what it opens */
.range-menu { width: 19rem; }
.range-menu label { min-width: 0; }
.filter-menu .form-check { margin-bottom: .75rem; }
.filter-menu .form-check-description { display: block; font-size: .75rem; color: var(--text-muted); }

.scopebar {
  padding: .4rem 0; background: var(--accent-wash);
  border-top: 1px solid var(--tblr-border-color); box-shadow: inset 3px 0 0 var(--tblr-primary);
}
.scopebar[hidden] { display: none; }
.scope-entity { display: inline-flex; align-items: center; gap: .5rem; min-width: 0; max-width: 100%; }
.scope-entity strong { font-weight: 600; }
.scope-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-width: 0; max-width: 100%; }
.scope-group[hidden] { display: none; }
.scope-group + .scope-group { padding-left: .5rem; border-left: 1px solid var(--tblr-border-color); }
.scope-entity .dot { margin: 0; }

/* System profile: the class as a filled badge in its class-group colour. */
.sys-badge {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 3rem; height: 3rem; border-radius: .5rem; font-weight: 700; font-size: .95rem;
}
.search-results .dropdown-header { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
.search-results .sys-chip {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 4px; font-size: .65rem; font-weight: 700;
}

.value-table th.n, .value-table td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.value-table td:first-child { white-space: nowrap; }
.value-table tr.sum td { font-weight: 600; border-top: 1px solid var(--tblr-border-color); }

.top-years td { vertical-align: middle; white-space: nowrap; }
.top-years .year { font-weight: 600; font-variant-numeric: tabular-nums; width: 3.5rem; }
.top-years .who {
  display: inline-flex; align-items: center; gap: .4rem; border: 0; background: none; padding: .1rem .25rem;
  border-radius: 4px; color: inherit; max-width: 12rem;
}
.top-years .who:hover, .top-years .who:focus-visible { background: var(--accent-wash); outline: none; }
.top-years .who span { overflow: hidden; text-overflow: ellipsis; }
.top-years .who small { color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- content */

/* ------------------------------------------------------------- loading
   Everything here appears only after a short delay, so answers from the cache don't flash it. */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes load-slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* A thin bar sliding along the bottom of the sticky header while anything loads. */
.load-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; overflow: hidden; pointer-events: none; opacity: 0; }
.load-bar::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%;
  background: var(--tblr-primary); animation: load-slide 1.1s ease-in-out infinite;
}
body.is-busy .load-bar { animation: fade-in .2s .25s both; }

/* "Loading…", "Still loading…" or an error with Retry, at the end of the filter bar. */
.load-status { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text-secondary); }
.load-status[hidden] { display: none; }
.load-status[data-state="busy"] { animation: fade-in .2s .25s both; }
.load-status[data-state="error"] { color: var(--tblr-danger); }
.load-status[data-state="error"] .spinner-border { display: none; }

/* An area being refreshed: its content dims under a "Loading…" pill, which app.js keeps in the
   middle of the area's visible part (placePills). */
.is-loading > :not(.area-loader) { opacity: .35; transition: opacity .2s .25s; }
.area-loader {
  display: inline-flex; align-items: center; gap: .5rem; position: absolute; z-index: 5;
  transform: translate(-50%, -50%);
  width: auto; margin: 0; /* a .row gives every child full width and gutters */
  padding: .4rem .85rem; border-radius: 999px; font-size: .8rem; white-space: nowrap; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--tblr-border-color); color: var(--text-secondary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .15); animation: fade-in .2s .25s both;
}
.area-loader[hidden] { display: none; }

@media (max-width: 767.98px), (max-width: 1199.98px) and (max-height: 499.98px) {  /* header is tight: spinner only, text still read out */
  #loadText { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .load-bar::before { animation: none; width: 100%; opacity: .6; }
}

.tile .subheader { display: flex; align-items: center; gap: .375rem; }
.tile .h1 { margin: .25rem 0 0; font-weight: 620; }
.tile .note { font-size: .75rem; color: var(--text-muted); margin-top: .125rem; }
.tile .delta { font-size: .75rem; color: var(--text-secondary); margin-top: .25rem; font-variant-numeric: tabular-nums; }
.trend-up { color: var(--trend-up); } .trend-down { color: var(--trend-down); } .trend-flat { color: var(--trend-flat); }
.tile .delta [class^="trend-"] { font-weight: 600; }

.chart { width: 100%; height: 280px; }
.chart-tall { height: 560px; }
.chart-short { height: 220px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: .75rem; color: var(--text-secondary); margin-top: .5rem; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-legend .ramp { display: inline-block; width: 120px; height: 8px; border-radius: 4px; margin: 0 6px; vertical-align: 0; }

.breadcrumb .breadcrumb-item button { border: 0; background: none; padding: 0; color: var(--tblr-primary); }
.breadcrumb .breadcrumb-item button:hover { text-decoration: underline; }
.breadcrumb .breadcrumb-item.active { color: var(--text-secondary); }

.table-scroll { max-height: 34rem; overflow: auto; }
.table-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-1); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table .name-cell { max-width: 12rem; }
.table .name-cell .text-truncate { display: block; }
.table .flags-cell { min-width: 7rem; }
.table .flags-cell .badge { margin: 1px 0; }

.split { display: flex; height: 8px; width: 96px; gap: 2px; }
.split span { display: block; height: 100%; }
.split span:first-child { border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.split span:last-child { border-top-right-radius: 4px; border-bottom-right-radius: 4px; }

.avatar { --tblr-avatar-bg: var(--surface-2); background-size: cover; }
.mini-list .list-group-item { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; background: transparent; }
.mini-list .list-group-item-action { cursor: pointer; }
.mini-list .n { margin-left: auto; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-list .empty { color: var(--text-muted); }
/* How they fight: share bars and typical fits */
.share-list { display: grid; gap: .3rem; }
.share-row { display: grid; grid-template-columns: minmax(6rem, 10rem) 1fr 2.75rem; align-items: center; gap: .5rem; font-size: .8125rem; }
.share-row .n, .fit-row .n { text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.share-bar { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.share-bar i { display: block; height: 100%; border-radius: 4px; }
.fit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: .75rem; }
.fit-card { border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem; min-width: 0; }
.fit-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .4rem; min-width: 0; }
.fit-row { display: grid; grid-template-columns: 2.25rem minmax(0, 1fr) 3.5rem 2.5rem; align-items: center; gap: .4rem; font-size: .8125rem; padding: 1px 0; }
.fit-row .slot { color: var(--text-muted); font-size: .6875rem; text-transform: uppercase; letter-spacing: .03em; }
.style-empty { padding: .5rem 0; }
.tile .h-text { font-size: 1.125rem; line-height: 1.35; }

.method { font-size: .8125rem; color: var(--text-secondary); }
.method dt { color: var(--text-primary); font-weight: 600; margin-top: .5rem; }
.method dd { margin: 0; }

/* ------------------------------------------------------------- side panels (kill feed left, leaderboard right) */

.layout { display: flex; align-items: flex-start; }
.layout > .page-wrapper { flex: 1 1 auto; min-width: 0; }

.side-panel {
  --panel-w: 26rem;
  flex: none; display: flex;
  position: sticky; top: var(--topbar-h, 6.5rem); height: calc(100vh - var(--topbar-h, 6.5rem));
  background: var(--surface-1);
}
.side-left { border-right: 1px solid var(--tblr-border-color); }
.side-right { border-left: 1px solid var(--tblr-border-color); }
.panel-body { width: var(--panel-w); display: flex; flex-direction: column; min-height: 0; }
.panel-head { padding: 1rem 1rem .75rem; border-bottom: 1px solid var(--tblr-border-color); }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.panel-foot { padding: .625rem 1rem; border-top: 1px solid var(--tblr-border-color); max-height: 40%; overflow-y: auto; }
.panel-collapse { color: var(--text-secondary); }

/* Collapsed: a tab attached to the screen edge near the top: flat against the edge, rounded toward
   the page, icon only. It slides out a little on hover, like a pull tab. Its name shows on hover. */
.panel-rail { display: none; }
.side-panel.collapsed { background: none; border-color: transparent; height: auto; padding-top: .75rem; }
.side-panel.collapsed .panel-body { display: none; }
.side-panel.collapsed .panel-rail, .side-panel .panel-rail {
  align-items: center; justify-content: center; cursor: pointer;
  padding: .5rem .4rem; background: var(--surface-1); color: var(--text-secondary);
  border: 1px solid var(--tblr-border-color); box-shadow: 0 3px 12px rgba(0, 0, 0, .2);
  transition: padding .15s ease, color .15s ease, border-color .15s ease;
}
.side-panel.collapsed .panel-rail { display: flex; }
.side-panel.side-left .panel-rail { border-left: 0; border-radius: 0 .75rem .75rem 0; }
.side-panel.side-right .panel-rail { border-right: 0; border-radius: .75rem 0 0 .75rem; }
.side-left .panel-rail:hover, .side-left .panel-rail:focus-visible { padding-left: .7rem; }
.side-right .panel-rail:hover, .side-right .panel-rail:focus-visible { padding-right: .7rem; }
.panel-rail:hover, .panel-rail:focus-visible { color: var(--tblr-primary); border-color: var(--tblr-primary); outline: none; }
.rail-icon { position: relative; display: grid; place-items: center; width: 2rem; height: 2rem; }
.rail-badge {
  position: absolute; top: -6px; right: -8px; min-width: 1.15rem; height: 1.15rem; padding: 0 .3rem;
  border-radius: 999px; background: var(--tblr-primary); color: #fff; font-size: .6875rem; font-weight: 600;
  line-height: 1.15rem; text-align: center;
}
/* New kills while the feed is collapsed: the rail's button breathes until it is opened. */
.panel-rail.has-new { border-color: var(--tblr-primary); color: var(--tblr-primary); animation: railPulse 2.4s ease-in-out infinite; }
@keyframes railPulse {
  0%, 100% { box-shadow: 0 3px 12px rgba(0, 0, 0, .2), 0 0 0 0 rgba(var(--tblr-primary-rgb), .5); background: var(--surface-1); }
  50% { box-shadow: 0 3px 12px rgba(0, 0, 0, .2), 0 0 0 7px rgba(var(--tblr-primary-rgb), 0); background: rgba(var(--tblr-primary-rgb), .16); }
}

.panel-backdrop { position: fixed; inset: 0; z-index: 1040; background: rgba(0, 0, 0, .45); }

/* Below 1200px each panel is a drawer over the page, opened from a tab on its screen edge. */
@media (max-width: 1199.98px) {
  .side-panel, .side-panel.collapsed { position: fixed; top: 0; bottom: 0; height: auto; z-index: 1045; padding: 0; background: none; border: 0; pointer-events: none; }
  .side-left { left: 0; }
  .side-right { right: 0; }
  .side-panel .panel-body, .side-panel.collapsed .panel-body {
    display: flex; position: absolute; top: 0; bottom: 0; width: min(var(--panel-w), 92vw);
    background: var(--surface-1); box-shadow: 0 0 32px rgba(0, 0, 0, .3);
    visibility: hidden; transition: transform .2s ease, visibility .2s; pointer-events: auto;
  }
  .side-left .panel-body { left: 0; transform: translateX(-105%); }
  .side-right .panel-body { right: 0; transform: translateX(105%); }
  .side-panel.open .panel-body { transform: none; visibility: visible; }
  .side-panel .panel-rail, .side-panel.collapsed .panel-rail {
    display: flex; position: absolute; top: 50%; transform: translateY(-50%); pointer-events: auto;
  }
  .side-left .panel-rail { left: 0; }
  .side-right .panel-rail { right: 0; }
  .side-panel.open .panel-rail, .drawer-open .side-panel .panel-rail { display: none; }
}

/* Leaderboard rows */
.board-row {
  display: grid; grid-template-columns: 2.25rem 2rem minmax(0, 1fr) auto; align-items: center; gap: .5rem;
  width: 100%; padding: .55rem 1rem; text-align: left; color: inherit;
  background: none; border: 0; border-bottom: 1px solid var(--grid); cursor: pointer;
}
.board-row:hover, .board-row:focus-visible { background: var(--accent-wash); outline: none; }
.board-row .rank { color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; font-size: .8125rem; }
.board-row .who { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.board-row .who .name { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .meta { font-size: .75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-row .value strong { display: block; font-weight: 620; }
.board-row .value small { color: var(--text-muted); }
.board-row .split { width: 100%; height: 6px; }
.board-row mark { padding: 0; background: rgba(var(--tblr-primary-rgb), .25); color: inherit; border-radius: 2px; }
.board-note { padding: .5rem 1rem; font-size: .75rem; color: var(--text-muted); border-bottom: 1px solid var(--grid); }
.board-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); }

/* ------------------------------------------------------------- live kill feed */

.live-status { display: inline-flex; align-items: center; gap: .375rem; font-size: .75rem; font-weight: 500; color: var(--text-muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.live-status[data-state="ok"] .live-dot { background: #0ca30c; animation: livePulse 2s ease-out infinite; }
.live-status[data-state="error"] .live-dot { background: #d03b3b; }
.live-status[data-state="paused"] .live-dot { background: #fab219; }
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, .55); }
  70% { box-shadow: 0 0 0 6px rgba(12, 163, 12, 0); }
  100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); }
}

.kill-item {
  display: grid; grid-template-columns: 2.25rem minmax(0, 1fr); gap: .625rem; align-items: start;
  padding: .625rem 1rem; color: inherit; text-decoration: none; border-bottom: 1px solid var(--grid);
}
.kill-item:hover { background: var(--accent-wash); }
/* Names in a kill scope the page to them; the zKill button opens the mail. */
.ki-link { border: 0; background: none; padding: 0; color: inherit; font: inherit; cursor: pointer; text-align: left; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: underline transparent; transition: text-decoration-color .15s; }
.ki-link:hover, .ki-link:focus-visible { color: var(--tblr-primary); text-decoration-color: currentColor; outline: none; }
.ki-sub .ki-link { color: var(--text-secondary); }
.ki-sep { color: var(--text-muted); margin: 0 .25rem; }
.ki-zkill { padding: 0 .4rem; font-size: .6875rem; line-height: 1.4; white-space: nowrap; flex: none; }
.kill-item .avatar { margin-top: 2px; }
.ki-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ki-top { display: flex; align-items: center; gap: .5rem; }
.ki-ship { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ki-value { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ki-line, .ki-sub { font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ki-sub { font-size: .75rem; color: var(--text-muted); }
.ki-flags .badge { margin: 2px 4px 0 0; }
.kill-empty { padding: 2rem 1rem; text-align: center; color: var(--text-muted); }

/* A newly arrived kill: accent edge and a wash that fades out, plus a "New" badge for a minute. */
.kill-item.kill-new { animation: killFlash 8s ease-out; box-shadow: inset 3px 0 0 var(--tblr-primary); }
@keyframes killFlash {
  0%, 15% { background-color: rgba(var(--tblr-primary-rgb), .22); }
  100% { background-color: transparent; }
}
.badge-new { animation: badgeFade 60s linear forwards; }
@keyframes badgeFade { 0%, 90% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .kill-item.kill-new { animation: none; background-color: rgba(var(--tblr-primary-rgb), .12); }
  .live-status[data-state="ok"] .live-dot, .panel-rail.has-new, .badge-new { animation: none; }
}

/* ------------------------------------------------------------- wormhole effect icons */

.fx-icon { display: inline-flex; vertical-align: -2px; line-height: 0; cursor: help; }
.fx-icon .fx-svg { display: block; }
.fx-tip {
  position: fixed; z-index: 2000; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  padding: .2rem .5rem; border-radius: .375rem; font-size: .75rem; font-weight: 500;
  background: var(--text-primary); color: var(--surface-1); box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}
.fx-tip[data-side="right"] { transform: translate(0, -50%); }
.fx-tip[data-side="left"] { transform: translate(-100%, -50%); }

/* ------------------------------------------------------------- small screens */

/* Search, measure, clock and theme don't fit beside the brand: search gets a row of its own. */
@media (max-width: 1099.98px) {
  .topbar .navbar .container-xl { flex-wrap: wrap; row-gap: .5rem; }
  .topbar .navbar .ms-auto { flex: 1 1 auto; flex-wrap: wrap; justify-content: flex-end; }
  .search-box { width: auto; flex: 1 0 100%; order: 9; }
}

@media (max-width: 767.98px) {
  .chart-tall { height: 420px; }
  .card-actions { margin-left: 0; }
}
/* Section nav: a row of jump links under the filters, the part in view highlighted */
.sectionnav { border-top: 1px solid var(--border); background: var(--surface-1); }
.sectionnav .container-xl { display: flex; align-items: center; gap: .25rem; overflow-x: auto; scrollbar-width: none; padding-top: .25rem; padding-bottom: .25rem; }
.sectionnav a { padding: .2rem .6rem; border-radius: 6px; font-size: .8125rem; color: var(--text-secondary); white-space: nowrap; text-decoration: none; }
.sectionnav a:hover { color: var(--text-primary); background: var(--surface-2); }
.sectionnav a.active { color: var(--text-primary); background: var(--accent-wash); font-weight: 600; }
.sectionnav #shareBtn { white-space: nowrap; }
#main > section, #main > .row, #tiles { scroll-margin-top: calc(var(--topbar-h, 150px) + 12px); }

/* Battles */
.battle-list { display: grid; }
.battle { padding: .75rem 1rem; border-top: 1px solid var(--border); display: grid; gap: .45rem; }
.battle:first-child { border-top: 0; }
.battle-head { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.class-badge { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 1.75rem; height: 1.75rem;
  border-radius: 50%; font-size: .6875rem; font-weight: 700; letter-spacing: -.02em; line-height: 1;
  box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3px var(--border); }
.class-badge.sm { width: 1.25rem; height: 1.25rem; font-size: .5625rem; box-shadow: none; }
.battle-sys { font-weight: 600; color: var(--text-primary); }
.battle-stats { font-variant-numeric: tabular-nums; }
.battle-links { margin-left: auto; display: flex; gap: .35rem; }
.battle-systems { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; font-size: .8125rem; }
.bsys { display: inline-flex; align-items: center; gap: .35rem; }
.bsys .btn-link { font-weight: 600; }
.battle-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--surface-2); }
.battle-bar i { display: block; height: 100%; }
.battle-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: .5rem 1rem; }
.battle-side { min-width: 0; padding: .35rem .5rem; border-radius: 6px; }
.battle-side.theirs { background: var(--accent-wash); }
.bs-head { font-size: .8125rem; display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; margin-bottom: .25rem; }
.bs-head .dot { margin: 0 .15rem 0 0; }
.bs-head strong { min-width: 0; }
.bs-eff { display: grid; grid-template-columns: minmax(4rem, 1fr) auto auto; align-items: center; gap: .4rem; font-size: .8125rem; margin: .15rem 0; }
.bs-eff .share-bar { height: 10px; border-radius: 5px; }
.bs-eff .share-bar i { border-radius: 5px; }
.bs-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.bs-trade { display: flex; flex-wrap: wrap; gap: .1rem .9rem; font-size: .8125rem; font-variant-numeric: tabular-nums; margin-bottom: .35rem; }
.bs-groups { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.bs-group { display: inline-flex; align-items: center; gap: .3rem; max-width: 14rem; padding: .1rem .45rem .1rem .15rem; border: 1px solid var(--border);
  border-radius: 999px; background: transparent; color: var(--text-primary); font-size: .75rem; cursor: pointer; }
.bs-group:hover { background: var(--surface-2); }
.bs-group .n { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.battle-empty { padding: 1rem; }

/* Fit window */
.fit-head { width: 100%; border: 0; background: transparent; padding: 0; color: inherit; text-align: left; cursor: pointer; }
.fit-head:hover strong { text-decoration: underline; }
.fit-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-1); color: var(--text-primary); }
.fit-dialog::backdrop { background: rgba(0, 0, 0, .55); }
.fd-head { display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
.fd-body { padding: .75rem 1rem 1rem; }
.fd-h { font-size: .9375rem; margin: 0 0 .5rem; }
.fd-variant { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .5rem; }
.fd-vhead { display: flex; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.fd-mods { columns: 2 280px; column-gap: 1rem; }
.fd-mods .fit-row { break-inside: avoid; }
.fd-mod { grid-template-columns: 2.25rem 1.25rem minmax(0, 1fr); }
.fd-freq { columns: 2 300px; column-gap: 1rem; }
.fd-freq .fit-row { break-inside: avoid; }
.min-w-0 { min-width: 0; }
/* The main column narrows when the side panels are open, but Bootstrap's columns follow the window.
   So inside it, columns follow the column's own width: six stat tiles a row only when they fit,
   charts side by side only with room for both. */
#main { container-type: inline-size; }
@container (max-width: 1099.98px) {
  #main .row > .col-xl-2 { flex: 0 0 auto; width: 33.3333%; }
}
@container (max-width: 639.98px) {
  #main .row > .col-xl-2 { width: 50%; }
}
@container (max-width: 879.98px) {
  #main .row > [class*="col-lg-"]:not(.col-xl-2) { flex: 0 0 auto; width: 100%; }
  #main .row > .col-md-6.col-lg-4, #main .row > .col-md-6.col-lg-3 { width: 50%; }
}
@container (max-width: 559.98px) {
  #main .row > [class*="col-md-"]:not(.col-xl-2) { flex: 0 0 auto; width: 100%; }
}

/* ------------------------------------------------------------- phones
   A compact sticky header (brand, search, filters) over a row of filter chips; the filter bar
   becomes a bottom sheet; the page is four views (stats, battles, kills, leaderboard) switched
   from a tab bar at the bottom. app.js sets body[data-view] and moves the display controls.
   A phone is a narrow screen, or a short one below desktop width (a phone held sideways), so
   the same query is in app.js (phone) and .phone-only hides outside it. */

.tabbar { display: none; }
@media (min-width: 768px) and (min-height: 500px), (min-width: 1200px) {
  .phone-only { display: none !important; }
}

@media (max-width: 767.98px), (max-width: 1199.98px) and (max-height: 499.98px) {
  body {
    padding-bottom: calc(3.5rem + env(safe-area-inset-bottom));
    /* Sideways, the notch and rounded corners sit at the left and right. */
    padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right);
  }
  body.sheet-open, body.search-open { overflow: hidden; }

  .topbar .navbar { min-height: 3.25rem; padding: .25rem 0; }
  .topbar .navbar .container-xl { flex-wrap: nowrap; }
  .topbar .navbar .ms-auto { flex: none; flex-wrap: nowrap; gap: .25rem !important; }
  .topbar .navbar .btn-icon { width: 2.5rem; height: 2.5rem; border: 0; background: none; box-shadow: none; }
  #filterOpen .rail-badge { top: 2px; right: 0; }
  .sectionnav { display: none; }

  /* Active filters: one scrolling row of chips, each opening the sheet. */
  .chiprow {
    display: flex; gap: .375rem; overflow-x: auto; scrollbar-width: none; padding: 0 1rem .5rem;
  }
  .chiprow::-webkit-scrollbar { display: none; }
  .chip {
    flex: none; display: inline-flex; align-items: center; gap: .3rem; height: 1.875rem; padding: 0 .7rem;
    border: 1px solid var(--tblr-border-color); border-radius: 999px; background: var(--surface-2);
    color: var(--text-primary); font-size: .8125rem; white-space: nowrap;
  }
  .chip.on { background: var(--accent-wash); border-color: rgba(var(--tblr-primary-rgb), .45); }
  .chip .dot { margin: 0; }

  /* The filter bar as a bottom sheet. */
  .filterbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1055; max-height: 85dvh; overflow-y: auto;
    overscroll-behavior: contain; padding: 0 0 calc(1.25rem + env(safe-area-inset-bottom));
    background: var(--surface-1); border: 0; border-radius: 1rem 1rem 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .35);
    transform: translateY(100%); visibility: hidden; transition: transform .25s ease, visibility .25s;
    max-width: 40rem; margin: 0 auto;  /* centred when held sideways */
  }
  body.sheet-open .filterbar { transform: none; visibility: visible; }
  .sheet-backdrop { z-index: 1050; }
  body.sheet-open .topbar { z-index: 1050; }  /* above the tab bar and the page */
  .sheet-head {
    position: sticky; top: 0; z-index: 2; display: flex; align-items: center; padding: 1rem 1rem .5rem;
    background: var(--surface-1);
  }
  .sheet-grip { position: absolute; top: .4rem; left: 50%; width: 2.5rem; height: 4px; margin-left: -1.25rem; border-radius: 2px; background: var(--axis); }
  .filterbar > .container-xl { flex-direction: column; flex-wrap: nowrap !important; align-items: stretch !important; gap: .5rem !important; }
  .sheet-label { margin-top: .5rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
  /* Segmented groups wrap as rows of pills, big enough to tap. */
  .filterbar .btn-group { display: flex; flex-wrap: wrap; gap: .4rem; }
  .filterbar .btn-group > .btn, .filterbar .btn-group > .btn-group > .btn {
    flex: 0 0 auto; min-height: 2.5rem; padding: 0 .9rem; margin: 0 !important; border-radius: 999px !important; font-size: .875rem;
  }
  .filterbar .btn-group > .btn-group { margin: 0 !important; }
  .filterbar .form-select { width: 100% !important; min-height: 2.75rem; font-size: 16px; }  /* 16px: iOS zooms smaller inputs */
  .filterbar input[type="date"] { font-size: 16px; }
  /* The "Filters" menu's switches sit in the sheet itself. */
  .filter-drop > .dropdown-toggle { display: none; }
  .filter-drop > .filter-menu { display: block; position: static; width: auto; padding: 0 !important; margin: 0; border: 0; box-shadow: none; background: none; }
  .filter-menu .form-check { margin-bottom: 1rem; }
  .sheet-display { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .sheet-display .btn-icon { width: 2.5rem; height: 2.5rem; border-radius: 999px; }

  /* Search: the whole screen while open. */
  .search-box { display: none; }
  body.search-open .topbar { z-index: 1060; }
  body.search-open .search-box {
    display: flex; flex-wrap: wrap; align-content: flex-start; gap: .5rem; position: fixed !important; inset: 0; z-index: 1060;
    width: auto; padding: .5rem 1rem; background: var(--surface-1);
  }
  body.search-open .search-box .input-icon { flex: 1; }
  body.search-open #search { font-size: 16px; min-height: 2.75rem; }
  body.search-open .search-results {
    position: static; flex: 1 0 100%; max-height: calc(100dvh - 4.5rem); margin: 0; border: 0; box-shadow: none; padding: 0;
  }
  body.search-open .search-results .dropdown-item { min-height: 3rem; }

  /* What the page is scoped to: one row of chips. */
  .scopebar .container-xl { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; }
  .scope-label, #placeKind, #entityKind, #placeClear .ms-1, #entityClear .ms-1 { display: none; }
  .scope-group { flex-wrap: nowrap; }
  .scope-entity strong { max-width: 42vw; }

  /* Views. Kills and the leaderboard are pages of their own, scrolling with the window. */
  .side-panel, .side-panel.collapsed { display: none; position: static; padding: 0; pointer-events: auto; background: var(--surface-1); }
  body[data-view="kills"] #killPanel, body[data-view="leaders"] #boardPanel { display: block; flex: 1 1 auto; width: 100%; border: 0; }
  .side-panel .panel-body, .side-panel.collapsed .panel-body {
    display: flex; position: static; width: 100%; transform: none; visibility: visible; box-shadow: none;
  }
  .side-panel .panel-rail, .side-panel.collapsed .panel-rail, .panel-collapse { display: none !important; }
  .panel-scroll { overflow: visible; }
  .panel-foot { max-height: none; }
  body[data-view="kills"] .page-wrapper, body[data-view="leaders"] .page-wrapper { display: none; }
  body[data-view="stats"] #battleCard { display: none; }
  body[data-view="battles"] #main > :not(#battleCard) { display: none; }

  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--surface-1); border-top: 1px solid var(--tblr-border-color);
  }
  .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 3.5rem;
    border: 0; background: none; color: var(--text-muted); font-size: .6875rem; font-weight: 500;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar button[aria-current="page"] { color: var(--tblr-primary); }
  .tab-icon { position: relative; line-height: 0; }
  .tab-icon .rail-badge { top: -4px; right: -10px; line-height: 1.15rem; }

  /* Tighter tiles, so their labels don't break on the narrowest screens. */
  .tile .card-body { padding: .875rem 1rem; }
}

/* Held sideways there is little height: the header scrolls away with the page and the tab bar is
   one slim row of icon and label. */
@media (max-width: 1199.98px) and (max-height: 499.98px) {
  .topbar { position: static; }
  body { padding-bottom: calc(2.75rem + env(safe-area-inset-bottom)); }
  .tabbar button { flex-direction: row; gap: .5rem; min-height: 2.75rem; font-size: .8125rem; }
  .tabbar svg { width: 20px; height: 20px; }
  .filterbar { max-height: 92dvh; }
}
