/* discussion.win — two-theme design system (light + dark).
   ═══════════════════════════════════════════════════════════════════════
   DECLARED CONTRACTS (for the app.js / navigation lanes — CSS is written
   against these hooks defensively; the page renders correctly whether or
   not JS has fired them yet):

   • <html data-theme="light"|"dark"> — explicit theme override. Set before
     first paint by the boot script in index.html, which reads localStorage
     "dw_theme" ("light" | "dark" | absent). Absent attribute = follow the
     system (prefers-color-scheme). The profile-page toggle lane writes the
     same key + attribute; it may also refresh the <meta name=theme-color>
     elements (values: light #E9ECE6, dark #141719).
   • <body class="mode-forum|mode-dm|no-mode"> — focus modes (app.js).
     mode-forum retints the canvas blue (the forum visual language);
     mode-dm / no-mode keep the neutral palette.
   • <body class="hdr-collapsed|left-collapsed"> — shell collapse toggles
     (desktop only; phones run the two-screen shell below).
   • <body class="m-contacts|m-chat"> — WeChat-nav screen shell (app.js
     sets these at EVERY width): m-contacts = the contacts home, the
     full-screen list a fresh open lands on; m-chat = the conversation
     screen with the back arrow (#m-back), screen title (#m-title) and
     (≤720px only) the room chip strip (#m-strip). Desktop keeps the
     contacts rail as a sidebar beside an open conversation.
   • #pd-theme — the profile-page Light / Dark control. It writes
     localStorage "dw_theme" = light|dark|system and applies data-theme
     live; a stored "system" selects neither chip and follows
     prefers-color-scheme until the user taps. The pre-paint boot script
     in index.html reads the same key.
   • #auth-panel.no-email — email form family hidden (Google-only auth).

   RUNTIME-STYLE OVERRIDE NOTE: app.js currently injects #dw-shell-styles,
   a legacy block of hard-coded dark colors for toasts, contact rows, the
     account menu, badges, dots, #dm-lockchip and #dw-join. Those selectors
   are re-declared below with a `body ` prefix (higher specificity) so the
   token system always wins. When the app.js lane retires that block, these
   rules keep working unchanged. Look for "runtime chrome overrides".

   COLOR RULE: every color in this file flows through the tokens below.
   The only literal color values allowed are inside token declarations.
   Exceptions living in tokens, not in rules: --letterbox #000 (video
   letterbox) and the Google button tokens (Google's light branding, kept
   identical in both themes per their guidelines). The vendored G-mark SVG
   brand colors live in app.js, not here.

   Contrast: every text/UI pairing was verified >= WCAG AA (4.5:1 body
   text, 3:1 UI components) in BOTH themes; see the table in the PR body.
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  color-scheme: light;

  /* ── light palette — WeChat-adjacent: gray-green canvas, white cards ── */
  --bg: #E9ECE6;             /* page canvas (chat + shell chrome) */
  --bg-forum: #E4EAF3;       /* mode-forum canvas: soft blue tint */
  --bg-telegram: #F4EDDC;    /* mode-telegram canvas: warm paper tint */
  --bg-elevated: #FFFFFF;    /* cards, menus, sheets, toasts */
  --panel: #F1F3EF;          /* inputs, inset surfaces */
  --panel-2: #E3E6DF;        /* secondary buttons, hover fills */
  --panel-active: #FFFFFF;   /* active tab / selected row */
  --bubble: #FFFFFF;         /* message bubbles */
  --border: #D9DDD4;         /* hairline */
  --border-strong: #C2C8BC;  /* control borders, track grooves */
  --border-focus: #64786A;   /* focus rings (>=3:1 on panel) */
  --fg: #1B1F1C;             /* body text */
  --fg-bright: #0E120F;      /* emphasized text, input text */
  --fg-muted: #47534B;       /* secondary text, button labels */
  --fg-muted-2: #525E56;     /* tertiary text */
  --fg-faint: #5C695A;       /* timestamps, muted labels (still AA) */
  --accent: #14804A;         /* the one accent: restrained green */
  --accent-hover: #0E6B41;
  --on-accent: #FFFFFF;
  --link: #0C5C38;           /* accent as text — darker to hold AA on canvas */
  --ok: #15703F;
  --ok-dim: #3D6B4F;
  --ok-bg: #E7F3EB;
  --ok-border: #BCD9C6;
  --ok-btn: #D9EDDF;
  --ok-btn-hover: #CBE4D4;
  --danger: #C22F2F;
  --badge-bg: #C22F2F;       /* unread / request badges */
  --badge-fg: #FFFFFF;
  --dot: #1E9E5A;            /* presence: online */
  --dot-off: #878E84;        /* presence: offline */
  --shadow: rgba(23, 32, 26, .16);
  --backdrop: rgba(22, 28, 24, .42);  /* modal scrims */
  --call-bar: rgba(12, 17, 15, .88);  /* video-call control bar */
  --swatch-border: rgba(20, 28, 23, .45);
  /* fixed-value tokens (identical in both themes by design) */
  --qr-bg: #FFFFFF;          /* QR needs light modules-on-white to scan */
  --letterbox: #000000;      /* video letterbox / unfetched video tiles */
  --tile-fg: #E8ECEA;        /* text over the letterbox */
  --g-btn-bg: #FFFFFF;       /* Google sign-in pill: Google's light branding */
  --g-btn-fg: #1F1F1F;
  --g-btn-border: #DADCE0;
  --g-btn-hover: #F8F9FA;

  /* Legacy-name aliases (declared once; they resolve lazily to whatever
     the active palette above sets). app.js's runtime-injected styles
     still use the pre-rework names --muted/--muted-2/--muted-3/--faint;
     new code should use the --fg-* names. */
  --muted: var(--fg-muted);
  --muted-2: var(--fg-muted-2);
  --muted-3: var(--fg-faint);
  --faint: var(--fg-faint);
}

/* Dark palette — true dark grays (never pure black), light-gray text
   hierarchy, the same green accent brightened for dark with near-black
   text on it. Declared twice: once as the prefers-color-scheme default,
   once as the explicit [data-theme] override. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #141719;
    --bg-forum: #101720;
    --bg-telegram: #211D12;
    --bg-elevated: #1C2023;
    --panel: #22262A;
    --panel-2: #2A2F33;
    --panel-active: #262C31;
    --bubble: #1E2226;
    --border: #272C31;
    --border-strong: #394046;
    --border-focus: #5F7563;
    --fg: #D5DAD7;
    --fg-bright: #ECF0ED;
    --fg-muted: #A7B0AB;
    --fg-muted-2: #98A29D;
    --fg-faint: #87918C;
    --accent: #2FBE72;
    --accent-hover: #43D389;
    --on-accent: #071510;
    --link: #58C98F;
    --ok: #7FD5A4;
    --ok-dim: #9CC9AB;
    --ok-bg: #12241A;
    --ok-border: #275038;
    --ok-btn: #1A3325;
    --ok-btn-hover: #214030;
    --danger: #FF9C9C;
    --badge-bg: #FF8080;
    --badge-fg: #230606;
    --dot: #3ECF8E;
    --dot-off: #6A746F;
    --shadow: rgba(0, 0, 0, .5);
    --backdrop: rgba(0, 0, 0, .6);
    --call-bar: rgba(10, 14, 12, .88);
    --swatch-border: rgba(236, 240, 237, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #141719;
  --bg-forum: #101720;
  --bg-elevated: #1C2023;
  --panel: #22262A;
  --panel-2: #2A2F33;
  --panel-active: #262C31;
  --bubble: #1E2226;
  --border: #272C31;
  --border-strong: #394046;
  --border-focus: #5F7563;
  --fg: #D5DAD7;
  --fg-bright: #ECF0ED;
  --fg-muted: #A7B0AB;
  --fg-muted-2: #98A29D;
  --fg-faint: #87918C;
  --accent: #2FBE72;
  --accent-hover: #43D389;
  --on-accent: #071510;
  --link: #58C98F;
  --ok: #7FD5A4;
  --ok-dim: #9CC9AB;
  --ok-bg: #12241A;
  --ok-border: #275038;
  --ok-btn: #1A3325;
  --ok-btn-hover: #214030;
  --danger: #FF9C9C;
  --badge-bg: #FF8080;
  --badge-fg: #230606;
  --dot: #3ECF8E;
  --dot-off: #6A746F;
  --shadow: rgba(0, 0, 0, .5);
  --backdrop: rgba(0, 0, 0, .6);
  --call-bar: rgba(10, 14, 12, .88);
  --swatch-border: rgba(236, 240, 237, .4);
}

/* Mode visual language: forum focus = blue-tinted canvas, a Telegram
   conversation (bridge chat open) = warm paper, private DM and no-mode =
   the neutral palette. One override retints the whole shell because every
   surface derives from these vars. */
body.mode-forum { --bg: var(--bg-forum); }
body.mode-telegram { --bg: var(--bg-telegram); }

* { box-sizing: border-box; }
/* The hidden attribute must always win: author display rules (e.g. the
   auth panel's display:flex) otherwise override the UA's [hidden] rule
   and leak login forms to signed-in users. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
input::placeholder, textarea::placeholder { color: var(--fg-muted); opacity: 1; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }

/* ── classic single-column page (pre-shell layout; harmless under #shell) */
main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 14px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
}
h1 { margin: 0; font-size: 18px; letter-spacing: .4px; }
/* The legacy header auth block (handle + Sign out / Sign in) is retired
   from every screen: account actions live on the profile page (profile
   lane) and sign-in lives in the you-block's .dw-signin / the Me tab.
   The child rules below stay — renderAuth still fills the node. */
body #auth { display: none; }
#auth .who {
  color: var(--ok); font-size: 12.5px; font-weight: 600; text-decoration: none;
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#auth .who:hover { text-decoration: underline; }
#auth button { flex: 0 0 auto; }
#auth button, #auth-panel button {
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#auth button:hover, #auth-panel button:hover { color: var(--fg-bright); border-color: var(--border-focus); }
#auth-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0 4px;
}
#auth-panel .row { display: flex; gap: 8px; }
/* Google-only mode (email auth disabled server-side): the email form
   family hides; the Google button above is the sign-in surface. */
