/* =========================================================
   FireHose web_v2 — production component stylesheet
   ---------------------------------------------------------
   Consumes tokens from /design-system/colors_and_type.css.
   Selectors use --bg-1, --fg-1, --accent etc. directly (the
   :root layer); theme switching happens via [data-theme] on
   <html>.

   Sections:
     1. Base + utility
     2. App shell (top nav, main, footer)
     3. Buttons
     4. Inputs (text, search, affix, select, textarea, toggle,
        checkbox, radio, slider, tags, chips)
     5. Cards (signal cards + generic)
     6. Tier sections (briefing structure)
     7. Modals
     8. Toasts
     9. Tooltips
    10. Popovers
    11. Dropdowns / menus
    12. Tabs / segmented
    13. Breadcrumbs
    14. Pagination
    15. Empty states
    16. Skeleton (loading)
    17. Progress (linear + circular)
    18. Charts (sparkline / bar / heatmap)
    19. Avatar / source masthead / stack
    20. Date inputs + calendar
    21. Mobile (bottom nav + sheet)
    22. Reader prose
    23. Badge + alert
   ========================================================= */

/* ===== 1. BASE + UTILITY ===== */
*, *::before, *::after { box-sizing: border-box; }
html { font-family: var(--font-body); }
body {
  margin: 0;
  font-size: var(--fs-14);
  line-height: var(--lh-ui);
  color: var(--fg-1);
  background: var(--bg-0);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
[x-cloak] { display: none !important; }

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

/* Eyebrow utility */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--fg-3);
  font-weight: var(--fw-medium);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 2px 5px;
  border: 1px solid var(--border-strong);
  background: var(--bg-2);
  border-radius: 2px;
  line-height: 1;
  color: var(--fg-3);
}
/* Keyboard hints are useless on touch devices and they push button content
 * past the viewport edge on the reader action bar at narrow widths. */
@media (max-width: 640px) {
  .kbd { display: none; }
}

.numeric, .num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.measure { max-width: var(--container-prose); margin: 0 auto; }
.surface { background: var(--bg-1); border: 1px solid var(--border); }
.surface.surface-raised { background: var(--bg-2); }
.hairline { height: 1px; background: var(--border); margin: var(--space-8) 0; border: 0; }

.section-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: var(--space-9) 0 var(--space-7);
}
.section-head h2 { margin: 0; }
.section-head .eyebrow { color: var(--fg-3); }
.section-head .section-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--fg-3);
}
/* The .row.between inside .section-head puts the h1-display next to the
 * "N ranked · {timestamp}" meta. At narrow widths the h1 wraps and the meta
 * overlaps it. Wrap to column instead so meta sits below the title. */
.section-head .row.between {
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Lucide icon container default */
i.lucide, [data-lucide] {
  display: inline-flex;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  flex: none;
}
i.lucide svg, [data-lucide] svg { stroke-width: 1.5; }

/* ===== 2. APP SHELL ===== */
.app-main {
  max-width: var(--container-app);
  margin: 0 auto;
  padding: var(--space-9) var(--space-7) var(--space-11);
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: color-mix(in oklch, var(--bg-1) 92%, transparent);
  backdrop-filter: saturate(var(--saturate-nav)) blur(var(--blur-nav));
  -webkit-backdrop-filter: saturate(var(--saturate-nav)) blur(var(--blur-nav));
  border-bottom: 1px solid var(--border);
}

[data-theme='light'] .top-nav,
:root:not([data-theme='dark']) .top-nav {
  background: color-mix(in oklch, var(--bg-1) 92%, transparent);
}
.top-nav-inner {
  width: 100%;
  max-width: var(--container-app);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: 0 var(--space-7);
  height: 56px;
}
.top-nav .brand { display: flex; align-items: center; }
.top-nav .brand-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--fg-1);
  min-height: 34px;
}
.top-nav .brand-mark {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border-strong);
  background: var(--bg-1);
  color: var(--fg-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 15px;
  border-radius: var(--radius-2);
}
.top-nav .brand-word {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}
.top-nav .signal-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.top-nav .mobile-nav-title {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  font-family: var(--font-display);
  font-size: var(--fs-16);
  font-weight: 600;
  color: var(--fg-1);
  text-align: center;
}
.top-nav .nav-items {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  gap: 2px;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg-1);
  border-radius: var(--radius-2);
  padding: 3px;
}

[data-theme='light'] .top-nav .brand-mark,
:root:not([data-theme='dark']) .top-nav .brand-mark,
[data-theme='light'] .top-nav .nav-items,
:root:not([data-theme='dark']) .top-nav .nav-items,
[data-theme='light'] .top-nav .user-pill,
:root:not([data-theme='dark']) .top-nav .user-pill {
  background: var(--bg-1);
}
.top-nav .nav-items a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--radius-1);
  color: var(--fg-3);
  text-decoration: none;
  font-size: var(--fs-12);
  font-weight: 500;
  transition: color var(--dur-chrome) var(--ease), background var(--dur-chrome) var(--ease);
}
.top-nav .nav-items a:hover {
  color: var(--fg-1);
  background: var(--bg-2);
}
.top-nav .nav-items a.active {
  color: var(--fg-1);
  background: var(--bg-0);
  box-shadow: inset 0 0 0 1px var(--border);
}

[data-theme='light'] .top-nav .nav-items a:hover,
:root:not([data-theme='dark']) .top-nav .nav-items a:hover {
  background: var(--bg-2);
}

[data-theme='light'] .top-nav .nav-items a.active,
:root:not([data-theme='dark']) .top-nav .nav-items a.active {
  background: var(--bg-0);
}
.top-nav .nav-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Theme toggle: show/hide sun vs moon based on current theme */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme='dark'] .theme-toggle .icon-sun  { display: block; }
[data-theme='dark'] .theme-toggle .icon-moon { display: none; }

.top-nav .user-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  text-decoration: none;
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: var(--fs-11);
}
.top-nav .user-pill .initials {
  width: 26px; height: 26px;
  background: var(--bg-2);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
}

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 640px) {
  .app-main {
    padding: var(--space-7) var(--space-5) calc(72px + var(--space-8));
  }
  .top-nav {
    height: 48px;
  }
  .top-nav-inner {
    gap: var(--space-4);
    padding: 0 var(--space-5);
    height: 48px;
  }
  .top-nav .nav-items { display: none; }
  .top-nav .brand-word { display: none; }
  .top-nav .mobile-nav-title { display: inline-flex; }
  .top-nav .nav-right { margin-left: 0; }
  .top-nav .user-pill { display: none; }

  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-nav);
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--border);
    background: color-mix(in oklch, var(--bg-1) 94%, transparent);
    backdrop-filter: saturate(var(--saturate-nav)) blur(var(--blur-nav));
    -webkit-backdrop-filter: saturate(var(--saturate-nav)) blur(var(--blur-nav));
  }
  .mobile-bottom-nav a {
    min-width: 0;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--fg-3);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .mobile-bottom-nav a.active {
    color: var(--fg-1);
    box-shadow: inset 0 2px 0 var(--accent);
  }
  .mobile-bottom-nav i,
  .mobile-bottom-nav [data-lucide] {
    width: 20px;
    height: 20px;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .top-nav,
  .mobile-bottom-nav {
    background: var(--bg-1);
  }
}

/* ===== 3. BUTTONS ===== */
.btn {
  font-family: var(--font-body);
  font-size: var(--fs-13);
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  min-height: 34px;
  /* Multi-word button labels (Save to queue / Open original / Hide notes) used to
   * wrap inside the button at narrow widths, producing 2- and 3-line buttons in
   * the reader action bar. Pair with `flex-wrap: wrap` on the parent row so the
   * buttons themselves stack onto new rows instead of breaking text. */
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--fg-1);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  transition:
    background-color var(--dur-chrome) var(--ease),
    border-color var(--dur-chrome) var(--ease),
    color var(--dur-chrome) var(--ease),
    box-shadow var(--dur-chrome) var(--ease),
    transform var(--dur-chrome) var(--ease);
}
.btn:focus:not(:focus-visible) { outline: none; }
.btn:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: 2px; }
.btn[disabled], .btn[aria-disabled="true"] {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
  pointer-events: none;
}
.btn-sm { font-size: var(--fs-12); padding: 6px 10px; min-height: 28px; }
.btn-lg { font-size: var(--fs-14); padding: 12px 18px; min-height: 42px; }
.btn-icon { padding: 0; width: 34px; height: 34px; min-height: 0; }
.btn-icon.btn-sm { width: 28px; height: 28px; }

.btn-primary { background: var(--fg-1); color: var(--bg-1); border-color: var(--fg-1); }
.btn-primary:hover { background: var(--fg-2); border-color: var(--fg-2); }
.btn-primary:active { background: var(--fg-2); box-shadow: inset 0 1px 0 color-mix(in oklch, var(--fg-1) 18%, transparent); transform: translateY(1px); }

