/* ChatFlow Tracker view (#tracker-view), v2: the old Tracker layout and density on design A,
   with the 2026-09-30 colour language (identity chips, status chips with words, threshold
   coloured Match %, tinted Open and Delete, soft card shadows). Needs tokens.css,
   components.css and chrome.css (.cf-page) first.

   The list: page header (Period, Refresh, one primary New Campaign), one table (Campaign with
   its type chip, Platform, Bot, DM Account, Clicks, DMs, VIP Joins, Match %, Updated, Open and
   Delete on every row) and the Match % legend. The detail: Back, the name with Rename and the
   type chip, the platform chip-button on the right, then the tabs (Bot Config, Domains, DM
   Tracking, Postbacks) straight under the title; each tab is a stack of cards as before.

   Class names are tr-* (or the colour language names below, scoped to the Tracker), so the
   old night layer's .flow-list, .wrap, .toggle-slider and [style*=...] rules never reach it. */

/* ---------- Colour language tokens ----------
   The status, identity, card shadow and canvas tokens come from tokens.css (COLOUR-TOKENS.md),
   the same values this view had scoped to itself before the colour pass landed. Only this
   view's own names stay here:
   - --idle-tint keeps the Tracker's --fill ground (tokens.css darkened it by day for the
     chips on the canvas), so the Tracker's grey chips render as before;
   - --info-hover keeps a hovered Open at 4.5:1 (not in COLOUR-TOKENS.md);
   - the --tr-* surfaces: the inset panel inside a card, the raised neutral button on it, and
     the neutral button that sits on the canvas (tokens.css --canvas-ctl, under its old name). */
#tracker-view,
.tr-dialog {
  --idle-tint: var(--fill);   /* --idle (--ink-2) 5.30:1 on it */
  /* the words of an info-tinted button under the hover overlay: 5.03:1 on #D6DEEA
     (--info-tint plus --press-overlay), where --info would drop to 4.46 */
  --info-hover: #0A56BD;
  --tr-inset: var(--hover);
  --tr-raised: var(--pop);
  --tr-raised-edge: var(--line);
  --tr-on-canvas: var(--canvas-ctl);
  --tr-on-canvas-shadow: var(--canvas-ctl-shadow);
}
:root[data-theme="night"] #tracker-view,
:root[data-theme="night"] .tr-dialog {
  --info-hover: var(--info);  /* 4.83:1 under the night hover overlay */
  --tr-inset: var(--fill);
  /* the night --line value as a fixed ground (ink 11.37:1): Increase Contrast turns --line
     itself into the #8E8E93 edge colour, which would leave the words at 2.67:1 */
  --tr-raised: #2C2C31;
  --tr-raised-edge: var(--edge);
}

/* colour classes: the same rules as components.css, kept scoped here so they keep their
   specificity over the Tracker's own chip and tag rules */