#auth-panel.no-email #auth-email,
#auth-panel.no-email #auth-username,
#auth-panel.no-email .row { display: none; }
#auth-panel .row button { flex: 1; }
#auth-panel input {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  outline: none;
}
#auth-panel input:focus { border-color: var(--border-focus); }
#auth-panel button { background: var(--accent); border: none; color: var(--on-accent); font-weight: 600; padding: 9px 0; }
#auth-google-gsi { display: flex; justify-content: center; }
/* Our Google sign-in button (renderGoogleButton in app.js): Google's own
   renderButton labels itself in the browser locale — Khmer in Cambodia,
   Chinese in a zh webview — so we vendor the G mark and own the copy.
   White outlined pill per Google's light branding (kept in both themes;
   brand colors ride the --g-btn-* tokens). The FedCM/One Tap sheet the
   click opens is browser-native and follows the device locale; that
   surface is the browser's, not ours. */
.gbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--g-btn-bg); color: var(--g-btn-fg);
  border: 1px solid var(--g-btn-border); border-radius: 999px;
  padding: 7px 16px; font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
}
.gbtn:hover { background: var(--g-btn-hover); }
.gbtn svg { width: 18px; height: 18px; display: block; }
/* Phone-width corner: our own 32px G icon button (aria-label carries the
   full "Continue with Google"). */
.gbtn.gbtn-icon { width: 32px; height: 32px; padding: 0; gap: 0; }
.gbtn.gbtn-icon svg { width: 20px; height: 20px; }
#auth-panel button.ghost, #auth button.ghost { background: var(--panel-2); border: 1px solid var(--border-strong); color: var(--fg-muted); font-weight: 400; }
#auth-status { margin: 0; color: var(--fg-muted-2); font-size: 12.5px; min-height: 16px; }
#auth-status a { color: var(--ok); }

#tabs { display: flex; gap: 6px; padding: 10px 0 0; }
#tabs .tab {
  background: var(--panel);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px 8px 0 0;
  border-bottom: none;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#tabs .tab.active {
  background: var(--panel-active);
  color: var(--fg-bright);
  border-color: var(--border-focus);
  font-weight: 600;
}
#tabs .tab:hover { color: var(--fg-bright); }
#presence { margin: 8px 0 0; color: var(--fg-faint); font-size: 11.5px; min-height: 0; }
#tabs .tab.home { color: var(--fg-faint); font-size: 12px; }

/* ---- WeChat-nav mobile pieces (hidden on desktop) -------------------
   #m-back / #m-title: the chat screen's header guests. #m-strip: the
   room chip strip row (chat screen only, ≤720px block below shows it). */
#m-back, #m-title, #m-strip { display: none; }
#m-back {
  background: none; border: 0; color: var(--fg-muted); font: inherit;
  font-size: 26px; line-height: 1; padding: 2px 8px 4px 2px;
  cursor: pointer; flex: none; margin-left: calc(-4px - env(safe-area-inset-left));
}
#m-back::after { content: "‹"; }
#m-back:hover { color: var(--fg-bright); }
#m-title {
  font-size: 15px; font-weight: 700; color: var(--fg-bright);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
/* Mobile room strip chips (WeChat header): the same tab look, rounded all
   round and padded for thumbs, riding the strip row under the header. */
#m-strip .tab {
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 13px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
#m-strip .tab.active {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
  font-weight: 600;
}
#m-strip .dm-tab { font-weight: 600; }
#m-strip #channel-create { display: flex; gap: 4px; align-items: center; flex: none; }
#m-strip #channel-create input {
  width: 104px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  outline: none;
}
#m-strip #channel-create button {
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
#m-strip #tab-add { min-width: 34px; }
#channel-create { display: flex; gap: 4px; align-items: center; padding-top: 4px; }
#channel-create input {
  width: 110px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}
#channel-create button {
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

#servers { padding: 12px 0 4px; border-bottom: 1px solid var(--border); }
#servers h2 { margin: 0 0 8px; font-size: 13px; color: var(--fg-faint); text-transform: lowercase; letter-spacing: .5px; }
#server-list { display: flex; flex-direction: column; gap: 4px; }
#server-list .server-link { color: var(--fg-muted); text-decoration: none; font-size: 13px; }
#server-list .server-link:hover { color: var(--fg-bright); text-decoration: underline; }
#server-list .none { color: var(--fg-faint); font-size: 12.5px; font-style: italic; }

#welcome {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--ok-border);
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 13.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#welcome .sub { color: var(--ok-dim); font-size: 11.5px; line-height: 1.5; }
#welcome button {
  align-self: flex-start;
  margin-top: 4px;
  background: var(--ok-btn);
  color: var(--ok);
  border: 1px solid var(--ok-border);
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#welcome button:hover { background: var(--ok-btn-hover); }

.msg .verb { color: var(--fg-muted-2); font-size: 11px; font-style: italic; }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 2px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
/* Message bubbles: tinted surfaces over the canvas, strong text contrast
   in both themes (light: white cards on the gray-green canvas; dark:
   raised gray over the deeper canvas). */
.msg {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline;
  background: var(--bubble);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
}
.msg .name { font-weight: 600; font-size: 13.5px; }
.msg .time { color: var(--fg-faint); font-size: 11px; }
.msg .text { flex: 1; min-width: 60%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.pending { opacity: .5; }
.msg.pending .text::after {
  content: " · sending…";
  color: var(--fg-muted-2);
  font-size: 11px;
  font-style: italic;
}
/* Encrypted row the client filter refuses to show: name and time stay, the
   body is the hidden placeholder — no reveal toggle in v1. */
.msg.blocked .text { color: var(--fg-faint); font-style: italic; }
.empty { color: var(--fg-faint); font-style: italic; align-self: center; margin-top: 40px; }

#error { margin: 0 0 8px; color: var(--danger); font-size: 13px; min-height: 17px; }

#composer {
  display: flex;
  gap: 8px;
  padding: 10px 0 calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}
#name { width: 130px; }
#input { flex: 1; min-width: 0; }
#name, #input {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
  outline: none;
}
#name:focus, #input:focus { border-color: var(--border-focus); }
#composer button {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#composer button:hover { background: var(--accent-hover); }

@media (max-width: 560px) {
  #name { width: 96px; }
  #composer { flex-wrap: wrap; }
  #name { flex: 1; }
  #input { flex-basis: 100%; }
  #composer button { flex-basis: 100%; }
  /* Recording takes the whole row: name + conversation buttons already fill
     the first line, and the bar's controls cannot shrink below content.
     Double id: the voice-bar section below re-declares flex:1 with a plain
     id, so the media override needs to outrank it by order AND id count. */
  #composer #voice-bar { flex-basis: 100%; }
}

#profile { padding: 12px 0; display: flex; flex-direction: column; gap: 14px; }
/* While a profile page is showing (body.dw-profile): the chat-screen room
   strip — and its "+" — leaves (it is chat chrome, not profile chrome),
   and the back arrow owns the way out. The old "← discussion.win" link is
   retired at EVERY width (the <a> carries an inline display; !important
   beats it). */
body.dw-profile #m-strip { display: none !important; }
#profile > .home { display: none !important; }
/* The profile header — one elevated card, symmetric: a single centered
   column (photo over name over handle over metadata over the QR block);
   no side columns, no asymmetric bands. */
#profile-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg-elevated); border-radius: 12px; padding: 22px 16px 18px;
  box-shadow: 0 1px 3px var(--shadow);
  text-align: center;
}
.pd-head { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
#profile-card .pd-name { font-size: 23px; font-weight: 700; color: var(--fg-bright); /* readableTextColor paints over this when a hex is set */ }
#profile-card .pd-handle { color: var(--fg-faint); font-size: 13.5px; }
/* Handle + copy chip + theme flip on one centered row (the flip rides
   the own profile's card only) */
.pd-handle-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.pd-theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--panel-2); border: 1px solid var(--border-strong);
  color: var(--fg-muted); cursor: pointer; padding: 0;
}
.pd-theme-toggle:hover { color: var(--fg-bright); border-color: var(--border-focus); }
.pd-copy {
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 3px 10px;
  font: inherit;
  font-size: 11.5px;
  line-height: 1.4;
  cursor: pointer;
}
.pd-copy:hover { color: var(--fg-bright); border-color: var(--border-focus); }
/* Add-contact action on someone else's profile (the landing point of a
   username click): accent button while not a contact, settled chip after. */
.pd-add-row { display: flex; justify-content: center; margin-top: 4px; }
.pd-add {
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.pd-add:hover { background: var(--accent-hover); }
.pd-add:disabled { opacity: .6; cursor: default; }
.pd-contact-chip { color: var(--ok); font-size: 12.5px; }
#profile-card .pd-joined { color: var(--fg-faint); font-size: 11.5px; }
#profile-card .pd-bio { margin-top: 8px; max-width: 34em; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
#profile-card a { color: var(--link); word-break: break-all; }
/* Avatar inner markup (shared by every photo box): the image fills its
   box (cover), or the silhouette span centers a quiet person. The box
   itself owns size/radius — the 38px contact row, the 64px profile
   header, the editor preview. */
.c-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.c-avatar-none {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-muted);
}
.c-avatar-svg { width: 62%; height: 62%; }
/* Profile header photo: centered above the display name, as public as it */
#profile-card .pd-photo {
  width: 80px; height: 80px; border-radius: 20px; overflow: hidden; flex: none;
  background: var(--panel-2);
}
/* Editor photo block: preview beside the picker + remove */
.pe-photo { display: flex; align-items: center; gap: 12px; }
.pe-photo #pe-photo-preview {
  width: 64px; height: 64px; border-radius: 14px; overflow: hidden; flex: none;
  background: var(--panel-2);
}
.pe-photo-side { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.pe-photo-label { font-size: 12.5px; color: var(--fg-muted); font-weight: 600; }
#profile-edit input[type="file"] { padding: 4px; font-size: 12px; color: var(--fg-muted); }
#profile-edit #pe-photo-remove {
  background: var(--panel-2); color: var(--fg-muted);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: 4px 10px; font-size: 11.5px; font-weight: 400;
}
/* ── Settings group (app.js gathers #pd-theme + #profile-edit here) ────
   One panel under the card, WeChat settings-list language: hairline
   separators between rows, labels left, controls right, full width —
   not a form floating in a column. The account rows (.pd-actions) are a
   second panel of the same shape. */
