/* ============================================================================
 * MCD (M365 Change Digest) — css/app.css
 * Self-contained app stylesheet: design tokens (dark default + light), toolbar,
 * command bar, filter sidebar, change cards, per-product timeline, detail
 * drawer, status bar. No external resources. Token values mirror the msnugget
 * family (cmtrace / MSFinder); a semantic status palette is layered on top.
 * ==========================================================================*/

@font-face {
  font-family: "Manrope";
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
  src: url("../assets/fonts/manrope.woff2") format("woff2");
}

/* ---------------------------------------------------------------------------
 * Design tokens — DARK is the default brand theme.
 * ------------------------------------------------------------------------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #000000;
  --bg-elev: #0c120b;
  --bg-elev-2: #11180f;
  --bg-grid: #050705;

  --fg: #d2d7dc;
  --fg-dim: #9aa1a8;
  --fg-faint: rgba(255, 255, 255, 0.42);

  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent: #39a751;          /* msnugget green */
  --accent-fg: #ffffff;
  --accent-soft: rgba(57, 167, 81, 0.16);
  --accent-border: rgba(57, 167, 81, 0.55);

  --hover-bg: rgba(255, 255, 255, 0.06);
  --active-bg: rgba(255, 255, 255, 0.10);
  --row-sel-bg: rgba(57, 167, 81, 0.18);
  --hl: rgba(57, 167, 81, 0.34);

  --heading: #ffffff;

  /* Semantic status palette (change lifecycle) */
  --st-dev: #e0a014;          --st-dev-soft: rgba(224, 160, 20, 0.16);
  --st-rolling: #2f86ee;      --st-rolling-soft: rgba(47, 134, 238, 0.16);
  --st-launched: #2fae57;     --st-launched-soft: rgba(47, 174, 87, 0.16);
  --st-cancelled: #8a949c;    --st-cancelled-soft: rgba(138, 148, 156, 0.16);

  --shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --scroll-thumb: rgba(255, 255, 255, 0.16);
  --scroll-thumb-hover: rgba(255, 255, 255, 0.30);

  --font-ui: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;

  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 14px;

  --toolbar-h: 56px;
  --status-h: 30px;
  --sidebar-w: 280px;
}

/* ---- LIGHT theme ---- */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #ffffff;
  --bg-elev: #f5f7f5;
  --bg-elev-2: #eef1ee;
  --bg-grid: #ffffff;

  --fg: #1d2421;
  --fg-dim: #5b665f;
  --fg-faint: #8a948c;

  --border: #e2e8e3;
  --border-strong: #cdd6cf;

  --accent: #1f8f3d;
  --accent-fg: #ffffff;
  --accent-soft: rgba(31, 143, 61, 0.12);
  --accent-border: rgba(31, 143, 61, 0.45);

  --hover-bg: rgba(0, 0, 0, 0.05);
  --active-bg: rgba(0, 0, 0, 0.08);
  --row-sel-bg: rgba(31, 143, 61, 0.14);
  --hl: rgba(31, 143, 61, 0.22);

  --heading: #0c130f;

  /* darkened for WCAG AA (≥4.5:1) text contrast on the soft pill backgrounds */
  --st-dev: #8a5300;          --st-dev-soft: rgba(138, 83, 0, 0.14);
  --st-rolling: #1659b8;      --st-rolling-soft: rgba(22, 89, 184, 0.13);
  --st-launched: #15723a;     --st-launched-soft: rgba(21, 114, 58, 0.14);
  --st-cancelled: #585f67;    --st-cancelled-soft: rgba(88, 95, 103, 0.14);

  --shadow: 0 10px 30px rgba(16, 24, 40, 0.16), 0 2px 6px rgba(16, 24, 40, 0.08);
  --shadow-sm: 0 1px 4px rgba(16, 24, 40, 0.10);
  --scroll-thumb: rgba(0, 0, 0, 0.18);
  --scroll-thumb-hover: rgba(0, 0, 0, 0.32);
}

/* ---------------------------------------------------------------------------
 * Reset / base
 * ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }
html {
  font-family: var(--font-ui);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { background: var(--bg); color: var(--fg); overflow: hidden; line-height: 1.45; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); background-clip: padding-box; }

.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex: none; }
.icon svg, svg.icon { width: 100%; height: 100%; display: block; }

/* ---------------------------------------------------------------------------
 * App shell
 * ------------------------------------------------------------------------- */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