:is(#tracker-view, .tr-dialog) .chip-ok { background: var(--ok-tint); color: var(--ok); }
:is(#tracker-view, .tr-dialog) .chip-warn { background: var(--warn-tint); color: var(--warn); }
:is(#tracker-view, .tr-dialog) .chip-bad { background: var(--bad-tint); color: var(--bad); }
:is(#tracker-view, .tr-dialog) .chip-info { background: var(--info-tint); color: var(--info); }
:is(#tracker-view, .tr-dialog) .chip-idle { background: var(--idle-tint); color: var(--idle); }
:is(#tracker-view, .tr-dialog) .chip-meta { background: var(--id-meta-tint); color: var(--id-meta); }
:is(#tracker-view, .tr-dialog) .chip-tiktok { background: var(--id-tiktok-tint); color: var(--id-tiktok); box-shadow: inset 0 0 0 1px var(--id-tiktok-edge); }
:is(#tracker-view, .tr-dialog) .chip-bot { background: var(--id-bot-tint); color: var(--id-bot); }
:is(#tracker-view, .tr-dialog) .chip-dm { background: var(--id-dm-tint); color: var(--id-dm); }
:is(#tracker-view, .tr-dialog) .chip-channel { background: var(--id-channel-tint); color: var(--id-channel); }
#tracker-view .num-ok { color: var(--ok); }
#tracker-view .num-warn { color: var(--warn); }
#tracker-view .num-bad { color: var(--bad); }
/* tinted secondary actions: Open (blue), Delete and Disconnect (red) */
#tracker-view .btn.btn-tint-info { background-color: var(--info-tint); color: var(--info); }
#tracker-view .btn.btn-tint-info:hover:not(:disabled) { color: var(--info-hover); }
#tracker-view .btn.btn-tint-bad { background-color: var(--bad-tint); color: var(--bad); }
/* the raised neutral: a button on an inset panel (day --pop with a --line edge; night the
   night --line value as a fixed ground with an --edge edge), and the neutral on the canvas
   (Period, Refresh, Back) */
#tracker-view .btn.tr-raised { background-color: var(--tr-raised); box-shadow: inset 0 0 0 1px var(--tr-raised-edge); }
#tracker-view .btn.tr-on-canvas { background-color: var(--tr-on-canvas); box-shadow: var(--tr-on-canvas-shadow); }

/* ---------- Frame ---------- */
#tracker-view { background: var(--canvas); }
.tr-page > * { max-width: 1400px; }
/* anything this view hides with the hidden attribute stays hidden, whatever display its class sets */
.tr-page [hidden], .tr-dialog [hidden] { display: none; }
.tr-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.input.tr-mono { font-size: var(--fs-label); }
.tr-page .input[readonly], .tr-dialog .input[readonly] { background: var(--hover); }
.tr-page .input { height: 34px; }
.tr-page textarea.input { height: auto; }
.tr-none { color: var(--ink-2); }
.tr-page code { font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Chips ----------
   .tr-id: an identity (or a status that stands in for one) with its 14px icon, 22px tall;
   .tr-id.is-sm: the campaign type chip under a name, 18px; .tr-tag: a status word, 11px. */
.tr-id {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  height: 22px;
  box-sizing: border-box;
  padding: 0 8px 0 6px;
  border-radius: 6px;
  font: var(--fw-semibold) var(--fs-caption)/16px var(--font);
  white-space: nowrap;
  vertical-align: middle;
}
.tr-id > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tr-id > svg { flex: none; }
.tr-id.is-sm { height: 18px; padding: 0 6px 0 4px; font-size: var(--fs-badge); line-height: 14px; }
.tr-tag {
  flex: none;
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font: var(--fw-semibold) var(--fs-badge)/var(--lh-badge) var(--font);
  white-space: nowrap;
}

/* ---------- Page header: Period, Refresh, New Campaign ---------- */
.tr-head { margin-bottom: 24px; }
.tr-head .page-title:focus { outline: none; }
.tr-period {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--control-h);
  box-sizing: border-box;
  padding: 0 8px 0 12px;
  border-radius: var(--radius-control);
  background: var(--tr-on-canvas);
  box-shadow: var(--tr-on-canvas-shadow);
  color: var(--ink);
  font: var(--fw-regular) var(--fs-label)/16px var(--font);
  white-space: nowrap;
  cursor: pointer;
}
.tr-period:hover { background-image: linear-gradient(var(--press-overlay), var(--press-overlay)); }
.tr-period-label { color: var(--ink-2); }
.tr-period select {
  appearance: none;
  -webkit-appearance: none;
  margin: 0 -24px 0 0;
  padding: 0 24px 0 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: var(--fw-semibold) var(--fs-label)/16px var(--font);
  color-scheme: var(--scheme);
  field-sizing: content;
  cursor: pointer;
  outline: none;
}
.tr-period .ic { color: var(--ink-2); pointer-events: none; }
.tr-period:has(select:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.tr-refresh[aria-busy="true"] .ic { animation: tr-spin 0.9s linear infinite; }
@keyframes tr-spin { to { transform: rotate(360deg); } }

/* ---------- Tables: the campaign list, Postbacks, Executions ----------
   Each scrolls inside its card: sideways when it cannot fit (the list keeps its Campaign
   column frozen), down with a sticky header (Executions caps its height). */
.tr-scroll {
  overflow: auto;
  overscroll-behavior-x: contain;
  max-height: max(360px, calc(100dvh - 160px));
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--pop);
  box-shadow: var(--shadow-card);
  scrollbar-width: thin;
  scrollbar-color: var(--edge-field) transparent;
}
.tr-scroll:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* a table inside a card: an inset box, no shadow of its own */
.tr-scroll.is-inset { border-radius: 10px; box-shadow: none; }
.tr-exec-scroll { max-height: 320px; }
/* max-content: columns never squeeze below their content; the card scrolls instead */
.tr-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--ink);
  font: var(--fw-regular) var(--fs-label)/16px var(--font);
  font-variant-numeric: tabular-nums;
}
.tr-table th,
.tr-table td {
  height: 44px;
  box-sizing: border-box;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: var(--pop);
  text-align: left;
  white-space: nowrap;
  vertical-align: middle;
}
.tr-table tr > :first-child { padding-left: 16px; }
.tr-table tr > :last-child { padding-right: 16px; }
.tr-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 32px;
  padding-top: 0;
  padding-bottom: 0;
  background: var(--fill);
  color: var(--ink-2);
  font: var(--fw-semibold) var(--fs-caption)/var(--lh-caption) var(--font);
}
.tr-table tbody th { font-weight: var(--fw-regular); }
.tr-table tbody tr:last-child > * { border-bottom: 0; }
.tr-table tbody tr:hover > * { background: var(--hover); }
.tr-table .tr-r { text-align: right; }
.tr-table .tr-mono { font-size: var(--fs-caption); }
.tr-table .tr-zero, .tr-table .tr-upd { color: var(--ink-2); }
/* the campaign list: 56px rows, the Campaign column stays put when the table scrolls sideways */
.tr-table.is-list tbody th, .tr-table.is-list tbody td { height: 56px; padding-top: 0; padding-bottom: 0; }
/* a name that wraps grows its row: the name's 28px target overhangs its 16px line by 6px */
.tr-table.is-list tbody th { padding-top: 8px; padding-bottom: 8px; }
/* a long handle ends in an ellipsis (its full text is the chip's title) */
.tr-table .tr-id { max-width: 240px; }
.tr-table.is-list tr > :first-child { position: sticky; left: 0; z-index: 1; }
.tr-table.is-list thead tr > :first-child { z-index: 3; }
.tr-scroll.is-scrolled-x .tr-table.is-list tr > :first-child { box-shadow: inset -1px 0 0 var(--line); }
/* When the one-line table would scroll sideways in its card (trFitList), the list compacts
   as the old one did: 6px cells, Updated as the date over the time, VIP Joins on two lines.
   About 100px narrower, so every column and both row buttons fit from a ~1300px window. */
.tr-scroll.is-compact .tr-table.is-list th,
.tr-scroll.is-compact .tr-table.is-list td { padding-left: 6px; padding-right: 6px; }
.tr-scroll.is-compact .tr-table.is-list tr > :first-child { padding-left: 14px; }
.tr-scroll.is-compact .tr-table.is-list tr > :last-child { padding-right: 14px; }
.tr-scroll.is-compact .tr-upd-t,
.tr-scroll.is-compact .tr-th-2 { display: block; }

/* Campaign cell: the name (a button that opens it) over its type chip */
.tr-camp { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tr-camp-link {
  display: inline-flex;
  align-items: center;
  max-width: 240px;
  min-height: 28px;
  margin: -6px 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: var(--fw-semibold) var(--fs-label)/16px var(--font);
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.tr-camp-link:hover { color: var(--reply); text-decoration: underline; }
.tr-camp-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.tr-match { display: inline-flex; align-items: center; gap: 6px; }
.tr-pct { min-width: 30px; font-weight: var(--fw-semibold); }
.tr-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.tr-row-actions .btn.btn-sm { padding: 0 12px; }
.tr-mappings { display: flex; flex-wrap: wrap; gap: 4px; white-space: normal; min-width: 180px; }
/* the Match % legend under the list */
.tr-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 12px 0 0 2px; font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }
.tr-legend-item { display: inline-flex; align-items: center; gap: 5px; margin-left: 4px; }

/* ---------- List states: skeleton, inline error with Try Again, empty ---------- */
.tr-error {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 16px;
  padding: 8px 8px 8px 12px;
  border-radius: var(--radius-control);
  background: var(--bad-tint);
  color: var(--bad);
  font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font);
}
.tr-error > .ic { flex: none; }
.tr-error-text { flex: 1 1 240px; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.tr-error .btn { background-color: var(--pop); }
.tr-card > .tr-error, .tracker-pane > .tr-error, #tracker-detail-state > .tr-error { margin: 0; }
.tr-skel { border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--pop); box-shadow: var(--shadow-card); overflow: hidden; }
.tr-skel-row { display: flex; align-items: center; gap: 24px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.tr-skel-row:first-child { height: 32px; background: var(--fill); }
.tr-skel-row:last-child { border-bottom: 0; }
.tr-skel-bar { display: block; flex: 0 1 64px; height: 12px; border-radius: 4px; background: var(--skeleton-a); animation: tr-pulse 1.2s ease-in-out infinite alternate; }
.tr-skel-row .tr-skel-bar:first-child { flex-basis: 160px; }
.tr-skel-row .tr-skel-bar:last-child { margin-left: auto; flex-basis: 128px; height: 28px; border-radius: var(--radius-control); }
.tr-skel-row:first-child .tr-skel-bar { height: 10px; }
.tr-skel-row:first-child .tr-skel-bar:last-child { height: 10px; }
@keyframes tr-pulse { from { background: var(--skeleton-a); } to { background: var(--skeleton-b); } }
.tr-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 24px; box-shadow: var(--shadow-card); }
.tr-empty-title { margin: 0; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.tr-empty-text { margin: 0 0 12px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.tr-note { margin: 0; padding: 14px 20px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.tr-table-note { margin: 12px 0 0 2px; font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }

/* ---------- Detail header: Back, name, Rename, type chip ... platform ---------- */
.tr-detail-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; min-height: 32px; }
.tr-back .ic { margin-left: -2px; }
.tr-title-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tr-title-line .page-title { min-width: 0; overflow-wrap: anywhere; }
/* the title takes focus when a campaign opens; it is not a control */
.tr-title-line .page-title:focus { outline: none; }
.tr-plat-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  box-sizing: border-box;
  margin-left: auto;
  padding: 0 6px 0 10px;
  border: 0;
  border-radius: var(--radius-control);
  font: var(--fw-semibold) var(--fs-label)/16px var(--font);
  white-space: nowrap;
  cursor: pointer;
}
.tr-plat-btn:hover { background-image: linear-gradient(var(--press-overlay), var(--press-overlay)); }
.tr-plat-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Tabs: straight under the title ---------- */
.tr-tabs { display: flex; gap: 4px; margin: 16px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tr-tab {
  flex: none;
  height: 38px;
  box-sizing: border-box;
  margin-bottom: -1px;
  padding: 2px 12px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font: var(--fw-semibold) var(--fs-label)/16px var(--font);
  white-space: nowrap;
  cursor: pointer;
}
.tr-tab:hover { color: var(--ink); }
.tr-tab[aria-selected="true"] { color: var(--reply); border-bottom-color: var(--reply); }
.tr-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: var(--radius-control) var(--radius-control) 0 0; }
.tr-tab[hidden] { display: none; }
#tracker-detail-state { margin-top: 16px; }
#tracker-detail-state > .tr-note { padding: 0; }
.tracker-pane { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.tracker-pane[hidden] { display: none; }
.tracker-pane:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--radius-control); }

/* ---------- Cards and what sits in them ---------- */
.tr-card { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 16px 20px; box-shadow: var(--shadow-card); overflow: visible; }
.tr-card.is-flush { gap: 0; padding: 0; overflow: hidden; }
.tr-h2 { display: flex; align-items: center; gap: 6px; margin: 0; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.tr-h2 > svg { flex: none; color: var(--id-channel); }
.tr-h2:focus { outline: none; }
.tr-sub { margin: -10px 0 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.tr-sub b { font-weight: var(--fw-semibold); color: var(--ink); }
.tr-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.tr-card-head-text { flex: 1 1 180px; min-width: 0; }
.tr-card-head-text .tr-sub { margin-top: 2px; }
.tr-card.is-flush > .tr-card-head { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.tr-head-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.tr-card .field { gap: 6px; }
.tr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* a field with its buttons on one line (Whitepage URL, Short Ads URL, the channel picker) */
.tr-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tr-inline > .input { flex: 1 1 240px; width: auto; min-width: 0; }
/* labels sit 6px over their field, 12px under what comes before */
.tr-card > .field-label, .tr-inset > .field-label { margin-bottom: -6px; }
/* the inset panel inside a card: the account, the bot, token join, the token form */
.tr-inset { display: flex; flex-direction: column; gap: 12px; box-sizing: border-box; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--tr-inset); }
.tr-inset.is-row { flex-direction: row; align-items: center; flex-wrap: wrap; }
.tr-idrow-main { flex: 1 1 180px; display: flex; flex-direction: column; min-width: 0; }
.tr-idrow-title { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.tr-idrow-meta { margin: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tr-idrow-side { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
/* identity tiles: the bot, the DM account (round), a channel (small) */
.tr-tile { flex: none; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; }
.tr-tile.is-round { border-radius: 50%; }
.tr-tile.is-sm { width: 28px; height: 28px; border-radius: 8px; }
.tr-status-line, .tr-inline-status { margin: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.tr-status-line:empty, .tr-inline-status:empty { display: none; }
.tr-status-line.is-error, .tr-inline-status.is-error { color: var(--bad); font-weight: var(--fw-semibold); }
/* the error under a field: red words with the alert icon */
.tr-field-error { display: flex; align-items: center; gap: 6px; margin: -6px 0 0; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--bad); }
.tr-field-error:empty { display: none; }
.tr-field-error > .ic { flex: none; }
.tr-ok-line { display: flex; align-items: center; gap: 6px; margin: -6px 0 0; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ok); }
.tr-ok-line > svg { flex: none; }

/* Banners: the status tint is the whole ground (DM Tracking Active, Driver: Bot API) */
.tr-banner { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; box-sizing: border-box; padding: 12px 16px; border-radius: var(--radius-card); }
.tr-banner.is-ok { background: var(--ok-tint); }
.tr-banner.is-info { padding: 10px 16px; background: var(--info-tint); }
.tr-banner-disc { flex: none; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ok); color: var(--ok-tint); }
.tr-banner-glyph { flex: none; display: flex; color: var(--id-bot); }
.tr-banner-text { flex: 1 1 260px; min-width: 0; }
.tr-banner-title { margin: 0; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.tr-banner-sub, .tr-banner-note { margin: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.tr-banner-note { flex: 1 1 260px; min-width: 0; color: var(--ink); }
.tr-banner-sub b, .tr-banner-note b { font-weight: var(--fw-semibold); color: var(--ink); }
.tr-banner-side { flex: none; display: flex; align-items: center; gap: 12px; }

/* Callouts: a notice inside a card (warn, info, ok) with its one action. The icon and the
   words are one group (the icon on the first line), centred against the button. */
.tr-callout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  box-sizing: border-box;
  padding: 10px 12px 10px 14px;
  border-radius: 10px;
  font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font);
}
.tr-callout-body { flex: 1 1 260px; display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.tr-callout-body > svg { flex: none; margin-top: 1px; }
.tr-callout-text { flex: 1 1 auto; min-width: 0; margin: 0; }
.tr-callout-text b { font-weight: var(--fw-semibold); }
.tr-callout.is-warn { background: var(--warn-tint); color: var(--warn); }
.tr-callout.is-ok { background: var(--ok-tint); color: var(--ok); }
.tr-callout.is-ok .tr-callout-text { font-weight: var(--fw-semibold); }
.tr-callout.is-info { background: var(--info-tint); color: var(--ink); }
.tr-hook:empty { display: none; }
.tr-hook > .tr-inline-status { padding: 2px 0; }

/* ---------- Switch: a checkbox with role="switch" on a 44x28 target, --reply when on ---------- */
.tr-switch-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tr-switch-text { flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tr-switch-desc { margin: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink-2); }
.tr-switch-desc.is-ok { font-weight: var(--fw-semibold); color: var(--ok); }
.tr-switch-desc.is-error { font-weight: var(--fw-semibold); color: var(--bad); }
.tr-switch-row.is-compact .tr-h2 { font-size: var(--fs-label); line-height: var(--lh-label); }
.tr-switch-row.is-compact .tr-switch-desc { font-size: var(--fs-caption); line-height: var(--lh-caption); }
.tr-switch-side { flex: none; display: flex; align-items: center; gap: 10px; }
.tr-switch-word { min-width: 22px; text-align: right; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }
.tr-switch-word.is-off { color: var(--ink-2); }
.tr-switch { position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 28px; margin: 0 -2px; }
.tr-switch input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.tr-switch-track { position: relative; width: 40px; height: 24px; box-sizing: border-box; border-radius: 12px; background: var(--edge-field); transition: background .15s ease; }
.tr-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 2px rgba(0, 0, 0, .24); transition: transform .15s ease; }
.tr-switch input:checked + .tr-switch-track { background: var(--reply); }
.tr-switch input:checked + .tr-switch-track::after { transform: translateX(16px); }
.tr-switch input:focus-visible + .tr-switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.tr-switch input:disabled { cursor: default; }
.tr-switch input:disabled + .tr-switch-track { opacity: .5; }

/* ---------- Checkboxes: box, icon and words are one target ---------- */
.tr-check { flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 28px; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); cursor: pointer; }
.tr-check.is-plain { font-weight: var(--fw-regular); }
.tr-check input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--reply); color-scheme: var(--scheme); cursor: pointer; }
.tr-check > svg, .tr-days-label > svg { flex: none; color: var(--ink-2); }
.tr-check.is-disabled { color: var(--ink-2); cursor: default; }
.tr-check.is-disabled input { cursor: default; }

/* ---------- Bot Config: channels ---------- */
.tr-chan { display: flex; flex-direction: column; gap: 8px; padding: 12px 20px; }
.tr-chan + .tr-chan { border-top: 1px solid var(--line); }
.tr-chan-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tr-chan-title { flex: 1 1 auto; min-width: 0; margin: 0; overflow-wrap: anywhere; font: var(--fw-semibold) var(--fs-body)/var(--lh-body) var(--font); color: var(--ink); }
.tr-chan-tags { flex: none; display: flex; gap: 6px; }
.tr-chan-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding-left: 38px; }
.tr-chan-line .tr-check { margin: -5px 0; }
.tr-chan-hint { flex: 1 1 260px; min-width: 0; font: var(--fw-regular) var(--fs-caption)/var(--lh-caption) var(--font); color: var(--ink-2); }
.tr-chan-hint b { font-weight: var(--fw-semibold); color: var(--ink); }
.tr-days-label { flex: none; display: flex; align-items: center; gap: 6px; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }
.tr-page .tr-days-select { flex: none; width: 108px; height: 28px; }
.tr-bound { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }
.tr-aa { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }
.tr-page .tr-aa .input { width: 76px; }
.tr-secret { display: flex; gap: 8px; align-items: center; }
.tr-secret .input { flex: 1; min-width: 0; }
.tr-secret .btn { height: 34px; }

/* ---------- DM Tracking: the two columns, the preset, the code boxes ---------- */
.tr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tr-preset-row { display: flex; align-items: flex-end; gap: 8px; }
.tr-preset-row .input { flex: 1; min-width: 0; min-height: 56px; }
.tr-otp { display: flex; gap: 8px; }
.tr-page .tr-otp .input { width: 44px; height: 44px; padding: 0; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }
.tr-fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.tr-fieldset > legend { padding: 0; margin: 0 0 8px; font: var(--fw-semibold) var(--fs-label)/var(--lh-label) var(--font); color: var(--ink); }
.tr-form { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
.tr-form > .tr-actions { margin-top: 0; }
/* the whitepage form sits under a hairline, as the old card had it */
.tr-cloak-form { padding-top: 12px; border-top: 1px solid var(--line); }
.tr-inset.is-token { padding: 8px 12px; }

/* ---------- Dialogs ---------- */
.tr-dialog { width: 480px; }
.tr-dialog-wide { width: 600px; }
.tr-dialog .seg { display: grid; width: 100%; }
.tr-dialog .seg > button { min-width: 0; }
.tr-dialog .form-stack + .form-stack,
.tr-dialog .modal-text + .form-stack { margin-top: 16px; }
.tr-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.tr-maps { display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.tr-maps > li { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; box-sizing: border-box; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); font: var(--fw-regular) var(--fs-label)/var(--lh-label) var(--font); }
.tr-maps > li b { font-weight: var(--fw-semibold); }
.tr-map-add { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; }
.tr-map-add .field { flex: 1 1 200px; }
.tr-map-add .field:first-child { flex-basis: 100%; }
.tr-map-add .seg > button { white-space: normal; height: auto; min-height: 28px; padding: 4px 8px; line-height: 16px; }
.tr-bind { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tr-bind .input { flex: 1 1 220px; width: auto; min-width: 0; }
.modal-box .input.tr-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.tr-preview { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .tr-refresh[aria-busy="true"] .ic, .tr-skel-bar { animation: none; }
  .tr-switch-track, .tr-switch-track::after { transition: none; }
}

/* ---------- Touch: 44px targets ---------- */
@media (pointer: coarse) {
  .tr-tab { height: 44px; }
  .tr-camp-link { min-height: 44px; margin: -14px 0; }
  .tr-plat-btn { height: 44px; }
  .tr-switch { width: 56px; height: 44px; }
  .tr-switch-track { width: 52px; height: 32px; border-radius: 16px; }
  .tr-switch-track::after { width: 28px; height: 28px; }
  .tr-switch input:checked + .tr-switch-track::after { transform: translateX(20px); }
  .tr-check { min-height: 44px; }
  .tr-page .input, .tr-page .tr-days-select, .tr-secret .btn { height: 44px; }
}

/* ---------- Narrow windows and phones ---------- */
@media (max-width: 899px) {
  .tr-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .tr-head .page-actions { flex: 1 1 100%; }
  .tr-camp-link { max-width: 150px; }
  /* the name is the Open here: the Open column would sit far off to the right */
  .tr-row-actions .tr-open { display: none; }
  .tr-scroll:not(.tr-exec-scroll) { max-height: max(360px, calc(100dvh - 120px)); }
  .tr-title-line { flex: 1 1 200px; }
  .tr-plat-btn { margin-left: 0; }
  .tr-card { padding: 14px 16px; }
  .tr-card.is-flush > .tr-card-head, .tr-chan { padding-left: 16px; padding-right: 16px; }
  .tr-chan-line { padding-left: 0; }
  .tr-chan-head { flex-wrap: wrap; }
  .tr-idrow-side { flex: 1 1 100%; }
  .tr-banner-side { flex: 1 1 100%; justify-content: space-between; }
  .tr-preset-row { flex-direction: column; align-items: stretch; }
  .tr-preset-row .btn { align-self: flex-start; }
  .tr-otp { gap: 6px; }
}