.pd-settings, .pd-actions {
  display: flex; flex-direction: column;
  background: var(--bg-elevated); border-radius: 12px;
  box-shadow: 0 1px 3px var(--shadow);
}
.pd-settings > :not([hidden]) + :not([hidden]) { border-top: 1px solid var(--border); }
/* Theme row (the runtime-injected .pd-theme look yields to the group:
   #profile-scoped rules outrank the bare-class injection). */
#profile .pd-theme {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 13px 16px; border: 0; border-radius: 0; background: none; max-width: none;
}
/* Notifications row (own profile, quick settings beside the theme
   control): label left, live state + one switch right. The tap on the
   switch is the user gesture the permission prompt requires; on turns
   it off through the real unsubscribe path. Green while on, grey while
   off — hidden entirely where no action exists (blocked/unavailable). */
.pd-notif-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; min-width: 0;
}
.pd-notif-label { font-size: 15px; font-weight: 500; color: var(--fg); flex: none; }
.pd-notif-state {
  margin-left: auto; color: var(--fg-faint); font-size: 13px;
  text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pd-notif-state.ok { color: var(--ok); }
.pd-notif-state.warn { color: var(--danger); }
.pd-notif-switch {
  flex: none; position: relative; width: 44px; height: 26px; padding: 0;
  border-radius: 13px; border: 1px solid var(--border-strong);
  background: var(--panel-2); cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.pd-notif-switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  transition: left .15s ease;
}
.pd-notif-switch[aria-checked="true"] { background: var(--ok); border-color: var(--ok); }
.pd-notif-switch[aria-checked="true"]::after { left: auto; right: 2px; }
.pd-notif-switch:disabled { opacity: .6; cursor: default; }
/* Picture-quality row (own profile, quick settings): the muted section
   title on its own line, the SD/HD/FHD segmented control under it on one
   non-wrapping row (it scrolls horizontally if a phone is narrower than
   the trio). Every rung — FHD included — is selectable: no paid gate. */
.pd-picture-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  padding: 12px 16px; min-width: 0;
}
.pd-picture-label {
  flex-basis: 100%; font-size: 13px; font-weight: 600; color: var(--fg-muted);
}
.pd-picture-seg {
  display: inline-flex; max-width: 100%; overflow-x: auto; white-space: nowrap;
  border: 1px solid var(--border-strong); border-radius: 8px;
}
.pd-picture-btn {
  background: var(--panel-2); color: var(--fg-muted); border: 0;
  border-right: 1px solid var(--border); padding: 6px 12px;
  font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.pd-picture-btn:last-child { border-right: 0; }
.pd-picture-btn.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
#profile-edit { display: flex; flex-direction: column; max-width: none; }
#profile-edit > * + * { border-top: 1px solid var(--border); }
#profile-edit > * { padding: 12px 0; }
#profile-edit .pe-photo { justify-content: space-between; }
#profile-edit .pe-color { gap: 6px; }
#profile-edit .pe-color-controls { justify-content: space-between; }
#profile-edit .pe-color-label, #profile-edit .pe-photo-label, #profile-edit .pe-row-label {
  font-size: 15px; font-weight: 500; color: var(--fg);
}
#profile-edit .row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#profile-edit .row #pe-save { flex: 1; }
#profile-edit input, #profile-edit textarea {
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--fg-bright);
  border-radius: 8px; padding: 9px 11px; font: inherit; outline: none; resize: vertical;
}
#profile-edit input:focus, #profile-edit textarea:focus { border-color: var(--border-focus); }
#profile-edit button {
  background: var(--accent); border: 0; color: var(--on-accent); border-radius: 8px;
  padding: 9px 0; font: inherit; font-weight: 600; cursor: pointer;
}
/* Account rows (own profile only): quiet full-width rows; sign out is a
   danger label, not an accent button. */
.pd-actions > .pd-action-row + .pd-action-row { border-top: 1px solid var(--border); }
.pd-action-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; padding: 13px 16px;
  font: inherit; font-size: 15px; color: var(--fg); cursor: pointer; text-align: left;
}
.pd-action-row .pd-req-count { margin-left: auto; }
.pd-signout-row { color: var(--danger); }
/* Inline request list under the "Contact requests" row — the same
   m-head / m-row markup the account menu builds (buildRequestRows), so
   it needs the menu's row look restated in this scope. */
.pd-req-list { display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--border); }
.pd-req-list .m-head { color: var(--fg-muted); font-size: 11.5px; text-transform: lowercase; letter-spacing: .5px; }
.pd-req-list .m-none { color: var(--fg-faint); font-style: italic; }
.pd-req-list .m-row { display: flex; align-items: center; gap: 6px; }
.pd-req-list .m-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pd-req-list button {
  background: var(--panel-2); color: var(--fg-muted); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 4px 9px; font: inherit; font-size: 11.5px; cursor: pointer;
}
.pd-req-list button.primary { background: var(--accent); color: var(--on-accent); border: 0; font-weight: 600; }

/* Telegram & contact-backup settings sections (render only while the
   server advertises the feature): the head row is the Notifications row
   language; the body rows stack under it. */
.pd-tg, .pd-backup { display: flex; flex-direction: column; }
.tg-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 16px 14px; min-width: 0; }
.tg-link { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tg-linked { color: var(--fg-muted); font-size: 13px; }
.tg-code-panel { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.tg-code-line { color: var(--fg-muted-2); font-size: 13px; line-height: 1.5; }
.tg-code {
  font: 600 20px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--fg-bright); background: var(--panel);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 14px;
  letter-spacing: 2px; user-select: all;
}
.tg-open { text-decoration: none; display: inline-block; }
.tg-field { display: flex; align-items: center; gap: 8px; }
.tg-field > span { font-size: 13px; color: var(--fg-muted); flex: none; }
.tg-field input {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--border-strong);
  color: var(--fg-bright); border-radius: 8px; padding: 7px 10px; font: inherit;
  font-size: 13px; outline: none;
}
.tg-field input:focus { border-color: var(--border-focus); }
.tg-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--fg); cursor: pointer; }
.tg-check input { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.tg-note { margin: 0; color: var(--fg-faint); font-size: 12.5px; line-height: 1.5; }
.tg-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Profile color picker row: swatches + native picker + hex field, with a
   live sample of the display name and the inline validation message. */
.pe-color { display: flex; flex-direction: column; gap: 6px; }
.pe-color .row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pe-color-label { font-size: 12.5px; color: var(--fg-faint); }
#pe-swatches { display: flex; gap: 5px; flex-wrap: wrap; }
#pe-swatches button {
  width: 22px; height: 22px; border-radius: 6px; padding: 0;
  border: 1px solid var(--swatch-border); cursor: pointer;
}
#pe-swatches button.sel { outline: 2px solid var(--fg-bright); outline-offset: 1px; }
#pe-picker {
  width: 36px; height: 34px; padding: 2px 4px; cursor: pointer; flex: none;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel);
}
#pe-hex { width: 96px; flex: none; text-transform: lowercase; }
.pe-color-meta { min-height: 18px; }
#pe-color-sample { font-weight: 600; font-size: 13.5px; }
#pe-color-err { color: var(--danger); font-size: 12px; }
a.msg-name { text-decoration: none; font-weight: 600; }
a.msg-name:hover { text-decoration: underline; }

.msg .text img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  display: block;
  margin-top: 4px;
  border: 1px solid var(--border);
}

/* ── app shell ────────────────────────────────────────────────────────
   #shell: header row (auto) over #left (250px) + #main (1fr); phones
   stack the contacts rail as a bounded slab under the header. */

#shell {
  display: grid;
  height: 100dvh;
  grid-template-rows: auto 1fr;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "hdr hdr" "left main";
}

/* Header row — the shell chrome follows the canvas color (WeChat-style
   unified chrome; mode-forum retints it with everything else). */
#hdr {
  grid-area: hdr;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
#you-block { display: flex; align-items: center; gap: 8px; flex-shrink: 0; min-width: 0; }
/* The ☰ is retired from every screen (the menu's requests, rename and
   sign-out move to the profile page — profile lane). The node stays in
   the DOM: its contents (renderYouMenuContents, the rename form) are
   still owned by JS. body-prefixed so no media rule can re-show it. */
body #you-menu { display: none; }
#req-badge {
  background: var(--badge-bg); color: var(--badge-fg); font-size: 10.5px; font-weight: 700;
  border-radius: 999px; min-width: 16px; height: 16px; line-height: 16px;
  text-align: center; padding: 0 4px;
}
#hdr #tabs {
  flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden;
  align-items: flex-end;
  /* headroom so a tab's absolutely-positioned unread badge (-6px) renders
     inside the padding box instead of being clipped by overflow-y:hidden */
  padding: 6px 0 0; scrollbar-width: thin;
}
/* Identity block sizes to its content and may shrink; the handle
   ellipsizes inside, so the Sign out button never overflows into the
   request badge. A max-width keeps a long handle from eating the tabs
   lane. */
#hdr #you-block { flex: 0 1 auto; max-width: 320px; align-self: center; }
/* The handle link is the shrinkable piece: long names ellipsize instead of
   overflowing the header (and panning the whole page sideways). Shrink
   factor 100 makes it yield before anything else — the unshrinkable Sign
   out button keeps its width and never slides under the request badge. */
#you-block .who-slot {
  flex: 0 100 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ok);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
}
#you-block .who-slot:hover { text-decoration: underline; }
#you-block .dw-signin { flex: 0 0 auto; }
#tabs .tab { flex: 0 0 auto; white-space: nowrap; }
#hdr #tabs::-webkit-scrollbar { height: 4px; }
#hdr #tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
#hdr #tabs::-webkit-scrollbar-track { background: transparent; }
/* Google one-click sign-in lives at the header's top-right: our own
   English pill (or the 32px G icon on phones) — .gbtn above.
   Empty + hidden until initGsi renders into it. */