.btn-secondary { background: transparent; color: var(--fg-1); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-2); border-color: var(--fg-1); }
.btn-secondary:active { background: var(--bg-3); border-color: var(--fg-1); transform: translateY(1px); }

.btn-ghost { background: transparent; color: var(--fg-1); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-2); }
.btn-ghost:active { background: var(--bg-3); transform: translateY(1px); }

.btn-accent { background: var(--accent); color: var(--accent-on); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-accent:active { box-shadow: inset 0 1px 0 color-mix(in oklch, var(--fg-1) 22%, transparent); transform: translateY(1px); }

.btn-accent-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-accent-outline:hover { background: var(--accent-soft); }

.btn-danger { background: var(--danger); color: var(--accent-on); border-color: var(--danger); }
.btn-danger:hover { background: var(--accent-hover); }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }

.btn-success { background: var(--success); color: var(--accent-on); border-color: var(--success); }
.btn-success-outline { background: transparent; color: var(--success); border-color: var(--success); }

.btn-warning-outline { background: transparent; color: var(--warning); border-color: var(--warning); }

.btn-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  overflow: hidden;
}
.btn-group .btn {
  border-radius: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--fg-2);
}
.btn-group .btn:last-child { border-right: 0; }
.btn-group .btn:hover { background: var(--bg-2); color: var(--fg-1); }
.btn-group .btn[aria-pressed="true"] {
  background: var(--bg-3);
  color: var(--fg-1);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}
.btn svg { width: 14px; height: 14px; flex: none; }

/* ===== 4. INPUTS ===== */
.field-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-body);
  font-size: var(--fs-13);
  line-height: 1.35;
  padding: 9px 12px;
  min-height: 34px;
  color: var(--fg-1);
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  caret-color: var(--accent);
  transition:
    background-color var(--dur-chrome) var(--ease),
    border-color var(--dur-chrome) var(--ease),
    box-shadow var(--dur-chrome) var(--ease);
}
.input::placeholder { color: var(--fg-4); }
.input:hover { border-color: var(--fg-2); }
.input:focus, .input.is-focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.input:focus:not(:focus-visible), .input.is-focus { outline: none; }
.input[disabled], .input.is-disabled {
  color: var(--fg-4);
  background: var(--bg-2);
  border-color: var(--border);
  cursor: not-allowed;
}
.input-sm { font-size: var(--fs-12); padding: 6px 10px; min-height: 28px; }
.input-lg { font-size: var(--fs-14); padding: 12px 14px; min-height: 42px; }
.input.is-success {
  border-color: var(--success);
  background: color-mix(in oklch, var(--success) 10%, var(--bg-1));
}
.input.is-warning {
  border-color: var(--warning);
  background: color-mix(in oklch, var(--warning) 10%, var(--bg-1));
}
.input.is-danger, .input[aria-invalid="true"] {
  border-color: var(--danger);
  background: color-mix(in oklch, var(--danger) 10%, var(--bg-1));
}

textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }

/* Highlight/quote textarea — display font + italic, used in
   reader.html annotation create form. */
textarea.input.ann-quote {
  font-family: var(--font-display);
  font-style: italic;
}

.msg {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-3);
}
.msg.is-success { color: var(--success); }
.msg.is-warning { color: var(--warning); }
.msg.is-danger { color: var(--danger); }
.msg .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.search { position: relative; }
.search .input { padding-left: 34px; padding-right: 56px; }
.search .icon-search {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--fg-3);
  width: 14px; height: 14px;
}
.search .kbd-hint {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
}

.affix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  background: var(--bg-1);
  overflow: hidden;
}
.affix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.affix .tag {
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--fg-3);
  background: var(--bg-2);
  padding: 0 12px;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--border);
}
.affix .tag.right { border-right: 0; border-left: 1px solid var(--border); }
.affix input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--fg-1);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: var(--fs-13);
  min-width: 0;
}
.affix input:focus:not(:focus-visible) { outline: none; }

.select-wrap { position: relative; display: inline-block; width: 100%; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1px solid var(--fg-2);
  border-bottom: 1px solid var(--fg-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
select.input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
}

.tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 8px;
  min-height: 34px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  align-items: center;
}
.tags .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-1);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 2px 4px 2px 8px;
  border-radius: var(--radius-1);
}

.opt-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.opt-row:first-child { border-top: 0; }
.opt-row .copy { flex: 1; font-size: var(--fs-13); color: var(--fg-1); }
.opt-row .copy small {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  margin-top: 2px;
}
.toggle {
  position: relative;
  width: 32px; height: 18px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  flex: none;
  transition: background var(--dur-chrome) var(--ease);
}
.toggle::after {
  content: "";
  position: absolute;
  left: 2px; top: 50%;
  width: 12px; height: 12px;
  background: var(--fg-2);
  border-radius: 50%;
  transform: translateY(-50%);
  transition: left var(--dur-chrome) var(--ease);
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on::after { left: 16px; background: var(--accent-on); }

.check {
  width: 16px; height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  background: var(--bg-1);
  position: relative;
  cursor: pointer;
  flex: none;
}
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 5px; height: 9px;
  border-right: 1.5px solid var(--accent-on);
  border-bottom: 1.5px solid var(--accent-on);
  transform: rotate(45deg);
}

.radio {
  width: 16px; height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-1);
  position: relative;
  cursor: pointer;
  flex: none;
}
.radio.on { border-color: var(--accent); }
.radio.on::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.slider {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
}
.slider input[type="range"] { width: 100%; accent-color: var(--accent); }
.slider .value {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-2);
  min-width: 56px;
  text-align: right;
}

.counter {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
}

/* ===== 5. CARDS ===== */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  padding: var(--space-6) var(--space-7);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--dur-chrome) var(--ease), background var(--dur-chrome) var(--ease);
}
.card:hover { border-color: var(--border-strong); background: var(--bg-2); }
[data-theme='light'] .card,
:root:not([data-theme='dark']) .card {
  background: var(--bg-1);
}
[data-theme='light'] .card:hover,
:root:not([data-theme='dark']) .card:hover {
  background: var(--bg-1);
}
.card .meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  letter-spacing: 0.04em;
  color: var(--fg-3);
}
.card .meta .source { color: var(--fg-2); font-weight: 500; }
.card .meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--fg-4); display: inline-block; }
.card .item-number {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--fg-1);
  background: var(--bg-0);
  font-size: 10px;
  letter-spacing: 0;
}
.card .card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}
.card .card-read-link {
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 22px;
}
.card .card-read-link:hover {
  color: var(--fg-1);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.card h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-18);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
