/*
 * Elgrace Team, in the Elgrace app family look (Client V12 is the reference:
 * velora-unified-app/shared/visual-reference-v12.css, navigation-v12.css, versions/v12/src/navigation-islands.css).
 *   - Inter (bundled in /fonts), headings weight 550 with tight tracking, pill buttons, 20px calm cards;
 *   - the measured V12 palette, light and dark;
 *   - two purple glass islands: navigation (top left, a menu) and views (bottom centre, a tab bar). Both open and
 *     close only by hand; no timers, no scrim;
 *   - the italic "eg" mark.
 * Laptop (>= 760px): header with the island, then the full screen. Phone: one pane at a time, chat full screen.
 */

/* ------------------------------------------------------------------ font */
@font-face {
  font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20B9, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ------------------------------------------------------------------ tokens (V12 measured palette) */
:root {
  color-scheme: light;
  --font: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --font-mark: Georgia, "Times New Roman", serif;

  --page: #f8f7fa;
  --surface: #ffffff;
  --raised: #ffffff;
  --soft: #faf7fd;
  --ink: #2d2936;
  --ink-2: #4a4453;
  --muted: #666170;
  --faint: #8f889a;
  --accent: #756082;
  --line: #e8e3ed;
  --line-2: #ded3e6;
  --lavender: #e5dff4;
  --hover: #f4eff9;
  --primary: #29272f;
  --on-primary: #ffffff;
  --primary-hover: #47404e;
  --card-shadow: 0 7px 30px rgba(78, 45, 102, .027);
  --shadow-1: 0 1px 2px rgba(51, 36, 64, .05);
  --shadow-2: 0 8px 28px rgba(51, 36, 64, .08), 0 1px 3px rgba(51, 36, 64, .05);
  --shadow-3: 0 22px 60px rgba(38, 22, 56, .18), 0 2px 8px rgba(38, 22, 56, .08);
  --focus: #8a6fa0;

  --mine: #e5dff4;
  --theirs: #ffffff;
  --chat-bg: #f8f7fa;
  --sys-bg: rgba(255, 255, 255, .86);

  --green: #35745d;  --green-soft: #e3f1ea;
  --amber: #8f5a12;  --amber-soft: #fbefdc; --amber-line: #efd6ad;
  --red: #a34144;    --red-soft: #fbe8ea;   --red-line: #f0c6cb;
  --blue: #3f5e96;   --blue-soft: #e8eef9;
  --danger-bg: #a34144; --danger-hover: #8c3538; --danger-ink: #ffffff;

  /* the glass islands (V9/V12 material) */
  --glass: rgba(109, 91, 124, .94);
  --glass-solid: #756583;
  --glass-ink: #ffffff;
  --glass-border: rgba(255, 255, 255, .45);
  --glass-shadow: 0 7px 28px #33244022, 0 0 0 4px #b1a5bd38;
  --glass-on: #ffffff1c;
  --glass-on-line: #ffffff30;
  --glass-hover: #ffffff12;

  --menu-bg: rgba(255, 255, 255, .94);
  --head-glass: rgba(248, 247, 250, .84);
  --ring: #b3a9c1;
  --switch-on: #756082;
  --ai-ring: #cdbde0;

  --av0-bg: #ece5f5; --av0-ink: #6a5480;
  --av1-bg: #f5e4ec; --av1-ink: #8a4262;
  --av2-bg: #e3ecf5; --av2-ink: #3c5f80;
  --av3-bg: #e4f0e8; --av3-ink: #3a6a50;
  --av4-bg: #f5ebdd; --av4-ink: #7b5528;
  --av5-bg: #e9e6ef; --av5-ink: #544d63;

  --r-m: 14px; --r-l: 20px; --r-pill: 999px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --morph: 240ms cubic-bezier(.22, 1, .36, 1);

  --head-h: 64px;
  --list-w: 348px;
  --chat-head-h: 62px;
  --chat-fs: 15px;
  --chat-gutter: clamp(14px, 4.5%, 64px);
  --ctx-space: 0px;
}

/* Dark: same tokens, twice (system preference unless forced light, or forced dark). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #15131c; --surface: #211d2b; --raised: #2b2436; --soft: #26202f;
    --ink: #f1eaf8; --ink-2: #d9d0e4; --muted: #bfb7cc; --faint: #8e8599;
    --accent: #d2b3ed; --line: #43364f; --line-2: #695277; --lavender: #3b2b4a; --hover: #392b46;
    --primary: #d1b0ec; --on-primary: #24142f; --primary-hover: #e1c6f7;
    --card-shadow: 0 7px 30px #0002; --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 8px 26px rgba(0, 0, 0, .34); --shadow-3: 0 24px 64px rgba(0, 0, 0, .55);
    --focus: #d2b3ed;
    --mine: #3b2b4a; --theirs: #211d2b; --chat-bg: #15131c; --sys-bg: rgba(33, 29, 43, .9);
    --green: #91d6b3; --green-soft: #1d3329; --amber: #f0c07f; --amber-soft: #382a16; --amber-line: #5c4423;
    --red: #ffacb4; --red-soft: #3d2029; --red-line: #6a3441; --blue: #aec4f3; --blue-soft: #1f2940;
    --danger-bg: #ffacb4; --danger-hover: #ffc3c9; --danger-ink: #3a1017;
    --glass: rgba(53, 43, 66, .94); --glass-solid: #352b42; --glass-ink: #f6efff; --glass-border: rgba(237, 220, 255, .2);
    --glass-shadow: 0 7px 28px #0003, 0 0 0 4px #b1a5bd16;
    --menu-bg: rgba(43, 36, 54, .96); --head-glass: rgba(21, 19, 28, .84);
    --ring: #6d6179; --switch-on: #b893d8; --ai-ring: #6c5689;
    --av0-bg: #3b2d4c; --av0-ink: #dccbf3; --av1-bg: #472a3a; --av1-ink: #f4c8d8; --av2-bg: #233648; --av2-ink: #bcd8ef;
    --av3-bg: #213a2d; --av3-ink: #b6e3c8; --av4-bg: #42321f; --av4-ink: #efd2ab; --av5-bg: #312d3c; --av5-ink: #d8d2e4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #15131c; --surface: #211d2b; --raised: #2b2436; --soft: #26202f;
  --ink: #f1eaf8; --ink-2: #d9d0e4; --muted: #bfb7cc; --faint: #8e8599;
  --accent: #d2b3ed; --line: #43364f; --line-2: #695277; --lavender: #3b2b4a; --hover: #392b46;
  --primary: #d1b0ec; --on-primary: #24142f; --primary-hover: #e1c6f7;
  --card-shadow: 0 7px 30px #0002; --shadow-1: 0 1px 2px rgba(0, 0, 0, .3); --shadow-2: 0 8px 26px rgba(0, 0, 0, .34); --shadow-3: 0 24px 64px rgba(0, 0, 0, .55);
  --focus: #d2b3ed;
  --mine: #3b2b4a; --theirs: #211d2b; --chat-bg: #15131c; --sys-bg: rgba(33, 29, 43, .9);
  --green: #91d6b3; --green-soft: #1d3329; --amber: #f0c07f; --amber-soft: #382a16; --amber-line: #5c4423;
  --red: #ffacb4; --red-soft: #3d2029; --red-line: #6a3441; --blue: #aec4f3; --blue-soft: #1f2940;
  --danger-bg: #ffacb4; --danger-hover: #ffc3c9; --danger-ink: #3a1017;
  --glass: rgba(53, 43, 66, .94); --glass-solid: #352b42; --glass-ink: #f6efff; --glass-border: rgba(237, 220, 255, .2);
  --glass-shadow: 0 7px 28px #0003, 0 0 0 4px #b1a5bd16;
  --menu-bg: rgba(43, 36, 54, .96); --head-glass: rgba(21, 19, 28, .84);
  --ring: #6d6179; --switch-on: #b893d8; --ai-ring: #6c5689;
  --av0-bg: #3b2d4c; --av0-ink: #dccbf3; --av1-bg: #472a3a; --av1-ink: #f4c8d8; --av2-bg: #233648; --av2-ink: #bcd8ef;
  --av3-bg: #213a2d; --av3-ink: #b6e3c8; --av4-bg: #42321f; --av4-ink: #efd2ab; --av5-bg: #312d3c; --av5-ink: #d8d2e4;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--page); }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--page);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
  font-feature-settings: normal; letter-spacing: normal; overflow: hidden; overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; font-feature-settings: normal; }
button { cursor: pointer; background: none; border: 0; padding: 0; margin: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: var(--accent); -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
h1 { font-weight: 550; letter-spacing: -.045em; }
::selection { background: var(--lavender); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin: 0 -2px 0 6px; cursor: pointer; opacity: .75;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f889a' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M7 7l10 10M17 7 7 17'/%3E%3C/svg%3E") center / 16px no-repeat;
}
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.scroller, .msgs, .sheet-inner, .menu, .mention-pop, textarea { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 18%, transparent) transparent; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; }

/* the "eg" mark (Operations and Client V12 use the same italic serif monogram) */
.brand-mark, .eg-mark {
  display: inline-block; font-family: var(--font-mark); font-style: italic; font-weight: 400; color: var(--ink);
  line-height: 1; transform: rotate(-8deg); user-select: none; -webkit-user-select: none;
}
.brand-mark { flex: none; width: 42px; min-height: 44px; font-size: 34px; letter-spacing: -8px; padding: 0 10px 6px 0; text-align: left; }
.eg-lg { font-size: 76px; letter-spacing: -17px; padding-right: 17px; }
:root[data-theme="dark"] .brand-mark, :root[data-theme="dark"] .eg-mark { color: var(--ink); }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border-radius: 28px; border: 1px solid transparent; font-size: 14px; font-weight: 550; line-height: 1.3; white-space: nowrap;
  user-select: none; -webkit-user-select: none; position: relative; box-shadow: none;
  transition: background-color .18s var(--ease-soft), border-color .18s, color .18s, transform .16s var(--ease), opacity .18s;
}
.btn .ic { width: 18px; height: 18px; stroke-width: 1.9; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.secondary { background: var(--surface); color: var(--accent); border-color: var(--line-2); }
.btn.secondary:hover:not(:disabled) { background: var(--hover); }
.btn.ghost { color: var(--accent); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { background: var(--danger-bg); color: var(--danger-ink); border-color: var(--danger-bg); }
.btn.danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn.danger-text { color: var(--red); }
.btn.sm { min-height: 38px; padding: 0 15px; font-size: 13.5px; }
.btn.sm .ic { width: 16px; height: 16px; }
.btn.wide { width: 100%; }
.btn.busy { color: transparent !important; pointer-events: none; }
.btn.busy .ic { opacity: 0; }
.btn.busy::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--on-primary); border-color: var(--on-primary) transparent var(--on-primary) transparent; animation: spin .8s linear infinite;
}
.btn.secondary.busy::after, .btn.ghost.busy::after { border-color: var(--accent) transparent var(--accent) transparent; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; color: var(--accent);
  transition: background-color .15s, color .15s, transform .16s var(--ease);
}
.icon-btn:hover { background: var(--lavender); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.sm { width: 34px; height: 34px; }
.icon-btn.sm .ic { width: 18px; height: 18px; }

.field {
  display: block; width: 100%; min-height: 46px; padding: 11px 15px; border-radius: 14px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font-size: 15px; line-height: 1.4; outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.field:focus { border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 15%, transparent); }
textarea.field { resize: none; }
select.field {
  -webkit-appearance: none; appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f889a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6.5 9.5 5.5 5.5 5.5-5.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 18px;
}
select.field option { background: var(--surface); color: var(--ink); }

.search {
  display: flex; align-items: center; gap: 10px; min-width: 0; height: 44px; padding: 0 16px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); transition: border-color .15s, box-shadow .15s;
}
.search .ic { width: 18px; height: 18px; }
.search:focus-within { border-color: var(--line-2); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 10%, transparent); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; font-size: 15px; color: var(--ink); -webkit-appearance: none; appearance: none; }
.search-page { margin: 0 0 18px; }