#gsi-corner { flex-shrink: 0; display: flex; align-items: center; margin-left: 6px; }
/* Returning Google users: personalized pill ("Continue as <name>")
   instead of the generic branded button. */
#gsi-corner #gsi-as {
  background: var(--panel); color: var(--fg-muted); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 12.5px;
  cursor: pointer; white-space: nowrap; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis;
}
#gsi-corner #gsi-as:hover { color: var(--fg-bright); border-color: var(--border-focus); }
#collapse-hdr {
  position: absolute; left: 0; right: 0; bottom: 0; height: 14px;
  background: transparent; border: none; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
#collapse-hdr::after {
  content: "↑"; display: block; width: auto; height: auto;
  font-size: 13px; line-height: 1; color: var(--fg-muted);
}
#collapse-hdr:hover::after { color: var(--fg-bright); }

/* Bare expand strip while the header is collapsed: no title, no buttons
   — the header's space goes to the chat. The whole strip restores. */
#hdrbar {
  grid-area: hdr;
  display: none; align-items: center; justify-content: center;
  height: 14px; padding: env(safe-area-inset-top) 0 0; background: var(--bg);
  border-bottom: 1px solid var(--border); cursor: pointer;
  font-size: 13px; font-weight: 600;
}
body.hdr-collapsed #hdr { display: none; }
body.hdr-collapsed #hdrbar { display: flex; }
#hdrbar::after { content: "↓"; font-size: 13px; line-height: 1; color: var(--fg-muted); }
#hdrbar:hover::after { color: var(--fg-bright); }
/* Server focus keeps an identity bar: room name + join affordance. */
body.mode-forum #hdrbar {
  display: flex; height: auto; justify-content: flex-start; gap: 10px;
  padding: calc(5px + env(safe-area-inset-top)) 14px 5px; cursor: default;
}
body.mode-forum #hdrbar::after { content: none; }
#hdrbar-title {
  display: none; font-size: 12.5px; color: var(--fg-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  min-width: 0; flex: 0 1 auto; /* long server names ellipsize, Join stays */
}
body.mode-forum #hdrbar-title { display: inline; }
/* A Telegram thread keeps the same identity-bar shape as a forum focus. */
body.mode-telegram #hdrbar {
  display: flex; height: auto; justify-content: flex-start; gap: 10px;
  padding: calc(5px + env(safe-area-inset-top)) 14px 5px; cursor: default;
}
body.mode-telegram #hdrbar::after { content: none; }
body.mode-telegram #hdrbar-title { display: inline; }

/* Contacts rail */
#left-wrap { grid-area: left; display: flex; min-width: 0; }
#left {
  width: 250px; flex-shrink: 0; display: flex; flex-direction: column;
  gap: 8px; padding: 12px 10px; overflow-y: auto; overflow-x: hidden;
  background: var(--bg);
  border-right: 1px solid var(--border);
  position: relative;
  transition: width .18s ease;
}
/* Collapsed rail (desktop) / collapsed slab (phones): same rule serves both. */
body.left-collapsed #left {
  width: 0;
  padding-left: 0;
  padding-right: 0;
  border-right: 0;
  overflow: hidden;
}
#contacts-signin {
  margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--fg-muted-2);
  border: 1px dashed var(--border-strong); border-radius: 8px; padding: 10px;
}
/* Contacts home header: "Chat" on the left, a bare search icon, then a
   bare "+" on the right (WeChat's title row — icons only, no boxes).
   The + menu and the add form are app.js-built; this row is the anchor
   surface for both. Signed out, the two icons hide and only the title
   (above the sign-in line) remains. */
#contacts-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 6px;
  padding: 0 2px 10px;
  overflow: hidden; /* clips the search row while it is slid up */
  flex: none;
}
#contacts-title {
  font-size: 15px; font-weight: 700; color: var(--fg-bright);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Bare icon buttons: ~28px glyph, transparent, borderless; the hit area
   comes from padding (≥44px), not from a visible box. */
#contacts-head .ch-btn {
  min-width: 44px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--fg-muted); font: inherit; font-size: 28px; line-height: 1;
  cursor: pointer; padding: 0 2px;
}
#contacts-head .ch-btn:hover { color: var(--fg-bright); }
#contacts-plus { font-size: 28px; font-weight: 500; line-height: 1; }
/* Search field: slides down from under the header row (~150ms). Closed,
   it is translated up behind the title row and clipped; the negative
   margin keeps its space collapsed so the list never shifts. */
#contacts-searchrow {
  --csr-h: 42px;
  grid-column: 1 / -1;
  display: flex;
  height: var(--csr-h);
  margin-bottom: calc(-1 * var(--csr-h));
  transform: translateY(-101%);
  visibility: hidden;
  transition: transform .15s ease, margin-bottom .15s ease, visibility 0s .15s;
}
#contacts-head.search-open #contacts-searchrow {
  margin-bottom: 0;
  transform: none;
  visibility: visible;
  transition: transform .15s ease, margin-bottom .15s ease;
}
#contacts-search-input {
  flex: 1; min-width: 0;
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--fg-bright);
  border-radius: 8px; padding: 7px 11px; font: inherit; font-size: 13px; outline: none;
}
#contacts-search-input:focus { border-color: var(--border-focus); }
#contacts-list { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 0; }
#collapse-left {
  flex-shrink: 0; width: 14px; display: flex; align-items: center;
  justify-content: center; background: transparent; border: none;
  border-left: 1px solid var(--border); cursor: pointer; padding: 0;
  position: static;
}
#collapse-left::after {
  content: "‹"; width: auto; height: auto; font-size: 14px;
  line-height: 1; color: var(--fg-muted);
}
body.left-collapsed #collapse-left::after { content: "›"; }
#collapse-left:hover::after { color: var(--fg-bright); }

/* Center column: this file owns `main`; the shell owns its height.
   Undoes the classic centered-page sizing above (the shell spans it). */
#main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: auto;
  max-width: none;
  margin: 0;
  padding: 0 14px;
}

/* New composer pieces (direct-message mode) */
#dm-mode {
  background: var(--panel); color: var(--fg-muted); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 0 10px; font: inherit; font-size: 12px;
  cursor: pointer; align-self: stretch; white-space: nowrap;
}
#dm-mode:hover { color: var(--fg-bright); border-color: var(--border-focus); }

/* New profile field */
#pe-default-mode {
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--fg-bright);
  border-radius: 8px; padding: 9px 11px; font: inherit; outline: none;
  width: max-content;
}

/* ── contacts, presence, badges ─────────────────────────────────────── */
/* runtime chrome overrides — see the contract block at the top of this
   file: these body-prefixed rules out-specify the legacy dark block that
   app.js injects as #dw-shell-styles. */
.contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--fg-muted);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.contact-row:hover { background: var(--panel); color: var(--fg-bright); }
.contact-row.pending { opacity: .45; cursor: default; }
.contact-row.pending::after { content: "⌛"; margin-left: auto; font-size: 12px; }

body #contacts-list .contact {
  position: relative; display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; color: var(--fg); padding: 7px 8px;
  border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; text-align: left;
}
body #contacts-list .contact:hover { background: var(--panel); }
body #contacts-list .contact.active { background: var(--panel-active); outline: 1px solid var(--border-focus); }
body #contacts-list .contact .c-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The name is the profile affordance inside a row whose click opens the
   DM — underline says so without a second chrome element. */
body #contacts-list .contact .c-name:hover { text-decoration: underline; }
body #contacts-list .contact.pending { opacity: .55; }
body #contacts-list .contact .hourglass { font-size: 11px; flex: none; }
body #contacts-list .contacts-empty { color: var(--fg-faint); font-size: 12.5px; font-style: italic; padding: 6px 8px; }
body #contacts-list .add-form { display: flex; gap: 6px; padding: 6px 4px; }
body #contacts-list .add-form input {
  flex: 1; min-width: 0; background: var(--panel); border: 1px solid var(--border-strong);
  color: var(--fg-bright); border-radius: 7px; padding: 6px 9px; font: inherit;
  font-size: 12.5px; outline: none;
}
body #contacts-list .add-form input:focus { border-color: var(--border-focus); }
body #contacts-list .add-form button {
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: 7px;
  padding: 6px 10px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
}
/* Telegram chats (bridge list): the same contact-row shape under a small
   section head; the "Also on this app" pill rides the name line. */
body #contacts-list .tg-list-head {
  padding: 12px 8px 2px; color: var(--fg-faint); font-size: 11.5px;
  text-transform: lowercase; letter-spacing: .5px;
}
/* Swipe-left chat actions (contacts home, touch): the row slides aside
   over the hidden action strip — Profile and the red trash. The trash is
   device-local list removal, never a server delete. */