.card h4 a { color: var(--fg-1); text-decoration: none; }
.card h4 a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.card .dek {
  margin: 0;
  font-size: var(--fs-13);
  line-height: 1.5;
  color: var(--fg-2);
  max-width: 60ch;
}
.card .card-why {
  margin: var(--space-2) 0 0;
  display: grid;
  gap: 6px;
  max-width: 70ch;
  padding: var(--space-4);
  border-left: 3px solid var(--accent);
  background: color-mix(in oklch, var(--accent-soft) 36%, transparent);
}
.card .card-why span,
.card .card-section-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.card .card-why p {
  margin: 0;
  color: var(--fg-1);
  font-size: var(--fs-14);
  line-height: 1.5;
}
.card .card-section {
  display: grid;
  gap: 7px;
  margin-top: var(--space-2);
  max-width: 72ch;
}
.card .card-takeaways {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--fg-1);
  font-size: var(--fs-13);
  line-height: 1.42;
}
.card .card-takeaways li {
  position: relative;
  padding-left: 15px;
  max-width: 68ch;
}
.card .card-takeaways li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fg-3);
}
.card .card-summary {
  margin: 0;
  color: var(--fg-2);
  font-size: var(--fs-13);
  line-height: 1.5;
  max-width: 68ch;
}
.card .card-summary p { margin: 0 0 0.75em; }
.card .card-summary p:last-child { margin-bottom: 0; }
.card .card-details {
  margin: 2px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.card .card-details span {
  min-width: 0;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-1);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.card .card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.card .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.card .tagdot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.card.featured {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.card .card-actions {
  display: inline-flex;
  gap: 4px;
}
.card .feedback-actions {
  display: inline-flex;
  gap: 2px;
  padding-right: 4px;
  margin-right: 2px;
  border-right: 1px solid var(--border);
}
.card .card-actions .btn-icon {
  width: 28px; height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-3);
  border-radius: var(--radius-1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.card .card-actions .btn-icon:hover { background: var(--bg-3); color: var(--fg-1); }
.card .card-actions .btn-icon svg { width: 14px; height: 14px; }
.card .card-actions .feedback-btn.active,
.card [aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

/* ===== 6. TIER SECTIONS ===== */
.tier { display: flex; flex-direction: column; gap: var(--space-6); margin-bottom: var(--space-9); }
.tier-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.tier-head .eyebrow { color: var(--fg-1); }
.tier-head .tier-count {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-3);
}
.tier-items { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
@media (max-width: 768px) {
  .tier-items { grid-template-columns: 1fr; }
}

/* ===== 6a. BRIEFING READER ===== */
.briefing-page {
  max-width: 980px;
  margin: 0 auto;
}

.briefing-head {
  margin-bottom: var(--space-6);
}

.briefing-date-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.density-control {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-1);
  background: var(--bg-1);
}

[data-theme='light'] .density-control,
:root:not([data-theme='dark']) .density-control {
  background: var(--bg-1);
}

.density-button {
  border: 0;
  border-radius: calc(var(--radius-1) - 2px);
  padding: 5px 8px;
  background: transparent;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.density-button[aria-pressed="true"] {
  background: var(--fg-1);
  color: var(--bg-1);
}

.top-five {
  margin: 0 0 var(--space-8);
  padding: var(--space-7);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2);
  background: var(--bg-1);
}

[data-theme='light'] .top-five,
:root:not([data-theme='dark']) .top-five {
  background: var(--bg-1);
}

.top-five-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
}

.top-five-head h2 {
  margin: var(--space-2) 0 0;
  font-family: var(--font-display);
  font-size: var(--fs-28);
  line-height: 1.14;
  font-weight: 600;
  letter-spacing: 0;
}

.top-five-head p {
  margin: var(--space-2) 0 0;
  color: var(--fg-3);
  font-size: var(--fs-14);
  line-height: 1.45;
}

.top-five-skip {
  flex: none;
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

.top-five-skip:hover {
  color: var(--fg-1);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.top-five-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.top-five-item {
  border-bottom: 1px solid var(--border);
}

.top-five-item:last-child {
  border-bottom: 0;
}

.top-five-item a {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: var(--space-4);
  padding: var(--space-5) 0;
  color: var(--fg-1);
  text-decoration: none;
}

.top-five-item a:hover .top-five-title {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

.top-five-rank {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--fg-1);
  background: var(--bg-0);
}

.top-five-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.top-five-meta {
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-five-title {
  font-family: var(--font-display);
  font-size: var(--fs-19);
  line-height: 1.22;
  font-weight: 600;
  letter-spacing: 0;
}

.top-five-why {
  max-width: 70ch;
  color: var(--fg-2);
  font-size: var(--fs-14);
  line-height: 1.5;
}

.briefing-index {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-8);
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--bg-0);
}

.briefing-index a {
  min-width: 0;
  padding: 12px 14px;
  color: var(--fg-2);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-right: 1px solid var(--border);
}

.briefing-index a:last-child { border-right: 0; }
.briefing-index a:hover { color: var(--fg-1); background: var(--bg-1); }
.briefing-index .numeric { color: var(--fg-3); }

.briefing-stream {
  display: flex;
  flex-direction: column;
  gap: var(--space-9);
}

.briefing-page .tier {
  gap: var(--space-4);
  margin-bottom: 0;
  scroll-margin-top: 76px;
}

.briefing-page .tier-head {
  align-items: flex-start;
  padding-bottom: var(--space-4);
  border-bottom-color: var(--border-strong);
}

.briefing-page summary.tier-head {
  list-style: none;
  cursor: pointer;
}

.briefing-page summary.tier-head::-webkit-details-marker {
  display: none;
}

.tier-collapsible {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  background: var(--bg-1);
}

[data-theme='light'] .tier-collapsible,
:root:not([data-theme='dark']) .tier-collapsible {
  background: var(--bg-1);
}

.tier-collapsible .tier-head {
  padding-bottom: 0;
  border-bottom: 0;
}

.tier-collapsible[open] .tier-head {
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-strong);
}

.tier-collapsible .tier-count::after {
  content: "+";
  margin-left: 8px;
  color: var(--fg-2);
}

.tier-collapsible[open] .tier-count::after {
  content: "-";
}

.tier-collapsible .tier-items {
  margin-top: var(--space-4);
}

.tier-description {
  margin: 6px 0 0;
  max-width: 58ch;
  color: var(--fg-3);
  font-size: var(--fs-13);
  line-height: 1.45;
}

.briefing-page .tier-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.briefing-page .card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  padding: var(--space-6);
  gap: var(--space-3);
  margin: 0;
}

.briefing-page .card:hover {
  background: var(--bg-1);
  border-color: var(--border-strong);
}

[data-theme='light'] .briefing-page .card,
:root:not([data-theme='dark']) .briefing-page .card,
[data-theme='light'] .briefing-page .card:hover,
:root:not([data-theme='dark']) .briefing-page .card:hover {
  background: var(--bg-1);
}

.briefing-page .card .meta {
  gap: 8px;
  font-size: 10px;
}

.briefing-page .card h4 {
  font-size: var(--fs-20);
  line-height: 1.2;
  max-width: 48rem;
}

.briefing-page .card .dek {
  max-width: 68ch;
  font-size: var(--fs-14);
  line-height: 1.52;
}

.briefing-page .card .card-takeaways {
  font-size: var(--fs-15);
  line-height: 1.48;
}

.briefing-page .card .card-summary {
  font-size: var(--fs-15);
  line-height: 1.58;
}

.briefing-page .card .card-details {
  margin-top: var(--space-2);
}

.briefing-page .card .card-foot {
  margin-top: 2px;
}

.briefing-page .card.featured {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2);
  padding: var(--space-7);
  margin-bottom: var(--space-3);
}

.briefing-page .card.featured h4 {
  font-size: var(--fs-22);
  line-height: 1.18;
  max-width: 48rem;
}

.briefing-page .card.featured .dek {
  max-width: 72ch;
}

[data-density='compact'] .briefing-stream,
[data-density='compact'] .briefing-document {
  gap: var(--space-5);
}

[data-density='compact'] .briefing-page .tier,
[data-density='compact'] .read-section {
  gap: var(--space-3);
}

[data-density='compact'] .briefing-page .card,
[data-density='compact'] .read-item {
  padding: var(--space-4) var(--space-5);
}

[data-density='compact'] .briefing-page .card .card-summary,
[data-density='compact'] .reader-summary-body {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

[data-density='compact'] .card .card-takeaways li:nth-child(n + 3),
[data-density='compact'] .read-item .reader-takeaways li:nth-child(n + 3) {
  display: none;
}

.briefing-read-page {
  max-width: var(--container-prose);
  margin: 0 auto;
}

.briefing-read-page .read-index {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.briefing-document {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.read-section {
  scroll-margin-top: 76px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.read-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) 0 var(--space-4);
  border-top: 2px solid var(--fg-1);
  border-bottom: 1px solid var(--border);
}

.read-item {
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  background: var(--bg-1);
}

.read-item:first-of-type {
  padding-top: var(--space-6);
}

[data-theme='light'] .read-item,
:root:not([data-theme='dark']) .read-item {
  background: var(--bg-1);
}

.read-item h2 {
  font-family: var(--font-display);
  font-size: var(--fs-30);
  line-height: 1.14;
  font-weight: 600;
  letter-spacing: 0;
  margin: var(--space-3) 0 var(--space-5);
}

.read-item h2 a {
  color: var(--fg-1);
  text-decoration: none;
}

.read-item h2 a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

.read-item .reader-takeaways {
  margin-bottom: var(--space-5);
}

.read-summary-fallback {
  color: var(--fg-2);
  font-size: var(--fs-16);
  line-height: 1.65;
  margin: 0;
}

.read-anatomy {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

.read-anatomy h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-21);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--fg-1);
}

.read-why p {
  margin: 0;
  color: var(--fg-1);
  font-size: var(--fs-16);
  line-height: 1.6;
}

.read-details {
  margin-top: var(--space-5);
}

.read-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

