/* SAM's Garage — dense, dark-first UI in the GenGIS house style. Colors are variables on :root; the light theme
   overrides them when the system prefers light (and no manual choice was made) or when data-theme="light". */
:root {
  --bg: #0b1118;
  --bg-2: #10171f;
  --bg-3: #182029;
  --bg-hover: #222c38;
  --border: #243040;
  --text: #e6ebf2;
  --text-dim: #93a0b3;
  --accent: #1db3a9;
  --accent-strong: #26c9bd;
  --accent-ink: #06201e;         /* text on accent */
  --accent-soft: rgba(29, 179, 169, .14);
  --link: #4fd1c7;
  --warn: #ffd166;
  --danger: #ff6b6b;
  --st-open: #3ecf8e;
  --st-pre: #7aa2ff;
  --st-fc: #f2b84b;
  --st-closed: #8d9aad;
  --new: #e4572e;
  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
  --scroll-thumb: #2e3b4c;
  --scroll-thumb-hover: #3f5064;
  --radius: 8px;
  --topbar-h: 52px;
  --panel-w: 264px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6f9; --bg-2: #ffffff; --bg-3: #eef1f5; --bg-hover: #e2e7ee; --border: #d3dae3;
    --text: #111a24; --text-dim: #4f5d6e; --accent: #0b7f78; --accent-strong: #096b65; --accent-ink: #ffffff;
    --accent-soft: rgba(11, 127, 120, .10); --link: #0a6f69; --warn: #8a5a00; --danger: #c62828;
    --st-open: #157a4a; --st-pre: #3459c4; --st-fc: #8a5a00; --st-closed: #5d6b7c; --new: #c2410c;
    --shadow: 0 8px 28px rgba(15, 30, 50, .18); --scroll-thumb: #c4ccd6; --scroll-thumb-hover: #a5b0bd; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f6f9; --bg-2: #ffffff; --bg-3: #eef1f5; --bg-hover: #e2e7ee; --border: #d3dae3;
  --text: #111a24; --text-dim: #4f5d6e; --accent: #0b7f78; --accent-strong: #096b65; --accent-ink: #ffffff;
  --accent-soft: rgba(11, 127, 120, .10); --link: #0a6f69; --warn: #8a5a00; --danger: #c62828;
  --st-open: #157a4a; --st-pre: #3459c4; --st-fc: #8a5a00; --st-closed: #5d6b7c; --new: #c2410c;
  --shadow: 0 8px 28px rgba(15, 30, 50, .18); --scroll-thumb: #c4ccd6; --scroll-thumb-hover: #a5b0bd; color-scheme: light;
}

* { box-sizing: border-box; }
/* thin scrollbars in the theme's colors (the standard properties; ::-webkit-scrollbar for Safari and older Chrome) */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border: 2px solid transparent; border-radius: 6px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 13px; line-height: 1.45; color: var(--text); background: var(--bg); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h1, h2, h3 { margin: 0; }
.hidden { display: none !important; }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.pad { padding: 12px var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-size: 12px; font-family: var(--mono); }
kbd { background: var(--bg-3); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; font-family: var(--mono); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: 8px; top: -40px; z-index: 5000; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; border-radius: 6px; }
.skip-link:focus { top: 8px; }
.noscript { padding: 24px; }

#app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }

/* ---------- buttons ---------- */
.btn {
  background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px; cursor: pointer;
  color: var(--text); line-height: 1.2; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-3); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  position: relative; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius);
  background: var(--bg-3); border: 1px solid var(--border); cursor: pointer; color: var(--text); padding: 0; text-decoration: none; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--bg-hover); }
.icon-btn[aria-current="page"] { border-color: var(--accent); color: var(--accent); }
.icon-btn.mini { width: 26px; height: 26px; background: transparent; border-color: transparent; color: var(--text-dim); font-size: 18px; }
.icon-btn.mini:hover { background: var(--bg-3); color: var(--text); }
.badge {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent);
  color: var(--accent-ink); font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
