:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #f0f2f5; --text: #1a1d23; --muted: #5d6573; --border: #dde1e7;
  --accent: #2457d6; --accent-soft: #e6edfc; --ok: #1d7a46; --ok-soft: #e3f3ea; --warn: #9a6200; --warn-soft: #fdf1dc;
  --bad: #b42318; --bad-soft: #fde7e5; --info-soft: #e8f1fb;
  --gap-mark: rgba(250, 204, 21, .45); --gap-edge: rgba(202, 138, 4, .6);
  --radius: 10px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111318; --surface: #181b22; --surface-2: #20242d; --text: #e7e9ee; --muted: #9aa2b1; --border: #2c313c;
    --accent: #7aa2ff; --accent-soft: #1d2a4a; --ok: #5cc98a; --ok-soft: #15301f; --warn: #f0b44c; --warn-soft: #33270f;
    --bad: #ff8a80; --bad-soft: #3a1714; --info-soft: #172436;
    --gap-mark: rgba(250, 204, 21, .3); --gap-edge: rgba(250, 204, 21, .55);
  }
}
:root[data-theme="dark"] {
    --bg: #111318; --surface: #181b22; --surface-2: #20242d; --text: #e7e9ee; --muted: #9aa2b1; --border: #2c313c;
    --accent: #7aa2ff; --accent-soft: #1d2a4a; --ok: #5cc98a; --ok-soft: #15301f; --warn: #f0b44c; --warn-soft: #33270f;
    --bad: #ff8a80; --bad-soft: #3a1714; --info-soft: #172436;
    --gap-mark: rgba(250, 204, 21, .3); --gap-edge: rgba(250, 204, 21, .55);
}
:root { color-scheme: light dark; }
:root[data-theme="light"] { color-scheme: light; } :root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; height: 100vh; }
.sidebar:has(#bell-button[aria-expanded="true"]) { z-index: 45; }  /* its open bell menu draws over the page and the side panel (09.11) */
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; color: var(--text); padding: 4px 8px 12px; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); display: inline-block; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 8px 4px; }
.nav-item { display: block; padding: 6px 8px; border-radius: 7px; color: var(--text); }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--border); padding: 10px 8px 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { padding: 20px 24px 48px; min-width: 0; }
.page-head { margin-bottom: 16px; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.page-head p { margin: 2px 0 0; flex-basis: 100%; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; min-width: 0; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { color: var(--muted); font-size: 12px; }
.tile-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); padding: 6px 8px; white-space: nowrap; }
.table td { border-bottom: 1px solid var(--border); padding: 7px 8px; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table-wrap { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.pill-ok { background: var(--ok-soft); color: var(--ok); } .pill-warn { background: var(--warn-soft); color: var(--warn); } .pill-bad { background: var(--bad-soft); color: var(--bad); }
.banner { border-radius: var(--radius); padding: 9px 12px; margin-bottom: 10px; border: 1px solid var(--border); background: var(--info-soft); }
.banner-warn { background: var(--warn-soft); border-color: transparent; } .banner-bad { background: var(--bad-soft); border-color: transparent; }
.button { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.button:hover { background: var(--surface-2); text-decoration: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.danger { color: var(--bad); }
.button[disabled] { opacity: .5; cursor: not-allowed; }
.link-button { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
.link-button.danger { color: var(--bad); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; }
textarea { width: 100%; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.inline-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.center-card { max-width: 440px; margin: 12vh auto; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.center-card h1 { display: flex; gap: 10px; align-items: center; }
.dev-login form { margin: 6px 0; } .dev-login .button { width: 100%; justify-content: flex-start; }
.roles dt { font-weight: 600; margin-top: 8px; } .roles dd { margin: 2px 0 0; color: var(--muted); }
.spark { width: 120px; height: 28px; display: block; }
.why { font-size: 12.5px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }  /* a 64-character hash must not widen the page */
.stale { color: var(--warn); font-weight: 600; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; } /* the bar keeps its own height; the page takes the rest */
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 2px; } .nav-section { display: none; } .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr 1fr; }
  .main { padding: 16px; }
}
.report-frame { width: 100%; height: calc(100vh - 150px); border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border, #ccc); font-size: 13px; text-decoration: none; color: inherit; }
.chip[aria-current="true"] { background: var(--surface-2); font-weight: 600; }
.chip .count { color: var(--muted); }
tr.is-inactive { opacity: .7; }
dialog#confirm-dialog { max-width: 28rem; border-radius: 10px; }
.log { list-style: none; padding: 0; } .log li { padding: 4px 0; border-bottom: 1px solid var(--border, #eee); }
/* State tones (design §5.3): a shape as well as a colour, so state is never colour alone */
.pill[class*="tone-"]::before { display: inline-block; width: 1em; margin-right: 4px; text-align: center; }
.tone-ok::before { content: "●"; } .tone-neutral::before { content: "○"; } .tone-info::before { content: "◆"; }
.tone-warn::before { content: "▲"; } .tone-bad::before { content: "■"; } .tone-unknown::before { content: "?"; }
.tone-info { background: var(--surface-2); color: var(--accent); }

/* Cost page */
.budget { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.budget span { display: block; height: 100%; background: var(--accent); }
.budget.is-over span { background: var(--bad); }
.chart-frame svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.fill-generation { fill: var(--accent); } .fill-translation { fill: var(--ok); } .fill-unattributed { fill: var(--muted); }
.bg-generation { background: var(--accent); } .bg-translation { background: var(--ok); } .bg-unattributed { background: var(--muted); }
.bars { display: grid; grid-template-columns: minmax(0, max-content) minmax(40px, 1fr) max-content; gap: 6px 10px; align-items: center; }
.bars code { overflow-wrap: anywhere; }
.bars .bar { display: block; height: 10px; border-radius: 3px; background: var(--accent); }
.bars .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid-cost { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 800px) { .grid-cost, .split { grid-template-columns: minmax(0, 1fr); } }

/* Page X-ray */
.sub { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.xray-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.xray-form input[type="text"], .xray-form input[type="url"] { flex: 1 1 22rem; min-width: 0; }
.xray-chips { margin: 10px 0; }
.xray-table td { vertical-align: top; }
.xray-table td, .xray-table th { padding-left: 6px; padding-right: 6px; }
.xray-table .pill { white-space: normal; }  /* «є в даних сторінки, не намальовано» wraps: the Details column stays in view at 1280 */
.xray-table details summary { cursor: pointer; white-space: nowrap; }
.xray-table details[open] { min-width: 18rem; }
.xray-reason strong { display: block; }
.pill.tone-ok { background: var(--ok-soft); color: var(--ok); } .pill.tone-warn { background: var(--warn-soft); color: var(--warn); }
.pill.tone-bad { background: var(--bad-soft); color: var(--bad); }

/* Discussion panel on the chain and request pages (chat step 7) */
.chat-panel { margin-bottom: 14px; }
.chat-panel .quote { margin: 0 0 6px; padding-left: 10px; border-left: 3px solid var(--border-strong); font-size: 13px; }
.chat-panel .quote .when { color: var(--muted); font-size: 12px; }
.chat-panel .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* The bell (DESIGN §9.9): in the sidebar head on every page for people with chat; the menu opens over the page. */
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-top .brand { padding-bottom: 4px; }
.bell { position: relative; flex: none; }
.bell-button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--text); cursor: pointer; }
.bell-button:hover { background: var(--surface-2); }
/* the sprite's icons on every page (chat.css had the only rule, so a page without it drew them at full size, 08.11) */
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; }
.bell .icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bell-badge { position: absolute; top: -2px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.bell-badge[hidden] { display: none; }
.bell-menu { position: fixed; top: 52px; left: 12px; z-index: 40; width: min(400px, calc(100vw - 24px)); max-height: min(70vh, 520px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px -8px rgba(16, 24, 40, .3); }
.bell-menu[hidden] { display: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.bell-empty { padding: 12px; margin: 0; }
.notif { list-style: none; margin: 0; padding: 4px; }
.notif li { border-radius: 8px; }
.notif li + li { margin-top: 2px; }
.notif a { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.notif a:hover, .notif a:focus-visible { background: var(--surface-2); text-decoration: none; }
.notif .n-icon { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.notif .n-bot { background: var(--accent-soft); color: var(--accent); }
.notif .n-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.notif .n-title { font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.notif li.is-unread .n-title { font-weight: 600; }
.notif .n-meta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif .n-dot { flex: none; width: 8px; height: 8px; margin-top: 10px; border-radius: 50%; background: var(--accent); }
.nav-item .nav-badge { float: right; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; background: var(--bad); color: #fff; }

/* Releases (§16.4): tabs and the preflight checks */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.tabs a { padding: 5px 12px; border-radius: 7px; color: var(--muted); font-size: 13px; text-decoration: none; }
.tabs [aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 650; }
.tabs .count { font-size: 11px; color: var(--muted); margin-left: 4px; }
.tag { display: inline-flex; align-items: center; padding: 0 6px; height: 18px; border-radius: 5px; font-size: 11px; font-weight: 650; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.tag.is-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checks li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: start; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.checks li::before { content: "✓"; font-weight: 700; color: var(--ok); text-align: center; }
.checks li.is-warn::before { content: "!"; color: var(--warn); } .checks li.is-bad::before { content: "✕"; color: var(--bad); }
.checks li.is-na::before { content: "–"; color: var(--muted); }
.checks li.is-warn { background: var(--warn-soft); border-color: transparent; } .checks li.is-bad { background: var(--bad-soft); border-color: transparent; }
.checks .sub { display: block; font-size: 12.5px; color: var(--muted); }
details.return-to-test > summary { list-style: none; cursor: pointer; display: inline-block; }
details.return-to-test > summary::-webkit-details-marker { display: none; }
details.return-to-test[open] { min-width: 16rem; }
details.return-to-test form { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

/* Quality overview and Review (§16.6) */
.signal { padding: 8px 0; border-bottom: 1px solid var(--border); } .signal:last-child { border-bottom: 0; }
.signal ul { margin: 4px 0 0; padding-left: 18px; }
.prompt { white-space: pre-wrap; max-height: 24rem; overflow: auto; font-size: 12px; background: var(--surface-2); padding: 8px; border-radius: 8px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row .field { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; } .progress > span { display: block; height: 100%; background: var(--accent); }
.review-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.review-row:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.review-row.is-answered { border-left: 3px solid var(--ok); }
.review-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 14rem; overflow: auto; margin: 6px 0; font-size: 13.5px; }
.review-errors { margin: 4px 0; padding-left: 18px; }
.review-answer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.button-group { display: inline-flex; gap: 4px; }
.button.small { padding: 3px 10px; font-size: 13px; }
.button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Factory «What is stopped»: the cause picked as a filter */
#issues tr.selected td { background: var(--accent-soft); }
/* Fits a 1280-pixel window (click-through 08.11: 111 px wider than its card): prose and the state pill wrap. */
#issues .status-table td.why { min-width: 150px; max-width: 360px; }
#issues .status-table td:first-child { min-width: 150px; }
#issues .status-table .pill { white-space: normal; }
#issues tr.status-working td { opacity: .78; }
#issues .status-others { margin-top: 10px; }
#issues .status-others summary { cursor: pointer; font-size: 13px; color: var(--muted); padding: 6px 0; }
/* a segmented switch (the agent's All · Mine, the usage period) */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; vertical-align: middle; }
.seg-item { padding: 4px 10px; font-size: 13px; text-decoration: none; color: var(--text); }
.seg-item + .seg-item { border-left: 1px solid var(--border); }
.seg-item.is-active { background: var(--accent-soft); font-weight: 600; }
.seg-item .count { font-size: 11.5px; color: var(--muted); margin-left: 2px; }
.usage-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 0; }
.usage-tiles dt { color: var(--muted); font-size: 12px; } .usage-tiles dd { margin: 2px 0 0; font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.usage-tiles dd.tile-note { font-size: 12px; font-weight: 400; color: var(--muted); }

/* «Якість» (08.11): texts list, one text with the judge's issues, editors' memory */
.q-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.q-head h1 { margin-right: 4px; }
.q-head .tabs { margin-left: auto; }
.q-intro p { margin: 0 0 6px; }
.q-legend .pill { margin: 0 2px; }
.q-filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; }
.q-filters .field select, .q-filters .field input { min-width: 0; }
.judge-reviewed { display: flex; gap: 6px; align-items: center; padding-bottom: 8px; }
.judge-note { flex-basis: 100%; margin: 0; }
.judge-dates { display: none; }
.judge-form:has(select[name="param_period"] option[value="custom"]:checked) .judge-dates { display: contents; }
.q-list tr.q-row { cursor: pointer; }
.q-list tr.q-row:hover td { background: var(--surface-2); }
.q-why { max-width: 460px; }
.pager { display: flex; gap: 14px; align-items: center; margin-top: 10px; }
.q-nav { display: flex; gap: 16px; margin: 0 0 10px; }
.q-text-head h2 { margin: 0 0 6px; }
.q-verdict { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.q-issues { margin: 0; padding-left: 22px; display: grid; gap: 10px; }
.q-issue { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.q-issue.level-critical { box-shadow: inset 3px 0 0 var(--bad); } .q-issue.level-major { box-shadow: inset 3px 0 0 var(--warn); }
.q-change { margin: 4px 0; font-size: 14px; }
.q-was { background: var(--bad-soft); color: var(--bad); padding: 1px 4px; border-radius: 4px; text-decoration: line-through; text-decoration-thickness: 1px; }
.q-should { background: var(--ok-soft); color: var(--ok); padding: 1px 4px; border-radius: 4px; font-weight: 600; }
.q-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; line-height: 1.55; max-height: 70vh; overflow: auto; }
.q-mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.q-mark sup { color: var(--warn); font-weight: 700; margin-right: 1px; }
.q-agreed { border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin: 0 0 8px; display: grid; gap: 3px; }
.q-note { display: block; margin-bottom: 8px; } .q-note input { width: 100%; max-width: 560px; }
.q-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.q-what { margin-top: 8px; } .q-what ul { margin: 6px 0 0; padding-left: 18px; }
.m-rule { padding: 10px 0; border-bottom: 1px solid var(--border); }
.m-rule:last-child { border-bottom: 0; }
.m-rule.state-off { opacity: .65; }
.m-rule.is-saved { margin: 0 -10px; padding: 10px; border-radius: var(--radius); background: var(--ok-soft); scroll-margin-top: 80px; }
.m-text { margin: 6px 0; font-size: 14.5px; }
.m-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.m-actions form.inline { display: inline; }
.m-edit { flex-basis: 100%; }
.m-form { display: grid; gap: 8px; margin-top: 6px; }
.m-form textarea { width: 100%; }
.m-wide { display: block; } .m-half { flex: 1 1 260px; } .m-half input { width: 100%; }
@media (max-width: 800px) { .q-head .tabs { margin-left: 0; } .q-why { max-width: none; } }

/* Texts per hour (Fahad 08.11): the last-hour tile, clickable lines and the big chart (static/aigen/js/throughput.js) */
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1250px) { .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid-5 { grid-template-columns: 1fr 1fr; } }
.tile-unit { font-size: 12px; font-weight: 400; }
.spark-open { display: block; padding: 2px; margin: -2px; border: 0; border-radius: 6px; background: none; color: inherit; cursor: zoom-in; }
.spark-open:hover { background: var(--surface-2); }
.spark-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tp-dialog { width: min(780px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 14px 18px 16px; }
.tp-dialog::backdrop { background: rgba(10, 14, 22, .45); }
.tp-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.tp-head h2 { margin: 0; overflow-wrap: anywhere; }
.tp-head form { margin: 0; }
.tp-summary { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 10px 0 12px; }
.tp-summary dt { color: var(--muted); font-size: 12px; }
.tp-summary dd { margin: 0; font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tp-summary dd .muted { font-size: 12px; font-weight: 400; }
.tp-plot { position: relative; }
.tp-chart { width: 100%; height: auto; display: block; }
.tp-bar path { fill: var(--accent); }
.tp-bar.is-current path, .tp-bar.is-current rect:not(.tp-hit) { opacity: .35; }
.tp-bar:hover path, .tp-bar:focus path, .tp-bar:hover rect:not(.tp-hit), .tp-bar:focus rect:not(.tp-hit) { opacity: .72; }
.tp-bar.is-current:hover path, .tp-bar.is-current:focus path, .tp-bar.is-current:hover rect:not(.tp-hit) { opacity: .5; }
.tp-bar:focus .tp-hit { stroke: var(--accent); stroke-width: 1; }
.tp-hit { fill: transparent; }
.tp-grid { stroke: var(--border); stroke-width: 1; }
.tp-base { stroke: var(--muted); stroke-width: 1; }
.tp-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tp-day { font-weight: 600; }
.tp-tip { position: absolute; left: 0; top: 0; background: var(--text); color: var(--surface); font-size: 12px; padding: 4px 8px; border-radius: 6px; pointer-events: none; white-space: nowrap; z-index: 2; }
.tp-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.tp-table .table-wrap, .tp-table table { margin-top: 6px; }
.tp-chart.is-ok .tp-bar path { fill: var(--ok); }
.tp-inline { min-height: 60px; }
.tp-inline .tp-chart { width: 100%; height: auto; max-width: 100%; }
.tp-summary.is-compact { gap: 4px 22px; margin: 2px 0 8px; }
.tp-summary.is-compact dd { font-size: 15px; }
/* numbers above the bars (Fahad 08.11): text ink, never the series colour; a surface halo keeps them clear of grid lines */
.tp-val { fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; paint-order: stroke; stroke: var(--surface);
  stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }
.tp-val.is-current { fill: var(--muted); }
.tp-threshold { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 4; }
.tp-bar .fill-translation { fill: var(--ok); } .tp-bar .fill-unattributed { fill: var(--muted); } .tp-bar .fill-generation { fill: var(--accent); }
.tp-table th.num { white-space: nowrap; }
/* the chart's «numbers above the bars» switch (Fahad 08.11) */
.tp-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 4px 16px; }
.tp-toggle { display: inline-flex; align-items: center; gap: 7px; margin: 0 0 6px auto; padding: 3px 4px; border: 0; border-radius: 6px;
  background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; }
.tp-toggle:hover { color: var(--text); }
.tp-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tp-switch { position: relative; flex: none; width: 26px; height: 15px; border-radius: 999px; background: var(--border); transition: background .15s; }
.tp-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.tp-toggle[aria-pressed="true"] .tp-switch { background: var(--accent); }
.tp-toggle[aria-pressed="true"] .tp-switch::after { transform: translateX(11px); }
@media (prefers-reduced-motion: reduce) { .tp-switch, .tp-switch::after { transition: none; } }

/* Tables (Fahad 08.11): sorting by a header click, quick filters and search (static/aigen/js/tables.js) */
table.is-sortable thead th { cursor: pointer; user-select: none; }
table.is-sortable thead th:hover { color: var(--text); }
table.is-sortable thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
table.is-sortable thead th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
/* every sortable column shows it can be sorted (Fahad 08.11: «the table itself has no way to sort»): a faint ↕ until it is the sorted one */
table.is-sortable thead th[aria-sort="none"]::after { content: " ↕"; font-size: 10px; opacity: .35; }
table.is-sortable thead th[aria-sort="none"]:hover::after { opacity: .8; }
table.is-sortable thead th[aria-sort="ascending"], table.is-sortable thead th[aria-sort="descending"] { color: var(--text); }
table.is-sortable thead th:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.table-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin: 0 0 10px; }
button.chip { background: var(--surface); font: inherit; font-size: 13px; cursor: pointer; }
button.chip:hover { background: var(--surface-2); }
button.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
button.chip[aria-pressed="true"] .count { color: inherit; }
.table-search { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
.table-tools .table-search { margin: 0; }
/* Select filters (Factory, Releases 09.11): one wrapping row; a select is as wide as its longest option, so it is capped. */
.table-selects { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.table-selects label { white-space: nowrap; }
.table-selects select { max-width: 13rem; text-overflow: ellipsis; }
.table-search input { min-width: min(240px, 100%); }
.xsmall { font-size: 12px; }
.m-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.m-owner { margin-left: auto; font-size: 12px; color: var(--muted); }
.m-owner::before { content: "👤 "; }
.m-rule[hidden] { display: none; }
/* «Якість» list: who checked what at a glance (Fahad 08.11) */
.q-found { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; margin-bottom: 8px; }
.q-found p { margin: 0; }
.q-human { white-space: nowrap; }
.q-check { color: var(--ok); font-weight: 700; }
.q-uncheck { color: var(--muted); }
.q-list tr.is-checked td:first-child { box-shadow: inset 3px 0 0 var(--ok); }

/* One text (Fahad 08.11: texts on top, click a span to see the judge's fix, «more appealing and easier to use») */
.q-nav { align-items: center; justify-content: space-between; flex-wrap: wrap; }
.q-nav-step { display: inline-flex; align-items: center; gap: 8px; }
.q-top { display: flex; gap: 18px; align-items: flex-start; justify-content: space-between; }
.q-top h1 { font-size: 20px; margin: 0 0 6px; }
.q-top-main { min-width: 0; flex: 1; }
.q-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.q-summary { margin: 8px 0 0; max-width: 980px; }
.q-score { flex: none; text-align: center; min-width: 110px; padding: 6px 12px; border-radius: 10px; background: var(--surface-2); }
.q-score-value { font-size: 30px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.q-levels { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.q-level::before { content: "■ "; } .q-level.level-critical { color: var(--bad); } .q-level.level-major { color: var(--warn); } .q-level.level-minor { color: var(--muted); }
.q-toolbar { position: sticky; top: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin: 0 0 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.q-toolbar .q-hint { margin: 0; }
.q-toolbar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.q-toolbar .button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.q-texts { align-items: start; }
.q-pane-title { font-size: 14px; margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.q-pane-main { box-shadow: inset 0 3px 0 var(--accent); }
.q-doc { font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }
.q-doc.is-plain { white-space: pre-wrap; }
.q-doc h1, .q-doc h2, .q-doc h3, .q-doc h4 { font-size: 16px; margin: 16px 0 6px; line-height: 1.35; }
.q-doc h1:first-child, .q-doc h2:first-child, .q-doc h3:first-child, .q-doc p:first-child { margin-top: 0; }
.q-doc p { margin: 0 0 10px; }
.q-doc ul, .q-doc ol { margin: 0 0 10px; padding-left: 22px; }
.q-doc li { margin: 2px 0; }
.q-code { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; }
.q-doc mark.q-mark, .q-code mark.q-mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 1px 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone;
  border-bottom: 2px solid var(--warn); transition: background .15s, box-shadow .15s; }
.q-doc mark.q-mark[data-level="critical"] { background: var(--bad-soft); border-bottom-color: var(--bad); }
.q-doc mark.q-mark[data-level="minor"] { background: var(--info-soft); border-bottom-color: var(--accent); }
.q-trans mark.q-mark { cursor: pointer; }
.q-trans mark.q-mark:hover { filter: brightness(.96); }
.q-doc mark.q-mark.is-fixed { background: var(--ok-soft); border-bottom-color: var(--ok); color: var(--text); }
.q-doc mark.q-mark.is-fixed .q-num { background: var(--ok); }
.q-doc mark.q-mark.is-fixed .q-num::after { content: " ✓"; }
.q-doc mark.q-mark.is-removed .q-txt::before { content: "прибрано"; font-size: 11px; color: var(--ok); font-style: italic; }
.q-doc mark.q-mark.is-gone { display: none; }
.q-doc mark.q-mark.is-linked, .q-code mark.q-mark.is-linked { box-shadow: 0 0 0 2px var(--accent); }
.q-num { display: inline-block; min-width: 16px; padding: 0 4px; margin-right: 3px; border-radius: 8px; background: var(--warn); color: var(--surface);
  font-size: 10.5px; font-weight: 700; line-height: 15px; text-align: center; vertical-align: 2px; }
mark.q-mark[data-level="critical"] .q-num { background: var(--bad); } mark.q-mark[data-level="minor"] .q-num { background: var(--accent); }
.q-sample { cursor: default; }
@keyframes q-flash { 0%, 60% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.is-flash { animation: q-flash 1.4s ease-out; }
.q-pop { position: absolute; z-index: 30; max-width: 420px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); box-shadow: 0 8px 28px rgba(0, 0, 0, .18); display: grid; gap: 6px; font-size: 13px; pointer-events: none; }
.q-pop[hidden] { display: none; }
.q-pop .q-badge { display: none; }
.q-issues-card { margin-top: 14px; }
.q-issues-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
.q-issues-head h2 { margin: 0; }
.q-issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
.q-issue { display: grid; gap: 6px; align-content: start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); transition: box-shadow .15s, border-color .15s; }
.q-issue.level-critical { box-shadow: inset 3px 0 0 var(--bad); } .q-issue.level-major { box-shadow: inset 3px 0 0 var(--warn); } .q-issue.level-minor { box-shadow: inset 3px 0 0 var(--accent); }
.q-issue.is-linked { border-color: var(--accent); }
.q-issue.is-fixed { background: var(--ok-soft); }
.q-issue-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.q-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 12px; }
.q-why-text { margin: 0; }
.q-issue-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 2px; }
.q-issue-actions .button[aria-pressed="true"] { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.q-agree { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 600; }
.q-to-memory { margin-left: auto; }
.q-what { margin-top: 0; } .q-what ul { margin: 6px 0 0; padding-left: 18px; }
.q-answerbar { position: sticky; bottom: 0; z-index: 5; margin-top: 14px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: 0 -6px 20px rgba(0, 0, 0, .08); }
.q-answer-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.q-ask { white-space: nowrap; }
.q-answerbar .q-note { flex: 1 1 260px; min-width: 200px; }
.q-answered { margin: 6px 0 0; } .q-answered.is-warn strong { color: var(--warn); }
@media (max-width: 900px) { .q-top { flex-direction: column; } .q-issues { grid-template-columns: minmax(0, 1fr); } .q-toolbar { position: static; } }

/* Theme switch in the sidebar (Fahad 08.11: «add a light mode … they will be sitting here for a lot of time») */
.theme-switch { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); gap: 2px; }
.theme-switch button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 6px; cursor: pointer; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.sidebar-theme { padding: 8px 8px 0; }
@media (max-width: 900px) { .sidebar-theme { padding: 0; } }

.xray-first { margin-top: 6px; }
/* «Записати на сайт» (quality/_fix.html) */
.q-fix { margin-top: 14px; } .q-fix h2 { margin-bottom: 6px; }
.q-fix-changes { margin: 8px 0; padding-left: 22px; display: grid; gap: 6px; } .q-fix-changes li { line-height: 1.6; }
.q-fix-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 4px; } .q-fix-actions form { margin: 0; }
.q-fix-note { border-left: 3px solid var(--border); padding-left: 8px; }

/* Page X-ray: the block text panel on the right (08.11; Fahad moved it from the left) and the performance and place section */
.xray-open { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.xray-open:hover strong, .xray-open:focus-visible strong { text-decoration: underline; }
.xray-open.is-open strong { color: var(--text); }
.side-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: var(--side-panel-w, 560px); max-width: calc(100% - 32px);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: -4px 0 24px rgba(0, 0, 0, .12); display: flex; }
.side-panel[hidden] { display: none; }
.side-panel-body { flex: 1; min-width: 0; overflow: auto; padding: 16px 18px 24px; }
.side-panel-resizer { width: 8px; flex: 0 0 8px; cursor: col-resize; background: transparent; border-right: 1px solid var(--border); }
.side-panel-resizer:hover, .side-panel-resizer.is-dragging { background: var(--accent-soft); }
.side-panel-resizer:focus-visible { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.side-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.side-panel-head h2 { margin: 0; font-size: 17px; }
.side-panel-head .sub { display: block; }
.side-panel-facts { margin: 0 0 10px; }
.side-panel-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.xray-doc { border-top: 1px solid var(--border); padding-top: 12px; }
.xray-doc code, .side-panel-body code { font-family: var(--mono); font-size: 12px; }
body.is-resizing { cursor: col-resize; user-select: none; }
/* wide screens: the page makes room for the panel but keeps at least 640px for its tables */
@media (min-width: 1200px) { body.side-panel-open .main { margin-right: min(var(--side-panel-w, 560px), max(0px, calc(100vw - 860px))); } }
/* the chain page and the agent conversation in the same panel (08.11) */
.xray-chain-open { text-decoration: none; } .xray-chain-open.is-open { font-weight: 600; color: var(--text); }
.xray-new-chain { margin-left: 6px; }
.xray-chain .grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.xray-chain .card { box-shadow: none; }
.xray-chain-action:not(:empty) { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 8px; }
.xray-agent-form textarea { width: 100%; font: inherit; line-height: 1.5; }
.xray-agent-msgs { display: grid; gap: 10px; margin: 0 0 12px; }
.xray-agent-msg { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.xray-agent-msg.is-agent { border-color: var(--accent); }
.xray-agent-msg p { margin: 0 0 4px; }
.xray-agent-body { line-height: 1.55; overflow-wrap: anywhere; } .xray-agent-body table { font-size: 13px; }
.xray-place { margin: 0 0 6px; font-size: 15px; }
.xray-rank { font-size: 22px; font-variant-numeric: tabular-nums; margin-right: 4px; }
.xray-ladder { margin: 6px 0 8px; }
/* «По місяцях» as small line charts, one per field (Fahad 09.11): static/aigen/js/trends.js */
.xray-trends { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; margin: 12px 0 6px; }
.xray-trend { margin: 0; padding: 10px 12px 6px; }
.xray-trend.is-picked { border-color: var(--accent); }
.xray-trend-when { color: var(--muted); }
.xray-trend-plot { height: 92px; margin-top: 4px; outline-offset: 2px; border-radius: 6px; }
.trend-svg { display: block; overflow: visible; }
.trend-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 2 3; }
.trend-base { stroke: var(--border); stroke-width: 1; }
.trend-tick { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.trend-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-line.is-partial { stroke-dasharray: 3 4; }
.trend-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.trend-dot.is-partial { fill: var(--surface); stroke: var(--accent); }
.trend-guide { stroke: var(--muted); stroke-width: 1; }
.trend-mark { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.xray-months-box summary { cursor: pointer; margin: 6px 0; font-weight: 600; }

/* Translations: every number explained, every problem opens its page (Fahad 08.11) */
.tr-flow { max-width: 980px; }
.tile[data-tone="bad"] { border-color: var(--bad); } .tile[data-tone="warn"] { border-color: var(--warn); }
.tile-link { color: inherit; text-decoration: none; border-bottom: 1px dashed currentColor; }
.tile-link:hover { text-decoration: none; opacity: .85; }
#tr-issues td.why { min-width: 140px; max-width: 340px; }
#tr-issues td:first-child { min-width: 170px; }
#tr-issues td.why, #tr-issues td:first-child { overflow-wrap: anywhere; }  /* (llm_gateway_translation_queue), translation_source_changed */
#tr-issues .pill { white-space: normal; }
#tr-issues .tr-issue-link { text-decoration: none; }
#tr-issues tr[data-tone="ok"] td { opacity: .78; }
#tr-affected tr[data-tone="bad"] td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
#tr-affected tr[data-tone="warn"] td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tr-help .kv { gap: 6px 16px; } .tr-help .kv dd { max-width: 900px; line-height: 1.5; }
.tr-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.tr-links { white-space: nowrap; } .tr-links a + a { margin-left: 8px; }
.tr-url { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Usage: the period choice (Fahad 08.11: Today, Yesterday, 7/30/90 days and chosen days) */
.usage-period { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 4px; }
.usage-range { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.usage-range.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.usage-range label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.usage-range input[type="date"] { font: inherit; padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }

/* ===== The side panel's shared parts (08.11): Back, the chain a conversation is about, «Ask about this chain», the agent's
   proposals, and the template library (apps/agent/template_views.py). chat.css loads only on chat pages, so the panel's own
   look lives here. ===== */
.side-panel { --agent-line: var(--agent, var(--accent)); --agent-tint: var(--agent-soft, var(--accent-soft)); }
.side-panel-back { position: absolute; top: 12px; left: 22px; z-index: 1; }
.button[hidden], .side-panel-back[hidden] { display: none; }
.side-panel-back:not([hidden]) + .side-panel-body { padding-top: 50px; }
.side-panel .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.side-panel .stack { display: grid; gap: 8px; }
.side-panel label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.banner-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

/* the chain a conversation is about */
.chain-chip { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); }
.chain-chip-icon { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.chain-chip-main { min-width: 0; flex: 1; }
.chain-chip-name { font-weight: 650; overflow-wrap: anywhere; }
.chain-chip-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 5px; color: var(--muted); }
.chain-chip-facts strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* «Ask about this chain»: quick questions, then one question box */
.ask-quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.ask-chip { padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text);
  font: inherit; font-size: 12.5px; cursor: pointer; transition: border-color .12s, background .12s, color .12s; }
.ask-chip:hover { border-color: var(--accent); color: var(--accent); }
.ask-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ask-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.ask-chip.is-more { border-style: dashed; color: var(--muted); }
.ask-form { margin: 0; }
.ask-form > p { margin: 8px 0 0; }
.ask-box { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; transition: border-color .12s, box-shadow .12s; }
.ask-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-context { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.ask-box textarea { display: block; width: 100%; min-height: 128px; padding: 10px 12px; border: 0; border-radius: 0; outline: 2px solid transparent; resize: vertical;
  background: transparent; line-height: 1.5; }
.ask-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px 8px 12px; }

/* the Factory table's «Ask» next to the state */
.state-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; }
/* «Спитати» (Fahad 08.11: «very important for us … they will be used a lot»): always visible, the agent's colour, a filled
   chip that turns solid on hover and while its panel is open. */
.ask-chain { --ask: var(--agent, var(--accent)); display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px 3px 8px;
  border: 1px solid var(--ask); border-radius: 999px; background: var(--agent-soft, var(--accent-soft)); color: var(--ask); font: inherit;
  font-size: 12.5px; font-weight: 650; line-height: 1.35; white-space: nowrap; cursor: pointer; transition: background .12s, color .12s, box-shadow .12s; }
.ask-chain svg { flex: none; }
.ask-chain:hover { background: var(--ask); color: var(--surface); }
.ask-chain:focus-visible { outline: 2px solid var(--ask); outline-offset: 2px; }
.ask-chain.is-open { background: var(--ask); color: var(--surface); box-shadow: 0 0 0 3px var(--agent-soft, var(--accent-soft)); }

/* the agent's proposals in the panel: the action's own preview opens below, in #action-state */
.actcard.is-compact { margin-top: 8px; border: 1px solid var(--agent-line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.actcard.is-compact .actcard-head { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--agent-tint); color: var(--agent-line);
  font-size: 12px; font-weight: 700; }
.actcard.is-compact .actcard-body { display: grid; gap: 6px; padding: 8px 10px; }
.actcard.is-compact .actcard-title { font-weight: 650; overflow-wrap: anywhere; }
.actcard.is-compact .actcard-body p { margin: 0; }
.actcard.is-compact .button-group { flex-wrap: wrap; gap: 6px; }
.dots { display: inline-block; width: 1.4em; text-align: left; }
.dots::after { content: "•••"; letter-spacing: 1px; animation: dots-pulse 1.2s ease-in-out infinite; }
@keyframes dots-pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots::after { animation: none; opacity: .6; } }
.composer-tpl { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.composer-tpl:hover, .composer-tpl.is-open { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.composer-tpl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the template library: one colour per category, used as a dot, a card edge and a tag (never for text) */
.tpl-cat-chain_create { --cat: #2457d6; } .tpl-cat-chain_update { --cat: #7048e8; } .tpl-cat-launch { --cat: #0b7285; }
.tpl-cat-quality { --cat: #c2255c; } .tpl-cat-translation { --cat: #2b8a3e; } .tpl-cat-investigate { --cat: #d9480f; } .tpl-cat-other { --cat: #868e96; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tpl-cat-chain_create { --cat: #7aa2ff; } :root:not([data-theme="light"]) .tpl-cat-chain_update { --cat: #b197fc; }
  :root:not([data-theme="light"]) .tpl-cat-launch { --cat: #63c1d0; } :root:not([data-theme="light"]) .tpl-cat-quality { --cat: #f783ac; }
  :root:not([data-theme="light"]) .tpl-cat-translation { --cat: #69db7c; } :root:not([data-theme="light"]) .tpl-cat-investigate { --cat: #ffa94d; }
  :root:not([data-theme="light"]) .tpl-cat-other { --cat: #adb5bd; }
}
:root[data-theme="dark"] .tpl-cat-chain_create { --cat: #7aa2ff; } :root[data-theme="dark"] .tpl-cat-chain_update { --cat: #b197fc; }
:root[data-theme="dark"] .tpl-cat-launch { --cat: #63c1d0; } :root[data-theme="dark"] .tpl-cat-quality { --cat: #f783ac; }
:root[data-theme="dark"] .tpl-cat-translation { --cat: #69db7c; } :root[data-theme="dark"] .tpl-cat-investigate { --cat: #ffa94d; }
:root[data-theme="dark"] .tpl-cat-other { --cat: #adb5bd; }
.tpl-filter { display: grid; gap: 10px; margin: 4px 0 14px; }
.tpl-search input { width: 100%; padding: 8px 14px; border-radius: 999px; }
.tpl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-chip { position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-size: 12.5px; font-weight: 500; cursor: pointer; user-select: none; }
.tpl-chip input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-chip[class*="tpl-cat-"]::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--cat); }
.tpl-chip:hover { border-color: var(--muted); }
.tpl-chip:has(input:checked) { border-color: var(--text); background: var(--text); color: var(--surface); }
.tpl-chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tpl-chip .count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tpl-chip:has(input:checked) .count { color: inherit; opacity: .7; }
.tpl-chip-mine { border-style: dashed; }
.tpl-group { margin: 0 0 18px; }
.tpl-group-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0 0 8px; font-size: 13.5px; font-weight: 650; }
.tpl-dot { flex: none; align-self: center; width: 8px; height: 8px; border-radius: 50%; background: var(--cat); }
.tpl-cards { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.tpl-page .tpl-cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.tpl-card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px 10px 15px; overflow: hidden; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
  transition: border-color .12s, box-shadow .12s; }
.tpl-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cat, var(--border)); }
.tpl-card:hover { border-color: var(--cat, var(--accent)); box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.tpl-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tpl-card.is-open { border-color: var(--cat, var(--accent)); box-shadow: 0 0 0 1px var(--cat, var(--accent)); }
.tpl-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.tpl-card-title { font-weight: 650; line-height: 1.3; }
.tpl-card-summary { font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.tpl-card-meta { margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.tpl-fit { flex: none; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: 11px; font-weight: 600; white-space: nowrap; }
.tpl-fit.is-ready { background: var(--ok-soft); color: var(--ok); }
.tpl-badge { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
.tpl-author { font-weight: 600; color: var(--text); }
.tpl-empty { padding: 12px 0; }
.tpl-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 8px; color: var(--muted); }
.tpl-cat-tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 12px; font-weight: 600; }
.tpl-cat-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cat); }
.tpl-legend { margin: 6px 0; }
.tpl-preview { max-height: 52vh; overflow: auto; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.tpl-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.55; }
mark.tpl-filled { padding: 0 2px; border-radius: 3px; background: var(--accent-soft); color: inherit; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
mark.tpl-gap { padding: 0 3px; border-radius: 3px; border-bottom: 1px dashed var(--warn); background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.tpl-gap-note mark { margin-right: 4px; }
/* Unfilled gaps inside a question box (static/aigen/js/gap-marks.js): a see-through yellow layer in front of the textarea;
   its text is transparent, so the textarea's own text, caret and selection show through, and clicks pass to it. */
textarea + .gap-layer { position: absolute; margin: 0; box-sizing: border-box; overflow: hidden; pointer-events: none; border-style: solid; border-color: transparent;
  background: transparent; color: transparent; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; text-align: start; }
.gap-layer mark { color: transparent; background: var(--gap-mark); border-radius: 3px; box-shadow: 0 0 0 1px var(--gap-edge); }
.tpl-archive { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.tpl-form { display: grid; gap: 12px; }
.tpl-form-row { display: flex; flex-wrap: wrap; gap: 10px; }
.tpl-field { display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.tpl-field input, .tpl-field select, .tpl-field textarea { width: 100%; font-weight: 400; }
.tpl-field-wide { flex: 1 1 220px; }
.tpl-form-row .tpl-field:not(.tpl-field-wide) { flex: 0 1 190px; }
.tpl-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 4px; }
.tpl-insert { padding: 2px 7px; border: 1px dashed var(--border); border-radius: 6px; background: var(--surface); color: var(--accent); font: inherit;
  font-size: 11.5px; font-weight: 500; cursor: pointer; }
.tpl-insert:hover { background: var(--accent-soft); border-color: var(--accent); }
.tpl-insert.is-gap { color: var(--warn); }
.tpl-insert.is-gap:hover { background: var(--warn-soft); border-color: var(--warn); }
#tpl-body { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }

/* «Як це працює» (08.11; redesigned 08.11 evening, Fahad: «Release … above the whole pipeline in a separate description box»,
   «the whole pipeline needs a better design»). A person's box on top (warm), then the conveyor (blue): seven stations in one line,
   lanes dashed under the step they leave from, the watchdog as a band over all of them. The diagram follows its own width
   (container query), so the side panel and phones get the vertical form. */
.how-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--surface);
  font-size: 12px; font-weight: 700; flex: none; font-variant-numeric: tabular-nums; }
.how-h2 { font-size: 16px; margin: 4px 0 10px; }
.how-h2.is-first { margin-top: 0; }

.how-human { container-type: inline-size; background: var(--surface); border: 1px solid var(--warn); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: inset 4px 0 0 var(--warn); scroll-margin-top: 16px; }
.how-human:target { box-shadow: inset 4px 0 0 var(--warn), 0 0 0 2px var(--warn-soft); }
.how-human-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; }
.how-human-ico { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); flex: none; }
.how-human-title { flex: 1 1 320px; min-width: 0; }
.how-human-title h2 { margin: 0; font-size: 16px; }
.how-human-title p { margin: 4px 0 0; }
.how-human .how-live { margin: 0; }
.how-human-steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px 28px; }
@container (min-width: 700px) {
  .how-human-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .how-human-steps li:not(:first-child)::before { content: "→"; position: absolute; left: -28px; width: 28px; top: 0; bottom: 0; display: grid;
    place-items: center; color: var(--warn); font-size: 18px; }
}
.how-human-steps li { position: relative; display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 8px; background: var(--warn-soft); min-width: 0; }
.how-human-steps b { display: block; }
.how-human-text { display: block; font-size: 12.5px; color: var(--muted); }
.how-human-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--warn); color: var(--warn);
  font-size: 11px; font-weight: 700; flex: none; margin-top: 1px; }
.how-human-back { display: flex; gap: 6px; align-items: flex-start; color: var(--muted); margin: 10px 0 0; }
.how-human-back .icon { flex: none; margin-top: 2px; }
.how-human-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; margin-top: 6px; }
.how-human-foot .how-open { margin-top: 0; }
.how-handoff { display: flex; flex-direction: column; align-items: center; margin: 0; }
.how-handoff-line { width: 0; height: 14px; border-left: 2px solid var(--border); }
.how-handoff-text { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); font-size: 12.5px; color: var(--muted); text-align: center; }
.how-handoff-text .icon { color: var(--accent); flex: none; }
.how-handoff::after { content: ""; width: 0; height: 12px; border-left: 2px solid var(--accent); }

.how-diagram { container-type: inline-size; padding: 14px 16px; margin-bottom: 14px; border-color: var(--accent); }
.how-diagram-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; }
.how-diagram-head p { margin: 0 0 4px; }
.how-auto { display: inline-flex; align-items: center; gap: 4px; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); font-size: 12px; font-weight: 600; vertical-align: 2px; }
.how-dia { --gx: 26px; --gy: 30px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gy) var(--gx); margin-top: 14px; }
.how-st, .how-ln, .how-band { position: relative; display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; border-radius: var(--radius);
  color: var(--text); min-width: 0; }
.how-st { background: var(--surface-2); border: 1px solid var(--border); }
.how-ln { background: var(--accent-soft); border: 1.5px dashed var(--accent); }
.how-st:hover, .how-ln:hover, .how-band:hover { text-decoration: none; border-color: var(--accent); border-style: solid; }
.how-st:focus-visible, .how-ln:focus-visible, .how-band:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.how-st-top, .how-ln-tag { display: flex; align-items: center; gap: 6px; font-weight: 650; line-height: 1.25; }
.how-st-top .icon, .how-ln-tag .icon { color: var(--accent); flex: none; }
.how-ln-tag { color: var(--accent); }
.how-st-title { min-width: 0; }
.how-st-num { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.how-st-label { font-size: 12px; color: var(--muted); }
.how-ln-short { font-size: 12.5px; margin-top: 2px; }
.how-band { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 12px; border: 1.5px dashed var(--accent);
  background: var(--surface); font-size: 13px; }
.how-band-text { flex: 1 1 260px; min-width: 0; }
.how-band-num { color: var(--muted); font-size: 12.5px; }
.how-band-num strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
/* narrow: one column, a lane indented under its step; ↓ between stations, a dashed elbow into each lane */
.how-st:not(:first-child)::before { content: "↓"; position: absolute; left: 0; right: 0; top: calc(-1 * var(--gy)); height: var(--gy);
  display: grid; place-items: center; color: var(--accent); font-size: 18px; font-weight: 700; }
.how-ln { margin-left: 28px; }
.how-ln::before { content: ""; position: absolute; left: -18px; top: calc(-1 * var(--gy) - 2px); height: calc(var(--gy) + 50%); width: 16px;
  border-left: 2px dashed var(--accent); border-bottom: 2px dashed var(--accent); border-bottom-left-radius: 8px; }
/* medium: the stations down the left, each lane beside its step */
@container (min-width: 620px) {
  .how-dia { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .how-st { grid-column: 1; grid-row: var(--c); }
  .how-ln { grid-column: 2; grid-row: var(--c); margin-left: 0; align-self: center; }
  .how-ln::before { left: calc(-1 * var(--gx) - 2px); top: 50%; height: 0; width: var(--gx); border-left: 0; border-bottom: 0; border-radius: 0;
    border-top: 2px dashed var(--accent); }
}
/* wide: seven stations in one line, the lanes hang under their step */
@container (min-width: 1040px) {
  .how-dia { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .how-st { grid-column: var(--c); grid-row: 1; }
  .how-ln { grid-column: var(--c); grid-row: var(--r, 2); align-self: start; }
  .how-st:not(:first-child)::before { content: "→"; left: calc(-1 * var(--gx)); right: auto; top: 0; bottom: 0; width: var(--gx); height: auto; font-size: 18px; }
  .how-ln::before { left: 50%; top: calc(-1 * var(--gy) - 2px); width: 0; height: var(--gy); border-top: 0; border-left: 2px dashed var(--accent); }
}

.how-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.how-facts .tile-value { font-size: 20px; }
.how-flow { list-style: none; margin: 0 0 14px; padding: 0; }
.how-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; position: relative; padding-bottom: 28px; scroll-margin-top: 16px; }
.how-row:last-child { padding-bottom: 0; }
.how-row:not(:last-child)::after { content: ""; position: absolute; left: 25px; top: 12px; bottom: 6px; border-left: 2px solid var(--border); }
.how-row:not(:last-child)::before { content: ""; position: absolute; left: 21px; bottom: 0; border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 7px solid var(--muted); }
.how-step, .how-branch { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0;
  position: relative; z-index: 1; }
.how-row:target .how-step { border-color: var(--accent); }
.how-branch { border: 1.5px dashed var(--accent); background: var(--surface); scroll-margin-top: 16px; margin-left: 46px; }
.how-branch::before { content: ""; position: absolute; left: -21px; top: -12px; height: calc(50% + 12px); width: 19px; border-left: 2px dashed var(--accent);
  border-bottom: 2px dashed var(--accent); border-bottom-left-radius: 8px; }
.how-branch:target { box-shadow: 0 0 0 2px var(--accent-soft); border-style: solid; }
.is-band .how-branch { margin-left: 0; }
.is-band .how-branch::before { display: none; }
.how-step-head { display: flex; align-items: center; gap: 8px; }
.how-step-head h3 { margin: 0; font-size: 15px; font-weight: 650; min-width: 0; flex: 0 1 auto; }
.how-step-head .pill { flex: none; }
.how-ico { color: var(--accent); display: inline-flex; }
.how-term { font-weight: 400; color: var(--muted); font-size: 12px; font-family: var(--mono); }
.how-short { margin: 8px 0 6px; }
.how-live { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 6px 0; padding: 5px 10px; background: var(--surface-2);
  border-radius: 8px; width: fit-content; max-width: 100%; }
.how-live span { color: var(--muted); font-size: 12px; }
.how-live strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.how-when { font-size: 13px; display: flex; gap: 6px; align-items: flex-start; color: var(--muted); margin: 6px 0; }
.how-when .icon { margin-top: 2px; flex: none; }
.how-more summary { cursor: pointer; color: var(--accent); font-size: 13px; width: fit-content; }
.how-more[open] summary { margin-bottom: 6px; }
.how-more p { margin: 6px 0; }
.how-more ul { margin: 6px 0; padding-left: 18px; }
.how-open { display: inline-block; margin-top: 6px; font-size: 13px; }
.how-branch-tag { color: var(--accent); margin: 0 0 6px; letter-spacing: .02em; }
.how-causes { list-style: none; margin: 0; padding: 0; }
.how-causes li { display: grid; grid-template-columns: minmax(0, 2fr) auto minmax(0, 3fr); gap: 4px 10px; align-items: baseline; padding: 8px 0;
  border-bottom: 1px solid var(--border); }
.how-causes li:last-child { border-bottom: 0; }
.how-cause { font-weight: 600; }
.how-arrow { color: var(--accent); }
@media (max-width: 640px) {
  .how-causes li { grid-template-columns: auto minmax(0, 1fr); }
  .how-cause { grid-column: 1 / -1; }
}
.how-terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 22px; margin: 0; }
.how-terms > div { scroll-margin-top: 16px; border-radius: 6px; }
.how-terms > div:target { box-shadow: 0 0 0 2px var(--accent); }
.how-terms dt { font-weight: 600; }
.how-terms dd { margin: 3px 0 0; font-size: 13px; }

/* «Видалити ланцюжок» (Fahad 08.11): the chain page's last card and the two dialogs (dry run, then the typed name) */
.danger-zone { border-color: var(--bad); }
.danger-zone h2 { display: flex; align-items: center; gap: 6px; color: var(--bad); }
.confirm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.confirm-box { width: min(520px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 16px 18px; }
.confirm-box::backdrop { background: rgba(10, 14, 22, .5); }
.confirm-box h2 { margin: 0 0 4px; font-size: 18px; }
.confirm-box textarea, .confirm-box input[type=text] { width: 100%; box-sizing: border-box; }
.confirm-box-name { overflow-wrap: anywhere; }
.confirm-box-check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.confirm-box-check input { margin-top: 3px; flex: none; }
.confirm-box-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.button.danger.strong { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.button.danger.strong:disabled { opacity: .45; cursor: not-allowed; }
.danger-zone-item + .danger-zone-item, .danger-zone-item + p { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* «Рекомендації» (08.11): one card per thing to do, best value first */
.reco-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); margin-top: 12px; }
.reco-card { border: 1px solid var(--border, #d8dde3); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.reco-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.reco-num strong { font-size: 1.15em; }
.reco-title { font-size: 1rem; margin: 0; overflow-wrap: anywhere; }
.reco-card details a { overflow-wrap: anywhere; }
.reco-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: auto; padding-top: 6px; }
.reco-dismiss form { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; margin-top: 6px; }

/* «Новий ланцюжок» (D5, 08.11): prompt excerpts and the drafts list */
.prompt-excerpt { white-space: pre-wrap; word-break: break-word; max-height: 16rem; overflow: auto; font-size: .8rem; padding: 8px 10px;
  border: 1px solid var(--border, #d8dde3); border-radius: 8px; margin: 4px 0 8px; }
.draft-row { padding: 10px 0; min-width: 0; }
.draft-row + .draft-row { border-top: 1px solid var(--border, #d8dde3); }
.draft-row textarea { width: 100%; max-width: 100%; box-sizing: border-box; }

/* Requests and usage tables fit a 1280-pixel window (08.11): the state pill and long column names wrap. */
.requests-table .pill { white-space: normal; }
.usage-table th { white-space: normal; vertical-align: bottom; }

/* The bot's slots, top right of every page (08.11): how many of the agent's parallel runs are taken now */
/* Pinned to the top right while the page scrolls (Fahad 08.11: «always there, no matter how I scroll»). The row lets clicks
   through; only the strip itself takes them. Under the side panel and pop-ups (z 30–40), over sticky toolbars (4–5). */
.topbar { display: flex; justify-content: flex-end; margin: -8px 0 10px; min-height: 28px; position: sticky; top: 8px; z-index: 20;
  pointer-events: none; }
.topbar .bot-slots { pointer-events: auto; box-shadow: 0 2px 10px rgba(0, 0, 0, .14); }
.bot-slots { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); max-width: 100%; }
.bot-slots .icon { color: var(--accent); }
.bot-slots-label { color: var(--muted); }
.bot-slots-value { font-variant-numeric: tabular-nums; }
.bot-slots-cells { display: inline-flex; gap: 2px; }
.bot-slots-cells i { width: 7px; height: 14px; border-radius: 2px; background: color-mix(in srgb, var(--muted) 38%, var(--surface)); }
.bot-slots-cells i.on { background: var(--accent); }
.bot-slots-note { color: var(--muted); }
.bot-slots-link { font-size: 12px; }
.bot-slots.is-full { background: var(--warn-soft); border-color: transparent; }
.bot-slots.is-full .bot-slots-cells i.on { background: var(--warn); }
.bot-slots.is-full .bot-slots-note { color: var(--warn); font-weight: 600; }
@media (max-width: 720px) { .topbar { justify-content: flex-start; margin-top: 0; position: static; } .bot-slots-cells { display: none; } }
/* Under every agent composer, shown only while the strip says every slot is taken (refreshed with it every 15 s) */
.bot-full-note { display: none; margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--text); }
body:has(#bot-slots.is-full) .bot-full-note { display: block; }

/* «За розкладом»: the agent's scheduled checks (09.11) */
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.sched-form { max-width: 880px; }
.sched-field { display: flex; flex-direction: column; gap: 4px; }
.sched-field textarea, .sched-field input { width: 100%; }
.sched-when, .sched-where { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 0; }
.sched-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 4px; }
.sched-row label { display: flex; align-items: center; gap: 6px; }
.sched-row [hidden] { display: none; }
.sched-row input[name="channel"], .sched-row input[name="person"] { min-width: 14rem; flex: 1 1 14rem; }
.sched-actions form { display: inline; }

/* «Схема» (chains/<id>/schema/): the n8n graph at its own size, scrolled; «Вмістити в екран» fits it to the width */
.schema-card { position: relative; }
.schema-fit { position: absolute; opacity: 0; pointer-events: none; }
.schema-fit:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.schema-fit:checked + label { background: var(--surface-2); }
.schema-scroll { overflow: auto; max-height: 78vh; margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.schema-scroll svg { display: block; }
.schema-fit:checked ~ .schema-scroll svg { width: 100%; height: auto; }
.schema-text ul.plain { margin: 0; padding-left: 18px; }
.schema-text li { margin: 2px 0; }
/* «Новий ланцюжок» on a phone (09.11): a fieldset keeps its content's width unless told otherwise, and the template names are long */
fieldset.stack { min-width: 0; } fieldset.stack label { overflow-wrap: anywhere; }
#draft-choose select { max-width: 100%; }

.xray-ask { margin-left: 6px; }
.ask-xray-block { margin: 0 0 10px; overflow-wrap: anywhere; }
.ask-chip.is-pinned { border-style: solid; }
.tpl-pin-box { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* The chat dock (Fahad 09.11; static/aigen/js/chat-dock.js): up to three agent chats at the bottom right of every page. */
.chat-dock { position: fixed; right: 12px; bottom: 0; z-index: 35; display: flex; align-items: flex-end; gap: 12px; pointer-events: none; max-width: calc(100vw - 24px); }
.chat-dock > * { pointer-events: auto; }
.dock-chat { flex: none; width: min(372px, calc(100vw - 24px)); height: min(500px, 66vh); display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-bottom: 0; border-radius: 12px 12px 0 0; box-shadow: 0 -4px 24px rgba(0, 0, 0, .18); overflow: hidden; }
.dock-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2, var(--surface)); }
.dock-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dock-tools { display: inline-flex; gap: 2px; flex: none; }
.dock-btn { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font-size: 14px; line-height: 1; cursor: pointer; text-decoration: none; }
.dock-btn:hover, .dock-btn:focus-visible { background: var(--accent-soft); color: var(--text); }
.dock-pin { filter: grayscale(1); opacity: .55; }
.dock-pin[aria-pressed="true"] { filter: none; opacity: 1; background: var(--accent-soft); }
.dock-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.is-waiting .dock-dot { background: var(--accent); animation: dock-pulse 1.2s ease-in-out infinite; }
.is-new .dock-dot { background: var(--good, #2e9d5b); }
@keyframes dock-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .is-waiting .dock-dot { animation: none; } }
.dock-chat.is-new { border-color: var(--good, #2e9d5b); box-shadow: 0 -4px 24px rgba(46, 157, 91, .28); }
.dock-body { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 10px 12px; }
.dock-body .xray-agent-msgs { max-height: none; }
.dock-loading { padding: 16px; }
.dock-reply { display: flex; gap: 6px; align-items: flex-end; padding: 8px; border-top: 1px solid var(--border); }
.dock-reply textarea { flex: 1; min-width: 0; resize: none; max-height: 140px; }
.dock-tray { position: relative; align-self: flex-end; margin-bottom: 10px; }
.dock-tray-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 11px 20px; font-size: 15px; min-height: 46px;
  font-weight: 600; cursor: pointer; box-shadow: 0 2px 12px rgba(0, 0, 0, .18); white-space: nowrap; }
.dock-tray-button.is-new { border-color: var(--good, #2e9d5b); color: var(--good, #2e9d5b); }
.dock-list { position: absolute; right: 0; bottom: calc(100% + 8px); width: min(340px, calc(100vw - 24px)); max-height: 60vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); padding: 6px; }
.dock-list-head { margin: 4px 8px 6px; font-size: 12px; color: var(--muted); }
.dock-row { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.dock-row:hover { background: var(--accent-soft); }
.dock-row-open { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; text-align: left; border: 0;
  background: transparent; color: var(--text); padding: 7px 8px; cursor: pointer; }
.dock-row-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.dock-row-state { grid-column: 2; }
.dock-row.is-new .dock-row-state { color: var(--good, #2e9d5b); font-weight: 600; }
@media (max-width: 640px) { .chat-dock { right: 8px !important; left: 8px; } .dock-chat { flex: 1 1 auto; width: auto; height: min(520px, 70vh); }
  .dock-tray { position: absolute; left: 0; bottom: calc(100% + 6px); margin: 0; } .dock-list { left: 0; right: auto; } }
.dock-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 6px; padding: 0 5px; border-radius: 9px;
  background: var(--good, #2e9d5b); color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.xray-agent-msg .agent-note { margin: 6px 0 0; padding: 6px 8px; border-radius: 6px; background: var(--accent-soft); }

/* «Тексти ланцюжка» side panel (09.11, apps/factory/chain_texts.py) */
.ct-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.ct-ask input[type=number] { width: 5.5em; }
.ct-list { display: flex; flex-direction: column; gap: 12px; }
.ct-list.htmx-request { opacity: .55; }
.ct-text { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.ct-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ct-page { font-size: 14px; line-height: 1.35; }
.ct-head .pill { flex: none; }
.pill.ct-published { background: var(--ok-soft); color: var(--ok); }
.pill.ct-blocked { background: var(--warn-soft); color: var(--warn); }
.ct-body { max-height: 22em; overflow: auto; margin: 8px 0 4px; padding: 10px 12px; border-radius: var(--radius); background: var(--surface-2); font-size: 14px; line-height: 1.55; }
.ct-body > :first-child { margin-top: 0; } .ct-body > :last-child { margin-bottom: 0; }
.ct-langs { margin-top: 8px; }
.ct-langs > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--accent); }
.ct-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ct-tab-input { position: absolute; opacity: 0; pointer-events: none; }
.ct-tab { order: 0; padding: 3px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; cursor: pointer; }
.ct-tab.is-missing, .ct-tab.is-same_as_english, .ct-tab.is-synced { color: var(--muted); border-style: dashed; }
.ct-tab-input:checked + .ct-tab { background: var(--accent); border-color: var(--accent); color: #fff; border-style: solid; }
.ct-tab-input:focus-visible + .ct-tab { outline: 2px solid var(--accent); outline-offset: 2px; }
.ct-pane { order: 1; width: 100%; display: none; }
.ct-tab-input:checked + .ct-tab + .ct-pane { display: block; }