@media (max-width: 900px) {
  .briefing-page {
    max-width: 100%;
  }

  .briefing-index,
  .briefing-read-page .read-index {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .briefing-index a:nth-child(2n) { border-right: 0; }
  .briefing-index a:nth-child(n + 3) { border-top: 1px solid var(--border); }
}

@media (max-width: 640px) {
  .top-five {
    padding: var(--space-5) 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .top-five-head {
    flex-direction: column;
    gap: var(--space-3);
  }

  .top-five-head h2 {
    font-size: var(--fs-24);
  }

  .top-five-item a {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: var(--space-3);
  }

  .top-five-title {
    font-size: var(--fs-17);
  }

  .briefing-index {
    grid-template-columns: 1fr;
  }

  .briefing-index a {
    border-right: 0;
    border-top: 1px solid var(--border);
  }

  .briefing-index a:first-child { border-top: 0; }

  .briefing-page .card,
  .briefing-page .card.featured {
    padding: var(--space-5) 0;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .briefing-page .card.featured {
    background: transparent;
  }

  .briefing-page .card.featured h4 {
    font-size: var(--fs-18);
  }

  .briefing-page .card h4 {
    font-size: var(--fs-18);
  }

  .card .card-head {
    gap: var(--space-3);
  }

  .card .card-read-link {
    display: none;
  }

  .briefing-read-page .read-index {
    grid-template-columns: 1fr;
  }

  .read-item h2 {
    font-size: var(--fs-22);
  }
}

/* ===== 7. MODALS ===== */
.modal-portal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}
.modal-scrim {
  position: absolute;
  inset: 0;
  background: var(--scrim);
  z-index: var(--z-modal-scrim);
}
.modal {
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-2);
  width: 100%;
  z-index: var(--z-modal);
}
.modal-sm { max-width: 360px; }
.modal-md { max-width: 480px; }
.modal-lg { max-width: 640px; }
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
}
.modal-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--fg-3);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.modal-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.modal-eyebrow.danger .dot { background: var(--danger); }
.modal-eyebrow.warning .dot { background: var(--warning); }
.modal-eyebrow.success .dot { background: var(--success); }
.modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-22);
  line-height: 1.25;
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
}
.modal-close {
  background: transparent;
  border: 0;
  padding: 4px;
  color: var(--fg-3);
  cursor: pointer;
}
.modal-close:hover { color: var(--fg-1); }
.modal-body {
  padding: 4px 24px 16px;
  color: var(--fg-2);
  font-size: var(--fs-13);
  line-height: var(--lh-body);
}
.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}

/* ===== 8. TOASTS ===== */
.toast-region {
  position: fixed;
  top: 80px; right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}
.toast {
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2);
  padding: 12px 14px;
  box-shadow: var(--shadow-1);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.toast .icon-wrap {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--accent-soft);
  color: var(--accent);
}
.toast .copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toast .title { font-size: var(--fs-13); font-weight: 600; }
.toast .meta { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--fg-3); }
.toast .actions { display: inline-flex; align-items: flex-start; }
.toast .close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-1);
  background: transparent;
  color: var(--fg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.toast .close:hover,
.toast .close:focus-visible {
  background: var(--bg-2);
  color: var(--fg-1);
  outline: none;
}
.toast.success .icon-wrap { background: color-mix(in oklch, var(--success) 14%, var(--bg-1)); color: var(--success); }
.toast.warning .icon-wrap { background: color-mix(in oklch, var(--warning) 14%, var(--bg-1)); color: var(--warning); }
.toast.danger  .icon-wrap { background: color-mix(in oklch, var(--danger) 14%, var(--bg-1)); color: var(--danger); }
.toast.info    .icon-wrap { background: color-mix(in oklch, var(--info) 14%, var(--bg-1)); color: var(--info); }
.toast .progress {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: left;
}
.toast.success .progress { background: var(--success); }
.toast.warning .progress { background: var(--warning); }
.toast.danger .progress { background: var(--danger); }
@keyframes toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.htmx-target-error {
  outline: 2px solid color-mix(in oklch, var(--danger) 55%, transparent);
  outline-offset: 3px;
}

.htmx-target-error-message {
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in oklch, var(--danger) 42%, var(--border));
  border-radius: var(--radius-1);
  background: color-mix(in oklch, var(--danger) 10%, var(--bg-1));
  color: var(--fg-1);
  font-size: var(--fs-13);
  font-weight: 600;
}

/* ===== 9. TOOLTIPS (data-tip approach) ===== */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg-1);
  color: var(--bg-1);
  padding: 4px 8px;
  border-radius: var(--radius-1);
  font-family: var(--font-body);
  font-size: var(--fs-12);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-chrome) var(--ease);
  z-index: var(--z-tooltip);
}
[data-tip]:hover::after { opacity: 1; }
[data-tip-position="bottom"]::after { top: calc(100% + 6px); bottom: auto; }

/* ===== 10. POPOVERS ===== */
.pop-wrap { position: relative; display: inline-block; }
.pop-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-1);
  padding: 8px 12px;
  border-radius: var(--radius-1);
  font-family: var(--font-body);
  font-size: var(--fs-13);
  cursor: pointer;
}
.pop {
  position: absolute;
  margin-top: 6px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-1);
  z-index: var(--z-dropdown);
  width: 320px;
}
.pop-sm { width: 240px; } .pop-md { width: 320px; } .pop-lg { width: 480px; }
.pop-anchor-bottom-start { left: 0; top: 100%; }
.pop-anchor-bottom-end   { right: 0; top: 100%; }
.pop-header { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); }
.pop-eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: var(--tracking-eyebrow); text-transform: uppercase; color: var(--fg-3); margin-bottom: 4px; }
.pop-title { font-family: var(--font-display); font-size: var(--fs-14); font-weight: 600; margin: 0; }
.pop-body { padding: 12px 14px; font-size: var(--fs-13); line-height: 1.5; color: var(--fg-2); }
.pop-footer { display: flex; gap: 6px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); }

/* ===== 11. DROPDOWNS / MENUS ===== */
.menu-wrap { position: relative; display: inline-block; }
.menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-1);
  padding: 8px 12px;
  border-radius: var(--radius-1);
  font-family: var(--font-body);
  font-size: var(--fs-13);
  cursor: pointer;
}
.menu {
  position: absolute;
  top: 100%; left: 0;
  margin-top: 4px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-1);
  z-index: var(--z-dropdown);
  min-width: 220px;
  padding: 4px 0;
}
.menu-anchor-bottom-end { left: auto; right: 0; }
.menu-section {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  padding: 8px 12px 4px;
}
.menu-item {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px 12px;
  font-size: var(--fs-13);
  color: var(--fg-1);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-chrome) var(--ease);
}
.menu-item:hover, .menu-item.active { background: var(--bg-2); }
.menu-item.active { box-shadow: inset 2px 0 0 var(--accent); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: color-mix(in oklch, var(--danger) 8%, var(--bg-1)); }
.menu-item[aria-disabled="true"] { color: var(--fg-4); cursor: not-allowed; pointer-events: none; }
.menu-separator { height: 1px; background: var(--border); margin: 4px 0; }

/* ===== 12. TABS / SEGMENTED ===== */
.tablist {
  display: flex;
  border-bottom: 1px solid var(--border);
  align-items: stretch;
  gap: 0;
}
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--fg-3);
  font-family: var(--font-body);
  font-size: var(--fs-13);
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  text-decoration: none;
  transition: color var(--dur-chrome) var(--ease), border-color var(--dur-chrome) var(--ease);
}
.tab:hover { color: var(--fg-1); }
.tab[aria-selected="true"] { color: var(--fg-1); border-bottom-color: var(--accent); }
.tab .count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  background: var(--bg-2);
  border-radius: var(--radius-1);
  padding: 2px 5px;
  line-height: 1;
}
.tab[aria-selected="true"] .count { color: var(--fg-1); background: var(--accent-soft); }
.tab[aria-disabled="true"] { opacity: var(--opacity-disabled); cursor: not-allowed; }

/* ===== 13. BREADCRUMBS ===== */
.crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  letter-spacing: 0.04em;
  color: var(--fg-3);
  flex-wrap: wrap;
}
.crumbs a {
  color: var(--fg-2);
  text-decoration: none;
  padding: 2px 4px;
  border-radius: var(--radius-1);
}
.crumbs a:hover { color: var(--fg-1); background: var(--bg-2); }
.crumbs .current { color: var(--fg-1); font-weight: 500; }
.crumbs .sep { color: var(--fg-4); user-select: none; }

/* ===== 14. PAGINATION ===== */
.pager {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
}
.pager a, .pager .page, .pager button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  color: var(--fg-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-1);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.pager a:hover { background: var(--bg-2); color: var(--fg-1); }
.pager .current {
  background: var(--bg-3);
  color: var(--fg-1);
  font-weight: 600;
  border-color: var(--border-strong);
}
.pager .ellipsis { cursor: default; color: var(--fg-4); }
.pager .arrow { color: var(--fg-2); border-color: var(--border); }
.pager .arrow svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.pager .arrow[aria-disabled="true"] { color: var(--fg-4); pointer-events: none; opacity: 0.5; }
.pager .pager-total {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-3);
  margin-left: 12px;
}

/* ===== 15. EMPTY STATES ===== */
.empty {
  border: 1px dashed var(--border-strong);
  background: var(--bg-1);
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  max-width: 540px;
}
.empty .eyebrow { color: var(--fg-3); }
.empty.signal .eyebrow .dot { background: var(--accent); }
.empty.error .eyebrow .dot  { background: var(--danger); }
.empty.warning .eyebrow .dot { background: var(--warning); }
.empty.search .eyebrow .dot { background: var(--info); }
.empty h3 {
  font-family: var(--font-display);
  font-size: var(--fs-22);
  line-height: 1.2;
  font-weight: 600;
  margin: 0;
  text-wrap: balance;
}
.empty p {
  margin: 0;
  color: var(--fg-2);
  font-size: var(--fs-14);
  line-height: var(--lh-body);
  max-width: 60ch;
}
.empty p em {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--fg-1);
}
.empty .actions { display: flex; gap: 8px; margin-top: 4px; }

