/* ============================================================================
 * MSChanges — css/app.css
 * Self-contained app stylesheet: design tokens (dark default + light), toolbar,
 * search bar, product tabs, status filters, change feed, empty states, status
 * bar. No external resources. Token values mirror MSFinder / cmtrace.
 * ==========================================================================*/

/* ---- Self-hosted variable Manrope (relative to /css/) ---- */
@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-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;
  --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.32);

  --heading: #ffffff;
  --tile-fg: #ffffff;

  /* Change-status accents */
  --st-added: #39a751;
  --st-modified: #2f80ed;
  --st-renamed: #f59e0b;
  --st-removed: #e5484d;

  --shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);
  --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",
    "Cascadia Mono", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono",
    monospace;

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

  --toolbar-h: 56px;
  --status-h: 30px;
}

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

  --bg: #ffffff;
  --bg-elev: #f5f7f5;
  --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;
  --tile-fg: #ffffff;

  --st-added: #1f8f3d;
  --st-modified: #1d6fd6;
  --st-renamed: #c77700;
  --st-removed: #d33;

  --shadow: 0 10px 30px rgba(16, 24, 40, 0.16), 0 2px 6px rgba(16, 24, 40, 0.08);
  --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; }

[hidden] { display: none !important; }

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

/* Thin styled scrollbars */
* { 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; }

/* ---------------------------------------------------------------------------
 * App shell
 * ------------------------------------------------------------------------- */
#app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  background:
    radial-gradient(1100px 560px at 50% -10%, var(--accent-soft), transparent 70%),
    var(--bg);
}

/* ---------------------------------------------------------------------------
 * Toolbar
 * ------------------------------------------------------------------------- */
#toolbar {
  flex: 0 0 auto;
  height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.brand-home {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.18rem;
  letter-spacing: -0.02em;
  color: var(--heading);
}
.brand-home:hover { text-decoration: none; }
.brand-glyph { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px; display: block; }
.brand-name { color: var(--heading); }
.brand-dev { color: var(--accent); }

.tb-spacer { flex: 1 1 auto; }
.tb-group { display: inline-flex; align-items: center; gap: var(--sp-1); }

.tb-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.tb-btn:hover { background: var(--hover-bg); color: var(--fg); text-decoration: none; }
.tb-btn:active { background: var(--active-bg); }
.tb-btn .icon { width: 18px; height: 18px; pointer-events: none; }

/* Sun / moon swap by theme */
.icon-sun { display: none; }
:root[data-theme="light"] .icon-sun { display: inline-block; }
:root[data-theme="light"] .icon-moon { display: none; }

@media (max-width: 620px) { .tb-label { display: none; } }

/* ---------------------------------------------------------------------------
 * Main / feed stage
 * ------------------------------------------------------------------------- */
#main {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#feed-stage {
  width: 100%;
  max-width: 940px;
  padding: clamp(1.2rem, 3.5vw, 2.4rem) var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* ---- Page intro ---- */
.stage-head { display: flex; flex-direction: column; gap: 6px; }
.stage-title {
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--heading);
  margin: 0;
}
.stage-title .accent { color: var(--accent); }
.stage-sub { margin: 0; color: var(--fg-dim); font-size: 0.95rem; }

/* ---- Command / search bar ---- */
#search-form { width: 100%; }
#command-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  height: 56px;
  padding: 0 var(--sp-3) 0 var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
#command-bar:focus-within { border-color: var(--accent-border); box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); }
.cb-icon { flex: 0 0 auto; width: 22px; height: 22px; color: var(--fg-dim); }
.cb-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.cb-input:focus { outline: none; }
.cb-input::placeholder { color: var(--fg-faint); font-weight: 500; }
.cb-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.cb-clear {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 999px; color: var(--fg-dim);
}
.cb-clear:hover { background: var(--hover-bg); color: var(--fg); }
.cb-clear .icon { width: 16px; height: 16px; }
.cb-hint {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg-dim);
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * Filters: product tabs + status + window
 * ------------------------------------------------------------------------- */
#filters { display: flex; flex-direction: column; gap: var(--sp-3); }

