/* ==========================================================================
   cns.im — Design system
   One hand-written stylesheet. No Tailwind, no Bootstrap.
   Tokens → base → primitives → app shell → features → responsive.
   Theme: html[data-theme="light" | "dark"], set before paint by the inline
   script in App.razor / index.html (window.msngTheme).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  /* Type */
  --font-sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --fs-2xs: 10.5px;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-md: 13.5px;
  --fs-base: 14px;
  --fs-lg: 15px;
  --fs-xl: 17px;
  --fs-2xl: 20px;
  --fs-3xl: 26px;
  --lh-tight: 1.25;
  --lh: 1.45;
  --lh-loose: 1.6;

  /* Space (4px grid) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* Radii */
  --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 12px;
  --r-xl: 16px; --r-2xl: 20px; --r-full: 999px;

  /* Motion */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-spring: cubic-bezier(.34, 1.4, .64, 1);
  --t-fast: 120ms;
  --t-base: 180ms;
  --t-slow: 280ms;

  /* Layout */
  --rail-w: 64px;
  --list-w: 368px;
  --dock-h: 280px;

  /* Platforms (brand colours — identical in both themes) */
  --p-email: #64748B;
  --p-telegram: #2AABEE;
  --p-whatsapp: #25D366;
  --p-teams: #5B5FC7;
  --p-teamspersonal: #7B83EB; /* lighter than work Teams: the two tiles must be told apart */
  --p-wechat: #07C160;
  --p-gmail: #EA4335;

  --z-dock: 40;
  --z-drawer: 60;
  --z-modal: 80;
  --z-menu: 90;
  --z-toast: 100;
}

/* Light ------------------------------------------------------------------- */
:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #F3F4F6;
  --pane: #F3F4F6;
  --surface: #FFFFFF;
  --surface-2: #F2F3F5;
  --surface-3: #E7E9EC;
  --raised: #FFFFFF;
  --field: #FFFFFF;
  --line: rgba(16, 22, 34, .09);
  --line-strong: rgba(16, 22, 34, .15);
  --hover: rgba(16, 22, 34, .045);
  --press: rgba(16, 22, 34, .08);

  --text: #0C0E12;
  --text-2: #3C414B;
  --text-3: #6A707B;
  --text-4: #9BA1AB;

  --accent: #0B9A61;
  --accent-strong: #08834F;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(11, 154, 97, .10);
  --accent-soft-2: rgba(11, 154, 97, .16);
  --accent-text: #067A4A;

  --ok: #0B9A61;     --ok-soft: rgba(11, 154, 97, .10);
  --warn: #B86E00;   --warn-soft: rgba(230, 150, 20, .14);
  --danger: #D23B3B; --danger-soft: rgba(210, 59, 59, .10);
  --info: #2462E0;   --info-soft: rgba(36, 98, 224, .10);
  --star: #E8A300;

  --bubble-me: #DFF4E9;
  --bubble-me-text: #0A2418;
  --bubble-me-line: rgba(11, 154, 97, .16);
  --bubble-them: #F1F2F4;
  --bubble-them-text: var(--text);

  --selected: #FFFFFF;
  --selected-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 0 0 1px rgba(16, 24, 40, .06);

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 0 0 1px rgba(16, 24, 40, .05);
  --shadow-2: 0 10px 28px -8px rgba(16, 24, 40, .16), 0 0 0 1px rgba(16, 24, 40, .06);
  --shadow-3: 0 28px 70px -16px rgba(16, 24, 40, .30), 0 0 0 1px rgba(16, 24, 40, .07);
  --focus-ring: 0 0 0 3px rgba(11, 154, 97, .22);
  --backdrop: rgba(12, 14, 18, .32);

  --terminal-bg: #0C0D10;
  --terminal-line: rgba(255, 255, 255, .07);
}

/* Dark -------------------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08090A;
  --pane: #08090A;
  --surface: #111214;
  --surface-2: #18191C;
  --surface-3: #202226;
  --raised: #17181B;
  --field: #18191C;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .12);
  --hover: rgba(255, 255, 255, .04);
  --press: rgba(255, 255, 255, .07);

  --text: #EFF0F2;
  --text-2: #B3B6BD;
  --text-3: #80848D;
  --text-4: #575B63;

  --accent: #3DDC97;
  --accent-strong: #62E6AC;
  --accent-ink: #04170E;
  --accent-soft: rgba(61, 220, 151, .11);
  --accent-soft-2: rgba(61, 220, 151, .18);
  --accent-text: #5FE3A8;

  --ok: #3DDC97;     --ok-soft: rgba(61, 220, 151, .12);
  --warn: #F3B43F;   --warn-soft: rgba(243, 180, 63, .13);
  --danger: #FF6E6E; --danger-soft: rgba(255, 110, 110, .12);
  --info: #74A7FF;   --info-soft: rgba(116, 167, 255, .12);
  --star: #F5C04A;

  --bubble-me: #12301F;
  --bubble-me-text: #DDF6E9;
  --bubble-me-line: rgba(61, 220, 151, .16);
  --bubble-them: #1A1B1E;
  --bubble-them-text: var(--text);

  --selected: #1B1C20;
  --selected-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);

  --shadow-1: inset 0 1px 0 rgba(255, 255, 255, .03), 0 0 0 1px rgba(255, 255, 255, .06);
  --shadow-2: 0 12px 32px -8px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255, 255, 255, .07);
  --shadow-3: 0 30px 80px -12px rgba(0, 0, 0, .75), 0 0 0 1px rgba(255, 255, 255, .08);
  --focus-ring: 0 0 0 3px rgba(61, 220, 151, .25);
  --backdrop: rgba(0, 0, 0, .58);

  --terminal-bg: #060708;
  --terminal-line: rgba(255, 255, 255, .06);
}

/* --------------------------------------------------------------------------
   2. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
  overflow: hidden;
}
h1, h2, h3, h4, h5, h6, p, figure, blockquote { margin: 0; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.015em; line-height: var(--lh-tight); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img, svg, video, iframe { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; }
::selection { background: var(--accent-soft-2); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
code, kbd, pre, samp { font-family: var(--font-mono); }

/* View-transition theme swap: a quick crossfade instead of a hard flip */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 260ms; animation-timing-function: var(--ease-out); }

/* Thin, quiet scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background-color: var(--text-4); }

/* Utilities (deliberately few) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: var(--s-2); }
.stack { display: flex; flex-direction: column; gap: var(--s-2); }
.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }
.only-mobile { display: none !important; }

/* Theme-aware icon swap (no Blazor state needed) */
:root[data-theme="dark"] .when-light,
:root:not([data-theme="dark"]) .when-dark { display: none !important; }

/* --------------------------------------------------------------------------
   3. Primitives
   -------------------------------------------------------------------------- */

/* Buttons ----------------------------------------------------------------- */
.btn {
  --btn-h: 36px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--btn-h); padding: 0 14px;
  border-radius: var(--r-md);
  font-size: var(--fs-md); font-weight: 550; line-height: 1;
  white-space: nowrap; user-select: none;
  border: 1px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  flex: none;
}
.btn i { font-size: 15px; line-height: 1; }
.btn:active:not(:disabled) { transform: translateY(.5px) scale(.99); }
.btn:disabled { opacity: .5; }
.btn-sm { --btn-h: 30px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); gap: 6px; }
.btn-sm i { font-size: 13px; }
.btn-lg { --btn-h: 42px; padding: 0 18px; font-size: var(--fs-base); border-radius: var(--r-lg); }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(0,0,0,.12); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: 0 1px 2px rgba(16,24,40,.05); }
:root[data-theme="dark"] .btn-secondary { background: var(--surface-2); box-shadow: none; }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-strong); }
:root[data-theme="dark"] .btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-accent-ghost { color: var(--accent-text); }
.btn-accent-ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-ink { background: var(--text); color: var(--bg); }
.btn-ink:hover:not(:disabled) { opacity: .9; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; border-radius: var(--r-md);
  color: var(--text-3);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.icon-btn i { font-size: 16px; line-height: 1; }
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn:active:not(:disabled) { background: var(--press); transform: scale(.96); }
.icon-btn.is-on { color: var(--accent-text); background: var(--accent-soft); }
.icon-btn.is-star { color: var(--star); }
.icon-btn:disabled { opacity: .45; }
.icon-btn-sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
.icon-btn-sm i { font-size: 14px; }

/* Spinner ---------------------------------------------------------------- */
.spinner {
  --size: 14px;
  width: var(--size); height: var(--size); flex: none;
  border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
  opacity: .85;
}
.spinner-lg { --size: 28px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Fields ----------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--fs-sm); font-weight: 550; color: var(--text-2); }
.hint { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--field); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: var(--r-md);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
:root[data-theme="dark"] .input, :root[data-theme="dark"] .select, :root[data-theme="dark"] .textarea { box-shadow: none; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-4); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }
.input[readonly], .input:disabled, .select:disabled { opacity: .65; cursor: not-allowed; }
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: var(--lh); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='%23888'%3E%3Cpath d='M1.6 5.2a.75.75 0 0 1 1.06 0L8 10.54l5.34-5.34a.75.75 0 1 1 1.06 1.06l-5.87 5.87a.75.75 0 0 1-1.06 0L1.6 6.26a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > i:first-child { position: absolute; left: 12px; color: var(--text-4); font-size: 15px; pointer-events: none; }
.input-wrap > .input { padding-left: 38px; }
.input-wrap > .input-action { position: absolute; right: 4px; }
.input-wrap > .input:has(+ .input-action) { padding-right: 42px; }
.input-lg { height: 52px; font-size: 22px; letter-spacing: .3em; text-align: center; font-family: var(--font-mono); }
.input.invalid, .input.is-invalid { border-color: var(--danger); }
.input.invalid:focus, .input.is-invalid:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.validation-message { color: var(--danger); font-size: var(--fs-xs); }
.validation-errors { margin: 6px 0 0; padding-left: 18px; color: var(--danger); font-size: var(--fs-sm); }

.check { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-md); color: var(--text-2); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; }

/* Badges & chips --------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 22px; padding: 0 8px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 550; line-height: 1; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--text-3); }
.badge-warn .dot, .badge-info .dot { animation: pulse-dot 1.4s var(--ease-in-out) infinite; }
@keyframes pulse-dot { 50% { opacity: .35; } }

.count {
  display: inline-grid; place-items: center; flex: none;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 650; line-height: 1; font-variant-numeric: tabular-nums;
}

.kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 5px; font-family: var(--font-sans); font-size: 10.5px; font-weight: 550; color: var(--text-3);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong), 0 1px 0 var(--line-strong);
}

/* Callouts --------------------------------------------------------------- */
.callout {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r-lg);
  font-size: var(--fs-md); line-height: 1.5;
  background: var(--surface-2); color: var(--text-2);
}
.callout > i { font-size: 16px; line-height: 1.3; flex: none; }
.callout strong { color: var(--text); font-weight: 600; }
.callout-info { background: var(--info-soft); } .callout-info > i { color: var(--info); }
.callout-ok { background: var(--ok-soft); } .callout-ok > i { color: var(--ok); }
.callout-warn { background: var(--warn-soft); } .callout-warn > i { color: var(--warn); }
.callout-danger { background: var(--danger-soft); } .callout-danger > i, .callout-danger strong { color: var(--danger); }
.callout-accent { background: var(--accent-soft); } .callout-accent > i { color: var(--accent-text); }