select, input[type="date"], input[type="text"], input[type="number"], textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px; color: var(--text);
}
select { height: 30px; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- top bar ---------- */
#topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 var(--gutter);
  padding-top: env(safe-area-inset-top, 0); box-sizing: content-box;
  background: var(--bg-2); border-bottom: 1px solid var(--border); flex: 0 0 auto; position: relative; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; flex: 0 0 auto; }
.brand .logo { display: block; border-radius: 6px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .2px; white-space: nowrap; }
.brand-accent { color: var(--accent); }
.search-wrap { position: relative; flex: 1 1 520px; max-width: 640px; margin: 0 auto; display: flex; align-items: center; min-width: 0; }
.search-icon { position: absolute; left: 10px; color: var(--text-dim); pointer-events: none; }
#q {
  flex: 1; width: 100%; min-width: 0; height: 34px; padding: 0 34px 0 34px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
#q:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search-kbd { position: absolute; right: 9px; color: var(--text-dim); pointer-events: none; }
#q:focus + .search-kbd, #q:not(:placeholder-shown) + .search-kbd { display: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* Desktop app: the top bar is the window's title bar (electron/main.js). Its empty parts move the window and a
   double-click on them maximizes it; its controls stay clickable. The system's window buttons sit over its right
   end (Windows, Linux: where env(titlebar-area-*) ends; about 138 px if the browser does not say) or, on macOS, its
   left end. Panels that cover the page (the side-panel drawer, a full-window topic) start below the bar, so the
   window can still be moved and its buttons stay clear. */