/* Product tabs — single-select, scrollable on small screens */
.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--fg-dim);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.tab:hover { color: var(--fg); border-color: var(--border-strong); }
.tab.is-active { color: var(--heading); background: var(--active-bg); border-color: var(--border-strong); }
.tab .tab-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bg-elev) 70%, transparent);
}
.tab.tab-all .tab-dot { background: var(--accent); }
.tab-count {
  font-variant-numeric: tabular-nums;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--fg-faint);
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
}
.tab.is-active .tab-count { color: var(--heading); background: color-mix(in srgb, var(--fg) 14%, transparent); }

/* Bottom filter row: status pills (left) + window select (right) */
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.status-toggle { display: inline-flex; flex-wrap: wrap; gap: var(--sp-2); }
.status-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--fg-faint);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease, opacity 0.14s ease;
}
.status-btn:hover { color: var(--fg); border-color: var(--border-strong); }
.status-btn.is-active { color: var(--fg); border-color: var(--border-strong); background: var(--hover-bg); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: currentColor; opacity: 0.45; }
.status-btn.is-active .status-dot { opacity: 1; }
.status-btn[data-status="added"] .status-dot { color: var(--st-added); }
.status-btn[data-status="modified"] .status-dot { color: var(--st-modified); }
.status-btn[data-status="renamed"] .status-dot { color: var(--st-renamed); }
.status-btn[data-status="removed"] .status-dot { color: var(--st-removed); }

.window-select {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px;
  gap: 2px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.window-btn {
  height: 28px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--fg-dim);
  transition: background-color 0.14s ease, color 0.14s ease;
}
.window-btn:hover { color: var(--fg); }
.window-btn.is-active { color: var(--accent-fg); background: var(--accent); }

/* ---------------------------------------------------------------------------
 * Change feed
 * ------------------------------------------------------------------------- */
#feed { display: flex; flex-direction: column; gap: var(--sp-3); }

.day-group { display: flex; flex-direction: column; gap: 6px; }
.day-head {
  position: sticky;
  top: -1px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 2px 4px;
  background: linear-gradient(var(--bg) 60%, transparent);
}
.day-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
}
.day-rule { flex: 1 1 auto; height: 1px; background: var(--border); }
.day-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

#feed-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.change {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 3px solid var(--st-modified);
  background: var(--bg-elev);
  color: var(--fg);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.change:hover { background: var(--hover-bg); }
.change.st-added { border-left-color: var(--st-added); }
.change.st-modified { border-left-color: var(--st-modified); }
.change.st-renamed { border-left-color: var(--st-renamed); }
.change.st-removed { border-left-color: var(--st-removed); }

.change-tile {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--tile-fg);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  margin-top: 1px;
}
.change-tile .svc-ico { width: 22px; height: 22px; display: block; }
/* Real product logos render full-colour on a white tile. */
.change-tile .svc-logo { width: 26px; height: 26px; object-fit: contain; display: block; }
.change-tile.has-logo { box-shadow: inset 0 0 0 1px var(--border); text-shadow: none; }
.change { cursor: pointer; }
.change:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.change-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.change-title-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.change-title {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
}
.change-title mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 1px; font-weight: 800; }