/* Avatars ---------------------------------------------------------------- */
.avatar {
  --size: 40px;
  position: relative; flex: none;
  width: var(--size); height: var(--size);
}
.avatar-face {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: 50%;
  background: var(--surface-3) center / cover no-repeat;
  box-shadow: inset 0 0 0 1px var(--line);
}
.avatar-face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface); border-radius: 50%; }
/* A domain icon (email): small artwork centred on a white disc, legible in light and dark themes. */
.avatar-face img.is-icon { object-fit: contain; padding: 20%; background: #fff; box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }
.avatar-sm { --size: 32px; }
.avatar-md { --size: 36px; }
.avatar-lg { --size: 44px; }
.avatar-initial {
  display: grid; place-items: center; color: #fff;
  font-weight: 650; font-size: calc(var(--size) * .4); letter-spacing: -.02em;
}
.avatar .platform {
  position: absolute; right: -3px; bottom: -3px;
  width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  font-size: 9.5px; box-shadow: 0 0 0 2px var(--ring, var(--pane));
}
.avatar .presence {
  position: absolute; right: -2px; top: -2px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 2px var(--ring, var(--pane));
}
.avatar-xl { --size: 64px; }
/* Account mark (Accounts -> Icon): bottom-left, opposite the platform badge */
.avatar .acct-mark {
  --mk: clamp(16px, calc(var(--size) * .4), 26px);
  position: absolute; left: -3px; bottom: -3px;
  width: var(--mk); height: var(--mk); border-radius: 50%;
  display: grid; place-items: center; overflow: hidden;
  background: var(--acct); color: #fff; box-shadow: 0 0 0 2px var(--ring, var(--pane));
  font-size: calc(var(--mk) * .56); line-height: 1;
}
.acct-mark i { font-size: inherit; line-height: 1; }
.acct-mark b { font-weight: 750; letter-spacing: -.03em; line-height: 1; font-size: calc(var(--mk) * .58); }
.acct-mark.t2 b { font-size: calc(var(--mk) * .45); letter-spacing: -.04em; }
.acct-mark.img { background: #fff; }
.acct-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Account settings -> Icon picker */
.aip .section-title { display: flex; align-items: center; gap: 8px; }
.aip .section-title::after { order: 1; }
.aip-state { order: 2; display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); font-weight: 550; color: var(--ok); text-transform: none; letter-spacing: 0; }
.aip-state .spinner { width: 14px; height: 14px; }
.aip-help { margin: -6px 0 0; font-size: var(--fs-sm); color: var(--text-3); }
.aip-body { display: grid; grid-template-columns: 96px 1fr; gap: 18px; align-items: start; }
.aip-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 8px 10px; border-radius: var(--r-lg); background: var(--surface-2); font-size: var(--fs-xs); color: var(--text-3); --ring: var(--surface-2); }
.aip-pick { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.aip-glyphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.aip-g {
  height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2); font-size: 15px;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.aip-g:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.aip-g:active:not(:disabled) { transform: scale(.94); }
.aip-g.is-on { background: var(--acct); color: #fff; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--acct) 45%, transparent); }
.aip-g.is-none.is-on { background: var(--text-3); }
.aip-g:disabled, .aip-c:disabled { cursor: default; opacity: .6; }
.aip-text-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aip-text { max-width: 340px; }
.aip-text.is-invalid { border-color: var(--danger); }
.aip-upload { gap: 7px; cursor: pointer; position: relative; }
.aip-upload.is-disabled { opacity: .55; pointer-events: none; }
.aip-upload:focus-within { box-shadow: var(--focus-ring); }
.aip-g.is-img { padding: 0; overflow: hidden; background: #fff; }
.aip-g.is-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aip-colors { display: flex; flex-wrap: wrap; gap: 9px; }
.aip-c { width: 24px; height: 24px; border-radius: 50%; background: var(--acct); transition: box-shadow var(--t-fast), transform var(--t-fast); }
.aip-c:hover:not(:disabled) { transform: scale(1.1); }
.aip-c.is-on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--acct); }
.aip-err { font-size: var(--fs-sm); color: var(--danger); margin: 0; }
@media (max-width: 560px) { .aip-body { grid-template-columns: 1fr; } .aip-preview { flex-direction: row; justify-content: center; } }


/* Platform colouring helpers */
.pf-email    { --pf: var(--p-email); }
.pf-telegram { --pf: var(--p-telegram); }
.pf-whatsapp { --pf: var(--p-whatsapp); }
.pf-teams    { --pf: var(--p-teams); }
.pf-teamspersonal { --pf: var(--p-teamspersonal); }
.pf-wechat   { --pf: var(--p-wechat); }
.pf-gmail    { --pf: var(--p-gmail); }
.pf-bg { background: var(--pf, var(--p-email)); }
.pf-fg { color: var(--pf, var(--p-email)); }
.pf-tile {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 9px;
  color: var(--pf); background: color-mix(in srgb, var(--pf) 14%, transparent);
  font-size: 15px;
}
.pf-tile-lg { width: 44px; height: 44px; border-radius: 13px; font-size: 21px; }

/* Segmented control ------------------------------------------------------ */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 3px; gap: 2px; border-radius: var(--r-md);
  background: var(--surface-3);
}
:root[data-theme="dark"] .segmented { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.segmented button {
  height: 28px; border-radius: 7px; padding: 0 10px;
  font-size: var(--fs-sm); font-weight: 550; color: var(--text-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background var(--t-base) var(--ease-out), color var(--t-fast), box-shadow var(--t-base);
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(16,24,40,.08), 0 0 0 1px rgba(16,24,40,.04); }
:root[data-theme="dark"] .segmented button.is-active { background: var(--surface-3); box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.segmented .seg-count { font-size: 10.5px; color: var(--text-4); font-variant-numeric: tabular-nums; }
.segmented button.is-active .seg-count { color: var(--text-3); }

/* Skeleton --------------------------------------------------------------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 40%, var(--surface-3) 80%);
  background-size: 300% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: 6px;
}
:root[data-theme="dark"] .skeleton { background-image: linear-gradient(90deg, #17181b 0%, #202226 40%, #17181b 80%); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }

/* Menus ------------------------------------------------------------------ */
.menu {
  min-width: 200px; padding: 5px;
  background: var(--raised); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: pop-in 160ms var(--ease-out) both;
  transform-origin: var(--origin, top left);
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  height: 34px; padding: 0 10px; border-radius: var(--r-sm);
  font-size: var(--fs-md); color: var(--text); text-align: left;
  transition: background var(--t-fast);
}
.menu-item i { width: 16px; font-size: 15px; color: var(--text-3); text-align: center; flex: none; }
.menu-item:hover { background: var(--hover); }
.menu-item.is-active { background: var(--accent-soft); color: var(--accent-text); }
.menu-item.is-active i { color: var(--accent-text); }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger i { color: var(--danger); }
.menu-item .menu-trail { margin-left: auto; color: var(--text-4); font-size: var(--fs-xs); }
.menu-label { padding: 8px 10px 4px; font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4); }
.menu-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu-catcher { position: fixed; inset: 0; z-index: var(--z-menu); }
.menu-floating { position: fixed; z-index: calc(var(--z-menu) + 1); }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(-2px); } to { opacity: 1; transform: none; } }

/* Theme picker inside menus */
.theme-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; }
.theme-pick button {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 4px 8px; border-radius: var(--r-sm); font-size: var(--fs-xs); color: var(--text-3);
  box-shadow: inset 0 0 0 1px var(--line);
}
.theme-pick button i { font-size: 16px; }
.theme-pick button:hover { background: var(--hover); color: var(--text); }
.theme-pick button.is-active { color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--accent); background: var(--accent-soft); }

/* Tooltips (CSS only, for icon controls) --------------------------------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; z-index: 120; pointer-events: none;
  left: calc(100% + 10px); top: 50%; transform: translate(-4px, -50%);
  padding: 6px 9px; border-radius: 7px; white-space: nowrap;
  background: #111214; color: #F2F3F5; font-size: 12px; font-weight: 500; line-height: 1;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  opacity: 0; transition: opacity var(--t-fast), transform var(--t-fast) var(--ease-out);
}
:root[data-theme="dark"] [data-tip]::after { background: #2A2C31; }
[data-tip]:hover::after { opacity: 1; transform: translate(0, -50%); transition-delay: 300ms; }
[data-tip-pos="bottom"]::after { left: 50%; top: calc(100% + 8px); transform: translate(-50%, -4px); }
[data-tip-pos="bottom"]:hover::after { transform: translate(-50%, 0); }
[data-tip-pos="bottom-end"]::after { left: auto; right: 0; top: calc(100% + 8px); transform: translateY(-4px); }
[data-tip-pos="bottom-end"]:hover::after { transform: none; }
/* Above the control, kept inside its pane: start = left edges line up, end = right edges line up. */
[data-tip-pos="top-start"]::after, [data-tip-pos="top-end"]::after { top: auto; bottom: calc(100% + 8px); transform: translateY(4px); }
[data-tip-pos="top-start"]::after { left: 0; }
[data-tip-pos="top-end"]::after { left: auto; right: 0; }
[data-tip-pos="top-start"]:hover::after, [data-tip-pos="top-end"]:hover::after { transform: none; }

/* --------------------------------------------------------------------------
   4. App shell
   -------------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) var(--list-w) minmax(0, 1fr);
  height: 100vh; height: 100dvh;
  background: var(--bg);
  transition: height var(--t-slow) var(--ease-out);
}
.app.has-dock { height: calc(100dvh - var(--dock-h)); }

/* Rail ------------------------------------------------------------------- */
.rail {
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 12px; gap: 4px; min-height: 0;
}
.rail-mark {
  width: 36px; height: 36px; margin-bottom: 14px; flex: none;
  border-radius: 10px; display: grid; place-items: center;
  transition: transform var(--t-base) var(--ease-spring);
}
.rail-mark img { width: 34px; height: 34px; }
.rail-mark:hover { transform: rotate(-6deg) scale(1.04); }
.rail-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rail-scroll { flex: 1 1 auto; min-height: 0; padding: 2px 0; }
.rail-sep { width: 24px; height: 1px; background: var(--line-strong); margin: 6px 0; flex: none; }
.rail-btn {
  position: relative; flex: none;
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  color: var(--text-3);
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-base);
}
.rail-btn i { font-size: 18px; line-height: 1; }
.rail-btn:hover { background: var(--hover); color: var(--text); }
.rail-btn.is-active { background: var(--selected); color: var(--text); box-shadow: var(--selected-shadow); }
.rail-btn.is-active.pf-fg-on i { color: var(--pf); }
.rail-btn.is-active::before {
  content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.rail-btn.is-on { color: var(--accent-text); }
.rail-btn.is-dashed { box-shadow: inset 0 0 0 1px var(--line-strong); border-radius: 11px; }
.rail-btn.is-dashed:hover { box-shadow: inset 0 0 0 1px var(--text-4); }
.rail-btn .rail-count {
  position: absolute; top: 1px; right: 0; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-size: 9.5px; font-weight: 700; line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--bg); font-variant-numeric: tabular-nums;
}
.rail-btn.is-danger:hover { color: var(--danger); background: var(--danger-soft); }
.rail-me {
  width: 34px; height: 34px; border-radius: 50%; margin-top: 6px; flex: none;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 650; color: var(--accent-ink);
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #0b3d2a));
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--line-strong);
  transition: box-shadow var(--t-fast);
}
.rail-me:hover { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.rail-popover { left: calc(var(--rail-w) - 4px); bottom: 12px; --origin: bottom left; width: 248px; }
.rail-popover .who { padding: 10px 10px 8px; }
.rail-popover .who b { display: block; font-size: var(--fs-md); font-weight: 600; }
.rail-popover .who span { display: block; font-size: var(--fs-xs); color: var(--text-3); }

/* List pane -------------------------------------------------------------- */
.listpane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--pane); }
.listpane-head { padding: 18px 16px 10px 8px; display: flex; flex-direction: column; gap: 12px; flex: none; }
.listpane-title { display: flex; align-items: center; gap: 10px; min-height: 32px; padding-left: 4px; }
.listpane-title h1 { font-size: var(--fs-2xl); font-weight: 650; letter-spacing: -.025em; }
.listpane-title .total { font-size: var(--fs-sm); color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }

.conn {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 8px;
  border-radius: var(--r-full); font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .02em;
  color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line);
}
.conn .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; position: relative; }
.conn.is-live { color: var(--ok); }
.conn.is-live .dot::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 1.5px solid currentColor; opacity: 0; animation: ping 2.4s var(--ease-out) infinite; }
.conn.is-sync { color: var(--warn); }
.conn.is-sync .dot { animation: pulse-dot 1s var(--ease-in-out) infinite; }
.conn.is-off { color: var(--danger); }
@keyframes ping { 0% { transform: scale(.6); opacity: .8; } 80%, 100% { transform: scale(2); opacity: 0; } }