.c-swipe { position: relative; overflow: hidden; }
body #contacts-list .c-swipe .contact {
  position: relative; z-index: 1;
  transition: transform .18s ease;
}
body #contacts-list .c-swipe .contact.swiping { transition: none; }
.c-swipe-acts {
  position: absolute; top: 0; right: 0; bottom: 0;
  display: flex; z-index: 0;
  /* Hidden until the row is open or mid-drag: the row button is
     transparent, so an always-visible strip would shine through every
     closed row (and leak onto desktop, where rows never move). */
  visibility: hidden;
}
.c-swipe.open .c-swipe-acts,
.c-swipe.dragging .c-swipe-acts { visibility: visible; }
.c-swipe-acts .sw-act {
  width: 76px; border: 0; padding: 0; font: inherit; font-size: 12.5px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.c-swipe-acts .sw-profile { background: var(--panel-active); color: var(--fg-bright); }
.c-swipe-acts .sw-del { background: var(--danger); color: #fff; font-weight: 600; }
/* The delete confirm rides the shared dw-menu; the red button marks the
   destructive half, and the note says what the action does not do. */
body .dw-menu .sw-note { color: var(--fg-muted); font-size: 12px; }
body .dw-menu button.sw-yes { background: var(--danger); color: #fff; border: 0; font-weight: 600; }
.tg-also {
  flex: none; font-size: 10.5px; font-weight: 600; color: var(--fg-muted);
  background: var(--panel-2); border-radius: 999px; padding: 1px 7px; white-space: nowrap;
}
/* The thread subtitle chip ("Telegram") on the conversation titles. */
.tg-chip {
  display: inline-block; margin-left: 8px; padding: 1px 8px; font-size: 10.5px;
  font-weight: 600; letter-spacing: .3px; color: var(--fg-muted); background: var(--panel);
  border: 1px solid var(--border-strong); border-radius: 999px; vertical-align: 1px;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dot);
  margin-left: auto;
  flex: 0 0 auto;
}
.dot-stale { display: none; }
body .dot { background: var(--dot-off); }
body .dot.on { background: var(--dot); }

/* Unread / request badge. The "99+" cap is applied by JS to the text. */
.badge, #req-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-fg);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex: 0 0 auto;
}
body .badge {
  background: var(--badge-bg); color: var(--badge-fg);
  border-radius: 9px; font-size: 10.5px; font-weight: 700; line-height: 1;
  padding: 3px 6px; flex: none;
}
body .tab { position: relative; }
body .tab .badge { position: absolute; top: -6px; right: -6px; }

/* ── toasts ─────────────────────────────────────────────────────────── */
/* runtime chrome override (see contract): bottom-right stack, themed. */
#toast-root {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); z-index: 1000; display: flex;
  flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 24px));
  padding: calc(8px + env(safe-area-inset-top)) 12px 12px;
  pointer-events: none;
}
body #toast-root {
  top: auto; left: auto; bottom: calc(16px + env(safe-area-inset-bottom));
  right: 16px; transform: none; width: auto;
  max-width: min(340px, calc(100vw - 24px)); padding: 0; z-index: 60;
}
.toast, body .toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 8px 24px var(--shadow);
  font-size: 13px;
  /* slide up on entry, hold, fade out by ~6s; JS removes the node */
  animation: dw-toast-in .22s ease, dw-toast-out .6s ease 5.4s forwards;
}
body .toast .t-msg { flex: 1; min-width: 0; }
.toast .toast-actions { display: flex; gap: 6px; margin-left: auto; }
.toast button {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.toast button:hover { color: var(--fg-bright); border-color: var(--border-focus); }
body .toast .t-btn {
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: 7px;
  padding: 5px 10px; font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
body .toast .t-x { background: none; border: 0; color: var(--fg-muted); cursor: pointer; font-size: 15px; padding: 2px 4px; }
@keyframes dw-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes dw-toast-out {
  to { opacity: 0; }
}

/* ── DM extras ──────────────────────────────────────────────────────── */
/* 32px ghost icon button beside Send (overrides the composer's accent
   button styling via the double id). */
#composer #dm-mode {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--fg-muted);
  font: inherit;
  cursor: pointer;
}
#composer #dm-mode:hover {
  background: transparent;
  color: var(--fg-bright);
  border-color: var(--border-focus);
}

/* Encrypted-conversation chip: the lock glyph comes from ::before; the
   element's own text is just the word "encrypted". Double id also keeps
   it ahead of app.js's legacy injected rule. */
#composer #dm-lockchip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--ok-border);
  border-radius: 999px;
  color: var(--ok);
  background: var(--ok-bg);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  align-self: center;
}
#composer #dm-lockchip::before { content: "🔒"; font-size: 10px; }
body #dm-lockchip { display: inline-flex; align-items: center; gap: 4px; color: var(--ok); font-size: 11.5px; }

/* ── screen model at every width (contacts home ⇄ conversation) ───────
   The two-screen shell is no longer phone-only. m-contacts is the
   signed-in home at ANY width: main stays hidden until a conversation,
   a forum, or a profile opens (m-chat). On m-chat the desktop keeps the
   contacts rail as a sidebar beside main; the phone block below swaps
   to a single column and hides the rail instead. The back arrow
   (#m-back) and screen title (#m-title) are m-chat chrome at every
   width. The contacts-home grid re-layout is desktop-only (min-width
   below): the phone block's #shell grid already fills its single
   column, and a higher-specificity override here would out-rank it. */
body.m-contacts #shell > main { display: none; }
body.m-chat #m-back { display: block; }
body.m-chat #m-title { display: block; flex: 0 1 auto; margin-right: 8px; }
/* The screen title names a person only in a DM — tapping it then opens
   their profile (app.js toggles the class). */
#m-title.t-profile, #hdrbar-title.t-profile { cursor: pointer; }
#m-title.t-profile:hover, #hdrbar-title.t-profile:hover { text-decoration: underline; }

/* Contacts home = WeChat's chat list, at every width. #hdr has nothing
   to say on this screen (no ☰, no Sign out, no back arrow), so it never
   stacks a second bar above the list header: #contacts-head is the only
   top row. The list itself goes full-bleed — no inset cards, hairline
   dividers between rows. Scoped to m-contacts so the desktop
   conversation sidebar (body.m-chat #left) keeps its inset rail. */
body.m-contacts #hdr { display: none; }
body.m-contacts #left {
  padding-left: 0;
  padding-right: 0;
  gap: 0;
}
body.m-contacts #contacts-head { padding: 0 16px 8px; }
body.m-contacts #contacts-signin { margin: 4px 16px 12px; }
body.m-contacts #contacts-list { gap: 0; }
body.m-contacts #contacts-list .contact {
  padding: 12px 16px;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}
body.m-contacts #contacts-list .contact:hover { background: var(--panel-2); }
body.m-contacts #contacts-list .contact.active { background: var(--panel-2); outline: none; }
body.m-contacts #contacts-list .contacts-empty { padding: 10px 16px; }
body.m-contacts #contacts-list .add-form { padding: 8px 16px; }

@media (min-width: 721px) {
  /* Contacts home on a wide screen: the list fills the shell — one
     column, no rail border, no collapse strip. */
  body.m-contacts #shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "hdr" "left";
  }
  body.m-contacts #left { width: 100%; border-right: none; }
  body.m-contacts #collapse-left { display: none; }
  /* Back control on a wide screen matches the phone's big target: a
     48px box with a 34px glyph (~3× the old 26px hit area). */
  body.m-chat #m-back {
    display: inline-flex;
    align-items: center;
    min-width: 48px;
    min-height: 48px;
    padding: 0 10px 0 2px;
    font-size: 34px;
    line-height: 1;
  }
}

/* ── mobile shell (<=720px): the WeChat two-screen shell ─────────────
   Two screens, one grid: a contacts screen (the fresh-open default) and
   a conversation screen. body.m-contacts / body.m-chat (set by app.js
   at every width — see the all-width rules above) pick which screen
   fills the content row; #hdr swaps its contents to match — account
   corner on contacts, back arrow + title on chat. The room strip
   (#m-strip) is the chat screen's second header row. Phones hide the
   contacts rail entirely on m-chat (desktop keeps it as a sidebar). */
@media (max-width: 720px) {
  #shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "hdr" "strip" "content";
  }
  #m-strip { grid-area: strip; }
  #left-wrap, #shell > main { grid-area: content; }
  #hdr { padding: 6px 10px 8px; padding-top: max(6px, env(safe-area-inset-top)); }

  /* Screen swap. Only one of the two is ever displayed. (Hiding main on
     m-contacts is the all-width rule above; here the phone additionally
     hides the rail on m-chat — one column, no sidebar.) */
  body.m-chat #left-wrap { display: none; }
  body.m-chat #m-strip {
    display: flex;
    gap: 6px; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
    padding: 6px 10px calc(6px + env(safe-area-inset-right)) 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  body.m-chat #m-strip::-webkit-scrollbar { display: none; }
  #m-strip .tab { scroll-snap-align: center; flex: none; }
  #tabs { display: none; }                    /* rooms live in the strip */
  /* The tabs lane used to push the account corner outward; with tabs gone
     the G corner takes that job on the contacts screen. */
  body.m-contacts #gsi-corner { margin-left: auto; }
  body.m-chat #m-back { display: block; }
  body.m-chat #m-title { display: block; flex: 1 1 auto; }
  /* #auth is hidden at every width now (see the base rule) — the chat
     header is back + title + the account corner. */
  /* Screens replace the collapse model and the identity bar on phones. */
  #hdrbar, .hdr-collapsed #hdrbar,
  body.m-chat #hdrbar,
  body.mode-forum #hdrbar { display: none; }
  .hdr-collapsed #hdr { display: flex; }
  #collapse-hdr, #collapse-left { display: none; }

  /* Contacts screen: full-height list under the account corner. #left
     grows into the content row (column flex child, content-sized by
     default) so the list fills the screen, not just its own rows. With
     #hdr hidden (all-width rule above), #contacts-head is the screen's
     top row and carries the safe-area inset; the bottom padding clears
     the fixed footer tabs (#m-tabs: 48px + inset + breathing). */
  #left-wrap { flex-direction: column; }
  body.m-contacts #contacts-head { padding-top: max(8px, env(safe-area-inset-top)); }
  body.m-contacts #left { padding: 0 0 calc(56px + env(safe-area-inset-bottom)); }
  #left {
    flex: 1 1 auto;
    min-height: 0;
    width: auto; border-right: none; border-bottom: none;
    position: static; inset: auto; z-index: auto; box-shadow: none;
    padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  }
  /* Desktop collapse state must not leak into the screen model. */
  .left-collapsed #left, body.mode-dm #left {
    width: auto; padding: 10px 12px; overflow-y: auto; border-right: none;
  }
  /* The Google corner shrinks to our own 32px G icon button on phones;
     the remembered-name pill truncates. */
  #gsi-corner { margin-left: 4px; }
  #gsi-corner #gsi-as { max-width: 140px; font-size: 12px; padding: 5px 10px; }
  /* Identity block sizes to its content, capped at 45vw (chat screen
     34vw): handles ellipsize inside; the Sign out button keeps its width. */
  #hdr #you-block { flex: 0 1 auto; max-width: 45vw; }
  body.m-chat #you-block { max-width: 34vw; }
  /* Phones drop the standalone handle link — #auth carries the same handle
     (transitional duplicate markup; the navigation lane owns it) and the
     menu + Sign out + badge already fill the cap at 320px. */
  #you-block > .who-slot { display: none; }
}