.badge {
  flex: 0 0 auto;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge.st-added { color: var(--st-added); background: color-mix(in srgb, var(--st-added) 14%, transparent); border-color: color-mix(in srgb, var(--st-added) 45%, transparent); }
.badge.st-modified { color: var(--st-modified); background: color-mix(in srgb, var(--st-modified) 14%, transparent); border-color: color-mix(in srgb, var(--st-modified) 45%, transparent); }
.badge.st-renamed { color: var(--st-renamed); background: color-mix(in srgb, var(--st-renamed) 14%, transparent); border-color: color-mix(in srgb, var(--st-renamed) 45%, transparent); }
.badge.st-removed { color: var(--st-removed); background: color-mix(in srgb, var(--st-removed) 14%, transparent); border-color: color-mix(in srgb, var(--st-removed) 45%, transparent); }

.change-crumb {
  font-size: 0.78rem;
  color: var(--fg-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crumb-sep { color: var(--fg-faint); margin: 0 5px; }
.crumb-product { font-weight: 700; color: var(--fg); }

.change-msg {
  font-size: 0.82rem;
  color: var(--fg-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}
.change-msg mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; padding: 0 1px; }

.change-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--fg-dim);
}
.meta-pill { display: inline-flex; align-items: center; gap: 5px; }
.meta-pill .icon { width: 13px; height: 13px; opacity: 0.8; }
.diffstat { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.diffstat .add { color: var(--st-added); font-weight: 700; }
.diffstat .del { color: var(--st-removed); font-weight: 700; }
.foot-sep { color: var(--fg-faint); }

.change-actions {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-left: var(--sp-2);
}
.change-time { font-size: 0.72rem; color: var(--fg-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.act-links { display: inline-flex; gap: 6px; }
.act-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  color: var(--fg-dim);
  border: 1px solid var(--border);
  background: var(--bg);
  transition: color 0.14s ease, border-color 0.14s ease, background-color 0.14s ease;
}
.act-link:hover { color: var(--accent); border-color: var(--accent-border); background: var(--accent-soft); text-decoration: none; }
.act-link .icon { width: 15px; height: 15px; }

/* ---------------------------------------------------------------------------
 * Empty / loading / end states
 * ------------------------------------------------------------------------- */
.feed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-2);
  padding: clamp(1.6rem, 6vw, 3.4rem) var(--sp-4);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}
.feed-empty-icon { width: 46px; height: 46px; color: var(--fg-faint); opacity: 0.8; }
.feed-empty-title { margin: 6px 0 0; font-size: 1.05rem; font-weight: 700; color: var(--heading); }
.feed-empty-sub { margin: 0; color: var(--fg-dim); font-size: 0.9rem; max-width: 44ch; }

.feed-end {
  text-align: center;
  color: var(--fg-faint);
  font-size: 0.78rem;
  padding: var(--sp-3) 0 var(--sp-2);
}

.load-more {
  align-self: center;
  margin-top: var(--sp-1);
  height: 40px;
  padding: 0 22px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--fg);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  transition: background-color 0.14s ease, border-color 0.14s ease;
}
.load-more:hover { background: var(--hover-bg); border-color: var(--accent-border); }

/* ---------------------------------------------------------------------------
 * Status bar
 * ------------------------------------------------------------------------- */
#statusbar {
  flex: 0 0 auto;
  height: var(--status-h);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-4);
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  font-size: 0.74rem;
  color: var(--fg-dim);
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}
#statusbar .status-item { font-variant-numeric: tabular-nums; }
#status-count { font-weight: 700; color: var(--fg); }
.status-spacer { flex: 1 1 auto; }
.status-live { display: inline-flex; align-items: center; gap: 6px; }
.status-live .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
@media (max-width: 560px) { #status-meta { overflow: hidden; text-overflow: ellipsis; } }

/* ---------------------------------------------------------------------------
 * Responsive — phones
 * ------------------------------------------------------------------------- */
@media (max-width: 640px) {
  #toolbar { padding: 0 var(--sp-3); }
  #feed-stage { padding: var(--sp-4) var(--sp-3) var(--sp-3); gap: var(--sp-3); }
  #command-bar { height: 52px; padding: 0 var(--sp-2) 0 var(--sp-3); gap: var(--sp-2); }
  .cb-hint { display: none; }
  .change { padding: 11px; gap: var(--sp-2); }
  .change-tile { width: 36px; height: 36px; }
  .change-actions { flex-direction: row; align-items: center; }
  .change-time { display: none; }
}

/* ---------------------------------------------------------------------------
 * Activity timeline (horizontal histogram, stacked by product)
 * ------------------------------------------------------------------------- */
#timeline-wrap {
  padding: var(--sp-3) var(--sp-4) 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}