.search {
  position: relative; display: flex; align-items: center;
}
.search > i { position: absolute; left: 11px; color: var(--text-4); font-size: 14px; pointer-events: none; }
.search input {
  width: 100%; height: 36px; padding: 0 34px 0 34px;
  border-radius: var(--r-md); border: 1px solid transparent;
  background: var(--surface-3); color: var(--text); font-size: var(--fs-md);
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
:root[data-theme="dark"] .search input { background: var(--surface-2); border-color: var(--line); }
.search input::placeholder { color: var(--text-4); }
.search input:focus { background: var(--surface); border-color: var(--accent); box-shadow: var(--focus-ring); }
.search .search-clear { position: absolute; right: 4px; }

.listpane-body { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 2px 8px 16px 0; }

/* Chat rows -------------------------------------------------------------- */
.nx-chat-row { position: relative; margin: 1px 0; border-radius: 12px; }
.nx-chat-row-inner {
  --ring: var(--pane);
  position: relative;
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 11px 12px; border-radius: 12px; cursor: pointer;
  transition: background var(--t-fast), box-shadow var(--t-base);
  background: var(--pane);
}
.nx-chat-row-inner:hover { --ring: color-mix(in srgb, var(--text) 4%, var(--pane)); background: var(--ring); }
.nx-chat-row.is-selected .nx-chat-row-inner { --ring: var(--selected); background: var(--selected); box-shadow: var(--selected-shadow); }
.nx-chat-row .line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nx-chat-row .line + .line { margin-top: 3px; }
.nx-chat-row .name { font-size: var(--fs-base); font-weight: 550; color: var(--text); flex: 0 1 auto; }
.nx-chat-row .time { margin-left: auto; font-size: var(--fs-xs); color: var(--text-3); flex: none; font-variant-numeric: tabular-nums; }
.nx-chat-row .preview { font-size: var(--fs-md); color: var(--text-3); flex: 1 1 auto; }
.nx-chat-row.is-unread .name { font-weight: 650; }
.nx-chat-row.is-unread .preview { color: var(--text-2); }
.nx-chat-row.is-unread .time { color: var(--accent-text); font-weight: 550; }
.nx-chat-row .assignee {
  flex: none; height: 18px; padding: 0 7px; border-radius: var(--r-full);
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2);
}
.nx-chat-row .assignee.is-me { background: var(--accent-soft); color: var(--accent-text); }
.nx-chat-row .typing { color: var(--warn); font-size: 11px; flex: none; animation: pulse-dot 1.2s infinite; }
.nx-chat-row .trail { display: flex; align-items: center; gap: 2px; flex: none; margin-right: -4px; }

.nx-flag-btn, .nx-complete-btn {
  width: 24px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center;
  color: var(--text-4); transition: background var(--t-fast), color var(--t-fast), opacity var(--t-fast), transform var(--t-fast);
}
.nx-flag-btn i { font-size: 12.5px; }
.nx-flag-btn:hover { color: var(--star); background: var(--hover); }
.nx-flag-btn:not(.flagged) { opacity: 0; }
.nx-flag-btn.flagged { color: var(--star); }
.nx-chat-row-inner:hover .nx-flag-btn, .nx-chat-row-inner:focus-within .nx-flag-btn { opacity: 1; }

.nx-complete-btn { position: relative; width: auto; min-width: 22px; padding: 0 2px; }
.nx-complete-btn .nx-complete-count:empty { display: none; }
.nx-complete-btn .nx-complete-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-full); background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1;
  transition: opacity var(--t-fast), transform var(--t-fast) var(--ease-out);
}
.nx-complete-btn .nx-complete-icon {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px;
  opacity: 0; transform: scale(.6); color: var(--accent-text);
  transition: opacity var(--t-fast), transform var(--t-base) var(--ease-spring);
}
.nx-complete-btn:not(.has-unread) { opacity: 0; width: 24px; }
.nx-chat-row-inner:hover .nx-complete-btn { opacity: 1; }
.nx-complete-btn:hover { background: var(--accent-soft); }
.nx-complete-btn:hover .nx-complete-count { opacity: 0; transform: scale(.7); }
.nx-complete-btn:hover .nx-complete-icon { opacity: 1; transform: none; }

/* Swipe-to-complete (driven by msng.initSwipe) */
.nx-chat-row.nx-swiping { background: var(--accent-soft); }
.nx-chat-row.nx-swiping::before {
  content: "✓ Done"; font-family: var(--font-sans); font-weight: 600; position: absolute; left: 22px; top: 50%;
  transform: translateY(-50%); color: var(--accent-text); font-size: 13px; opacity: .5; transition: opacity var(--t-fast);
}
.nx-chat-row.nx-swipe-ready::before { opacity: 1; }
.nx-chat-row.nx-swipe-complete { animation: row-out 300ms var(--ease-out) forwards; }
@keyframes row-out { to { opacity: 0; height: 0; margin: 0; } }

/* Skeleton rows */
.skel-row { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: center; padding: 11px 12px; }
.skel-row .skeleton:first-child { width: 40px; height: 40px; border-radius: 12px; }

/* List empty / welcome */
.list-empty { padding: 32px 16px; text-align: center; color: var(--text-3); font-size: var(--fs-md); }
.list-empty i { display: block; font-size: 22px; color: var(--text-4); margin-bottom: 10px; }
.welcome { margin: 8px 4px; padding: 22px 18px; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-1); }
.welcome h3 { font-size: var(--fs-lg); margin: 14px 0 6px; }
.welcome p { color: var(--text-3); font-size: var(--fs-md); margin-bottom: 16px; }
.welcome ol { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; counter-reset: s; }
.welcome li { counter-increment: s; display: flex; gap: 10px; align-items: center; font-size: var(--fs-sm); color: var(--text-2); }
.welcome li::before {
  content: counter(s); width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent-text);
}
.welcome-icons { display: flex; gap: 6px; }

/* Conversation pane ------------------------------------------------------ */
.convo {
  position: relative;
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  margin: 8px 8px 8px 0;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-1);
  /* clip, not just hidden: a hidden box can still be scrolled sideways (text selection, scrollIntoView), which slid the
     whole thread left under the dialog list. */
  overflow: hidden; overflow: clip;
}
.convo-body { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; animation: fade-up 260ms var(--ease-out) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.convo-head {
  display: flex; align-items: center; gap: 12px; flex: none;
  min-height: 64px; padding: 10px 14px 10px 20px;
  border-bottom: 1px solid var(--line);
}
.convo-head .avatar { --ring: var(--surface); }
.convo-id { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; }
.convo-id h2 { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.015em; }
.convo-sub { display: flex; align-items: center; gap: 8px; font-size: var(--fs-xs); color: var(--text-3); min-width: 0; }
.convo-sub .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-4); flex: none; }
.convo-sub .online { color: var(--ok); display: inline-flex; align-items: center; gap: 5px; font-weight: 550; }
.convo-sub .online::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.convo-sub .presence { color: var(--warn); font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.convo-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.convo-actions .vsep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 6px; }
.assign-select {
  height: 30px; max-width: 190px; padding: 0 28px 0 10px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 550;
  border: 1px solid var(--line-strong); background-color: var(--surface); color: var(--text-2);
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 16 16' fill='%23888'%3E%3Cpath d='M1.6 5.2a.75.75 0 0 1 1.06 0L8 10.54l5.34-5.34a.75.75 0 1 1 1.06 1.06l-5.87 5.87a.75.75 0 0 1-1.06 0L1.6 6.26a.75.75 0 0 1 0-1.06z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.assign-select:hover { border-color: var(--text-4); color: var(--text); }
.assign-select:focus { border-color: var(--accent); box-shadow: var(--focus-ring); }

/* Messages --------------------------------------------------------------- */
.nx-messages-area { flex: 1 1 auto; overflow-y: auto; min-height: 0; overscroll-behavior: contain; scroll-behavior: auto; }
/* Conversation column: --thread-w (user's width, theme.js) or the style's default; left or centred. */
:root { --thread-w-default: 880px; --thread-pad: 28px; --composer-pad: 20px; }
.nx-messages-inner {
  max-width: var(--thread-w, var(--thread-w-default)); margin: 0 auto; padding: 8px var(--thread-pad) 28px;
  display: flex; flex-direction: column; gap: 10px;
}
:root[data-chat-align="left"] .nx-messages-inner { margin-left: 0; }

/* The stage holds the scrolling stream and the width handle at the column's edge. */
.thread-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.thread-resizer {
  --edge: min(var(--thread-w, var(--thread-w-default)), calc(100% - 8px));
  position: absolute; top: 0; bottom: 0; left: var(--edge); z-index: 7;
  width: 16px; margin-left: -8px; cursor: col-resize; touch-action: none; outline: none;
}
:root[data-chat-align="center"] .thread-resizer { left: calc(50% + var(--edge) / 2); }
.thread-resizer::before {          /* the guide line */
  content: ""; position: absolute; top: 10px; bottom: 10px; left: 50%; width: 2px; margin-left: -1px;
  border-radius: 2px; background: var(--accent); opacity: 0; transform: scaleY(.6);
  transition: opacity 160ms var(--ease-out), transform 220ms var(--ease-out);
}
.thread-resizer-grip {             /* the pill you grab */
  position: absolute; top: 50%; left: 50%; width: 8px; height: 40px; translate: -50% -50%;
  border-radius: 999px; background: var(--raised); box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line);
  opacity: 0; scale: .85; transition: opacity 160ms var(--ease-out), scale 200ms var(--ease-spring, var(--ease-out)), background 160ms;
}
.thread-resizer-grip::before, .thread-resizer-grip::after {
  content: ""; position: absolute; left: 50%; width: 2px; height: 10px; margin-left: -1px; border-radius: 2px;
  background: var(--text-4); top: 9px;
}
.thread-resizer-grip::after { top: auto; bottom: 9px; }
.thread-resizer-tip {
  position: absolute; top: calc(50% + 30px); left: 50%; translate: -50% 0; white-space: nowrap;
  padding: 3px 8px; border-radius: 999px; font-size: var(--fs-2xs); font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--text); color: var(--bg, #fff); box-shadow: var(--shadow-2);
  opacity: 0; transition: opacity 140ms var(--ease-out); pointer-events: none;
}
.thread-stage:hover .thread-resizer-grip { opacity: .75; scale: 1; }
.thread-resizer:hover::before, .thread-resizer:focus-visible::before,
:root.is-resizing-thread .thread-resizer::before { opacity: .5; transform: none; }
.thread-resizer:hover .thread-resizer-grip, .thread-resizer:focus-visible .thread-resizer-grip,
:root.is-resizing-thread .thread-resizer-grip { opacity: 1; scale: 1; background: var(--accent); }
.thread-resizer:hover .thread-resizer-grip::before, .thread-resizer:hover .thread-resizer-grip::after,
.thread-resizer:focus-visible .thread-resizer-grip::before, .thread-resizer:focus-visible .thread-resizer-grip::after,
:root.is-resizing-thread .thread-resizer-grip::before, :root.is-resizing-thread .thread-resizer-grip::after { background: var(--accent-ink, #fff); }
.thread-resizer:hover .thread-resizer-tip:not(:empty), .thread-resizer:focus-visible .thread-resizer-tip:not(:empty),
:root.is-resizing-thread .thread-resizer-tip:not(:empty) { opacity: 1; }
:root.is-resizing-thread, :root.is-resizing-thread * { cursor: col-resize !important; user-select: none !important; }
:root.is-resizing-thread .nx-bubble-wrap { animation: none; }
.load-older { display: flex; justify-content: center; padding: 14px 0 6px; }

.nx-date-sep {
  display: flex; align-items: center; gap: 12px; margin: 14px 0 4px;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-4);
}
.nx-date-sep::before, .nx-date-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.nx-bubble-wrap { display: flex; flex-direction: column; max-width: 76%; animation: bubble-in 220ms var(--ease-out) both; }
.nx-bubble-wrap.them { align-self: flex-start; align-items: flex-start; }
.nx-bubble-wrap.me { align-self: flex-end; align-items: flex-end; max-width: 86%; }
.nx-bubble-wrap.me.im-me { max-width: 72%; }
.nx-bubble-wrap.html-email { align-self: stretch; max-width: 100%; width: 100%; }
.nx-bubble-wrap.me.html-email { align-self: flex-end; width: 92%; }
.nx-bubble-wrap.system { align-self: center; max-width: 640px; width: 100%; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(4px) scale(.995); } to { opacity: 1; transform: none; } }