html[data-titlebar] #topbar { -webkit-app-region: drag; user-select: none; }
html[data-titlebar] #topbar :is(input, button, select, a, .search-wrap, .menu-wrap, .pill) { -webkit-app-region: no-drag; }
html[data-titlebar="overlay"] #topbar { padding-right: calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, calc(100vw - 138px)) + 8px); }
html[data-titlebar="mac"] #topbar { padding-left: 84px; }
html[data-titlebar] :is(#sidepanel, #detail, .scrim) { top: calc(var(--topbar-h) + 1px) !important; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-dim); font-size: 12px; white-space: nowrap; text-decoration: none;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-closed); flex: 0 0 auto; }
.pill.ok .dot { background: var(--st-open); }
.pill.warn .dot { background: var(--warn); }
.pill.stale .dot { background: var(--danger); }
.pill.fixture { border-color: var(--warn); color: var(--warn); }
.pill:hover { color: var(--text); }

/* ---------- layout ---------- */
#main {
  flex: 1 1 auto; min-height: 0; display: grid; position: relative;
  grid-template-columns: var(--panel-w) minmax(360px, 1fr) minmax(420px, 1.3fr);
  grid-template-areas: "panel results detail";
}
#results { grid-area: results; display: flex; flex-direction: column; min-width: 0; min-height: 0; border-right: 1px solid var(--border); }
#detail { grid-area: detail; overflow: auto; min-width: 0; min-height: 0; background: var(--bg); }
/* the views other than the list: a header (back home + title) over a scrolling body, beside the side panel */
.view { grid-column: 2 / -1; grid-row: 1; min-height: 0; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
#main:not([data-view="list"]) > :is(#results, #detail) { display: none; }
.view-head {
  display: flex; align-items: center; gap: 10px; padding: 8px var(--gutter); min-height: 46px; flex: 0 0 auto;
  border-bottom: 1px solid var(--border); background: var(--bg-2);
}
.view-head .list-title { outline: none; }
.view-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.back-home { padding-left: 4px; color: var(--text-dim); }
.back-home:hover { color: var(--text); }
#main:not(.mode-watch) #watchBack { display: none; }

/* ---------- side panel: navigation, filters (list of all topics only), pinned footer ---------- */
.sidepanel {
  grid-area: panel; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
  background: var(--bg-2); border-right: 1px solid var(--border);
}
.sp-head { display: none; align-items: center; gap: 8px; padding: 8px 8px 8px var(--gutter); border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.sp-head-title { flex: 1; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }
.sp-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.sp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-nav { padding: 8px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.sp-item {
  display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 6px 10px; border-radius: var(--radius);
  color: var(--text); text-decoration: none;
}
.sp-item svg { color: var(--text-dim); flex: 0 0 auto; }
.sp-item:hover { background: var(--bg-3); }
.sp-item:focus-visible { outline-offset: -2px; }
.sp-item[aria-current="page"] { background: var(--accent-soft); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sp-item[aria-current="page"] svg { color: var(--accent); }
.sp-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-count, .sp-version { color: var(--text-dim); font-size: 11.5px; font-weight: 400; font-variant-numeric: tabular-nums; }
.sp-filters { flex: 1 0 auto; display: flex; flex-direction: column; }
.sp-foot { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0)); display: flex; flex-direction: column; gap: 6px; }
.theme-seg { display: flex; flex-wrap: nowrap; }
.theme-seg button { flex: 1; padding: 5px 6px; min-height: 30px; }
.sp-results { display: none; position: sticky; bottom: 0; padding: 10px var(--gutter); background: var(--bg-2); border-top: 1px solid var(--border); }
.sp-results .btn { width: 100%; justify-content: center; min-height: 40px; }
.count-pill {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.grow { flex: 1; }

/* ---------- filters ---------- */
.filters-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 8px var(--gutter); border-bottom: 1px solid var(--border); }
.filters-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }
.filters-body { flex: 1 0 auto; padding: 4px 0 16px; }
.fsec { padding: 10px var(--gutter); border-bottom: 1px solid var(--border); }
.fsec:last-child { border-bottom: 0; }
.fsec h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); font-weight: 600; margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.fsec h3 .grow { flex: 1; }
.fsec h3 .btn { text-transform: none; letter-spacing: 0; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); cursor: pointer; font-size: 12px; line-height: 1.5; white-space: nowrap;
}
.chip:hover { background: var(--bg-hover); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.chip[aria-pressed="true"]::before { content: "✓"; color: var(--accent); font-weight: 700; }
.chip .n { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.chip.zero { opacity: .55; }
.checks { display: flex; flex-direction: column; gap: 1px; max-height: 260px; overflow: auto; }
.check { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; cursor: pointer; }
.check:hover { background: var(--bg-3); }
.check input { margin: 0; accent-color: var(--accent); width: 15px; height: 15px; flex: 0 0 auto; }
.check .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check .code { font-weight: 600; }
.check .n { color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }
.check.zero .lbl { opacity: .55; }
.subchecks { margin: 2px 0 6px 22px; border-left: 2px solid var(--border); padding-left: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--bg); border: 0; border-right: 1px solid var(--border); padding: 4px 9px; cursor: pointer; color: var(--text-dim); font-size: 12px; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.saved-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.saved-list li { display: flex; align-items: center; gap: 4px; }
.saved-list a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 4px; border-radius: 6px; text-decoration: none; }
.saved-list a:hover { background: var(--bg-3); }
.save-row input { flex: 1; min-width: 0; height: 28px; }

/* ---------- stats bar + list ---------- */
.statsbar { display: flex; align-items: center; gap: 10px; padding: 8px var(--gutter); border-bottom: 1px solid var(--border); background: var(--bg-2); flex-wrap: wrap; }
.list-title { font-size: 14px; font-weight: 700; }
.count { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.index-state { font-size: 11px; }
.stats-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.menu-wrap { position: relative; }
.dropdown { position: absolute; z-index: 40; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.dropdown.menu { right: 0; top: calc(100% + 4px); min-width: 180px; padding: 4px; display: flex; flex-direction: column; }
.dropdown.menu button { text-align: left; background: transparent; border: 0; padding: 7px 10px; border-radius: 6px; cursor: pointer; }
.dropdown.menu button:hover, .dropdown.menu button:focus-visible { background: var(--bg-3); }
.active-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--gutter); }
.active-chips:not(:empty) { padding: 8px var(--gutter); border-bottom: 1px solid var(--border); }
.active-chips .chip::after { content: "×"; color: var(--text-dim); font-size: 14px; line-height: 1; margin-left: 2px; }
.active-chips .chip.clear-all { border-style: dashed; }
.active-chips .chip.clear-all::after { content: none; }

.list { flex: 1; overflow: auto; padding: 8px var(--gutter) 24px; display: flex; flex-direction: column; gap: 8px; outline: none; overscroll-behavior: contain; }
.skeleton { height: 96px; border-radius: var(--radius); background: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; flex: 0 0 auto; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }
.empty { padding: 32px 8px; text-align: center; color: var(--text-dim); }
.empty .btn { margin-top: 10px; }
.more { text-align: center; padding: 8px; }

.card {
  position: relative; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px 10px;
  cursor: pointer; flex: 0 0 auto; transition: border-color .12s;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.card.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.card:focus-within { border-color: var(--accent); }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-right: 30px; font-size: 12px; }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.35; margin: 5px 0 4px; overflow-wrap: anywhere; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-title a:focus-visible { outline: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); } /* whole card is the link */