/* ===== 16. SKELETON ===== */
.skel {
  display: block;
  background: linear-gradient(90deg, var(--bg-2) 0%, var(--bg-3) 50%, var(--bg-2) 100%);
  background-size: 200% 100%;
  border-radius: var(--radius-1);
  animation: skel-pulse 1600ms linear infinite;
}
@keyframes skel-pulse {
  0%   { background-position: 100% 0; opacity: 0.85; }
  50%  { opacity: 0.6; }
  100% { background-position: -100% 0; opacity: 0.85; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; opacity: 0.7; }
}
.skel-line { height: 12px; }
.skel-line.sm { height: 10px; }
.skel-line.lg { height: 16px; }
.skel-block { height: 80px; }
.skel-circle { border-radius: 50%; }
.skel-card {
  border: 1px solid var(--border);
  background: var(--bg-1);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* htmx loading indicator — hidden by default, shown while a request is in flight.
   htmx adds .htmx-request to the indicator element while the request runs. */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* ===== 17. PROGRESS ===== */
.pgline {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}
.pgline .track {
  position: relative;
  height: 4px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.pgline .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--accent);
  transition: width var(--dur-content) var(--ease);
}
.pgline.success .fill { background: var(--success); }
.pgline.warning .fill { background: var(--warning); }
.pgline.danger .fill { background: var(--danger); }
.pgline.indet .track::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  width: 30%;
  animation: pg-slide 1400ms linear infinite;
}
.pgline.indet .fill { display: none; }
@keyframes pg-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(380%); }
}
.pgline .num {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
  min-width: 64px;
  text-align: right;
}
.pgmeta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-3);
}

.pcircle {
  --size: 56px;
  width: var(--size);
  height: var(--size);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pcircle svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.pcircle circle { fill: none; stroke-width: 4; }
.pcircle .bg { stroke: var(--bg-3); }
.pcircle .fg { stroke: var(--accent); transition: stroke-dashoffset var(--dur-content) var(--ease); }
.pcircle .label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-1);
}

/* ===== 18. CHARTS ===== */
.sparkline { display: inline-flex; align-items: center; gap: 8px; }
.sparkline .last { font-family: var(--font-mono); font-size: var(--fs-11); color: var(--fg-2); }
.sparkline .delta.up   { color: var(--success); font-family: var(--font-mono); font-size: 10px; }
.sparkline .delta.down { color: var(--danger);  font-family: var(--font-mono); font-size: 10px; }

.bars { display: grid; grid-template-columns: 1fr; gap: 6px; max-width: 480px; }
.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 64px;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-2);
}
.bar-row .label { color: var(--fg-1); font-family: var(--font-body); font-size: var(--fs-12); font-weight: 500; }
.bar-row .track { position: relative; height: 16px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-1); }
.bar-row .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.bar-row.muted .fill { background: var(--fg-3); }

/* ===== 19. AVATAR ===== */
.avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-2);
  color: var(--fg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-1);
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  overflow: hidden;
}
.avatar.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.avatar-xl { width: 64px; height: 64px; font-size: 20px; }
.avatar.circle { border-radius: 50%; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar .status-dot {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--fg-3);
  border: 2px solid var(--bg-1);
}
.avatar.live .status-dot   { background: var(--accent); }
.avatar.ok .status-dot     { background: var(--success); }
.avatar.warn .status-dot   { background: var(--warning); }
.avatar.error .status-dot  { background: var(--danger); }

.source-mast {
  width: 36px; height: 36px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--fg-1);
}

.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { margin-right: -8px; box-shadow: 0 0 0 2px var(--bg-1); }
.avatar-stack .avatar:last-child { margin-right: 0; }
.avatar-stack .more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  color: var(--fg-3);
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  border-radius: var(--radius-1);
}

/* ===== 20. DATE INPUTS + CALENDAR ===== */
.date-input {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  background: var(--bg-1);
  overflow: hidden;
}
.date-input input {
  border: 0;
  background: transparent;
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  padding: 8px 12px;
  min-width: 130px;
  font-variant-numeric: tabular-nums;
}
.date-input input:focus:not(:focus-visible) { outline: none; }
.date-input .cal-icon {
  padding: 0 12px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  color: var(--fg-3);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  border: 0;
}
.date-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.range {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-1);
  overflow: hidden;
}
.range input {
  border: 0;
  background: var(--bg-1);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  padding: 8px 12px;
  width: 130px;
  font-variant-numeric: tabular-nums;
}
.range input:focus:not(:focus-visible) { outline: none; }
.range .arrow {
  padding: 0 8px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--fg-3);
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips .chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  padding: 4px 9px;
  border-radius: var(--radius-1);
  cursor: pointer;
  letter-spacing: 0.04em;
}
.chips .chip.on {
  background: var(--bg-3);
  color: var(--fg-1);
  border-color: var(--border-strong);
}

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-1);
  border-top: 1px solid var(--border-strong);
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-2);
  padding: 12px 16px 18px;
  z-index: var(--z-modal);
}
.sheet .grabber {
  width: 36px; height: 4px;
  background: var(--border-strong);
  border-radius: 999px;
  margin: 0 auto 12px;
  display: block;
}