/* segmented control (sheets, profile menu) */
.seg { display: inline-flex; gap: 4px; padding: 0; }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border-radius: 22px;
  font-size: 14px; font-weight: 400; color: var(--muted); border: 1px solid var(--line); background: var(--surface);
  transition: background-color .2s var(--ease-soft), color .2s, border-color .2s;
}
.seg button .ic { width: 16px; height: 16px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-selected="true"], .seg button[aria-checked="true"] { background: var(--lavender); color: var(--ink); border-color: var(--line-2); font-weight: 550; }
.seg-full { display: flex; width: 100%; }
.seg-full button { flex: 1; }

.pill {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 22px; font-size: 13.5px; font-weight: 500;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); transition: background-color .15s, border-color .15s, color .15s;
}
.pill:hover { background: var(--hover); }
.pill[aria-pressed="true"] { background: var(--lavender); color: var(--ink); border-color: var(--line-2); font-weight: 550; }

.switch {
  -webkit-appearance: none; appearance: none; width: 51px; height: 31px; margin: 0; border-radius: var(--r-pill); flex: none; cursor: pointer;
  background: var(--line-2); position: relative; transition: background-color .22s var(--ease-soft);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .18), 0 0 0 .5px rgba(0, 0, 0, .04); transition: transform .24s var(--ease);
}
.switch:checked { background: var(--switch-on); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .45; cursor: default; }

.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; margin-left: auto;
  font-size: 11.5px; font-weight: 650; line-height: 1; font-style: normal; background: #fff; color: #5c4a6b; font-variant-numeric: tabular-nums;
}
.badge.alert { background: #f2b8c2; color: #5c1a2a; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: var(--r-pill); flex: none;
  font-size: 12px; font-weight: 550; line-height: 1; white-space: nowrap;
}
.chip .ic { width: 13px; height: 13px; stroke-width: 2.1; }
.chip-progress { background: var(--blue-soft); color: var(--blue); }
.chip-blocked { background: var(--red-soft); color: var(--red); }
.chip-reported { background: var(--amber-soft); color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber-line); }
.chip-done { background: var(--green-soft); color: var(--green); }
.chip-cancelled { background: var(--hover); color: var(--muted); }
.chip-soft { background: var(--lavender); color: var(--accent); }
.chip-ai {
  height: 17px; padding: 0 5px; border-radius: 6px; font-size: 10.5px; font-weight: 650; letter-spacing: .03em;
  background: var(--lavender); color: var(--accent); vertical-align: 1px;
}
.count { font-weight: 500; }

/* avatars */
.av {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; position: relative;
  font-size: 15px; font-weight: 550; letter-spacing: .01em; user-select: none; -webkit-user-select: none;
  background: var(--av-bg, var(--av0-bg)); color: var(--av-ink, var(--av0-ink));
}
.av .ic { width: 22px; height: 22px; }
.av.xs { width: 22px; height: 22px; font-size: 9.5px; }
.av.xs .ic { width: 13px; height: 13px; }
.av.sm { width: 34px; height: 34px; font-size: 12px; }
.av.md { width: 40px; height: 40px; font-size: 14px; }
.av.is-ai { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ai-ring); }
.av.xs.is-ai { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 2.5px var(--ai-ring); }
.av.is-group { background: var(--av-bg, var(--lavender)); color: var(--av-ink, var(--accent)); }
.c0 { --av-bg: var(--av0-bg); --av-ink: var(--av0-ink); }
.c1 { --av-bg: var(--av1-bg); --av-ink: var(--av1-ink); }
.c2 { --av-bg: var(--av2-bg); --av-ink: var(--av2-ink); }
.c3 { --av-bg: var(--av3-bg); --av-ink: var(--av3-ink); }
.c4 { --av-bg: var(--av4-bg); --av-ink: var(--av4-ink); }
.c5 { --av-bg: var(--av5-bg); --av-ink: var(--av5-ink); }
.avatar-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; transition: transform .16s var(--ease); }
.avatar-btn:active { transform: scale(.94); }

/* ------------------------------------------------------------------ boot + login */
.boot, .login {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 520px at 50% -12%, color-mix(in srgb, var(--lavender) 70%, transparent), transparent 70%), var(--page);
}
.boot .eg-mark { animation: breathe 1.8s var(--ease-soft) infinite; }
.login-card { width: min(400px, 100%); display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 7vh; animation: rise .5s var(--ease); }
.login-title { margin: 22px 0 8px; font-size: 32px; line-height: 1.1; font-weight: 550; letter-spacing: -.045em; }
.login-lead { font-size: 17px; font-weight: 550; color: var(--ink); }
.login-sub { margin: 6px 0 26px; max-width: 320px; font-size: 14.5px; color: var(--muted); }
.login-lead, .empty-sub, .chat-empty-sub, .msgs-state p { text-wrap: balance; }
.login-form { display: flex; gap: 8px; width: 100%; }
.login-form .field { flex: 1; min-width: 0; border-radius: 24px; padding-left: 18px; }
.login-form.shake { animation: shake .36s var(--ease-soft); }