.card-title a:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 1px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--text-dim); }
.card-meta .topic { font-family: var(--mono); font-size: 11.5px; }
.close-date.soon { color: var(--danger); font-weight: 600; }
.close-date.past { text-decoration: line-through; }
/* forecasted / pre-release dates are estimates: a passed estimate is dim, never the red "closed" style */
.close-date.est-passed, .open-date.est-passed { color: var(--text-dim); font-style: italic; }
.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.open { color: var(--st-open); }
.status.pre_release { color: var(--st-pre); }
.status.forecasted { color: var(--st-fc); }
.status.closed, .status.unknown { color: var(--st-closed); }
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--bg-3); border: 1px solid var(--border); font-size: 11px; line-height: 17px; white-space: nowrap; color: var(--text); }
.tag.agency { font-weight: 600; }
.tag.new { background: var(--new); border-color: var(--new); color: #fff; font-weight: 700; letter-spacing: .4px; }
.kw { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.kw .tag { color: var(--text-dim); }
.prof { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 6px; font-size: 12px; }
.prof .p { color: var(--accent); font-weight: 600; }
.prof .p.inactive { color: var(--text-dim); font-weight: 500; }
.prof .terms { color: var(--text-dim); }
.prof .score { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.star {
  position: absolute; top: 6px; right: 6px; z-index: 1; width: 30px; height: 30px; border: 0; background: transparent; cursor: pointer;
  color: var(--text-dim); border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.star:hover { background: var(--bg-3); color: var(--text); }
.star[aria-pressed="true"] { color: var(--warn); }
.star svg { width: 18px; height: 18px; }
.star[aria-pressed="true"] svg path { fill: currentColor; }

/* ---------- detail ---------- */
.detail-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 4px; }
.detail-empty p { margin: 4px 0; }
.d-wrap { padding: 14px var(--gutter) 40px; max-width: 900px; }
.d-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; position: sticky; top: 0; background: var(--bg); padding: 8px 0; z-index: 2; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.d-toolbar .grow { flex: 1; }
.d-back { display: none; }
.d-title { font-size: 19px; line-height: 1.3; font-weight: 700; margin: 6px 0 8px; overflow-wrap: anywhere; outline: none; }
.d-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.d-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 14px 0; font-size: 13px; }
.d-grid dt { color: var(--text-dim); }
.d-grid dd { margin: 0; overflow-wrap: anywhere; }
.d-section { margin-top: 18px; }
.d-section h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin-bottom: 8px; }
.d-desc p { margin: 0 0 10px; line-height: 1.6; font-size: 14px; max-width: 75ch; }
.d-links { display: flex; flex-direction: column; gap: 4px; }
.d-links a { overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0; }
.timeline li { position: relative; flex: 1 1 110px; min-width: 100px; padding: 18px 8px 0 0; font-size: 12px; }
.timeline li::before { content: ""; position: absolute; top: 6px; left: 0; right: 0; height: 2px; background: var(--border); }
.timeline li::after { content: ""; position: absolute; top: 2px; left: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--text-dim); }
.timeline li.past::before { background: var(--accent); }
.timeline li.past::after { background: var(--accent); border-color: var(--accent); }
.timeline li.today::after { box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline li.est::after { border-style: dashed; }
.timeline li.est-passed .when, .timeline li.est-passed .rel { color: var(--text-dim); font-style: italic; }
.timeline li.est-passed .when { font-weight: 400; }
.link-hint { color: var(--text-dim); }
.timeline .lbl { color: var(--text-dim); display: block; }
.timeline .when { font-weight: 600; }
.timeline .rel { color: var(--text-dim); display: block; font-size: 11px; }
.changelog { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.changelog li { padding: 4px 0; border-bottom: 1px dashed var(--border); }
.loading-line { height: 12px; border-radius: 4px; background: var(--bg-3); margin: 8px 0; animation: shimmer 1.2s infinite linear; background-size: 200% 100%; background-image: linear-gradient(90deg, var(--bg-2), var(--bg-3), var(--bg-2)); }

/* ---------- SQL console ---------- */
.sql { display: grid; grid-template-columns: 240px 1fr; height: 100%; min-height: 0; }
.sql-schema { border-right: 1px solid var(--border); overflow: auto; padding: 12px var(--gutter); background: var(--bg-2); font-size: 12px; }
.sql-schema h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin-bottom: 8px; }
.sql-schema details { margin-bottom: 4px; }
.sql-schema summary { cursor: pointer; font-weight: 600; padding: 2px 0; }
.sql-schema summary .k { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.sql-schema ul { list-style: none; margin: 2px 0 6px 12px; padding: 0; }
.sql-schema li { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }
.sql-schema li b { color: var(--text); font-weight: 500; }
.sql-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 12px var(--gutter); gap: 8px; overflow: auto; }
.sql-main textarea { width: 100%; min-height: 140px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.5; tab-size: 2; }
.sql-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sql-bar .grow { flex: 1; }
.sql-msg { font-size: 12px; }
.sql-msg.err { color: var(--danger); white-space: pre-wrap; font-family: var(--mono); }
.sql-out { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); min-height: 80px; flex: 1 1 auto; }
.sql-out table { border-collapse: collapse; font-size: 12px; width: max-content; min-width: 100%; }
.sql-out th, .sql-out td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sql-out th { position: sticky; top: 0; background: var(--bg-3); font-weight: 600; }
.sql-out td.num { text-align: right; font-variant-numeric: tabular-nums; }
.sql-out td.null { color: var(--text-dim); font-style: italic; }
.notice { border: 1px solid var(--border); border-left: 4px solid var(--warn); background: var(--bg-2); border-radius: var(--radius); padding: 14px 16px; max-width: 720px; }
.notice h2 { font-size: 15px; margin-bottom: 6px; }
.notice p { margin: 6px 0; }
.progress { height: 6px; background: var(--bg-3); border-radius: 3px; overflow: hidden; max-width: 360px; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .15s; }