/* ── phone footer tabs: Chat | Me ──────────────────────────────────────
   The two-screen shell's bottom navigation, ≤720px only (desktop keeps
   the header/sidebar paths). Chat = the contacts home; Me = the own
   profile or sign-in. Hidden inside a conversation — the composer owns
   that screen, and WeChat hides its tab bar inside a chat too — but
   app.js keeps it up while a profile is open so Chat is always the way
   home. app.js drives [hidden] and aria-pressed; the global [hidden]
   rule at the top of this file outranks the display below. */
#m-tabs { display: none; }
@media (max-width: 720px) {
  #m-tabs {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #m-tabs button {
    flex: 1 1 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    min-height: 48px;
    padding: 5px 0 4px;
    background: none; border: 0;
    color: var(--fg-muted);
    font: inherit; font-size: 11px; line-height: 1.2;
    cursor: pointer;
  }
  #m-tabs button[aria-pressed="true"] { color: var(--fg-bright); }
}

/* ── tabs "+" and the floating create-server panel ──────────────────── */
#tab-add {
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  color: var(--fg-muted);
  border-style: dashed;
  border-color: var(--border-strong);
  min-width: 30px;
  padding: 4px 9px;
  transition: color .15s, border-color .15s, transform .15s;
}
#tab-add:hover, #tab-add:focus-visible {
  color: var(--fg-bright);
  border-color: var(--accent);
  transform: translateY(-1px);
}

#float-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
}
#float-panel {
  position: fixed;
  z-index: 91;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 18px 40px var(--shadow);
  animation: float-in .16s cubic-bezier(.2, .9, .3, 1.2);
}
#float-panel::before { /* arrow pointing back at the "+" */
  content: '';
  position: absolute;
  top: -5px;
  left: 22px;
  width: 9px;
  height: 9px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-strong);
  border-top: 1px solid var(--border-strong);
  transform: rotate(45deg);
}
@keyframes float-in {
  from { opacity: 0; transform: translateY(-6px) scale(.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.float-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--fg-bright);
  letter-spacing: .3px;
}
#float-panel input {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: 8px;
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  outline: none;
}
#float-panel input:focus { border-color: var(--border-focus); }
#float-err { color: var(--danger); font-size: 12.5px; }
.float-row { display: flex; gap: 8px; justify-content: flex-end; }

/* ── QR add-code on profile pages ───────────────────────────────────── */
.qr-wrap {
  margin: 18px auto 0; display: flex; flex-direction: column; gap: 6px;
  align-items: center;
}
.qr-card {
  background: var(--qr-bg); /* scannability: light modules-on-white whatever the theme */
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  line-height: 0;
}
.qr-card svg { width: 148px; height: 148px; display: block; }
.qr-cap { color: var(--fg-faint); font-size: 12px; text-align: center; max-width: 250px; }

/* ── voice + video messages ─────────────────────────────────────────── */
/* The composer mic/camera/attach + the DM call buttons: 32px ghost icon
   buttons, same language as #dm-mode (the double id outranks the
   composer's accent button rule). */
#composer #mic, #composer #cam, #composer #attach,
#composer #dm-call, #composer #dm-video {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--fg-muted);
  font: inherit;
  cursor: pointer;
}
#composer #mic:hover, #composer #cam:hover, #composer #attach:hover,
#composer #dm-call:hover, #composer #dm-video:hover {
  background: transparent;
  color: var(--fg-bright);
  border-color: var(--border-focus);
}
#composer #mic:disabled, #composer #cam:disabled,
#composer #attach:disabled { opacity: .35; cursor: default; }
/* Attach (photo/video picker) keeps a 48px touch target on phones — the
   floor for a one-tap file control; mic/cam stay 32px until the
   phone-scale lane grows the whole row, at which point this rule folds
   into that selector list. */
@media (max-width: 560px) {
  #composer #attach { width: 48px; height: 48px; }
}

/* Recording bar: replaces the input row while a voice note is being made. */
#voice-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 11px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}
#voice-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); flex: 0 0 auto;
}
#voice-dot.rec { animation: dw-rec-pulse 1.2s ease infinite; }
@keyframes dw-rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
#voice-time {
  font-variant-numeric: tabular-nums;
  color: var(--fg-bright);
  font-size: 13px;
  min-width: 3em;
}
#voice-bar button {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#voice-bar button:hover { color: var(--fg-bright); border-color: var(--border-focus); }
#voice-bar button:disabled { opacity: .4; cursor: default; }
#voice-bar #voice-send {
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  font-weight: 600;
}
#voice-bar #voice-send:hover { background: var(--accent-hover); color: var(--on-accent); }

/* Compact player row inside a message: play/pause, duration, thin bar. */
.voice-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: min(240px, 100%);
  vertical-align: middle;
}
.voice-btn {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
}
.voice-btn:hover { color: var(--fg-bright); border-color: var(--border-focus); }
.voice-time {
  color: var(--fg-muted-2);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.voice-track {
  position: relative;
  flex: 1 1 80px;
  min-width: 56px;
  height: 3px;
  border-radius: 2px;
  background: var(--panel-2); /* the groove the accent fill rides (>=3:1) */
  cursor: pointer;
}
.voice-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0%;
  border-radius: 2px;
  background: var(--accent);
}
.voice-expired {
  color: var(--fg-faint);
  font-style: italic;
  font-size: 12.5px;
}
/* Finished-call marker in a DM (server-written envelope). */
.call-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-faint);
  font-size: 12.5px;
  white-space: nowrap;
}

/* ── voice calls ────────────────────────────────────────────────────── */
/* Bottom-center cards (toasts own the bottom-right): ring banner while
   incoming, control bar while connected. Normal themed surfaces. */
#call-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100vw - 24px));
  pointer-events: none;
}
.call-card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow);
  font-size: 13px;
}
.call-ic { color: var(--ok); display: inline-flex; flex: 0 0 auto; }
.call-card.calling .call-ic { animation: dw-rec-pulse 1.4s ease infinite; }
.call-who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.call-dur {
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted-2);
  font-size: 12.5px;
  white-space: nowrap;
}
.call-card button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  border-radius: 7px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.call-card button:hover { color: var(--fg-bright); border-color: var(--border-focus); }
.call-card .call-acc {
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  font-weight: 600;
}
.call-card .call-acc:hover { background: var(--accent-hover); color: var(--on-accent); }
.call-card .call-end { color: var(--danger); border-color: var(--danger); }
.call-card .call-end:hover { color: var(--danger); border-color: var(--danger); }

/* ── invite & share (menu under + add contact, #add= landing banner) ── */
/* Fixed anchored panel, same layer as the account menu. Built by app.js
   (openShareMenu). */
.dw-share {
  position: fixed;
  z-index: 70;
  width: min(320px, calc(100vw - 16px));
  padding: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 10px 30px var(--shadow);
  font-size: 13px;
}
/* The exact text (and link) that will be shared — plain text, no markup. */
.dw-share-prev {
  padding: 0 2px 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  overflow-wrap: anywhere;
}
.dw-share-prev .dw-share-link {
  color: var(--fg-faint);
  font-size: 11.5px;
  margin-top: 2px;
}
.dw-share-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}
.dw-share-grid a,
.dw-share-grid button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 7px;
  background: none;
  border: none;
  color: var(--fg-muted);
  font: inherit;
  font-size: 12.5px;
  text-decoration: none;
  cursor: pointer;
}
.dw-share-grid a:hover,
.dw-share-grid button:hover { background: var(--panel-2); color: var(--fg-bright); }
.dw-share-grid svg { flex: none; }
.dw-share-grid span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Landing banner for /#add=<name>: one line at the top of main, above the
   sign-in / pending-add flow. Dismissed with ×; purely presentational. */
#invite-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--fg);
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
#invite-banner .ib-x {
  flex: none;
  margin: -2px -4px 0 0;
  padding: 2px 6px;
  background: none;
  border: none;
  color: var(--fg-faint);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
#invite-banner .ib-x:hover { color: var(--fg-bright); }

/* ── first-run onboarding card ("you have a handle") ────────────────── */
#onboard-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--backdrop);
}
#onboard-card {
  position: relative;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 18px 44px var(--shadow);
  animation: float-in .16s cubic-bezier(.2, .9, .3, 1.2);
}
#onboard-card .onboard-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--fg-faint);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
#onboard-card .onboard-x:hover { color: var(--fg-bright); }
.onboard-title { font-size: 17px; font-weight: 700; color: var(--fg-bright); padding-right: 24px; }
.onboard-sub { color: var(--fg-muted-2); font-size: 13px; line-height: 1.5; }
.onboard-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.onboard-actions #onboard-copy {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.onboard-actions #onboard-copy:hover { background: var(--accent-hover); }
.onboard-actions a { color: var(--link); font-size: 13px; }
#onboard-done {
  align-self: flex-start;
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#onboard-done:hover { color: var(--fg-bright); border-color: var(--border-focus); }

/* ── one-time backup offer ("back up your phone contacts?") ────────────
   Same card language as the onboarding panel; its own ids so the two
   panels never collide. */
#backup-offer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--backdrop);
}
#backup-offer-card {
  position: relative;
  width: min(380px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 18px 44px var(--shadow);
  animation: float-in .16s cubic-bezier(.2, .9, .3, 1.2);
}
#backup-offer-card .onboard-x {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--fg-faint);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
#backup-offer-card .onboard-x:hover { color: var(--fg-bright); }
#backup-offer-card .bo-yes {
  background: var(--accent);
  color: var(--on-accent);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#backup-offer-card .bo-yes:hover { background: var(--accent-hover); }