.nx-bubble {
  position: relative; padding: 9px 13px 7px; border-radius: 18px;
  font-size: var(--fs-base); line-height: 1.5; overflow-wrap: anywhere;
  /* Never wider than its column: a reply quote is one unwrapped line, and without this cap it stretched the bubble
     past the pane (cut off on the left for our replies, a sideways scrollbar for theirs). */
  max-width: 100%; min-width: 0;
}
.nx-bubble.them { background: var(--bubble-them); color: var(--bubble-them-text); border-bottom-left-radius: 6px; }
.nx-bubble.me { background: var(--bubble-me); color: var(--bubble-me-text); border-bottom-right-radius: 6px; box-shadow: inset 0 0 0 1px var(--bubble-me-line); }
.nx-bubble.system { background: transparent; border-radius: var(--r-xl); box-shadow: inset 0 0 0 1px var(--line-strong); padding: 14px 16px 10px; }
.nx-bubble.system .sys-subject { font-weight: 650; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.nx-bubble.system .sys-details { margin-top: 12px; }
.nx-bubble.system .sys-details pre, .nx-bubble.system .sys-details .mono { font-size: 12px; }
.nx-bubble.html-email { background: transparent; box-shadow: none; padding: 0; border-radius: 0; width: 100%; }

/* AI translation ------------------------------------------------------- */
.tr-block {
  margin-top: 8px; padding-top: 7px;
  border-top: 1px solid color-mix(in srgb, currentColor 14%, transparent);
  animation: tr-in 220ms var(--ease-out) both;
}
.tr-head {
  display: flex; align-items: center; gap: 6px; margin-bottom: 3px;
  font-size: var(--fs-2xs); font-weight: 600; letter-spacing: .02em;
  color: var(--accent-text); opacity: .9;
}
.nx-bubble.me .tr-head, .nx-bubble.im-me .tr-head { color: inherit; opacity: .7; }
.tr-head i { font-size: 11px; }
.tr-text { line-height: 1.5; }
.tr-text p { margin: 0; }
.tr-block.is-note .tr-head { color: var(--text-4); font-weight: 500; margin: 0; }
.tr-block.is-loading .tr-head { color: var(--text-3); font-weight: 500; margin: 0; }
.tr-dots { display: inline-flex; gap: 3px; margin-left: 2px; }
.tr-dots span { width: 4px; height: 4px; border-radius: 50%; background: currentColor; opacity: .3; animation: tr-dot 1s infinite ease-in-out; }
.tr-dots span:nth-child(2) { animation-delay: .15s; }
.tr-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes tr-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: .9; transform: translateY(-2px); } }
@keyframes tr-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
.msg-actions button.is-on { color: var(--accent-text); }

.tr-wrap { position: relative; }
.tr-menu { position: absolute; top: calc(100% + 6px); right: 0; z-index: calc(var(--z-menu) + 1); width: 300px; --origin: top right; }
.tr-toggle {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-sm); text-align: left;
}
.tr-toggle:hover { background: var(--hover); }
.tr-toggle-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.tr-toggle-text b { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.tr-toggle-text span { font-size: var(--fs-xs); color: var(--text-3); }
.tr-switch {
  flex: none; width: 34px; height: 20px; border-radius: 999px; position: relative;
  background: var(--border-strong, var(--hover)); transition: background 160ms var(--ease-out);
}
.tr-switch span {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 180ms var(--ease-out);
}
.tr-switch.is-on { background: var(--accent); }
.tr-switch.is-on span { transform: translateX(14px); }
.tr-lang { display: flex; align-items: center; gap: 10px; padding: 6px 10px 8px; font-size: var(--fs-sm); color: var(--text-3); }
.tr-lang select {
  flex: 1; height: 32px; padding: 0 8px; border-radius: var(--r-sm);
  background: var(--sunken, var(--hover)); color: var(--text); border: 1px solid var(--border);
  font: inherit; font-size: var(--fs-sm);
}
.tr-tips { margin: 2px 4px 4px; padding: 8px 8px 2px; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.tr-tips div { display: grid; grid-template-columns: 14px 1fr; gap: 6px; align-items: start; font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; }
.tr-tips div > i:first-child { color: var(--text-4); text-align: center; margin-top: 1px; }
.tr-tips span i { color: var(--text-2); }

.tr-bar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 10px;
  border-radius: var(--r-md); background: var(--accent-soft); color: var(--text);
  font-size: var(--fs-sm); animation: tr-in 200ms var(--ease-out) both;
}
.tr-bar > i { color: var(--accent-text); font-size: 15px; }
.tr-bar-text { min-width: 0; }
.tr-bar-orig { color: var(--text-3); font-size: var(--fs-xs); margin-top: 1px; }

.friend-req { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.friend-req-note { font-size: var(--fs-sm); color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.friend-req-note.is-ok { color: var(--success, var(--text-2)); }
.nx-bubble-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 3px; min-height: 16px; }
.nx-bubble-time { font-size: 10.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nx-bubble.me .nx-bubble-time { color: color-mix(in srgb, var(--bubble-me-text) 55%, transparent); }
.nx-bubble-meta .seen { color: var(--info); font-size: 13px; }
.nx-bubble-meta .sent { color: var(--text-4); font-size: 13px; }
.nx-bubble.me .nx-bubble-meta .sent { color: color-mix(in srgb, var(--bubble-me-text) 45%, transparent); }
.nx-bubble-meta .expand { color: inherit; opacity: .55; width: 20px; height: 18px; display: grid; place-items: center; border-radius: 6px; }
.nx-bubble-meta .expand:hover { opacity: 1; background: var(--hover); }

.media { margin: 2px -6px 8px; }
.media img { max-height: 240px; max-width: min(320px, 100%); border-radius: 12px; object-fit: cover; }
.media video { max-width: 100%; border-radius: 12px; }
.media .file {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 12px;
  background: var(--hover); color: inherit; font-size: var(--fs-md); font-weight: 550; text-decoration: none;
}
.media .file i { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: var(--surface); color: var(--text-2); font-size: 15px; }

/* HTML email card */
.email-card { border-radius: var(--r-xl); overflow: hidden; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-strong); }
.email-card .ai-summary { margin: 12px 12px 0; }
.email-frame { position: relative; margin: 12px; border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.email-frame.is-clamped { max-height: 480px; overflow-y: auto; }
.email-frame iframe { width: 100%; border: 0; background: #fff; min-height: 60px; }
.email-frame .fade { position: sticky; bottom: 0; left: 0; right: 0; height: 64px; margin-top: -64px; background: linear-gradient(transparent, rgba(255,255,255,.96)); pointer-events: none; }
.email-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px 10px 8px; }
.ai-summary { padding: 10px 12px; border-radius: var(--r-lg); background: var(--accent-soft); font-size: var(--fs-md); line-height: 1.55; color: var(--text); }
.ai-summary .ai-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 4px; }

/* Markdown inside bubbles / assistant ------------------------------------ */
.nx-md { font-size: inherit; }
.nx-md > * + * { margin-top: .55em; }
.nx-md p, .nx-md ul, .nx-md ol, .nx-md blockquote, .nx-md pre, .nx-md h1, .nx-md h2, .nx-md h3, .nx-md h4 { margin-bottom: 0; }
.nx-md h1 { font-size: 1.25em; } .nx-md h2 { font-size: 1.15em; } .nx-md h3, .nx-md h4 { font-size: 1.05em; }
.nx-md h1, .nx-md h2, .nx-md h3, .nx-md h4 { margin-top: .9em; font-weight: 650; }
.nx-md > :first-child { margin-top: 0; }
.nx-md ul, .nx-md ol { padding-left: 1.3em; }
.nx-md li + li { margin-top: .25em; }
.nx-md li::marker { color: var(--text-4); }
.nx-md blockquote { padding-left: 12px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.nx-md code { font-size: .88em; padding: .12em .4em; border-radius: 5px; background: var(--press); }
.nx-md pre { padding: 12px 14px; border-radius: var(--r-lg); background: var(--terminal-bg); color: #E4E6EA; overflow-x: auto; font-size: 12.5px; line-height: 1.55; }
.nx-md pre code { background: none; padding: 0; font-size: inherit; color: inherit; }
.nx-md a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 2px; }
.nx-md a:hover { text-decoration-color: currentColor; }
.nx-md strong { font-weight: 650; }
.nx-md hr { border: 0; height: 1px; background: var(--line); margin: 1em 0; }
.nx-md table { border-collapse: collapse; font-size: .92em; }
.nx-md th, .nx-md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.nx-md img { border-radius: 8px; }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.nx-copy-btn {
  display: inline-grid; place-items: center; vertical-align: -2px;
  width: 18px; height: 18px; margin-left: 2px; border-radius: 5px;
  color: var(--text-3); background: var(--hover); font-size: 10px; transition: color var(--t-fast), background var(--t-fast);
}
.nx-copy-btn:hover { color: var(--accent-text); background: var(--accent-soft); }
.nx-copy-btn .bi-check-lg { color: var(--ok); }

/* Composer --------------------------------------------------------------- */
.composer { flex: none; padding: 8px var(--composer-pad) 16px; }
/* Same column as the stream: its edges line up with the bubbles. */
.composer-inner { max-width: calc(var(--thread-w, var(--thread-w-default)) - 2 * var(--thread-pad)); margin: 0 auto; }
:root[data-chat-align="left"] .composer-inner { margin-left: calc(var(--thread-pad) - var(--composer-pad)); }
.composer-box {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 6px; border-radius: 16px;
  background: var(--field); border: 1px solid var(--line-strong);
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 6px 20px -12px rgba(16,24,40,.12);
  transition: border-color var(--t-fast), box-shadow var(--t-base);
}
:root[data-theme="dark"] .composer-box { box-shadow: none; }
.composer-box:focus-within { border-color: color-mix(in srgb, var(--accent) 70%, var(--line-strong)); box-shadow: var(--focus-ring); }
.composer-box textarea {
  flex: 1 1 auto; min-width: 0; resize: none; border: 0; background: transparent;
  padding: 8px 4px; max-height: 160px; min-height: 36px; line-height: 1.45; font-size: var(--fs-base); color: var(--text);
}
.composer-box textarea::placeholder { color: var(--text-4); }
.send-btn {
  width: 36px; height: 36px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  transition: background var(--t-fast), transform var(--t-base) var(--ease-spring), opacity var(--t-fast);
}
.send-btn i { font-size: 15px; transform: translateX(-1px); }
.send-btn:hover:not(:disabled) { background: var(--accent-strong); transform: scale(1.04); }
.send-btn:disabled { background: var(--surface-3); color: var(--text-4); cursor: default; }
.composer-hint { display: flex; justify-content: flex-end; gap: 12px; padding: 6px 6px 0; font-size: var(--fs-2xs); color: var(--text-4); }
.composer-hint span { display: inline-flex; align-items: center; gap: 4px; }

.reply-bar, .draft-note {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 8px 8px 12px;
  border-radius: var(--r-lg); background: var(--surface-2); position: relative; overflow: hidden;
  animation: fade-up 200ms var(--ease-out) both;
}
.reply-bar::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
/* The contact can't be reached (deleted Telegram account, blocked…): shown above the box to everyone on the account. */
.undeliverable-bar {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; padding: 8px 12px;
  border-radius: var(--r-lg); background: var(--danger-soft); color: var(--danger); font-size: var(--fs-sm);
}
.undeliverable-bar i { margin-top: 1px; }
.undeliverable-bar .grow { min-width: 0; color: var(--text-2); }
.undeliverable-bar b { color: var(--danger); font-weight: 650; }
/* A send to this chat just failed: nudge the bar (the only message; there is no toast). */
/* A send that did not go out: why, with Send anyway after a teammate's reply (SendGate). */
.send-refused { align-items: center; }
.send-refused .btn, .send-refused .icon-btn { flex: none; }
.undeliverable-bar.is-bumped { animation: bar-nudge 420ms ease; box-shadow: inset 0 0 0 1px var(--danger); }
@keyframes bar-nudge { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.reply-bar .what { font-size: var(--fs-2xs); font-weight: 650; color: var(--accent-text); letter-spacing: .02em; }
.reply-bar .quote { font-size: var(--fs-md); color: var(--text-2); }
.draft-note { background: var(--accent-soft); align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); white-space: pre-wrap; }
.draft-note i { color: var(--accent-text); margin-top: 1px; }
.draft-note.is-working { align-items: center; color: var(--text-3); }
.draft-note .grow { min-width: 0; }
.draft-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; white-space: normal; }
.src-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 280px; height: 24px; padding: 0 9px;
  border-radius: 999px; background: var(--raised); color: var(--text-2); font-size: var(--fs-2xs); font-weight: 550;
  box-shadow: inset 0 0 0 1px var(--line); text-decoration: none; transition: box-shadow var(--t-fast), color var(--t-fast);
}
.src-chip i { font-size: 11px; margin: 0; }
a.src-chip:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.draft-teach { flex: none; align-self: flex-start; margin: -3px -2px 0 0; }

/* Drafts from Claude (connector) ------------------------------------------------ */
.ext-draft {
  display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; padding: 10px 10px 10px 12px;
  border-radius: var(--r-lg); background: var(--accent-soft); font-size: var(--fs-sm); animation: fade-up 200ms var(--ease-out) both;
}
.ext-draft > i { color: var(--accent-text); margin-top: 2px; }
.ext-draft .grow { flex: 1; min-width: 0; }
.ext-head { color: var(--text-3); font-size: var(--fs-xs); }
.ext-head b { color: var(--text); font-weight: 600; }
.ext-text { margin-top: 3px; color: var(--text); white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ext-note { margin-top: 4px; color: var(--text-3); font-size: var(--fs-xs); }
.ext-actions { display: flex; gap: 6px; flex: none; }

/* Connect Claude panel ---------------------------------------------------------- */
.modal.cn { width: min(720px, 100%); }
/* New e-mail (NewEmailDialog) */
.modal.ne { width: min(680px, 100%); }
.ne-body { display: grid; gap: 14px; align-content: start; }
.ne-text { min-height: 220px; }
.ne-none { color: var(--text-3); }
.ne-error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font-size: var(--fs-sm); }
.ne-actions { display: flex; gap: 8px; margin-left: auto; }
/* Delete message confirmation */
.modal.dm { width: min(460px, 100%); }
.dm-body { display: grid; gap: 12px; align-content: start; }
.dm-quote { margin: 0; padding: 8px 12px; border-left: 3px solid var(--border, rgba(0,0,0,.15)); color: var(--text-2); font-size: var(--fs-sm); white-space: pre-wrap; word-break: break-word; max-height: 120px; overflow: auto; }
.dm-check { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); cursor: pointer; }
.dm-what { margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.dm-what i { color: var(--text-3); margin-right: 4px; }
.menu-item.is-danger, .menu-item.is-danger i { color: var(--danger); }
.email-cc { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 6px; }
.email-cc b { font-weight: 600; margin-right: 4px; }
.cn-body { display: grid; gap: 18px; }
.cn-url { display: grid; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); }
.cn-url-row { display: flex; gap: 8px; }
.cn-url-row .input { flex: 1; font-family: var(--font-mono, ui-monospace, monospace); font-size: 13px; }
.cn-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cn-steps section { padding: 12px 14px; border-radius: var(--r-lg); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--fs-sm); color: var(--text-2); }
.cn-steps h3 { font-size: var(--fs-md); font-weight: 650; margin-bottom: 8px; display: flex; gap: 7px; align-items: center; color: var(--text); }
.cn-steps h3 i { color: var(--accent-text); }
.cn-steps ol { padding-left: 18px; display: grid; gap: 4px; line-height: 1.45; }
.cn-steps p { margin-top: 8px; line-height: 1.45; }
.cn-cmd { display: block; padding: 8px 10px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 12px; word-break: break-all; }
.cn-try p { font-size: var(--fs-sm); color: var(--text-2); font-style: italic; margin: 4px 0; }
.cn-apps { display: grid; gap: 8px; }
.cn-none { font-size: var(--fs-sm); color: var(--text-4); }
.cn-app { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.cn-app i { color: var(--accent-text); }
.cn-app .grow { flex: 1; min-width: 0; display: grid; }
.cn-app small { color: var(--text-4); font-size: var(--fs-2xs); }
@media (max-width: 767px) { .cn-steps { grid-template-columns: 1fr; } }

/* Connect page (OAuth consent) */
.cx { max-width: 460px; }
.cx-wait { display: grid; place-items: center; padding: 40px; }
.cx-app { color: var(--accent-text); }
.cx-list { list-style: none; padding: 0; margin: 16px 0 10px; display: grid; gap: 8px; }
.cx-list li { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-md); color: var(--text-2); line-height: 1.4; }
.cx-list li.ok i { color: var(--success, var(--accent-text)); }
.cx-list li.no i { color: var(--danger); }
.cx-redirect { font-size: var(--fs-xs); color: var(--text-4); line-height: 1.45; }
.cx-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* GitLab tasks panel -------------------------------------------------------- */
.modal.tk { width: min(760px, 100%); height: min(760px, calc(100dvh - 48px)); }
.tk-body { display: flex; flex-direction: column; gap: 14px; }
.tk-banner { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); color: var(--text-2); font-size: var(--fs-sm); }
.tk-toolbar { display: flex; align-items: center; gap: 8px; }
.tk-toolbar .grow, .tk-actions .grow { flex: 1; }
.tk-count { font-size: var(--fs-sm); color: var(--text-3); font-weight: 550; }
.tk-empty { margin: auto; display: grid; justify-items: center; gap: 8px; max-width: 380px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.5; padding: 30px 0; }
.tk-empty > i { font-size: 30px; color: var(--accent-text); }
.tk-empty b { color: var(--text); font-size: var(--fs-lg, 16px); }
.tk-list { display: grid; gap: 10px; }
.tk-card { border-radius: var(--r-lg); padding: 12px 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: grid; gap: 6px; animation: fade-up 200ms var(--ease-out) both; }
.tk-card-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tk-title { flex: 1; min-width: 0; font-weight: 600; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-title:hover { text-decoration: underline; }
.tk-kind { flex: none; font-size: var(--fs-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); }
.tk-kind.k-bug { background: var(--danger-soft); color: var(--danger); }
.tk-kind.k-feature { background: var(--accent-soft); color: var(--accent-text); }
.tk-state { flex: none; font-size: var(--fs-2xs); font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-3); }
.tk-state.s-opened { background: color-mix(in srgb, var(--success, #1f9d55) 14%, transparent); color: var(--success, #1f9d55); }
.tk-state.s-merged { background: color-mix(in srgb, #7c5cff 16%, transparent); color: #7c5cff; }
.tk-meta { font-size: var(--fs-xs); color: var(--text-4); }
.tk-meta a { color: var(--text-3); }
.tk-mr { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); background: var(--raised); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-2); font-size: var(--fs-sm); text-decoration: none; min-width: 0; }
.tk-mr:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--text); }
.tk-mr .truncate { flex: 1; min-width: 0; }
.tk-claude { font-size: var(--fs-xs); color: var(--text-3); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tk-claude i { color: var(--accent-text); }
.tk-hint { color: var(--text-4); }
.tk-ask { display: flex; gap: 8px; align-items: center; }
.tk-ask .input { flex: 1; height: 32px; }
.tk-ask-btn { justify-self: start; }
.tk-form { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; position: relative; }
.tk-writing { display: flex; gap: 8px; align-items: center; font-size: var(--fs-sm); color: var(--text-3); padding: 8px 10px; border-radius: var(--r-md); background: var(--accent-soft); }
.tk-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.tk-field { display: grid; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); }
.tk-field em { font-style: normal; font-weight: 500; color: var(--text-4); }
.tk-field.grow { flex: 1; grid-template-rows: auto 1fr; min-height: 0; }
.tk-field .textarea { height: 100%; min-height: 200px; resize: none; line-height: 1.5; }
.tk-field .textarea.mono { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12.5px; }
.tk-check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.45; cursor: pointer; }
.tk-check input { margin-top: 3px; accent-color: var(--accent); }
.tk-check.is-off { opacity: .55; cursor: not-allowed; }
.tk-actions { display: flex; align-items: center; gap: 8px; }
@media (max-width: 767px) { .tk-row { grid-template-columns: 1fr; } .modal.tk { height: 92dvh; } }