/* ------------------------------------------------------------------ shell and header */
/* One row per band, pinned to the viewport: a long page scrolls inside its own scroller. */
.shell { display: grid; grid-template-rows: var(--head-h) minmax(0, 1fr); height: 100vh; height: 100dvh; }
:root[data-has-ctx] { --ctx-space: calc(76px + env(safe-area-inset-bottom)); }
:root[data-has-ctx][data-ctx-open] { --ctx-space: calc(126px + env(safe-area-inset-bottom)); }
.app-header {
  position: relative; z-index: 45; display: flex; align-items: center; gap: 16px; min-width: 0; height: var(--head-h);
  padding: 0 20px 0 16px; background: var(--page); border-bottom: 1px solid var(--line);
}
.workspace-name { min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.me-btn .av { box-shadow: none; background: var(--lavender); color: var(--accent); }
.stage { position: relative; min-width: 0; min-height: 0; height: 100%; overflow: hidden; }
.view { height: 100%; }
.view.enter { animation: view-in .26s var(--ease); }

/* ------------------------------------------------------------------ the glass islands */
.island {
  isolation: isolate; overflow: hidden; color: var(--glass-ink); background: var(--glass); border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow); -webkit-backdrop-filter: blur(18px) saturate(115%); backdrop-filter: blur(18px) saturate(115%);
  transition: width var(--morph), height var(--morph), border-radius var(--morph), padding var(--morph);
}
.island-trigger {
  display: flex; align-items: center; justify-content: center; width: 100%; min-width: 0; height: 44px; min-height: 44px; gap: 8px; padding: 0 10px;
  border: 0; border-radius: 22px; background: transparent; color: inherit; font-size: 13px; font-weight: 500; line-height: 1.2; white-space: nowrap; position: relative;
}
.island-trigger .ic { width: 19px; height: 19px; }
.island :is(button, a):focus-visible { outline: 2px solid var(--glass-ink); outline-offset: -4px; }
.island-items { opacity: 1; visibility: visible; transition: opacity 140ms ease; }
.island.is-collapsed .island-items { opacity: 0; visibility: hidden; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .island :is(.island-trigger, .rail-item, .island-footer > button, .island-items > button):hover { background: var(--glass-hover); }
}

/* navigation island: top left, a menu that grows out of the pill */
.nav-slot { position: relative; flex: 0 0 82px; height: 50px; z-index: 50; }
.g-island { position: absolute; left: 0; top: 0; width: 82px; height: 50px; border-radius: 25px; padding: 2px; }
.g-island.is-expanded { width: var(--open-w, 214px); height: var(--open-h, 480px); max-height: calc(100dvh - 20px); border-radius: 27px; padding: 3px; overflow-y: auto; scrollbar-width: none; }
.g-island::-webkit-scrollbar { display: none; }
.g-island.is-collapsed .island-trigger { flex-direction: column; gap: 3px; padding: 3px 4px; }
.island-current { font-size: 10.5px; line-height: 12px; max-width: 74px; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.island-min { display: none; }
.g-island.is-expanded .island-trigger { flex-direction: row; justify-content: flex-start; padding: 0 12px; }
.island-title { display: none; flex: 1; text-align: left; font-size: 13px; font-weight: 550; }
.g-island.is-expanded .island-current { display: none; }
.g-island.is-expanded .island-title { display: block; }
.g-island.is-expanded .island-min { display: block; width: 16px; height: 16px; }
.island-dot {
  position: absolute; top: 3px; right: 3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; font-style: normal; line-height: 1; background: #fff; color: #5c4a6b; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); font-variant-numeric: tabular-nums;
}
.island-dot.alert { background: #f2b8c2; color: #5c1a2a; }
.g-island.is-expanded .island-dot { display: none; }
.g-island .island-items { display: flex; flex-direction: column; width: calc(var(--open-w, 214px) - 8px); padding-bottom: 2px; }
.rail-item {
  display: flex; align-items: center; gap: 11px; min-height: 48px; margin: 2px 0 0; padding: 0 13px; border-radius: 20px; border: 1px solid transparent;
  color: inherit; font-size: 13.5px; line-height: 1.3; white-space: nowrap; text-align: left; transition: background-color .18s;
}
.rail-item .ic { width: 20px; height: 20px; }
.rail-item[aria-current="page"] { background: var(--glass-on); border-color: var(--glass-on-line); font-weight: 600; }
.rail-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.island-footer { border-top: 1px solid var(--glass-border); margin-top: 4px; padding-top: 3px; }
.island-footer > button { display: flex; align-items: center; gap: 10px; min-height: 44px; width: 100%; padding: 0 13px; border-radius: 17px; color: inherit; font-size: 13px; }
.island-footer .ic { width: 18px; height: 18px; }

/* context island: bottom centre, a tab bar that stays open once opened */
.c-island {
  position: fixed; z-index: 44; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: 168px; height: 50px; max-width: calc(100vw - 20px); border-radius: 25px; padding: 2px;
}
.c-island.is-expanded { width: var(--open-w, 190px); height: 100px; border-radius: 27px; padding: 3px 6px 6px; }
.c-island .island-trigger { gap: 7px; }
.c-closed, .c-open { display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 0; }
.c-closed > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.c-island .chev { width: 14px; height: 14px; }
.c-open { display: none; }
.c-island.is-expanded .c-closed { display: none; }
.c-island.is-expanded .c-open { display: flex; }
.c-island.is-expanded .island-trigger { height: 32px; min-height: 32px; padding: 0; }
.island-grip { height: 3px; width: 23px; border-radius: 3px; background: currentColor; opacity: .6; }
.c-island .island-items {
  --gap: 3px; position: relative; display: grid; grid-template-columns: repeat(var(--tabs, 2), minmax(0, 1fr)); gap: var(--gap);
}
.c-island .island-items::before {
  content: ""; position: absolute; inset-block: 0; left: 0; z-index: -1; pointer-events: none;
  width: calc((100% - (var(--tabs, 2) - 1) * var(--gap)) / var(--tabs, 2)); border: 1px solid var(--glass-on-line); border-radius: 18px; background: var(--glass-on);
  transform: translateX(calc(var(--active, 0) * (100% + var(--gap)))); transition: transform var(--morph);
}
.c-island .island-items > button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; height: 56px; min-width: 0; padding: 6px 3px;
  border-radius: 18px; color: inherit; font-size: 12px; line-height: 1.25; text-align: center; white-space: nowrap;
}
.c-island .island-items > button > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.c-island .island-items > button[aria-selected="true"] { font-weight: 600; }
.c-island .island-items .ic { width: 20px; height: 20px; stroke-width: 1.8; }

/* ------------------------------------------------------------------ chats: list + chat, full screen */
.view-chats { padding: 0; }
.chats-panel { height: 100%; display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr); overflow: hidden; }
.threads-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); border-right: 1px solid var(--line); }
.pane-head { display: flex; align-items: center; gap: 6px; padding: 14px 10px 8px 14px; }
.pane-head .search { flex: 1; }
.filters { display: flex; gap: 6px; padding: 2px 14px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 34px; padding: 0 14px; border-radius: 22px;
  font-size: 13.5px; color: var(--muted); border: 1px solid transparent; transition: background-color .15s, color .15s;
}
.filter:hover { color: var(--ink); background: var(--hover); }
.filter[aria-pressed="true"] { background: var(--lavender); color: var(--ink); border-color: var(--line-2); font-weight: 550; }
.filter-n { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 650; background: var(--accent); color: var(--surface); }
.attention { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; flex: none; }
.att {
  display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 10px 0 12px; border-radius: 22px; text-align: left;
  font-size: 13.5px; font-weight: 550; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); transition: background-color .15s;
}
.att:hover { background: var(--hover); }
.att .ic { width: 17px; height: 17px; color: var(--accent); }
.att .att-go { width: 14px; height: 14px; color: var(--faint); margin-left: -2px; }
.att-late { border-color: var(--red-line); background: var(--red-soft); }
.att-late .ic:first-child { color: var(--red); }
.threads { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px 0 18px; }
.list-head { padding: 14px 22px 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }

.thread {
  display: flex; align-items: center; gap: 12px; width: calc(100% - 16px); margin: 0 8px; min-height: 72px; padding: 10px;
  border-radius: 18px; text-align: left; transition: background-color .15s;
}
.thread:hover { background: var(--hover); }
.thread.active { background: var(--lavender); }
.t-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.t-top, .t-bottom { display: flex; align-items: center; gap: 6px; min-width: 0; }
.t-name { min-width: 0; font-size: 15px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-top .chip-ai { flex: none; }
.t-time { margin-left: auto; padding-left: 6px; flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.t-prev { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-prev .draft { color: var(--accent); font-weight: 600; }
.t-unread {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--surface); font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums;
}
.thread.unread .t-time { color: var(--accent); font-weight: 600; }
.thread.unread .t-prev { color: var(--ink-2); }
.thread.unread .t-name { font-weight: 650; }

/* skeletons and states */
.sk { display: block; border-radius: 8px; background: linear-gradient(90deg, var(--hover) 0%, var(--lavender) 45%, var(--hover) 90%); background-size: 220% 100%; animation: shimmer 1.5s linear infinite; }
.sk-row { display: flex; align-items: center; gap: 12px; padding: 13px 18px; }
.sk-av { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.sk-lines { flex: 1; display: grid; gap: 8px; }
.sk-l1 { height: 12px; width: 52%; }
.sk-l2 { height: 11px; width: 80%; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 52px 24px; color: var(--muted); }
.empty-icon { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 8px; background: var(--lavender); color: var(--accent); }
.empty-icon .ic { width: 26px; height: 26px; }
.empty-title { font-size: 17px; font-weight: 550; letter-spacing: -.01em; color: var(--ink); }
.empty-sub { font-size: 14px; max-width: 340px; }
.empty .btn { margin-top: 12px; }

/* chat pane */
.chat-pane { position: relative; min-width: 0; min-height: 0; background: radial-gradient(1100px 620px at 100% 0%, color-mix(in srgb, var(--lavender) 45%, transparent), transparent 62%), var(--chat-bg); }
.chat-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center; }
.chat-empty-icon { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; margin-bottom: 12px; background: var(--lavender); color: var(--accent); }
.chat-empty-icon .ic { width: 26px; height: 26px; }
.chat-empty-title { font-size: 24px; font-weight: 550; letter-spacing: -.04em; }
.chat-empty-sub { font-size: 14px; color: var(--muted); }
.chat-empty .btn { margin-top: 16px; }

.chat { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.chat-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6; height: var(--chat-head-h); display: flex; align-items: center; gap: 4px; padding: 0 14px;
  background: var(--head-glass); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%);
}
.back { display: none; }
.chat-id { display: flex; align-items: center; gap: 11px; min-width: 0; max-width: 100%; min-height: 48px; padding: 4px 10px 4px 4px; border-radius: 16px; text-align: left; transition: background-color .15s; }
.chat-id:hover { background: var(--hover); }
.chat-title { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.chat-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 16px; font-weight: 550; line-height: 1.25; }
.chat-name .cn { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msgs {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none;
  padding: calc(var(--chat-head-h) + 2px) var(--chat-gutter) 12px; scroll-padding-top: calc(var(--chat-head-h) + 8px);
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 12px), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 12px), transparent);
}
.msgs:focus-visible { outline: none; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--focus) 40%, transparent); }
.msgs-top { height: 38px; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
.msgs-list { display: flex; flex-direction: column; }
.msgs-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.day { display: flex; justify-content: center; margin: 14px 0 6px; pointer-events: none; }
.float-day {
  position: absolute; top: calc(var(--chat-head-h) + 8px); left: 50%; z-index: 5; display: flex; pointer-events: none;
  opacity: 0; transform: translate(-50%, -4px); transition: opacity .22s var(--ease-soft), transform .22s var(--ease);
}
.float-day.show { opacity: 1; transform: translate(-50%, 0); }
.day span, .float-day span {
  padding: 5px 12px; border-radius: var(--r-pill); font-size: 12px; font-weight: 550; color: var(--ink-2);
  background: var(--sys-bg); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}

.msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 2px; touch-action: pan-y; position: relative; }
.msg.first { margin-top: 10px; }
.msg.mine { align-items: flex-end; }
.msg:focus-visible { outline: none; }
.msg:focus-visible .bubble, .msg:focus-visible .sys-card { box-shadow: 0 0 0 2px var(--focus); }
.msg.enter { animation: msg-in .24s var(--ease); }
.msg.mine.enter { animation-name: msg-in-mine; }
.msg.flash .bubble, .msg.flash .sys-card { animation: flash 1.4s var(--ease-soft); }

.bubble {
  position: relative; max-width: min(74%, 640px); min-width: 72px; padding: 7px 11px 8px 12px; border-radius: 16px;
  background: var(--theirs); border: 1px solid var(--line); box-shadow: 0 2px 5px #33333303;
  font-size: var(--chat-fs); line-height: 1.45; overflow-wrap: anywhere; word-break: normal;
}
.bubble.snap { transition: transform .24s var(--ease); }
.msg.first:not(.mine) .bubble { border-top-left-radius: 5px; }
.msg.first.mine .bubble { border-top-right-radius: 5px; }
.msg.mine .bubble { background: var(--mine); border-color: transparent; }
.msg-author { display: flex; align-items: center; gap: 6px; margin: 0 0 2px; font-size: 12.5px; font-weight: 600; color: var(--av-ink); }
.msg-author .an { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-text { white-space: pre-wrap; }
/* Room for the time/tick on the last line, WhatsApp style. */
.msg-text::after, .msg-text.blocks > :last-child::after { content: ""; display: inline-block; width: 60px; height: 1px; }
.msg.mine .msg-text::after, .msg.mine .msg-text.blocks > :last-child::after { width: 76px; }
.msg-text.blocks { white-space: normal; }
.msg-text.blocks::after { display: none; }
.msg-text .ln, .msg-text .li { white-space: pre-wrap; }
.msg-text .li { position: relative; padding-left: 15px; margin-top: 3px; }
.msg-text .li::before { content: ""; position: absolute; left: 3px; top: .64em; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .45; }
.msg-text .ln + .li { margin-top: 5px; }
.msg-text .li + .ln { margin-top: 5px; }
.msg-text .gap { height: .45em; }
.msg-meta {
  position: absolute; right: 10px; bottom: 6px; display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; line-height: 1; color: var(--muted); white-space: nowrap; pointer-events: none; font-variant-numeric: tabular-nums;
}
.msg-meta .ic { width: 15px; height: 15px; stroke-width: 2; }
.msg.mine .msg-meta { color: color-mix(in srgb, var(--ink) 62%, transparent); }
.msg.mine .msg-meta .ic { color: var(--accent); }
.msg.pending .msg-meta .ic { color: var(--muted); }
.msg.failed .bubble { border-color: var(--red-line); }
.msg.failed .msg-meta .ic { color: var(--red); }
.msg-fail { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; margin-top: 4px; padding: 0 12px; border-radius: var(--r-pill); font-size: 13px; font-weight: 550; color: var(--red); background: var(--red-soft); }
.msg-fail .ic { width: 15px; height: 15px; }

.mention { color: var(--accent); font-weight: 600; }
.mention.me { background: var(--lavender); border-radius: 5px; padding: 0 3px; }
.msg.mine .mention.me { background: color-mix(in srgb, var(--surface) 55%, transparent); }
.bubble a, .sys-card a, .fact-text a, .task-panel a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; overflow-wrap: anywhere; }

.quote {
  display: block; width: 100%; margin: 2px 0 5px; padding: 5px 9px 6px; border-radius: 10px; text-align: left;
  background: color-mix(in srgb, var(--ink) 5%, transparent); border-left: 3px solid var(--accent); font-size: 13.5px; line-height: 1.35; transition: background-color .15s;
}
.quote:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.quote b { display: block; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.quote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); white-space: pre-wrap; }