#toolbar {
  height: var(--toolbar-h); flex: none;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.brand-home { display: inline-flex; align-items: center; gap: 10px; color: var(--heading); }
.brand-home:hover { text-decoration: none; }
.brand-glyph { width: 30px; height: 30px; flex: none; border-radius: 8px; }
.brand-wordmark { font-weight: 800; font-size: 1.12rem; letter-spacing: -0.01em; }
.brand-name { color: var(--heading); }
.brand-dev { color: var(--accent); }
.brand-tag { color: var(--fg-faint); font-weight: 600; font-size: .78rem; margin-left: 2px; }
.tb-spacer { flex: 1 1 auto; }

.tb-group { display: inline-flex; align-items: center; gap: var(--sp-2); }
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev-2); color: var(--fg);
}
.tb-btn:hover { background: var(--hover-bg); border-color: var(--border-strong); }
.tb-btn .icon { width: 18px; height: 18px; }

/* view toggle (segmented) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-elev-2); }
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; color: var(--fg-dim); font-weight: 600; font-size: .86rem;
  border-right: 1px solid var(--border);
}
.seg button:last-child { border-right: none; }
.seg button .icon { width: 17px; height: 17px; }
.seg button.is-active { background: var(--accent-soft); color: var(--accent); }
.seg button:hover:not(.is-active) { background: var(--hover-bg); color: var(--fg); }

/* theme toggle icon swap */
#btn-theme .icon-sun { display: none; }
:root[data-theme="light"] #btn-theme .icon-moon { display: none; }
:root[data-theme="light"] #btn-theme .icon-sun { display: block; }

/* ---------------------------------------------------------------------------
 * Body: sidebar + content
 * ------------------------------------------------------------------------- */
#body { flex: 1 1 auto; display: flex; min-height: 0; }

#sidebar {
  width: var(--sidebar-w); flex: none;
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
}
.sidebar-head h2 { margin: 0; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-dim); display: inline-flex; align-items: center; gap: 7px; }
.sidebar-head .icon { width: 16px; height: 16px; color: var(--fg-dim); }
.btn-reset {
  font-size: .78rem; font-weight: 600; color: var(--accent);
  padding: 3px 8px; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.btn-reset:hover { background: var(--accent-soft); }
.btn-reset:disabled { color: var(--fg-faint); cursor: default; }
.btn-reset:disabled:hover { background: none; }

.facets { overflow-y: auto; padding: var(--sp-2) var(--sp-2) var(--sp-4); flex: 1 1 auto; }

.facet { border-bottom: 1px solid var(--border); }
.facet:last-child { border-bottom: none; }
.facet > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 11px var(--sp-3); font-weight: 700; font-size: .9rem; color: var(--heading);
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary .chev { width: 16px; height: 16px; margin-left: auto; color: var(--fg-faint); transition: transform .15s ease; }
.facet[open] > summary .chev { transform: rotate(180deg); }
.facet > summary .fcount { font-size: .74rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.facet-body { padding: 2px var(--sp-2) var(--sp-3); }

.prod-search {
  width: 100%; height: 32px; margin: 0 0 var(--sp-2);
  padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--fg); font-size: .84rem;
}
.prod-search:focus-visible { border-color: var(--accent-border); }
.facet-scroll { max-height: 230px; overflow-y: auto; }

.opt {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; user-select: none;
}
.opt:hover { background: var(--hover-bg); }
.opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt .box {
  width: 17px; height: 17px; flex: none; border-radius: 5px;
  border: 1.5px solid var(--border-strong); display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s ease, border-color .12s ease;
}
.opt .box svg { width: 12px; height: 12px; opacity: 0; }
.opt input:checked + .box { background: var(--accent); border-color: var(--accent); }
.opt input:checked + .box svg { opacity: 1; color: #fff; }
.opt input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.opt .opt-label { flex: 1 1 auto; font-size: .87rem; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; min-width: 0; }
.opt .opt-label > span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .opt-count { font-size: .76rem; color: var(--fg-faint); font-variant-numeric: tabular-nums; flex: none; }
.opt.is-zero { opacity: .42; }

/* status / generic colour dot */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dot, var(--fg-faint)); }
.dot-dev { --dot: var(--st-dev); }
.dot-rolling { --dot: var(--st-rolling); }
.dot-launched { --dot: var(--st-launched); }
.dot-cancelled { --dot: var(--st-cancelled); }

