:root {
  color-scheme: dark;
  --bg: #25282b;
  --frame: #1c1f22;
  --panel: #2d3134;
  --card: #313538;
  --surface: #353a3e;
  --surface-raised: #3d4347;
  --surface-hover: #394045;
  --field: #292d30;
  --ink: #f1f4f5;
  --muted: #a8b0b5;
  --faint: #7a8389;
  --line: #3f454a;
  --line-strong: #535a60;
  --accent: #19a87b;
  --accent-dark: #11845f;
  --accent-pale: #244d41;
  --outgoing: #1f6a54;
  --outgoing-automated: #2a3f39;
  --incoming: #383d42;
  --on-accent: #ffffff;
  --danger: #ef9b9b;
  --status-all: #19a87b;
  --success: #3ccf94;
  --status-auto: #ffd60a;
  --status-manual: #8b7cf6;
  --status-ignore: var(--status-all);
  --status-waiting: #8fb3e8;
  --status-blocked: #ff6fae;
  --status-stopped: #e5676b;
  --status-finished: #1db954;
  --star: #ffc43d;
  --shadow: 0 16px 44px rgba(12, 14, 16, 0.45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); scrollbar-color: var(--surface-raised) var(--panel); }
::selection { color: var(--on-accent); background: var(--accent-dark); }
::placeholder { color: var(--muted); opacity: 1; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea { color: inherit; font: inherit; }

/* ---------- app frame & top bar ---------- */
/* The top bar sits on the dark frame; each page's content is a card below it, rounded on top
   and running into the bottom edge of the window. */
.app { display: grid; height: 100dvh; padding: 0 12px; grid-template-rows: 60px minmax(0, 1fr); overflow: hidden; background: var(--frame); }
.app-topbar { position: relative; z-index: 30; display: grid; min-width: 0; padding: 0 6px; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; background: transparent; }
.app-brand { display: flex; min-width: 0; align-items: center; gap: 10px; }
.app-logo { display: block; width: 28px; height: 28px; flex: 0 0 auto; filter: drop-shadow(0 2px 8px rgba(25, 168, 123, .45)); }
.app-brand-name { overflow: hidden; font-size: 14px; font-weight: 750; letter-spacing: -.01em; text-overflow: ellipsis; white-space: nowrap; }
/* Each tab has its own grid column, so the pill under the active tab shares that column without
   measuring anything (the React app's nav, frontend/src/shell/SectionNav.tsx, does the same).
   Moving to another section, the pill slides there as a view transition (below). */
.app-nav { display: grid; padding: 4px 2px; grid-auto-flow: column; background: rgba(255, 255, 255, .03); border: 1px solid var(--line); border-radius: 12px; }
.app-nav > * { grid-row: 1; }
.app-nav-item { position: relative; z-index: 1; display: inline-flex; height: 32px; margin: 0 2px; padding: 0 18px; align-items: center; text-decoration: none; white-space: nowrap; color: var(--muted); background: transparent; border: 0; border-radius: 9px; font-size: 13px; font-weight: 650; transition: color .16s ease, background .16s ease; }
.app-nav-item:hover { color: var(--ink); background: var(--surface-hover); }
.app-nav-item.active, .app-nav-item.active:hover { color: var(--ink); background: transparent; }
.app-nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app-nav-item[href="/"] { grid-column: 1; view-transition-name: nav-tab-messenger; }
.app-nav-item[href="/workflows"] { grid-column: 2; view-transition-name: nav-tab-workflows; }
.app-nav-item[href="/copilot"] { grid-column: 3; view-transition-name: nav-tab-copilot; }
.app-nav-item[href="/mailings"] { grid-column: 4; view-transition-name: nav-tab-mailings; }
.app-nav-item[href="/analytics"] { grid-column: 5; view-transition-name: nav-tab-analytics; }
.app-nav-item[href="/team"] { grid-column: 6; view-transition-name: nav-tab-team; }
.app-nav-pill { z-index: 0; margin: 0 2px; background: var(--surface-raised); border-radius: 9px; box-shadow: inset 0 0 0 1px var(--line-strong), 0 2px 8px rgba(12, 14, 16, .35); pointer-events: none; view-transition-name: nav-pill; }
.app-nav:has(> .active[href="/"]) > .app-nav-pill { grid-column: 1; }
.app-nav:has(> .active[href="/workflows"]) > .app-nav-pill { grid-column: 2; }
.app-nav:has(> .active[href="/copilot"]) > .app-nav-pill { grid-column: 3; }
.app-nav:has(> .active[href="/mailings"]) > .app-nav-pill { grid-column: 4; }
.app-nav:has(> .active[href="/analytics"]) > .app-nav-pill { grid-column: 5; }
.app-nav:has(> .active[href="/team"]) > .app-nav-pill { grid-column: 6; }

/* Moving between sections, whichever page each one is: the browser keeps the old page until the
   new one can draw, the pill slides to the new tab, the tab labels stay put (they are captured
   on their own, above the pill) and the rest changes with a short cross-fade. Chrome 126+ and
   Safari 18.2+; elsewhere the page simply changes. */
@view-transition { navigation: auto; }
::view-transition-group(nav-pill) { animation-duration: .36s; animation-timing-function: cubic-bezier(.3, .8, .25, 1); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
.account-switcher { position: relative; min-width: 0; justify-self: end; }
.bot-identity { display: flex; min-width: 0; max-width: 100%; padding: 4px 8px 4px 6px; align-items: center; gap: 10px; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 12px; transition: background .16s ease, border-color .16s ease; }
.bot-identity:hover, .account-switcher.open .bot-identity { background: var(--surface-hover); border-color: var(--line); }
.bot-identity:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bot-identity-copy span { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.account-switcher-chevron { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .16s ease; }
.account-switcher.open .account-switcher-chevron { transform: rotate(180deg); }
.account-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; display: grid; width: min(330px, calc(100vw - 32px)); max-height: calc(100dvh - 90px); padding: 10px; overflow-y: auto; gap: 8px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow); }
.account-menu-header { display: flex; min-height: 28px; padding: 0 4px; align-items: center; gap: 8px; font-size: 13px; }
.account-menu-back { display: grid; width: 28px; height: 28px; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 8px; }
.account-menu-back:hover { color: var(--ink); background: var(--surface-hover); }
.account-menu-list { display: grid; margin: 0; padding: 0; gap: 2px; list-style: none; }
.account-menu-row { display: flex; align-items: center; gap: 2px; }
.account-menu-item { display: flex; min-width: 0; flex: 1 1 auto; padding: 7px 8px; align-items: center; gap: 10px; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 10px; }
button.account-menu-item:hover:not(:disabled) { background: var(--surface-hover); }
.account-menu-item.active { background: var(--accent-pale); border-color: rgba(25, 168, 123, .45); cursor: default; }
.account-menu-item:disabled:not(.active) { opacity: .6; cursor: progress; }
.account-menu-avatar { display: grid; width: 32px; height: 32px; flex: 0 0 auto; overflow: hidden; place-items: center; color: #fff; background: var(--peer-avatar, linear-gradient(145deg, #2bb58a, #127a5c)); border-radius: 50%; font-size: 12px; font-weight: 850; }
.account-menu-avatar img { width: 100%; height: 100%; object-fit: cover; }
.account-menu-copy { display: grid; min-width: 0; flex: 1 1 auto; gap: 1px; }
.account-menu-copy strong, .account-menu-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-copy strong { font-size: 13px; }
.account-menu-copy span { color: var(--muted); font-size: 11px; }
/* The active connection's @username opens it in Telegram. */
.account-menu-copy a { color: var(--accent); font-weight: 650; text-decoration: none; border-radius: 4px; }
.account-menu-copy a:hover { text-decoration: underline; }
.account-menu-copy a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.account-menu-icon { display: grid; width: 30px; height: 30px; flex: 0 0 auto; place-items: center; color: var(--muted); text-decoration: none; background: transparent; border: 0; border-radius: 8px; font-size: 15px; }
.account-menu-icon:hover:not(:disabled) { color: var(--ink); background: var(--surface-hover); }
.account-menu-icon.danger:hover:not(:disabled) { color: var(--danger); }
.account-menu-icon[aria-pressed] { width: auto; padding: 0 6px; font-size: 11px; font-weight: 700; }
.account-menu-icon[aria-pressed="true"] { color: var(--accent); }
.account-menu-actions { display: grid; padding-top: 8px; gap: 2px; border-top: 1px solid var(--line); }
.account-menu-add { padding: 8px 10px; color: var(--accent); text-align: left; background: transparent; border: 0; border-radius: 9px; font-size: 13px; font-weight: 650; }
.account-menu-add:hover { background: var(--surface-hover); }
.account-menu-logout { color: var(--muted); }
.account-menu-logout:hover { color: var(--ink); }
.account-menu-form { display: grid; padding: 0 4px 4px; gap: 10px; }
.account-menu-field { display: grid; gap: 5px; font-size: 12px; font-weight: 650; }
.account-menu-field input { width: 100%; height: 36px; padding: 0 10px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 9px; font-size: 13px; font-weight: 500; }
.account-menu-field input:focus { border-color: var(--accent); outline: none; }
.account-menu-field small { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.4; }
.account-menu-field small a { color: var(--accent); }
.account-menu-submit { height: 36px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 9px; font-size: 13px; font-weight: 700; }
.account-menu-submit:hover:not(:disabled) { background: var(--accent-dark); }
.account-menu-submit:disabled { opacity: .6; cursor: progress; }
.account-menu-secondary { height: 32px; color: var(--accent); background: transparent; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 12px; font-weight: 650; }
.account-menu-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.account-menu-secondary:disabled { opacity: .6; cursor: progress; }
.account-menu-error { margin: 0; padding: 8px 10px; color: var(--danger); background: rgba(229, 103, 107, .12); border-radius: 9px; font-size: 12px; }
.account-menu-empty { margin: 0; padding: 8px; color: var(--muted); font-size: 12px; }
.bot-status-pill { flex: 0 0 auto; margin-right: 4px; padding: 4px 10px; color: #0c2a1f; background: var(--success); border-radius: 999px; font-size: 11px; font-weight: 800; }
/* The initials, and over them the photo once the browser has it (the server draws both, top_bar.py): nothing is swapped, so a cached photo is there in the first frame. */
.bot-avatar { display: grid; width: 36px; height: 36px; flex: 0 0 auto; overflow: hidden; place-items: center; color: var(--on-accent); background: var(--peer-avatar, linear-gradient(145deg, #2bb58a, #127a5c)); border-radius: 50%; font-size: 13px; font-weight: 850; }
.bot-avatar > *, .account-menu-avatar > * { grid-area: 1 / 1; }
.bot-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bot-identity-copy { display: grid; min-width: 0; gap: 1px; }
.bot-identity-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
button { cursor: pointer; }
input[type="checkbox"] { accent-color: var(--accent); }

.shell {
  display: grid;
  grid-template-columns: 476px minmax(0, 1fr) 0;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
  transition: grid-template-columns .2s cubic-bezier(.4, 0, .2, 1);
}
.shell.copilot-open { grid-template-columns: 476px minmax(0, 1fr) 350px; }
.shell.folders-collapsed { grid-template-columns: 358px minmax(0, 1fr) 0; }
.shell.folders-collapsed.copilot-open { grid-template-columns: 358px minmax(0, 1fr) 350px; }

.sidebar { position: relative; min-width: 0; min-height: 0; overflow: hidden; border-right: 1px solid var(--line); }
.folder-panel { width: 176px; height: 100%; padding: 22px 10px; overflow: hidden; background: var(--panel); border-right: 1px solid var(--line); transition: width .2s cubic-bezier(.4, 0, .2, 1); }
.folder-heading { display: flex; min-height: 43px; padding: 0 8px 18px; align-items: center; gap: 10px; }
.folder-heading-copy { min-width: 0; opacity: 1; transform: translateX(0); transition: opacity .12s ease, transform .16s ease; }
.folder-heading h2 { margin: 0; font-size: 16px; font-weight: 750; letter-spacing: -.01em; }
.folder-toggle { display: grid; width: 26px; height: 26px; flex: 0 0 auto; padding: 0; place-items: center; color: var(--muted); background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 8px; transition: color .18s ease, background .18s ease, border-color .18s ease; }
.folder-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s cubic-bezier(.4, 0, .2, 1); }
.folders-collapsed .folder-toggle svg { transform: rotate(180deg); }
.folder-toggle:hover { color: var(--on-accent); background: var(--accent-dark); border-color: var(--accent-dark); }
.folder-item { position: relative; display: grid; width: 100%; min-height: 40px; margin-bottom: 2px; padding: 8px 9px; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 9px; align-items: center; color: var(--muted); text-align: left; background: transparent; border: 0; border-radius: 10px; font-size: 13px; font-weight: 600; transition: color .18s ease, background .18s ease; }
.folder-item:hover { color: var(--ink); background: rgba(255, 255, 255, .05); }
.folder-item.active { color: var(--ink); background: var(--surface-raised); }
.folder-item.active::before { position: absolute; top: 9px; bottom: 9px; left: -10px; width: 3px; background: var(--status, var(--accent)); border-radius: 0 3px 3px 0; content: ""; }
.folder-icon { display: grid; width: 22px; height: 22px; place-items: center; color: var(--status, var(--muted)); }
.folder-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.folder-item.active .folder-icon { color: var(--status, var(--accent)); }
.folder-label { overflow: hidden; opacity: 1; white-space: nowrap; transform: translateX(0); transition: opacity .12s ease, transform .16s ease; }
.folder-count { min-width: 22px; padding: 3px 7px; overflow: hidden; color: var(--muted); text-align: center; background: rgba(255, 255, 255, .07); border-radius: 999px; box-shadow: 0 0 0 2px var(--panel); opacity: 1; font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; transition: opacity .1s ease, color .18s ease, background .18s ease; }
.folder-count[hidden] { display: none; }
/* Only Ignore holds leads who wrote and wait for us, so only its counter should draw the eye. */
.folder-item[data-folder="ignore"] .folder-count { color: #0c2a1f; background: var(--status-ignore); box-shadow: 0 0 0 2px var(--panel), 0 0 10px color-mix(in srgb, var(--status-ignore) 55%, transparent); }
.folder-section { margin: 14px 9px 6px; overflow: hidden; color: var(--faint); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap; transition: opacity .12s ease; }
.folder-item[data-folder="all"] { --status: var(--status-all); }
.folder-item[data-folder="auto"] { --status: var(--status-auto); }
.folder-item[data-folder="manual"] { --status: var(--status-manual); }
.folder-item[data-folder="ignore"] { --status: var(--status-ignore); }
.folder-item[data-folder="waiting"] { --status: var(--status-waiting); }
.folder-item[data-folder="blocked"] { --status: var(--status-blocked); }
.folder-item[data-folder="stopped"] { --status: var(--status-stopped); }
.folder-item[data-folder="finished"] { --status: var(--status-finished); }
.folders-collapsed .folder-section { opacity: 0; }
.folders-collapsed .folder-panel { width: 58px; }
.folders-collapsed .folder-panel { padding-right: 8px; padding-left: 12px; }
.folders-collapsed .folder-heading { padding-right: 9px; padding-left: 9px; }
.folders-collapsed .folder-heading-copy, .folders-collapsed .folder-label { width: 0; min-width: 0; opacity: 0; transform: translateX(-6px); }
/* Collapsed: the count stays visible as a small badge on the icon corner. */
.folders-collapsed .folder-count { position: absolute; top: 2px; left: calc(50% + 4px); min-width: 16px; padding: 2px 4px; font-size: 9px; line-height: 12px; }
.folders-collapsed .folder-item { padding-right: 10px; padding-left: 10px; grid-template-columns: 22px 0 0; gap: 0; justify-content: center; }
.chat-browser { position: absolute; inset: 0 auto 0 176px; display: flex; width: 300px; min-width: 0; min-height: 0; flex-direction: column; contain: layout paint style; transform: translateX(0); transition: transform .2s cubic-bezier(.4, 0, .2, 1); will-change: transform; }
.folders-collapsed .chat-browser { transform: translateX(-118px); }
.chat-header { display: flex; align-items: center; }
h2, p { margin-top: 0; }

.icon-button, .back-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border: 0;
  border-radius: 11px;
  font-size: 20px;
}

.chat-browser { background: var(--panel); border-left: 1px solid var(--line); }
.chat-browser-head { display: flex; align-items: center; gap: 8px; margin: 16px 14px 10px; }
.chat-browser-head .search-box { flex: 1; min-width: 0; margin: 0; }
.select-chats-button { position: relative; display: grid; width: 38px; height: 38px; flex: 0 0 auto; padding: 0; place-items: center; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 11px; transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.select-chats-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.select-chats-button .select-chats-tick { opacity: 0; transition: opacity .16s ease; }
.select-chats-button:hover { color: var(--ink); background: var(--surface-hover); border-color: var(--line-strong); }
.select-chats-button.active, .select-chats-button.active:hover { color: var(--on-accent); background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .18); }
.select-chats-button.active .select-chats-tick { opacity: 1; }
.chat-item.selectable { position: relative; padding-left: 44px; cursor: pointer; }
.chat-check { position: absolute; top: 50%; left: 14px; width: 20px; height: 20px; background: var(--field); border: 1.5px solid var(--line-strong); border-radius: 50%; transform: translateY(-50%); transition: background .14s ease, border-color .14s ease; }
.chat-item.selectable:hover .chat-check { border-color: var(--accent); }
.chat-item.picked .chat-check { background: var(--accent); border-color: var(--accent); }
.chat-check::after { position: absolute; inset: 3px 6px 7px; content: ""; border: solid var(--on-accent); border-width: 0 2px 2px 0; opacity: 0; transform: rotate(45deg) scale(.6); transition: opacity .14s ease, transform .14s ease; }
.chat-item.picked .chat-check::after { opacity: 1; transform: rotate(45deg) scale(1); }
.chat-item.picked, .chat-item.picked:hover { background: var(--accent-pale); }
.chat-browser .chat-list { flex: 1; }
/* The bar of bulk actions under the list: a counter line with «Выбрать все» and the «×», then
   the status and tag choices with «Применить» once a chat is picked. */
.bulk-bar { display: grid; gap: 10px; padding: 10px 12px 12px; background: var(--surface-raised); border-top: 1px solid var(--line-strong); box-shadow: 0 -8px 20px rgba(12, 14, 16, .18); font-size: 12.5px; }
.bulk-bar[hidden] { display: none; }
.bulk-bar-head { display: flex; min-height: 28px; align-items: center; gap: 4px; }
.bulk-count { display: flex; min-width: 0; flex: 1; align-items: baseline; gap: 5px; overflow: hidden; color: var(--muted); white-space: nowrap; text-overflow: ellipsis; }
.bulk-count b { color: var(--ink); font-size: 14px; font-weight: 750; font-variant-numeric: tabular-nums; }
.bulk-progress { color: var(--faint); font-variant-numeric: tabular-nums; }
.bulk-progress:not(:empty)::before { content: "· "; }
.bulk-link { height: 28px; flex: 0 0 auto; padding: 0 9px; color: var(--accent); white-space: nowrap; background: transparent; border: 0; border-radius: 8px; font-size: 12.5px; font-weight: 700; transition: background .14s ease, color .14s ease; }
.bulk-link:hover:not(:disabled) { color: var(--ink); background: var(--surface-hover); }
.bulk-link:disabled { color: var(--faint); }
.bulk-close { display: grid; width: 28px; height: 28px; flex: 0 0 auto; padding: 0; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 8px; transition: background .14s ease, color .14s ease; }
.bulk-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.bulk-close:hover { color: var(--ink); background: var(--surface-hover); }
.bulk-bar-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.bulk-bar-actions[hidden] { display: none; }
.bulk-field { position: relative; display: block; min-width: 0; }
.bulk-field[hidden] { display: none; }
.bulk-bar-actions:has(.bulk-field[hidden]) .bulk-field { grid-column: 1 / -1; }
.bulk-field select { width: 100%; height: 36px; padding: 0 30px 0 11px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; background: var(--field); border: 1px solid var(--line); border-radius: 10px; font-size: 12.5px; font-weight: 600; appearance: none; transition: border-color .16s ease, box-shadow .16s ease, color .16s ease; }
.bulk-field select:hover:not(:disabled) { border-color: var(--line-strong); }
.bulk-field select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .14); }
.bulk-field select:disabled { color: var(--faint); opacity: .7; }
.bulk-field.chosen select { color: var(--ink); border-color: var(--accent); }
.bulk-field select option { color: var(--ink); background: var(--panel); }
.bulk-field svg { position: absolute; top: 50%; right: 10px; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transform: translateY(-50%); pointer-events: none; }
.bulk-field.chosen svg { stroke: var(--accent); }
.bulk-apply { grid-column: 1 / -1; height: 36px; padding: 0 14px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 10px; font-size: 13px; font-weight: 700; transition: background .16s ease, opacity .16s ease, transform .1s ease; }
.bulk-apply:hover:not(:disabled) { background: var(--accent-dark); }
.bulk-apply:active:not(:disabled) { transform: translateY(1px); }
.bulk-apply:disabled { color: var(--muted); background: var(--surface); opacity: .8; }
.bulk-hint { margin: -2px 0 0; color: var(--faint); font-size: 12px; }
.bulk-hint[hidden] { display: none; }
.search-box { position: relative; display: flex; height: 38px; gap: 8px; align-items: center; margin: 16px 14px 10px; padding: 0 10px 0 12px; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 11px; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.search-box:hover { border-color: var(--line-strong); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .14); }
.search-icon { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; transition: stroke .16s ease; }
.search-box:focus-within .search-icon { stroke: var(--accent); }
.search-box input { width: 100%; min-width: 0; height: 100%; padding: 0; outline: none; background: transparent; border: 0; color: var(--ink); font-size: 13.5px; }
.search-box input::-webkit-search-cancel-button, .search-box input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
.search-clear { display: grid; width: 22px; height: 22px; flex: 0 0 auto; padding: 0; place-items: center; color: var(--muted); background: var(--surface-raised); border: 0; border-radius: 50%; transition: background .14s ease, color .14s ease; }
.search-clear svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.search-clear:hover { color: var(--ink); background: var(--line-strong); }
.chat-list { min-height: 0; overflow-y: auto; contain: layout paint style; }
.chat-list-empty { margin: 24px 18px; color: var(--muted); text-align: center; font-size: 12px; line-height: 1.5; }

.chat-list, .message-area {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-raised) transparent;
}

.chat-list::-webkit-scrollbar, .message-area::-webkit-scrollbar { width: 7px; }
.chat-list::-webkit-scrollbar-track, .message-area::-webkit-scrollbar-track {
  margin-block: 8px;
  background: linear-gradient(
    to right,
    transparent 2px,
    var(--line) 2px,
    var(--line) 5px,
    transparent 5px
  );
  border-radius: 999px;
}
.chat-list::-webkit-scrollbar-thumb, .message-area::-webkit-scrollbar-thumb {
  min-height: 56px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.chat-list::-webkit-scrollbar-thumb:hover, .message-area::-webkit-scrollbar-thumb:hover { background: var(--accent-dark); }
.chat-list::-webkit-scrollbar-button, .message-area::-webkit-scrollbar-button,
.chat-list::-webkit-scrollbar-button:single-button,
.message-area::-webkit-scrollbar-button:single-button,
.chat-list::-webkit-scrollbar-button:vertical:decrement,
.message-area::-webkit-scrollbar-button:vertical:decrement,
.chat-list::-webkit-scrollbar-button:vertical:increment,
.message-area::-webkit-scrollbar-button:vertical:increment {
  display: none;
  width: 0;
  height: 0;
  appearance: none;
  background: transparent;
}

.chat-item {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 11px;
  width: 100%;
  padding: 12px 16px;
  text-align: left;
  background: transparent;
  border: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  box-shadow: inset 3px 0 0 transparent;
  content-visibility: auto;
  transition: background .14s ease;
  contain-intrinsic-size: auto 70px;
}
.chat-item:hover { background: var(--surface-hover); }
.chat-item.active { background: var(--accent-pale); border-bottom-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chat-item[data-folder="stopped"] { background: color-mix(in srgb, var(--status-stopped) 10%, transparent); }
.chat-item[data-folder="stopped"]:hover { background: color-mix(in srgb, var(--status-stopped) 16%, transparent); }
.chat-item[data-folder="stopped"].active { background: color-mix(in srgb, var(--status-stopped) 20%, transparent); border-bottom-color: var(--status-stopped); box-shadow: inset 0 0 0 1px var(--status-stopped); }
/* Telegram's seven placeholders for a chat without a photo (peerColorIndex in common.js): red,
   orange, violet, green, cyan, blue, pink, lighter at the top as in the Telegram apps. */
[data-peer-color="0"] { --peer-avatar: linear-gradient(180deg, #ff885e, #ff516a); }
[data-peer-color="1"] { --peer-avatar: linear-gradient(180deg, #ffcd6a, #ffa85c); }
[data-peer-color="2"] { --peer-avatar: linear-gradient(180deg, #82b1ff, #665fff); }
[data-peer-color="3"] { --peer-avatar: linear-gradient(180deg, #a0de7e, #54cb68); }
[data-peer-color="4"] { --peer-avatar: linear-gradient(180deg, #00fcfd, #4acccd); }
[data-peer-color="5"] { --peer-avatar: linear-gradient(180deg, #72d5fd, #2a9ef1); }
[data-peer-color="6"] { --peer-avatar: linear-gradient(180deg, #e0a2f3, #d669ed); }
.avatar { display: grid; place-items: center; width: 46px; height: 46px; color: white; background: var(--peer-avatar, linear-gradient(145deg, #2bb58a, #127a5c)); border-radius: 50%; font-weight: 750; }
.avatar { position: relative; overflow: hidden; flex: 0 0 auto; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-image { position: absolute; inset: 0; opacity: 0; }
.avatar-image.loaded { opacity: 1; }
.avatar-small { width: 38px; height: 38px; font-size: 13px; }
/* A starred lead: a small star on the top left of its avatar in the chat list. */
.chat-avatar-slot { position: relative; display: block; align-self: start; }
.chat-star { position: absolute; top: -4px; left: -5px; width: 16px; height: 16px; fill: var(--star); stroke: var(--panel); stroke-width: 2.4; stroke-linejoin: round; paint-order: stroke; pointer-events: none; }
/* The header's star marks or unmarks the open lead: empty until pressed, then yellow. */
.star-toggle { display: grid; width: 28px; height: 28px; flex: 0 0 auto; margin-right: -5px; padding: 0; place-items: center; color: var(--faint); background: transparent; border: 0; border-radius: 8px; cursor: pointer; transition: color .14s ease, background .14s ease; }
.star-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.star-toggle:hover { color: var(--muted); background: var(--surface-hover); }
.star-toggle[aria-pressed="true"] { color: var(--star); }
.star-toggle[aria-pressed="true"] svg { fill: currentColor; }
.star-toggle:disabled { cursor: progress; }
.chat-copy { min-width: 0; overflow: hidden; }
.chat-name-row { display: flex; min-width: 0; align-items: center; gap: 6px; overflow: hidden; }
.chat-name-row strong { min-width: 0; flex: 0 0 auto; white-space: nowrap; }
.chat-copy strong, .chat-preview { display: block; white-space: nowrap; }
.chat-preview { overflow: hidden; text-overflow: ellipsis; }
.chat-copy strong { margin: 3px 0 5px; font-size: 14px; }
.chat-preview { color: var(--muted); font-size: 12px; }
.chat-preview-author { color: var(--faint); }
.chat-preview-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: 1px; background: var(--accent); border-radius: 50%; }
.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; padding-top: 3px; color: var(--muted); font-size: 10px; }
.unread { display: grid; min-width: 20px; height: 20px; padding: 0 5px; place-items: center; color: white; background: var(--accent); border-radius: 10px; font-size: 10px; font-weight: 700; }
/* Rows standing in for the chat list until the server's first answer, when this browser kept
   no list (inbox/snapshot.js). */
.chat-skeleton { pointer-events: none; }
.chat-skeleton .avatar { background: var(--surface-raised); }
.chat-skeleton .chat-copy { display: grid; gap: 10px; align-content: center; }
.chat-skeleton .skeleton-line:first-child { width: 42%; }
.chat-skeleton .skeleton-line:last-child { width: 74%; height: 8px; }
.load-more, .older-button { margin: 10px auto; padding: 7px 12px; color: var(--accent-dark); background: transparent; border: 0; font-weight: 700; }

.conversation { position: relative; min-width: 0; min-height: 0; background-color: var(--bg); background-image: radial-gradient(rgba(168, 176, 181, .16) 0.7px, transparent 0.8px), linear-gradient(180deg, #2f3437 0%, #25282b 55%, #1d2022 100%); background-size: 16px 16px, 100% 100%; }
.empty-state { display: grid; height: 100%; padding: 20px; place-content: center; text-align: center; }
.empty-icon { display: grid; width: 58px; height: 58px; margin: 0 auto 18px; place-items: center; color: var(--accent); background: var(--accent-pale); border-radius: 18px; font-size: 27px; }
.empty-state h2 { margin-bottom: 7px; }
.empty-state p { color: var(--muted); }
.chat-view { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; height: 100%; }
/* backdrop-filter makes the header a stacking context. Keep that context above the timeline so
   the language menu cannot be covered by message controls or flow-step text. */
.chat-header { position: relative; z-index: 3; gap: 11px; padding: 13px 20px; background: rgba(45, 49, 52, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.back-button { display: none; }
.chat-title-wrap { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.chat-title-wrap strong { font-size: 14px; }
.chat-title-wrap span { color: var(--muted); font-size: 11px; }
.chat-subtitle-row { display: flex; min-width: 0; align-items: center; gap: 7px; overflow: hidden; }
.chat-subtitle-row > span:first-child { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-tags { display: flex; min-width: 0; flex: 1 1000 auto; align-items: center; gap: 4px; overflow: hidden; white-space: nowrap; }
.inline-tags .tag-chip { max-width: none; }
.tag-overflow-marker { flex: 0 0 auto; color: var(--muted) !important; font-size: 12px !important; font-weight: 800; user-select: none; }
.header-tags { flex-grow: 1; }
.inline-tags .tag-chip { flex: 0 0 auto; padding: 2px 6px; font-size: 9px; }
.copilot-toggle-slot { display: grid; flex: 0 0 auto; place-items: center; }
.copilot-toggle { display: grid; width: 26px; height: 26px; flex: 0 0 auto; padding: 0 0 2px; place-items: center; color: var(--muted); background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 8px; font-size: 16px; font-weight: 700; line-height: 1; transition: color .18s ease, background .18s ease, border-color .18s ease; }
.copilot-toggle:hover { color: var(--on-accent); background: var(--accent-dark); border-color: var(--accent-dark); }
.language-picker { position: relative; flex: 0 0 auto; }
.language-trigger { display: flex; height: 34px; padding: 0 6px 0 9px; align-items: center; gap: 6px; color: var(--muted); background: var(--field); border: 1px solid var(--line); border-radius: 10px; transition: color .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease; }
.language-trigger:hover { color: var(--ink); background: var(--surface-hover); border-color: var(--line-strong); }
.language-trigger[aria-expanded="true"] { color: var(--ink); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .16); }
.language-trigger[aria-expanded="true"] .select-chevron { color: var(--accent); transform: rotate(180deg); }
.language-trigger > svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.language-trigger .select-chevron { width: 18px; height: 18px; }
.language-trigger .select-chevron svg { width: 14px; height: 14px; }
.language-code { color: var(--ink); font-size: 11px; font-weight: 800; letter-spacing: .06em; }
.language-menu { position: absolute; z-index: 9; top: calc(100% + 6px); right: 0; display: grid; width: 210px; padding: 6px; gap: 2px; background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); animation: select-pop .14s ease-out; }
.language-menu-title { margin: 4px 8px 6px; color: var(--faint); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.language-option { display: flex; width: 100%; padding: 6px 8px 6px 6px; align-items: center; gap: 10px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 8px; }
.language-option:hover, .language-option:focus-visible { outline: none; background: var(--surface-hover); }
.language-option[aria-selected="true"] { background: rgba(25, 168, 123, .14); }
.language-option[aria-selected="true"]::after { width: 16px; height: 16px; flex: 0 0 auto; margin-left: auto; background: var(--accent); content: ""; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.language-badge { display: grid; width: 30px; height: 26px; flex: 0 0 auto; place-items: center; color: var(--accent); background: rgba(25, 168, 123, .14); border: 1px solid rgba(25, 168, 123, .32); border-radius: 7px; font-size: 10px; font-weight: 850; letter-spacing: .05em; }
.language-option-copy { display: grid; min-width: 0; gap: 1px; }
.language-option-copy strong { font-size: 13px; font-weight: 650; }
.language-option-copy small { color: var(--muted); font-size: 11px; }

.message-area { overflow-y: auto; padding: 22px clamp(16px, 4vw, 64px); background: transparent; }
.messages { display: flex; max-width: 850px; margin: 0 auto; flex-direction: column; gap: 7px; }
/* One day of the chat: its date pill sticks only while the day's rows are on screen. */
.day-group { display: flex; flex-direction: column; gap: 7px; }
.date-separator { position: sticky; top: 8px; z-index: 2; display: flex; width: 100%; margin: 8px 0 3px; justify-content: center; pointer-events: none; }
.date-separator span { padding: 5px 11px; color: var(--ink); background: rgba(45, 49, 52, .92); border: 1px solid var(--line-strong); border-radius: 999px; box-shadow: 0 2px 8px rgba(12, 14, 16, .18); backdrop-filter: blur(8px); font-size: 11px; font-weight: 700; line-height: 1; }
.message-row { display: flex; width: fit-content; max-width: min(76%, 650px); align-self: flex-start; align-items: center; gap: 7px; }
.message-row.outgoing { align-self: flex-end; }
.message-row.voice-row { width: min(380px, 76%); }
.message-row.voice-row:not(.outgoing) { margin-left: 33px; }
.message { min-width: 0; padding: 9px 11px 7px; background: var(--incoming); border-radius: 6px 15px 15px 15px; box-shadow: 0 1px 3px rgba(12, 14, 16, .24); overflow-wrap: anywhere; line-height: 1.4; font-size: 13px; white-space: pre-wrap; }
.message.outgoing { background: var(--outgoing); border-radius: 15px 6px 15px 15px; }
.message.outgoing.automated { background: var(--outgoing-automated); }
.message { border: 1px solid transparent; }
.message:not(.outgoing):not(.deleted-message) { border-color: var(--line); }
.message.outgoing { color: #fff; box-shadow: 0 2px 10px rgba(10, 50, 38, .35); }
.message.outgoing .message-time, .message.outgoing .voice-footer { color: rgba(255, 255, 255, .72); }
.message.outgoing .message-reply { background: rgba(255, 255, 255, .14); }
.message.outgoing .message-reply:hover { background: rgba(255, 255, 255, .22); }
.message.outgoing .message-reply::before { background: #fff; }
.message.outgoing .message-reply-sender { color: #fff; }
.message.outgoing .voice-play { color: var(--accent-dark); background: #fff; }
.message.outgoing .voice-waveform span { background: rgba(255, 255, 255, .6); }
.message.outgoing .voice-waveform span.played { background: #fff; }
.message.outgoing .voice-transcribe, .message.outgoing .transcribe-button { color: #fff; }
.message.outgoing .voice-transcribe { background: rgba(255, 255, 255, .16); }
.message.deleted-message { color: #ffd8d8; background: rgba(129, 37, 45, .72); border: 1px solid rgba(255, 111, 119, .48); }
.deleted-label { margin-right: 7px; color: #ffb3b8; font-size: 9px; font-weight: 750; }
.message-actions { position: relative; flex: 0 0 auto; }
.message-more { width: 30px; height: 28px; padding: 0; color: var(--muted); background: transparent; border: 0; opacity: 0; transition: color .14s ease, opacity .14s ease; }
.message-row:hover .message-more, .message-more:focus-visible, .message-more[aria-expanded="true"] { opacity: 1; }
.message-more:hover, .message-more[aria-expanded="true"] { color: var(--ink); background: transparent; }
.message-menu { position: absolute; z-index: 8; top: 31px; left: 50%; min-width: 116px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); transform: translateX(-50%); }
.message-menu button { display: block; width: 100%; padding: 7px 9px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 6px; font-size: 12px; }
.message-menu button:hover { background: var(--surface-hover); }
.message-menu button.danger { color: #ff8f96; }
.message-menu button:disabled { display: none; }
.message-reply { position: relative; display: grid; width: 100%; min-width: 150px; margin: -2px 0 7px; padding: 5px 8px 5px 10px; overflow: hidden; color: inherit; text-align: left; background: rgba(25, 168, 123, .14); border: 0; border-radius: 6px; cursor: pointer; line-height: 1.25; white-space: normal; }
.message-reply:hover { background: rgba(25, 168, 123, .23); }
.message-reply:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.message-reply::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); border-radius: 3px; content: ""; }
.message-reply-sender { overflow: hidden; color: var(--accent); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.message-reply-text { overflow: hidden; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.message.message-highlight { animation: message-highlight 1.45s ease-out; }
@keyframes message-highlight { 0%, 28% { box-shadow: 0 0 0 4px rgba(25, 168, 123, .62), 0 1px 3px rgba(12, 14, 16, .24); filter: brightness(1.2); } 100% { box-shadow: 0 1px 3px rgba(12, 14, 16, .24); filter: brightness(1); } }
.message-text { display: block; }
.message-sticker { display: block; width: 160px; max-width: 100%; height: auto; margin-bottom: 6px; object-fit: contain; }
.message-image { display: block; width: auto; max-width: min(420px, 100%); max-height: 520px; margin-bottom: 6px; border-radius: 10px; object-fit: contain; }
.message-video { display: block; width: min(420px, 100%); max-height: 520px; margin-bottom: 6px; background: #111; border-radius: 10px; object-fit: contain; cursor: pointer; }
.message-album-tile video { cursor: pointer; }
.message-row[hidden] { display: none; }
.message-buttons { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.message-button { padding: 4px 10px; color: inherit; background: rgba(255, 255, 255, .14); border-radius: 8px; font-size: 12px; text-decoration: none; }
a.message-button:hover { background: rgba(255, 255, 255, .24); }
.pending-messages:not(:empty) { margin-top: 7px; }
.message.outgoing.pending { opacity: .55; box-shadow: none; }
.message.outgoing.pending.failed { opacity: 1; background: #6b3434; }
.message.pending .saved-media, .message.pending .saved-album { width: min(340px, 100%); margin-bottom: 6px; }
.message.pending .saved-media img { max-height: 260px; }
.pending-status { font-style: italic; }
.message.pending.failed .pending-status { font-style: normal; white-space: normal; text-align: left; }
.pending-dismiss { flex: 0 0 auto; padding: 2px 8px; white-space: nowrap; color: #fff; background: rgba(255, 255, 255, .14); border: 0; border-radius: 6px; font-size: 10px; }
.pending-dismiss:hover { background: rgba(255, 255, 255, .24); }
.message:has(> .message-album) { width: min(340px, 100%); }
.message-album { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; margin-bottom: 6px; overflow: hidden; border-radius: 10px; }
.message-album.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.message-album-tile { display: grid; aspect-ratio: 1; overflow: hidden; place-items: center; color: var(--muted); background: var(--surface-hover); font-size: 12px; }
.message-album-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.message-album-video { display: block; width: 100%; height: 100%; background: #111; object-fit: cover; }
.message-album-tile.failed img, .message-album-tile.failed video { display: none; }
.message-album-tile.failed::after { content: "Медиа"; }
.message-media-error { display: block; min-width: 190px; padding: 24px 14px; color: var(--muted); text-align: center; background: var(--surface-hover); border-radius: 10px; }
.voice-message { width: 100%; max-width: 100%; padding: 10px 12px 8px; }
.voice-audio { display: none; }
.voice-controls { display: grid; min-width: 0; grid-template-columns: 46px minmax(0, 1fr) 38px; gap: 10px; align-items: center; }
.voice-play { display: grid; width: 46px; height: 46px; padding: 0 0 0 3px; place-items: center; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 50%; box-shadow: 0 3px 10px rgba(0, 0, 0, .16); font-size: 17px; line-height: 1; transition: background .16s ease, transform .16s ease; }
.voice-play:hover { background: var(--accent-dark); transform: scale(1.04); }
.voice-play:active { transform: scale(.96); }
.voice-waveform { display: flex; height: 26px; min-width: 0; padding: 0; align-items: center; gap: 2px; background: transparent; border: 0; }
.voice-waveform span { width: 2px; min-width: 1px; flex: 1 1 2px; background: var(--muted); border-radius: 999px; opacity: .52; transition: height .12s ease, background .12s ease, opacity .12s ease; }
.voice-waveform span.played { background: var(--accent); opacity: 1; }
.voice-waveform:hover span { opacity: .78; }
.voice-waveform:hover span.played { opacity: 1; }
.voice-transcribe { position: relative; display: grid; width: 38px; height: 32px; padding: 0; place-items: center; color: var(--accent); background: rgba(25, 168, 123, .12); border: 0; border-radius: 9px; font-size: 13px; font-weight: 800; transition: color .16s ease, background .16s ease, transform .16s ease; }
.voice-transcribe:hover { color: var(--on-accent); background: var(--accent-dark); transform: translateY(-1px); }
.voice-transcribe.loading { cursor: wait; }
.voice-transcribe.loading .voice-transcribe-icon { animation: transcription-pulse .8s ease-in-out infinite alternate; }
.voice-transcribe.complete { color: var(--on-accent); background: var(--accent-dark); }
.voice-footer { display: grid; margin: -6px 0 0 56px; grid-template-columns: 1fr auto; align-items: center; color: var(--muted); font-size: 10px; }
.voice-time { font-size: 10px; }
.voice-transcript { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .24s ease, opacity .18s ease, margin-top .24s ease; }
.voice-transcript > div { min-height: 0; overflow: hidden; }
.voice-transcript.visible { margin-top: 8px; grid-template-rows: 1fr; opacity: 1; }
.voice-transcript .transcript-text { margin: 0; padding-top: 8px; border-top: 1px solid rgba(141, 153, 176, .2); line-height: 1.45; }
@keyframes transcription-pulse { from { opacity: .35; transform: scale(.88); } to { opacity: 1; transform: scale(1.08); } }
.message-video-note { display: block; width: min(260px, 62vw); aspect-ratio: 1; margin: 0 auto 7px; overflow: hidden; background: #111; border-radius: 50%; object-fit: cover; }
.message-transcription { margin-top: 7px; padding-top: 7px; border-top: 1px solid rgba(141, 153, 176, .2); }
.transcribe-button { position: relative; padding: 4px 8px 4px 22px; color: var(--accent); background: transparent; border: 0; font-size: 11px; font-weight: 700; }
.transcribe-button::before { position: absolute; top: 50%; left: 7px; width: 8px; height: 8px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; content: ""; transform: translateY(-50%); }
.transcribe-button:not(.loading)::before { width: 7px; height: 7px; background: currentColor; border: 0; }
.transcribe-button.loading::before { animation: media-spin .75s linear infinite; }
.transcript-text { margin: 7px 0 2px; white-space: pre-wrap; }
.transcript-text:empty { display: none; }
/* What a model saw on the lead's photo or heard in a voice message: quieter than the message. */
.media-note { margin: 6px 0 2px; color: var(--muted); font-size: 13px; font-style: italic; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.voice-transcript .media-note { margin: 0; padding-top: 8px; border-top: 1px solid rgba(141, 153, 176, .2); }
.message.outgoing .media-note { color: rgba(255, 255, 255, .72); }
@keyframes media-spin { to { transform: translateY(-50%) rotate(360deg); } }
.message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 7px; margin-top: 3px; }
.message-step { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.message-time { color: var(--muted); text-align: right; font-size: 9px; line-height: 1; white-space: nowrap; }
/* Read ticks: grey on the lead's messages like their time, green on ours. */
.message-ticks { display: inline-flex; flex: 0 0 auto; margin-left: -4px; color: var(--muted); line-height: 0; }
.message-ticks svg { width: 16px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.message-ticks.ours { color: #5ff0b0; }
.voice-stamp { display: inline-flex; align-items: center; gap: 3px; }
.voice-length { display: inline-flex; align-items: center; gap: 5px; }
/* Telegram's dot on a recording nobody here has played yet. */
.unheard-dot { display: inline-block; width: 6px; height: 6px; flex: 0 0 auto; background: var(--accent); border-radius: 50%; }
.unheard-dot[hidden] { display: none; }
.message-meta .unheard-dot { margin-left: 2px; }
.voice-stamp .message-ticks { margin-left: 0; }
.translate-button { display: grid; width: 26px; height: 26px; flex: 0 0 auto; padding: 0; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 50%; opacity: .7; }
.translate-button img { width: 16px; height: 16px; pointer-events: none; }
.translate-button:hover, .translate-button.active { color: var(--ink); background: var(--surface-hover); opacity: 1; }
.translate-button.loading::after { width: 13px; height: 13px; content: ""; border: 2px solid rgba(238, 242, 248, .3); border-top-color: var(--ink); border-radius: 50%; animation: translation-spin .65s linear infinite; }
@keyframes translation-spin { to { transform: rotate(360deg); } }

.quick-templates { position: absolute; right: 12px; bottom: calc(100% + 6px); left: 12px; z-index: 6; display: grid; max-height: 320px; padding: 6px; overflow-y: auto; background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); }
.quick-templates[hidden] { display: none; }
.schedule-panel { position: absolute; right: 12px; bottom: calc(100% + 6px); left: 12px; z-index: 6; display: grid; gap: 8px; padding: 12px; background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; }
.schedule-panel[hidden] { display: none; }
.schedule-panel small { color: var(--faint); font-size: 11px; }
.schedule-choices, .schedule-custom { display: flex; flex-wrap: wrap; gap: 6px; }
.schedule-choice, .schedule-cancel { padding: 6px 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 700; }
.schedule-choice:hover, .schedule-cancel:hover { border-color: var(--accent); }
.schedule-custom input { padding: 6px 8px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 8px; color-scheme: dark; }
.schedule-submit { padding: 6px 12px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 999px; font-size: 12px; font-weight: 750; }
/* Later bubbles at the end of the chat: what the operator scheduled and what the flow will send
   by itself. A see-through fill and long dashes say "not sent yet"; ••• sits on the left like on
   our sent messages and a blank on the right stands for their translate button, so the bubble
   lines up with them and never runs past the edge. */
.later-actions-blank { width: 30px; }
.later-spacer { flex: 0 0 26px; }
.message.outgoing.later { color: rgba(255, 255, 255, .9); background-color: rgba(25, 168, 123, .13); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' rx='15' ry='15' fill='none' stroke='%2319a87b' stroke-width='3' stroke-dasharray='9 7' stroke-linecap='round'/%3E%3C/svg%3E"); border: 0; border-radius: 15px; box-shadow: none; }
/* What the flow will send: the automatic messages' dark green, the dashes a shade lighter to show. */
.message.outgoing.later.flow-plan { background-color: var(--outgoing-automated); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' rx='15' ry='15' fill='none' stroke='%234d7267' stroke-width='3' stroke-dasharray='9 7' stroke-linecap='round'/%3E%3C/svg%3E"); }
.message.outgoing.later .message-time { color: rgba(255, 255, 255, .62); font-size: 10px; }

/* Only the head of the generated series moves; delivery events replace pending bubbles. */
.message.outgoing.later.ai-sending { position: relative; background-image: none; }
.ai-send-border { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ai-send-border rect { width: calc(100% - 2px); height: calc(100% - 2px); fill: none; stroke: #72b69f; stroke-width: 1.5; stroke-dasharray: 9 7; stroke-linecap: round; animation: ai-send-breathe 2.8s ease-in-out infinite; }
@keyframes ai-send-breathe { 0%, 100% { opacity: .4; } 50% { opacity: .9; } }
/* Only named message bubbles participate, never the whole application. */
:root { view-transition-name: none; }
.message-area { view-transition-name: chat-lane; }
::view-transition-group(*) { animation-duration: .36s; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
::view-transition-old(*), ::view-transition-new(*) { animation-duration: .24s; }
@media (prefers-reduced-motion: reduce) { ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none; } }
@media (prefers-reduced-motion: reduce) { .ai-send-border rect { animation: none; stroke: #94e3c6; } }
.later-time::before { content: "⏰ "; }
.flow-plan .later-time::before { content: "⏱ "; }
.ai-typing-status { font-weight: inherit; text-transform: none; animation: ai-typing-pulse 2.4s ease-in-out infinite; }
.ai-typing-dots > span { animation: ai-typing-dot 1.2s ease-in-out infinite; }
.ai-typing-dots > span:nth-child(2) { animation-delay: .2s; }
.ai-typing-dots > span:nth-child(3) { animation-delay: .4s; }
@keyframes ai-typing-pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes ai-typing-dot { 0%, 70%, 100% { opacity: .3; text-shadow: none; } 35% { opacity: 1; text-shadow: 0 0 4px currentColor; } }
@media (prefers-reduced-motion: reduce) { .ai-typing-status, .ai-typing-dots > span { animation: none; } }
.flow-plan.step .message-text { color: rgba(255, 255, 255, .78); font-size: 13px; }
.later-label { display: block; margin-bottom: 3px; color: #8fb8aa; font-size: 10px; font-weight: 750; letter-spacing: .02em; text-transform: uppercase; }
.later-media { display: block; margin-bottom: 3px; color: rgba(255, 255, 255, .7); font-size: 12px; }
.later-sticker { display: block; width: 96px; height: 96px; margin: 2px 0 4px; object-fit: contain; }
.flow-plan.ai .message-text, .flow-plan.reply .message-text, .flow-plan.listening .message-text { color: rgba(255, 255, 255, .72); font-style: italic; }
.flow-plan.listening .later-time::before { content: "🎧 "; }
.later-time.countdown { font-variant-numeric: tabular-nums; }
/* The profile's quiet hours moved this send past them. */
.later-quiet { margin-left: 6px; color: rgba(255, 255, 255, .62); font-size: 10px; }
.later-quiet::before { content: "🌙 "; }
/* Pending actions remain visible beside the timer, including on touch screens. */
.later-hurry, .later-cancel { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border: 1px solid transparent; border-radius: 999px; font: inherit; font-size: 10.5px; font-weight: 650; line-height: 1.35; cursor: pointer; transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease; }
.later-hurry::before, .later-cancel::before { font-size: 8px; line-height: 1; }
.later-hurry { color: #d3f7e4; background: linear-gradient(135deg, #2f7a58, #226347); border-color: rgba(148, 227, 198, .34); box-shadow: 0 1px 6px rgba(25, 168, 123, .2); }
.later-hurry::before { content: "▶"; }
.later-cancel { color: #d9b3b6; background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .13); }
.later-cancel::before { content: "✕"; opacity: .75; }
.later-hurry:hover:not(:disabled) { background: linear-gradient(135deg, #38906a, #2a7656); box-shadow: 0 2px 10px rgba(25, 168, 123, .35); transform: translateY(-1px); }
.later-cancel:hover:not(:disabled) { color: #f0c5c8; background: rgba(160, 80, 88, .22); border-color: rgba(200, 120, 128, .4); transform: translateY(-1px); }
.later-hurry:active:not(:disabled), .later-cancel:active:not(:disabled) { transform: translateY(0) scale(.97); }
.later-hurry:disabled, .later-cancel:disabled { opacity: .55; cursor: default; }
.later-hurry:focus-visible, .later-cancel:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .later-hurry, .later-cancel { transition: none; } }
.later-meta { flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; }
.later-row.later-busy { opacity: .45; pointer-events: none; }
.later-row .message-menu button { white-space: nowrap; }
.quick-option { display: grid; gap: 2px; width: 100%; padding: 8px 10px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 8px; }
.quick-option.active, .quick-option:hover { background: var(--accent-pale); }
.quick-head { display: flex; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.quick-files { color: var(--accent); }
.quick-text { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.quick-text img { width: 1.1em; height: 1.1em; vertical-align: -.2em; }
.quick-description { overflow: hidden; color: var(--faint); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.quick-empty { margin: 0; padding: 10px; color: var(--faint); font-size: 12px; }
.saved-hint { margin: -4px 0 0; color: var(--faint); font-size: 11px; }
.composer { position: relative; padding: 0; background: var(--surface); border-top: 1px solid var(--line); }
.composer-reply { display: flex; margin: 6px 10px 0 56px; padding: 4px 4px 4px 10px; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); border-left: 2px solid var(--accent); font-size: 12px; }
.composer-reply[hidden] { display: none; }
.composer-reply div { display: grid; min-width: 0; }
.composer-reply strong { color: var(--accent); }
.composer-reply span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-reply button { width: 28px; height: 28px; flex: 0 0 auto; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 50%; font-size: 19px; }
.composer-reply button:hover { color: var(--ink); background: var(--surface-hover); }
.copilot-sidebar { min-width: 0; padding: 0 16px 20px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); opacity: 0; transform: translateX(22px); pointer-events: none; transition: opacity .2s ease, transform .26s ease; }
.shell.copilot-open .copilot-sidebar { opacity: 1; transform: translateX(0); pointer-events: auto; }
.copilot-content { padding-top: 16px; }
.copilot-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.copilot-panel-toggle-slot { width: 30px; height: 30px; }
.copilot-head strong { font-size: 14px; }
.copilot-tabs { display: flex; gap: 5px; padding: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.copilot-tab { display: grid; width: 30px; height: 30px; padding: 0; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: 17px; line-height: 1; }
.copilot-tab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.copilot-tab:hover { color: var(--ink); background: var(--surface-hover); }
.copilot-tab.active { color: var(--on-accent); background: linear-gradient(135deg, var(--accent), #4f9de5); }
.copilot-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* Copilot panel (manual mode): header, profile picker and the per-chat brief. */
.assistant-panel { display: grid; gap: 12px; }
.copilot-hero { display: grid; }
.copilot-hero-title { display: flex; align-items: center; gap: 8px; }
.copilot-hero-title h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.copilot-mode-chip { margin-left: auto; padding: 3px 8px; color: var(--status-manual); background: color-mix(in srgb, var(--status-manual) 14%, transparent); border: 1px solid color-mix(in srgb, var(--status-manual) 38%, transparent); border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; cursor: help; }

.profile-picker { position: relative; display: grid; gap: 6px; }
.profile-picker-label, .copilot-field-head strong { color: var(--faint); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.profile-picker-trigger { display: flex; width: 100%; min-height: 50px; padding: 7px 8px 7px 7px; align-items: center; gap: 10px; color: var(--ink); text-align: left; background: var(--field); border: 1px solid var(--line); border-radius: 12px; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.profile-picker-trigger:not(:disabled):hover { background: var(--surface-hover); border-color: var(--line-strong); }
.profile-picker-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .16); }
.profile-picker-trigger[aria-expanded="true"] .select-chevron { color: var(--accent); transform: rotate(180deg); }
.profile-picker-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.profile-badge { --badge: var(--accent); display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; color: var(--badge); background: color-mix(in srgb, var(--badge) 18%, transparent); border: 1px solid color-mix(in srgb, var(--badge) 40%, transparent); border-radius: 10px; font-size: 14px; font-weight: 800; line-height: 1; }
.profile-picker-copy, .profile-option-copy { display: grid; min-width: 0; flex: 1; gap: 2px; }
.profile-picker-copy strong, .profile-option-copy strong { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.profile-picker-copy small, .profile-option-copy small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.profile-picker-menu { position: absolute; z-index: 7; top: calc(100% + 6px); right: 0; left: 0; display: grid; max-height: 300px; padding: 5px; gap: 2px; overflow-y: auto; background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); animation: select-pop .14s ease-out; }
.profile-option { display: flex; width: 100%; padding: 6px 8px 6px 6px; align-items: center; gap: 10px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 9px; }
.profile-option .profile-badge { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
.profile-option:hover, .profile-option:focus-visible { outline: none; background: var(--surface-hover); }
.profile-option[aria-selected="true"] { background: rgba(25, 168, 123, .14); }
.profile-option[aria-selected="true"]::after { width: 16px; height: 16px; flex: 0 0 auto; background: var(--accent); content: ""; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.profile-flow-note { margin: 0; padding: 7px 9px; color: var(--status-waiting); background: color-mix(in srgb, var(--status-waiting) 10%, transparent); border: 1px solid color-mix(in srgb, var(--status-waiting) 30%, transparent); border-radius: 9px; font-size: 11px; line-height: 1.4; }

.copilot-session-slot { display: grid; }
.copilot-session-empty { margin: 0; padding: 18px 12px; color: var(--faint); text-align: center; border: 1px dashed var(--line); border-radius: 12px; font-size: 12px; }
.copilot-session { display: grid; gap: 12px; }
.copilot-brief { display: grid; gap: 10px; padding: 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.copilot-field { display: grid; gap: 5px; }
.copilot-field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.copilot-field-input { width: 100%; min-height: 40px; padding: 8px 10px; overflow: hidden; color: var(--ink); resize: none; background: var(--field); border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 12px; line-height: 1.45; }
.copilot-field-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(25, 168, 123, .13); }
.generate-button { width: 100%; padding: 11px 13px; font-size: 13px; }
.generate-model { display: flex; min-width: 0; align-items: center; justify-content: center; gap: 5px; margin: 6px 0 0; color: var(--faint); font-size: 11px; line-height: 1.3; }
.generate-model code { overflow: hidden; font: inherit; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .01em; text-overflow: ellipsis; white-space: nowrap; }
.generate-model-logo { width: 13px; height: 13px; flex: 0 0 13px; object-fit: contain; }
.generate-model-fallback { display: grid; place-items: center; border-radius: 50%; background: var(--surface-raised); font-size: 6px; font-weight: 900; line-height: 1; text-transform: uppercase; }
.primary-button, .send-button { padding: 9px 13px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 10px; font-weight: 750; font-size: 12px; white-space: nowrap; }
.primary-button:hover, .send-button:hover { background: var(--accent-dark); }
button:disabled { cursor: wait; opacity: .55; }
.suggestions { display: flex; flex-direction: column; gap: 10px; }
.suggestion-context { display: grid; gap: 6px; padding: 11px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; line-height: 1.45; }
.suggestion-context strong, .suggestion-tone { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.suggestion-card-head { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px; align-items: center; }
.suggestion-chip { max-width: 100%; overflow: hidden; padding: 2px 7px; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 999px; font-size: 10px; font-weight: 700; }
.stage-chip { color: var(--status-waiting); border-color: color-mix(in srgb, var(--status-waiting) 40%, transparent); background: color-mix(in srgb, var(--status-waiting) 12%, transparent); }
.language-chip { margin-left: auto; }
.muted-chip { color: var(--faint); }
.situation-card { padding: 2px 2px 4px; background: transparent; border: 0; border-radius: 0; }
.situation-card > span { color: var(--ink); font-size: 13px; font-weight: 650; }
.suggestion-editable { width: 100%; min-height: 38px; padding: 8px 9px; overflow: hidden; color: var(--ink); resize: none; background: var(--field); border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 12px; line-height: 1.45; }
.suggestion-editable:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(25, 168, 123, .13); }
.suggestion-editable[readonly] { color: var(--muted); }
.strategy-actions { display: flex; justify-content: space-between; gap: 6px; }
.strategy-actions:not(:has(button:not([hidden]))) { display: none; }
.strategy-clear { margin-left: auto; padding: 5px 8px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: 10px; font-weight: 750; }
.strategy-clear:hover { color: var(--ink); background: var(--surface-hover); }
.strategy-regenerate, .strategy-remember { padding: 5px 8px; color: var(--accent); background: transparent; border: 1px solid rgba(25, 168, 123, .35); border-radius: 8px; font-size: 10px; font-weight: 750; line-height: 1.25; }
.strategy-regenerate:hover, .strategy-remember:hover { background: rgba(25, 168, 123, .1); }
.strategy-remember { color: var(--muted); border-color: var(--line); }
.strategy-remember.saved { color: var(--success); border-color: color-mix(in srgb, var(--success) 45%, transparent); cursor: default; opacity: 1; }
.suggestion-reply { display: grid; gap: 8px; padding-top: 2px; }
.send-all-button { width: 100%; padding: 10px 12px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 10px; font-size: 12px; font-weight: 800; }
.send-all-button:hover { background: var(--accent-dark); }
.suggested-message-list { display: grid; gap: 8px; }
.suggested-message { display: grid; gap: 7px; padding: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; transition: opacity .2s, border-color .2s; }
.suggested-message-head { display: flex; justify-content: space-between; gap: 8px; }
.suggested-message-number { color: var(--muted); font-size: 10px; font-weight: 700; }
.suggested-message-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.suggested-message-actions button { padding: 7px 8px; border-radius: 8px; font-size: 11px; font-weight: 800; }
.suggested-message-send { color: var(--on-accent); background: var(--accent); border: 1px solid var(--accent); }
.suggested-message-send:hover { background: var(--accent-dark); }
.suggested-message-delete { color: #f08d8d; background: transparent; border: 1px solid rgba(240, 141, 141, .42); }
.suggestion-meta { margin: 0; color: var(--faint); font-size: 10px; text-align: center; }
.suggestion-loading { display: grid; gap: 8px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.suggestion-loading span { color: var(--muted); font-size: 12px; }
.skeleton-line { display: block; height: 10px; background: linear-gradient(90deg, var(--surface-raised), var(--surface-hover), var(--surface-raised)); background-size: 200% 100%; border-radius: 6px; animation: skeleton 1.2s ease-in-out infinite; }
.skeleton-line:nth-of-type(2) { width: 85%; }
.skeleton-line:nth-of-type(3) { width: 60%; }
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton-line { animation: none; } }
/* One spinner for every place that waits for the server (the React app's Spinner looks the same). */
.spinner { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spinner-turn .7s linear infinite; }
@keyframes spinner-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.6s; } }
/* The messages of a chat being opened: a spinner in the middle of the empty timeline. */
.messages-loading { display: grid; min-height: 40vh; place-items: center; }
.messages-loading[hidden] { display: none; }
.suggestion-error { display: grid; gap: 6px; padding: 12px; background: color-mix(in srgb, var(--danger) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); border-radius: 12px; font-size: 12px; }
.suggestion-error strong { color: var(--danger); }
.suggestion-error span { color: var(--muted); overflow-wrap: anywhere; }
.suggestion-text { color: var(--ink); }
.lead-status-block label { color: var(--muted); font-size: 10px; font-weight: 700; }
.lead-status-block select { width: 100%; padding: 10px 32px 10px 11px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 700; }
.lead-status-block select:focus { outline: 2px solid rgba(25, 168, 123, .25); border-color: var(--accent); }
.lead-workflow-select { width: 100%; padding: 9px 30px 9px 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
/* ---------- lead panel ---------- */
.lead-panel { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.lead-status-block, .lead-tags-block, .lead-information { padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.lead-status-block { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.lead-status-block h2 { margin: 0 0 4px; font-size: 13px; font-weight: 750; }
.tag-field-label { margin-top: 6px; color: var(--muted); font-size: 11px; font-weight: 650; }
.lead-tags-block { position: relative; display: grid; gap: 8px; }
.lead-tags-block h3 { margin: 0; font-size: 13px; font-weight: 750; }
.lead-save-button { width: 100%; padding: 11px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 11px; box-shadow: 0 6px 18px rgba(25, 168, 123, .28); font-size: 13px; font-weight: 750; transition: background .16s ease, box-shadow .16s ease; }
.lead-save-button:disabled { box-shadow: none; }
.lead-save-button.has-changes { outline: 2px solid var(--accent); outline-offset: 2px; }
.lead-information h3 { margin: 0 0 13px; font-size: 13px; font-weight: 750; }
.lead-tags-menu { top: 44px; right: 14px; left: 14px; width: auto; max-height: min(230px, calc(100dvh - 300px)); }

/* ---------- custom selects ---------- */
.tag-select-trigger { display: flex; width: 100%; min-height: 42px; padding: 6px 10px 6px 7px; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); text-align: left; background: var(--field); border: 1px solid var(--line); border-radius: 11px; font-size: 13px; font-weight: 600; transition: border-color .16s ease, background .16s ease, box-shadow .16s ease; }
.tag-select-trigger:not(:disabled):hover { background: var(--surface-hover); border-color: var(--line-strong); }
.tag-select-trigger[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .16); }
.tag-select-trigger:disabled { cursor: default; opacity: .5; }
.tag-select-placeholder { padding-left: 5px; color: var(--faint); font-weight: 500; }
.tag-select-value, .tag-option-copy { display: flex; min-width: 0; align-items: center; gap: 9px; }
.select-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-chevron { display: grid; width: 22px; height: 22px; flex: 0 0 auto; place-items: center; color: var(--muted); transition: transform .18s ease, color .18s ease; }
.select-chevron svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tag-select-trigger[aria-expanded="true"] .select-chevron { color: var(--accent); transform: rotate(180deg); }
.select-icon { --icon: var(--muted); display: grid; width: 26px; height: 26px; flex: 0 0 auto; place-items: center; color: var(--icon); background: color-mix(in srgb, var(--icon) 16%, transparent); border: 1px solid color-mix(in srgb, var(--icon) 32%, transparent); border-radius: 8px; }
.select-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.select-icon-flow { --icon: var(--accent); }
.select-icon-avatar { font-size: 12px; font-weight: 800; line-height: 1; }
.select-icon[data-status="auto"] { --icon: var(--status-auto); }
.select-icon[data-status="manual"] { --icon: var(--status-manual); }
.select-icon[data-status="ignore"] { --icon: var(--status-ignore); }
.select-icon[data-status="waiting"] { --icon: var(--status-waiting); }
.select-icon[data-status="blocked"] { --icon: var(--status-blocked); }
.select-icon[data-status="stopped"] { --icon: var(--status-stopped); }
.select-icon[data-status="finished"] { --icon: var(--status-finished); }
/* Step categories: same colors as the flow canvas (--cat-* in workflows.css). */
.select-icon[data-category="trigger"] { --icon: #3b9eff; }
.select-icon[data-category="communication"] { --icon: #f0b429; }
.select-icon[data-category="ai"] { --icon: #e879f9; }
.select-icon[data-category="change"] { --icon: #3ecf8e; }
.select-icon[data-category="logic"] { --icon: #f0506e; }
.select-icon[data-category="integration"] { --icon: #a78bfa; }
.step-label-kind { color: var(--step-color, var(--muted)); font-size: 10.5px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.step-label-kind[data-category="trigger"] { --step-color: #3b9eff; }
.step-label-kind[data-category="communication"] { --step-color: #f0b429; }
.step-label-kind[data-category="ai"] { --step-color: #e879f9; }
.step-label-kind[data-category="change"] { --step-color: #3ecf8e; }
.step-label-kind[data-category="logic"] { --step-color: #f0506e; }
.step-label-kind[data-category="integration"] { --step-color: #a78bfa; }
.step-label-name::before { margin: 0 6px; color: var(--muted); font-weight: 900; content: "•"; }
.tag-options { position: absolute; z-index: 6; top: calc(100% + 6px); right: 0; left: 0; display: grid; max-height: 240px; padding: 5px; gap: 2px; overflow-y: auto; background: var(--surface-raised); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow); animation: select-pop .14s ease-out; }
@keyframes select-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.tag-option { display: flex; width: 100%; min-height: 36px; padding: 5px 8px 5px 9px; align-items: center; justify-content: space-between; gap: 9px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 8px; font-size: 13px; cursor: pointer; }
.tag-option:hover, .tag-option:focus-visible { outline: none; background: var(--surface-hover); }
.select-option { padding-left: 5px; justify-content: flex-start; }
.select-option .select-label { flex: 1; }
.select-option[aria-selected="true"] { background: rgba(25, 168, 123, .14); }
.select-option[aria-selected="true"]::after { width: 16px; height: 16px; flex: 0 0 auto; background: var(--accent); content: ""; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }

.chat-event { display: flex; max-width: 82%; margin: 6px auto; align-items: baseline; justify-content: center; gap: 6px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.35; opacity: .85; }
.chat-event time { flex: 0 0 auto; font-variant-numeric: tabular-nums; opacity: .7; }
.chat-event-tags { align-items: center; color: color-mix(in srgb, var(--muted) 85%, transparent); opacity: 1; }
.chat-event-tags time { opacity: .6; }
.chat-event-tags .chat-event-text { display: inline-flex; min-width: 0; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px; }
.chat-event-tags .tag-chip { padding: 2px 6px; font-size: 9px; }
.lead-save-button:hover { background: var(--accent-dark); }
.lead-tags, .lead-tag-items { display: flex; min-height: 24px; flex-wrap: wrap; align-items: center; gap: 6px; }
.tag-chip { display: inline-flex; max-width: 100%; padding: 4px 8px; align-items: center; gap: 4px; color: white !important; border-radius: 999px; font-size: 10px; font-weight: 800; line-height: 1.2; user-select: none; }
.tag-remove { display: grid; width: 0; height: 15px; padding: 0; overflow: hidden; place-items: center; color: white; background: rgba(0, 0, 0, .18); border: 0; border-radius: 50%; opacity: 0; transition: width .14s ease, opacity .14s ease; }
.tag-chip:hover .tag-remove, .tag-remove:focus-visible { width: 15px; opacity: 1; }
.tag-remove:hover { background: rgba(0, 0, 0, .32); }
.chat-inline-tags { flex: 1 1 auto; }
.tag-select { position: relative; min-width: 0; }
.tag-select-inline { display: inline-flex; }
.add-tag-chip { min-height: 24px; padding: 4px 9px; color: var(--ink) !important; background: var(--surface-raised); border: 1px dashed var(--line-strong); cursor: pointer; }
.add-tag-chip:hover, .add-tag-chip[aria-expanded="true"] { background: var(--accent-pale); border-color: var(--accent); }
.add-tag-chip:disabled { cursor: default; }
.tag-color-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, .1); }
.tag-option-create { color: var(--accent); font-weight: 800; }
.tag-option-remove { display: grid; width: 24px; height: 24px; flex: 0 0 auto; padding: 0; place-items: center; color: var(--muted); background: transparent; border: 0; border-radius: 50%; font-size: 16px; }
.tag-option-remove:hover { color: white; background: rgba(198, 111, 115, .55); }
.tag-create-form { display: grid; gap: 9px; padding: 10px; background: rgba(0, 0, 0, .08); border: 1px solid var(--line); border-radius: 11px; }
.tag-create-form input[type="text"] { width: 100%; padding: 9px 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.tag-palette { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-color-swatch { width: 25px; height: 25px; padding: 0; border: 2px solid transparent; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14); }
.tag-color-swatch:hover { transform: scale(1.08); }
.tag-color-swatch.selected { border-color: white; box-shadow: 0 0 0 2px var(--surface-raised); }
.tag-create-form > button { padding: 9px 11px; color: var(--on-accent); background: var(--accent); border: 0; border-radius: 9px; font-size: 11px; font-weight: 800; }
.lead-details-save { margin-top: 0; }
.lead-information dl { display: grid; gap: 10px; margin: 0; }
.lead-information dl > div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.lead-information dt { color: var(--muted); font-size: 11px; }
.lead-information dd { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 11px; font-weight: 700; }
.lead-custom-data textarea { display: block; width: 100%; min-height: 84px; padding: 9px 10px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 12px; line-height: 1.4; resize: vertical; }
.lead-custom-data textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .16); }
.lead-custom-data textarea:disabled { opacity: .5; }
.lead-memory-field { display: grid; gap: 5px; margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.lead-memory input { display: block; width: 100%; padding: 8px 10px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 12px; }
.lead-memory input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .16); }
.lead-memory input:disabled { opacity: .5; }
.lead-memory textarea { min-height: 52px; }
.lead-memory-follow-up { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; color: #c9c1ff; background: rgba(139, 124, 246, .12); border: 1px dashed rgba(139, 124, 246, .55); border-radius: 9px; font-size: 12px; }
.lead-memory-follow-up[hidden] { display: none; }
.lead-memory-clear { width: 22px; height: 22px; padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 50%; font-size: 15px; line-height: 1; }
.lead-memory-clear:hover { color: var(--ink); background: var(--surface-hover); }
.lead-memory-hint { margin: 9px 0 0; color: var(--faint, var(--muted)); font-size: 11px; line-height: 1.35; }
.draft-area { width: 100%; }
.message-composer { display: flex; gap: 2px; align-items: flex-end; padding: 3px 8px; }
.draft-input-wrap { position: relative; display: flex; min-width: 0; flex: 1; }
.message-composer textarea, .draft-mirror { padding: 10px 6px 9px; font-size: 14px; line-height: 1.4; letter-spacing: normal; overflow-wrap: break-word; }
.message-composer textarea { position: relative; z-index: 1; width: 100%; min-width: 0; min-height: 40px; max-height: 128px; color: transparent; caret-color: var(--ink); resize: none; overflow-y: auto; scrollbar-width: none; outline: none; background: transparent; border: 0; }
.message-composer textarea::-webkit-scrollbar { display: none; }
.message-composer textarea::selection { color: transparent; }
.draft-mirror { position: absolute; inset: 0; overflow: hidden; color: var(--ink); white-space: pre-wrap; pointer-events: none; }
.apple-emoji.ready { color: transparent; -webkit-text-fill-color: transparent; background: var(--apple-emoji) center / 1.2em 1.2em no-repeat; }
.apple-emoji.ready::selection { color: transparent; -webkit-text-fill-color: transparent; }
.message-composer textarea::placeholder { color: var(--faint); }
.composer-icon { display: grid; width: 40px; height: 40px; flex: 0 0 auto; padding: 0; place-items: center; align-self: flex-end; color: var(--muted); background: transparent; border: 0; border-radius: 50%; transition: color .16s ease, background .16s ease; }
.composer-icon svg { display: block; width: 24px; height: 24px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-icon .emoji-eye { fill: currentColor; stroke: none; }
.composer-icon:hover { color: var(--ink); }
.composer-icon[aria-expanded="true"] { color: var(--accent); }
.composer-icon:focus-visible, .send-button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.send-button { position: relative; display: grid; width: 40px; height: 40px; padding: 0; flex: 0 0 auto; place-items: center; align-self: flex-end; color: var(--accent); background: transparent; border-radius: 50%; transition: background .16s ease; animation: send-pop .16s ease-out; }
@keyframes send-pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: scale(1); } }
.send-button svg { display: block; width: 22px; height: 22px; fill: currentColor; transform: translateX(1px); transition: transform .16s ease; }
.send-button:hover { color: var(--accent); background: transparent; }
.send-button:hover svg { transform: translateX(2px) scale(1.04); }
.send-button.loading svg { visibility: hidden; }
.send-button.loading::after { position: absolute; width: 16px; height: 16px; border: 2px solid rgba(25, 168, 123, .3); border-top-color: var(--accent); border-radius: 50%; content: ""; animation: translation-spin .65s linear infinite; }
.send-button:disabled { cursor: default; color: var(--accent); background: transparent; opacity: .6; }
.attach-menu-wrap { position: relative; flex: 0 0 auto; align-self: flex-end; }
.attach-menu { position: absolute; bottom: calc(100% + 10px); left: 0; z-index: 3; min-width: 220px; padding: 6px; background: var(--surface-raised); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.attach-menu-item { display: flex; width: 100%; gap: 12px; align-items: center; padding: 9px 12px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 8px; font-size: 13px; white-space: nowrap; }
.attach-menu-item svg { width: 20px; height: 20px; flex: 0 0 auto; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.attach-menu-item:hover, .attach-menu-item:focus-visible { outline: none; background: var(--surface-hover); }
.emoji-panel { user-select: none; -webkit-user-select: none; }
.emoji-section + .emoji-section { margin-top: 10px; }
.emoji-section-title { position: sticky; top: 0; z-index: 1; margin: 0; padding: 6px 4px; color: var(--muted); background: var(--panel); font-size: 12px; font-weight: 700; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; }
.emoji-option { display: grid; padding: 5px 3px; place-items: center; background: transparent; border: 0; border-radius: 8px; }
.emoji-option img { display: block; width: 28px; height: 28px; object-fit: contain; }
.emoji-option:hover, .emoji-option:focus-visible { outline: none; background: var(--surface-hover); }

/* ---------- saved messages ---------- */
.saved-panel { display: grid; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.saved-panel [hidden] { display: none !important; }
.saved-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.saved-head h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.saved-icon-button { display: grid; width: 32px; height: 32px; padding: 0; place-items: center; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.saved-icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.saved-icon-button:hover { color: var(--ink); background: var(--surface-hover); }
.saved-folders { display: flex; gap: 6px; margin: 0 -16px; padding: 2px 16px 6px; overflow-x: auto; scrollbar-width: thin; scroll-snap-type: x proximity; }
.saved-folder { display: inline-flex; flex: 0 0 auto; max-width: 180px; align-items: center; gap: 6px; padding: 6px 10px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 700; scroll-snap-align: start; }
.saved-folder span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-folder small { color: var(--faint); font-size: 11px; font-weight: 700; }
.saved-folder:hover { color: var(--ink); border-color: var(--line-strong); }
.saved-folder.active { color: var(--ink); background: var(--accent-pale); border-color: var(--accent); }
.saved-folder.active small { color: var(--accent); }
.saved-folder:focus-visible, .saved-panel button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.saved-folder-form { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.saved-folder-form .saved-danger { grid-column: 1 / -1; justify-self: start; }
.saved-panel input, .saved-panel select, .saved-panel textarea { width: 100%; min-width: 0; padding: 8px 10px; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 9px; font: inherit; font-size: 13px; }
.saved-panel textarea { min-height: 84px; resize: vertical; line-height: 1.4; }
.saved-panel input:focus, .saved-panel select:focus, .saved-panel textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(25, 168, 123, .16); }
.saved-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.saved-search { position: relative; display: block; }
.saved-search span { position: absolute; top: 50%; left: 10px; color: var(--faint); transform: translateY(-50%); pointer-events: none; }
.saved-search input { padding-left: 28px; }
.saved-primary, .saved-ghost, .saved-danger, .saved-send { padding: 7px 11px; border-radius: 9px; font-size: 12px; font-weight: 750; white-space: nowrap; }
.saved-primary { color: var(--on-accent); background: var(--accent); border: 1px solid var(--accent); }
.saved-primary:hover:not(:disabled) { background: var(--accent-dark); }
.saved-ghost { color: var(--muted); background: transparent; border: 1px solid var(--line); }
.saved-ghost:hover:not(:disabled) { color: var(--ink); background: var(--surface-hover); }
.saved-danger { color: var(--danger); background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.saved-danger:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.saved-send { color: var(--accent); background: transparent; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.saved-send:hover:not(:disabled) { color: var(--on-accent); background: var(--accent); }
.saved-panel button:disabled { cursor: not-allowed; opacity: .5; }
.saved-list { display: grid; gap: 8px; }
.saved-empty { margin: 6px 0; padding: 18px 12px; color: var(--faint); text-align: center; border: 1px dashed var(--line); border-radius: 12px; font-size: 12px; line-height: 1.45; }
.saved-card { display: grid; gap: 6px; padding: 10px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.saved-card:hover { border-color: var(--line-strong); }
.saved-card { position: relative; transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s ease, border-color .2s ease; }
.saved-card.draggable { cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.saved-list.sorting, .saved-list.sorting .saved-card { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.saved-card.lifted { z-index: 5; border-color: var(--accent); box-shadow: 0 18px 40px rgba(0, 0, 0, .45); transition: box-shadow .2s ease, border-color .2s ease; }
.saved-card.settling { z-index: 5; }
.saved-list.sorting .saved-card:not(.lifted) { opacity: .85; }
@media (prefers-reduced-motion: reduce) { .saved-card { transition: none; } }
.saved-panel .saved-handle { display: grid; width: 20px; height: 24px; flex: 0 0 auto; margin-left: -4px; padding: 0; place-items: center; color: var(--faint); background: transparent; border: 0; border-radius: 6px; cursor: grab; touch-action: none; }
.saved-panel .saved-handle:hover { color: var(--ink); background: var(--surface-hover); }
.saved-panel .saved-handle:active { cursor: grabbing; }
.saved-handle svg { width: 16px; height: 16px; fill: currentColor; }
.saved-order { min-width: 18px; padding: 1px 5px; color: var(--muted); background: var(--surface-raised); border-radius: 6px; font-size: 11px; font-weight: 750; text-align: center; }
.saved-add { width: 100%; padding: 10px; color: var(--muted); background: transparent; border: 1px dashed var(--line-strong); border-radius: 12px; font-size: 12px; font-weight: 750; }
.saved-add:hover { color: var(--accent); border-color: var(--accent); }
.saved-primary.stop { color: var(--danger); background: transparent; border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.saved-primary.stop:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 12%, transparent); }
.saved-card-head { display: flex; min-width: 0; align-items: center; gap: 6px; }
.saved-edit { display: grid; width: 26px; height: 26px; margin-left: auto; padding: 0; place-items: center; color: var(--faint); background: transparent; border: 0; border-radius: 7px; }
.saved-edit svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.saved-edit:hover { color: var(--ink); background: var(--surface-hover); }
.saved-description { margin: 0; color: var(--faint); font-size: 11px; line-height: 1.35; opacity: .8; }
.saved-text { display: -webkit-box; margin: 0; overflow: hidden; color: var(--ink); font-size: 13px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }
.saved-text img { width: 1.15em; height: 1.15em; vertical-align: -.2em; }
.saved-media { overflow: hidden; background: var(--field); border-radius: 9px; }
.saved-media img, .saved-media video { display: block; width: 100%; max-height: 180px; object-fit: cover; }
.saved-media video { object-fit: contain; background: #000; }
.saved-media.audio { padding: 4px; }
.saved-media audio { display: block; width: 100%; height: 34px; }
.saved-album { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; overflow: hidden; border-radius: 9px; }
.saved-album.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.saved-album-tile { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--field); }
.saved-album-tile img, .saved-album-tile video { display: block; width: 100%; height: 100%; object-fit: cover; }
.saved-album-video { position: absolute; top: 50%; left: 50%; display: grid; width: 26px; height: 26px; place-items: center; color: #fff; background: rgba(0, 0, 0, .55); border-radius: 50%; font-size: 10px; transform: translate(-50%, -50%); pointer-events: none; }
.saved-panel .saved-album-remove { position: absolute; top: 4px; right: 4px; display: grid; width: 22px; height: 22px; padding: 0; place-items: center; color: #fff; background: rgba(0, 0, 0, .6); border: 0; border-radius: 50%; font-size: 15px; line-height: 1; }
.saved-panel .saved-album-remove:hover { background: #9b4141; }
.saved-file-hint { color: var(--faint); font-size: 11px; }
.saved-card-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 2px; }
.saved-editor { display: grid; gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.saved-editor-title { margin: 0; font-size: 13px; font-weight: 750; }
.saved-field { display: grid; gap: 5px; }
.saved-field > span { color: var(--muted); font-size: 11px; font-weight: 650; }
.saved-field small { color: var(--faint); font-weight: 500; }
.saved-file { display: grid; gap: 6px; }
.saved-file-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.saved-editor-actions { display: flex; gap: 6px; }
.saved-editor-actions .saved-danger { margin-left: auto; }

.confirm-backdrop { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: rgba(8, 10, 12, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity .16s ease; }
.confirm-backdrop.visible { opacity: 1; }
.confirm-card { width: min(360px, 100%); padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); text-align: center; transform: scale(.96); transition: transform .16s ease; }
.confirm-backdrop.visible .confirm-card { transform: none; }
.confirm-title { margin: 0; color: var(--ink); font-size: 15px; font-weight: 650; line-height: 1.35; }
.confirm-text { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.confirm-actions button { height: 36px; padding: 0 14px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.confirm-cancel { color: var(--ink); background: transparent; border: 1px solid var(--line); }
.confirm-cancel:hover { background: var(--surface-hover); }
.confirm-action { color: var(--on-accent); background: var(--accent); border: 0; }
.confirm-action:hover { background: var(--accent-dark); }
.confirm-action.danger { background: #e5676b; }
.confirm-action.danger:hover { background: #d0555a; }
.toast { position: fixed; right: 28px; bottom: 28px; z-index: 5; padding: 11px 15px; color: var(--ink); background: var(--surface-raised); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; font-size: 12px; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #9b4141; }

@media (max-width: 760px) {
  /* Every page on a phone, after the Telegram app: the brand, the bell and the account at the
     top, the section tabs as a bottom bar. Only the page's own content scrolls. */
  .app { padding: 0 0 calc(60px + env(safe-area-inset-bottom)); grid-template-rows: auto minmax(0, 1fr); }
  .bot-identity-copy, .bot-status-pill { display: none; }
  /* iOS zooms into any field with smaller text. */
  .app input:not([type="checkbox"]):not([type="radio"]), .app textarea, .app select { font-size: 16px; }
  .app-topbar { min-height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0 16px; grid-template-columns: minmax(0, 1fr) auto; background: var(--panel); border-bottom: 0; }
  .app-brand-name { display: block; font-size: 18px; font-weight: 800; }
  /* Section tabs: a bottom bar that scrolls sideways when they do not fit. */
  .app-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 40; display: flex; height: calc(60px + env(safe-area-inset-bottom)); padding: 5px 4px env(safe-area-inset-bottom); gap: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; background: rgba(28, 31, 34, .96); border: 0; border-top: 1px solid var(--line); border-radius: 0; backdrop-filter: blur(16px); }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-nav-pill { display: none; }
  .app-nav-item { height: 50px; min-width: 60px; flex: 1 0 auto; margin: 0; padding: 0 4px; flex-direction: column; justify-content: center; gap: 4px; font-size: 10.5px; border-radius: 10px; -webkit-tap-highlight-color: transparent; }
  .app-nav-item::before { width: 24px; height: 24px; background: currentColor; content: ""; -webkit-mask: var(--nav-icon) center / contain no-repeat; mask: var(--nav-icon) center / contain no-repeat; }
  .app-nav-item:hover { background: transparent; }
  .app-nav-item.active { color: var(--accent); background: transparent; box-shadow: none; }
  .app-nav-item[href="/"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8.5 8.5 0 0 1-12.4 7.55L4 20.5l.95-4.35A8.5 8.5 0 1 1 21 12Z'/%3E%3C/svg%3E"); }
  .app-nav-item[href="/workflows"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='6' cy='6' r='2.5'/%3E%3Ccircle cx='18' cy='6' r='2.5'/%3E%3Ccircle cx='18' cy='18' r='2.5'/%3E%3Cpath d='M8.5 6h7M6 8.5V13a5 5 0 0 0 5 5h4.5'/%3E%3C/svg%3E"); }
  .app-nav-item[href="/copilot"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 3.5 12.9 9l5.6 2-5.6 2L11 18.5 9.1 13l-5.6-2 5.6-2L11 3.5Z'/%3E%3Cpath d='M18.5 15.5v5M16 18h5'/%3E%3C/svg%3E"); }
  .app-nav-item[href="/mailings"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 10v4a1 1 0 0 0 1 1h2l6 4V5L7 9H5a1 1 0 0 0-1 1Z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E"); }
  .app-nav-item[href="/analytics"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 20h15M7 16.5V11M12 16.5V5.5M17 16.5v-4'/%3E%3C/svg%3E"); }
  .app-nav-item[href="/team"] { --nav-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='9' cy='8' r='3.25'/%3E%3Cpath d='M3.5 19.5a5.5 5.5 0 0 1 11 0M15.5 4.9a3.25 3.25 0 0 1 0 6.2M17.5 14.3a5.5 5.5 0 0 1 3 5.2'/%3E%3C/svg%3E"); }
  .toast { top: calc(12px + env(safe-area-inset-top)); right: 12px; bottom: auto; left: 12px; text-align: center; transform: translateY(-8px); }
  /* An opened item (phoneDetailView in common.js) takes the whole screen, like an open chat. */
  .app.phone-detail { grid-template-rows: minmax(0, 1fr); padding-bottom: 0; }
  .app.phone-detail .app-topbar { display: none; }
  .phone-back { display: grid; width: 40px; height: 40px; flex: 0 0 auto; padding: 0; place-items: center; color: var(--accent); background: transparent; border: 0; border-radius: 10px; -webkit-tap-highlight-color: transparent; }
  .phone-back::before { width: 26px; height: 26px; background: currentColor; content: ""; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m14.5 5.5-6.5 6.5 6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m14.5 5.5-6.5 6.5 6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat; }
  .phone-back:active { background: var(--surface-hover); }
}
@media (min-width: 761px) { .phone-back { display: none; } }

/* ---------- messenger on a phone (inbox/mobile.js), after the Telegram app ----------
   The chat list with folder tabs and the section tabs at the bottom; an open chat takes the
   whole screen; the side panel opens under the composer like a keyboard. */
#emojiButton .composer-icon-sticker, #emojiButton .composer-icon-keyboard { display: none; }
.panel-focus-bar { display: none; }

@media (max-width: 760px) {
  /* The page never scrolls or bounces as a whole; only its lists do. mobile.js fits it to the
     part of the screen above the keyboard and follows Safari's pan (--app-height, --app-offset);
     its fixed children (the panel, the bottom tabs, sheets) are placed against it. */
  html:has(.inbox-app), html:has(.inbox-app) body { height: 100%; overflow: hidden; overscroll-behavior: none; }
  .inbox-app { position: fixed; top: 0; right: 0; left: 0; height: var(--app-height, 100dvh); overflow: visible; transform: translateY(var(--app-offset, 0px)); }
  .inbox-app.keyboard-open { padding-bottom: 0; }
  .inbox-app.keyboard-open .app-nav { display: none; }
  /* Safari pans the page to a field it focuses, animating that pan after it already reported
     where the page ends up; the page fits the space above the keyboard anyway. A field that is
     invisible at the moment it gets focus is not panned to. */
  .inbox-app input:focus, .inbox-app textarea:focus { animation: no-focus-pan .01s; }
  /* Messages sliding along with the keyboard pass under the header, not over it. */
  .inbox-app .chat-header { position: relative; z-index: 3; }
  .inbox-app:has(.shell.chat-open) { grid-template-rows: minmax(0, 1fr); padding-bottom: 0; }
  .inbox-app:has(.shell.chat-open) .app-topbar { display: none; }
  /* iOS zooms into any field with smaller text. */
  .inbox-app input, .inbox-app textarea, .inbox-app select, .inbox-app .draft-mirror { font-size: 16px; }

  /* Chat list: search, then the folder tabs, then the chats; only the chats scroll. */
  .inbox-app .shell { display: flex; flex-direction: column; border: 0; border-radius: 0; box-shadow: none; }
  .inbox-app .sidebar { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; border-right: 0; }
  .inbox-app .shell.chat-open .sidebar { display: none; }
  .inbox-app .chat-browser { display: contents; }
  .inbox-app .chat-browser-head { order: 1; margin: 0 12px 4px; }
  .inbox-app .search-box { height: 40px; border-radius: 12px; }
  .inbox-app .select-chats-button { width: 40px; height: 40px; border-radius: 12px; }
  .inbox-app .folder-panel { position: relative; order: 2; display: flex; width: auto; height: auto; flex: 0 0 auto; padding: 0 6px; gap: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scrollbar-width: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .inbox-app .folder-panel::-webkit-scrollbar { display: none; }
  .inbox-app .folder-heading, .inbox-app .folder-section, .inbox-app .folder-icon { display: none; }
  .inbox-app .folder-item { display: inline-flex; width: auto; min-height: 44px; flex: 0 0 auto; margin: 0; padding: 0 12px; gap: 6px; background: transparent; border-radius: 0; font-size: 14px; font-weight: 650; -webkit-tap-highlight-color: transparent; }
  .inbox-app .folder-item:hover, .inbox-app .folder-item.active { background: transparent; }
  .inbox-app .folder-item.active::before { top: auto; right: 8px; bottom: 0; left: 8px; width: auto; height: 3px; border-radius: 3px 3px 0 0; }
  .inbox-app .folder-label { width: auto; opacity: 1; transform: none; }
  .inbox-app .folder-count { position: static; min-width: 20px; padding: 2px 6px; box-shadow: none; font-size: 11px; line-height: 14px; }
  .inbox-app .chat-list { order: 3; flex: 1 1 auto; overscroll-behavior-y: contain; touch-action: pan-y pinch-zoom; }
  .inbox-app .bulk-bar { order: 4; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .inbox-app .bulk-field select, .inbox-app .bulk-apply { height: 44px; border-radius: 12px; }
  .inbox-app .bulk-field select, .inbox-app .bulk-apply { font-size: 15px; }
  .inbox-app .chat-item { position: relative; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; padding: 8px 14px 8px 12px; border-bottom: 0; -webkit-tap-highlight-color: transparent; contain-intrinsic-size: auto 70px; }
  .inbox-app .chat-item::after { position: absolute; right: 0; bottom: 0; left: 78px; height: 1px; background: var(--line); content: ""; }
  .inbox-app .chat-item.selectable { padding-left: 48px; }
  .inbox-app .chat-item.selectable::after { left: 114px; }
  .inbox-app .chat-check { left: 14px; width: 22px; height: 22px; }
  .inbox-app .chat-check::after { inset: 4px 7px 8px; }
  .inbox-app .chat-item:not(.picked):not([data-folder="stopped"]):hover { background: transparent; }
  .inbox-app .chat-item:active { background: var(--surface-hover); }
  .inbox-app .chat-item .avatar { width: 54px; height: 54px; font-size: 18px; }
  .inbox-app .chat-copy strong { margin: 5px 0 4px; font-size: 16px; font-weight: 650; }
  .inbox-app .chat-preview { font-size: 14.5px; }
  .inbox-app .chat-meta { padding-top: 5px; gap: 8px; font-size: 12.5px; }
  .inbox-app .unread { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; font-size: 12px; }

  /* An open chat takes the whole screen. */
  .inbox-app .conversation { display: none; flex: 1 1 auto; min-height: 0; flex-direction: column; }
  /* Room for the keyboard or the panel under the composer (mobile.js measures it). */
  .inbox-app .shell.chat-open .conversation { display: flex; padding-bottom: var(--composer-lift, 0px); }
  .inbox-app .chat-view { flex: 1 1 auto; height: auto; min-height: 0; }
  .inbox-app .chat-header { min-height: calc(56px + env(safe-area-inset-top)); padding: calc(6px + env(safe-area-inset-top)) 10px 6px 2px; gap: 8px; }
  .inbox-app .back-button { display: grid; width: 40px; height: 40px; flex: 0 0 auto; color: var(--accent); background: transparent; font-size: 0; }
  .inbox-app .back-button::before { width: 26px; height: 26px; background: currentColor; content: ""; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m14.5 5.5-6.5 6.5 6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m14.5 5.5-6.5 6.5 6.5 6.5'/%3E%3C/svg%3E") center / contain no-repeat; }
  .inbox-app .chat-title-wrap strong { font-size: 16px; }
  .inbox-app .chat-title-wrap span { font-size: 12.5px; }
  .inbox-app .chat-header .copilot-toggle-slot { display: none; }
  .inbox-app .language-trigger { height: 36px; padding: 0 8px; }
  .inbox-app .language-trigger .select-chevron { display: none; }
  .inbox-app .message-area { padding: 10px 10px 12px; overscroll-behavior-y: contain; }
  .inbox-app .message-row { max-width: 88%; gap: 4px; }
  .inbox-app .message-row.voice-row { width: min(380px, 88%); }
  .inbox-app .message { padding: 7px 10px 6px; border-radius: 8px 18px 18px 18px; font-size: 15.5px; line-height: 1.38; }
  .inbox-app .message.outgoing { border-radius: 18px 8px 18px 18px; }
  .inbox-app .message-time { font-size: 11px; }
  .inbox-app .message-ticks svg { width: 18px; height: 12px; }
  /* Tapping a message opens its actions as a sheet at the bottom; the message stays lit. */
  .inbox-app .message-actions { display: contents; }
  .inbox-app .message-more { display: none; }
  .inbox-app .message-menu { position: fixed; top: auto; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); left: 10px; z-index: 50; min-width: 0; padding: 6px; border-radius: 16px; transform: none; box-shadow: 0 0 0 100vmax rgba(8, 10, 12, .55), var(--shadow); animation: sheet-rise .18s ease-out; }
  .inbox-app .message-menu button { padding: 14px 16px; text-align: center; border-radius: 10px; font-size: 16px; }
  .inbox-app .message-row:has(.message-menu:not([hidden])) .message { position: relative; z-index: 51; }

  /* Telegram's composer: clip, the field, the sticker button (a keyboard button while the
     panel is up), then send. */
  .inbox-app .composer { padding-bottom: env(safe-area-inset-bottom); }
  .inbox-app .shell.composer-lifted .composer { padding-bottom: 0; }
  .inbox-app .composer-reply { margin-left: 12px; }
  .inbox-app .message-composer { gap: 0; padding: 4px; }
  .inbox-app .draft-input-wrap { order: 1; }
  .inbox-app #emojiButton { order: 2; }
  .inbox-app .send-button { order: 3; }
  .inbox-app #emojiButton .composer-icon-emoji { display: none; }
  .inbox-app #emojiButton[aria-expanded="false"] .composer-icon-sticker,
  .inbox-app #emojiButton[aria-expanded="true"] .composer-icon-keyboard { display: block; }
  .inbox-app #emojiButton[aria-expanded="true"] { color: var(--muted); }

  /* The side panel stands where the keyboard stands, as tall as it, so switching between them
     leaves the composer in place. Its tabs float over the content at the bottom. */
  .inbox-app .copilot-sidebar { display: none; }
  .inbox-app .shell.chat-open.copilot-open .copilot-sidebar { position: fixed; right: 0; bottom: var(--panel-bottom, 0px); left: 0; z-index: 20; display: block; width: auto; height: var(--panel-height, 42dvh); min-height: 0; padding: 12px 16px 0; overflow-y: auto; overscroll-behavior: none; touch-action: pan-y pinch-zoom; border-top: 1px solid var(--line); border-left: 0; opacity: 1; transform: none; pointer-events: auto; transition: none; }
  .inbox-app .copilot-content { display: flex; min-height: 100%; flex-direction: column; padding-top: 0; }
  .inbox-app .copilot-head { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 4; order: 99; align-self: center; margin: auto 0 calc(10px + env(safe-area-inset-bottom)); padding-top: 14px; pointer-events: none; }
  .inbox-app .copilot-panel-toggle-slot { display: none; }
  /* Typing in one of the panel's fields: the panel covers the chat above the keyboard, keeps only
     that field's block (larger) and puts its name and "Готово" on top; the tabs are hidden. */
  .inbox-app .shell.panel-editing .copilot-head { display: none; }
  .inbox-app .shell.chat-open.copilot-open.panel-editing .copilot-sidebar { padding-top: 0; border-top: 0; }
  .inbox-app .shell.panel-editing .panel-focus-bar { position: sticky; top: 0; z-index: 5; display: flex; min-height: calc(52px + env(safe-area-inset-top)); margin: 0 -16px 14px; padding: env(safe-area-inset-top) 6px 0 16px; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
  .inbox-app .panel-focus-bar strong { min-width: 0; overflow: hidden; font-size: 16px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
  .inbox-app .panel-focus-done { flex: 0 0 auto; padding: 8px 10px; color: var(--accent); background: transparent; border: 0; border-radius: 10px; font-size: 16px; font-weight: 700; -webkit-tap-highlight-color: transparent; }
  .inbox-app .panel-focus-done:active { background: var(--surface-hover); }
  .inbox-app .panel-focus-hidden { display: none !important; }
  .inbox-app .shell.panel-editing .panel-focus-block textarea { min-height: calc(var(--app-height, 60dvh) * 0.4); }
  .inbox-app .copilot-tabs { position: relative; display: grid; grid-template-columns: repeat(4, 54px); gap: 0; padding: 4px; pointer-events: auto; background: rgba(61, 67, 71, .62); border: 1px solid rgba(255, 255, 255, .09); border-radius: 999px; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); }
  /* The slider under the active tab. */
  .inbox-app .copilot-tabs::before { position: absolute; top: 4px; bottom: 4px; left: 4px; width: 54px; background: linear-gradient(135deg, var(--accent), #4f9de5); border-radius: 999px; content: ""; transform: translateX(calc(var(--active-tab, 0) * 100%)); transition: transform .24s cubic-bezier(.2, .8, .2, 1); }
  .inbox-app .copilot-tab { position: relative; z-index: 1; width: auto; height: 36px; border-radius: 999px; -webkit-tap-highlight-color: transparent; }
  .inbox-app .copilot-tab:hover, .inbox-app .copilot-tab.active { background: transparent; }
  .inbox-app .copilot-tab.active { color: var(--on-accent); }
  .inbox-app .emoji-section-title { position: static; }
  .inbox-app .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .inbox-app .emoji-option img { width: 32px; height: 32px; }
  .inbox-app .tag-remove { width: 15px; opacity: 1; }
}

@keyframes sheet-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes no-focus-pan { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .shell, .folder-panel, .chat-browser, .folder-heading-copy, .folder-label, .folder-count { transition: none; }
  .inbox-app .message-menu { animation: none !important; }
  .inbox-app .copilot-tabs::before { transition: none; }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .copilot-sidebar { position: absolute; inset: 0 0 0 auto; z-index: 4; width: 350px; box-shadow: -14px 0 36px rgba(12, 14, 16, .28); }
  .shell, .shell.copilot-open { grid-template-columns: 476px minmax(0, 1fr); }
  .shell.folders-collapsed, .shell.folders-collapsed.copilot-open { grid-template-columns: 358px minmax(0, 1fr); }
}

.avatar-viewer { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: rgba(8, 10, 12, .82); opacity: 0; transition: opacity .2s ease; }
.avatar-viewer.open { opacity: 1; }
.avatar-viewer-image { width: min(640px, 86vw, 86vh); aspect-ratio: 1; object-fit: cover; border-radius: 14px; box-shadow: 0 24px 70px rgba(0, 0, 0, .5); }
#headerAvatar:has(.avatar-image.loaded), .message-image, .message-album-tile img { cursor: pointer; }
.photo-viewer { padding: 24px 76px; }
.photo-viewer-image { position: relative; z-index: 1; max-width: 100%; max-height: calc(100vh - 96px); object-fit: contain; border-radius: 10px; box-shadow: 0 24px 70px rgba(0, 0, 0, .5); }
.photo-viewer-video { width: min(960px, 100%); background: #000; }
.photo-viewer-image[hidden] { display: none; }
.photo-viewer-counter { position: fixed; top: 18px; left: 50%; z-index: 2; padding: 4px 12px; color: #fff; background: rgba(0, 0, 0, .45); border-radius: 999px; font-size: 13px; font-weight: 600; transform: translateX(-50%); }
.photo-viewer-close { position: fixed; top: 12px; right: 14px; z-index: 2; display: grid; width: 40px; height: 40px; padding: 0; place-items: center; color: #fff; background: rgba(255, 255, 255, .1); border: 0; border-radius: 50%; font-size: 26px; line-height: 1; cursor: pointer; }
.photo-viewer-close:hover { background: rgba(255, 255, 255, .22); }
.photo-viewer-arrow { position: fixed; top: 0; bottom: 0; display: flex; width: 25vw; padding: 0 16px; align-items: center; color: #fff; background: transparent; border: 0; cursor: pointer; }
.photo-viewer-arrow.prev { left: 0; justify-content: flex-start; }
.photo-viewer-arrow.next { right: 0; justify-content: flex-end; }
.photo-viewer-arrow-icon { display: grid; width: 48px; height: 48px; place-items: center; background: rgba(255, 255, 255, .1); border-radius: 50%; transition: background .15s ease; }
.photo-viewer-arrow:hover .photo-viewer-arrow-icon { background: rgba(255, 255, 255, .24); }
.photo-viewer-arrow:focus-visible { outline: none; }
.photo-viewer-arrow:focus-visible .photo-viewer-arrow-icon, .photo-viewer-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.photo-viewer-arrow svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.photo-viewer-arrow[hidden], .photo-viewer-counter[hidden] { display: none; }
@media (max-width: 760px) {
  .photo-viewer { padding: 56px 8px; }
  .photo-viewer-arrow { width: 30vw; padding: 0 6px; }
  .photo-viewer-arrow-icon { width: 40px; height: 40px; background: rgba(0, 0, 0, .45); }
}
@media (prefers-reduced-motion: reduce) { .avatar-viewer { transition: none; } }

/* "Typing…": ours as a bubble where our next message will appear, the lead's in the chat list. */
.message-composer { position: relative; }
/* "печатает" of a flow or Copilot: grey text over the right end of the input row, beside the
   emoji button. It is out of the flow, so showing or hiding it moves nothing. */
.composer-typing { position: absolute; right: 52px; bottom: 13px; z-index: 2; display: inline-flex; align-items: center; gap: 6px; padding: 1px 0 1px 18px; color: var(--faint); font-size: 12px; background: linear-gradient(90deg, transparent, var(--surface) 18px); pointer-events: none; }
.composer-typing[hidden] { display: none; }
.message-composer:has(.send-button:not([hidden])) .composer-typing { right: 92px; }
.typing-label { display: inline-flex; align-items: center; gap: 6px; }
.chat-preview.typing { color: var(--accent); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; background: currentColor; border-radius: 50%; animation: typing-dot 1.2s ease-in-out infinite; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-dot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .typing-dots i { animation: none; } }