/* message kinds: plan, report, alert, approval ("karu?") */
.bubble.card { max-width: min(88%, 660px); padding: 12px 15px 9px; border-radius: 18px; }
.bubble.card .msg-text::after, .bubble.card .msg-text.blocks > :last-child::after { display: none; }
.bubble.card .msg-meta { position: static; display: flex; justify-content: flex-end; margin-top: 8px; }
.kind-head { display: flex; align-items: center; gap: 6px; margin: 1px 0 6px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.kind-head .ic { width: 16px; height: 16px; stroke-width: 2; }
.k-plan .bubble { box-shadow: inset 3px 0 0 var(--accent), var(--card-shadow); }
.k-report .bubble { box-shadow: inset 3px 0 0 var(--green), var(--card-shadow); }
.k-report .kind-head { color: var(--green); }
.k-alert .bubble { background: var(--red-soft); border-color: var(--red-line); }
.k-alert .kind-head { color: var(--red); }
.k-approval .bubble { background: var(--surface); border-color: var(--line-2); box-shadow: var(--shadow-2); }
.appr-actions { display: flex; gap: 8px; margin-top: 12px; }
.appr-actions .btn { flex: 1; }
.bubble .appr-tags { margin-top: 8px; }
.appr-state { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.appr-state .ic { width: 16px; height: 16px; stroke-width: 2; }
.appr-state.st-approved { color: var(--green); }
.appr-state.st-rejected { color: var(--red); }
.appr-state.st-failed { color: var(--amber); }

/* what runs when the owner approves */
.runs { margin-top: 10px; padding: 10px 12px 11px; border-radius: 14px; background: var(--soft); border: 1px solid var(--line); }
.runs-head { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.runs-head .ic { width: 16px; height: 16px; }
.runs-rows { display: grid; gap: 6px; margin: 8px 0 0; }
.runs-row { display: grid; grid-template-columns: 86px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.runs-row dt { font-size: 12.5px; color: var(--muted); }
.runs-row dd { margin: 0; font-size: 14px; color: var(--ink); overflow-wrap: anywhere; white-space: pre-wrap; }
.runs-row.long { grid-template-columns: 1fr; gap: 1px; }

.msg.sys { align-items: center; margin: 12px 0 4px; }
.sys-card {
  max-width: min(92%, 580px); padding: 8px 14px 9px; border-radius: 14px; text-align: center; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 13.5px; line-height: 1.45; color: var(--ink-2); background: var(--sys-bg); border: 1px solid var(--line); box-shadow: var(--shadow-1);
}
.sys-author { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sys-card.long { text-align: left; padding: 10px 16px; }
.sys-card.long .sys-author { justify-content: flex-start; }
.sys-time { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }

.typing { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--muted); animation: msg-in .24s var(--ease); }
.dots { display: inline-flex; gap: 4px; padding: 11px 13px; border-radius: 16px; border-top-left-radius: 5px; background: var(--theirs); border: 1px solid var(--line); }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: dot 1.3s infinite var(--ease-soft); }
.dots i:nth-child(2) { animation-delay: .16s; }
.dots i:nth-child(3) { animation-delay: .32s; }

/* hover tools (mouse) */
.hover-tools {
  position: absolute; top: -17px; right: 8px; z-index: 3; display: flex; gap: 1px; padding: 2px; border-radius: 14px;
  background: var(--menu-bg); border: 1px solid var(--line); box-shadow: var(--shadow-2); animation: pop .14s var(--ease);
}
.msg.mine .hover-tools { right: auto; left: 8px; }
.hover-tools.side { top: 2px; left: calc(100% + 6px); right: auto; }
.msg.mine .hover-tools.side { left: auto; right: calc(100% + 6px); }
.hover-tools .icon-btn { width: 32px; height: 32px; }
.hover-tools .icon-btn .ic { width: 17px; height: 17px; }

/* composer */
.composer { position: relative; flex: none; padding: 6px var(--chat-gutter) calc(12px + env(safe-area-inset-bottom)); }
.compose-row {
  display: flex; align-items: flex-end; gap: 6px; padding: 4px 4px 4px 18px; border-radius: 26px;
  background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-2); transition: border-color .15s, box-shadow .15s;
}
.compose-row:focus-within { border-color: color-mix(in srgb, var(--focus) 55%, var(--line-2)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 12%, transparent), var(--shadow-2); }
#compose {
  flex: 1; min-width: 0; margin: 0; padding: 10px 0; border: 0; outline: 0; background: none; resize: none; max-height: 168px;
  font-size: var(--chat-fs); line-height: 1.4; color: var(--ink); overflow-y: auto;
}
#compose:focus-visible { outline: none; }
.send {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); transition: transform .18s var(--ease), opacity .18s, background-color .18s;
}
.send .ic { width: 20px; height: 20px; stroke-width: 2.2; }
.send:hover:not(:disabled) { background: var(--primary-hover); }
.send:active:not(:disabled) { transform: scale(.9); }
.send:disabled { opacity: .22; cursor: default; }

.reply-bar {
  display: flex; align-items: center; gap: 10px; margin: 0 4px 6px; padding: 7px 6px 7px 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); animation: rise .18s var(--ease); color: var(--accent);
}
.reply-bar > .ic { width: 18px; height: 18px; }
.reply-line { flex: 1; min-width: 0; padding-left: 9px; border-left: 3px solid var(--accent); }
.reply-line b { display: block; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.reply-line span { display: block; font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.mention-pop {
  position: absolute; left: var(--chat-gutter); bottom: calc(100% - 2px); z-index: 10; width: min(370px, calc(100% - 2 * var(--chat-gutter)));
  max-height: 312px; overflow-y: auto; padding: 6px; border-radius: 20px; background: var(--menu-bg); border: 1px solid var(--line);
  box-shadow: var(--shadow-3); transform-origin: bottom left; animation: pop .16s var(--ease);
  -webkit-backdrop-filter: blur(24px) saturate(150%); backdrop-filter: blur(24px) saturate(150%);
}
.mp-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 10px; border-radius: 14px; text-align: left; }
.mp-item[aria-selected="true"] { background: var(--lavender); }
.mp-main { min-width: 0; display: flex; flex-direction: column; }
.mp-name { display: flex; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 550; }
.mp-handle { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.jump {
  position: absolute; right: var(--chat-gutter); bottom: calc(100% + 10px); z-index: 5; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; background: var(--menu-bg); color: var(--accent); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); animation: pop .18s var(--ease);
}
.jump .ic { width: 20px; height: 20px; }
.jump-count {
  position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent); color: var(--surface); font-size: 11.5px; font-weight: 650; font-style: normal;
}

/* ------------------------------------------------------------------ pages */
.view-page { position: relative; }
.page-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.page { max-width: 980px; margin: 0 auto; padding: 30px 36px calc(56px + var(--ctx-space)); }
.page-narrow { max-width: 780px; }
.view-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; min-height: 48px; }
.view-titles { flex: 1; min-width: 0; }
.view-head h1 { font-size: 30px; line-height: 1.15; }
.view-sub { margin-top: 5px; font-size: 14px; color: var(--muted); text-wrap: pretty; }
.view-sub .late { color: var(--red); font-weight: 550; }
.view-sub .proof { color: var(--amber); font-weight: 550; }

.groups { display: flex; flex-direction: column; }
.group-head { display: flex; align-items: baseline; gap: 8px; padding: 4px 6px 9px; font-size: 14px; font-weight: 550; color: var(--ink); }
.group-head .count { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 12.5px; background: var(--lavender); color: var(--accent); font-variant-numeric: tabular-nums; align-self: center; }
.group-head.late { color: var(--red); }
.group-head.proof { color: var(--amber); }
.group-head.done { color: var(--green); }
/* Rows render flat (so they can be reused between renders); these classes draw the calm card around a group. */
.row-item { background: var(--surface); border: 1px solid var(--line); border-bottom-width: 0; }
.row-item + .row-item:not(.g-first) { border-top-color: color-mix(in srgb, var(--line) 70%, transparent); }
.row-item.g-first { border-top-left-radius: 20px; border-top-right-radius: 20px; }
.row-item.g-last { border-bottom-width: 1px; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; margin-bottom: 24px; box-shadow: var(--card-shadow); }