/* AI knowledge panel ------------------------------------------------------ */
.modal.kn { width: min(980px, 100%); height: min(720px, calc(100dvh - 48px)); }
.kn-body { display: grid; grid-template-columns: 330px 1fr; gap: 0; padding: 0; overflow: hidden; }
.kn-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.kn-tools { display: flex; gap: 8px; padding: 14px 14px 10px; }
.kn-search { position: relative; flex: 1; }
.kn-search i { position: absolute; left: 10px; top: 50%; translate: 0 -50%; color: var(--text-4); font-size: 13px; }
.kn-search .input { padding-left: 30px; height: 32px; }
.kn-items { flex: 1; overflow-y: auto; padding: 2px 8px 8px; display: grid; gap: 2px; align-content: start; }
.kn-item {
  display: grid; gap: 2px; text-align: left; padding: 9px 10px; border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.kn-item:hover { background: var(--hover); }
.kn-item.is-active { background: var(--accent-soft); }
.kn-item b { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.kn-snip { font-size: var(--fs-xs); color: var(--text-3); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kn-item small { font-size: var(--fs-2xs); color: var(--text-4); }
.kn-empty { flex: 1; display: grid; place-content: center; gap: 6px; padding: 24px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); }
.kn-empty b { color: var(--text); font-size: var(--fs-md); }
.kn-reach { border-top: 1px solid var(--line); padding: 4px 14px 12px; display: grid; gap: 6px; font-size: var(--fs-xs); color: var(--text-2); }
.kn-reach .menu-label { padding: 8px 0 0; }
.kn-reach div:not(.menu-label) { display: flex; gap: 8px; align-items: baseline; line-height: 1.4; }
.kn-reach i { color: var(--accent-text); }
.kn-reach .is-off { color: var(--text-4); }
.kn-reach .is-off i { color: var(--text-4); }
.kn-editor { display: flex; flex-direction: column; gap: 14px; padding: 18px 22px; min-height: 0; }
.kn-field { display: grid; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--text-3); }
.kn-field em { font-style: normal; font-weight: 500; color: var(--text-4); float: right; font-variant-numeric: tabular-nums; }
.kn-field.grow { flex: 1; grid-template-rows: auto 1fr; min-height: 0; }
.kn-field .textarea { height: 100%; min-height: 220px; resize: none; font-size: var(--fs-md); line-height: 1.55; }
.kn-actions { display: flex; align-items: center; gap: 8px; }
.kn-actions .grow { flex: 1; }
.kn-confirm { font-size: var(--fs-sm); color: var(--danger); }
.kn-saved { font-size: var(--fs-xs); color: var(--success, var(--accent-text)); display: inline-flex; gap: 4px; align-items: center; animation: fade-in 200ms var(--ease-out); }
.kn-placeholder { margin: auto; display: grid; justify-items: center; gap: 8px; max-width: 360px; text-align: center; color: var(--text-3); font-size: var(--fs-sm); line-height: 1.5; }
.kn-placeholder > i { font-size: 30px; color: var(--accent-text); }
.kn-placeholder b { color: var(--text); font-size: var(--fs-lg, 16px); }
@media (max-width: 767px) {
  .kn-body { grid-template-columns: 1fr; grid-template-rows: minmax(160px, 40%) 1fr; }
  .kn-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .modal.kn { height: 92dvh; }
}

/* Conversation empty state ---------------------------------------------- */
.convo-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 24px; text-align: center; animation: fade-in 300ms both;
}
.empty-art { position: relative; width: 132px; height: 104px; margin-bottom: 28px; }
.empty-art .card {
  position: absolute; width: 104px; height: 64px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; justify-content: center; gap: 7px; padding: 0 14px;
}
.empty-art .card span { height: 6px; border-radius: 3px; background: var(--surface-3); }
.empty-art .card span:first-child { width: 55%; background: var(--line-strong); }
.empty-art .card.c1 { left: 0; top: 0; transform: rotate(-6deg); opacity: .7; }
.empty-art .card.c2 { right: 0; bottom: 0; transform: rotate(4deg); }
.empty-art .card.c2 span:first-child { background: var(--accent); width: 40%; }
.convo-empty h3 { font-size: var(--fs-xl); font-weight: 650; margin-bottom: 8px; }
.convo-empty p { color: var(--text-3); max-width: 360px; font-size: var(--fs-md); line-height: 1.55; }
.convo-empty .hints { display: flex; gap: 16px; margin-top: 22px; font-size: var(--fs-xs); color: var(--text-4); flex-wrap: wrap; justify-content: center; }
.convo-empty .hints span { display: inline-flex; align-items: center; gap: 6px; }

/* Forward overlay -------------------------------------------------------- */
.forward-overlay {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--surface) 75%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade-in 180ms both;
}
.forward-card { text-align: center; max-width: 320px; padding: 28px 24px 22px; border-radius: var(--r-2xl); background: var(--raised); box-shadow: var(--shadow-3); animation: pop-in 220ms var(--ease-out) both; }
.forward-card .pf-tile { margin: 0 auto 14px; }
.forward-card h3 { font-size: var(--fs-lg); margin-bottom: 6px; }
.forward-card p { font-size: var(--fs-md); color: var(--text-3); margin-bottom: 18px; }

/* --------------------------------------------------------------------------
   5. Overlays: modal, drawer, assistant, dock, toasts
   -------------------------------------------------------------------------- */