/* ===== 22. READER PROSE ===== */
.reader {
  max-width: var(--container-prose);
  margin: 0 auto;
  padding: var(--space-8) var(--space-7) var(--space-11);
}
[data-theme='light'] .reader,
:root:not([data-theme='dark']) .reader {
  background: var(--bg-1);
  border: 1px solid var(--border);
}
.reader header { margin-bottom: var(--space-8); }
.reader-mobile-return {
  display: none;
}
.reader header .eyebrow { margin-bottom: var(--space-5); }
.reader h1 {
  font-family: var(--font-display);
  font-size: var(--fs-48);
  font-weight: 600;
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-display);
  margin: 0 0 var(--space-5);
  text-wrap: balance;
}
.reader .lede {
  font-family: var(--font-display);
  font-size: var(--fs-22);
  font-style: italic;
  line-height: 1.4;
  color: var(--fg-2);
  margin: 0 0 var(--space-8);
}
.reader .byline {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  letter-spacing: 0.06em;
  color: var(--fg-3);
  margin-bottom: var(--space-7);
  display: flex;
  gap: 12px;
}
.reader-facts {
  margin: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.reader-facts div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: var(--space-5);
  padding: 9px 0;
  border-top: 1px solid var(--border);
}
.reader-facts div:first-child { border-top: 0; }
.reader-facts dt {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.reader-facts dd {
  margin: 0;
  color: var(--fg-2);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.reader-facts a {
  color: var(--fg-1);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.reader-summary {
  margin: 0 0 var(--space-8);
  padding: var(--space-7) 0;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: var(--space-7);
}
.reader-anatomy {
  display: grid;
  gap: var(--space-3);
}
.reader-anatomy h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-20);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--fg-1);
}
.reader-why p {
  margin: 0;
  color: var(--fg-1);
  font-size: var(--fs-17);
  line-height: 1.58;
}
.reader-takeaways {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.reader-takeaways li {
  position: relative;
  padding-left: 18px;
  color: var(--fg-1);
  font-size: var(--fs-15);
  line-height: 1.55;
}
.reader-takeaways li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}
.reader-summary-body {
  color: var(--fg-2);
  font-size: var(--fs-16);
  line-height: 1.65;
}
.reader-summary-body p { margin: 0 0 1em; }
.reader-summary-body p:last-child { margin-bottom: 0; }
.reader-source-disclosure {
  margin: var(--space-7) 0 var(--space-9);
  border: 1px solid var(--border);
  background: var(--bg-1);
  padding: var(--space-5) var(--space-6);
}
[data-theme='light'] .reader-source-disclosure,
:root:not([data-theme='dark']) .reader-source-disclosure {
  background: var(--bg-1);
}
.reader-source-disclosure > summary {
  color: var(--fg-3);
}
.reader-source-disclosure .body {
  margin-top: var(--space-6);
}
.reader-plain-source {
  margin-top: var(--space-6);
  display: grid;
  gap: var(--space-4);
  color: var(--fg-2);
  font-size: var(--fs-15);
  line-height: 1.65;
}
.reader-plain-source p {
  margin: 0;
}
.reader .body {
  font-size: var(--fs-16);
  line-height: var(--lh-body);
  color: var(--fg-1);
}
.reader .body p,
.reader .body ul,
.reader .body ol { margin: 0 0 1em; max-width: none; }
.reader .body h2, .reader .body h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0;
  margin: var(--space-9) 0 var(--space-5);
}
.reader .body h2 { font-size: var(--fs-28); }
.reader .body h3 { font-size: var(--fs-22); }
.reader .body blockquote {
  margin: var(--space-7) 0;
  padding-left: var(--space-7);
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-18);
  color: var(--fg-2);
}
.reader .body a {
  color: var(--fg-1);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.reader .body strong { font-weight: 650; }

@media (max-width: 640px) {
  .app-main {
    width: 100%;
  }

  .reader {
    padding: var(--space-5) var(--space-5) calc(88px + var(--space-7));
    border-left: 0;
    border-right: 0;
  }

  [data-theme='light'] .reader,
  :root:not([data-theme='dark']) .reader {
    border-left: 0;
    border-right: 0;
  }

  .reader-mobile-return {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-3);
    align-items: center;
    margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-6);
    padding: 10px var(--space-5);
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    position: sticky;
    top: 48px;
    z-index: calc(var(--z-nav) - 1);
  }

  .reader-mobile-return a {
    min-width: 0;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--fg-2);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: var(--fs-11);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .reader-mobile-return a:first-child {
    color: var(--fg-1);
  }

  .reader-mobile-return i,
  .reader-mobile-return [data-lucide] {
    width: 16px;
    height: 16px;
  }

  .reader h1 {
    font-size: clamp(31px, 9vw, 40px);
    line-height: 1.05;
    margin-bottom: var(--space-4);
  }

  .reader .lede {
    font-size: var(--fs-18);
    margin-bottom: var(--space-6);
  }

  .reader .byline {
    flex-wrap: wrap;
    row-gap: 6px;
    margin-bottom: var(--space-6);
  }

  .reader-facts div {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .reader > .row.wrap.gap-6.mb-7 {
    position: sticky;
    top: 104px;
    z-index: calc(var(--z-nav) - 2);
    margin: 0 calc(var(--space-5) * -1) var(--space-6);
    padding: 10px var(--space-5);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: color-mix(in oklch, var(--bg-1) 96%, transparent);
    backdrop-filter: saturate(var(--saturate-nav)) blur(var(--blur-nav));
    -webkit-backdrop-filter: saturate(var(--saturate-nav)) blur(var(--blur-nav));
  }

  .reader > .row.wrap.gap-6.mb-7 nav {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .reader > .row.wrap.gap-6.mb-7 .btn,
  .reader > .row.wrap.gap-6.mb-7 .density-control,
  .reader > .row.wrap.gap-6.mb-7 > button {
    width: 100%;
    justify-content: center;
  }

  .reader > .row.wrap.gap-6.mb-7 .density-control {
    grid-column: 1 / -1;
  }

  .reader-summary {
    padding: var(--space-6) 0;
    gap: var(--space-6);
  }

  .reader .body {
    font-size: var(--fs-17);
    line-height: 1.7;
  }

  .reader .body h2 {
    font-size: var(--fs-24);
  }

  .reader .body blockquote {
    padding-left: var(--space-5);
    font-size: var(--fs-17);
  }
}

/* ===== 23. BADGE + ALERT ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-1);
  background: var(--bg-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
}
.badge-signal { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.badge-success { color: var(--success); border-color: var(--success); }
.badge-warning { color: var(--warning); border-color: var(--warning); }
.badge-danger  { color: var(--danger); border-color: var(--danger); }

.alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: var(--fs-13);
}
.alert-icon { color: var(--fg-3); }
.alert-body { display: flex; flex-direction: column; gap: 2px; }
.alert-title { font-weight: 600; }
.alert-text { color: var(--fg-2); }
.alert-action { color: var(--accent); text-decoration: underline; }
.alert-success { background: color-mix(in oklch, var(--success) 6%, var(--bg-1)); border-color: var(--success); }
.alert-success .alert-icon { color: var(--success); }
.alert-warning { background: color-mix(in oklch, var(--warning) 6%, var(--bg-1)); border-color: var(--warning); }
.alert-warning .alert-icon { color: var(--warning); }
.alert-danger { background: color-mix(in oklch, var(--danger) 6%, var(--bg-1)); border-color: var(--danger); }
.alert-danger .alert-icon { color: var(--danger); }
.alert-info { background: color-mix(in oklch, var(--info) 6%, var(--bg-1)); border-color: var(--info); }
.alert-info .alert-icon { color: var(--info); }

/* =========================================================
   12. Status indicator dots (active/paused/idle pills)
   --------------------------------------------------------- */
.indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--fg-4);
}
.indicator-active  { background: var(--success); }
.indicator-paused  { background: var(--fg-4); }
.indicator-warning { background: var(--warning); }
.indicator-danger  { background: var(--danger); }

/* =========================================================
   13. Data tables (sources, etc.)
   ---------------------------------------------------------
   Used by pages/sources_rows.html (HTMX-swappable partial).
   --------------------------------------------------------- */
/* Wrap any .data-table in a .table-wrap to keep narrow viewports from
 * letting the table push the page wider than the viewport. The wrap
 * provides horizontal scroll inside the wrap; the page chrome stays
 * width-constrained. */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
  border: 1px solid var(--border);
}

/* Marker for "no value" inside a data-table cell. Distinct from the
 * page-level .empty empty-state component (which is a giant dashed
 * card). Reusing .empty here paints every blank cell as a giant
 * dashed box. */
.data-table .cell-empty,
.cell-empty {
  color: var(--fg-4);
  font-style: italic;
}
.data-table thead tr { background: var(--bg-2); }
.data-table th {
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-weight: normal;
}
.data-table th.num    { text-align: right; }
.data-table th.center { text-align: center; }
.data-table th a {
  color: inherit;
  text-decoration: none;
}
.data-table th a:hover { color: var(--fg-1); }

.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table td {
  padding: 10px 14px;
  vertical-align: top;
}
.data-table td.num    { text-align: right; }
.data-table td.center { text-align: center; }
.data-table td.actions {
  text-align: right;
  white-space: nowrap;
}

.data-table .row-name { font-weight: 500; }
.data-table .row-subtext {
  font-size: var(--fs-11);
  font-family: var(--font-mono);
  color: var(--fg-3);
  margin-top: 2px;
  word-break: break-all;
  max-width: 340px;
}
.data-table .empty { color: var(--fg-4); }
.data-table .err   { color: var(--danger); font-weight: 600; }