#backup-offer-card .bo-later {
  align-self: flex-start;
  background: var(--panel-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
#backup-offer-card .bo-later:hover { color: var(--fg-bright); border-color: var(--border-focus); }

/* ── video messages ─────────────────────────────────────────────────── */
/* Inline player: same 280px ceiling as images, letterbox while loading
   and behind the picture. */
.video-msg video {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  display: block;
  margin-top: 4px;
  border: 1px solid var(--border);
  background: var(--letterbox);
}
/* Not yet fetched (video loads on first tap, like voice notes): a black
   tile with the duration — never a 30 MB fetch just to scroll past.
   max-width caps the 210px floor at very narrow viewports. */
.video-msg .video-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-width: 210px;
  height: 112px;
  margin-top: 4px;
  padding: 0 14px;
  background: var(--letterbox);
  color: var(--tile-fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.video-msg .video-tile:hover { border-color: var(--border-focus); color: var(--tile-fg); }
.video-expired {
  color: var(--fg-faint);
  font-style: italic;
  font-size: 12.5px;
}

/* ── image messages (picked photos) ─────────────────────────────────── */
/* Shown inline, constrained to the column; the 360px ceiling is the
   attachment spec (inline-URL images keep their 280px rule — the extra
   class outspecifies .msg .text img). Tapping opens the full-size blob
   URL, so the cursor says so. */
.msg .text .image-msg img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 8px;
  display: block;
  margin-top: 4px;
  border: 1px solid var(--border);
  cursor: zoom-in;
}
/* Until the bytes arrive: the same letterbox tile language as video. */
.image-msg .image-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 160px;
  height: 96px;
  margin-top: 4px;
  padding: 0 14px;
  background: var(--letterbox);
  color: var(--tile-fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
}
.image-expired {
  color: var(--fg-faint);
  font-style: italic;
  font-size: 12.5px;
}

/* Recording sheet: modal, because the live camera needs real estate the
   composer row does not have. */
#vid-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--backdrop);
}
#vid-sheet {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 18px 44px var(--shadow);
  animation: float-in .16s cubic-bezier(.2, .9, .3, 1.2);
}
#vid-sheet video {
  width: 100%;
  max-height: 300px;
  background: var(--letterbox);
  border: 1px solid var(--border);
  border-radius: 10px;
}
#vid-sheet .vid-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg-muted-2);
  font-size: 12.5px;
  min-height: 20px;
}
#vid-sheet .vid-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger); flex: 0 0 auto;
}
#vid-sheet .vid-dot.rec { animation: dw-rec-pulse 1.2s ease infinite; }
#vid-sheet .vid-time {
  font-variant-numeric: tabular-nums;
  color: var(--fg-bright);
  font-size: 13px;
}
#vid-sheet .vid-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
#vid-sheet .vid-actions button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  border-radius: 7px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#vid-sheet .vid-actions button:hover {
  color: var(--fg-bright);
  border-color: var(--border-focus);
}
#vid-sheet .vid-actions button:disabled { opacity: .4; cursor: default; }
#vid-sheet .vid-actions .vid-rec {
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  font-weight: 600;
}
#vid-sheet .vid-actions .vid-rec:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

/* ── video calls ────────────────────────────────────────────────────── */
/* A video call takes over the screen: the remote picture fills it, the
   local camera is a small draggable tile, controls sit over the bottom.
   z-index sits BELOW toasts and menus so their messages still show.
   The stage is a dark letterbox world in BOTH themes, so the overlay
   scopes its own light-on-dark token values. */
#dw-call-video {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: auto;
  background: var(--letterbox);
  --fg: #ECF0ED;
  --fg-bright: #ECF0ED;
  --fg-muted: #A7B0AB;
  --fg-muted-2: #A7B0AB;
  --fg-faint: #87918C;
  --border: #272C31;
  --border-strong: #394046;
  --border-focus: #5F7563;
  --accent: #2FBE72;
  --accent-hover: #43D389;
  --on-accent: #071510;
  --danger: #FF9C9C;
}
#dw-call-video .cv-remote {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--letterbox);
}
#dw-call-video .cv-pip {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  width: 120px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--letterbox);
  object-fit: cover;
  z-index: 2; /* above the remote picture, below the control bar */
  touch-action: none; /* dragging the tile must not scroll the page */
  cursor: grab;
}
#dw-call-video .cv-pip.mirror { transform: scaleX(-1); }
#dw-call-video .cv-pip:active { cursor: grabbing; }
#dw-call-video .cv-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 3;
  display: flex;
  align-items: center;
  /* Phones: mute + camera + flip + end + timer + name cannot fit one row,
     so the bar wraps centered instead of running past the screen edge. */
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: calc(100vw - 16px);
  padding: 10px 12px;
  background: var(--call-bar);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 10px 30px var(--shadow);
  color: var(--fg);
  font-size: 13px;
}
#dw-call-video .cv-bar button {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  border-radius: 7px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
#dw-call-video .cv-bar button:hover {
  color: var(--fg-bright);
  border-color: var(--border-focus);
}
#dw-call-video .cv-bar .call-dur { color: var(--fg-muted-2); }
#dw-call-video .cv-bar .cv-end {
  color: var(--danger);
  border-color: var(--danger);
}
#dw-call-video .cv-bar .cv-end:hover { color: var(--danger); border-color: var(--danger); }
@media (max-width: 760px) {
  #dw-call-video .cv-pip { width: 96px; }
}

/* ── account menu (runtime chrome override — see contract) ──────────── */
body .dw-menu {
  position: fixed; z-index: 70; background: var(--bg-elevated);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px;
  min-width: 250px; max-width: min(320px, calc(100vw - 16px));
  box-shadow: 0 10px 30px var(--shadow); font-size: 13px;
  display: flex; flex-direction: column; gap: 8px;
}
body .dw-menu a { color: var(--link); text-decoration: none; }
body .dw-menu .m-head { color: var(--fg-muted); font-size: 11.5px; text-transform: lowercase; letter-spacing: .5px; }
body .dw-menu .m-none { color: var(--fg-faint); font-style: italic; }
body .dw-menu .m-row { display: flex; align-items: center; gap: 6px; }
body .dw-menu .m-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body .dw-menu button {
  background: var(--panel-2); color: var(--fg-muted); border: 1px solid var(--border-strong);
  border-radius: 7px; padding: 4px 9px; font: inherit; font-size: 11.5px; cursor: pointer;
}
body .dw-menu button:hover { color: var(--fg-bright); border-color: var(--border-focus); }
body .dw-menu button.primary { background: var(--accent); color: var(--on-accent); border: 0; font-weight: 600; }
body .dw-menu input {
  background: var(--panel); border: 1px solid var(--border-strong); color: var(--fg-bright);
  border-radius: 7px; padding: 6px 9px; font: inherit; font-size: 12.5px; outline: none;
}
body .dw-menu input:focus { border-color: var(--border-focus); }
body .dw-menu .m-form { display: flex; flex-direction: column; gap: 8px; }
body .dw-menu .m-form .m-row { justify-content: flex-end; }
body .dw-menu .m-err { color: var(--danger); font-size: 12px; }
body .dw-menu .m-signout { align-self: flex-start; }

/* Join affordance inside the collapsed-header identity bar (server pages). */
body #hdrbar #dw-join {
  background: var(--panel); color: var(--fg-muted); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 3px 10px; font: inherit; font-size: 12px;
  cursor: pointer; margin-left: 10px; flex: none;
}
body #hdrbar #dw-join:hover { color: var(--fg-bright); border-color: var(--border-focus); }

/* ---- Message actions (msg-menu lane): long-press / right-click menu on a
   message (Copy, Forward, Delete, Quote), the forward target picker, the
   composer quote bar, and the rendered quote block. The menu reuses the
   .dw-menu shell (theme-tuned above); this section adds its action rows. ---- */
body .dw-msgmenu { min-width: 170px; max-width: 260px; gap: 2px; }
/* The contacts-home "+" menu (New Chat / Add Contact / Scan): the same
   action-row language as the message menu, in the account-menu shell. */
body .dw-plusmenu { min-width: 190px; max-width: 260px; gap: 2px; padding: 6px; }
body .dw-msgmenu .m-item, body .dw-plusmenu .m-item {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; border-radius: 7px;
  color: var(--fg-bright); padding: 8px 10px; font: inherit; font-size: 13px;
  cursor: pointer;
}
body .dw-msgmenu .m-item:hover, body .dw-plusmenu .m-item:hover { background: var(--panel-2); }
body .dw-msgmenu .m-item.danger { color: var(--danger); }
body .dw-plusmenu .m-hint {
  color: var(--fg-faint); font-size: 11.5px; padding: 0 10px 6px;
}
body .dw-msgmenu .m-list { display: flex; flex-direction: column; gap: 2px; }
body .dw-msgmenu .m-list .m-item { align-items: center; text-align: left; }
body .dw-msgmenu .m-list {
  max-height: min(300px, calc(100vh - 220px)); overflow-y: auto;
}

/* Quote block inside a message: the leading "> @name: …" line renders as a
   quote, visually distinct in both themes. */
.msg .text .quoted {
  border-left: 3px solid var(--border-strong);
  background: var(--panel);
  color: var(--fg-muted);
  border-radius: 4px;
  padding: 4px 8px;
  margin: 2px 0 4px;
  font-size: 12.5px;
  overflow-wrap: anywhere;
  flex-basis: 100%;
}

/* Composer quote bar: dismissable preview of the message being quoted. */
#composer { flex-wrap: wrap; }
#quote-bar {
  flex-basis: 100%;
  display: flex; align-items: center; gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12.5px;
  min-width: 0;
  order: -1; /* sits above the input row */
}
#quote-bar[hidden] { display: none; }
#quote-bar .q-who { color: var(--fg-muted); font-weight: 600; flex: none; }
#quote-bar .q-snip {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--fg-faint);
}
#quote-bar .q-x {
  flex: none; background: none; border: 0;
  color: var(--fg-muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 2px 6px;
}
#quote-bar .q-x:hover { color: var(--fg-bright); }

/* ── phone scale (≤720px): low-vision pass ────────────────────────────
   Accessibility IS the layout at phone width: 18px body text, 48px rows
   and controls (56px for the call launchers), 17px control labels. The
   block sits last so the equal-specificity phone rules above yield to it
   by cascade order; desktop (>720px) never matches this media query and
   is byte-for-byte unaffected. Sizing only — no color declarations at
   all, so the token system keeps both themes and AA contrast as
   verified. The video-call overlay (#dw-call-video) belongs to another
   lane and is deliberately absent here; the ringing card (#call-root)
   grows, scoped under #call-root so shared classes (.call-dur,
   .call-who, .call-card) cannot leak into the overlay. The QR card
   stays 148px — it must scan. Glyphs inside the 56px buttons (16px
   SVGs) are sized by app.js, out of this file's reach; the large button
   IS the target, and that is this lane's contract. */