/* product monogram tile */
.prod-tile {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; font-size: .62rem; font-weight: 800;
  background: var(--prod, var(--accent)); color: #fff; letter-spacing: -.02em;
}
.prod-tile-sm { width: 18px; height: 18px; border-radius: 5px; font-size: .56rem; }
.prod-tile-lg { width: 30px; height: 30px; border-radius: 8px; font-size: .76rem; }

/* real product logo on a white chip (logos are full-colour on transparent) */
.prod-tile-logo { background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.prod-tile-logo img { width: 72%; height: 72%; object-fit: contain; display: block; }

/* ---------------------------------------------------------------------------
 * Content area
 * ------------------------------------------------------------------------- */
#content { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

#content-head {
  flex: none; padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border); background: var(--bg);
  display: flex; flex-direction: column; gap: var(--sp-3);
}
.cb-row { display: flex; align-items: center; gap: var(--sp-3); }

#command-bar {
  flex: 1 1 auto; display: flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--bg-elev); transition: border-color .15s ease, box-shadow .15s ease;
}
#command-bar:focus-within { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.cb-icon { width: 20px; height: 20px; color: var(--fg-dim); flex: none; }
.cb-input { flex: 1 1 auto; border: none; background: none; outline: none; font-size: 1rem; color: var(--fg); min-width: 0; }
.cb-input::placeholder { color: var(--fg-faint); }
.cb-clear { display: inline-flex; padding: 4px; border-radius: var(--radius-sm); color: var(--fg-dim); }
.cb-clear:hover { background: var(--hover-bg); color: var(--fg); }
.cb-clear .icon { width: 18px; height: 18px; }

.sort-wrap { position: relative; flex: none; }
.sort-select {
  appearance: none; height: 44px; padding: 0 32px 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--fg); font-weight: 600; font-size: .88rem; cursor: pointer;
}
.sort-select:hover { border-color: var(--border-strong); }
.sort-wrap::after { content: ""; position: absolute; right: 12px; top: 50%; width: 9px; height: 9px; border-right: 2px solid var(--fg-dim); border-bottom: 2px solid var(--fg-dim); transform: translateY(-65%) rotate(45deg); pointer-events: none; }

.btn-filters-m { display: none; }

/* active filter chips row */
#active-chips { display: flex; flex-wrap: wrap; gap: 7px; }
#active-chips:empty { display: none; }
.achip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--bg-elev-2); border: 1px solid var(--border); font-size: .8rem; color: var(--fg);
}
.achip .x { display: inline-flex; padding: 2px; border-radius: 50%; color: var(--fg-dim); }
.achip .x:hover { background: var(--hover-bg); color: var(--fg); }
.achip .x svg { width: 13px; height: 13px; }

/* results scroll region */
#results-region { flex: 1 1 auto; overflow-y: auto; padding: var(--sp-4); min-height: 0; }

/* ---- LIST VIEW: change cards ---- */
#list { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 1100px; margin: 0 auto; }
.change {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg-elev); padding: var(--sp-4);
  display: grid; grid-template-columns: 1fr auto; gap: 4px var(--sp-4);
  cursor: pointer; transition: border-color .12s ease, background .12s ease, transform .06s ease;
}
.change:hover { border-color: var(--border-strong); background: var(--bg-elev-2); }
.change:active { transform: translateY(1px); }
.change-main { min-width: 0; grid-column: 1; }
.change-title { font-size: 1.02rem; font-weight: 700; color: var(--heading); margin: 0 0 6px; line-height: 1.3; }
.change-desc { color: var(--fg-dim); font-size: .9rem; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.change-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 10px; }
.change-side { grid-column: 2; grid-row: 1 / span 3; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; text-align: right; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap;
}
.badge-prod { background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--fg); padding-left: 5px; }
.badge-prod .prod-tile { width: 17px; height: 17px; border-radius: 4px; font-size: .54rem; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap;
  border: 1px solid transparent;
}
.pill .dot { width: 7px; height: 7px; }
.pill[data-status="dev"]       { color: var(--st-dev); background: var(--st-dev-soft); }
.pill[data-status="rolling"]   { color: var(--st-rolling); background: var(--st-rolling-soft); }
.pill[data-status="launched"]  { color: var(--st-launched); background: var(--st-launched-soft); }
.pill[data-status="cancelled"] { color: var(--st-cancelled); background: var(--st-cancelled-soft); }