/* Operator ingestion review / smart queue */
.operator-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: var(--space-5);
}
.operator-filterbar label {
  display: grid;
  gap: 4px;
  min-width: 130px;
}
.operator-filterbar label > span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.operator-batchbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: var(--space-4);
  border: 1px solid var(--accent);
  border-radius: var(--radius-2);
  background: var(--accent-soft);
  color: var(--fg-1);
  font-size: var(--fs-13);
}
.operator-batchbar[hidden] { display: none; }
.operator-batches {
  display: grid;
  gap: 8px;
  margin-bottom: var(--space-4);
}
.operator-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.operator-metrics .metric-value {
  margin-top: 4px;
  font-size: var(--fs-24);
  font-weight: 650;
  color: var(--fg-1);
}
.operator-review-table .row-name {
  display: inline-block;
  max-width: 32ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.operator-review-table .badge { margin-left: 6px; }
.operator-review-table .btn-icon {
  width: 28px;
  height: 28px;
}
.operator-review-table .justify-end { justify-content: flex-end; }
.operator-queue-cards { display: none; }
.operator-row-pinned { background: color-mix(in oklch, var(--success) 7%, var(--bg-1)); }
.operator-row-muted { background: var(--bg-2); }
.operator-why {
  max-width: 24ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Monitoring / logbook pages migrated from web/ into web_v2.
   These monitor-* classes are the native v2 replacement for the
   legacy Tailwind-shaped tokens that used to live in those templates. */
.monitor-bg-white,
.monitor-bg-gray-900,
.monitor-dark-bg-gray-900,
.monitor-bg-surface { background: var(--bg-1); }
.monitor-bg-gray-50,
.monitor-bg-gray-800,
.monitor-bg-gray-800-30,
.monitor-bg-gray-800-50,
.monitor-dark-bg-gray-800,
.monitor-dark-bg-gray-800-30,
.monitor-dark-bg-gray-800-50 { background: var(--bg-2); }
.monitor-bg-gray-100,
.monitor-bg-gray-300,
.monitor-dark-bg-gray-600 { background: var(--border); }
.monitor-bg-green-50,
.monitor-bg-green-50-50,
.monitor-bg-green-100,
.monitor-dark-bg-green-900-10,
.monitor-dark-bg-green-900-20,
.monitor-dark-bg-green-900-30 { background: color-mix(in oklch, var(--success) 9%, var(--bg-1)); }
.monitor-bg-yellow-50,
.monitor-bg-yellow-100,
.monitor-dark-bg-yellow-900-20,
.monitor-dark-bg-yellow-900-30,
.monitor-bg-amber-50,
.monitor-dark-bg-amber-900-20 { background: color-mix(in oklch, var(--warning) 10%, var(--bg-1)); }
.monitor-bg-red-50,
.monitor-bg-red-50-50,
.monitor-bg-red-100,
.monitor-dark-bg-red-900-10,
.monitor-dark-bg-red-900-20,
.monitor-dark-bg-red-900-30,
.monitor-dark-bg-red-950-30 { background: color-mix(in oklch, var(--danger) 9%, var(--bg-1)); }
.monitor-bg-blue-50,
.monitor-dark-bg-blue-900-20,
.monitor-bg-indigo-50,
.monitor-dark-bg-indigo-900-20,
.monitor-bg-emerald-50,
.monitor-dark-bg-emerald-900-20,
.monitor-bg-teal-50,
.monitor-dark-bg-teal-900-20 { background: color-mix(in oklch, var(--info) 9%, var(--bg-1)); }
.monitor-bg-purple-50,
.monitor-bg-purple-100,
.monitor-dark-bg-purple-900-20,
.monitor-dark-bg-purple-900-30 { background: color-mix(in oklch, var(--accent) 9%, var(--bg-1)); }
.monitor-bg-rose-50,
.monitor-bg-orange-50,
.monitor-dark-bg-rose-900-20,
.monitor-dark-bg-orange-900-20 { background: color-mix(in oklch, var(--danger) 8%, var(--bg-1)); }
.monitor-bg-slate-50,
.monitor-dark-bg-slate-800-60 { background: var(--bg-2); }
.monitor-bg-purple-500 { background: var(--accent); }
.monitor-bg-green-400,
.monitor-bg-green-500,
.monitor-dark-bg-green-500 { background: var(--success); }
.monitor-bg-red-200,
.monitor-bg-red-500,
.monitor-dark-bg-red-500,
.monitor-dark-bg-red-800 { background: var(--danger); }
.monitor-bg-yellow-200,
.monitor-bg-yellow-400,
.monitor-dark-bg-yellow-800 { background: var(--warning); }

.monitor-border,
.monitor-border-gray-100,
.monitor-border-gray-200,
.monitor-border-gray-300,
.monitor-dark-border-gray-700,
.monitor-dark-border-gray-800 { border-color: var(--border); }
.monitor-border-green-100,
.monitor-border-green-200,
.monitor-dark-border-green-800,
.monitor-dark-border-green-900 { border-color: var(--success); }
.monitor-border-yellow-200,
.monitor-dark-border-yellow-800,
.monitor-border-amber-200,
.monitor-border-amber-300,
.monitor-dark-border-amber-700,
.monitor-dark-border-amber-800 { border-color: var(--warning); }
.monitor-border-red-200,
.monitor-border-red-300,
.monitor-dark-border-red-800,
.monitor-dark-border-red-900 { border-color: var(--danger); }
.monitor-border-blue-200,
.monitor-border-blue-500,
.monitor-dark-border-blue-800,
.monitor-border-indigo-200,
.monitor-dark-border-indigo-800,
.monitor-border-emerald-200,
.monitor-dark-border-emerald-800,
.monitor-border-teal-200,
.monitor-dark-border-teal-800 { border-color: var(--info); }
.monitor-border-purple-200,
.monitor-dark-border-purple-800 { border-color: var(--accent); }
.monitor-border-rose-200,
.monitor-dark-border-rose-800 { border-color: var(--danger); }
.monitor-border-slate-200,
.monitor-dark-border-slate-700 { border-color: var(--border); }

.monitor-text-gray-900,
.monitor-dark-text-gray-100,
.monitor-text-slate-900,
.monitor-dark-text-slate-100 { color: var(--fg-1); }
.monitor-text-gray-700,
.monitor-dark-text-gray-300,
.monitor-text-slate-600,
.monitor-dark-text-slate-300 { color: var(--fg-2); }
.monitor-text-gray-600,
.monitor-text-gray-500,
.monitor-dark-text-gray-400,
.monitor-dark-text-gray-500 { color: var(--fg-3); }
.monitor-text-gray-400,
.monitor-text-gray-300,
.monitor-dark-text-gray-600 { color: var(--fg-4); }
.monitor-text-blue-600,
.monitor-text-blue-700,
.monitor-dark-text-blue-300,
.monitor-dark-text-blue-400,
.monitor-text-indigo-700,
.monitor-dark-text-indigo-300,
.monitor-dark-text-indigo-400,
.monitor-text-emerald-700,
.monitor-dark-text-emerald-300,
.monitor-text-teal-700,
.monitor-dark-text-teal-300 { color: var(--info); }
.monitor-text-green-600,
.monitor-text-green-700,
.monitor-dark-text-green-300,
.monitor-dark-text-green-400 { color: var(--success); }
.monitor-text-yellow-600,
.monitor-text-yellow-700,
.monitor-text-yellow-800,
.monitor-dark-text-yellow-200,
.monitor-dark-text-yellow-300,
.monitor-dark-text-yellow-400,
.monitor-text-amber-700,
.monitor-dark-text-amber-300,
.monitor-dark-text-amber-400,
.monitor-text-orange-700,
.monitor-dark-text-orange-400 { color: var(--warning); }
.monitor-text-red-500,
.monitor-text-red-600,
.monitor-text-red-700,
.monitor-text-red-800,
.monitor-dark-text-red-200,
.monitor-dark-text-red-300,
.monitor-dark-text-red-400 { color: var(--danger); }
.monitor-text-purple-600,
.monitor-text-purple-700,
.monitor-dark-text-purple-300,
.monitor-dark-text-purple-400 { color: var(--accent); }
.monitor-text-rose-700,
.monitor-dark-text-rose-300 { color: var(--danger); }

.monitor-block { display: block; }
.monitor-inline-block { display: inline-block; }
.monitor-flex { display: flex; }
.monitor-inline-flex { display: inline-flex; }
.monitor-grid { display: grid; }
.monitor-hidden { display: none; }
.monitor-items-center { align-items: center; }
.monitor-items-start { align-items: flex-start; }
.monitor-justify-between { justify-content: space-between; }
.monitor-flex-col { flex-direction: column; }
.monitor-flex-row { flex-direction: row; }
.monitor-flex-wrap { flex-wrap: wrap; }
.monitor-flex-1 { flex: 1; }
.monitor-flex-shrink-0,
.monitor-shrink-0 { flex-shrink: 0; }
.monitor-min-w-0 { min-width: 0; }
.monitor-w-full { width: 100%; }
.monitor-w-1-5 { width: 6px; }
.monitor-w-2 { width: 8px; }
.monitor-w-3 { width: 12px; }
.monitor-h-1-5 { height: 6px; }
.monitor-h-3 { height: 12px; }
.monitor-h-4 { height: 16px; }
.monitor-max-w-xs { max-width: 20rem; }
.monitor-max-w-md { max-width: 28rem; }
.monitor-grid-cols-1 { grid-template-columns: minmax(0, 1fr); }
.monitor-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.monitor-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.monitor-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.monitor-col-span-2 { grid-column: span 2 / span 2; }

.monitor-gap-1 { gap: var(--space-1); }
.monitor-gap-1-5 { gap: 6px; }
.monitor-gap-2 { gap: var(--space-2); }
.monitor-gap-3 { gap: var(--space-3); }
.monitor-gap-4 { gap: var(--space-4); }
.monitor-gap-x-3 { column-gap: var(--space-3); }
.monitor-gap-y-1 { row-gap: var(--space-1); }
.monitor-space-y-0-5 > * + * { margin-top: 2px; }
.monitor-space-y-1 > * + * { margin-top: var(--space-1); }
.monitor-space-y-2 > * + * { margin-top: var(--space-2); }
.monitor-space-y-3 > * + * { margin-top: var(--space-3); }
.monitor-space-y-4 > * + * { margin-top: var(--space-4); }

.monitor-mt-0-5 { margin-top: 2px; }
.monitor-mt-1 { margin-top: var(--space-1); }
.monitor-mt-2 { margin-top: var(--space-2); }
.monitor-mt-3 { margin-top: var(--space-3); }
.monitor-mb-1 { margin-bottom: var(--space-1); }
.monitor-mb-2 { margin-bottom: var(--space-2); }
.monitor-mb-3 { margin-bottom: var(--space-3); }
.monitor-mb-4 { margin-bottom: var(--space-4); }
.monitor-mb-6 { margin-bottom: var(--space-6); }
.monitor-mb-8 { margin-bottom: var(--space-8); }
.monitor-ml-1 { margin-left: var(--space-1); }
.monitor-ml-2 { margin-left: var(--space-2); }
.monitor-ml-3 { margin-left: var(--space-3); }
.monitor-ml-auto { margin-left: auto; }
.monitor-mr-2 { margin-right: var(--space-2); }
.monitor-p-3 { padding: var(--space-3); }
.monitor-p-4 { padding: var(--space-4); }
.monitor-p-6 { padding: var(--space-6); }
.monitor-p-8 { padding: var(--space-8); }
.monitor-px-2 { padding-left: var(--space-2); padding-right: var(--space-2); }
.monitor-px-2-5 { padding-left: 10px; padding-right: 10px; }
.monitor-px-3 { padding-left: var(--space-3); padding-right: var(--space-3); }
.monitor-px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.monitor-py-0-5 { padding-top: 2px; padding-bottom: 2px; }
.monitor-py-1 { padding-top: var(--space-1); padding-bottom: var(--space-1); }
.monitor-py-1-5 { padding-top: 6px; padding-bottom: 6px; }
.monitor-py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.monitor-py-2-5 { padding-top: 10px; padding-bottom: 10px; }
.monitor-py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.monitor-pb-3 { padding-bottom: var(--space-3); }
.monitor-pb-4 { padding-bottom: var(--space-4); }
.monitor-pt-1 { padding-top: var(--space-1); }
.monitor-pt-3 { padding-top: var(--space-3); }
.monitor-pl-3 { padding-left: var(--space-3); }
.monitor-pr-3 { padding-right: var(--space-3); }

.monitor-rounded-sm { border-radius: var(--radius-1); }
.monitor-rounded,
.monitor-rounded-md { border-radius: var(--radius-1); }
.monitor-rounded-lg { border-radius: var(--radius-2); }
.monitor-rounded-full { border-radius: 999px; }
.monitor-border { border-width: 1px; border-style: solid; }
.monitor-border-t { border-top-width: 1px; border-top-style: solid; }
.monitor-border-b { border-bottom-width: 1px; border-bottom-style: solid; }
.monitor-overflow-hidden { overflow: hidden; }
.monitor-overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.monitor-divide-y > * + * { border-top-width: 1px; border-top-style: solid; border-color: var(--border); }
.monitor-divide-gray-100 > * + *,
.monitor-dark-divide-gray-800 > * + * { border-color: var(--border); }
.monitor-divide-yellow-100 > * + *,
.monitor-dark-divide-yellow-900-20 > * + * { border-color: color-mix(in oklch, var(--warning) 28%, var(--border)); }
.monitor-divide-red-100 > * + *,
.monitor-dark-divide-red-900-20 > * + * { border-color: color-mix(in oklch, var(--danger) 28%, var(--border)); }

.monitor-text-left { text-align: left; }
.monitor-text-right { text-align: right; }
.monitor-text-center { text-align: center; }
.monitor-text-xs { font-size: var(--fs-12); }
.monitor-text-sm { font-size: var(--fs-14); }
.monitor-text-lg { font-size: var(--fs-18); }
.monitor-text-2xl { font-size: var(--fs-24); }
.monitor-text-3xl { font-size: var(--fs-32); }
.monitor-font-normal { font-weight: 400; }
.monitor-font-medium { font-weight: 500; }
.monitor-font-semibold { font-weight: 600; }
.monitor-font-bold { font-weight: 650; }
.monitor-font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.monitor-uppercase { text-transform: uppercase; }
.monitor-tracking-wider { letter-spacing: var(--tracking-eyebrow); }
.monitor-whitespace-nowrap { white-space: nowrap; }
.monitor-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.monitor-break-words { overflow-wrap: anywhere; }
.monitor-list-disc { list-style-type: disc; }
.monitor-list-inside { list-style-position: inside; }
.monitor-opacity-75 { opacity: 0.75; }
.monitor-opacity-80 { opacity: 0.8; }
.monitor-transition { transition: color var(--dur-chrome) var(--ease), background var(--dur-chrome) var(--ease), border-color var(--dur-chrome) var(--ease), box-shadow var(--dur-chrome) var(--ease); }
.monitor-cursor-pointer { cursor: pointer; }
.monitor-underline { text-decoration-line: underline; }
.monitor-hover-underline:hover { text-decoration-line: underline; }
.monitor-underline-offset-4 { text-underline-offset: 4px; }
.monitor-decoration-2 { text-decoration-thickness: 2px; }
.monitor-hover-shadow-sm:hover { box-shadow: var(--shadow-1); }
.monitor-hover-bg-gray-50:hover,
.monitor-hover-bg-gray-100:hover,
.monitor-dark-hover-bg-gray-800:hover,
.monitor-dark-hover-bg-gray-800-50:hover { background: var(--bg-2); }
.monitor-hover-text-gray-700:hover,
.monitor-dark-hover-text-gray-300:hover { color: var(--fg-1); }
.monitor-ring-2 { box-shadow: 0 0 0 2px var(--info); }
.monitor-ring-blue-500-70 { --monitor-ring: var(--info); }
.monitor-animate-pulse { animation: monitor-pulse 1.4s ease-in-out infinite; }
@keyframes monitor-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (min-width: 640px) {
  .monitor-sm-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitor-sm-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .monitor-sm-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .monitor-sm-flex-row { flex-direction: row; }
  .monitor-sm-items-center { align-items: center; }
  .monitor-sm-justify-between { justify-content: space-between; }
  .monitor-sm-table-cell { display: table-cell; }
  .monitor-sm-text-right { text-align: right; }
}
@media (min-width: 768px) {
  .monitor-md-block { display: block; }
  .monitor-md-hidden { display: none; }
  .monitor-md-table { display: table; }
  .monitor-md-table-cell { display: table-cell; }
  .monitor-md-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitor-md-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .monitor-md-grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .monitor-lg-grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .monitor-lg-grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .monitor-lg-grid-cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .monitor-lg-grid-cols-minmax-0-2fr-minmax-280px-1fr { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
}
@media (min-width: 1280px) {
  .monitor-xl-grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .monitor-xl-grid-cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .operator-filterbar label,
  .operator-filterbar .btn {
    width: 100%;
  }
  .operator-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .operator-queue-cards {
    display: grid;
    gap: var(--space-3);
  }
  .operator-queue-table {
    display: none;
  }
  .operator-mobile-facts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: var(--space-3);
    font-size: var(--fs-12);
  }
  .operator-mobile-facts span {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-3);
  }
  .operator-mobile-facts strong {
    display: block;
    margin-top: 2px;
    color: var(--fg-2);
    font-weight: 500;
  }
}

/* Inline-edit popover anchored to a table-row action button. */
.edit-popover {
  position: absolute;
  right: 0;
  z-index: 10;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-2);
  padding: var(--space-3);
  min-width: 280px;
  box-shadow: var(--shadow-2);
}
.edit-popover-title { font-weight: 600; font-size: var(--fs-13); }
.edit-popover-label { font-size: var(--fs-12); color: var(--fg-3); }

