/* MOMU — "Doyat" theme (দোয়াত, ink-pot).
   Warm ink-on-paper: coffee-toned near-black ink in dark mode, rice-paper
   warmth in light mode, one marigold accent (a Bangla festival color, used
   sparingly — never as a wash or gradient background).
   Type: Bricolage Grotesque for display, Hind Siliguri for text (renders Bangla + Latin). */

:root {
  --font-display: "Bricolage Grotesque", "Hind Siliguri", "Noto Sans Bengali", system-ui, sans-serif;
  --font-text: "Hind Siliguri", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-s: 9px;
  --radius-m: 14px;
  --radius-l: 20px;
  --sidebar-w: 288px;
  --fs: 16px;
  --density: 1;
  --lh: 1.55;
}
:root[data-fs="small"] { --fs: 13.5px; }
:root[data-fs="large"] { --fs: 19px; }
:root[data-density="compact"] { --density: .5; --lh: 1.38; }

/* Accent hue (--h). Every surface is a low-saturation tint of it, so the theme
   stays neutral instead of washing the whole screen in one colour. */
:root, :root[data-accent="amber"]   { --h: 38;  --s: 78%; }
:root[data-accent="orange"]  { --h: 24;  --s: 82%; }
:root[data-accent="yellow"]  { --h: 50;  --s: 80%; }
:root[data-accent="lime"]    { --h: 86;  --s: 55%; }
:root[data-accent="green"]   { --h: 148; --s: 55%; }
:root[data-accent="teal"]    { --h: 174; --s: 60%; }
:root[data-accent="cyan"]    { --h: 190; --s: 70%; }
:root[data-accent="blue"]    { --h: 214; --s: 80%; }
:root[data-accent="indigo"]  { --h: 236; --s: 70%; }
:root[data-accent="violet"]  { --h: 266; --s: 70%; }
:root[data-accent="fuchsia"] { --h: 300; --s: 65%; }
:root[data-accent="pink"]    { --h: 330; --s: 70%; }
:root[data-accent="red"]     { --h: 4;   --s: 72%; }
:root[data-accent="white"] { --h: 0; --s: 0%; }   /* no colour at all — see the neutral palettes below */

:root[data-theme="dark"] {
  --bg: hsl(var(--h) 10% 8%); --surface: hsl(var(--h) 10% 11%); --surface-2: hsl(var(--h) 9% 15%); --surface-3: hsl(var(--h) 8% 20%);
  --line: hsl(var(--h) 8% 24%); --text: hsl(var(--h) 20% 94%); --muted: hsl(var(--h) 8% 66%);
  --brand: hsl(var(--h) var(--s) 62%); --brand-strong: hsl(var(--h) var(--s) 70%); --on-brand: hsl(var(--h) 60% 8%); --brand-soft: hsl(var(--h) var(--s) 62% / .15);
  --danger: #E4574A; --danger-soft: rgba(228,87,74,.13); --ok: #6FB77E; --warn: #D9824A;
  --shadow: 0 10px 30px rgba(0,0,0,.45); --rule: rgba(255,255,255,.04);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: hsl(var(--h) 30% 97%); --surface: #FFFFFF; --surface-2: hsl(var(--h) 25% 94%); --surface-3: hsl(var(--h) 22% 89%);
  --line: hsl(var(--h) 18% 83%); --text: hsl(var(--h) 30% 12%); --muted: hsl(var(--h) 10% 40%);
  --brand: hsl(var(--h) var(--s) 38%); --brand-strong: hsl(var(--h) var(--s) 31%); --on-brand: #FFFFFF; --brand-soft: hsl(var(--h) var(--s) 38% / .11);
  --danger: #C23B2E; --danger-soft: rgba(194,59,46,.09); --ok: #2F7A3D; --warn: #B15A20;
  --shadow: 0 10px 30px rgba(20,20,30,.12); --rule: rgba(0,0,0,.04);
  color-scheme: light;
}

/* White accent: no tint anywhere, so the app feels like plain white.
   White  → dark: soft neutral greys with WHITE buttons · light: pure white page with near-black buttons. */
:root[data-accent="white"][data-theme="dark"] {
  --bg: #121212; --surface: #181818; --surface-2: #202020; --surface-3: #2a2a2a;
  --line: #333333; --text: #FFFFFF; --muted: #A8A8A8;
  --brand: #FFFFFF; --brand-strong: #E6E6E6; --on-brand: #000000; --brand-soft: rgba(255,255,255,.12);
}
:root[data-accent="white"][data-theme="light"] {
  --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #F5F5F5; --surface-3: #EBEBEB;
  --line: #DEDEDE; --text: #111111; --muted: #6B6B6B;
  --brand: #2B2B2B; --brand-strong: #111111; --on-brand: #FFFFFF; --brand-soft: rgba(0,0,0,.07);
}

/* Accent picker in Settings */
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: hsl(var(--sw) 70% 52%); }
.swatch[aria-pressed="true"] { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg) inset; }
/* The global button:hover / :active / :focus background stays "stuck" after a tap on a phone and, on the already-selected swatch, painted it
   grey/black (looked like a bug). A swatch always keeps its own colour. */
.swatch:active, .swatch:focus, .swatch[aria-pressed="true"] { background: hsl(var(--sw) 70% 52%); }
:where(html[data-input="mouse"]) .swatch:hover, :where(html[data-input="mouse"]) .swatch[aria-pressed="true"]:hover { background: hsl(var(--sw) 70% 52%); }
/* The two neutral swatches: a real white and a real black dot (with a hairline so white shows on a white page). */
.swatch[data-accent="white"], .swatch[data-accent="white"]:active, .swatch[data-accent="white"]:focus, .swatch[data-accent="white"][aria-pressed="true"] { background: #FFFFFF; box-shadow: 0 0 0 1px #8a8a8a inset; }
:where(html[data-input="mouse"]) .swatch[data-accent="white"]:hover { background: #FFFFFF; box-shadow: 0 0 0 1px #8a8a8a inset; }
.msg.user { align-items: flex-start; gap: 6px; }
/* Copy / Share / Edit for a message you sent (see enableUserActions in chat.js). Desktop: icons sit BELOW the bubble and
   fade in while the pointer is anywhere over the message's whole row (the row height is always reserved, so nothing jumps).
   Phones / touch: no icons at all — hold the message to get the same actions in a menu. */
.user-actions { display: flex; gap: 2px; justify-content: flex-end; margin-top: 4px; height: 30px; color: var(--muted); opacity: 0; transition: opacity .12s; }
.msg.user:focus-within .user-actions { opacity: 1; }
:where(html[data-input="mouse"]) .msg.user:hover .user-actions { opacity: 1; }
.user-actions button { border: none; background: transparent; color: inherit; width: 30px; min-height: 30px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; }
:where(html[data-input="mouse"]) .user-actions button:hover { background: var(--surface-2); color: var(--text); }
.user-actions button svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.user-menu { min-width: 170px; }
.msg.momu.regenerating .content { opacity: .5; transition: opacity .15s; }
/* touch behaviour (was a media query; now follows html[data-input], see theme-init.js) */
  html[data-input="touch"] .user-actions { display: none; }
  html[data-input="touch"] .msg.user.has-actions .stack { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
  html[data-input="touch"] .msg img, html[data-input="touch"] .msg-images img, html[data-input="touch"] .attach-thumb img { -webkit-touch-callout: none; -webkit-user-drag: none; }
  html[data-input="touch"] .msg-actions .regen { display: none; }
/* Read aloud lives ONLY in the reply's "..." menu, on every device (phone, PC, Windows app). The button itself stays in the page, hidden,
   so js/speak.js can still follow it (Stop state, "reply left the page" check). */
.msg-actions .speak { display: none !important; }

.edit-box { width: min(86%, 620px); display: flex; flex-direction: column; gap: 8px; }
.edit-box textarea { min-height: 70px; }
.edit-box .row { display: flex; gap: 8px; justify-content: flex-end; }
/* Editing a message that has pictures/files: those stay put (read-only) above the
   editable textarea, with a small note explaining why they can't be touched here. */
.edit-box .edit-attachments { display: flex; flex-direction: column; gap: 6px; opacity: .85; }
.edit-box .edit-attachments .msg-images img, .edit-box .edit-attachments .msg-files .file-chip { cursor: default; }
.edit-lock-note { margin: 0; font-size: .78rem; color: var(--muted); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-size: var(--fs); }
/* No pinch-zoom and no double-tap zoom anywhere in the app (the viewport tag says the same; this covers
   browsers that ignore it). pan-x/pan-y keep normal scrolling. The camera's own picture viewer sets
   touch-action: none on itself and handles its pinch in code, so it is unaffected. */
html { touch-action: pan-x pan-y; }
html, body { height: 100%; background: var(--bg); }
/* Pages with a sticky top bar (Settings, Admin, Devices): a sticky header can only stay on screen inside its parent. With the body fixed
   at 100% height that parent ended after one screen, so on a phone the bar scrolled away with the content. These pages let the body grow
   with its content instead, so the bar stays visible whether you scroll down or not. (The class is added by common.js for browsers without :has.) */
body:has(> .page-bar), body:has(> .admin-bar), body.has-sticky-bar { height: auto; min-height: 100%; }
/* The chat screen is exactly one window tall and scrolls inside its own panels (chat list, messages). The page itself must never scroll:
   selecting text makes browser extensions (Grammarly and similar) and the browser's own selection handles drop small elements just past the
   bottom edge, and on a page that was merely 100% tall that grew a second, page-level scrollbar next to the real one. */
html.chat-page, html.chat-page body { overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-text); font-size: 1rem; line-height: var(--lh);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--brand); }
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.15; margin: 0; letter-spacing: -.02em; font-weight: 700; }
::selection { background: var(--brand-soft); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Controls ---------- */
button {
  font: inherit; font-size: .9rem; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 14px;
  min-height: 38px; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s, border-color .15s, opacity .15s;
}
:where(html[data-input="mouse"]) button:hover { background: var(--surface-3); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); font-weight: 600; }
:where(html[data-input="mouse"]) button.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
button.ghost { background: transparent; border-color: transparent; }
:where(html[data-input="mouse"]) button.ghost:hover { background: var(--surface-2); }
button.danger { color: var(--danger); background: transparent; border-color: var(--danger-soft); }
:where(html[data-input="mouse"]) button.danger:hover { background: var(--danger-soft); }
button.small { min-height: 30px; padding: 4px 10px; font-size: .82rem; }
button.icon { width: 40px; padding: 0; display: inline-grid; place-items: center; }
button svg, .icon-svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

input, textarea, select {
  font: inherit; font-size: 1rem; /* 16px min stops iOS zooming on focus */
  color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 10px 12px; width: 100%; min-height: 42px;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input:disabled, textarea:disabled, select:disabled { opacity: .55; cursor: not-allowed; }
label { font-size: .88rem; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > small { color: var(--muted); font-size: .8rem; }

/* Themed scrollbars — matches the surface/line palette instead of the OS default */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; border: 2px solid var(--bg); background-clip: padding-box; }
:where(html[data-input="mouse"]) ::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: padding-box; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; flex-wrap: wrap; }
.segmented button { border: none; background: transparent; border-radius: 9px; min-height: 32px; padding: 4px 12px; }
.segmented button[aria-pressed="true"], .segmented button[aria-pressed="true"]:hover { background: var(--brand); color: var(--on-brand); font-weight: 600; }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform .18s, background .15s; }
.switch input:checked + span { background: var(--brand); border-color: var(--brand); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--on-brand); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: .75rem; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.pill.ok { background: rgba(35,168,90,.14); color: var(--ok); }
.pill.warn { background: rgba(228,185,92,.16); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }

.logo { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.logo img { width: 30px; height: 30px; display: block; }

#toasts { position: fixed; z-index: 200; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 420px); pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .9rem; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; display: flex; align-items: center; gap: 8px; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
.toast-text { flex: 1; }
/* The little "×2", "×3…" counter that appears when the same toast repeats instead of a new
   bubble stacking underneath it — see toast() in common.js. */
.toast-count { flex: none; font-size: .74rem; font-weight: 700; background: rgba(255,255,255,.22); padding: 1px 7px; border-radius: 999px; }

/* ---------- Auth page (unified "Log in or sign up") ---------- */
.auth-page { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0,1.1fr) minmax(0,.9fr); background: var(--bg); }

/* Left: a quiet ruled page with a small chat that plays once (public/js/hero-demo.js).
   Every colour comes from the same theme variables as the login form on the right (--surface, --text, --muted, --brand, --on-brand, --line),
   so it follows light/dark and the accent colour. Only transform/opacity animate. */
.auth-hero { position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; min-height: 0;
  padding: clamp(24px, 4vw, 52px) clamp(28px, 4.5vw, 64px) clamp(24px, 4.5vh, 48px);
  background: var(--surface); color: var(--text); box-shadow: inset -1px 0 0 var(--line); }
/* ruled paper */
.auth-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--rule) 31px 32px); background-position: 0 -1px; }
.hero-logo { align-self: flex-start; font-size: 1.1rem; letter-spacing: .02em; animation: fadeUp .7s ease both; }
.hero-stage { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 600px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: clamp(20px, 4vh, 40px); padding: clamp(14px, 2.5vh, 28px) 0 0; }
.hero-copy { margin: 0; max-width: none; }
.hero-title { font-size: clamp(2.1rem, 3.3vw, 3.4rem); line-height: 1.08; letter-spacing: -.035em; font-weight: 700; text-wrap: balance; animation: fadeUp .8s .12s cubic-bezier(.2,.7,.2,1) both; }
.hero-title span { display: block; }
.hero-title span + span { color: var(--brand); }
.hero-sub { margin: 16px 0 0; max-width: 34rem; color: var(--muted); font-size: 1.02rem; line-height: 1.65; animation: fadeUp .8s .24s cubic-bezier(.2,.7,.2,1) both; }

/* The chat preview is a self-contained window: it has a fixed, comfortable height, so the left side is always filled and never half empty. */
.hc-chat { position: relative; flex: none; width: 100%; height: clamp(380px, 54vh, 540px); display: flex; flex-direction: column; border-radius: 24px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 34px 60px -40px rgba(0,0,0,.5), 0 2px 6px rgba(0,0,0,.06); overflow: hidden; animation: fadeUp .9s .4s ease both; }
.hc-chat-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.hc-chat-head img { width: 24px; height: 24px; border-radius: 8px; }
.hc-live { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); }
.hc-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: blink 2.2s ease-in-out infinite; }
.hc-chat-thread { position: relative; flex: 1 1 0; min-height: 0; overflow: hidden; padding: 0 16px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 36px); mask-image: linear-gradient(to bottom, transparent 0, #000 36px); }
.hc-chat-in { position: absolute; left: 16px; right: 16px; bottom: 0; display: flex; flex-direction: column; gap: 14px; padding: 0 0 12px; will-change: transform; transition: opacity .45s ease; }
.hc-chat-in.out { opacity: 0; }
.hc-empty { position: absolute; inset: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 8px; padding: 0 12%; transition: opacity .4s ease; }
.hc-empty span { padding: 6px 13px; border-radius: 999px; border: 1px dashed var(--line); color: var(--muted); font-size: .82rem; }
.hc-chat.has-msgs .hc-empty { opacity: 0; }

.hc-msg { display: flex; opacity: 0; transform: translateY(10px) scale(.985); transition: opacity .38s ease, transform .45s cubic-bezier(.2,.8,.2,1); }
.hc-msg.in { opacity: 1; transform: none; }
.hc-msg.user { align-self: flex-end; max-width: 88%; transform-origin: 100% 100%; }
.hc-msg.ai { align-self: flex-start; max-width: 96%; gap: 10px; align-items: flex-start; transform-origin: 0 100%; }
.hc-msg-av { flex: none; width: 28px; height: 28px; border-radius: 9px; margin-top: 2px; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.hc-msg-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; min-width: 0; }
.hc-bubble { padding: 10px 16px; font-family: var(--font-text); font-size: .98rem; line-height: 1.6; overflow-wrap: anywhere; }
.hc-msg.user .hc-bubble { background: var(--brand); color: var(--on-brand); font-weight: 500; border-radius: 18px 18px 6px 18px; box-shadow: 0 8px 16px -12px var(--brand); }
.hc-msg.ai .hc-bubble { background: var(--surface-2); color: var(--text); border-radius: 6px 18px 18px 18px; border: 1px solid var(--line); min-height: 44px; }
.hc-bubble.hide { display: none; }
.hc-text { white-space: pre-wrap; }
.hc-typing { display: none; gap: 5px; align-items: center; height: 24px; }
.hc-typing.on { display: inline-flex; }
.hc-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: bounce 1s ease-in-out infinite; }
.hc-typing i:nth-child(2) { animation-delay: .15s; } .hc-typing i:nth-child(3) { animation-delay: .3s; }
.hc-stream-caret { display: none; width: 2px; height: 1.05em; margin-left: 2px; vertical-align: -.15em; background: var(--brand); animation: blink .9s steps(1) infinite; }
.hc-stream-caret.on { display: inline-block; }
.hc-msg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: .74rem; color: var(--muted); background: var(--surface);
  opacity: 0; transform: translateY(4px); transition: opacity .35s ease, transform .35s ease; }
.hc-msg-chip.in { opacity: 1; transform: none; }
.hc-msg-chip svg { width: 12px; height: 12px; color: var(--brand); flex: none; }
.hc-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* attachments (picture / file) inside the sent message and inside the message box */
.hc-att { display: flex; align-items: center; gap: 9px; margin: 0 0 6px; padding: 5px 12px 5px 5px; border-radius: 12px; background: rgba(255,255,255,.18); font-size: .82rem; font-weight: 600; }
.hc-att svg { flex: none; width: 30px; height: 37px; border-radius: 6px; display: block; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.hc-att small { display: block; font-weight: 500; opacity: .8; font-size: .72rem; }
.hc-comp-attach { display: none; flex: none; align-items: center; gap: 8px; max-width: 46%; padding: 4px 10px 4px 4px; margin-left: -8px; border-radius: 12px; background: var(--surface-3); font-size: .78rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: fadeUp .35s ease both; }
.hc-comp-attach.on { display: inline-flex; }
.hc-comp-attach svg { flex: none; width: 24px; height: 30px; border-radius: 5px; }

/* "what MOMU is doing" rows: reading a picture / file, searching the web, then the sources it used */
.hc-tools { display: flex; flex-direction: column; gap: 7px; }
.hc-tool { display: flex; align-items: center; gap: 8px; font-size: .84rem; color: var(--muted); opacity: 0; transform: translateY(4px); transition: opacity .35s ease, transform .35s ease; }
.hc-tool.in { opacity: 1; transform: none; }
.hc-tool .hc-spin { flex: none; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.hc-tool.done .hc-spin { animation: none; border: 0; background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12.5l4 4 8-9'/%3E%3C/svg%3E") center / 80% no-repeat; }
.hc-tool b { color: var(--text); font-weight: 600; }
.hc-srcs { display: flex; flex-wrap: wrap; gap: 6px; }
.hc-src { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .76rem; color: var(--text);
  opacity: 0; transform: translateY(4px) scale(.96); transition: opacity .35s ease, transform .35s ease; }
.hc-src.in { opacity: 1; transform: none; }
.hc-src i { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: .66rem; font-weight: 700; color: #fff; background: var(--brand); text-transform: uppercase; }

.hc-chat-composer { flex: none; display: flex; align-items: center; gap: 10px; min-height: 56px; margin: 0 12px 12px; padding: 0 10px 0 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 10px 24px -18px rgba(0,0,0,.3); transition: border-color .25s ease, box-shadow .25s ease; }
.hc-chat-composer.active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), 0 10px 24px -18px rgba(0,0,0,.3); }
.hc-comp-field { flex: 1; min-width: 0; display: flex; align-items: center; font-family: var(--font-text); font-size: 1rem; white-space: nowrap; overflow: hidden; }
.hc-comp-ph { color: var(--muted); opacity: .85; }
.hc-chat-composer.active .hc-comp-ph, .hc-chat-composer.has-text .hc-comp-ph { display: none; }
.hc-comp-caret { display: none; width: 2px; height: 1.15em; margin-left: 1px; background: var(--brand); animation: blink .9s steps(1) infinite; }
.hc-chat-composer.active .hc-comp-caret { display: inline-block; }
.hc-comp-send { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--surface-3); color: var(--muted); transition: background .25s ease, color .25s ease, transform .16s ease; }
.hc-comp-send.ready { background: var(--brand); color: var(--on-brand); }
.hc-comp-send.press { transform: scale(.86); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes blink { 50% { opacity: 0; } }
/* shorter screens: tighten the headline so the chat keeps room */
@media (max-height: 800px) { .hero-title { font-size: clamp(1.9rem, 2.9vw, 2.8rem); } .hero-sub { margin-top: 10px; font-size: .94rem; line-height: 1.55; } .hc-chat { height: clamp(340px, 54vh, 450px); } }
@media (max-height: 720px) { .hero-sub { display: none; } .hero-stage { gap: 18px; } .hc-chat { height: clamp(320px, 58vh, 420px); } }

/* Right: one calm column. Inputs/buttons follow the site theme (light or dark). */
.auth-panel { display: flex; align-items: center; justify-content: center; padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom)); }
.auth-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.mobile-logo { display: none; align-self: center; font-size: 1.35rem; }
.mobile-tag { display: none; }
.auth-view { display: flex; flex-direction: column; gap: 16px; animation: fadeUp .45s cubic-bezier(.2,.7,.2,1) both; }
.auth-view.hidden { display: none; }
.auth-title { font-family: var(--font-display); font-weight: 600; font-size: 1.85rem; letter-spacing: -.02em; text-align: center; margin: 0 0 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .field > small { margin: 2px 4px 0; }
.auth-card input:not(.visually-hidden) { width: 100%; box-sizing: border-box; min-height: 54px; padding: 0 18px; border-radius: 16px; font-size: max(16px, 1rem); border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 1rem; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
.auth-card input::placeholder { color: var(--muted); opacity: .85; }
.auth-card input:not(.visually-hidden):focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.auth-card .pw-wrap > input { padding-right: 52px; }
.auth-card .otp-input { text-align: center; letter-spacing: .6em; padding-left: calc(18px + .6em); font-size: 1.35rem; font-weight: 700; }
.auth-card .error-msg { color: var(--danger); font-size: .9rem; min-height: 0; text-align: center; }
.auth-card .error-msg:empty { display: none; }
/* Continue + Continue with Google: always the accent colour (--brand / --on-brand), on every device and theme. */
.auth-card button.primary, .auth-card .g-btn, .auth-card .g-btn:focus, .auth-card .g-btn:active {
  width: 100%; min-height: 54px; border-radius: 16px; font-size: 1rem; font-weight: 600; letter-spacing: .005em;
  background: var(--brand); color: var(--on-brand); border: 1px solid var(--brand);
  box-shadow: 0 1px 2px rgba(0,0,0,.14);
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s, opacity .15s; }
.auth-card button.primary { margin-top: 2px; }
.auth-card .g-btn { gap: 12px; }
.auth-card button.primary:active, .auth-card .g-btn:active { transform: scale(.985); }
.auth-card button.primary:disabled { opacity: .55; cursor: default; box-shadow: none; }
.auth-card button.primary:focus-visible, .auth-card .g-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Continue gets a slightly deeper accent on hover; "Continue with Google" has no hover effect at all. */
:where(html[data-input="mouse"]) .auth-card button.primary:hover:not(:disabled) { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }
.auth-card .g-btn-icon { width: 28px; height: 28px; border-radius: 9px; background: #fff; display: grid; place-items: center; flex: none; box-shadow: 0 1px 2px rgba(0,0,0,.18); }
.auth-card .g-btn-icon svg { width: 18px; height: 18px; }
.auth-divider { margin: 2px 0; font-size: .75rem; letter-spacing: .12em; }
.auth-divider.hidden { display: none; }
.auth-lede { text-align: center; margin: 0; }
.auth-switch { text-align: center; color: var(--muted); font-size: .92rem; margin: 0; }
.auth-switch button { background: none; border: none; color: var(--brand); padding: 4px 2px; min-height: 0; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-family: inherit; font-size: inherit; }
.auth-forgot { text-align: left; margin: -2px 0 0 4px; }
.auth-legal { margin: 6px 0 0; text-align: center; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.auth-card .auth-legal a { color: var(--text); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; padding: 2px 1px; }
.auth-help { font-size: .85rem; line-height: 1.5; }
.auth-help.hidden { display: none; }
.auth-help a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 4px 2px; }
.auth-note { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(228,185,92,.13); color: var(--warn); font-size: .88rem; text-align: center; }
.email-chip { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 54px; padding: 0 16px 0 18px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: 1rem; cursor: pointer; text-align: left; transition: border-color .15s; }
.email-chip:hover { border-color: var(--muted); background: var(--surface-2); }
.email-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.email-chip-edit { flex: none; color: var(--brand); font-weight: 600; font-size: .9rem; }
.auth-card .visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; opacity: 0; pointer-events: none; }
/* Desktop: no box — the form sits straight on the page background, centred in the right half. */
@media (min-width: 901px) {
  .auth-panel { padding: 40px 32px; }
  .auth-card { max-width: 400px; padding: 0; gap: 0; background: none; border: 0; border-radius: 0; box-shadow: none; }
  .auth-card .auth-title { font-size: 2rem; margin-bottom: 14px; }
  .auth-view { gap: 14px; }
}
/* Phone / tablet: no hero. First screen = brand centred in the open space, everything you tap anchored at the bottom
   (like ChatGPT). Later steps (password, create account, codes…) put a small logo on top and the form right under it. */
@media (max-width: 900px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { align-items: stretch; padding: calc(env(safe-area-inset-top, 0px) + 28px) 22px calc(env(safe-area-inset-bottom, 0px) + 24px); }
  .auth-card { max-width: 460px; margin: 0 auto; flex: 1 1 auto; gap: 0; }
  .mobile-logo { display: inline-flex; align-self: center; margin: 5vh 0 30px; font-size: 1.3rem; }
  .auth-card .auth-title { font-size: 1.75rem; margin-bottom: 8px; }
  .auth-view { gap: 14px; }

  .auth-page[data-view="start"] .mobile-logo { flex: 1 1 auto; flex-direction: column; justify-content: center; gap: 18px; margin: 0; min-height: 120px; font-size: 2.1rem; letter-spacing: .02em; pointer-events: none; }
  .auth-page[data-view="start"] .mobile-logo img { width: 84px; height: 84px; border-radius: 24px; box-shadow: 0 2px 8px rgba(0,0,0,.16); }
  .auth-page[data-view="start"] .mobile-tag { display: block; max-width: 18rem; margin: -4px auto 0; text-align: center; font-family: var(--font-display); font-size: 1.05rem; font-weight: 500; letter-spacing: 0; color: var(--muted); line-height: 1.35; }
  .auth-page[data-view="start"] #start-view { padding-top: 12px; }
  .auth-page[data-view="start"] .auth-title { font-size: 1.45rem; margin-bottom: 4px; }
}
@media (max-width: 900px) and (max-height: 640px) {
  .auth-page[data-view="start"] .mobile-logo img { width: 56px; height: 56px; border-radius: 17px; }
  .auth-page[data-view="start"] .mobile-logo { font-size: 1.6rem; gap: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-hero, .auth-hero *, .auth-hero *::before, .auth-hero *::after, .auth-view, .auth-view > * { animation: none !important; transition: none !important; }
}

/* ---------- Login polish: soft accent glow behind the form, nicer fields/buttons, gentle staggered entrance ---------- */
.auth-panel { position: relative; isolation: isolate; }
/* (the soft accent glow behind the form was removed — the login page is a clean flat surface) */
.auth-panel::before { content: none; }
.auth-sub { margin: -4px 0 10px; text-align: center; color: var(--muted); font-size: .96rem; line-height: 1.5; }
.auth-card .auth-title { color: var(--text); }
.auth-card input:not(.visually-hidden) { box-shadow: none; }
.auth-card input:not(.visually-hidden):hover:not(:focus) { border-color: color-mix(in srgb, var(--brand) 38%, var(--line)); }
.auth-card button.primary, .auth-card .g-btn { background-image: none; box-shadow: 0 1px 2px rgba(0,0,0,.14); }

.auth-card .g-btn-icon { box-shadow: none; }
.auth-divider { color: var(--muted); }
.auth-view > * { animation: fadeUp .5s cubic-bezier(.2,.7,.2,1) both; }
.auth-view > :nth-child(2) { animation-delay: .04s; } .auth-view > :nth-child(3) { animation-delay: .08s; }
.auth-view > :nth-child(4) { animation-delay: .12s; } .auth-view > :nth-child(5) { animation-delay: .16s; } .auth-view > :nth-child(n+6) { animation-delay: .2s; }
@media (max-width: 900px) {
  .auth-sub { display: none; }
  /* Steps 2+ (password, create account, codes…): logo + form sit together in the vertical middle, a touch above centre. */
  .auth-page:not([data-view="start"]) .auth-card { justify-content: center; }
  .auth-page:not([data-view="start"]) .mobile-logo { margin: 0 0 26px; }
  .auth-page:not([data-view="start"]) .auth-panel { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 9vh); }
}

/* ---------- Chat shell ---------- */
.app { display: flex; height: 100vh; height: 100dvh; height: calc(var(--app-vh, 1vh) * 100); overflow: hidden; }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px 12px; gap: 10px; transition: width .2s ease, padding .2s ease, opacity .15s ease; position: relative; }
.sidebar.resizing { transition: none; }
/* Drag handle for the desktop-only resizable sidebar (see the drag logic in chat.js). Sits
   half on/half off the existing border so it's easy to grab without adding a visible strip. */
.sidebar-resize-handle { position: absolute; top: 0; right: -3px; width: 6px; height: 100%; cursor: col-resize; z-index: 5; background: transparent; touch-action: none; }
.sidebar-resize-handle::after { content: ""; position: absolute; top: 0; right: 2px; width: 2px; height: 100%; background: transparent; transition: background .15s ease; }
.sidebar-resize-handle.dragging::after, .sidebar-resize-handle:focus-visible::after { background: var(--brand); opacity: .6; }
:where(html[data-input="mouse"]) .sidebar-resize-handle:hover::after { background: var(--brand); opacity: .6; }
.sidebar-resize-handle:focus-visible { outline: none; }
/* Invisible grab strip on the window's left edge, shown only while the desktop sidebar is collapsed:
   the cursor becomes the resize arrows and dragging right reopens the sidebar (see chat.js). */
.sidebar-reopen-handle { display: none; }
/* Desktop: the sidebar keeps its chosen width whatever the window size. When the window is too narrow for both,
   the page scrolls sideways (the sidebar stays pinned to the left) instead of the sidebar closing itself. */
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) .app { overflow: hidden; }
  :where(html[data-layout="wide"]) .main { min-width: 0; }
  :where(html[data-layout="wide"]) .sidebar { position: sticky; left: 0; z-index: 20; }

/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) .app.sidebar-collapsed .sidebar-reopen-handle { display: block; position: fixed; top: 0; left: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 55; background: transparent; }

body.sidebar-resizing, body.sidebar-resizing * { cursor: col-resize !important; user-select: none !important; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 4px; }
.sidebar-head-actions { display: flex; align-items: center; gap: 2px; }
.sidebar-head a.logo { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; border-radius: 10px; padding: 2px 4px; margin-left: -4px; -webkit-tap-highlight-color: transparent; }
.sidebar-head a.logo, .sidebar-head a.logo:hover, .sidebar-head a.logo:active, .sidebar-head a.logo:focus, .sidebar-head a.logo:focus-visible { background: transparent; outline: none; box-shadow: none; }
/* The two top-level sidebar actions ("New chat" and "Projects") — plain nav rows, same size
   and weight as any other nav entry, not a big standalone pill button. */
.sidebar-nav { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px;
  border-radius: 10px; background: transparent; border: none; color: var(--text);
  font-size: .93rem; font-weight: 500; cursor: pointer; text-align: left;
}
:where(html[data-input="mouse"]) .nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--surface-2); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-search { position: relative; }
.chat-search input { padding-left: 36px; min-height: 40px; background: var(--surface-2); }
.chat-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; margin: 0 -4px; padding: 0 4px; overscroll-behavior: contain; }
.chat-group { font-size: .78rem; color: var(--muted); padding: 12px 8px 4px; }
/* Marks the first group heading of a new sidebar section (Pinned / a project / the plain
   date-grouped chats) so the sections read as visually separate blocks, not one long list —
   set via chat-group-sep in chat.js, only on the group that starts a new section. */
.chat-group.chat-group-sep { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 14px; }
/* A project's own name heading the chats inside it — this is a title the person chose, not
   a date label like "Today"/"Yesterday", so it gets real weight instead of the tiny muted
   .chat-group style above. */
.chat-group.chat-group-project {
  font-size: .95rem; font-weight: 700; color: var(--text); padding: 14px 8px 6px;
  display: flex; align-items: center; gap: 6px;
}
.chat-group.chat-group-project svg { width: 15px; height: 15px; flex: none; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-group-project .proj-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-group-project .proj-menu-btn {
  opacity: 0; border: none; background: transparent; color: var(--muted); min-height: 26px; width: 26px; padding: 0;
  display: grid; place-items: center; border-radius: 7px; flex: none;
}
.chat-group-project .proj-menu-btn[aria-expanded="true"] { opacity: 1; }
:where(html[data-input="mouse"]) .chat-group-project:hover .proj-menu-btn { opacity: 1; }
.chat-group-project .proj-menu-btn svg { width: 15px; height: 15px; }
.chat-group-project .proj-menu-btn[aria-expanded="true"] { color: var(--text); background: var(--surface-3); }
:where(html[data-input="mouse"]) .chat-group-project .proj-menu-btn:hover { color: var(--text); background: var(--surface-3); }
.chat-group-empty { color: var(--muted); font-size: .82rem; padding: 2px 10px 10px 30px; }
.chat-item { display: flex; align-items: center; gap: 4px; padding: 0 4px 0 10px; border-radius: 10px; cursor: pointer; min-height: 42px; }
.chat-item.active { background: var(--surface-2); }
:where(html[data-input="mouse"]) .chat-item:hover { background: var(--surface-2); }
.chat-item.active { box-shadow: inset 3px 0 0 var(--brand); }
.chat-item .title { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .93rem; }
/* A chat that belongs to a project: the project's name, small and faded, right after the title. */
.chat-item .chat-project-tag { flex: 0 1 auto; min-width: 0; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; color: var(--muted); opacity: .8; margin-left: 4px; }
.chat-item .pin-btn { margin-left: auto; }
.chat-item .row-btn { flex: none; box-sizing: border-box; opacity: 0; border: none; background: transparent; color: var(--muted); min-height: 32px; height: 32px; min-width: 32px; width: 32px; padding: 0; display: grid; place-items: center; border-radius: 8px; }   /* flex:none → a long title / project tag can never squeeze the pin and "..." buttons: same place and same hover size on every row */
.chat-item.active .row-btn, .chat-item:focus-within .row-btn { opacity: 1; }
:where(html[data-input="mouse"]) .chat-item:hover .row-btn { opacity: 1; }
:where(html[data-input="mouse"]) .chat-item .row-btn:hover { color: var(--danger); background: var(--danger-soft); }
:where(html[data-input="mouse"]) .chat-item .row-btn.pin-btn:hover { color: var(--brand); background: var(--brand-soft); }
/* Per-chat reply status in the sidebar: spinner while MOMU is still answering, blue dot once a reply is waiting. */
.chat-item .chat-status, .pj-chat-row .chat-status { flex: none; margin-left: auto; margin-right: 6px; width: 14px; height: 14px; display: inline-block; }
.chat-item .chat-status + .pin-btn { margin-left: 0; }
.chat-item .chat-status.is-working, .pj-chat-row .chat-status.is-working { border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: chat-status-spin .8s linear infinite; box-sizing: border-box; }
.chat-item .chat-status.is-unread, .pj-chat-row .chat-status.is-unread { width: 8px; height: 8px; margin-left: auto; margin-right: 10px; border-radius: 50%; background: #3b82f6; }
/* While MOMU is answering in a chat, its row shows ONLY the spinner, at the far right where the pin / "..." buttons normally sit. */
.chat-item.is-busy .row-btn, .chat-item.is-busy.pinned .row-btn { display: none; }
.chat-item.is-busy .chat-status.is-working { margin-left: auto; margin-right: 9px; }
.pj-chat-row.is-busy .pj-chat-menu { visibility: hidden; pointer-events: none; }
.chat-item.is-busy { -webkit-touch-callout: none; }
@keyframes chat-status-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .chat-item .chat-status.is-working { animation-duration: 2s; } }
/* "Reply ready" notice for a chat you're not looking at. Click it to open that chat; it fades on its own. */
#reply-notices { position: fixed; top: calc(max(0px, env(safe-area-inset-top)) + 62px); right: 14px; z-index: 300; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.reply-notice { pointer-events: auto; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); cursor: pointer; min-height: 0; animation: reply-notice-in .22s ease; transition: opacity .2s ease, transform .2s ease; }
.reply-notice strong { font-size: .93rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-notice span { font-size: .86rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-notice.out { opacity: 0; transform: translateY(-6px); }
:where(html[data-input="mouse"]) .reply-notice:hover { background: var(--surface-2); }
@keyframes reply-notice-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
/* [compact layout: phones only] */ :where(html[data-layout="compact"]) #reply-notices { top: calc(max(0px, env(safe-area-inset-top)) + 62px); right: 50%; transform: translateX(50%); }    /* just under the top bar, so the menu / title / incognito buttons stay tappable */
.chat-item.pinned .pin-btn { opacity: 1; color: var(--brand); }
.chat-item.pinned .pin-btn svg, .chat-item.pinned .pin-btn:hover svg { fill: currentColor; }
.chat-empty { color: var(--muted); font-size: .9rem; padding: 14px 8px; }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-family: var(--font-display); font-weight: 700; flex: none; text-transform: uppercase; background-size: cover; background-position: center; }
.avatar.has-pic { color: transparent; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar-picker { display: flex; align-items: center; gap: 16px; padding: 4px 0; }
.avatar-picker-actions { display: flex; flex-direction: column; gap: 8px; }
.avatar-picker-actions button { width: fit-content; }
.who { min-width: 0; flex: 1; line-height: 1.25; }
.who b { display: block; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.who span { font-size: .78rem; color: var(--muted); }
/* Desktop: the avatar + name button that opens the account dropdown (Settings/Admin/Log out —
   see openAccountMenu in chat.js). Plain flex row, no button chrome, so it still looks like the
   old static avatar+name — just with a hover state and a click target now. */
.profile-trigger { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; border: none; background: transparent; padding: 6px; margin: -6px; border-radius: var(--radius-s); text-align: left; cursor: pointer; }
.profile-trigger[aria-expanded="true"] { background: var(--surface-2); }
:where(html[data-input="mouse"]) .profile-trigger:hover { background: var(--surface-2); }
/* Desktop keeps only the profile trigger down here — Admin/Settings move into the dropdown it
   opens, so the standalone icon row is hidden. The mobile media query below brings it back. */
.foot-actions { display: none; gap: 2px; }
.foot-actions button, .foot-actions a { color: var(--muted); }
.foot-actions a.icon { display: inline-grid; place-items: center; width: 40px; min-height: 38px; border-radius: var(--radius-s); }
:where(html[data-input="mouse"]) .foot-actions a.icon:hover { background: var(--surface-2); color: var(--text); }

.main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
/* Plain chats (and the new-chat screen) get a transparent header — no bar, no border — with
   each action floating as its own circle (see the icon rules below). Only a chat that lives in
   a project keeps the boxed look, since it has a project name + chat title to sit on top of;
   .in-project is toggled in chat.js (updateChatHeader). */
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 56px; border-bottom: 1px solid transparent; background: transparent; }
.topbar .menu-btn { display: none; }
.topbar #expand-sidebar-btn { display: none; }
/* Sidebar toggle (hamburger / expand) is always its own circle, on mobile and desktop, in a
   project chat or not — this one doesn't change with .in-project. */
.topbar .menu-btn, .topbar #expand-sidebar-btn { border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
:where(html[data-input="mouse"]) .topbar .menu-btn:hover, :where(html[data-input="mouse"]) .topbar #expand-sidebar-btn:hover { background: var(--surface-3); }
/* Bolder two-bar glyph instead of a thin three-line hamburger. */
.topbar .menu-btn svg { stroke-width: 2.75; }
/* Non-project chats: New chat / Share / "..." / incognito each become their own floating circle
   (matching the sidebar toggle) instead of sitting on a shared bar. A project chat's topbar is
   untouched — those keep the original pill-style Share-with-label button. */
.topbar #chat-new-btn,
.topbar #chat-more-btn,
.topbar #incognito-btn,
.topbar button.topbar-share {
  border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line);
  width: 40px; padding: 0; justify-content: center;
}
:where(html[data-input="mouse"]) .topbar #chat-new-btn:hover, :where(html[data-input="mouse"]) .topbar #chat-more-btn:hover, :where(html[data-input="mouse"]) .topbar #incognito-btn:hover, :where(html[data-input="mouse"]) .topbar button.topbar-share:hover { background: var(--surface-3); }
.topbar button.topbar-share span { display: none; }
.topbar #incognito-btn.on { background: var(--brand-soft); }
/* A chat inside a project has the very same floating topbar as a plain chat. Only differences: its project name floats
   as a clickable pill (see .crumb-project below), and it shows no chat name and no Share button (Share stays in the "..." menu). */
/* (Share now shows in project chats too: computers keep the Share circle, phones swap New chat for Share — see updateChatHeader.) */
/* Desktop sidebar collapse: the header's own toggle hides the sidebar entirely and the
   topbar's twin icon (hidden the rest of the time) takes its place to bring it back.
   Scoped to desktop widths only — otherwise this (higher-specificity) rule beats the
   mobile overlay's own .sidebar rule below and leaves the hamburger menu opening a
   sidebar that's stuck at width:0/opacity:0/pointer-events:none. */
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) .app.sidebar-collapsed .sidebar { width: 0; min-width: 0; padding: 0; border-right: 0; opacity: 0; overflow: hidden; pointer-events: none; }

.app.sidebar-collapsed .topbar #expand-sidebar-btn { display: inline-grid; }
.topbar .chat-title { flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: none; background: transparent; text-align: left; padding: 6px 8px; border-radius: 8px; }
:where(html[data-input="mouse"]) .topbar .chat-title:hover { background: var(--surface-2); }
/* A chat outside any project shows no name up top at all (kept in the layout via visibility,
   not display, so the project crumb/Share/"..." on the right don't shift) — see updateChatHeader
   in chat.js. A chat that lives in a project still shows its name, same as always. */
.topbar .chat-title.title-hidden { visibility: hidden; }
/* Non-project chats (a plain chat, and the blank new-chat screen) go further: the topbar is
   taken out of document flow entirely and floats over the thread instead of reserving its own
   row, so the message list gets the full viewport height and starts right at the top of the
   screen, same as the reference layout. A chat that lives in a project (.in-project) and the
   Projects browsing pages (.view-page) are untouched — both keep the topbar as a normal,
   in-flow bar exactly as before, with the same icons/Share/"..." behaviour unchanged either way. */
.main:not(.view-page) .topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6; pointer-events: none;
}
.main:not(.view-page) .topbar > * { pointer-events: auto; }
/* Padding on the scrollable thread itself, not reserved layout space — it scrolls out of the
   way immediately, so the extra viewport height above is still gained; it just keeps the very
   first message from rendering directly under the floating icons. */
.main:not(.view-page) .topbar ~ .scroller .thread {
  padding-top: calc(56px + 24px * var(--density));
}
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 16px; background: var(--brand-soft); font-size: .9rem; border-bottom: 1px solid var(--line); }
.banner span { flex: 1; }
.banner button { min-height: 28px; padding: 0 8px; }
.banner.warn { background: rgba(228,185,92,.16); border-bottom-color: var(--warn); }
.banner.warn span { color: var(--warn); font-weight: 600; }
.banner button { flex: none; cursor: pointer; }
/* Notice banner (maintenance / admin announcement) in a plain or new chat. Those chats have a
   floating, transparent topbar (menu / new chat / "..." / incognito circles) that sits ON TOP of the
   page, so an in-flow banner used to slide underneath those circles and its text and ✕ got covered.
   Here the banner is pushed down by exactly the topbar's height, so it always sits BELOW the icons,
   and it keeps its ✕ so people can close it. The buttons themselves are not touched. A chat inside a
   project keeps its normal in-flow topbar, so it needs none of this. */
:root { --floating-topbar-h: 56px; }
.main:not(.view-page) .topbar ~ .banner:not(.hidden) {
  margin: var(--floating-topbar-h) 14px 0; border: 1px solid var(--line); border-radius: 12px;
  position: relative; z-index: 5;
}
.main:not(.view-page) .topbar ~ .banner.warn:not(.hidden) { border-color: var(--warn); }
/* the banner already clears the icons, so the thread only needs a small gap under it */
.main:not(.view-page) .topbar ~ .banner:not(.hidden) ~ .scroller .thread {
  padding-top: calc(12px * var(--density));
}
/* maintenance mode: chat box switched off (non-admins) */
.composer.maintenance-off { opacity: .65; background: var(--surface-2, var(--surface)); }
.composer.maintenance-off textarea, .composer.maintenance-off button { cursor: not-allowed; }
.composer.maintenance-off textarea { height: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.composer.maintenance-off textarea::placeholder { color: var(--warn); opacity: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; }

.scroller { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.thread { width: 100%; max-width: 800px; margin: 0 auto; padding: calc(24px * var(--density)) 18px 12px; display: flex; flex-direction: column; gap: calc(22px * var(--density)); }
.jump { position: absolute; right: 22px; bottom: 132px; z-index: 5; box-shadow: var(--shadow); border-radius: 999px; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
.jump.hidden { display: none; }

.welcome { margin: auto; padding: 6vh 0 2vh; max-width: 640px; }
.welcome h2 { font-size: clamp(1.7rem,4.6vw,2.4rem); }
.welcome .bn { font-size: 1.1rem; color: var(--muted); margin: 8px 0 28px; line-height: 1.5; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.suggestion { text-align: left; padding: 15px 16px; border-radius: var(--radius-m); background: var(--surface); min-height: 0; line-height: 1.4; border: 1px solid var(--line); transition: border-color .15s, background .15s, transform .15s; }
.suggestion b { display: block; font-weight: 600; margin-bottom: 3px; }
.suggestion span { color: var(--muted); font-size: .85rem; }
:where(html[data-input="mouse"]) .suggestion:hover { border-color: var(--brand); background: var(--surface-2); transform: translateY(-1px); }

.msg { display: flex; gap: calc(12px * var(--density)); max-width: 100%; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: min(86%, 620px); padding: calc(10px * var(--density)) 15px; border-radius: 17px 17px 4px 17px; background: var(--brand-soft); border: 1px solid var(--brand-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
/* User bubbles can now hold rendered bold, italic and code markup (see addUserMessage in
   chat.js), not just a plain text node. Browsers give <p>/<ul>/etc their own default margins,
   which made a one-line bubble balloon in height even though the text itself was unchanged —
   same fix .content already has below, mirrored here so the bubble always hugs its text. */
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 .5em; }
.bubble ul, .bubble ol { margin: 0 0 .5em; padding-left: 1.3em; }
.bubble li { margin: .15em 0; }
.bubble code { font-family: var(--font-mono); font-size: .86em; background: rgba(0,0,0,.12); padding: 1px 6px; border-radius: 6px; }
.bubble h3, .bubble h4, .bubble h5, .bubble h6 { margin: .4em 0 .2em; font-size: 1em; }
.bubble blockquote { margin: 0 0 .5em; padding: 1px 10px; border-left: 2px solid currentColor; opacity: .85; }
.bubble hr { border: none; border-top: 1px solid currentColor; opacity: .3; margin: .5em 0; }
.msg.momu { align-items: flex-start; }
.msg .mark { width: calc(22px + 8px * var(--density)); height: calc(22px + 8px * var(--density)); flex: none; margin-top: 2px; }
.msg .body { min-width: 0; flex: 1; }
.msg .content { overflow-wrap: anywhere; }
.msg.error .content { color: var(--danger); }

.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }
.content p { margin: 0 0 .75em; }
.content h3, .content h4, .content h5, .content h6 { margin: 1.1em 0 .4em; }
.content h3 { font-size: 1.2rem; } .content h4 { font-size: 1.08rem; } .content h5, .content h6 { font-size: 1rem; }
.content ul, .content ol { margin: 0 0 .8em; padding-left: 1.4em; }
.content li { margin: .2em 0; }
.content blockquote { margin: 0 0 .8em; padding: 2px 14px; border-left: 3px solid var(--brand); color: var(--muted); }
.content hr { border: none; border-top: 1px solid var(--line); margin: 1em 0; }
.content code { font-family: var(--font-mono); font-size: .86em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.content a.cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 1px; font-size: .68rem; font-weight: 600; text-decoration: none; background: var(--brand-soft); border-radius: 9px; vertical-align: 2px; }
.codeblock { margin: 0 0 .9em; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.codehead { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 14px; background: var(--surface-2); font-size: .78rem; color: var(--muted); }
.codehead button { min-height: 26px; padding: 0 8px; font-size: .76rem; background: transparent; border-color: transparent; color: var(--muted); }
.codeblock pre { margin: 0; padding: 12px 14px; overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; scroll-behavior: smooth; }
.codeblock code { background: none; padding: 0; font-size: .84rem; line-height: 1.55; }
/* Copy card — a titled, copyable block for a generated deliverable (email, essay, paragraph,
   letter, dialogue...) as opposed to a .codeblock, which is monospaced source code. Rendered
   from a ```copy Title``` fence — see the copyMatch branch in md.js. */
.copycard { margin: 0 0 .9em; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.copycard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 14px; background: var(--surface-2); }
.copycard-title { font-size: .8rem; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copycard-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.copycard-actions button { min-height: 30px; width: 30px; padding: 0; display: inline-grid; place-items: center; background: transparent; border-color: transparent; color: var(--muted); border-radius: 8px; }
:where(html[data-input="mouse"]) .copycard-actions button:hover { background: var(--surface); color: var(--text); }
.copycard-body { padding: 14px 16px; font-size: .95rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.copycard-expand-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; line-height: 1.6; }
/* Side-scroll edge shadows — a soft vignette pinned to the wrap's own edges (background-attachment:
   scroll fixes it to the box, not the scrolling content or the viewport) so it stays put as a
   constant "there's more this way" hint, however far the table/code has scrolled. Purely a shadow,
   so it needs no background-color match against whatever sits behind it (a chat bubble here, an
   admin/share page there). Scoped to tables and code blocks only — normal message text never
   scrolls sideways. */
.table-wrap, .codeblock pre {
  background-image: radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.16), rgba(0,0,0,0)), radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.16), rgba(0,0,0,0));
  background-position: left center, right center;
  background-size: 14px 92%, 14px 92%;
  background-repeat: no-repeat;
  background-attachment: scroll, scroll;
}
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; scroll-behavior: smooth; margin: 0 0 .9em; border: 1px solid var(--line); border-radius: var(--radius-s); }
/* A table sized to 100% of the bubble squeezes every column until words break one letter
   per line (unreadable on a narrow phone bubble). Instead let the table size itself to its
   own content — width: max-content, with min-width: 100% so a small table still fills the
   bubble — so cells stay on one line and .table-wrap above scrolls sideways for anything
   that doesn't fit, rather than the text wrapping badly. This is scoped to tables (and
   .codeblock pre above) only, not the message bubble as a whole. */
.content table, .bubble table { border-collapse: collapse; width: max-content; min-width: 100%; max-width: none; font-size: .92rem; white-space: normal; }
.content th, .content td, .bubble th, .bubble td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.content th, .bubble th { background: var(--surface-2); font-weight: 600; }
.content tbody tr:nth-child(even) td, .bubble tbody tr:nth-child(even) td { background: var(--surface-2); }
.content tr:last-child td, .bubble tr:last-child td { border-bottom: none; }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.source { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .78rem; }
:where(html[data-input="mouse"]) .source:hover { border-color: var(--brand); }
.source i { font-style: normal; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: .68rem; font-weight: 700; }
.source span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 8px; color: var(--muted); }
.msg-actions button { border: none; background: transparent; color: inherit; min-height: 30px; width: 30px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; }
:where(html[data-input="mouse"]) .msg-actions button:hover { background: var(--surface-2); color: var(--text); }
.msg-actions button:disabled { opacity: .5; cursor: not-allowed; }
.msg-actions .regen.spinning svg { animation: msg-regen-spin .8s linear infinite; }
@keyframes msg-regen-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .msg-actions .regen.spinning svg { animation: none; } }
/* Like / dislike: no coloured pill. Off = the plain outline icon, on = the same icon filled solid in the accent
   colour (yellow with the yellow accent). The look follows aria-pressed and nothing else, with no transition, so
   switching it off is instant. */
.msg-actions button.up, .msg-actions button.down { transition: none; }
.msg-actions button[aria-pressed="true"], .msg-actions button.down[aria-pressed="true"] { color: var(--brand); background: transparent; }
:where(html[data-input="mouse"]) .msg-actions button.up[aria-pressed="true"]:hover, :where(html[data-input="mouse"]) .msg-actions button.down[aria-pressed="true"]:hover { color: var(--brand); background: var(--surface-2); }
.msg-actions button[aria-pressed="true"] svg { fill: currentColor; }
.msg-actions .note { font-size: .76rem; margin-left: 8px; }
/* Speak aloud (js/speak.js): the speaker icon turns into a round Stop button while the reply is being read. */
.msg-actions button.speak.speaking { color: var(--text); }
.msg-actions button.speak .stop-dot { fill: var(--bg); }
.msg-actions button.speak svg { fill: none; }
.msg-actions button.speak.speaking svg { fill: none; }

/* Follow-up suggestions live inside the reply's own last lines — a ↳-prefixed line per
   suggestion, styled like a natural "I can do X. ↳ do X" continuation, not a separate row of
   boxes/pills below the message actions. */
.inline-followups { margin: .6em 0 0; }
.inline-followup-line { margin: .15em 0 0; font-size: .95em; line-height: 1.5; }
.inline-followup-hook { display: inline-block; margin-right: 6px; color: var(--muted, var(--text)); opacity: .7; }
.inline-followup-link { color: var(--brand); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent); text-underline-offset: 2px; cursor: pointer; }
.inline-followup-link:focus-visible { text-decoration-color: var(--brand); }
:where(html[data-input="mouse"]) .inline-followup-link:hover { text-decoration-color: var(--brand); }
/* Inline tap option inside a paragraph: "I can ↪ examine them and tell you what they do." */
.inline-tap-hook { color: var(--muted, var(--text)); opacity: .7; }
.inline-tap { color: var(--brand); text-decoration: underline dotted; text-decoration-color: color-mix(in srgb, var(--brand) 60%, transparent); text-underline-offset: 3px; cursor: pointer; }
.inline-tap:focus-visible { text-decoration-style: solid; text-decoration-color: var(--brand); }
:where(html[data-input="mouse"]) .inline-tap:hover { text-decoration-style: solid; text-decoration-color: var(--brand); }

.typing { display: inline-flex; gap: 5px; padding: 10px 0; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: pulse 1.1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
/* "Working… 12s" — joins the dots only when an answer is slow (js/working-timer.js). Numbers keep a fixed width so the text doesn't jitter. */
.typing-timer { display: none; margin-left: 6px; font-size: .82rem; line-height: 1.2; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; -webkit-text-size-adjust: 100%; }
.typing-timer.on { display: inline; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

.composer-wrap { padding: calc(8px * var(--density)) 14px calc(12px * var(--density) + env(safe-area-inset-bottom)); background: var(--bg); }
.composer { max-width: 800px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 7px 7px 7px 16px; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
/* ---------- Composer live shortcut preview ----------
   msg-input-backdrop sits directly under the textarea, same font/padding/line-height, and
   shows the same text with the markdown marker characters rendered faded (.sc-mark) and the text they
   wrap rendered bold/italic/underlined/code (renderComposerPreview() in chat.js rebuilds it on
   every input). The real textarea stays on top with transparent text and a visible caret, so
   typing, selecting and the wrap-on-select shortcuts (Ctrl+B etc.) all still work exactly as
   before — only its text color changes, nothing about its behavior. */
.composer-input-wrap { position: relative; flex: 1 1 auto; min-width: 0; --composer-preview: 1; max-height: 176px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; }
/* The chip and the text live in ONE scrolling box: the chip is the first row, so a long message scrolls it out of view like normal text. */
.composer-field { position: relative; }
#msg-input-backdrop {
  position: absolute; inset: 0; margin: 0; z-index: 0; pointer-events: none; overflow: hidden;
  font: inherit; font-size: 1rem; padding: calc(9px * var(--density)) 0; line-height: 1.45;
  white-space: pre-wrap; word-wrap: break-word; word-break: break-word; color: var(--text);
}
.composer-input-wrap textarea { position: relative; z-index: 1; display: block; width: 100%; }
/* Text is only made transparent once chat.js has confirmed this stylesheet (and so the preview
   layer) is really loaded — a stale cached CSS can never leave typed text invisible. */
.composer-input-wrap.preview-on textarea { color: transparent; caret-color: var(--text); }
.sc-mark { opacity: .38; }
/* The preview layer sits UNDER a transparent textarea, so every glyph must keep exactly the
   width of the plain text or the caret drifts away from what you see. That's why bold uses a
   thin outline instead of a wider bold face, and code keeps the normal font (tinted, not mono). */
#msg-input-backdrop b { font-weight: inherit; -webkit-text-stroke: .045em currentColor; }
#msg-input-backdrop code { font-family: inherit; font-size: inherit; background: var(--brand-soft); border-radius: 4px; }
.composer textarea { border: none; background: transparent; box-shadow: none !important; padding: calc(9px * var(--density)) 0; min-height: 24px; max-height: none; overflow: hidden; resize: none; line-height: 1.45; }
.composer .send { width: 44px; height: 44px; border-radius: 50%; padding: 0; display: grid; place-items: center; flex: none; }
/* Nothing typed yet → Send looks clearly inactive: a flat grey button with a muted arrow (not a faded
   version of the coloured one), so it reads as "can't tap yet". It turns into the normal coloured button
   the moment there is text. Attachments alone can't be sent, so it stays grey until there is text. */
.composer .send.is-empty:not(:disabled) {
  background: var(--surface-3); border-color: var(--surface-3); color: var(--muted); opacity: 1; cursor: not-allowed;
}
:where(html[data-input="mouse"]) .composer .send.is-empty:not(:disabled):hover {
  background: var(--surface-3); border-color: var(--surface-3); color: var(--muted); opacity: 1; cursor: not-allowed;
}
.composer .send svg { stroke-width: 2.2; }
/* While MOMU is answering, Send becomes Stop: same round button, a square instead of the arrow. */
.composer .send .ico-stop { display: none; width: 24px; height: 24px; }
.composer .send.is-stop .ico-stop { display: block; }
.composer .send.is-stop .ico-send { display: none; }
.composer .send.is-stop, .composer .send.is-stop.is-empty:not(:disabled) { cursor: pointer; opacity: 1; background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
:where(html[data-input="mouse"]) .composer .send.is-stop:hover { cursor: pointer; opacity: 1; background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.hint-link { color: inherit; text-decoration: none; }
.hint-link:hover, .hint-link:focus-visible { text-decoration: underline; text-underline-offset: 2px; }
.incog-foot .hint-link { pointer-events: auto; }
.composer-hint { max-width: 800px; margin: 6px auto 0; text-align: center; font-size: .74rem; color: var(--muted); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s; }

/* ---------- Modal / sheet ---------- */
.modal-backdrop { position: fixed; inset: 0; height: 100vh; height: 100dvh; height: calc(var(--app-vh, 1vh) * 100); z-index: 100; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 520px; max-height: min(88vh, 760px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px 8px; }
.modal-head h2 { flex: 1; min-width: 0; font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-head .ghost.icon { flex: none; }
.modal-body { padding: 8px 20px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.setting-group { display: flex; flex-direction: column; gap: 12px; }
.setting-group > h3 { font-size: .95rem; color: var(--muted); font-weight: 600; font-family: var(--font-text); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.setting-row .txt { min-width: 0; }
.setting-row .txt b { display: block; font-weight: 500; font-size: .98rem; }
.setting-row .txt small { color: var(--muted); font-size: .82rem; line-height: 1.35; display: block; }

/* ---------- Profile picture adjuster (drag to pan, +/- or slider to zoom) ----------
   The card, hint text and footer are themed like every other dialog in the app (.modal,
   .modal-head, .modal-foot — see above) so it never looks like a bolted-on widget. Only the
   circular photo stage stays a near-black "inkwell" regardless of light/dark mode: a dimmed
   photo needs a dark backdrop to actually read as dimmed, the same reason every photo picker
   (not just this app) keeps its crop canvas dark. Its tone still borrows the app's own accent
   hue at very low saturation/lightness, so it reads as this app's ink rather than a generic
   black rectangle. */
.avatar-crop-card { max-width: 400px; }
.avatar-crop-hint { margin: -8px 0 0; color: var(--muted); font-size: .86rem; }
.avatar-crop-stage { display: flex; align-items: center; justify-content: center; padding: 22px 0 4px; }
.avatar-crop-viewport {
  position: relative; width: min(64vw, 264px); height: min(64vw, 264px); border-radius: 22px;
  background: hsl(var(--h) 20% 6%); touch-action: none; cursor: grab;
  box-shadow: 0 0 0 1px var(--line), 0 14px 34px rgba(0,0,0,.35);
}
.avatar-crop-viewport.dragging { cursor: grabbing; }
/* The photo is shown twice, at identical size/position (settings.js keeps both in lockstep),
   so the whole square reads as one continuous picture: .avatar-crop-dim is the full square,
   dimmed, so you can see the rest of the photo around the crop (its rounded corners just
   echo the viewport's own) — .avatar-crop-mask is the same picture at full brightness,
   clipped to a circle smaller than the square via clip-path, and that gap between circle and
   square is exactly what lets the dimmed corners show through. The ring is a purely decorative
   outline sized to match the clip-path circle. CROP_CIRCLE in settings.js (0.84) must stay
   equal to this clip-path radius (42% = half of 84%) and the ring's 84% width/height, or the
   visible circle and the exported crop will disagree. */
.avatar-crop-dim, .avatar-crop-mask { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: 22px; }
.avatar-crop-dim img, .avatar-crop-mask img { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.avatar-crop-dim img { opacity: .28; filter: saturate(.8); }
.avatar-crop-mask { clip-path: circle(42% at 50% 50%); }
.avatar-crop-ring {
  position: absolute; inset: 0; margin: auto; width: 84%; height: 84%; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 3px hsl(var(--h) 20% 6%), 0 0 0 5px var(--brand);
}
/* Zoom: a slider track (drag or click to jump straight to a level, arrow keys when focused)
   flanked by +/- buttons for a precise nudge — the fill and thumb position both track
   cropScale live via cropUpdateZoomUI() in settings.js. */
.avatar-crop-zoom-row { display: flex; align-items: center; gap: 14px; padding: 16px 2px 4px; }
.avatar-crop-zoom-btn {
  flex: none; width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 50%; position: relative; z-index: 1;
  display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
:where(html[data-input="mouse"]) .avatar-crop-zoom-btn:hover { background: var(--surface-3); }
.avatar-crop-zoom-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
/* The track owns its thumb: --p (0..1, set by cropUpdateZoomUI) moves the fill, and the thumb is pinned to the fill's right end,
   so it can never leave the track and touch the +/- buttons. ::before is an invisible taller hit area for fingers. */
.avatar-crop-zoom-track {
  --p: 0; --thumb: 20px;
  position: relative; flex: 1 1 auto; min-width: 0; height: 6px; border-radius: 999px; background: var(--surface-3); cursor: pointer; touch-action: none;
}
.avatar-crop-zoom-track::before { content: ""; position: absolute; inset: -14px 0; }
.avatar-crop-zoom-track:focus-visible { outline: 2px solid var(--brand); outline-offset: 6px; }
.avatar-crop-zoom-fill {
  position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--brand);
  width: calc(var(--thumb) + (100% - var(--thumb)) * var(--p));
}
.avatar-crop-zoom-fill::after {
  content: ""; position: absolute; right: 0; top: 50%; width: var(--thumb); height: var(--thumb); border-radius: 50%; box-sizing: border-box;
  background: var(--brand); border: 3px solid var(--surface); transform: translateY(-50%); box-shadow: 0 1px 5px rgba(0,0,0,.35);
}
/* No stray scrollbar beside the +/- buttons; short phones shrink the photo instead of scrolling. */
.avatar-crop-card .modal-body { overflow-x: hidden; scrollbar-width: none; }
.avatar-crop-card .modal-body::-webkit-scrollbar { display: none; }
.avatar-crop-card { max-height: min(92dvh, 760px); }
@media (max-width: 480px) {
  /* The photo takes whatever height is left after the title, hint, slider and buttons, so the zoom row is always on screen. */
  .avatar-crop-viewport { width: clamp(120px, min(58vw, 220px, calc(100vh - 400px)), 220px); height: clamp(120px, min(58vw, 220px, calc(100vh - 400px)), 220px); }
  .avatar-crop-viewport { width: clamp(120px, min(58vw, 220px, calc(100dvh - 400px)), 220px); height: clamp(120px, min(58vw, 220px, calc(100dvh - 400px)), 220px); }
  .avatar-crop-hint { margin-block: 0 6px; font-size: .92rem; }
  .avatar-crop-zoom-row { padding-top: 12px; }
}
@media (max-height: 600px) { .avatar-crop-hint { display: none; } }

/* ---------- Attachment viewers (picture / file previews are full screen; pasted text is a card) ---------- */
.msg-images img, .file-chip.viewable, .attach-thumb.viewable { cursor: pointer; }
.edit-box .edit-attachments .msg-images img, .edit-box .edit-attachments .msg-files .file-chip { cursor: default; }
:where(html[data-input="mouse"]) .file-chip.viewable:hover { background: var(--surface-3); }

/* Full-screen viewers: a top bar with the ✕ on the left, then the title, then the actions. */
.modal-backdrop.viewer-full { padding: 0; background: var(--bg); align-items: stretch; justify-content: stretch; z-index: 120; }
.modal-backdrop.viewer-full .modal.viewer-card {
  width: 100%; max-width: none; height: 100%; max-height: none; border: none; border-radius: 0; box-shadow: none;
  background: var(--surface); overflow: hidden;
}
.viewer-bar {
  flex: none; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line);
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  background: var(--surface);
}
.viewer-title { flex: 1; min-width: 0; padding: 0 4px; }
.viewer-title h2 { font-size: 1.02rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title small { display: block; color: var(--muted); font-size: .78rem; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .viewer-x { flex: none; }
.viewer-bar button.icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.img-viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: hsl(var(--h) 20% 6%); overflow: hidden; padding: 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
.img-viewer-stage.zoomed { cursor: grab; }
.img-viewer-stage.zoomed:active { cursor: grabbing; }
.img-viewer-stage img { transform-origin: center center; will-change: transform; -webkit-user-drag: none; display: block; max-width: 100%; max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); object-fit: contain; }

.file-viewer-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 16px 20px; background: var(--surface-2); -webkit-overflow-scrolling: touch; }
.file-viewer-pages { max-width: 900px; margin: 0 auto; }
.file-viewer-pages canvas { display: block; width: 100%; height: auto; margin: 0 auto 12px; background: #fff; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.file-viewer-pages-note { color: var(--muted); font-size: .82rem; text-align: center; padding: 6px 0 2px; }
.file-viewer-loading { color: var(--muted); font-size: .9rem; padding: 20px 0; text-align: center; }
.file-viewer-text {
  max-width: 820px; margin: 0 auto; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: .92rem; line-height: 1.55; color: var(--text);
}
.viewer-foot { flex: none; justify-content: center; gap: 8px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); }
@media (max-width: 520px) {
  .viewer-foot button { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; }
  .file-viewer-body { padding: 10px 8px 14px; }
  .file-viewer-text { padding: 14px; }
}

/* Top-bar buttons of the viewers (Copy / Download / Open): icon + word on wide screens, icon only on phones. */
.modal-backdrop.viewer-full .modal.viewer-card { position: relative; }
.vbtn {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--text);
  font: inherit; font-size: .88rem; font-weight: 500; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
:where(html[data-input="mouse"]) .vbtn:hover { background: var(--surface-2); }
.vbtn svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.vbtn[aria-disabled="true"] { opacity: .4; pointer-events: none; }
@media (max-width: 600px) {
  .vbtn { padding: 0; width: 40px; }
  .vbtn .vb-label { display: none; }
  .vbtn.copied-text { width: auto; padding: 0 10px; }
  .viewer-bar { gap: 4px; }
}
/* zoom − 100% + : floats at the bottom centre of a full-screen viewer */
.zoom-bar {
  position: absolute; left: 50%; bottom: max(16px, calc(env(safe-area-inset-bottom) + 10px)); transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.zoom-bar button { min-height: 36px; width: 38px; padding: 0; border: none; border-radius: 999px; background: transparent; color: var(--text); display: inline-grid; place-items: center; touch-action: manipulation; }
.zoom-bar button.zoom-pct { width: auto; min-width: 58px; padding: 0 8px; font-size: .84rem; font-variant-numeric: tabular-nums; }
.zoom-bar svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
:where(html[data-input="mouse"]) .zoom-bar button:hover { background: var(--surface-2); }
.file-viewer-body { touch-action: pan-x pan-y; padding-bottom: 84px; overscroll-behavior: contain; }
.file-viewer-pages canvas { max-width: none; }

/* Pasted-text preview: full screen like the other previews — top bar (X, title, Undo/Redo on phones, Copy, Download), roomy text, Close / Show in chat / Save at the bottom. */
.modal-backdrop.viewer-full .modal.paste-card { display: flex; flex-direction: column; }
.paste-bar .viewer-title { flex: 1; }
.paste-undo-pill { flex: none; display: none; align-items: center; gap: 2px; padding: 3px 6px; border-radius: 999px; background: var(--surface-2); }
.paste-undo-pill.hidden { display: none !important; }
.paste-undo-pill button { width: 38px; height: 36px; min-height: 36px; padding: 0; border: none; border-radius: 999px; background: transparent; color: var(--text); display: grid; place-items: center; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.paste-undo-pill button:disabled { opacity: .35; }
.paste-undo-pill svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* touch behaviour (was a media query; now follows html[data-input], see theme-init.js) */
 html[data-input="touch"] .paste-undo-pill:not(.hidden) { display: inline-flex; } 

.paste-body { flex: 1; min-height: 0; display: flex; padding: 14px 8px 8px 18px; background: var(--surface); }
.paste-body textarea {
  flex: 1; width: 100%; max-width: 860px; margin: 0 auto; min-height: 0; resize: none; border: none; outline: none; background: transparent; color: var(--text);
  font: inherit; font-size: .98rem; line-height: 1.65; padding: 4px 12px 6px 0; overflow: auto;
  -webkit-overflow-scrolling: touch; overscroll-behavior: contain; box-shadow: none; border-radius: 0;
}
.paste-body textarea:focus { box-shadow: none; outline: none; }
.paste-body textarea:disabled { opacity: .6; }
.paste-foot { flex: none; display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.paste-foot button { min-height: 42px; min-width: 110px; padding: 0 20px; border-radius: 999px; font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.paste-foot button.hidden { display: none; }
.paste-cancel { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
:where(html[data-input="mouse"]) .paste-cancel:hover { background: var(--surface-2); }
/* Save: grey and untouchable until the text really changed, then solid black (white in dark mode). */
.paste-save, .paste-save:disabled { border: 1px solid var(--surface-3); background: var(--surface-3); color: var(--muted); cursor: not-allowed; opacity: 1; }
.paste-save.is-ready:not(:disabled) { border-color: var(--text); background: var(--text); color: var(--surface); cursor: pointer; }
@media (max-width: 520px) {
  .paste-body { padding: 10px 4px 6px 14px; }
  .paste-foot { padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); gap: 8px; }
  .paste-foot button { flex: 1 1 0; min-width: 0; padding: 0 8px; font-size: .85rem; }
}

/* A copy button that says "Copied" (✓ + word) in green — used by the file / pasted-text previews. */
button.copied-text, button.copied.copied-text { background: var(--ok); border-color: var(--ok); color: #fff; gap: 6px; display: inline-flex; align-items: center; justify-content: center; }
button.copied-text svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
/* Once it says "Copied" it never changes on hover (the normal hover rules of .pbtn / .vbtn are stronger, so be explicit). */
button.copied-text, button.copied-text:hover, button.copied-text:focus, button.copied-text:active,
.vbtn.copied-text, .vbtn.copied-text:hover, .pbtn.copied-text, .pbtn.copied-text:hover:not(:disabled) { background: var(--ok) !important; border-color: var(--ok) !important; color: #fff !important; }

/* ---------- Responsive chat ---------- */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(86vw, 330px); transform: translateX(-102%); transition: transform .24s cubic-bezier(.3,.7,.2,1); padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
  :where(html[data-layout="compact"]) .sidebar.open { transform: none; }
  /* Resizing is a desktop (mouse-drag) concept only — keep the overlay sidebar's own width. */
  :where(html[data-layout="compact"]) .sidebar-resize-handle { display: none; }
  :where(html[data-layout="compact"]) .scrim.show { opacity: 1; pointer-events: auto; }
  /* Collapse is a desktop-only concept — on mobile the sidebar is an overlay that the
     hamburger (topbar .menu-btn) and the header's own X (#close-sidebar) already handle. */
  :where(html[data-layout="compact"]) #collapse-sidebar-btn { display: none; }
  :where(html[data-layout="compact"]) .app.sidebar-collapsed .topbar #expand-sidebar-btn { display: none; }
  :where(html[data-layout="compact"]) .topbar { padding-top: max(10px, env(safe-area-inset-top)); }
  :where(html[data-layout="compact"]) .topbar .menu-btn { display: inline-grid; }
  /* Slightly bigger tap targets on phones for the header icons people tap most — menu,
     incognito and "..." — just enough to make them easier to hit, not a visual overhaul. */
  :where(html[data-layout="compact"]) .topbar .menu-btn, :where(html[data-layout="compact"]) .topbar #incognito-btn, :where(html[data-layout="compact"]) .topbar #chat-more-btn, :where(html[data-layout="compact"]) #pj-proj-more, :where(html[data-layout="compact"]) button.topbar-newchat.ghost.icon {
    width: 42px; min-height: 42px;
  }
  :where(html[data-layout="compact"]) .topbar .menu-btn svg, :where(html[data-layout="compact"]) .topbar #chat-more-btn svg, :where(html[data-layout="compact"]) #pj-proj-more svg, :where(html[data-layout="compact"]) button.topbar-newchat.ghost.icon svg {
    width: 20px; height: 20px;
  }
  :where(html[data-layout="compact"]) .topbar #incognito-btn svg { width: 24px; height: 24px; }
  :where(html[data-layout="compact"]) .thread { padding: 18px 14px 8px; gap: 18px; }
  /* Same floating topbar as desktop, but its icons sit lower for the status bar/notch, so the
     thread's clearance underneath needs the same safe-area allowance. */
  :where(html[data-layout="compact"]) .main:not(.view-page) .topbar ~ .scroller .thread {
    padding-top: calc(56px + max(10px, env(safe-area-inset-top)) + 18px);
  }
  /* phone topbar = status-bar/notch gap + 42px circles + 10px, so the banner starts just below it */
  html[data-layout="compact"] { --floating-topbar-h: calc(max(10px, env(safe-area-inset-top)) + 42px + 10px); }
  :where(html[data-layout="compact"]) .main:not(.view-page) .topbar ~ .banner:not(.hidden) { margin-left: 10px; margin-right: 10px; font-size: .84rem; }
  :where(html[data-layout="compact"]) .main:not(.view-page) .topbar ~ .banner:not(.hidden) ~ .scroller .thread { padding-top: 10px; }
  :where(html[data-layout="compact"]) .suggestions { grid-template-columns: 1fr; }
  :where(html[data-layout="compact"]) .welcome { padding-top: 4vh; }
  :where(html[data-layout="compact"]) .msg .bubble { max-width: 92%; }
  :where(html[data-layout="compact"]) .jump { bottom: 120px; right: 14px; }
  /* No hover on touch, and no spare row for a tap target either — the pin/"..." buttons on a
     chat row and a project's own "..." button are hidden entirely on mobile (rather than
     forced visible) and holding the row down opens the same menu instead. See attachLongPress
     in chat.js. */
  :where(html[data-layout="compact"]) .chat-item .row-btn, :where(html[data-layout="compact"]) .chat-group-project .proj-menu-btn { display: none; }
  /* Dialogs stay a centered, content-sized card on mobile too (like a native alert) instead
     of a full-width sheet pinned to the screen edges — ".modal-backdrop .modal" outweighs the
     unconditional ".dialog-sm{max-width:440px}" rule further down so this actually wins. */
  :where(html[data-layout="compact"]) .modal-backdrop { padding: 20px; }
  :where(html[data-layout="compact"]) .modal-backdrop .modal { width: 100%; max-width: 400px; max-height: min(80dvh, 620px); border-radius: var(--radius-l); }
  :where(html[data-layout="compact"]) .composer-hint { display: none; }
  /* A confirm dialog's Cancel + action buttons live side by side in a 400px-wide modal,
     which is too narrow for a longer label ("Delete and turn off memory") — the label
     wraps onto two or three lines, and modal-foot's default stretch alignment then forces
     BOTH buttons up to that wrapped height, so even "Cancel" balloons to match. Stacking
     them full-width instead keeps every button a normal, single-line height. */
  :where(html[data-layout="compact"]) .dialog-sm .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  :where(html[data-layout="compact"]) .dialog-sm .modal-foot button { width: 100%; }
  /* Phones keep Admin/Settings as their own icons beside the profile, same as before — only
     desktop folds them into the dropdown (see .foot-actions above and .profile-trigger's
     click handler in chat.js, which no-ops on a touch-width screen). Sized up well past the
     old ~44px touch target so they read clearly next to the avatar, ChatGPT-app style. */
  :where(html[data-layout="compact"]) .foot-actions { display: flex; gap: 4px; }
  :where(html[data-layout="compact"]) .foot-actions a.icon, :where(html[data-layout="compact"]) .foot-actions button.icon { width: 52px; min-height: 52px; }
  :where(html[data-layout="compact"]) .foot-actions svg, :where(html[data-layout="compact"]) .foot-actions .icon-svg { width: 26px; height: 26px; }
  /* No dropdown to open here (Log out lives in Settings' own phone home list instead, see
     settings.html/.js) — the trigger is just the avatar + name, not an interactive control. */
  :where(html[data-layout="compact"]) .profile-trigger { cursor: default; }
  :where(html[data-layout="compact"]) .profile-trigger[aria-expanded="true"] { background: transparent; }
:where(html[data-layout="compact"][data-input="mouse"]) .profile-trigger:hover { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Admin ---------- */
.admin-bar { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.admin-bar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 18px 0; display: flex; flex-direction: column; gap: 6px; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-top .right { display: flex; gap: 8px; align-items: center; }
.admin-top .right button { white-space: nowrap; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 0 -18px; padding: 0 18px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: transparent; border: none; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 14px; min-height: 44px; color: var(--muted); white-space: nowrap; }
:where(html[data-input="mouse"]) .tab:hover { background: transparent; color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
/* Phone: the horizontal tab strip is replaced by the full-screen home list further down
   (#admin-mobile-home) — each admin section becomes its own full-width page instead of a
   cramped, side-scrolling row of tabs. Desktop keeps the tab strip untouched. */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .tabs { display: none; }

.admin-main { max-width: 1120px; margin: 0 auto; padding: 22px 18px calc(60px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 22px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.panel > h2 { font-size: 1.08rem; }
.panel > .sub { color: var(--muted); font-size: .9rem; margin: -8px 0 0; }
.grid { display: grid; gap: 14px; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.stats { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.stat { padding: 16px 16px 15px; min-width: 0; border-left: 1px solid var(--line); }
.stat:first-child { border-left: none; }
.stat .n { font-family: var(--font-display); font-size: 1.65rem; font-weight: 700; line-height: 1.1; letter-spacing: -.01em; }
.stat .l { color: var(--muted); font-size: .8rem; margin-top: 5px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .grow { flex: 1; min-width: 160px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.status-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.status-item:last-child { border-bottom: none; padding-bottom: 0; }
.status-item small { color: var(--muted); display: block; }

.chart { width: 100%; height: 150px; display: block; }
.chart .bar { fill: var(--brand); opacity: .85; }
.chart line { stroke: var(--line); }
.chart-labels { display: flex; margin-top: 4px; }
.chart-labels span { flex: 1; text-align: center; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.chart-labels span.off { visibility: hidden; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar .top { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 4px; }
.hbar .track { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; background: var(--brand); border-radius: 99px; }

/* Admin's Facts/Users tables: same touch handling as .table-wrap (chat's markdown tables) —
   without it this was the one horizontally-scrollable area in the app where a two-finger touch
   could still start a native pinch-zoom on mobile before the page-level gesture guard caught it. */
.table-scroll { overflow-x: auto; margin: 0 -18px; padding: 0 18px; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { color: var(--muted); font-weight: 500; font-size: .82rem; white-space: nowrap; }
table.data td.wrap { min-width: 220px; max-width: 420px; overflow-wrap: anywhere; }
table.data tr:last-child td { border-bottom: none; }

.cards { display: flex; flex-direction: column; gap: 10px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); min-width: 0; }
.card .q { font-weight: 600; overflow-wrap: anywhere; }
.card .a { color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; white-space: pre-wrap; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .a.open { -webkit-line-clamp: unset; display: block; }
.card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--muted); }
.card textarea { min-height: 90px; }
.empty { color: var(--muted); text-align: center; padding: 28px 12px; }
.kbd { font-family: var(--font-mono); font-size: .82rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; overflow-x: auto; white-space: pre; display: block; }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.compare .col { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; background: var(--bg); min-width: 0; }
.compare .col h3 { font-size: .95rem; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.compare .col .content { font-size: .93rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.save-bar { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; justify-content: flex-end; }
.save-bar .inner { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow); }
/* Auto-save status light in the admin header (there is no Save button — see admin.js). */
.save-status { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); min-width: 0; text-align: right; }
.save-status::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); opacity: .6; }
.save-status[data-state="saving"]::before { background: var(--warn); opacity: 1; animation: save-pulse 1s ease-in-out infinite; }
.save-status[data-state="saved"] { color: var(--text); }
.save-status[data-state="saved"]::before { background: var(--ok); opacity: 1; }
.save-status[data-state="error"] { color: var(--danger); }
.save-status[data-state="error"]::before { background: var(--danger); opacity: 1; }
.save-status button { min-height: 0; padding: 0; background: none; border: 0; box-shadow: none; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.field-error { color: var(--danger); font-size: .8rem; }
[aria-invalid="true"] { border-color: var(--danger) !important; }
@keyframes save-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .save-status[data-state="saving"]::before { animation: none; } }

/* Floating Save/Cancel bar for free-typed text boxes. Every other control (switches,
   segmented buttons, dropdowns) saves the instant it changes, but a half-typed sentence in a
   text box or textarea shouldn't be sent mid-keystroke — so those wait here for an explicit
   Save, or Cancel to put the box back to what's already saved. Sits near the header on a
   desktop-sized screen (.pos-top) and near the thumb, above the keyboard, on a phone
   (.pos-bottom) — see positionTextSaveBar() in settings.js / admin.js. */
.text-save-bar { position: fixed; left: 0; right: 0; z-index: 2147483000; display: flex; justify-content: center; padding: 0 14px; pointer-events: none; }
.text-save-bar.hidden { display: none; }
.text-save-bar.pos-top { bottom: calc(18px + env(safe-area-inset-bottom)); }
.text-save-bar.pos-bottom { bottom: calc(18px + env(safe-area-inset-bottom)); }
.text-save-bar .inner { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 10px 10px 16px; box-shadow: var(--shadow); max-width: 92vw; }
.text-save-bar .inner kbd { font: inherit; font-size: .72rem; opacity: .7; margin-left: 4px; }
.text-save-bar .inner span { font-size: .85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-save-bar .inner .actions { display: flex; gap: 8px; flex: none; }
/* Phones use the header checkmark (.header-save-btn) instead — never show the floating bar there. */
@media (max-width: 640px) { .text-save-bar, .text-save-bar:not(.hidden) { display: none !important; } }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .save-status:not([data-state="error"]) { font-size: 0; gap: 0; }
  .save-status[data-state="error"] { max-width: 46vw; font-size: .74rem; }
  /* Icon-only back button on Settings — matches the header check button beside it; the label is
     still there for a screen reader via aria-label on the link itself, just visually hidden.
     Scoped to #back-to-chat only, so the plain text-and-icon back button on other page-bar
     screens (My Devices, share/invite pages) is untouched. */
  #back-to-chat .btn-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  #back-to-chat { width: 38px; padding: 8px; gap: 0; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.cols-2, .compare, .form-grid { grid-template-columns: 1fr; }
  .admin-main { padding-top: 16px; }
  .panel { padding: 14px; }
  .table-scroll { margin: 0 -14px; padding: 0 14px; }
}

/* ---------- Image attachments ---------- */
.attach-strip { box-sizing: border-box; width: 100%; margin: 0; padding: 2px 2px 6px; display: flex; flex-wrap: nowrap; gap: 8px; align-items: flex-start; justify-content: flex-start; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.attach-strip > * { flex: none; }
.composer-input-wrap > .attach-strip { position: sticky; top: 0; z-index: 3; background: var(--surface); }
.attach-strip { --att-h: 46px; }
.attach-thumb { position: relative; flex: none; width: var(--att-h); min-width: var(--att-h); height: var(--att-h); min-height: var(--att-h); box-sizing: border-box; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-thumb.sketch img { background: #fff; }
.attach-thumb .sk-badge { position: absolute; left: 3px; bottom: 3px; width: 16px; height: 16px; border-radius: 50%; background: rgba(17,17,17,.72); color: #fff; display: grid; place-items: center; pointer-events: none; }
.attach-thumb .sk-badge svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.attach-thumb button, .attach-strip .af-remove { box-sizing: border-box; display: grid; place-items: center; padding: 0; margin: 0; aspect-ratio: 1 / 1; border-radius: 50%; line-height: 1; border: none; }
.attach-thumb button { position: absolute; top: 3px; right: 3px; width: 16px; min-width: 16px; height: 16px; min-height: 16px; background: rgba(17,17,17,.72); color: #fff; }
.attach-thumb button svg, .attach-strip .af-remove svg { width: 10px; height: 10px; stroke-width: 2.6; }
.composer .attach-btn { align-self: flex-end; margin-bottom: 2px; color: var(--muted); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
/* No leftover "pressed" look after a tap: the button only looks active while its menu is really open. */
.composer .attach-btn:focus:not(:focus-visible) { outline: none; }
.composer .attach-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }

/* ---------- Attach popup: "Camera" / "Choose files" / "Choose image" ----------
   Reuses the .row-menu look (see chat row "..." menu) so it feels like part of the same
   app rather than a bespoke control, but with slightly bigger icon-forward rows since it's
   only ever three items. Anchored to attach-btn's rect and flipped upward, same logic as
   openRowMenu — the composer sits at the bottom of the screen, so there's rarely room below. */
.attach-menu { min-width: 208px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; scrollbar-width: thin; }
.attach-menu button { min-height: 42px; flex: none; }
.attach-menu button svg { width: 19px; height: 19px; }
/* Desktop: a single "Add photos & files  Upload from computer" row (the phone keeps three rows). */
.attach-menu-pc { min-width: 300px; }
.attach-menu-pc .mi-label { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.attach-menu-pc .mi-sub { color: var(--muted); font-size: .85rem; font-weight: 400; }
/* the Sketch entry's scribble icon is teal (computer menu and phone sheet) */
.attach-menu button[data-act="sketch"] > svg:first-child, .as-row[data-as="sketch"] .as-row-ico svg { stroke: #20a58d !important; color: #20a58d; }

/* ---------- Camera: in-app mini screen ----------
   A rounded 3:4 card that sits at the bottom of the app over a dimmed page (on wide screens it is
   centred). Live: ‹ back · shutter · ⋮ more. Review: rotate + pencil on top, ← / → at the bottom. */
.camera-modal {
  position: fixed; inset: 0; z-index: 150; display: flex; align-items: flex-end; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom));
  background: rgba(8,10,14,.5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.camera-modal.hidden { display: none; }
@media (min-width: 720px) { .camera-modal { align-items: center; } }
.cam-card {
  position: relative; flex: none; width: min(100%, 440px); aspect-ratio: 3 / 4;
  max-height: 100%; border-radius: 30px; overflow: hidden; background: #0b0d10; color: #fff;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.cam-stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: #000; }
.cam-stage.drawing { cursor: crosshair; }
.cam-stage video { width: 100%; height: 100%; object-fit: cover; background: #000; display: block; }
.cam-stage video.mirror { transform: scaleX(-1); }
/* last picture kept on screen while the other camera starts (see freezeFrame() in chat.js) */
.cam-freeze { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; pointer-events: none; filter: brightness(.7) blur(2px); opacity: 1; transition: opacity .22s ease; }
.cam-freeze.mirror { transform: scaleX(-1); }
.cam-freeze.out { opacity: 0; }
#cam-edit {
  position: absolute; left: 50%; top: 50%; transform-origin: center; will-change: transform;
  transform: translate(-50%,-50%); max-width: none; background: #fff;
}
.cam-flash { position: absolute; inset: 0; z-index: 3; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.cam-flash.on { opacity: .8; transition: opacity 0s; }

/* round overlay buttons */
.camera-icon-btn {
  flex: none; position: relative; width: 54px; height: 54px; min-height: 54px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(22,24,28,.78); border: none; color: #fff; padding: 0;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); -webkit-tap-highlight-color: transparent;
}
.camera-icon-btn.sm { width: 46px; height: 46px; min-height: 46px; }
:where(html[data-input="mouse"]) .camera-icon-btn:hover { background: rgba(50,54,60,.85); }
.camera-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.camera-icon-btn:active { transform: scale(.94); }
.camera-icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.camera-icon-btn.cam-ok, .camera-icon-btn.active { background: #fff; color: #111; }
:where(html[data-input="mouse"]) .camera-icon-btn.cam-ok:hover, :where(html[data-input="mouse"]) .camera-icon-btn.active:hover { background: #ececec; }

/* bottom bar (live + review): non-blocking so pinch-zoom still works under it */
.cam-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 4; pointer-events: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 22px;
  background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.4));
}
.cam-bar > * { pointer-events: auto; }
.cam-bar > .cam-bar-gap { width: 54px; height: 54px; pointer-events: none; }
.camera-shutter {
  width: 76px; height: 76px; min-height: 76px; border-radius: 50%; padding: 0;
  background: rgba(20,22,26,.85); border: none; display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
}
.camera-shutter span { width: 60px; height: 60px; border-radius: 50%; background: #fff; transition: transform .1s; }
.camera-shutter:active span { transform: scale(.88); }
.camera-shutter:disabled { opacity: .6; }

/* ⋮ → a stack that grows upward: flashlight, switch camera, then the ⋮ which turns into ✕ */
.cam-more {
  position: absolute; right: 20px; bottom: 33px; z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.cam-more.hidden { display: none; }
.cam-more > #camera-flash-btn, .cam-more > #camera-flip {
  opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(16px) scale(.85);
  transition: opacity .16s, transform .16s, visibility 0s .16s;
}
.cam-more.open > #camera-flash-btn, .cam-more.open > #camera-flip {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity .16s, transform .16s, visibility 0s;
}
.cam-more.open > #camera-flip { transition-delay: 0s; }
.cam-more.open > #camera-flash-btn { transition-delay: .03s; }
.cam-more.solo-flash > #camera-flip { display: none; }
/* Computer: no flashlight (webcams have none), no "use the phone's camera app" fallback, and no empty ⋮ stack. */
body:not(.no-keyboard) #camera-flash-btn { display: none; }
body:not(.no-keyboard) #cam-perm-fallback { display: none; }
.cam-more.no-extras > #camera-more-btn { display: none; }
#camera-more-btn .ico-x { display: none; }
.cam-more.open #camera-more-btn .ico-x { display: block; }
.cam-more.open #camera-more-btn .ico-dots { display: none; }
/* flashlight icon follows its mode: auto (bolt + A) · on (solid bolt) · off (bolt with a slash) */
#camera-flash-btn .fl { display: none; }
#camera-flash-btn[data-mode="auto"] .fl-auto, #camera-flash-btn[data-mode="on"] .fl-on, #camera-flash-btn[data-mode="off"] .fl-off { display: block; }
#camera-flash-btn[data-mode="on"] { background: #ffd60a; color: #111; }
:where(html[data-input="mouse"]) #camera-flash-btn[data-mode="on"]:hover { background: #ffdf3d; }
/* No flashlight on this camera (front): same faded bolt-with-a-slash, never yellow, not tappable */
#camera-flash-btn.unavail { opacity: .45; background: rgba(20,22,26,.6); color: #fff; cursor: default; }
:where(html[data-input="mouse"]) #camera-flash-btn.unavail:hover { opacity: .45; background: rgba(20,22,26,.6); color: #fff; cursor: default; }

/* short status chip: "Flash on" etc. */
.cam-hint {
  position: absolute; top: 16px; left: 50%; z-index: 6; transform: translate(-50%, -6px); opacity: 0; pointer-events: none;
  padding: 7px 14px; border-radius: 999px; background: rgba(22,24,28,.82); color: #fff; font-size: .84rem; white-space: nowrap;
  transition: opacity .18s, transform .18s;
}
.cam-hint.show { opacity: 1; transform: translate(-50%, 0); }

/* review: top tools */
.cam-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 4; display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 14px 30px; background: linear-gradient(rgba(0,0,0,.5), rgba(0,0,0,0)); pointer-events: none;
}
.cam-top > * { pointer-events: auto; }
.cam-top.hidden { display: none; }
.cam-draw-bar {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%); z-index: 4; display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 999px; background: rgba(22,24,28,.82); max-width: calc(100% - 24px);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.cam-draw-bar.hidden { display: none; }
.cam-swatch {
  flex: none; width: 26px; height: 26px; min-height: 26px; padding: 0; border-radius: 50%;
  background: var(--c); border: 2px solid rgba(255,255,255,.55); box-sizing: border-box; -webkit-tap-highlight-color: transparent;
}
.cam-swatch:active, .cam-swatch:focus { background: var(--c); }
:where(html[data-input="mouse"]) .cam-swatch:hover { background: var(--c); }   /* the global button:hover would otherwise grey it out (and hover sticks after a tap) */
.cam-undo:active { background: rgba(255,255,255,.14); color: #fff; }
:where(html[data-input="mouse"]) .cam-undo:hover { background: rgba(255,255,255,.14); color: #fff; }
.cam-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.35); transform: scale(1.12); }
.cam-draw-sep { flex: none; width: 1px; height: 20px; background: rgba(255,255,255,.28); margin: 0 2px; }
.cam-undo { flex: none; width: 30px; height: 30px; min-height: 30px; padding: 0; display: grid; place-items: center; background: none; border: none; color: #fff; border-radius: 50%; }
.cam-undo svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.cam-undo:disabled { opacity: .35; }

/* permission gate */
.cam-perm {
  position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; text-align: center; padding: 28px; background: #0b0d10;
}
.cam-perm h3 { margin: 4px 0 0; font-size: 1.1rem; color: #fff; }
.cam-perm p { margin: 0; max-width: 300px; color: rgba(255,255,255,.72); font-size: .9rem; line-height: 1.5; }
.cam-perm .primary { margin-top: 6px; }
.cam-link { background: none; border: none; color: rgba(255,255,255,.7); font-size: .85rem; min-height: 36px; padding: 0 10px; text-decoration: underline; }
:where(html[data-input="mouse"]) .cam-link:hover { color: #fff; }
.msg-images { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.msg-images img { max-width: 180px; max-height: 180px; border-radius: 12px; border: 1px solid var(--line); object-fit: cover; cursor: zoom-in; background: var(--surface-2); min-width: 60px; min-height: 60px; }
.msg.user .stack { display: flex; flex-direction: column; align-items: flex-end; max-width: min(86%, 620px); min-width: 0; }
.msg.user .stack .bubble { max-width: 100%; }

/* ---------- Auth: Google button, divider, one-time-code input ---------- */
.auth-lede { color: var(--muted); font-size: .95rem; margin: 0 0 4px; line-height: 1.5; }
.auth-lede b { color: var(--text); overflow-wrap: anywhere; }
/* Custom-styled "Continue with Google" — a real button (not an embedded Google iframe: that
   turned out to silently fail on some browsers/networks with no visible error at all) that
   does a plain top-level redirect to Google's own sign-in page. Colored with --brand/
   --on-brand so it recolors automatically with the accent colour, same as every other button
   on the site. See startGoogleRedirect() in public/js/auth.js. */
.g-btn {
  width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--brand); color: var(--on-brand); border: none; border-radius: var(--radius-m); font-weight: 600;
  font-size: .95rem; cursor: pointer; transition: filter .15s; font-family: inherit;
}
/* No hover effect at all. The global button:hover (grey background) is stronger than .g-btn, so it painted the button near-white on hover: name every state and keep the colour. */
.g-btn:hover, .g-btn:focus, .g-btn:focus-visible, .g-btn:active { background: var(--brand); color: var(--on-brand); filter: none; }
.g-btn-icon { width: 22px; height: 22px; border-radius: 6px; background: #fff; display: grid; place-items: center; flex: none; }
.g-btn-icon svg { width: 14px; height: 14px; }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .82rem; margin: 2px 0; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.otp-input { text-align: center; letter-spacing: .6em; font-size: 1.3rem; font-weight: 700; padding-left: .6em; }

/* ---------- Standalone pages: Settings + My Devices ---------- */
.page-bar { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.page-bar-inner { max-width: 780px; margin: 0 auto; padding: 10px 18px; display: flex; align-items: center; gap: 10px; }
.page-bar-inner h1 { flex: 1; font-size: 1.2rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-bar a.btn, a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 14px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-decoration: none; font-size: .9rem; white-space: nowrap; }

/* Header "Save" checkmark: phone only (see the 641px+ rule below). Grey and inert with nothing
   pending; turns solid brand colour and tappable the instant a text/number box is edited — this
   sits in the sticky header so it's never covered by the on-screen keyboard, unlike the floating
   Save/Cancel bar near the bottom of the screen. Desktop is untouched: the existing bar + the
   "All changes saved" status text keep doing the whole job there, so this button just stays hidden. */
.header-save-btn {
  display: none; flex: none; width: 36px; height: 36px; margin-left: auto; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  align-items: center; justify-content: center; padding: 0; cursor: not-allowed;
}
.header-save-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.header-save-btn.has-changes { background: var(--brand); border-color: var(--brand); color: var(--on-brand); cursor: pointer; }
:where(html[data-input="mouse"]) .header-save-btn.has-changes:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.header-save-btn:disabled { pointer-events: none; }
@media (max-width: 640px) { .header-save-btn { display: flex; } }
:where(html[data-input="mouse"]) a.btn:hover { background: var(--surface-3); }
a.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); font-weight: 600; }
:where(html[data-input="mouse"]) a.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.page-nav { max-width: 780px; margin: 0 auto; padding: 0 18px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.page-nav::-webkit-scrollbar { display: none; }
.page-nav a { padding: 8px 12px; color: var(--muted); text-decoration: none; font-size: .88rem; white-space: nowrap; border-bottom: 2px solid transparent; }
:where(html[data-input="mouse"]) .page-nav a:hover { color: var(--text); }
.page-nav a.on { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.page-main { max-width: 780px; margin: 0 auto; padding: 20px 18px calc(90px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px; }
.page-main section.panel { scroll-margin-top: 110px; }

/* Settings: sidebar layout (left nav + one visible pane), like a native app's settings. */
.settings-shell { max-width: 1020px; margin: 0 auto; display: flex; align-items: flex-start; gap: 28px; padding: 22px 18px calc(90px + env(safe-area-inset-bottom)); }
.settings-sidebar { flex: none; width: 220px; position: sticky; top: 84px; display: flex; flex-direction: column; gap: 2px; }
.settings-sidebar button { display: flex; align-items: center; gap: 10px; text-align: left; background: transparent; border: none; border-radius: var(--radius-s); padding: 10px 12px; color: var(--muted); font-size: .92rem; min-height: 40px; cursor: pointer; }
.settings-sidebar button svg { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:where(html[data-input="mouse"]) .settings-sidebar button:hover { background: var(--surface-2); color: var(--text); }
.settings-sidebar button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
.settings-sidebar button.danger-link { color: var(--danger); }
.settings-sidebar button.danger-link.on { background: var(--danger-soft); color: var(--danger); }
:where(html[data-input="mouse"]) .settings-sidebar button.danger-link:hover { background: var(--danger-soft); color: var(--danger); }
.settings-content { flex: 1; min-width: 0; }
.settings-pane { display: none; }
/* A tall page opened by its #hash (settings.html#personalize) is scrolled into view by the browser itself;
   without this margin its first card's heading ends up hidden behind the sticky header on a phone. */
.settings-pane { scroll-margin-top: calc(76px + env(safe-area-inset-top, 0px)); }
.settings-pane.on { display: flex; flex-direction: column; gap: 14px; }
.settings-nav-select { display: none; }
/* [compact layout: phones only] */
  /* Bug fix: the base rule above sets align-items: flex-start for the desktop
     sidebar+content row layout. Left in place here, a column-direction flex child
     (like .settings-mobile-home) sizes to its own content instead of the full
     width of the shell — which is exactly why the phone home list used to render
     "half width" while the Admin panel's equivalent (a plain body-level div, not
     inside this flex shell) rendered full width right beside it. Stretching the
     cross-axis here makes every child, including the phone home list, fill the
     shell the same way the Admin panel already did. */
  :where(html[data-layout="compact"]) .settings-shell { flex-direction: column; align-items: stretch; gap: 14px; padding-left: 0; padding-right: 0; }
  :where(html[data-layout="compact"]) .settings-sidebar { display: none; }
  :where(html[data-layout="compact"]) .settings-nav-select {
    display: block; width: calc(100% - 36px); margin: 0 18px 4px; min-height: 46px;
    padding: 10px 40px 10px 14px; border-radius: var(--radius-m); border: 1px solid var(--line);
    background-color: var(--surface); color: var(--text); font-size: .95rem; font-family: inherit;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
  }
  :where(html[data-layout="compact"]) .settings-nav-select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
  :where(html[data-layout="compact"]) .settings-content { padding: 0 18px; width: 100%; }


/* ---------- Phone-only "home" screens for Settings and the Admin panel ----------
   Below 860px each page shows one of two views, tracked as body[data-mobile-view]
   ("home" or "section" — see settings.js / admin.js). Default is "home": the full list
   of sections (a profile card on Settings, a plain title on Admin) — the actual page
   content only takes over once a row has been picked (or a #hash landed on one
   directly), which is when JS flips the attribute to "section". Desktop never sees
   either home screen — they're display:none outside the media query below, and the
   attribute itself is ignored there. */
.settings-mobile-home, .admin-mobile-home { display: none; }

/* Settings home: profile picture centered up top, name underneath — matching a native
   app's own "you" page (avatar, then name, then the section list below). The small
   pencil badge overlaps the avatar's bottom-right edge and opens Profile, the one place
   the picture and nickname actually get changed. */
.smh-profile { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 2px 26px; text-align: center; }
.smh-avatar-wrap { position: relative; }
.avatar-xl { width: 92px; height: 92px; font-size: 2rem; }
.smh-avatar-edit {
  position: absolute; right: -3px; bottom: -3px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--bg); color: var(--text);
  display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
}
.smh-avatar-edit svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
:where(html[data-input="mouse"]) .smh-avatar-edit:hover { background: var(--surface-2); }
.smh-profile b { font-size: 1.1rem; font-weight: 700; }

/* Admin home: no picture/name (there's no "you" here) — instead a small branded mark so
   the page still reads as its own place rather than a reskinned Settings screen. */
.amh-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 4px 2px 26px; text-align: center; }
.amh-logo { width: 52px; height: 52px; border-radius: 16px; background: var(--brand-soft); display: flex; align-items: center; justify-content: center; }
.amh-logo img { width: 30px; height: 30px; display: block; }
.amh-brand h2 { margin: 0; font-size: 1.2rem; }
.amh-brand .amh-sub { margin: 0; font-size: .86rem; color: var(--muted); max-width: 300px; }

/* Shared row-list look for both home screens — a small label over each group, then the
   group's rows as their own individually-rounded pills with a gap between (not one
   card with divider lines) — no trailing chevron; the pill shape itself is the "this
   is tappable" signal. */
.mm-group-label { margin: 0 4px 8px; font-size: .78rem; color: var(--muted); }
.mm-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }
.mm-row {
  width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
  background: var(--surface-2); border: none; border-radius: 16px;
  padding: 15px 16px; min-height: 52px; color: var(--text); font-size: .97rem; cursor: pointer;
}
.mm-row.on { background: var(--surface-3); }
:where(html[data-input="mouse"]) .mm-row:hover { background: var(--surface-3); }
.mm-ico { flex: none; width: 1.4em; text-align: center; font-size: 1.05rem; }
.mm-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-row.danger-link { color: var(--danger); }
:where(html[data-input="mouse"]) .mm-row.danger-link:hover { background: var(--danger-soft); }

/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .settings-mobile-home { display: block; padding: 0 18px; }
  :where(html[data-layout="compact"]) .settings-content { display: none; }
  :where(html[data-layout="compact"]) body[data-mobile-view="section"] .settings-mobile-home { display: none; }
  :where(html[data-layout="compact"]) body[data-mobile-view="section"] .settings-content { display: block; }

  :where(html[data-layout="compact"]) .admin-mobile-home { display: block; max-width: 1120px; margin: 0 auto; padding: 8px 18px calc(60px + env(safe-area-inset-bottom)); }
  :where(html[data-layout="compact"]) .admin-main { display: none; }
  :where(html[data-layout="compact"]) body[data-mobile-view="section"] .admin-mobile-home { display: none; }
  :where(html[data-layout="compact"]) body[data-mobile-view="section"] .admin-main { display: flex; }

  /* Home list has nothing to save or refresh — those only mean something once a
     section/page with actual fields is open, so keep them out of the header until then. */
  :where(html[data-layout="compact"]) body[data-mobile-view="home"] .header-save-btn, :where(html[data-layout="compact"]) body[data-mobile-view="home"] .save-status, :where(html[data-layout="compact"]) body[data-mobile-view="home"] #refresh-btn { display: none; }

.panel.danger-zone { border-color: var(--danger-soft); }
.panel.danger-zone > h2 { color: var(--danger); }
.panel details { border-top: 1px solid var(--line); padding-top: 10px; }
.panel details summary { cursor: pointer; font-size: .95rem; padding: 4px 0; }
.link-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.save-note { color: var(--muted); font-size: .85rem; }

/* My Devices */
.dev-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.dev-head h2 { font-size: 1.6rem; }
.dev-head p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.dev-head .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.notice { border: 1px solid var(--warn); background: rgba(217,130,74,.1); border-radius: var(--radius-m); padding: 14px 16px; }
.notice b { display: block; color: var(--warn); margin-bottom: 3px; }
.notice p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.dev-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.dev-stat { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-m); padding: 18px; }
.dev-stat .n { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.dev-stat .l { color: var(--muted); font-size: .82rem; margin-top: 6px; }
.dev-list { display: flex; flex-direction: column; gap: 12px; }
.device { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-m); padding: 16px 18px; }
.device.current { border-color: var(--brand); }
.dev-ico { width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.dev-ico svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dev-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 600; }
.dev-sub { color: var(--brand); font-size: .9rem; margin-top: 3px; }
.dev-meta { display: flex; gap: 6px 26px; flex-wrap: wrap; margin-top: 8px; font-size: .78rem; color: var(--muted); }
.dev-meta b { color: var(--text); font-weight: 600; }
.dev-note { margin: 14px 2px 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.dev-empty { text-align: center; color: var(--muted); padding: 28px 12px; border: 1px dashed var(--line); border-radius: var(--radius-m); }
@media (max-width: 640px) {
  .dev-stats { grid-template-columns: 1fr; }
  .dev-stat { display: flex; align-items: baseline; gap: 12px; padding: 14px 16px; }
  .device { grid-template-columns: auto minmax(0, 1fr); }
  .device .dev-action { grid-column: 1 / -1; }
  .device .dev-action button { width: 100%; }
  .dev-head .btns { width: 100%; }
  .dev-head .btns > * { flex: 1; }
}

/* ==========================================================================
   Chat row menu, share + delete dialogs, custom select, shortcuts
   ========================================================================== */

/* ---------- Chat row: "..." menu plus a dedicated pin button ----------
   Rename/share/delete live behind the "..." menu; pin also gets its own button beside it
   (.pin-btn — see .chat-item .row-btn.pin-btn above) so pinning/unpinning is one click
   either way. It stays out of the way until the row is actually hovered/focused (or the
   chat is already pinned, or the screen is touch-only — see .chat-item .row-btn { opacity:
   1 } in the mobile media query), so it's not a stray tap away from the chat you meant to
   open. */
:where(html[data-input="mouse"]) .chat-item .row-btn.menu-btn-row:hover { color: var(--text); background: var(--surface-3); }
.chat-item .row-btn.menu-btn-row[aria-expanded="true"] { opacity: 1; color: var(--text); background: var(--surface-3); }

.row-menu {
  position: fixed; z-index: 120; min-width: 196px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px;
}
.row-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px;
  padding: 8px 10px; border: none; background: transparent; color: var(--text);
  border-radius: var(--radius-s); font-size: .92rem; text-align: left; justify-content: flex-start;
}
.row-menu button span.mi-label { flex: 1; }
:where(html[data-input="mouse"]) .row-menu button:hover { background: var(--surface-2); }
.row-menu button svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.row-menu .stop-dot { fill: var(--surface); }
.row-menu .sep { height: 1px; background: var(--line); margin: 4px 2px; }
.row-menu button.danger-item { color: var(--danger); }
:where(html[data-input="mouse"]) .row-menu button.danger-item:hover { background: var(--danger-soft); }
/* The single-letter key hint shown at the right of a row-menu item on desktop (e.g. "P" for
   Pin, "R" for Rename, "D" for Delete) — pressing that key while the menu is open runs the
   action, same as the icon/label the hint sits next to. Hidden on touch-only devices since
   there's no keyboard to show a hint for. */
.row-menu .mi-key {
  flex: none; min-width: 20px; height: 20px; padding: 0 5px; display: grid; place-items: center;
  border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); font-size: .74rem; font-weight: 600; font-family: inherit;
}
body.no-keyboard .row-menu .mi-key { display: none; }
.row-menu button.mi-has-sub svg.mi-chevron { width: 15px; height: 15px; opacity: .6; }

/* ---------- Add to project dialog ---------- */
.project-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; margin: 2px 0; }
.project-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; padding: 8px 10px;
  border: none; background: transparent; color: var(--text); border-radius: var(--radius-s);
  font-size: .93rem; text-align: left; cursor: pointer;
}
:where(html[data-input="mouse"]) .project-row:hover { background: var(--surface-2); }
.project-row.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.project-row svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; flex: none; }
.project-row .proj-count { margin-left: auto; color: var(--muted); font-size: .8rem; font-weight: 400; }
.project-row.active .proj-count { color: var(--brand); }
.project-new-row { display: flex; gap: 8px; margin-top: 8px; }
.project-new-row input { flex: 1; }
.project-empty-note { color: var(--muted); font-size: .88rem; margin: 4px 0 0; }
/* The dedicated Projects folder browser (nav item → #projects-dialog) gets more room than
   the small "Add to project" picker, since it's the primary way to reach a project now. */
.projects-folder-list { max-height: min(50vh, 420px); }
.projects-folder-list .proj-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Search chats dialog ---------- */
.search-modal { max-width: 560px; padding: 0; }
.search-modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.search-modal-head svg:first-child { width: 18px; height: 18px; color: var(--muted); stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; flex: none; }
.search-modal-head input { flex: 1; border: none; background: transparent; font-size: 1rem; padding: 6px 0; min-height: 0; }
.search-modal-head input:focus { outline: none; box-shadow: none; }
/* The native round "x" clear button is replaced by the explicit .search-modal-clear text
   button below, so it's hidden here rather than left to double up with it. */
.search-modal-head input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.search-modal-clear { flex: none; padding: 6px 10px; font-size: .88rem; color: var(--muted); min-height: 0; border-right: 1px solid var(--line); border-radius: 0; }
:where(html[data-input="mouse"]) .search-modal-clear:hover { color: var(--text); background: transparent; }
.search-modal-clear.hidden { display: none; }
.search-modal-list { max-height: min(60vh, 480px); overflow-y: auto; padding: 8px; }
.search-modal-list .chat-item .row-btn { display: none; }

/* ---------- Confirm / share dialogs ---------- */
.dialog-sm { max-width: 440px; }
.dialog-sm .modal-body { gap: 10px; padding-top: 18px; }
.dialog-sm h2 { font-size: 1.15rem; margin: 0; }
.dialog-sm p { color: var(--text); font-size: .95rem; margin: 0; }
.dialog-sm p.sub { color: var(--muted); font-size: .86rem; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
/* The global button:hover (grey/pale background) is stronger than .btn-danger, so in light mode the red confirm button
   (Delete, Delete all reports, Remove …) went pale with white text on hover and the label vanished. Keep it red in every state. */
button.btn-danger:hover:not(:disabled), button.btn-danger:focus:not(:disabled), button.btn-danger:active:not(:disabled) { background: var(--danger); color: #fff; border-color: transparent; }
:where(html[data-input="mouse"]) button.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

/* ---------- Checkbox option list (e.g. "Delete all chats" dialog's extra options) ---------- */
.check-list { display: flex; flex-direction: column; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; font-size: .92rem; color: var(--text); cursor: pointer; }
.check-row input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; flex: none; accent-color: var(--brand); cursor: pointer; }

/* ---------- Bulleted note list (e.g. the "Delete account" dialog) ---------- */
.bullet-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.bullet-list li::marker { color: var(--muted); }

/* A disabled danger button (the locked "Delete my account" confirm) shouldn't look clickable
   even though .btn-danger otherwise reads as an inviting solid color. */
.btn-danger:disabled { background: var(--surface-3); color: var(--muted); }
.btn-danger:disabled .lock-ico { opacity: .8; }

/* Preview box: a soft tint of the accent colour (surface + one layer of --brand-soft, plain
   alpha layering, so it works on every browser — no color-mix needed). The person's message
   sits in a stronger accent bubble, and MOMU's reply gets its own bordered bubble on top. */
.share-preview {
  border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px;
  background-color: var(--surface-2);
  background-color: var(--surface); background-image: linear-gradient(var(--brand-soft), var(--brand-soft));
  max-height: 230px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
}
.share-preview .pv-user { align-self: flex-end; max-width: 80%; color: var(--text); padding: 7px 12px; border-radius: 14px 14px 4px 14px; font-size: .88rem;
  background-color: var(--surface); background-image: linear-gradient(var(--brand-soft), var(--brand-soft)), linear-gradient(var(--brand-soft), var(--brand-soft)); }
.share-preview .pv-momu { align-self: flex-start; max-width: 90%; font-size: .88rem; color: var(--text); padding: 9px 13px; border-radius: 14px 14px 14px 4px;
  background: var(--surface); border: 1px solid var(--line); }
.share-preview .pv-brand { align-self: flex-end; font-family: var(--font-display); font-weight: 700; color: var(--muted); font-size: .95rem; margin-top: 2px; }
.share-note { text-align: center; color: var(--muted); font-size: .82rem; margin: 0; }

/* ---------- Custom dropdown (replaces the native <select> on mobile settings) ----------
   A native <select> renders its option list with the OS's own colours, so on a phone the
   list came up white-on-white regardless of MOMU's theme — the one piece of UI the theme
   couldn't reach. This is a real listbox, so the dark surface and the accent highlight
   match the desktop sidebar exactly. */
.cselect { position: relative; display: none; }
.cselect-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 10px 14px; border-radius: var(--radius-m); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-size: .95rem; font-weight: 600; text-align: left;
}
.cselect-btn[aria-expanded="true"] { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.cselect-btn .cs-label { flex: 1; display: flex; align-items: center; gap: 9px; min-width: 0; }
.cselect-btn .cs-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-btn .cs-caret { transition: transform .18s; flex: none; width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cselect-btn[aria-expanded="true"] .cs-caret { transform: rotate(180deg); }
.cselect-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60; padding: 6px;
  background: var(--surface); border: 1px solid var(--brand); border-radius: var(--radius-m);
  box-shadow: var(--shadow); max-height: 62vh; overflow-y: auto;
}
.cselect-list[hidden] { display: none; }
.cselect-list button {
  width: 100%; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px;
  border: none; background: transparent; color: var(--text); border-radius: var(--radius-s);
  font-size: .93rem; text-align: left; justify-content: flex-start;
}
:where(html[data-input="mouse"]) .cselect-list button:hover { background: var(--surface-2); }
.cselect-list button[aria-selected="true"], .cselect-list button[aria-selected="true"]:hover { background: var(--brand); color: var(--on-brand); font-weight: 600; }
.cselect em { font-style: normal; flex: none; width: 1.25em; text-align: center; }

/* ---------- Keyboard / Shortcuts settings ---------- */
.panel p.hint { color: var(--muted); font-size: .86rem; margin: -4px 0 6px; line-height: 1.5; }
.sc-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.sc-row:last-child { border-bottom: none; }
.sc-row .sc-name { flex: 1; min-width: 0; font-size: .93rem; }
.sc-row .sc-name small { display: block; color: var(--muted); font-size: .8rem; }
.sc-keys {
  display: inline-flex; gap: 4px; align-items: center; flex: none;
  font-family: var(--font-mono); font-size: .8rem; color: var(--muted);
}
kbd {
  display: inline-block; padding: 3px 7px; border-radius: 6px; border: 1px solid var(--line);
  border-bottom-width: 2px; background: var(--surface-2); color: var(--text);
  font-family: var(--font-mono); font-size: .78rem; line-height: 1.3; white-space: nowrap;
}
button.sc-edit { min-height: 32px; padding: 5px 10px; font-size: .82rem; flex: none; }
button.sc-edit.recording { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.sc-row.off .sc-name, .sc-row.off .sc-keys { opacity: .45; }
.sc-group-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 18px 0 2px; font-weight: 600; }
.sc-group-title:first-child { margin-top: 0; }
.code-chip { font-family: var(--font-mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; font-size: .84rem; flex: 0 1 auto; max-width: 46%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; text-align: left; }
/* Typed-code rows: the text column keeps a readable width; long codes (table) drop under it on phones. */
.sc-row .sc-name { min-width: 120px; }
@media (max-width: 720px) {
  .sc-row.sc-long { flex-wrap: wrap; align-items: flex-start; }
  .sc-row.sc-long .sc-name { flex: 1 1 100%; min-width: 0; }
  .sc-row.sc-long .code-chip { max-width: 100%; order: 2; }
}

/* ---------- Read-only shared chat page ---------- */
.share-page { max-width: 760px; margin: 0 auto; padding: 0 18px calc(60px + env(safe-area-inset-bottom)); }
.share-head { padding: 28px 0 8px; }   /* space between the top bar and the title */
.share-head h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 6px; overflow-wrap: anywhere; }
.share-head p { color: var(--muted); font-size: .86rem; margin: 0; }
/* The top bar of shared pages stays on screen while the page scrolls. */
body:has(> .page-bar) > .page-bar, body.has-sticky-bar > .page-bar { position: sticky; top: 0; z-index: 30; }
.pop-head { padding: 26px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.pop-head h1 { font-size: 1.5rem; margin: 0 0 6px; }
.pop-head p { color: var(--muted); font-size: .86rem; margin: 0; }
.share-foot { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: .86rem; }
.share-foot a { color: var(--brand); }
.share-empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.project-share-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.project-share-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-m);
  background: var(--surface); color: var(--text); text-decoration: none; width: 100%; text-align: left; font: inherit;
}
:where(html[data-input="mouse"]) .project-share-row:hover { background: var(--surface-2); border-color: var(--brand); }
.project-share-row .ps-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-share-row .ps-date { color: var(--muted); font-size: .82rem; flex: none; }

/* A shared project's read-only page, when the visitor isn't signed in — see requireAuth
   on GET /api/public/shared-project/:token. */
.share-signin { text-align: center; padding: 60px 20px 30px; }
.share-signin-icon {
  width: 52px; height: 52px; margin: 0 auto 18px; border-radius: 50%;
  background: var(--surface-2); display: grid; place-items: center; color: var(--muted);
}
.share-signin-icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share-signin h2 { font-size: 1.2rem; margin: 0 0 8px; }
.share-signin p { color: var(--muted); font-size: .92rem; max-width: 380px; margin: 0 auto 20px; line-height: 1.6; }

select.role-select {
  min-height: 34px; padding: 4px 26px 4px 10px; font-size: .84rem; border-radius: 999px;
  border: 1px solid var(--line); background-color: var(--surface-2); color: var(--text); flex: none;
}

/* ---------- Share dialogs (#project-share-dialog, #share-dialog) ----------
   Modelled on the reference screenshots: a 460px card, light header, one bordered email
   box, a "Who has access" dropdown, the owner + invited people, a grey privacy note and
   a pill button bottom-right. Colours come from the theme tokens so it works in every
   theme/accent. Dropdowns are the .sh-pop popovers built in chat.js. */
.modal-backdrop .modal.sh-card { max-width: 460px; width: 100%; border-radius: 20px; border: none; padding: 0; overflow: visible; max-height: min(90dvh, 720px); }
.sh-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 20px 24px 6px; }
.sh-head h2 { font-family: var(--font-text); font-size: 1.1rem; font-weight: 500; letter-spacing: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sh-head .ghost.icon { flex: none; border: none; background: transparent; width: 34px; min-height: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--text); }
.sh-head .ghost.icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
:where(html[data-input="mouse"]) .sh-head .ghost.icon:hover { background: var(--surface-2); }
.sh-body { padding: 12px 24px 6px; overflow-y: auto; display: flex; flex-direction: column; gap: 0; }

/* email box: chips + input, role dropdown pinned to the right once a chip exists */
.sh-emailbox {
  display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px 6px 10px; min-height: 46px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); cursor: text;
}
.sh-emailbox:focus-within { border-color: var(--text); box-shadow: none; }
.sh-emailflow { flex: 1; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sh-emailbox > .sh-drop { margin-top: 5px; }
.sh-emailbox input { flex: 1 1 60px; min-width: 60px; width: auto; border: none; background: transparent; padding: 6px 2px; min-height: 30px; font-size: 1rem; box-shadow: none; }
.sh-emailbox input:focus { outline: none; box-shadow: none; border: none; }
.sh-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 3px 4px 3px 10px; border-radius: 8px; background: var(--surface-3); font-size: .9rem; }
.sh-chip-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.sh-chip button { border: none; background: transparent; color: var(--muted); width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; }
:where(html[data-input="mouse"]) .sh-chip button:hover { background: var(--surface-2); color: var(--text); }
.sh-chip button svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.sh-error { color: var(--danger); font-size: .82rem; margin: 6px 2px 0; }
.sh-error.hidden { display: none; }

.sh-label { margin: 18px 0 4px; color: var(--muted); font-size: .9rem; }

/* borderless dropdown triggers ("Only those invited ⌄", "Can edit ⌄") */
.sh-drop, .sh-access {
  display: inline-flex; align-items: center; gap: 4px; border: none; background: transparent; color: var(--text);
  font: inherit; font-size: .92rem; padding: 6px 8px; min-height: 34px; border-radius: 10px; white-space: nowrap;
}
.sh-drop { color: var(--muted); flex: none; }
.sh-drop[aria-expanded="true"], .sh-access[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
:where(html[data-input="mouse"]) .sh-drop:hover, :where(html[data-input="mouse"]) .sh-access:hover { background: var(--surface-2); color: var(--text); }
.sh-drop svg, .sh-chev { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sh-access { padding-left: 2px; align-self: flex-start; font-size: .95rem; }
.sh-access .sh-ico svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.sh-access .sh-ico { display: grid; margin-right: 4px; }
.sh-role-btn.hidden { display: none; }

/* owner + invited people */
.sh-people { display: flex; flex-direction: column; margin-top: 8px; }
.sh-row { display: flex; align-items: center; gap: 10px; min-height: 46px; }
.sh-avatar { width: 26px; height: 26px; font-size: .78rem; flex: none; color: #fff; }
.sh-avatar:not([style*="background"]) { background: var(--brand); color: var(--on-brand); }
.sh-avatar.has-pic { color: transparent; }
.sh-name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 5px; font-size: .92rem; white-space: nowrap; }
.sh-name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sh-name em { font-style: normal; color: var(--muted); font-size: .8rem; flex: none; }
.sh-owner-tag { flex: none; padding: 0 8px; color: var(--text); font-size: .92rem; }
.sh-row.pending .sh-name b { color: var(--muted); }
.sh-row.pending .sh-avatar { opacity: .55; }
.sh-row.denied .sh-name b { color: var(--muted); }
.sh-row.denied .sh-name em { color: var(--danger); }
.sh-row.denied .sh-avatar { opacity: .5; filter: grayscale(.6); }

.sh-note { display: flex; gap: 12px; align-items: flex-start; margin: 14px 0 14px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: .82rem; line-height: 1.45; }
.sh-note svg { width: 17px; height: 17px; flex: none; margin-top: 1px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.sh-note b { display: block; color: var(--text); font-size: .86rem; margin-bottom: 1px; }

.sh-foot { padding: 4px 24px 22px; }
.sh-foot-row { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.sh-foot-row.hidden { display: none; }
.sh-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 20px; border-radius: 999px; font-weight: 600; font-size: .95rem; border: 1px solid transparent; }
.sh-btn i { display: grid; }
.sh-btn i svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sh-btn-dark { background: var(--text); color: var(--bg); border-color: var(--text); }
:where(html[data-input="mouse"]) .sh-btn-dark:hover { background: var(--text); filter: opacity(.85); }
.sh-btn-dark.copied { background: var(--ok); border-color: var(--ok); color: #fff; }
.sh-btn-line { background: transparent; color: var(--text); border-color: var(--line); }
:where(html[data-input="mouse"]) .sh-btn-line:hover { background: var(--surface-2); }
.sh-btn-brand { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
:where(html[data-input="mouse"]) .sh-btn-brand:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.sh-btn:disabled { opacity: .6; cursor: default; }

/* popover menus (role / access dropdowns) */
.sh-pop {
  position: fixed; z-index: 140; min-width: 270px; max-width: calc(100vw - 16px); padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  animation: shPop .12s ease-out;
}
@keyframes shPop { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }
.sh-pop-item { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; border: none; background: transparent; color: var(--text); padding: 10px 12px; min-height: 0; border-radius: 10px; }
:where(html[data-input="mouse"]) .sh-pop-item:hover { background: var(--surface-2); }
.sh-pop-ico { display: grid; color: var(--muted); flex: none; }
.sh-pop-ico svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sh-pop-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sh-pop-txt b { font-weight: 500; font-size: .95rem; }
.sh-pop-txt small { color: var(--muted); font-size: .8rem; }
.sh-pop-check { display: grid; color: var(--brand); flex: none; }
.sh-pop-check svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sh-pop-item.selected .sh-pop-ico, .sh-pop-item.selected .sh-pop-txt b { color: var(--brand); }
.sh-pop-item.danger, .sh-pop-item.danger .sh-pop-ico { color: var(--danger); }
.sh-pop-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* chat share (snapshot) */
.sh-head-line { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.sh-head-line h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; }
.sh-chat-body { padding: 18px 24px 8px; display: flex; flex-direction: column; gap: 22px; overflow-y: auto; }
.sh-chat-card .share-preview { max-height: 250px; border-radius: 14px; flex: none; min-height: 0; }
/* Preview bubbles must never be squashed by the flex column (that is what cut the text off and made rows overlap on desktop):
   every row keeps its full height and the preview box itself scrolls. */
.share-preview > * { flex: none; min-width: 0; line-height: 1.5; overflow-wrap: anywhere; }
.share-preview .pv-user, .share-preview .pv-momu { box-sizing: border-box; }
.sh-chat-body > * { flex: none; }
.sh-chat-body > .share-preview { flex: none; }
.sh-chat-card .share-preview .pv-user, .sh-chat-card .share-preview .pv-momu { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
/* Clamped bubbles: the 4-line cut is made at the PADDING edge, so real padding would let the 5th line
   peek out underneath. A transparent border does the same spacing job (the bubble colour still paints
   under it) and the cut happens inside it, so nothing peeks on any device. */
.sh-chat-card .share-preview .pv-user { padding: 0; border: 7px solid transparent; border-width: 7px 12px; }
.sh-chat-card .share-preview .pv-momu { padding: 0; border: 9px solid transparent; border-width: 9px 13px; }
.sh-round-row { display: flex; justify-content: center; gap: 34px; }
.sh-round { display: flex; flex-direction: column; align-items: center; gap: 8px; border: none; background: none; color: var(--text); font-size: .82rem; min-height: 0; padding: 0; }
:where(html[data-input="mouse"]) .sh-round:hover { background: none; }
.sh-round i { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--on-brand); transition: filter .15s, transform .15s; }
:where(html[data-input="mouse"]) .sh-round:hover:not(:disabled) i { filter: brightness(1.08); transform: translateY(-1px); }
.sh-round i svg { width: 23px; height: 23px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sh-round.is-off { opacity: .45; cursor: default; }
.sh-round.copied i { background: var(--ok, #3f9d6b); color: #fff; }
.sh-chat-foot { margin: 0; padding: 14px 24px 20px; text-align: center; color: var(--muted); font-size: .84rem; line-height: 1.5; }

@media (max-width: 520px) {
  .sh-head { padding: 18px 18px 4px; }
  .sh-body { padding: 10px 18px 4px; }
  .sh-foot { padding: 4px 18px 18px; }
  .sh-chip-email { max-width: 150px; }
}

/* project chats in the main sidebar list get a folder mark before the title */
.chat-item .chat-proj-ico { display: grid; flex: none; margin-right: 6px; color: var(--muted); }
.chat-item .chat-proj-ico svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Sidebar nav items ---------- */
.nav-item { position: relative; }

/* ---------- Invite accept/decline landing page (public/invite.html) ---------- */
.invite-card {
  max-width: 440px; margin: 60px auto; padding: 30px 26px; border: 1px solid var(--line);
  border-radius: var(--radius-l); background: var(--surface); text-align: center;
}
.invite-card .invite-icon {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center;
}
.invite-card .invite-icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.invite-card h1 { font-size: 1.2rem; margin: 0 0 8px; }
.invite-card p { color: var(--muted); font-size: .92rem; line-height: 1.6; margin: 0 0 6px; }
.invite-card .invite-role { display: inline-block; background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: .82rem; color: var(--text); margin: 6px 0 18px; }
.invite-card .invite-actions { display: flex; gap: 10px; margin-top: 18px; }
.invite-card .invite-actions button, .invite-card .invite-actions a { flex: 1; }
.invite-card .invite-result { font-size: 1rem; font-weight: 600; margin: 4px 0 6px; }

/* [compact layout: phones only] */
  /* The native <select> is gone from settings.html entirely — it's this listbox now, so the
     option list finally obeys the theme and the accent colour on phones too. */
  :where(html[data-layout="compact"]) .cselect { display: block; width: calc(100% - 36px); margin: 0 18px 4px; }
  :where(html[data-layout="compact"]) .row-menu { min-width: 210px; }


/* ---------- Pages inside the chat shell: Projects list + one project ----------
   Both fill .main (the sidebar stays), replacing the thread + composer. */
.page-view { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.main.view-page > .scroller, .main.view-page > .jump, .main.view-page > .composer-wrap { display: none; }
.main.view-page .topbar { border-bottom-color: transparent; background: transparent; }
.main.view-page .topbar .chat-title, .main.view-page .topbar .crumb-project, .main.view-page .topbar .crumb-sep, .main.view-page .topbar .topbar-right { display: none; }
/* Nothing left in the top bar on a page but the sidebar toggle — on desktop with the sidebar open, drop it entirely. */
/* [wide layout: every computer, any window width] */ :where(html[data-layout="wide"]) .app:not(.sidebar-collapsed) .main.view-page .topbar { display: none; } 

.pj-wrap { max-width: 860px; margin: 0 auto; padding: clamp(20px, 7vh, 64px) 24px calc(60px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.pj-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.pj-title { font-size: 2rem; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
.pj-head-tools { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pj-search { flex: 1 1 auto; width: 250px; min-width: 0; }
.pj-search input { width: 100%; min-height: 40px; border-radius: 999px; background: var(--surface-2); font-size: 1rem; padding-right: 14px; }
.pj-new { flex: none; border-radius: 999px; padding: 0 22px; min-height: 40px; }
.pj-head .pj-head-tools { justify-content: flex-end; }

/* All / Created by you / Shared with you, then a full-width rule. */
.pj-tabs { display: flex; gap: 6px; margin-top: 28px; padding-bottom: 14px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.pj-tabs::-webkit-scrollbar { display: none; }
.pj-tab { flex: none; background: transparent; border: none; border-radius: 999px; padding: 0 16px; min-height: 38px; color: var(--muted); font-weight: 500; white-space: nowrap; }
:where(html[data-input="mouse"]) .pj-tab:hover { background: var(--surface-2); color: var(--text); }
.pj-tab.active { background: var(--surface-3); color: var(--text); font-weight: 600; }

/* Name | Modified — the header and every row share the same right-anchored columns. */
.pj-table-head { display: grid; grid-template-columns: minmax(0, 1fr) 170px 36px; gap: 12px; padding: 16px 12px 8px; color: var(--muted); font-size: .84rem; }
.pj-table-head.hidden { display: none; }
.pj-rows { display: flex; flex-direction: column; gap: 2px; }
.pj-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) 170px 36px; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-m); cursor: pointer; }
.pj-row:focus-visible { background: var(--surface-2); outline: none; }
:where(html[data-input="mouse"]) .pj-row:hover { background: var(--surface-2); outline: none; }
.pj-row-icon { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; display: grid; place-items: center; background: var(--bg); }
.pj-row-icon svg, .pj-row-people svg, .pj-row-pin svg { flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pj-row-icon svg { width: 18px; height: 18px; }
.pj-row-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pj-row-name .pn { font-size: .96rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-row { position: relative; }
.pj-row-pin { position: absolute; top: 50%; right: 62px; transform: translateY(-50%); display: inline-flex; width: 15px; height: 15px; color: var(--brand); pointer-events: none; }   /* right side of the row, just before the "..." button */
:where(html[data-layout="compact"]) .pj-row-pin { right: 8px; }
html[data-input="touch"] .pj-row-pin { right: 14px; }   /* touch: the "..." button is hidden, so the pin moves to the very end of the row */
:where(html[data-layout="compact"]) #view-projects .pj-row .pj-row-pin { top: 18px; transform: none; width: 16px; height: 16px; }
.pj-row-pin svg { width: 100%; height: 100%; stroke-width: 2; fill: currentColor; }
.pj-row-people { flex: none; display: inline-flex; color: var(--muted); }
.pj-row-people svg { width: 16px; height: 16px; }
.pj-row-mod { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.pj-row-menu { width: 36px; min-height: 36px; opacity: 0; color: var(--muted); }
.pj-row:focus-within .pj-row-menu, .pj-row-menu[aria-expanded="true"] { opacity: 1; }
:where(html[data-input="mouse"]) .pj-row:hover .pj-row-menu { opacity: 1; }

.pj-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 20px; text-align: center; color: var(--muted); }
.pj-empty.hidden { display: none; }
.pj-empty svg { width: 40px; height: 40px; stroke: currentColor; fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: .5; }

/* One project's page */
.pj-proj-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pj-proj-icon { flex: none; display: grid; place-items: center; color: var(--text); }
.pj-proj-icon svg { width: 28px; height: 28px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.pj-proj-title h1 { margin: 0; font-size: 1.6rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-proj-head .pj-head-tools { flex: none; }

.pj-newchat { display: flex; align-items: center; gap: 4px; margin: 26px 0 28px; padding: 8px 8px 8px 10px; border: 1px solid var(--line); border-radius: 30px; background: var(--surface); box-shadow: 0 2px 12px rgba(0,0,0,.07); transition: border-color .15s, box-shadow .15s; }
.pj-newchat:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.pj-newchat > .icon { flex: none; color: var(--muted); border-radius: 50%; width: 40px; min-height: 40px; }
.pj-newchat > .icon svg { width: 22px; height: 22px; }
.pj-newchat input { flex: 1; min-width: 0; border: none; background: transparent; box-shadow: none !important; min-height: 44px; padding: 0 8px; font-size: 1.02rem; }
.pj-newchat .send { flex: none; width: 42px; height: 42px; min-height: 42px; border-radius: 50%; padding: 0; display: grid; place-items: center; }
.pj-newchat .send svg { stroke-width: 2.2; }

.pj-subhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.pj-tabs.pj-tabs-solo { margin-top: 0; padding-bottom: 0; border-bottom: none; }
.pj-subhead .pj-search { flex: 0 1 240px; }

.pj-chat-rows { display: flex; flex-direction: column; gap: 2px; }
.pj-chat-row { display: flex; align-items: center; gap: 14px; padding: 14px 12px; border-radius: var(--radius-m); cursor: pointer; }
.pj-chat-row:focus-visible { background: var(--surface-2); outline: none; }
:where(html[data-input="mouse"]) .pj-chat-row:hover { background: var(--surface-2); outline: none; }
.pj-chat-avatar { width: 38px; height: 38px; font-size: .95rem; }
.pj-chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pj-chat-title { font-weight: 600; font-size: .98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-chat-preview { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pj-chat-preview.hidden { display: none; }
.pj-chat-date { flex: none; color: var(--muted); font-size: .86rem; white-space: nowrap; }
.pj-chat-menu { flex: none; width: 34px; min-height: 34px; margin-left: -6px; opacity: 0; color: var(--muted); }
.pj-chat-row:focus-within .pj-chat-menu, .pj-chat-menu[aria-expanded="true"] { opacity: 1; }
:where(html[data-input="mouse"]) .pj-chat-row:hover .pj-chat-menu { opacity: 1; }

/* Back arrow on a project's own page, before the folder icon — phones only (see .pj-proj-back
   display rule below): the sidebar is an overlay there, hidden once you're on a project page,
   so this is the only way back to the Projects list without the hamburger + Projects tap. */
.pj-proj-back { flex: none; display: none; width: 34px; min-height: 34px; margin-left: -6px; color: var(--muted); border-radius: 50%; }
.pj-proj-back svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .pj-wrap { padding: 14px 16px calc(48px + env(safe-area-inset-bottom)); }
  :where(html[data-layout="compact"]) .pj-title { font-size: 1.7rem; }
  :where(html[data-layout="compact"]) .pj-tabs { margin-top: 20px; }
  :where(html[data-layout="compact"]) .pj-table-head { display: none; }
  :where(html[data-layout="compact"]) .pj-row { grid-template-columns: 38px minmax(0, 1fr) auto 36px; }
  :where(html[data-layout="compact"]) .pj-row-mod { font-size: .8rem; }
  /* No hover on touch, and no spare row for a tap target either — same pattern as the sidebar
     chat rows (see .chat-item .row-btn above): these "..." buttons are hidden entirely and
     holding the row down opens the same menu instead (attachLongPress in chat.js). */
  :where(html[data-layout="compact"]) .pj-row-menu, :where(html[data-layout="compact"]) .pj-chat-menu { display: none; }
  :where(html[data-layout="compact"]) .pj-proj-back { display: grid; place-items: center; }

/* Same reasoning, but keyed off touch capability rather than screen width: a touch device
   whose viewport happens to be wider than 860px (a tablet, a wide phone, a resized app
   webview) still has no hover and still gets the long-press menu (attachLongPress in
   chat.js), so the "..." button is just as redundant there. */
/* touch behaviour (was a media query; now follows html[data-input], see theme-init.js) */
  html[data-input="touch"] .pj-row-menu,
html[data-input="touch"] .pj-chat-menu { display: none; }

@media (max-width: 560px) {
  .pj-head-tools .pj-search { flex: 1 1 0; width: auto; }
  .pj-subhead { flex-direction: column; align-items: stretch; gap: 8px; }
  .pj-subhead .pj-search { flex: none; width: 100%; }
  .pj-proj-head { flex-wrap: wrap; }
  .pj-proj-title h1 { font-size: 1.35rem; }
  .pj-newchat { margin: 18px 0 20px; }
}

/* ---------- Project crumb, Share button, collaborator avatars (chat header + project page) ---------- */
.crumb-project { flex: 0 1 auto; display: inline-flex; align-items: center; gap: 7px; min-height: 36px; max-width: 200px; padding: 0 10px; border-radius: 10px; font-family: var(--font-display); font-weight: 600; font-size: .95rem; }
.crumb-project svg { width: 18px; height: 18px; }
.crumb-project span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-sep { color: var(--muted); margin: 0 -2px; user-select: none; }
.topbar .crumb-project + .crumb-sep + .chat-title { flex: 1; }
button.topbar-share { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 0 14px; border-radius: 999px; border-color: var(--line); font-weight: 600; font-size: .9rem; white-space: nowrap; }
button.topbar-share svg { width: 17px; height: 17px; }
.topbar-right { gap: 4px; }
.avatar-stack { display: flex; align-items: center; margin-right: 6px; }
.avatar-stack .avatar-xs { width: 28px; height: 28px; font-size: .78rem; border: 2px solid var(--bg); margin-left: -8px; box-sizing: content-box; }
.avatar-stack .avatar-xs:first-child { margin-left: 0; }
.avatar-more { margin-left: 6px; font-size: .74rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 7px; }
button.topbar-newchat.ghost.icon { display: none; }
/* [compact layout: phones only] */
  /* Chat header on phones: New chat + "..." (no Share); a project chat shows Share + "..." instead. The project page keeps Share + "...". */
  :where(html[data-layout="compact"]) .topbar:not(.in-project) #chat-share-btn { display: none !important; }
  :where(html[data-layout="compact"]) button.topbar-newchat.ghost.icon:not(.hidden) { display: grid; place-items: center; }
  :where(html[data-layout="compact"]) button.topbar-share { padding: 0; width: 42px; min-height: 42px; justify-content: center; }
  :where(html[data-layout="compact"]) button.topbar-share span { display: none; }
  :where(html[data-layout="compact"]) button.topbar-share svg { width: 19px; height: 19px; }
  :where(html[data-layout="compact"]) .topbar .avatar-stack { display: none; }


/* ---------- File attachments (composer strip + sent messages) ---------- */
.attach-strip .file-chip { flex: none; width: auto; max-width: min(210px, 70vw); height: var(--att-h); box-sizing: border-box; gap: 8px; padding: 0 8px 0 6px; border-radius: 10px; }
.attach-strip .file-chip .fc-icon { width: 30px; height: 30px; border-radius: 8px; }
.attach-strip .file-chip .fc-icon svg { width: 16px; height: 16px; }
.attach-strip .file-chip .fc-text { flex: 1 1 auto; min-width: 0; }
.attach-strip .file-chip .fc-text b { font-size: .8rem; }
.attach-strip .file-chip .fc-text small { font-size: .68rem; }
.attach-strip .file-chip .af-remove { flex: none; width: 18px; min-width: 18px; height: 18px; min-height: 18px; margin-left: 0; }
.file-chip { position: relative; display: inline-flex; align-items: center; gap: 10px; max-width: 260px; min-width: 0; padding: 8px 12px 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); text-align: left; }
.file-chip .fc-icon { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.file-chip .fc-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.file-chip .fc-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.file-chip .fc-text b { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .fc-text small { font-size: .75rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip.reading .fc-icon { animation: fc-pulse 1s ease-in-out infinite; }
@keyframes fc-pulse { 50% { opacity: .35; } }
.file-chip .af-remove { flex: none; width: 22px; min-height: 22px; height: 22px; padding: 0; margin-left: 2px; border-radius: 50%; font-size: .7rem; line-height: 1; background: var(--surface-3); color: var(--text); border: none; cursor: pointer; }
:where(html[data-input="mouse"]) .file-chip .af-remove:hover { background: var(--danger-soft); color: var(--danger); }
.msg-files { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.msg-files .file-chip { background: var(--surface); }
body.dragging-files .composer { outline: 2px dashed var(--brand); outline-offset: 3px; }

/* ---------- Incognito chat ---------- */
.topbar-right { position: relative; flex: none; display: flex; align-items: center; }
.incognito-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.incognito-btn .bubble-path { stroke-dasharray: 2.6 2.7; }
.incognito-btn .bubble-check { display: none; }
.incognito-btn.on { background: var(--brand-soft); color: var(--brand-strong); }
.incognito-btn.on svg { stroke-width: 2.3; }
.incognito-btn.on .bubble-path { stroke-dasharray: none; }
.incognito-btn.on .bubble-check { display: inline; }
body.incognito .composer { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
body.incognito .topbar .chat-title { cursor: default; }
:where(html[data-input="mouse"]) body.incognito .topbar .chat-title:hover { background: transparent; }
.incognito-welcome { text-align: center; }
.incognito-welcome .incog-badge { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); }
.incognito-welcome .incog-badge svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.incognito-welcome .bn { margin: 10px auto 12px; max-width: 48ch; }
.incognito-welcome .incog-note { margin: 0 auto; max-width: 52ch; font-size: .86rem; line-height: 1.55; color: var(--muted); }
body.incognito .thread { padding-top: 60px; }
.topbar .chat-title:disabled { color: var(--text); opacity: 1; }


/* ---------- "Deleted / no longer shared" state on the public share pages ---------- */
.share-gone { max-width: 380px; margin: 0 auto; padding: 30px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.share-gone-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.share-gone-icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; }
.share-gone h2 { font-size: 1.25rem; color: var(--text); }
.share-gone p { margin: 0 0 8px; color: var(--muted); font-size: .95rem; line-height: 1.6; }

/* message box on a shared project's chat (Can chat / Can edit) */
.ps-composer { display: flex; gap: 10px; align-items: flex-end; margin-top: 22px; position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); }
.ps-composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; border-radius: 14px; }
.ps-composer.hidden, #ps-readonly.hidden { display: none; }

/* ---------- Settings → Chat → Shared links (#shared-links-dialog) ---------- */
.modal-backdrop .modal.sl-card { max-width: 760px; border-radius: 18px; padding: 22px 26px 18px; gap: 0; }
.sl-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sl-head h2 { font-family: var(--font-text); font-size: 1.3rem; font-weight: 500; letter-spacing: 0; }
.sl-head .ghost.icon { border: none; background: transparent; width: 34px; min-height: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.sl-head .ghost.icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.sl-sub { margin: 8px 0 18px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.sl-table { overflow-y: auto; max-height: min(52vh, 420px); }
.sl-tr { display: grid; grid-template-columns: minmax(0, 1fr) 90px 170px 76px; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.sl-tr.sl-th { position: sticky; top: 0; background: var(--surface); font-weight: 600; padding-top: 4px; z-index: 1; }
.sl-name { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--brand); text-decoration: none; }
:where(html[data-input="mouse"]) .sl-name:hover span { text-decoration: underline; }
.sl-name svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sl-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-type, .sl-date { color: var(--text); }
.sl-act { display: flex; justify-content: flex-end; gap: 4px; }
.sl-act a, .sl-act button { width: 32px; height: 32px; min-height: 0; padding: 0; display: grid; place-items: center; border: none; background: transparent; color: var(--muted); border-radius: 8px; }
:where(html[data-input="mouse"]) .sl-act a:hover, :where(html[data-input="mouse"]) .sl-act button:hover { background: var(--surface-2); color: var(--text); }
:where(html[data-input="mouse"]) .sl-act .sl-del:hover { background: var(--danger-soft); color: var(--danger); }
.sl-act svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sl-empty { text-align: center; color: var(--muted); padding: 34px 10px 26px; font-size: .95rem; }
@media (max-width: 620px) {
  .modal-backdrop .modal.sl-card { padding: 18px 16px 14px; }
  .sl-tr { grid-template-columns: minmax(0, 1fr) 76px; row-gap: 2px; }
  .sl-tr .sl-type, .sl-th .sl-date, .sl-th .sl-type { display: none; }
  .sl-tr .sl-date { grid-column: 1; grid-row: 2; font-size: .8rem; color: var(--muted); }
  .sl-tr .sl-act { grid-column: 2; grid-row: 1 / span 2; }
  .sl-tr.sl-th { grid-template-columns: 1fr; }
  .sl-th .sl-act { display: none; }
}


/* ---- Appearance: Text size + Compact mode (clearly visible) -------------------------------
   Text size is set on <html> (html { font-size: var(--fs) }) so every rem in this file scales
   with it — before, only body text moved and most of the UI stayed put.
   The three "A" buttons in Settings preview their own size. */
#fs-switch button[data-fs="small"]  { font-size: 12px; }
#fs-switch button[data-fs="medium"] { font-size: 16px; }
#fs-switch button[data-fs="large"]  { font-size: 21px; }

/* Compact mode: noticeably tighter chat, sidebar and controls. */
:root[data-density="compact"] .msg .bubble { padding-left: 12px; padding-right: 12px; }
:root[data-density="compact"] .bubble p,
:root[data-density="compact"] .content p { margin-bottom: .35em; }
:root[data-density="compact"] .content ul, :root[data-density="compact"] .content ol,
:root[data-density="compact"] .content blockquote { margin-bottom: .4em; }
:root[data-density="compact"] .content h3, :root[data-density="compact"] .content h4,
:root[data-density="compact"] .content h5, :root[data-density="compact"] .content h6 { margin: .6em 0 .25em; }
:root[data-density="compact"] .content li { margin: .05em 0; }
:root[data-density="compact"] .codeblock { margin-bottom: .5em; }
:root[data-density="compact"] .thread { padding-left: 12px; padding-right: 12px; }
:root[data-density="compact"] .sidebar { gap: 6px; padding-top: 10px; }
:root[data-density="compact"] .chat-item { min-height: 30px; }
:root[data-density="compact"] .sidebar-nav { gap: 0; }
:root[data-density="compact"] button.small { min-height: 26px; }

/* ---- Show / hide password (eye) — public/js/pw-toggle.js ---- */
.pw-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.pw-wrap > input { width: 100%; padding-right: 46px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; min-height: 0; padding: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px; box-shadow: none;
  color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pw-eye:focus-visible { color: var(--text, currentColor); background: var(--brand-soft); outline: none; }
:where(html[data-input="mouse"]) .pw-eye:hover { color: var(--text, currentColor); background: var(--brand-soft); outline: none; }
.pw-eye svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Settings → Personalize: dropdown rows (Base style and tone + Characteristics) ---------- */
.pz-row { align-items: flex-start; padding: 2px 0; }
.pz-row .txt small { max-width: 46ch; }
.pz-group { margin-top: 6px; }
.pz-group .sc-group-title { margin: 10px 0 2px; font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.pz-group-sub { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.pz-custom { margin-top: 6px; }
.pz-custom > label { font-weight: 500; font-size: .98rem; }
.dd { position: relative; flex: none; width: 240px; max-width: 100%; }
.dd-btn { display: flex; width: 100%; box-sizing: border-box; justify-content: space-between; align-items: center; gap: 8px; min-height: 36px; padding: 6px 10px 6px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: inherit; font-size: .92rem; cursor: pointer; white-space: nowrap; }
:where(html[data-input="mouse"]) .dd-btn:hover { background: var(--surface-3); }
.dd-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.dd-btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.dd.open .dd-btn svg { transform: rotate(180deg); }
.dd-menu { position: absolute; left: 0; right: auto; top: calc(100% + 6px); z-index: 60; width: 100%; max-width: none; max-height: min(70vh, 420px); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin; box-sizing: border-box; padding: 6px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 12px 34px rgba(0,0,0,.35); display: none; }
.dd.open .dd-menu { display: block; }
.dd.up .dd-menu { top: auto; bottom: calc(100% + 6px); }
.dd-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; padding: 9px 12px; border: none; border-radius: 10px; background: transparent; color: var(--text); font: inherit; cursor: pointer; min-height: 44px; }
.dd-opt:focus-visible { background: var(--surface-2); outline: none; }
:where(html[data-input="mouse"]) .dd-opt:hover { background: var(--surface-2); outline: none; }
.dd-opt .t { display: block; font-size: .95rem; }
.dd-opt .d { display: block; color: var(--muted); font-size: .8rem; line-height: 1.3; }
.dd-opt svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; visibility: hidden; }
.dd-opt[aria-selected="true"] svg { visibility: visible; }
@media (max-width: 560px) {
  .pz-row { gap: 10px; flex-direction: column; align-items: stretch; }
  .dd { width: 100%; }
  .pz-row .txt small { max-width: none; }
}


/* Memory card (inside Personalize, below the style/tone card) */
.mem-add-row { display: flex; gap: 8px; align-items: stretch; }
.mem-add-row input { flex: 1 1 auto; min-width: 0; }
.mem-add-row button { flex: 0 0 auto; }
.mem-note { margin: 0; color: var(--muted); font-size: .82rem; line-height: 1.5; }
#memory-card .setting-row > button { flex: 0 0 auto; }
#memory-list .card .q { overflow-wrap: anywhere; word-break: break-word; }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) #personalize { gap: 12px; }
  :where(html[data-layout="compact"]) #memory-card .setting-row { gap: 10px; }

#memory-card { scroll-margin-top: calc(76px + env(safe-area-inset-top, 0px)); }


/* ---- "Signing you in…" screen shown while coming back from Google (index.html + auth.js) ---- */
.g-return { display: none; position: fixed; inset: 0; z-index: 9999; align-items: center; justify-content: center; text-align: center; padding: 24px; background: var(--bg, #131315); color: var(--text, inherit); }
html.g-returning .g-return { display: flex; }
html.g-returning .auth-page { visibility: hidden; }
.g-return-box { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 340px; }
.g-return-box h2 { font-size: 1.35rem; margin: 6px 0 0; }
.g-return-box p { opacity: .7; margin: 0; font-size: .95rem; line-height: 1.45; }
.g-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(128,128,128,.28); border-top-color: hsl(var(--h, 38), var(--s, 78%), 55%); animation: g-spin .8s linear infinite; }
@keyframes g-spin { to { transform: rotate(360deg); } }

/* "Your Info Related" chip in the composer (coloured like normal link text, with an ✕) */
.info-chip { display: flex; align-items: center; gap: 2px; width: fit-content; max-width: 100%; padding-top: calc(6px * var(--density)); color: var(--brand); font-weight: 600; font-size: .95rem; line-height: 1.2; white-space: nowrap; }
.info-chip.hidden { display: none; }
.chip-row { display: flex; flex-wrap: nowrap; column-gap: 14px; align-items: center; }
.info-chip-label { overflow: hidden; text-overflow: ellipsis; }
.info-chip-x { display: grid; place-items: center; width: 22px; height: 22px; min-width: 22px; min-height: 22px; max-height: 22px; aspect-ratio: 1 / 1; margin: 0; padding: 0; line-height: 0; border: none; border-radius: 50%; background: transparent; color: var(--brand); cursor: pointer; flex: none; }
:where(html[data-input="mouse"]) .info-chip-x:hover { background: var(--brand-soft); }
.info-chip-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* The chips a message was sent with (Your Info Related / Web search / Weather and Time): small coloured tags above the
   message, never text inside it. Wraps on narrow screens, never wider than the message column. */
.sent-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 100%; margin-bottom: 6px; }
.sent-chips.hidden { display: none; }
.sent-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 3px 10px 3px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .78rem; font-weight: 600; line-height: 1.25; white-space: nowrap; user-select: none; -webkit-user-select: none; }
.sent-chip svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sent-chip span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- Per-reply "..." menu + Sources dialog ---------- */
.reply-menu { min-width: 200px; }
.reply-menu-time { padding: 8px 12px 6px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.src-body { padding-bottom: 22px; gap: 4px; max-height: min(60dvh, 460px); }
.src-group { margin: 6px 0 4px; font-size: 1.02rem; font-weight: 600; color: var(--muted); }
.src-item { padding: 8px 0 10px; }
.src-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .84rem; }
.src-label svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.src-text { margin-top: 3px; font-weight: 600; font-size: .98rem; line-height: 1.45; color: var(--text); overflow-wrap: anywhere; text-decoration: none; display: block; }
:where(html[data-input="mouse"]) a.src-text:hover { text-decoration: underline; }

/* ---------- Phones: New chat / Share / "..." / incognito share ONE floating pill (like the reference), instead of separate circles.
   Same in plain chats and project chats; buttons keep their own functions. The sidebar toggle stays its own circle. ---------- */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .topbar .topbar-right {
    gap: 0; padding: 0 4px; min-height: 44px; box-sizing: border-box;
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
  }
  :where(html[data-layout="compact"]) .topbar .topbar-right:not(:has(> button:not(.hidden))) { display: none; }   /* nothing to show → no empty pill */
  :where(html[data-layout="compact"]) body .topbar .topbar-right > button:is(#chat-new-btn, #chat-more-btn, #incognito-btn, #chat-share-btn) {
    background: transparent; border: none; border-radius: 50%; width: 42px; min-height: 42px; padding: 0;
  }
:where(html[data-layout="compact"][data-input="mouse"]) body .topbar .topbar-right > button:is(#chat-new-btn, :where(html[data-input="mouse"]) #chat-more-btn, :where(html[data-input="mouse"]) #incognito-btn, :where(html[data-input="mouse"]) #chat-share-btn):hover {
    background: transparent; border: none; border-radius: 50%; width: 42px; min-height: 42px; padding: 0;
  }
  :where(html[data-layout="compact"]) body .topbar .topbar-right > button:is(#chat-new-btn, #chat-more-btn, #incognito-btn, #chat-share-btn):active { background: var(--surface-3); }
  :where(html[data-layout="compact"]) body .topbar .topbar-right > #incognito-btn.on { background: var(--brand-soft); }


/* ---------- Scroll boxes: long lists (Settings → Memory; Admin → Training data, Knowledge, Users, Reports, Activity) ----------
   The box has no frame of its own and simply grows with its content, so a short list looks exactly like before. Once it
   reaches the limit (about 60% of the screen height, never under 280px and never over 560px) it stops growing and scrolls
   inside itself — the page stays short however many items there are. */
.scroll-box { max-height: 3360px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
/* Phones: 3x the old height (the old cap was 560px; PC is 6x = 3360px, phones 3x = 1680px). */
/* [compact layout: phones only] */ :where(html[data-layout="compact"]) .scroll-box { max-height: 1680px; } 
.scroll-box::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-box::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
:where(html[data-input="mouse"]) .scroll-box::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.scroll-box.cards > * { flex-shrink: 0; }
.scroll-box.cards { padding-right: 4px; }
.scroll-box table.data thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); box-shadow: 0 1px 0 var(--line); }


/* =====================================================================================================
   Touch / phone fixes
   ===================================================================================================== */

/* The Settings and Admin home lists: a finger resting on a row (or a long press) must do nothing — no
   highlight, no text selection, no Android/iOS callout. A tap opens the page and that is all. */
.mm-row, .admin-mobile-home, .settings-mobile-home {
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.mm-row { transition: none; }
.mm-row:focus, .mm-row:active { outline: none; }

/* Nothing in the app may scroll sideways by itself: wide things (tables, code) scroll inside their own box. */
html { overflow-x: hidden; max-width: 100%; }
body { max-width: 100%; overflow-x: clip; }
.admin-bar, .panel, .cards, .card { max-width: 100%; min-width: 0; }
/* These three keep their own 1120px desktop width (set earlier); a blanket max-width:100% here used to override it and stretched Admin edge to edge on PC. */
.admin-bar-inner, .admin-main, .admin-mobile-home { min-width: 0; }
.card, .panel { overflow-wrap: anywhere; }

/* [compact layout: phones only] */
  /* The phone Admin header has no tab strip under it, so its bottom padding was 0 and the back button sat
     right on the header's bottom line. Give it the same breathing room as above it. */
  :where(html[data-layout="compact"]) .admin-bar-inner { padding-top: 10px; padding-bottom: 10px; }
  :where(html[data-layout="compact"]) .admin-top { min-width: 0; }
  :where(html[data-layout="compact"]) .admin-top .logo { min-width: 0; }
  :where(html[data-layout="compact"]) .admin-top .right { flex: none; gap: 6px; }

@media (max-width: 640px) {
  .admin-bar-inner { padding-left: 14px; padding-right: 14px; }
  .admin-top { gap: 8px; }
  .admin-top .right button.ghost { padding: 6px 8px; }
  .toolbar .grow { min-width: 0; flex: 1 1 100%; }
  .card .meta, .row-actions { min-width: 0; }
}

/* ---------- Copy cards: editable, Share, ✓ feedback ---------- */
.copycard-body { cursor: text; outline: none; -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.copycard { transition: border-color .15s; }
.copycard.editing { border-color: var(--brand); }
.copycard-actions button.copied, .code-copy.copied, .cc-copy.copied, .user-actions button.copied, .msg-actions button.copied { color: var(--text); }
.cc-copy.copied svg { stroke: currentColor; }
.code-copy.copied { color: var(--text); }
.copycard-actions button svg, .code-copy svg { stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; width: 17px; height: 17px; }
.copycard-expand-body { outline: none; min-height: 40vh; cursor: text; -webkit-user-select: text; user-select: text; padding: 2px; }
.cc-modal .modal-foot { display: flex; gap: 8px; align-items: center; }
.cc-modal .modal-foot .cc-close { margin-right: auto; }
.cc-modal .modal-foot .cc-share { display: inline-flex; align-items: center; gap: 7px; }
.cc-modal .modal-foot .cc-share svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* Share menu (Gmail · Outlook · WhatsApp) — a small rounded popover anchored under the Share button. */
.share-menu {
  position: fixed; z-index: 400; min-width: 200px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.share-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; min-height: 44px; padding: 8px 12px;
  background: transparent; border: none; border-radius: 12px; color: var(--text); font-size: .95rem; -webkit-user-select: none; user-select: none;
}
:where(html[data-input="mouse"]) .share-item:hover { background: var(--surface-2); }
.share-ico { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; }
.share-ico svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.share-ico.tone-gmail { background: #d9483b; }
.share-ico.tone-outlook { background: #1f6fd0; }
.share-ico.tone-whatsapp { background: #25a35a; }

/* The home lists never show a "current page": the row that was marked .on for whichever page was open
   (on a fresh load that is Overview / the first Settings page) must not look selected there. */
body[data-mobile-view="home"] .mm-row.on:not(.danger-link) { background: var(--surface-2); }
/* Admin and Settings: vertical panning only. A sideways drag on the page itself does nothing (wide tables
   and code boxes are their own scroll containers and still pan sideways inside themselves). */
body:has(> .admin-bar), body:has(> .page-bar) { touch-action: pan-y; }


/* ---------- Copy box: no inner scrolling, full screen views ---------- */
/* The box grows to fit its text, so a finger (or the wheel) over a long email or essay still scrolls the CHAT.
   (It used to be a 360px box with its own scrollbar that trapped the scroll.) */
.copycard-body { max-height: none; overflow: visible; }
.copycard-edit { display: none !important; }
/* touch behaviour (was a media query; now follows html[data-input], see theme-init.js) */
  html[data-input="touch"] .copycard-edit { display: inline-grid !important; }
  html[data-input="touch"] .copycard-body { cursor: pointer; }

html.cc-lock, html.cc-lock body { overflow: hidden; }
.cc-full { position: fixed; left: 0; right: 0; top: 0; z-index: 150; height: 100vh; height: 100dvh; height: calc(var(--app-vh, 1vh) * 100); display: flex; flex-direction: column; background: var(--bg); color: var(--text); }
.cc-full button { -webkit-tap-highlight-color: transparent; }
.cc-full .ccf-top button svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ccf-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.ccf-text { display: block; width: 100%; border: none; outline: none; resize: none; background: transparent; color: var(--text); font: inherit; font-size: 1rem; line-height: 1.7; overflow: hidden; box-shadow: none; border-radius: 0; padding: 0; min-height: 50%; }
.ccf-text:focus { box-shadow: none; border: none; }

/* Phone full screen: round exit button on the left, a pill of Undo · Redo · Copy · Share on the right. */
.cc-full-m .ccf-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 14px 10px; border-bottom: 1px solid var(--line); }
.ccf-round { width: 46px; height: 46px; min-height: 46px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: none; color: var(--text); }
.ccf-pill { display: flex; align-items: center; gap: 2px; padding: 4px 8px; border-radius: 999px; background: var(--surface-2); }
.ccf-pill button { width: 44px; height: 42px; min-height: 42px; padding: 0; border: none; border-radius: 999px; background: transparent; color: var(--text); display: grid; place-items: center; }
.ccf-pill button:disabled { opacity: .35; }
.ccf-pill button.copied { color: var(--text); }
.ccf-subject { display: flex; align-items: center; gap: 12px; padding: 4px 18px; border-bottom: 1px solid var(--line); }
.ccf-subject label { font-weight: 700; flex: none; }
.ccf-subject input { flex: 1; min-width: 0; border: none; outline: none; box-shadow: none; background: transparent; color: var(--text); font: inherit; padding: 12px 0; border-radius: 0; }
.cc-full-m .ccf-scroll { padding: 18px 18px calc(24px + env(safe-area-inset-bottom)); }

/* PC full screen: close · title on the left, Copy · Download on the right, text in a centred column. */
.cc-full-d { z-index: 150; }
.cc-full-d .ccf-top { display: flex; align-items: center; gap: 14px; height: 58px; flex: none; padding: 0 18px; border-bottom: 1px solid var(--line); }
.ccf-x, .ccf-right button { width: 38px; height: 38px; min-height: 38px; padding: 0; border: none; border-radius: 10px; background: transparent; color: var(--text); display: grid; place-items: center; }
.ccf-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .95rem; }
.ccf-right { display: flex; align-items: center; gap: 4px; }
:where(html[data-input="mouse"]) .ccf-x:hover, :where(html[data-input="mouse"]) .ccf-right button:hover { background: var(--surface-2); }
.cc-full-d .ccf-scroll { padding: 34px 24px 80px; }
.cc-full-d .ccf-text { max-width: 740px; margin: 0 auto; font-size: 1.02rem; }

/* Popover header + file-type tags (Download menu) */
.pop-head { padding: 8px 12px 4px; font-size: .82rem; color: var(--muted); }
.share-ext { margin-left: auto; padding-left: 18px; color: var(--muted); font-size: .85rem; }
.share-menu:has(.share-ext) { min-width: 270px; }
.share-ico.tone-txt { background: #5b6472; }
.share-ico.tone-pdf { background: #d9483b; }
.share-ico.tone-docx { background: #1f6fd0; }
.share-ico.tone-xlsx { background: #1d7a45; }


/* =====================================================================================================
   Phone layout for Admin + Settings: nothing may scroll sideways, nothing may poke out of its box.
   ===================================================================================================== */
.panel pre, .panel code, .panel .kbd, .panel .sub, .card, .card * { overflow-wrap: anywhere; word-break: break-word; }
.panel pre, .kbd { white-space: pre-wrap; max-width: 100%; overflow-x: hidden; box-sizing: border-box; }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]), :where(html[data-layout="compact"]) body { overflow-x: clip; max-width: 100vw; }
  :where(html[data-layout="compact"]) .admin-main, :where(html[data-layout="compact"]) .admin-mobile-home, :where(html[data-layout="compact"]) .settings-content, :where(html[data-layout="compact"]) .settings-mobile-home, :where(html[data-layout="compact"]) .page-main { max-width: 100%; overflow-x: clip; box-sizing: border-box; }
  :where(html[data-layout="compact"]) .panel, :where(html[data-layout="compact"]) .setting-row, :where(html[data-layout="compact"]) .toolbar, :where(html[data-layout="compact"]) .form-grid, :where(html[data-layout="compact"]) .field { max-width: 100%; min-width: 0; box-sizing: border-box; }
  :where(html[data-layout="compact"]) .panel input, :where(html[data-layout="compact"]) .panel select, :where(html[data-layout="compact"]) .panel textarea { max-width: 100%; box-sizing: border-box; }
  :where(html[data-layout="compact"]) .toolbar .grow { min-width: 0; flex-basis: 100%; }
  :where(html[data-layout="compact"]) .segmented { max-width: 100%; flex-wrap: wrap; }
  :where(html[data-layout="compact"]) .tabs, :where(html[data-layout="compact"]) .page-nav { touch-action: pan-y; }

  /* Tables (Users, Knowledge) turn into stacked cards: no sideways scrolling at all. */
  :where(html[data-layout="compact"]) .table-scroll { overflow-x: visible; margin: 0; padding: 0; touch-action: pan-y; }
  :where(html[data-layout="compact"]) table.data, :where(html[data-layout="compact"]) table.data tbody, :where(html[data-layout="compact"]) table.data tr, :where(html[data-layout="compact"]) table.data td { display: block; width: 100%; box-sizing: border-box; }
  :where(html[data-layout="compact"]) table.data thead { display: none; }
  :where(html[data-layout="compact"]) table.data tr { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; margin-bottom: 10px; background: var(--bg); }
  :where(html[data-layout="compact"]) table.data td, :where(html[data-layout="compact"]) table.data td.wrap { border-bottom: none; padding: 5px 0; min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
  :where(html[data-layout="compact"]) table.data td[data-label]:not(:empty)::before { content: attr(data-label); display: block; color: var(--muted); font-size: .76rem; font-weight: 500; margin-bottom: 1px; }
  :where(html[data-layout="compact"]) table.data td.empty { text-align: center; }
  :where(html[data-layout="compact"]) table.data td.empty::before { display: none !important; }
  :where(html[data-layout="compact"]) table.data td .row-actions { margin-top: 4px; }



/* =====================================================================================================
   Memory page, Admin → Manage training page, page-flow lists, Activity delete (select mode + sheet)
   Everything here is written phone-first: nothing may overflow sideways, buttons wrap instead of squashing.
   ===================================================================================================== */
.page-main.wide { max-width: 980px; }
.mem-head h2 { font-size: 1.25rem; margin: 0 0 4px; }
.mem-head p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.45; overflow-wrap: anywhere; }
.mem-note a { color: var(--brand); }
.meta-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mem-card .meta { justify-content: space-between; flex-wrap: nowrap; }
.mem-card .meta .mem-date { min-width: 0; }
.mem-card .meta button { flex: none; }

/* "Load more" under a list that grows with the page */
.load-more-wrap { display: flex; justify-content: center; padding: 6px 0 2px; }
.load-more-wrap.hidden { display: none; }
.load-more-wrap button { min-width: 160px; }
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) .load-more-wrap { padding: 14px 0 6px; }
  :where(html[data-layout="wide"]) .load-more-wrap button { width: min(100%, 420px); min-height: 46px; font-size: .95rem; border-radius: 12px; }


/* Delete (and any small action) buttons never split their label across lines ("Dele / te") */
button.small, .row-actions button { white-space: nowrap; }
button.nowrap { white-space: nowrap; }
table.data td.act-cell { width: 1%; white-space: nowrap; text-align: right; }
/* [compact layout: phones only] */ :where(html[data-layout="compact"]) table.data td.act-cell { width: 100%; text-align: left; } 

/* Link-buttons inside setting rows (Manage memory / Manage trainings) */
.setting-row > a.btn { flex: none; }

/* Edit dialog (Manage training) */
.edit-modal { max-width: 560px; }
.edit-modal textarea { width: 100%; box-sizing: border-box; }

/* Activity: select mode — one floating bar at the bottom of the screen */
.select-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 60;
  width: calc(100% - 24px); max-width: 600px; box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); }
.select-bar.hidden { display: none; }
.select-bar > span { font-size: .88rem; color: var(--muted); white-space: nowrap; }
.select-bar .actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; min-width: 0; }
body.selecting .admin-main { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
.card.selectable { position: relative; cursor: pointer; padding-left: 48px; -webkit-tap-highlight-color: transparent; }
.card.selectable.picked { border-color: var(--brand); background: var(--brand-soft); }
.card .sel-box { position: absolute; left: 14px; top: 14px; width: 22px; height: 22px; display: block; }
.card .sel-box input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.card .sel-box span { position: absolute; inset: 0; border: 2px solid var(--muted); border-radius: 6px; background: var(--bg); }
.card .sel-box input:checked + span { background: var(--brand); border-color: var(--brand); }
.card .sel-box input:checked + span::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid var(--on-brand); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.card.selectable .a { cursor: pointer; }

/* Activity: "Delete…" sheet */
.act-delete-modal { max-width: 480px; }
.opt-list { display: flex; flex-direction: column; gap: 8px; }
.opt-list .opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 12px 14px; min-height: 52px; border-radius: var(--radius-m); background: var(--surface-2); border: 1px solid var(--line); color: var(--text); white-space: normal; }
.opt-list .opt b { font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; }
.opt-list .opt small { color: var(--muted); font-size: .8rem; font-weight: 400; overflow-wrap: anywhere; }
.opt-list .opt[data-mode="all"] b { color: var(--danger); }
:where(html[data-input="mouse"]) .opt-list .opt:hover { background: var(--surface-3); }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .act-delete-modal .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  :where(html[data-layout="compact"]) .act-delete-modal .modal-foot button { width: 100%; }
  :where(html[data-layout="compact"]) .edit-modal .modal-foot { flex-direction: column-reverse; align-items: stretch; }
  :where(html[data-layout="compact"]) .edit-modal .modal-foot button { width: 100%; }
  :where(html[data-layout="compact"]) .select-bar { justify-content: center; }
  :where(html[data-layout="compact"]) .select-bar .actions { width: 100%; justify-content: stretch; }
  :where(html[data-layout="compact"]) .select-bar .actions button { flex: 1 1 auto; }
  :where(html[data-layout="compact"]) .load-more-wrap button { width: 100%; }
  :where(html[data-layout="compact"]) .page-main { padding-left: 14px; padding-right: 14px; }

.act-delete-modal .modal-body { gap: 10px; padding-top: 16px; }
.act-delete-modal h2 { margin: 0; font-size: 1.15rem; }
.act-delete-modal p.sub { margin: 0; font-size: .84rem; color: var(--muted); }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .opt-list { gap: 6px; }
  :where(html[data-layout="compact"]) .opt-list .opt { padding: 9px 12px; min-height: 0; }
  :where(html[data-layout="compact"]) .opt-list .opt b { font-size: .9rem; }


/* Settings → Chat → "Shared links" Manage button: never let the flex row squeeze it into "Ma/nag/e" on narrow phones. */
#shared-links-open { flex: 0 0 auto; white-space: nowrap; width: auto; min-width: 84px; padding-left: 16px; padding-right: 16px; }


/* ---- Chat tables: small toolbar (Copy table · Download · Full screen) — like a copy box, without Edit / Share ---- */
.tablecard { margin: 0 0 .9em; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--surface); }
.tablecard .table-wrap { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; }
.tablecard-head .copycard-title { flex: 1; min-width: 0; }
.tablecard-actions button.copied, .tablecard-head button.copied { color: var(--text); }
.tablecard-head button { min-height: 30px; width: 30px; padding: 0; display: inline-grid; place-items: center; background: transparent; border-color: transparent; color: var(--muted); border-radius: 8px; }
.tablecard-head button svg { stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; width: 17px; height: 17px; }
:where(html[data-input="mouse"]) .tablecard-head button:hover { background: var(--surface); color: var(--text); }
/* touch behaviour (was a media query; now follows html[data-input], see theme-init.js) */
 html[data-input="touch"] .tablecard-head button { width: 36px; min-height: 36px; } 


/* Full-screen table (phone, tablet and computer): scrolls both ways, header row stays in view */
.cct-scroll { overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-x pan-y; }
.cct-inner { padding: 18px; width: max-content; min-width: 100%; box-sizing: border-box; }
.cc-full-d .cct-scroll { padding: 0; }
.cc-full-d .cct-inner { padding: 24px; }
.cc-full-m .cct-scroll { padding: 0; }
.cct-title { position: sticky; left: 0; padding: 16px 18px 0; font-weight: 600; font-size: 1.05rem; max-width: 100vw; box-sizing: border-box; }
.cct-inner .table-wrap { overflow: visible; margin: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background-image: none; }
.cct-inner table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; max-width: none; font-size: .95rem; }
.cct-inner th, .cct-inner td { padding: 10px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.cct-inner th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); font-weight: 600; box-shadow: 0 1px 0 var(--line); }
.cct-inner tbody tr:nth-child(even) td { background: var(--surface-2); }
.cct-inner tr:last-child td { border-bottom: none; }

/* ---------- Tables are edited like copy boxes ---------- */
/* PC: click a cell and type (Enter = the cell below, Tab = the next cell). Phone: tap the table, or the pencil, to edit it in full screen. */
.tablecard { transition: border-color .15s; }
.tablecard:focus-within { border-color: var(--brand); }
.tablecard th[contenteditable], .tablecard td[contenteditable], .cct-inner th[contenteditable], .cct-inner td[contenteditable] { cursor: text; outline: none; -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.tablecard th[contenteditable]:focus, .tablecard td[contenteditable]:focus, .cct-inner th[contenteditable]:focus, .cct-inner td[contenteditable]:focus { box-shadow: inset 0 0 0 2px var(--brand); }
.cct-inner th[contenteditable]:focus { z-index: 2; }
.tablecard-edit { display: none !important; }
/* touch behaviour (was a media query; now follows html[data-input], see theme-init.js) */
  html[data-input="touch"] .tablecard-edit { display: inline-grid !important; }
  html[data-input="touch"] .tablecard .table-wrap { cursor: pointer; }

.cc-full-t .ccf-top button:disabled { opacity: .35; }


/* ---- heading of a table / copy box: ONLY in full screen (centred, like the heading of a downloaded file); deleted = gone ---- */
.cct-title { text-align: center; font-weight: 700; outline: none; cursor: text; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; padding: 16px 18px 4px; font-size: 1.1rem; min-height: 1.4em; }
.cct-title:empty::before { content: attr(data-ph); color: var(--muted); font-weight: 500; opacity: .5; }
.cct-title:focus { box-shadow: inset 0 0 0 2px var(--brand); border-radius: 6px; }

/* ---- copy box full screen: heading box · [address block] · Subject row (bold, never removable) · text ---- */
.ccf-doc { min-height: 100%; box-sizing: border-box; }
.ccf-heading { position: static; max-width: none; padding: 6px 8px 12px; margin: 0 0 16px; border-bottom: 1px solid var(--line); border-radius: 0; }
.ccf-heading:focus { border-radius: 6px; }
.ccf-doc .ccf-text { min-height: 0; }
.ccf-doc .ccf-main { min-height: 40vh; }
.ccf-doc .ccf-pre { margin-bottom: 14px; }
.ccf-subjrow { display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; }
.ccf-subjrow label { font-weight: 700; flex: none; font-size: 1rem; }
.ccf-subjrow .ccf-subj { flex: 1; min-width: 0; border: none; border-bottom: 1px dashed var(--line); outline: none; box-shadow: none; background: transparent; color: var(--text); font: inherit; font-weight: 700; font-size: 1rem; line-height: 1.7; padding: 0 0 2px; border-radius: 0; }
.ccf-subjrow .ccf-subj:focus { border-bottom-color: var(--brand); box-shadow: none; }
.ccf-subjrow .ccf-subj::placeholder { font-weight: 500; opacity: .5; }
.cc-full-d .ccf-doc > * { max-width: 740px; margin-left: auto; margin-right: auto; }
.cc-full-d .ccf-doc > .ccf-text { font-size: 1.02rem; }

/* ---- copy box in the chat: email / application = text · Subject (bold, locked label) · text ---- */
.copycard-body[data-mail] { white-space: normal; }
.cc-seg { white-space: pre-wrap; overflow-wrap: anywhere; outline: none; cursor: inherit; min-height: 1.6em; }
.cc-seg:empty { min-height: 1.6em; }
.cc-subj { font-weight: 700; margin: 1.6em 0; outline: none; cursor: inherit; overflow-wrap: anywhere; white-space: normal; }
.cc-seg:first-child + .cc-subj, .cc-subj:first-child { margin-top: 0; }
.cc-subj::before { content: attr(data-label) ": "; }
.cc-subj:empty::after { content: attr(data-ph); font-weight: 500; opacity: .45; }
.cc-subj:not(:empty)::after { content: none; }
.cc-subj + .cc-seg { margin-top: 0; }
.copycard-body[data-mail] .cc-subj:focus { box-shadow: none; }


/* ---------- Code inside the one copy box ---------- */
/* Code is the same .copycard as an email or essay (same toolbar, same full screen); only the text is monospaced,
   keeps its indentation, and scrolls sideways instead of wrapping. */
.copycard[data-code] .copycard-body { font-family: var(--font-mono); font-size: .84rem; line-height: 1.55; white-space: pre; overflow-wrap: normal; overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; tab-size: 4; }
.copycard[data-code] .copycard-title { text-transform: lowercase; font-family: var(--font-mono); font-size: .76rem; }
.cc-full-code .ccf-text, .cc-full-code .ccf-main { font-family: var(--font-mono); font-size: .88rem; line-height: 1.55; white-space: pre; overflow-wrap: normal; overflow-x: auto; tab-size: 4; }

/* ---- Letter / application Subject: bold but an ordinary line — empty it and it disappears (an email's Subject is never removed) ---- */
.cc-subj[data-free]:empty:not(:focus) { display: none; }
.cc-subj[data-free]:empty::after { content: none; }
.cc-subj[data-free]:empty:not(:focus) + .cc-seg { margin-top: 1.6em; }

/* ---- Voice typing (js/voice.js): mic beside Send, and the recording pill that covers the composer ---- */
.composer { position: relative; }
.composer .mic-btn { align-self: flex-end; margin-bottom: 2px; flex: none; color: var(--text); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.composer .mic-btn svg { width: 22px; height: 22px; stroke-width: 1.9; }
.composer .mic-btn:disabled { opacity: .4; cursor: not-allowed; }
.composer .mic-btn.hidden { display: none; }
:where(html[data-input="mouse"]) .composer .mic-btn:not(:disabled):hover { background: var(--surface-2); }
/* While listening the composer grows: live words on top, controls underneath (✕ · level · waveform · Stop · Send). */
.composer.recording { align-items: stretch; padding: 8px 7px 7px 10px; }
.composer.recording > :not(.rec-bar) { display: none !important; }
.rec-bar { position: static; flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; min-width: 0; background: transparent; border-radius: inherit; }
.rec-bar.hidden { display: none; }
.rec-bar button { flex: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.rec-live { position: relative; min-height: 26px; max-height: 148px; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 4px 6px 2px; font: inherit; line-height: 1.5; color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.rec-live-text { color: var(--text); }
.rec-live-prev { color: var(--muted); }
.rec-live .rec-hint { display: none; color: var(--muted); font-style: italic; }
.rec-live.is-empty .rec-hint { display: inline; }
.rec-live.is-empty .rec-dots { display: none; }
.rec-dots { display: none; margin-left: 4px; white-space: nowrap; vertical-align: baseline; }
.rec-live.is-working .rec-dots { display: inline-block; }
.rec-dots i { display: inline-block; width: 5px; height: 5px; margin: 0 1.5px; border-radius: 50%; background: var(--muted); animation: recDot 1.1s infinite ease-in-out; }
.rec-dots i:nth-child(2) { animation-delay: .15s; } .rec-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes recDot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.rec-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rec-cancel { width: 40px; height: 40px; color: var(--text); }
.rec-cancel svg { width: 22px; height: 22px; stroke-width: 2; }
.rec-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); opacity: .55; transition: background .15s, opacity .15s, transform .15s; }
.rec-bar.is-speaking .rec-dot { background: #1aa37a; opacity: 1; transform: scale(1.25); }
.rec-bar.is-processing .rec-dot { background: var(--brand); opacity: 1; }
.rec-wave { flex: 1 1 auto; min-width: 0; height: 30px; display: flex; align-items: center; justify-content: center; gap: 3px; overflow: hidden; }
.rec-wave span { flex: 0 0 3px; width: 3px; height: 100%; border-radius: 2px; background: var(--muted); transform: scaleY(.1); transform-origin: center; transition: transform .06s linear; }
/* Stop: a soft, clearly visible round ring (never a heavy black outline) with a small rounded square inside; it breathes gently while listening. */
.rec-stop { width: 44px; height: 44px; border-radius: 50%; padding: 0; background: var(--surface-2); color: var(--text); border: 1.5px solid color-mix(in srgb, var(--text) 26%, transparent); display: grid; place-items: center; box-sizing: border-box; animation: none; transition: background .15s, border-color .15s, transform .12s; }
/* The ring must always be visible: "button.ghost" (transparent border) is stronger than ".rec-stop", so name both. */
button.ghost.rec-stop, button.ghost.rec-stop:hover, button.ghost.rec-stop:focus-visible { border: 1.5px solid color-mix(in srgb, var(--text) 26%, transparent); border-radius: 50%; width: 44px; min-height: 44px; height: 44px; flex: none; background: var(--surface-2); color: var(--text); animation: none; box-shadow: none; }
button.ghost.rec-stop:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.rec-stop svg { width: 28px; height: 28px; display: block; }
.rec-stop:active:not(:disabled) { transform: scale(.94); }
:where(html[data-input="mouse"]) button.ghost.rec-stop:not(:disabled):hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 26%, transparent); }
.rec-stop:disabled { animation: none; }
@keyframes recStopPulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 26%, transparent); } 70%, 100% { box-shadow: 0 0 0 9px transparent; } }
@media (prefers-reduced-motion: reduce) { .rec-stop { animation: none; } }
/* Bangla ⇄ English switch beside Stop (Alt+L): a soft recessed track with a dark pill that slides to the language being listened to */
.rec-lang { position: relative; flex: none; display: inline-grid; grid-template-columns: 1fr 1fr; align-items: center; height: 36px; padding: 3px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--text) 12%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--text) 7%, var(--surface-2)), var(--surface-2)); box-shadow: inset 0 1px 2px color-mix(in srgb, var(--text) 12%, transparent), 0 1px 0 color-mix(in srgb, var(--bg) 70%, transparent); color: var(--muted); font-family: var(--font-text, inherit); font-size: 12.5px; font-weight: 650; line-height: 1; letter-spacing: .02em; cursor: pointer; box-sizing: border-box; -webkit-tap-highlight-color: transparent; touch-action: manipulation; isolation: isolate; transition: border-color .2s, box-shadow .2s; }
.rec-lang::before { content: ""; position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 999px; background: linear-gradient(180deg, color-mix(in srgb, var(--text) 86%, var(--bg)), var(--text)); box-shadow: 0 2px 6px color-mix(in srgb, var(--text) 28%, transparent), inset 0 1px 0 color-mix(in srgb, var(--bg) 22%, transparent); transition: transform .26s cubic-bezier(.3, .8, .3, 1); }
.rec-lang[data-lang="en"]::before { transform: translateX(100%); }
.rec-lang span { min-width: 33px; height: 100%; padding: 0 7px; display: grid; place-items: center; border-radius: 999px; transition: color .2s; white-space: nowrap; }
.rec-lang span[data-l="en"] { font-family: "Outfit", var(--font-text, inherit); font-size: 12.5px; font-weight: 650; letter-spacing: .06em; }
/* Bangla letters sit lower and look smaller than Latin ones at the same size, so বাং gets its own Bengali font (Anek Bangla, loaded in chat.html) and a larger size to match the height of EN */
.rec-lang span[data-l="bn"] { font-family: "Anek Bangla", "Hind Siliguri", "Noto Sans Bengali", "Kalpurush", "Nirmala UI", "Vrinda", "FreeSans", sans-serif; font-size: 15.5px; font-weight: 600; letter-spacing: 0; padding-top: 3px; }
.rec-lang[data-lang="bn"] span[data-l="bn"], .rec-lang[data-lang="en"] span[data-l="en"] { color: var(--bg); }
:where(html[data-input="mouse"]) .rec-lang:hover { border-color: color-mix(in srgb, var(--text) 24%, transparent); }
.rec-lang:active::before { filter: brightness(1.12); }
.rec-lang:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
@media (max-width: 420px) { .rec-row { gap: 6px; } .rec-lang { height: 34px; } .rec-lang span { min-width: 29px; padding: 0 5px; } .rec-lang span[data-l="bn"] { font-size: 15px; } .rec-cancel { width: 36px; } }
@media (prefers-reduced-motion: reduce) { .rec-lang::before, .rec-lang span { transition: none; } }
.rec-send { width: 44px; height: 44px; border-radius: 50%; padding: 0; display: grid; place-items: center; }
.rec-send svg { width: 22px; height: 22px; stroke-width: 2.3; }
.rec-bar button:disabled { opacity: .45; }
@media (prefers-reduced-motion: reduce) { .rec-wave span { transition: none; } .rec-dots i { animation: none; opacity: .7; } }

/* How-to strip above the message box while it holds a table (chat.js → tableHint) */
.table-hint { position: relative; margin: 0 0 6px; padding: 8px 30px 8px 10px; border-radius: var(--radius-s); background: var(--brand-soft); border: 1px solid var(--line); font-size: .8rem; line-height: 1.4; color: var(--text); }
.table-hint ol { margin: 4px 0 0; padding-left: 18px; }
.table-hint li { margin: 2px 0; }
.table-hint code, .table-hint kbd { font-size: .78rem; padding: 0 4px; border-radius: 4px; background: var(--surface-3); }
.table-hint .th-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: .8rem; }
.table-hint .th-x:hover { color: var(--text); }

/* ---- Admin -> AI & brain ---- */
/* Each brain row is a fixed 3-column grid (text | ▲▼ | switch) so the arrows and switches line up
   in the same two columns on every row, whatever the length of the description. */
.setting-row.brain-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 46px; align-items: center; column-gap: 12px; }
.brain-row .brain-order { display: flex; justify-content: center; gap: 6px; margin: 0; }
.brain-row .brain-order button { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; line-height: 1; font-size: .8rem; }
.brain-row .switch { justify-self: end; }
/* key status sits right under the model box */
.brain-key-box { display: flex; flex-direction: column; gap: 2px; }
.brain-key-box small { color: var(--muted); font-size: .8rem; }
@media (max-width: 520px) { .setting-row.brain-row { grid-template-columns: minmax(0, 1fr) 72px 44px; column-gap: 8px; } }


/* =====================================================================================================
   v137 — Admin → Support and Admin → Reports on a phone
   One column, 16px text (no zoom-in), tall tap targets, full-width buttons, pills that wrap instead of poking out.
   ===================================================================================================== */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) #tab-support > .panel, :where(html[data-layout="compact"]) #tab-reports > .panel { background: transparent; border: 0; padding: 0; gap: 12px; }
  :where(html[data-layout="compact"]) #tab-support > .panel > h2, :where(html[data-layout="compact"]) #tab-reports > .panel > h2 { font-size: 1.2rem; }
  :where(html[data-layout="compact"]) #tab-support .toolbar, :where(html[data-layout="compact"]) #tab-reports .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  :where(html[data-layout="compact"]) #tab-support .toolbar .grow, :where(html[data-layout="compact"]) #tab-reports .toolbar .grow { flex: none; width: 100%; }
  :where(html[data-layout="compact"]) #tab-support .toolbar input, :where(html[data-layout="compact"]) #tab-reports .toolbar input { min-height: 50px; height: 50px; font-size: 16px; border-radius: 14px; }
  :where(html[data-layout="compact"]) #tab-support .toolbar .sx, :where(html[data-layout="compact"]) #tab-reports .toolbar .sx { flex: none; width: 100%; min-width: 0; }
  :where(html[data-layout="compact"]) #tab-support .toolbar > button, :where(html[data-layout="compact"]) #tab-reports .toolbar > button { width: 100%; min-height: 48px; border-radius: 14px; font-size: .98rem; white-space: normal; }

  :where(html[data-layout="compact"]) #tab-support .cards, :where(html[data-layout="compact"]) #tab-reports .cards { gap: 12px; }
  :where(html[data-layout="compact"]) #tab-support .card, :where(html[data-layout="compact"]) #tab-reports .card { background: var(--surface-2); border-radius: 18px; padding: 14px; gap: 10px; }
  :where(html[data-layout="compact"]) #tab-support .card .a, :where(html[data-layout="compact"]) #tab-reports .card .a { font-size: .97rem; line-height: 1.5; color: var(--text); }
  :where(html[data-layout="compact"]) #tab-support .card .meta, :where(html[data-layout="compact"]) #tab-reports .card .meta { gap: 6px; font-size: .82rem; }
  :where(html[data-layout="compact"]) #tab-support .card .pill, :where(html[data-layout="compact"]) #tab-reports .card .pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  :where(html[data-layout="compact"]) #tab-support .card .meta > span:not(.pill), :where(html[data-layout="compact"]) #tab-reports .card .meta > span:not(.pill) { min-width: 0; overflow-wrap: anywhere; }

  /* buttons on a card: two per row, easy to hit */
  :where(html[data-layout="compact"]) #tab-support .card .row-actions, :where(html[data-layout="compact"]) #tab-reports .card .row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
  :where(html[data-layout="compact"]) #tab-support .card .row-actions button, :where(html[data-layout="compact"]) #tab-reports .card .row-actions button { width: 100%; min-height: 46px; border-radius: 12px; font-size: .95rem; white-space: normal; }
  :where(html[data-layout="compact"]) #tab-support .card .sp-body .row-actions { grid-template-columns: 1fr; }
  :where(html[data-layout="compact"]) #tab-support .card .sp-body .row-actions button.primary { min-height: 50px; font-size: 1rem; }
  :where(html[data-layout="compact"]) #tab-support .card textarea { min-height: 130px; font-size: 16px; border-radius: 14px; padding: 12px 14px; width: 100%; box-sizing: border-box; }
  :where(html[data-layout="compact"]) #tab-support .sp-body { min-width: 0; }
  :where(html[data-layout="compact"]) #tab-support .sp-body > div { overflow-wrap: anywhere; }
  :where(html[data-layout="compact"]) #tab-support #sp-mail-warn { font-size: .9rem; }



/* ---- v138: login page — "Create an account" sits a little lower (a clear gap under Continue with Google so it
   isn't tapped by mistake), with a quiet "Contact support" line below it ---- */
.auth-cta { margin-top: 16px; padding-top: 2px; }
.auth-help { margin-top: 8px; font-size: .85rem; line-height: 1.5; }
.auth-help a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 4px 2px; }
.g-btn + .auth-cta { margin-top: 18px; }

/* ---- v138: phone — Delete account and Support use the same icon-only back button as Settings ---- */
@media (max-width: 640px) {
  .page-bar a.back-icon .btn-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .page-bar a.back-icon { width: 38px; padding: 8px; gap: 0; flex: none; }
}

/* ---- v139: sign-up page — Terms / Privacy line above the Create account button ---- */
.auth-legal { margin: 2px 0 10px; color: var(--muted); font-size: .84rem; line-height: 1.5; }
.auth-legal b { color: var(--text); font-weight: 600; }
.auth-legal a { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 3px 1px; }

/* ---------- Device limit page (public/device-limit.html) ---------- */
.dl-body { min-height: 100vh; min-height: 100dvh; background: var(--bg); color: var(--text); }
.dl-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.dl-card { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 28px 26px 22px; display: flex; flex-direction: column; align-items: stretch; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.18); }
.dl-logo { align-self: center; font-size: 1.2rem; margin-bottom: 2px; }
.dl-ico { align-self: center; width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.dl-ico svg { width: 32px; height: 32px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.dl-card h1 { margin: 4px 0 0; font-size: 1.55rem; line-height: 1.2; text-align: center; font-family: var(--font-display); }
.dl-lead { margin: 0; text-align: center; color: var(--muted); line-height: 1.55; font-size: .96rem; overflow-wrap: anywhere; }
.dl-lead b { color: var(--text); }
.dl-status { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 14px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: .9rem; text-align: center; line-height: 1.4; }
.dl-status.ok { background: rgba(35,168,90,.14); color: var(--ok); }
.dl-spin { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: dl-rot .8s linear infinite; }
.dl-spin.hidden { display: none; }
@keyframes dl-rot { to { transform: rotate(360deg); } }
.dl-main { width: 100%; min-height: 50px; height: auto; padding: 12px 16px; font-size: 1rem; line-height: 1.3; white-space: normal; text-align: center; margin-top: 4px; }
.dl-hint { margin: -4px 2px 0; text-align: center; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.dl-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .82rem; margin: 2px 0; }
.dl-or::before, .dl-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.dl-steps { border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 14px 16px; }
.dl-steps h2 { margin: 0 0 8px; font-size: 1rem; font-family: var(--font-display); }
.dl-steps ol { margin: 0; padding-left: 1.25em; display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.dl-steps li::marker { color: var(--brand); font-weight: 700; }
.dl-steps b { color: var(--text); font-weight: 600; }
.dl-error { padding: 10px 14px; border-radius: 12px; background: var(--danger-soft); color: var(--danger); font-size: .9rem; line-height: 1.4; }
.dl-error.hidden { display: none; }
.dl-foot { display: flex; justify-content: center; margin-top: 2px; }
.dl-foot .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 22px; }
.dl-foot .btn.primary { background: var(--brand); color: var(--on-brand); border-color: transparent; }
@media (max-width: 520px) {
  .dl-wrap { align-items: flex-start; padding-top: max(16px, env(safe-area-inset-top)); }
  .dl-card { padding: 22px 16px 18px; border-radius: 16px; box-shadow: none; }
  .dl-card h1 { font-size: 1.35rem; }
  .dl-foot .btn { width: 100%; }
}
@media (max-height: 560px) and (orientation: landscape) { .dl-wrap { align-items: flex-start; } .dl-ico { display: none; } }
@media (prefers-reduced-motion: reduce) { .dl-spin { animation-duration: 2.4s; } }

/* Admin → Users: the action buttons always stay on one line in one tidy row (the table scrolls sideways when the window is
   too narrow), whatever the other rows hold — e.g. a long "deleted by admin · 30 days left" label no longer squeezes them. */
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) #users-table { min-width: 900px; }
  :where(html[data-layout="wide"]) #users-table td.nowrap, :where(html[data-layout="wide"]) #users-table td:nth-child(2), :where(html[data-layout="wide"]) #users-table td:nth-child(3), :where(html[data-layout="wide"]) #users-table td:nth-child(4) { white-space: nowrap; }
  :where(html[data-layout="wide"]) #users-table td:first-child { min-width: 240px; }
  :where(html[data-layout="wide"]) #users-table td.act-cell { width: 1%; white-space: nowrap; text-align: left; }
  :where(html[data-layout="wide"]) #users-table td.act-cell .row-actions { flex-wrap: nowrap; justify-content: flex-start; }
  :where(html[data-layout="wide"]) #users-table td.act-cell .row-actions button { flex: none; }


/* Settings → Report a problem: the box, a quiet character count, and one footer row —
   the Support link on the left, the Send button on the right (stacked, full-width button on phones). */
.report-field { position: relative; }
.report-field textarea { width: 100%; min-height: 150px; padding: 14px 14px 30px; border-radius: 14px; line-height: 1.5; resize: vertical; box-sizing: border-box; }
.report-count { position: absolute; right: 14px; bottom: 10px; font-size: .75rem; color: var(--muted); pointer-events: none; }
.report-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.report-alt { margin: 0; color: var(--muted); font-size: .88rem; }
.report-alt a { color: var(--brand); font-weight: 600; }
.report-send { min-height: 44px; padding: 0 26px; border-radius: 12px; font-weight: 700; }
@media (max-width: 560px) {
  .report-foot { flex-direction: column-reverse; align-items: stretch; }
  .report-send { width: 100%; }
  .report-alt { text-align: center; }
}

/* ---------- New chat page ----------
   A one-line greeting, the chat box and four suggestions.
   Computer: greeting + box + suggestion rows (under the box, closable) form one group in the middle of the page; the first
   message glides the box to the bottom (.is-new goes away). An opened chat always keeps the box at the bottom.
   Phone: the box always stays at the bottom; greeting ("Hi name" + big line) and suggestion pills sit in the middle.
   Incognito with no message yet: box in the middle on a computer (.is-incog-new), at the bottom on a phone. */
.welcome-sug { display: none; }
.welcome.new-welcome { margin: auto; padding: 0 0 4px; max-width: 760px; text-align: center; }
.new-welcome .hi { display: none; margin: 0; }
.new-welcome h2 { margin: 0; font-family: "Outfit", var(--font-display); font-weight: 600; font-size: clamp(1.6rem, 1.7vw, 1.95rem); line-height: 1.25; letter-spacing: -.005em; text-wrap: balance; color: var(--text); animation: ncRise .6s .05s cubic-bezier(.2,.7,.2,1) both; }
.new-welcome .hi-name { color: inherit; }

/* the soft living glow behind the page: three blurred colour pools made from the accent (so it follows the accent and the
   light / dark theme), a faint dotted texture that fades out towards the edges, and a gentle bottom shade.
   Only transform animates (cheap on phones); reduced-motion = still. */
.main.is-new:not(.view-page) { --nc-a: .17; --nc-b: .10; --nc-l: 58%; }
:root[data-theme="light"] .main.is-new:not(.view-page) { --nc-a: .17; --nc-b: .10; --nc-l: 62%; }
:root[data-accent="white"] .main.is-new:not(.view-page) { --nc-a: .08; --nc-b: .05; }
.main.is-new:not(.view-page)::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; clip-path: inset(0);
  /* dark: one clean warm halo behind the greeting and two very quiet side pools of (almost) the same hue, no dots */
  background:
    radial-gradient(54% 40% at 50% 30%, hsl(var(--h) var(--s) var(--nc-l) / var(--nc-a)), transparent 74%),
    radial-gradient(44% 34% at 10% 88%, hsl(calc(var(--h) + 10) calc(var(--s) - 18%) 52% / .06), transparent 72%),
    radial-gradient(40% 32% at 92% 10%, hsl(calc(var(--h) - 10) calc(var(--s) - 18%) 52% / .05), transparent 72%),
    linear-gradient(to top, hsl(var(--h) 20% 4% / .22), transparent 28%);
  transform-origin: 50% 32%; animation: ncAurora 26s ease-in-out infinite alternate; will-change: transform;
}
:root[data-theme="light"] .main.is-new:not(.view-page)::before {
  background:
    radial-gradient(46% 38% at 50% 30%, hsl(var(--h) var(--s) var(--nc-l) / var(--nc-a)), transparent 72%),
    radial-gradient(40% 34% at 12% 82%, hsl(calc(var(--h) + 38) var(--s) var(--nc-l) / var(--nc-b)), transparent 70%),
    radial-gradient(38% 32% at 90% 16%, hsl(calc(var(--h) - 34) var(--s) var(--nc-l) / var(--nc-b)), transparent 70%);
}
:root[data-theme="light"] .main.is-new:not(.view-page)::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .28;
  background-image: radial-gradient(circle, var(--muted) 0.8px, transparent 1.3px); background-size: 26px 26px; background-position: center top;
  -webkit-mask-image: radial-gradient(62% 46% at 50% 34%, #000 0%, transparent 78%); mask-image: radial-gradient(62% 46% at 50% 34%, #000 0%, transparent 78%);
}

@keyframes ncAurora { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(0, -1.2%, 0) scale(1.07); } }
@media (prefers-reduced-motion: reduce) { .main.is-new:not(.view-page)::before { animation: none; } }
.main.is-new:not(.view-page) > .scroller, .main.is-new:not(.view-page) > .welcome-sug, .main.is-new:not(.view-page) > .composer-wrap { position: relative; }
.main.is-new:not(.view-page) > .scroller { z-index: 1; }
.main.is-new:not(.view-page) > .welcome-sug { z-index: 2; }
.main.is-new:not(.view-page) > .composer-wrap { z-index: 3; background: transparent; }
.main.is-new:not(.view-page) > .welcome-sug { display: block; }

/* the chat box on the New chat page: a floating glass bar */
.main.is-new:not(.view-page) .composer {
  background: var(--surface); background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.15); backdrop-filter: blur(16px) saturate(1.15);
  border-color: var(--line); border-color: color-mix(in srgb, var(--line) 75%, transparent);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 20px 50px -24px rgba(40,28,10,.34), 0 3px 10px -4px rgba(40,28,10,.08);
  transition: border-color .2s, box-shadow .25s;
  animation: ncRise .7s .16s cubic-bezier(.2,.7,.2,1) both;
}
.main.is-new:not(.view-page) .composer:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft), 0 24px 60px -24px hsl(var(--h) var(--s) 40% / .5); }
:root[data-theme="dark"] .main.is-new:not(.view-page) .composer { box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 22px 54px -22px rgba(0,0,0,.75); }
:root[data-theme="dark"] .main.is-new:not(.view-page) .composer:focus-within { box-shadow: 0 0 0 4px var(--brand-soft), 0 26px 64px -22px rgba(0,0,0,.8); }

/* suggestion rows (computer) / pills (phone) */
.sug-wrap { position: relative; }
.sug-list { display: flex; flex-direction: column; gap: 2px; }
.sug-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 0; padding: 12px 14px; border: 0; border-radius: 14px; background: transparent; color: var(--text);
  font: inherit; font-size: .88rem; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .18s, transform .18s, box-shadow .18s;
  animation: ncRise .6s calc(.26s + var(--i, 0) * .065s) cubic-bezier(.2,.7,.2,1) both;
}
.sug-item[data-k="math"]    { --c: 262; }
.sug-item[data-k="weather"] { --c: 204; }
.sug-item[data-k="learn"]   { --c: 32; }
.sug-item[data-k="news"]    { --c: 152; }
.sug-tile { flex: none; display: grid; place-items: center; width: 18px; height: 18px; color: var(--text); }
.sug-ico { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sug-emoji { display: none; font-size: 1.25rem; line-height: 1; }
.sug-text { min-width: 0; flex: 0 1 auto; overflow-wrap: anywhere; }
.sug-go { display: none; flex: none; margin-left: -4px; width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: translateX(-6px); transition: opacity .18s, transform .18s; }
.sug-row { position: relative; display: flex; align-items: center; width: 100%; max-width: 100%; }
.sug-row .sug-item { flex: 1 1 auto; padding-right: 48px; }
/* the cross of one suggestion: vertically centred in its own row */
.sug-x { position: absolute; top: 0; bottom: 0; margin: auto 0; right: 10px; transform: none; width: 28px; height: 28px; min-height: 0; box-sizing: border-box; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; opacity: .55; transition: opacity .15s, background .15s, color .15s; -webkit-tap-highlight-color: transparent; }
.sug-x svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sug-row:hover .sug-x, .sug-x:focus-visible { opacity: 1; }
:where(html[data-input="mouse"]) .sug-item:hover { background: var(--surface-2); background: color-mix(in srgb, var(--surface-3) 55%, transparent); }
  :where(html[data-input="mouse"]) .sug-item:hover .sug-go { opacity: .9; transform: none; }
  :where(html[data-input="mouse"]) .sug-x:hover { background: var(--surface-2); color: var(--text); }
.sug-item:active { transform: scale(.985); }
.sug-item:focus-visible { outline-offset: -2px; }

@keyframes ncRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes ncPulse { 0%, 100% { opacity: .75; transform: scale(1); } 50% { opacity: 1; transform: scale(1.12); } }
@keyframes ncDrift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(1.5%, -2%, 0) scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
  }

/* ----- computer ----- */
/* [wide layout: every computer, any window width] */
  /* Auto margins (not justify-content) centre the group, so an announcement banner above it stays at the top. */
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .scroller { flex: 0 0 auto; overflow: visible; margin-top: auto; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .welcome-sug { margin-bottom: auto; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .scroller .thread, :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .topbar ~ .scroller .thread, :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .topbar ~ .banner:not(.hidden) ~ .scroller .thread { padding-top: 0; padding-bottom: 26px; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .composer-wrap { order: 2; padding-top: 0; padding-bottom: 0; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .welcome-sug { order: 3; width: 100%; max-width: 800px; margin-left: auto; margin-right: auto; padding: 0 14px; box-sizing: border-box; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .welcome-sug:not(:empty) { padding-top: 10px; padding-bottom: 14px; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .composer { max-width: 760px; border-radius: 30px; padding: 10px 10px 10px 20px; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page):not(.is-incog-new) .composer-hint { display: none; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .sug-wrap { max-width: 760px; margin: 0 auto; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .sug-list { padding: 0 4px; }
  /* incognito (nothing sent yet): same middle position; its own page text stays exactly as it was */
  :where(html[data-nc="pc"]) .main.is-incog-new:not(.view-page) > .composer-wrap { padding-bottom: 0; }

/* Computer, any window height: the greeting hangs upward and the suggestions hang downward from the box, so the BOX itself
   sits exactly in the middle of the page (like ChatGPT / Gemini) and the suggestions never push it up. (Very short windows
   hide the suggestions altogether, see below.) The old 640px height limit made normal laptop windows fall back to a group
   that was centred WITH the suggestions, which lifted the box above the middle. */
/* [wide layout: every computer, any window width] */
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .scroller { flex: 0 0 0; position: relative; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .scroller .thread, :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .topbar ~ .scroller .thread, :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .topbar ~ .banner:not(.hidden) ~ .scroller .thread { position: absolute; left: 0; right: 0; bottom: 0; padding-top: 0; padding-bottom: 26px; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .welcome-sug, :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .welcome-sug:not(:empty) { height: 0; padding-top: 0; padding-bottom: 0; overflow: visible; }
  :where(html[data-nc="pc"]) .main.is-new:not(.view-page) .sug-wrap { padding-top: 8px; }



/* ----- phone ----- */
/* [compact layout: phones only] */
    :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .scroller { flex: 0 0 auto; overflow: visible; margin-top: auto; }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug { margin-bottom: auto; }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .scroller .thread, :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) .topbar ~ .scroller .thread, :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) .topbar ~ .banner:not(.hidden) ~ .scroller .thread { padding-top: 0; padding-bottom: 6px; }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .composer-wrap { order: 3; }
  :where(html[data-nc="phone"]) .welcome.new-welcome { margin: 0; max-width: none; padding: 0 6px; text-align: center; }
  :where(html[data-nc="phone"]) .new-welcome .hi { display: block; margin: 0 0 2px; font-family: "Outfit", var(--font-display); font-size: clamp(1.3rem, 6.2vw, 1.6rem); font-weight: 600; line-height: 1.2; color: var(--text); animation: ncRise .6s cubic-bezier(.2,.7,.2,1) both; }
  :where(html[data-nc="phone"]) .new-welcome h2 { font-size: clamp(1.45rem, 7.9vw, 2.2rem); font-weight: 600; line-height: 1.22; letter-spacing: -.012em; width: 100%; max-width: none; }
  @media (max-width: 340px) { :where(html[data-nc="phone"]) .new-welcome h2 { font-size: 7.4vw; } }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug:not(:empty) { padding: 14px 18px 8px; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-list { align-items: flex-start; gap: 8px; padding: 0; }
  :where(html[data-nc="phone"]) .sug-item { gap: 10px; }
  :where(html[data-nc="phone"]) .sug-item { width: auto; max-width: 100%; flex: none; gap: 12px; min-height: 44px; padding: 0 18px 0 14px; border-radius: 999px; background: var(--surface); box-shadow: 0 1px 3px rgba(40,28,10,.06); font-size: .9rem; color: var(--muted); color: color-mix(in srgb, var(--text) 74%, var(--surface)); }
  html[data-nc="phone"][data-theme="dark"] .sug-item { box-shadow: 0 0 0 1px var(--line); }
  :where(html[data-nc="phone"]) .sug-item:active { background: var(--surface-2); }
  :where(html[data-nc="phone"]) .sug-tile { width: auto; height: auto; }
  :where(html[data-nc="phone"]) .sug-ico, :where(html[data-nc="phone"]) .sug-go { display: none; }
  :where(html[data-nc="phone"]) .sug-row { width: auto; }
  :where(html[data-nc="phone"]) .sug-row .sug-item { padding-right: 44px; }
  :where(html[data-nc="phone"]) .sug-x { right: 8px; opacity: .7; }
  :where(html[data-nc="phone"]) .sug-emoji { display: inline-block; font-size: 1rem; }
  :where(html[data-nc="phone"]) .sug-text { flex: 0 1 auto; }

/* Phone with the keyboard up (very short screen): the pills make room for the box and the greeting. */
@media (max-height: 520px) and (orientation: landscape) { :where(html[data-nc="phone"]) .main.is-new:not(.view-page) > .welcome-sug { display: none !important; } }
/* Computer window that is very short: the rows would push the box off screen, so they step aside. */
@media (max-height: 560px) { :where(html[data-nc="pc"]) .main.is-new:not(.view-page) > .welcome-sug { display: none !important; } }
/* Admin → Site: suggestions switched off for computers / phones */
/* [wide layout: every computer, any window width] */ :where(html[data-nc="pc"]) .main[data-sug-pc="0"] > .welcome-sug > .sug-wrap { display: none; } 
/* [compact layout: phones only] */ :where(html[data-nc="phone"]) .main[data-sug-mobile="0"] > .welcome-sug > .sug-wrap { display: none; } 

/* Incognito footer line (in the page flow, never absolutely positioned). Only used by the computer layout. */
.incog-foot { display: none; }

/* Incognito welcome: plain centred title (regular weight) + grey note, like ChatGPT's temporary chat. */
.incognito-welcome h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.45rem, 2vw, 1.7rem); letter-spacing: -.01em; line-height: 1.25; }
.incognito-welcome .bn { margin: 14px auto 0; max-width: 52ch; font-size: .95rem; line-height: 1.55; color: var(--muted); }
.main.is-incog-new:not(.view-page)::before { display: none; }
/* [wide layout: every computer, any window width] */
  :where(html[data-nc="pc"]) .main.is-incog-new:not(.view-page) > .composer-wrap { position: static; }
  :where(html[data-nc="pc"]) .main.is-incog-new:not(.view-page) > .composer-wrap .composer-hint { display: none; }
  /* taken out of the flow (pinned to the bottom edge) so it can't pull the box off the exact middle */
  :where(html[data-nc="pc"]) .main.is-incog-new:not(.view-page) > .incog-foot { display: block; position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; width: 100%; box-sizing: border-box; margin: 0; padding: 0 16px calc(10px + env(safe-area-inset-bottom)); text-align: center; font-size: .74rem; color: var(--muted); pointer-events: none; }
  :where(html[data-nc="pc"]) .main.is-incog-new:not(.view-page) .composer { box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 22px -10px rgba(0,0,0,.18); }


/* Phone, incognito with nothing sent yet: the title + grey note sit in the middle of the screen (between the floating
   top buttons and the chat box), centred left-to-right too. */
/* [compact layout: phones only] */
  :where(html[data-nc="phone"]) .main.is-incog-new:not(.view-page) > .scroller .thread {
    min-height: 100%; box-sizing: border-box; justify-content: center;
    padding-top: var(--floating-topbar-h, 62px) !important; padding-bottom: 12px !important;
  }
  :where(html[data-nc="phone"]) .main.is-incog-new:not(.view-page) .incognito-welcome { margin: 0 auto; padding: 0 12px; text-align: center; max-width: 100%; }
  :where(html[data-nc="phone"]) .main.is-incog-new:not(.view-page) .incognito-welcome .bn { margin-left: auto; margin-right: auto; }


/* =====================================================================================
   Admin → Support: an inbox. Requests on the left, the open one on the right (conversation, actions and the
   reply box all in one place). On a phone the list is one page and each request opens as its own page.
   ===================================================================================== */
.sp-panel { gap: 12px; }
.sp-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sp-top-text { min-width: 0; }
.sp-top-text .sub { margin: 4px 0 0; }
.sp-top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.sp-more, .panel .sp-more { position: relative; border-top: 0; padding-top: 0; }
.panel .sp-more > summary, .sp-more > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; box-sizing: border-box; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); font-size: .88rem; line-height: 1; white-space: nowrap; user-select: none; }
.panel .sp-more > summary { padding: 0 14px; font-size: .88rem; }
.sp-more > summary > .sp-more-chev { flex: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s ease; }
.sp-more[open] > summary > .sp-more-chev { transform: rotate(180deg); }
.sp-more > summary::-webkit-details-marker { display: none; }
.sp-more[open] > summary { background: var(--surface-3); }
.sp-more-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; min-width: 230px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 120px); box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.sp-more-menu button { text-align: left; border: 0; background: transparent; min-height: 0; padding: 9px 10px; border-radius: 8px; white-space: nowrap; width: 100%; }
/* [compact layout: phones only] */ :where(html[data-layout="compact"]) .sp-more-menu { max-width: calc(100vw - 48px); } 

.sp-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sp-filters .grow { flex: 1; min-width: 200px; }
.sp-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sp-chip { min-height: 0; padding: 6px 12px; border-radius: 999px; font-size: .84rem; background: transparent; border: 1px solid var(--line); color: var(--muted); }
.sp-chip b { font-weight: 600; margin-left: 4px; color: var(--text); opacity: .75; }
:where(html[data-input="mouse"]) .sp-chip:hover { background: var(--surface-2); color: var(--text); }
.sp-chip.on, .sp-chip.on:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.sp-chip.on b { color: inherit; opacity: .9; }

.sp-layout { display: grid; grid-template-columns: 350px minmax(0, 1fr); height: clamp(480px, calc(100dvh - 300px), 800px); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--bg); }
.sp-list { overflow-y: auto; overscroll-behavior: auto; border-right: 1px solid var(--line); background: var(--surface); min-width: 0; }
.sp-list > .empty { padding: 36px 14px; }
.sp-detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.sp-row { display: flex; gap: 11px; align-items: flex-start; width: 100%; min-height: 0; padding: 13px 14px 13px 15px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--text); font: inherit; text-align: left; position: relative; cursor: pointer; }
:where(html[data-input="mouse"]) .sp-row:hover { background: var(--surface-2); }
.sp-row.active, .sp-row.active:hover { background: var(--brand-soft); }
.sp-row.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); }
.sp-av { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .95rem; background: hsl(var(--sp-h, 38) 45% 55% / .22); color: var(--text); }
.sp-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sp-name { font-weight: 600; font-size: .94rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row.open .sp-name { font-weight: 700; }
.sp-row time { font-size: .74rem; color: var(--muted); white-space: nowrap; flex: none; }
.sp-row-mid { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-row-msg { font-size: .86rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; line-height: 1.4; }
.sp-row.open .sp-row-msg { color: var(--text); }
.sp-row-tags { display: flex; margin-top: 4px; }
.sp-state { flex: none; width: 9px; height: 9px; margin-top: 7px; border-radius: 50%; background: var(--surface-3); }
.sp-state.open { background: var(--warn); }
.sp-state.answered { background: var(--ok); }

.sp-none { margin: auto; padding: 30px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); }
.sp-none b { color: var(--text); }
.sp-none-ico { font-size: 1.8rem; opacity: .8; }

.sp-d-head { display: flex; flex-direction: column; gap: 10px; padding: 14px 18px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sp-back { display: none; align-self: flex-start; align-items: center; gap: 6px; }
.sp-back svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.sp-d-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sp-d-who .sp-av { width: 42px; height: 42px; font-size: 1.05rem; }
.sp-d-names { display: flex; flex-direction: column; min-width: 0; }
.sp-d-names b { font-size: 1.02rem; overflow-wrap: anywhere; }
.sp-d-names span { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.sp-d-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.sp-d-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.sp-d-actions .sp-grow { flex: 1; }
.sp-note { margin: 12px 18px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface-2); color: var(--muted); font-size: .86rem; line-height: 1.5; overflow-wrap: anywhere; }
.sp-note b { color: var(--text); }

.sp-thread { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.sp-msg { display: flex; flex-direction: column; gap: 4px; max-width: 86%; min-width: 0; }
.sp-msg.me { align-self: flex-end; align-items: flex-end; }
.sp-msg-meta { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); }
.sp-msg-meta b { color: var(--text); font-weight: 600; }
.sp-bubble { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); font-size: .94rem; line-height: 1.5; }
.sp-msg.me .sp-bubble { background: var(--brand-soft); border-color: transparent; }

.sp-composer { display: flex; flex-direction: column; gap: 8px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.sp-composer textarea { width: 100%; box-sizing: border-box; min-height: 64px; max-height: 220px; resize: none; }
.sp-composer > .sp-note { margin: 0; }
.sp-comp-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; }
.sp-comp-hint { flex: 1 1 200px; min-width: 0; color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.sp-comp-btns { display: flex; gap: 8px; margin-left: auto; }

/* Phone: the list is one page; opening a request shows it full screen with a back button. */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .sp-top-actions { gap: 6px; }
  :where(html[data-layout="compact"]) .sp-layout { display: block; height: auto; min-height: 0; border: 0; border-radius: 0; overflow: visible; background: transparent; }
  :where(html[data-layout="compact"]) .sp-list { border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
  :where(html[data-layout="compact"]) .sp-detail { display: none; }
  :where(html[data-layout="compact"]) .sp-layout.show-detail .sp-list { display: none; }
  :where(html[data-layout="compact"]) .sp-layout.show-detail .sp-detail { display: flex; height: calc(100dvh - 120px); min-height: 440px; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--bg); }
  :where(html[data-layout="compact"]) .sp-panel:has(.sp-layout.show-detail) > .sp-top, :where(html[data-layout="compact"]) .sp-panel:has(.sp-layout.show-detail) > .sp-filters { display: none; }
  :where(html[data-layout="compact"]) .sp-back { display: inline-flex; }
  :where(html[data-layout="compact"]) .sp-d-head, :where(html[data-layout="compact"]) .sp-d-actions, :where(html[data-layout="compact"]) .sp-thread, :where(html[data-layout="compact"]) .sp-composer { padding-left: 14px; padding-right: 14px; }
  :where(html[data-layout="compact"]) .sp-note { margin-left: 14px; margin-right: 14px; }
  :where(html[data-layout="compact"]) .sp-msg { max-width: 94%; }
  :where(html[data-layout="compact"]) .sp-comp-btns { width: 100%; }
  :where(html[data-layout="compact"]) .sp-comp-btns button { flex: 1; }
  :where(html[data-layout="compact"]) .sp-filters .grow { flex-basis: 100%; }



/* ---------- Attachments live INSIDE the chat box ----------
   With a picture or file attached the box becomes two rows (like Claude / ChatGPT): row 1 = one scrolling area that holds the
   pictures + files (one row, scrolls sideways), then the picked options (Web search, Weather and Time …), then the text —
   a long message scrolls all of it together; row 2 = Attach on the left, mic + Send on the right. */
.composer.has-attach { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: end; gap: 6px 8px; padding-top: 12px; }
.composer.has-attach > .composer-input-wrap { grid-column: 1 / -1; grid-row: 1; max-height: min(380px, 52dvh); }
.composer.has-attach > .attach-btn { grid-column: 1; grid-row: 2; margin-bottom: 0; }
.composer.has-attach > .mic-btn { grid-column: 3; grid-row: 2; margin-bottom: 0; }
.composer.has-attach > .send { grid-column: 4; grid-row: 2; }
.composer.has-attach.recording { display: flex; }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .attach-strip { --att-h: 44px; }
  :where(html[data-layout="compact"]) .attach-strip .file-chip { max-width: min(190px, 68vw); }
  :where(html[data-layout="compact"]) .composer.has-attach > .composer-input-wrap { max-height: min(340px, 46dvh); }


/* The picked options (chips) sit in their own row, like the pictures and files: one line that scrolls sideways (finger or mouse wheel / drag),
   never wrapping. The text always starts UNDER them. */
.composer-input-wrap { display: flex !important; flex-wrap: wrap; align-items: flex-start; column-gap: 8px; }   /* !important: the box carries an inline display:block */
.composer-input-wrap > .attach-strip { flex: 0 0 100%; }
.attach-strip.is-hscroll { cursor: grab; }
.attach-strip.is-grabbing { cursor: grabbing; user-select: none; }
.composer-input-wrap > .composer-field { flex: 1 1 100%; min-width: 0; }
/* Attach menu: a tick on every picked option */
.attach-menu button .mi-check { display: none; margin-left: auto; flex: none; width: 18px; height: 18px; fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.attach-menu button.is-on .mi-check { display: block; }
.attach-menu button.is-on { background: var(--surface-2); }
.attach-menu-pc button.is-on .mi-check { margin-left: auto; }

/* Chat not found page (inside the chat shell, sidebar stays) */
#view-gone { display: flex; }
#view-gone.hidden { display: none; }
.gone-wrap { margin: auto; padding: 24px 20px calc(60px + env(safe-area-inset-bottom)); max-width: 460px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.gone-ico { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-strong); margin-bottom: 6px; }
.gone-ico svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gone-title { font-weight: 500; font-size: clamp(1.4rem, 4vw, 1.75rem); letter-spacing: -.01em; }
.gone-sub { margin: 0 0 10px; color: var(--muted); font-size: .96rem; line-height: 1.5; }

/* =====================================================================================================
   Admin → Support inbox — polish (v174): open-request badge, refresh, calmer list, tidy conversation header,
   phone: icon back arrow, two-column action grid, scrolling filter chips, 16px reply box
   ===================================================================================================== */
/* The number sits dead-centre in its oval: a grid centres it both ways, and a plain system font (instead of the page's display font, whose digits ride high) keeps it there on every device. */
.tab-count { display: inline-grid; place-items: center; box-sizing: border-box; min-width: 20px; height: 20px; margin-left: 7px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--on-brand); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: .72rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; text-align: center; vertical-align: middle; flex: none; }
.mm-row .tab-count { margin-left: 8px; }

.sp-refresh { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; box-sizing: border-box; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); color: var(--text); font-size: .88rem; line-height: 1; white-space: nowrap; cursor: pointer; }
.sp-refresh svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:where(html[data-input="mouse"]) .sp-refresh:hover:not(:disabled) { background: var(--surface-3); }
.sp-refresh:disabled { opacity: .7; cursor: default; }
.sp-refresh.spin svg { animation: spRefreshSpin .8s linear infinite; }
@keyframes spRefreshSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .sp-refresh.spin svg { animation: none; } }

.sp-layout { border-radius: 16px; }
.sp-list { background: var(--surface); }
.sp-row { padding: 14px 14px 14px 16px; transition: background .12s; }
.sp-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.sp-row.open .sp-row-mid { color: var(--text); }
.sp-row-tags .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sp-list-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 44px 22px; text-align: center; color: var(--muted); }
.sp-list-empty b { color: var(--text); font-size: .98rem; }
.sp-list-empty span { font-size: .88rem; line-height: 1.5; max-width: 30ch; }
.sp-none b { font-size: 1.05rem; }
.sp-none span { max-width: 34ch; line-height: 1.5; }

/* conversation header: one tidy row (back · who · status) and a quiet line of facts under it */
.sp-d-head { gap: 10px; padding: 14px 18px 12px; }
.sp-d-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sp-d-top > .pill { margin-left: auto; flex: none; text-transform: capitalize; padding: 3px 11px; font-size: .78rem; font-weight: 600; }
.sp-d-who { flex: 1; min-width: 0; }
.sp-d-names b, .sp-d-names span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
.sp-back { display: none; flex: none; width: 40px; height: 40px; padding: 0; margin-left: -6px; align-items: center; justify-content: center; border-radius: 50%; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.sp-back svg { width: 22px; height: 22px; }
:where(html[data-input="mouse"]) .sp-back:hover { background: var(--surface-3); }
.sp-d-badges { align-items: center; gap: 6px; }
.sp-d-badges .pill { font-size: .74rem; padding: 2px 9px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sp-d-when { margin-left: auto; color: var(--muted); font-size: .76rem; white-space: nowrap; }

.sp-d-actions { padding: 10px 18px; gap: 8px; }
.sp-d-actions button { min-height: 36px; border-radius: 9px; }
.sp-d-actions .row-actions { display: contents; }   /* the auto-reopen buttons sit in the same row as the rest */

/* the conversation */
.sp-thread { padding: 18px; gap: 16px; background: var(--bg); }
.sp-msg-meta { padding: 0 4px; }
.sp-msg.them .sp-bubble { border-top-left-radius: 5px; }
.sp-msg.me .sp-bubble { border-top-right-radius: 5px; background: var(--brand-soft); }

.sp-composer { gap: 10px; }
.sp-composer textarea { border-radius: 12px; padding: 11px 13px; line-height: 1.5; font-family: inherit; }
.sp-composer textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.sp-comp-hint { font-size: .76rem; }
.sp-comp-btns button { min-height: 40px; border-radius: 10px; padding: 0 16px; }

/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .sp-back { display: inline-flex; }
  :where(html[data-layout="compact"]) .sp-top { align-items: center; }
  :where(html[data-layout="compact"]) .sp-top-actions .sp-refresh span { display: none; }
  :where(html[data-layout="compact"]) .sp-top-actions .sp-refresh { width: 36px; padding: 0; justify-content: center; }

  /* filters: search on its own line, the four chips slide sideways instead of wrapping into two rows */
  :where(html[data-layout="compact"]) .sp-filters { flex-direction: column; align-items: stretch; gap: 10px; }
  :where(html[data-layout="compact"]) .sp-filters .grow { min-width: 0; width: 100%; min-height: 46px; font-size: 16px; border-radius: 12px; }
  :where(html[data-layout="compact"]) .sp-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -2px; padding: 0 2px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  :where(html[data-layout="compact"]) .sp-chips::-webkit-scrollbar { display: none; }
  :where(html[data-layout="compact"]) .sp-chip { flex: none; min-height: 38px; padding: 0 14px; font-size: .88rem; }

  :where(html[data-layout="compact"]) .sp-layout { border-radius: 0; }
  :where(html[data-layout="compact"]) .sp-list { border-radius: 16px; }
  :where(html[data-layout="compact"]) .sp-layout.show-detail .sp-detail { border-radius: 16px; height: calc(100dvh - 112px); }
  :where(html[data-layout="compact"]) .sp-d-head { padding: 10px 14px 10px 8px; }
  :where(html[data-layout="compact"]) .sp-d-badges { padding-left: 4px; }

  /* actions: big two-column buttons */
  :where(html[data-layout="compact"]) .sp-d-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 14px; }
  :where(html[data-layout="compact"]) .sp-d-actions .sp-grow { display: none; }
  :where(html[data-layout="compact"]) .sp-d-actions button { width: 100%; min-height: 44px; border-radius: 12px; font-size: .92rem; white-space: normal; }
  :where(html[data-layout="compact"]) .sp-d-actions button.primary:only-child { grid-column: 1 / -1; }

  :where(html[data-layout="compact"]) .sp-composer textarea { font-size: 16px; min-height: 76px; }
  :where(html[data-layout="compact"]) .sp-comp-btns button { min-height: 46px; border-radius: 12px; }

@media (max-width: 380px) { .sp-d-actions { grid-template-columns: 1fr; } }

/* Screenshot taken: a soft white flash, like a shutter. Never blocks clicks. */
.shot-flash { position: fixed; inset: 0; z-index: 99999; pointer-events: none; background: #fff; opacity: 0; animation: shotFlash .42s ease-out; }
@keyframes shotFlash { 0% { opacity: 0; } 18% { opacity: .55; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .shot-flash { display: none; } }

/* ---------- Screenshot: chooser + full-screen editor (computers). Logic: takeScreenshot() in chat.js ---------- */
.shot-pick { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.46); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: shotFade .18s ease-out; }
.shot-pick-card { width: min(440px, 100%); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 22px; padding: 22px; box-shadow: 0 24px 70px rgba(0,0,0,.45); animation: shotPop .22s cubic-bezier(.2,.8,.2,1); }
.shot-pick-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.shot-pick-head h2 { margin: 0; font-size: 1.2rem; font-family: var(--font-display); letter-spacing: -.01em; }
.shot-pick-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }
.shot-pick-x { flex: none; width: 34px; height: 34px; min-height: 0; padding: 0; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.shot-pick-x svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; }
.shot-pick-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.shot-pick-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 16px; min-height: 0; text-align: left; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); transition: border-color .15s, background .15s, transform .15s; }
.shot-pick-opt b { font-size: .98rem; font-weight: 650; }
.shot-pick-opt small { color: var(--muted); font-size: .8rem; line-height: 1.35; font-weight: 400; }
.shot-pick-ico { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; margin-bottom: 10px; background: var(--brand-soft); color: var(--brand); }
.shot-pick-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:where(html[data-input="mouse"]) .shot-pick-opt:hover { border-color: var(--brand); background: var(--surface-3); transform: translateY(-1px); }
.shot-pick-opt:focus-visible, .shot-pick-x:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.shot-pick.is-desktop .shot-pick-card { width: min(600px, 100%); }
.shot-pick.is-desktop .shot-pick-opts { grid-template-columns: repeat(3, 1fr); }
.shot-wins { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 18px; max-height: min(54vh, 440px); overflow-y: auto; overscroll-behavior: contain; padding: 2px; }
.shot-wins-msg { grid-column: 1 / -1; margin: 18px 0; text-align: center; color: var(--muted); font-size: .92rem; }
.shot-win { display: flex; flex-direction: column; gap: 8px; align-items: stretch; padding: 8px 8px 10px; min-height: 0; text-align: left; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); transition: border-color .15s, background .15s, transform .15s; }
.shot-win img { width: 100%; aspect-ratio: 3 / 2; object-fit: contain; border-radius: 9px; background: color-mix(in srgb, var(--text) 8%, transparent); }
.shot-win span { font-size: .82rem; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
:where(html[data-input="mouse"]) .shot-win:hover { border-color: var(--brand); background: var(--surface-3); transform: translateY(-1px); }
.shot-win:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
@media (max-width: 560px) { .shot-pick.is-desktop .shot-pick-opts { grid-template-columns: 1fr; } .shot-pick.is-desktop .shot-pick-opt { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; } .shot-pick.is-desktop .shot-pick-ico { margin: 0; } }
.shot-pick-note { margin: 16px 2px 0; color: var(--muted); font-size: .78rem; line-height: 1.45; }
@media (max-width: 420px) { .shot-pick-opts { grid-template-columns: 1fr; } .shot-pick-opt { flex-direction: row; align-items: center; gap: 12px; flex-wrap: wrap; } .shot-pick-ico { margin: 0; } }

.shot-ed { position: fixed; inset: 0; z-index: 1300; color: #fff; font-family: var(--font-text); background: rgba(8,10,12,.95); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); opacity: 0; transition: opacity .18s ease-out; user-select: none; -webkit-user-select: none; }
.shot-ed.show { opacity: 1; }
.shot-ed.is-leaving { opacity: 0; transition-duration: .14s; pointer-events: none; }
.shot-ed-top { position: absolute; left: 0; right: 0; top: 0; height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 22px; }
.shot-ed-title { font-weight: 650; font-size: 1rem; letter-spacing: .01em; }
.shot-ed-size { padding: 4px 11px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: .78rem; font-variant-numeric: tabular-nums; color: rgba(255,255,255,.82); }
.shot-ed-x { margin-left: auto; width: 40px; height: 40px; min-height: 0; padding: 0; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.1); border: none; color: #fff; }
.shot-ed-x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
:where(html[data-input="mouse"]) .shot-ed-x:hover { background: rgba(255,255,255,.2); }
.shot-ed-stage { position: absolute; left: 28px; right: 28px; top: 64px; bottom: 112px; display: flex; align-items: center; justify-content: center; touch-action: none; }
.shot-ed-frame { position: relative; flex: none; touch-action: none; cursor: crosshair; transform: translateY(8px) scale(.985); opacity: 0; transition: transform .26s cubic-bezier(.2,.8,.2,1), opacity .2s; }
.shot-ed.show .shot-ed-frame { transform: none; opacity: 1; }
.shot-ed-frame.dragging { cursor: grabbing; }
.shot-ed-cv { display: block; width: 100%; height: 100%; border-radius: 10px; box-shadow: 0 18px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.1); pointer-events: none; }
.shot-ed-dim { position: absolute; inset: 0; border-radius: 10px; background: rgba(4,6,8,.62); pointer-events: none; transition: opacity .15s; }
.shot-ed-sel { position: absolute; box-sizing: border-box; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.35); cursor: move; }
.shot-ed-sel.is-all { border-color: transparent; box-shadow: none; cursor: crosshair; }
.shot-ed-sel .g { position: absolute; background: rgba(255,255,255,.4); opacity: 0; transition: opacity .15s; pointer-events: none; }
.shot-ed-sel .g1, .shot-ed-sel .g2 { top: 0; bottom: 0; width: 1px; } .shot-ed-sel .g1 { left: 33.333%; } .shot-ed-sel .g2 { left: 66.666%; }
.shot-ed-sel .g3, .shot-ed-sel .g4 { left: 0; right: 0; height: 1px; } .shot-ed-sel .g3 { top: 33.333%; } .shot-ed-sel .g4 { top: 66.666%; }
.shot-ed-frame.dragging .g { opacity: 1; }
.shot-ed-sel .h { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.5); }
.shot-ed-sel .h::before { content: ""; position: absolute; inset: -12px; }                 /* a bigger invisible grab area for fingers and pens */
.shot-ed-sel.is-all .h { display: none; }
.shot-ed-sel .h-nw { left: 0; top: 0; cursor: nwse-resize; } .shot-ed-sel .h-n { left: 50%; top: 0; width: 28px; height: 6px; margin: -3px 0 0 -14px; border-radius: 4px; cursor: ns-resize; }
.shot-ed-sel .h-ne { left: 100%; top: 0; cursor: nesw-resize; } .shot-ed-sel .h-e { left: 100%; top: 50%; width: 6px; height: 28px; margin: -14px 0 0 -3px; border-radius: 4px; cursor: ew-resize; }
.shot-ed-sel .h-se { left: 100%; top: 100%; cursor: nwse-resize; } .shot-ed-sel .h-s { left: 50%; top: 100%; width: 28px; height: 6px; margin: -3px 0 0 -14px; border-radius: 4px; cursor: ns-resize; }
.shot-ed-sel .h-sw { left: 0; top: 100%; cursor: nesw-resize; } .shot-ed-sel .h-w { left: 0; top: 50%; width: 6px; height: 28px; margin: -14px 0 0 -3px; border-radius: 4px; cursor: ew-resize; }
.shot-ed-hint { position: absolute; left: 50%; bottom: 100px; transform: translateX(-50%); padding: 6px 14px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: .8rem; color: rgba(255,255,255,.8); white-space: nowrap; pointer-events: none; transition: opacity .25s; }
.shot-ed.has-moved .shot-ed-hint { opacity: 0; }
.shot-ed-bar { position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 7px; border-radius: 22px; background: rgba(32,35,38,.82); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 14px 40px rgba(0,0,0,.5); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); max-width: calc(100vw - 24px); }
.shot-ed-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 16px; border: none; background: transparent; color: #fff; font-size: .92rem; font-weight: 550; white-space: nowrap; transition: background .15s, opacity .15s; }
.shot-ed-btn svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:where(html[data-input="mouse"]) .shot-ed-btn:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.shot-ed-btn:disabled { opacity: .38; cursor: default; }
.shot-ed-btn.is-primary { background: var(--brand); color: var(--on-brand); font-weight: 650; padding: 0 20px; }
:where(html[data-input="mouse"]) .shot-ed-btn.is-primary:hover:not(:disabled) { background: var(--brand-strong); }
.shot-ed-btn:focus-visible, .shot-ed-x:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.shot-ed-sep { width: 1px; height: 24px; background: rgba(255,255,255,.16); margin: 0 4px; }
@media (max-width: 560px) {
  .shot-ed-stage { left: 12px; right: 12px; bottom: 104px; }
  .shot-ed-btn { padding: 0 12px; } .shot-ed-btn span { font-size: .85rem; } .shot-ed-btn.is-primary { padding: 0 16px; }
  .shot-ed-title { display: none; }
}
@keyframes shotFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shotPop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .shot-pick, .shot-pick-card, .shot-ed, .shot-ed-frame { animation: none; transition: none; } .shot-ed-frame { transform: none; opacity: 1; } }


/* ---------- v186: attachment row in the chat box — neat on every device ----------
   Pictures / sketches: a small square with a round cross in the corner. A file: a compact card (icon, name, size line) with its round cross
   at the right end. Every size is fixed with !important because the global button rules (min-height, padding, border) used to stretch the
   cross into a big shape. */
.attach-strip { --att-h: 44px; gap: 8px; }
.attach-thumb { width: var(--att-h); min-width: var(--att-h); height: var(--att-h); min-height: var(--att-h); border-radius: 10px; }
.attach-thumb.sketch { background: #fff; }
.attach-thumb.sketch img { object-fit: contain; }
.attach-thumb button.at-x, .attach-strip .file-chip .af-remove {
  box-sizing: border-box !important; display: grid !important; place-items: center !important; padding: 0 !important; margin: 0 !important;
  width: 18px !important; height: 18px !important; min-width: 18px !important; min-height: 18px !important; max-width: 18px !important; max-height: 18px !important;
  border: 0 !important; border-radius: 50% !important; line-height: 1 !important; aspect-ratio: 1 / 1; flex: none !important;
  background: rgba(17,17,17,.72) !important; color: #fff !important; box-shadow: none !important;
}
.attach-thumb button.at-x { position: absolute; top: 3px; right: 3px; }
.attach-thumb button.at-x svg, .attach-strip .file-chip .af-remove svg { width: 10px !important; height: 10px !important; stroke-width: 2.6; }
:where(html[data-input="mouse"]) .attach-thumb button.at-x:hover, :where(html[data-input="mouse"]) .attach-strip .file-chip .af-remove:hover { background: rgba(17,17,17,.9) !important; color: #fff !important; }
.attach-strip .file-chip {
  width: max-content !important; max-width: min(176px, 62vw) !important; min-width: 0; height: var(--att-h); gap: 7px; padding: 0 7px 0 6px !important;
  border-radius: 10px; flex: none; overflow: hidden;
}
.attach-strip .file-chip .fc-icon { width: 28px; height: 28px; flex: none; }
.attach-strip .file-chip .fc-text { flex: 1 1 auto; min-width: 0; }
.attach-strip .file-chip .fc-text b, .attach-strip .file-chip .fc-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.attach-strip .file-chip .fc-text b { font-size: .78rem; }
.attach-strip .file-chip .fc-text small { font-size: .66rem; }
/* [compact layout: phones only] */ :where(html[data-layout="compact"]) .attach-strip { --att-h: 42px; } :where(html[data-layout="compact"]) .attach-strip .file-chip { max-width: min(160px, 60vw) !important; } 


/* ================= v188 ================= */
/* Settings → Security: "Log out" of the log-out-of-all-devices row is one word on one line, whatever the phone's width. */
#logout-btn { flex: 0 0 auto; white-space: nowrap; width: auto; min-width: 88px; padding-left: 16px; padding-right: 16px; }

.foot-newchat { display: none; }

/* ----- phone: New chat suggestions exactly like the Gemini reference (plain rows, outline icon 21px, text 16px, three rows) ----- */
/* [compact layout: phones only] */
  /* greeting centred in the free space, suggestions pinned just above the chat box (42px gap), like the reference */
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .scroller { margin-bottom: auto; }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug { margin-bottom: 0; }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug:not(:empty) { padding: 0 0 34px; }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug .sug-list { align-items: stretch; gap: 7px; padding: 0; }
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) .sug-wrap { max-width: none; margin: 0; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-row { width: 100%; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-item, :where(html[data-nc="phone"]) .welcome-sug .sug-row .sug-item { width: 100%; flex: 1 1 auto; gap: 21px; min-height: 0; padding: 10px 40px 10px 50px; border-radius: 12px; background: transparent; box-shadow: none; font-size: 16px; line-height: 20px; color: var(--text); }
  html[data-nc="phone"][data-theme="dark"] .welcome-sug .sug-item { box-shadow: none; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-item:active { background: var(--surface-2); }
  :where(html[data-nc="phone"]) .welcome-sug .sug-tile { width: 21px; height: 21px; display: grid; place-items: center; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-ico { display: block; width: 21px; height: 21px; stroke-width: 1.5; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-emoji, :where(html[data-nc="phone"]) .welcome-sug .sug-go { display: none; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-x { right: 6px; opacity: .55; }

/* ----- phone: the sidebar is a full-screen page (Claude / Gemini references) ----- */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .sidebar { width: 100vw; width: 100dvw; max-width: none; border-right: 0; border-radius: 0; box-shadow: none; padding-left: 18px; padding-right: 18px; gap: 6px; }
  :where(html[data-layout="compact"]) .sidebar.open { transform: none; }
  :where(html[data-layout="compact"]) .scrim, :where(html[data-layout="compact"]) .scrim.show { display: none; }
  :where(html[data-layout="compact"]) .sidebar-head { padding: 6px 0 10px; }
  :where(html[data-layout="compact"]) .sidebar-head a.logo { margin-left: 0; }
  :where(html[data-layout="compact"]) .sidebar-head a.logo img { width: 34px; height: 34px; }
  :where(html[data-layout="compact"]) .sidebar-head a.logo .site-name { font-size: 1.7rem; font-weight: 600; letter-spacing: -.01em; }
  :where(html[data-layout="compact"]) .sidebar-head-actions { gap: 6px; }
  :where(html[data-layout="compact"]) .sidebar-head-actions .ghost.icon { width: 44px; min-height: 44px; }
  :where(html[data-layout="compact"]) #close-sidebar svg { width: 26px; height: 26px; }
  :where(html[data-layout="compact"]) .sidebar-nav { gap: 2px; margin-top: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
  :where(html[data-layout="compact"]) #new-chat-btn { display: none; }
  :where(html[data-layout="compact"]) .sidebar-nav .nav-item { min-height: 56px; padding: 0 4px; gap: 18px; font-size: 1.1rem; font-weight: 400; border-radius: 12px; }
  :where(html[data-layout="compact"]) .sidebar-nav .nav-item svg { width: 24px; height: 24px; }
  :where(html[data-layout="compact"]) .chat-list:not(:empty)::before { content: "Recents"; display: block; padding: 16px 4px 4px; font-size: 1rem; font-weight: 500; color: var(--muted); }
  :where(html[data-layout="compact"]) .chat-group { padding-left: 4px; }
  :where(html[data-layout="compact"]) .sidebar-foot { border-top: 0; padding-top: 8px; gap: 8px; }
  :where(html[data-layout="compact"]) .sidebar-foot .who { display: none; }
  :where(html[data-layout="compact"]) .profile-trigger { flex: 0 0 auto; margin: 0; padding: 0; }
  :where(html[data-layout="compact"]) .foot-actions { margin-right: auto; }
  :where(html[data-layout="compact"]) .foot-actions a.icon, :where(html[data-layout="compact"]) .foot-actions button.icon { width: 44px; min-height: 44px; }
  :where(html[data-layout="compact"]) .foot-actions svg, :where(html[data-layout="compact"]) .foot-actions .icon-svg { width: 24px; height: 24px; }
  :where(html[data-layout="compact"]) .foot-newchat { display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--text); color: var(--bg); font: inherit; font-size: 1.02rem; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  :where(html[data-layout="compact"]) .foot-newchat svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }


/* ================= v189 ================= */
/* ----- Recents header (phone sidebar) + the All / Ready / Pinned / In progress filter menu ----- */
.recents-head { display: none; }
[data-filter-btn].has-filter { color: var(--brand); position: relative; }
[data-filter-btn].has-filter::after { content: ""; position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 2px var(--bg); }
.filter-menu { position: fixed; z-index: 130; min-width: 250px; padding: 8px; display: flex; flex-direction: column; gap: 4px; background: var(--bg); border-radius: 26px; box-shadow: 0 0 0 1px var(--line), 0 12px 40px rgba(0,0,0,.22); animation: fm-in .14s ease; }
@keyframes fm-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.filter-menu .fm-item { display: flex; align-items: center; gap: 16px; width: 100%; min-height: 52px; padding: 0 18px; border: 0; border-radius: 22px; background: transparent; color: var(--text); font: inherit; font-size: 1.08rem; font-weight: 400; text-align: left; justify-content: flex-start; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.filter-menu .fm-item.on { background: var(--surface-2); }
:where(html[data-input="mouse"]) .filter-menu .fm-item:hover { background: var(--surface-2); }
.filter-menu .fm-ico { width: 24px; height: 24px; display: grid; place-items: center; flex: none; }
.filter-menu .fm-ico svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.filter-menu .fm-dot { width: 11px; height: 11px; border-radius: 50%; background: #3b82f6; }
.filter-menu .fm-spin { width: 18px; height: 18px; border-radius: 50%; border: 2.2px solid currentColor; border-right-color: transparent; box-sizing: border-box; }
.filter-menu .fm-label { flex: 1; }
.filter-menu .fm-check { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ----- Chats page ----- */
#view-chats { display: flex; flex-direction: column; position: relative; }
#view-chats.hidden { display: none; }
.cp-wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 18px calc(120px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.cp-head { position: relative; display: flex; align-items: center; min-height: 64px; padding-top: max(8px, env(safe-area-inset-top)); }
.cp-head .ghost.icon { width: 46px; min-height: 46px; border-radius: 50%; color: var(--text); }
.cp-head .ghost.icon svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cp-head .ghost.icon:disabled { opacity: .35; }
.cp-lead { margin-left: -8px; }
.cp-title { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; font-size: 1.3rem; font-weight: 600; letter-spacing: -.005em; pointer-events: none; }
.cp-tools { margin-left: auto; display: flex; align-items: center; gap: 4px; margin-right: -8px; }
.cp-search { position: relative; margin: 6px 0 12px; }
.cp-search svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; color: var(--muted); stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; pointer-events: none; }
.cp-search input { width: 100%; box-sizing: border-box; height: 54px; padding: 0 16px 0 56px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); font-size: 1.1rem; }
.cp-list { display: flex; flex-direction: column; gap: 2px; }
.cp-row { display: flex; align-items: flex-start; gap: 16px; padding: 14px 6px; border-radius: 14px; cursor: pointer; position: relative; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; }
.cp-row:active, .cp-row.selected { background: var(--surface-2); }
:where(html[data-input="mouse"]) .cp-row:hover { background: var(--surface-2); }
.cp-ico { width: 22px; height: 22px; flex: none; margin-top: 4px; stroke: var(--muted); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.cp-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cp-name { font-size: 1.25rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cp-sub { color: var(--muted); font-size: 1.02rem; }
.cp-check { display: none; width: 26px; height: 26px; flex: none; margin-top: 2px; box-sizing: border-box; border: 2px solid var(--muted); border-radius: 8px; place-items: center; }
.cp-check svg { width: 16px; height: 16px; stroke: var(--bg); fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.selecting .cp-check { display: grid; }
.cp-row.selected .cp-check { background: var(--text); border-color: var(--text); }
.cp-row.selected .cp-check svg { opacity: 1; }
.cp-status { flex: none; align-self: center; margin-left: 4px; }
.cp-status.is-working { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); box-sizing: border-box; animation: chat-status-spin .8s linear infinite; }
.cp-status.is-unread { width: 9px; height: 9px; border-radius: 50%; background: #3b82f6; margin-right: 6px; }
.cp-empty { text-align: center; padding: 40px 8px; }
.cp-fab { position: fixed; right: 22px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20; display: inline-flex; align-items: center; gap: 8px; height: 54px; padding: 0 24px; border: 0; border-radius: 999px; background: var(--text); color: var(--bg); font: inherit; font-size: 1.05rem; font-weight: 600; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.28); -webkit-tap-highlight-color: transparent; }
.cp-fab svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.selecting .cp-fab { display: none; }
.main.view-chats .topbar { display: none; }
.sidebar-nav #chats-nav-btn svg { fill: none; }
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) #chats-menu-btn, :where(html[data-layout="wide"]) .cp-fab { display: none !important; }
  :where(html[data-layout="wide"]) .cp-wrap { padding-top: clamp(20px, 7vh, 64px); padding-bottom: 60px; }
  :where(html[data-layout="wide"]) .cp-head { min-height: 0; padding-top: 0; }
  :where(html[data-layout="wide"]) .cp-title { position: static; transform: none; font-size: 2rem; font-weight: 600; pointer-events: auto; margin-right: auto; }
  :where(html[data-layout="wide"]) .cp-tools { margin-left: 0; }
  :where(html[data-layout="wide"]) .cp-head .ghost.icon { width: 40px; min-height: 40px; }


/* ----- phone sidebar, like the Claude / ChatGPT / Gemini references ----- */
.sidebar { touch-action: pan-y; }
.scrim.dragging { display: block; opacity: 1; pointer-events: none; transition: none; background: rgba(0,0,0, calc(.42 * var(--dim, 1))); }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .scrim.dragging { display: block; }
  :where(html[data-layout="compact"]) #open-search-btn { display: none; }
  :where(html[data-layout="compact"]) #close-sidebar { display: inline-grid; }
  :where(html[data-layout="compact"]) .sidebar-head { padding: 6px 0 12px; }
  :where(html[data-layout="compact"]) .sidebar-nav .nav-item { min-height: 58px; font-size: 1.12rem; }
  :where(html[data-layout="compact"]) .sidebar-nav .nav-item.active { background: var(--surface-2); }
  :where(html[data-layout="compact"]) .recents-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 2px; font-size: 1.05rem; font-weight: 500; color: var(--muted); }
  :where(html[data-layout="compact"]) .recents-head .ghost.icon { width: 44px; min-height: 44px; margin-right: -8px; color: var(--muted); border-radius: 50%; }
  :where(html[data-layout="compact"]) .recents-head .ghost.icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  :where(html[data-layout="compact"]) .chat-list:not(:empty)::before { content: none; display: none; }
  :where(html[data-layout="compact"]) .chat-item { min-height: 54px; padding: 0 4px; border-radius: 12px; }
  :where(html[data-layout="compact"]) .chat-item .title { font-size: 1.1rem; }
  :where(html[data-layout="compact"]) .chat-item .chat-proj-ico svg { width: 18px; height: 18px; }
  /* bottom bar: round profile (opens Settings) + round Admin shield on the left, black "New chat" pill on the right */
  :where(html[data-layout="compact"]) .sidebar-foot { padding: 10px 0 4px; gap: 12px; align-items: center; }
  :where(html[data-layout="compact"]) .profile-trigger, :where(html[data-layout="compact"]) .foot-actions a.icon { flex: none; width: 58px; height: 58px; min-height: 58px; padding: 0; margin: 0; border-radius: 50%; display: grid; place-items: center; background: var(--bg); box-shadow: 0 0 0 1px var(--line), 0 6px 18px rgba(0,0,0,.14); -webkit-tap-highlight-color: transparent; }
  :where(html[data-layout="compact"]) .profile-trigger .avatar { width: 46px; height: 46px; font-size: 1.25rem; font-weight: 600; color: #fff; background-color: var(--brand); background-image: linear-gradient(140deg, hsl(var(--h) var(--s) 56%), hsl(calc(var(--h) + 38) var(--s) 40%)); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
  :where(html[data-layout="compact"]) .profile-trigger .avatar.has-pic { color: transparent; }
  :where(html[data-layout="compact"]) .foot-actions { margin-right: auto; display: flex; gap: 12px; }
  :where(html[data-layout="compact"]) .foot-actions a.icon { color: var(--text); }
  :where(html[data-layout="compact"]) .foot-actions a.icon svg { width: 25px; height: 25px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  :where(html[data-layout="compact"]) .foot-actions a.icon:active, :where(html[data-layout="compact"]) .profile-trigger:active { transform: scale(.96); }
  :where(html[data-layout="compact"]) .foot-newchat { height: 56px; padding: 0 26px; gap: 10px; font-size: 1.08rem; }
  :where(html[data-layout="compact"]) .foot-newchat svg { width: 22px; height: 22px; stroke-width: 1.9; stroke-linejoin: round; }



/* ---------- Project chat topbar: same floating, transparent bar as a plain chat ----------
   Computer: the project name is a floating pill at the left, right after the sidebar button.
   Phone: it sits in the middle of the bar as plain text (no pill). The chat name is never shown up here. */
.topbar .crumb-project { min-height: 40px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); max-width: 280px; }
:where(html[data-input="mouse"]) .topbar .crumb-project:hover { background: var(--surface-3); }
.topbar .chat-title.title-hidden { display: block; flex: 1; }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .topbar .crumb-project {
    position: absolute; left: 50%; transform: translateX(-50%);
    top: max(10px, env(safe-area-inset-top)); height: 42px; min-height: 42px; box-sizing: border-box;
    max-width: calc(100% - 232px); padding: 0 8px; gap: 7px;
    background: transparent; border: none; border-radius: 12px;
    font-size: 1.08rem; justify-content: center;
  }
  :where(html[data-layout="compact"]) .topbar .crumb-project svg { width: 18px; height: 18px; }
  :where(html[data-layout="compact"]) .topbar .crumb-project:active { background: var(--surface-2); }



/* ---------- Phone: "+" button and the "Add to chat" bottom sheet ---------- */
.attach-btn .ico-plus { display: none; }
.attach-btn.is-plus .ico-clip { display: none; }
.attach-btn.is-plus .ico-plus { display: inline; stroke-width: 2.1; }
.attach-sheet-root { position: fixed; inset: 0; z-index: 1200; overflow: hidden; }
.attach-sheet-root .as-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.36); opacity: 0; transition: opacity .25s ease; }
.attach-sheet-root.show .as-backdrop { opacity: 1; }
.as-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); border-radius: 28px 28px 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,.18); will-change: transform; overflow: hidden;
  touch-action: none; overscroll-behavior: contain;
}
.as-grab { flex: none; padding: 10px 18px 6px; cursor: grab; touch-action: none; }
.as-handle { display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--line-strong, rgba(0,0,0,.18)); margin: 0 auto 10px; }
.as-head { display: flex; align-items: center; gap: 8px; min-height: 48px; position: relative; justify-content: center; }
.as-head h2 { margin: 0; font-size: 1.06rem; font-weight: 700; font-family: inherit; }
.as-head .as-back, .as-head .as-x { position: absolute; left: -4px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: transparent; border: none; color: var(--text); }
.as-head .as-x svg, .as-head .as-back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
/* Half open: the body never scrolls and every finger movement belongs to the sheet (touch-action none → the browser can't steal the swipe
   or scroll the page behind). Fully open: the body scrolls on its own when the content is taller than the screen. */
.as-body { flex: 1 1 auto; min-height: 0; overflow-y: hidden; padding: 6px 12px calc(18px + env(safe-area-inset-bottom, 0px)); touch-action: none; overscroll-behavior: contain; }
.as-sheet.is-full .as-body { overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
/* Half open: never an inside scroll, whatever else happens (the swipe only opens the sheet). */
.as-sheet.is-half .as-body { overflow-y: hidden !important; touch-action: none !important; }
.attach-sheet-root, .attach-sheet-root .as-backdrop { touch-action: none; overscroll-behavior: contain; }
.as-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.as-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 112px; padding: 14px 6px; border-radius: 20px; background: var(--surface); border: none; color: var(--text); font-size: 1rem; font-weight: 500; -webkit-tap-highlight-color: transparent; }
.as-tile:active, .as-row:active { background: var(--surface-2); }
.as-ico { flex: none; width: 52px; height: 52px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.as-ico svg, .as-row-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.as-card { background: var(--surface); border-radius: 20px; margin-bottom: 12px; overflow: hidden; }
.as-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 10px 16px 10px 12px; background: transparent; border: none; border-radius: 0; color: var(--text); text-align: left; font-size: 1.05rem; -webkit-tap-highlight-color: transparent; }
.as-card .as-row + .as-row { border-top: 1px solid var(--line); }
.as-row-ico { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; }
.as-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.as-row-text b { font-weight: 500; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-row-text small { font-size: .98rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.as-row-text small.is-set { color: var(--brand-strong, var(--brand)); }
.as-chev { flex: none; width: 20px; height: 20px; color: var(--muted); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.as-switch { flex: none; position: relative; width: 52px; height: 32px; border-radius: 999px; background: var(--surface-3, #ccc); transition: background .18s ease; }
.as-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s ease; }
.as-row[aria-checked="true"] .as-switch { background: var(--brand); }
.as-row[aria-checked="true"] .as-switch::after { transform: translateX(20px); }
.as-search { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; margin: 4px 0 14px; border: 1px solid var(--line-strong, var(--line)); border-radius: 16px; background: var(--bg); }
.as-search svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.as-search input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font: inherit; font-size: 1.05rem; color: var(--text); padding: 0; min-height: 0; height: 100%; box-shadow: none; }
.as-pj-ico { flex: none; width: 24px; height: 24px; color: var(--text); }
.as-pj-ico svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.as-pj-row { min-height: 60px; padding-left: 16px; }
.as-pj-row .as-check { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.as-empty { padding: 22px 16px; color: var(--muted); text-align: center; font-size: .98rem; }
@media (prefers-reduced-motion: reduce) { .attach-sheet-root .as-backdrop, .as-switch, .as-switch::after { transition: none; } }

/* ================= v193 ================= */
/* ----- Computer sidebar: ONE "Recents" list (no date headings), title = dropdown, new-chat icon ----- */
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) .recents-head { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 10px 2px 2px 8px; color: var(--muted); }
  :where(html[data-layout="wide"]) .recents-toggle { display: inline-flex; align-items: center; gap: 4px; min-height: 30px; padding: 0 6px 0 0; border: none; background: transparent; color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; border-radius: 8px; cursor: pointer; }
  :where(html[data-layout="wide"][data-input="mouse"]) .recents-toggle:hover { color: var(--text); }
  :where(html[data-layout="wide"]) .recents-chev { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .16s ease; }
  :where(html[data-layout="wide"]) .recents-head.is-collapsed .recents-chev { transform: rotate(-90deg); }
  :where(html[data-layout="wide"]) .recents-tools { display: flex; align-items: center; gap: 0; }
  :where(html[data-layout="wide"]) .recents-tools .ghost.icon { width: 30px; min-height: 30px; border-radius: 8px; color: var(--muted); }
  :where(html[data-layout="wide"]) .recents-tools .ghost.icon svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  :where(html[data-layout="wide"][data-input="mouse"]) .recents-tools .ghost.icon:hover { background: var(--surface-2); color: var(--text); }
  :where(html[data-layout="wide"]) .chat-list.recents-collapsed { display: none; }

/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .recents-toggle { display: inline-flex; align-items: center; border: none; background: transparent; padding: 0; font: inherit; color: inherit; pointer-events: none; }
  :where(html[data-layout="compact"]) .recents-chev, :where(html[data-layout="compact"]) .recents-new { display: none; }
  :where(html[data-layout="compact"]) .recents-tools { display: flex; }


/* ----- Projects page: Select, delete bar, phone layout like the Chats page ----- */
.pj-list-head { position: relative; }
.pj-lead, .pj-select-btn, .pj-delete-btn { flex: none; }
#proj-menu-btn { display: none; }
.pj-select-btn, .pj-delete-btn, #proj-select-back { width: 40px; min-height: 40px; border-radius: 50%; color: var(--text); }
.pj-select-btn svg, .pj-delete-btn svg, .pj-lead svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pj-delete-btn:disabled { opacity: .35; }
.pj-sel-count { color: var(--muted); font-size: .95rem; margin-right: 4px; white-space: nowrap; }
#proj-select-back { margin-right: 6px; }
.pj-list-head #proj-tools-select { margin-left: auto; }
.pj-row .cp-check { display: none; }
.selecting .pj-row .cp-check { display: grid; align-self: center; }
.pj-row.selected { background: var(--surface-2); }
.pj-row-edited { display: none; }
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) #view-projects.selecting .pj-row { grid-template-columns: 26px 38px minmax(0, 1fr) 170px 36px; }
  :where(html[data-layout="wide"]) #view-projects.selecting .pj-table-head { padding-left: 88px; }
  :where(html[data-layout="wide"]) #view-projects.selecting .pj-new { display: none; }
  :where(html[data-layout="wide"]) #view-projects.selecting .pj-row-menu { visibility: hidden; }

.pbk-sec { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.pbk-sec h3 { margin: 0 0 4px; font-size: .95rem; }
.pbk-sec p { margin: 0; font-size: .92rem; color: var(--muted); }
.pbk-sec.hidden { display: none; }
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .main.view-projects .topbar { display: none; }
  :where(html[data-layout="compact"]) #view-projects .pj-wrap { padding: 0 18px calc(120px + env(safe-area-inset-bottom)); }
  :where(html[data-layout="compact"]) #view-projects .pj-list-head { flex-wrap: wrap; align-items: center; min-height: 64px; padding-top: max(8px, env(safe-area-inset-top)); gap: 0; }
  :where(html[data-layout="compact"]) #proj-menu-btn { display: grid; margin-left: -8px; }
  :where(html[data-layout="compact"]) #view-projects .pj-lead, :where(html[data-layout="compact"]) #view-projects .pj-select-btn, :where(html[data-layout="compact"]) #view-projects .pj-delete-btn { width: 46px; min-height: 46px; }
  :where(html[data-layout="compact"]) #view-projects .pj-lead svg, :where(html[data-layout="compact"]) #view-projects .pj-select-btn svg, :where(html[data-layout="compact"]) #view-projects .pj-delete-btn svg { width: 26px; height: 26px; }
  :where(html[data-layout="compact"]) #view-projects .pj-title { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 1.3rem; font-weight: 600; letter-spacing: -.005em; pointer-events: none; }
  :where(html[data-layout="compact"]) #proj-tools-normal { display: contents; }
  :where(html[data-layout="compact"]) #proj-tools-normal .pj-select-btn { order: 2; margin-left: auto; margin-right: -8px; }
  :where(html[data-layout="compact"]) #proj-tools-normal .pj-new { display: none; }
  :where(html[data-layout="compact"]) #proj-tools-normal .pj-search { order: 5; flex: 0 0 100%; width: 100%; margin: 6px 0 12px; position: relative; }
  :where(html[data-layout="compact"]) #proj-tools-normal .pj-search input { height: 54px; min-height: 54px; border-radius: 16px; background: var(--bg); border: 1px solid var(--line); padding-left: 56px; font-size: 1.1rem; }
  :where(html[data-layout="compact"]) #proj-tools-normal .pj-search svg { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); width: 24px; height: 24px; color: var(--muted); stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
  :where(html[data-layout="compact"]) #view-projects .pj-tabs { margin-top: 4px; padding-bottom: 10px; }
  :where(html[data-layout="compact"]) #view-projects .pj-tab { min-height: 40px; font-size: 1rem; }
  :where(html[data-layout="compact"]) #view-projects .pj-row { grid-template-columns: 46px minmax(0, 1fr); grid-template-areas: "icon name" "icon edited"; gap: 3px 12px; align-items: center; padding: 12px 6px; border-radius: 14px; }
  :where(html[data-layout="compact"]) #view-projects .pj-row-menu, :where(html[data-layout="compact"]) #view-projects .pj-row-mod { display: none; }
  :where(html[data-layout="compact"]) #view-projects .pj-row-icon { display: grid; grid-area: icon; grid-row: 1 / span 2; width: 44px; height: 44px; border-radius: 13px; }
  :where(html[data-layout="compact"]) #view-projects .pj-row-icon svg { width: 22px; height: 22px; }
  :where(html[data-layout="compact"]) #view-projects .pj-row-name { grid-area: name; }
  :where(html[data-layout="compact"]) #view-projects .pj-row-name .pn { font-size: 1.25rem; font-weight: 400; line-height: 1.3; }
  :where(html[data-layout="compact"]) #view-projects .pj-row-edited { display: block; grid-area: edited; color: var(--muted); font-size: 1.02rem; }
  :where(html[data-layout="compact"]) #view-projects.selecting .pj-row { grid-template-columns: 26px 46px minmax(0, 1fr); grid-template-areas: "chk icon name" "chk icon edited"; column-gap: 12px; }
  :where(html[data-layout="compact"]) #view-projects.selecting .pj-row .cp-check { grid-area: chk; align-self: start; margin-top: 2px; }
  :where(html[data-layout="compact"]) #proj-tools-select .pj-sel-count { display: none; }
  :where(html[data-layout="compact"]) .pj-fab { display: inline-flex; }

.pj-row.selected .cp-check { background: var(--text); border-color: var(--text); }
.pj-row.selected .cp-check svg { opacity: 1; }

/* ================= v194 ================= */
/* One size scale for the sidebar, the Chats page and the Projects page, on every device:
   rows .96rem / 40-44px, sub-text .85rem, search box 40-42px, header icons 40px (glyph 22px), titles 2rem (computer) / 1.3rem (phone). */

/* ----- Back from Settings / Admin on a phone: the sidebar is there from the first frame (see the inline script in chat.html) ----- */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]).sb-boot .sidebar { transform: none; transition: none; }


/* ----- "Chats / Recents" header of the sidebar list: plain text + chevron, never a button (no pill, no tooltip) ----- */
.recents-toggle, .recents-toggle:hover, .recents-toggle:focus, .recents-toggle:active {
  background: transparent !important; border-color: transparent !important; box-shadow: none; outline: none;
}
.recents-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.recents-toggle .rl-mob { display: none; }
/* [wide layout: every computer, any window width] */
  :where(html[data-layout="wide"]) .recents-toggle:hover { color: var(--muted); }
  /* Collapsed: keep the (empty) list's space so the profile row stays at the bottom instead of jumping up under the header. */
  :where(html[data-layout="wide"]) .chat-list.recents-collapsed { display: flex; overflow: hidden; }
  :where(html[data-layout="wide"]) .chat-list.recents-collapsed > * { display: none; }
  :where(html[data-layout="wide"]) #chats-nav-btn { display: none; }          /* computer: New chat + Projects only; the "Chats" header below is the chat list */
  :where(html[data-layout="wide"]) .recents-tools .ghost.icon svg { width: 18px; height: 18px; }

/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .recents-toggle .rl-desk { display: none; }
  :where(html[data-layout="compact"]) .recents-toggle .rl-mob { display: inline; }


/* ----- Filter menu ----- */
.filter-menu { min-width: 168px; border-radius: 14px; padding: 4px; gap: 2px; }
.filter-menu .fm-item { min-height: 36px; gap: 10px; padding: 0 10px; border-radius: 10px; font-size: .86rem; }
.filter-menu .fm-ico { width: 18px; height: 18px; }
.filter-menu .fm-ico svg { width: 16px; height: 16px; }
.filter-menu .fm-dot { width: 9px; height: 9px; }
.filter-menu .fm-spin { width: 14px; height: 14px; border-width: 2px; }
.filter-menu .fm-check { width: 16px; height: 16px; }

/* ----- Chats page (same sizes as the Projects page) ----- */
.cp-title { font-size: 2rem; }
.cp-search { margin: 6px 0 10px; }
.cp-search svg { left: 12px; width: 17px; height: 17px; }
.cp-search input { height: 40px; min-height: 40px; padding: 0 14px 0 36px; border-radius: 999px; background: var(--surface-2); font-size: 1rem; }
.cp-list { gap: 2px; }
.cp-row { gap: 12px; padding: 10px 12px; border-radius: var(--radius-m); align-items: center; }
.cp-ico { width: 20px; height: 20px; margin-top: 0; }
.cp-txt { gap: 1px; }
.cp-name { font-size: .96rem; font-weight: 500; line-height: 1.3; }
.cp-sub { font-size: .85rem; }
.cp-check { width: 22px; height: 22px; margin-top: 0; border-radius: 7px; }
.cp-check svg { width: 14px; height: 14px; }
.cp-head .ghost.icon, #view-projects .pj-select-btn, #view-projects .pj-delete-btn, #view-projects .pj-lead { width: 40px; min-height: 40px; }
.cp-head .ghost.icon svg, #view-projects .pj-select-btn svg, #view-projects .pj-delete-btn svg, #view-projects .pj-lead svg { width: 22px; height: 22px; }
.cp-fab { height: 46px; padding: 0 20px; font-size: .96rem; gap: 8px; }
.cp-fab svg { width: 20px; height: 20px; }

/* ----- Phone: Chats + Projects pages ----- */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .cp-head, :where(html[data-layout="compact"]) #view-projects .pj-list-head { min-height: 56px; }
  :where(html[data-layout="compact"]) .cp-title, :where(html[data-layout="compact"]) #view-projects .pj-title { top: max(8px, env(safe-area-inset-top)); bottom: auto; height: 40px; line-height: 40px; font-size: 1.3rem; }
  :where(html[data-layout="compact"]) .cp-head .ghost.icon, :where(html[data-layout="compact"]) #view-projects .pj-lead, :where(html[data-layout="compact"]) #view-projects .pj-select-btn, :where(html[data-layout="compact"]) #view-projects .pj-delete-btn { width: 40px; min-height: 40px; }
  :where(html[data-layout="compact"]) .cp-head .ghost.icon svg, :where(html[data-layout="compact"]) #view-projects .pj-lead svg, :where(html[data-layout="compact"]) #view-projects .pj-select-btn svg, :where(html[data-layout="compact"]) #view-projects .pj-delete-btn svg { width: 22px; height: 22px; }
  :where(html[data-layout="compact"]) .cp-search { margin: 4px 0 10px; }
  :where(html[data-layout="compact"]) .cp-search input, :where(html[data-layout="compact"]) #proj-tools-normal .pj-search input { height: 42px; min-height: 42px; border-radius: 999px; background: var(--surface-2); font-size: 1rem; padding-left: 40px; }
  :where(html[data-layout="compact"]) .cp-search svg, :where(html[data-layout="compact"]) #proj-tools-normal .pj-search svg { left: 14px; width: 18px; height: 18px; }
  :where(html[data-layout="compact"]) #proj-tools-normal .pj-search { margin: 4px 0 10px; }
  :where(html[data-layout="compact"]) .cp-row { padding: 10px 8px; gap: 12px; }
  :where(html[data-layout="compact"]) .cp-name, :where(html[data-layout="compact"]) #view-projects .pj-row-name .pn { font-size: .96rem; font-weight: 500; line-height: 1.3; }
  :where(html[data-layout="compact"]) .cp-sub, :where(html[data-layout="compact"]) #view-projects .pj-row-edited { font-size: .85rem; }
  :where(html[data-layout="compact"]) #view-projects .pj-row { padding: 10px 8px; gap: 1px 0; }
  :where(html[data-layout="compact"]) #view-projects .pj-tab { min-height: 36px; font-size: .92rem; padding: 0 14px; }
  :where(html[data-layout="compact"]) #view-projects.selecting .pj-row { column-gap: 12px; }
  :where(html[data-layout="compact"]) .cp-wrap, :where(html[data-layout="compact"]) #view-projects .pj-wrap { padding-left: 16px; padding-right: 16px; }


/* ----- Phone sidebar: same sizes as the computer sidebar (a little taller rows for thumbs) ----- */
/* [compact layout: phones only] */
  :where(html[data-layout="compact"]) .sidebar { gap: 4px; padding-left: 14px; padding-right: 14px; }
  :where(html[data-layout="compact"]) .sidebar-head { padding: 4px 0 8px; }
  :where(html[data-layout="compact"]) .sidebar-head a.logo img { width: 30px; height: 30px; }
  :where(html[data-layout="compact"]) .sidebar-head a.logo .site-name { font-size: 1.2rem; }
  :where(html[data-layout="compact"]) .sidebar-head-actions .ghost.icon { width: 40px; min-height: 40px; }
  :where(html[data-layout="compact"]) #close-sidebar svg { width: 22px; height: 22px; }
  /* top: New chat, Chats, Projects (the New chat row was hidden before) */
  :where(html[data-layout="compact"]) #new-chat-btn { display: flex; }
  :where(html[data-layout="compact"]) .sidebar-nav { gap: 1px; margin-top: 2px; padding-bottom: 8px; }
  :where(html[data-layout="compact"]) .sidebar-nav .nav-item { min-height: 44px; padding: 0 10px; gap: 12px; font-size: .96rem; font-weight: 500; border-radius: 10px; }
  :where(html[data-layout="compact"]) .sidebar-nav .nav-item svg { width: 20px; height: 20px; }
  :where(html[data-layout="compact"]) .recents-head { padding: 10px 10px 2px; font-size: .85rem; font-weight: 600; }
  :where(html[data-layout="compact"]) .recents-head .ghost.icon, :where(html[data-layout="compact"]) .recents-tools .ghost.icon { width: 36px; min-height: 36px; margin-right: -6px; }
  :where(html[data-layout="compact"]) .recents-head .ghost.icon svg, :where(html[data-layout="compact"]) .recents-tools .ghost.icon svg { width: 20px; height: 20px; }
  :where(html[data-layout="compact"]) .chat-item { min-height: 44px; padding: 0 10px; border-radius: 10px; }
  :where(html[data-layout="compact"]) .chat-item .title { font-size: .96rem; }
  :where(html[data-layout="compact"]) .chat-item .chat-proj-ico svg { width: 15px; height: 15px; }
  /* bottom: avatar (opens Settings), Admin panel beside it (admins only), New chat on the right */
  :where(html[data-layout="compact"]) .sidebar-foot { padding: 8px 0 4px; gap: 10px; }
  :where(html[data-layout="compact"]) .profile-trigger, :where(html[data-layout="compact"]) .foot-actions a.icon { width: 48px; height: 48px; min-height: 48px; }
  :where(html[data-layout="compact"]) .profile-trigger .avatar { width: 38px; height: 38px; font-size: 1rem; }
  :where(html[data-layout="compact"]) .foot-actions { gap: 10px; margin-right: auto; }
  :where(html[data-layout="compact"]) .foot-actions a.icon svg { width: 22px; height: 22px; }
  :where(html[data-layout="compact"]) .foot-newchat { height: 44px; padding: 0 20px; gap: 8px; font-size: .96rem; }
  :where(html[data-layout="compact"]) .foot-newchat svg { width: 18px; height: 18px; }


/* ----- Sidebar button in the top bar (phone): the long / short / long icon ----- */
.topbar .menu-btn svg { stroke-width: 2; }

/* ================= v196 ================= */
/* ----- phone, New chat: suggestions line up with the greeting, no crosses -----
   The greeting sits at 14px (thread) + 8px (its own padding) from the edge; the suggestion icons now start on the very same line
   (before they were pushed 50px in). The cross is gone on phones: the three suggestions are always there. */
/* [compact layout: phones only] */
  :where(html[data-nc="phone"]) .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug:not(:empty) { padding: 0 14px 34px; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-item, :where(html[data-nc="phone"]) .welcome-sug .sug-row .sug-item { padding: 10px 8px; gap: 16px; }
  :where(html[data-nc="phone"]) .welcome-sug .sug-x { display: none !important; }
  /* Admin → Site: "Suggestions on phones" off → the box takes no room at all */
  :where(html[data-nc="phone"]) .main[data-sug-mobile="0"] > .welcome-sug:not(:empty) { padding: 0 !important; }


/* ----- phone, keyboard REALLY up (see syncKbClass in chat.js) -----
   The suggestions stay right above the box. The greeting stays too whenever there is room for it: it is centred in the free
   space under the top bar. When there is no room (html.kb-tight) only the suggestions remain. With the keyboard closed
   (also when it was closed with the back button while the box still had focus) the normal layout returns. */
/* [compact layout: phones only] */
  :where(html[data-nc="phone"]).kb-up .main.is-new:not(.view-page):not(.is-incog-new) > .scroller {
    flex: 1 1 auto; min-height: 0; overflow: visible;
    margin: var(--floating-topbar-h) 0 0;
    display: flex; flex-direction: column; justify-content: center;
  }
  :where(html[data-nc="phone"]).kb-up .main.is-new:not(.view-page):not(.is-incog-new) .topbar ~ .scroller .thread, :where(html[data-nc="phone"]).kb-up .main.is-new:not(.view-page):not(.is-incog-new) .topbar ~ .banner:not(.hidden) ~ .scroller .thread { padding-bottom: 0; flex: none; }
  :where(html[data-nc="phone"]).kb-up .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug { margin: 0; }
  :where(html[data-nc="phone"]).kb-up .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug:not(:empty) { padding-bottom: 18px; }
  :where(html[data-nc="phone"]).kb-up.kb-tight .main.is-new:not(.view-page):not(.is-incog-new) > .scroller { display: none; }
  :where(html[data-nc="phone"]).kb-up.kb-tight .main.is-new:not(.view-page):not(.is-incog-new) > .welcome-sug { margin-top: auto; }
  :where(html[data-nc="phone"]).kb-up .main[data-sug-mobile="0"] > .welcome-sug:not(:empty) { padding: 0 !important; }


/* ----- Pinned dropdown (above Recents, every device) ----- */
.pinned-head[hidden], .pinned-list[hidden] { display: none !important; }
.pinned-head { padding-bottom: 2px; }
.pinned-toggle, .pinned-toggle:hover, .pinned-toggle:focus, .pinned-toggle:active { pointer-events: auto !important; cursor: pointer; background: transparent !important; border-color: transparent !important; box-shadow: none !important; outline: none; }
.pinned-toggle .recents-chev { display: inline-block !important; }
.pinned-head.is-collapsed .recents-chev { transform: rotate(-90deg); }
.chat-list.pinned-list { flex: none; max-height: 38vh; margin-bottom: 4px; }
.chat-list.pinned-list::before { content: none !important; display: none !important; }
.chat-list.pinned-list.recents-collapsed { display: none; }
.cp-pin { display: inline-grid; place-items: center; margin-left: auto; color: var(--brand); flex: none; }
.cp-pin svg { width: 16px; height: 16px; stroke: currentColor; fill: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }


/* ----- Sidebar: top actions fixed, Pinned + Recents scroll together beneath them (every device) ----- */
.sidebar-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; margin: 0 -8px; padding: 0 8px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sidebar-scroll .chat-list, .sidebar-scroll .chat-list.pinned-list { flex: none; overflow: visible; max-height: none; margin: 0; padding: 0; }
.sidebar-scroll .recents-head { flex: none; }
.sidebar-nav, .sidebar-head, .sidebar-foot { flex: none; }

/* ----- "+" attach menu on a computer: it scales down with the window instead of running off the edge ----- */
.attach-menu-pc { min-width: min(300px, calc(100vw - 16px)); max-width: calc(100vw - 16px); box-sizing: border-box; }
.attach-menu-pc button { min-width: 0; }
.attach-menu-pc .mi-label { min-width: 0; overflow: hidden; }
.attach-menu-pc .mi-sub { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) {
  .attach-menu-pc button { min-height: 36px; gap: 8px; padding-left: 10px; padding-right: 10px; font-size: .88rem; }
  .attach-menu-pc button svg { width: 16px; height: 16px; }
  .attach-menu-pc .mi-label { gap: 6px; }
  .attach-menu-pc .mi-sub { font-size: .74rem; }
}
@media (max-width: 360px) { .attach-menu-pc .mi-sub { display: none; } }

/* ----- Computer: a narrow window keeps the computer layout (docked sidebar) and just scales it down ----- */
@media (max-width: 900px) {
  :where(html[data-layout="wide"]) .main { min-width: 0; }
  :where(html[data-layout="wide"]) .sidebar { width: clamp(180px, var(--sidebar-w), 44vw); }
}
@media (max-width: 520px) {
  :where(html[data-layout="wide"]) .sidebar { padding-left: 8px; padding-right: 8px; }
  :where(html[data-layout="wide"]) .sidebar-head-actions { gap: 0; }
  :where(html[data-layout="wide"]) .sidebar-head-actions .ghost.icon { width: 32px; min-height: 32px; }
}


/* =====================================================================================================================
   SMALL COMPUTER WINDOW  (html[data-layout="wide"][data-drawer="on"]: a computer whose window is <= 760px wide)
   Only the SHAPE changes — the sidebar becomes a slide-over panel (☰ opens it, ✕ closes it, tap outside closes it) and the
   Settings / Admin side menus become a dropdown. Everything inside keeps the computer design. Phones are untouched.
   ===================================================================================================================== */
html[data-layout="wide"][data-drawer="on"] .app { overflow: hidden; }
html[data-layout="wide"][data-drawer="on"] .app .main { min-width: 0; }
html[data-layout="wide"][data-drawer="on"] .app .sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(100vw, 360px); max-width: 100vw; min-width: 0;
  transform: translateX(-102%); visibility: hidden; opacity: 1; pointer-events: auto; overflow: hidden;
  transition: transform .24s cubic-bezier(.3,.7,.2,1), visibility 0s linear .24s;
  box-shadow: var(--shadow); border-right: 1px solid var(--line); padding: 14px 12px 12px;
}
html[data-layout="wide"][data-drawer="on"] .app .sidebar.open { transform: none; visibility: visible; transition: transform .24s cubic-bezier(.3,.7,.2,1), visibility 0s; }
html[data-layout="wide"][data-drawer="on"] .sidebar-resize-handle,
html[data-layout="wide"][data-drawer="on"] .sidebar-reopen-handle,
html[data-layout="wide"][data-drawer="on"] #collapse-sidebar-btn,
html[data-layout="wide"][data-drawer="on"] .app .topbar #expand-sidebar-btn { display: none !important; }
html[data-layout="wide"][data-drawer="on"] .scrim.show { opacity: 1; pointer-events: auto; }
html[data-layout="wide"][data-drawer="on"] .topbar .menu-btn { display: inline-grid; place-items: center; }
html[data-layout="wide"][data-drawer="on"] .app .main.view-page .topbar { display: flex; }   /* the ☰ must stay reachable on Projects pages */
html[data-layout="wide"][data-drawer="on"] .app .main.view-page .topbar .menu-btn { display: inline-grid; }

/* ---- the dropdown (built by nav-menu.js) — hidden everywhere except a small computer window ---- */
.nm { display: none; position: relative; min-width: 0; }
html[data-layout="wide"][data-drawer="on"] .nm { display: block; }
.nm-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 0 12px 0 14px; text-align: left;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-size: .96rem; font-weight: 600;
  cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.05); transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
:where(html[data-input="mouse"]) .nm-btn:hover { background: var(--surface-2); }
.nm.open .nm-btn, .nm-btn:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.nm-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm-ico { display: grid; place-items: center; width: 20px; height: 20px; flex: none; color: var(--muted); }
.nm-ico svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nm-caret { display: grid; place-items: center; width: 20px; height: 20px; flex: none; color: var(--muted); transition: transform .2s ease; }
.nm-caret svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nm.open .nm-caret { transform: rotate(180deg); color: var(--brand); }
.nm.nm-danger .nm-btn { color: var(--danger); }
.nm-scrim { position: fixed; inset: 0; z-index: 90; background: transparent; }
.nm-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 91; box-sizing: border-box; max-height: min(66dvh, 460px); overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin;
  padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  box-shadow: 0 18px 44px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.08); animation: nm-in .16s ease-out; transform-origin: top center;
}
.nm-panel[hidden], .nm-scrim[hidden] { display: none; }
.nm-panel.nm-up { top: auto; bottom: calc(100% + 8px); transform-origin: bottom center; }
@keyframes nm-in { from { opacity: 0; transform: translateY(-6px) scale(.985); } to { opacity: 1; transform: none; } }
.nm-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 12px; text-align: left; border: 0; border-radius: 11px;
  background: transparent; color: var(--text); font: inherit; font-size: .95rem; cursor: pointer;
}
:where(html[data-input="mouse"]) .nm-opt:hover, .nm-opt:focus-visible { background: var(--surface-2); outline: none; }
.nm-opt.on { background: var(--brand-soft); font-weight: 600; }
.nm-opt.danger { color: var(--danger); }
.nm-opt.danger.on, :where(html[data-input="mouse"]) .nm-opt.danger:hover { background: var(--danger-soft); }
.nm-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm-tick { width: 18px; height: 18px; flex: none; color: var(--brand); opacity: 0; }
.nm-tick svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.nm-opt.on .nm-tick { opacity: 1; }
.nm-opt.danger .nm-tick { color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .nm-panel { animation: none; } .nm-caret { transition: none; } }

/* Settings: dropdown on top, content below, no side column */
html[data-layout="wide"][data-drawer="on"] .settings-shell { flex-direction: column; align-items: stretch; gap: 14px; }
html[data-layout="wide"][data-drawer="on"] .settings-shell > .settings-sidebar { display: none; }
html[data-layout="wide"][data-drawer="on"] .page-bar > .nm { margin: 0 auto; padding: 2px 14px 10px; max-width: 1020px; box-sizing: border-box; }
html[data-layout="wide"][data-drawer="on"] .settings-content { width: 100%; }
/* Admin: the dropdown replaces the tab strip inside the sticky header */
html[data-layout="wide"][data-drawer="on"] .admin-bar-inner > .tabs { display: none; }
html[data-layout="wide"][data-drawer="on"] .admin-bar-inner > .nm { margin: 4px 0 8px; }


/* ----- "+" attach menu on a COMPUTER: every entry has its own colour (like Sketch), not plain white/black -----
   Scoped to .attach-menu-pc so the phone's "Add to chat" sheet is not touched. */
.attach-menu-pc button > svg:first-child { stroke: var(--mi-c, currentColor); }
.attach-menu-pc button:not([data-act]) { --mi-c: #3b82f6; }              /* Add photos & files */
.attach-menu-pc button[data-act="camera"] { --mi-c: #ec4899; }
.attach-menu-pc button[data-act="shot"] { --mi-c: #8b5cf6; }              /* Take a screenshot */
.attach-menu-pc button[data-act="sketch"] { --mi-c: #20a58d; }
.attach-menu-pc button[data-act="info"] { --mi-c: #f97316; }              /* Your Info Related */
.attach-menu-pc button[data-act="web"] { --mi-c: #0ea5e9; }               /* Web search */
.attach-menu-pc button[data-act="weather"] { --mi-c: #eab308; }           /* Weather and Time */
.attach-menu-pc button[data-act="writing"] { --mi-c: #ef4444; }           /* Writings */
.attach-menu-pc button[data-act="table"] { --mi-c: #22c55e; }             /* Table */


/* =====================================================================================================================
   v217 — ONE chat box everywhere + the refined New chat page
   The chat box is now exactly the design: the message on top, and one calm row underneath — a round "+" on the left,
   mic and Send on the right. The SAME box is used on the New chat page, in every old chat, in projects and in incognito.
   (form#composer wins over every older, page-specific composer rule above, so nothing can drift apart any more.)
   ===================================================================================================================== */
form#composer.composer {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: end; gap: 2px 8px;
  padding: 14px 12px 12px 22px; border-radius: 28px; border: 1px solid var(--line);
  background: var(--surface); background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.1); backdrop-filter: blur(18px) saturate(1.1);
  box-shadow: 0 1px 0 rgba(255,255,255,.75) inset, 0 18px 44px -26px rgba(34,24,70,.30), 0 2px 8px -4px rgba(34,24,70,.08);
  transition: border-color .2s, box-shadow .25s, background .2s;
}
:root[data-theme="dark"] form#composer.composer { border-color: hsl(var(--h) 8% 20%); box-shadow: 0 1px 0 rgba(255,255,255,.045) inset, 0 20px 48px -24px rgba(0,0,0,.78), 0 2px 8px -4px rgba(0,0,0,.4); }
form#composer.composer:focus-within { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); box-shadow: 0 0 0 4px var(--brand-soft), 0 18px 44px -26px rgba(34,24,70,.34); }
:root[data-theme="dark"] form#composer.composer:focus-within { box-shadow: 0 0 0 4px var(--brand-soft), 0 22px 52px -24px rgba(0,0,0,.85); }
body.incognito form#composer.composer { border-color: var(--brand); }
form#composer.composer.maintenance-off { background: var(--surface-2, var(--surface)); }
form#composer.composer > .composer-input-wrap { grid-column: 1 / -1; grid-row: 1; max-height: min(340px, 48dvh); margin: 0; }
form#composer.composer > .composer-input-wrap textarea { padding: 2px 0 10px; min-height: 28px; font-size: 1.02rem; }
form#composer.composer > .composer-input-wrap textarea::placeholder { color: var(--muted); opacity: .9; }
#msg-input-backdrop { padding: 2px 0 10px; font-size: 1.02rem; }
form#composer.composer > .attach-btn { grid-column: 1; grid-row: 2; margin: 0; align-self: center; }
form#composer.composer > .mic-btn { grid-column: 3; grid-row: 2; margin: 0; align-self: center; }
form#composer.composer > .send { grid-column: 4; grid-row: 2; align-self: center; }
/* The picked options (Web search, Weather and Time, Table, Writings, Your Info Related): ONE row at the bottom of the box, between
   "+" and the mic — same height as the buttons beside it. More chips than fit scroll sideways (wheel, drag, touch, or the
   newest chip scrolls into view); the edges fade out so a half-hidden chip never looks cut. Phones / tablets (no keyboard)
   show no chips here — the "Add to chat" sheet carries the on/off switches instead. */
form#composer.composer > .chip-row { grid-column: 2; grid-row: 2; align-self: center; min-width: 0; height: 40px; box-sizing: border-box; display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; padding: 0 2px;
  overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-behavior: smooth; }
form#composer.composer > .chip-row::-webkit-scrollbar { display: none; }
form#composer.composer > .chip-row:not(:has(.info-chip:not(.hidden))) { display: none; }
form#composer.composer > .chip-row.is-hscroll { cursor: grab; }
form#composer.composer > .chip-row.fade-l { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px); mask-image: linear-gradient(90deg, transparent 0, #000 18px); }
form#composer.composer > .chip-row.fade-r { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent 100%); mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent 100%); }
form#composer.composer > .chip-row.fade-l.fade-r { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%); }
form#composer.composer > .chip-row.is-grabbing { cursor: grabbing; user-select: none; scroll-behavior: auto; }
form#composer.composer > .chip-row .info-chip { flex: none; box-sizing: border-box; height: 32px; width: auto; max-width: none; gap: 2px; padding: 0 5px 0 12px; border-radius: 999px; font-size: .86rem; font-weight: 600; letter-spacing: -.005em;
  color: var(--brand); background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); transition: background .15s, border-color .15s; }
form#composer.composer > .chip-row .info-chip.hidden { display: none; }
:where(html[data-input="mouse"]) form#composer.composer > .chip-row .info-chip:hover { border-color: color-mix(in srgb, var(--brand) 55%, transparent); }
form#composer.composer > .chip-row .info-chip-label { overflow: visible; text-overflow: clip; }
form#composer.composer > .chip-row .info-chip-x { width: 22px; height: 22px; min-width: 22px; min-height: 22px; max-height: 22px; flex: none; align-self: center; }
:where(html[data-input="mouse"]) form#composer.composer > .chip-row .info-chip-x:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); }
body.no-keyboard form#composer.composer > .chip-row { display: none !important; }
@media (prefers-reduced-motion: reduce) { form#composer.composer > .chip-row { scroll-behavior: auto; } }
/* the round "+" */
form#composer.composer .attach-btn { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--text); background: transparent; border: 1px solid var(--line); border-color: color-mix(in srgb, var(--line) 85%, transparent); }
form#composer.composer .attach-btn svg { width: 19px; height: 19px; stroke-width: 1.9; }
form#composer.composer .attach-btn[aria-expanded="true"] { background: var(--surface-2); }
:where(html[data-input="mouse"]) form#composer.composer .attach-btn:hover { background: var(--surface-2); }
/* mic: bare icon, same height as the buttons beside it */
form#composer.composer .mic-btn { width: 40px; height: 40px; min-height: 0; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
form#composer.composer .mic-btn.hidden { display: none; }
form#composer.composer .mic-btn svg { width: 20px; height: 20px; stroke-width: 1.8; }
:where(html[data-input="mouse"]) form#composer.composer .mic-btn:not(:disabled):hover { color: var(--text); }
form#composer.composer .send { width: 42px; height: 42px; }
/* listening: the box turns into the recording bar, as before */
form#composer.composer.recording { display: flex; align-items: stretch; padding: 8px 8px 8px 10px; }
.composer-hint { margin-top: 8px; font-size: .72rem; opacity: .8; }

/* ---------- New chat page: greeting ---------- */
.new-welcome h2 { font-weight: 600; font-size: clamp(1.7rem, 2vw, 2.15rem); letter-spacing: -.02em; line-height: 1.2; }
.nc-mark, .nc-br { display: none; }
.sug-sub { display: none; }

/* ---------- New chat page: background (a quiet aurora + a hair of grain, follows the accent and the theme) ---------- */
.main.is-new:not(.view-page)::before {
  background:
    radial-gradient(46% 34% at 50% 34%, hsl(var(--h) var(--s) var(--nc-l) / calc(var(--nc-a) * 1.05)), transparent 72%),
    radial-gradient(34% 28% at 50% 36%, hsl(calc(var(--h) + 24) var(--s) calc(var(--nc-l) + 8%) / calc(var(--nc-a) * .55)), transparent 70%),
    radial-gradient(42% 34% at 6% 96%, hsl(calc(var(--h) - 28) calc(var(--s) - 14%) 56% / .075), transparent 70%),
    radial-gradient(40% 32% at 96% 4%, hsl(calc(var(--h) + 34) calc(var(--s) - 14%) 56% / .06), transparent 70%),
    linear-gradient(to top, hsl(var(--h) 24% 4% / .20), transparent 30%);
}
:root[data-theme="light"] .main.is-new:not(.view-page)::before {
  background:
    radial-gradient(48% 36% at 50% 34%, hsl(var(--h) var(--s) var(--nc-l) / var(--nc-a)), transparent 72%),
    radial-gradient(34% 28% at 50% 36%, hsl(calc(var(--h) + 30) var(--s) 74% / .16), transparent 70%),
    radial-gradient(42% 34% at 8% 94%, hsl(calc(var(--h) - 30) var(--s) var(--nc-l) / calc(var(--nc-b) * .8)), transparent 70%),
    radial-gradient(38% 32% at 94% 6%, hsl(calc(var(--h) + 36) var(--s) var(--nc-l) / calc(var(--nc-b) * .8)), transparent 70%);
}
.main.is-new:not(.view-page)::after, :root[data-theme="light"] .main.is-new:not(.view-page)::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px; background-position: 0 0; -webkit-mask-image: none; mask-image: none;
  -webkit-mask-image: radial-gradient(80% 70% at 50% 36%, #000 0%, transparent 100%); mask-image: radial-gradient(80% 70% at 50% 36%, #000 0%, transparent 100%);
}
:root[data-theme="light"] .main.is-new:not(.view-page)::after { opacity: .07; mix-blend-mode: multiply; }

/* ---------- New chat page · computer: three quiet cards under the box ---------- */
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-wrap { max-width: 760px; padding-top: 22px; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; padding: 0; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-row { display: block; min-width: 0; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-item {
  flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 14px; width: 100%; height: 100%; padding: 16px 18px 17px; border-radius: 20px;
  border: 1px solid var(--line); border-color: color-mix(in srgb, var(--line) 70%, transparent);
  background: var(--surface); background: color-mix(in srgb, var(--surface) 60%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-size: .95rem; line-height: 1.3;
  transition: background .2s, border-color .2s, transform .2s, box-shadow .2s;
}
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-tile { width: 34px; height: 34px; border-radius: 11px; border: 1px solid var(--line); border-color: color-mix(in srgb, var(--line) 80%, transparent); background: var(--surface-2); background: color-mix(in srgb, var(--surface-2) 70%, transparent); color: var(--muted); }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-ico { width: 17px; height: 17px; stroke-width: 1.6; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-text { display: flex; flex-direction: column; gap: 3px; width: 100%; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-title { font-weight: 500; color: var(--text); }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-more { display: none; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-sub { display: block; font-size: .8rem; color: var(--muted); }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-x { top: 8px; bottom: auto; right: 8px; margin: 0; opacity: 0; width: 24px; height: 24px; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-row:hover .sug-x { opacity: .6; }
html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-row:hover .sug-x:hover { opacity: 1; }
:where(html[data-input="mouse"]) html[data-nc="pc"] .main.is-new:not(.view-page) .welcome-sug .sug-item:hover,
html[data-nc="pc"][data-input="mouse"] .main.is-new:not(.view-page) .welcome-sug .sug-item:hover { background: var(--surface); background: color-mix(in srgb, var(--surface) 92%, transparent); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); transform: translateY(-2px); box-shadow: 0 14px 30px -20px rgba(34,24,70,.4); }

/* ---------- New chat page · phone: ringed logo, two-line greeting, plain rows ---------- */
html[data-nc="phone"] .main.is-new:not(.view-page):not(.is-incog-new) .nc-mark {
  display: grid; place-items: center; width: 80px; height: 80px; margin: 0 auto 22px; border-radius: 50%; position: relative;
  border: 1px solid var(--line); border-color: color-mix(in srgb, var(--text) 14%, transparent);
  background: radial-gradient(circle at 50% 38%, color-mix(in srgb, var(--surface) 70%, transparent), transparent 78%);
  box-shadow: 0 0 56px 4px hsl(var(--h) var(--s) 62% / .13), 0 0 0 6px color-mix(in srgb, var(--text) 2.5%, transparent);
  animation: ncRise .6s cubic-bezier(.2,.7,.2,1) both;
}
html[data-nc="phone"] .nc-mark img { width: 42px; height: 42px; border-radius: 11px; display: block; }
html[data-nc="phone"] .new-welcome h2 { font-size: clamp(1.3rem, 6vw, 1.95rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.22; text-wrap: initial; }
html[data-nc="phone"] .new-welcome .nc-br { display: block; }
html[data-nc="phone"] .welcome-sug .sug-sub { display: none; }
html[data-nc="phone"] .welcome-sug .sug-text { display: block; }
html[data-nc="phone"] .welcome-sug .sug-title { font-weight: 400; }
html[data-nc="phone"] .welcome-sug .sug-tile { color: var(--text); }
@media (prefers-reduced-motion: reduce) { html[data-nc="phone"] .nc-mark { animation: none; } }

/* ---------- v218: New chat page — no "New chat" title in the top bar; glow a little lower (still follows the accent) ---------- */
.main.is-new:not(.view-page):not(.is-incog-new) #chat-title { display: none; }
.main.is-new:not(.view-page) { --nc-a: .12; --nc-b: .075; }
:root[data-theme="light"] .main.is-new:not(.view-page) { --nc-a: .12; --nc-b: .075; }
:root[data-accent="white"] .main.is-new:not(.view-page) { --nc-a: .06; --nc-b: .04; }

/* v219: with the "New chat" title hidden, the title no longer pushes the right-hand buttons (incognito) to the edge — do it explicitly */
.topbar .topbar-right { margin-left: auto; }

/* ---------- v220: computer only — the "+" menu's "Add to project" view (a searchable project list inside the menu) ---------- */
.attach-menu-pj { padding: 6px; }
.attach-menu-pj .apj-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px 6px; font-size: .92rem; }
.attach-menu-pj .apj-head b { font-weight: 600; }
.attach-menu-pj button.apj-back { min-height: 0; width: 32px; height: 32px; padding: 0; border-radius: 50%; display: grid; place-items: center; flex: none; color: var(--muted); }
.attach-menu-pj button.apj-back svg { width: 18px; height: 18px; }
.attach-menu-pj .apj-search { display: flex; align-items: center; gap: 8px; margin: 0 2px 6px; padding: 0 12px; height: 38px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); border-color: color-mix(in srgb, var(--line) 80%, transparent); color: var(--muted); }
.attach-menu-pj .apj-search:focus-within { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); color: var(--text); }
.attach-menu-pj .apj-search svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.attach-menu-pj .apj-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; box-shadow: none; padding: 0; height: 100%; font: inherit; font-size: .9rem; color: var(--text); }
.attach-menu-pj .apj-list { display: flex; flex-direction: column; gap: 1px; max-height: 252px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.attach-menu-pj button.apj-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: left; font: inherit; font-size: .92rem; cursor: pointer; }
:where(html[data-input="mouse"]) .attach-menu-pj button.apj-row:hover { background: var(--surface-2); }
.attach-menu-pj button.apj-row.is-cur { background: var(--surface-2); }
.attach-menu-pj .apj-ico { display: grid; place-items: center; flex: none; width: 20px; height: 20px; color: var(--muted); }
.attach-menu-pj .apj-ico svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.attach-menu-pj .apj-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-menu-pj .apj-row > svg.as-check { width: 17px; height: 17px; flex: none; fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.attach-menu-pj .apj-none .apj-name { color: var(--muted); }
.attach-menu-pj .apj-empty { padding: 14px 10px 12px; font-size: .88rem; color: var(--muted); text-align: center; }

/* v220: phone — the project name in the middle of the bar gets more room (it was cut to "Physics n…") */
:where(html[data-layout="compact"]) .topbar .crumb-project { max-width: calc(100% - 200px); }

/* v221: computer "+" menu — Add to project row/list polish */
.attach-menu-pc button[data-act="project"] { --mi-c: #6366f1; }                     /* Add to project icon gets its own colour like the other rows */
.attach-menu-pc.attach-menu-pj { width: 340px; min-width: 0; max-width: calc(100vw - 16px); }   /* the project list keeps one steady width (long names are cut with …, never widen it) */
.attach-menu-pj button.apj-back svg { stroke: currentColor; }                        /* back arrow stays muted grey, not the blue of the first row */
.attach-menu-pj button.apj-row svg { stroke: currentColor; }
.attach-menu-pj button.apj-row:focus-visible, .attach-menu-pj button.apj-back:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 60%, transparent); outline-offset: -2px; }
.attach-menu-pj .apj-row > svg.as-check { margin-left: auto; }

/* v221: new chat — the accent glow a little softer (still a touch more than the plain reference) */
.main.is-new:not(.view-page) { --nc-a: .095; --nc-b: .06; }
:root[data-theme="light"] .main.is-new:not(.view-page) { --nc-a: .095; --nc-b: .06; }
:root[data-accent="white"] .main.is-new:not(.view-page) { --nc-a: .05; --nc-b: .035; }

/* v221: copy-box Undo / Redo never look "selected" after a tap */
.paste-undo-pill button:hover, .paste-undo-pill button:focus, .paste-undo-pill button:active { background: transparent; box-shadow: none; outline: none; }
:where(html[data-input="mouse"]) .paste-undo-pill button:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 8%, transparent); }
.paste-undo-pill button:active:not(:disabled) { background: color-mix(in srgb, var(--text) 8%, transparent); }


/* ---- Fewer hints (v233): no key letters in menus, no "how to fill the table" strip above the box ---- */
.row-menu .mi-key, .menu-key, .mi-key { display: none !important; }
.table-hint { display: none !important; }

/* The suggestion cross is gone on computers too (phones never had it). Admin can still switch suggestions on/off. */
.sug-x { display: none !important; }
html[data-about-off] .mm-row[data-target="about"], html[data-about-off] .settings-sidebar button[data-href="/about.html"] { display: none !important; }

/* ---- "Your response is ready" card (v237): icon + chat name + one short line, soft rounded card, no cross, leaves by itself ---- */
.reply-notice { flex-direction: row; align-items: center; gap: 12px; padding: 12px 16px 12px 12px; border-radius: 18px; border-color: color-mix(in srgb, var(--line) 70%, transparent); box-shadow: 0 10px 30px -8px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.12); }
.reply-notice .rn-ico { flex: none; width: 30px; height: 30px; border-radius: 9px; }
.reply-notice .rn-txt { color: var(--text); white-space: normal; overflow: visible; font-size: inherit; display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.reply-notice .rn-txt strong { font-size: .93rem; }
.reply-notice .rn-txt span { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Small popups ("Copied", errors ...) in the same soft card style as "Your response is ready" (v238): icon + text, no cross, leaves by itself ---- */
.toast { background: var(--surface); color: var(--text); border: 1px solid color-mix(in srgb, var(--line) 70%, transparent); border-radius: 16px; padding: 11px 16px 11px 12px; gap: 10px;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.35), 0 2px 6px rgba(0,0,0,.12); }
.toast .toast-ico { flex: none; display: grid; place-items: center; width: 22px; height: 22px; color: var(--brand); }
.toast .toast-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toast.error { background: var(--surface); color: var(--text); border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.toast.error .toast-ico { color: var(--danger); }
.toast .toast-count { background: var(--surface-2); color: var(--muted); }

/* v251: the small popups (hints, errors, "Copied") now appear at the top right, right under the top bar, exactly where the
   "Your response is ready" card appears - not at the bottom middle. They are only a hint: not clickable (clicks go through to the page).
   On phones (compact layout) they sit centred just under the top bar, so the menu / title / incognito buttons are never covered. */
#toasts { top: calc(max(0px, env(safe-area-inset-top)) + 62px); bottom: auto; left: auto; right: 14px; transform: none; align-items: flex-end; width: min(360px, calc(100vw - 28px)); z-index: 300; pointer-events: none; }
.toast, .toast * { pointer-events: none !important; -webkit-user-select: none; user-select: none; }
.toast { max-width: 100%; animation: reply-notice-in .22s ease; }
.toast.out { transform: translateY(-6px); }
:where(html[data-layout="compact"]) #toasts { right: 50%; transform: translateX(50%); align-items: center; }
/* a reply card and a popup at the same time: the popup waits just below the card instead of covering it */
body:has(#reply-notices .reply-notice) #toasts { top: calc(max(0px, env(safe-area-inset-top)) + 62px + 78px); }

/* v240: chip cross (Weather and Time, Writings ...) - clearer, never touches the label */
form#composer.composer > .chip-row .info-chip { gap: 6px; padding: 0 6px 0 13px; }
form#composer.composer > .chip-row .info-chip-x, .info-chip-x { width: 24px; height: 24px; min-width: 24px; min-height: 24px; max-height: 24px; }
.info-chip-x svg { width: 15px; height: 15px; stroke-width: 2.8; }

/* "All set — go back to the MOMU app": the end of the browser step of the Windows app's Google sign-in. No endless spinner. */
.g-return-box .hidden { display: none !important; }
.g-done-tick { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #7c5cff, #d65db1); box-shadow: 0 8px 28px rgba(124, 92, 255, .35); animation: g-pop .35s cubic-bezier(.2, 1.4, .4, 1) both; }
.g-done-tick svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
@keyframes g-pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.g-return-open { margin-top: 6px; padding: 11px 22px; border-radius: 999px; font-weight: 600; font-size: .95rem; text-decoration: none; color: var(--text, inherit);
  border: 1px solid rgba(128, 128, 128, .4); transition: background .15s, border-color .15s; }
.g-return-open:hover { background: rgba(128, 128, 128, .14); border-color: rgba(128, 128, 128, .6); }
@media (prefers-reduced-motion: reduce) { .g-done-tick { animation: none; } }

/* ---------- Admin → Support → "Send email" card (v262 redesign) ----------
   One card, two views: WRITE (short form + live preview; the page scrolls normally — no scroll boxes inside scroll boxes)
   and SENT (conversations + replies). Phone: one column, the preview opens full screen, Send stays pinned at the bottom. */
#tab-support .panel.ems { scroll-margin-top: 118px; margin-top: 18px; padding: 0; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 1px 0 var(--rule), 0 14px 36px rgba(0, 0, 0, .07); }
.ems-head { display: flex; align-items: center; justify-content: space-between; gap: 14px 18px; flex-wrap: wrap; padding: 20px 22px 18px; }
.ems-id { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1 1 320px; }
.ems-logo { flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: var(--on-brand); background: linear-gradient(135deg, var(--brand), var(--brand-strong)); box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 32%, transparent); }
.ems-logo svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ems-id-text { min-width: 0; }
.ems .ems-id-text h2 { margin: 0; font-size: 1.22rem; line-height: 1.2; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ems-sub { margin: 4px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.45; }
.em-unread { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.ems-head-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.ems-seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.ems-seg button { min-height: 38px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.ems-seg button.on, .ems-seg button.on:hover { background: var(--brand); color: var(--on-brand); box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 28%, transparent); }
.ems-seg b { min-width: 22px; padding: 0 6px; border-radius: 999px; font-size: .74rem; font-weight: 700; line-height: 20px; text-align: center; background: var(--surface-3); color: var(--text); }
.ems-seg button.on b { background: color-mix(in srgb, var(--on-brand) 20%, transparent); color: inherit; }
.ems-seg b.alert { background: var(--danger); color: #fff; }
.ems .ems-refresh { width: 42px; height: 42px; min-height: 42px; padding: 0; justify-content: center; border-radius: 12px; }
.ems-note { margin: 0 22px 16px; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: .84rem; line-height: 1.5; overflow-wrap: anywhere; }
.ems-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); }
.ems-view { border-top: 1px solid var(--line); min-width: 0; }

/* WRITE */
.ems-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px 22px 24px; align-items: start; }
.ems-form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ems .ems-block { border: 1px solid var(--line); border-radius: 16px; background: var(--bg); padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ems-label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ems-label i { font-style: normal; flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 700; background: var(--brand-soft); color: var(--brand); }
.ems-label b { font-size: 1rem; }
.ems-label small { color: var(--muted); font-size: .8rem; }
.ems-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ems-fields .full { grid-column: 1 / -1; }
.ems .field label small { color: var(--muted); opacity: .85; font-weight: 400; }
.ems input { min-height: 46px; border-radius: 12px; }
.ems-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.ems-who { display: inline-flex; align-self: flex-start; padding: 4px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.ems-who button { min-height: 36px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.ems-who button.on, .ems-who button.on:hover { background: var(--brand); color: var(--on-brand); box-shadow: 0 3px 10px color-mix(in srgb, var(--brand) 28%, transparent); }
.ems-aud { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.ems-aud-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ems-aud-main b { font-size: 1.5rem; line-height: 1.1; letter-spacing: -.02em; }
.ems-aud-main span { color: var(--muted); font-size: .9rem; }
.ems-aud-sub { color: var(--text); font-size: .86rem; font-weight: 600; }
.ems-bc { margin: 20px 22px 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.ems-bc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ems-bc-top span { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }
.ems-bc-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.ems-bc-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--brand); transition: width .4s ease; }
.ems-bc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: .84rem; }
.ems-bc-foot button { min-height: 34px; padding: 0 14px; }
.em-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .86rem; font-weight: 500; cursor: pointer; transition: border-color .15s, background .15s, transform .1s; }
.em-chip i { width: 8px; height: 8px; border-radius: 50%; background: #8B6CF0; flex: none; }
.em-chip.em-tone-success i { background: #3E8E5C; } .em-chip.em-tone-warn i { background: #C9822A; } .em-chip.em-tone-danger i { background: #C8483D; } .em-chip.em-tone-info i { background: #8A8374; }
html[data-input="mouse"] .em-chip:hover { border-color: var(--brand); background: var(--surface-2); }
.em-chip:active { transform: scale(.97); }
.em-chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.ems-editor { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.ems-editor:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ems-tools { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ems-tools button { width: 38px; min-height: 36px; height: 36px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--text); }
.ems-tools button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ems-tools button b { font-size: 1rem; }
.ems-count { margin-left: auto; padding-right: 6px; color: var(--muted); font-size: .76rem; }
.ems .ems-editor textarea { display: block; border: 0; border-radius: 0; box-shadow: none; background: transparent; min-height: 190px; resize: none; line-height: 1.6; padding: 14px 16px; overflow-y: auto; }
.ems .ems-editor textarea:focus { border: 0; box-shadow: none; }
.ems-tip { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.ems-tip code { background: var(--surface-3); padding: 1px 6px; border-radius: 6px; font-size: .78rem; }
.ems details.ems-block { padding: 0; gap: 0; border-top: 1px solid var(--line); }
.ems .ems-design > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; min-height: 54px; font-size: 1rem; user-select: none; border-radius: 16px; -webkit-tap-highlight-color: transparent; }
.ems .ems-design > summary::-webkit-details-marker { display: none; }
.ems-chev { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.ems-design[open] .ems-chev { transform: rotate(180deg); }
.ems-design-fields { padding: 16px; border-top: 1px solid var(--line); }

/* preview */
.ems-prev { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ems-prev-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap; }
.ems-prev-title { display: flex; flex-direction: column; min-width: 0; }
.ems-prev-title b { font-size: .95rem; }
.ems-prev-state { color: var(--muted); font-size: .76rem; }
.ems-mode { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); }
.ems-mode button { min-height: 30px; padding: 2px 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; }
.ems-mode button.on, .ems-mode button.on:hover { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.ems-prev-close { display: none; min-height: 40px; padding: 0 16px; border-radius: 12px; }
.ems-frame-wrap { border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: #F4F0E8; box-shadow: 0 8px 24px rgba(0, 0, 0, .07); }
#em-frame { display: block; width: 100%; height: clamp(420px, calc(100dvh - 150px), 820px); border: 0; background: #F4F0E8; }
#em-frame.phone { width: 390px; max-width: 100%; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); }
html.ems-lock, html.ems-lock body { overflow: hidden; }

/* the bar that stays at the bottom of the screen while you write */
.ems-bar { position: sticky; bottom: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; padding: 12px 22px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-radius: 0 0 19px 19px; }
.ems-bar-hint { color: var(--muted); font-size: .8rem; flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.ems-bar-btns { display: flex; gap: 8px; margin-left: auto; }
.ems-bar-btns button { min-height: 44px; border-radius: 12px; padding: 0 20px; }
.ems-bar-btns .primary { min-width: 150px; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 28%, transparent); }
.ems-show-prev { display: none; }

/* SENT */
.ems-sent { display: grid; grid-template-columns: minmax(290px, 360px) minmax(0, 1fr); min-height: 520px; }
.ems-side { display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--line); background: var(--surface); border-radius: 0 0 0 19px; }
.ems-side-top { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.ems-side-row { display: flex; gap: 8px; }
.ems .ems-search { flex: 1; min-width: 0; min-height: 44px; border-radius: 12px; }
.ems-new { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: 12px; flex: none; }
.ems-new svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.ems-list { max-height: min(640px, 72dvh); overflow-y: auto; overscroll-behavior: auto; }
.ems-list > .empty { padding: 36px 14px; }
.ems-pane { min-width: 0; display: flex; flex-direction: column; background: var(--bg); border-radius: 0 0 19px 0; }
.ems-none { margin: auto; padding: 56px 24px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); }
.ems-none b { color: var(--text); font-size: 1.05rem; }
.ems-none span { max-width: 34ch; line-height: 1.5; font-size: .9rem; }
.ems-none button { margin-top: 10px; min-height: 44px; padding: 0 22px; border-radius: 12px; }
.ems-none-ico { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 4px; }
.ems-none-ico svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ems-p-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ems-p-head .sp-av { width: 42px; height: 42px; font-size: 1.05rem; }
.ems-back { display: none; flex: none; width: 40px; height: 40px; min-height: 40px; padding: 0; margin-left: -8px; border: 0; border-radius: 50%; background: transparent; color: var(--text); align-items: center; justify-content: center; }
.ems-back svg { width: 22px; height: 22px; }
.ems-p-who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.ems-p-who b { font-size: 1.02rem; overflow-wrap: anywhere; }
.ems-p-who span { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.ems-p-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1 1 100%; min-width: 0; }
.ems-subj { max-width: 100%; overflow: hidden; text-overflow: ellipsis; padding: 3px 11px; font-size: .78rem; }
.ems-p-when { margin-left: auto; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.ems-p-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.ems-p-actions button { min-height: 38px; border-radius: 10px; }
.ems-grow { flex: 1; }
.ems-inline-note { margin: 14px 20px 0; }
.ems-thread { display: flex; flex-direction: column; gap: 16px; padding: 20px; flex: 1; }
.ems-reply { position: sticky; bottom: 0; z-index: 4; display: flex; flex-direction: column; gap: 10px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); border-radius: 0 0 19px 0; }
.ems .em-reply-ta { width: 100%; box-sizing: border-box; min-height: 84px; max-height: 280px; resize: none; border-radius: 12px; padding: 11px 13px; line-height: 1.5; }
.ems-reply-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.ems-reply-bar .primary { min-height: 44px; border-radius: 12px; padding: 0 22px; }

/* ---------------------------------------------------------------------------------------------------------------------
   Layout of this card follows ITS OWN WIDTH, never the device and never the window width.
   admin.js (emMeasure) measures #em-panel and writes data-w = xl (>= 900px) | lg (700-899) | md (560-699) | sm (< 560).
   A small PC window, a phone, a split-screen tablet and a big monitor all get what fits; the rest of the app is untouched.
     xl : Write = form + live preview side by side · Sent = list + conversation side by side
     lg : Write = one column, "Preview" opens full screen · Sent = side by side
     md : Write = one column · Sent = one pane at a time (list OR conversation)
     sm : phone layout (everything stacked, full-width buttons, bar pinned at the bottom)
   --------------------------------------------------------------------------------------------------------------------- */
#em-panel[data-w="xl"] .ems-grid { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: 24px; }
#em-panel[data-w="xl"] .ems-prev { position: sticky; top: 16px; }
/* everything narrower than xl: the preview opens full screen from the "Preview" button */
#em-panel:not([data-w="xl"]) .ems-show-prev { display: inline-flex; align-items: center; justify-content: center; }
#em-panel:not([data-w="xl"]) .ems-prev { display: none; }
#em-panel:not([data-w="xl"]) .ems-prev.open { display: flex; position: fixed; inset: 0; z-index: 90; background: var(--bg); padding: calc(12px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom)); gap: 10px; }
#em-panel:not([data-w="xl"]) .ems-prev.open .ems-prev-close { display: inline-flex; align-items: center; }
#em-panel:not([data-w="xl"]) .ems-prev.open .ems-frame-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#em-panel:not([data-w="xl"]) .ems-prev.open #em-frame { flex: 1; height: 100%; min-height: 0; }
#em-panel:not([data-w="xl"]) .ems-prev.open #em-frame.phone { flex: none; height: 100%; }
/* Sent: below 700px wide only one pane shows at a time (list, then the conversation with a Back button) */
#em-panel[data-w="md"] .ems-sent,
#em-panel[data-w="sm"] .ems-sent { display: block; min-height: 0; }
#em-panel[data-w="md"] .ems-side,
#em-panel[data-w="sm"] .ems-side { border-right: 0; border-radius: 0 0 19px 19px; }
#em-panel[data-w="md"] .ems-list,
#em-panel[data-w="sm"] .ems-list { max-height: none; overflow: visible; }
#em-panel[data-w="md"] .ems-sent:not(.show-detail) .ems-pane,
#em-panel[data-w="sm"] .ems-sent:not(.show-detail) .ems-pane { display: none; }
#em-panel[data-w="md"] .ems-sent.show-detail .ems-side,
#em-panel[data-w="sm"] .ems-sent.show-detail .ems-side { display: none; }
#em-panel[data-w="md"] .ems-pane,
#em-panel[data-w="sm"] .ems-pane { border-radius: 0 0 19px 19px; }
#em-panel[data-w="md"] .ems-reply,
#em-panel[data-w="sm"] .ems-reply { border-radius: 0 0 19px 19px; }
#em-panel[data-w="md"] .ems-back,
#em-panel[data-w="sm"] .ems-back { display: inline-flex; }
#em-panel[data-w="md"] .ems-chips,
#em-panel[data-w="sm"] .ems-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -2px; padding: 0 2px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
#em-panel[data-w="md"] .ems-chips::-webkit-scrollbar,
#em-panel[data-w="sm"] .ems-chips::-webkit-scrollbar { display: none; }
#em-panel[data-w="md"] .ems-chips .sp-chip,
#em-panel[data-w="sm"] .ems-chips .sp-chip { flex: none; min-height: 38px; padding: 0 14px; }
/* sm: the phone layout of the card */
#em-panel[data-w="sm"] .ems-head { padding: 16px 16px 14px; }
#em-panel[data-w="sm"] .ems-head-actions { width: 100%; }
#em-panel[data-w="sm"] .ems-seg { flex: 1; }
#em-panel[data-w="sm"] .ems-seg button { flex: 1; }
#em-panel[data-w="sm"] .ems-note { margin: 0 16px 14px; }
#em-panel[data-w="sm"] .ems-grid { padding: 14px 14px 18px; gap: 14px; }
#em-panel[data-w="sm"] .ems-block { padding: 14px; border-radius: 14px; }
#em-panel[data-w="sm"] .ems-fields { grid-template-columns: minmax(0, 1fr); }
#em-panel[data-w="sm"] .ems-design-fields { padding: 14px; }
#em-panel[data-w="sm"] .ems-presets { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 2px 14px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
#em-panel[data-w="sm"] .ems-presets::-webkit-scrollbar { display: none; }
#em-panel[data-w="sm"] .em-chip { flex: none; }
#em-panel[data-w="sm"] input, #em-panel[data-w="sm"] textarea { font-size: 16px; }
#em-panel[data-w="sm"] .ems-mode { display: none; }
#em-panel[data-w="sm"] .ems-bar { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
#em-panel[data-w="sm"] .ems-bar-hint { display: none; }
#em-panel[data-w="sm"] .ems-bar-btns { width: 100%; }
#em-panel[data-w="sm"] .ems-bar-btns button { padding: 0 14px; }
#em-panel[data-w="sm"] .ems-bar-btns .ems-show-prev { flex: 1; }
#em-panel[data-w="sm"] .ems-bar-btns .primary { flex: 2; min-width: 0; }
#em-panel[data-w="sm"] .ems-p-head { padding: 12px 14px 12px 10px; }
#em-panel[data-w="sm"] .ems-p-actions { display: grid; grid-template-columns: 1fr 1fr; padding: 10px 14px; }
#em-panel[data-w="sm"] .ems-p-actions .ems-grow { display: none; }
#em-panel[data-w="sm"] .ems-p-actions button { min-height: 44px; border-radius: 12px; white-space: normal; }
#em-panel[data-w="sm"] .ems-thread { padding: 16px 14px; }
#em-panel[data-w="sm"] .ems-inline-note { margin: 12px 14px 0; }
#em-panel[data-w="sm"] .ems-reply { padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); }
#em-panel[data-w="sm"] .ems-reply-bar .ems-bar-hint { display: block; flex: 1 1 100%; }
#em-panel[data-w="sm"] .ems-reply-bar .primary { width: 100%; min-height: 48px; }
#em-panel[data-w="sm"] .sp-msg { max-width: 94%; }
@media (prefers-reduced-motion: reduce) { .ems *, .ems *::before { transition: none !important; } }


/* =====================================================================================================================
   v270 — Admin → Support + Users redesign, Settings → username note.
   These follow the ROOM the card really has (container queries), never the kind of device, so a small desktop window,
   a phone, a split-screen tablet and a big monitor all get a layout that fits. Nothing here can scroll sideways.
   Support: >= 720px wide = list + conversation side by side · below = one pane at a time (JS: SP_NARROW_MAX in admin.js).
   ===================================================================================================================== */

/* ---- Settings: username needs a password first ---- */
.username-needpw { margin-top: 10px; padding: 14px; border: 1px dashed var(--line); border-radius: var(--radius-m); background: var(--surface-2); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.username-needpw p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.5; }

/* ---- Support: shared pieces (any width) ---- */
#tab-support .sp-panel { container: sp / inline-size; min-width: 0; gap: 14px; }
#tab-support .sp-top { align-items: center; }
#tab-support .sp-top-text h2 { margin: 0; font-family: var(--font-display); letter-spacing: -.015em; }
#tab-support .sp-top-text .sub { margin: 3px 0 0; line-height: 1.45; }
#tab-support .sp-filters { gap: 12px; }
#tab-support .sp-filters .grow { min-height: 44px; border-radius: 12px; padding-left: 14px; background: var(--surface-2); }
#tab-support .sp-chips { gap: 6px; }
#tab-support .sp-chip { min-height: 36px; padding: 0 14px; font-size: .86rem; font-weight: 500; background: var(--surface-2); border-color: transparent; transition: background .15s, color .15s; }
#tab-support .sp-chip.on, #tab-support .sp-chip.on:hover { background: var(--text); color: var(--bg); }
#tab-support .sp-chip:focus-visible, #tab-support .sp-row:focus-visible, #tab-support .sp-back:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

#tab-support .sp-layout { border-radius: 18px; background: var(--surface); }
#tab-support .sp-list { background: var(--surface); }
#tab-support .sp-row { gap: 12px; padding: 14px 16px; }
#tab-support .sp-av { width: 40px; height: 40px; background: hsl(var(--sp-h, 38) 50% 52% / .2); }
#tab-support .sp-name { font-size: .96rem; }
#tab-support .sp-row-main { gap: 3px; }
#tab-support .sp-row-tags { flex-wrap: wrap; gap: 4px; }
#tab-support .sp-row-tags .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#tab-support .sp-state { box-shadow: 0 0 0 3px var(--surface); }

/* conversation: nothing may overflow its pane */
#tab-support .sp-detail { background: var(--bg); overflow: hidden; }
#tab-support .sp-d-head, #tab-support .sp-d-actions, #tab-support .sp-note, #tab-support .sp-composer { min-width: 0; box-sizing: border-box; }
#tab-support .sp-d-top { min-width: 0; }
#tab-support .sp-d-names { flex: 1; }
#tab-support .sp-d-badges .pill { max-width: 100%; }
#tab-support .sp-d-actions { gap: 8px; }
#tab-support .sp-d-actions button { white-space: normal; text-align: center; line-height: 1.2; min-width: 0; }
#tab-support .sp-note { width: auto; }
#tab-support .sp-thread { background: var(--bg); overflow-x: hidden; }
#tab-support .sp-bubble { box-shadow: 0 1px 0 var(--rule); }
#tab-support .sp-composer { background: var(--surface); }
#tab-support .sp-composer textarea { background: var(--bg); }
#tab-support .sp-comp-btns button { white-space: nowrap; }

/* ---- Support: TWO PANES (room for it) ---- */
@container sp (min-width: 720px) {
  #tab-support .sp-layout { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); height: clamp(500px, calc(100dvh - 300px), 820px); border: 1px solid var(--line); overflow: hidden; background: var(--surface); }
  #tab-support .sp-list { display: block; overflow-y: auto; border: 0; border-right: 1px solid var(--line); border-radius: 0; }
  #tab-support .sp-layout.show-detail .sp-list, #tab-support .sp-layout .sp-list { display: block; }
  #tab-support .sp-detail, #tab-support .sp-layout.show-detail .sp-detail { display: flex; height: auto; min-height: 0; border: 0; border-radius: 0; }
  #tab-support .sp-back { display: none; }
  #tab-support .sp-panel:has(.sp-layout.show-detail) > .sp-top, #tab-support .sp-panel:has(.sp-layout.show-detail) > .sp-filters { display: flex; }
  #tab-support .sp-d-actions { display: flex; }
  #tab-support .sp-d-actions .sp-grow { display: block; flex: 1; }
  #tab-support .sp-d-actions button { width: auto; min-height: 36px; }
}

/* ---- Support: ONE PANE (small window, phone, split screen) ---- */
@container sp (max-width: 719px) {
  #tab-support .sp-top-actions .sp-refresh span { display: none; }
  #tab-support .sp-top-actions .sp-refresh { width: 38px; min-height: 38px; padding: 0; justify-content: center; }
  #tab-support .sp-more > summary { min-height: 38px; }
  #tab-support .sp-more-menu { max-width: min(260px, calc(100vw - 32px)); }
  #tab-support .sp-filters { flex-direction: column; align-items: stretch; gap: 10px; }
  #tab-support .sp-filters .grow { flex: none; min-width: 0; width: 100%; font-size: 16px; }
  #tab-support .sp-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -2px; padding: 0 2px 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  #tab-support .sp-chips::-webkit-scrollbar { display: none; }
  #tab-support .sp-chip { flex: none; min-height: 40px; }

  #tab-support .sp-layout { display: block; height: auto; min-height: 0; border: 0; border-radius: 0; overflow: visible; background: transparent; }
  /* the list becomes a stack of cards */
  #tab-support .sp-list { display: flex; flex-direction: column; gap: 10px; overflow: visible; border: 0; border-radius: 0; background: transparent; }
  #tab-support .sp-list > .sp-list-empty { border: 1px dashed var(--line); border-radius: 16px; background: var(--surface); }
  #tab-support .sp-row { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 14px; box-shadow: 0 1px 0 var(--rule); }
  #tab-support .sp-row.active, #tab-support .sp-row.active:hover { border-color: var(--brand); background: var(--brand-soft); }
  #tab-support .sp-row.active::before { display: none; }
  #tab-support .sp-row-msg { -webkit-line-clamp: 2; }

  #tab-support .sp-detail { display: none; }
  #tab-support .sp-layout.show-detail .sp-list { display: none; }
  #tab-support .sp-layout.show-detail .sp-detail { display: flex; flex-direction: column; height: clamp(480px, calc(100dvh - 150px), 920px); border: 1px solid var(--line); border-radius: 18px; background: var(--bg); overflow: hidden; }
  #tab-support .sp-panel:has(.sp-layout.show-detail) > .sp-top, #tab-support .sp-panel:has(.sp-layout.show-detail) > .sp-filters, #tab-support .sp-panel:has(.sp-layout.show-detail) > #sp-mail-warn { display: none; }

  /* an open conversation takes the whole card: no card inside a card */
  #tab-support .sp-panel:has(.sp-layout.show-detail) { padding: 0; border: 0; background: transparent; box-shadow: none; }
  #tab-support .sp-back { display: inline-flex; }
  #tab-support .sp-d-head { padding: 10px 14px 12px 8px; }
  #tab-support .sp-d-badges { padding-left: 6px; }
  #tab-support .sp-d-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; padding: 10px 14px; }
  #tab-support .sp-d-actions .sp-grow { display: none; }
  #tab-support .sp-d-actions button { width: 100%; min-height: 42px; border-radius: 12px; font-size: .9rem; }
  #tab-support .sp-d-actions button.primary:only-child { grid-column: 1 / -1; }
  #tab-support .sp-note { margin: 10px 14px 0; }
  #tab-support .sp-thread { padding: 14px; gap: 14px; min-height: 120px; }
  #tab-support .sp-msg { max-width: 94%; }
  #tab-support .sp-composer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  #tab-support .sp-composer textarea { font-size: 16px; min-height: 72px; }
  #tab-support .sp-comp-bar { flex-direction: column; align-items: stretch; }
  #tab-support .sp-comp-hint { flex: none; }
  #tab-support .sp-comp-btns { width: 100%; margin-left: 0; }
  #tab-support .sp-comp-btns button { flex: 1; min-height: 46px; border-radius: 12px; }
}

/* very small screens: the quick actions stack one per row */
@container sp (max-width: 300px) {
  #tab-support .sp-d-actions { grid-template-columns: 1fr; }
}

/* ---- Users: cards instead of a table (no sideways scrolling at any width) ---- */
.u-panel { container: usr / inline-size; min-width: 0; gap: 14px; }
.u-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.u-top h2 { margin: 0; font-family: var(--font-display); letter-spacing: -.015em; }
.u-count { flex: none; padding: 3px 11px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: .8rem; font-weight: 600; }
.u-count:empty { display: none; }
.u-searchbox { position: relative; }
.u-searchbox svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.u-searchbox input { width: 100%; box-sizing: border-box; min-height: 46px; padding: 0 14px 0 42px; border-radius: 12px; background: var(--surface-2); font-size: 16px; }
.u-list { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.u-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 38px 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }
.u-empty b { color: var(--text); }

.u-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 16px; min-width: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--bg); box-shadow: 0 1px 0 var(--rule); transition: border-color .15s; }
:where(html[data-input="mouse"]) .u-card:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.u-card.is-off { opacity: .86; }
.u-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.u-av { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; color: var(--text); background: hsl(var(--u-h, 38) 50% 52% / .22); }
.u-id { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.u-nick { font-size: 1.02rem; overflow-wrap: anywhere; }
.u-mail, .u-handle { color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.u-badges { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.u-badges .pill { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.u-stats { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.u-stats > div { min-width: 0; padding: 9px 11px; border-radius: 12px; background: var(--surface-2); }
.u-stats dt { color: var(--muted); font-size: .72rem; font-weight: 500; }
.u-stats dd { margin: 2px 0 0; font-weight: 600; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-foot { min-width: 0; padding-top: 14px; border-top: 1px solid var(--line); }
.u-foot .row-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); gap: 8px; }
.u-foot .row-actions button { width: 100%; min-height: 40px; border-radius: 11px; white-space: normal; line-height: 1.2; }
.u-foot .row-actions .pill { justify-self: start; }
.u-auto { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 12px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: .86rem; line-height: 1.45; overflow-wrap: anywhere; }
.u-auto .row-actions, .u-auto > div { min-width: 0; }

@container usr (max-width: 520px) {
  .u-card { padding: 14px; border-radius: 16px; }
}
@container usr (max-width: 400px) {
  .u-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container usr (max-width: 300px) {
  .u-foot .row-actions { grid-template-columns: 1fr; }
}
@container usr (min-width: 760px) {
  .u-card { grid-template-columns: minmax(0, 1fr) minmax(350px, 420px); grid-template-areas: "head stats" "badges stats" "foot foot"; column-gap: 20px; row-gap: 12px; align-items: center; }
  .u-head { grid-area: head; }
  .u-badges { grid-area: badges; }
  .u-stats { grid-area: stats; }
  .u-foot { grid-area: foot; }
  .u-card > .u-auto { grid-column: 1 / -1; }
  .u-foot .row-actions { display: flex; flex-wrap: wrap; }
  .u-foot .row-actions button { width: auto; min-width: 0; padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) { .u-card, #tab-support .sp-chip { transition: none; } }

/* ---- v270b: System status — API limit / key problems ---- */
.status-item > div { min-width: 0; }
.status-item small { overflow-wrap: anywhere; line-height: 1.5; }
.status-item .pill { flex: none; }
.st-raw { display: block; margin-top: 6px; font-size: .78rem; opacity: .75; font-family: var(--font-mono); overflow-wrap: anywhere; }
@media (max-width: 480px) { .status-item { align-items: flex-start; } }

/* ---- v270b: web-search source test results ---- */
.sd-sum { display: flex; flex-direction: column; gap: 3px; margin-bottom: 12px; }
.sd-sum span { color: var(--muted); font-size: .86rem; }
.sd-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.sd-row { display: flex; gap: 10px; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.sd-dot { flex: none; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--surface-3); }
.sd-ok .sd-dot { background: var(--ok); } .sd-bad .sd-dot { background: var(--danger); } .sd-limit .sd-dot { background: var(--warn); }
.sd-blocked, .sd-skip { opacity: .72; }
.sd-bad { border-color: var(--danger); background: var(--danger-soft); }
.sd-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sd-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.sd-line b { font-size: .92rem; overflow-wrap: anywhere; }
.sd-tag { flex: none; padding: 1px 8px; border-radius: 999px; font-size: .7rem; background: var(--surface-3); color: var(--muted); }
.sd-ok .sd-tag { background: rgba(35,168,90,.14); color: var(--ok); } .sd-bad .sd-tag { background: var(--danger-soft); color: var(--danger); } .sd-limit .sd-tag { background: rgba(228,185,92,.16); color: var(--warn); }
.sd-detail { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.sd-tip { color: var(--muted); font-size: .78rem; line-height: 1.45; overflow-wrap: anywhere; }
.sd-foot { margin: 12px 0 0; color: var(--muted); font-size: .84rem; line-height: 1.5; }

/* ---- Admin → Overview → System status: every brain problem is visible, calm and premium ---- */
.st-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 2px 0 12px; }
.st-bar .st-check { min-height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 600; font-size: .86rem; }
.st-bar .st-check:disabled { opacity: .6; }
.st-bar-note { color: var(--muted); font-size: .8rem; flex: 1 1 200px; min-width: 0; line-height: 1.4; }
@media (max-width: 720px) {
  .status-item { align-items: flex-start; flex-wrap: wrap; }
  .status-item .pill { margin-left: auto; }
}

/* ---- System status (Admin → Overview): one calm, evenly aligned list ----
   Every row — normal or tinted — has the same 14px inner padding and the same width as the notice above it, so nothing sticks out of the
   card any more (the old tinted rows used a negative margin, which made their edges and the notice's border look broken). Row dividers
   are inset hairlines (not borders), so a tinted row keeps a clean, fully rounded outline. */
#model-status .st-alert { display: flex; align-items: flex-start; gap: 13px; margin: 6px 0 20px; padding: 15px 16px; border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--danger) 34%, var(--line));
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 10%, var(--surface)), color-mix(in srgb, var(--danger) 5%, var(--surface)));
  box-shadow: none; }
#model-status .st-alert > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
#model-status .st-alert b { font-size: .98rem; font-weight: 650; letter-spacing: -.005em; color: var(--danger); }
#model-status .st-alert span { color: var(--muted); font-size: .86rem; line-height: 1.55; }
#model-status .st-ico { position: relative; flex: none; width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 15%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 22%, transparent); }
#model-status .st-ico::before { content: ""; position: absolute; inset: 0; background: var(--danger);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 8v5M12 16.5v.01'/%3E%3Cpath d='M10.3 3.9 2.4 17.5A2 2 0 0 0 4.1 20.5h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 8v5M12 16.5v.01'/%3E%3Cpath d='M10.3 3.9 2.4 17.5A2 2 0 0 0 4.1 20.5h15.8a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3C/svg%3E") center / 18px 18px no-repeat; }

#model-status .status-item { position: relative; margin: 0; padding: 13px 14px; border: 0; border-radius: 14px; }
#model-status .status-item:not(:last-child)::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 0; height: 1px; background: var(--line); opacity: .8; }
#model-status .status-item:last-child { padding-bottom: 13px; }
#model-status .status-item.is-bad, #model-status .status-item.is-warn { margin: 4px 0; }
#model-status .status-item.is-bad { background: color-mix(in srgb, var(--danger) 8%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 24%, transparent); }
#model-status .status-item.is-warn { background: color-mix(in srgb, var(--warn) 9%, var(--surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 24%, transparent); }
#model-status .status-item.is-bad::after, #model-status .status-item.is-warn::after,
#model-status .status-item:has(+ .is-bad)::after, #model-status .status-item:has(+ .is-warn)::after { display: none; }
#model-status .status-item.is-bad small b, #model-status .status-item.is-warn small b { color: var(--text); }
#model-status .status-item > div > b { font-weight: 650; }
#model-status .status-item small { margin-top: 3px; }
#model-status .st-raw { padding: 7px 10px; border-radius: 9px; background: color-mix(in srgb, var(--text) 5%, transparent); opacity: .8; }
