/* ── design.css ── */

/*
 * design.css — Aether Messenger · Iconic Edition
 *
 * ═══════════════════════════════════════════════════════════
 * DESIGN VISION
 * "Warm Intelligence" — a messenger that feels like a thinking
 * companion, not a utility. Every surface breathes. Every
 * interaction has weight. The AI is woven into the fabric,
 * not bolted on top.
 *
 * SIGNATURE TRAIT: The Floating Composer
 * The input zone floats above the canvas on a layered glass
 * surface with a slow aurora border. When focused, it subtly
 * lifts with shadow. When AI is active, the aurora intensifies.
 * This is the product's heartbeat — unmistakable at a glance.
 * ═══════════════════════════════════════════════════════════
 */

/* ── Fonts ── */
/* fonts loaded via <link> in index.html — no duplicate @import needed */

/* ═══════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════ */
:root {
  /* ─────────────────────────────────────────────────────────────────────────
   * These app-facing names are now thin ALIASES onto the canonical design
   * tokens defined in css/design-system/tokens.css (loaded before this file).
   * The literal after each comma is a fallback: if tokens.css is ever missing,
   * the app renders exactly as before. Light-mode values live entirely in
   * tokens.css — theming is a token swap, not a per-component override.
   * ───────────────────────────────────────────────────────────────────────── */

  /* Surfaces — midnight with warm undertone */
  --void:    var(--hz-surface-canvas, #060610);
  --surface: var(--hz-surface,        #0B0B1C);
  --raised:  var(--hz-surface-raised, #101024);
  --hover:   var(--hz-surface-hover,  #161630);
  --active:  var(--hz-surface-active, #1C1C3A);

  /* Borders */
  --border:     var(--hz-border,        rgba(255,255,255,.055));
  --border-mid: var(--hz-border-strong, rgba(255,255,255,.100));

  /* Brand accent — slightly desaturated, luxurious */
  --accent:      var(--hz-brand);
  --accent-2:    var(--hz-brand-2);
  /* ink — the brand colour TUNED TO BE READ, per the --hz-brand-ink contract in
     tokens.css. --accent-2 is a highlight stop chosen to look good as a fill: as
     text it is 2.4:1 on the light canvas, well under AA. Any brand-coloured
     copy, icon or hairline that has to be READ takes --accent-ink; the plain
     hue stays for fills and glows. In dark the two are the same colour. */
  --accent-ink:  var(--hz-brand-ink,  var(--hz-brand));
  --accent-glow: var(--hz-brand-glow);
  --accent-soft: var(--hz-brand-soft);
  /* The keyboard focus outline of every focusable control (the
     :focus-visible block below) — a token, so a partner white-label can
     re-colour it with its brand (partners/whitelabel-shell.js). */
  --hz-focus-outline: color-mix(in srgb, var(--hz-brand) 60%, transparent);

  /* P2P */
  --p2p:        var(--hz-p2p,        #25D07E);
  --p2p-soft:   var(--hz-p2p-soft,   rgba(37,208,126,.10));
  --p2p-border: var(--hz-p2p-border, rgba(37,208,126,.22));

  /* Agent */
  --agent:        var(--hz-agent,        #E879A6);
  --agent-soft:   var(--hz-agent-soft,   rgba(232,121,166,.10));
  --agent-border: var(--hz-agent-border, rgba(232,121,166,.22));

  /* Group */
  --group:        var(--hz-group,        #F8B74A);
  --group-soft:   var(--hz-group-soft,   rgba(248,183,74,.10));
  --group-border: var(--hz-group-border, rgba(248,183,74,.22));

  /* Utility */
  --warn: var(--hz-warning, #F8B74A);
  --err:  var(--hz-danger,  #F47373);

  /* Text */
  --t1: var(--hz-text,        #EDEDF8);
  --t2: var(--hz-text-muted,  #6E6E90);
  --t3: var(--hz-text-subtle, #363658);
  /* meta — AA-compliant timestamp/count colour. --t3 (subtle) fails contrast as
     text (~2.2:1 light / ~1.7:1 dark); read-important meta must use --tmeta. */
  --tmeta: var(--hz-text-meta, #6E7581);

  /* Outgoing — desaturated indigo-violet, not pure purple */
  --out: var(--hz-bubble-out, linear-gradient(148deg, #5240E8 0%, #7665FF 55%, #6858F0 100%));

  /* Layout */
  --sb:  282px;
  --hh:  64px;  /* +2px vs v118: better tap-target margin, matches 48px content + 16px safe padding */
  --nh:  58px;
  --fh:  220px;
  --st:  env(safe-area-inset-top, 0px);
  --sb2: env(safe-area-inset-bottom, 0px);
  /* Total space occupied at the bottom of the viewport that a full-screen panel
     must clear: the tab bar (--nh, which :root redefines per breakpoint), the
     hardware safe-area inset, and the cookie-consent banner while it is
     unanswered (--hz-consent-h, published by public/js/cookie-consent.js).
     ONE definition: every panel that used to hand-write
     calc(var(--nh) + var(--sb2)) reads this instead, so raising the tab bar to
     clear the banner can never leave a panel behind under it.
     The safe-area term is `* .4` because the floating bar only rises by 40% of
     the inset (the phone .mnav rule: it sits inside the home-indicator zone, like
     a native tab bar), and the clearance must track the bar, not the hardware.
     Deliberately NOT folded into --sb2 itself: focus-addon.js overrides --sb2
     inline to 0px while the soft keyboard is up, and that must keep meaning
     "no safe-area inset", not "no consent banner either". */
  --hz-nav-clear: calc(var(--nh) + var(--sb2) * .4 + var(--hz-consent-h, 0px));

  /* Motion */
  --ease:        var(--hz-ease,        cubic-bezier(.4,0,.2,1));
  --ease-spring: var(--hz-ease-spring, cubic-bezier(.34,1.4,.64,1));
  --ease-out:    var(--hz-ease-out,    cubic-bezier(0,0,.2,1));

  /* Nav — frosted surface of the ≥641px top nav (.tnav). Light variant lives
     in tokens.css [data-theme="light"]. The phone tab bar is a floating lens,
     not a bar, and reads its own --hz-tabbar-* register instead. */
  --mnav-bg:      var(--hz-nav-bg,     rgba(10, 10, 22, 0.82));
  --mnav-border:  var(--hz-nav-border, rgba(255,255,255,.11));

  /* ── App button register ──────────────────────────────────────────────────
     The app skins the shared .hz-btn atom (design-system/atoms.css) as its own
     product-DENSITY register — exactly like marketing.css re-points the same
     component tokens for its expressive register. Every value here reproduces
     the app's historical bespoke .btn look (measured, dark), so migrating
     .btn → .hz-btn is value-preserving. Light overrides live in the app's
     [data-theme="light"] block; the coarse-pointer tap-min bump stays gated in
     the @media (pointer: coarse) block. The primary's FILL is not re-pointed:
     it is the token layer's --hz-brand-gradient (the action blue,
     --hz-action-gradient), the same in both themes and the same blue as the
     sidebar New chat — one primary look across the app, white label ≥ 4.6:1. */
  --hz-btn-primary-shadow:   0 2px 10px rgba(15, 92, 217, .30);
  --hz-btn-border-width:     0;     /* app primary was border:none; secondary/danger keep their own 1px */
  --hz-btn-min-h:            38px;
  --hz-btn-min-w:            80px;
  --hz-btn-gap:              6px;
  --hz-btn-pad-x:            18px;
  --hz-btn-font-size:        14px;
  --hz-btn-tracking:         normal;
  --hz-btn-hover-transform:  translateY(-1px);
  --hz-btn-active-transform: scale(.97);
  --hz-btn-disabled-opacity: .4;
  --hz-btn-secondary-fg:     var(--t2);
  --hz-btn-secondary-border: var(--border-mid);

  /* ── App input register ───────────────────────────────────────────────────
     Skins the shared .hz-input atom as the app's product-density form field
     (the modal .fld inputs). Reproduces the app's historical field look
     (measured): 14px text, 10·12 padding, 1px border, natural desktop height —
     bg/border-color/placeholder/focus already match the product defaults in
     dark, so only these density values are re-pointed. Focus is the token
     layer's blue in both themes; the coarse-pointer block bumps
     the font to 16px (no iOS zoom-on-focus) and restores the 44px tap floor. */
  --hz-input-min-h:      auto;       /* desktop density; coarse restores the 44px floor */
  --hz-input-pad:        10px 12px;
  --hz-input-font-size:  14px;
  --hz-input-border-width: 1px;
}

/* ── --hz-nav-clear is zero while the soft keyboard is up ─────────────────
   (the token itself is defined with the rest of the layout metrics above)

   `kb-open` is set on <html> by focus-addon.js in exactly one situation: the
   keyboard is open AND the layout viewport did NOT shrink for it — iOS Safari
   and iOS PWA always, plus any Android browser that ignores this app's
   `interactive-widget=resizes-content` (Samsung Internet, most in-app
   webviews). There, the addon pins `.cm` to the visual viewport while `#mnav`
   stays fixed to the layout viewport — so the tab bar is BEHIND the keyboard,
   and every panel reserving --hz-nav-clear for it leaves a dead strip of that
   height above the keyboard with nothing in it. That strip is the reported
   defect on the Agents page.

   Where the layout viewport DOES shrink (Android honouring resizes-content)
   the bar rides up and stays visible above the keyboard, `kb-open` is not set,
   and the clearance correctly stands. One token, both modes, no per-platform
   branch anywhere else in the stylesheet.

   "The bar is behind the keyboard" is MADE true rather than assumed: the iOS
   26 PWA shrinks the layout viewport with the keyboard (innerHeight ==
   vv.height, focus-addon.js) while still reading as displaced, so `kb-open`
   is set yet the fixed bar lands right above the keyboard — over the chat
   list's docked composer, whose clearance had just collapsed (the input and
   send button sat under the capsule). With the keyboard up the bar steps out,
   as a native tab bar does: hidden from sight, taps and assistive tech alike
   (visibility, so the JS-owned inline `display` stays untouched). */
html.kb-open { --hz-nav-clear: 0px; }
html.kb-open .mnav { visibility: hidden; }

/* Root boundary hand-off (nav-controller.js HzRoot.leave): a signed-out visitor
   arriving home is on the way to '/', the pre-login page. The shell steps aside
   while the browser loads it, so the screen underneath — the app's own home —
   never flashes in between. The body keeps its background; a return from the
   back/forward cache clears the attribute (pageshow). */
html[data-hz-leaving] body > * { visibility: hidden !important; }

/* ═══════════════════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════════════════ */

/* The `hidden` attribute must actually hide.
 *
 * The UA sheet says `[hidden] { display: none }`, but ANY author rule that sets
 * `display` on the element beats it — so every component that declares
 * `display: flex/grid/inline-flex` silently opts out of the one attribute 82
 * call sites in public/js use to hide a control. The app has been patching that
 * one component at a time for years (`.ci-pin[hidden]`, `.cmh-toprow[hidden]`,
 * `.crs-rail[hidden]`, six more) and, inevitably, missed some: the AI Course's
 * handouts button is hidden on the preview by `lib.hidden = …` and rendered
 * anyway, offering a control the server can only answer 403 to.
 *
 * One rule, once — the operator panel reached the same conclusion on its own
 * (operator-panel.css, "Declared once, here, so no page has to remember it")
 * and this is that rule lifted into the app shell, where the same trap is 82
 * call sites wide instead of two.
 *
 * `!important` is load-bearing and cannot be traded for source order:
 * course.css, home.css, notes.css and store-trending.css all load AFTER this
 * file, so a component rule in any of them would out-order an unweighted reset.
 *
 * Safe by inspection: nothing in the app sets a non-`none` display on
 * `[hidden]`; the two rules that mention the attribute at all use
 * `:not([hidden])`. The per-component companions inside the app shell
 * (.ci-pin, .cmh-*, .crs-rail, .aifs-hact, .nb-ap-panel) are redundant from
 * here on, and are left in place rather than swept in a change about panel
 * heads. The ones in marketing.css and cookie-consent.css are NOT redundant —
 * those sheets serve pages that never load this file. */
[hidden] { display: none !important; }

body {
  font-family: 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', 'IBM Plex Sans Devanagari', 'Noto Sans Armenian', system-ui, sans-serif;
  font-feature-settings: 'kern' 1, 'liga' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  letter-spacing: -.012em;
  font-size: 14px;
  /* Shell backdrop = the app SURFACE, not the --void canvas.
     The shell height is pinned to --app-vh (the real visible viewport, set by the
     blocking script in index.html <head>) at ≥641px, so on iPad it fills the
     viewport in both orientations and shrinks above the soft keyboard while a field
     is focused — see the .app rule below. This body colour is
     the belt-and-suspenders fallback: if --app-vh is ever absent and the root
     height resolves through -webkit-fill-available / 100dvh (values iOS/iPadOS
     cache short until the next relayout), the strip below the shell shows the body
     background PROPAGATED to the viewport canvas. With the darker --void there it
     reads as a grey line beneath the white (--surface) sidebar + composer; painting
     the backdrop --surface makes any residual shortfall blend in. Mirrored for
     light in the [data-theme="light"] body rule. */
  background: var(--surface);
  color: var(--t1);
}
code, kbd, .hpid, .myid-txt, .ppid {
  font-family: 'JetBrains Mono', monospace;
}

/* Scrollbars */
::-webkit-scrollbar             { width: 3px; height: 3px; }
::-webkit-scrollbar-track       { background: transparent; }
::-webkit-scrollbar-thumb       { background: rgba(255,255,255,.06); border-radius: var(--hz-radius-2); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.12); }
*                               { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.06) transparent; }

/* Anonymous visitors: sidebar hidden, home fills full width */
body.anon-mode .sb { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR — structured, premium depth
═══════════════════════════════════════════════════════════ */
.sb {
  width: var(--sb); min-width: var(--sb);
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
  /* Atmospheric header glow */
  background-image: radial-gradient(ellipse 100% 22% at 50% 0%,
    color-mix(in srgb, var(--hz-brand) 6%, transparent) 0%, transparent 100%);
}

/* ── Panel head ────────────────────────────────────────────────────────────
   The title row and the search field, pinned together above a scrolling list.

   The chat list defines this pattern; every other list surface reuses THIS
   definition rather than restating it, so the two cannot drift apart again.
   Consumers apply .hz-panel-head alongside their own name: .sb-head (chat
   list), .cs-hdr (agents store), #ntlPane's head (AI Notes). Their own class
   stays for the surface and the breakpoint rules that are genuinely theirs.

   The search field lives inside the head, not at the top of the scrolling
   body — that is what keeps it reachable no matter how far the list is
   scrolled, and it is also what puts it on the head's surface rather than on
   the list canvas, so one .srch definition renders identically on both.
   (The one exception is deliberate: on a phone the chat list's head is the top
   of its content and scrolls away with the chats — "The chat list scrolls as
   one screen" below. Its field is in the bar only while search is open, and
   then it stays put.) */
.hz-panel-head {
  padding: var(--hz-panel-head-pad);
  flex-shrink: 0;
  display: flex; flex-direction: column; gap: var(--hz-panel-head-gap);
}

/* The title row: one cluster left, one right. --hz-panel-head-row-h is the
   chat list's brand-mark height, so a surface whose row is shorter (the
   store's back button + title) still lands its search field on the same
   baseline instead of jumping when you move between them. */
.hz-panel-head-row {
  display: flex; align-items: center;
  justify-content: space-between; padding: var(--hz-panel-head-row-pad);
  min-height: var(--hz-panel-head-row-h);
}

/* A full-bleed child of the head: it cancels the head's side inset and runs
   edge to edge, so a horizontal scroller (the chat list's stories row,
   stories.css) scrolls out under the panel's edges instead of being clipped
   10px short of them. The child brings its own inline padding. The phone
   twin (-pad-x-dense) is set beside the dense head below. */
.hz-panel-head-bleed { margin-inline: calc(-1 * var(--hz-panel-head-pad-x)); }

/* ── The title cluster ──────────────────────────────────────────────────────
   The row's two halves. `.hz-panel-head-lead` is what the surface leads with —
   an optional back control, then the title (with an optional eyebrow above it);
   `.hz-panel-head-actions` is the trailing group. The chat list's `.brand` and
   `.hbtns` are the same two roles under their own names, kept because the brand
   mark is not a title.

   Three screens each drew this row for themselves — `.cs-hdr-l` + `.cs-title`
   on the agents store, `.sp-back` + `.sp-title` on Profile, `.crs-back` +
   `.crs-crumb` on the AI Course — with three back buttons (34 / 34 / 40px, two
   different colours) and two title sizes. They are one object now, and every
   measurement is single-sourced from --hz-panel-head-*. */
.hz-panel-head-lead {
  display: flex; align-items: center; min-width: 0;
  gap: var(--hz-panel-head-lead-gap);
}
.hz-panel-head-titles {
  display: flex; flex-direction: column; justify-content: center; min-width: 0;
}
/* A heading element, so the panel has a real name in the document outline and
   a screen reader can say which screen it landed on. The margin reset is the
   component's own — a page-level reset is not something a component may
   assume. */
.hz-panel-head-title {
  margin: 0; min-width: 0;
  font-size: var(--hz-panel-head-title-size);
  font-weight: var(--hz-panel-head-title-weight);
  letter-spacing: var(--hz-panel-head-title-tracking);
  color: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hz-panel-head-eyebrow {
  font-size: var(--hz-panel-head-eyebrow-size);
  font-weight: var(--hz-weight-bold);
  letter-spacing: var(--hz-panel-head-eyebrow-tracking);
  text-transform: uppercase;
  color: var(--t2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* THE back control — and the only one a panel head may carry.
   It means one step UP this panel's own stack, never "close this screen":
   a screen that owns a tab has no parent to go up to, and the platform's own
   back (swipe / hardware key / browser button) already closes it through
   nav-controller.js. See the /design-system page, "Panel head". */
/* `.hz-panel-head-action` is its trailing sibling: a single-glyph action on
   the screen as a whole (a profile's Share), drawn exactly like the back
   control so the head reads as one row of one family. */
.hz-panel-head-back,
.hz-panel-head-action {
  appearance: none; -webkit-appearance: none;
  flex-shrink: 0;
  width: var(--hz-panel-head-back-size); height: var(--hz-panel-head-back-size);
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%; background: transparent;
  color: var(--accent); cursor: pointer;
  transition: background .13s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
/* Hover only behind a real pointer (as the .hz-btn atoms): iOS keeps :hover
   on the last tapped element, which left the circle painted after a tap. */
@media (hover: hover) and (pointer: fine) {
  .hz-panel-head-back:hover, .hz-panel-head-action:hover { background: var(--accent-soft); }
}
.hz-panel-head-back:active, .hz-panel-head-action:active { transform: scale(.9); }
.hz-panel-head-back[hidden],
.hz-panel-head-action[hidden] { display: none; }
.hz-panel-head-back svg {
  width: var(--hz-panel-head-back-glyph); height: var(--hz-panel-head-back-glyph);
  fill: none; stroke: currentColor;
  stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}
/* A share glyph is drawn lighter than the chevron: 2.5 would clot its box. */
.hz-panel-head-action svg {
  width: var(--hz-panel-head-back-glyph); height: var(--hz-panel-head-back-glyph);
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.hz-panel-head-actions {
  display: flex; align-items: center; flex-shrink: 0;
  gap: var(--hz-panel-head-actions-gap);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; padding: 5px 8px; margin: -5px -8px;
  border-radius: var(--hz-radius-12); cursor: pointer; color: inherit; font: inherit;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* A partner-only white-label mark takes the 44px sidebar mark's place
     (atoms.css .hz-cobrand). */
  --hz-cobrand-solo-h: 44px;
}
.brand:hover  { background: var(--hover); }
.brand:active { transform: scale(.97); }
/* ── Brand icon ────────────────────────────────────────────────────────── */
.bmark    {
  width: 44px; height: 44px;
  border-radius: var(--hz-radius-14);
  overflow: hidden;
  flex-shrink: 0; position: relative;
}
.bmark img { width: 44px; height: 44px; display: block; object-fit: cover; border-radius: var(--hz-radius-14); }
.bmark svg { flex-shrink: 0; }
/* ── Brand title — wrapper + colour hook for the shared .hz-wordmark atom ── */
.bname { display: inline-block; height: 17px; color: var(--t1); }
.p2p-badge { display: none; }
.hbtns { display: flex; gap: 8px; align-items: center; }
/* Compose button in header gets a visible pill background */
.hbtns .ib { width: 34px; height: 34px; background: rgba(255,255,255,.07); border-radius: var(--hz-radius-pill); }
.ib {
  width: 30px; height: 30px; border: none; background: transparent;
  color: var(--t2); border-radius: var(--hz-radius-6); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .13s, color .13s, transform .1s;
  flex-shrink: 0; touch-action: manipulation;
}
.ib:hover  { background: var(--hover); color: var(--t1); }
.ib:active { transform: scale(.88); }
.ib svg    { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* My ID bar */
.myid-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--hz-brand) 7%, transparent), rgba(37,208,126,.04));
  border: 1px solid color-mix(in srgb, var(--hz-brand) 14%, transparent);
  border-radius: var(--hz-radius-10); margin-bottom: 9px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.myid-bar:hover { border-color: var(--p2p-border); background: linear-gradient(135deg, color-mix(in srgb, var(--hz-brand) 6%, transparent), rgba(37,208,126,.06)); }
.myid-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--t3); flex-shrink: 0; transition: background .3s; }
.myid-dot.on { background: var(--p2p); box-shadow: 0 0 8px rgba(37,208,126,.55); animation: pulse 2.2s infinite; }
.myid-txt { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.myid-txt b { color: var(--t1); font-weight: 500; }
.myid-copy { width: 22px; height: 22px; border: none; background: transparent; color: var(--t3); cursor: pointer; border-radius: var(--hz-radius-4); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .13s; }
.myid-copy:hover { background: var(--hover); color: var(--t1); }
.myid-copy svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* Search */
/* The chat list's search row (index.html .sb-search-row): ≥641px it dissolves
   and the field lays out as before; the phone rules below make it the bar. */
.sb-search-row { display: contents; }
.sb-search-back { display: none; }
.srch {
  display: flex; align-items: center; gap: 0;
  background: var(--raised); border: 1px solid var(--border);
  border-radius: var(--hz-radius-pill); padding: 0 16px; height: 44px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.srch:focus-within {
  border-color: color-mix(in srgb, var(--hz-brand) 45%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hz-brand) 8%, transparent);
  background: var(--surface);
}
.srch input {
  flex: 1; background: transparent; border: none;
  padding-block: 0; padding-inline: 10px 0; font-family: inherit; font-size: 14px;
  color: var(--t1); outline: none;
  /* Remove default browser appearance */
  -webkit-appearance: none; appearance: none;
  /* What is typed lays out by its own first letter: "@anna" stays "@anna" in an
     Arabic UI (a leading "@" is direction-neutral, so the page's RTL would show
     "anna@"), an Arabic query stays right-to-left in an English one. Empty, the
     field and its placeholder keep the page's direction. */
  unicode-bidi: plaintext;
}
/* --hz-text-meta, not --t3/--hz-text-subtle: the placeholder is this field's
   only label — it is what tells you the chat list searches agents too — and
   the design system reserves -subtle for decoration (see its own note: ~2.2:1,
   "must not carry read-important text"). On --raised it measured 1.63:1 in
   dark. -meta is the register's AA-compliant ink and flips itself, so one
   declaration serves both themes and both surfaces. */
.srch input::placeholder { color: var(--hz-text-meta); }
/* Hide browser clear/cancel buttons */
.srch input::-webkit-search-cancel-button { display: none; }
.srch input::-webkit-search-decoration { display: none; }
/* The magnifier is the field's affordance, not decoration — WCAG 1.4.11 puts
   the floor for non-text UI at 3:1, and var(--t3) gave it 1.63:1 in dark. */
.srch-i {
  width: 16px; height: 16px; stroke: var(--hz-text-meta); fill: none;
  stroke-width: 2; stroke-linecap: round; flex-shrink: 0;
  transition: stroke .2s;
}
.srch:focus-within .srch-i { stroke: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   LIST ROW (.ci) — the chat list, the notes list
   One component, every measurement and ink from the --hz-row-* register
   (tokens.css), which also switches it between the compact (mouse) and the
   touch density. Nothing below restates a size per breakpoint or a colour
   per theme: that is exactly how this row drifted into six competing blocks.

   Anatomy — avatar · [ title ········· ticks · time ]
                       [ ⓘ preview ········· badge | pin ]
   The trailing slot holds ONE thing: the unread count, else the pin.
   States live on the row: .on (selected — split view only), .has-unread,
   .is-error (the last reply failed), .pinned.
═══════════════════════════════════════════════════════════ */
/* #sbScroll wraps the head and the list (index.html). Beside a conversation
   (≥641px) it is not a box at all: the head stays put and #clist scrolls under
   it, exactly as before. On a phone it becomes the scroller — see "The chat
   list scrolls as one screen" in the MOBILE block. */
.sb-scroll { display: contents; }
.clist { flex: 1; overflow-y: auto; padding: 4px 8px 8px; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
.clist::-webkit-scrollbar { width: 0; }

.ci {
  display: flex; align-items: center; gap: var(--hz-row-gap);
  min-height: var(--hz-row-h);
  padding: 0 var(--hz-row-pad-x);
  border-radius: var(--hz-row-radius);
  margin-bottom: 2px;
  position: relative; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .14s var(--ease);
}
@media (hover: hover) {
  .ci:hover { background: var(--hz-row-bg-hover); }
}
.ci:active { background: var(--hz-row-bg-pressed); }
.ci:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--hz-focus-ring); }
/* Selected = the conversation open beside the list. A phone shows the list OR
   the conversation, never both, so there a "selected" row is only a leftover
   from the last chat you opened — it is not drawn there. */
@media (min-width: 641px) {
  .ci.on,
  .ci.on:hover { background: var(--hz-row-bg-selected); }
}

/* Avatars — one shape for every identity at every size: --hz-radius-avatar
   (tokens.css). Surfaces size an avatar; none of them re-round it. */
.av {
  width: 40px; height: 40px; border-radius: var(--hz-radius-avatar);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex-shrink: 0; position: relative;
}
/* ── Profile-photo avatars ──────────────────────────────────────────────────
   When AvatarStore mounts an <img.av-img> inside any avatar container (.av,
   .mav, the settings hero), it fills the box and clips to the parent's
   border-radius (circle for peers, rounded-square for groups/agents). One rule
   covers every surface so a photo renders identically on phone, tablet and
   desktop. object-fit:cover guarantees no stretch regardless of source aspect. */
.av-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}
/* The image sits on top and fully covers the box (object-fit:cover). We keep the
   gradient background and only hide the text — so if the image ever fails to
   load (dead CDN URL, offline), the gradient shows through instead of a broken
   glyph. For opaque avatars the gradient is fully occluded, so there's no
   visual change in the normal case. */
.av.has-img, .mav.has-img { color: transparent; }
/* A PERSON with no photo: the Harizma mark on a surface disc (AvatarStore
   `person`, avatar.js) — one default for every human, on every tile class
   (.av, .mav, .sp-av, .hz-me-av, .upf-av, the Feed's author chips).
   The tile keeps its own size, radius and ring; this paints only its face.
   Two classes deep so it outranks a tile's own fallback paint (.sp-av's
   gradient) wherever the tile's rule sits in the cascade. A photo is an
   <img.av-img> laid over it; `has-img` drops the mark so a transparent photo
   never shows dots through it, and a failed photo removes `has-img` again. */
[class].av-person {
  background: var(--hz-avatar-person-bg) var(--hz-avatar-person-mark) center / 78% no-repeat;
  color: transparent;
}
[class].av-person.has-img { background-image: none; }
.av::after { content: ''; position: absolute; bottom: 1px; inset-inline-end: 1px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--surface); display: none; }
.av.s-on::after   { display: block; background: var(--p2p); box-shadow: 0 0 0 1px rgba(37,208,126,.2); animation: pulse 2.2s infinite; }
.av.s-off::after  { display: block; background: var(--t3); }
.av.s-away::after { display: block; background: var(--warn); }
.av.s-ai::after   { display: none !important; }
.av-badg { position: absolute; bottom: -2px; inset-inline-end: -2px; width: 14px; height: 14px; border-radius: var(--hz-radius-4); border: 2px solid var(--surface); display: flex; align-items: center; justify-content: center; }
.av-badg svg { width: 7px; height: 7px; }

/* The row's avatar: the one avatar circle for every kind of chat — a person,
   an agent, a conversation, a group — so photos, logos and initials line up
   as one column. .sq is the one exception, and it is not an avatar: a note's
   icon in the notes list, a "what" rather than a "who", keeps a step radius. */
.ci .av {
  width: var(--hz-row-av); height: var(--hz-row-av);
  border-radius: var(--hz-radius-avatar);
  font-size: var(--hz-row-av-glyph); line-height: 1;
  /* Outline, not border: it paints above a photo and never changes the size. */
  outline: 1px solid var(--hz-row-av-ring); outline-offset: -1px;
}
.ci .av.sq { border-radius: var(--hz-radius-14); }
.ci .av::after {
  inset-inline-end: 0; bottom: 0;
  width: calc(var(--hz-row-av) * .27); height: calc(var(--hz-row-av) * .27);
  box-sizing: border-box;
  border: 2.5px solid var(--hz-row-status-ring);
}

/* Text column — two lines, each a flex row so the trailing marks never wrap. */
.cimeta { flex: 1; min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: var(--hz-row-line-gap); }
.r1, .r2 { display: flex; align-items: center; gap: 6px; min-width: 0; }

.cname { font-size: var(--hz-row-title-size); font-weight: var(--hz-role-title-weight); letter-spacing: var(--hz-role-title-tracking); line-height: var(--hz-row-leading); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--hz-row-title-ink); }
.ctime { font-size: var(--hz-row-meta-size); font-weight: var(--hz-role-meta-weight); line-height: var(--hz-row-leading); color: var(--tmeta); font-variant-numeric: tabular-nums; flex-shrink: 0; white-space: nowrap; }
.ci.has-unread .ctime { color: var(--hz-row-unread-ink); }
.cprev { font-size: var(--hz-row-preview-size); line-height: var(--hz-row-leading); color: var(--hz-row-preview-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
/* Not a message — "3 members", an agent's tagline in a chat with no messages yet. */
.cprev.is-placeholder { font-style: italic; }

/* Live activity replaces the preview while it lasts ("typing…", "Thinking…"). */
.cl-typing { color: var(--hz-row-live-ink); font-weight: 500; font-style: normal; }

/* A reply that failed (an agent error — the ⚠️ body of the wire contract):
   an alert glyph and the preview in the danger ink, instead of a bare emoji.
   Live activity wins: while a retry is thinking, the alert steps aside. */
.ci-alert { display: none; flex-shrink: 0; width: 16px; height: 16px; color: var(--hz-row-danger-ink); }
.ci-alert svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ci.is-error .ci-alert { display: inline-flex; }
.ci.is-error .cprev { color: var(--hz-row-danger-ink); font-weight: 500; }
.ci.is-error .r2:has(.cl-typing) .ci-alert { display: none; }

/* Pin — a quiet glyph in the trailing slot (renderContact hides it while the
   chat has unread messages; the count is what matters then). The [hidden]
   rule is required: display:inline-flex beats the attribute's UA default. */
.ci-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--hz-row-pin-size);
  height: var(--hz-row-pin-size);
  color: var(--hz-row-pin-ink);
  flex-shrink: 0;
}
.ci-pin svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ci-pin[hidden] { display: none; }

/* Unread count — one colour for every kind of chat; scales from 1 digit to 99+. */
.unr {
  min-width: var(--hz-row-badge-size); height: var(--hz-row-badge-size);
  box-sizing: border-box; padding: 0 7px;
  border-radius: var(--hz-radius-pill);
  background: var(--hz-row-badge-bg); color: var(--hz-row-badge-ink);
  font-size: var(--hz-text-xs); font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* Delivery ticks — a person's chat, when the last message is yours. */
.sb-tick { display: none; align-items: center; position: relative; width: 18px; height: 12px; flex-shrink: 0; }
.sb-tick svg { position: absolute; width: 11px; height: 11px; fill: none; stroke: var(--hz-row-meta-ink); stroke-width: 2.5; stroke-linecap: round; }
.sb-tick svg:last-child { left: 5px; } /* physical: the ✓✓ glyph pair never mirrors */
.sb-tick.read svg { stroke: var(--hz-row-read-ink); }
.sb-tick.failed svg { stroke: var(--hz-row-danger-ink); }

/* ── Flush list — the phone's edge-to-edge variant ─────────────────────────
   On a phone the list IS the screen: rows run edge to edge and are separated
   by a hairline that starts where the text starts (the avatar column stays
   clean), instead of floating as rounded tiles in a gutter. Opt in per list
   with .hz-list-flush; wider screens keep the inset rounded rows. The hairline
   is an inset shadow, so it never changes a row's height. */
@media (max-width: 640px) {
  .clist { padding: 4px 8px 16px; }
  .hz-list-flush { padding-inline-start: 0; padding-inline-end: 0; }
  .hz-list-flush > .ci {
    border-radius: 0; margin-bottom: 0;
    padding-block: 0; padding-inline: var(--hz-row-pad-x-flush) 0;
  }
  .hz-list-flush > .ci > .cimeta {
    padding-inline-end: var(--hz-row-pad-x-flush);
    box-shadow: inset 0 -1px 0 var(--hz-row-divider);
  }
}

.divln { height: 1px; background: var(--border); margin: 5px 6px; }

/* ── Chat list empty state ─────────────────────────────────────────────────
   The design system's .hz-empty (atoms.css), built by contacts.js
   _showChatListEmptyIfNeeded. While it is the list's only content the list is
   a flex column, so the empty state takes the room left under the head and
   centres in it (on a phone that is the room between the stories and the
   docked composer). */
.clist:has(> .cl-empty) { display: flex; flex-direction: column; }


/* Star balance is shown in the header pill (#starBal).
   Hide the footer element onboarding-welcome.js injects.
   All properties set to prevent any layout contribution. */
#cmwStarBal { display: none !important; height: 0 !important; max-height: 0 !important; overflow: hidden !important; margin: 0 !important; padding: 0 !important; border: none !important; opacity: 0 !important; pointer-events: none !important; }

/* ═══════════════════════════════════════════════════════════
   CHAT HEADER — frosted, intentional
   v120: clean header — no type badges, no avatar rings
   • data-type="agent|p2p|group|broadcast" on .chdr drives
     a) a 1.5px accent line (::after) at the bottom of the header
   • Type is communicated by avatar colour + subtitle text alone
   • Right-side actions use .ib.ctx for contextual primary icon
     and .chdr-divider for the separator before ⋮
═══════════════════════════════════════════════════════════ */
.chdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; height: calc(var(--hh) + var(--st)); padding-top: var(--st);
  border-bottom: 1px solid var(--border);
  background: var(--hz-surface-chathdr, rgba(9,9,22,.90));
  backdrop-filter: var(--hz-chathdr-blur, blur(32px) saturate(1.9));
  -webkit-backdrop-filter: var(--hz-chathdr-blur, blur(32px) saturate(1.9));
  flex-shrink: 0; z-index: 10; position: relative;
  box-shadow: var(--hz-chathdr-shadow, 0 1px 0 rgba(255,255,255,.04));
  transition: background .2s;
}
/* Type accent line — removed v120; avatar colour carries type signal */
.chdr::after { display: none; }

/* Avatar — no type ring; avatar colour + subtitle carry full context */

/* Header avatar — the same avatar circle as the chat list (.av); only its size
   changes here. */
/* When a photo is present the header avatar opens the full-screen viewer on
   tap (wired in app.js); show a zoom affordance. has-img is added by
   AvatarStore.applyAvatar only when an image is actually mounted. */
.chdr .av.has-img { cursor: zoom-in; }
@media (min-width: 900px) {
  .chdr .av { width: 44px; height: 44px; font-size: 20px; }
}

.chdr-l { display: flex; align-items: center; gap: 9px; cursor: pointer; flex: 1; min-width: 0; }
.hinfo  { min-width: 0; flex: 1; }
.hname-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.hnm {
  /* An <h1> (the screen's heading): no heading margin; the type is set here. */
  margin: 0; line-height: inherit;
  font-size: 15px; font-weight: 600; letter-spacing: -.18px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--t1);
}

/* ── Type chip ─────────────────────────────────────────────
   v120: #hTypeChip element removed from index.html.
   Chip manipulation blocks removed from chat-registry.js,
   agents-addon.js, and groups-addon.js.
   ───────────────────────────────────────────────────────── */

.hst {
  font-size: 12px; display: flex; align-items: center;
  gap: 4px; margin-top: 2px; color: var(--t2);
}
.hst::before { display: none; } /* dot removed — text is the signal */
.hst:empty   { display: none; }
.hst.p2p    { color: var(--t2); }
.hst.ai     { color: var(--t2); }
.hst.group  { color: var(--t2); }
.hst.away   { color: var(--warn); }
.hst.off    { color: var(--t3); }
.hst.typing { color: var(--p2p); }

/* Right action area */
.chdr-r { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* Contextual action icon — tinted to match chat type */
.chdr-r .ib.ctx { transition: background .13s, color .13s, transform .1s; }
.chdr[data-type="agent"]     .chdr-r .ib.ctx { color: var(--accent-2); }
.chdr[data-type="p2p"]       .chdr-r .ib.ctx { color: var(--p2p); }
.chdr[data-type="group"]     .chdr-r .ib.ctx { color: var(--group); }
.chdr[data-type="broadcast"] .chdr-r .ib.ctx { color: var(--agent); }
.chdr[data-type="agent"]     .chdr-r .ib.ctx:hover { background: var(--accent-soft); }
.chdr[data-type="p2p"]       .chdr-r .ib.ctx:hover { background: var(--p2p-soft); }
.chdr[data-type="group"]     .chdr-r .ib.ctx:hover { background: var(--group-soft); }
.chdr[data-type="broadcast"] .chdr-r .ib.ctx:hover { background: var(--agent-soft); }

/* Vertical separator in the header action row */
.chdr-divider { width: 1px; height: 18px; background: var(--border-mid); flex-shrink: 0; margin: 0 2px; }

/* Inline peer ID pill */
.hpid { font-family: 'JetBrains Mono', monospace; font-size: 9px; color: var(--t3); background: var(--raised); border: 1px solid var(--border); padding: 2px 7px; border-radius: var(--hz-radius-4); max-width: 125px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: border-color .13s, color .13s; }
.hpid:hover { border-color: var(--p2p-border); color: var(--p2p); }

/* Back button */
.backbtn {
  display: none; width: 34px; height: 34px; border: none;
  background: transparent; color: var(--accent);
  cursor: pointer; align-items: center; justify-content: center;
  border-radius: var(--hz-radius-10); margin-inline-end: 2px;
  transition: background .13s, color .13s; flex-shrink: 0;
}
.backbtn:hover  { background: var(--accent-soft); }
.backbtn:active { background: var(--accent-soft); transform: scale(.9); }
.backbtn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
/* A chat opened as a step of another section (the AI Course's practice agent)
   has somewhere to go back TO even on desktop, where the list sits beside the
   chat and the arrow is otherwise hidden. HzNav stamps the class while that way
   back is live (nav-bar.js, "Chat return"); a phone shows the arrow anyway. */
.cm-chat.hz-chat-returns .backbtn { display: flex; }

/* ═══════════════════════════════════════════════════════════
   MESSAGE CANVAS — atmospheric, alive
═══════════════════════════════════════════════════════════ */
.cm {
  flex: 1; display: flex; flex-direction: column;
  background: var(--void); overflow: hidden; min-width: 0; position: relative;
}

/* Section takeover — while AI Notes, AI Files or the AI Course owns #cm (its
   addon sets the mode class: HzNav's `takeover` sections, nav-bar.js), that
   section's panel is the ONLY #cm child on screen: Home, the chat and every
   other panel step aside.

   Declared here, in the render-blocking shell sheet, and nowhere else. Each
   section's own sheet (notes.css, ai-files.css, course.css) is lazy-loaded, and
   a rule about WHICH screen is showing cannot depend on a skin that may not
   have arrived: with course.css still on the wire — or lost to a dropped
   request on a mobile network — the Course tab lit up and opened its panel
   UNDER the Home screen, which stayed on screen with nothing to say it was
   not the course. The section sheets style their panels; this owns the screen.

   `!important`: Home and the panels are shown with inline `display` by their
   own open functions, which nothing but an important rule outranks. */
#cm.notes-mode > *:not(#cmNotes),
#cm.files-mode > *:not(#cmFiles),
#cm.course-mode > *:not(#cmCourse) { display: none !important; }

/* Welcome state — overridden by CMW agent-grid section below */
.cm-welcome { flex: 1; min-height: 0; }
/* Legacy stubs — elements no longer in HTML, kept for graceful degradation */
.cm-welcome-ic    { display: none; }
.cm-welcome-title { display: none; }
.cm-welcome-sub   { display: none; }

/* ★ Message area — layered atmosphere */
.mw {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 20px 20px 12px;
  display: flex; flex-direction: column; gap: 2px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  will-change: scroll-position, opacity;
  /* The thread — one ground for every chat, the apps' too (tokens.css --hz-thread-*):
     the wash, and over it "Pixel Life" (scripts/generate-thread-pattern.js bakes the
     tile per theme). The scroll container's OWN background, so it stays put while
     the messages scroll over it. 420px = the tile's 140 sprite pixels × 3. */
  background-color: var(--hz-thread-bg);
  background-image: url(/img/thread-pattern-dark.svg), var(--hz-thread-wash);
  background-size: 420px 420px, 100% 100%;
}
.mw::-webkit-scrollbar { width: 3px; }
.mw::-webkit-scrollbar-thumb { background: rgba(255,255,255,.07); border-radius: var(--hz-radius-2); }

#fc { position: absolute; top: 0; height: 100%; width: 340px; left: 50%; transform: translateX(-50%); display: block; }

/* Day separator — above each day's first message (chat-timeline.js), the apps'
   DaySeparator: the meta type on the fill ground, whose ink holds AA on it, so
   the chip reads over the thread's pattern too. Sentence case, as written —
   "Today", "Monday, September 14". */
.ds { display: flex; justify-content: center; padding: 6px 0; flex-shrink: 0; }
.ds time {
  font-size: var(--hz-row-meta-size); font-weight: var(--hz-role-meta-weight);
  letter-spacing: var(--hz-role-meta-tracking); line-height: 1.2;
  color: var(--hz-text-meta-fill); background: var(--hz-surface-fill);
  padding: 4px 10px; border-radius: var(--hz-radius-20);
}

/* Chat event — a line of the thread that is nobody's message ("Anna joined
   the group", utils/chat-event.js; the apps' EventLine). The day separator's
   chip, so the two read as one family of service lines; it wraps for a long
   name (a separator never needs to) and stays within the thread's measure. */
.mg.ev { align-items: center; margin-bottom: 10px; padding: 0 var(--hz-space-4, 16px); }
.mg.ev .ev-pill {
  max-width: min(100%, 420px); text-align: center; overflow-wrap: anywhere;
  font-size: var(--hz-row-meta-size); font-weight: var(--hz-role-meta-weight);
  letter-spacing: var(--hz-role-meta-tracking); line-height: 1.35;
  color: var(--hz-text-meta-fill); background: var(--hz-surface-fill);
  padding: 4px 10px; border-radius: var(--hz-radius-20);
}

/* ═══════════════════════════════════════════════════════════
   MESSAGE BUBBLES — crafted objects, not components
═══════════════════════════════════════════════════════════ */
.mg { display: flex; flex-direction: column; gap: 3px; margin-bottom: 10px; flex-shrink: 0; }
.mg.out { align-items: flex-end; }
.mg.in  { align-items: flex-start; }
.mr { display: flex; align-items: flex-end; gap: 6px; }
.mg.out .mr { flex-direction: row-reverse; }

/* Mini avatars — the sender beside an incoming message (and the typing row).
   The avatar circle, like every other avatar. */
.mav {
  width: 24px; height: 24px; border-radius: var(--hz-radius-avatar);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600;
  flex-shrink: 0; margin-bottom: 2px;
}
.mavsp { width: 24px; flex-shrink: 0; }

/* Base bubble — comfortable density, modern AI-app feel */
.bub {
  max-width: min(560px, 78vw);
  padding: var(--hz-bubble-pad);
  border-radius: var(--hz-bubble-radius);
  font-size: var(--hz-bubble-font-size); line-height: var(--hz-bubble-line-height);
  letter-spacing: var(--hz-bubble-letter-spacing); word-break: break-word;
  position: relative;
}

/* ★ OUTGOING — vivid electric gradient (#7B5BFF → #FF4D9D) */
/* The gradient is the user's signature. Same diagonal angle as
   the play button, the wave, the streaming cursor — repetition
   makes it brand, not decoration. */
.mg.out .bub {
  background: var(--hz-bubble-out-bg);
  color: var(--hz-bubble-out-color);
  box-shadow: var(--hz-bubble-out-shadow);
}
/* No glass overlay — flat solid gradient reads modern.
   The old ::after gradient sheen reads "skeuomorphic 2018". */
.mg.out .bub::after { content: none; }
/* Tail asymmetry — the bottom inline-end corner (bottom-right in LTR, bottom-left in
   RTL) tightens to the tail radius on every outgoing bubble. Logical corners, so the
   tail mirrors with the bubble: .mg.out aligns to flex-end = the inline end. */
.mg.out .mr:last-child .bub { border-end-end-radius: var(--hz-bubble-tail); }
.mg.out .mr:not(:last-child)  .bub { border-end-end-radius: var(--hz-bubble-tail); }
.mg.out .mr:not(:first-child) .bub { border-start-end-radius: var(--hz-bubble-tail); }

/* ★ INCOMING (P2P friend) — soft surface pill, NO border */
/* Friends ≠ AI. The bubble shape itself signals "this is a person". */
.mg.in .bub {
  background: var(--hz-bubble-in-bg);
  color: var(--hz-bubble-in-color);
  box-shadow: var(--hz-bubble-in-shadow);
  border: none;
}
.mg.in .mr:last-child .bub { border-end-start-radius: var(--hz-bubble-tail); }
.mg.in .mr:not(:last-child)  .bub { border-end-start-radius: var(--hz-bubble-tail); }
.mg.in .mr:not(:first-child) .bub { border-start-start-radius: var(--hz-bubble-tail); }

/* ★ AGENT — bubbleless, plain text on canvas (ChatGPT/Claude style) */
/* This is the single biggest signal of "modern AI app". */
.mg.ag .bub {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 2px 0;
  border-radius: 0;
  color: var(--hz-bubble-agent-color);
  max-width: min(680px, 100%);   /* of its row: inside the reply card, never past it */
  font-size: var(--hz-bubble-agent-font-size);   /* reads like a document, not a chat pill */
  line-height: var(--hz-bubble-agent-line-height);
}
/* Exception: thinking bubble keeps its surface (it's an indicator, not text) */
.mg.ag .bub.think-bub {
  background: linear-gradient(135deg, rgba(123, 91, 255, .10), rgba(255, 77, 157, .10)), var(--hz-thread-reply-bg);
  border: 0.5px solid rgba(123, 91, 255, .22);
  border-radius: var(--hz-radius-20);
  padding: 11px 16px;
  box-shadow: none;
  display: inline-flex;
  font-size: 14px;
  color: #B8A6FF;
}
/* Agent row — wider, full reading width */
.mg.ag .mr {
  align-items: flex-start;
  max-width: 100%;   /* the row never outgrows its group, so the bubble's 100% is the column's */
}
/* Agent cards sit directly in .mr, no bubble wrapper needed */

/* Metadata — the time under a bubble (chat-timeline.js), as the apps draw it:
   4px in from the bubble's edge, on the side the bubble sits. An incoming row
   steps past the sender's face: the 24px .mav (28px on a phone) and the row's
   6px gap. A reply card's time lines up with its text. */
.mmeta { display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.mg.out .mmeta { justify-content: flex-end; }
.mg.in  .mmeta { padding-inline-start: 34px; }
.mg.in.ag .mmeta { padding-inline-start: 0; }
/* A reply with an actions row carries its time IN the row (chat-timeline.js), at
   the start of its trailing group: the bottom-end corner, just before ⋯ — one
   line where the time and the row used to take two (the apps' MessageActionRow).
   No step past a face there: the row already starts at the text. It stays when
   the row steps aside for a selection (forward-addon hides the row's buttons). */
#mw .ag-actions-trail > .mmeta { padding: 0; padding-inline-start: 4px; }   /* ⋯ brings its own inset on the far side */
#cmChat.hz-selecting #mw .ag-actions-trail > .mmeta { visibility: visible; }

/* ★ AGENT REPLY CARD — on the thread's pattern an agent's reply sits on a card of
   its own (the apps' ReplyCard): the whole message group — the reply, its time,
   its actions row (share-addon) — so no line of it runs over the sprites. A card,
   not a bubble: square to the column, no tail (a bubble is a person). Not the
   indicators (the thinking placeholder, an image being made), which keep their
   own surface. */
.mg.ag:not(.think-placeholder):not(.im-job) {
  /* A phone's card spans the column, as in the apps; a wide screen's hugs its reply (≤ 680px). */
  align-self: var(--reply-card-align, flex-start);
  max-width: 100%;
  margin: 4px 0 10px;
  padding: var(--reply-card-pad, 12px 16px 6px);
  border-radius: var(--reply-card-radius, var(--hz-bubble-radius));
  background: var(--hz-thread-reply-bg);
  box-shadow: var(--hz-bubble-in-shadow);
}
/* Who answered, heading an agent's reply card in a group (msg-renderer.js
   agentSenderHtml): the agent's face and name, as the apps' AgentSender — on the
   card, so the name never runs over the sprites. Over an offer card (no card
   around it) it heads the offer instead. */
.ag-sender { display: flex; align-items: center; gap: 8px; min-width: 0; margin-bottom: 3px; }
.ag-sender-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--hz-row-meta-size); font-weight: 600;
  letter-spacing: var(--hz-role-meta-tracking); line-height: 1.2;
  color: var(--hz-brand-ink);
}
/* Over an offer (no card around it) the name stands on the pattern: the ink that
   holds AA over any sprite, as a bubble's time and a person's name. */
#mw .mg.ag:has(.hz-offer-card) .ag-sender-name { color: var(--hz-thread-meta-ink); }
/* A sender's run (chat-timeline.js data-run): their name and face head its first
   message only; the face keeps its room, so the run's bubbles stay in line. */
#mw .mg[data-run="cont"] .ag-sender,
#mw .mg[data-run="cont"] .bub-sender { display: none; }
#mw .mg[data-run="cont"] > .mr > .mav { visibility: hidden; }
/* An offer is a card already (msg-renderer.js offerCardHtml): no card around it. Its
   own rule — and as specific as the card's — so a browser without :has() keeps the cards. */
.mg.ag:not(.think-placeholder):not(.im-job):has(.hz-offer-card) { padding: 0; background: none; box-shadow: none; }
/* What sits on the pattern itself (a bubble's time) holds AA over any sprite;
   on a reply card it is the card's own meta ink, as the apps' ReplyCard. */
#mw .mtime { color: var(--hz-thread-meta-ink); }
#mw .mg.ag:not(.think-placeholder):not(.im-job):not(:has(.hz-offer-card)) .mtime { color: var(--tmeta); }
.mtime {
  font-size: var(--hz-row-meta-size); font-weight: var(--hz-role-meta-weight);
  letter-spacing: var(--hz-role-meta-tracking); line-height: 1.2;
  font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--tmeta);
}

/* ── Harizma "✨ Prompt & details" disclosure ───────────────────────────────
   The optimized prompt tucked behind a collapsed, native <details> toggle on a
   Harizma routing reply (msg-renderer.js hzDisclosureHtml). Quiet by default so
   the warm line + result lead; only the curious open it. Native <details> means
   the expand/collapse needs no JS and behaves identically on every platform. */
.hz-details {
  margin-top: 8px;
  border-top: 0.5px solid var(--border);
  padding-top: 6px;
  max-width: min(680px, 86vw);
}
.hz-details-sum {
  display: inline-flex;
  align-items: center;
  gap: var(--hz-space-2, 8px);
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--t2);
  min-height: var(--hz-tap-min, 44px);   /* comfortable tap target on touch devices */
  padding: 4px 2px;
  border-radius: var(--hz-radius-8);
  transition: color var(--hz-dur-fast, .15s) var(--hz-ease, ease);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;            /* kill the 300ms tap delay on mobile */
}
.hz-details-sum::-webkit-details-marker { display: none; }
.hz-details-sum::before {
  content: "▸";
  font-size: 10px;
  color: var(--t3);
  transition: transform var(--hz-dur-fast, .15s) var(--hz-ease, ease);
}
.hz-details[open] > .hz-details-sum::before { transform: rotate(90deg); }
/* ▸ is not Bidi_Mirrored: closed, it must point to inline-end (left) in RTL. Open,
   rotate(90deg) above (higher specificity) turns it down in both directions. */
[dir="rtl"] .hz-details-sum::before { transform: scaleX(-1); }
.hz-details-sum:hover { color: var(--accent); }
.hz-details-body {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: hzDetailsIn var(--hz-dur, .2s) var(--hz-ease, ease);
}
@keyframes hzDetailsIn { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
.hz-details-prompt {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--t1);
  background: var(--raised);
  border: 0.5px solid var(--border);
  border-radius: var(--hz-radius-12);
  padding: 11px 13px;
  word-break: break-word;
  overflow-wrap: anywhere;
}
/* The prompt renders as markdown (aetherFmt) — tighten the block spacing of its
   generated children so the "details" view stays compact inside the bubble. */
.hz-details-prompt > :first-child { margin-top: 0; }
.hz-details-prompt > :last-child  { margin-bottom: 0; }
.hz-details-prompt p { margin: 0 0 6px; }
.hz-details-prompt ul, .hz-details-prompt ol { margin: 4px 0; padding-inline-start: 20px; }
.hz-details-prompt li { margin: 1px 0; }

/* Ticks */
.tick { display: inline-flex; position: relative; width: 18px; height: 12px; flex-shrink: 0; }
.tick svg { position: absolute; width: 11px; height: 11px; fill: none; stroke: rgba(255,255,255,.35); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: stroke .3s, transform .25s var(--ease-spring); }
.tick svg:last-child { left: 5px; } /* physical: the ✓✓ glyph pair never mirrors */
.tick.sent      svg { stroke: rgba(255,255,255,.35); }
.tick.delivered svg { stroke: rgba(255,255,255,.7); }
.tick.delivered svg:last-child { transform: translateX(-1px); }
.tick.read      svg { stroke: var(--p2p); }
.tick.read      svg:first-child { transform: translateX(-1px) scale(1.05); }
.tick.read      svg:last-child  { transform: translateX(-1px) scale(1.05); }
.tick.queued    svg { stroke: var(--warn); opacity: .7; }
.tick.failed    svg { stroke: var(--err); opacity: .9; }

/* ── Group message sender name + bubble wrapper ─────────────────────────────
   Used by groups-addon.appendGroupMessage for a person's incoming messages (an
   agent's reply is its card, headed by .ag-sender).
   .bub-wrap  — flex column holding the sender name above the bubble.
   .bub-sender — the small name label above the bubble text.
   ─────────────────────────────────────────────────────────────────────────── */
.bub-wrap   { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bub-sender { font-size: 11px; font-weight: 600; color: var(--hz-thread-meta-ink); line-height: 1; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* on the thread's pattern: AA over any sprite */

/* ── Forwarded message label ────────────────────────────────────────────────
   "Forwarded from Alice" — the first line inside a forwarded message's bubble
   (msg-renderer.js forwardedLabelHtml, docs/forwarding.md §6). It takes the
   bubble's own ink (your gradient bubble or their surface bubble, light or
   dark theme) at a lower emphasis, so it reads as metadata above the words.
   In a photo bubble it sits in the caption's inset, above the media. */
.bub-fwd {
  display: flex; align-items: center; gap: var(--hz-space-1);
  margin-bottom: var(--hz-space-1);
  font-size: var(--hz-text-xs); line-height: 1.3;
  font-weight: var(--hz-weight-medium);
  color: inherit; opacity: .78;
  min-width: 0;
}
.bub-fwd > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bub-fwd-name { font-weight: var(--hz-weight-semibold); }
.bub-fwd-ico {
  width: 12px; height: 12px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
[dir="rtl"] .bub-fwd-ico { transform: scaleX(-1); }
.bub-media > .bub-fwd { padding: var(--hz-space-1) var(--hz-space-2) 0; }

/* System message */
.sysmsg { text-align: center; padding: 5px 0; font-size: 11px; color: var(--t3); display: flex; align-items: center; justify-content: center; gap: 5px; flex-shrink: 0; }
.sysmsg svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sysmsg.p2p { color: var(--p2p); }

/* Typing */
.typr { display: flex; align-items: flex-end; gap: 6px; flex-shrink: 0; }
/* P2P typing indicator — v72: gradient-tint, gradient dots */
.tybub {
  background: linear-gradient(135deg, rgba(123,91,255,.10), rgba(255,77,157,.10)), var(--hz-thread-reply-bg);
  border: 0.5px solid rgba(123,91,255,.20);
  border-radius: var(--hz-radius-20);
  border-end-start-radius: var(--hz-radius-8);
  padding: 11px 14px;
  display: flex; gap: 4px; align-items: center;
  box-shadow: none;
}
.tyd {
  width: 6px; height: 6px;
  background: linear-gradient(135deg, #7B5BFF, var(--hz-accent-pink));
  border-radius: 50%;
  animation: td 1.4s infinite;
}
.tyd:nth-child(2) { animation-delay: .18s; opacity: .8; }
.tyd:nth-child(3) { animation-delay: .36s; opacity: .55; }
@keyframes td { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

/* v114: ETA text inside .tybub for the agent-thinking fallback indicator.
   Used when showAgentThinking paints the in-chat dots on register-ack
   replay / openChat re-install, carrying the "(~Xs)" label (see
   contacts.js showAgentThinking). .tybub is flex with gap:4px, so the
   label sits to the right of the three .tyd dots on a single row.
   Matches .think-txt visual weight so the fallback reads the same as
   streamLM's optimistic .bub.think-bub. Empty for P2P peer-typing
   (that path never passes a label; the span is simply absent). */
.ty-label {
  font-size: 13px;
  color: var(--t2, #aaa);
  font-weight: 500;
  margin-inline-start: 6px;
  white-space: nowrap;
  letter-spacing: .01em;
}

/* Thinking bubble */

/* ═══════════════════════════════════════════════════════════════════════
   IMAGE PREVIEWS  —  AI-generated (.im-img-wrap) & user-sent (.bub-img-wrap)

   Design principle (Telegram / iMessage pattern):
   • Respect the image's NATURAL aspect ratio — never force a shape.
   • Cap width so it fits the chat column; cap height so portrait images
     don't take over the screen.
   • object-fit: contain — always shows the full image, no cropping.
   • The wrap shrink-wraps to the rendered image size.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Shared container — v71 unified 18px media shape ── */
.im-img-wrap,
.bub-img-wrap {
  position: relative;
  display: inline-block;   /* shrink-wraps to image natural size */
  line-height: 0;          /* kills phantom bottom gap */
  border-radius: var(--hz-radius-18);
  overflow: hidden;
  box-shadow: 0 3px 14px rgba(0,0,0,.18);
  background: transparent; /* no dark bleed-through */
  vertical-align: top;
}

/* ── AI-generated image ── */
/* Phone default: up to 72 vw, never wider than 320px               */
.im-img-wrap { max-width: min(320px, 72vw); }
.im-img {
  display: block;
  width: 100%;           /* fills container width                   */
  height: auto;          /* natural proportions                     */
  max-height: 360px;     /* cap very tall portrait images           */
  object-fit: contain;   /* full image visible, no crop             */
  border-radius: var(--hz-radius-18);
  transition: opacity .35s ease;
  background: transparent;
  image-orientation: from-image; /* honour EXIF rotation on all platforms  */
}
.im-img.im-img-loading { opacity: 0; }
.im-img.im-img-reveal  { opacity: 1; }

/* ── Skeleton shimmer (while loading) — v71 18px ── */
.im-skeleton {
  position: absolute; inset: 0; border-radius: var(--hz-radius-18);
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--hz-brand) 4%, transparent) 25%,
    color-mix(in srgb, var(--hz-brand) 12%, transparent) 50%,
    color-mix(in srgb, var(--hz-brand) 4%, transparent) 75%
  );
  background-size: 200% 100%;
  animation: im-shimmer 1.5s ease-in-out infinite;
}
/* Hide skeleton once image is revealed */
.im-img-wrap:has(.im-img-reveal) .im-skeleton { display: none; }
@keyframes im-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Action bar (download / zoom) — v71 18px ── */
.im-img-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: flex-end; gap: 6px;
  padding: 30px 8px 8px;
  background: linear-gradient(to top, rgba(0,0,0,.60) 0%, transparent 100%);
  border-radius: 0 0 var(--hz-radius-18) var(--hz-radius-18);
  opacity: 0;
  transition: opacity .18s;
  pointer-events: none;
}
.im-img-wrap:hover .im-img-bar { opacity: 1; pointer-events: auto; }
.im-img-act {
  background: rgba(255,255,255,.20);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--hz-radius-8);
  color: #fff; font-size: 13px; font-weight: 500;
  padding: 4px 10px; cursor: pointer;
  text-decoration: none; line-height: 1.5;
  transition: background .15s;
}
.im-img-act:hover { background: rgba(255,255,255,.38); }

/* Touch: always show bar (no :hover) */
@media (hover: none) {
  .im-img-wrap .im-img-bar { opacity: 1; pointer-events: auto; }
}

/* ── User-sent image — image IS the bubble ──────────────────────
   Modern messengers integrate the image into the bubble shape.
   The old "Image" label + caption-below pattern wastes space
   and reads dated. On outgoing, the image sits on top of the
   gradient bubble with matching radius.

   ── Sizing contract: ONE column, derived both ways ──────────────
   --hz-bubble-media-width is the picture's column; --hz-bubble-media-pad is
   the rim of bubble surface around it. A bubble that carries media derives
   its own max-width from those two, and the picture then fills that bubble's
   content box. Neither side owns a private cap, so "picture wider than its
   bubble" is no longer representable.

   This is the defect that rule replaces: the wrap capped itself at
   min(280px, 68vw) while `.bub` capped itself at min(270px, 80vw) with 14px
   side padding, and the wrap bled out of that padding with `margin: -2px -4px`.
   Both caps are legitimate on their own, but they are unrelated numbers — from
   390px viewports upward (i.e. every current phone: 390 / 393 / 412 / 430) the
   column outgrew the bubble's content box and the picture hung past the
   bubble's right edge by up to 20px, which is the reported defect. The negative
   margin also made the rim asymmetric by construction (it can only pull left,
   never give the right side back), so it is gone: the rim is now real padding.

   The hook is the `bub-media` CLASS, which every renderer that builds a media
   bubble puts on it, with `:has()` kept beside it only as a safety net for a
   renderer that forgets. Deliberately that way round, not `:has()` alone:
   containment must not depend on a selector an engine may not have. The two sit
   in one `:is()` — a forgiving selector list, so an engine without `:has()`
   drops that branch and keeps the class instead of throwing the whole rule away
   (a plain `a, b` list would be invalidated entirely by the unknown half). */
.bub:is(.bub-media, :has(> .bub-img-wrap)) {
  max-width: calc(var(--hz-bubble-media-width) + var(--hz-bubble-media-pad) * 2);
  padding: var(--hz-bubble-media-pad);
  /* The bubble is a flex item of .mr, so its automatic minimum size is its
     content-based minimum — which comes from MediaFrame's inline natural width
     (1024px and up). Flexbox says to clamp that by max-width and engines do,
     but saying it outright costs nothing and removes the dependency: the cap
     above is then the only thing deciding this bubble's width. Safe because the
     picture tracks the bubble (100% below), so they shrink together. */
  min-width: 0;
  /* A picture is never upscaled past its natural width (MediaFrame pins that
     width inline), so a small original — or a caption long enough to widen the
     bubble on its own — leaves slack. Centre it instead of pinning it left with
     all the slack on one side; the rim stays even either way. */
  text-align: center;
}
.bub-img-wrap {
  /* The whole containment guarantee, in one plain declaration that every engine
     back to CSS 2.1 understands: a picture is never wider than the bubble it
     sits in. The rule above makes that bubble exactly one media column wide, so
     100% IS the column — but if that rule ever fails to apply (an engine, a
     renderer that forgets the class) the picture still cannot escape; it just
     renders at the plain bubble's width.
     NB not `min(column, 100%)`: a percentage makes the whole min() stop
     constraining INTRINSIC sizing, so the bubble would size itself from the
     inline 1024px natural width instead — measured, see verify-chat-media.js. */
  max-width: 100%;
  border-radius: var(--hz-radius-16);   /* deliberate: media sits 2px tighter
     than the .im-img-wrap/.bub-img-wrap shared 18px shape above */
}
.bub-img {
  display: block;
  width: 100%; height: auto;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--hz-radius-16);
  background: rgba(0,0,0,.08);
  cursor: zoom-in;
  transition: opacity .2s;
  image-orientation: from-image; /* honour EXIF rotation on all platforms  */
}
.bub-img:hover { opacity: .92; }
/* Drop the loud "Image" label — image speaks for itself. It returns only when
   the bitmap fails to decode (e.g. a HEIF CDN URL outside Safari), where the
   broken <img> is pulled entirely so its alt text can't show through. */
.bub-img-lbl { display: none; }
.bub-img-broken .bub-img-lbl {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 0 4px; font-size: 13px; opacity: .7;
}
.bub-img-broken .bub-img,
.bub-img-broken .bub-img-grid-item { display: none; }
/* ── A clip in a person's bubble — a video, a voice message, a song
   (msg-renderer.js fillMessageClips: a forwarded one, or any a person's
   message carries). The players are an agent reply's own — imagemind's video,
   voice-addon's waveform — so a clip looks and plays the same wherever it is.
   A sound sits on the caption's inset; on the gradient of your own bubble the
   waveform takes the bubble's white ink, the play button turns white. */
.bub-clip { text-align: start; }
.bub-clip + .bub-clip { margin-top: var(--hz-space-2); }
.bub-clip--audio { padding: var(--hz-space-1) var(--hz-space-2); }
.bub-clip--video .im-video { max-width: 100%; }
.mg.out .bub-clip .vm-play { background: #fff; box-shadow: none; }
.mg.out .bub-clip .vm-play svg { fill: var(--hz-bubble-violet); }   /* the gradient's own start */
.mg.out .bub-clip .vm-bar { background: rgba(255,255,255,.4); }
.mg.out .bub-clip .vm-bar.played,
.mg.out .bub-clip .vm-bar.active { background: #fff; }
.mg.out .bub-clip .vm-wf-cursor { background: rgba(255,255,255,.75); }
.mg.out .bub-clip .vm-dur { color: rgba(255,255,255,.85); }
.bub-img-txt {
  font-size: 15px; line-height: 1.5;
  text-align: start;            /* the caption reads left/RTL-start, not centred */
  /* Side inset is media-pad + 8 = the 18px the bubble's own text padding used
     to give the caption; the rim carries the rest. */
  padding: 8px 8px 2px;
  color: inherit;
  letter-spacing: -.005em;
}

/* ── Multi-image grid ───────────────────────────────────────────
   2-up fluid cells. Fixed 130px columns (263px total) used to be wider than
   the column on narrow phones, where the wrap's overflow:hidden silently cut
   the right-hand cell in half; fluid cells can't outgrow the wrap. aspect-ratio
   preserves the 130×110 cell shape AND reserves each cell's height before its
   bitmap decodes, so the grid keeps the no-jump contract.

   minmax(0, 1fr), not a bare 1fr: a bare 1fr is minmax(AUTO, 1fr), and the auto
   minimum of an <img> is its intrinsic width — a 1024px photo. Chromium happens
   to clamp that here, engines are free not to, and a blown-out track is the very
   overflow this section exists to make impossible. min-width/min-height:0 on the
   cell says the same thing from the item's side, which is what WebKit reads. */
.bub-img-grid-wrap { width: var(--hz-bubble-media-width); }
.bub-img-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px; border-radius: var(--hz-radius-16); overflow: hidden;
}
.bub-img-grid-item {
  display: block; width: 100%; height: auto;
  min-width: 0; min-height: 0;
  aspect-ratio: 130 / 110; object-fit: cover;
  cursor: zoom-in; transition: opacity .15s;
  image-orientation: from-image;
}
.bub-img-grid-item:hover { opacity: .92; }
/* A lone cell spans both columns, in the wider 263×200 shape. */
.bub-img-grid:has(:only-child) .bub-img-grid-item {
  grid-column: 1 / -1; aspect-ratio: 263 / 200;
}

/* ── Unified media frame: shimmer + reveal + space reservation ─────────────
   Brings the AI-image (.im-img-*) loading contract to user-sent and received
   (P2P) images so EVERY chat image reserves its box, shows a shimmer while it
   decodes, and cross-fades in — no reflow, no jump, no scroll-snap cascade.
   Built by MediaFrame (js/media-frame.js); see that file for the rationale. */

/* Shimmer skeleton — sits behind the picture (z-index) until it reveals. */
.bub-skeleton {
  position: absolute; inset: 0; z-index: 1;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgba(123,91,255,.05) 25%,
    rgba(123,91,255,.14) 50%,
    rgba(123,91,255,.05) 75%
  );
  background-size: 200% 100%;
  animation: im-shimmer 1.4s ease-in-out infinite;
}
/* Hide the shimmer once nothing is still loading (or on failure). Gating on
   "no .bub-img-loading remain" keeps the skeleton up behind a multi-image grid
   until EVERY cell has decoded, instead of vanishing when the first one does. */
.bub-img-wrap:not(:has(.bub-img-loading)) .bub-skeleton,
.bub-img-broken .bub-skeleton { display: none; }

/* Picture rides above the skeleton; fades from hidden → shown on decode. */
.bub-img, .bub-img-grid-item { position: relative; z-index: 2; }
.bub-img.bub-img-loading, .bub-img-grid-item.bub-img-loading { opacity: 0; }
.bub-img.bub-img-reveal,  .bub-img-grid-item.bub-img-reveal  {
  animation: bub-img-fade .32s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes bub-img-fade { from { opacity: 0; } to { opacity: 1; } }

/* Reserve a stable box for a SINGLE image whose dimensions aren't known until
   decode. Explicit width+height (not just aspect-ratio) is required because
   .bub-img-wrap is display:inline-block — for non-replaced elements content
   height would otherwise win and collapse the box (same reasoning as the
   imagemind .im-img-wrap rule). Images that carry width/height attributes are
   excluded — the browser reserves their exact ratio natively, so they never
   match this rule and never settle. :has() ships in all evergreen targets
   (Chrome 105+, Safari 15.4+, Firefox 121+); older engines fall back to the
   natural shrink-to-image behaviour. */
.bub-img-wrap:not(.bub-img-grid-wrap):has(.bub-img-loading:not([width])) {
  width: var(--hz-bubble-media-width);
  height: var(--hz-bubble-media-width);
}
/* The picture fills whichever definite box the wrap reserved — the inline
   aspect-ratio box (known dimensions) or the square fallback (unknown). cover
   keeps the settled crop identical to the pre-reservation behaviour. Grids are
   excluded — their cells are fixed-size and reserve themselves. */
.bub-img-wrap:not(.bub-img-grid-wrap) .bub-img {
  width: 100%; height: 100%; object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .bub-skeleton { animation: none; }
  .bub-img.bub-img-reveal, .bub-img-grid-item.bub-img-reveal { animation: none; opacity: 1; }
  .hz-details-body { animation: none; }
  .hz-details-sum::before { transition: none; }
}

/* ══ TABLET  ≥641px ══════════════════════════════════════════════ */
/* Chat column ≈ 520-600px — wider images feel natural             */
/* ═══════════════════════════════════════════════════════════════ */

/* ══ DESKTOP ≥900px ══════════════════════════════════════════════ */
/* Chat column ≈ 660px wide (.mw padding 28×2, sb 310px)          */
/* ═══════════════════════════════════════════════════════════════ */

/* ══ WIDE ≥1280px ════════════════════════════════════════════════ */
/* Chat column ≈ 820px wide (.mw padding 36×2, sb 340px)          */
/* ═══════════════════════════════════════════════════════════════ */

/* ★ Thinking bubble — v72 gradient-tinted indicator
   Soft gradient background (like the brand sparkle but at low opacity) +
   gradient dots inside. Replaces the old white card with a coloured glow. */
.bub.think-bub {
  min-width: 64px;
  background: linear-gradient(135deg, rgba(123,91,255,.10), rgba(255,77,157,.10)), var(--hz-thread-reply-bg) !important;
  border: 0.5px solid rgba(123,91,255,.20) !important;
  border-radius: var(--hz-radius-20) !important;
  padding: 11px 16px !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center !important;
  animation: none !important;
}
@keyframes think-glow {
  /* !important is invalid inside @keyframes (ignored per spec) — dropped. */
  0%,100% { border-color: rgba(232,121,166,.15); box-shadow: 0 1px 2px rgba(0,0,0,.22), 0 4px 14px rgba(0,0,0,.18); }
  50%     { border-color: rgba(232,121,166,.42); box-shadow: 0 0 22px rgba(232,121,166,.12); }
}
.think-wrap { display: flex; align-items: center; gap: 10px; padding: 1px 2px; }
.think-orb  { display: flex; gap: 4px; align-items: center; }
.think-orb span {
  width: 7px; height: 7px; border-radius: 50%;
  background: linear-gradient(135deg, #7B5BFF, var(--hz-accent-pink));
  animation: think-bounce 1.4s ease-in-out infinite;
}
.think-orb span:nth-child(2) { animation-delay: .15s; width: 5px; height: 5px; opacity: .8; }
.think-orb span:nth-child(3) { animation-delay: .30s; width: 4px; height: 4px; opacity: .55; }
@keyframes think-bounce { 0%,70%,100% { transform: translateY(0) scale(1); opacity: .35; } 35% { transform: translateY(-7px) scale(1.2); opacity: 1; } }
.think-txt { font-size: 13px; font-style: italic; font-weight: 400; letter-spacing: .04em; background: linear-gradient(90deg, var(--t3) 0%, var(--agent) 42%, #b8b1ff 58%, var(--t3) 100%); background-size: 300% auto; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; animation: think-sweep 3s linear infinite; user-select: none; }
@keyframes think-sweep { to { background-position: -300% center; } }

/* Stop bar */
/* .stbar — stop bar is hidden; the in-composer .sbtn-stop is used instead.
   Hard override at end of file keeps .stbar.on from accidentally showing it. */
.stbar { display: none; padding: 5px 14px; justify-content: center; flex-shrink: 0; }
.stbar.on { display: flex; } /* overridden by !important rule at end of file */
.stbtn { display: flex; align-items: center; gap: 6px; padding: 6px 16px; background: rgba(244,115,115,.07); border: 1px solid rgba(244,115,115,.24); border-radius: var(--hz-radius-pill); color: var(--err); font-family: inherit; font-size: 12px; font-weight: 500; cursor: pointer; transition: background .15s; }
.stbtn:hover { background: rgba(244,115,115,.14); }
.stbtn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* ═══════════════════════════════════════════════════════════
   AI FILTER BAR
═══════════════════════════════════════════════════════════ */
.aif-bar {
  display: flex; align-items: center; gap: 5px;
  padding: 0 14px; flex-shrink: 0; overflow: hidden;
  max-height: 0; opacity: 0;
  transition: max-height .28s var(--ease), opacity .22s, padding .28s var(--ease);
  border-top: 1px solid transparent;
  background: rgba(6,6,16,.55);
}
.aif-bar.show { max-height: 58px; opacity: 1; padding: 7px 14px 9px; border-top-color: var(--border); }
.aif-sep { width: 1px; height: 16px; background: rgba(255,255,255,.09); flex-shrink: 0; margin: 0 1px; }

.aif-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 13px; height: 32px; border-radius: var(--hz-radius-pill);
  font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.04); color: var(--t2);
  transition: all .18s; white-space: nowrap; flex-shrink: 0; letter-spacing: .01em;
}
.aif-toggle svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.aif-toggle:active { transform: scale(.95); }
.aif-toggle.on { background: color-mix(in srgb, var(--hz-brand) 14%, transparent); color: var(--accent-2); border-color: color-mix(in srgb, var(--hz-brand) 32%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hz-brand) 8%, transparent); }
.aif-toggle.proc { color: var(--warn); border-color: rgba(248,183,74,.35); background: rgba(248,183,74,.07); animation: pulse .9s infinite; }

.aif-presets { display: flex; gap: 4px; overflow-x: auto; flex: 1; min-width: 0; -ms-overflow-style: none; scrollbar-width: none; padding: 1px 0; -webkit-mask-image: linear-gradient(to right, transparent 0, #000 6px, #000 calc(100% - 6px), transparent 100%); }
.aif-presets::-webkit-scrollbar { display: none; }

.pchip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 0 12px; height: 32px; border-radius: var(--hz-radius-pill);
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer; border: 1px solid rgba(255,255,255,.09);
  background: rgba(255,255,255,.04); color: var(--t2);
  transition: background .18s, color .18s, border-color .18s, box-shadow .18s, transform .12s;
  white-space: nowrap; flex-shrink: 0; letter-spacing: .01em;
  touch-action: manipulation; user-select: none;
}
.pchip-ic { font-size: 12px; line-height: 1; flex-shrink: 0; }
.pchip:active { transform: scale(.95); }
@media (hover: hover) {
  .pchip:hover { color: var(--t1); background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); transform: translateY(-1.5px); box-shadow: 0 3px 12px rgba(0,0,0,.3); }
  .pchip[data-color="purple"]:hover { background: color-mix(in srgb, var(--hz-brand) 12%, transparent); border-color: color-mix(in srgb, var(--hz-brand) 28%, transparent); color: var(--accent-2); }
  .pchip[data-color="orange"]:hover { background: rgba(251,147,60,.10); border-color: rgba(251,147,60,.28); color: #FFBD84; }
  .pchip[data-color="blue"]:hover   { background: rgba(96,165,250,.10); border-color: rgba(96,165,250,.28); color: #93C5FD; }
  .pchip[data-color="green"]:hover  { background: rgba(52,211,153,.10); border-color: rgba(52,211,153,.28); color: #6EE7B7; }
  .pchip[data-color="pink"]:hover   { background: rgba(244,114,182,.10); border-color: rgba(244,114,182,.28); color: #F9A8D4; }
  .pchip[data-color="yellow"]:hover { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.28); color: #FDE68A; }
  .pchip[data-color="teal"]:hover   { background: rgba(45,212,191,.10); border-color: rgba(45,212,191,.28); color: #5EEAD4; }
}
.pchip[data-color="purple"].on  { background: color-mix(in srgb, var(--hz-brand) 17%, transparent); border-color: color-mix(in srgb, var(--hz-brand) 40%, transparent); color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hz-brand) 9%, transparent), 0 3px 14px color-mix(in srgb, var(--hz-brand) 20%, transparent); }
.pchip[data-color="orange"].on  { background: rgba(251,147,60,.14); border-color: rgba(251,147,60,.40); color: #FFBD84; box-shadow: 0 0 0 3px rgba(251,147,60,.09); }
.pchip[data-color="blue"].on    { background: rgba(96,165,250,.14); border-color: rgba(96,165,250,.40); color: #93C5FD; box-shadow: 0 0 0 3px rgba(96,165,250,.09); }
.pchip[data-color="green"].on   { background: rgba(52,211,153,.13); border-color: rgba(52,211,153,.40); color: #6EE7B7; box-shadow: 0 0 0 3px rgba(52,211,153,.09); }
.pchip[data-color="pink"].on    { background: rgba(244,114,182,.13); border-color: rgba(244,114,182,.40); color: #F9A8D4; box-shadow: 0 0 0 3px rgba(244,114,182,.09); }
.pchip[data-color="yellow"].on  { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.40); color: #FDE68A; box-shadow: 0 0 0 3px rgba(251,191,36,.09); }
.pchip[data-color="teal"].on    { background: rgba(45,212,191,.13); border-color: rgba(45,212,191,.40); color: #5EEAD4; box-shadow: 0 0 0 3px rgba(45,212,191,.09); }
.pchip[data-color="gray"].on    { background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.22); color: var(--t1); box-shadow: 0 0 0 3px rgba(255,255,255,.06); }

.aif-cfg { width: 32px; height: 32px; border-radius: var(--hz-radius-pill); border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.04); color: var(--t3); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .18s; }
.aif-cfg:hover { background: rgba(255,255,255,.08); color: var(--t1); transform: rotate(45deg); }
.aif-cfg svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ═══════════════════════════════════════════════════════════
   ★★★ FLOATING COMPOSER — THE SIGNATURE TRAIT ★★★
   Hovers above the canvas. Aurora border breathes slowly.
   On focus: lifts with shadow, aurora intensifies.
   On AI active: aurora shifts brighter (blue/cyan mix).
═══════════════════════════════════════════════════════════ */
.iz {
  padding: 8px 12px 10px;
  padding-bottom: calc(10px + var(--sb2));
  flex-shrink: 0; z-index: 10;
  /* Glass floor — backdrop-filter is expensive; give it a reasonable
     blur that still works on mid-range Android. Over 20px is wasted
     since each pixel of blur radius costs exponential GPU time. */
  background: var(--hz-surface-composer, rgba(8,8,20,.82));
  backdrop-filter: var(--hz-composer-blur, blur(16px) saturate(1.6));
  -webkit-backdrop-filter: var(--hz-composer-blur, blur(16px) saturate(1.6));
  border-top: var(--hz-composer-border-top, 1px solid rgba(255,255,255,.06));
  /* ── Keyboard-follow — iOS Safari soft-keyboard fix ──
     The JS visualViewport handler writes the keyboard inset to
     --kb-inset. We translate the whole composer up by that amount
     so it stays pinned above the keyboard. On desktop or Android
     (where the layout viewport already shrinks), --kb-inset is 0
     and this translate is a no-op. */
  transform: translateY(calc(var(--kb-inset, 0px) * -1));
  transition: transform .18s ease;
}

/* Chat composer bar — a single-row COMPOSITION of the shared composer register
   (--hz-composer-*). The home hero (.cmh-composer) consumes the same register,
   so the two read as one component; only the layout differs. */
.ish {
  display: flex; align-items: center; gap: var(--hz-composer-gap);
  background: var(--hz-composer-bg);
  border: var(--hz-composer-border-width) solid var(--hz-composer-border);
  border-radius: var(--hz-composer-radius);
  padding-block: 7px; padding-inline: 14px 8px;
  position: relative;
  /* Calm resting state — subtle lift, no heavy shadow */
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  transition: border-color .18s, box-shadow .18s, background .18s;
}

/* Focus — the shared brand-blue halo (register), matching the home composer. */
.ish:focus-within {
  border-color: var(--hz-composer-focus-border);
  box-shadow:
    0 1px 2px rgba(0,0,0,.12),
    var(--hz-composer-focus-ring);
}

/* Textarea — 16px is the magic number that prevents iOS Safari
   from auto-zooming the viewport when the input gets focus.
   Any value below 16px triggers the zoom and makes the composer
   appear to jump, which users perceive as "the keyboard hides it". */
.mta {
  flex: 1; background: transparent; border: none; outline: none;
  /* Was `'Plus Jakarta Sans', inherit` — invalid (inherit cannot sit in a list), so the
     whole declaration was dropped and the textarea fell back to the UA font. */
  font-family: 'Plus Jakarta Sans', 'IBM Plex Sans Arabic', 'IBM Plex Sans Devanagari', 'Noto Sans Armenian', system-ui, sans-serif;
  font-size: 16px;         /* critical — see comment above */
  color: var(--t1); resize: none; max-height: 110px; line-height: 1.5;
  padding: 4px 0; letter-spacing: -.005em;
  /* No height transition: the field follows the text at once (composer.js
     autosize) — an animated height re-lays the whole chat panel out on every
     frame of every new line. */
  /* Disable iOS tap highlight + stop autocorrect from shifting the caret */
  -webkit-tap-highlight-color: transparent;
}
.mta::placeholder { color: var(--hz-input-placeholder); font-size: 15px; }
.mta:disabled     { opacity: .4; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════════════════
   SHARED COMPOSER CONTROL ATOMS  (design-system, --hz-composer-* register)
   ─────────────────────────────────────────────────────────────────────────
   One definition each for the composer's icon buttons (.hz-composer-btn:
   attach "+", emoji, mic) and its send button (.hz-composer-send). Used by BOTH
   the chat bar (.ish/.iacts) and the home hero (.cmh-composer/.cmh-toolbar), so
   size + colour live in exactly one place. Legacy aliases .abtn/.sbtn are kept
   as thin pointers so existing markup/JS ids keep working.
   ══════════════════════════════════════════════════════════════════════════ */
.hz-composer-btn, .abtn {
  width: var(--hz-composer-control-size); height: var(--hz-composer-control-size);
  border: none; background: transparent; color: var(--hz-composer-icon-color);
  cursor: pointer; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: color .13s, background .13s, transform .13s; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.hz-composer-btn:hover, .abtn:hover { color: var(--hz-composer-icon-hover-color); background: var(--hz-composer-icon-hover-bg); }
.hz-composer-btn:active, .abtn:active { transform: scale(.9); }
.hz-composer-btn:focus-visible, .abtn:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 2px; }
.hz-composer-btn[aria-expanded="true"], .abtn[aria-expanded="true"] { color: var(--hz-brand); background: var(--hz-composer-icon-hover-bg); }
.hz-composer-btn.has-attachments, .abtn.has-attachments { color: var(--hz-brand); }
.hz-composer-btn svg, .abtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }

/* SEND — a filled brand-blue circle (unified with every other primary action).
   Ready by default; :disabled shows the idle state (nothing to send yet). */
.hz-composer-send, .sbtn {
  width: var(--hz-composer-control-size); height: var(--hz-composer-control-size);
  border: none; border-radius: 50%;
  background: var(--hz-composer-send-bg); color: var(--hz-composer-send-fg);
  box-shadow: var(--hz-composer-send-shadow);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0; position: relative;
  transition: transform .18s var(--ease-spring), box-shadow .18s, background .15s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.hz-composer-send:hover, .sbtn:hover  { transform: scale(1.06); box-shadow: 0 6px 20px var(--hz-brand-glow); }
.hz-composer-send:active, .sbtn:active { transform: scale(.94); }
.hz-composer-send:focus-visible, .sbtn:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 2px; }
.hz-composer-send:disabled, .hz-composer-send[disabled],
.sbtn:disabled, .sbtn[disabled] {
  background: var(--hz-composer-send-idle-bg); color: var(--hz-composer-send-idle-fg);
  box-shadow: none; cursor: not-allowed; pointer-events: none;
}
.hz-composer-send svg, .sbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

/* One box size for every composer control: 40 on a fine pointer, 44 (tap floor)
   on coarse/touch. */
@media (pointer: coarse) {
  .hz-composer-btn, .abtn, .hz-composer-send, .sbtn {
    width: var(--hz-composer-control-size-touch); height: var(--hz-composer-control-size-touch);
  }
}

.iacts { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }

/* ── Shared composer STRUCTURE hooks ─────────────────────────────────────────
   Cross-surface marker classes (see public/js/composer.js) so the chat bar
   (.iz / .iacts) and the home hero (.cmh-composer / .cmh-toolbar) read as ONE
   component alongside the shared control atoms above:
     .hz-composer          → the composer container   (.iz | .cmh-composer)
     .hz-composer-tray     → the attachment tray       (#attachTray | #cmhAttachTray)
     .hz-composer-actions  → the actions cluster       (.iacts | .cmh-toolbar)
   Additive identity hooks only — per-surface layout stays in .iz / .cmh-composer
   (chat is a single inline row; home stacks tray · input · toolbar by design). */
.hz-composer, .hz-composer-tray, .hz-composer-actions { box-sizing: border-box; }

/* ═══════════════════════════════════════════════════════════
   TOASTS
═══════════════════════════════════════════════════════════ */
/* Toasts sit above every overlay — including the full-screen image viewer
   (image-addon.js, z-index 9999), whose own actions (Download, Share) answer
   with a toast that must be readable. A toast is brief (3–4 s) and may cover
   a corner control for that long; that is the trade for being seen. */
.tstack { position: fixed; top: calc(14px + var(--st)); inset-inline-end: 14px; z-index: 10000; display: flex; flex-direction: column; gap: 7px; pointer-events: none; max-width: 300px; width: calc(100vw - 28px); }
.toast { pointer-events: all; background: var(--surface); border: 1px solid var(--border-mid); border-radius: var(--hz-radius-14); padding: 12px 13px; box-shadow: var(--hz-toast-shadow, 0 12px 44px rgba(0,0,0,.65), 0 2px 8px rgba(0,0,0,.3)); display: flex; flex-direction: column; gap: 8px; animation: tin .22s var(--ease) both; }
.toast.out { animation: tout .18s var(--ease) both; }
.t-top { display: flex; align-items: center; gap: 9px; }
.t-ico { width: 30px; height: 30px; border-radius: var(--hz-radius-8); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.t-ico svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; }
.t-title { font-size: 13px; font-weight: 600; color: var(--t1); }
.t-sub   { font-size: 12px; color: var(--t2); margin-top: 1px; }
.t-sub code { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--p2p); background: var(--raised); padding: 1px 4px; border-radius: var(--hz-radius-2); }
.t-acts { display: flex; gap: 5px; }
.t-act  { flex: 1; padding: 5px 0; border: none; border-radius: var(--hz-radius-6); font-family: inherit; font-size: 12px; font-weight: 500; cursor: pointer; transition: all .13s; }
.t-act.acc { background: var(--p2p-soft); color: var(--p2p); border: 1px solid var(--p2p-border); }
.t-act.acc:hover { background: rgba(37,208,126,.2); }
.t-act.dec { background: var(--raised); color: var(--t2); border: 1px solid var(--border); }
.t-act.dec:hover { background: var(--hover); color: var(--t1); }
/* A notice that stays gets a ✕ (toast({ close: true })): a quiet 28px mark
   with a 44px touch target. */
.t-close { position: relative; align-self: flex-start; flex-shrink: 0; width: 28px; height: 28px; margin-block-start: -4px; margin-inline: auto -6px; padding: 0; border: none; border-radius: 50%; background: transparent; color: var(--t3); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .13s, color .13s; }
.t-close::after { content: ""; position: absolute; inset: -8px; }
.t-close:hover { background: var(--hover); color: var(--t1); }
.t-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.t-txt { min-width: 0; }
/* A text action (cls 'link'): read as the next line of the notice, under its
   words — not a button pair. */
.t-acts--links { padding-inline-start: 39px; }
.t-act.link { flex: none; padding: 2px 0; background: none; border: none; color: var(--accent-ink); font-size: 13px; font-weight: 600; text-align: start; }
.t-act.link:hover { text-decoration: underline; text-underline-offset: 3px; }
/* The welcome gift (home.js): a moment, not a status line — a larger mark
   and type, the words starting at the top beside it. */
.toast[data-type="gift"] .t-top { align-items: flex-start; gap: 12px; }
.toast[data-type="gift"] .t-ico { width: 40px; height: 40px; border-radius: var(--hz-radius-12); }
.toast[data-type="gift"] .t-ico svg { width: 20px; height: 20px; fill: #fff; stroke: none; }
.toast[data-type="gift"] .t-title { font-size: 15px; line-height: 1.3; }
.toast[data-type="gift"] .t-sub { font-size: 14px; line-height: 1.45; margin-top: 3px; }
.toast[data-type="gift"] .t-acts--links { padding-inline-start: 52px; margin-top: -2px; }
/* Wider screens: the welcome reads in three lines, not five. Phones (the
   max-width: 640px .tstack rule) keep notices spanning the screen. */
@media (min-width: 641px) {
  .tstack:has(> .toast[data-type="gift"]) { max-width: 380px; }
}

/* ═══════════════════════════════════════════════════════════
   MODALS
═══════════════════════════════════════════════════════════ */
/* .moverlay / .moverlay.open / .modal / .moverlay.open .modal are defined once,
   canonically, further below (the "Overlay"/"Modal card" block) — the earlier
   duplicate definitions here were fully superseded by source order and never
   rendered, so they were removed. */
.mh { display: flex; align-items: center; justify-content: space-between; padding: 20px 20px 0; }
.mt { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--t1); }
.mt svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.mt.p2t svg { stroke: var(--p2p); }
.mclose { width: 28px; height: 28px; border: none; background: var(--raised); color: var(--t2); border-radius: var(--hz-radius-6); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .13s; }
.mclose:hover { background: var(--hover); color: var(--t1); }
.mclose svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }
.mbody { overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.mbody::-webkit-scrollbar { width: 0; }
.mfoot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 7px; justify-content: flex-end; flex-shrink: 0; }

/* Form fields */
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld label { font-size: 10px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--t3); }
/* .fld form fields are the shared .hz-input atom (design-system/atoms.css),
   skinned by the app input register in :root. The bespoke .fld input/select/
   textarea rules + their [data-theme="light"] patches were removed in the
   Phase-3 field migration. */
select { color-scheme: dark; }
select option { background: #181830; color: var(--t1); }
.fld .hint { font-size: 11px; color: var(--t3); line-height: 1.5; }
.fld .hint code { font-family: 'JetBrains Mono', monospace; font-size: 11px; background: var(--raised); padding: 1px 4px; border-radius: var(--hz-radius-2); color: var(--t1); }
.frow { display: flex; gap: 7px; align-items: flex-end; }

/* Status rows */
.srow { display: flex; align-items: flex-start; gap: 7px; padding: 9px 11px; border-radius: var(--hz-radius-10); font-size: 13px; font-weight: 500; border: 1px solid transparent; }
.srow.ok { background: rgba(37,208,126,.06); border-color: rgba(37,208,126,.18); color: var(--p2p); }
.srow.er { background: rgba(244,115,115,.06); border-color: rgba(244,115,115,.18); color: var(--err); }
.srow.pe { background: rgba(248,183,74,.06); border-color: rgba(248,183,74,.18); color: var(--warn); }
.srow svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; flex-shrink: 0; margin-top: 1px; }

/* Buttons — the app's .btn family is now the shared .hz-btn atom
   (design-system/atoms.css) skinned by the app button register in :root above.
   The former bespoke .btn / .bp / .bsec / .bdng / .b2p blocks (and their
   [data-theme="light"] !important patches) were removed in the Phase-3 atom
   migration; .b2p had no markup and was dropped. Icon sizing for the atom's
   in-button SVGs (the app's only button-svg consumer) lives here: */
.hz-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* Peer ID panel */
.myid-panel { display: flex; align-items: center; gap: 10px; padding: 11px 13px; background: var(--raised); border: 1px solid var(--p2p-border); border-radius: var(--hz-radius-10); }
.myid-panel .lbl { font-size: 10px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--t3); white-space: nowrap; }
.myid-panel .val { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--p2p); font-weight: 500; word-break: break-all; }
.myid-panel .cpbtn { width: 26px; height: 26px; border: none; background: transparent; color: var(--t3); cursor: pointer; border-radius: var(--hz-radius-4); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .13s; }
.myid-panel .cpbtn:hover { background: var(--hover); color: var(--t1); }
.myid-panel .cpbtn svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; }

/* Peers list */
.plist { display: flex; flex-direction: column; gap: 4px; }
.pitem { display: flex; align-items: center; gap: 9px; padding: 8px 10px; background: var(--raised); border: 1px solid var(--border); border-radius: var(--hz-radius-10); }
.pdot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pdot.on { background: var(--p2p); animation: pulse 2s infinite; }
.pdot.off { background: var(--t3); }
.pnm { flex: 1; font-size: 13px; font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--t1); }
.ppid { font-size: 10px; color: var(--t3); font-family: 'JetBrains Mono', monospace; }
.pdel { width: 22px; height: 22px; border: none; background: transparent; color: var(--t3); cursor: pointer; border-radius: var(--hz-radius-4); display: flex; align-items: center; justify-content: center; transition: all .13s; flex-shrink: 0; }
.pdel:hover { background: rgba(244,115,115,.12); color: var(--err); }
.pdel svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.5; }

/* Slider */
.slw { display: flex; align-items: center; gap: 9px; }
.slw input[type=range] { flex: 1; -webkit-appearance: none; height: 3px; background: var(--hover); border-radius: var(--hz-radius-2); outline: none; cursor: pointer; }
.slw input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; box-shadow: 0 2px 6px var(--accent-glow); }
.slv { font-size: 12px; font-weight: 600; color: var(--accent); min-width: 28px; text-align: end; font-family: 'JetBrains Mono', monospace; }

/* LM Pill */
.lmpill { display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--hz-radius-pill); font-size: 10px; font-weight: 600; letter-spacing: .2px; cursor: pointer; transition: all .2s; border: 1px solid transparent; }
.lmpill.on   { color: var(--p2p); background: var(--p2p-soft); border-color: var(--p2p-border); }
.lmpill.off  { color: var(--t3); background: var(--raised); border-color: var(--border); }
.lmpill.wait { color: var(--warn); background: rgba(248,183,74,.08); border-color: rgba(248,183,74,.18); }
.lmpill .ld  { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.lmpill.on .ld { animation: pulse 2s infinite; }

/* Settings */
/* `bottom: 0` at every width: the phone's tab-bar clearance is the shared
   .hz-phone-panel rule's padding (≤640px), and ≥641px never had a tab bar. */
#settPanel { position: fixed; inset: 0; z-index: 70; background: var(--hz-surface-panel-settings, var(--void)); display: none; flex-direction: column; animation: slideInRight .25s var(--ease) both; }
#settPanel.show { display: flex; }
@media (min-width: 641px) {
  #settPanel { inset-inline-start: var(--sb); top: var(--tnav-h); bottom: 0; animation: none; }
  .sp-body { display: flex; flex-direction: column; align-items: center; padding: 0 24px 32px; }
  .sp-body > * { width: 100%; max-width: 580px; }
  /* (.sp-hdr's desktop 28px side padding is gone — the head is the shared
     .hz-panel-head, whose inset is --hz-panel-head-pad on every panel.) */
  /* image previews — the bubble media column is one token; the media bubble's
     own max-width follows from it (see the .bub.bub-media rule). */
  .im-img-wrap { max-width: min(340px, 60vw); }
  :root { --hz-bubble-media-width: min(260px, 50vw); }
  /* Toasts appear below the top nav */
  .tstack { top: calc(var(--tnav-h) + 14px); }
}
/* Layout comes from the shared .hz-panel-head (above); only the surface is
   Profile's own — the same frosted band the agents store and the chat list
   carry. The geometry this rule used to declare (its own padding, its own
   safe-area inset, its own 14px gap) and the fixed height that lived in
   store-trending.css are gone: one register describes every panel head now. */
.sp-hdr {
  background: var(--hz-surface-panelhdr, rgba(9,9,22,.92));
  backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
  -webkit-backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
  box-shadow: var(--hz-panelhdr-shadow, none);
}
/* .cs-hdr (agent-store header) is the same frosted panel-header surface as
   .sp-hdr/.mkt-hdr — it now reads --hz-surface-panelhdr on its canonical rule
   below; the earlier partial + dark-scoped-literal rules here were redundant. */
/* .sp-hdr .hz-btn--primary — REMOVED. It re-pointed the brand gradient for a
   Save button that the panel's autosave replaced; the head has carried only a
   title and the "Saving…/Saved" status ever since, and nothing injects a
   button into it (the settings addons append to #_settStarsCard and
   #_settGeneralCard, both in the body). A scoped override with no element
   under it is where the next head edit lands by accident. */
/* .sp-back / .sp-title — REMOVED. Profile owns a tab, so it is a root
   destination and carries no back control; its title is the shared
   .hz-panel-head-title. */
.sp-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; padding-bottom: 24px; }
.sp-section { padding: 0 18px; }
.sp-sect-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--t3); padding: 0 6px; margin-bottom: 10px; }
.sp-card { background: var(--surface); border: var(--hz-elevation-border, 1px solid var(--border-mid)); border-radius: var(--hz-radius-18); overflow: hidden; box-shadow: var(--hz-spcard-shadow, none); }
.sp-toggle-btn { width: 44px; height: 26px; border-radius: var(--hz-radius-12); border: none; background: var(--raised); cursor: pointer; position: relative; flex-shrink: 0; transition: background .2s; }
.sp-toggle-btn::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.sp-toggle-btn.on { background: var(--p2p); }
.sp-toggle-btn.on::after { transform: translateX(calc(18px * var(--hz-inline-dir, 1))); } /* knob travels toward inline-end: right in LTR, left in RTL */
.sp-row { display: flex; align-items: center; gap: 14px; padding: 14px 18px; min-height: 52px; border-bottom: 1px solid var(--border); transition: background .12s; }
/* A row that is an action: a real <button> (keyboard, screen readers) that
   looks exactly like the other rows. */
.sp-row-btn { width: 100%; margin: 0; background: none; border: 0; border-bottom: 1px solid var(--border); font: inherit; color: inherit; text-align: start; cursor: pointer; }
.sp-row-btn .sp-row-lbl, .sp-row-btn .sp-row-sub { display: block; }   /* spans: a button holds phrasing content only */
.sp-row:last-child { border-bottom: none; }
/* A row a card does not show right now (a feature this account lacks, a row
   that waits for data) is [hidden]: .sp-row's display:flex would outrank the
   UA rule. The divider is drawn under every row but the last one SHOWN — a row
   followed only by hidden ones closes the card. */
.sp-card > [hidden] { display: none; }
.sp-card > .sp-row:not(:has(~ :not([hidden]))) { border-bottom: none; }
.sp-row:hover { background: var(--hover); }
.sp-row-ic { width: 36px; height: 36px; border-radius: var(--hz-radius-10); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sp-row-ic svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sp-row-body { flex: 1; min-width: 0; }
.sp-row-lbl { font-size: 15px; font-weight: 500; color: var(--t1); }
.sp-row-sub { font-size: 12px; color: var(--t3); margin-top: 2px; }

/* Settings — profile hero */
.sp-profile-hero { display: flex; flex-direction: column; align-items: center; padding: 24px 20px 20px; gap: 10px; }
.sp-profile-hero-bg { display: none; }
.sp-profile-info { text-align: center; width: 100%; }
.sp-av-wrap { position: relative; z-index: 1; flex-shrink: 0; width: 72px; }
/* The Profile panel's own avatar (#settAv) — settings-addon paints only its
   background (the user's gradient) or mounts the photo; everything else is here. */
.sp-av { width: 72px; height: 72px; flex-shrink: 0; border-radius: var(--hz-radius-avatar); background: linear-gradient(135deg,var(--hz-brand),var(--hz-accent-cyan)); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; color: #fff; box-shadow: 0 8px 24px color-mix(in srgb, var(--hz-brand) 35%, transparent), 0 0 0 3px rgba(255,255,255,.08); }
.sp-profile-name { font-size: 20px; font-weight: 700; color: var(--t1); letter-spacing: -.3px; }
.sp-profile-handle { font-size: 13px; color: var(--t3); margin-top: 3px; font-family: 'JetBrains Mono', monospace; }
.sp-field-lbl { color: var(--t2); font-size: 14px; min-width: 72px; flex-shrink: 0; }
.sp-field-input { flex: 1; background: transparent; border: none; outline: none; padding: 0; font-family: inherit; font-size: 15px; color: var(--t1); text-align: end; min-width: 0; }
.sp-field-input::placeholder { color: var(--t3); }
.sp-field-value { flex: 1; text-align: end; color: var(--t2); font-size: 14px; font-family: 'JetBrains Mono', monospace; }
.sp-field-value.small { font-size: 11px; color: var(--t3); word-break: break-all; line-height: 1.5; max-width: 60%; }
.sp-end-section { margin-top: 22px; padding-bottom: calc(40px + var(--sb2)); }

/* Agent chips bar */
.ag-chips-bar, #agChips { padding: 8px 16px; gap: 5px; background: transparent; }
/* The composer's "/" menu is open (composer-commands.js): the chips rail and
   the voice picker step aside, so the menu sits on the composer's edge instead
   of floating over the thread — as Android's ChatScreen hides them while it
   picks. !important: both rows show and hide by an inline display. */
html.hz-cmd-open #agChips,
html.hz-cmd-open #vmVoicePicker { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   TAB BAR — phone only (≤640px), iOS "liquid glass"
   ─────────────────────────────────────────────────────────────
   Anatomy (index.html #mnav):

     .mnav            fixed, transparent layout row — owns position only
     └─ .mni          the glass CAPSULE, read left-to-right:
        └─ .nit ×4    Chats · AI Agents · AI Course · Settings

   Sections live together in one lens, four equal flex:1 slots — the Android
   app's bar, slot for slot. There is no New-chat button: on a phone the chat
   list IS the new chat, its composer docked at the foot (composer-host.js).
   The selected tab carries a tinted pill (the "lens") and the ONE tint
   colour, like a native tab bar; per-tab rainbow accents are gone.

   Every colour is a token (design-system/tokens.css), flipped per theme
   there — nothing in this block forks on [data-theme]: item states are the
   --hz-navitem-* register the ≥641px top nav reads too (one selected look on
   every device) and the glass surface is --hz-tabbar-*.

   Hidden here and laid out inside @media (max-width: 640px) below: ≥641px the
   top nav (#tnav) takes over — iPad, Android tablets, desktop and phones in
   landscape all land there.
═══════════════════════════════════════════════════════════ */
:root {
  --hz-tabbar-h:     60px;   /* capsule height (iOS 26: ~62pt)                 */
  /* Side inset scales with the phone: 12.8px on a 320px SE, ~16px on a 393px
     iPhone, capped at 20px — close to native on every width without starving
     the four tab slots on the narrowest one. */
  --hz-tabbar-inset: clamp(10px, 4vw, 20px);
  /* Lift — the distance from the layout-viewport bottom to the bar, declared
     on the phone .mnav rule as calc(var(--sb2) * .4 + 8px). A native floating
     tab bar sits INSIDE the home-indicator safe area (≈21pt up on a Face ID
     iPhone, not 34pt + a margin): that gives 21.6px there and 8px on a phone
     with no inset. Linear in --sb2, so --hz-nav-clear tracks it exactly. */
}
.mnav {
  display: none;
  position: fixed;
  /* NOTE: the tab bar is display:none here and only becomes visible inside
     @media (max-width: 640px), which declares its bottom/left/right. Any
     bottom-offset change (e.g. the cookie-consent clearance) belongs THERE,
     on the rule that actually renders — setting it here silently does nothing. */
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  /* The row is a layout box, not a surface: the corners outside the
     capsule's curves must let taps through to the content underneath. The
     capsule opts back in. */
  pointer-events: none;
}

/* ── The glass recipe (the capsule) ────────────────────────────────────── */
.mni {
  pointer-events: auto;
  position: relative;
  isolation: isolate;               /* keeps the ::before sheen under the content */
  background: var(--hz-tabbar-glass);
  border: 0.5px solid var(--hz-tabbar-rim);
  box-shadow: var(--hz-tabbar-shadow);
  /* 16px, softer than the 24px the old slab used: on a surface this small
     a lighter blur keeps the COLOUR of what scrolls underneath — the "liquid"
     read of iOS 26 glass — while still breaking up text. saturate() restores
     the vibrancy the blur averages away. */
  backdrop-filter: blur(16px) saturate(1.8);
  -webkit-backdrop-filter: blur(16px) saturate(1.8);
}
/* Specular sheen — the light a curved lens catches along its top edge. */
.mni::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--hz-tabbar-sheen);
  pointer-events: none;
  z-index: -1;
}

/* ── Capsule ───────────────────────────────────────────────────────────── */
.mni {
  flex: 1; min-width: 0;
  display: flex; align-items: stretch;
  height: var(--hz-tabbar-h);
  padding: 4px;
  border-radius: var(--hz-radius-pill);
}
.nit {
  /* min-width:0 lets a slot shrink below its label's intrinsic width, which is
     what makes the ellipsis on .nit > span reachable. Without it four equal
     flex children on a 320px phone would each refuse to go under their text
     width and push the bar into horizontal overflow. */
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px; padding: 0 2px;
  border: none; border-radius: var(--hz-radius-pill);
  background: transparent;
  color: var(--hz-navitem-ink); cursor: pointer; font-family: inherit;
  font-size: 10px; font-weight: 500; line-height: 1.2; letter-spacing: .01em;
  position: relative;
  isolation: isolate;               /* the lens (::before, z-index -1) paints under THIS slot's glyph */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
  transition: color .2s var(--ease);
}
/* Tab label. Direct child only — .nbdg (the unread badge) is a <div>, and this
   must never clamp it. One line always: a two-word label ("AI Agents",
   "AI Course") wrapping on a narrow phone would make that one slot taller than
   its neighbours and shove the icon row out of alignment. */
.nit > span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Sections with a nav destination but no slot on the phone tab bar (AI
   Files). They stay in the DOM as setNavActive / HzNav targets —
   see the #mnav comment in index.html — but never take a column. Declared
   after .nit so it wins on equal specificity, with no !important needed. */
.nit-offbar { display: none; }
/* The lens — the tinted pill behind the selected tab. Painted by the slot
   itself (not one shared, JS-positioned indicator), so it is correct on the
   first frame, for any number of slots, with no layout read. */
.nit::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: var(--hz-navitem-lens);
  opacity: 0;
  transform: scale(.86);
  transition: opacity .22s var(--ease), transform .32s var(--ease-spring), background-color .2s var(--ease);
  z-index: -1;
}
.nit.on { color: var(--hz-navitem-active); }
.nit.on::before { opacity: 1; transform: none; }
/* Press: the lens swells under the finger (on an inactive tab it appears
   faintly), the glyph dips — the same feedback a native tab gives. */
.nit:active::before { opacity: 1; transform: scale(1.04); transition-duration: .12s; }
.nit:not(.on):active::before { background: var(--hz-navitem-press); }
.nit svg {
  width: 24px; height: 24px; flex-shrink: 0;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .18s var(--ease-spring);
}
/* Selected glyph gets a soft tinted fill — the web stand-in for iOS swapping
   to the ".fill" SF Symbol — and a slightly firmer stroke. */
.nit.on svg { fill: currentColor; fill-opacity: .16; stroke-width: 2; }
.nit:active svg { transform: scale(.88); transition-duration: .07s; }
@media (hover: hover) and (pointer: fine) {
  .nit:not(.on):hover::before { opacity: 1; transform: none; background: var(--hz-navitem-press); }
}
/* Keyboard focus: a tint-coloured ring that follows the slot's pill radius
   and sits INSIDE the slot, so it never overlaps the neighbouring tab or the
   capsule rim. Scoped under .mni on purpose: the app-wide ring further down
   (`button:focus-visible, … [onclick]:focus-visible`, offset 2px OUTSIDE) is
   the same 0,2,0 specificity as `.nit:focus-visible` and later in the file,
   so an unscoped rule here silently loses to it — which is also how the old
   `outline: none` on this selector never actually took effect. */
.mni .nit:focus-visible {
  outline: 2px solid var(--hz-navitem-active); outline-offset: -2px;
  /* Re-asserted: the app-wide rule also sets `border-radius: inherit`, which
     would swap the slot's pill for its parent's radius while focused. */
  border-radius: var(--hz-radius-pill);
}

/* Unread badge — iOS count badge: system red capsule at the glyph's top-right
   corner. Anchored by its LEFT edge to the glyph (not its right edge to the
   slot), so a "99+" grows outward instead of back across the icon. */
.nbdg {
  position: absolute;
  top: calc(50% - 26px); inset-inline-start: calc(50% + 4px);
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--hz-radius-pill);
  background: var(--hz-tabbar-badge);
  color: #fff; font-size: 11px; font-weight: 600; line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 1;
}

/* ── Platform + preference fallbacks ───────────────────────────────────── */
/* No backdrop blur (older Android WebViews, Firefox < 103): a 56% fill with
   nothing blurred behind it is just a smudge over the list — go opaque. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .mni { background: var(--hz-tabbar-solid); }
}
/* The user asked the OS for less transparency: honour it the same way. */
@media (prefers-reduced-transparency: reduce) {
  .mni { background: var(--hz-tabbar-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  .mni { background: var(--hz-tabbar-solid); border-color: currentColor; }
  .nit { color: var(--t1); }
  .nit.on { color: var(--hz-navitem-active); }
}
@media (prefers-reduced-motion: reduce) {
  .nit, .nit::before, .nit svg { transition: none; }
  .nit:active::before { transform: none; }
  .nit:active svg { transform: none; }
}
/* Windows High Contrast / forced colours: glass, tints and shadows are all
   dropped by the UA, so draw the structure explicitly. */
@media (forced-colors: active) {
  .mni { border: 1px solid CanvasText; background: Canvas; }
  .nit.on { outline: 2px solid Highlight; outline-offset: -3px; }
  .nbdg { border: 1px solid CanvasText; }
}

/* Narrowest phones (iPhone SE 1st gen, small Androids — 320–359px): four
   slots cannot hold "AI-агенты" / "Настройки" at 10px with full padding.
   Trade a little of the bar height and the slot padding for label room
   rather than ellipsising a tab name — enough for the longest label in
   either locale. */
@media (max-width: 359px) {
  :root { --hz-tabbar-h: 56px; }
  .nit { padding: 0; letter-spacing: 0; }
}

/* Misc */
.proc-dots { display: inline-flex; gap: 3px; align-items: center; vertical-align: middle; margin-inline-start: 4px; }
.proc-dots span { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); display: inline-block; animation: td .9s infinite; }
.proc-dots span:nth-child(2) { animation-delay: .18s; }
.proc-dots span:nth-child(3) { animation-delay: .36s; }

/* Onboarding */
.ob { position: fixed; inset: 0; z-index: 999; background: var(--hz-surface-panel-onboard, var(--void)); display: flex; align-items: center; justify-content: center; padding: 24px; }
.ob.hidden { display: none; }
.ob.fade-out { animation: obOut .35s var(--ease) forwards; pointer-events: none; }
@keyframes obOut { to { opacity: 0; transform: scale(.97); } }
.ob-card { width: 100%; max-width: 400px; animation: obIn .45s cubic-bezier(.34,1.56,.64,1) both; background: var(--surface); border: var(--hz-elevation-border, 1px solid var(--border-mid)); border-radius: var(--hz-radius-24); padding: 36px 32px; box-shadow: var(--hz-obcard-shadow, 0 24px 80px rgba(0,0,0,.7)); }
@keyframes obIn { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
.ob-logo { width: 52px; height: 52px; background: var(--hz-action-gradient); border-radius: var(--hz-radius-16); display: flex; align-items: center; justify-content: center; margin: 0 auto 20px; box-shadow: 0 10px 32px var(--accent-glow); }
.ob-logo svg { width: 22px; height: 22px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; }
.ob-h   { font-size: 23px; font-weight: 700; letter-spacing: -.45px; text-align: center; margin-bottom: 7px; color: var(--t1); }
.ob-sub { font-size: 14px; color: var(--t2); text-align: center; line-height: 1.65; margin-bottom: 28px; }
/* The sign-up gift's amount (hz-signup-gift.js) in the app's sign-in window (login-addon.js, a sign-up):
   "50 ⭐ Stars" is never broken across lines. The marketing modal's twin is hz-auth.css. */
.hz-gift-amount { white-space: nowrap; }
.ob-btn { width: 100%; background: var(--hz-action-gradient); border: none; border-radius: var(--hz-radius-12); padding: 14px; font-family: inherit; font-size: 15px; font-weight: 600; color: #fff; cursor: pointer; transition: opacity .15s, transform .12s; box-shadow: 0 4px 20px var(--accent-glow); }
.ob-btn:hover { opacity: .9; transform: translateY(-1px); }
.ob-btn:active { transform: scale(.98); }
.ob-btn:disabled { opacity: .5; pointer-events: none; }

/* Invite landing */
.il-ov { position: fixed; inset: 0; z-index: 998; background: rgba(0,0,0,.78); backdrop-filter: blur(10px); display: none; align-items: center; justify-content: center; padding: 24px; }
.il-ov.show { display: flex; }
.il-card { background: var(--surface); border: 1px solid var(--border-mid); border-radius: var(--hz-radius-22); padding: 34px 30px; width: 100%; max-width: 370px; text-align: center; box-shadow: 0 32px 80px rgba(0,0,0,.65); animation: obIn .4s cubic-bezier(.34,1.56,.64,1) both; }
.il-av { width: 62px; height: 62px; border-radius: var(--hz-radius-avatar); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; margin: 0 auto 16px; }
.il-title { font-size: 19px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 7px; color: var(--t1); }
.il-sub { font-size: 13px; color: var(--t2); line-height: 1.6; margin-bottom: 8px; }
.il-pid { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--t3); margin-bottom: 22px; }
.il-accept { width: 100%; background: var(--hz-action-gradient); border: none; border-radius: var(--hz-radius-12); padding: 13px; font-family: inherit; font-size: 14px; font-weight: 600; color: #fff; cursor: pointer; box-shadow: 0 4px 16px var(--accent-glow); margin-bottom: 9px; transition: opacity .15s; }
.il-accept:hover { opacity: .9; }
/* The fill is the action blue in both themes — NOT --out, whose legacy token
   (--hz-bubble-out) turns the light chat-bubble green. Light only calms the
   glow on paper (no !important). */
[data-theme="light"] .il-accept {
  box-shadow: 0 2px 10px color-mix(in srgb, var(--hz-blue-action) 28%, transparent);
}
.il-skip { width: 100%; background: transparent; border: 1.5px solid var(--border-mid); color: var(--t2); border-radius: var(--hz-radius-12); padding: 12px; font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: all .15s; }
.il-skip:hover { color: var(--t1); background: var(--raised); }

/* ═══════════════════════════════════════════════════════════
   MARKDOWN — HzMd strict subset per docs/markdown-subset.md §1–§2
   Rules below cover exactly what HzMd.render emits:
   headings (h1–h6), paragraphs, lists (ul/ol), thematic breaks (hr),
   inline code, fenced code, strong, em, links (GFM tables keep the browser's
   table defaults).
   Out-of-scope constructs (blockquotes, checklists, spoilers, strikethrough)
   are handled as literal text by the renderer and need no CSS.
═══════════════════════════════════════════════════════════ */
.md { line-height: 1.65; word-break: break-word; }
.md p { margin: 0 0 .55em; }
.md p:last-child { margin-bottom: 0; }
.md code { font-family: 'JetBrains Mono', monospace; font-size: .82em; padding: 1px 5px; border-radius: var(--hz-radius-4); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.08); }
.mg.out .bub .md code { background: rgba(0,0,0,.2); border-color: rgba(0,0,0,.14); }
.md pre { margin: .6em 0; border-radius: var(--hz-radius-10); overflow: hidden; }
.md pre code { display: block; padding: 11px 14px; background: #090916; border: 1px solid rgba(255,255,255,.08); border-radius: var(--hz-radius-10); font-size: 12px; line-height: 1.65; color: #C8C6E0; overflow-x: auto; white-space: pre; }
.mg.out .bub .md pre code { background: rgba(0,0,0,.32); border-color: rgba(0,0,0,.22); color: #E8E8F8; }
.md-code-wrap { position: relative; direction: ltr; } /* code + its lang tag / copy chrome stay LTR in every UI language (atoms.css §2) */
.md-code-lang { position: absolute; top: 8px; inset-inline-end: 10px; font-family: 'JetBrains Mono', monospace; font-size: 10px; color: rgba(255,255,255,.28); letter-spacing: .05em; text-transform: lowercase; pointer-events: none; }
.md-copy { position: absolute; top: 6px; inset-inline-end: 10px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); border-radius: var(--hz-radius-6); color: rgba(255,255,255,.4); font-size: 10px; padding: 2px 8px; cursor: pointer; transition: all .15s; font-family: 'Plus Jakarta Sans', sans-serif; display: none; }
.md-code-wrap:hover .md-copy { display: block; }
.md-copy:hover { background: rgba(255,255,255,.14); color: #fff; }
.md-copy.ok { color: var(--p2p); border-color: var(--p2p-border); }
.md ul, .md ol { margin: .4em 0; padding-inline-start: 1.4em; }
.md li { margin: .18em 0; padding-inline-start: .15em; }
.md ul li::marker { color: var(--accent); }
.mg.out .bub .md ul li::marker { color: rgba(255,255,255,.7); }
.md ol { list-style: decimal; }
.md ol li::marker { color: var(--accent); font-weight: 600; font-size: .9em; }
/* Heading steps are spaced enough to read as headings, not just bold body:
   a bold word (700, 1em) must not look the same as an h3. */
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { font-weight: 700; line-height: 1.3; letter-spacing: -.01em; margin: .8em 0 .3em; }
.md h1 { font-size: 1.45em; }
.md h2 { font-size: 1.28em; }
.md h3 { font-size: 1.16em; }
.md h4 { font-size: 1.08em; }
.md h5 { font-size: 1.02em; }
.md h6 { font-size: 1em; color: var(--t2); }
.md h1:first-child, .md h2:first-child, .md h3:first-child, .md h4:first-child, .md h5:first-child, .md h6:first-child { margin-top: 0; }
.md h1:last-child, .md h2:last-child, .md h3:last-child, .md h4:last-child, .md h5:last-child, .md h6:last-child { margin-bottom: 0; }
/* A section divider: a hairline with a heading's breathing room above and below. */
.md hr { border: 0; border-top: 1px solid var(--hz-border); margin: .9em 0; }
.md hr:first-child { margin-top: 0; }
.md hr:last-child { margin-bottom: 0; }
.mg.out .bub .md hr { border-top-color: rgba(255,255,255,.3); }
.md strong { font-weight: 700; }
.md em { font-style: italic; color: var(--t2); }
.mg.out .bub .md em { color: rgba(255,255,255,.8); }
.md a { color: var(--accent); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--hz-brand) 35%, transparent); transition: border-color .13s; }
.md a:hover { border-bottom-color: var(--accent); }
.mg.out .bub .md a { color: #fff; border-bottom-color: rgba(255,255,255,.4); }
.ai-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-2); margin-bottom: 4px; }
.ai-badge svg { width: 9px; height: 9px; }
.bub-orig { font-size: 11px; margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.15); cursor: pointer; }
.bub-orig-lbl { display: flex; align-items: center; gap: 4px; font-size: 10px; color: rgba(255,255,255,.5); font-weight: 500; margin-bottom: 3px; }
.bub-orig-lbl svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform .15s; }
.bub-orig.open .bub-orig-lbl svg { transform: rotate(90deg); }
.bub-orig-txt { display: none; font-style: italic; color: rgba(255,255,255,.6); }
.bub-orig.open .bub-orig-txt { display: block; }

/* Empty state */


/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════ */
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(.78); } }
@keyframes msgIn { 0% { opacity: 0; transform: translateY(9px) scale(.97); } 60% { opacity: 1; transform: translateY(-1px) scale(1.005); } 100% { opacity: 1; transform: none; } }
/* Direction-aware motion: X offsets × --hz-inline-dir (1 LTR, -1 RTL — tokens.css), so an
   incoming message still arrives from its own (start) side, and toasts / panels still
   arrive from the end edge, in Arabic. One keyframe set serves both directions. */
@keyframes msgInLeft { 0% { opacity: 0; transform: translateX(calc(-8px * var(--hz-inline-dir, 1))) scale(.97); } 60% { opacity: 1; transform: translateX(calc(1px * var(--hz-inline-dir, 1))) scale(1.005); } 100% { opacity: 1; transform: none; } }
@keyframes fi { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes mi { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes tin  { from { opacity: 0; transform: translateX(calc(20px * var(--hz-inline-dir, 1))) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes tout { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(calc(20px * var(--hz-inline-dir, 1))); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(calc(18px * var(--hz-inline-dir, 1))); } to { opacity: 1; transform: none; } }
@keyframes agPop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }

.mg.new.out { animation: msgIn     .24s cubic-bezier(.34,1.4,.64,1) both; }
.mg.new.in  { animation: msgInLeft .24s cubic-bezier(.34,1.4,.64,1) both; }
.mg.new.ag  { animation: msgInLeft .24s cubic-bezier(.34,1.4,.64,1) both; }
.cm  { animation: fi .28s .04s var(--ease) both; }
.sb  { animation: fi .30s var(--ease) both; }

/* ═══════════════════════════════════════════════════════════
   DESKTOP TOP NAVIGATION
═══════════════════════════════════════════════════════════ */
.tnav {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--tnav-h);
  /* Surface = the --hz-nav-* register, flipped per theme in tokens.css (the
     light theme used to override all of this with raw values below). */
  background: var(--mnav-bg);
  background-image: var(--hz-nav-glow);
  border-bottom: 1px solid var(--mnav-border);
  box-shadow: var(--hz-nav-shadow);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  z-index: 200;
  align-items: center;
  padding: 0 16px;
}

/* ── Brand ──────────────────────────────────────────────── */
.tnav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding-block: 5px; padding-inline: 4px 10px;
  border-radius: var(--hz-radius-12);
  cursor: pointer;
  color: inherit;
  font: inherit;
  flex-shrink: 0;
  transition: background .15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.tnav-brand:hover  { background: var(--hover); }
.tnav-brand:active { transform: scale(.97); }

.tnav-mark {
  width: 28px; height: 28px;
  border-radius: var(--hz-radius-8);
  overflow: hidden;
  flex-shrink: 0;
}
.tnav-mark img { width: 28px; height: 28px; display: block; object-fit: cover; }

.tnav-name {           /* wrapper + colour hook for the .hz-wordmark atom */
  display: inline-block;
  height: 14px;
  color: var(--t1);
}

/* ── Navigation tabs — flex:1 centre column, naturally avoids brand/right ── */
.tnav-tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
/* The tabs themselves (role="tablist"): one row, spaced like the group, so a
   white-label's partner link can sit beside them in the same menu without
   being a child of the tablist. */
.tnav-tablist {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ── Right column: plan pill + login button ────────────────────────────── */
.tnav-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
  /* margin-left:auto is a defensive guard: with .tnav-tabs{flex:1} it resolves
     to 0 and has no effect; if flex:1 is ever removed it keeps the right
     column anchored to the right edge without needing justify-content changes. */
  margin-inline-start: auto;
}

.tnit {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 15px;
  border: none;
  border-radius: var(--hz-radius-pill);
  background: transparent;
  /* Item states are the --hz-navitem-* register the phone tab bar reads too:
     the same ink, the same ONE tint and the same lens on every device. */
  color: var(--hz-navitem-ink);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.01em;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;   /* an item may be a link (a white-label's partner site) */
  transition: background .14s var(--ease), color .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
@media (hover: hover) and (pointer: fine) {
  .tnit:not(.on):hover { background: var(--hz-navitem-press); }
}
.tnit:active { transform: scale(.96); transition-duration: .07s; }

.tnit svg {
  width: 15px; height: 15px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .18s var(--ease-spring);
}
.tnit:active svg { transform: scale(.85); transition-duration: .07s; }

/* Selected — the lens + the one tint, exactly as on the phone tab bar. One
   class rule, not a list of ids: a new section is selected-styled for free.
   Weight stays 500 so the label never changes width when it is selected. */
.tnit.on { background: var(--hz-navitem-lens); color: var(--hz-navitem-active); }

/* Feed: web mobile + Telegram. The Feed is a tab of the phone bar (#nFeed) on
   every web client, but of this top nav only inside the Telegram Mini App
   (<html class="hz-tg">, set by tg-boot.js before first paint) — a desktop
   browser's top nav carries no Feed tab (index.html, the #mnav note). The
   flag's own rule (lib/feature-bootstrap.js) still hides both when it is off. */
html:not(.hz-tg) #tnFeed { display: none; }

/* Keyboard focus — the phone tab bar's ring: the tint, inside the pill.
   Scoped under .tnav because the app-wide `[onclick]:focus-visible` ring
   (violet, offset OUTSIDE) is the same 0,2,0 specificity as
   `.tnit:focus-visible` and later in the file, so the unscoped rule this
   replaces never actually applied. */
.tnav .tnit:focus-visible {
  outline: 2px solid var(--hz-navitem-active);
  outline-offset: -2px;
  /* Re-asserted: the app-wide rule's `border-radius: inherit` would take the
     tab strip's square corners, drawing a rectangular ring around a pill. */
  border-radius: var(--hz-radius-pill);
}

/* White-label: the partner's site is a menu item like the tabs (partnerLink,
   painted by partners/whitelabel-shell.js) — the .tnit look and nothing of its
   own. One guard, invisible at any ordinary label length: a label too long for
   the bar is cut with "…", and the menu keeps clear of the logo, rather than
   overlap it. */
.hz-wl-partner-link { min-width: 0; }
.hz-wl-partner-link span { overflow: hidden; text-overflow: ellipsis; }
html[data-wl] .tnav-tabs { padding-inline: var(--hz-space-3); }


/* ── Unified plan + stars pill (.npp) ──────────────────────────────────
   Two sections in one pill: plan tier (blue) | stars balance (amber).
   Tier half is hidden until JS sets its text — no empty-badge flash.
   Only the stars half is interactive (opens the buy modal).
────────────────────────────────────────────────────────────────────── */
.npp {
  display: inline-flex; align-items: stretch;
  height: 30px; border-radius: var(--hz-radius-pill); overflow: hidden;
  border: 1.5px solid color-mix(in srgb, var(--hz-brand) 38%, transparent);
  flex-shrink: 0; margin-inline-start: 0;
}
/* Mobile: taller touch target (hbtns gap handles spacing) */
@media (max-width: 640px) {
  .npp { height: 34px; }
}
/* Tier label — hidden until JS writes text, then slides in */
.npp-tier {
  display: none;
  padding-block: 0; padding-inline: 13px 10px;
  background: color-mix(in srgb, var(--hz-brand) 14%, transparent);
  color: rgba(140,190,255,.95);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  align-items: center; white-space: nowrap;
  border-inline-end: 1px solid color-mix(in srgb, var(--hz-brand) 22%, transparent);
}
.npp-tier:not(:empty) { display: flex; }
/* The plan half is a button for everyone (subscription-addon.js
   _updateHeaderTierCta): free → choose a plan, paid → your plan. */
.npp-tier[role="button"] {
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .15s, transform .1s;
}
.npp:not(.npp--cta) .npp-tier[role="button"]:hover { background: color-mix(in srgb, var(--hz-brand) 24%, transparent); }
.npp-tier[role="button"]:active { transform: scale(.96); }
/* Focus rings sit INSIDE each half: the pill clips its rounded corners
   (overflow: hidden), which cut an outside ring into a stray crescent. */
.npp-tier[role="button"]:focus-visible,
.npp-stars:focus-visible { outline: 2px solid var(--hz-brand-2); outline-offset: -2px; }
/* Stars button — always visible, clickable */
.npp-stars {
  display: inline-flex; align-items: center; gap: 5px;
  padding-block: 0; padding-inline: 9px 13px;
  background: rgba(255,178,36,.10);
  color: var(--hz-amber-600);
  border: none; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
  letter-spacing: -.01em; white-space: nowrap;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.npp-stars svg { flex-shrink: 0; color: #F5A623; }
/* The credit glyph: a star on the web, a bolt in the Telegram Mini App, where
   Harizma credits are "energy" so they never look like the Telegram Stars the
   person pays with (i18n.js HOST_MESSAGES). html.hz-tg is set in <head> by
   tg-boot.js, so the right glyph is the first one painted. */
.hz-cur--energy { display: none; }
html.hz-tg .hz-cur--star { display: none; }
html.hz-tg .hz-cur--energy { display: inline-block; }

/* ── Balance notice in a chat (msg-renderer.js starsNoticeHtml) ─────────────
   A reply blocked for the balance: what happened, and the button that fixes
   it (Top up → the Balance sheet; Get Plus → the Plus sheet). */
.hz-stars-notice { display: flex; flex-direction: column; gap: 6px; padding: 2px 0; }
.hz-stars-notice-title { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--t1); line-height: 1.35; }
.hz-stars-notice-ico { display: inline-flex; width: 18px; height: 18px; flex-shrink: 0; color: var(--hz-plus-hue-stars, #FFB30E); }
.hz-stars-notice-ico svg { width: 100%; height: 100%; }
.hz-stars-notice-text { color: var(--t2); font-size: 14px; line-height: 1.45; }
.hz-stars-notice-btn {
  align-self: flex-start; margin-top: 4px; min-height: 40px; padding: 0 18px;
  border: 0; border-radius: var(--hz-radius-pill, 999px);
  background: var(--hz-blue-action); color: var(--hz-text-onbrand, #fff);   /* 5.9:1 in both themes */
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.hz-stars-notice-btn:hover { filter: brightness(1.08); }
.hz-stars-notice-btn:focus-visible { outline: 2px solid var(--hz-brand-2); outline-offset: 2px; border-radius: var(--hz-radius-pill, 999px); }
/* The second way out (invite a friend): a quiet ghost beside the top-up. */
.hz-stars-notice-btn.hz-stars-notice-btn--ghost,
[data-theme="light"] .hz-stars-notice-btn.hz-stars-notice-btn--ghost {
  margin-top: 0; background: transparent; color: var(--t1);
  box-shadow: inset 0 0 0 1px var(--hz-border-strong);
}
.hz-stars-notice-btn.hz-stars-notice-btn--ghost:hover { filter: none; background: var(--hz-invite-tint); }
/* The in-chat Plus suggestion (subscription-addon.js _nudgeHtml): the same
   notice with a price line and two ways out side by side. */
.hz-stars-notice-offer { color: var(--t1); font-size: 14px; font-weight: 600; line-height: 1.45; }
.hz-stars-notice-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.hz-stars-notice-acts .hz-stars-notice-btn { margin-top: 0; }
.npp-stars:hover  { background: rgba(255,178,36,.20); }
.npp-stars:active { transform: scale(.96); }

/* ── Profile button (.hz-me) ─────────────────────────────────────────────
   The member's own avatar beside the plan pill — the top nav's right column
   (#tnProfileBtn) and the phone chat list's head (#sbProfileBtn). It opens
   their public profile (nav-bar.js onNavProfile); profile-button-addon.js
   paints the avatar and shows the button once a signed-in person is known.
   Sized to the pill it sits beside and ringed with the pill's own brand edge,
   so the two read as one account cluster. While their profile is on screen
   (.on) the ring takes the nav's selected tint — the same "you are here" a
   selected tab wears. The button is the tap box; .hz-me-av is the paint. */
.hz-me {
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
  border: none;
  border-radius: var(--hz-radius-avatar);
  background: transparent;
  color: var(--hz-text-onbrand);
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hz-me[hidden] { display: none; }
.hz-me-av {
  width: var(--hz-nav-me-size); height: var(--hz-nav-me-size);
  border-radius: var(--hz-radius-avatar);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 0 0 1.5px var(--hz-nav-me-ring);
  transition: box-shadow .15s var(--ease), transform .1s var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .hz-me:not(.on):hover .hz-me-av { box-shadow: 0 0 0 2px var(--hz-nav-me-ring); }
}
.hz-me:active .hz-me-av { transform: scale(.94); }
.hz-me.on .hz-me-av { box-shadow: 0 0 0 2px var(--hz-navitem-active); }
/* The app-wide focus ring (further down) takes `border-radius: inherit` —
   the square corners of the row it sits in. A round control keeps its circle. */
button.hz-me:focus-visible { border-radius: var(--hz-radius-avatar); }
/* Phone: the pill is 34px there, so is the avatar. After the base rule on
   purpose — same specificity, so source order decides. */
@media (max-width: 640px) {
  .hz-me-av { width: var(--hz-nav-me-size-phone); height: var(--hz-nav-me-size-phone); font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .hz-me-av { transition: none; }
  .hz-me:active .hz-me-av { transform: none; }
}

/* ── Full-width New Chat button in sidebar (desktop only) ── */
.sb-ncb {
  display: none; /* enabled in desktop breakpoint below */
  width: 100%; height: 40px; flex-shrink: 0;
  /* The primary nav action — --hz-nav-action: the tint blue as a solid fill
     that holds its white label at 5.9:1. */
  background: var(--hz-nav-action);
  color: #fff;
  border: none; border-radius: var(--hz-radius-12);
  font-family: inherit; font-size: 14px; font-weight: 600;
  letter-spacing: -.1px;
  cursor: pointer;
  align-items: center; justify-content: center; gap: 7px;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.sb-ncb svg { stroke: currentColor; flex-shrink: 0; }
.sb-ncb:hover  { filter: brightness(1.06); }
.sb-ncb:active { transform: scale(.98); }

/* ── Desktop breakpoint ──────────────────────────────────────────────────── */
@media (min-width: 641px) {
  .tnav      { display: flex; }
  /* Sidebar: brand row hidden entirely (stars moved to top nav, + replaced by
     sb-ncb), so its head reclaims the space the row was holding. Deliberately
     NOT shared with .cs-hdr: the store keeps its back button and title here,
     so it keeps the row and the inset that goes above it. */
  .sb-top    { display: none; }
  .sb-head   { padding-top: 6px; gap: 8px; }
  /* Full-width New Chat button visible on desktop */
  .sb-ncb    { display: inline-flex; }
}

/* ── Compact tablet (641–899 px) — icons-only nav tabs ──────────────────────
   On narrow tablets (iPad Mini, iPad portrait) the 5 text-labelled tabs are
   too wide to centre between brand and right pill without risk of overlap.
   Hiding the text labels and tightening padding keeps tabs clearly readable
   and comfortably spaced on any iPad or small-screen tablet.
   Text labels re-appear at ≥900px where there is room for the full layout.
──────────────────────────────────────────────────────────────────────────── */
@media (min-width: 641px) and (max-width: 899px) {
  .tnit span  { display: none; }
  .tnit       { padding: 6px 11px; }
}
/* ── White-label: a background image behind the top of the page ─────────────
   (navBackground — partners/whitelabel-shell.js sets <html data-wl-backdrop>
   and, in the DARK theme only, the image tokens: --hz-wl-backdrop (the bar),
   --hz-wl-backdrop-surface / -void (the image under a fade into that surface
   colour), --hz-wl-backdrop-h (its height at the page's width) and
   --hz-wl-backdrop-edge (the bar's border).)
   The image is TALLER than the bar: it runs from the top of the page, under
   the bar, down into the sidebar and the main column. Each surface under it is
   opaque, so each paints the same image, sized to the viewport and shifted by
   its own offset from the viewport's top-left corner — one continuous picture;
   the fade takes its lower half into the surface's colour, so it never ends in
   a seam. Where a token is unset (the light theme) every surface keeps exactly
   what it paints today — no theme fork here. */
@media (min-width: 641px) {
  html[data-wl-backdrop] :is(.tnav, .sb, .cm, #cmHome, #cmStore, #cmFeed) {
    background-repeat: no-repeat;
    background-size: 100vw var(--hz-wl-backdrop-h);
    background-position: var(--hz-wl-backdrop-x, 0px) var(--hz-wl-backdrop-y, 0px);
  }
  html[data-wl-backdrop] .tnav {
    background-image: var(--hz-wl-backdrop, var(--hz-nav-glow));
    border-bottom-color: var(--hz-wl-backdrop-edge, var(--mnav-border));   /* bar and page: one surface */
  }
  html[data-wl-backdrop] .sb {
    background-image: var(--hz-wl-backdrop-surface, none);
    --hz-wl-backdrop-y: calc(-1 * var(--tnav-h));
  }
  /* The main column's panels fill it, so they inherit its offset. */
  html[data-wl-backdrop] .cm {
    --hz-wl-backdrop-x: calc(-1 * var(--sb));
    --hz-wl-backdrop-y: calc(-1 * var(--tnav-h));
  }
  html[data-wl-backdrop] body.anon-mode .cm { --hz-wl-backdrop-x: 0px; }   /* no sidebar */
  html[data-wl-backdrop] :is(.cm, #cmHome, #cmFeed) { background-image: var(--hz-wl-backdrop-void, none); }
  html[data-wl-backdrop] #cmStore { background-image: var(--hz-wl-backdrop-surface, none); }
}

/* A white-labelled menu with the partner's item (html[data-wl-link]) is one
   item longer, beside a wider co-brand logo: the whole menu goes compact the
   same way, up to 1023px — every item shows its label, or none does. */
@media (min-width: 900px) and (max-width: 1023px) {
  html[data-wl-link] .tnit span  { display: none; }
  html[data-wl-link] .tnit       { padding: 6px 11px; }
}

/* ── Light mode ─────────────────────────────────────────── */
/* Same preference handling as the phone tab bar. Forced colours strip the
   lens (a background), which would leave the selected item unmarked. */
@media (prefers-reduced-motion: reduce) {
  .tnit, .tnit svg { transition: none; }
  .tnit:active, .tnit:active svg { transform: none; }
}
@media (forced-colors: active) {
  .tnit.on { outline: 2px solid Highlight; outline-offset: -2px; }
}

/* .tnav / .tnav-name / .tnit light overrides — REMOVED. The surface, the
   ink, the lens and the tint are tokens that flip in tokens.css, so the top
   nav has no theme fork left (and cannot drift from the tab bar again). */
[data-theme="light"] .npp            { border-color: color-mix(in srgb, var(--hz-brand) 35%, transparent); }
[data-theme="light"] .npp-tier       { background: color-mix(in srgb, var(--hz-brand) 10%, transparent); color: var(--hz-brand-deep); border-inline-end-color: color-mix(in srgb, var(--hz-brand) 20%, transparent); }
[data-theme="light"] .npp:not(.npp--cta) .npp-tier[role="button"]:hover { background: color-mix(in srgb, var(--hz-brand) 18%, transparent); }
[data-theme="light"] .npp-stars      { background: rgba(255,178,36,.09); color: #B06B00; }
[data-theme="light"] .npp-stars svg  { color: #E89400; }
[data-theme="light"] .npp-stars:hover { background: rgba(255,178,36,.18); }

/* ── "Plus" CTA (.npp--cta) ─────────────────────────────────────────────
   Free tier only: subscription-addon adds .npp--cta to the pill once the tier
   is resolved (subscribers never get it, so nothing flashes for them). The
   label keeps being a plain textContent written by subscription-addon/i18n.
   Look: the tier half is a solid tinted button in the Plus accent — no
   gradient text, no glow, no motion: it reads as a control because it is
   filled, not because it shimmers. Colours are the Plus tokens (tokens.css),
   themed there, so no light-theme rule is needed here.
────────────────────────────────────────────────────────────────────── */
.npp.npp--cta { border-color: var(--hz-plus-border); }
.npp.npp--cta .npp-tier {
  padding-block: 0; padding-inline: 13px 11px;
  background: var(--hz-plus-soft);
  color: var(--hz-plus-ink);
  border-inline-end-color: var(--hz-plus-border);
  user-select: none; -webkit-user-select: none;
  transition: background-color var(--hz-dur-fast) var(--hz-ease), transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.npp.npp--cta .npp-tier:hover,
.npp.npp--cta .npp-tier:focus-visible { background: var(--hz-plus-soft-hover); }
@media (prefers-reduced-motion: reduce) {
  .npp-tier[role="button"], .npp.npp--cta .npp-tier { transition: none; }
  .npp-tier[role="button"]:active { transform: none; }
}
@media (forced-colors: active) {
  .npp.npp--cta .npp-tier { background: ButtonFace; color: ButtonText; }
}

/* ── Desktop tnav login button (guests only) ──────────────────────────
   Positioned absolutely at the right edge of tnav, mirroring how
   tnav-tabs is centred absolutely. Visibility driven by
   _homeUpdateToprow() via the hidden attribute — same logic as the
   mobile toprow, so the two are always in sync.
─────────────────────────────────────────────────────────────────────── */
.tnav-login-btn {
  display: none;               /* hidden by default; shown only on desktop */
  align-items: center;
  flex-shrink: 0;
  padding: 6px 18px;
  height: 34px;
  background: var(--raised);
  border: 1.5px solid var(--border-mid);
  border-radius: var(--hz-radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  cursor: pointer;
  white-space: nowrap;
  transition: background .14s, border-color .14s;
  -webkit-tap-highlight-color: transparent;
}
/* Only show on desktop (tnav is display:none on mobile anyway, but be explicit) */
@media (min-width: 641px) {
  .tnav-login-btn:not([hidden]) { display: flex; }
}
.tnav-login-btn:hover  { background: var(--hover); border-color: color-mix(in srgb, var(--hz-brand) 45%, transparent); }
.tnav-login-btn:active { opacity: .85; }
[data-theme="light"] .tnav-login-btn { border-color: rgba(0,0,0,.13); }

/* ═══════════════════════════════════════════════════════════
   MOBILE ≤640px
═══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  :root {
    --sb: 100vw; --fh: 165px;
    /* Tab-bar clearance, minus the safe-area term --hz-nav-clear adds itself:
       the bar (60) + its base lift (8) + 8px so content never kisses the glass. */
    --nh: calc(var(--hz-tabbar-h) + 16px);
  }

  /* ── The one way a full-screen phone panel clears the tab bar ────────────
     The tab bar is a floating glass capsule. Glass only reads as glass when
     the screen's CONTENT moves underneath it — so a panel must not stop its
     content above the bar.

     History, so neither mistake comes back:
       1. Panels ended their box above the bar (`bottom: var(--hz-nav-clear)`).
          The body backdrop showed through the strip — a white gash in light,
          and behind the keyboard an empty band.
       2. The fix padded the PANEL instead (`padding-bottom: var(--hz-nav-clear)`).
          That painted the strip, but with the panel's flat background: every
          scroller still stopped at a hard line above the bar, and the bar sat
          on a grey shelf with nothing behind its glass.

     Now: the panel fills the viewport and reserves NOTHING. Its scroller
     (.hz-panel-scroll) runs to the bottom edge, under the glass, and reserves
     the bar's clearance at the END OF ITS CONTENT — a spacer after the last
     item plus scroll-padding — so rows glide under the bar while scrolling and
     the last one still comes to rest above it.

     A panel with a fixed action footer (.hz-panel-foot — the AI Course's
     «Далее») floats that footer too: frosted like the panel heads, pinned to
     the bottom, its buttons lifted clear of the bar. The panel's scroller then
     reserves the footer's measured height (--hz-panel-foot-h, published by the
     panel's addon) instead of the bar's alone.

     --hz-nav-clear still collapses to 0 under html.kb-open (the bar is behind
     the keyboard), so every reservation below collapses with it.

     Opt in with the classes; do not re-declare `bottom` on a panel. */
  .hz-phone-panel {
    bottom: 0;
    --hz-panel-reserve: max(var(--hz-nav-clear), var(--hz-panel-foot-h, 0px));
  }
  .hz-phone-panel .hz-panel-scroll { scroll-padding-bottom: var(--hz-panel-reserve); }
  .hz-phone-panel .hz-panel-scroll::after {
    content: '';
    display: block;
    height: var(--hz-panel-reserve);
    /* A flex scroller (the chat list's #sbScroll) would otherwise shrink an
       empty box to nothing the moment its content overflows. */
    flex: none;
    pointer-events: none;
  }
  .hz-phone-panel .hz-panel-foot {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
    padding-bottom: calc(10px + var(--hz-nav-clear));
    background: var(--hz-surface-panelhdr, rgba(9,9,22,.92));
    backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
    -webkit-backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
  }

  .sb { position: fixed; inset: 0; width: 100%; min-width: 100%; border-inline-end: none; z-index: 50; }

  /* ── The phone's screen stack: the chat list stays under what is pushed ──
     A chat, Home or a section opens OVER the chat list (#cm.show, z-index
     above #sb) and the list is marked `.hide`. Hidden means out of sight, out
     of the accessibility tree, out of tab order and untouchable — NOT out of
     the layout:

       • The list stays rendered while the incoming screen makes its entrance
         (slideInRight, --hz-screen-push long), so the screen slides and fades
         in OVER the list instead of over an empty backdrop; the list goes
         invisible once it is fully covered. `visibility` is the one property
         that can wait for that: it transitions discretely at the end of the
         delay, on every engine, with no script and no timer.
       • Back is instant. The list was never torn down, so revealing it is a
         paint: no style and layout of every row from scratch, no avatar and
         story picture decoded again, its scroll position kept. As
         `display: none` it was rebuilt on every Back — and its `fi` entrance
         replayed from opacity 0, which goBack() then had to fight (the
         override it used restarted the very fade it meant to skip).
       • A hidden screen does no work: its looping animations (the online
         dots' pulse) are paused, as they were when the list was not rendered.

     Removing `.hide` reveals at once (the base state has no delay); re-adding
     it inside the delay just restarts the wait. Everything that asks whether
     the list is the screen reads the class (composer-host.js listVisible,
     focus-addon.js _shownPanel), never the box. */
  :root { --hz-screen-push: .25s; }
  .sb.hide {
    visibility: hidden;
    transition: visibility 0s linear var(--hz-screen-push);
  }
  /* !important: a component's own `animation` shorthand resets play-state to
     running, and no component may keep a covered screen ticking. */
  .sb.hide *, .sb.hide *::before, .sb.hide *::after { animation-play-state: paused !important; }

  /* ── The chat list scrolls as one screen ─────────────────────────────────
     The market's inbox pattern — Instagram, WhatsApp, Messenger, Telegram's
     stories: the bar and the stories are the top of the CONTENT, not a frame
     around it. They scroll away with the chats, so the whole screen goes to
     the list, and come back when the list is back at its top (or on a re-tap
     of the Chats tab — onNavChats → scrollChatListToTop).

     One scroller: #sbScroll holds the head, the home agents and #clist and
     carries .hz-panel-scroll, so it also runs under the tab bar and reserves
     it at the end (above). #clist stops scrolling and grows to at least the
     room left under the head — the loading spinner and the empty state centre
     there (they are positioned over #clist).

     Search keeps its bar: while open, the brand row, the stories and #clist
     are out of the layout, the results panel (.hzs, search.css) takes the room
     left under the field and scrolls itself, so the field never scrolls away.

     The status bar strip (--st: a PWA on a notched phone) is frosted and
     pinned, as every native bar's is, so the chats never scroll under the
     clock. It overlays the head's own top inset (that inset carries --st), so
     at rest nothing moves; where there is no strip it is 0px tall. */
  .sb-scroll {
    display: flex; flex-direction: column;
    flex: 1; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scroll-padding-top: var(--st);
  }
  .sb-scroll::before {
    content: '';
    position: sticky; top: 0; z-index: 3;
    flex: none;
    height: var(--st);
    margin-bottom: calc(-1 * var(--st));
    background: var(--hz-surface-panelhdr, rgba(9,9,22,.92));
    backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
    -webkit-backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
    pointer-events: none;
  }
  .sb-scroll > .clist { flex: 1 0 auto; overflow: visible; }
  .cm { position: fixed; inset: 0; z-index: 60; display: none; background: var(--void); }
  .cm.show { display: flex; flex-direction: column; animation: slideInRight var(--hz-screen-push) var(--ease) both; }
  .backbtn { display: flex !important; }

  /* Panel head — every consumer at once; see --hz-panel-head-* in tokens.css. */
  .hz-panel-head     { padding: var(--hz-panel-head-pad-dense); gap: var(--hz-panel-head-gap-dense); }
  .hz-panel-head-bleed { margin-inline: calc(-1 * var(--hz-panel-head-pad-x-dense)); }
  .hz-panel-head-row { align-items: center; }
  .bmark   { width: 44px; height: 44px; border-radius: var(--hz-radius-14); overflow: hidden; }
  .p2p-badge { display: none; }

  /* Header buttons — clean icon buttons, no box */
  .hbtns { display: flex; gap: 4px; align-items: center; }
  .ib { width: 40px; height: 40px; border-radius: 50%; background: transparent; border: none; }
  .ib svg { width: 20px; height: 20px; }


  /* My ID bar */
  .myid-bar { padding: 10px 14px; border-radius: var(--hz-radius-14); margin-bottom: 10px; }
  .myid-dot { width: 8px; height: 8px; }
  .myid-txt { font-size: 12px; }
  .myid-copy { width: 30px; height: 30px; border-radius: var(--hz-radius-8); }
  .myid-copy svg { width: 13px; height: 13px; }

  /* Search lives in the bar — the Android Chats tab's pattern (docs/composer.md
     §3). The magnifier in the brand row (#sbSearchBtn) opens it
     (search/ui/addon.js openBar → #sb.hz-searching): the brand row, the
     stories and the docked composer step aside, and the row — Back, then the
     field — takes the bar's place. One text field on the screen at a time.
     Closed, the row is out of the layout (not just empty: the head's gap would
     still count it). Back is a history layer (nav-controller.js 'search'). */
  .sb-search-row { display: none; }
  .sb.hz-searching .sb-search-row {
    display: flex; align-items: center;
    gap: var(--hz-panel-head-lead-gap);
    min-height: var(--hz-panel-head-row-h);
  }
  .sb.hz-searching .sb-search-back { display: flex; margin-inline-start: -6px; }
  .sb.hz-searching .srch { flex: 1; min-width: 0; }
  .sb.hz-searching .sb-top,
  .sb.hz-searching #sbForYou,
  .sb.hz-searching #sbComposer { display: none; }

  /* Search */
  .srch { border-radius: var(--hz-radius-pill); padding: 0 16px; height: 44px; }
  .srch input { padding-block: 11px; padding-inline: 10px 0; font-size: 15px; }
  .srch-i { width: 16px; height: 16px; }

  /* Chat list rows: the .ci component + its --hz-row-* register (touch
     density on a phone) — see LIST ROW above. Generic avatars below. */
  .av { width: 48px; height: 48px; font-size: 16px; }
  .av::after { width: 12px; height: 12px; border-width: 2.5px; }
  .divln { display: none; }
  /* ── Tab bar: floating liquid-glass capsule, four tabs ── */
  .mnav {
    display: flex; align-items: center;
    left: var(--hz-tabbar-inset); right: var(--hz-tabbar-inset);
    /* Float above the cookie-consent banner while it is unanswered. The banner
       is fixed to the bottom at --hz-z-overlay — above this bar's z-index: 100 —
       so without this it covers the whole tab bar and a first-time visitor on a
       phone cannot navigate at all until they answer it: a functional block, not
       a cosmetic overlap. That became a first-run state when '/' started serving
       the app to signed-out visitors (lib/entry-policy.js).
       --hz-consent-h is published by public/js/cookie-consent.js while the
       banner shows and removed the moment it is answered; the 0px fallback is
       the exact previous layout, so this is inert on every other page load.
       The rest is the bar's lift (see the TAB BAR :root block): 40% of the
       safe-area inset + 8px, i.e. inside the home-indicator zone like a
       native tab bar. --hz-nav-clear uses the same `* .4`. */
    bottom: calc(var(--sb2) * .4 + 8px + var(--hz-consent-h, 0px));
    height: var(--hz-tabbar-h);
    border-radius: var(--hz-radius-pill);
  }
  .chdr { padding: 0 12px; height: calc(60px + var(--st)); padding-top: var(--st); }
  .chdr-l { gap: 10px; }
  .backbtn { width: 34px; height: 34px; border-radius: 50%; border: none; background: transparent; }
  .backbtn svg { width: 20px; height: 20px; }
  .chdr .av { width: 40px; height: 40px; font-size: 14px; }
  .hnm { font-size: 15px; font-weight: 600; letter-spacing: -.18px; }
  .hst { font-size: 12px; margin-top: 2px; }
  .r1  { margin-bottom: 0; }
  .chdr-r .ib { width: 36px; height: 36px; background: transparent; border: none; border-radius: 50%; }
  .chdr-r .ib svg { width: 18px; height: 18px; }
  .hpid { display: none; }

  /* ── iOS keyboard auto-scroll fix ────────────────────────────────────
     When the soft keyboard opens, iOS Safari auto-scrolls the nearest
     overflow:hidden container (.cm-chat) to reveal the focused textarea.
     The textarea's layout position is near the bottom of .cm-chat (~842px),
     so iOS scrolls ~530px upward — pushing .chdr (the header) off-screen.
     CSS transform: translateY() on .iz only moves it visually; iOS uses
     layout coordinates for scroll decisions, so the transform doesn't help.

     Two-layer defence:
       1. overflow:clip — iOS 16+ (Safari 16, Sep 2022): the container is
          never a scroll container at all. scrollTop stays 0 permanently.
          Older browsers ignore unknown values, keeping overflow:hidden.
       2. position:sticky on .chdr — iOS 15 fallback: if the container
          somehow scrolls, the header sticks at the top of the visible area.
          z-index:11 (+1 vs base 10) ensures header paints above mw content
          that slides underneath when sticky is active.
     ── */
  .cm-chat { overflow: clip; }
  .chdr    { position: sticky; top: 0; z-index: 11; }

  /* ── Message area — more breathing room for content ── */
  .mw { padding: 10px 12px 6px; gap: 1px; --reply-card-pad: 10px 14px 4px; --reply-card-radius: var(--hz-bubble-radius-dense); --reply-card-align: stretch; }

  /* ── Bubbles — tighter, more readable on small screens ── */
  .bub { max-width: min(270px, 80vw); font-size: var(--hz-bubble-font-size); padding: var(--hz-bubble-pad-dense); border-radius: var(--hz-bubble-radius-dense); line-height: var(--hz-bubble-line-height-dense); }
  .mg.out .bub { border-end-end-radius: var(--hz-bubble-tail-dense); }
  .mg.in  .bub { border-end-start-radius: var(--hz-bubble-tail-dense); }
  .mg { gap: 4px; margin-bottom: 3px; }
  .mav { width: 28px; height: 28px; font-size: 11px; }
  .mg.in .mmeta { padding-inline-start: 38px; }   /* past the phone's 28px .mav */
  .tick svg { width: 12px; height: 12px; }

  /* ── Agent chips bar — scrollable, hinted ── */
  #agChips {
    padding: 7px 12px 8px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 10px, #000 calc(100% - 24px), transparent 100%);
  }
  /* RTL: the row scrolls the other way, so the wider "more" fade moves to the left (inline end). */
  [dir="rtl"] #agChips {
    -webkit-mask-image: linear-gradient(to left, transparent 0, #000 10px, #000 calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to left, transparent 0, #000 10px, #000 calc(100% - 24px), transparent 100%);
  }
  #agChips::-webkit-scrollbar { display: none; }
  #agChips .apv-chip { height: 32px; font-size: 12px; padding: 0 14px; white-space: nowrap; flex-shrink: 0; }

  /* ── AI filter bar ── */
  .aif-bar { padding: 7px 12px 0; gap: 6px; }
  .aif-bar.show { max-height: 54px; padding: 7px 12px 6px; }
  .aif-toggle { height: 34px; font-size: 12px; padding: 0 11px; }
  .pchip { height: 34px; font-size: 12px; padding: 0 11px; }

  /* ── Input zone — mobile: v72 with proper iOS zoom prevention ── */
  .iz { padding: 8px 12px; padding-bottom: calc(8px + var(--sb2)); }
  /* Mobile bumps the composer's top hairline to --border-mid in DARK only; light
     keeps the thinner --hz-composer-border-top, so this must not apply in light. */
  :root:not([data-theme="light"]) .iz { border-top: 1px solid var(--border-mid); }
  .ish { padding-block: 6px; padding-inline: 14px 6px; border-radius: var(--hz-radius-20); }
  /* font-size MUST stay 16px — lower triggers iOS Safari auto-zoom */
  .mta { font-size: 16px; line-height: 1.4; min-height: 24px; }
  .iz .ib { width: 38px; height: 38px; border-radius: var(--hz-radius-10); }
  /* Composer control sizing is handled by the shared --hz-composer-* register
     (@media (pointer: coarse) → 44px tap floor) — no per-width override here. */
  .modal { border-radius: var(--hz-radius-26); max-width: 100%; }
  .tstack { right: 12px; left: 12px; max-width: none; }
  .toast { border-radius: var(--hz-radius-18); padding: 14px 16px; }
  #fc { width: 240px; }
  .sp-row { padding: 14px 18px; }

  /* ── Agent Store — mobile optimised ──
     Only the panel's own shell is here. Everything inside it (the row, the
     heads, the two shelves) tightens on a phone by RE-POINTING its register in
     store-trending.css, so there is one description of each component at any
     width instead of a second copy of the layout in this block. */
  /* No tab-bar term: the PANEL clears the bar (.hz-phone-panel), and adding it
     here too reserved it twice. It was invisible only because store-trending.css
     lazy-loads after this file and re-declares the padding — so the double
     reservation was one failed stylesheet load away from being real. */
  .cs-body { padding: 10px 12px 12px; }
  .cs-lbl { font-size: 10px; padding: 3px 2px 6px; }
}

/* ═══════════════════════════════════════════════════════════
   TABLET  641px – 899px
   iPad mini / iPad / iPad Air portrait + landscape, Surface Go,
   Android tablets. Two-column layout (sidebar + chat) is kept —
   same as desktop. These rules tune three things the base styles
   get wrong for this screen class:

   1. Bubble max-width — base .bub uses min(560px,78vw) which is
      wider than the chat column at tablet sizes and produces
      wall-to-wall bubbles with no breathing room. We cap relative
      to the actual column: calc(100vw - var(--sb) - 110px).
      The 110px = mw horizontal padding (40px) + intentional
      breathing room (70px). Using --sb keeps this adaptive — if
      the sidebar width ever changes, bubbles scale automatically.

   2. Message canvas + composer padding — a gentle step up from
      mobile base (16/18px) toward the desktop values (22/28px).
      Horizontal padding aligns mw and .iz so they feel like one
      column, not two separate elements with different margins.

   3. Chat header blur — base is blur(32px) saturate(1.9), which
      is expensive on tablet-class GPUs (iPad mini, older iPads,
      budget Android tablets). Reduced to blur(20px) saturate(1.5):
      still visually glassy, significantly cheaper to composite.
═══════════════════════════════════════════════════════════ */
@media (min-width: 641px) and (max-width: 899px) {

  /* Bubbles: constrain to actual column width, not raw viewport.
     --sb is always 282px in this range, but using the variable
     means the formula stays correct if --sb is ever updated. */
  .bub { max-width: min(440px, calc(100vw - var(--sb) - 110px)); }

  /* Message canvas: steps between mobile (16px 18px) and desktop (22px 28px). */
  .mw { padding: 18px 20px 10px; }

  /* Composer: horizontal padding matches .mw so the two feel like one column. */
  .iz { padding: 10px 20px; padding-bottom: calc(10px + var(--sb2)); }

  /* Header blur: visually equivalent, significantly cheaper on tablet GPUs.
     Dark-only — light headers carry no blur (--hz-chathdr-blur is none), so this
     reduction must not re-introduce one over the light token. */
  :root:not([data-theme="light"]) .chdr {
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
  }

}


@media (min-width: 900px) {
  :root { --sb: 310px; --hh: 68px; }  /* +2px from v118 66px */
  body { font-size: 15px; }
  .srch { padding: 0 12px; height: 38px; }
  .srch input { font-size: 14px; padding-block: 9px; padding-inline: 7px 0; }
  .av { width: 46px; height: 46px; font-size: 15px; }
  .hnm { font-size: 16px; }
  .hst { font-size: 12px; }
  .chdr-r .ib { width: 34px; height: 34px; border-radius: var(--hz-radius-10); }
  .bub { max-width: min(560px, 68vw); padding: var(--hz-bubble-pad-dense); font-size: var(--hz-bubble-font-size); border-radius: var(--hz-bubble-radius-dense); }
  .mw { padding: 22px 28px 10px; }
  .iz { padding: 12px 28px; padding-bottom: calc(12px + var(--sb2)); }
  .mta { font-size: 16px; }
  .sp-row { padding: 15px 20px; font-size: 15px; }
  /* image previews */
  .im-img-wrap { max-width: 360px; }
  :root { --hz-bubble-media-width: 280px; }

}

/* ═══════════════════════════════════════════════════════════
   LARGE DESKTOP ≥1280px
═══════════════════════════════════════════════════════════ */
@media (min-width: 1280px) {
  :root { --sb: 340px; }
  .av { width: 48px; height: 48px; }
  .bub { max-width: min(580px, 64vw); font-size: var(--hz-bubble-font-size); }
  .mw { padding: 26px 36px 12px; }
  .iz { padding: 13px 36px; padding-bottom: calc(13px + var(--sb2)); }
  .hnm { font-size: 17px; }
  .chdr-r .ib { width: 36px; height: 36px; }
  /* image previews */
  .im-img-wrap { max-width: 400px; }
  :root { --hz-bubble-media-width: 310px; }

}



/* ── light-theme.css ── */

/*
 * light-theme.css — Aether · Telegram-inspired Light
 * Exact TG palette: sage-green canvas, white sidebar, pure white bubbles.
 */

[data-theme="light"] {
  /* ─────────────────────────────────────────────────────────────────────────
   * Light-mode design tokens now live in ONE place: css/design-system/
   * tokens.css ([data-theme="light"]). The app-facing aliases in :root above
   * (--void → var(--hz-surface-canvas), etc.) resolve to the light values
   * automatically, so there is no need to re-declare every token here.
   *
   * This also completes the theme: --agent-soft/-border and --group* — which
   * previously fell through to their dark-mode values in light mode — are now
   * correctly tinted by the canonical light theme.
   *
   * Only these light-only helper tokens have no canonical equivalent yet: */
  --s1: #FFFFFF;
  --s2: var(--hz-paper-50);
  --b1: rgba(0,0,0,.11);

  /* App button register — light overrides (dark values are in :root). The
     primary keeps the token layer's action blue (no light re-point: one
     primary look in both themes); the secondary uses primary text + a
     slightly stronger border, matching the app's historical light .btn. The
     field focus is the token layer's blue too (no app override). */
  --hz-btn-secondary-fg:     var(--t1);
  --hz-btn-secondary-border: rgba(0, 0, 0, .15);
}

/* Shell backdrop = --surface (not the --void canvas) — see the base `body` rule
   for why: keeps the iOS bottom "gray line" from showing under the white panels. */
[data-theme="light"] body { background: var(--surface); color: var(--t1); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,.16); }

/* ─── Sidebar — pure white like TG ─── */
[data-theme="light"] .sb {
  background: #FFFFFF;
  border-inline-end: 1px solid rgba(0,0,0,.08);
  background-image: none;
}
[data-theme="light"] .myid-bar {
  background: var(--hz-paper-50);
  border: 1px solid rgba(0,0,0,.08);
}
[data-theme="light"] .myid-bar:hover { background: #EBEBEB; border-color: rgba(0,0,0,.12); }
/* .myid-txt / .myid-txt b light colors removed — base uses var(--t2)/var(--t1). */
[data-theme="light"] .srch {
  background: #F2F2F7;
  border: 1.5px solid transparent;
  box-shadow: none;
}
[data-theme="light"] .srch:focus-within {
  background: #FFFFFF;
  border-color: color-mix(in srgb, var(--hz-brand) 45%, transparent);
  box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--hz-brand) 10%, transparent);
}
[data-theme="light"] .srch input   { color: var(--t1); background: transparent; border: none; }
/* Both .srch-i light overrides removed: the base strokes var(--hz-text-meta),
   which the light block already flips, and the focused stroke was var(--accent)
   in light exactly as it is in the base. A second value is a second decision. */
[data-theme="light"] .ib           { color: var(--t2); }
[data-theme="light"] .ib:hover     { background: var(--hz-paper-100); color: var(--t1); }
/* Compose/action buttons in header — branded blue, consistent with .sb-filter.on */
[data-theme="light"] .hbtns .ib   { background: color-mix(in srgb, var(--hz-brand) 9%, transparent); color: var(--hz-brand-deep); border: 1px solid color-mix(in srgb, var(--hz-brand) 28%, transparent); border-radius: var(--hz-radius-10); }
[data-theme="light"] .hbtns .ib:hover { background: var(--hz-brand); color: #fff; border-color: transparent; }

/* Chat rows: no light fork — the --hz-row-* register flips in tokens.css. */
[data-theme="light"] .av::after     { border-color: #FFFFFF; }
[data-theme="light"] .divln { background: rgba(0,0,0,.07); }

/* ─── Header — white like TG ─── */
/* .chdr light theme now flips via --hz-surface-chathdr / --hz-chathdr-blur /
   --hz-chathdr-shadow tokens (border-bottom already flips via --hz-border). */
/* Accent line removed in v120 — no light override needed */

/* Light-theme header — type-chip element removed in v120 */

/* Avatar ring — removed in v120; no overrides needed */

[data-theme="light"] .hnm { color: #000000; }
[data-theme="light"] .hst       { color: rgba(0,0,0,.42); }
[data-theme="light"] .hst.off   { color: rgba(0,0,0,.30); }
[data-theme="light"] .hst.away  { color: var(--warn); }

[data-theme="light"] .chdr-divider { background: rgba(0,0,0,.10); }

[data-theme="light"] .hpid { background: var(--hz-paper-100); border-color: rgba(0,0,0,.10); color: var(--t2); }
[data-theme="light"] .hpid:hover { border-color: rgba(79,174,78,.30); color: var(--p2p); }
[data-theme="light"] .chdr .ib,
[data-theme="light"] .chdr-r .ib { color: var(--t2); background: transparent; border: none; }
[data-theme="light"] .chdr .ib:hover,
[data-theme="light"] .chdr-r .ib:hover { background: var(--hz-paper-100); color: #000; }
[data-theme="light"] .backbtn { color: var(--accent); }
[data-theme="light"] .backbtn:hover { background: var(--accent-soft); }

/* Contextual tints for light mode */
[data-theme="light"] .chdr[data-type="agent"]     .chdr-r .ib.ctx { color: #187db8; }
[data-theme="light"] .chdr[data-type="p2p"]       .chdr-r .ib.ctx { color: var(--p2p); }
[data-theme="light"] .chdr[data-type="group"]     .chdr-r .ib.ctx { color: #9a6200; }
[data-theme="light"] .chdr[data-type="broadcast"] .chdr-r .ib.ctx { color: var(--agent); }

/* ─── Canvas — TG signature sage green ─── */
/* v72 chat column container — warm canvas matching .mw, so the chips
   bar (which lives between .mw and .iz) sits on the same surface. */
[data-theme="light"] #cm {
  background-color: #FAFAF9;
  background-image:
    radial-gradient(ellipse 70% 30% at 100% 0%, rgba(255,77,157,.06) 0%, transparent 55%),
    radial-gradient(ellipse 70% 40% at 0% 100%, color-mix(in srgb, var(--hz-brand) 5.5%, transparent) 0%, transparent 55%);
  position: relative;
}
[data-theme="light"] #cm::before { display: none; }

/* The thread, light: the same wash tokens flip; only the baked tile differs. */
[data-theme="light"] .mw { background-image: url(/img/thread-pattern-light.svg), var(--hz-thread-wash); }

/* ─── BUBBLES — exact TG style ─── */

/* ★ INCOMING (P2P friend) — soft white pill, v71 token */
/* Light bubbles out-specify their base rules by [data-theme] + selector depth,
   so !important is dead weight here and has been dropped — EXCEPT the tick
   stroke colours below, which must beat the later equal-specificity green-tick
   rules (kept !important, by design). */
/* Incoming (person) bubble surface flips entirely via --hz-bubble-in-* (white pill
   + hairline shadow + black text). Only the radius pin remains: in LIGHT the
   incoming/outgoing bubbles keep the full 20px corner at every breakpoint (they do
   NOT tighten to the compact mobile radius the way dark does — a pre-existing
   theme quirk, preserved here; unifying it is a deliberate visual change for later). */
[data-theme="light"] .mg.in .bub,
[data-theme="light"] .mg.out .bub { border-radius: var(--hz-bubble-radius); }
[data-theme="light"] .mg.in .mr:last-child .bub { border-end-start-radius: var(--hz-bubble-tail); }
[data-theme="light"] .mg.in .mr:not(:last-child)  .bub { border-end-start-radius: var(--hz-bubble-tail); }
[data-theme="light"] .mg.in .mr:not(:first-child) .bub { border-start-start-radius: var(--hz-bubble-tail); }

/* ★ OUTGOING — v71 electric gradient (#7B5BFF → #FF4D9D)
   Same gradient as dark mode. The user's signature is the same in both themes. */
/* Outgoing bubble is the user's signature — the SAME gradient in both themes, so
   --hz-bubble-out-* does not flip and no per-theme surface rule is needed here.
   (The white markdown-text children below still need the light overrides.) */
[data-theme="light"] .mg.out .bub::after { content: none; display: none; }
[data-theme="light"] .mg.out .bub .md,
[data-theme="light"] .mg.out .bub .md p,
[data-theme="light"] .mg.out .bub .md li,
[data-theme="light"] .mg.out .bub .md h1,
[data-theme="light"] .mg.out .bub .md h2,
[data-theme="light"] .mg.out .bub .md h3,
[data-theme="light"] .mg.out .bub .md h4,
[data-theme="light"] .mg.out .bub .md h5,
[data-theme="light"] .mg.out .bub .md h6 { color: #fff; }
[data-theme="light"] .mg.out .bub .md a { color: rgba(255,255,255,.9); }
[data-theme="light"] .mg.out .mtime { color: rgba(0,0,0,.38); }
[data-theme="light"] .tick.sent svg,
[data-theme="light"] .tick.delivered svg { stroke: rgba(255,255,255,.7) !important; }
[data-theme="light"] .tick.read svg { stroke: #C8FFE8 !important; }
/* Tail asymmetry — match v71 dark mode (8px on bottom-right, not the old sharp 4px) */
[data-theme="light"] .mg.out .mr:last-child .bub { border-end-end-radius: var(--hz-bubble-tail); }
[data-theme="light"] .mg.out .mr:not(:last-child)  .bub { border-end-end-radius: var(--hz-bubble-tail); }
[data-theme="light"] .mg.out .mr:not(:first-child) .bub { border-start-end-radius: var(--hz-bubble-tail); }

/* Outgoing markdown text stays white on the gradient (overrides any dark-text rule) */
[data-theme="light"] .mg.out .bub .md { color: #fff; }
[data-theme="light"] .mg.out .bub .md a { color: #fff; border-bottom-color: rgba(255,255,255,.4); }
[data-theme="light"] .mg.out .bub .md code { background: rgba(0,0,0,.18); border-color: rgba(0,0,0,.22); color: #fff; }

/* AGENT */
[data-theme="light"] .mg.ag .bub {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 2px 0;
  color: var(--t1);
}

/* TG tick colors — green checkmarks on sent */
[data-theme="light"] .tick.sent      svg { stroke: rgba(79,174,78,.70); }
[data-theme="light"] .tick.delivered svg { stroke: rgba(79,174,78,.70); }
[data-theme="light"] .tick.read      svg { stroke: #4FAE4E; }

[data-theme="light"] .mtime { color: var(--tmeta); }
/* Outgoing message meta on green bg */
[data-theme="light"] .mg.out .mtime { color: rgba(0,0,0,.45); }

[data-theme="light"] .tybub {
  background: linear-gradient(135deg, rgba(123,91,255,.07), rgba(255,77,157,.07)), var(--hz-thread-reply-bg);
  border: 0.5px solid rgba(123,91,255,.20);
  box-shadow: none;
}
[data-theme="light"] .tyd { background: linear-gradient(135deg, #7B5BFF, var(--hz-accent-pink)); }
[data-theme="light"] .sysmsg { color: rgba(0,0,0,.50); }
[data-theme="light"] .sysmsg.p2p { color: var(--p2p); }

/* ─── Composer (light) ───────────────────────────────────────────────────────
   The composer shell + controls are fully token-driven now (--hz-composer-*,
   --hz-surface-*, --hz-brand-*), and every one of those tokens already flips in
   the [data-theme="light"] block. So light theme is a pure token swap — no
   composer-specific light rules needed (the old send/focus patches are
   gone; caret follows the blue brand via --hz-input-* / var(--t1)). */
[data-theme="light"] .mta { caret-color: var(--hz-brand); }

/* ─── v72 AI chips (light) ─── */
[data-theme="light"] .aif-bar {
  background: #FFFFFF;
  border-top-color: rgba(0,0,0,.06);
}
/* (Earlier duplicate .ag-chip / :hover / -hist light block removed — every
   declaration it set was overridden by the later live [data-theme="light"]
   .ag-chip block below on source order, except its :hover transform, which
   falls through to the identical base .ag-chip:hover — so it never rendered.) */
/* pchip is the voice variant (Heart/Sky/Echo) — separate block below */
/* Voice chips: the base-light .pchip no longer uses !important, so the .on
   selected states (higher specificity) win on their own — the whole family
   sheds !important together (see the .pchip.on gradient block further below). */
[data-theme="light"] .pchip {
  background: #FFFFFF;
  border: 0.5px solid rgba(0,0,0,.10);
  color: #1F1E2A;
  box-shadow: none;
  font-weight: 500;
}
[data-theme="light"] .pchip:hover {
  background: color-mix(in srgb, var(--hz-brand) 6%, transparent);
  border-color: color-mix(in srgb, var(--hz-brand) 24%, transparent);
  color: var(--hz-blue-700);
}
/* SELECTED voice chip — full gradient, same affordance as send button */
[data-theme="light"] .pchip.on,
[data-theme="light"] .pchip.active,
[data-theme="light"] .pchip[aria-selected="true"] {
  background: linear-gradient(135deg, var(--hz-brand) 0%, var(--hz-accent-cyan) 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 3px 10px color-mix(in srgb, var(--hz-brand) 32%, transparent);
}
[data-theme="light"] .aif-toggle { background: #F4F2EE; border: 0.5px solid rgba(0,0,0,.10); color: var(--t2); }
[data-theme="light"] .aif-toggle.on { background: color-mix(in srgb, var(--hz-brand) 10%, transparent); border-color: color-mix(in srgb, var(--hz-brand) 32%, transparent); color: var(--hz-blue-700); }
[data-theme="light"] .aif-cfg { background: #F4F2EE; border: 0.5px solid rgba(0,0,0,.08); color: var(--t2); }
[data-theme="light"] .aif-cfg:hover { background: var(--hz-paper-200); color: #000; }
[data-theme="light"] #agChips,
[data-theme="light"] .ag-chips-bar {
  background: transparent !important;
  border-top: none;
  border-bottom: none;
}

/* ─── Nav ─── */
/* The phone tab bar's glass adapts per theme via the --hz-tabbar-* tokens
   (design-system/tokens.css); its focus ring lives with the component. */

/* ─── Settings ─── */
/* #settPanel + .sp-hdr light flip via --hz-surface-panel-settings /
   --hz-surface-panelhdr / --hz-panelhdr-blur / --hz-panelhdr-shadow tokens. */
/* .cs-hdr light flips via --hz-surface-panelhdr / --hz-panelhdr-blur / --hz-panelhdr-shadow. */
/* .cs-title/.sp-title/.sp-back light colors removed with the rules themselves —
   the shared .hz-panel-head-title/-back read --t1/--accent, which flip. */
/* bg omitted — base .sp-card uses var(--surface), already #FFFFFF in light. */
/* .sp-card border/shadow flip via --hz-elevation-border / --hz-spcard-shadow. */
[data-theme="light"] .sp-row { border-bottom-color: rgba(0,0,0,.06); }
[data-theme="light"] .sp-row:hover { background: #F9F9F9; }
[data-theme="light"] .sp-row-lbl { color: #000000; }
[data-theme="light"] .sp-row-sub { color: var(--t3); }
[data-theme="light"] .sp-row-ic  { background: var(--accent-soft); color: var(--accent); }
[data-theme="light"] .sp-toggle-btn { background: rgba(0,0,0,.14); }
[data-theme="light"] .sp-toggle-btn.on { background: var(--p2p); }
[data-theme="light"] .sp-profile-name   { color: #000; }
[data-theme="light"] .sp-profile-handle { color: rgba(0,0,0,.40); }
[data-theme="light"] .sp-field-input    { color: #000; }
[data-theme="light"] .sp-field-lbl      { color: rgba(0,0,0,.50); }
[data-theme="light"] .sp-field-value    { color: rgba(0,0,0,.55); }
[data-theme="light"] .sp-field-value.small { color: rgba(0,0,0,.35); }

/* ─── Modals ─── */
/* .moverlay scrim + .modal border/shadow flip via --hz-overlay-* / --hz-elevation-border
   / --hz-modal-shadow tokens (modal bg already flips via var(--surface)). */
/* .mt light color removed — base uses var(--t1) (=#000 in light). */
[data-theme="light"] .mclose { background: var(--hz-paper-100); color: var(--t2); border: 1px solid rgba(0,0,0,.10); }
[data-theme="light"] .mclose:hover { background: var(--hz-paper-200); color: #000; }
[data-theme="light"] .mfoot { background: #F9F9F9; border-top: 1px solid rgba(0,0,0,.07); }
[data-theme="light"] .fld label { color: var(--t3); }
/* .fld field light styling now comes from the .hz-input atom + the app input
   register's [data-theme="light"] tokens — the bespoke light patches were removed. */
[data-theme="light"] .srow.ok { background: rgba(79,174,78,.07);  border-color: rgba(79,174,78,.18);  color: #2E7D32; }
[data-theme="light"] .srow.er { background: rgba(229,57,53,.07);  border-color: rgba(229,57,53,.18);  color: var(--err); }
[data-theme="light"] .srow.pe { background: rgba(232,162,23,.07); border-color: rgba(232,162,23,.18); color: var(--warn); }
[data-theme="light"] .pitem  { background: #F9F9F9; border-color: rgba(0,0,0,.08); }
[data-theme="light"] .pnm    { color: #000000; }
[data-theme="light"] .myid-panel { background: rgba(79,174,78,.06); border-color: rgba(79,174,78,.20); }
[data-theme="light"] .myid-panel .lbl { color: var(--t3); }
[data-theme="light"] .myid-panel .val { color: #2E7D32; }
[data-theme="light"] .lmpill { background: #FFFFFF; border-color: rgba(0,0,0,.12); color: var(--t2); }
[data-theme="light"] .lmpill.on  { background: rgba(79,174,78,.09); border-color: rgba(79,174,78,.20); color: #2E7D32; }
[data-theme="light"] .lmpill.off { color: var(--t3); }
/* .toast shadow flips via --hz-toast-shadow; border-color already flips via --border-mid. */
/* .t-title (→var(--t1)) / .t-sub (→var(--t2)) light colors removed — base flips. */

/* Onboarding */
/* .ob light flips via --hz-surface-panel-onboard token. */
[data-theme="light"] .ob-logo { box-shadow: 0 10px 30px color-mix(in srgb, var(--hz-blue-action) 30%, transparent); }
/* .ob-card border/shadow flip via --hz-elevation-border / --hz-obcard-shadow (bg via var(--surface)). */
/* .ob-h (→var(--t1)) / .ob-sub (→var(--t2)) light colors removed — base flips. */


/* ── Light theme: welcome screen (CMW) — full rules in CMW section at end of file ── */
[data-theme="light"] .cm-welcome { background: var(--hz-paper-150); background-image: radial-gradient(ellipse 80% 50% at 50% -10%,color-mix(in srgb, var(--hz-brand) 10%, transparent) 0%,transparent 65%); }
[data-theme="light"] .cmw-headline { color: var(--hz-blue-975); }
[data-theme="light"] .cmw-headline em { background: linear-gradient(125deg,var(--hz-brand-deep),#0891b2); -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text; }
[data-theme="light"] .cmw-kicker { color:var(--hz-blue-800); background:color-mix(in srgb, var(--hz-brand) 8%, transparent); border-color:color-mix(in srgb, var(--hz-brand) 20%, transparent); }
[data-theme="light"] .cmw-kicker-dot { background:var(--hz-brand-deep); }
[data-theme="light"] .cmw-sub { color:#6B6788; }
[data-theme="light"] .cmw-row { background:#fff; border-color:rgba(0,0,0,.08); box-shadow:0 2px 10px rgba(0,0,0,.06); }
[data-theme="light"] .cmw-row-name { color:var(--hz-blue-975); }
[data-theme="light"] .cmw-row-desc { color:#8E8EA8; }
[data-theme="light"] .cmw-row-arrow { color:rgba(0,0,0,.3); }
[data-theme="light"] .cmw-row-gpt .cmw-row-logo  { background:rgba(16,185,129,.18); }
[data-theme="light"] .cmw-row-flux .cmw-row-logo { background:color-mix(in srgb, var(--hz-accent-cyan) 18%, transparent); }
[data-theme="light"] .cmw-row-seed .cmw-row-logo { background:color-mix(in srgb, var(--hz-brand) 15%, transparent); }
[data-theme="light"] .cmw-row-nano .cmw-row-logo { background:rgba(249,203,66,.22); }
[data-theme="light"] .cmw-row-gpt:hover  { border-color:rgba(16,185,129,.45); box-shadow:0 6px 24px rgba(16,185,129,.14); }
[data-theme="light"] .cmw-row-flux:hover { border-color:color-mix(in srgb, var(--hz-accent-cyan) 45%, transparent); box-shadow:0 6px 24px color-mix(in srgb, var(--hz-accent-cyan) 14%, transparent); }
[data-theme="light"] .cmw-row-seed:hover { border-color:color-mix(in srgb, var(--hz-brand) 45%, transparent); box-shadow:0 6px 24px color-mix(in srgb, var(--hz-brand) 12%, transparent); }
[data-theme="light"] .cmw-row-nano:hover { border-color:rgba(249,203,66,.5); box-shadow:0 6px 24px rgba(249,203,66,.16); }

/* Admin card */
/* .ag-adm keeps !important — it must beat the later grouped light rule
   ([data-theme="light"] .ag-wc,…,.ag-adm) which sets a different border/shadow. */
[data-theme="light"] .ag-adm { background: #FFFFFF !important; border: none !important; box-shadow: 0 1px 3px rgba(0,0,0,.12) !important; }
[data-theme="light"] .ag-adm-head { background: #F9F9F9; color: var(--t2); border-bottom: 1px solid rgba(0,0,0,.08); }
[data-theme="light"] .ag-adm-stats { background: rgba(0,0,0,.05); }
[data-theme="light"] .ag-adm-stat  { background: #FFFFFF; }
[data-theme="light"] .ag-adm-stat-lbl { color: var(--t3); }
[data-theme="light"] .ag-adm-section  { color: var(--t3); }
[data-theme="light"] .ag-adm-row { background: #F9F9F9; border: 1px solid rgba(0,0,0,.06); }
[data-theme="light"] .ag-adm-name { color: #000000; }
[data-theme="light"] .ag-adm-handle, [data-theme="light"] .ag-adm-time { color: var(--t3); }

/* Groups */
[data-theme="light"] #createGroupModal #cgModal { color: #000000; }
[data-theme="light"] #createGroupModal #cgNameIn { color: #000000; background: var(--hz-paper-100); border-color: rgba(0,0,0,.12); }
[data-theme="light"] #createGroupModal .cgPeerOpt { background: #F9F9F9; color: #000000; border-color: transparent; }
[data-theme="light"] #createGroupModal .cgPeerOpt:hover { background: var(--hz-paper-100); }

/* Markdown in incoming bubbles */
[data-theme="light"] .mg.in .bub .md a { color: #168ACD; }
[data-theme="light"] .mg.in .bub .md code { background: rgba(0,0,0,.07); border-color: rgba(0,0,0,.09); color: #000; }

/* ═══════════════════════════════════════════════════════════
   AGENT PROFILE VIEW — light mode
   agent-profile-view.js injects styles using CSS vars.
   In TG light mode, --out = green bubble = invisible on canvas.
═══════════════════════════════════════════════════════════ */
[data-theme="light"] #agProfileView {
  background: #FFFFFF;
}
[data-theme="light"] .apv-hero {
  background: #FFFFFF;
}
[data-theme="light"] .apv-hero-bg {
  opacity: .04;
}
[data-theme="light"] .apv-glow {
  opacity: .10;
}
[data-theme="light"] .apv-name {
  color: #000000;
}
[data-theme="light"] .apv-tagline {
  color: var(--hz-text-lite-2);
}
[data-theme="light"] .apv-online {
  color: #059669;
  background: rgba(5,150,105,.09);
  border-color: rgba(5,150,105,.20);
}
[data-theme="light"] .apv-online::before {
  background: #059669;
  box-shadow: 0 0 5px rgba(5,150,105,.5);
}

/* Stats card — solid white card, real border */
[data-theme="light"] .apv-stats {
  background: #FFFFFF;
  border: 1.5px solid rgba(0,0,0,.12);
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border-radius: var(--hz-radius-14);
}
[data-theme="light"] .apv-stat {
  border-inline-end-color: rgba(0,0,0,.10);
}
[data-theme="light"] .apv-stat-v {
  color: #000000;
  font-weight: 700;
}
[data-theme="light"] .apv-stat-l {
  color: var(--hz-text-lite-3);
}

/* CTA — branded blue */
[data-theme="light"] .apv-cta {
  background: var(--hz-brand);
  color: #FFFFFF;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--hz-brand) 28%, transparent);
}
[data-theme="light"] .apv-cta:hover {
  background: var(--hz-brand-deep);
  opacity: 1;
}
[data-theme="light"] .apv-cta svg {
  stroke: #FFFFFF;
}

/* Chips section */
[data-theme="light"] .apv-chips-wrap {
  background: #FFFFFF;
  border-top-color: rgba(0,0,0,.08);
}
[data-theme="light"] .apv-chips-label {
  color: var(--hz-text-lite-3);
}
[data-theme="light"] .apv-chip {
  background: var(--hz-paper-100);
  border-color: rgba(0,0,0,.12);
  color: #000000;
}
[data-theme="light"] .apv-chip:hover {
  background: color-mix(in srgb, var(--hz-brand) 8%, transparent);
  border-color: var(--hz-brand-border);
  color: var(--hz-brand);
}

/* Theme toggle */
.theme-toggle-sun, .theme-toggle-moon { transition: opacity .22s, transform .22s; }
[data-theme="light"] .theme-toggle-moon { opacity: 0; transform: scale(.5) rotate(45deg); position: absolute; }
[data-theme="light"] .theme-toggle-sun  { opacity: 1; transform: none; }
:not([data-theme="light"]) .theme-toggle-sun  { opacity: 0; transform: scale(.5) rotate(-45deg); position: absolute; }
:not([data-theme="light"]) .theme-toggle-moon { opacity: 1; transform: none; }
[data-theme="light"] .theme-row-ic { background: linear-gradient(135deg, var(--hz-brand), var(--hz-brand-deep)); }

html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color .22s cubic-bezier(.4,0,.2,1),
    border-color     .22s cubic-bezier(.4,0,.2,1),
    color            .18s cubic-bezier(.4,0,.2,1),
    box-shadow       .22s cubic-bezier(.4,0,.2,1) !important;
}

/* ─── Agent messages: subtle tinted surface in light mode ─── */

/* ═══ BMARK + P2P BADGE — placed last, maximum specificity ═══ */
/* bmark uses icon-512.png — no CSS background needed on any theme */

html[data-theme="light"] .p2p-badge {
  display: none !important;
}

html[data-theme="light"] .p2p-badge,
html[data-theme="light"] .brand .p2p-badge,
html[data-theme="light"] .sb .p2p-badge {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  overflow: hidden !important;
}


/* ★ Thinking bubble (light) — v72 gradient-tinted indicator */
[data-theme="light"] .bub.think-bub {
  background: linear-gradient(135deg, rgba(123,91,255,.07), rgba(255,77,157,.07)), var(--hz-thread-reply-bg) !important;
  border: 0.5px solid rgba(123,91,255,.20) !important;
  box-shadow: none !important;
  border-radius: var(--hz-radius-20) !important;
  padding: 11px 16px !important;
  display: inline-flex !important;
  animation: none !important;
}
[data-theme="light"] .think-txt {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  /* v114.6 (2026-04-21): reset -webkit-text-fill-color too. The base
     .think-txt rule sets it to transparent (so the gradient background
     shows through clipped to text shape). When the light-theme override
     here strips the background + background-clip but leaves the
     transparent fill color in place, the result is invisible text on
     light theme — visible bubble bounds, dots animate, but the
     "Generating… (~30s)" label is rendered with rgba(0,0,0,0). Pre-v114.6
     the bug masked itself: the chat:observer log saw the text in the
     DOM, but the user's eye saw nothing. Adding `color: var(--t1)` and
     resetting -webkit-text-fill-color brings it back. animation: none
     turns off the gradient sweep (no gradient to sweep on light). */
  -webkit-text-fill-color: var(--t1);
  color: var(--t1);
  animation: none;
}

/* (Earlier [data-theme="light"] .stbar/.stbtn block removed — superseded by the
   higher-specificity html[data-theme="light"] rules below, so it never rendered.) */

/* ── Thinking bubble (light, high-specificity) — v72 ── */
/* Higher specificity selector wins over .mg.ag .bub transparent rule */
html[data-theme="light"] .mg.ag .bub.think-bub {
  background: linear-gradient(135deg, rgba(123,91,255,.07), rgba(255,77,157,.07)), var(--hz-thread-reply-bg) !important;
  border: 0.5px solid rgba(123,91,255,.20) !important;
  border-radius: var(--hz-radius-20) !important;
  padding: 11px 16px !important;
  box-shadow: none !important;
  display: inline-flex !important;
  align-items: center !important;
  animation: none !important;
}

/* ── Stop generating bar ── */
html[data-theme="light"] .stbar {
  background: rgba(248,247,244,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(0,0,0,.06);
}
html[data-theme="light"] .stbtn {
  background: rgba(220,38,38,.07);
  border-color: rgba(220,38,38,.25);
  color: #DC2626;
}
html[data-theme="light"] .stbtn:hover {
  background: rgba(220,38,38,.14);
}

/* ── Onboarding button — uses accent color ── */



/* ── agents-addon.css ── */

/*
 * agents-addon.css — Aether Agent Rich Components
 *
 * ═══════════════════════════════════════════════════════════
 * DESIGN SYSTEM
 * All agent cards share one design language:
 *   - Surface: var(--raised) — adapts to dark/light theme
 *   - Border: var(--border-mid) — consistent edge definition
 *   - Radius: 16px — friendly, modern
 *   - Shadow: layered depth without heaviness
 *   - Typography: Plus Jakarta Sans, strong hierarchy
 *   - Accent: color used sparingly — numbers and labels only
 * ═══════════════════════════════════════════════════════════
 */

/* ══════════════════════════════════════════════════════════
   SHARED CARD SHELL
   Every card inherits this base — one design language
══════════════════════════════════════════════════════════ */
.ag-wc,
.ag-fc,  .ag-food,
.ag-wk,  .ag-wo,
.ag-wt,
.ag-tm,
.ag-adm {
  background: var(--raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--hz-radius-16);
  overflow: hidden;
  animation: agPop .22s cubic-bezier(.34,1.4,.64,1) both;
  box-shadow:
    0 1px 2px rgba(0,0,0,.12),
    0 4px 16px rgba(0,0,0,.10);
  /* consistent max-width */
  max-width: 360px;
  width: 100%;
}

@keyframes agPop {
  from { opacity: 0; transform: translateY(6px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* Card section divider */
.ag-divider {
  height: 1px;
  background: var(--border);
  margin: 0;
}

/* ══════════════════════════════════════════════════════════
   WORD CARD — English Tutor
══════════════════════════════════════════════════════════ */
.ag-wc { max-width: 340px; }

.ag-wc-head {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.ag-wc-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 4px;
  gap: 8px;
}
.ag-wc-word {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--t1);
  line-height: 1.1;
}
.ag-wc-ipa {
  font-size: 13px;
  color: var(--p2p);
  letter-spacing: .3px;
  margin-top: 3px;
  font-family: 'JetBrains Mono', monospace;
}
.ag-wc-trans {
  font-size: 15px;
  font-weight: 600;
  color: var(--t1);
  margin-top: 4px;
}
.ag-wc-freq {
  font-size: 11px;
  color: var(--t3);
  margin-top: 3px;
}
.ag-wc-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 2px;
  flex-shrink: 0;
}
.ag-wc-lvl {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--hz-radius-pill);
  border: 1px solid;
}
.ag-wc-pos {
  font-size: 10px;
  background: var(--hover);
  color: var(--t2);
  padding: 2px 8px;
  border-radius: var(--hz-radius-pill);
  border: 1px solid var(--border);
}

.ag-wc-body { padding: 12px 16px 14px; }
.ag-wc-def {
  font-size: 13px;
  color: var(--t2);
  line-height: 1.6;
  margin-bottom: 10px;
  font-style: italic;
}
.ag-wc-ex {
  font-size: 13px;
  color: var(--t1);
  padding: 6px 10px;
  border-inline-start: 2.5px solid var(--p2p);
  background: var(--p2p-soft);
  border-start-start-radius: 0; border-start-end-radius: var(--hz-radius-8); border-end-end-radius: var(--hz-radius-8); border-end-start-radius: 0;
  margin-bottom: 6px;
  line-height: 1.5;
}
.ag-wc-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.ag-wc-syn {
  font-size: 11px;
  background: var(--p2p-soft);
  color: var(--p2p);
  padding: 2px 9px;
  border-radius: var(--hz-radius-pill);
  border: 1px solid var(--p2p-border);
}
.ag-wc-ant {
  font-size: 11px;
  background: rgba(244,115,115,.07);
  color: var(--err);
  padding: 2px 9px;
  border-radius: var(--hz-radius-pill);
  border: 1px solid rgba(244,115,115,.18);
}
.ag-wc-etym {
  font-size: 11px;
  color: var(--t3);
  line-height: 1.5;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
.ag-wc-tip {
  margin-top: 10px;
  background: var(--p2p-soft);
  border: 1px solid var(--p2p-border);
  border-radius: var(--hz-radius-8);
  padding: 8px 11px;
  font-size: 12px;
  color: var(--p2p);
  line-height: 1.5;
}

/* Level badges — consistent color system */
.lvl-A1 { background: rgba(34,197,94,.12);  color: #22c55e; border-color: rgba(34,197,94,.25); }
.lvl-A2 { background: rgba(132,204,22,.12); color: #84cc16; border-color: rgba(132,204,22,.25); }
.lvl-B1 { background: rgba(234,179,8,.12);  color: #eab308; border-color: rgba(234,179,8,.25); }
.lvl-B2 { background: rgba(249,115,22,.12); color: #f97316; border-color: rgba(249,115,22,.25); }
.lvl-C1 { background: rgba(239,68,68,.12);  color: #ef4444; border-color: rgba(239,68,68,.25); }
.lvl-C2 { background: rgba(220,38,38,.12);  color: #dc2626; border-color: rgba(220,38,38,.25); }

/* ══════════════════════════════════════════════════════════
   FOOD LOG CARD — Diet Coach
══════════════════════════════════════════════════════════ */
.ag-fc, .ag-food { max-width: 320px; }

.ag-fc-head, .ag-food-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.ag-fc-em, .ag-food-em { font-size: 26px; flex-shrink: 0; }
.ag-fc-info, .ag-food-info { flex: 1; min-width: 0; }
.ag-fc-name, .ag-food-nm {
  font-size: 15px;
  font-weight: 700;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ag-fc-kcal {
  font-size: 13px;
  color: var(--t2);
  margin-top: 2px;
}
.ag-food-ok { font-size: 12px; color: var(--t2); margin-top: 2px; }
.ag-fc-hs, .ag-food-kcal {
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Macro bar */
.ag-fc-bar, .ag-macro-bar {
  height: 4px;
  display: flex;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--hover);
}
.ag-macro-seg { min-width: 1px; }

/* Macros grid */
.ag-fc-macros, .ag-macro-grid {
  display: flex;
  gap: 0;
  padding: 10px 16px 12px;
}
.ag-macro-grid { gap: 6px; padding: 10px 16px 12px; }
.ag-fc-m {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 0;
  border-inline-end: 1px solid var(--border);
}
.ag-fc-m:last-child { border-inline-end: none; }
.ag-macro-cell {
  flex: 1;
  background: var(--hover);
  border-radius: var(--hz-radius-8);
  padding: 7px 4px;
  text-align: center;
}
.ag-macro-val { font-size: 13px; font-weight: 700; color: var(--t1); display: block; }
.ag-macro-lbl { font-size: 10px; color: var(--t3); margin-top: 1px; display: block; }

.ag-fc-msg, .ag-food-msg {
  padding: 8px 16px 12px;
  font-size: 13px;
  color: var(--t2);
  line-height: 1.5;
  border-top: 1px solid var(--border);
}

/* Health dots (legacy) */
.ag-hdots { display: flex; gap: 3px; align-items: center; }
.ag-hdot  { width: 6px; height: 6px; border-radius: 50%; }

/* ══════════════════════════════════════════════════════════
   WORKOUT CARD — Weight Coach / Fitness
══════════════════════════════════════════════════════════ */
.ag-wk, .ag-wo { max-width: 320px; }

.ag-wk-head, .ag-wo-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.ag-wk-em, .ag-wo-em { font-size: 26px; flex-shrink: 0; }
.ag-wk-info, .ag-wo-info { flex: 1; min-width: 0; }
.ag-wk-name, .ag-wo-nm {
  font-size: 15px;
  font-weight: 700;
  color: var(--t1);
}
.ag-wk-meta, .ag-wo-meta {
  font-size: 12px;
  color: var(--t2);
  margin-top: 3px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.ag-wk-burn {
  font-size: 15px;
  font-weight: 700;
  color: #f97316;
  flex-shrink: 0;
}
.ag-wk-int {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.ag-wk-msg, .ag-wo-msg, .ag-wo-body {
  padding: 10px 16px 12px;
  font-size: 13px;
  color: var(--t2);
  line-height: 1.5;
}

/* Zone badge */
.ag-zone {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--hz-radius-pill);
  border: 1px solid;
  font-weight: 600;
}
.ag-zone-lbl { font-size: 10px; color: var(--t3); }

/* Stats row */
.ag-wo-stats { display: flex; gap: 20px; padding: 10px 16px 0; }
.ag-wo-sv { font-size: 18px; font-weight: 700; color: var(--t1); display: block; }
.ag-wo-sl { font-size: 10px; color: var(--t3); }

/* Intensity bar */
.ag-int-bar, .ag-wk-int-bar {
  height: 3px;
  background: var(--hover);
  margin: 8px 16px;
  border-radius: var(--hz-radius-2);
  overflow: hidden;
}
.ag-int-fill {
  height: 100%;
  border-radius: var(--hz-radius-2);
}

/* ══════════════════════════════════════════════════════════
   WEIGHT LOG CARD
══════════════════════════════════════════════════════════ */
.ag-wt { max-width: 260px; }

.ag-wt-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.ag-wt-em { font-size: 28px; flex-shrink: 0; }
.ag-wt-kg {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.ag-wt-val { font-size: 28px; font-weight: 700; color: var(--t1); }
.ag-wt-unit { font-size: 14px; color: var(--t2); }
.ag-wt-delta { font-size: 13px; font-weight: 600; margin-top: 3px; }
.ag-wt-bmi   { font-size: 11px; color: var(--t3); margin-top: 2px; }
.ag-wt-loss  { color: var(--p2p); }
.ag-wt-gain  { color: var(--err); }
.ag-wt-msg   { padding: 10px 16px 12px; font-size: 13px; color: var(--t2); line-height: 1.5; }

/* ══════════════════════════════════════════════════════════
   TASK MANAGER CARD
══════════════════════════════════════════════════════════ */
.ag-tm { max-width: 380px; }

/* Header */
.ag-tm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.ag-tm-head-left { display: flex; align-items: center; gap: 7px; }
.ag-tm-head-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
}
.ag-tm-head-count {
  font-size: 11px;
  color: var(--t3);
  background: var(--hover);
  padding: 1px 7px;
  border-radius: var(--hz-radius-pill);
  border: 1px solid var(--border);
}
.ag-tm-head-right { display: flex; align-items: center; gap: 6px; }
.ag-tm-badge-today {
  font-size: 10px;
  font-weight: 700;
  color: var(--p2p);
  background: var(--p2p-soft);
  padding: 2px 8px;
  border-radius: var(--hz-radius-pill);
  border: 1px solid var(--p2p-border);
}
.ag-tm-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--t2);
}

/* Progress bar */
.ag-tm-progress {
  height: 2px;
  background: var(--hover);
}
.ag-tm-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--p2p));
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* Task list */
.ag-tm-list { padding: 4px 0; }

/* Task row */
.ag-tm-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-block: 8px; padding-inline: 0 12px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background .12s;
}
.ag-tm-row:last-child { border-bottom: none; }
.ag-tm-row:hover { background: var(--hover); }
.ag-tm-row.done .ag-tm-text { text-decoration: line-through; opacity: .45; }
.ag-tm-row.done .ag-tm-emoji { opacity: .3; }

/* Priority edge */
.ag-tm-prio-bar {
  width: 3px;
  position: absolute;
  inset-inline-start: 0; top: 0; bottom: 0;
  border-start-start-radius: 0; border-start-end-radius: var(--hz-radius-2); border-end-end-radius: var(--hz-radius-2); border-end-start-radius: 0;
}

/* Checkbox */
.ag-tm-cb {
  width: 28px; height: 28px;
  background: none; border: none;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: background .12s;
  margin-inline-start: 10px;
}
.ag-tm-cb:hover { background: var(--hover); }
.ag-tm-cb svg { width: 18px; height: 18px; }

/* Task content */
.ag-tm-body { flex: 1; min-width: 0; }
.ag-tm-title {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}
.ag-tm-emoji { font-size: 13px; flex-shrink: 0; }
.ag-tm-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--t1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all .2s;
}
.ag-tm-meta { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.ag-tm-due {
  font-size: 10px;
  font-weight: 700;
  padding: 1.5px 7px;
  border-radius: var(--hz-radius-pill);
  letter-spacing: .2px;
}
.ag-tm-prio-pill {
  font-size: 10px;
  padding: 1.5px 7px;
  border-radius: var(--hz-radius-pill);
  font-weight: 600;
}

/* Delete */
.ag-tm-del {
  width: 24px; height: 24px;
  background: none; border: none;
  cursor: pointer; color: var(--t3);
  opacity: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--hz-radius-6);
  transition: opacity .15s, background .12s, color .12s;
  flex-shrink: 0;
}
.ag-tm-row:hover .ag-tm-del { opacity: 1; }
.ag-tm-del:hover { background: rgba(244,115,115,.12); color: var(--err); }
.ag-tm-del svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* Footer */
.ag-tm-footer {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--t2);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* Empty state */
.ag-tm-empty {
  padding: 32px 20px;
  text-align: center;
}
.ag-tm-empty-ico { font-size: 32px; margin-bottom: 10px; }
.ag-tm-empty-title { font-size: 16px; font-weight: 700; color: var(--t1); margin-bottom: 4px; }
.ag-tm-empty-sub   { font-size: 13px; color: var(--t3); }

/* ══════════════════════════════════════════════════════════
   ADMIN DASHBOARD CARD
══════════════════════════════════════════════════════════ */
.ag-adm { max-width: 400px; }

.ag-adm-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.ag-adm-head svg {
  width: 14px; height: 14px;
  fill: none; stroke: var(--t3);
  stroke-width: 2; stroke-linecap: round;
  flex-shrink: 0;
}
.ag-adm-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t2);
  flex: 1;
}
.ag-adm-ts { font-size: 10px; color: var(--t3); font-family: 'JetBrains Mono', monospace; }

/* Stats grid */
.ag-adm-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 1px solid var(--border);
}
.ag-adm-stat {
  padding: 14px 12px;
  text-align: center;
  border-inline-end: 1px solid var(--border);
}
.ag-adm-stat:nth-child(3),
.ag-adm-stat:nth-child(6) { border-inline-end: none; }
.ag-adm-stat-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
  display: block;
}
.ag-adm-stat-lbl {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t3);
  display: block;
}

/* Online users */
.ag-adm-section {
  padding: 10px 16px 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--t3);
}
.ag-adm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  transition: background .12s;
}
.ag-adm-row:hover { background: var(--hover); }
.ag-adm-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  flex: 1;
}
.ag-adm-handle { font-size: 12px; color: var(--t2); }
.ag-adm-time {
  font-size: 11px;
  color: var(--t3);
  font-family: 'JetBrains Mono', monospace;
}
/* Online dot */
.ag-adm-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--p2p);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--p2p-soft);
}

/* ══════════════════════════════════════════════════════════
   CHIP SUGGESTIONS (agent action chips)
══════════════════════════════════════════════════════════ */
.ag-chips-bar, #agChips {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 10px 16px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right,
    transparent 0, #000 12px,
    #000 calc(100% - 12px), transparent 100%);
  /* Follow keyboard — same translation as .iz composer */
  transform: translateY(calc(var(--kb-inset, 0px) * -1));
  transition: transform .18s ease;
}
.ag-chips-bar::-webkit-scrollbar, #agChips::-webkit-scrollbar { display: none; }

/* Surface hand-off — the rail fades in when it takes the skills surface back
   from the empty-chat skill grid (the first message clears the grid; see
   skills-grid.js "ONE SKILLS SURFACE AT A TIME"). Added by showAgentChips only
   when the bar was actually off-screen, so a mid-conversation re-render never
   re-animates. OPACITY ONLY, and no fill-mode forwards: `transform` on the base
   rule above is owned by the keyboard-follow inset, and freezing an animated
   copy of it would strand the rail when the keyboard opens. */
@keyframes hz-agchips-enter { from { opacity: 0; } to { opacity: 1; } }
.ag-chips-bar.ag-chips-enter, #agChips.ag-chips-enter {
  animation: hz-agchips-enter var(--hz-dur) var(--hz-ease) backwards;
}
@media (prefers-reduced-motion: reduce) {
  .ag-chips-bar.ag-chips-enter, #agChips.ag-chips-enter { animation: none; }
}

@media (pointer: fine) { .ag-chips-bar, #agChips { cursor: grab; } }
.ag-chips-bar.is-dragging, #agChips.is-dragging { cursor: grabbing; user-select: none; }

/* ★ v72 Quick chips — elevated card with brand sparkle.
   Each chip is a small raised card with a colored gradient sparkle on the
   left (added by JS as <span class="ag-chip-spark"></span>). The chip's
   own background stays white/raised, so the sparkle does the brand work
   while the label stays readable. Hover only highlights the card with a
   brand-tinted shadow, so the row remains visually steady. */
.ag-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding-block: 0; padding-inline: 11px 16px;
  height: 44px;
  border-radius: var(--hz-radius-14);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.005em;
  white-space: nowrap;
  cursor: pointer;
  border: 0.5px solid var(--border);
  background: var(--raised);
  color: var(--t1);
  box-shadow: 0 2px 8px rgba(0,0,0,.04), 0 1px 0 rgba(255,255,255,.04) inset;
  transition: background .18s, color .18s, box-shadow .18s, border-color .15s;
  flex-shrink: 0;
  font-family: inherit;
  line-height: 1;
}
/* The leading "✦ Skills" chip — the gateway to the full skill tray (HzSkills).
   Brand-tinted label so it reads as the entry point, distinct from the neutral
   quick-chips beside it; the ✦ tile stays the shared spark gradient. Two selectors
   so the tint out-specs both the base `.ag-chip` (dark) and the
   `[data-theme="light"] .ag-chip` colour override (light) — no !important. */
.ag-chip.ag-chip--skills,
[data-theme="light"] .ag-chip.ag-chip--skills { color: var(--accent); font-weight: 600; }

/* The brand sparkle — gradient tile on the left of every chip.
   JS injects <span class="ag-chip-spark"></span> as the first child.
   Default (no modifier class): the action blue + ✦ glyph. */
.ag-chip-spark {
  width: 24px; height: 24px; border-radius: var(--hz-radius-6);
  background: var(--hz-action-gradient);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px color-mix(in srgb, var(--hz-blue-action) 30%, transparent);
  font-size: 12px; line-height: 1; color: #fff;
  position: relative;
}
/* Default ✦ — shown only on the base (unmodified) tile.
   Any category modifier hides this so the SVG glyph shows instead. */
.ag-chip-spark::before {
  content: '✦';
  font-size: 11px; line-height: 1;
  font-weight: 600;
}
.ag-chip-spark.food::before,
.ag-chip-spark.drink::before,
.ag-chip-spark.sport::before,
.ag-chip-spark.stats::before,
.ag-chip-spark.time::before,
.ag-chip-spark.love::before,
.ag-chip-spark.joke::before,
.ag-chip-spark.info::before,
.ag-chip-spark.think::before,
.ag-chip-spark.plant::before,
.ag-chip-spark.image::before,
.ag-chip-spark.music::before,
.ag-chip-spark.book::before,
.ag-chip-spark.chat::before,
.ag-chip-spark.code::before,
.ag-chip-spark.edit::before,
.ag-chip-spark.sparkle::before,
.ag-chip-spark.translate::before,
.ag-chip-spark.calendar::before,
.ag-chip-spark.money::before,
.ag-chip-spark.lightning::before,
.ag-chip-spark.location::before,
.ag-chip-spark.mail::before,
.ag-chip-spark.checklist::before,
.ag-chip-spark.plus::before,
.ag-chip-spark.video::before,
.ag-chip-spark.check::before,
.ag-chip-spark.search::before,
.ag-chip-spark.note::before,
.ag-chip-spark.sound::before { content: none; }

/* SVG glyph inside category tiles — fixed size, white stroke */
.ag-chip-spark svg { width: 14px; height: 14px; display: block; }

/* ── Category gradients — same tile shape, different color family.
   Shadow tint uses the mid-color of each gradient so the glow feels
   native to the category. ── */
.ag-chip-spark.food  { background: linear-gradient(135deg, #FF9E3D 0%, #FFB95D 100%); box-shadow: 0 2px 6px rgba(239,159,39,.30); }
.ag-chip-spark.drink { background: linear-gradient(135deg, #378ADD 0%, #5DA8F0 100%); box-shadow: 0 2px 6px rgba(55,138,221,.30); }
.ag-chip-spark.sport { background: linear-gradient(135deg, #1D9E75 0%, #5DCAA5 100%); box-shadow: 0 2px 6px rgba(29,158,117,.30); }
.ag-chip-spark.stats { background: linear-gradient(135deg, #2F5FD0 0%, #5B8DEF 100%); box-shadow: 0 2px 6px rgba(47,95,208,.30); }
.ag-chip-spark.time  { background: linear-gradient(135deg, #1A86CF 0%, #3DB9E8 100%); box-shadow: 0 2px 6px rgba(26,134,207,.30); }
.ag-chip-spark.love  { background: linear-gradient(135deg, #D4537E 0%, #ED93B1 100%); box-shadow: 0 2px 6px rgba(212,83,126,.30); }
.ag-chip-spark.joke  { background: linear-gradient(135deg, #E5487A 0%, #FF9E3D 100%); box-shadow: 0 2px 6px rgba(229,72,122,.30); }
.ag-chip-spark.info  { background: linear-gradient(135deg, #378ADD 0%, #85B7EB 100%); box-shadow: 0 2px 6px rgba(55,138,221,.30); }
.ag-chip-spark.think { background: linear-gradient(135deg, #BA7517 0%, #EF9F27 100%); box-shadow: 0 2px 6px rgba(186,117,23,.30); }
.ag-chip-spark.plant { background: linear-gradient(135deg, #639922 0%, #97C459 100%); box-shadow: 0 2px 6px rgba(99,153,34,.30); }
.ag-chip-spark.image { background: linear-gradient(135deg, #1A86CF 0%, #3DB9E8 100%); box-shadow: 0 2px 6px rgba(26,134,207,.30); }
.ag-chip-spark.music { background: linear-gradient(135deg, #D4537E 0%, #FF8A5B 100%); box-shadow: 0 2px 6px rgba(212,83,126,.30); }
.ag-chip-spark.book  { background: linear-gradient(135deg, #BA7517 0%, #D4537E 100%); box-shadow: 0 2px 6px rgba(186,117,23,.30); }
.ag-chip-spark.chat      { background: linear-gradient(135deg, #2F5FD0 0%, #5B8DEF 100%); box-shadow: 0 2px 6px rgba(47,95,208,.30); }
.ag-chip-spark.code      { background: linear-gradient(135deg, #1D9E75 0%, #378ADD 100%); box-shadow: 0 2px 6px rgba(55,138,221,.30); }
.ag-chip-spark.edit      { background: linear-gradient(135deg, #BA7517 0%, #EF9F27 100%); box-shadow: 0 2px 6px rgba(186,117,23,.30); }
.ag-chip-spark.sparkle   { background: linear-gradient(135deg, #2F5FD0 0%, #3DB9E8 100%); box-shadow: 0 2px 6px rgba(47,95,208,.30); }
.ag-chip-spark.translate { background: linear-gradient(135deg, #378ADD 0%, #2F5FD0 100%); box-shadow: 0 2px 6px rgba(55,138,221,.30); }
.ag-chip-spark.calendar  { background: linear-gradient(135deg, #D4537E 0%, #FF9E3D 100%); box-shadow: 0 2px 6px rgba(212,83,126,.30); }
.ag-chip-spark.money     { background: linear-gradient(135deg, #1D9E75 0%, #97C459 100%); box-shadow: 0 2px 6px rgba(29,158,117,.30); }
.ag-chip-spark.lightning { background: linear-gradient(135deg, #BA7517 0%, #FFD56F 100%); box-shadow: 0 2px 6px rgba(186,117,23,.30); }
.ag-chip-spark.location  { background: linear-gradient(135deg, #D85A30 0%, #FF9E3D 100%); box-shadow: 0 2px 6px rgba(216,90,48,.30); }
.ag-chip-spark.mail      { background: linear-gradient(135deg, #2F5FD0 0%, #378ADD 100%); box-shadow: 0 2px 6px rgba(47,95,208,.30); }
.ag-chip-spark.checklist { background: linear-gradient(135deg, #2F5FD0 0%, #5B8DEF 100%); box-shadow: 0 2px 6px rgba(47,95,208,.30); }
.ag-chip-spark.plus      { background: linear-gradient(135deg, #1D9E75 0%, #5DCAA5 100%); box-shadow: 0 2px 6px rgba(29,158,117,.30); }
.ag-chip-spark.video     { background: linear-gradient(135deg, #378ADD 0%, var(--hz-accent-cyan) 100%); box-shadow: 0 2px 6px rgba(55,138,221,.30); }
.ag-chip-spark.check     { background: linear-gradient(135deg, #1D9E75 0%, #97C459 100%); box-shadow: 0 2px 6px rgba(29,158,117,.30); }
.ag-chip-spark.search    { background: linear-gradient(135deg, #378ADD 0%, #85B7EB 100%); box-shadow: 0 2px 6px rgba(55,138,221,.30); }
.ag-chip-spark.note      { background: linear-gradient(135deg, #BA7517 0%, #EF9F27 100%); box-shadow: 0 2px 6px rgba(186,117,23,.30); }
.ag-chip-spark.sound     { background: linear-gradient(135deg, #D4537E 0%, #FF8A5B 100%); box-shadow: 0 2px 6px rgba(212,83,126,.30); }
.ag-chip:hover {
  box-shadow: 0 6px 18px color-mix(in srgb, var(--hz-brand) 18%, transparent), 0 2px 6px rgba(0,0,0,.06);
  border-color: color-mix(in srgb, var(--hz-brand) 20%, transparent);
}
.ag-chip:active {
  transform: translateY(0) scale(.97);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* History chips — dashed, slightly muted (sparkle hidden) */
.ag-chip-hist {
  border-style: dashed;
  color: var(--t2);
  background: transparent;
  box-shadow: none;
}
.ag-chip-hist .ag-chip-spark { display: none; }
.ag-chip-hist:hover {
  background: var(--accent-soft);
  border-style: solid;
  border-color: color-mix(in srgb, var(--hz-brand) 30%, transparent);
  color: var(--accent-2);
}

/* ══════════════════════════════════════════════════════════
   MARKETPLACE
══════════════════════════════════════════════════════════ */
#agMktPanel {
  position: fixed;
  inset: 0;
  background: var(--void);
  z-index: 80;
  display: none;
  flex-direction: column;
  animation: slideInRight .22s var(--ease, cubic-bezier(.4,0,.2,1)) both;
}
#agMktPanel.show { display: flex; }

.mkt-hdr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  padding-top: calc(18px + var(--st));
  border-bottom: 1px solid var(--border);
  background: var(--hz-surface-panelhdr, rgba(9,9,22,.92));
  backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
  -webkit-backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
  box-shadow: var(--hz-panelhdr-shadow, none);
  flex-shrink: 0;
}
.mkt-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.35px;
  flex: 1;
  color: var(--t1);
}
.mkt-close {
  width: 34px; height: 34px;
  border: none; background: transparent;
  border-radius: 50%; color: var(--accent);
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .13s;
}
.mkt-close:hover { background: var(--accent-soft); }
.mkt-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.mkt-srch {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  display: flex;
  gap: 8px;
}
.mkt-srch input {
  flex: 1;
  background: var(--raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--hz-radius-10);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--t1);
  outline: none;
  transition: border-color .15s;
}
.mkt-srch input:focus { border-color: var(--accent); }
.mkt-srch input::placeholder { color: var(--t3); }

.mkt-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.mkt-tab {
  padding: 5px 14px;
  border-radius: var(--hz-radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--t2);
  font-family: inherit;
  transition: all .15s;
}
.mkt-tab.on { background: var(--accent-soft); color: var(--accent-2); border-color: color-mix(in srgb, var(--hz-brand) 32%, transparent); }

.mkt-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  -webkit-overflow-scrolling: touch;
}
.mkt-section-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 12px 4px 8px;
}

.mkt-card {
  background: var(--surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--hz-radius-14);
  overflow: hidden;
  margin-bottom: 8px;
  transition: border-color .15s;
}
.mkt-card:hover { border-color: var(--accent); }
.mkt-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 10px;
  cursor: pointer;
}
.mkt-av {
  width: 42px; height: 42px;
  border-radius: var(--hz-radius-avatar);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.mkt-info { flex: 1; min-width: 0; }
.mkt-name-row { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.mkt-name { font-size: 14px; font-weight: 700; color: var(--t1); }
.mkt-badge { font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: var(--accent-soft); color: var(--accent-2); padding: 1px 6px; border-radius: var(--hz-radius-pill); border: 1px solid color-mix(in srgb, var(--hz-brand) 22%, transparent); }
.mkt-tag { font-size: 12px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mkt-arrow { color: var(--t3); flex-shrink: 0; }
.mkt-arrow svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

.mkt-card-actions {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
}
.mkt-act {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--hz-radius-8);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-mid);
  background: var(--raised);
  color: var(--t2);
  font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: all .13s;
}
.mkt-act:hover { background: var(--hover); color: var(--t1); }
.mkt-act.primary { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--hz-brand) 28%, transparent); }
.mkt-act.primary:hover { background: color-mix(in srgb, var(--hz-brand) 18%, transparent); }
.mkt-act svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

.mkt-fab {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  inset-inline-end: 16px;
  width: 48px; height: 48px;
  background: var(--accent);
  border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px var(--accent-glow);
  transition: transform .15s, box-shadow .15s;
  z-index: 5;
}
.mkt-fab:hover { transform: scale(1.08); box-shadow: 0 6px 22px var(--accent-glow); }
.mkt-fab svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2.5; stroke-linecap: round; }

.mkt-empty { padding: 48px 20px; text-align: center; }
.mkt-empty-ic { font-size: 36px; margin-bottom: 12px; }
.mkt-empty-ttl { font-size: 16px; font-weight: 700; color: var(--t1); margin-bottom: 4px; }
.mkt-empty-sub  { font-size: 13px; color: var(--t2); }

/* ══════════════════════════════════════════════════════════
   AGENT SHARE OVERLAY
══════════════════════════════════════════════════════════ */
.ag-share-url {
  background: var(--raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--hz-radius-10);
  padding: 9px 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
  transition: border-color .15s;
  word-break: break-all;
}
.ag-share-url:hover { border-color: var(--accent); color: var(--t1); }

/* ══════════════════════════════════════════════════════════
   DAILY STATS WIDGET
══════════════════════════════════════════════════════════ */
.ag-ds-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--raised);
  border-radius: var(--hz-radius-12);
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--t2);
}
.ag-ds-val { font-weight: 700; color: var(--t1); }

/* ══════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
══════════════════════════════════════════════════════════ */

/* In light mode, cards need stronger shadow for depth on light canvas */
[data-theme="light"] .ag-wc,
[data-theme="light"] .ag-fc, [data-theme="light"] .ag-food,
[data-theme="light"] .ag-wk, [data-theme="light"] .ag-wo,
[data-theme="light"] .ag-wt,
[data-theme="light"] .ag-tm,
[data-theme="light"] .ag-adm {
  background: #FFFFFF;
  border-color: rgba(37,105,220,.12);
  box-shadow:
    0 1px 2px rgba(0,0,0,.06),
    0 4px 16px rgba(0,0,0,.08);
}

/* Live .ag-chip light theme (supersedes the earlier duplicate that was deleted).
   Out-specifies the base .ag-chip by [data-theme], so no !important needed. */
[data-theme="light"] .ag-chip {
  background: #FFFFFF;
  border: 1.5px solid rgba(0,0,0,.14);
  color: #1a1a2e;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
  font-weight: 500;
}
[data-theme="light"] .ag-chip:hover {
  background: color-mix(in srgb, var(--hz-brand) 7%, transparent);
  border-color: color-mix(in srgb, var(--hz-brand) 38%, transparent);
  color: var(--hz-blue-700);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--hz-brand) 14%, transparent);
}
[data-theme="light"] .ag-chip-hist {
  background: transparent;
  border-color: color-mix(in srgb, var(--hz-brand) 30%, transparent);
  color: var(--hz-blue-700);
}

/* Agent plain text on light canvas */
[data-theme="light"] .mg.ag .bub {
  color: var(--t1) !important;
}

/* Marketplace in light */
[data-theme="light"] #agMktPanel { background: #EFEFF4; }
/* .mkt-hdr light flips via --hz-surface-panelhdr / --hz-panelhdr-blur / --hz-panelhdr-shadow. */
[data-theme="light"] .mkt-title  { color: #000000; }
[data-theme="light"] .mkt-close  { color: var(--accent); }
[data-theme="light"] .mkt-srch   { background: #FFFFFF; border-bottom-color: rgba(0,0,0,.08); }
[data-theme="light"] .mkt-srch input { background: var(--hz-paper-100); border-color: rgba(0,0,0,.10); color: #000; }
[data-theme="light"] .mkt-srch input:focus { border-color: color-mix(in srgb, var(--hz-brand) 45%, transparent); background: #FFF; }
[data-theme="light"] .mkt-tabs   { background: #FFFFFF; border-bottom-color: rgba(0,0,0,.08); }
[data-theme="light"] .mkt-tab    { border-color: rgba(0,0,0,.12); color: var(--hz-text-lite-2); }
[data-theme="light"] .mkt-tab.on { background: color-mix(in srgb, var(--hz-brand) 9%, transparent); color: var(--hz-brand); border-color: color-mix(in srgb, var(--hz-brand) 28%, transparent); }
[data-theme="light"] .mkt-card   { background: #FFFFFF; border-color: rgba(0,0,0,.10); }
[data-theme="light"] .mkt-card:hover { border-color: color-mix(in srgb, var(--hz-brand) 35%, transparent); }
[data-theme="light"] .mkt-name   { color: #000000; }
[data-theme="light"] .mkt-tag    { color: var(--hz-text-lite-2); }
[data-theme="light"] .mkt-act    { background: var(--hz-paper-100); color: var(--hz-text-lite-2); border-color: rgba(0,0,0,.10); }
[data-theme="light"] .mkt-act.primary { background: color-mix(in srgb, var(--hz-brand) 9%, transparent); color: var(--hz-brand); border-color: color-mix(in srgb, var(--hz-brand) 26%, transparent); }
[data-theme="light"] .ag-chips-bar { background: transparent; border-bottom: none; }


/* ── modal-system.css ── */

/* ═══════════════════════════════════════════════════════════════════════════
   HARIZMA — UNIFIED MODAL DESIGN SYSTEM
   Single source of truth for all modals across all addons.
   ═══════════════════════════════════════════════════════════════════════════

   Structure every modal like this:

   <div class="moverlay" id="myOv">
     <div class="modal">
       <div class="mh">                          ← header
         <div class="mh-info">
           <div class="mh-title">Title</div>
           <div class="mh-sub">Optional subtitle</div>
         </div>
         <button class="mclose">✕</button>
       </div>
       <div class="mbody">…</div>               ← scrollable content
       <div class="mfoot">                       ← footer buttons
         <button class="btn bsec">Cancel</button>
         <button class="btn bp">Confirm</button>
       </div>
     </div>
   </div>

   For branded agent modals (with gradient header), add .mh-gradient before .mbody.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Overlay ── */
.moverlay {
  position: fixed; inset: 0;
  background: var(--hz-overlay-scrim, rgba(0,0,0,.6));
  backdrop-filter: var(--hz-overlay-blur, blur(12px)); -webkit-backdrop-filter: var(--hz-overlay-blur, blur(12px));
  z-index: 10100;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; pointer-events: none;
  /* visibility:hidden (not just opacity/pointer-events) takes every field
     inside a closed modal out of the tab/keyboard-navigation order. Without
     it, iOS treats #pidIn (below) as a second focusable text field reachable
     from the chat composer and shows its Previous/Next keyboard accessory
     bar even though the modal is invisible and unclickable. The delay on
     the closed-state transition lets the opacity fade-out finish before the
     element actually leaves the accessibility tree; opening has no delay so
     it becomes focusable the instant it becomes visible. */
  visibility: hidden;
  transition: opacity .2s cubic-bezier(.4,0,.2,1), padding-bottom .15s ease, visibility 0s linear .2s;
}
.moverlay.open { opacity: 1; visibility: visible; pointer-events: all; transition: opacity .2s cubic-bezier(.4,0,.2,1), padding-bottom .15s ease; }

/* ── Modal card ── */
.modal {
  background: var(--surface);
  border: var(--hz-elevation-border, 1px solid var(--border-mid));
  border-radius: var(--hz-radius-20);
  width: 100%; max-width: 440px;
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow: hidden;
  display: flex; flex-direction: column;
  transform: scale(.96) translateY(8px);
  transition: transform .22s cubic-bezier(.34,1.2,.64,1);
  box-shadow: var(--hz-modal-shadow, 0 24px 80px rgba(0,0,0,.55), 0 4px 16px rgba(0,0,0,.25));
}
.moverlay.open .modal { transform: none; }

/* ── Header ── */
.mh {
  display: flex; align-items: center;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px; flex-shrink: 0;
}
.mh-icon {
  width: 36px; height: 36px; border-radius: var(--hz-radius-10); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.mh-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mh-info { flex: 1; min-width: 0; }
.mh-title { font-size: 15px; font-weight: 700; color: var(--t1); line-height: 1.2; }
.mh-sub   { font-size: 12px; color: var(--t3); margin-top: 2px; }

/* Legacy .mt alias — keep working */
.mt { font-size: 15px; font-weight: 700; color: var(--t1); display: flex; align-items: center; gap: 8px; }
.mt svg { width: 16px; height: 16px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.mt.p2t svg { stroke: var(--p2p); }

/* ── Close button ── */
.mclose {
  width: 30px; height: 30px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: var(--hover); color: var(--t2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .13s, color .13s;
  margin-inline-start: auto;
}
.mclose:hover { background: var(--active); color: var(--t1); }
.mclose svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* ── Gradient header (branded agent modals) ── */
.mh-gradient {
  padding: 24px 20px 20px;
  flex-shrink: 0;
  position: relative;
}
.mh-gradient .mclose-abs {
  position: absolute; top: 14px; inset-inline-end: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.2); border: none;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .13s;
}
.mh-gradient .mclose-abs:hover { background: rgba(0,0,0,.35); }
.mh-gradient .mclose-abs svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

/* ── Body ── */
.mbody {
  overflow-y: auto; flex: 1; min-height: 0;
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.mbody::-webkit-scrollbar { width: 0; }

/* ── Footer ── */
.mfoot {
  padding: 12px 18px 14px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  flex-shrink: 0;
}

/* ── Form fields (inside .mbody) ── */
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld label {
  font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--t3);
}
/* .fld form fields → the shared .hz-input atom (app input register in :root);
   bespoke input/select/textarea rules removed in the Phase-3 field migration. */
.fld .hint { font-size: 12px; color: var(--t3); line-height: 1.5; }
.frow { display: flex; gap: 7px; align-items: flex-end; }

/* ── Status rows ── */
.srow { display: flex; align-items: flex-start; gap: 7px; padding: 9px 12px; border-radius: var(--hz-radius-10); font-size: 13px; font-weight: 500; border: 1px solid transparent; }
.srow.ok   { background: var(--p2p-soft);            border-color: var(--p2p-border);              color: var(--p2p); }
.srow.er   { background: rgba(255,85,102,.08);        border-color: rgba(255,85,102,.2);             color: var(--err); }
.srow.pe   { background: rgba(255,179,64,.08);        border-color: rgba(255,179,64,.2);             color: var(--warn); }
.srow svg  { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; flex-shrink: 0; margin-top: 1px; }

/* ── Url row (share modals) ── */
.murl-row {
  display: flex; align-items: center; gap: 0;
  background: var(--raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--hz-radius-12); overflow: hidden;
}
.murl-text {
  flex: 1; padding: 11px 13px;
  font-size: 12px; font-family: 'JetBrains Mono', monospace;
  color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.murl-copy {
  flex-shrink: 0; width: 42px; height: 42px;
  background: var(--hover); border: none;
  border-inline-start: 1px solid var(--border-mid);
  cursor: pointer; color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: background .13s, color .13s;
}
.murl-copy:hover { background: var(--active); color: var(--t1); }
.murl-copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Buttons ──
   Migrated to the shared .hz-btn atom (see the app button register in :root).
   .btn.bp → .hz-btn.hz-btn--primary, .btn.bsec → .hz-btn.hz-btn--secondary,
   .btn.bdng → .hz-btn.hz-btn--danger-soft. The old bespoke base + variants and
   their [data-theme="light"] !important patches were removed. */

/* ── Share modal two-button row ── */
.mbtn-row {
  display: flex; gap: 10px; margin-top: 4px;
}
.mbtn-row .hz-btn { flex: 1; height: 44px; font-size: 14px; }

/* ── Section label inside body ── */
.mlabel {
  font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--t3);
}

/* ── Member/peer option row ── */
.mopt {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--hz-radius-10);
  cursor: pointer; border: 1px solid transparent;
  background: var(--raised);
  transition: border-color .12s, background .12s;
  user-select: none;
}
.mopt:hover { background: var(--hover); }
.mopt.selected { border-color: var(--p2p-border); background: var(--p2p-soft); }
.mopt-av { width: 34px; height: 34px; border-radius: var(--hz-radius-avatar); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 600; }
/* The name + caption column takes the row's free width, so the check sits at
   the row's end — not right after the name (it did, with the column sized to
   its text). */
.mopt-body { flex: 1; min-width: 0; }
.mopt-name { font-size: 14px; font-weight: 500; color: var(--t1); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mopt-sub  { font-size: 12px; color: var(--t3); }
.mopt-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .12s;
}
.mopt.selected .mopt-check { background: var(--p2p); border-color: var(--p2p); }

/* ── Emoji picker ── */
.moji-grid {
  display: flex; flex-wrap: wrap; gap: 7px;
}
.moji-btn {
  width: 44px; height: 44px; border-radius: var(--hz-radius-10);
  border: 2px solid transparent;
  background: var(--raised);
  font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .12s, background .12s, transform .1s;
}
.moji-btn:hover { background: var(--hover); transform: scale(1.08); }
.moji-btn.selected { border-color: var(--accent); background: var(--accent-soft); }

/* ── Light mode ── */
/* .moverlay scrim + .modal border/shadow flip via the elevation tokens (above).
   The canonical light values now live in tokens.css, not here. */
[data-theme="light"] .mh         { border-bottom-color: rgba(0,0,0,.07); }
[data-theme="light"] .mh-title   { color: #000; }
[data-theme="light"] .mh-sub     { color: #888; }
[data-theme="light"] .mclose     { background: var(--hz-paper-100); color: #555; }
[data-theme="light"] .mclose:hover { background: #E5E5E5; color: #000; }
[data-theme="light"] .mfoot      { background: #FAFAFA; border-top-color: rgba(0,0,0,.07); }
[data-theme="light"] .murl-row   { background: var(--hz-paper-100); border-color: rgba(0,0,0,.1); }
[data-theme="light"] .murl-copy  { background: var(--hz-paper-200); border-inline-start-color: rgba(0,0,0,.1); }
[data-theme="light"] .murl-copy:hover { background: #DCDCDC; color: #000; }
[data-theme="light"] .mopt       { background: #F5F5F5; border-color: transparent; }
[data-theme="light"] .mopt:hover { background: #EBEBEB; }
[data-theme="light"] .mopt-name  { color: #000; }
[data-theme="light"] .moji-btn   { background: var(--hz-paper-100); }
[data-theme="light"] .moji-btn:hover { background: #E5E5E5; }
[data-theme="light"] .mlabel     { color: #999; }

/* Light-mode button values are driven by the app button register's
   [data-theme="light"] token overrides (see the light-theme block above) —
   the former .btn.bp / .btn.bsec !important patches were removed. */

/* ── Chat loading spinner ── */
.chat-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 240px;
  gap: 12px;
  pointer-events: none;
}
.chat-spinner .cs-ring {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2.5px solid var(--border-mid);
  border-top-color: var(--accent);
  animation: cs-spin .65s linear infinite;
  flex-shrink: 0;
}
.chat-spinner .cs-label {
  font-size: 12px;
  color: var(--t3);
  letter-spacing: .02em;
}
@keyframes cs-spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 640px) {
  .modal { border-radius: var(--hz-radius-24); max-width: 100%; }
  .moverlay { padding: 12px 12px max(12px, env(safe-area-inset-bottom, 0px)) 12px; align-items: flex-end; }
  .modal { border-end-start-radius: 0; border-end-end-radius: 0; max-height: 92vh; max-height: 92dvh; }
}

/* ── Agent streaming bubble ─────────────────────────────────────────────── */
/* Clean live text with blinking cursor — like Claude / ChatGPT              */

.bub.stream-bub {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}

/* The streamed text — normal readable font */
.stream-text {
  color: var(--t1);
  font-size: inherit;
  line-height: inherit;
}

/* Blinking cursor — thin vertical bar, same as code editors */
.stream-cur {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent);
  border-radius: var(--hz-radius-2);
  margin-inline-start: 1px;
  vertical-align: text-bottom;
  animation: stream-blink .5s step-end infinite;
  opacity: 1;
}
@keyframes stream-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Light mode */
[data-theme="light"] .stream-text { color: #000; }
[data-theme="light"] .stream-cur  { background: var(--accent, var(--hz-brand)); }

/* ── AI Filter chip selected states — light mode fix ────────────────────────
   light-theme.css sets background/border/color with !important on .pchip
   which kills all .on states. Override here since modal-system loads last.  */
[data-theme="light"] .pchip.on {
  color: #fff;
  box-shadow: none;
  transform: none;
}
[data-theme="light"] .pchip[data-color="purple"].on {
  background: var(--hz-action-gradient);
  border-color: var(--hz-brand);
}
[data-theme="light"] .pchip[data-color="orange"].on {
  background: linear-gradient(135deg, #FF8C00, #FFB340);
  border-color: #FF8C00;
}
[data-theme="light"] .pchip[data-color="blue"].on {
  background: linear-gradient(135deg, var(--hz-brand), var(--hz-brand-2));
  border-color: var(--hz-brand);
}
[data-theme="light"] .pchip[data-color="green"].on {
  background: linear-gradient(135deg, #22C55E, #4ADE80);
  border-color: #22C55E;
}
[data-theme="light"] .pchip[data-color="pink"].on {
  background: linear-gradient(135deg, #EC4899, #F472B6);
  border-color: #EC4899;
}
[data-theme="light"] .pchip[data-color="yellow"].on {
  background: linear-gradient(135deg, #F59E0B, #FCD34D);
  border-color: #F59E0B;
  color: #fff;
}
[data-theme="light"] .pchip[data-color="teal"].on {
  background: linear-gradient(135deg, #14B8A6, #2DD4BF);
  border-color: #14B8A6;
}
[data-theme="light"] .pchip[data-color="gray"].on {
  background: #374151;
  border-color: #374151;
}

/* ── Kill the aif-presets mask from design.css — it clips the first chip ── */
.aif-presets {
  -webkit-mask-image: none !important;
  mask-image: none !important;
}

/* ── Emoji-only bubbles — override all theme backgrounds ── */
.mg.out .bub.bub-emoji,
.mg.in  .bub.bub-emoji,
[data-theme="light"] .mg.out .bub.bub-emoji,
[data-theme="light"] .mg.in  .bub.bub-emoji {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 2px 4px;
  font-size: var(--hz-bubble-emoji-font-size);
  line-height: var(--hz-bubble-emoji-line-height);
  max-width: none;
}

/* ── Beautiful Code Blocks ───────────────────────────────────────────────── */
.code-block {
  direction: ltr;               /* code reads LTR in every language; header chrome follows it */
  margin: 10px 0;
  border-radius: var(--hz-radius-12);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.10);
  background: #161B22;
  font-size: 13px;
  box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.cb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  background: #1C2128;
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 34px;
}
.cb-lang {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 600;
  color: #58A6FF;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.cb-copy {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: #8B949E;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--hz-radius-6);
  padding: 3px 10px;
  cursor: pointer;
  transition: background .13s, color .13s, border-color .13s;
  margin-inline-start: auto;
}
.cb-copy:hover { background: rgba(255,255,255,.10); color: #E6EDF3; border-color: rgba(255,255,255,.22); }
.cb-copy:active { transform: scale(.95); }
.cb-copy.ok { color: var(--p2p); border-color: var(--p2p-border); background: rgba(37,208,126,.08); }
.code-block pre {
  margin: 0 !important;
  padding: 14px 16px !important;
  overflow-x: auto !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.code-block pre code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace !important;
  font-size: 13px !important;
  line-height: 1.55 !important;
  color: #E6EDF3 !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  white-space: pre !important;
  tab-size: 2 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
/* Light mode */
[data-theme="light"] .code-block {
  background: #F6F8FA !important;
  border-color: rgba(0,0,0,.12) !important;
  box-shadow: 0 1px 6px rgba(0,0,0,.08) !important;
}
[data-theme="light"] .cb-header {
  background: #EAEEF2 !important;
  border-bottom-color: rgba(0,0,0,.10) !important;
}
[data-theme="light"] .cb-lang { color: #0969DA !important; }
[data-theme="light"] .cb-copy {
  color: #57606A !important;
  background: rgba(0,0,0,.04) !important;
  border-color: rgba(0,0,0,.14) !important;
}
[data-theme="light"] .cb-copy:hover { background: rgba(0,0,0,.08) !important; color: #24292F !important; }
[data-theme="light"] .cb-copy.ok { color: #17a05e !important; border-color: rgba(37,208,126,.30) !important; background: rgba(37,208,126,.07) !important; }
[data-theme="light"] .code-block pre { background: transparent !important; }
[data-theme="light"] .code-block pre code { color: #24292F !important; background: transparent !important; }

/* ── Prompt card ─────────────────────────────────────────────────────────────
   A ready-to-run prompt an agent (AI Tutor) hands the user. enhanceCodeBlocks()
   upgrades a ```prompt fenced block into this card.

   Design-system native by construction:
   • Surface = DS card tokens (--hz-card-bg / -border / -radius / -shadow), so it
     is exactly a chat card and flips light/dark on its own — NO [data-theme]
     overrides, no bespoke hexes.
   • Copy button = the shared .hz-btn atom (.hz-btn--secondary.hz-btn--sm, applied
     in enhanceCodeBlocks) — the same control the agent share-card uses in chat —
     so it inherits the DS tap target, hover-gating, touch handling and press.
   • One restrained brand cue: a faint --accent-soft header wash + an "✨ Prompt"
     accent label mark it as a distinct artifact (no accent rails / heavy tints).
   • Body wraps as readable prose (--hz-font-body, pre-wrap) — never a sideways-
     scrolling monospace block — so it reads well from narrow phones to desktop.
   Separate class tree from .code-block so it inherits none of its forced rules. */
.prompt-card {
  margin: 10px 0;
  border-radius: var(--hz-card-radius);
  overflow: hidden;
  background: var(--hz-card-bg);
  border: 1px solid var(--hz-card-border);
  box-shadow: var(--hz-card-shadow);
}
.prompt-card .pc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hz-space-3);
  padding-block: var(--hz-space-2); padding-inline: var(--hz-space-4) var(--hz-space-2);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--hz-border);
}
.prompt-card .pc-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-family: var(--hz-font-body);
  font-size: var(--hz-text-sm);
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
}
.prompt-card .pc-label::before { content: '✨'; font-size: 13px; line-height: 1; }
/* The button itself is the DS .hz-btn--secondary.hz-btn--sm atom — base look,
   hover-gating, tap target and press all come from there. Only the copied-
   confirmation state and a focus ring (the app root isn't .hz-root, so the DS
   focus rule doesn't reach here) are bespoke. */
.prompt-card .pc-copy { flex-shrink: 0; }
.prompt-card .pc-copy.ok {
  color: var(--p2p);
  border-color: var(--p2p-border);
  background: var(--p2p-soft);
}
.prompt-card .pc-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.prompt-card pre { margin: 0; overflow-x: auto; }
/* The prompt is natural language, not code: each paragraph takes the direction of its
   own first strong letter (overrides atoms.css pre/code → LTR). */
.prompt-card pre, .prompt-card pre code { unicode-bidi: plaintext; text-align: start; }
.prompt-card pre code {
  display: block;
  padding: var(--hz-space-4);
  background: transparent;
  border: none;
  border-radius: 0;
  font-family: var(--hz-font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--hz-text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── App card — an app built in chat (```hz-app marker, chat-apps) ──
   Rendered by fmt.js enhanceCodeBlocks as static markup; opened by
   public/js/addons/apps-addon.js. Same DS card surface as .prompt-card; the
   buttons are the shared .hz-btn atoms. Icon tile uses the brand register so
   the card reads as "something you run", not text to read.
   The PDF card (```hz-pdf marker, doc-files; fmt.js _pdfCard, opened by
   public/js/addons/pdf-docs-addon.js) is the same card: one rule set, two
   class trees (each addon binds only its own). */
.hz-app-card,
.hz-pdf-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--hz-space-3);
  margin: var(--hz-space-2) 0;
  padding: var(--hz-space-3);
  border-radius: var(--hz-card-radius);
  background: var(--hz-card-bg);
  border: 1px solid var(--hz-card-border);
  box-shadow: var(--hz-card-shadow);
  /* Its own surface, so its own ink (Android PdfCardBlock: c.text): a card
     also lives in a person's bubble — a forwarded PDF in the gradient one,
     whose white text it must never inherit (white on the card's white). */
  color: var(--hz-text);
  max-width: 380px;
}
.hz-app-card__icon,
.hz-pdf-card__icon {
  width: var(--hz-space-11);
  height: var(--hz-space-11);
  border-radius: var(--hz-radius-12);
  display: grid;
  place-items: center;
  color: var(--hz-text-onbrand);
  background: var(--hz-brand-gradient);
}
.hz-app-card__icon svg { fill: currentColor; }
.hz-app-card__body,
.hz-pdf-card__body { min-width: 0; display: grid; gap: 2px; }
.hz-app-card__title,
.hz-pdf-card__title {
  font-weight: 700;
  font-size: var(--hz-text-md);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hz-app-card__meta,
.hz-pdf-card__meta {
  display: flex;
  gap: var(--hz-space-1);
  font-size: var(--hz-text-xs);
  color: var(--hz-text-meta);
}
.hz-app-card__actions,
.hz-pdf-card__actions { grid-column: 1 / -1; display: flex; gap: var(--hz-space-2); }
.hz-app-card__open,
.hz-pdf-card__open { flex: 1; }
/* A document's title is often a sentence ("Bloom Coffee — launch plan"): two
   lines before it is cut, as on Android (PdfCardBlock maxLines = 2). */
.hz-pdf-card__title {
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: anywhere;
}
/* "PDF · 1 page · 21 kB": each part stays whole and the line wraps between
   parts — a long localized word («21 كيلوبايت») never splits mid-word. */
.hz-pdf-card__meta { flex-wrap: wrap; }
.hz-pdf-card__meta > span { white-space: nowrap; }
.hz-app-card__code,
.hz-pdf-card__download { flex: none; }
.hz-pdf-card[aria-busy="true"] .hz-pdf-card__actions { opacity: .6; pointer-events: none; }

/* ── Maker card — the agent a person is making with Agent Maker ──
   Rendered by fmt.js _agentCard from the ```hz-agent marker (agent-maker/);
   buttons painted by public/js/addons/agent-maker-addon.js. Surface = the
   .hz-card atom, state = the .hz-pill atom, buttons = .hz-btn; only the layout
   and the four-step progress live here. Same 380px width as its siblings.
   NOT .hz-agent-card: that is the design system's agent launcher tile
   (design-system/agent-card.css) — tests/unit/addons/agent-maker-addon.test.js
   keeps the two apart.
   • Secondary register, scoped, as the offer card does: the secondary buttons
     are live actions and keep the full-contrast text (the app's dark register
     mutes secondary text below AA).
   • The Ready pill uses the brand INK (the brand itself is below AA on the
     brand-soft wash in light). */
.hz-maker-card {
  --hz-btn-secondary-fg: var(--hz-text);
  display: grid;
  gap: var(--hz-space-3);
  margin: var(--hz-space-2) 0;
  padding: var(--hz-space-4);
  inline-size: 380px;
  max-inline-size: 100%;
  box-sizing: border-box;
  border-color: var(--hz-border-strong);
  text-align: start;
}
.hz-maker-card__head { display: flex; align-items: center; gap: var(--hz-space-3); min-width: 0; }
.hz-maker-card__avatar {
  flex: none;
  width: var(--hz-space-11);
  height: var(--hz-space-11);
  border-radius: var(--hz-radius-avatar);
  display: grid;
  place-items: center;
  font-size: var(--hz-text-lg);
  line-height: 1;
  color: var(--hz-text-onbrand);
  background: var(--hz-brand-gradient);
}
/* The face: the avatar, its picture over the emoji, and — for the owner —
   the control to change it (agent-maker-addon.js), a camera badge on its edge. */
.hz-maker-card__face { position: relative; flex: none; line-height: 0; }
.hz-maker-card__avatar { position: relative; overflow: hidden; }
.hz-maker-card__emoji { line-height: 1; }
.hz-maker-card__pic {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: inherit;
}
.hz-maker-card__pic-btn {
  position: absolute; inset: 0;
  margin: 0; padding: 0; border: 0;
  border-radius: var(--hz-radius-avatar);
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hz-maker-card__pic-btn:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .hz-maker-card__face:hover .hz-maker-card__avatar { filter: brightness(.9); }
}
.hz-maker-card__cam {
  position: absolute; inset-inline-end: -4px; bottom: -4px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: var(--hz-radius-full);
  background: var(--hz-brand); color: var(--hz-text-onbrand);
  /* A cut-out ring in the card's own colour separates badge and avatar. */
  box-shadow: 0 0 0 2px var(--hz-surface-raised, var(--surface));
  pointer-events: none;
}
.hz-maker-card__cam svg { width: 11px; height: 11px; }
/* Making or saving a picture: the face dims under a spinning ring. */
.hz-maker-card__face.is-busy .hz-maker-card__avatar { filter: brightness(.55); }
.hz-maker-card__face.is-busy .hz-maker-card__cam { opacity: 0; }
.hz-maker-card__face.is-busy::after {
  content: ''; position: absolute; inset: 6px;
  border-radius: var(--hz-radius-full);
  border: 2.5px solid var(--hz-viewer-surface-hover);
  border-top-color: var(--hz-viewer-ink);
  animation: hz-mk-spin .8s linear infinite;
  pointer-events: none;
}
@keyframes hz-mk-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .hz-maker-card__face.is-busy::after { animation-duration: 2s; } }

/* The picture sheet (agent-maker-addon.js): describe → Generate · N ⭐, then the
   Settings rows (.sp-card / .sp-row-btn) for Upload and Remove. */
/* Its secondary buttons read as buttons (the card's own register), never as disabled. */
.hz-mkpic { --hz-btn-secondary-fg: var(--hz-text); display: grid; gap: var(--hz-space-3); }
.hz-mkpic__lead { margin: 0; font-size: var(--hz-text-sm); color: var(--hz-text-meta); line-height: 1.4; }
.hz-mkpic__describe { min-height: 72px; }
.hz-mkpic__go { width: 100%; }
.hz-mkpic__rows .sp-row-ic { background: var(--accent-soft); color: var(--accent); }
.hz-mkpic__rows .is-danger .sp-row-ic { background: var(--hz-danger-soft); color: var(--hz-danger); }
.hz-mkpic__rows .is-danger .sp-row-lbl { color: var(--hz-danger-ink); }
.hz-mkpic__rows .sp-row-btn:focus-visible { outline: 2px solid var(--hz-focus-ring, var(--hz-brand)); outline-offset: -2px; }
.hz-mkpic__tip { margin: 0; font-size: var(--hz-text-xs); color: var(--hz-text-meta); line-height: 1.4; }
/* The knowledge sheet: the file it answers from, and who sees what / who pays. */
.hz-mkknow__file { display: flex; align-items: center; gap: var(--hz-space-3); padding: var(--hz-space-3); }
.hz-mkknow__file-ic { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--hz-radius-8); background: var(--accent-soft); color: var(--accent); }
.hz-mkknow__file-ic svg { width: 20px; height: 20px; }
.hz-mkknow__file-body { min-width: 0; display: grid; gap: 2px; }
.hz-mkknow__file-title { font-size: var(--hz-text-sm); font-weight: 600; color: var(--hz-text); overflow-wrap: anywhere; }
.hz-mkknow__file-meta { font-size: var(--hz-text-xs); color: var(--hz-text-meta); }
/* The Knowledge sheet's sources: one row each — kind, name, size — with a page's
   Refresh and every source's Remove (44px targets on touch). */
.hz-mkknow__list { display: grid; padding: var(--hz-space-1) 0; }
.hz-mkknow__src { display: flex; align-items: center; gap: var(--hz-space-3); padding: var(--hz-space-2) var(--hz-space-2) var(--hz-space-2) var(--hz-space-3); min-height: 56px; }
.hz-mkknow__src + .hz-mkknow__src { border-top: 1px solid var(--border); }
.hz-mkknow__src .hz-mkknow__file-body { flex: 1; }
.hz-mkknow__src-act { appearance: none; -webkit-appearance: none; flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: none; border-radius: 50%; background: transparent; color: var(--hz-text-meta); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.hz-mkknow__src-act svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hz-mkknow__src-act.is-danger { color: var(--hz-danger); }
@media (hover: hover) and (pointer: fine) { .hz-mkknow__src-act.is-danger:hover { background: var(--hz-danger-soft); } }
@media (hover: hover) and (pointer: fine) { .hz-mkknow__src-act:hover { background: var(--hover); } }
.hz-mkknow__src-act:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hz-mkknow__total { margin-top: calc(var(--hz-space-1) * -1); }
/* Adding: a file button over a page address field with its own Add. */
.hz-mkknow__add { display: grid; gap: var(--hz-space-2); }
.hz-mkknow__link { display: flex; gap: var(--hz-space-2); align-items: stretch; }
.hz-mkknow__link-input { flex: 1; min-width: 0; min-height: 40px; padding: 0 var(--hz-space-3); border: 1px solid var(--border); border-radius: var(--hz-radius-12); background: var(--hz-surface, var(--bg)); color: var(--hz-text); font: inherit; font-size: var(--hz-text-sm); }
.hz-mkknow__link-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.hz-mkknow__link-go { flex: none; min-height: 40px; }
/* On touch, every control here clears the 44px floor (the design system's tap minimum). */
@media (pointer: coarse) {
  .hz-mkknow__src-act { min-width: var(--hz-tap-min); min-height: var(--hz-tap-min); }
  .hz-mkknow__link-input, .hz-mkknow__link-go { min-height: var(--hz-tap-min); }
}
.hz-mkknow__notes { margin: 0; padding-inline-start: var(--hz-space-4); display: grid; gap: var(--hz-space-1); font-size: var(--hz-text-xs); color: var(--hz-text-meta); line-height: 1.4; }

.hz-maker-card__id { min-width: 0; flex: 1; display: grid; gap: 2px; }
/* Up to two lines, like the offer card: a long model-written name stays readable. */
.hz-maker-card__name {
  margin: 0;
  font-family: inherit;
  font-weight: 700;
  font-size: var(--hz-text-md);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.hz-maker-card__sub {
  font-size: var(--hz-text-xs);
  color: var(--hz-text-meta);
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.hz-maker-card__state { flex: none; }
.hz-maker-card__state.hz-pill--brand { color: var(--hz-brand-ink); }
.hz-maker-card__state.hz-pill--green { color: var(--hz-success-ink); }
.hz-maker-card__address {
  font-size: var(--hz-text-sm);
  color: var(--hz-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  unicode-bidi: isolate;
  user-select: all;
}
/* The four steps: a filled mark for a done step, a ringed one for the next,
   a hollow one for the rest — and the words beside them, so the state is
   never carried by colour alone (the hidden text says it for a reader). */
.hz-maker-card__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--hz-space-2);
}
.hz-maker-card__step {
  display: grid;
  justify-items: center;
  gap: var(--hz-space-1);
  font-size: var(--hz-text-xs);
  color: var(--hz-text-meta);
  text-align: center;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.hz-maker-card__mark {
  width: var(--hz-space-3);
  height: var(--hz-space-3);
  border-radius: var(--hz-radius-full);
  border: 2px solid var(--hz-text-meta);
  box-sizing: border-box;
  transition: background var(--hz-dur-fast) var(--hz-ease), border-color var(--hz-dur-fast) var(--hz-ease), box-shadow var(--hz-dur-fast) var(--hz-ease);
}
.hz-maker-card__step.is-done { color: var(--hz-text); }
.hz-maker-card__step.is-done .hz-maker-card__mark { background: var(--hz-success); border-color: var(--hz-success); }
.hz-maker-card__step.is-next { color: var(--hz-text); font-weight: 600; }
.hz-maker-card__step.is-next .hz-maker-card__mark { border-color: var(--hz-brand-ink); box-shadow: 0 0 0 3px var(--hz-brand-soft); }
.hz-maker-card__hint { font-size: var(--hz-text-sm); color: var(--hz-text-meta); margin: 0; flex: 1 1 100%; }
.hz-maker-card__ask { font-size: var(--hz-text-sm); color: var(--hz-text); margin: 0; flex: 1 1 100%; }
.hz-maker-card__actions { display: flex; flex-wrap: wrap; gap: var(--hz-space-2); }
.hz-maker-card__actions:empty { display: none; }
/* Equal halves while both labels fit; a label that does not (Russian, German)
   takes its own row instead of losing its padding. */
.hz-maker-card__actions .hz-btn { flex: 1 1 0; min-width: max-content; max-width: 100%; }
.hz-maker-card__actions .hz-btn:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 2px; }
/* Three actions (Public): the primary takes its own row, so a long label in
   German or Russian never leaves the tertiary action alone and stretched. */
.hz-maker-card__actions:has(> .hz-btn:nth-child(3)) .hz-btn--primary { flex-basis: 100%; }
/* A full-width row under the buttons, set off by a hairline like a sheet row:
   "Show on my profile" (the share sheet's switch — its knob, .sp-toggle-btn) and
   the agent's knowledge (an icon, what it answers from, a chevron to its sheet). */
.hz-maker-card__row {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: var(--hz-space-3);
  min-height: 48px;
  margin: var(--hz-space-1) 0 0;
  padding: var(--hz-space-3) 0 0;
  border: 0;
  border-top: 1px solid var(--hz-border);
  background: none;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
}
.hz-maker-card__row:disabled { cursor: progress; }
/* A row answers the pointer and the press, like a sheet's row. */
@media (hover: hover) and (pointer: fine) { .hz-maker-card__row:not(:disabled):hover .hz-maker-card__row-lbl { color: var(--hz-brand-ink); } }
.hz-maker-card__row:not(:disabled):active { opacity: .72; }
/* The switch's track is visible when off, on the card's own surface in both themes. */
.hz-maker-card .sp-toggle-btn:not(.on) { box-shadow: inset 0 0 0 1px var(--hz-border-strong); }
.hz-maker-card__row:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 2px; border-radius: var(--hz-radius-8); }
.hz-maker-card__row-body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.hz-maker-card__row-lbl { font-size: var(--hz-text-sm); font-weight: 600; color: var(--hz-text); }
.hz-maker-card__row-sub { font-size: var(--hz-text-xs); color: var(--hz-text-meta); line-height: 1.35; overflow-wrap: anywhere; }
.hz-maker-card__row-ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--hz-radius-8); background: var(--accent-soft); color: var(--accent); }
.hz-maker-card__row-ic svg, .hz-maker-card__row-go svg { width: 18px; height: 18px; }
.hz-maker-card__row-go { flex: none; display: grid; color: var(--hz-text-meta); }
[dir="rtl"] .hz-maker-card__row-go svg { transform: scaleX(-1); }
.hz-maker-card__knowledge[aria-busy="true"] .hz-maker-card__row-sub { color: var(--hz-text); }
/* Two rows in a column (Public: knowledge, then the profile switch): one hairline between. */
.hz-maker-card__row + .hz-maker-card__row { margin-top: 0; }
/* "More settings": the switches most owners never touch, folded behind one row
   (agent-maker-addon.js _moreSettings). Its chevron points down, and up when open. */
.hz-maker-card__more .hz-maker-card__row-go svg,
[dir="rtl"] .hz-maker-card__more .hz-maker-card__row-go svg { transform: rotate(90deg); transition: transform .15s ease; }
.hz-maker-card__more.is-open .hz-maker-card__row-go svg,
[dir="rtl"] .hz-maker-card__more.is-open .hz-maker-card__row-go svg { transform: rotate(-90deg); }
.hz-maker-card__more-body { flex: 1 1 100%; display: flex; flex-direction: column; }
/* In a column each switch is as tall as its own words (a row's `flex: 1 1 100%` is for the wrapping line above). */
.hz-maker-card__more-body > .hz-maker-card__row { flex: 0 0 auto; padding-bottom: var(--hz-space-3); }
.hz-maker-card__more-body > .hz-maker-card__row:last-child { padding-bottom: 0; }
.hz-maker-card__more-body[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .hz-maker-card__more .hz-maker-card__row-go svg { transition: none; } }
/* The Telegram sheet (agent-maker-addon.js _openTelegram): the three steps in
   @BotFather, the token field (the knowledge sheet's address field), a folded
   "I already have a bot". */
.hz-mktg__steps { margin: 0; padding-inline-start: var(--hz-space-5); display: grid; gap: var(--hz-space-1); font-size: var(--hz-text-sm); color: var(--hz-text); line-height: 1.45; }
.hz-mktg__more { display: grid; gap: var(--hz-space-2); }
.hz-mktg__more > summary { cursor: pointer; padding: var(--hz-space-2) 0; font-size: var(--hz-text-sm); font-weight: 600; color: var(--hz-brand-ink); min-height: 36px; }
.hz-mktg__more > summary:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 2px; border-radius: var(--hz-radius-8); }
.hz-mktg__more[open] > * + * { margin-top: var(--hz-space-2); }
.hz-mktg__status { min-height: 0; }
.hz-mktg__connect { display: grid; gap: var(--hz-space-1); }
.hz-mktg__err { margin: 0; font-size: var(--hz-text-xs); line-height: 1.4; color: var(--hz-danger); }
.hz-mktg__err:empty { display: none; }
@media (pointer: coarse) { .hz-mktg__more > summary { min-height: 44px; display: flex; align-items: center; } }
.hz-maker-card__row-sub.is-warn { color: var(--hz-warning-ink); font-weight: 600; }
/* The Insights sheet (_openInsights): the period as three choices, the four
   figures (the design system's stat group, 2×2 on a phone), the days as bars. */
.hz-mkins__pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 2px; border-radius: var(--hz-radius-12); background: var(--hz-surface-raised); border: 1px solid var(--hz-border); }
.hz-mkins__opt { appearance: none; -webkit-appearance: none; min-height: 36px; padding: 0 var(--hz-space-2); border: 0; border-radius: var(--hz-radius-8); background: none; font: inherit; font-size: var(--hz-text-sm); font-weight: 600; color: var(--hz-text-meta); cursor: pointer; }
.hz-mkins__opt.is-on { background: var(--hz-brand-soft); color: var(--hz-text); box-shadow: 0 0 0 1px var(--hz-brand-border); }
.hz-mkins__opt:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 1px; }
@media (pointer: coarse) { .hz-mkins__opt { min-height: 44px; } }
.hz-mkins__box { display: grid; gap: var(--hz-space-3); min-height: 180px; align-content: start; }
.hz-mkins__box[aria-busy="true"] { opacity: .6; }
.hz-mkins__stats { --hz-stat-cols: 4; }
@media (max-width: 420px) { .hz-mkins__stats { --hz-stat-cols: 2; } }
.hz-mkins__was { display: block; margin-top: 2px; font-size: var(--hz-text-2xs); color: var(--hz-text-meta); }
.hz-mkins__h { margin: 0; font-size: var(--hz-text-xs); font-weight: 700; color: var(--hz-text-meta); }
/* The scale: one faint line at the top with the number it stands for. */
.hz-mkins__plot { position: relative; padding-top: var(--hz-space-4); }
.hz-mkins__top { position: absolute; inset-inline: 0; top: var(--hz-space-4); border-top: 1px dashed var(--hz-border-strong); }
.hz-mkins__top span { position: absolute; inset-inline-end: 0; bottom: 100%; font-size: var(--hz-text-2xs); line-height: 1.4; color: var(--hz-text-meta); font-variant-numeric: tabular-nums; }
.hz-mkins__chart { display: flex; align-items: flex-end; gap: 2px; height: 88px; border-bottom: 1px solid var(--hz-border-strong); }
.hz-mkins__bar { flex: 1 1 0; min-width: 2px; height: calc(var(--hz-bar, 0) * 1%); border-radius: var(--hz-radius-2) var(--hz-radius-2) 0 0; background: var(--hz-brand-ink); }
.hz-mkins__bar.is-zero { height: 2px; background: var(--hz-border-strong); border-radius: 0; }
.hz-mkins__axis { display: flex; justify-content: space-between; margin-top: calc(var(--hz-space-2) * -1); font-size: var(--hz-text-2xs); color: var(--hz-text-meta); }
@media (forced-colors: active) { .hz-mkins__bar { background: CanvasText; } .hz-mkins__opt.is-on { outline: 2px solid CanvasText; } }
/* The owner's testing strip in their own agent's chat (agent-maker-addon.js
   _syncOwnStrip): the design system's banner, its icon in the brand ink, the
   one action (Edit) at a 44px tap height on touch screens. */
.hz-mk-own__ic { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--hz-radius-8); background: var(--hz-surface); color: var(--hz-brand-ink); }
.hz-mk-own__ic svg { width: 18px; height: 18px; }
.hz-mk-own__edit { flex: none; }
@media (pointer: coarse) { .hz-mk-own__edit { min-height: 44px; } }
/* Text for screen readers only (the step state words on the maker card). */
.hz-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Offer card — an orchestrator offers an agent's own chat ──
   Rendered by msg-renderer.js offerCardHtml from Harizma's offer record
   (hz.handoff.openChat); the button is handled by
   public/js/addons/agent-offer-addon.js. Surface = the .hz-card atom, button =
   the .hz-btn atom (--primary to open, --secondary once opened); only the
   layout lives here.
   • One width for every card (380px, the .hz-app-card width), so a card with a
     short line or none lines up with its neighbours instead of shrinking.
   • 16px padding (the app card's 12px + the room its pitch line needs).
   • Secondary register, scoped: the opened state's "Go to chat" is still the
     card's live action, so its text uses the full-contrast --hz-text (the app's
     dark register mutes secondary text to --t2, 3.8:1 here — it read as
     disabled). Same scoped-register pattern as cookie-consent.css. */
.hz-offer-card {
  --hz-btn-secondary-fg: var(--hz-text);
  display: grid;
  gap: var(--hz-space-3);
  margin: var(--hz-space-2) 0;
  padding: var(--hz-space-4);
  inline-size: 380px;
  max-inline-size: 100%;
  box-sizing: border-box;
}
.hz-offer-card__head { display: flex; align-items: center; gap: var(--hz-space-3); min-width: 0; }
.hz-offer-card__id { min-width: 0; display: grid; gap: 2px; }
/* Up to two lines: a long agent name stays readable, never cut to one. */
.hz-offer-card__name {
  font-weight: 700;
  font-size: var(--hz-text-md);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.hz-offer-card__status { font-size: var(--hz-text-xs); color: var(--hz-text-meta); }
.hz-offer-card__text {
  margin: 0;
  font-size: var(--hz-text-md);
  line-height: 1.45;
  color: var(--hz-text);
  overflow-wrap: anywhere;
}
/* An opaque ring — the global one is translucent (~2.3:1 on a card). Same
   pattern as the composer's own buttons. */
.hz-offer-card__open:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 2px; }
/* A username card (msg-renderer.js usernameCardHtml) is the same card with a
   person in it: their tile is the agent tile's size and shape (agentAvatarHtml
   44px), its face the shared person avatar (.av-person, avatar.js); the note
   is the card's second line of copy ("This is your username", "Check the
   spelling…"), a step quieter than Harizma's own line. */
.hz-offer-card__av {
  position: relative;
  inline-size: 44px;
  block-size: 44px;
  flex-shrink: 0;
  border-radius: var(--hz-radius-avatar);
  overflow: hidden;
}
.hz-offer-card__note {
  margin: 0;
  font-size: var(--hz-text-sm);
  line-height: 1.45;
  color: var(--hz-text-meta);   /* the AA ink for small copy (atoms.css .hz-stat-label) */
  overflow-wrap: anywhere;
}

/* A group card (msg-renderer.js groupCardHtml) is the same card holding one
   row per username: a 32px face (the username card's, smaller), the name and
   the @handle — or "No one has this username" — under it. The head's tile is
   the group's own mark (the group's default emoji). Rows never widen the card
   (380px, max 100%): a long name wraps inside its row. */
.hz-group-card__mark {
  display: grid;
  place-items: center;
  font-size: 22px;
  background: var(--hz-surface-fill);
}
.hz-group-card__members {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--hz-space-2);
}
.hz-group-card__member { display: flex; align-items: center; gap: var(--hz-space-3); min-width: 0; }
.hz-offer-card__av.hz-group-card__av { inline-size: 32px; block-size: 32px; }
.hz-group-card__member .ag-av { flex-shrink: 0; }
.hz-group-card__name {
  font-weight: 600;
  font-size: var(--hz-text-sm);
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.hz-group-card__member[data-state="none"] .hz-group-card__name { color: var(--hz-text-meta); }

#mw.mw-loading{opacity:0;pointer-events:none}
#mw.mw-loading *{animation:none!important;transition:none!important}
#mw.mw-ready{animation:mw-reveal .18s ease both}
/* translateY removed — it fought the ScrollController's scrollTop write,
   causing the bottom of the last message to appear briefly clipped.
   Pure opacity fade is imperceptible as a transition and produces no
   layout shift. Duration reduced to 180ms (was 220ms) for snappier feel. */
@keyframes mw-reveal{from{opacity:0}to{opacity:1}}
/* .bub-in — entry animation for the think-bub → reply in-place transition.
   Applied by agents-addon C17 when ws:chat_msg arrives and the reply is
   rendered directly into the existing think-bub element (no DOM wipe).
   Uses ease-out for a snappy, natural feel without spring overshoot.
   Duration 220ms matches the .mg.new.ag entry animation. */
.mg.ag .bub.bub-in{animation:bub-in .22s cubic-bezier(.4,0,.2,1) both}
@keyframes bub-in{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:none}}
/* Content images get a neutral backdrop while the skeleton/reservation owns
   sizing. Scoped to chat media only — the old blanket `#mw img{min-height:48px}`
   forced a 48px floor on EVERY image (avatars included) and made content images
   collapse to a stub before decode, then jump to full size on load. Space is
   now reserved by MediaFrame (width/height attrs) and the .bub-img-wrap skeleton
   box, so no min-height floor is needed and avatars keep their true size. */
#mw .bub-img, #mw .bub-img-grid-item, #mw .im-img { background: var(--raised); }
[data-theme="light"] #mw .bub-img,
[data-theme="light"] #mw .bub-img-grid-item,
[data-theme="light"] #mw .im-img { background: rgba(0,0,0,.05); }

/* ── Scroll stability (ScrollController refactor) ─────────────────────────
   overflow-anchor:none disables the browser's built-in scroll anchoring
   feature. That feature tries to keep the current visible element anchored
   when content above changes height — which fights our explicit
   scrollTop=scrollHeight writes and causes the "stuck mid-chat" visual.
   ScrollController owns scroll pinning; we turn off the browser's attempt. */
#mw { overflow-anchor: none; }

/* Reserve vertical space for image placeholders so scrollHeight is stable
   from the moment a bubble is inserted — ONLY while the image is still
   loading. Once loaded, .im-img-loading is removed (see _resolveJob) and
   :has() no longer matches, so the wrapper reverts to height:auto and the
   image displays at its real aspect ratio. No cropping, no surprise jumps.
   :has() ships in Chrome 105+, Safari 15.4+, Firefox 121+ — all current
   evergreen targets. Browsers without :has() fall back to the old behaviour
   (min-height:80px from existing rules), which was tolerable pre-refactor. */
.im-img-wrap:has(.im-img-loading) { aspect-ratio: 4 / 3; }


/* .hst.ai color and dot suppression now handled by base .hst rules (v120) */




/* ═══════════════════════════════════════════════════════════
   BASE RESET & SHELL
   Duplicated in a minimal inline block for critical path.
   app.css is the canonical source — inline just provides
   the fallback tokens/reset before this file fully loads.
═══════════════════════════════════════════════════════════ */

*,*::before,*::after {
  box-sizing: border-box;
  margin: 0; padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════════════════════
   MOBILE TAP HARDENING
   
   touch-action: manipulation on all interactive elements:
   • Eliminates the 300ms "double-tap to zoom" delay on older
     Android Chrome (and some Samsung Internet builds). Modern
     Chrome does this automatically when viewport is set, but
     explicit declaration costs nothing and covers edge cases.
   • `manipulation` allows pan + pinch-zoom but blocks the
     double-tap gesture specifically — perfect for buttons.
═══════════════════════════════════════════════════════════ */
button,
a,
.ag-chip, .qchip, .pchip, .vchip, .apv-chip,
.sbtn, .abtn, .vm-play,
.im-img, .bub-img, .media,
[role="button"], [onclick] {
  touch-action: manipulation;
}

/* ═══════════════════════════════════════════════════════════
   KEYBOARD ACCESSIBILITY — focus-visible rings
   
   The global tap-highlight: transparent above removes the focus
   outline on mouse/touch — good. But keyboard users (Tab key)
   NEED a visible focus indicator. `:focus-visible` shows the
   ring ONLY for keyboard navigation, never for pointer/touch.
═══════════════════════════════════════════════════════════ */
button:focus-visible,
a:focus-visible,
.ag-chip:focus-visible,
[role="button"]:focus-visible,
[onclick]:focus-visible {
  outline: 2px solid var(--hz-focus-outline);
  outline-offset: 2px;
  border-radius: inherit;
}
/* Textarea + input get a softer inset halo (matches our brand blue) */
textarea:focus-visible,
input:focus-visible {
  outline: none; /* the parent .ish already shows the halo */
}

/* ═══════════════════════════════════════════════════════════
   ROOT HEIGHT — the document is exactly the layout viewport
   
   html and body are `height: 100%` — the initial containing block, i.e. the
   LAYOUT viewport — so the document is never taller than the area the page
   is laid out in, and the window never has anything to scroll. Every screen
   is a fixed panel with its own scroller; the window itself must stay still.
   
   NOT 100dvh / -webkit-fill-available. Viewport units do not follow the soft
   keyboard on iOS, while the installed iOS app (iOS 26) DOES shrink the
   layout viewport to the area above it (innerHeight == visualViewport.height,
   focus-addon.js). A 100dvh document then stood a keyboard's height taller
   than the viewport, and iOS used that room: it scrolled the window to bring
   the composer into view. Fixed panels ride that scroll while the keyboard
   is up, and focus-addon pins the chat at visualViewport.offsetTop — which
   reports the same scroll a moment earlier or later. The chat jumped between
   three places with every keyboard event: the header pushed down onto the
   keyboard, only the composer at the top of the screen, or right. With no
   scroll room there is no window scroll, offsetTop stays 0, and the chat
   (fixed, inset: 0) simply fills the shrunken viewport above the keyboard.
   Where the layout viewport keeps its size (older iOS, Safari in a tab) the
   document is that size too, exactly as before.
   ≥641px the shell's own measured height applies (--app-vh, below).
   
   overscroll-behavior: none — prevents iOS "pull-to-refresh" and
   Android rubber-band scroll from leaking to document level.
═══════════════════════════════════════════════════════════ */
html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

/* App shell — fixed full-screen flex container. Fixed, so its height never
   adds scroll room to the document (ROOT HEIGHT above); on a phone the panels
   inside are fixed to the viewport themselves and follow the keyboard there. */
.app {
  display: flex;
  position: fixed; inset: 0;
  overflow: hidden;
}
@supports (height: 100dvh) {
  .app { height: 100dvh; }
}
/* Tablet + desktop (≥641px, both iPad orientations): offset the shell below the
   fixed top nav AND pin its height to the JS-measured viewport.

   Why not `height: auto` (rely on inset:0 bottom:0)?  On iOS/iPadOS a fixed
   element's bottom resolves against the LAYOUT viewport, whose height WebKit
   caches and can report short until the next relayout — worst on iPad in
   landscape, where the shell ends above the visible bottom and a strip of body
   backdrop shows beneath the composer (the reported whitespace). --app-vh is set
   by the blocking script in index.html <head> to the real visible viewport: it
   equals window.innerHeight at rest but, while an editable field is focused,
   shrinks to the live visible area above the soft keyboard (via visualViewport) —
   because iPad/iOS WebKit ignore interactive-widget=resizes-content, so innerHeight
   alone does not track the keyboard there. The shell therefore always fills the
   real viewport, keyboard up or down. 100dvh is the fallback when --app-vh is
   absent (JS off, or other pages that load app.css without the writer) — identical
   to the previous behaviour, so this is inert unless the writer is present. Scoped
   to ≥641 so the phone keyboard flow (height: 100% + focus-addon) is untouched. */
@media (min-width: 641px) {
  html, body { height: var(--app-vh, 100dvh); }
  .app { top: var(--tnav-h); height: calc(var(--app-vh, 100dvh) - var(--tnav-h)); }
}

/* .cm-chat — inner chat panel, fills remaining space */
/* overflow:hidden (base) → iOS 15 fallback: container clips translated children.
   overflow:clip (mobile override below) → iOS 16+: truly prevents iOS from
   programmatically scrolling .cm-chat when keyboard opens, which was pushing
   the header off-screen. clip differs from hidden: it never creates a scroll
   container, so scrollTop stays 0 and iOS cannot auto-scroll it. */
/* padding-bottom clears the cookie-consent banner while it is unanswered:
   .iz (the composer) is the last, flex-shrink:0 child of this column, so
   shrinking the column lifts the composer above the banner instead of letting
   it be typed into behind one. Padding — never a transform — so the iOS
   keyboard-follow translate on .iz below is left completely alone.
   var(--hz-consent-h, 0px) is 0 whenever no banner is showing, so the resting
   layout is byte-identical. Published by public/js/cookie-consent.js. */
.cm-chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; padding-bottom: var(--hz-consent-h, 0px); }

/* Compatibility stubs — kept for graceful degradation */
.tabs, .tab, .sec, .sec-btn { display: none; }


/* ═══════════════════════════════════════════════════════════
   SIDEBAR — QUICK-NAV CARDS
   Base desktop styles. Mobile overrides live in the
   max-width:640px block further down in this file.
═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════
   AGENT STORE PANEL  (#cmStore)
   Full base styles — mobile overrides at max-width:640px.
═══════════════════════════════════════════════════════════ */

#cmStore {
  display: none;
  position: absolute; inset: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--hz-surface-panel-store, var(--surface));
  z-index: 20;
}
#cmStore.show { display: flex; }

/* Layout comes from the shared panel head above; only the surface is the
   store's own. The store body is a tinted card canvas in light while the
   chat list body is not, so the head carries its own (matching) surface. */
.cs-hdr {
  background: var(--hz-surface-panelhdr, rgba(9,9,22,.92));
  backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
  -webkit-backdrop-filter: var(--hz-panelhdr-blur, blur(24px));
  box-shadow: var(--hz-panelhdr-shadow, none);
}
/* .cs-hdr-l / .cs-title — REMOVED. The store's title row is the shared
   .hz-panel-head-lead + .hz-panel-head-title, and its back button is gone: the
   Agents page owns a tab, so it is a root destination with no parent to go up
   to (see the /design-system page, "Panel head"). */

.cs-body {
  flex: 1; overflow-y: auto;
  padding: 10px 14px 24px;
  -webkit-overflow-scrolling: touch;
}

/* .cs-search — REMOVED. A second, divergent search-field definition (14px
   radius, 42px tall, its own light-theme rule) with no markup behind it: the
   store's field is the shared .srch, the same one the chat list uses. Left in
   place it is a trap — the next edit to the store's field lands here and
   re-forks the two surfaces without touching anything the app renders. */

.cs-lbl {
  font-size: 11px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--t3); padding: 4px 2px 8px;
}

.cs-list { display: block; }

/* .cs-item / .cs-av / .cs-info / .cs-name-row / .cs-name / .cs-tag — REMOVED.
   The Agents page's flat legacy row, kept for years as a "fallback" for markup
   that no longer existed in any code path. Agents are listed through ONE
   component now — the shared `.hz-agent-card` in design-system/agent-card.css,
   browse and search alike, here and on the home screen; a second, dead row
   definition sitting here is a trap, not a safety net. */

/* .cs-price — MOVED.
   The Stars price is part of the agent CARD now, not a badge this page owns:
   it rides the shared card's meta line as `.hz-agent-card-price`, styled with
   the card in design-system/agent-card.css and built by
   public/js/utils/agent-card.js. Its values come from the --hz-agentcard-price-*
   register, and the ★ from the --hz-star token, so the one hardcoded warm
   yellow that used to live here is a token like everything else. */

/* .cs-arr / .cs-chat-btn / .cs-sec-* — REMOVED.
   .cs-chat-btn was the store card's full-width blue "Message" button. Repeated
   on every one of ninety-six cards it stopped reading as a call to action, and
   the row it sat in was already the tap target — so the row became the whole
   control and the button went. .cs-arr and the .cs-sec-* group styled markup
   no code path has emitted since the sectioned "All" view was rebuilt. */

/* .cs-empty is styled by store-trending.css — the store is its only consumer,
   and the empty state is now a glyph over a sentence rather than a bare line. */


/* ═══════════════════════════════════════════════════════════
   WELCOME SCREEN — CMW Agent Grid
   Overrides the legacy centered .cm-welcome from earlier
   in this file. The scrollable agent grid is the active UI.
═══════════════════════════════════════════════════════════ */

.cm-welcome {
  position: absolute; inset: 0;
  display: block;
  overflow-y: auto; overflow-x: hidden;
  background: var(--void);
  background-image:
    radial-gradient(ellipse 120% 55% at 50% -8%, color-mix(in srgb, var(--hz-brand) 16%, transparent) 0%, transparent 58%),
    radial-gradient(ellipse 55%  35% at 90% 95%, color-mix(in srgb, var(--hz-accent-cyan) 7%, transparent)  0%, transparent 55%);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cm-welcome::-webkit-scrollbar { display: none; }

.cmw-inner {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  width: 100%; max-width: 580px;
  flex-shrink: 0;
  padding: 40px 28px;
  margin: 0 auto;
}

/* Kicker pill */
.cmw-kicker {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 9px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--hz-blue-300);
  background: color-mix(in srgb, var(--hz-brand) 12%, transparent);
  border: 1px solid rgba(90,155,255,.25);
  border-radius: var(--hz-radius-20); padding: 4px 13px;
  margin-bottom: 18px;
  animation: cmw-up .5s .05s ease both;
}
.cmw-kicker-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--hz-blue-300); flex-shrink: 0;
  animation: cmw-pulse 2.4s ease-in-out infinite;
}
@keyframes cmw-pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(90,155,255,.5); }
  55%     { opacity: .6; box-shadow: 0 0 0 6px rgba(90,155,255,0); }
}

/* Headline */
.cmw-headline {
  font-family: var(--hz-font-display);
  font-size: clamp(22px, 3.8vw, 38px);
  font-weight: 800; letter-spacing: -.04em; line-height: 1.1;
  color: var(--t1); text-align: center;
  margin-bottom: 6px; white-space: nowrap;
  animation: cmw-up .6s .12s ease both;
}
.cmw-headline em {
  font-style: normal;
  background: linear-gradient(118deg, var(--hz-blue-300) 0%, var(--hz-brand) 45%, var(--hz-accent-cyan) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.cmw-headline span {
  display: block;
  font-size: clamp(12px, 1.4vw, 15px); font-weight: 400;
  letter-spacing: .005em; color: var(--t3);
  margin-top: 9px; white-space: normal;
  -webkit-text-fill-color: var(--t3);
}

/* Category tabs */
.cmw-cats {
  display: flex; gap: 6px; margin-bottom: 8px;
  flex-wrap: wrap; justify-content: center; width: 100%;
  animation: cmw-up .45s .22s ease both;
}
.cmw-cat {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 7px 16px; border-radius: var(--hz-radius-22);
  border: 1px solid var(--border-mid);
  background: transparent; color: var(--t3);
  cursor: pointer; transition: all .17s ease;
  white-space: nowrap; letter-spacing: -.01em;
}
.cmw-cat:hover {
  border-color: rgba(90,155,255,.5);
  color: var(--hz-blue-300); background: color-mix(in srgb, var(--hz-brand) 7%, transparent);
}
.cmw-cat.on {
  background: var(--hz-action-gradient);
  border-color: transparent; color: #fff;
  box-shadow: 0 4px 20px rgba(37,105,220,.38), 0 1px 0 rgba(255,255,255,.12) inset;
}

/* Category tagline */
.cmw-sub {
  font-size: 13px; color: var(--t3); text-align: center;
  margin-bottom: 14px; max-width: 340px; line-height: 1.6;
  min-height: 20px;
  animation: cmw-up .45s .28s ease both;
  transition: opacity .2s ease;
}

/* Agent list containers */
.cmw-agents    { display: flex; flex-direction: column; gap: 8px;  width: 100%; }
.cmw-cat-group { display: flex; flex-direction: column; gap: 9px;  width: 100%; }

/* Agent row */
.cmw-row {
  display: flex; flex-direction: row; align-items: center; gap: 15px;
  width: 100%; font-family: inherit; text-align: start; cursor: pointer;
  background: var(--raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--hz-radius-20); padding: 14px 18px;
  position: relative; overflow: hidden;
  transition: transform .2s cubic-bezier(.34,1.3,.64,1), border-color .2s ease, box-shadow .2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
}
.cmw-row::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 20%; bottom: 20%; width: 3px;
  border-start-start-radius: 0; border-start-end-radius: var(--hz-radius-4); border-end-end-radius: var(--hz-radius-4); border-end-start-radius: 0;
  background: var(--cmw-accent);
  opacity: 0; transition: opacity .2s, top .25s, bottom .25s;
}
.cmw-row:hover                    { transform: translateX(calc(6px * var(--hz-inline-dir, 1))) translateY(-1px); }
.cmw-row:hover .cmw-row-name      { color: var(--t1); }
.cmw-row:hover .cmw-row-wash      { opacity: 1; }
.cmw-row:hover .cmw-row-arrow     { opacity: 1; transform: translateX(0); }
.cmw-row:hover .cmw-row-logo      { transform: scale(1.1) rotate(-6deg); }
.cmw-row:hover::before            { opacity: 1; top: 12%; bottom: 12%; }
.cmw-row:active                   { transform: translateX(calc(3px * var(--hz-inline-dir, 1))) translateY(0) scale(.99); }

/* Skeleton shimmer (while names load) */
.cmw-row-name:empty,
.cmw-row-desc:empty {
  border-radius: var(--hz-radius-6);
  background: linear-gradient(90deg, var(--border-mid) 25%, var(--hover) 50%, var(--border-mid) 75%);
  background-size: 200% 100%;
  animation: cmw-shimmer 1.5s ease infinite; display: block;
}
.cmw-row-name:empty { height: 15px; width: 52%; margin-bottom: 7px; }
.cmw-row-desc:empty { height: 11px; width: 36%; }
@keyframes cmw-shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* Row internals */
.cmw-row-logo {
  width: 52px; height: 52px; border-radius: var(--hz-radius-16);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0; position: relative; z-index: 1;
  transition: transform .28s cubic-bezier(.34,1.4,.64,1);
  box-shadow: 0 2px 10px rgba(0,0,0,.12), 0 1px 0 rgba(255,255,255,.1) inset;
}
.cmw-row-wash { position: absolute; inset: 0; border-radius: var(--hz-radius-20); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
.cmw-row-text { flex: 1; min-width: 0; position: relative; z-index: 1; }
.cmw-row-name { font-size: 15px; font-weight: 650; color: var(--t1); letter-spacing: -.03em; line-height: 1.25; transition: color .2s; }
.cmw-row-desc { font-size: 12px; color: var(--t3); margin-top: 4px; letter-spacing: -.01em; line-height: 1.4; display: flex; align-items: center; flex-wrap: wrap; gap: 1px; }
.cmw-desc-model  { font-weight: 600; color: var(--hz-blue-300); letter-spacing: -.02em; }
.cmw-desc-sep    { color: var(--t3); opacity: .55; margin: 0 1px; }
.cmw-desc-maker  { color: var(--t3); }
.cmw-row-arrow   { opacity: 0; transform: translateX(calc(-8px * var(--hz-inline-dir, 1))); flex-shrink: 0; display: flex; align-items: center; position: relative; z-index: 1; color: var(--t3); transition: opacity .2s, transform .2s; }

/* Copyright */
.cmw-copy {
  font-size: 11px; color: var(--t3); text-align: center;
  margin-top: 22px; letter-spacing: .025em; opacity: .6;
  animation: cmw-up .5s .8s ease both; padding-bottom: 4px;
}

@keyframes cmw-up { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* CMW responsive */
@media (min-width: 1280px) {
  .cmw-inner    { padding: 52px 40px 44px; }
  .cmw-headline { font-size: 48px; }
  .cmw-headline span { font-size: 18px; }
}
@media (max-width: 900px) {
  .cmw-headline { font-size: 36px; }
}
@media (max-width: 640px) {
  .cmw-inner {
    padding: 28px 18px 24px;
  }
  .cmw-cats {
    flex-wrap: nowrap; overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none; padding-bottom: 3px;
  }
  .cmw-cats::-webkit-scrollbar { display: none; }
  .cmw-kicker    { font-size: 9px; padding: 4px 11px; margin-bottom: 16px; }
  .cmw-headline  { font-size: 28px; margin-bottom: 6px; }
  .cmw-headline span { font-size: 14px; margin-top: 7px; }
  .cmw-cats      { gap: 6px; margin-bottom: 10px; }
  .cmw-cat       { font-size: 12px; padding: 6px 13px; }
  .cmw-sub       { font-size: 13px; margin-bottom: 14px; }
  .cmw-row       { padding: 12px 14px; gap: 13px; border-radius: var(--hz-radius-16); }
  .cmw-row-logo  { width: 44px; height: 44px; font-size: 20px; border-radius: var(--hz-radius-12); }
  .cmw-row-name  { font-size: 14px; }
  .cmw-row-desc  { font-size: 11px; }
  .cmw-copy      { margin-top: 16px; }
}
@media (max-width: 380px) {
  .cmw-headline { font-size: 24px; }
  .cmw-cat      { font-size: 11px; padding: 6px 10px; }
}

/* CMW — light mode */
[data-theme="light"] .cm-welcome {
  background: var(--hz-paper-150);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--hz-brand) 10%, transparent) 0%, transparent 65%);
}
[data-theme="light"] .cmw-headline       { color: var(--hz-blue-975); }
[data-theme="light"] .cmw-headline span  { color: rgba(0,0,0,.45); -webkit-text-fill-color: rgba(0,0,0,.45); }
[data-theme="light"] .cmw-headline em    { background: linear-gradient(125deg, var(--hz-brand-deep), #0891b2); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
[data-theme="light"] .cmw-kicker         { color: var(--hz-blue-800); background: color-mix(in srgb, var(--hz-brand) 8%, transparent); border-color: color-mix(in srgb, var(--hz-brand) 20%, transparent); }
[data-theme="light"] .cmw-kicker-dot     { background: var(--hz-brand-deep); }
[data-theme="light"] .cmw-sub            { color: #6B6788; }
[data-theme="light"] .cmw-cat            { border-color: rgba(0,0,0,.12); color: rgba(0,0,0,.55); }
[data-theme="light"] .cmw-cat:hover      { border-color: rgba(26,79,181,.30); color: var(--hz-brand-ink); background: rgba(26,79,181,.06); }
[data-theme="light"] .cmw-row            { background: #fff; border-color: rgba(0,0,0,.08); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
[data-theme="light"] .cmw-row:hover      { box-shadow: 0 6px 22px rgba(0,0,0,.09); }
[data-theme="light"] .cmw-row-name       { color: var(--hz-blue-975); }
[data-theme="light"] .cmw-row-desc       { color: #8E8EA8; }
[data-theme="light"] .cmw-row-arrow      { color: rgba(0,0,0,.3); }
[data-theme="light"] .cmw-desc-model     { color: var(--hz-brand-ink); }
[data-theme="light"] .cmw-copy           { color: rgba(0,0,0,.35); }


/* ═══════════════════════════════════════════════════════════
   COMPOSER — MISSING PIECES
═══════════════════════════════════════════════════════════ */

/* Send button + its arrow are fully styled by the shared .hz-composer-send atom
   (flat brand-blue, no gradient gloss) — nothing extra needed here. */

/* In-composer stop button — replaces send button while AI streams */
.sbtn-stop {
  width: 36px; height: 36px; border: none; border-radius: var(--hz-radius-12);
  background: rgba(255,255,255,.10); color: var(--t2);
  cursor: pointer;
  display: none; align-items: center; justify-content: center;
  transition: transform .18s cubic-bezier(.34,1.56,.64,1), background .15s, box-shadow .15s;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.sbtn-stop.on {
  display: flex;
  animation: sbtn-pulse 2s ease-in-out infinite;
}
@keyframes sbtn-pulse {
  0%,100% { box-shadow: 0 2px 8px rgba(0,0,0,.18), 0 0 0 0   color-mix(in srgb, var(--hz-brand) 0%, transparent); }
  50%     { box-shadow: 0 2px 8px rgba(0,0,0,.18), 0 0 0 5px color-mix(in srgb, var(--hz-brand) 15%, transparent); }
}
.sbtn-stop:hover  { background: rgba(255,255,255,.16); transform: scale(1.08) translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.sbtn-stop:active { transform: scale(.9); }
.sbtn-stop svg    { width: 11px; height: 11px; fill: currentColor; opacity: .85; }

/* Stop bar — always hidden; JS uses .sbtn-stop instead */
.stbar { display: none !important; }


/* ═══════════════════════════════════════════════════════════
   MODAL — GRADIENT HERO HEADER & URL ROW
   Already partially defined above; these are the variants
   used by the P2P connect modal and agent modals.
═══════════════════════════════════════════════════════════ */

/* Standalone .mclose-abs (outside .mh-gradient context) */
.mclose-abs {
  position: absolute; top: 12px; inset-inline-end: 12px;
  width: 28px; height: 28px; border: none;
  background: rgba(255,255,255,.15); border-radius: var(--hz-radius-8);
  cursor: pointer; color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .13s; flex-shrink: 0;
}
.mclose-abs:hover { background: rgba(255,255,255,.26); }
.mclose-abs svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

[data-theme="light"] .il-card  { background: #FFFFFF; border-color: rgba(0,0,0,.10); }
[data-theme="light"] .il-title { color: #000; }
[data-theme="light"] .il-sub   { color: rgba(0,0,0,.55); }
[data-theme="light"] .il-pid   { color: rgba(0,0,0,.35); }
[data-theme="light"] .il-skip  { border-color: rgba(0,0,0,.14); color: rgba(0,0,0,.55); }
[data-theme="light"] .il-skip:hover { background: var(--hz-paper-100); color: #000; }


/* ═══════════════════════════════════════════════════════════
   AGENT STORE — LIGHT THEME
═══════════════════════════════════════════════════════════ */

/* #cmStore light flips via --hz-surface-panel-store token. */
/* (second .cs-hdr light override removed — folded into the panelhdr tokens.) */
/*
 * Two rules, where there used to be twelve. The store's list, heads and shelves
 * are built from semantic tokens now, so light mode is the token swap this file
 * promised rather than a per-component patch list — and the patches that stayed
 * behind were the reason the light store kept drifting: they styled `.cs-item`,
 * `.cs-sec-*` and `.cs-section` surfaces that no code path had rendered for
 * months, so they could only ever go stale.
 */
/* (the .cs-title light override went with .cs-title — the shared
   .hz-panel-head-title reads --t1, which flips itself) */
[data-theme="light"] .cs-lbl   { color: var(--hz-text-subtle); }


/* ═══════════════════════════════════════════════════════════
   FEED PANEL  (#cmFeed)
═══════════════════════════════════════════════════════════ */

#cmFeed {
  display: none;
  position: absolute; inset: 0;
  flex-direction: column;
  overflow: hidden;
  background: var(--void);
  z-index: 20;
}
#cmFeed.show { display: flex; }

.cf-hdr {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; padding-top: calc(14px + var(--st));
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  /* No backdrop-filter: the Feed header sits on an OPAQUE surface with the
     scroll area as a flex sibling below it (nothing renders behind it), so a
     blur is a no-op in both themes — proven pixel-identical. Dropping it also
     removes the light-theme Safari asymmetry the old override left behind
     (backdrop-filter:none without the -webkit- pair). bg + border flip via the
     --surface / --border tokens, so no [data-theme="light"] override is needed. */
}
.cf-hdr-l { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.cf-title { font-size: 17px; font-weight: 700; letter-spacing: -.3px; color: var(--t1); }

.cf-body   { flex: 1; overflow: hidden; }
.cf-scroll { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* Responsive preview grid — 3 columns on phones (mirrors the profile grid),
   scaling to 4 on tablets and 5 on desktop. A centred max-width keeps tiles
   immersive on wide screens instead of stretching edge-to-edge. */
.cf-inner  {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  max-width: 640px; margin: 0 auto;
  padding: 12px 12px calc(72px + var(--sb2, 0px));
}
@media (min-width: 700px) {
  .cf-inner { grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 900px; padding: 20px 20px 40px; }
}
@media (min-width: 1160px) {
  .cf-inner { grid-template-columns: repeat(5, 1fr); gap: 10px; max-width: 1160px; }
}

/* Filter tabs */
.cf-tabs {
  display: flex; align-items: center; gap: 2px;
  margin-inline-start: auto; flex-shrink: 0;
}
.cf-tab {
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--t3);
  padding: 5px 11px; border-radius: var(--hz-radius-20);
  transition: color .15s, background .15s; font-family: inherit;
  white-space: nowrap;
}
.cf-tab:hover  { color: var(--t2); background: var(--hover); }
.cf-tab.active { color: var(--accent); background: color-mix(in srgb, var(--hz-brand) 13%, transparent); }
[data-theme="light"] .cf-tab.active { background: color-mix(in srgb, var(--hz-brand) 10%, transparent); }

/* ── Preview tile ───────────────────────────────────────────────────────────
   One square cell of the feed grid. Media tiles (image / video-with-poster)
   show a cover image; audio / text / poster-less video render a styled card.
   Tapping any tile opens the full post in #feedLightbox. */
.ftile {
  position: relative; aspect-ratio: 1; overflow: hidden; cursor: pointer;
  background: var(--raised);
  border-radius: var(--hz-radius-4);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
  animation: ftileIn .34s var(--ease-out) both;
}
@media (min-width: 700px) {
  .ftile { border-radius: var(--hz-radius-8); }
  .ftile:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0,0,0,.30); z-index: 1; }
}
.ftile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; z-index: 2; }

@keyframes ftileIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

.ftile-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: transform .45s var(--ease-out), opacity .25s ease;
}
/* Video first-frame preview shares .ftile-img sizing/cover/reveal; black backing
   while metadata loads so it never flashes the tile surface through. */
.ftile-vid { background: #000; }
.ftile-img.fcard-media-ready { opacity: 1; }
@media (min-width: 700px) { .ftile:hover .ftile-img { transform: scale(1.06); } }

/* Media shimmer: the tile itself pulses while its image decodes.
   Class names (fcard-media-loading / fcard-media-ready) are shared with the
   reveal helper in feed-addon.js so the lightbox reuses the same lifecycle. */
.ftile.fcard-media-loading { animation: skelPulse 1.5s ease-in-out infinite; }
/* Every source failed (utils/tile-media.js walked thumbnail → preview →
   original): say "no picture" in the tile's own quiet ink instead of leaving
   an empty square that reads as still loading. */
.ftile--broken { display: flex; align-items: center; justify-content: center; }
.ftile-broken-ic {
  width: 26px; height: 26px;
  fill: none; stroke: var(--t3); stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
@media (prefers-reduced-motion: reduce) {
  .ftile-img { transition: none; }
  .ftile.fcard-media-loading { animation: none; }
}

/* Author avatar chip — bottom-left, identifies the creator at a glance */
.ftile-av {
  position: absolute; inset-inline-start: 6px; bottom: 6px; z-index: 3;
  width: 22px; height: 22px; border-radius: var(--hz-radius-avatar);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff;
  border: 1.5px solid rgba(255,255,255,.9);
  box-shadow: 0 1px 5px rgba(0,0,0,.4);
  pointer-events: none;
}

/* Content-type badge — top-right */
.ftile-badge {
  position: absolute; top: 6px; inset-inline-end: 6px; z-index: 3;
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(6,6,16,.62); color: rgba(255,255,255,.94);
  border-radius: var(--hz-radius-6); padding: 3px 6px;
  font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}
.ftile-badge svg { width: 10px; height: 10px; fill: currentColor; }

/* Play glyph — centred on video tiles */
.ftile-play {
  position: absolute; top: 50%; left: 50%; z-index: 3; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%;
  background: rgba(6,6,16,.46);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.ftile-play svg { width: 17px; height: 17px; fill: #fff; margin-left: 2px; } /* optical centring of ▶ — play never mirrors, so physical */

/* Hover overlay with engagement stats (pointer devices only) */
.ftile-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  background: rgba(6,6,16,0); opacity: 0;
  transition: opacity .2s, background .2s; pointer-events: none;
}
@media (min-width: 700px) { .ftile:hover .ftile-overlay { opacity: 1; background: rgba(6,6,16,.44); } }
.ftile-stat { display: flex; align-items: center; gap: 6px; color: #fff; font-size: 14px; font-weight: 700; }
.ftile-stat svg { width: 18px; height: 18px; fill: #fff; }

/* Card tiles — audio / text / poster-less video share one surface */
.ftile-card {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  padding: 12px; background: var(--raised); overflow: hidden;
}
.ftile-card-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 2; }
[data-theme="light"] .ftile-card { background: rgba(0,0,0,.04); }

.ftile-audio { align-items: center; justify-content: center; gap: 10px; }
.ftile-waveform { display: flex; align-items: flex-end; gap: 3px; height: 24px; }
.ftile-wave { width: 3px; border-radius: var(--hz-radius-2); background: var(--t2); animation: fwave .9s ease-in-out infinite; }
.ftile-wave:nth-child(1) { height: 8px;  animation-delay: 0s; }
.ftile-wave:nth-child(2) { height: 15px; animation-delay: .08s; }
.ftile-wave:nth-child(3) { height: 21px; animation-delay: .16s; }
.ftile-wave:nth-child(4) { height: 12px; animation-delay: .24s; }
.ftile-wave:nth-child(5) { height: 18px; animation-delay: .32s; }
.ftile-wave:nth-child(6) { height: 9px;  animation-delay: .40s; }
.ftile-wave:nth-child(7) { height: 16px; animation-delay: .12s; }
@keyframes fwave { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.3); } }

.ftile-text { align-items: flex-start; justify-content: flex-end; }
.ftile-text-label {
  font-size: 8px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--t3); margin-bottom: 4px;
}
.ftile-text-body {
  font-size: 11px; line-height: 1.45; color: var(--t2);
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}

/* Skeleton loading tiles */
.ftile-skel {
  aspect-ratio: 1; border-radius: var(--hz-radius-4);
  background: var(--raised);
  animation: skelPulse 1.5s ease-in-out infinite;
}
@media (min-width: 700px) { .ftile-skel { border-radius: var(--hz-radius-8); } }
[data-theme="light"] .ftile, [data-theme="light"] .ftile-skel { background: rgba(0,0,0,.05); }

/* Empty state — spans the full grid width */
.cf-empty {
  grid-column: 1 / -1;
  text-align: center; padding: 64px 20px; color: var(--t3); font-size: 14px;
}

@keyframes skelPulse {
  0%, 100% { opacity: .24; }
  50%       { opacity: .52; }
}

/* ═══════════════════════════════════════════════════════════
   POST VIEWER  (#feedLightbox) — full-screen viewer for a shared post:
   the Feed, a public profile, a shared-post link (feed-addon.js,
   window.HzPostViewer). Always dark, whatever the theme — media reads best
   on a dark stage — so every colour comes from the theme-invariant
   --hz-viewer-* register in tokens.css.

   One layout for every kind of post:
     header  close · counter
     stage   the post itself (picture, video, sound cover + player, text,
             note), centred in whatever height is left
     panel   author · meta   [share] [owner's remove]
             caption
             [ one full-width call to action ]
═══════════════════════════════════════════════════════════ */
#feedLightbox {
  position: fixed; inset: 0;
  /* Above the mobile tab bar and every panel, below app toasts so a
     confirmation still surfaces over the viewer. */
  z-index: 999;
  display: none; opacity: 0;
  flex-direction: column;               /* header · stage(flex:1) · panel */
  overscroll-behavior: contain;
  color: var(--hz-viewer-ink);
  transition: opacity var(--hz-dur) var(--ease-out);
}
#feedLightbox.open { display: flex; opacity: 1; }
/* Freeze the feed scroll while the viewer is up (prevents iOS scroll bleed). */
.flb-open .cf-scroll { overflow: hidden; }
.flb-backdrop {
  position: absolute; inset: 0; z-index: 0;
  background: var(--hz-viewer-scrim);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  touch-action: none;
}

.flb-header {
  position: relative; z-index: 3; flex-shrink: 0;
  padding: calc(var(--st, 0px) + var(--hz-space-3)) var(--hz-space-3) var(--hz-space-2);
  display: flex; align-items: center; justify-content: space-between;
}
.flb-header-end { width: 40px; flex-shrink: 0; }   /* balances the close button */
.flb-counter {
  font-size: var(--hz-text-sm); font-weight: var(--hz-weight-semibold);
  color: var(--hz-viewer-ink-2); font-variant-numeric: tabular-nums;
}

/* The viewer's one icon button: close, share, remove. */
.flb-icon-btn {
  appearance: none; -webkit-appearance: none;
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--hz-space-2);
  border: none; border-radius: var(--hz-radius-full);
  background: var(--hz-viewer-surface); color: var(--hz-viewer-ink);
  font: inherit; font-size: var(--hz-text-sm); font-weight: var(--hz-weight-semibold);
  cursor: pointer;
  transition: background var(--hz-dur-fast) var(--hz-ease), transform var(--hz-dur-fast) var(--hz-ease);
  -webkit-tap-highlight-color: transparent;
}
.flb-icon-btn:hover  { background: var(--hz-viewer-surface-hover); }
.flb-icon-btn:active { transform: scale(.94); }
.flb-icon-btn:focus-visible { outline: var(--hz-focus-width) solid var(--hz-focus-ring); outline-offset: 2px; }
.flb-icon-btn svg {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.flb-icon-btn--danger { color: var(--hz-red-400); }
/* First tap on a destructive action: the icon grows a label and asks. */
.flb-icon-btn--armed {
  width: auto; padding: 0 var(--hz-space-4);
  background: var(--hz-viewer-surface-hover); color: var(--hz-red-400);
}
/* Like — a heart and the post's real total (feed-addon.js _feedLikeMount,
   post-likes.js). Round while nobody has liked the post; a pill once its
   count shows. Yours: the heart fills in the like colour. */
.flb-icon-btn--like {
  width: auto; min-width: 40px; padding: 0 var(--hz-space-3);
  font-variant-numeric: tabular-nums;
}
.flb-icon-btn--like[hidden] { display: none; }
.flb-like-count:empty { display: none; }
.flb-icon-btn--like[aria-pressed="true"] { color: var(--hz-red-400); }
.flb-icon-btn--like[aria-pressed="true"] svg { fill: currentColor; }
.flb-icon-btn--like.flb-like--pop svg { animation: flb-like-pop .36s var(--ease-spring); }
@keyframes flb-like-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}
/* The double tap's heart, over the picture (#flbMedia centres it). */
.flb-burst {
  position: absolute; left: 50%; top: 50%; z-index: 2;
  width: 96px; height: 96px; margin: -48px 0 0 -48px;
  color: var(--hz-viewer-ink);
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, .45));
  pointer-events: none;
  animation: flb-burst .8s var(--ease-out) forwards;
}
.flb-burst svg { width: 100%; height: 100%; fill: currentColor; stroke: none; }
@keyframes flb-burst {
  0%   { opacity: 0; transform: scale(.4); }
  20%  { opacity: 1; transform: scale(1.12); }
  35%  { transform: scale(.96); }
  70%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .flb-icon-btn--like.flb-like--pop svg { animation: none; }
  .flb-burst { display: none; }
}

/* Stage: grows to fill the space between header and panel, so the media box
   is derived from layout — a long caption can never overlap the picture. */
.flb-stage {
  position: relative; z-index: 2; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.flb-media {
  position: absolute; inset: 0;
  padding: var(--hz-space-2) 72px;
  display: flex; align-items: center; justify-content: center;
}
.flb-media > img, .flb-media > video {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: var(--hz-radius-12);
  box-shadow: var(--hz-viewer-media-shadow);
  opacity: 0; transition: opacity var(--hz-dur) ease;
}
.flb-media > img.fcard-media-ready, .flb-media > video.fcard-media-ready { opacity: 1; }
.flb-media > video { background: var(--hz-ink-900); }
/* A picture is double-tapped to like it (feed-addon.js): the browser's own
   double-tap zoom must not take the gesture. Pinch-zoom and panning stay. */
.flb-media > img { touch-action: manipulation; }

/* Spinner while a picture/video decodes — the canonical DS conic ring
   (.cl-sp-ring, loading-spinner-addon); only centring + the visibility gate
   are the viewer's. Never shown on a cache hit (no .fcard-media-loading). */
.flb-spinner {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1; opacity: 0; pointer-events: none;
  transition: opacity var(--hz-dur) ease;
}
.flb-media.fcard-media-loading .flb-spinner { opacity: 1; }

/* Sound: a square cover in the author's gradient, the player under it. */
.flb-audio-card {
  width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: var(--hz-space-4);
}
.flb-audio-art {
  aspect-ratio: 1; width: 100%; max-height: 42vh; margin: 0 auto;
  border-radius: var(--hz-radius-20);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--hz-viewer-media-shadow);
}
.flb-audio-art svg {
  width: 30%; height: 30%;
  fill: none; stroke: #fff; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  opacity: .92;
}
/* The shared player (.ap, audio-player.css) sits on the viewer's dark stage in
   both themes: one card like the cover above it. #feedLightbox outranks the
   player's own light-theme override, which would paint it on a light tint. */
#feedLightbox .flb-audio-card .ap {
  width: 100%;
  background: var(--hz-viewer-surface);
  border: 1px solid var(--hz-viewer-border);
  border-radius: var(--hz-radius-16);
}

/* Text and notes: a reading card, scrolled inside itself. */
.flb-text-card, .flb-doc {
  width: 100%; max-width: 640px; max-height: 100%; overflow-y: auto;
  padding: var(--hz-space-6);
  background: var(--hz-viewer-surface);
  border: 1px solid var(--hz-viewer-border);
  border-radius: var(--hz-radius-16);
  color: var(--hz-viewer-ink);
  font-size: var(--hz-text-md); line-height: var(--hz-leading-relaxed);
  overscroll-behavior: contain;
}

/* A shared note (utils/note-view.js): cover, title, then its blocks. */
.flb-doc { padding: 0; }
.flb-doc > *:not(.flb-doc-cover) { margin-inline-start: var(--hz-space-6); margin-inline-end: var(--hz-space-6); }
.flb-doc-cover {
  display: block; width: 100%; max-height: 180px; object-fit: cover;
  border-radius: var(--hz-radius-16) var(--hz-radius-16) 0 0;
}
.flb-doc-title {
  margin-top: var(--hz-space-6); margin-bottom: var(--hz-space-3);
  font-size: var(--hz-text-xl); font-weight: var(--hz-weight-bold);
  letter-spacing: var(--hz-tracking-tight); line-height: var(--hz-leading-tight);
  color: var(--hz-viewer-ink); overflow-wrap: anywhere;
}
.flb-doc-body { padding-bottom: var(--hz-space-6); overflow-wrap: anywhere; }
.flb-doc-body > * { margin: 0 0 var(--hz-space-3); }
.flb-doc-body h1, .flb-doc-body h2, .flb-doc-body h3 {
  margin-top: var(--hz-space-5); color: var(--hz-viewer-ink);
  font-weight: var(--hz-weight-bold); line-height: var(--hz-leading-tight);
}
.flb-doc-body h1 { font-size: var(--hz-text-lg); }
.flb-doc-body h2 { font-size: var(--hz-text-md); }
.flb-doc-body h3 { font-size: var(--hz-text-base); }
.flb-doc-body ul, .flb-doc-body ol { padding-inline-start: 1.3em; }
.flb-doc-body blockquote {
  padding-inline-start: var(--hz-space-3); border-inline-start: 3px solid var(--hz-viewer-border); color: var(--hz-viewer-ink-2);
}
.flb-doc-body pre {
  padding: var(--hz-space-3); overflow-x: auto;
  background: var(--hz-viewer-surface); border-radius: var(--hz-radius-10);
  font-family: var(--hz-font-mono); font-size: var(--hz-text-sm);
}
.flb-doc-body code { font-family: var(--hz-font-mono); }
.flb-doc-body hr { border: none; border-top: 1px solid var(--hz-viewer-border); }
.flb-doc-body figure { margin-inline-start: 0; margin-inline-end: 0; }
.flb-doc-body img, .flb-doc-body video { max-width: 100%; border-radius: var(--hz-radius-12); display: block; }
.flb-doc-body audio { width: 100%; }
.flb-doc-body figcaption { margin-top: var(--hz-space-1); font-size: var(--hz-text-sm); color: var(--hz-viewer-ink-2); }
.flb-doc-body .hz-note-table { overflow-x: auto; }
.flb-doc-body table { border-collapse: collapse; font-size: var(--hz-text-sm); }
.flb-doc-body th, .flb-doc-body td { padding: var(--hz-space-2) var(--hz-space-3); border: 1px solid var(--hz-viewer-border); text-align: start; }
.flb-doc-body .hz-note-callout {
  display: flex; gap: var(--hz-space-2);
  padding: var(--hz-space-3); border-radius: var(--hz-radius-12); background: var(--hz-viewer-surface);
}
.flb-doc-gate { padding-bottom: var(--hz-space-6); color: var(--hz-viewer-ink-2); }
.flb-doc-skel {
  height: 14px; margin-bottom: var(--hz-space-3); border-radius: var(--hz-radius-6);
  background: var(--hz-viewer-surface); animation: skelPulse 1.5s ease-in-out infinite;
}
.flb-doc-skel:last-child { width: 60%; margin-bottom: var(--hz-space-6); }

/* Prev / next — for a pointer. On a touch screen you swipe (feed-addon.js
   _feedLbSwipe); the arrows only covered the edges of the picture there. */
.flb-nav {
  position: absolute; top: 50%; z-index: 4; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: var(--hz-radius-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--hz-viewer-surface); color: var(--hz-viewer-ink);
  border: none; cursor: pointer;
  transition: background var(--hz-dur-fast) var(--hz-ease);
}
.flb-nav:hover { background: var(--hz-viewer-surface-hover); }
.flb-nav:focus-visible { outline: var(--hz-focus-width) solid var(--hz-focus-ring); outline-offset: 2px; }
.flb-nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.flb-prev { inset-inline-start: var(--hz-space-4); } .flb-next { inset-inline-end: var(--hz-space-4); }
.flb-nav[disabled] { opacity: .3; pointer-events: none; }
.flb-nav[hidden] { display: none; }
@media (hover: none) {
  /* Out of sight, NOT out of reach: a screen reader on a phone takes the
     swipe for its own navigation, so the arrows stay in the accessibility
     tree (visually hidden) as that reader's way to the next post. */
  .flb-nav:not([hidden]) {
    width: 1px; height: 1px; min-width: 0; min-height: 0; padding: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .flb-media { padding: var(--hz-space-2) var(--hz-space-3); }
}

/* Panel — who, what, and what you can do. */
.flb-panel {
  position: relative; z-index: 3; flex-shrink: 0;
  padding: var(--hz-space-4) var(--hz-space-5) calc(var(--hz-space-5) + var(--sb2, 0px));
}
.flb-panel-inner { max-width: 640px; margin: 0 auto; }
.flb-head { display: flex; align-items: center; gap: var(--hz-space-3); }
.flb-author {
  display: flex; align-items: center; gap: var(--hz-space-3);
  min-width: 0; flex: 1;
}
/* On the Feed the author row is a button to their in-app profile. */
button.flb-author {
  appearance: none; -webkit-appearance: none;
  margin: calc(-1 * var(--hz-space-1)); padding: var(--hz-space-1);
  background: transparent; border: none; border-radius: var(--hz-radius-12);
  font: inherit; color: inherit; text-align: start; cursor: pointer;
  transition: background var(--hz-dur-fast) var(--hz-ease);
  -webkit-tap-highlight-color: transparent;
}
button.flb-author:hover { background: var(--hz-viewer-surface); }
button.flb-author:focus-visible { outline: var(--hz-focus-width) solid var(--hz-focus-ring); outline-offset: 2px; }
.flb-av {
  position: relative; overflow: hidden;
  width: 40px; height: 40px; border-radius: var(--hz-radius-avatar); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--hz-text-sm); font-weight: var(--hz-weight-bold); color: #fff;
}
.flb-av.has-img { color: transparent; }
.flb-author-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.flb-author-name {
  font-size: var(--hz-text-base); font-weight: var(--hz-weight-semibold); color: var(--hz-viewer-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flb-author-handle { font-weight: var(--hz-weight-regular); color: var(--hz-viewer-ink-2); }
.flb-author-sub {
  font-size: var(--hz-text-sm); color: var(--hz-viewer-ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.flb-tools { display: flex; align-items: center; gap: var(--hz-space-2); flex-shrink: 0; }

.flb-caption {
  margin-top: var(--hz-space-3);
  font-size: var(--hz-text-base); line-height: var(--hz-leading-normal); color: var(--hz-viewer-ink-2);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  cursor: pointer;
}
/* Tapping a clamped caption expands it (scrolls within a capped height). */
.flb-caption.flb-caption--open {
  display: block; -webkit-line-clamp: none; overflow-y: auto;
  max-height: 32vh; cursor: default; overscroll-behavior: contain;
}
.flb-caption .md a, .flb-text-card .md a, .flb-doc a { color: var(--hz-brand-2); }
.flb-caption .md h1 { font-size: 1.15em; }
.flb-caption .md h2 { font-size: 1.05em; }
.flb-caption .md h3, .flb-caption .md h4, .flb-caption .md h5, .flb-caption .md h6 { font-size: 1em; }
.flb-caption .md code, .flb-text-card .md code {
  background: var(--hz-viewer-surface-hover); border-radius: var(--hz-radius-4); padding: 1px 4px;
}
/* The one call to action — the DS primary button, full width. */
/* The post's one call to action ("Try with <agent>", a note's Open / Join):
   a compact pill under the post (.hz-btn--sm), sized to its words — it
   follows the post, it does not compete with it. A long agent name is cut
   with "…" rather than wrap the pill. */
.flb-cta {
  margin-top: var(--hz-space-3);
  max-width: 100%;
}
.flb-cta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flb-cta:disabled { opacity: .6; cursor: progress; }
.flb-cta svg { width: 14px; height: 14px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 700px) {
  .flb-media { padding: var(--hz-space-2) var(--hz-space-3); }
  .flb-panel { padding-inline-start: var(--hz-space-4); padding-inline-end: var(--hz-space-4); }
  .flb-text-card { padding: var(--hz-space-5); }
  /* A note is edge-to-edge (its cover bleeds); only its text is inset. */
  .flb-doc > *:not(.flb-doc-cover) { margin-inline-start: var(--hz-space-5); margin-inline-end: var(--hz-space-5); }
}

/* (#nFeed.on's pink accent — REMOVED: every nav item takes the one
   --hz-navitem-active tint; see TAB BAR.) */

/* Light theme */
[data-theme="light"] #cmFeed  { background: #F3F4F8; }
/* .cf-hdr needs no light override: background:var(--surface) → #FFFFFF and
   border:var(--border) → rgba(0,0,0,.08) already flip per theme, and the base
   rule no longer carries a blur to cancel. */
[data-theme="light"] .ftile-av { border-color: rgba(255,255,255,.95); }
/* #feedLightbox stays dark in both themes by design (media viewer). */
/* Note: tile entrance (ftileIn) + waveform (fwave) animations are neutralised
   by the global (prefers-reduced-motion: reduce) block further down app.css. */


/* ── Inline-only rules migrated from index.html (were missing from app.css) ── */


/* Markdown — outgoing bubble dark-mode overrides */
.mg.out .bub .md ol li::marker{color:rgba(255,255,255,.7)}

/* ── Group @mention styles ───────────────────────────────────────────────────
   Moved from runtime JS injection in groups-addon.js.
   ─────────────────────────────────────────────────────────────────────────── */

/* Popup */
/* The @mention list: the chat's popover surface in both themes (the same tokens
   as the header's ⋯ menu), the brand for the picked row and the matched letters. */
#grpMentionPopup{position:fixed;z-index:9999;background:var(--surface);border:1px solid var(--border-mid);border-radius: var(--hz-radius-12);overflow:hidden;box-shadow:var(--hz-shadow-lg);display:none;min-width:220px;max-width:300px;transform-origin:bottom left}
[dir="rtl"] #grpMentionPopup{transform-origin:bottom right}
#grpMentionPopup.visible{display:block;animation:mentionSlideUp .14s cubic-bezier(.16,1,.3,1)}
@keyframes mentionSlideUp{from{opacity:0;transform:translateY(6px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}
#grpMentionPopup .mp-header{padding:6px 12px 4px;font-size:10px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:var(--t3)}
#grpMentionPopup .mp-item{display:flex;align-items:center;gap:10px;padding:8px 12px;cursor:pointer;transition:background .08s;user-select:none}
#grpMentionPopup .mp-item:hover{background:var(--hover)}
#grpMentionPopup .mp-item.active{background:var(--hz-brand-soft)}
#grpMentionPopup .mp-av{width:32px;height:32px;border-radius:var(--hz-radius-avatar);display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:700;flex-shrink:0;color:#fff}
#grpMentionPopup .mp-name{font-size: 14px;font-weight:500;color:var(--t1);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
#grpMentionPopup .mp-name mark,#grpMentionPopup .mp-role mark{background:none;color:var(--hz-brand);font-weight:700}
#grpMentionPopup .mp-role{font-size:11px;color:var(--t3);margin-top:1px}
#grpMentionPopup .mp-sep{height:1px;background:var(--border-mid);margin:2px 0}

/* @mention tag pills in message bubbles */
.grp-tag{display:inline;font-weight:500;border-radius: var(--hz-radius-4);padding:0 4px;font-size:.92em;cursor:default;white-space:nowrap}
.mg.in  .bub .grp-tag{color:#6C5FE6;background:rgba(108,95,230,.12)}
.mg.out .bub .grp-tag{color:var(--hz-mention-out-ink);background:var(--hz-mention-out-bg)}

/* Agent @mention chips — clickable pills that open the agent's chat */
.ag-mention{display:inline;font-weight:600;border-radius: var(--hz-radius-4);padding:0 4px;font-size:.92em;cursor:pointer;white-space:nowrap;background:none;border:none;font-family:inherit;line-height:inherit;vertical-align:baseline}
.mg.in  .bub .ag-mention{color:#6C5FE6;background:rgba(108,95,230,.15)}
.mg.out .bub .ag-mention{color:var(--hz-mention-out-ink);background:var(--hz-mention-out-bg)}
.mg.in  .bub .ag-mention:hover{background:rgba(108,95,230,.28)}
.mg.out .bub .ag-mention:hover{background:rgba(255,255,255,.32)}
[data-theme="light"] .mg.in .bub .ag-mention{color:#5a50cc;background:rgba(108,95,230,.12)}
[data-theme="light"] .mg.in .bub .ag-mention:hover{background:rgba(108,95,230,.22)}

/* Mirror-div input highlight ─────────────────────────────────────────────────
   Textarea is ALWAYS fully visible — cursor is always correct.
   Mirror sits behind and renders only @mention backgrounds (color:transparent).
   Computed styles are copied via JS to get exact pixel values (not em ratios),
   preventing sub-pixel letter-spacing drift on long strings.
   font-variant-ligatures:none on both prevents ligature-based width variance. */
.mta-mirror{
  position:absolute;pointer-events:none;user-select:none;z-index:0;
  color:transparent;background:transparent;border:none;outline:none;
  white-space:pre-wrap;overflow-wrap:break-word;word-break:break-word;
  overflow:hidden;box-sizing:border-box;
  /* Ligatures disabled to prevent variable glyph widths */
  font-variant-ligatures:none;font-kerning:none;
}
/* Textarea on top — text visible, background transparent to see mirror beneath */
.mta-mirror ~ .mta{
  position:relative;z-index:1;
  background:transparent!important;
  font-variant-ligatures:none;font-kerning:none;
}
/* @mention: background tint only, color transparent so only the tint is visible.
   No padding or font-weight — zero impact on text layout widths. */
.mta-tag{display:inline;color:transparent;background:rgba(108,95,230,.28);border-radius: var(--hz-radius-2)}
[data-theme="light"] .mta-tag{background:rgba(108,95,230,.18)}
[data-theme="light"] .mg.in .bub .grp-tag{color:#5a50cc;background:rgba(108,95,230,.10)}

/* ═══════════════════════════════════════════════════════════
   LANDSCAPE PHONE — small screens rotated sideways
   
   On a 375×667 phone rotated → 667×375. The chips bar + composer
   + keyboard eat most of the vertical space. Shrink:
   • textarea max-height: 110 → 72px (about 3 lines)
   • composer padding reduced
   • chips bar slightly tighter
   
   Kicks in only when height <= 480 AND orientation is landscape,
   so it doesn't affect portrait small phones.
═══════════════════════════════════════════════════════════ */
@media (max-height: 480px) and (orientation: landscape) {
  .mta { max-height: 72px; }
  .iz { padding: 6px 10px 8px; padding-bottom: calc(8px + var(--sb2)); }
  .ish { padding-block: 5px; padding-inline: 12px 6px; }
  .ag-chips-bar, #agChips { padding: 6px 14px 8px; }
  .ag-chip { height: 36px; font-size: 13px; }
  .ag-chip-spark { width: 20px; height: 20px; border-radius: var(--hz-radius-6); }
}

/* ═══════════════════════════════════════════════════════════
   REDUCED MOTION — respect OS accessibility setting
   
   Users who set "Reduce motion" in iOS/Android/macOS should see
   animations disabled. This is a WCAG 2.1 requirement.
═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  /* Keep the keyboard-follow translation instant too */
  .iz, .ag-chips-bar, #agChips { transition: none; }
}



/* ═══════════════════════════════════════════════════════════
   FILTER RAIL — the shared horizontal chip bar
   Built by HzFilterBar (public/js/utils/filter-bar.js); the agent store's
   category rail is its first consumer, the chat list's filter bar its second.
   Every value reads the --hz-chip-* register in tokens.css, so light mode is a
   token swap and the rail cannot drift per surface.
═══════════════════════════════════════════════════════════ */
.sb-filters {
  display: flex; gap: var(--hz-chip-rail-gap);
  padding: 0 4px 10px;
  flex-shrink: 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-padding-inline: 4px;
}
.sb-filters::-webkit-scrollbar { display: none; }

.sb-filter {
  display: inline-flex; align-items: center; gap: var(--hz-chip-gap);
  padding: 0 var(--hz-chip-pad-x); height: var(--hz-chip-h);
  border-radius: var(--hz-chip-radius);
  font-family: inherit;
  font-size: var(--hz-chip-font-size); font-weight: var(--hz-chip-weight);
  line-height: 1; white-space: nowrap; flex-shrink: 0; cursor: pointer;
  border: none; outline: none;
  background: var(--hz-chip-bg); color: var(--hz-chip-fg);
  transition: background var(--hz-dur-fast) var(--hz-ease),
              color      var(--hz-dur-fast) var(--hz-ease),
              transform  var(--hz-dur-instant) var(--hz-ease);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.sb-filter svg { width: 14px; height: 14px; flex-shrink: 0; }
.sb-fi { line-height: 1; font-style: normal; }  /* emoji icon span */
@media (hover: hover) and (pointer: fine) {
  .sb-filter:hover { color: var(--hz-chip-fg-hover); background: var(--hz-chip-bg-hover); }
}
.sb-filter:active { transform: scale(.95); }
.sb-filter:focus-visible {
  outline: var(--hz-focus-width) solid var(--hz-focus-ring);
  outline-offset: 2px;
}

.sb-filter.on { background: var(--hz-chip-on-bg); color: var(--hz-chip-on-fg); }
.sb-filter.on svg { color: var(--hz-chip-on-fg); }
@media (hover: hover) and (pointer: fine) {
  .sb-filter.on:hover { background: var(--hz-chip-on-bg-hover); color: var(--hz-chip-on-fg); }
}

/* The per-chip count. Dimmed rather than a second pill: it is a hint about how
   much is behind the chip, not a badge demanding to be read. */
.sb-fc {
  font-size: var(--hz-chip-count-size);
  font-weight: var(--hz-weight-semibold);
  opacity: .58;
  margin-inline-start: 1px;
  font-variant-numeric: tabular-nums;
}
.sb-filter.on .sb-fc { opacity: .78; }

@media (max-width: 640px) {
  .sb-filters { padding: 0 6px 10px; }
  .sb-filter  { height: var(--hz-chip-h-dense); }
}

@media (prefers-reduced-motion: reduce) {
  .sb-filter { transition: none; }
}

/* ── Scroll Indicator ──────────────────────────────────────────────────────
   Universal overlay scroll-position track. Used by ScrollIndicator class.
   Applied to notes editor; reusable on any scrollable panel in Harizma.
   ────────────────────────────────────────────────────────────────────────── */

/* Suppress native scrollbar on elements managed by ScrollIndicator */
.si-enabled                     { scrollbar-width: none; }
.si-enabled::-webkit-scrollbar  { display: none; }

/* Track — the fixed rail on the right edge of the container.
   Hidden at rest; fades in only while the user is actively scrolling. */
.si-track {
  position: absolute;
  inset-inline-end: 4px;
  width: 4px;
  border-radius: var(--hz-radius-2);
  background: rgba(255, 255, 255, .06);
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  transition: opacity 260ms var(--ease);
}

.si-track.si-no-overflow { display: none; }

/* Active: track becomes visible while scrolling */
.si-track.si-active { opacity: 1; }

/* Thumb — shows proportional position within the document */
.si-thumb {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  min-height: 28px;
  background: rgba(255, 255, 255, .32);
  border-radius: var(--hz-radius-2);
  transition: transform 60ms linear, height 60ms linear;
  will-change: transform;
}

/* Light theme overrides */
[data-theme="light"] .si-track          { background: rgba(0, 0, 0, .06); }
[data-theme="light"] .si-thumb          { background: rgba(0, 0, 0, .32); }

/* ── Memory Note addon ───────────────────────────────────────────────────── */
/* The composer "brain" button (#mnBtn / .mn-btn) was replaced by the "Note"
   entry in the unified "+" attachment menu (attach-menu.js); its styles were
   removed with it. */

/* ── Note picker modal sizing ── */
/* Base max-width (mobile-first); tablet+ overrides below */
.mn-modal { max-width: 420px; }

/* ── Note picker body — compact list layout ── */
/* Overrides the standard .mbody padding/gap which is tuned for form fields,
   not dense lists. Tighter padding keeps more notes visible without scrolling. */
.mn-picker-body { padding: 12px 14px; gap: 8px; }

/* ── Note picker footer — destructive action left, safe action right ── */
/* Standard .mfoot uses justify-content:flex-end (right-aligned cluster).
   For a destructive+cancel pair the UX convention is: danger left, cancel right.
   margin-inline-end:auto on the danger button achieves this without layout surgery
   (and mirrors it in RTL: danger at the start edge, cancel at the end). */
.mn-picker-foot #mnDetachBtn { margin-inline-end: auto; }

/* ── Active note section labels ── */
.mn-section-lbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 0 2px;
  margin: 0;
  user-select: none;
  pointer-events: none;
}
.mn-section-lbl--list { margin-top: 6px; }

.mn-stale-note {
  font-size: 13px;
  color: var(--t3);
  padding: 6px 4px 2px;
  user-select: none;
}

/* ── Note picker list items ── */
.mn-note-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: start;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--hz-radius-12);
  padding: 12px 14px;
  min-height: 52px; /* iOS HIG: 44px min; 52px gives comfortable tap zone */
  cursor: pointer;
  transition: background .13s, border-color .13s;
  color: var(--t1);
}
.mn-note-item:hover { background: var(--hover); border-color: var(--border-mid); }
.mn-note-item:focus-visible { outline: 2px solid var(--hz-brand); outline-offset: 1px; }
[data-theme="light"] .mn-note-item:focus-visible { outline-color: var(--hz-blue-700); }
.mn-note-item.mn-selected {
  border-color: color-mix(in srgb, var(--hz-brand) 50%, transparent);
  background: color-mix(in srgb, var(--hz-brand) 8%, transparent);
}
[data-theme="light"] .mn-note-item.mn-selected {
  border-color: rgba(37,105,220,.4);
  background: rgba(37,105,220,.06);
}

.mn-note-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.mn-note-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mn-note-title { font-size: 14px; font-weight: 600; color: var(--t1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mn-note-excerpt { font-size: 12px; color: var(--t3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Checkmark — visible only on selected */
.mn-check { width: 18px; height: 18px; flex-shrink: 0; color: var(--hz-brand); opacity: 0; transition: opacity .13s; }
.mn-note-item.mn-selected .mn-check { opacity: 1; }
.mn-check svg { width: 16px; height: 16px; }

/* Empty / loading states */
.mn-empty, .mn-loading {
  text-align: center;
  padding: 28px 16px;
  font-size: 13px;
  color: var(--t3);
  line-height: 1.5;
}

/* Tablet / desktop: wider modal */
@media (min-width: 600px) {
  .mn-modal { max-width: 460px; }
}

/* ============================================================================
 * Touch targets (Phase 3 · a11y) — on coarse-pointer (touch) devices the
 * standard button system and the prominent standalone action / close controls
 * meet the design-system 44px tap minimum (--hz-tap-min; WCAG 2.5.5, Apple HIG,
 * Material). Desktop (fine pointer) keeps its compact density. Scoped to the
 * controls that measured below 44px — deliberately NOT a blanket rule, so the
 * dense chat / message-action toolbars are not reflowed.
 * ========================================================================== */
@media (pointer: coarse) {
  /* Touch-target floor (WCAG 2.5.5 / Apple HIG 44pt / Material). Scoped to the
     standalone, single-instance controls where 44px is an unambiguous win and
     there's layout room: the standard text-button system and the modal
     close / copy controls (one or two per modal). Applying min-height only to
     .hz-btn leaves width/padding intact; icon controls get a square 44×44 tap box
     with the glyph centered — no visual regression on desktop, which keeps its
     compact density because this whole block is gated to (pointer: coarse).

     Composer controls (the send + icon buttons: .hz-composer-send /
     .hz-composer-btn, incl. the legacy .sbtn/.abtn aliases) DO get the 44px
     floor on touch — but via the shared --hz-composer-* register's own
     (pointer: coarse) rule near the atoms, not here.

     Still deliberately NOT enlarged: .ib/.aif-cfg and inline copy affordances
     (.myid-copy/.cpbtn). Those live in tightly-spaced clusters where forcing
     44px would break the compact layout; at ≥24px with adequate inter-target
     spacing they satisfy WCAG 2.5.8 (AA). Enlarging them is a layout redesign,
     not a value-preserving a11y bump, so it stays out of this surgical pass. */
  .hz-btn { min-height: var(--hz-tap-min); }

  /* Form fields on touch: restore the 44px tap floor and lift the font to 16px
     so iOS Safari does not zoom the viewport on focus. */
  .hz-input { --hz-input-min-h: var(--hz-tap-min); --hz-input-font-size: 16px; }

  .mclose,
  .mclose-abs,
  .pr-close,
  .murl-copy { min-width: var(--hz-tap-min); min-height: var(--hz-tap-min); }

  /* The panel head's back control. It is one control at the top-left corner of
     the screen with a whole row to itself, so there is nothing to crowd — and
     it was the one below the floor on every panel that had it (34px on the
     agents store and Profile, 40px on the AI Course). The paint stays a
     --hz-panel-head-back-size circle; only the target grows, and the hover
     circle it grows into never renders on a device with no hover. */
  .hz-panel-head-back,
  .hz-panel-head-action { min-width: var(--hz-tap-min); min-height: var(--hz-tap-min); }

  /* The Profile button: the avatar keeps the plan pill's height; the tap box
     around it grows to the floor. It sits at the end of its row, so the extra
     box only reaches into the row's own edge padding. */
  .hz-me { min-width: var(--hz-tap-min); min-height: var(--hz-tap-min); }

  /* Post viewer — close / share / remove (a handful per screen, ample room)
     meet the 44px floor on touch. */
  .flb-icon-btn { min-width: var(--hz-tap-min); min-height: var(--hz-tap-min); }
}
/* (The home-screen .cmh-* action buttons carry their own coarse-pointer bump
   in home.css, where they're defined with a competing min-height.) */