@media (max-width: 720px) {

  /* Reading surface. */
  .msg { padding: 10px 14px; }
  #messages { gap: 10px; }
  .msg .name { font-size: 18px; }
  .msg .time { font-size: 15px; }
  .msg .text { font-size: 18px; line-height: 1.45; }
  .msg .verb { font-size: 15px; }
  .msg.pending .text::after { font-size: 15px; }
  .msg .text .quoted { font-size: 16px; }
  .call-note { font-size: 15px; }
  .empty { font-size: 17px; }
  #error { font-size: 17px; }
  #presence { font-size: 14px; }

  /* Chat-screen header: back control is a big thumb box — 56px with a
     40px glyph, ~3× the old hit area (padding counts toward the box;
     flex centers the ::after). */
  body.m-chat #m-back {
    display: inline-flex;
    align-items: center;
    min-width: 56px;
    min-height: 56px;
    padding: 0 12px 0 2px;
    font-size: 40px;
    line-height: 1;
  }
  #m-title { font-size: 22px; }
  #req-badge { font-size: 13px; min-width: 20px; height: 20px; line-height: 20px; }
  #auth .who { font-size: 15px; }
  #auth button { font-size: 17px; min-height: 44px; padding: 8px 14px; }

  /* Room strip: every phone-visible tab is a 48px-tall chip (all strip
     entries carry .tab — room chips, dm-tab, server-tab, tab-add). */
  body.m-chat #m-strip { padding: 8px 10px calc(8px + env(safe-area-inset-right)); }
  #m-strip .tab {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 6px 16px;
    font-size: 17px;
  }
  #m-strip #tab-add { min-width: 48px; }
  #m-strip #channel-create input { width: 150px; font-size: 17px; min-height: 48px; }
  #m-strip #channel-create button { font-size: 17px; min-height: 48px; padding: 6px 14px; }

  /* Composer, stacked for thumbs: name and input each own a full row
     (the input must remain the thing you type into); the 56px launchers
     and Send wrap onto the row below instead of squashing the input.
     DOM order is preserved — focus order stays linear. The generic
     button rule sizes Send and the recording buttons; the double-id
     icon rules below win by specificity, as they already do. */
  #composer { gap: 10px; }
  #name { flex: 1 1 100%; width: auto; font-size: 18px; min-height: 48px; padding: 10px 14px; }
  #input { flex: 1 1 100%; font-size: 18px; min-height: 48px; padding: 10px 14px; }
  #composer button {
    flex: 1 1 auto;
    font-size: 17px;
    min-height: 48px;
    padding: 10px 18px;
  }
  #composer #mic, #composer #cam, #composer #dm-call, #composer #dm-video {
    width: 56px;
    height: 56px;
    border-radius: 12px;
  }
  #composer #dm-mode { width: 56px; height: 56px; }
  #composer #voice-bar { flex: 1 1 100%; padding: 8px 10px 8px 14px; }
  #voice-time { font-size: 17px; }
  #voice-dot { width: 11px; height: 11px; }
  #quote-bar { font-size: 15px; padding: 8px 12px; }
  #composer #quote-bar .q-x { flex: 0 0 auto; font-size: 20px; padding: 6px 10px; }

  /* Message-media controls: 48px play buttons, readable durations, and
     a finger-sized scrub groove (padding grows the hit area; the fill
     insets to match so the 3px visual groove is unchanged). */
  .voice-btn { width: 48px; height: 48px; }
  .voice-time { font-size: 15px; }
  .voice-track { padding: 20px 0; background-clip: content-box; }
  .voice-fill { top: 20px; bottom: 20px; }
  .voice-expired, .video-expired { font-size: 15px; }
  .video-msg .video-tile { font-size: 17px; min-width: 240px; }

  /* Video-message recording sheet. */
  #vid-sheet .vid-dot { width: 11px; height: 11px; }
  #vid-sheet .vid-meta { font-size: 15px; }
  #vid-sheet .vid-time { font-size: 17px; }
  #vid-sheet .vid-actions button { font-size: 17px; min-height: 48px; padding: 10px 16px; }

  /* Ringing card (#call-root ONLY — the in-call overlay is another
     lane; every selector here is scoped under #call-root so the shared
     classes never reach #dw-call-video). */
  #call-root .call-card { font-size: 17px; }
  #call-root .call-card .call-dur { font-size: 15px; }
  #call-root .call-card button { font-size: 17px; min-height: 48px; padding: 10px 16px; }

  /* Contacts screen: rows are the primary navigation — 48px each; the
     header icons keep the bare ≥44px hit area from the base .ch-btn
     rule (glyph already ~28px). */
  #contacts-signin { font-size: 15px; }
  #contacts-title { font-size: 22px; }
  #contacts-searchrow { --csr-h: 58px; }
  #contacts-search-input { font-size: 17px; min-height: 48px; padding: 10px 14px; }
  body #contacts-list .contact { font-size: 17px; min-height: 48px; padding: 10px 12px; }
  .contact-row { font-size: 17px; min-height: 48px; padding: 10px 12px; }
  body #contacts-list .contacts-empty { font-size: 15px; }
  body #contacts-list .add-form input { font-size: 17px; min-height: 48px; padding: 10px 12px; }
  body #contacts-list .add-form button { font-size: 17px; min-height: 48px; padding: 10px 14px; }
  .dot { width: 10px; height: 10px; }
  body .badge { font-size: 13px; padding: 4px 7px; }

  /* Menus: account menu, share sheet, message-action menu. */
  body .dw-menu { font-size: 17px; }
  body .dw-menu .m-head { font-size: 14px; }
  body .dw-menu button { font-size: 17px; min-height: 48px; padding: 8px 14px; }
  body .dw-menu input { font-size: 17px; min-height: 48px; padding: 10px 12px; }
  body .dw-msgmenu .m-item, body .dw-plusmenu .m-item { font-size: 17px; min-height: 48px; padding: 12px 14px; }
  .dw-share { font-size: 17px; }
  .dw-share-prev .dw-share-link { font-size: 15px; }
  .dw-share-grid a, .dw-share-grid button { font-size: 17px; min-height: 48px; padding: 10px 12px; }

  /* Toasts. */
  body .toast { font-size: 17px; }
  body .toast button { font-size: 17px; min-height: 44px; padding: 8px 14px; }
  body .toast .t-x { font-size: 20px; padding: 8px 10px; }

  /* Sign-in and first-run surfaces. */
  .gbtn { font-size: 17px; padding: 12px 20px; }
  .gbtn svg { width: 20px; height: 20px; }
  .gbtn.gbtn-icon { width: 44px; height: 44px; }
  .gbtn.gbtn-icon svg { width: 24px; height: 24px; }
  #gsi-corner #gsi-as { font-size: 15px; min-height: 44px; padding: 10px 14px; max-width: 160px; }
  #auth-panel input { font-size: 17px; min-height: 48px; padding: 12px 14px; }
  #auth-panel button { font-size: 17px; min-height: 48px; padding: 12px 16px; }
  #auth-status { font-size: 15px; }
  #welcome { font-size: 16px; }
  #welcome .sub { font-size: 14px; }
  #welcome button { font-size: 17px; min-height: 48px; padding: 10px 16px; }
  #onboard-card .onboard-x { width: 44px; height: 44px; font-size: 18px; }
  .onboard-sub { font-size: 16px; }
  .onboard-actions #onboard-copy { font-size: 17px; min-height: 48px; padding: 12px 18px; }
  .onboard-actions a { font-size: 17px; }
  #onboard-done { font-size: 17px; min-height: 48px; padding: 10px 16px; }
  #invite-banner { font-size: 16px; }
  #invite-banner .ib-x { font-size: 20px; padding: 8px 10px; }

  /* Server rail + create-server panel. */
  #servers h2 { font-size: 14px; }
  #server-list .server-link { font-size: 17px; }
  #server-list .none { font-size: 15px; }
  #float-panel { width: min(340px, calc(100vw - 32px)); }
  .float-title { font-size: 17px; }
  #float-panel input { font-size: 17px; min-height: 48px; padding: 10px 14px; }
  #float-panel button { font-size: 17px; min-height: 48px; padding: 10px 16px; }
  #float-err { font-size: 15px; }

  /* Profile page: sits tight under the header (the strip is gone), and
     the back arrow is a big thumb target — 56px box, 40px glyph (~3× the
     old hitbox). */
  #profile { padding-top: 6px; }
  #profile-card .pd-handle { font-size: 16px; }
  #profile-edit .pe-color-label, #profile-edit .pe-photo-label, #profile-edit .pe-row-label { font-size: 17px; }
  .pd-notif-label { font-size: 17px; }
  .pd-notif-state { font-size: 15px; }
  .pd-action-row { font-size: 17px; min-height: 48px; }
  .pd-req-list button { font-size: 15px; }
  .pd-copy { font-size: 15px; min-height: 44px; padding: 8px 14px; }
  .pd-add { font-size: 17px; min-height: 48px; padding: 10px 16px; }
  .pd-contact-chip { font-size: 15px; }
  #profile-card .pd-joined { font-size: 14px; }
  #profile-card .pd-bio { font-size: 17px; }
  #profile-edit input, #profile-edit textarea { font-size: 17px; padding: 12px 14px; }
  #profile-edit button { font-size: 17px; min-height: 48px; }
  .pe-color-label { font-size: 15px; }
  #pe-swatches button { width: 44px; height: 44px; border-radius: 8px; }
  #pe-picker { width: 48px; height: 48px; }
  #pe-hex { width: 130px; font-size: 17px; }
  #pe-color-sample { font-size: 17px; }
  #pe-color-err { font-size: 15px; }
  #pe-default-mode { font-size: 17px; min-height: 48px; }
  .qr-cap { font-size: 15px; }
}