/* HTMX feedback region — keeps min-height so layout doesn't shift
   when HTMX swaps in/out a status pill or alert. */
.hx-feedback-region {
  min-height: 1rem;
}

/* Disclosure-toggle (<summary>) styling that matches the rest of the
   chrome — slim padding, muted color, pointer cursor. */
.details-summary {
  padding: var(--space-1) 0;
}

/* Count suffix for nav-button labels (e.g. `Articles (12)` chip). */
.btn-count {
  opacity: 0.6;
  font-size: 0.85em;
  margin-left: 2px;
}

/* =========================================================
   14. Chat answer cards (HTMX fragment in /chat)
   ---------------------------------------------------------
   Used by pages/chat_answer.html (rendered into #chat-thread).
   --------------------------------------------------------- */
.chat-msg {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}
.chat-msg .eyebrow {
  flex-shrink: 0;
  padding-top: 2px;
}
.chat-msg.assistant .eyebrow { color: var(--accent); }
.chat-msg .body { flex: 1; min-width: 0; }
.chat-msg .question {
  margin: 0;
  font-size: var(--fs-14);
  font-weight: 500;
}
.chat-msg .answer {
  font-size: var(--fs-14);
  line-height: 1.6;
}
.chat-msg .meta {
  font-size: var(--fs-11);
  margin-top: var(--space-2);
}

.chat-citations {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
}
.chat-citation {
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
  font-size: var(--fs-13);
}
.chat-citation .tag {
  flex-shrink: 0;
  min-width: 22px;
  text-align: center;
}
.chat-citation-body { min-width: 0; }
.chat-citation-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fg-1);
}
.chat-citation-meta { font-size: var(--fs-11); }

/* =========================================================
   15. Settings — vertical card list (channel toggles, etc.)
   --------------------------------------------------------- */
.list-card {
  padding: 0;
  overflow: hidden;
}
.list-card .list-row {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
}
.list-card .list-row:last-child { border-bottom: 0; }
.list-card .list-empty {
  padding: var(--space-4) var(--space-6);
  color: var(--fg-3);
  font-size: var(--fs-14);
}

/* =========================================================
   16. Annotation list (reader.html ann-list)
   --------------------------------------------------------- */
.ann-quote-display {
  margin: 0 0 var(--space-5);
  padding-left: var(--space-5);
  border-left: 2px solid var(--accent);
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--fs-14);
  color: var(--fg-2);
}
.ann-note {
  margin: 0;
  font-size: var(--fs-13);
  line-height: 1.5;
}
.ann-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-11);
  color: var(--fg-3);
}
.ann-delete-btn {
  font-size: var(--fs-11);
  padding: 0 var(--space-2);
}