.timeline-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 10px; }
.timeline-title {
  font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-dim);
}
.timeline-legend { display: flex; flex-wrap: wrap; gap: 10px; flex: 1 1 auto; }
.tl-leg { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--fg-dim); }
.tl-leg .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.timeline-clear {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; font-weight: 700; color: var(--accent);
  padding: 4px 9px; border-radius: 999px; border: 1px solid var(--accent-border); background: var(--accent-soft);
}
.timeline-clear:hover { filter: brightness(1.08); }
.timeline-clear .icon { width: 12px; height: 12px; }

.timeline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 74px;
}
.tl-bar {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: filter 0.12s ease, transform 0.08s ease;
}
.tl-bar:hover { filter: brightness(1.18); }
.tl-bar.is-active { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 3px; }
.tl-bar.is-dim { opacity: 0.32; }
.tl-seg { width: 100%; }
.tl-empty { width: 100%; height: 2px; background: var(--border); border-radius: 2px; }

.timeline-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.66rem;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

/* Floating tooltip */
.tl-tip {
  position: fixed;
  z-index: 1200;
  pointer-events: none;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  font-size: 0.74rem;
  color: var(--fg);
  transform: translate(-50%, calc(-100% - 10px));
}
.tl-tip .tt-when { font-weight: 700; color: var(--heading); margin-bottom: 4px; }
.tl-tip .tt-total { color: var(--fg-dim); margin-bottom: 4px; }
.tl-tip .tt-row { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.tl-tip .tt-row .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.tl-tip .tt-row .n { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; }

@media (max-width: 560px) {
  .timeline { height: 58px; }
  .timeline-legend { display: none; }
}

/* ---------------------------------------------------------------------------
 * Diff popup (modal)
 * ------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.5rem, 3vw, 2rem);
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal-x {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--fg-dim);
  background: var(--bg);
  border: 1px solid var(--border);
  z-index: 2;
}
.modal-x:hover { color: var(--fg); background: var(--hover-bg); }
.modal-x .icon { width: 16px; height: 16px; }
.modal-body {
  overflow-y: auto;
  padding: var(--sp-4) clamp(var(--sp-4), 3vw, 26px);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.modal-head { display: flex; align-items: flex-start; gap: var(--sp-3); padding-right: 38px; }
.modal-titles { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.modal-title-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.modal-title { font-size: 1.2rem; font-weight: 800; color: var(--heading); margin: 0; letter-spacing: -0.01em; }
.modal-msg { margin: 0; color: var(--fg); font-size: 0.95rem; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--border); }
.modal-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2);
  font-size: 0.76rem; color: var(--fg-dim);
}
.modal-meta code { font-family: var(--font-mono); }
.modal-meta .mono { font-family: var(--font-mono); width: 100%; color: var(--fg-faint); word-break: break-all; }

.diff {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow-x: auto;
  max-height: 46vh;
  overflow-y: auto;
}
.dl { white-space: pre; padding: 0 12px; }
.dl-add { background: color-mix(in srgb, var(--st-added) 16%, transparent); color: var(--st-added); }
.dl-del { background: color-mix(in srgb, var(--st-removed) 15%, transparent); color: var(--st-removed); }
.dl-hunk { background: color-mix(in srgb, var(--st-modified) 14%, transparent); color: var(--st-modified); font-weight: 600; }
.dl-meta { color: var(--fg-faint); }
.dl-ctx { color: var(--fg-dim); }
:root[data-theme="light"] .dl-add { color: #137a36; }
:root[data-theme="light"] .dl-del { color: #c0322b; }

.diff-none, .diff-trunc {
  font-size: 0.85rem; color: var(--fg-dim);
  padding: 12px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--bg);
}
.diff-trunc { border-style: solid; text-align: center; color: var(--fg-faint); font-size: 0.78rem; }

.modal-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); padding-top: var(--sp-1); }
.btn-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.86rem; font-weight: 700; color: var(--accent);
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--accent-border); background: var(--accent-soft);
}
.btn-link:hover { filter: brightness(1.08); text-decoration: none; }

@media (max-width: 560px) {
  .modal-meta .mono { display: none; }
  .diff { font-size: 0.72rem; }
}

/* ---------------------------------------------------------------------------
 * Motion preferences
 * ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