.meta-tag { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--fg-dim); }
.meta-tag .icon { width: 14px; height: 14px; color: var(--fg-faint); }
.ga-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; border: 1px dashed var(--border-strong); font-size: .76rem; font-weight: 700; color: var(--fg); }
.ga-chip .icon { width: 13px; height: 13px; color: var(--fg-dim); }
.src-chip { font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--fg-faint); }

/* ---- empty state ---- */
.empty { text-align: center; color: var(--fg-dim); padding: 64px 16px; max-width: 460px; margin: 24px auto; }
.empty .icon { width: 44px; height: 44px; color: var(--fg-faint); margin-bottom: 12px; }
.empty h3 { color: var(--heading); margin: 0 0 6px; font-size: 1.1rem; }
.empty p { margin: 0; font-size: .92rem; }

/* ---------------------------------------------------------------------------
 * TIMELINE VIEW — per-product lanes × quarter columns
 * ------------------------------------------------------------------------- */
#timeline { overflow: auto; max-width: 100%; }
.tl-controls { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin: 0 0 var(--sp-3); }
.tl-controls .tl-hint { margin: 0; flex: 1 1 360px; min-width: 0; }
.tl-range-wrap { flex: none; }
.tl-range-wrap .sort-select { height: 38px; }
.tl-hint { color: var(--fg-dim); font-size: .86rem; display: flex; align-items: center; gap: 8px; }
.tl-hint .icon { flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tl-grid { display: block; min-width: max-content; border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: var(--bg-elev); }
.tl-row { display: grid; border-top: 1px solid var(--border); }
.tl-row:first-child { border-top: none; }
.tl-cell { padding: 8px; border-left: 1px solid var(--border); min-height: 56px; }
.tl-cell:first-child { border-left: none; }

.tl-head { position: sticky; top: 0; z-index: 3; background: var(--bg-elev-2); }
.tl-head .tl-cell { font-size: .78rem; font-weight: 700; color: var(--fg-dim); text-align: center; min-height: 0; padding: 9px 8px; display: flex; align-items: center; justify-content: center; }
.tl-corner { position: sticky; left: 0; z-index: 4; background: var(--bg-elev-2); }

.tl-lane-head {
  position: sticky; left: 0; z-index: 2; background: var(--bg-elev);
  display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .84rem; color: var(--heading);
  border-right: 1px solid var(--border); min-width: 190px; max-width: 190px;
}
.tl-lane-head .lane-count { margin-left: auto; font-size: .72rem; color: var(--fg-faint); font-weight: 700; }
.tl-cell-tbd { background: repeating-linear-gradient(45deg, transparent, transparent 6px, var(--hover-bg) 6px, var(--hover-bg) 12px); }

.tl-chip {
  display: block; width: 100%; text-align: left; margin: 0 0 5px;
  padding: 5px 8px; border-radius: var(--radius-sm); font-size: .76rem; font-weight: 600; line-height: 1.25;
  border: 1px solid transparent; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-chip:last-child { margin-bottom: 0; }
.tl-chip[data-status="dev"]       { background: var(--st-dev-soft); border-color: color-mix(in srgb, var(--st-dev) 35%, transparent); }
.tl-chip[data-status="rolling"]   { background: var(--st-rolling-soft); border-color: color-mix(in srgb, var(--st-rolling) 35%, transparent); }
.tl-chip[data-status="launched"]  { background: var(--st-launched-soft); border-color: color-mix(in srgb, var(--st-launched) 35%, transparent); }
.tl-chip[data-status="cancelled"] { background: var(--st-cancelled-soft); border-color: color-mix(in srgb, var(--st-cancelled) 35%, transparent); }
.tl-chip:hover { filter: brightness(1.12); }
.tl-more { font-size: .72rem; color: var(--accent); font-weight: 700; padding: 2px 4px; }

/* ---------------------------------------------------------------------------
 * DETAIL POPUP (centred modal)
 * ------------------------------------------------------------------------- */
#overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); opacity: 0; pointer-events: none; transition: opacity .2s ease; z-index: 40; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
#overlay.is-open { opacity: 1; pointer-events: auto; }

#drawer {
  position: fixed; left: 50%; top: 50%;
  width: 600px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 48px);
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow);
  transform: translate(-50%, -48%) scale(.97); opacity: 0; pointer-events: none;
  transition: transform .2s cubic-bezier(.4,0,.2,1), opacity .18s ease;
  z-index: 50; display: flex; flex-direction: column;
}
#drawer.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) { #drawer { transition: opacity .18s ease; } }
.drawer-head { flex: none; display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4); border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 1.18rem; font-weight: 800; color: var(--heading); line-height: 1.25; flex: 1 1 auto; }
.drawer-close { flex: none; display: inline-flex; padding: 7px; border-radius: var(--radius); border: 1px solid var(--border); color: var(--fg-dim); }
.drawer-close:hover { background: var(--hover-bg); color: var(--fg); }
.drawer-body { overflow-y: auto; padding: var(--sp-4); flex: 1 1 auto; }
.drawer-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--sp-4); }
.drawer-desc { color: var(--fg); font-size: .95rem; line-height: 1.6; white-space: pre-line; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.kv dt { color: var(--fg-dim); font-size: .82rem; font-weight: 700; }
.kv dd { margin: 0; font-size: .88rem; color: var(--fg); }
.kv dd .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-lite { display: inline-flex; padding: 2px 8px; border-radius: 999px; background: var(--bg-elev-2); border: 1px solid var(--border); font-size: .76rem; }
.drawer-foot { flex: none; padding: var(--sp-4); border-top: 1px solid var(--border); display: flex; gap: var(--sp-3); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: var(--radius); font-weight: 700; font-size: .92rem;
  border: 1px solid var(--border-strong); color: var(--fg); background: var(--bg-elev);
}
.btn:hover { background: var(--hover-bg); text-decoration: none; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); flex: 1 1 auto; }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }

/* ---------------------------------------------------------------------------
 * Status bar
 * ------------------------------------------------------------------------- */
#statusbar {
  height: var(--status-h); flex: none;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4); border-top: 1px solid var(--border);
  background: var(--bg-elev); color: var(--fg-dim); font-size: .78rem;
}
.status-spacer { flex: 1 1 auto; }
.status-item { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.status-item .icon { width: 13px; height: 13px; }
#status-count { flex: 0 0 auto; }
#status-meta { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: block; }
/* on very narrow screens drop the secondary meta so the bar can't overflow */
@media (max-width: 430px) { #status-meta { display: none; } }

/* mobile sidebar toggle / backdrop */
#sidebar-backdrop { display: none; }

/* ---------------------------------------------------------------------------
 * Responsive
 * ------------------------------------------------------------------------- */
@media (max-width: 860px) {
  :root { --sidebar-w: 290px; }
  #sidebar {
    position: fixed; top: var(--toolbar-h); bottom: 0; left: 0; z-index: 30;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  #sidebar.is-open { transform: translateX(0); }
  #sidebar-backdrop.is-open { display: block; position: fixed; inset: var(--toolbar-h) 0 0 0; background: rgba(0,0,0,.45); z-index: 25; }
  .btn-filters-m { display: inline-flex; }
  .change { grid-template-columns: 1fr; }
  .change-side { grid-column: 1; grid-row: auto; flex-direction: row; align-items: center; text-align: left; flex-wrap: wrap; margin-top: 8px; }
}
@media (max-width: 560px) {
  #content-head { padding: var(--sp-3); }
  #results-region { padding: var(--sp-3); }
  .brand-tag { display: none; }
  .seg button span.lbl { display: none; }
  /* stack search + sort so the dropdown can't overflow the viewport */
  .cb-row { flex-wrap: wrap; }
  #search-form { flex: 1 1 100%; }
  .sort-wrap { flex: 1 1 100%; }
  .sort-select { width: 100%; }
}