/* ---------- about ---------- */
.about { padding: 16px var(--gutter) 40px; max-width: 860px; margin: 0 auto; }
.about h2 { font-size: 14px; margin: 22px 0 8px; }
.about-app { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.about-app img { border-radius: 8px; flex: 0 0 auto; }
.about-app h2 { font-size: 18px; margin: 0; }
.about-app p { margin: 0; }
.about p, .about li { line-height: 1.6; }
.about table { border-collapse: collapse; width: 100%; font-size: 12px; }
.about th, .about td { border-bottom: 1px solid var(--border); padding: 5px 8px; text-align: left; }
.about .ok { color: var(--st-open); }
.about .bad { color: var(--danger); }
.table-wrap { overflow-x: auto; }

/* ---------- settings (#/settings) ---------- */
.settings .set-sec { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 4px; }
.settings .set-sec:first-child { border-top: 0; margin-top: 0; }
.settings .set-sec h2 { margin: 12px 0 8px; }
.settings .theme-seg { display: inline-flex; min-width: 240px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; align-items: center; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; }

/* ---------- notifications (#/notify) ---------- */
.notify { padding: 16px var(--gutter) 48px; max-width: 860px; margin: 0 auto; }
.notify p, .notify li { line-height: 1.55; }
.nf-sec { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.nf-sec h2 { font-size: 15px; margin-bottom: 8px; }
.nf-sec h2.inline { display: inline; }
.nf-sec h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin: 14px 0 6px; }
.nf-sec summary { cursor: pointer; }
.nf-checks { display: flex; flex-direction: column; gap: 2px; }
.nf-toggle .lbl { white-space: normal; }
.nf-time { display: inline-flex; align-items: center; gap: 6px; }
.nf-time input { height: 30px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 8px; }
.nf-chips { margin: 6px 0; }
.nf-chip::after { content: "×"; color: var(--text-dim); font-size: 14px; line-height: 1; margin-left: 4px; }
.nf-add input { flex: 1 1 220px; min-width: 0; height: 30px; }
.nf-profiles { max-height: none; }
.nf-profiles .lbl { white-space: normal; overflow: visible; }
.nf-chans { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.nf-chan { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; background: var(--bg-2); }
.nf-chan.off { opacity: .7; }
.nf-chan p { margin: 6px 0 0; overflow-wrap: anywhere; }
.nf-chan .grow { flex: 1; }
.nf-name { font-weight: 700; overflow-wrap: anywhere; }
.nf-on { padding: 0; }
.nf-only { border-color: var(--warn); color: var(--warn); }
.nf-bad { border-color: var(--danger); color: var(--danger); }
.nf-form { display: grid; gap: 8px; }
.nf-form label { display: grid; gap: 3px; font-size: 12px; color: var(--text-dim); }
.nf-field { flex-wrap: nowrap; }
.nf-field input { flex: 1; min-width: 0; height: 30px; font-family: var(--mono); font-size: 12px; }
.nf-errors p { color: var(--danger); margin: 2px 0; }
.nf-addchan { margin-top: 4px; }
.warn-text { color: var(--warn); }
.nf-report { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; margin-top: 10px; background: var(--bg-2); }
.nf-headline { font-weight: 700; margin: 0 0 4px; }
.nf-rsec h3 { margin-top: 10px; }
.nf-rsec ul { margin: 0; padding-left: 18px; }
.nf-rsec li { margin: 4px 0; overflow-wrap: anywhere; }
.nf-payloads { margin-top: 10px; }
.nf-pre { width: 100%; max-height: 320px; overflow: auto; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; font-family: var(--mono); font-size: 11.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.nf-where { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; }
.nf-where dt { font-weight: 600; }
.nf-where dd { margin: 0; }
.nf-warn { margin: 8px 0; }
@media (max-width: 700px) {
  .nf-where { grid-template-columns: 1fr; gap: 2px; }
  .nf-where dd { margin-bottom: 8px; }
}

/* ---------- dialog (profiles) ---------- */
dialog {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  padding: 0; width: min(640px, calc(100vw - 2 * var(--gutter))); max-height: calc(100dvh - 48px);
}
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 12px var(--gutter); border-bottom: 1px solid var(--border); }
.dlg-head h2 { font-size: 15px; flex: 1; }
.dlg-body { padding: 12px var(--gutter); overflow: auto; max-height: calc(100dvh - 160px); }
.prof-item { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.prof-item .row { margin-bottom: 6px; }
.prof-item .name { font-weight: 700; flex: 1; }
.prof-item .terms { color: var(--text-dim); font-size: 12px; overflow-wrap: anywhere; }
.prof-form { display: grid; gap: 8px; }
.prof-form label { display: grid; gap: 3px; font-size: 12px; color: var(--text-dim); }
.prof-form textarea { min-height: 80px; font-family: var(--mono); font-size: 12px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%); z-index: 4000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 2 * var(--gutter)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; background: var(--bg-3); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px 8px 14px; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .18s ease-out;
}
.toast .msg { flex: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

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

/* ---------- wide: the side panel is a docked column; the menu button collapses it (prefs.panelCollapsed) ---------- */
@media (min-width: 1280px) {
  .panel-collapsed #main { grid-template-columns: 0 minmax(360px, 1fr) minmax(420px, 1.3fr); }
  .panel-collapsed #sidepanel { visibility: hidden; border-right: 0; }
}
/* ---------- medium widths: the side panel is an overlay drawer; list + detail stay side by side ---------- */
@media (max-width: 1279px) {
  #main { grid-template-columns: minmax(340px, 1fr) minmax(400px, 1.25fr); grid-template-areas: "results detail"; }
  #sidepanel {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(320px, calc(100vw - 48px)); z-index: 50;
    transform: translateX(-102%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s;
    box-shadow: var(--shadow); padding-top: env(safe-area-inset-top, 0);
  }
  body.panel-open #sidepanel { transform: none; visibility: visible; transition: transform .2s ease; }
  .sp-head { display: flex; }
  .sp-results { display: block; }
  .sp-item { min-height: 40px; }
  .theme-seg button { min-height: 36px; }
  .view { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  #sidepanel, body.panel-open #sidepanel { transition: none; }
}

/* ---------- narrow: stacked list; detail is a full-screen route ---------- */
@media (max-width: 1023px) {
  #main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "results"; }
  #results { border-right: 0; }
  #detail {
    position: fixed; inset: 0; z-index: 40; display: none; padding-top: env(safe-area-inset-top, 0);
  }
  #main[data-detail="open"] > #detail { display: block; }
  .d-back { display: inline-flex; }
  .detail-empty { display: none; }
}
/* the name beside the logo only when there is room for it; on phones the icon alone is the brand */
@media (max-width: 720px) {
  .brand-name { display: none; }
}
@media (max-width: 700px) {
  :root { --gutter: 12px; }
  .freshness .txt, .search-kbd { display: none; }
  .freshness { padding: 4px 8px; }
  #topbar { gap: 6px; }
  .topbar-right { gap: 4px; }
  .icon-btn { width: 36px; height: 36px; }
  .sql { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sql-schema { border-right: 0; border-bottom: 1px solid var(--border); max-height: 30vh; }
  .d-grid { grid-template-columns: 1fr; gap: 0; }
  .d-grid dt { margin-top: 6px; }
  .stats-right { margin-left: 0; width: 100%; }
  .stats-right select { flex: 1; min-width: 0; }
}
/* phones: the search gets its own full-width row under the brand and icons */
@media (max-width: 560px) {
  #topbar { height: auto; flex-wrap: wrap; row-gap: 8px; padding-top: calc(8px + env(safe-area-inset-top, 0)); padding-bottom: 8px; }
  .search-wrap { order: 10; flex: 1 1 100%; max-width: none; }
  .topbar-right { margin-left: auto; }
  #q { height: 38px; font-size: 16px; } /* 16px keeps iOS from zooming on focus */
}
@media (max-width: 400px) {
  #installBtn { display: none !important; }
  .brand .logo { width: 24px; height: 24px; }
}
@media print {
  #topbar, #sidepanel, #results, .d-toolbar, .toasts { display: none !important; }
  body { overflow: visible; }
  #main { display: block; }
  #detail { position: static !important; display: block !important; }
}