.modal-root { position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade-in 200ms both; }
.modal {
  position: relative; display: flex; flex-direction: column;
  width: min(780px, 100%); max-height: min(860px, calc(100dvh - 48px));
  background: var(--raised); border-radius: var(--r-2xl); box-shadow: var(--shadow-3);
  animation: modal-in 280ms var(--ease-out) both; overflow: hidden;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 16px 24px; border-bottom: 1px solid var(--line); flex: none; }
.modal-head .titles { flex: 1; min-width: 0; }
.modal-head h2 { font-size: 19px; font-weight: 650; letter-spacing: -.02em; display: flex; align-items: center; gap: 6px; }
.modal-head p { margin-top: 3px; font-size: var(--fs-md); color: var(--text-3); }
.modal-head .back { margin-left: -8px; }
.modal-body { flex: 1 1 auto; overflow-y: auto; padding: 20px 24px 24px; min-height: 0; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px; border-top: 1px solid var(--line); flex: none; font-size: var(--fs-xs); color: var(--text-3); }

/* Side drawer (legacy side menu) */
.drawer-root { position: fixed; inset: 0; z-index: var(--z-drawer); }
.drawer { position: absolute; top: 0; bottom: 0; left: 0; width: 300px; max-width: 86vw; background: var(--raised); box-shadow: var(--shadow-3); display: flex; flex-direction: column; animation: drawer-in 280ms var(--ease-out) both; }
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 20px 18px 16px; border-bottom: 1px solid var(--line); }
.drawer-head img { width: 36px; height: 36px; }
.drawer-head b { display: block; font-size: var(--fs-lg); }
.drawer-head span { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.drawer-nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.drawer-foot { padding: 8px; border-top: 1px solid var(--line); }

/* Brand lockup */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; }
.brand b { font-size: 17px; font-weight: 700; letter-spacing: -.02em; display: block; line-height: 1.1; }
.brand span { font-size: var(--fs-2xs); color: var(--text-3); letter-spacing: .02em; }