/* tasks */
.task { display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px 13px 8px; transition: background-color .15s; }
.check { flex: none; width: 44px; height: 44px; margin: -10px -4px -10px 0; display: grid; place-items: center; border-radius: 50%; }
.check .ring {
  width: 24px; height: 24px; border-radius: 50%; border: 1.8px solid var(--ring); display: grid; place-items: center; color: transparent;
  transition: background-color .2s, border-color .2s, color .2s, transform .2s var(--ease);
}
.check .ring .ic { width: 15px; height: 15px; stroke-width: 2.6; }
.check:hover .ring { border-color: var(--accent); color: var(--accent); }
.check:active .ring { transform: scale(.88); }
.s-done .check .ring { background: var(--green); border-color: var(--green); color: var(--surface); }
.s-reported .check .ring { border-color: var(--amber); border-style: dashed; }
.s-cancelled .check .ring { border-style: dotted; }
.task-main { flex: 1; min-width: 0; }
.task-title { display: block; width: 100%; text-align: left; padding: 1px 0; font-size: 15.5px; font-weight: 500; line-height: 1.38; color: var(--ink); overflow-wrap: anywhere; }
.s-done .task-title, .s-cancelled .task-title { color: var(--muted); }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.meta-item { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.meta-item .ic { width: 15px; height: 15px; }
.meta-item.late { color: var(--red); font-weight: 550; }
.meta-item.proj { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; padding: 1px 8px; border-radius: 7px; background: var(--hover); color: var(--ink-2); }
.task-quick { flex: none; align-self: center; }
.task.open-panel .task-quick { display: none; }
.task-panel { display: grid; gap: 10px; margin-top: 12px; padding: 14px; border-radius: 16px; background: var(--soft); border: 1px solid var(--line); animation: rise .2s var(--ease); }
.task-detail { font-size: 14px; color: var(--ink-2); white-space: pre-wrap; }
.panel-form { display: flex; gap: 8px; }
.panel-form .field { flex: 1; min-width: 0; min-height: 44px; }
.panel-note { font-size: 12.5px; color: var(--muted); }
.panel-note.warn { color: var(--amber); }
.panel-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.panel-row.end { justify-content: flex-end; }
.panel-row .lbl-inline { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-right: 4px; }
.kv { font-size: 13px; color: var(--muted); }
.kv b { font-weight: 550; color: var(--ink-2); }

/* approvals */
.cards { display: grid; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--card-shadow); }
.appr { display: grid; gap: 10px; padding: 18px 20px; transition: opacity .26s var(--ease), transform .26s var(--ease); }
.appr.leaving { opacity: 0; transform: scale(.97); }
.appr-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.appr-head { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.appr-who { display: inline-flex; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 550; color: var(--ink); white-space: nowrap; }
.appr-by { min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appr-summary { font-size: 16px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.appr-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.appr-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.appr-foot .spacer { flex: 1; }
.appr-exp { flex: none; font-size: 12.5px; color: var(--muted); }
.appr .runs { margin-top: 0; }

/* people */
.person { display: flex; align-items: center; gap: 12px; min-height: 74px; padding: 12px 12px 12px 16px; }
.person-main { flex: 1; min-width: 0; }
.person-name, .row-title { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 15.5px; font-weight: 550; text-align: left; }
.row-title { width: 100%; min-height: 28px; }
.row-title:disabled { cursor: default; opacity: 1; }
.person-name .pn, .row-title .pn { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-sub.usage { margin-top: 2px; font-variant-numeric: tabular-nums; }
.person-sub.bad { color: var(--red); font-weight: 550; }
.person-ai { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; margin-top: 7px; min-height: 30px; padding: 3px 11px 3px 3px; border-radius: var(--r-pill); background: var(--hover); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; transition: background-color .15s; }
.person-ai:hover { background: var(--lavender); }
.person-ai .h { min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-actions { display: flex; gap: 2px; flex: none; }

/* admin */
.admin-row { align-items: flex-start; }
.admin-row > .av { margin-top: 2px; }
.admin-row.is-paused > .av { filter: grayscale(.8); opacity: .7; }
.admin-row .switch-wrap { flex: none; display: flex; align-items: center; min-height: 44px; padding: 0 4px; }
.admin-row.fact { align-items: center; }
.admin-row.fact .btn { flex: none; }
.admin-panel { margin-right: -2px; }
.admin-panel label { display: block; min-width: 0; }
.admin-panel label.switch-row { display: flex; }
.admin-panel .lbl { margin-top: 0; }
.switch-row.slim { margin: 22px 0 0; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); }
.invites { display: grid; gap: 8px; margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.invite-list { display: grid; gap: 6px; }
.invite-row { display: flex; align-items: center; gap: 10px; min-height: 38px; }
.invite-when { flex: 1; min-width: 0; font-size: 13px; color: var(--muted); }
.note-card { display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; margin-bottom: 20px; background: var(--soft); }
.note-card p { display: grid; gap: 2px; font-size: 13.5px; color: var(--muted); }
.note-card b { color: var(--ink); font-weight: 550; font-size: 14.5px; }
.audit-row { display: flex; gap: 14px; align-items: baseline; padding: 11px 16px; }
.audit-row time { flex: none; width: 66px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.audit-row p { flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2); overflow-wrap: anywhere; }
.audit-row p b { color: var(--ink); font-weight: 550; }
.audit-row small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.audit-target { color: var(--ink); font-weight: 500; }

/* admin health tiles (on Company) */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.stat { min-width: 0; padding: 12px 14px 11px; border-radius: 16px; background: var(--soft); border: 1px solid var(--line); }
.stat-label { display: block; font-size: 12.5px; font-weight: 550; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { display: block; margin-top: 2px; font-size: 22px; font-weight: 550; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.stat-note { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.bad .stat-value { color: var(--red); }
.stat.warn .stat-value { color: var(--amber); }
.stat.good .stat-value { color: var(--green); }

/* brain */
.brain-add { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 14px; padding: 6px 6px 6px 4px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--card-shadow); transition: border-color .15s, box-shadow .15s; }
.brain-add:focus-within { border-color: color-mix(in srgb, var(--focus) 50%, var(--line)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 10%, transparent); }
.brain-add .field { flex: 1; border: 0; box-shadow: none !important; background: none; min-height: 44px; max-height: 180px; }
.fact { display: flex; align-items: flex-start; gap: 10px; padding: 14px 12px 14px 18px; }
.fact-main { flex: 1; min-width: 0; }
.fact-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.fact-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.fact-meta > * + *::before { content: "·"; margin: 0 7px; color: var(--faint); }
.fact-meta > .chip { margin-right: 8px; }
.fact-meta > .chip + *::before { content: none; }
.fact .confirm { min-height: 38px; padding: 0 14px; border-radius: var(--r-pill); font-size: 13.5px; font-weight: 550; color: var(--danger-ink); background: var(--danger-bg); animation: pop .16s var(--ease); }

/* company */
.company { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.co-card { padding: 18px 20px 20px; min-width: 0; }
.co-card.wide { grid-column: 1 / -1; }
.co-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-width: 0; }
.co-head h2 { flex: 1; min-width: 0; font-size: 17px; font-weight: 550; letter-spacing: -.02em; }
.co-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--lavender); color: var(--accent); }
.co-ic .ic { width: 19px; height: 19px; }
.mode-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 550; background: var(--hover); color: var(--muted); white-space: nowrap; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.mode-chip i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.mode-chip.m-live { background: var(--green-soft); color: var(--green); }
.mode-chip.m-warn { background: var(--amber-soft); color: var(--amber); }
.co-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.co-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; padding: 14px 16px; border-radius: 16px; text-align: left; background: var(--soft); border: 1px solid var(--line); transition: background-color .15s, border-color .15s; }
.co-tile:hover { background: var(--hover); }
.co-tile-top { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.co-tile-top .ic { width: 17px; height: 17px; }
.co-tile strong { font-size: 30px; font-weight: 550; letter-spacing: -.04em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.co-tile small { font-size: 12.5px; color: var(--muted); }
.co-tile.warn strong { color: var(--amber); }
.co-tile.bad strong { color: var(--red); }
.co-tile.accent strong { color: var(--accent); }
.co-bigs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.co-big { min-width: 0; }
.co-big span { display: block; font-size: 12.5px; color: var(--muted); }
.co-big strong { display: block; font-size: 24px; font-weight: 550; letter-spacing: -.035em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.co-big.bad strong { color: var(--red); }
.co-big.good strong { color: var(--green); }
.co-line { margin-top: 12px; font-size: 13px; color: var(--muted); }
.co-list { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.co-list-head { font-size: 12.5px; font-weight: 550; color: var(--muted); margin-bottom: 4px; }
.co-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.co-row:last-child { border-bottom: 0; }
.co-row-main, .co-row-end { display: flex; flex-direction: column; min-width: 0; }
.co-row-main { flex: 1; }
.co-row-end { align-items: flex-end; text-align: right; flex: none; }
.co-row b { font-size: 14px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.co-row small { font-size: 12px; color: var(--muted); }
.co-row small.bad { color: var(--red); }
.co-sources { display: flex; flex-direction: column; min-width: 0; }
.co-src { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 9px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.co-src:last-child { border-bottom: 0; }
.co-src-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--hover); color: var(--accent); flex: none; }
.co-src-ic .ic { width: 17px; height: 17px; }
.co-src-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.co-src-main b { font-size: 14px; font-weight: 550; }
.co-src-main small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co-src-end { display: flex; align-items: center; gap: 6px; flex: none; font-size: 13px; font-weight: 550; white-space: nowrap; }
.co-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.s-live .co-src-end { color: var(--green); }
.s-stale .co-src-end { color: var(--amber); }
.s-stale .co-dot { background: var(--amber); }
.s-down .co-src-end { color: var(--red); }
.s-down .co-dot { background: var(--red); }
.s-off .co-src-end { color: var(--muted); }
.s-off .co-dot { background: var(--faint); }
.mode-chip.m-off i { background: var(--faint); }
.co-empty { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--soft); border: 1px dashed var(--line-2); color: var(--muted); }
.co-empty .ic { width: 20px; height: 20px; color: var(--accent); margin-top: 1px; }
.co-empty p { display: grid; gap: 2px; font-size: 13.5px; }
.co-empty b { color: var(--ink); font-weight: 550; }
.co-sk { display: grid; gap: 10px; }
.co-sk .sk { height: 16px; }
.co-sk .sk:nth-child(2n) { width: 70%; }
.co-card .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.co-card .empty { padding: 20px 10px; }

/* apps launcher */
.apps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.app-tile { display: flex; flex-direction: column; gap: 14px; min-height: 172px; padding: 20px; text-decoration: none; color: var(--ink); transition: transform .18s var(--ease), border-color .15s, background-color .15s; }
.app-tile:hover { border-color: var(--line-2); background: var(--soft); }
.app-tile:active { transform: scale(.985); }
.app-ic { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; background: var(--lavender); color: var(--accent); }
.app-ic .ic { width: 23px; height: 23px; }
.app-main { flex: 1; display: grid; gap: 4px; }
.app-main b { font-size: 17px; font-weight: 550; letter-spacing: -.02em; }
.app-main small { font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.app-go { display: flex; align-items: center; gap: 6px; color: var(--accent); font-size: 12.5px; }
.app-go .ic { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ sheets (dialogs) */
dialog.sheet {
  padding: 0; border: 0; border-radius: 28px; width: min(540px, calc(100vw - 32px)); max-width: none; max-height: min(88dvh, 820px); overflow: hidden;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
}
dialog.sheet[open] { display: flex; animation: sheet-in .28s var(--ease); }
dialog.sheet::backdrop { background: rgba(22, 13, 32, .30); }
.sheet-inner { display: flex; flex-direction: column; width: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 24px 24px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin: -2px -10px 6px 0; }
.sheet-head h2 { flex: 1; font-size: 22px; font-weight: 550; letter-spacing: -.035em; }
.sheet-lead { font-size: 14.5px; color: var(--muted); margin-bottom: 4px; }
.sheet-note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.sheet-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.sheet-foot .sheet-note { margin: 0 auto 0 0; }
.lbl { display: block; margin: 14px 0 6px; font-size: 13px; font-weight: 550; color: var(--ink-2); }
.lbl .opt { font-weight: 400; color: var(--faint); margin-left: 4px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.switch-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 12px 14px; border-radius: 16px; background: var(--soft); border: 1px solid var(--line); cursor: pointer; }
.switch-row > span { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.switch-row b { font-size: 14.5px; font-weight: 550; }
.switch-row small { font-size: 12.5px; color: var(--muted); }
#dlg-chat .sheet-inner { gap: 10px; }
#dlg-chat .sheet-head { margin-bottom: 0; }
#dlg-chat .search { flex: none; }
.group-fields .lbl { margin-top: 2px; }
.pick-list { display: flex; flex-direction: column; margin: 0 -10px; min-height: 120px; }
.pick-head { padding: 12px 12px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.pick { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 62px; padding: 8px 12px; border-radius: 16px; text-align: left; transition: background-color .15s; }
.pick:hover { background: var(--hover); }
.pick-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pick-name { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 550; }
.pick-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-tick { width: 24px; height: 24px; border-radius: 50%; border: 1.8px solid var(--ring); display: grid; place-items: center; color: transparent; flex: none; transition: background-color .15s, border-color .15s; }
.pick-tick .ic { width: 15px; height: 15px; stroke-width: 2.6; }
.pick[aria-pressed="true"] .pick-tick { background: var(--switch-on); border-color: var(--switch-on); color: #fff; }
#dlg-chat .sheet-foot { position: sticky; bottom: -24px; margin: 6px -24px -24px; padding: 12px 24px 16px; background: var(--surface); border-top: 1px solid var(--line); }

.invite-ok { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--green-soft); color: var(--ink); font-size: 14.5px; }
.invite-ok:empty { display: none; }
.invite-ok .ok-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: var(--surface); flex: none; }
.invite-ok .ok-dot .ic { width: 17px; height: 17px; stroke-width: 2.6; }
.invite-ok small { display: block; color: var(--ink-2); font-size: 13px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .field { flex: 1; min-width: 0; background: var(--soft); }
.copy-row .btn { min-width: 108px; }
.btn.primary.done, .btn.primary.done:hover { background: var(--green); border-color: var(--green); color: var(--surface); }

.remove-list { margin: 4px 0 2px; padding: 0; list-style: none; display: grid; gap: 10px; }
.remove-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; color: var(--ink-2); }
.remove-list li .ic { width: 18px; height: 18px; color: var(--red); margin-top: 1px; }
.warn-box { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: var(--red-soft); color: var(--red); font-size: 13.5px; font-weight: 550; }
.warn-box .ic { width: 18px; height: 18px; margin-top: 1px; }

/* ------------------------------------------------------------------ menu (grows from its anchor) */
.menu {
  position: fixed; z-index: 90; min-width: 236px; max-width: min(340px, calc(100vw - 16px)); max-height: min(72vh, 560px); overflow-y: auto;
  padding: 6px; border-radius: 20px; background: var(--menu-bg); border: 1px solid var(--line); box-shadow: var(--shadow-3);
  -webkit-backdrop-filter: blur(26px) saturate(150%); backdrop-filter: blur(26px) saturate(150%);
  transform-origin: var(--mo, top left); animation: menu-in .2s var(--ease);
}
.menu-item { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 46px; padding: 0 12px; border-radius: 14px; font-size: 15px; text-align: left; color: var(--ink); }
.menu-item .ic { width: 19px; height: 19px; color: var(--accent); }
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); outline: none; }
.menu-item.danger, .menu-item.danger .ic { color: var(--red); }
.menu-item .mi-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-item .mi-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-item.person-item { min-height: 56px; }
.menu-sep { height: 1px; margin: 6px 6px; background: var(--line); }
.menu-label { padding: 8px 12px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.menu-head { display: flex; align-items: center; gap: 11px; padding: 8px 10px; }
.menu-who { min-width: 0; display: flex; flex-direction: column; }
.menu-who b { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 550; }
.menu-who span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu .seg { margin: 0 6px 4px; width: calc(100% - 12px); display: flex; }
.menu .seg button { flex: 1; padding: 0 8px; }

/* ------------------------------------------------------------------ toasts + connection */
.toasts {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom) + var(--ctx-space)); z-index: 100; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(460px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 100%; min-height: 48px; padding: 11px 12px 11px 18px; border-radius: 20px;
  background: rgba(41, 39, 47, .94); color: #fbf8fe; font-size: 14.5px; font-weight: 500; box-shadow: var(--shadow-3);
  -webkit-backdrop-filter: blur(20px) saturate(150%); backdrop-filter: blur(20px) saturate(150%); animation: toast-in .28s var(--ease);
}
.toast.error { background: rgba(140, 45, 58, .96); }
.toast.out { animation: toast-out .22s var(--ease-soft) forwards; }
.toast-text { flex: 1; min-width: 0; }
.toast-ic { width: 18px; height: 18px; stroke-width: 2.4; margin-right: -4px; color: #a9e7c6; }
.toast-act { flex: none; min-height: 36px; padding: 0 12px; border-radius: var(--r-pill); font-weight: 650; color: #e6d5ff; }
.toast-act:hover { background: rgba(255, 255, 255, .12); }
:root[data-theme="dark"] .toast { background: rgba(241, 234, 248, .96); color: #1f1729; }
:root[data-theme="dark"] .toast-act { color: #6a4f86; }
:root[data-theme="dark"] .toast-ic { color: #2f6f55; }
:root[data-theme="dark"] .toast.error { background: rgba(255, 200, 208, .97); color: #4a1020; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .toast { background: rgba(241, 234, 248, .96); color: #1f1729; }
  :root:not([data-theme="light"]) .toast-act { color: #6a4f86; }
  :root:not([data-theme="light"]) .toast-ic { color: #2f6f55; }
  :root:not([data-theme="light"]) .toast.error { background: rgba(255, 200, 208, .97); color: #4a1020; }
}
dialog .toasts { position: fixed; bottom: calc(26px + env(safe-area-inset-bottom)); }

.conn {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; z-index: 95; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: var(--r-pill);
  background: var(--glass); color: var(--glass-ink); border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); font-size: 13px; font-weight: 550; animation: drop .28s var(--ease);
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #f5c96a; animation: pulse 1.4s var(--ease-soft) infinite; }

/* ------------------------------------------------------------------ motion */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }
@keyframes breathe { 0%, 100% { transform: rotate(-8deg) scale(1); opacity: 1; } 50% { transform: rotate(-8deg) scale(.95); opacity: .75; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px) scale(.985); transform-origin: left bottom; } to { opacity: 1; transform: none; } }
@keyframes msg-in-mine { from { opacity: 0; transform: translateY(6px) scale(.985); transform-origin: right bottom; } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes menu-in { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes drop { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes dot { 0%, 70%, 100% { transform: translateY(0); opacity: .5; } 35% { transform: translateY(-4px); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes flash { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 20% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* No frosted glass support, or reduced transparency: keep it readable and solid. */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .island, .conn { background: var(--glass-solid); }
  .chat-head { background: var(--chat-bg); }
  .menu, .mention-pop, .hover-tools, .jump { background: var(--surface); }
}
@media (prefers-reduced-transparency: reduce) {
  .island, .conn { background: var(--glass-solid); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ------------------------------------------------------------------ sizes */
@media (min-width: 760px) and (max-width: 1023px) {
  :root { --list-w: 310px; }
  .page { padding: 26px 26px calc(48px + var(--ctx-space)); }
  .apps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .company { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1440px) {
  :root { --list-w: 380px; }
}
@media (pointer: coarse) {
  .icon-btn, .icon-btn.sm { width: 44px; height: 44px; }
  .btn.sm, .pill, .fact .confirm, .toast-act { min-height: 44px; }
  .seg button, .filter { min-height: 40px; }
  .msg-fail { min-height: 40px; }
  .person-ai { min-height: 34px; padding-right: 12px; }
}
@media (hover: none) {
  .bubble, .sys-card { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .task:hover, .thread:hover, .pick:hover { background: transparent; }
  .thread.active { background: transparent; }
}

/* ------------------------------------------------------------------ phone: one pane at a time */
@media (max-width: 759px) {
  :root { --chat-fs: 16px; --chat-head-h: calc(60px + env(safe-area-inset-top)); --chat-gutter: 10px; --head-h: calc(62px + env(safe-area-inset-top)); }
  body { font-size: 16px; }
  .shell { height: 100%; }
  .app-header { gap: 8px; padding: env(safe-area-inset-top) 10px 0 12px; border-bottom-color: transparent; }
  .nav-slot { flex-basis: 64px; }
  .g-island { width: 64px; }
  .island-current { max-width: 56px; font-size: 10px; }
  .brand-mark { font-size: 30px; width: 36px; letter-spacing: -7px; padding-right: 8px; }
  .workspace-name { font-size: 13px; }
  .c-island { bottom: calc(10px + env(safe-area-inset-bottom)); }
  .c-island.is-expanded { padding-inline: 4px; }
  .c-island .island-items { --gap: 2px; }
  .c-island .island-items > button { font-size: 11.5px; padding-inline: 1px; }

  .chats-panel { display: block; height: 100%; overflow: visible; }
  .threads-pane { height: 100%; border: 0; background: var(--page); transition: transform .34s var(--ease), opacity .34s var(--ease); }
  .shell[data-chat-open] .threads-pane { transform: translateX(-20%); opacity: .5; }
  .pane-head { padding: 4px 8px 8px 14px; gap: 4px; }
  .filters { padding: 0 14px 10px; }
  .threads { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .thread { min-height: 76px; margin: 0 6px; width: calc(100% - 12px); padding: 10px; }
  .av { width: 50px; height: 50px; font-size: 16px; }
  .av.xs { width: 22px; height: 22px; font-size: 9.5px; }
  .av.sm { width: 36px; height: 36px; font-size: 12.5px; }
  .av.md { width: 40px; height: 40px; font-size: 14px; }
  .t-name { font-size: 16.5px; }
  .t-prev { font-size: 15px; }
  .t-time { font-size: 12.5px; }

  .chat-pane {
    position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100dvh); z-index: 60;
    transform: translateX(100%); visibility: hidden; transition: transform .34s var(--ease), visibility 0s linear .34s;
    box-shadow: -12px 0 32px rgba(20, 10, 30, .10);
  }
  .shell[data-chat-open] .chat-pane { transform: none; visibility: visible; transition: transform .34s var(--ease); }
  .shell[data-chat-open] .c-island { display: none; }
  .chat-empty { display: none; }
  .chat-head { padding: env(safe-area-inset-top) 8px 0 2px; }
  .back { display: inline-grid; width: 44px; height: 44px; color: var(--accent); }
  .back .ic { width: 26px; height: 26px; stroke-width: 2; }
  .chat-id { padding: 4px 8px 4px 2px; }
  .chat-name { font-size: 16.5px; }
  .chat-sub { font-size: 13px; }
  .bubble { max-width: 85%; }
  .bubble.card { max-width: 95%; }
  .msg-meta { font-size: 11.5px; }
  .runs-row { grid-template-columns: 78px minmax(0, 1fr); }
  .runs-row dd { font-size: 15px; }
  .composer { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  .compose-row { padding-left: 16px; }
  .send { width: 42px; height: 42px; }
  .mention-pop { left: 8px; width: calc(100% - 16px); }
  .jump { right: 12px; }

  .page { padding: 8px 16px calc(28px + env(safe-area-inset-bottom) + var(--ctx-space)); }
  .view-head { margin-bottom: 16px; gap: 0 8px; flex-wrap: wrap; }
  .view-titles { display: contents; }
  .view-head h1 { flex: 1; min-width: 0; font-size: 29px; }
  .view-head .view-sub { order: 5; flex-basis: 100%; margin-top: 3px; font-size: 14.5px; }
  .person-sub { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .panel-form.proof-form { flex-wrap: wrap; }
  .panel-form.proof-form .field { flex-basis: 100%; }
  .panel-form.proof-form .btn { flex: 1; }
  .chips-row { flex-wrap: nowrap; overflow-x: auto; margin: 8px -18px 0; padding: 0 18px 2px; scrollbar-width: none; }
  .chips-row::-webkit-scrollbar { display: none; }
  .chips-row .pill { flex: none; padding: 0 12px; }
  .person-ai .h { display: none; }
  .task-quick { display: none; }
  .task-title { font-size: 16.5px; }
  .task-meta { font-size: 13.5px; }
  .person-name, .row-title { font-size: 16.5px; }
  .person-sub { font-size: 14px; }
  .fact-text { font-size: 16px; }
  .appr { padding: 16px; }
  .appr-top { flex-wrap: wrap; row-gap: 2px; }
  .appr-by { white-space: normal; }
  .appr-top .appr-exp { order: 3; flex-basis: 100%; padding-left: 46px; }
  .appr-summary { font-size: 16.5px; }
  .appr-foot .btn:not(.ghost) { flex: 1; }
  .appr-foot .spacer { display: none; }
  .appr-foot .btn.ghost { flex-basis: 100%; order: 3; }

  .company { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .co-card { padding: 16px; }
  /* Phone: the three tiles become three calm rows (label and note left, the number right). */
  .co-tiles { grid-template-columns: 1fr; gap: 8px; }
  .co-tile { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; padding: 12px 16px; }
  .co-tile-top { grid-column: 1; grid-row: 1; font-size: 14.5px; color: var(--ink); font-weight: 550; }
  .co-tile small { grid-column: 1; grid-row: 2; font-size: 13px; }
  .co-tile strong { grid-column: 2; grid-row: 1 / 3; font-size: 28px; }
  .co-bigs { grid-template-columns: 1fr 1fr; row-gap: 12px; }
  .co-big strong { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .apps { grid-template-columns: 1fr; gap: 10px; }
  .app-tile { flex-direction: row; align-items: center; min-height: 0; padding: 16px; gap: 14px; }
  .app-go small { display: none; }
  .audit-row { gap: 10px; padding: 11px 14px; }
  .audit-row time { width: 58px; }

  .field, .search input { font-size: 16px; } /* 16px keeps iOS from zooming on focus */

  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 28px 28px 0 0; max-height: 92dvh; }
  dialog.sheet[open] { animation: sheet-up .34s var(--ease); }
  .sheet-inner { padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); }
  .sheet-inner::before { content: ""; flex: none; align-self: center; width: 38px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 0 10px; }
  #dlg-chat .sheet-foot { margin: 6px -18px calc(-18px - env(safe-area-inset-bottom)); padding: 12px 18px calc(14px + env(safe-area-inset-bottom)); bottom: calc(-18px - env(safe-area-inset-bottom)); }
  .sheet-foot .btn { flex: 1; }

  .toasts { bottom: calc(20px + env(safe-area-inset-bottom) + var(--ctx-space)); }
  .shell[data-chat-open] ~ .toasts { bottom: calc(86px + env(safe-area-inset-bottom)); }
  .menu { max-width: calc(100vw - 16px); }
}
@media (max-width: 370px) {
  .view-head .btn span { display: none; }
  .view-head .btn { width: 44px; padding: 0; }
  .row-2 { grid-template-columns: 1fr; gap: 0; }
  .co-tiles { grid-template-columns: 1fr; }
  .workspace-name { display: none; }
}

/* ------------------------------------------------------------------ reduced motion: keep it still */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
  .sk, .dots i, .conn-dot, .boot .eg-mark { animation: none !important; }
  .spinner, .btn.busy::after { animation: spin 1.6s linear infinite !important; }
}