/* Assistant -------------------------------------------------------------- */
.ai-root { position: fixed; inset: 0; z-index: var(--z-drawer); }
.ai-root .modal-backdrop { background: color-mix(in srgb, var(--backdrop) 55%, transparent); backdrop-filter: none; }
.ai-panel {
  position: absolute; top: 8px; right: 8px; bottom: 8px; width: min(440px, calc(100vw - 16px));
  display: flex; flex-direction: column; background: var(--raised);
  border-radius: 18px; box-shadow: var(--shadow-3); overflow: hidden;
  animation: ai-in 320ms var(--ease-out) both;
}
@keyframes ai-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.ai-root.is-full .ai-panel { left: 50%; right: auto; top: 24px; bottom: 24px; width: min(980px, calc(100vw - 48px)); transform: translateX(-50%); animation: modal-in-c 280ms var(--ease-out) both; }
@keyframes modal-in-c { from { opacity: 0; transform: translate(-50%, 10px) scale(.985); } to { opacity: 1; transform: translateX(-50%); } }
.ai-head { display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 18px; border-bottom: 1px solid var(--line); flex: none; }
.ai-head .t b { display: block; font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.01em; }
.ai-head .t span { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.ai-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: 17px; flex: none; }
.ai-msgs { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.ai-msgs-inner { max-width: 760px; margin: 0 auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 18px; }
.ai-msg { display: flex; gap: 10px; animation: bubble-in 240ms var(--ease-out) both; }
.ai-msg.user { justify-content: flex-end; }
.ai-msg.user .ai-content { background: var(--bubble-me); color: var(--bubble-me-text); box-shadow: inset 0 0 0 1px var(--bubble-me-line); padding: 9px 13px; border-radius: 16px 16px 6px 16px; max-width: 85%; }
.ai-msg.bot .ai-mark { width: 26px; height: 26px; border-radius: 8px; font-size: 13px; margin-top: 1px; }
.ai-msg.bot .ai-content { flex: 1; min-width: 0; font-size: var(--fs-base); line-height: 1.6; color: var(--text); }
.ai-options { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 36px; margin-top: -6px; }
.ai-options button {
  height: 32px; padding: 0 12px; border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 550;
  color: var(--accent-text); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: background var(--t-fast), transform var(--t-fast);
}
.ai-options button:hover { background: var(--accent-soft); }
.ai-welcome { text-align: center; padding: 28px 12px 8px; }
.ai-welcome .ai-mark { width: 52px; height: 52px; border-radius: 16px; font-size: 24px; margin: 0 auto 16px; }
.ai-welcome h3 { font-size: var(--fs-xl); margin-bottom: 6px; }
.ai-welcome p { font-size: var(--fs-md); color: var(--text-3); max-width: 320px; margin: 0 auto; line-height: 1.55; }
.ai-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 18px 10px; max-width: 760px; width: 100%; margin: 0 auto; flex: none; }
.ai-quick button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left;
  padding: 11px 12px; border-radius: var(--r-lg); font-size: var(--fs-sm); font-weight: 550; color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong); transition: background var(--t-fast), box-shadow var(--t-fast);
}
.ai-quick button i { color: var(--accent-text); font-size: 15px; }
.ai-quick button:hover { background: var(--hover); box-shadow: inset 0 0 0 1px var(--text-4); }
.ai-input { padding: 6px 14px 14px; flex: none; }
.ai-input .composer-box { max-width: 760px; margin: 0 auto; }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); animation: typing 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Debug dock ------------------------------------------------------------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--dock-h); z-index: var(--z-dock);
  display: flex; flex-direction: column; background: var(--terminal-bg); color: #D7DAE0;
  border-top: 1px solid var(--terminal-line); font-family: var(--font-mono); font-size: 12px;
  animation: dock-in 260ms var(--ease-out) both;
}
@keyframes dock-in { from { transform: translateY(100%); } to { transform: none; } }
.dock-bar { display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--terminal-line); flex: none; font-family: var(--font-sans); }
.dock-bar b { font-size: 12px; font-weight: 600; color: #F2F3F5; display: inline-flex; align-items: center; gap: 8px; }
.dock-bar b::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3DDC97; box-shadow: 0 0 0 3px rgba(61,220,151,.18); }
.dock-bar .n { font-size: 11px; color: #7C818B; }
.dock-bar button { height: 26px; padding: 0 10px; border-radius: 7px; font-size: 11.5px; color: #B9BDC5; }
.dock-bar button:hover { background: rgba(255,255,255,.07); color: #fff; }
.dock-log { flex: 1; overflow-y: auto; padding: 6px 0; }
.dock-entry { display: flex; gap: 10px; padding: 2px 14px; line-height: 1.6; }
.dock-entry:hover { background: rgba(255,255,255,.03); }
.dock-entry .t { color: #5D626C; flex: none; }
.dock-entry .m { color: #D7DAE0; white-space: pre-wrap; overflow-wrap: anywhere; }
.dock-empty { padding: 18px 14px; color: #5D626C; }

/* Toasts ----------------------------------------------------------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.app.has-dock ~ .toasts, body:has(.dock) .toasts { bottom: calc(var(--dock-h) + 16px); }
.toast {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start;
  padding: 13px 10px 13px 14px; border-radius: var(--r-lg);
  background: var(--raised); box-shadow: var(--shadow-3); overflow: hidden;
  animation: toast-in 340ms var(--ease-spring) both;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.toast .ic { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; }
.toast.is-error .ic { background: var(--danger-soft); color: var(--danger); }
.toast.is-ok .ic { background: var(--ok-soft); color: var(--ok); }
.toast b { display: block; font-size: var(--fs-md); font-weight: 600; margin-top: 1px; }
.toast p { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; line-height: 1.45; overflow-wrap: anywhere; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; transform-origin: left; animation: toast-bar 5s linear both; }
.toast.is-error .bar { background: var(--danger); }
.toast.is-ok .bar { background: var(--ok); }
@keyframes toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Global error UI + crash recovery --------------------------------------- */
#blazor-error-ui {
  display: none; position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 200;
  align-items: center; gap: 12px; padding: 10px 10px 10px 16px; border-radius: var(--r-lg);
  background: var(--danger); color: #fff; font-size: var(--fs-md); box-shadow: var(--shadow-3);
}
#blazor-error-ui a { color: #fff; font-weight: 600; text-decoration: underline; }
#blazor-error-ui .dismiss { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; cursor: pointer; }
#blazor-error-ui .dismiss:hover { background: rgba(255,255,255,.15); }
.crash { flex: 1; display: grid; place-items: center; padding: 40px; height: 100dvh; }
.crash .box { text-align: center; max-width: 380px; }
.crash .pf-tile { --pf: var(--warn); margin: 0 auto 16px; }
.crash h3 { font-size: var(--fs-xl); margin-bottom: 6px; }
.crash p { color: var(--text-3); font-size: var(--fs-md); margin-bottom: 18px; }

/* --------------------------------------------------------------------------
   6. Accounts
   -------------------------------------------------------------------------- */
.acc-page { max-width: 820px; margin: 0 auto; padding: 32px 24px 48px; height: 100dvh; overflow-y: auto; }
.acc-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.acc-page-head h1 { font-size: var(--fs-3xl); font-weight: 700; letter-spacing: -.03em; }
.acc-page-head p { color: var(--text-3); margin-top: 4px; }

.acc-summary { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.acc-group + .acc-group { margin-top: 22px; }
.acc-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 0 2px; }
.acc-group-head h3 { font-size: var(--fs-md); font-weight: 600; }
.acc-group-head .n { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.acc-group-head .btn { margin-left: auto; }
.acc-list { border-radius: var(--r-xl); box-shadow: inset 0 0 0 1px var(--line-strong); overflow: hidden; }
.acc-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 12px 14px; cursor: pointer; transition: background var(--t-fast);
}
.acc-row + .acc-row { box-shadow: inset 0 1px 0 var(--line); }
.acc-row:hover { background: var(--hover); }
.acc-row .who { min-width: 0; }
.acc-row .who .top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.acc-row .who b { font-size: var(--fs-base); font-weight: 550; }
.acc-row .who .sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.acc-row .who .sub.is-danger { color: var(--danger); }
.acc-row .tools { display: inline-flex; gap: 2px; opacity: 0; transition: opacity var(--t-fast); }
.acc-row:hover .tools, .acc-row:focus-within .tools { opacity: 1; }
.acc-row .tools .icon-btn { width: 26px; height: 26px; border-radius: 7px; }
.acc-row .tools .icon-btn i { font-size: 13px; }
.acc-row .tools .share-n { font-size: 10.5px; font-weight: 650; margin-left: 2px; }
.acc-row .right { display: flex; align-items: center; gap: 10px; }
.acc-row .chev { color: var(--text-4); font-size: 12px; transition: transform var(--t-fast); }
.acc-row:hover .chev { transform: translateX(2px); color: var(--text-3); }
.acc-row .avatar { --ring: var(--raised); }
.acc-rename { height: 30px; font-size: var(--fs-md); max-width: 280px; }
.acc-skel { display: grid; gap: 10px; }
.acc-skel .skeleton { height: 58px; border-radius: var(--r-lg); }

.pf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pf-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px; text-align: left;
  padding: 16px; border-radius: var(--r-xl); background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: box-shadow var(--t-base), transform var(--t-base) var(--ease-out), background var(--t-fast);
}
:root[data-theme="dark"] .pf-card { background: var(--surface-2); }
.pf-card:hover { box-shadow: inset 0 0 0 1.5px var(--pf), 0 8px 24px -12px color-mix(in srgb, var(--pf) 60%, transparent); transform: translateY(-1px); }
.pf-card div > b { display: block; font-size: var(--fs-base); font-weight: 600; }
.pf-card div > span { display: block; font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.pf-card.is-selected { box-shadow: inset 0 0 0 1.5px var(--pf); background: color-mix(in srgb, var(--pf) 7%, var(--surface)); }
.pf-card:disabled { opacity: .5; transform: none; }

/* Account details / wizard ---------------------------------------------- */
.wiz { display: flex; flex-direction: column; gap: 22px; }
.wiz-hero { display: flex; align-items: center; gap: 14px; }
.wiz-hero .t { flex: 1; min-width: 0; }
.wiz-hero .t b { display: block; font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.015em; }
.wiz-hero .t span { display: block; font-size: var(--fs-md); color: var(--text-3); }
.stepper { display: flex; align-items: center; gap: 10px; }
.step { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 550; color: var(--text-4); flex: none; }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 650; box-shadow: inset 0 0 0 1.5px var(--line-strong); transition: all var(--t-base) var(--ease-out); }
.step.is-current { color: var(--text); }
.step.is-current .n { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 4px var(--accent-soft); }
.step.is-done { color: var(--text-2); }
.step.is-done .n { background: var(--accent-soft); color: var(--accent-text); box-shadow: none; }
.step-line { flex: 1; height: 2px; border-radius: 2px; background: var(--line-strong); overflow: hidden; min-width: 16px; }
.step-line i { display: block; height: 100%; width: 0; background: var(--accent); transition: width var(--t-slow) var(--ease-out); }
.step-line.is-done i { width: 100%; }
.section { display: flex; flex-direction: column; gap: 14px; }
.section-title { font-size: var(--fs-2xs); font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.grid-port { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 12px; }
.auth-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center;
  min-height: 280px; padding: 28px 20px; border-radius: var(--r-xl);
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.auth-stage p { font-size: var(--fs-md); color: var(--text-3); }
.auth-stage .err { color: var(--danger); font-size: var(--fs-md); max-width: 420px; }
.qr-frame { padding: 14px; border-radius: 18px; background: #fff; box-shadow: var(--shadow-2); }
.qr-frame img { width: 220px; height: auto; border-radius: 6px; }
.device-code { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 18px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.device-code span { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: .14em; color: var(--text); }
.waiting { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-md); color: var(--text-3); }
.code-entry { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.code-entry .input-lg { flex: 1; }
.wiz-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.wiz-actions .end { display: flex; gap: 8px; margin-left: auto; }
.shake { animation: shake 360ms var(--ease-in-out); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* --------------------------------------------------------------------------
   7. Auth pages
   -------------------------------------------------------------------------- */
.auth {
  position: fixed; inset: 0; overflow-y: auto;
  display: grid; place-items: center; padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    radial-gradient(700px 420px at 110% 110%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
    var(--bg);
}
.auth::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 30%, transparent 75%);
}
.auth-card {
  position: relative; width: 100%; max-width: 410px; padding: 32px 30px 28px;
  background: var(--raised); border-radius: 22px; box-shadow: var(--shadow-3);
  animation: modal-in 400ms var(--ease-out) both;
}
.auth-card .brand { margin-bottom: 28px; }
.auth-card h1 { font-size: 24px; font-weight: 700; letter-spacing: -.03em; }
.auth-card .lede { color: var(--text-3); font-size: var(--fs-md); margin: 6px 0 24px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn-primary { margin-top: 6px; }
.auth-foot { margin-top: 18px; text-align: center; font-size: var(--fs-sm); color: var(--text-3); }
.auth-theme { position: fixed; top: 16px; right: 16px; z-index: 2; }
.strength { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.strength i { display: block; height: 100%; border-radius: 4px; transition: width var(--t-slow) var(--ease-out), background var(--t-base); }

/* --------------------------------------------------------------------------
   8. Mobile list menu
   -------------------------------------------------------------------------- */
.mobile-menu { position: relative; }
.mobile-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: calc(var(--z-menu) + 1); --origin: top right; width: 230px; }

/* --------------------------------------------------------------------------
   8b. Chat — grouping, replies, hover actions, composer tools
   -------------------------------------------------------------------------- */

/* Floating day pill (Telegram-style): sticks to the top while that day scrolls by */
.nx-date-sep { position: sticky; top: 8px; z-index: 3; justify-content: center; margin: 12px 0 6px; pointer-events: none; letter-spacing: .02em; text-transform: none; font-size: var(--fs-xs); }
.nx-date-sep::before, .nx-date-sep::after { display: none; }
.nx-date-sep span {
  padding: 4px 11px; border-radius: var(--r-full); color: var(--text-2); font-weight: 600;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow-1); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* Grouped runs: tight spacing, tail only on the last bubble */
.nx-bubble-wrap { position: relative; }
.nx-bubble-wrap.g-cont { margin-top: -7px; animation: none; }
.nx-bubble.them.g-cont { border-top-left-radius: 6px; }
.nx-bubble.me.g-cont { border-top-right-radius: 6px; }
.nx-bubble.them:not(.g-last) { border-bottom-left-radius: 6px; }
.nx-bubble.me:not(.g-last) { border-bottom-right-radius: 6px; }

/* Reply quote inside a bubble */
.reply-quote {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-width: 120px;
  margin: 1px -3px 6px; padding: 5px 10px 6px; border-radius: 9px; text-align: left; position: relative; overflow: hidden;
  background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: var(--fs-sm); line-height: 1.35;
  transition: background var(--t-fast);
}
.reply-quote::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.reply-quote b { color: var(--accent-text); font-weight: 650; max-width: 100%; }
.reply-quote span { color: inherit; opacity: .8; max-width: 100%; }
.reply-quote:hover { background: color-mix(in srgb, var(--accent) 17%, transparent); }
.nx-bubble.me .reply-quote { background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* Flash when jumping to a quoted message */
.nx-bubble-wrap.is-flash .nx-bubble { animation: flash 1.6s var(--ease-out); }
@keyframes flash { 0%, 35% { box-shadow: 0 0 0 3px var(--accent), 0 0 0 9px var(--accent-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* Hover actions beside a bubble */
.msg-actions {
  position: absolute; top: 50%; transform: translateY(-50%) scale(.92); z-index: 4;
  display: flex; gap: 1px; padding: 3px; border-radius: 11px;
  background: var(--raised); box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast), transform var(--t-base) var(--ease-out);
}
.nx-bubble-wrap.them .msg-actions { left: calc(100% + 8px); }
.nx-bubble-wrap.me .msg-actions { right: calc(100% + 8px); }
.nx-bubble-wrap.html-email .msg-actions { top: 18px; right: 18px; left: auto; transform: scale(.92); }
.nx-bubble-wrap:hover .msg-actions, .msg-actions:focus-within { opacity: 1; pointer-events: auto; transform: translateY(-50%); }
.nx-bubble-wrap.html-email:hover .msg-actions { transform: none; }
.msg-actions button { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: var(--text-3); font-size: 14px; transition: background var(--t-fast), color var(--t-fast); }
.msg-actions button:hover { background: var(--hover); color: var(--text); }
.msg-actions .is-ok { color: var(--ok); }

/* Photo opens in the lightbox */
.media-photo { display: block; border-radius: 12px; overflow: hidden; cursor: zoom-in; }
.media-photo img { transition: transform var(--t-slow) var(--ease-out); }
.media-photo:hover img { transform: scale(1.02); }
.lightbox {
  position: fixed; inset: 0; z-index: var(--z-modal); display: grid; place-items: center; padding: 40px;
  background: rgba(6, 7, 9, .86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade-in 180ms both; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: modal-in 260ms var(--ease-out) both; cursor: default; }
.lightbox-bar { position: absolute; top: 14px; right: 14px; display: flex; gap: 4px; }
.lightbox-bar .icon-btn { color: #e6e7ea; background: rgba(255,255,255,.08); }
.lightbox-bar .icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; }

/* Jump to latest */
.convo-body { position: relative; }
.jump-bottom {
  position: absolute; right: 24px; bottom: 112px; z-index: 6;
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--raised); color: var(--text-2); box-shadow: var(--shadow-2); font-size: 18px;
  opacity: 0; transform: translateY(10px) scale(.9); pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base) var(--ease-spring), color var(--t-fast);
}
.jump-bottom:hover { color: var(--text); }
.jump-bottom .count { position: absolute; top: -6px; right: -4px; }
.convo-body[data-away] .jump-bottom { opacity: 1; transform: none; pointer-events: auto; }

/* Reply bar target and drafts */
.reply-target { display: block; text-align: left; min-width: 0; border-radius: 6px; }
.reply-target:hover .quote { color: var(--text); }
.draft-tag { color: var(--danger); font-weight: 600; margin-right: 4px; }

/* Formatting bar + emoji */
.format-bar {
  display: flex; align-items: center; gap: 2px; margin-bottom: 8px; padding: 4px;
  border-radius: var(--r-lg); background: var(--surface-2); animation: fade-up 180ms var(--ease-out) both;
}
.format-bar button { width: 32px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); font-size: 16px; }
.format-bar button:hover { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.format-note { font-size: var(--fs-2xs); color: var(--text-4); padding-right: 8px; }
.emoji-wrap { position: relative; flex: none; }
.emoji-panel {
  position: absolute; bottom: calc(100% + 10px); left: -6px; z-index: calc(var(--z-menu) + 1); --origin: bottom left;
  display: grid; grid-template-columns: repeat(6, 36px); gap: 2px; min-width: 0; padding: 8px;
}
.emoji-panel button { width: 36px; height: 36px; border-radius: 9px; font-size: 20px; line-height: 1; display: grid; place-items: center; transition: background var(--t-fast), transform var(--t-fast) var(--ease-spring); }
.emoji-panel button:hover { background: var(--hover); transform: scale(1.15); }

/* --------------------------------------------------------------------------
   9. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) { :root { --list-w: 330px; } }
@media (max-width: 960px) {
  :root { --list-w: 300px; --rail-w: 58px; }
  :root { --thread-pad: 18px; --composer-pad: 12px; }
  .nx-messages-inner { padding-bottom: 22px; }
  .convo-head { padding-left: 14px; }
  .composer { padding: 8px 12px 12px; }
  .composer-hint { display: none; }
  .assign-select { max-width: 130px; }
}
@media (max-width: 767px) {
  .app, .app.has-dock { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .only-mobile { display: revert !important; }
  .hide-mobile { display: none !important; }
  .listpane-head { padding: 14px 12px 8px; }
  .listpane-body { padding: 2px 6px 24px; }
  .convo {
    position: fixed; inset: 0; z-index: 30; margin: 0; border-radius: 0; box-shadow: none;
    transform: translateX(100%); visibility: hidden;
    transition: transform var(--t-slow) var(--ease-out), visibility 0s linear var(--t-slow);
  }
  .convo.is-open { transform: none; visibility: visible; transition: transform var(--t-slow) var(--ease-out); }
  .convo-head { min-height: 58px; padding: 8px 10px; gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .convo-actions .vsep, .convo-actions .hide-sm { display: none; }
  .nx-bubble-wrap, .nx-bubble-wrap.me.im-me { max-width: 88%; }
  .nx-bubble-wrap.me { max-width: 92%; }
  .msg-actions { display: none; }
  .thread-resizer { display: none; }          /* phones: the conversation always fills the screen */
  .nx-messages-inner, .composer-inner { max-width: none; margin-left: auto; margin-right: auto; }
  .jump-bottom { right: 14px; bottom: 96px; }
  .format-note { display: none; }
  .composer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-root { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 20px 20px 0 0; animation: sheet-in 320ms var(--ease-out) both; }
  @keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
  .modal-head { padding: 16px 16px 12px 20px; }
  .modal-body { padding: 16px 16px 24px; }
  .modal-foot { padding: 10px 16px max(10px, env(safe-area-inset-bottom)); }
  .pf-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .ai-panel, .ai-root.is-full .ai-panel { inset: 0; width: 100%; border-radius: 0; transform: none; animation: sheet-in 300ms var(--ease-out) both; }
  .ai-quick { grid-template-columns: 1fr; }
  .toasts { right: 16px; left: 16px; width: auto; bottom: 16px; }
  .acc-row .tools { opacity: 1; }
  .nx-flag-btn:not(.flagged) { display: none; }
  .acc-page { padding: 20px 16px 40px; }
  .stepper .step .lbl { display: none; }
}

@media (hover: none) {
  .acc-row .tools { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* --------------------------------------------------------------------------
   10. Composer images and saved replies
   -------------------------------------------------------------------------- */
/* The conversation composer stacks its images above the text row (the AI panel keeps its one-row composer). */
.composer-stack { flex-direction: column; align-items: stretch; gap: 0; }
.composer-row { display: flex; align-items: flex-end; gap: 6px; min-width: 0; }
/* The box shows focus (its ring); no second outline on the text inside it. */
.composer-box textarea:focus-visible { outline: none; }

.attach-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 6px; }
.attach-chip {
  position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 280px;
  height: 52px; padding: 5px 32px 5px 5px; border-radius: 12px;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  animation: chip-in 240ms var(--ease-spring) both;
}
@keyframes chip-in { from { opacity: 0; transform: scale(.92) translateY(2px); } to { opacity: 1; transform: none; } }
.attach-thumb { position: relative; flex: none; width: 42px; height: 42px; border-radius: 8px; overflow: hidden; background: var(--surface-3); cursor: zoom-in; }
.attach-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.attach-thumb:disabled { cursor: default; }
.attach-busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(12, 14, 18, .38); color: #fff; }
.attach-busy .spinner { --size: 16px; }
.attach-busy.is-error { background: color-mix(in srgb, var(--danger) 72%, transparent); font-size: 15px; }
.attach-meta { display: grid; gap: 2px; min-width: 0; }
.attach-meta b { font-size: var(--fs-sm); font-weight: 600; color: var(--text); line-height: 1.2; }
.attach-meta span { font-size: var(--fs-2xs); color: var(--text-3); font-variant-numeric: tabular-nums; line-height: 1.2; }
.attach-x {
  position: absolute; top: 50%; right: 5px; translate: 0 -50%;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px;
  color: var(--text-3); font-size: 11px; transition: background var(--t-fast), color var(--t-fast);
}
.attach-x:hover { background: var(--press); color: var(--text); }
.attach-chip.is-uploading .attach-meta span { color: var(--accent-text); }
.attach-chip.is-error { background: var(--danger-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 40%, transparent); }
.attach-chip.is-error .attach-meta span { color: var(--danger); }

/* Drag images over the conversation */
.drop-overlay {
  position: absolute; inset: 10px; z-index: 35; display: grid; place-items: center; pointer-events: none;
  border-radius: var(--r-2xl); border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transform: scale(.985);
  transition: opacity 160ms var(--ease-out), transform 240ms var(--ease-out), visibility 0s linear 160ms;
}
.convo-body[data-dropping] > .drop-overlay { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.drop-card { display: grid; justify-items: center; gap: 4px; padding: 24px; text-align: center; }
.drop-icon {
  display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 10px; border-radius: 16px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 24px;
  transform: translateY(4px); transition: transform 320ms var(--ease-spring);
}
.convo-body[data-dropping] .drop-icon { transform: none; }
.drop-card b { font-size: var(--fs-lg); font-weight: 650; letter-spacing: -.01em; color: var(--text); }
.drop-card > span:last-child { font-size: var(--fs-sm); color: var(--text-3); }

/* Saved replies: the button under the message box and its popover */
.composer-hint { align-items: center; }
/* The popover anchors to the composer column, so it opens above the whole composer, left edges aligned. */
.composer-inner { position: relative; }
.snip-wrap { display: flex; }
.snip-trigger {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; margin-left: -6px; padding: 0 8px 0 6px;
  border-radius: 7px; font-size: var(--fs-xs); font-weight: 550; color: var(--text-3);
  transition: background var(--t-fast), color var(--t-fast);
}
.snip-trigger i { font-size: 13px; }
.snip-trigger:hover { background: var(--hover); color: var(--text); }
.snip-trigger.is-on { background: var(--accent-soft); color: var(--accent-text); }
.snip-count {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-3); font-size: 10px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.snip-trigger.is-on .snip-count { background: var(--accent-soft-2); color: var(--accent-text); }

.snip-pop {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: calc(var(--z-menu) + 1); --origin: bottom left;
  display: flex; flex-direction: column; width: min(400px, calc(100vw - 32px)); min-width: 0; padding: 0; overflow: hidden;
}
.snip-search { display: flex; align-items: center; gap: 9px; height: 46px; padding: 0 12px 0 14px; border-bottom: 1px solid var(--line); }
.snip-search > i { color: var(--text-4); font-size: 13px; }
.snip-search input { flex: 1; min-width: 0; border: 0; background: transparent; font-size: var(--fs-md); color: var(--text); outline: none; }
.snip-search input::placeholder { color: var(--text-4); }
.snip-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; max-height: 316px; overflow-y: auto; padding: 5px; overscroll-behavior: contain; }
.snip-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 10px;
  border-radius: var(--r-sm); text-align: left; transition: background var(--t-fast);
}
.snip-item.is-active { background: var(--accent-soft); }
.snip-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.snip-text b { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.snip-text b mark { background: var(--accent-soft-2); color: inherit; border-radius: 3px; padding: 0 1px; margin: 0 -1px; }
.snip-text > span { font-size: var(--fs-xs); color: var(--text-3); }
.snip-text > span.is-muted { color: var(--text-4); }
.snip-item.is-active .snip-text b { color: var(--accent-text); }
.snip-thumbs { display: flex; align-items: center; flex: none; }
.snip-thumbs > img, .snip-more {
  width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: var(--surface-3);
  box-shadow: 0 0 0 2px var(--raised);
}
.snip-thumbs > * + * { margin-left: -12px; }
.snip-more { display: grid; place-items: center; font-size: 10.5px; font-weight: 650; color: var(--text-2); }
.snip-foot { display: flex; align-items: center; gap: 2px; padding: 6px 6px 6px 14px; border-top: 1px solid var(--line); }
.snip-keys { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-2xs); color: var(--text-4); white-space: nowrap; }
.snip-keys .kbd:nth-child(3) { margin-left: 6px; }
.snip-none { padding: 22px 12px; text-align: center; font-size: var(--fs-sm); color: var(--text-3); }
.snip-skel { display: grid; gap: 7px; padding: 12px 10px; }
.snip-skel span { height: 10px; }
.snip-skel span:first-child { width: 38%; height: 12px; }
.snip-skel span:last-child { width: 72%; }
.snip-empty { display: grid; justify-items: center; gap: 6px; padding: 28px 26px 22px; text-align: center; }
.snip-empty-art {
  display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 6px; border-radius: 14px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 20px;
}
.snip-empty b { font-size: var(--fs-base); font-weight: 650; color: var(--text); }
.snip-empty p { max-width: 310px; font-size: var(--fs-sm); line-height: 1.5; color: var(--text-3); }
.snip-empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }

/* Saved replies dialog (builds on the AI knowledge layout) */
.modal.sn { width: min(960px, 100%); height: min(680px, calc(100dvh - 48px)); }
.sn-body { grid-template-columns: 320px 1fr; }
.sn-items { gap: 1px; grid-template-columns: minmax(0, 1fr); }
.sn-item {
  position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; padding: 9px 10px 9px 6px;
  border-radius: var(--r-md); cursor: pointer; transition: background var(--t-fast), opacity var(--t-fast);
}
.sn-item:hover { background: var(--hover); }
.sn-item.is-active { background: var(--accent-soft); }
.sn-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.sn-item.is-dragging { opacity: .4; }
.sn-item.drop-before::before, .sn-item.drop-after::after {
  content: ""; position: absolute; left: 6px; right: 6px; height: 2px; border-radius: 2px; background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.sn-item.drop-before::before { top: -2px; }
.sn-item.drop-after::after { bottom: -2px; }
.sn-grip {
  flex: none; align-self: stretch; width: 10px; margin: 2px 0; border-radius: 3px; cursor: grab; opacity: 0;
  background-image: radial-gradient(circle, var(--text-4) 1.1px, transparent 1.4px);
  background-size: 5px 5px; background-position: center; transition: opacity var(--t-fast);
}
.sn-item:hover .sn-grip, .sn-item:focus-visible .sn-grip, .sn-item.is-active .sn-grip { opacity: 1; }
.sn-item-text { display: grid; gap: 2px; flex: 1; min-width: 0; }
.sn-item-text b { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.sn-item-text .kn-snip { -webkit-line-clamp: 1; }
.sn-item-img { position: relative; flex: none; width: 36px; height: 36px; }
.sn-item-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; background: var(--surface-3); }
.sn-item-img span {
  position: absolute; right: -5px; bottom: -5px; display: grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 999px; background: var(--text); color: var(--bg); font-size: 9.5px; font-weight: 700; box-shadow: 0 0 0 2px var(--surface);
}
.sn-tip { border-top: 1px solid var(--line); padding: 10px 14px 12px; font-size: var(--fs-2xs); line-height: 1.6; color: var(--text-4); }
.sn-tip i { margin-right: 3px; color: var(--text-3); }
.sn-tip .kbd { height: 16px; min-width: 16px; font-size: 10px; }
.sn-editor { overflow-y: auto; }
.sn-editor .kn-field.grow .textarea { min-height: 120px; }
.sn-images-field { gap: 8px; }
.sn-images {
  position: relative; display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; padding: 10px;
  border-radius: var(--r-lg); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.sn-img { position: relative; display: grid; gap: 6px; min-width: 0; margin: 0; animation: chip-in 240ms var(--ease-spring) both; }
.sn-img > img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-1); }
.sn-img figcaption { font-size: var(--fs-2xs); font-weight: 500; color: var(--text-3); }
.sn-img-busy { position: absolute; left: 0; right: 0; top: 0; aspect-ratio: 1; display: grid; place-items: center; border-radius: 10px; background: rgba(12, 14, 18, .38); color: #fff; }
.sn-img-x {
  position: absolute; top: 6px; right: 6px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: rgba(12, 14, 18, .62); color: #fff; font-size: 11px; opacity: 0;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transition: opacity var(--t-fast), background var(--t-fast);
}
.sn-img:hover .sn-img-x, .sn-img-x:focus-visible { opacity: 1; }
.sn-img-x:hover { background: var(--danger); }
.sn-add {
  align-self: start; display: grid; place-content: center; justify-items: center; gap: 2px; aspect-ratio: 1; padding: 8px;
  border-radius: 10px; border: 1.5px dashed var(--line-strong); color: var(--text-3); text-align: center;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.sn-add i { margin-bottom: 6px; font-size: 20px; color: var(--accent-text); }
.sn-add b { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.sn-add span { font-size: var(--fs-2xs); color: var(--text-4); }
.sn-add:hover { border-color: var(--accent); background: var(--accent-soft); }
.sn-images .drop-veil {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; pointer-events: none;
  border-radius: inherit; border: 1.5px dashed var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  color: var(--accent-text); font-size: var(--fs-md); font-weight: 600; opacity: 0; transition: opacity 140ms var(--ease-out);
}
.sn-images[data-dropping] .drop-veil { opacity: 1; }

/* Saved Messages: pinned above the conversation list ------------------------------------------- */
.saved-row { margin-bottom: 7px; }
.saved-row::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -4px; height: 1px; background: var(--line); }
.saved-avatar {
  position: relative; flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(150deg, color-mix(in srgb, var(--pf, var(--accent)) 78%, #fff), var(--pf, var(--accent)));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.saved-avatar-md { width: 36px; height: 36px; }
/* A bookmark ribbon, drawn (the icon font has no bookmark). */
.saved-mark { width: 13px; height: 17px; background: #fff; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%); border-radius: 2px 2px 0 0; }
.saved-acc { color: var(--text-2); font-weight: 500; }
.saved-switch {
  display: inline-flex; align-items: center; gap: 3px; height: 20px; padding: 0 6px 0 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-3); font-size: 10.5px; font-weight: 650; font-variant-numeric: tabular-nums;
  transition: background var(--t-fast), color var(--t-fast);
}
.saved-switch i { font-size: 9px; transition: transform var(--t-base) var(--ease-out); }
.saved-switch:hover { background: var(--press); color: var(--text); }
.saved-switch.is-on { background: var(--accent-soft-2); color: var(--accent-text); }
.saved-switch.is-on i { transform: rotate(180deg); }
.saved-menu { position: absolute; left: 6px; right: 6px; top: calc(100% + 2px); z-index: calc(var(--z-menu) + 1); min-width: 0; --origin: top center; }
.saved-item { height: auto; min-height: 46px; padding: 6px 10px 6px 8px; }
.saved-item .pf-tile { width: 30px; height: 30px; }
.saved-item .pf-tile i { width: auto; color: inherit; font-size: 15px; }
.saved-item-text { display: grid; gap: 1px; flex: 1; min-width: 0; }
.saved-item-text b { font-size: var(--fs-md); font-weight: 600; color: var(--text); }
.saved-item-text span { font-size: var(--fs-xs); color: var(--text-3); }
.saved-item.is-active .saved-item-text b { color: var(--accent-text); }
.menu-item i.saved-check { color: var(--accent-text); width: auto; }

@media (hover: none) { .sn-img-x, .sn-grip { opacity: 1; } }
@media (max-width: 960px) {
  /* The keyboard hints go; the saved replies button stays. */
  .composer-hint { display: flex; padding-top: 4px; }
  .composer-hint > span:not(.grow) { display: none; }
}
@media (max-width: 600px) {
  /* Phones: the text gets the full width, the tools sit under it with Send on the right. */
  .composer-row { flex-wrap: wrap; row-gap: 2px; }
  .composer-row textarea { order: -1; flex-basis: 100%; padding: 6px 6px 4px; }
  .composer-row .send-btn { margin-left: auto; }
}
@media (max-width: 767px) {
  .snip-pop { position: fixed; left: 8px; right: 8px; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 84px); width: auto; }
  .snip-keys { display: none; }
  .attach-chip { max-width: 100%; }
  .sn-body { grid-template-columns: 1fr; }
}
