:root {
  /* UC-DS-1 tokens v2 (design canvas "Sotti UI Redesign" › hush.css). Color comes from the theme; sizes and type from
     the platform (html.android and the web: Material 3; html.ios: HIG, below). Light and dark change color only. */
  --bg: #ffffff; --surface: #f3f5f5; --fill: #e9eeee; --text: #161a1b; --muted: #586165; --outline: #7d878b; --border: #e2e7e8;
  --accent: #0f766e; --accent-text: #ffffff; --accent-cont: #d6efeb; --on-accent-cont: #0b5f58;
  --bubble-in: #e9eeee; --bubble-in-text: #161a1b; --bubble-out: #0f766e; --bubble-out-text: #ffffff;
  --danger: #b42318; --sw-off: #e3e8e8; --chrome: #ffffff; --grouped-page: #f3f5f5; --grouped-cell: #ffffff;
  --scrim: rgba(14, 17, 18, .40); --elev: 0 2px 6px rgba(0, 0, 0, .18); --warn-bg: #fff4e5; --warn-text: #7a4b00;
  --shadow: 0 8px 30px rgba(0, 0, 0, .18);
  /* Older names, kept as aliases of the tokens above */
  --bg-sidebar: var(--surface); --bg-hover: var(--fill); --bg-active: var(--accent-cont); --bg-input: var(--fill);
  /* Type scale (rem: iOS Dynamic Type scales it) */
  --text-2xs: 0.6875rem; /* 11 meta */
  --text-xs: 0.75rem;    /* 12 time, labels */
  --text-sm: 0.8125rem;  /* 13 hints */
  --text-md: 0.875rem;   /* 14 previews, secondary */
  --text-base: 0.9375rem; /* 15 */
  --text-lg: 1.0625rem;  /* 17 */
  --text-xl: 1.25rem;    /* 20 */
  --text-2xl: 1.5rem;    /* 24 */
  --text-3xl: 1.75rem;   /* 28 */
  /* Platform type roles: Android (Roboto, Material 3 type scale) */
  --fs-large: 1.375rem; --fw-large: 600;   /* 22: a root screen's title */
  --fs-title: 1.375rem;                    /* 22: a page's title */
  --fs-head: 1rem; --fw-head: 500;         /* 16: a row's name */
  --fs-body: 1rem; --lh-body: 1.5;         /* 16/24 */
  --fs-bubble: 1rem; --lh-bubble: 1.375;   /* 16/22 */
  --fs-foot: 0.875rem;                     /* 14: previews, subtitles */
  --fs-cap: 0.75rem;                       /* 12: times */
  --fs-tab: 0.75rem; --fs-sec: 0.875rem;   /* 12 tab labels, 14 section headers */
  /* Platform metrics: Android (Material 3, dp) */
  --bar: 64px; --tabbar: 80px; --target: 48px; --search-h: 56px; --r-search: 28px; --btn: 48px; --row1: 56px;
  --chat-row: 72px; --av-list: 48px; --av-bar: 40px; --field: 56px; --r-field: 12px; --r-sheet: 28px; --r-group: 0px; --r-fab: 16px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --radius-xs: 4px; --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-bubble: 20px; --radius-full: 999px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --dur-fast: 150ms; --dur-base: 220ms;
  --avatar-bg: 65% 88%; --avatar-fg: 60% 26%; /* pastel disc, dark initial (Signal's avatar colors); >= 4.6:1 for every hue */
  color-scheme: light;
}
/* iOS (HIG, pt): only sizes and type differ; colors are shared */
html.ios {
  --fs-large: 2.125rem; --fw-large: 700;   /* 34: large title */
  --fs-title: 1.0625rem;                   /* 17: navigation bar title */
  --fs-head: 1.0625rem; --fw-head: 600;
  --fs-body: 1.0625rem; --lh-body: 1.294;  /* 17/22 */
  --fs-bubble: 1.0625rem; --lh-bubble: 1.294;
  --fs-foot: 0.9375rem; --fs-cap: 0.75rem; --fs-tab: 0.625rem; --fs-sec: 0.8125rem;
  --bar: 44px; --tabbar: 49px; --target: 44px; --search-h: 36px; --r-search: 10px; --btn: 50px; --row1: 44px;
  --chat-row: 76px; --av-list: 52px; --av-bar: 36px; --field: 50px; --r-field: 10px; --r-sheet: 10px; --r-group: 10px;
}

/* Dark: the system's choice unless Settings › Appearance says Light, or Dark whatever the system says (UC-TH-1). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1112; --surface: #181c1e; --fill: #242a2c; --text: #e6eaeb; --muted: #9ca5a8; --outline: #6f797d; --border: #262c2e;
    --accent: #3cc2b1; --accent-text: #03201c; --accent-cont: #123a36; --on-accent-cont: #9fe6dc;
    --bubble-in: #242a2c; --bubble-in-text: #e6eaeb; --bubble-out: #13695f; --bubble-out-text: #ffffff;
    --danger: #f2766b; --sw-off: #394144; --chrome: #181c1e; --grouped-page: #0e1112; --grouped-cell: #181c1e;
    --scrim: rgba(0, 0, 0, .60); --elev: none; --warn-bg: #3a2c12; --warn-text: #f3c77a;
    --avatar-bg: 30% 28%; --avatar-fg: 70% 85%;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .author { color: hsl(var(--hue, 170) 60% 68%); }
}
:root[data-theme="dark"] {
  --bg: #0e1112; --surface: #181c1e; --fill: #242a2c; --text: #e6eaeb; --muted: #9ca5a8; --outline: #6f797d; --border: #262c2e;
  --accent: #3cc2b1; --accent-text: #03201c; --accent-cont: #123a36; --on-accent-cont: #9fe6dc;
  --bubble-in: #242a2c; --bubble-in-text: #e6eaeb; --bubble-out: #13695f; --bubble-out-text: #ffffff;
  --danger: #f2766b; --sw-off: #394144; --chrome: #181c1e; --grouped-page: #0e1112; --grouped-cell: #181c1e;
  --scrim: rgba(0, 0, 0, .60); --elev: none; --warn-bg: #3a2c12; --warn-text: #f3c77a;
  --avatar-bg: 30% 28%; --avatar-fg: 70% 85%;
  color-scheme: dark;
}
:root[data-theme="dark"] .author { color: hsl(var(--hue, 170) 60% 68%); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
/* The root never scrolls, so the top bar, tab bar and composer stay put: no rubber band dragging the whole app
   (overscroll-behavior counts only on the root, not on body) and no page shift when the keyboard opens. A page
   taller than the screen (onboarding, Terms) scrolls in body. iOS: capacitor.config.json ios.scrollEnabled false. */
html { -webkit-text-size-adjust: 100%; overflow: hidden; overscroll-behavior: none; }
body { overflow-y: auto; overscroll-behavior: none; }
/* No double-tap zoom (a double tap on text zoomed the app); pinch zoom stays on the web. The app's viewport fixes the
   scale (build-mobile.mjs): text grows with the system text size instead. */
* { touch-action: manipulation; }
/* iOS draws its own magnifier in a search field, beside ours: two icons. Plain fields; the clear button stays. */
input[type=search] { -webkit-appearance: none; appearance: none; }
/* iOS Dynamic Type (typography.md › Supporting Dynamic Type): --dt is the system text size over its default (app.js).
   As iOS's own bars do, the interface (every rem) grows to 1.35×; messages, the content, grow the whole way. */
html.ios { font-size: calc(16px * min(var(--dt, 1), 1.35)); }
html.ios .bubble:not([class*="jumbo-"]) { font-size: calc(var(--msg-font, var(--fs-bubble)) * max(1, var(--dt, 1) / 1.35)); }
body {
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  font: var(--fs-body)/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.danger { color: var(--danger); }
button:disabled { opacity: .6; cursor: default; }
a { color: var(--accent); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, li:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: var(--text-sm); }
.error { color: var(--danger); min-height: 1.2em; margin: 6px 0 0; font-size: var(--text-md); }
.error.small { margin: 0 16px; font-size: var(--text-sm); min-height: 0; }
code { background: var(--bg-input); padding: 1px 5px; border-radius: var(--radius-xs); font-size: var(--text-sm); }

/* Onboarding */
.onboarding { display: grid; place-items: center; min-height: 100%; padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left)); }
.onboarding-card { width: 100%; max-width: 400px; text-align: center; }
.onboarding-card h1 { margin: 12px 0 4px; font-size: var(--text-3xl); }
.onboarding-card form { text-align: left; margin: 24px 0 16px; display: grid; gap: 6px; }
.onboarding-card label { font-weight: 600; }
.onboarding-card input {
  border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 11px 12px;
}
.onboarding-card .hint { margin: 0 0 8px; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
label.check input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.onboarding-card label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 400; font-size: var(--text-md); margin-bottom: 4px; }
.onboarding-card label.check input { flex: none; width: 20px; height: 20px; margin: 0; padding: 0; accent-color: var(--accent); }
.onboarding-card button { padding: 11px; }
.onboarding-card .lead { margin: 0 0 4px; font-size: var(--text-lg); line-height: 1.45; }
.name-hint { margin: 0 0 8px; }
.name-hint.bad { color: var(--danger); }
.name-hint.ok { color: var(--accent); }
.onboarding-card input[aria-invalid="true"] { border-color: var(--danger); }
.onboarding-card #restore-btn { width: 100%; min-height: 44px; background: transparent; border-color: var(--border); font-weight: 600; }
.onboarding-card .actions { display: grid; gap: 8px; margin-top: 16px; }

/* Layout */
.app { display: grid; grid-template-columns: 320px minmax(0, 1fr); height: 100%; }
.sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.sidebar-header { padding: calc(14px + env(safe-area-inset-top)) 16px 8px calc(16px + env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; }
.author { font-size: var(--text-xs); font-weight: 600; margin: 6px 12px 2px; color: hsl(var(--hue, 170) 45% 32%); } /* 4.7:1 on white for every hue */
.group-form { display: grid; gap: 6px; }
.group-form input { border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 10px 12px; }
.group-form label { font-weight: 600; margin-top: 6px; }
.group-form .hint { margin: 0; }
.field-inputs { display: contents; } /* the edit page's fields sit in the form's grid */
.group-form textarea { border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 10px 12px; font: inherit; color: inherit; resize: vertical; }
.group-form .pick { font-weight: 400; margin: 0; }
.pick-title { display: block; font-weight: 600; margin: 4px 0; } /* New group's picker (AC-GR-20) */
/* A setting that shows its value and opens its own page, as Signal's profile rows */
.menu .value-row { display: flex; align-items: center; gap: 12px; }
.value-row .muted { margin-left: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.value-row::after { content: ""; flex: none; width: 8px; height: 8px; border-top: 2px solid var(--muted); border-right: 2px solid var(--muted); rotate: 45deg; }
#chat-photo { margin: 8px auto 12px; }
.dialog.page #chat-title, .dialog.page #chat-about, .dialog.page #chat-groups { text-align: center; }
/* Group info opens as Signal's group settings: the photo, name, member count and description centered on top */
#gi-photo { margin: 8px auto 12px; }
#gi-title, #gi-sub, #gi-desc { text-align: center; }
/* UC-DS-1 (design canvas › ChatSettings, GroupInfo): a page's rows lead with an icon (Material list item, iOS cell) */
.dialog.page .menu > button:is(#chat-nickname, #chat-style, #chat-mute, #chat-custom-notify, #chat-safety, #chat-block, #chat-report, #gi-media, #gi-add, #gi-leave) { display: flex; align-items: center; gap: var(--space-4); }
.dialog.page .menu > button:is(#chat-nickname, #chat-style, #chat-mute, #chat-custom-notify, #chat-safety, #chat-block, #chat-report, #gi-media, #gi-add, #gi-leave)::before { content: ""; flex: none; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
#chat-nickname { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 20h4L19 9l-4-4L4 16zM14 6l4 4'/></svg>"); }
#chat-style { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3a9 9 0 1 0 0 18c1.1 0 2-.9 2-2 0-1.4 1.1-2 2.3-2H18a3 3 0 0 0 3-3c0-6-4-11-9-11zM7.5 11h.01M10 7h.01M15 7h.01'/></svg>"); }
#chat-mute { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15zM10 20a2 2 0 0 0 4 0'/></svg>"); }
#chat-custom-notify { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15zM10 20a2 2 0 0 0 4 0M12 8v4'/></svg>"); }
#chat-safety { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3l7 3v6c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6zM9 12l2 2 4-4'/></svg>"); }
#chat-block { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM5.6 5.6l12.8 12.8'/></svg>"); }
#chat-report { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M5 21V4h11l-2 4 2 4H5'/></svg>"); }
#gi-media { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 5h16v14H4zM8 10a1.5 1.5 0 1 0 0-.01M20 15l-5-5-9 9'/></svg>"); }
#gi-add { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 5v14M5 12h14'/></svg>"); }
#gi-add { color: var(--accent); }
/* The timer row reads as a row with its value: the icon as the others, the select without a box */
.dialog.page #timer-row { gap: var(--space-4); }
.dialog.page #timer-row > svg { width: 22px; height: 22px; }
.dialog.page #timer-select { width: auto; min-width: 0; margin-inline-start: auto; border: 0; background: transparent; color: var(--muted); padding-inline: var(--space-1); font-size: var(--fs-body); }
.page-handle { margin: 0; text-align: center; color: var(--muted); font-size: var(--fs-foot, .875rem); }
/* Quick actions: an icon over a short label, equal tiles across the page (Signal's conversation settings buttons) */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: var(--space-2); margin: var(--space-4) 0; }
.quick { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1); min-height: 64px; padding: var(--space-2) 0; border: 0; border-radius: var(--radius-md); background: var(--fill); color: var(--text); font: inherit; font-size: var(--fs-cap, .75rem); font-weight: 500; }
.quick svg { color: var(--accent); }
html.ios .quick { background: var(--grouped-cell); border-radius: var(--r-group); }
/* Recent media: a heading with See all, four square photos */
.strip-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.strip-head h3 { margin: 0; }
.text-btn { min-height: var(--target, 44px); padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; }
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-1); }
.strip :is(.photo, .blur, .media-load) { width: 100%; max-width: none; min-width: 0; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }
.sidebar-header .icon-btn { color: var(--text); }
/* Header (as Signal): my avatar opens Settings · section title · New chat */
.sidebar-header { gap: var(--space-3); }
.me-btn { flex: none; display: grid; place-items: center; min-width: 44px; min-height: 44px; padding: 0; border: 0; background: none; border-radius: var(--radius-full); }
.list-head { flex: 1; min-width: 0; }
.list-title { margin: 0; font-size: var(--text-xl); font-weight: 700; }
.compose-btn { color: var(--accent) !important; } /* the one prominent action here (toolbars.md › Actions) */
.compose-btn[hidden] { display: none; }
/* UC-DS-2 Icons: Material's edit in Android's FAB; square.and.pencil in the iOS (and web) bar */
.compose-btn .ic-edit, .android .compose-btn .ic-compose { display: none; }
.android .compose-btn .ic-edit { display: block; }
/* Android: New chat is a floating button above the tab bar, as Signal's */
.android .compose-btn { position: fixed; right: calc(var(--space-4) + env(safe-area-inset-right)); bottom: calc(72px + var(--space-4) + env(safe-area-inset-bottom)); z-index: 3;
  width: 56px; height: 56px; border-radius: var(--radius-lg); background: var(--accent); color: var(--accent-text) !important; box-shadow: var(--shadow); }
@media (hover: hover) { .android .compose-btn:hover { background: var(--accent); } }
body:has(#chats-bar:not([hidden])) :is(.compose-btn, #list-camera, #list-more) { display: none; } /* selecting chats: the bar's actions, not New chat, and nothing over them */
/* Chats | Calls: a section is shown by the sidebar's data-tab */
.sidebar[data-tab="calls"] [data-tab="chats"], .sidebar:not([data-tab="calls"]) [data-tab="calls"] { display: none !important; }
.tab-bar { flex: none; display: flex; border-top: 1px solid var(--border); background: var(--bg-sidebar); padding: var(--space-1) var(--space-2) calc(var(--space-1) + env(safe-area-inset-bottom)) calc(var(--space-2) + env(safe-area-inset-left)); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 56px; padding: var(--space-1); border: 0; background: none; border-radius: var(--radius-md); color: var(--muted); font-size: var(--text-xs); font-weight: 600; }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"] svg { color: var(--accent); }
@media (hover: hover) { .tab:hover { background: var(--bg-hover); } }
.calls-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 0 var(--space-4) var(--space-4); overscroll-behavior: contain; }
.android .calls-panel { padding-bottom: calc(88px + var(--space-4)); } /* the last row clears the floating New call button */
.calls-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-3); }
.calls-actions button { min-height: 44px; }
.new-chat-form { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.new-chat-form label { font-weight: 600; }
.new-chat-form input { border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 11px 12px; }
.new-chat-form .error { margin: 0; }
.avatar.note-self { background: var(--bg-active); color: var(--accent); }
/* Settings (as Signal): my profile card, then grouped rows that open pages */
.settings-home { display: grid; gap: var(--space-4); margin-top: var(--space-2); }
.settings-home[hidden], .settings-page[hidden] { display: none; }
.settings-card-wrap { position: relative; }
.settings-qr { width: var(--target); height: var(--target); position: absolute; right: var(--space-2); top: 50%; translate: 0 -50%; color: var(--text); }
.settings-profile-card { padding-right: 60px !important; }
.settings-profile-card { display: flex; align-items: center; gap: var(--space-4); width: 100%; padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-md); background: none; text-align: left; }
.settings-card-text { display: grid; min-width: 0; }
.settings-card-name { font-size: var(--text-lg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-group { display: grid; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.settings-row { display: flex; align-items: center; gap: var(--space-4); min-height: 52px; padding: 0 var(--space-4); border: 0; border-radius: 0; background: none; text-align: left; }
.settings-row + .settings-row { border-top: 1px solid var(--border); }
@media (hover: hover) { .settings-row:hover, .settings-profile-card:hover { background: var(--bg-hover); } }
.settings-row svg { flex: none; color: var(--muted); }
.settings-row::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-top: 2px solid var(--muted); border-right: 2px solid var(--muted); rotate: 45deg; }
.settings-links { margin: 0; text-align: center; font-size: var(--text-sm); }
.settings-links a { display: inline-block; padding: 12px 6px; } /* a 44 pt tap height (Apple's audit: hit region) */
.settings-page-head { display: flex; align-items: center; gap: var(--space-1); margin: 0 0 var(--space-2) calc(-1 * var(--space-2)); }
.dialog .settings-page-head h2 { margin: 0; }
.dialog .settings-page-head h3 { margin: 0; font-size: var(--text-xl); font-weight: 700; color: var(--text); text-transform: none; letter-spacing: 0; }
.settings-page-head h3:focus { outline: none; }
.settings-page .toggle { padding: var(--space-2) 0; }
.settings-page .toggle + .toggle { border-top: 1px solid var(--border); }
/* Switches (toggles.md: the switch style in a list row): the knob moves and the track fills, not only a color change */
input[type="checkbox"][role="switch"] { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 46px; height: 28px; margin: 0; border: 2px solid var(--muted); border-radius: var(--radius-full); background: transparent; cursor: pointer; }
input[type="checkbox"][role="switch"]::before { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); }
input[type="checkbox"][role="switch"]:checked { border-color: var(--accent); background: var(--accent); }
input[type="checkbox"][role="switch"]:checked::before { left: 21px; background: var(--accent-text); }
@media (prefers-reduced-motion: no-preference) { input[type="checkbox"][role="switch"]::before { transition: left var(--dur-fast) var(--ease-out); } }
.calls-list .list-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: var(--space-8) var(--space-5); }
.calls-list .list-empty .hint { margin: 0; max-width: 30ch; }
.calls-list .list-empty button { margin-top: 10px; min-height: 44px; padding: 0 20px; }
#calls-new[hidden] { display: none; }
/* Group chats: room for the sender's avatar beside their last bubble (as Signal) */
.msg.grouped { position: relative; padding-inline-start: 36px; }
.msg-avatar { position: absolute; left: 0; bottom: 6px; width: 28px; height: 28px; font-size: var(--text-xs); }
.msg.grouped:has(.reactions) .msg-avatar { bottom: 22px; }
.msg:has(.select-check) .msg-avatar { display: none; } /* select mode: the checkbox takes that place */
/* Swipe on a row: the label sits in the gap the row leaves */
.conversation-list li { position: relative; touch-action: pan-y; }
.conversation-list li.swiping { background: var(--bg-hover); transition: none; }
.conversation-list li.swiping::after { content: attr(data-label); position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding: 0 var(--space-4); white-space: nowrap; font-size: var(--text-sm); font-weight: 600; color: var(--muted); }
.conversation-list li.swiping[data-swipe="right"]::after { right: 100%; }
.conversation-list li.swiping[data-swipe="left"]::after { left: 100%; }
.conversation-list li.armed::after { color: var(--accent); }
.conn { font-size: var(--text-xs); color: var(--muted); }
.conn.online::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #2e9d5b; margin-right: 5px; vertical-align: 1px; }
.search { position: relative; padding: var(--space-1) var(--space-4) var(--space-2); }
.search input { width: 100%; border: 0; background: var(--bg-input); border-radius: var(--radius-full); padding: var(--space-2) var(--space-4) var(--space-2) 40px; }
.search-icon { position: absolute; left: calc(var(--space-4) + 12px); top: calc(50% - 2px); translate: 0 -50%; color: var(--muted); pointer-events: none; }

.avatar {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: var(--text-base); text-transform: uppercase;
  color: hsl(var(--hue, 170) var(--avatar-fg)); background: hsl(var(--hue, 170) var(--avatar-bg));
}
.avatar.lg { width: 44px; height: 44px; font-size: var(--text-lg); }
.avatar.xl { width: 64px; height: 64px; font-size: var(--text-2xl); }
.avatar { background-size: cover; background-position: center; }
.avatar > svg { width: 55%; height: 55%; } /* Note to Self's note */
.photo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pin-bar { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 16px; border: 0; border-bottom: 1px solid var(--border); background: var(--bg-sidebar); color: var(--text); font: inherit; font-size: var(--text-md); text-align: left; cursor: pointer; }
.pin-bar[hidden] { display: none; }
#pin-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr { width: 200px; height: 200px; border-radius: var(--radius-md); overflow: hidden; }
#my-link { width: 100%; min-height: 44px; margin-top: 8px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
#gi-link { width: 100%; min-height: 44px; }
.calls-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.call-row { display: flex; align-items: center; gap: 4px; }
.calls-list li.list-label { padding: var(--space-4) var(--space-2) var(--space-1); font-size: var(--fs-sec, .875rem); font-weight: 600; color: var(--muted); }
html.ios .calls-list li.list-label { text-transform: uppercase; font-weight: 400; font-size: .8125rem; }
.call-open { flex: 1; min-width: 0; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: var(--radius-md); background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
@media (hover: hover) { .call-open:hover { background: var(--bg-hover); } }
.call-log-info { display: grid; min-width: 0; } /* not .call-info: that is the call screen's (calls.css), which centered these rows */
.call-dir { display: inline-flex; vertical-align: -2px; margin-right: 4px; }
.call-dir.in svg { rotate: 180deg; } /* ↙ in, ↗ out */
.call-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-text { font-size: var(--text-sm); color: var(--muted); }
.call-text.missed { color: var(--danger); }

.conversation-list { list-style: none; margin: 0; padding: 4px 8px calc(4px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.conversation-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-md); cursor: pointer;
}
.conversation-list li:active { background: var(--bg-hover); }
@media (hover: hover) { .conversation-list li:hover { background: var(--bg-hover); } }
.conv-open { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: inherit; }
.conv-open .conv-main, .conv-open .conv-top, .conv-open .conv-bottom { display: flex; } /* spans now (inside a button), laid out as before */
.conv-open .conv-main { flex-direction: column; }
@media (prefers-reduced-motion: no-preference) { .conversation-list li { transition: background-color var(--dur-fast) var(--ease-out); } }
.conversation-list li[aria-current="true"] { background: var(--bg-active); }
.conversation-list li.list-label { display: block; background: none; cursor: default; padding: 10px 10px 2px; font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
/* Empty list states: no chats yet, no search results, empty archive */
.conversation-list li.list-empty { flex-direction: column; justify-content: center; text-align: center; gap: 6px; padding: 32px 20px; cursor: default; background: none; }
.empty-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--bg-hover); color: var(--muted); }
.empty-title { margin: 6px 0 0; font-weight: 600; font-size: 1rem; }
.list-empty .hint { margin: 0; max-width: 30ch; line-height: 1.4; }
.list-empty button { margin-top: 10px; min-height: 44px; padding: 0 20px; }
.intro { margin: 4px 8px 8px calc(8px + env(safe-area-inset-left)); padding: 14px 16px; border-radius: var(--radius-md); background: var(--bg-active); }
.intro h2 { margin: 2px 0 6px; font-size: var(--text-lg); }
.intro h2:focus { outline: none; }
.intro p { margin: 0; }
.intro .intro-step { font-size: var(--text-xs); font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.intro-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.intro-actions button { min-height: 44px; padding: 0 18px; }
.conv-main { min-width: 0; flex: 1; }
.conv-top { display: flex; justify-content: space-between; gap: var(--space-2); margin-bottom: 2px; }
.conv-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: var(--text-xs); color: var(--muted); flex: none; align-self: center; }
/* Unread (Signal): bold name, darker preview, time in the accent color */
.conversation-list li.unread .conv-name { font-weight: 700; }
.conversation-list li.unread .conv-preview { color: var(--text); }
.conversation-list li.unread .conv-time { color: var(--accent); font-weight: 600; }
.conv-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.conv-preview { color: var(--muted); font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--accent); color: var(--accent-text); font-size: var(--text-xs); font-weight: 700; border-radius: var(--radius-full); min-width: 20px; height: 20px; line-height: 20px; padding: 0 6px; text-align: center; flex: none; font-variant-numeric: tabular-nums; }
.badge.muted { background: var(--muted); color: var(--bg); }
.conv-top .conv-name { flex: 1; min-width: 0; }
.conv-user { font-weight: 400; font-size: var(--text-sm); color: var(--muted); }
.conv-icon { display: inline-flex; color: var(--muted); flex: none; align-self: center; }
.conv-preview mark { background: none; color: var(--accent); font-weight: 600; } /* UC-SE-1: the match in the accent, as the design canvas */
.search :is(.search-back, .search-cancel, .search-hint) { display: none; }
.conversation-list li.archived-row { justify-content: center; gap: 8px; color: var(--muted); font-weight: 600; }
.conversation-list li.archive-head { display: flex; align-items: center; gap: 4px; padding: 4px 0; font-size: var(--text-base); color: var(--text); }
.more-btn { opacity: 0; border: 0; background: transparent; padding: 4px; border-radius: 50%; color: var(--muted); flex: none; display: grid; place-items: center; }
.more-btn:focus-visible { opacity: 1; }
@media (hover: hover) { .msg:hover .more-btn, .conversation-list li:hover .more-btn { opacity: 1; } }
@media (hover: hover) { .more-btn:hover { background: var(--bg-hover); } }
/* Touch: long-press opens the sheets (no ⋯), and must not start a text selection */
@media (hover: none) {
  .more-btn { display: none; }
  /* UC-DS-1 D-DS-15: a long press never selects text or opens the system's callout (Save image, link preview), as in
     Signal and Messenger: on the A03s it selected titles, hints and times, and the long press that opened a sheet went
     on to select its title; on iOS a photo (view-once ones too) offered Save to Photos. Fields stay editable. */
  body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
  img, video, a { -webkit-user-drag: none; }
  /* UC-DS-1 D-DS-15: what a press looks like. Android: Material's state layer, the content color at 12 %, on every
     control; iOS: cells highlight and the other buttons dim (UIKit's highlighted state). Chat rows keep their own. */
  html.android :is(button, summary, label.select-row, [role=button], a):not(:disabled, .conv-open):active,
  html.ios :is(.menu button, .settings-row, .settings-profile-card, .pick-row, .call-open, .media-row, label.select-row):not(:disabled):active {
    box-shadow: inset 0 0 0 100vmax color-mix(in srgb, currentColor 12%, transparent);
  }
  html.ios :is(button, summary, a):not(.menu button, .settings-row, .settings-profile-card, .pick-row, .call-open, .media-row, .conv-open, :disabled):active { opacity: .4; }
}

/* Conversation */
.conversation { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.empty { margin: auto; text-align: center; color: var(--muted); }
.empty .primary { margin-top: 12px; min-height: 44px; padding: 0 20px; }
.conversation-inner { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.conversation-inner { container: chat / inline-size; }
.conversation-header { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 10px 16px; border-bottom: 1px solid var(--border); }
.peer { flex: 1; min-width: 0; border: 0; background: none; padding: 2px 6px; text-align: left; border-radius: var(--radius-sm); display: flex; align-items: center; gap: 10px; }
.peer-text { min-width: 0; flex: 1; } /* the avatar is part of the button, as Signal: a tap on it opens the chat's info too */
@media (hover: hover) { .peer:hover { background: var(--bg-hover); } }
.peer-name, .peer-sub { display: block; }
.peer-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-sub { font-size: var(--text-xs); color: var(--muted); overflow-wrap: anywhere; }
.verified { font-size: var(--text-xs); color: var(--accent); font-weight: 600; }
.peer-timer { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; vertical-align: bottom; } /* leads the second line (AC-DM-21) */
.peer-timer svg { flex: none; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: var(--radius-sm); display: grid; place-items: center; color: var(--muted); }
@media (hover: hover) { .icon-btn:hover { background: var(--bg-hover); color: var(--text); } }
/* Larger text (the threshold is in rem, so it only trips when text is big or the screen small): buttons first, name below */
@container chat (max-width: 17rem) {
  .conversation-header { flex-wrap: wrap; row-gap: 2px; }
  .peer { order: 9; flex: 1 0 100%; }
  .peer-name { white-space: normal; overflow-wrap: anywhere; }
}
.back { display: none; }
/* Disappearing messages: a row of the chat sheet (as Signal's chat settings), label left, the choice right */
.timer-select { display: flex; align-items: center; gap: var(--space-2); min-height: 48px; padding: 0 var(--space-2) 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.timer-select[hidden] { display: none; }
.timer-label { flex: 1; min-width: 0; }
.timer-select select { flex: none; max-width: 55%; min-height: 44px; border: 0; background: var(--bg-input); padding: 0 var(--space-3); border-radius: var(--radius-sm); cursor: pointer; }
.conversation-header .icon-btn { color: var(--text); }
.conversation-header .peer-name { font-size: var(--text-lg); }
/* Swipe to reply: the reply arrow waits in the gap the message leaves */
.messages li.msg { touch-action: pan-y; }
.messages li.msg.swiping { position: relative; }
.messages li.msg.swiping::before { content: ""; position: absolute; right: 100%; top: 50%; translate: -12px -50%; width: 28px; height: 28px; background: var(--muted); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 7 5 12l5 5M5 12h9a5 5 0 0 1 5 5v1' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10 7 5 12l5 5M5 12h9a5 5 0 0 1 5 5v1' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 22px no-repeat; opacity: .5; } /* muted: >= 5:1 in both themes */
.messages li.msg.armed::before { opacity: 1; }
.video.video-send-preview { width: 100%; max-height: 50vh; margin: var(--space-2) 0; pointer-events: auto; } /* its own controls take the tap */
#video-send-caption { margin-bottom: var(--space-3); }
.video-send-once { margin-inline-end: auto; }
.edit-send .icon-btn { flex: none; color: #fff; width: 44px; height: 44px; }
/* Time and status inside the bubble, bottom right (as Signal); the text flows around them */
.meta.in-bubble { float: right; position: relative; top: 5px; margin: 0 -4px 0 var(--space-3); color: inherit; white-space: nowrap; } /* full color: at .8 it was 4.1:1 on the default bubble */
.msg.in .meta.in-bubble { color: var(--muted); opacity: 1; }
.meta.in-bubble .status-read { color: inherit; }
/* Status icons: the checks are cut out in the bubble's own color (a CSS class: the CSP blocks inline styles) */
.meta .knock { stroke: var(--bubble-out); }
.meta .knock-fill { fill: var(--bubble-out); }
.bubble::after { content: ""; display: block; clear: both; }
.bubble:has(.photo) .meta.in-bubble, .bubble:has(.video) .meta.in-bubble { margin: 2px 6px 0 var(--space-3); top: 0; }

.chat-search { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--bg); }
.chat-search input { flex: 1; min-width: 0; min-height: 44px; border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 8px 12px; font: inherit; color: inherit; }
.chat-search button { min-height: 44px; min-width: 44px; }
.chat-search-count { color: var(--muted); font-size: var(--text-md); white-space: nowrap; font-variant-numeric: tabular-nums; flex: 0 1 auto; max-width: 30%; min-width: 0; overflow: hidden; text-overflow: ellipsis; } /* the field keeps the room */
.chat-search input { min-width: 6em; }
.banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--warn-bg); color: var(--warn-text); padding: 10px 16px; font-size: var(--text-md); }
.banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.banner button { padding: 5px 12px; }

.messages-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.messages:focus { outline: none; }
.messages { position: relative; /* contains .meta.compact (absolute): unclipped it grew the page and the bars scrolled away */ list-style: none; margin: 0; padding: 16px calc(16px + env(safe-area-inset-right)) 16px 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 3px; overscroll-behavior: contain; }
.older { align-self: center; margin: 8px 0; }
.older-btn { min-height: 44px; padding: 0 16px; border-radius: var(--radius-full); font-size: var(--text-sm); }
.day { align-self: center; font-size: var(--text-xs); color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.unread-divider { align-self: stretch; display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; color: var(--accent); font-size: var(--text-xs); font-weight: 700; }
.unread-divider::before, .unread-divider::after { content: ""; flex: 1; height: 1px; background: currentColor; opacity: .4; }
.chat-intro { align-self: center; display: grid; justify-items: center; gap: 2px; max-width: 80%; margin: 24px 0 16px; text-align: center; color: var(--muted); font-size: var(--text-sm); }
.chat-intro p { margin: 0; }
.chat-intro .avatar { margin-bottom: 8px; }
.chat-intro-name { color: var(--text); font-size: var(--text-lg); font-weight: 600; }
.chat-intro-about { margin-top: 6px !important; }
.system { align-self: center; text-align: center; font-size: var(--text-sm); color: var(--muted); max-width: 80%; margin: 8px 0; }
/* AC-CH-08: a call, as Signal's call update: a quiet card with the call's icon, red when missed */
.system.call-event { display: grid; grid-template-columns: auto auto; justify-items: center; align-items: center; column-gap: 6px; padding: 8px 14px;
  border-radius: var(--radius-lg); background: var(--bubble-in); color: var(--bubble-in-text); }
.system.call-event svg { color: var(--muted); }
.system.call-event.missed svg { color: var(--danger); }
.call-event-time { grid-column: 1 / -1; font-size: var(--text-xs); color: var(--muted); }
.msg { max-width: min(72%, 560px); display: flex; flex-direction: column; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 7px 12px; border-radius: var(--radius-bubble); white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--msg-font, var(--fs-bubble)); } /* 16px, Signal's message size; Settings › Message font size overrides */
:root[data-font="small"] { --msg-font: var(--text-md); }
:root[data-font="large"] { --msg-font: var(--text-xl); }
:root[data-font="xlarge"] { --msg-font: var(--text-2xl); }
.msg.in .bubble, .msg-preview.in .bubble { background: var(--bubble-in); color: var(--bubble-in-text); }
.msg.out .bubble, .msg-preview.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); }
/* Clusters: bubbles from one author within 3 minutes sit tighter, squarer where they touch, and share the last one's time */
.msg.cont { margin-top: -1px; }
.msg.in.cont .bubble { border-top-left-radius: 6px; }
.msg.in.more .bubble { border-bottom-left-radius: 6px; }
.msg.out.cont .bubble { border-top-right-radius: 6px; }
.msg.out.more .bubble { border-bottom-right-radius: 6px; }
.meta.compact { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; } /* still read by screen readers */
.msg.failed .bubble { opacity: .65; }
.msg.deleted .bubble { font-style: italic; opacity: .75; }
.msg .bubble.jumbo { background: transparent; padding: 0 2px; line-height: 1.15; }
.bubble.jumbo-1 { font-size: 3rem; }
.bubble.jumbo-2 { font-size: 2.5rem; }
.bubble.jumbo-3 { font-size: 2rem; }
.bubble.jumbo-4, .bubble.jumbo-5 { font-size: var(--text-3xl); }
.safety-qr { display: flex; justify-content: center; margin: 12px 0 4px; }
.safety-qr svg { width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: var(--radius-sm); }
#timer-form .inline-form #timer-n { flex: 1 1 6em; min-width: 6em; min-height: var(--field); }
#timer-form .inline-form select { min-height: 44px; }
.reactions-emoji { font-size: var(--text-2xl); width: 2rem; text-align: center; }
.calls-filter { display: flex; gap: 8px; margin: 4px 0 8px; }
.calls-filter button { min-height: 44px; padding: 0 16px; border-radius: var(--radius-full); border: 1px solid var(--border); background: var(--bg); color: inherit; }
.calls-filter button[aria-pressed="true"] { background: var(--bg-active); border-color: transparent; color: var(--text); font-weight: 600; } /* tonal, as the folder chips */
.style-custom { display: flex; align-items: center; gap: 8px; margin-top: 8px; min-height: 44px; }
.style-custom input { width: 44px; height: 44px; padding: 0; border: 0; background: none; }
.edit-size { display: flex; align-items: center; gap: 8px; min-height: 44px; color: #fff; }
.edit-size input { flex: 1; min-height: 44px; }
.np-days { display: flex; flex-wrap: wrap; gap: 4px 12px; }
#np-sched-set .inline-form { align-items: center; flex-wrap: wrap; }
#np-sched-set input[type=time] { min-height: 44px; flex: 0 1 8em; }
.np-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px 6px 16px; background: var(--bg-hover); font-size: var(--text-md); }
.np-banner button { min-height: 44px; }
#np-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#np-list .member-name { flex: 1 1 8em; }
.select-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); }
.select-bar button { min-height: 44px; }
.select-bar #select-count, .select-bar #chats-count { flex: 1; text-align: center; font-weight: 600; }
#chats-bar { flex-wrap: wrap; justify-content: center; }
#chats-bar #chats-count { flex-basis: 100%; order: -1; }
.conversation-list li:has(.select-check) { position: relative; padding-inline-start: 52px; }
.conversation-list li.selected { background: var(--bg-hover); }
.composer.select-hidden { display: none; }
.msg.selected { background: var(--bg-active); box-shadow: 0 0 0 100vmax var(--bg-active); clip-path: inset(0 -100vmax); } /* the whole row tinted (the shadow paints only outside the row: walkthrough 2026-11-15 FW6), as Signal and Messenger; the check says it too */
.msg:has(.select-check) { cursor: pointer; position: relative; padding-inline-start: 48px; }
.msg.out:has(.select-check) { max-width: calc(min(72%, 560px) + 48px); }
.select-check { position: absolute; left: 0; top: 50%; translate: 0 -50%; width: 44px; height: 44px; border: 0; background: none; padding: 0; display: grid; place-items: center; }
.select-check::before { content: ""; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); box-sizing: border-box; }
.select-check[aria-checked="true"]::before { background: var(--accent) radial-gradient(circle, #fff 0 3px, transparent 4px); border-color: var(--accent); }
.request-groups { display: block; font-size: var(--text-sm); margin-top: 2px; }
.draft-label { color: var(--danger); font-style: italic; }
.msg-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg.highlight .bubble { box-shadow: 0 0 0 3px var(--accent); }
@media (prefers-reduced-motion: no-preference) { .bubble { transition: box-shadow .3s; } }
.quote-thumb { float: right; width: 40px; height: 40px; object-fit: cover; border-radius: var(--radius-xs); margin-left: 8px; }
.quote { display: block; width: 100%; min-width: 120px; text-align: left; border: 0; border-left: 3px solid currentColor; border-radius: var(--radius-sm); background: rgba(0, 0, 0, .08); color: inherit; padding: 4px 8px; margin: 2px 0 6px; font-size: var(--text-sm); white-space: normal; }
.msg.out .quote { background: rgba(255, 255, 255, .18); }
.bubble:has(.photo) .quote { width: auto; margin: 4px 4px 6px; }
.quote-author { display: block; font-weight: 600; }
.forwarded { font-size: var(--text-xs); font-style: italic; opacity: .8; margin-bottom: 2px; }
.mention { font-weight: 600; background: rgba(127, 127, 127, .2); border-radius: var(--radius-xs); padding: 0 2px; }
.mention.me { background: rgba(255, 190, 0, .4); }
.mention-picker { list-style: none; margin: 0 16px 4px; padding: 4px; max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); box-shadow: var(--shadow); }
.mention-picker li { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.mention-picker li[aria-selected="true"] { background: var(--bg-hover); }
@media (hover: hover) { .mention-picker li:hover { background: var(--bg-hover); } }
.sheet-search { width: 100%; border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 8px 12px; }
/* UC-CF-1 chat folders */
.folder-tabs { display: flex; gap: 6px; padding: 4px 12px 8px; overflow-x: auto; scrollbar-width: none; flex: none; }
.folder-tabs[hidden] { display: none; }
.folder-tab { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; border-radius: var(--radius-full); border: 1px solid var(--border); background: var(--bg); color: var(--text); font-weight: 600; font-size: var(--text-md); white-space: nowrap; }
.folder-tab[aria-pressed="true"] { background: var(--bg-active); color: var(--text); border-color: transparent; } /* tonal: accent is kept for unread and New chat */
.folder-list { list-style: none; margin: 8px 0; padding: 0; }
.folder-row { display: flex; align-items: center; gap: 4px; min-height: 48px; }
.folder-row .folder-name { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.folder-row .icon-btn { width: 44px; height: 44px; }
.folder-row .icon-btn:disabled { opacity: .35; }
.folder-set { border: 1px solid var(--border); border-radius: var(--radius-md); margin: 12px 0; padding: 8px 12px; min-width: 0; }
.folder-set[hidden] { display: none; }
.folder-set legend { font-weight: 600; padding: 0 4px; }
#folder-form > label:first-child { display: block; font-weight: 600; margin-bottom: 4px; }
#folder-name { width: 100%; }
#fwd-form { margin-top: var(--space-2); }
.pick-list, .media-list { list-style: none; margin: 8px 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; }
.pick input { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.pick-name, .media-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; } /* minmax(0): a photo's own width pushed the third column off a 384 px screen (media audit 2026-11-14) */
.media-grid :is(.photo, .blur, .media-pending) { width: 100%; max-width: none; min-width: 0; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }
.media-grid .photo-error { aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--bg-hover); font-size: var(--text-xs); }
.media-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 4px; border: 0; background: none; text-align: left; }
@media (hover: hover) { .media-row:hover { background: var(--bg-hover); } }
.media-meta { flex: none; font-size: var(--text-xs); color: var(--muted); }
.file-card, .voice { display: flex; align-items: center; gap: 10px; min-width: 200px; white-space: normal; }
.file-card { width: 280px; max-width: 100%; } /* a set width: its one-line name shortens instead of widening the bubble off the screen */
.file-info { flex: 1; min-width: 0; }
.file-name { font-weight: 600; display: flex; min-width: 0; white-space: nowrap; } /* one line; the extension always shows */
.file-base { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.file-ext { flex: none; }
.file-size { font-size: var(--text-xs); opacity: .8; }
.file-save { flex: none; padding: 4px 12px; border-radius: var(--radius-md); background: transparent; color: inherit; border-color: currentColor; }
.voice-play { flex: none; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(0, 0, 0, .1); color: inherit; }
.msg.out .voice-play { background: rgba(255, 255, 255, .2); }
.voice-track { flex: 1; height: 4px; border-radius: 2px; background: rgba(127, 127, 127, .35); overflow: hidden; }
.voice-fill { height: 100%; background: currentColor; }
.voice-time { font-size: var(--text-xs); font-variant-numeric: tabular-nums; min-width: 32px; }
.voice-speed { border: 0; border-radius: var(--radius-md); padding: 2px 8px; font-size: var(--text-xs); font-weight: 600; background: rgb(128 128 128 / 0.2); color: inherit; font-variant-numeric: tabular-nums; min-width: 44px; min-height: 44px; }
.lock { border: 0; padding: 0; margin: 0; width: 100%; height: 100%; max-width: none; max-height: none; background: var(--bg); color: var(--text); }
.lock[open] { display: grid; place-items: center; }
.lock::backdrop { background: #000; }
.lock-card { display: grid; gap: 12px; justify-items: center; text-align: center; }
.lock-card button { min-width: 160px; min-height: 44px; }
.quote-text { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; opacity: .9; }
.row { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.msg.out .row { flex-direction: row-reverse; }
.bubble:has(.photo) { padding: 4px; }
.bubble:has(.photo) .caption { padding: 4px 8px 2px; }
.photo { display: block; border-radius: var(--radius-md); max-width: min(320px, 100%); min-width: 128px; height: auto; object-fit: cover; background: var(--bg-hover); } /* a tiny image stays a tappable size, as Signal's minimum */
.photo-error { padding: 8px; font-size: var(--text-sm); }
button.photo-error { display: flex; align-items: center; gap: 8px; text-align: start; min-height: 44px; padding: 12px 16px; border: 0; border-radius: var(--radius-sm); background: var(--bg-hover); color: inherit; cursor: pointer; }
.upload-ring svg { width: 100%; height: 100%; }
.upload-ring::after { content: ""; position: absolute; inset: -4px; } /* a 44 px target even when drawn at 36 */
.uploading:has(> .file-card) > .upload-ring { right: auto; left: -7px; width: 36px; height: 36px; padding: 0; } /* a file: the ring takes the icon's place, as Signal */
.uploading > .file-card > svg:first-child { visibility: hidden; }
.uploading { position: relative; }
/* An album (AC-AT-17), as Signal Desktop's ImageGrid: 150 px pairs, 200 + 2 x 100, 2 x 2, 2 over 3 with "+N" */
.album { display: grid; gap: 2px; width: 302px; max-width: 100%; border-radius: var(--radius-md); overflow: hidden; }
.album.n2, .album.n4 { grid-template-columns: 1fr 1fr; }
.album.n3 { grid-template-columns: 2fr 1fr; }
.album.n3 > .tile:first-child { grid-row: span 2; aspect-ratio: auto; }
.album.n5 { grid-template-columns: repeat(6, 1fr); }
.album.n5 > .tile:nth-child(-n+2) { grid-column: span 3; }
.album.n5 > .tile:nth-child(n+3) { grid-column: span 2; }
.album > .tile { position: relative; aspect-ratio: 1; min-width: 0; overflow: hidden; background: var(--bg-hover); }
.album .tile > * { width: 100%; height: 100%; }
.album .tile .photo, .album .tile .blur, .album .tile video { width: 100%; height: 100%; max-width: none; min-width: 0; object-fit: cover; border-radius: 0; }
.album .tile .media-load, .album .tile .video-thumb, .album .tile .photo-error { min-width: 0; border-radius: 0; }
.album .more { position: absolute; inset: 0; border: 0; background: rgb(0 0 0 / .45); color: #fff; font-size: 1.5rem; font-weight: 600; cursor: pointer; }
.photo-nav { position: absolute; top: 50%; translate: 0 -50%; z-index: 2; width: 48px; height: 48px; border-radius: 50%; background: rgb(0 0 0 / .45); color: #fff; }
.photo-prev { left: 12px; }
.photo-next { right: 12px; }
.upload-ring { position: absolute; inset: 0; margin: auto; width: 48px; height: 48px; padding: 2px; border: 0; border-radius: 50%; background: rgb(0 0 0 / .55); color: #fff; display: grid; place-items: center; cursor: pointer; }
.link-card { display: flex; gap: 10px; margin-top: 6px; padding: 8px; border-radius: var(--radius-md); background: rgba(127, 127, 127, .12); color: inherit; text-decoration: none; max-width: 320px; }
.link-img { flex: none; width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; }
.link-info { display: grid; gap: 2px; min-width: 0; }
.link-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-desc { font-size: var(--text-sm); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.link-host { font-size: var(--text-xs); opacity: .8; }
.media-load { min-height: 44px; padding: 8px 14px; border: 1px dashed var(--border); border-radius: var(--radius-md); background: var(--bg-hover); color: inherit; font: inherit; font-size: var(--text-md); cursor: pointer; }
/* AC-VI-02: the first frame, a round play button and the length, as Signal's video bubble */
.video-thumb { position: relative; display: block; padding: 0; border: 0; border-radius: var(--radius-md); overflow: hidden; background: #000; cursor: pointer; }
.video { display: block; width: min(320px, 100%); height: auto; max-height: 420px; pointer-events: none; } /* width/height attributes keep its box before the first frame */
.video-play { position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; }
.video-length { position: absolute; left: 8px; bottom: 8px; padding: 1px 6px; border-radius: var(--radius-sm); background: rgba(0, 0, 0, .55); color: #fff; font-size: var(--text-xs); }
.video-length:empty { display: none; }
.video.loading { width: 320px; max-width: 100%; aspect-ratio: var(--ar, 16 / 9); max-height: 420px; overflow: hidden; background: var(--bg-hover); } /* the video's box, not a narrow strip */
.photo.zoomable { cursor: zoom-in; }
.photo-dialog { border: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); margin: 0; inset: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; box-sizing: border-box; background: #000; color: #f2f4f4; } /* black, as Signal's viewer (iOS let the chat show through the backdrop) */
.photo-dialog[open] { display: flex; flex-direction: column; }
.photo-dialog::backdrop { background: rgba(0, 0, 0, .9); }
.photo-head { display: flex; align-items: center; gap: var(--space-1); min-height: var(--bar); padding: 0 var(--space-1); }
.photo-title { display: grid; min-width: 0; margin: 0; }
.photo-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#photo-who { font-size: var(--fs-head); font-weight: 600; }
.photo-when { font-size: var(--fs-foot); opacity: .75; }
.photo-caption { margin: 0; padding: var(--space-3) var(--space-4) 0; font-size: var(--fs-body); max-height: 30dvh; overflow-y: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.photo-bar { display: flex; justify-content: space-around; padding: var(--space-2) var(--space-4); }
.photo-dialog .icon-btn { width: var(--target); height: var(--target); color: inherit; }
.photo-dialog img, .photo-dialog video { display: block; flex: 1; min-height: 0; width: 100%; object-fit: contain; } /* fit between the bars, small ones too, as Signal's viewer */
.photo-dialog [hidden] { display: none; }
/* UC-IE-1 photo editor: always dark, as Signal's */
.edit-dialog { border: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #000; color: #fff; color-scheme: dark; }
.edit-dialog[open] { display: flex; flex-direction: column; }
.edit-dialog::backdrop { background: #000; }
.edit-dialog .icon-btn { color: #fff; width: 44px; height: 44px; }
.edit-dialog .icon-btn[aria-pressed="true"] { background: #fff; color: #000; }
.edit-dialog .icon-btn:disabled { color: #8a8f94; }
.edit-top { display: flex; align-items: center; gap: 4px; padding: 6px 8px; }
.edit-modes { display: flex; gap: 4px; margin-left: auto; }
.edit-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; margin: 0 12px; }
.edit-stage canvas { display: block; touch-action: none; }
.edit-crop { position: absolute; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .6); outline: 2px solid #fff; touch-action: none; cursor: move; }
.edit-corner { position: absolute; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; touch-action: none; }
.edit-corner::after { content: ''; position: absolute; width: 18px; height: 18px; border: 0 solid #fff; filter: drop-shadow(0 0 1px #000); }
.edit-corner.nw { left: -22px; top: -22px; cursor: nwse-resize; } .edit-corner.nw::after { left: 20px; top: 20px; border-width: 4px 0 0 4px; }
.edit-corner.ne { right: -22px; top: -22px; cursor: nesw-resize; } .edit-corner.ne::after { right: 20px; top: 20px; border-width: 4px 4px 0 0; }
.edit-corner.sw { left: -22px; bottom: -22px; cursor: nesw-resize; } .edit-corner.sw::after { left: 20px; bottom: 20px; border-width: 0 0 4px 4px; }
.edit-corner.se { right: -22px; bottom: -22px; cursor: nwse-resize; } .edit-corner.se::after { right: 20px; bottom: 20px; border-width: 0 4px 4px 0; }
.edit-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 8px 12px; margin: 0; }
.edit-tools[hidden] { display: none; }
.edit-hint { color: #d0d4d8; font-size: var(--text-md); margin: 0; }
.edit-switch { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: var(--radius-full); background: #2a2d30; cursor: pointer; }
.edit-switch[hidden] { display: none; }
.edit-switch input { width: 20px; height: 20px; margin: 0; accent-color: #2bb3a3; }
.edit-choice { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-width: 0; max-width: 100%; border: 0; padding: 0; margin: 0; }
.edit-choice label { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: var(--radius-full); background: #2a2d30; cursor: pointer; }
.edit-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.edit-choice label:has(input:checked) { background: #fff; color: #000; }
.edit-choice label:has(input:focus-visible) { outline: 2px solid #2bb3a3; outline-offset: 2px; }
.edit-dialog select, #edit-reset { min-height: 44px; background: #2a2d30; color: #fff; border: 0; border-radius: var(--radius-full); padding: 0 14px; }
.edit-color { width: min(260px, 60vw); height: 44px; accent-color: #fff; appearance: none; background: transparent; }
.edit-color::-webkit-slider-runnable-track { height: 10px; border-radius: var(--radius-xs); background: linear-gradient(to right, #000 0 7%, red 7%, #ff0 22%, #0f0 37%, #0ff 52%, #00f 67%, #f0f 82%, #ff0051 95%, #fff 95%); }
.edit-color::-webkit-slider-thumb { appearance: none; width: 24px; height: 24px; margin-top: -7px; border-radius: 50%; background: #fff; border: 2px solid #000; }
.edit-send { display: flex; align-items: center; gap: 8px; padding: 8px 12px 12px; }
.edit-text { min-width: 0; width: min(260px, 70vw); min-height: 44px; background: #2a2d30; color: #fff; border: 0; border-radius: var(--radius-full); padding: 0 16px; }
.edit-text::placeholder { color: #b8bdc2; }
.edit-send input { flex: 1; min-width: 0; min-height: 44px; background: #2a2d30; color: #fff; border: 0; border-radius: var(--radius-full); padding: 0 16px; }
.edit-send input[hidden] { display: none; }
.edit-send input::placeholder { color: #b8bdc2; }
.edit-send .send { margin-left: auto; width: 48px; height: 48px; background: #2bb3a3; color: #06201d; }
.react-btn { opacity: 0; border: 0; background: transparent; padding: 4px; border-radius: 50%; color: var(--muted); flex: none; }
.react-btn:focus-visible, .react-btn[aria-expanded="true"] { opacity: 1; }
@media (hover: hover) { .msg:hover .react-btn { opacity: 1; } }
@media (hover: hover) { .react-btn:hover { background: var(--bg-hover); } }
.react-picker { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-full); padding: 4px; box-shadow: var(--shadow); margin: 4px 0; }
.react-picker button { border: 0; background: transparent; font-size: var(--text-xl); padding: 2px 6px; border-radius: 50%; }
.react-picker button[aria-pressed="true"] { background: var(--bg-hover); }
@media (hover: hover) { .react-picker button:hover { background: var(--bg-hover); } }
.reactions { display: flex; gap: 4px; margin: -4px 8px 0; position: relative; flex-wrap: wrap; }
.reactions button { border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius-md); padding: 0 6px; font-size: var(--text-sm); line-height: 1.5; }
.reactions button[aria-pressed="true"] { border-color: var(--accent); }
.reactions button { position: relative; min-width: 44px; }
.reactions button::after { content: ""; position: absolute; inset: -11px 0; } /* 44px tall hit area, same look */
@media (hover: none) { .react-btn { display: none; } } /* touch: long-press › React, as Signal (no smiley beside every bubble) */
.meta { font-size: var(--text-2xs); color: var(--muted); display: flex; align-items: center; gap: 4px; margin: 2px 6px 4px; }
.meta svg { display: block; }
.meta span { display: inline-flex; align-items: center; gap: 2px; }
.status-read { color: var(--accent); }
/* Chat color and wallpaper (UC-CS-1): --bubble-out and --wallpaper set per chat from domain/chat-style.js. */
.messages.has-wallpaper { background: var(--wallpaper); }
.messages.has-wallpaper .day, .messages.has-wallpaper .system, .messages.has-wallpaper .meta:not(.in-bubble) { background: var(--bg); border-radius: var(--radius-md); padding: 1px 8px; width: fit-content; }
.messages.has-wallpaper .chat-intro { background: var(--bg); border-radius: var(--radius-lg); padding: 16px 20px; } /* the name and @username stay readable (walkthrough 2026-11-15 S2) */
.messages.has-wallpaper .unread-divider > span { background: var(--bg); border-radius: var(--radius-md); padding: 1px 8px; } /* "Unread messages" too */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .messages.has-wallpaper.dim { box-shadow: inset 0 0 0 100vmax rgb(0 0 0 / 0.2); } }
:root[data-theme="dark"] .messages.has-wallpaper.dim { box-shadow: inset 0 0 0 100vmax rgb(0 0 0 / 0.2); }
.style-preview { flex: none; height: 120px; border-radius: var(--radius-md); border: 1px solid var(--border); overflow: hidden; margin: 0 0 8px; }
.style-preview .msg { max-width: 70%; }
.swatch-set { border: 0; margin: 8px 0; padding: 0; min-width: 0; }
.swatch-set legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 4px; }
.swatch { position: relative; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; }
.swatch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.swatch span { width: 34px; height: 34px; border-radius: 50%; background: var(--sw); border: 1px solid var(--border); display: grid; place-items: center; font-size: var(--text-xs); color: var(--muted); }
.swatch input:checked + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.swatch input:focus-visible + span { outline: 3px solid var(--text); outline-offset: 2px; }
.scan-video { display: block; width: 100%; max-height: 50vh; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-md); background: #000; }
.blur { display: block; max-width: 100%; height: auto; border-radius: var(--radius-md); filter: saturate(1.1); }
.media-load.has-blur { position: relative; padding: 0; overflow: hidden; min-width: 200px; }
.media-load.locked { cursor: default; }
.media-load.locked span { display: inline-flex; align-items: center; gap: var(--space-1); }
.media-load.has-blur .blur { width: 100%; }
.media-load.has-blur > span { position: absolute; inset: auto 8px 8px 8px; background: rgb(0 0 0 / .55); color: #fff; border-radius: var(--radius-sm); padding: 6px 8px; }
.video.loading .blur { width: 100%; height: 100%; object-fit: cover; }
/* A photo in a bubble keeps a sane box, as Signal's: at most 420 px tall (a 1080×6000 screenshot filled more than the
   screen) and at least 96 px (an 8000×1200 panorama was a 42 px strip), cropped to fill (media audit 2026-11-14). */
.msg :is(.photo, .blur, .media-ph):not(.album *) { max-height: 420px; min-height: 96px; object-fit: cover; }
/* A photo or video on its way down: Signal's spinner over its BlurHash (attachment audit 2026-11-14). */
.media-pending { position: relative; display: block; width: fit-content; max-width: 100%; }
.album .tile .media-pending, .strip .media-pending { width: 100%; height: 100%; }
.media-pending::after { content: ""; position: absolute; left: 50%; top: 50%; width: 32px; height: 32px; margin: -19px 0 0 -19px; border: 3px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; background: rgba(0, 0, 0, .3); animation: spin 1s linear infinite; pointer-events: none; }
@keyframes spin { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) { .media-pending::after { animation-duration: 3s; } }
.media-ph { display: block; width: 320px; max-width: 100%; aspect-ratio: var(--ar); background: var(--bg-hover); border-radius: var(--radius-md); }
.contact-card { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; row-gap: 2px; align-items: center; min-width: 200px; }
.contact-card > .avatar { grid-row: span 2; }
.contact-card > .contact-name:last-of-type { grid-row: span 2; } /* no username line: the name sits level with the avatar */
.contact-card > .contact-open { grid-column: 1 / -1; }
.contact-name { font-weight: 600; }
.contact-user { opacity: .8; font-size: var(--text-sm); }
.contact-open { margin-top: 6px; min-height: 44px; border: 0; border-radius: var(--radius-md); background: rgb(255 255 255 / .2); color: inherit; font: inherit; font-weight: 600; }
.msg.in .contact-open { background: var(--bg); color: var(--text); }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.info-label { color: var(--muted); }
.info-group h3 { font-size: var(--text-md); margin: 14px 0 4px; }
.info-people { list-style: none; margin: 0; padding: 0; }
.info-people li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--border); }
.info-time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.info-sealed { color: var(--muted); font-size: var(--text-sm); margin-inline: .5rem; white-space: nowrap; }
.edits-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.edits-list .msg { max-width: 90%; }
.edited { border: 0; background: none; color: inherit; padding: 0; font: inherit; text-decoration: underline; min-width: 44px; min-height: 44px; margin: -15px 0; } /* 44 px target, same line height; no side margin, so the time and ticks keep their gap (walkthrough 2026-11-15 E1) */
.not-sent { color: var(--danger); white-space: normal; }
.retry { position: relative; border: 0; background: none; color: var(--danger); padding: 0; font-size: var(--text-xs); text-decoration: underline; }
.retry::after { content: ""; position: absolute; inset: -14px -8px; } /* bigger hit area, same look */

/* Jump to latest */
.jump-latest { position: absolute; right: calc(16px + env(safe-area-inset-right)); bottom: 12px; z-index: 2; width: 40px; height: 40px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); animation: jump-in .16s ease-out; }
@media (hover: hover) { .jump-latest:hover { background: var(--bg-hover); } }
.jump-latest .badge { position: absolute; top: -9px; right: -5px; min-width: 20px; box-sizing: border-box; text-align: center; line-height: 18px; padding: 0 6px; box-shadow: 0 0 0 2px var(--bg); }
@keyframes jump-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .jump-latest { animation: none; } }

.typing { align-self: flex-start; margin: 0 16px 8px; background: var(--bubble-in); border-radius: var(--radius-bubble); padding: 10px 14px; display: flex; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .typing span, .rec-dot { animation: none; } }

.reply-bar { display: flex; align-items: center; gap: 8px; margin: 8px 16px 0; padding: 4px 4px 4px 12px; border-left: 3px solid var(--accent); border-radius: var(--radius-md); background: var(--bg-input); }
.reply-main { flex: 1; min-width: 0; font-size: var(--text-sm); }
.reply-label { font-weight: 600; color: var(--accent); }
.reply-text { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-note { margin: 6px 16px 0; font-size: var(--text-sm); color: var(--muted); }
/* The note over an open sheet or the viewer (UC-DS-1 D-DS-15), as Signal's toast: dark pill, bottom centre, above the bars. */
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); translate: -50% 0; width: max-content; max-width: calc(100vw - 32px); margin: 0; padding: 10px 16px; border-radius: 20px; background: rgba(28, 28, 30, .94); color: #fff; font-size: var(--fs-foot, .875rem); line-height: 1.35; text-align: center; pointer-events: none; }
.toast.action { display: flex; align-items: center; gap: 12px; padding: 4px 6px 4px 16px; pointer-events: auto; text-align: start; } /* UC-CL-1 AC-CL-10: a snackbar, as Signal */
.toast-action { min-height: 44px; padding: 0 12px; border: 0; border-radius: 16px; background: none; color: #8ee3d2; font: inherit; font-weight: 600; } /* light accent on the dark toast, about 9.6:1 */
.android:has(.toast:not([hidden])) .compose-btn { translate: 0 -60px; } /* the FAB moves up over a toast, as Material's snackbar */
@media (prefers-reduced-motion: no-preference) { .android .compose-btn { transition: translate var(--dur-fast) var(--ease-out); } }
.composer.blank .send, .composer:not(.blank):not(.recording) :is(.mic, .cam), .composer.recording :is(#attach-btn, .emoji-btn, .cam), .composer.recording textarea, .composer.recording .send { display: none; }
.mic { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.composer.recording .mic, html.ios .composer.recording .mic { background: var(--danger); color: #fff; border-radius: 50%; } /* iOS tints composer icons: not this one (on red) */
.rec-bar { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 8px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1.2s infinite; }
#rec-time { font-variant-numeric: tabular-nums; }
.rec-hint { flex: 1; color: var(--muted); font-size: var(--text-sm); text-align: center; }
/* Slide up to lock, as Signal's: a pill over the held mic */
.mic { position: relative; }
.rec-lock { position: absolute; bottom: calc(100% + 12px); left: 50%; translate: -50% 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 6px; border-radius: var(--radius-full); background: var(--surface, var(--bg)); color: var(--muted); box-shadow: var(--elev); pointer-events: none; }
.rec-lock[hidden] { display: none; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px calc(16px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) 16px; border-top: 1px solid var(--border); }
.composer .icon-btn { width: 40px; height: 40px; flex: none; }
.composer textarea {
  flex: 1; resize: none; border: 0; background: var(--bg-input); border-radius: var(--radius-bubble); padding: 9px 14px;
  max-height: 160px; line-height: 1.4;
}
.send { border: 0; background: var(--accent); color: var(--accent-text); border-radius: 50%; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; flex: none; }

/* Dialog */
.dialog { border: 0; border-radius: var(--radius-lg); padding: 24px; max-width: 420px; width: calc(100% - 32px); background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
/* Sheet handle (NFR-010-08, app.js initSheets): tap or swipe down closes, as Signal's BottomSheets.Handle (a 48 dp bar).
   A 64×44 button, so it is a real target; on a wide screen the sheet is a centered dialog and the handle is its ✕. */
.sheet-handle { display: block; position: relative; width: 64px; height: 44px; margin: -20px auto 0; padding: 0; border: 0; background: none; border-radius: var(--radius-md); touch-action: none; cursor: pointer; }
.sheet-handle > svg { display: none; } /* a grabber in a sheet; the ‹ of a page (below) */
.dialog-head { display: contents; } /* UC-DS-1: in a sheet the head is only its grabber; a page makes it a bar (below) */
/* UC-DS-1 Form sheet bar (D-DS-2, HIG sheets.md, Messenger): Cancel at the leading edge, the title centered, the action trailing. */
.sheet-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3);
  position: sticky; top: 0; z-index: 1; background: inherit; } /* Cancel and the action stay in reach when the keyboard scrolls the sheet (UIKit's sheet nav bar; walkthrough 2026-11-15) */
.sheet-bar > h2 { margin: 0; text-align: center; font-size: var(--text-lg); }
.sheet-bar > button { min-height: 44px; padding: 0 var(--space-2); border: 0; background: none; color: var(--accent); font: inherit; font-size: var(--text-lg); }
.sheet-bar > button:first-child { justify-self: start; margin-inline-start: calc(-1 * var(--space-2)); color: var(--text); }
.sheet-bar > button:last-child { justify-self: end; margin-inline-end: calc(-1 * var(--space-2)); font-weight: 600; }
.sheet-bar > button:disabled, .form-sheet:has(form:invalid) .sheet-bar > button:last-child { color: var(--muted); }
.form-sheet:has(form:invalid) .sheet-bar > button:last-child { pointer-events: none; } /* greyed until the form can be sent (D-DS-2) */
/* UC-DS-1 Page action (D-DS-6, Messenger's edit screens): Save trails the page bar, an accent text button. */
.dialog.page > .dialog-head > .primary { margin-inline-start: auto; min-height: 44px; padding: 0 var(--space-2); border: 0; background: none;
  color: var(--accent); font: inherit; font-size: var(--text-lg); font-weight: 600; }
.dialog.page:has(form:invalid) > .dialog-head > .primary, .dialog.page > .dialog-head > .primary:disabled { color: var(--muted); pointer-events: none; }
@media (min-width: 721px) { /* a page is a dialog here: its head is a row too, clear of the ✕ */
  .dialog.page > .dialog-head:has([data-page-title]) { display: flex; align-items: center; gap: var(--space-2); padding-inline-end: 44px; margin-bottom: var(--space-2); }
  .dialog.page > .dialog-head > [data-page-title] { margin: 0; }
}
.sheet-handle::before { content: ""; position: absolute; left: 16px; right: 16px; top: 16px; height: 4px; border-radius: 2px; background: var(--muted); }
.dialog.dragging { transition: none; }
@media (prefers-reduced-motion: no-preference) { .dialog { transition: translate var(--dur-fast) var(--ease-out); } }
@media (min-width: 721px) {
  .sheet-handle { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; margin: 0; color: var(--muted); }
  .sheet-handle::before { display: none; }
  .sheet-handle > svg:last-child { display: block; margin: auto; } /* ✕ (app.js ICONS.close) */
  .form-sheet .sheet-handle { display: none; } /* Cancel is in its bar */
  @media (hover: hover) { .sheet-handle:hover { background: var(--bg-hover); color: var(--text); } }
  .dialog > h2 { padding-right: 36px; }
}
.dialog h2 { margin: 0 0 8px; font-size: var(--text-xl); }
.dialog h3 { margin: 18px 0 6px; font-size: var(--text-md); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
/* Sheets' action lists: one grouped list with dividers (as Signal's menus and the Settings rows) */
.menu { display: grid; margin: 16px 0 8px; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.menu:empty { display: none; }
.menu > * { border: 0; border-radius: 0; }
.menu > :not([hidden]) ~ :not([hidden]) { border-top: 1px solid var(--border); }
.menu button { text-align: left; padding: 12px 16px; background: none; }
@media (hover: hover) { .menu button:hover { background: var(--bg-hover); } }
/* New group, as Signal's New chat screen: a row with a round icon, not a lone bordered box that reads as a text field */
#new-group-btn, #new-chat-scan { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.row-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--bubble-in); color: var(--accent); }
.menu .timer-select { border: 0; border-radius: 0; }
/* Long-press reactions row, as Signal */
.sheet-reactions { display: flex; justify-content: space-between; gap: var(--space-1); margin: 0 0 var(--space-2); }
.sheet-reactions[hidden] { display: none; }
.sheet-reactions button { min-width: 0; } /* seven in a row on a narrow sheet: they share the width */
@media (min-width: 721px) { #msg-dialog .sheet-reactions { margin-inline-end: 44px; } } /* clear of the sheet's ✕ on a wide screen */
.sheet-reactions .react-more { font-size: 1.5rem; font-weight: 300; color: var(--muted); }
.react-other { width: 100%; min-height: var(--target, 44px); margin: 0 0 var(--space-2); padding: 0 var(--space-4); border: 1px solid var(--outline); border-radius: var(--radius-full); background: var(--bg); color: var(--text); font-size: 1.25rem; }
/* Onboarding (design canvas › Onboarding): an @ before the username; a hint under Create until the terms are agreed (not
   dimmed: a dimmed live button failed contrast) */
.at-field { position: relative; }
.at-sign { position: absolute; left: 16px; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.onboarding-card .at-field input#register-name { padding-left: 38px; width: 100%; }
.onboarding-card #register-display { width: 100%; } /* AC-RG-05 */
#register-form:has(#register-terms:checked) #terms-hint { display: none; }
.terms-hint { text-align: center; }
/* A page's timer select stays narrow, so its label keeps one line */
.dialog.page #timer-row .timer-label { flex: 1; min-width: 0; }
.dialog.page #timer-select { max-width: 45%; text-overflow: ellipsis; } /* "30 seconds" was cut to "30 secon" at 26% on an iPhone X (device audit 2026-11-14) */
html.ios .dialog.page #timer-row { gap: var(--space-3); }
/* Attach sheet: round 56 tiles in the accent container, a 12/500 label under each (design canvas › Attach) */
.attach-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--space-4) var(--space-2); padding: var(--space-2) 0 var(--space-4); }
.attach-tiles button { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); min-height: var(--target); padding: 0; border: 0; background: none; color: var(--text); font-size: var(--fs-cap); font-weight: 500; text-align: center; }
.attach-tiles button[hidden] { display: none; }
.attach-tiles svg { box-sizing: content-box; padding: 16px; border-radius: 50%; background: var(--accent-cont); color: var(--on-accent-cont); }
/* AC-RE-04: the message the sheet acts on, on its own side, lifted; long ones fade out at 40% of the screen */
.msg-preview { display: flex; margin: 0 0 var(--space-3); max-height: 40vh; overflow: hidden; pointer-events: none; -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
.msg-preview[hidden] { display: none; }
.msg-preview.out { justify-content: flex-end; }
.msg-preview .bubble { max-width: 85%; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
#msg-reply { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M10 8L4 13l6 5M4 13h10a6 6 0 0 1 6 6'/></svg>"); }
#msg-copy { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M8 8h11v12H8zM5 16V4h11'/></svg>"); }
#msg-forward, #select-forward { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M14 8l6 5-6 5M20 13H10a6 6 0 0 0-6 6'/></svg>"); }
#msg-pin, #chat-pin { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M15 3l6 6-3 1-4 4 1 5-2 2-4-4-5 5M9 15l-4-4 2-2 5 1 4-4z'/></svg>"); }
#msg-edit { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 20h4L19 9l-4-4L4 16zM14 6l4 4'/></svg>"); }
#msg-info { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM12 11v5M12 8h.01'/></svg>"); }
#msg-select, #chat-select { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18zM8 12l3 3 5-6'/></svg>"); }
#msg-delete-me, #chat-delete, #chats-delete, #select-delete { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13'/></svg>"); }
#msg-delete-all { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13'/></svg>"); }
/* UC-RE-1 (design canvas › MessageActions), as Signal's long-press on a phone: no sheet; the reactions, the message and a
   short menu float on the message's side over a blurred chat. Each action leads with its icon (iOS: trails it). */
@media (max-width: 720px) {
  html #msg-dialog.dialog.floating { inset: 0; width: 100%; height: 100%; max-height: none; margin: 0; border-radius: 0; background: transparent; box-shadow: none; animation: none;
    padding: calc(var(--space-4) + env(safe-area-inset-top)) calc(var(--space-3) + env(safe-area-inset-right)) calc(var(--space-4) + env(safe-area-inset-bottom)) calc(var(--space-3) + env(safe-area-inset-left)); }
  #msg-dialog[open] { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: var(--space-2); }
  #msg-dialog[data-dir="out"] { align-items: flex-end; }
  #msg-dialog::backdrop { background: var(--scrim, rgba(14, 17, 18, .40)); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
  #msg-dialog > .dialog-head { display: none; }
  #msg-dialog .sheet-reactions { margin: 0; padding: var(--space-1); gap: 0; border-radius: var(--radius-full); background: var(--surface); box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
  #msg-dialog .sheet-reactions button { flex: none; width: 44px; height: 44px; min-height: 44px; background: none; font-size: 1.5rem; }
  #msg-dialog .msg-preview { margin: 0; width: 100%; max-height: 35vh; }
  #msg-dialog[data-dir="in"] .msg-preview { justify-content: flex-start; }
  #msg-dialog .menu { width: min(250px, 75vw); flex: none; border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 8px 28px rgba(0, 0, 0, .22); overflow: hidden; }
  #msg-dialog .menu button { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: 0 var(--space-4); }
  #msg-dialog .menu button::before { content: ""; flex: none; width: 20px; height: 20px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
  html.ios #msg-dialog .menu { border-radius: 13px; background: var(--chrome); }
  html.ios #msg-dialog .menu button { justify-content: space-between; min-height: 44px; }
  html.ios #msg-dialog .menu button::before { order: 2; }
}
.sheet-reactions button { flex: 1; min-height: 48px; border: 0; border-radius: var(--radius-full); background: var(--bg-input); font-size: var(--text-2xl); padding: 0; }
.sheet-reactions button[aria-pressed="true"] { background: var(--bg-active); outline: 2px solid var(--accent); outline-offset: -2px; }
/* Group info members: a row per member; its actions open below it */
.member-row { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: 48px; padding: var(--space-1) 0; border: 0; background: none; text-align: left; }
button.member-row::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: 45deg; translate: -4px -2px; }
button.member-row[aria-expanded="true"]::after { rotate: 225deg; translate: -4px 2px; }
.member-row .member-name { flex: 1 1 auto; }
.member-actions { margin: 0 0 var(--space-2) 44px; }
.member-actions[hidden] { display: none; }
.blocked-list { list-style: none; margin: 0; padding: 0; }
.blocked-list li { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.safety-digits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 16px; font: 600 1.125rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; margin: 20px 0; letter-spacing: 1px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
.dialog h2:focus { outline: none; }
dialog:focus, dialog:focus-visible { outline: none; } /* focused itself after a tap (app.js): nothing to ring */
.inline-form { display: flex; gap: 8px; margin: 8px 0; }
.inline-form input, .inline-form textarea { flex: 1; min-width: 0; border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 8px 12px; font: inherit; color: inherit; resize: vertical; }
.group-desc { white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0 8px; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.toggle .hint { display: block; }
.toggle input:not([role="switch"]) { flex: none; width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.member-list { list-style: none; margin: 0; padding: 0; }
/* A person to pick (New chat › Recent): avatar, name, @username under it; one button per row */
.pick-row { display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: var(--row1, 56px); padding: var(--space-1) 0; border: 0; background: none; color: inherit; font: inherit; text-align: start; }
.pick-row .avatar { width: 40px; height: 40px; flex: none; }
.pick-text { display: grid; min-width: 0; }
.pick-name, .pick-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-sub { font-size: var(--fs-foot, .875rem); color: var(--muted); }
.member-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; flex-wrap: wrap; }
.member-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-list li .member-name { flex: 1 1 6em; }
.admin-badge { font-size: var(--text-xs); font-weight: 600; color: var(--accent); }
.member-list button { padding: 4px 10px; font-size: var(--text-sm); }
.member-list li:has(> .member-row) { display: block; padding: 0; }
.member-list .member-row { padding: var(--space-1) 0; font-size: inherit; }
.member-list .menu button { padding: 12px 16px; font-size: inherit; }

/* Mobile: one pane at a time */
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); /* minmax: long previews must not widen the page */ }
  .app.show-conversation .sidebar { display: none; }
  .app:not(.show-conversation) .conversation { display: none; }
  .back { display: grid; }
  .icon-btn { min-width: 44px; min-height: 44px; }
  /* Sidebar: roomier rows, 44px search field */
  .sidebar { background: var(--bg); border-right: 0; }
  .search input { min-height: 44px; }
  .conversation-list { padding: 0 0 0 env(safe-area-inset-left); }
  .android .conversation-list { padding-bottom: 88px; } /* the last row clears the floating New chat button */
  .tab-bar { background: var(--bg); }
  .conversation-list li { padding: var(--space-3) var(--space-4); gap: var(--space-4); border-radius: 0; }
  .conversation-list li.list-label { padding: var(--space-4) var(--space-4) var(--space-1); }
  .conversation-list .avatar { width: 48px; height: 48px; font-size: var(--text-xl); }
  .conv-name { font-size: var(--text-lg); }
  .conv-preview { font-size: var(--text-base); }
  input, textarea, select { font-size: 1rem; } /* below 16px iOS zooms the page on focus */
  /* Conversation header: back | avatar | name | voice | video | menu (the timer is in the chat sheet) */
  .conversation-header { gap: 6px; padding: calc(6px + env(safe-area-inset-top)) calc(4px + env(safe-area-inset-right)) 6px calc(4px + env(safe-area-inset-left)); }
  .peer { padding-left: 4px; }
  /* One line, as Signal's and Messenger's header subtitle: a long @username broke mid-word onto a second line (edge audit 2026-11-14) */
  .peer-sub { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; overflow-wrap: normal; line-height: 1.25; }
  .messages { padding: 12px calc(12px + env(safe-area-inset-right)) 12px calc(12px + env(safe-area-inset-left)); }
  .msg { max-width: 85%; }
  .jump-latest { width: 44px; height: 44px; right: calc(12px + env(safe-area-inset-right)); }
  .react-btn { position: relative; }
  .reactions button { position: relative; min-width: 44px; }
  .reactions button::after { content: ""; position: absolute; inset: -12px 0; } /* 44px tall hit area, same look */
  .peer, .sheet-search, .lang-select { min-height: 44px; }
  .intro-actions button { min-height: 44px; }
  .react-btn::after { content: ""; position: absolute; inset: -8px -9px; } /* 44px hit area, same look */
  .react-picker button { min-width: 44px; min-height: 44px; }
  .voice-play { width: 44px; height: 44px; }
  .mention-picker { margin: 0 8px 4px; }
  .file-save, #rec-cancel { min-height: 44px; }
  .reply-bar { margin: 6px calc(8px + env(safe-area-inset-right)) 0 calc(8px + env(safe-area-inset-left)); }
  .inline-form input, .inline-form textarea { padding: 11px 12px; }
  .composer { gap: 6px; padding: 8px calc(8px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left)); }
  .composer .icon-btn, .send { width: 44px; height: 44px; }
  .composer textarea { min-height: 44px; }
  .banner button { min-height: 44px; }
  /* Settings is a full screen page on phones, as Signal: ‹ at the top closes it, no Close at the bottom */
  #settings-dialog { margin: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; border-radius: 0;
    padding: calc(var(--space-2) + env(safe-area-inset-top)) calc(var(--space-4) + env(safe-area-inset-right)) calc(var(--space-4) + env(safe-area-inset-bottom)) calc(var(--space-4) + env(safe-area-inset-left)); }
  /* A long task is a full screen page on phones (modality.md › full-screen modal style for a complex task), as Signal's
     group settings: the handle becomes ‹ at the top left; no swipe down (app.js). */
  .dialog.page { margin: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; border-radius: 0; animation: page-in var(--dur-base) var(--ease-out);
    padding: calc(var(--space-2) + env(safe-area-inset-top)) calc(var(--space-4) + env(safe-area-inset-right)) calc(var(--space-4) + env(safe-area-inset-bottom)) calc(var(--space-4) + env(safe-area-inset-left)); }
  /* ‹ stays on top while the page scrolls, over a strip of the page's color that also covers the status bar
     (iOS draws the page under it: scrolled text ran into the clock). */
  /* UC-DS-1 Page bar (D-DS-1, as Messenger): ‹ at the leading edge, the title beside it. It stays on top while the page
     scrolls, over a strip of the page's color that also covers the status bar (iOS draws the page under it). */
  .dialog.page > .dialog-head { display: flex; align-items: center; gap: var(--space-1); margin: 0 0 var(--space-2) -12px; min-height: 44px;
    position: sticky; top: calc(-1 * var(--space-2)); z-index: 3; } /* sticky counts from the padding edge (--space-2 + safe area): this lands right below the safe area */
  .dialog.page > .dialog-head::before { content: ""; position: absolute; z-index: -1; left: calc(12px - var(--space-4) - env(safe-area-inset-left)); width: 100vw;
    top: calc(-1 * (env(safe-area-inset-top) + var(--space-2))); bottom: 0; background: var(--bg); pointer-events: none; }
  .dialog.page > .dialog-head > .sheet-handle { margin: 0; width: 44px; flex: none; color: var(--text); }
  .dialog.page > .dialog-head > .sheet-handle::before { display: none; }
  .dialog.page > .dialog-head > .sheet-handle > svg:first-child { display: block; margin: auto; } /* the shared ‹ (app.js ICONS.back) */
  .dialog.page > .dialog-head > [data-page-title] { margin: 0; font-size: var(--text-xl); font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
  /* Dialogs become bottom sheets */
  .dialog { width: 100%; max-width: none; margin: auto 0 0; max-height: 85vh; max-height: 85dvh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0; animation: sheet-up .22s ease-out;
    padding: 20px calc(20px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left)); }
  /* A form sheet's bar sticks flush with the top (sticky stops inside the padding, which showed the list scrolling above it) */
  .dialog.form-sheet:not(.page) { padding-top: 0; }
  .dialog.form-sheet:not(.page) .sheet-handle { margin-top: 0; }
  .dialog button { min-height: var(--target); }
  .menu button { min-height: 48px; }
  .dialog a:not(.doc a) { display: inline-flex; align-items: center; min-height: 44px; } /* links inside running text are exempt (WCAG 2.5.8) */
  .group-form input { padding: 12px; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@keyframes page-in { from { transform: translateX(24px); opacity: 0; } }
@media (max-width: 720px) and (prefers-reduced-motion: no-preference) { #settings-dialog[open] { animation: page-in var(--dur-base) var(--ease-out); } }
@media (prefers-reduced-motion: reduce) { .dialog { animation: none; } }

/* Static pages (privacy policy) */
.doc { max-width: 680px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); line-height: 1.55; }
.doc h1 { font-size: var(--text-3xl); }
.dialog .doc { padding-top: 0; } /* in the sheet (D-DS-15) the page header holds the safe area */
.doc h2 { font-size: var(--text-lg); margin-top: 28px; }
.lang-select { width: 100%; margin: 8px 0; border: 1px solid var(--border); background: var(--bg-input); border-radius: var(--radius-md); padding: 8px 12px; }
.setting-label { display: block; margin-top: 12px; }
/* Text formatting (UC-TF-1): monospace and spoilers inside message bubbles */
.bubble code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: rgba(127, 127, 127, .18); border-radius: var(--radius-xs); padding: 0 3px; }
.spoiler { background: currentColor; border-radius: var(--radius-xs); cursor: pointer; }
.spoiler:not(.revealed), .spoiler:not(.revealed) * { color: transparent; }
.spoiler:focus-visible { outline: 2px solid var(--accent, #2c6bed); outline-offset: 1px; }
.spoiler.revealed { background: rgba(127, 127, 127, .18); cursor: auto; }
@media (prefers-reduced-motion: no-preference) { .spoiler { transition: background-color .2s; } }
/* View once (UC-VO-1) */
.icon-btn[aria-pressed="true"] { color: var(--accent); background: rgba(15, 118, 110, .14); }
.view-once { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 12px 4px 8px; border-radius: var(--radius-md); font: inherit; color: inherit; background: rgba(127, 127, 127, .14); border: 0; }
button.view-once { cursor: pointer; font-weight: 600; }
.view-once.done { opacity: .75; font-style: italic; }
/* Marked unread (UC-MU-1): a dot instead of a count */
.badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; }
/* Polls (UC-PL-1) */
.poll { display: grid; gap: 8px; min-width: min(260px, 70vw); }
.poll-q { font-size: var(--fs-head); font-weight: 600; }
.poll-hint { font-size: .85em; }
.poll-options { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
/* Design canvas › GroupChat: a radio, the text and its count on one line, a 6 px track under it (inset past the radio) */
.poll-opt { position: relative; width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0 18px 34px; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; text-align: start; }
.poll-opt::before { content: ""; position: absolute; left: 34px; right: 0; bottom: 6px; height: 6px; border-radius: 3px; background: linear-gradient(currentColor, currentColor) 0 0 / var(--pct, 0%) 100% no-repeat, rgba(127, 127, 127, .25); opacity: .75; }
.poll-opt::after { content: ""; position: absolute; left: 0; top: 7px; width: 22px; height: 22px; box-sizing: border-box; border: 2px solid currentColor; border-radius: 50%; opacity: .7; }
.poll-opt[aria-pressed="true"]::after { opacity: 1; background: currentColor; box-shadow: inset 0 0 0 4px var(--bubble-in); }
.msg.out .poll-opt[aria-pressed="true"]::after { box-shadow: inset 0 0 0 4px var(--bubble-out); }
.msg.in .poll-opt[aria-pressed="true"]::before, .msg.in .poll-opt[aria-pressed="true"]::after { color: var(--accent); } /* my pick in the accent (on my own bubble the accent is the bubble) */
.poll-opt:disabled { cursor: default; }
.poll-count { font-variant-numeric: tabular-nums; font-size: var(--fs-foot); opacity: .8; }
.poll-votes summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.poll-votes ul { margin: 0; padding-left: 18px; }
.poll-end { justify-self: start; min-height: 44px; background: transparent; color: inherit; border-color: currentColor; } /* on my own (accent) bubble the default white button hid its white label */
.poll-fields { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
@media (prefers-reduced-motion: no-preference) { .poll-opt::before { transition: background-size .3s ease-out; } }

/* ===== UC-DS-1 platform layer (D-DS-7..10): one markup, sized by the platform tokens at the top. Phones only (a
   wide screen keeps the two-pane layout). html.android and the mobile web follow Material 3, html.ios follows HIG. ===== */
@media (max-width: 720px) {
  /* Root screen bar: avatar · title · actions in a --bar row (Android 64 dp: title 22 inline) */
  .sidebar-header { min-height: calc(var(--bar) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) calc(4px + env(safe-area-inset-right)) 0 calc(4px + env(safe-area-inset-left)); gap: var(--space-1); }
  .me-btn { min-width: var(--target); min-height: var(--target); }
  .me-btn .avatar { width: var(--av-bar); height: var(--av-bar); }
  .sidebar-header .icon-btn { min-width: var(--target); min-height: var(--target); }
  .list-title { font-size: var(--fs-large); font-weight: var(--fw-large); line-height: 1.27; }
  /* Search: Material search bar 56 dp pill; iOS search field 36 pt, radius 10 */
  .search { padding: 0 var(--space-4) var(--space-2); }
  .search input { min-height: var(--search-h); height: var(--search-h); border-radius: var(--r-search); background: var(--fill); padding: 0 var(--space-4) 0 52px; font-size: var(--fs-body); }
  .search-icon { width: 24px; height: 24px; left: 32px; top: calc(50% - 4px); }
  /* UC-SE-1 search mode: the bar, banners and tabs step aside; the field gets the top (design canvas › Search) */
  .sidebar.searching > :is(.sidebar-header, #intro, #np-banner, #folder-tabs, .tab-bar) { display: none; }
  .sidebar.searching .search { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); padding-top: calc(var(--space-2) + env(safe-area-inset-top)); }
  .sidebar.searching .search input { flex: 1; min-width: 0; }
  .sidebar.searching .search-hint { display: block; flex-basis: 100%; margin: 0; padding-inline: var(--space-1); font-size: var(--fs-cap); color: var(--muted); }
  html:not(.ios) .sidebar.searching .search { padding-left: var(--space-1); }
  html:not(.ios) .sidebar.searching .search-back { display: inline-grid; place-items: center; width: var(--target); height: var(--target); }
  html:not(.ios) .sidebar.searching .search-icon { display: none; }
  html:not(.ios) .sidebar.searching .search input { padding-left: var(--space-4); background: transparent; box-shadow: inset 0 0 0 2px var(--accent); }
  html.ios .sidebar.searching .search-cancel { display: block; min-height: var(--target); padding: 0; border: 0; background: none; color: var(--accent); font-size: var(--fs-body); }
  html.ios .sidebar.searching .search-icon { top: calc(var(--space-2) + env(safe-area-inset-top) + var(--search-h) / 2); }
  /* Chat rows: Material two-line list item 72 dp, avatar 48; iOS 76 pt, avatar 52, inset separators, 2-line preview */
  .conversation-list li { min-height: var(--chat-row); padding: var(--space-2) var(--space-4); gap: var(--space-4); }
  .conversation-list li.list-label { min-height: 0; padding: var(--space-4) var(--space-4) var(--space-2); font-size: var(--fs-sec); font-weight: 600; }
  .conversation-list li.list-empty, .conversation-list li.archived-row, .conversation-list li.archive-head { min-height: 0; }
  .conversation-list .avatar { width: var(--av-list); height: var(--av-list); font-size: 1.125rem; }
  .conv-open { gap: var(--space-4); }
  .conv-name { font-size: var(--fs-head); font-weight: var(--fw-head); }
  .conv-time { font-size: var(--fs-cap); font-weight: 500; }
  .conv-preview { font-size: var(--fs-foot); }
  /* Chips (folders, call filter): Material filter chip 32 dp, radius 8, outline; selected = tonal. The 48 dp target
     is the row around them. */
  .folder-tabs { padding: var(--space-2) var(--space-4); gap: var(--space-2); }
  .folder-tab, .calls-filter button { min-height: 32px; height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-sm); border: 1px solid var(--outline); background: transparent; font-size: var(--text-md); font-weight: 500; position: relative; }
  .folder-tab::after, .calls-filter button::after { content: ""; position: absolute; inset: -8px 0; } /* 48 dp target, 32 dp look */
  .folder-tab[aria-pressed="true"], .calls-filter button[aria-pressed="true"] { background: var(--accent-cont); border-color: var(--accent-cont); color: var(--on-accent-cont); }
  .calls-filter { margin: var(--space-2) 0; }
  /* Navigation bar: Material 3, 80 dp, the selected icon in a 64×32 pill */
  .tab-bar { background: var(--surface); border-top: 0; padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  .tab { min-height: var(--tabbar); justify-content: center; gap: var(--space-1); border-radius: 0; font-size: var(--fs-tab); font-weight: 600; color: var(--muted); }
  .tab svg { box-sizing: border-box; width: 64px; height: 32px; padding: 4px 20px; border-radius: 16px; }
  .tab[aria-current="page"] { color: var(--text); }
  .tab[aria-current="page"] svg { background: var(--accent-cont); color: var(--on-accent-cont); }
  .android .conversation-list, .android .calls-panel { padding-bottom: calc(56px + var(--space-8)); } /* the last row clears the FAB */
  /* Chat bar: --bar tall, 48 dp targets edge to edge */
  .conversation-header { min-height: calc(var(--bar) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) calc(4px + env(safe-area-inset-right)) 0 calc(4px + env(safe-area-inset-left)); gap: 0; }
  .conversation-header .icon-btn { min-width: var(--target); min-height: var(--target); }
  .conversation-header .peer-name { font-size: var(--fs-head); font-weight: var(--fw-head); }
  .conversation-header .avatar { width: var(--av-bar); height: var(--av-bar); }
  .bubble { padding: var(--space-2) var(--space-3); line-height: var(--lh-bubble); }
  /* Composer: Material filled pill field */
  .composer { align-items: flex-end; gap: var(--space-1); padding: var(--space-2) calc(var(--space-2) + env(safe-area-inset-right)) calc(var(--space-2) + env(safe-area-inset-bottom)) calc(var(--space-2) + env(safe-area-inset-left)); }
  .composer .icon-btn, .send { width: var(--target); height: var(--target); }
  .composer textarea { min-height: var(--target); border-radius: calc(var(--target) / 2); border: 0; background: var(--fill); padding-inline: var(--space-4); }
  /* Pages (Settings, chat settings, Group info): bar --bar tall; the title is the platform's title role */
  .dialog.page > .dialog-head, .settings-page-head { min-height: var(--bar); }
  .dialog.page > .dialog-head > .sheet-handle, .settings-page-head .icon-btn { width: var(--target); min-height: var(--target); }
  .dialog.page > .dialog-head > [data-page-title], .dialog .settings-page-head h2, .dialog .settings-page-head h3 { font-size: var(--fs-title); font-weight: 600; }
  /* Lists in pages and sheets: Material flat rows (no boxes, no dividers, no chevrons; a value sits under its label) */
  .menu, .settings-group { border: 0; border-radius: var(--r-group); }
  .menu > :not([hidden]) ~ :not([hidden]), .settings-row + .settings-row { border-top: 0; }
  .menu button, button.settings-row { min-height: var(--row1); font-size: var(--fs-body); } /* button.: above .dialog button's floor */
  .android .settings-row::after, .android .value-row::after { display: none; }
  .android .menu .value-row { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; }
  .android .value-row .muted { margin-left: 0; max-width: 100%; font-size: var(--fs-foot); }
  .settings-profile-card { border: 0; }
  .android .settings-page .toggle + .toggle { border-top: 0; }
  /* Section headers: Material 14/600 sentence case; iOS 13 uppercase (below) */
  .dialog h3 { font-size: var(--fs-sec); font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); }
  /* A plain button in a page or sheet is a secondary capsule: Material outlined, iOS filled (below) */
  :where(.dialog, .onboarding-card, .calls-actions) button:not([class]):not(.menu button, .settings-page > button, .sheet-bar button, .dialog-head button, .sheet-reactions button, .react-picker button, .attach-tiles button), .calls-actions button { min-height: var(--target); padding: 0 var(--space-6); border-radius: var(--radius-full); border: 1px solid var(--outline); background: transparent; font-weight: 500; }
  /* Sheets: Material bottom sheet, surface, 28 dp top corners, a 32×4 grabber */
  .dialog:not(.page):not(#settings-dialog) { background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0; }
  .dialog::backdrop { background: var(--scrim, rgba(14, 17, 18, .40)); } /* iOS 16 WebKit: ::backdrop inherits no custom property (KI-42) */
  .sheet-bar > h2 { font-size: var(--fs-head); font-weight: 600; }
  .sheet-bar > button { font-size: var(--fs-body); min-width: var(--target); }
  /* Buttons: capsules, --btn tall */
  .dialog-actions button, .onboarding-card button, .empty .primary, .list-empty button, .calls-list .list-empty button, .intro-actions button { min-height: var(--btn); border-radius: var(--radius-full); padding: 0 var(--space-6); }
  /* Text fields: Material outlined field 56 dp, radius 12; focus = 2 dp accent border */
  :is(.onboarding-card, .group-form, .new-chat-form) input:not([type="checkbox"]):not([type="radio"]), .inline-form input { min-height: var(--field); border: 1px solid var(--outline); background: transparent; border-radius: var(--r-field); padding: 0 var(--space-4); font-size: var(--fs-body); width: 100%; min-width: 0; }
  :is(.onboarding-card, .group-form, .new-chat-form) input:not([type="checkbox"]):not([type="radio"]):focus, .inline-form input:focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); outline: none; }
  /* Onboarding (design canvas › Onboarding): the welcome text left-aligned, centered in the space above; the form at the
     bottom, in thumb reach (HIG layout.md › controls mid-screen or lower) */
  .onboarding { display: flex; justify-content: center; align-items: stretch; }
  .onboarding-card { display: flex; flex-direction: column; text-align: start; padding-inline: var(--space-2); }
  .onboarding-card .logo { margin-top: auto; }
  .onboarding-card h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 700; margin: var(--space-4) 0 var(--space-2); }
  .onboarding-card .lead { font-size: var(--fs-body); color: var(--muted); }
  .onboarding-card form { margin-top: auto; padding-top: var(--space-8); }
  .onboarding-card #restore-btn { border: 0; background: none; color: var(--accent); } /* a text button, as the canvas */
}
/* Switch: Material 3, 52×32: an outlined track with a 16 dp knob off, a filled track with a 24 dp knob on */
input[type="checkbox"][role="switch"] { width: 52px; height: 32px; border: 2px solid var(--outline); background: var(--fill); }
input[type="checkbox"][role="switch"]::before { top: 6px; left: 6px; width: 16px; height: 16px; background: var(--outline); }
input[type="checkbox"][role="switch"]:checked { border-color: var(--accent); background: var(--accent); }
input[type="checkbox"][role="switch"]:checked::before { top: 2px; left: 22px; width: 24px; height: 24px; background: var(--accent-text); }
@media (prefers-reduced-motion: no-preference) { input[type="checkbox"][role="switch"]::before { transition: left var(--dur-fast) var(--ease-out), width var(--dur-fast), height var(--dur-fast), top var(--dur-fast); } }
/* FAB (Android): Material 3 primary container, 56 dp, radius 16, above the navigation bar */
.android .compose-btn { width: 56px; height: 56px; border-radius: var(--r-fab); background: var(--accent-cont); color: var(--on-accent-cont) !important; box-shadow: var(--elev);
  bottom: calc(var(--tabbar) + var(--space-4) + env(safe-area-inset-bottom)); }
@media (hover: hover) { .android .compose-btn:hover { background: var(--accent-cont); } }

/* ----- iOS (HIG): same pieces, iOS sizes and placement ----- */
@media (max-width: 720px) {
  /* Root screen: a 44 pt bar (avatar · actions in the accent color), the 34 pt large title on its own line below */
  html.ios .sidebar-header { flex-wrap: wrap; padding-inline: calc(8px + env(safe-area-inset-left)) calc(8px + env(safe-area-inset-right)); }
  html.ios .list-head { order: 9; flex: 1 0 100%; padding: 0 8px 8px; }
  html.ios .me-btn { margin-inline-end: auto; }
  html.ios .sidebar-header .icon-btn, html.ios .conversation-header .icon-btn, html.ios .settings-page-head .icon-btn,
  html.ios .dialog.page > .dialog-head > .sheet-handle { color: var(--accent); }
  html.ios .search input { padding-left: 34px; }
  html.ios .search-icon { width: 20px; height: 20px; left: 24px; }
  /* Chat rows: 76 pt, 2-line preview, separators inset to the text (80 pt) */
  html.ios .conversation-list li:has(> .conv-open) { gap: var(--space-3); }
  html.ios .conversation-list li:has(> .conv-open):has(+ li > .conv-open) { background: linear-gradient(var(--border), var(--border)) 80px 100% / calc(100% - 80px) 1px no-repeat; }
  html.ios .conversation-list li:active, html.ios .conversation-list li[aria-current="true"] { background-color: var(--bg-hover); }
  html.ios .conv-open { gap: var(--space-3); }
  html.ios .conv-time { font-size: 0.9375rem; font-weight: 400; }
  html.ios .conv-preview { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  /* Chips: iOS capsules on a fill, the selected one in the accent */
  html.ios .folder-tab, html.ios .calls-filter button { border: 0; border-radius: var(--radius-full); background: var(--fill); font-size: 0.9375rem; font-weight: 400; color: var(--text); }
  html.ios .folder-tab[aria-pressed="true"], html.ios .calls-filter button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
  /* Tab bar: 49 pt, hairline on top, icon over a 10 pt label, the selected tab in the accent; no pill */
  html.ios .tab-bar { background: var(--chrome); border-top: 0.5px solid var(--border); }
  html.ios .tab { justify-content: flex-start; padding-top: 6px; gap: 1px; font-weight: 500; }
  html.ios .tab svg { width: 28px; height: 28px; padding: 2px; border-radius: 0; }
  html.ios .tab[aria-current="page"], html.ios .tab[aria-current="page"] svg { background: none; color: var(--accent); }
  /* Chat bar and composer: hairlines; the field is an outlined capsule */
  html.ios .conversation-header { border-bottom-width: 0.5px; }
  html.ios .composer { border-top-width: 0.5px; padding-block: 6px calc(6px + env(safe-area-inset-bottom)); }
  html.ios .composer textarea { background: transparent; border: 1px solid var(--outline); min-height: 36px; border-radius: 18px; padding-inline: var(--space-3); }
  html.ios .composer .icon-btn { color: var(--accent); }
  html.ios :is(#chat-menu-btn, #list-more) svg { transform: rotate(90deg); } /* HIG More: ••• (ellipsis), not Material's ⋮ */
  /* Pages and sheets: inset grouped (grey page, white cells with 10 pt corners, separators inset 16 pt, chevrons) */
  html.ios .dialog, html.ios .dialog.page > .dialog-head::before { background: var(--grouped-page); }
  html.ios .menu, html.ios .settings-group, html.ios .settings-profile-card, html.ios .dialog .toggle { background: var(--grouped-cell); }
  html.ios .dialog .toggle { padding-inline: var(--space-4); border-radius: var(--r-group); }
  html.ios .menu > :not([hidden]) ~ :not([hidden]) { background-image: linear-gradient(var(--border), var(--border)); background-repeat: no-repeat; background-position: 16px 0; background-size: calc(100% - 16px) 0.5px; }
  html.ios .settings-row + .settings-row { background-image: linear-gradient(var(--border), var(--border)); background-repeat: no-repeat; background-position: 54px 0; background-size: calc(100% - 54px) 0.5px; } /* inset past the icon */
  html.ios .menu button, html.ios button.settings-row { min-height: var(--row1); }
  html.ios .settings-profile-card { border-radius: var(--r-group); }
  html.ios .dialog h3 { font-weight: 400; text-transform: uppercase; margin-inline: var(--space-4); }
  html.ios :where(.dialog, .onboarding-card, .calls-actions) button:not([class]):not(.menu button, .settings-page > button, .sheet-bar button, .dialog-head button, .sheet-reactions button, .react-picker button, .attach-tiles button), html.ios .calls-actions button { border: 0; background: var(--fill); }
  html.ios .sheet-handle::before { left: 14px; right: 14px; top: 8px; height: 5px; border-radius: 3px; opacity: .5; }
  /* Buttons: secondary buttons are filled, not outlined */
  html.ios .dialog-actions button:not(.primary):not(.danger), html.ios .onboarding-card button:not(.primary) { border: 0; background: var(--fill); }
  /* Text fields: iOS filled field, no border, radius 10 */
  html.ios :is(.onboarding-card, .group-form, .new-chat-form) input:not([type="checkbox"]):not([type="radio"]), html.ios .inline-form input { border: 0; background: var(--fill); }
  html.ios :is(.onboarding-card, .group-form, .new-chat-form) input:not([type="checkbox"]):not([type="radio"]):focus, html.ios .inline-form input:focus { box-shadow: none; }
}
/* Switch: UISwitch, 51×31, white knob with a shadow, the accent when on */
html.ios input[type="checkbox"][role="switch"] { width: 51px; height: 31px; border: 0; background: var(--sw-off); }
html.ios input[type="checkbox"][role="switch"]::before { top: 2px; left: 2px; width: 27px; height: 27px; background: #ffffff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16); }
html.ios input[type="checkbox"][role="switch"]:checked { background: var(--accent); }
html.ios input[type="checkbox"][role="switch"]:checked::before { top: 2px; left: 22px; width: 27px; height: 27px; background: #ffffff; }
/* End panel: a message request, a blocked chat or a group I left replaces the composer at the bottom (Signal,
   Messenger; design canvas › Request): the surface, a line saying why, capsule buttons sharing the width */
.banner.end-panel { flex-direction: column; align-items: stretch; gap: var(--space-3); background: var(--surface); color: var(--text); border-top: 1px solid var(--border);
  padding: var(--space-4) calc(var(--space-4) + env(safe-area-inset-right)) calc(var(--space-4) + env(safe-area-inset-bottom)) calc(var(--space-4) + env(safe-area-inset-left)); text-align: center; font-size: var(--fs-foot); }
.banner.end-panel[hidden] { display: none; }
.end-panel .banner-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.end-note { font-size: var(--fs-cap, .75rem); color: var(--muted); }
#block-request-dialog .dialog-actions { display: flex; flex-direction: column-reverse; align-items: stretch; gap: var(--space-2); } /* three choices stacked, the strongest on top, Cancel last */
#block-request-dialog .dialog-actions button { width: 100%; }
.end-panel .banner-actions button { flex: 1 1 auto; white-space: nowrap; min-height: var(--target); padding: 0 var(--space-3); border-radius: var(--radius-full); border: 1px solid var(--outline); background: transparent; font-weight: 600; }
.end-panel .banner-actions button.primary { border-color: transparent; background: var(--accent); color: var(--accent-text); }
.end-panel .banner-actions button.danger { color: var(--danger); }
html.ios .banner.end-panel { background: var(--chrome); border-top-width: 0.5px; }
html.ios .end-panel .banner-actions button:not(.primary) { border: 0; background: var(--fill); }
/* Settings pages: a lone button is a row (Material list item; an iOS cell in the accent), toggles in a run form one group */
@media (max-width: 720px) {
  .settings-page > button:not([class]) { display: flex; align-items: center; width: 100%; min-height: var(--row1); padding: 0; border: 0; border-radius: 0; background: none; font-size: var(--fs-body); font-weight: 400; text-align: start; }
  html.ios .settings-page > button:not([class]) { padding: 0 var(--space-4); border-radius: var(--r-group); background: var(--grouped-cell); color: var(--accent); margin-block: var(--space-2); }
  html.ios .dialog .settings-page-head h3 { text-transform: none; font-size: var(--fs-title); font-weight: 600; color: var(--text); margin: 0; }
  /* Settings' root: the 34 pt large title on its own line under ‹ (design canvas › Settings, iOS) */
  html.ios #settings-home-head { flex-wrap: wrap; }
  html.ios #settings-home-head #settings-title { flex-basis: 100%; margin: 0 0 var(--space-2); padding-inline: var(--space-2); font-size: var(--fs-large); font-weight: var(--fw-large); line-height: 1.2; }
  html.ios .settings-page .toggle + .toggle { border-top: 0; border-start-start-radius: 0; border-start-end-radius: 0; background-image: linear-gradient(var(--border), var(--border)); background-repeat: no-repeat; background-position: 16px 0; background-size: calc(100% - 16px) 0.5px; }
  html.ios .settings-page .toggle:has(+ .toggle) { border-end-start-radius: 0; border-end-end-radius: 0; }
  html.ios .settings-page > .hint, html.ios .dialog .hint:not(.toggle .hint) { margin-inline: var(--space-4); }
}

/* ===== UC-DS-1 controls (control audit 2026-11-13, D-DS-14): one rule per control, as the canvas's hush.css ===== */
/* Buttons in sheets and pages (canvas .btn): a --btn capsule, 600 weight; filled = accent; secondary and destructive are
   outlined on Android and grey-filled on iOS. Rows, bars, tiles and list-item actions keep their own look. */
html :where(.dialog, .onboarding-card) :is(button.primary, button.danger, button:not([class])):not(:is(.menu, .sheet-bar, .dialog-head, .sheet-reactions, .react-picker, .attach-tiles, .banner-actions, li) button, .settings-page > button) {
  min-height: var(--btn); padding: 0 var(--space-6); border-radius: var(--radius-full); font-size: var(--fs-body); font-weight: 600; }
html:not(.ios) :where(.dialog, .onboarding-card) :is(button.danger, button:not([class])):not(:is(.menu, .sheet-bar, .dialog-head, .sheet-reactions, .react-picker, .attach-tiles, .banner-actions, li) button, .settings-page > button) {
  border: 1px solid var(--outline); background: transparent; }
html.ios :where(.dialog, .onboarding-card) :is(button.danger, button:not([class])):not(:is(.menu, .sheet-bar, .dialog-head, .sheet-reactions, .react-picker, .attach-tiles, .banner-actions, li) button, .settings-page > button) {
  border: 0; background: var(--fill); }
/* A destructive action alone on a Settings page is a red row, as the other lone actions there (canvas .row.danger) */
@media (max-width: 720px) {
  .settings-page > button.danger { display: flex; align-items: center; width: 100%; min-height: var(--row1); padding: 0; border: 0; border-radius: 0; background: none; font-size: var(--fs-body); font-weight: 400; text-align: start; }
  html.ios .settings-page > button.danger { padding: 0 var(--space-4); border-radius: var(--r-group); background: var(--grouped-cell); margin-block: var(--space-2); }
}
/* A sheet's bar (canvas .txt-btn): Cancel and the action in the accent, a full target tall; Android 600, iOS Cancel
   regular and the confirming action semibold (HIG toolbars.md: the action that confirms is the prominent one) */
.sheet-bar > button, .sheet-bar > button:first-child { min-height: var(--target); color: var(--accent); }
html:not(.ios) .sheet-bar > button { font-weight: 600; }
html.ios .sheet-bar > button:first-child { font-weight: 400; }
.dialog.page > .dialog-head > .primary { min-height: var(--target); }
/* Checkbox (canvas .cb): Android a square 18 with 2 px corners, iOS a circle 22; the accent with a white check when on */
html body input[type="checkbox"]:not([role="switch"]) { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 18px; height: 18px; margin: 0; padding: 0;
  border: 2px solid var(--outline); border-radius: 2px; background: transparent; }
html body input[type="checkbox"]:not([role="switch"]):checked { border-color: var(--accent); background: var(--accent); }
html body input[type="checkbox"]:not([role="switch"])::before { content: ""; position: absolute; left: 4px; top: 0; width: 4px; height: 9px; border: solid var(--accent-text); border-width: 0 2px 2px 0; rotate: 45deg; opacity: 0; }
html body input[type="checkbox"]:not([role="switch"]):checked::before { opacity: 1; }
html.ios body input[type="checkbox"]:not([role="switch"]) { width: 22px; height: 22px; border-width: 1.5px; border-radius: 50%; }
html.ios body input[type="checkbox"]:not([role="switch"])::before { left: 6.5px; top: 2.5px; width: 5px; height: 10px; }
html body .edit-dialog input[type="checkbox"] { border-color: #8a8f94; } /* the photo editor stays dark */
/* Text fields in sheets and pages (canvas .fld .box): Android outlined 56, radius 12, a 2 px accent ring when focused;
   iOS filled 50, radius 10, no border. A search box in a sheet is the search field (canvas .search). */
html :where(.dialog, .onboarding-card) :is(input:not([type]), input[type="text"], input[type="number"], input[type="email"], input[type="url"], input[type="password"], textarea, select:not(.lang-select)):not(.react-other, .sheet-search, #timer-select, .edit-dialog *) {
  min-height: var(--field); width: 100%; min-width: 0; padding: 0 var(--space-4); border: 1px solid var(--outline); border-radius: var(--r-field); background: transparent; color: var(--text); font-size: var(--fs-body); }
html :where(.dialog) textarea:not(.edit-dialog *) { padding-block: var(--space-3); }
html :where(.dialog, .onboarding-card) :is(input:not([type]), input[type="text"], input[type="number"], input[type="email"], input[type="url"], input[type="password"], textarea, select:not(.lang-select)):not(.react-other, .sheet-search, #timer-select, .edit-dialog *):focus { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); outline: none; }
html.ios :where(.dialog, .onboarding-card) :is(input:not([type]), input[type="text"], input[type="number"], input[type="email"], input[type="url"], input[type="password"], textarea, select:not(.lang-select)):not(.react-other, .sheet-search, #timer-select, .edit-dialog *) { border: 0; background: var(--fill); }
html.ios :where(.dialog, .onboarding-card) :is(input:not([type]), input[type="text"], input[type="number"], input[type="email"], input[type="url"], input[type="password"], textarea, select:not(.lang-select)):not(.react-other, .sheet-search, #timer-select, .edit-dialog *):focus { box-shadow: none; }
html .dialog .sheet-search { min-height: var(--search-h); border: 0; border-radius: var(--r-search); background: var(--fill); padding: 0 var(--space-4); font-size: var(--fs-body); }
#timer-unit.lang-select { min-height: var(--field); margin: 0; border: 1px solid var(--outline); border-radius: var(--r-field); background: transparent; padding: 0 var(--space-4); }
html.ios #timer-unit.lang-select { border: 0; background: var(--fill); }
/* A picker in Settings or a page (canvas .row with .val): a row, not a box. Android: the label, its value under it in
   grey; iOS: one cell, the label on the left, the value on the right before ›. The select covers the whole row (one
   target), its own text drawn where the value goes. */
.select-row { position: relative; display: flex; flex-direction: column; justify-content: flex-start; min-height: var(--row2, 72px); margin: 0; padding: 14px 0 0; font-weight: 400; }
.select-row > span { position: relative; z-index: 1; pointer-events: none; font-size: var(--fs-body); color: var(--text); }
.select-row > select.lang-select { appearance: none; -webkit-appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0; background: transparent;
  padding: 40px 0 10px; color: var(--muted); font-size: var(--fs-foot); line-height: 1.4; text-align: start; } /* the value's line sits under the label's */
.select-row > select.lang-select:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
html.ios .select-row { flex-direction: row; align-items: center; justify-content: flex-start; min-height: var(--row1); margin-block: var(--space-2); padding: 0 calc(var(--space-4) + 14px) 0 var(--space-4); border-radius: var(--r-group); background: var(--grouped-cell); }
html.ios .select-row > span { flex: 1; padding-inline-end: 40%; }
html.ios .select-row > select.lang-select { padding: 0 calc(var(--space-4) + 16px) 0 0; direction: rtl; font-size: var(--fs-body); border-radius: var(--r-group); }
html.ios .select-row > select.lang-select option { direction: ltr; }
html.ios .select-row::after { content: ""; position: absolute; right: var(--space-4); top: 50%; width: 8px; height: 8px; border-top: 2px solid var(--outline); border-right: 2px solid var(--outline); translate: 0 -50%; rotate: 45deg; pointer-events: none; }

/* UC-DS-2 D-DS2-2: a menu carries an icon on every row (HIG menus.md › "provide icons for all menu items in a group, or
   none of them"; Messenger's chat sheet). One shape per action, as the Icons table of UC-DS-2. */
:is(#chat-dialog:not(.page) .menu > button, :is(#chat-more-dialog, #list-more-dialog) .menu > button, :is(#folder-menu-read, #folder-menu-mute, #folder-menu-edit)) { display: flex; align-items: center; gap: var(--space-4); }
:is(#chat-dialog:not(.page) .menu > button, :is(#chat-more-dialog, #list-more-dialog) .menu > button, :is(#folder-menu-read, #folder-menu-mute, #folder-menu-edit))::before { content: ""; flex: none; width: 22px; height: 22px; background: currentColor; -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
#more-settings { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='9'/><path d='M12 11v5.5M12 7.6v.1'/></svg>"); }
#chat-media { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='16' rx='2.5'/><circle cx='9' cy='9.5' r='1.6'/><path d='M21 15.5l-5-5-10 9.5'/></svg>"); }
#chat-search-btn { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='6.5'/><path d='M20 20l-4.2-4.2'/></svg>"); }
:is(#more-mute, #chat-dialog:not(.page) #chat-mute, #folder-menu-mute, #chats-mute) { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 16v-5c0-1 .2-1.9.7-2.7M9 5.7A6 6 0 0 1 18 11v4M17.5 18h-13L6 16M10 20a2 2 0 0 0 4 0M4 4l16 16'/></svg>"); }
:is(#more-mute, #chat-dialog:not(.page) #chat-mute)[data-on="true"] { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 16v-5a6 6 0 0 1 12 0v5l1.5 2h-15zM10 20a2 2 0 0 0 4 0'/></svg>"); }
#chat-poll { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 20v-8M12 20V5M18 20v-5'/></svg>"); }
#chat-share-contact { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='16' rx='2.5'/><circle cx='12' cy='10' r='2.6'/><path d='M7.5 17a4.5 4.5 0 0 1 9 0'/></svg>"); }
#chat-pin[data-on="true"] { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M15 3l6 6-3 1-4 4 1 5-2 2-4-4-5 5M9 15l-4-4 2-2 5 1 4-4zM3 3l18 18'/></svg>"); }
:is(#chat-unread, #folder-menu-read) { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M14 5H4v15l5-4h11v-5'/><circle cx='19' cy='5.5' r='2.5' fill='black' stroke='none'/></svg>"); }
:is(#chat-unread[data-on="true"], #folder-menu-read, #chats-read) { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 5h16v11H9l-5 4z'/><path d='M8.5 10.5l2.2 2.2 4.3-4.4'/></svg>"); }
#chat-archive, #chats-archive { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M3 5h18v4H3zM5 9v10h14V9M10 13h4'/></svg>"); }
#chat-archive[data-on="true"] { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M3 5h18v4H3zM5 9v10h14V9M12 17v-5M9.5 14.5L12 12l2.5 2.5'/></svg>"); }
#chat-folders { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M3 6.5A1.5 1.5 0 0 1 4.5 5H9l2 2h8.5A1.5 1.5 0 0 1 21 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5z'/></svg>"); }
#folder-menu-edit { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 20h4L19 9l-4-4L4 16zM14 6l4 4'/></svg>"); }

/* UC-DS-2 D-DS2-1: the chat bar's ⋮ / ••• opens a menu anchored under it, not a sheet: Material 3's menu on Android
   (surface, 4 dp corners, 48 dp items, leading icons, no scrim); HIG's pull-down menu on iOS (13 pt corners, 44 pt
   items, icons trailing, thin separators, translucent material). app.js sets --at to the button's bottom. */
html :is(#chat-more-dialog, #list-more-dialog).dialog { position: fixed; inset: var(--at, 56px) calc(8px + env(safe-area-inset-right)) auto auto; margin: 0;
  width: min(280px, calc(100vw - 16px)); max-width: none; max-height: 70vh; max-height: 70dvh; padding: 8px 0; overflow-y: auto;
  border-radius: 4px; background: var(--surface); box-shadow: 0 4px 16px rgba(0, 0, 0, .2); animation: menu-in var(--dur-fast, .12s) var(--ease-out, ease-out); transform-origin: top right; }
:is(#chat-more-dialog, #list-more-dialog)::backdrop { background: transparent; }
:is(#chat-more-dialog, #list-more-dialog) .sheet-handle { display: none; }
html :is(#chat-more-dialog, #list-more-dialog) .menu { margin: 0; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
html :is(#chat-more-dialog, #list-more-dialog) .menu > button { min-height: 48px; padding: 0 16px; border: 0; border-radius: 0; background: none; font-size: var(--fs-body); }
html.ios :is(#chat-more-dialog, #list-more-dialog).dialog { width: min(250px, calc(100vw - 16px)); padding: 0; border-radius: 13px; background: var(--chrome);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 10px 40px rgba(0, 0, 0, .22); }
html.ios :is(#chat-more-dialog, #list-more-dialog) .menu > button { justify-content: space-between; min-height: 44px; }
html.ios :is(#chat-more-dialog, #list-more-dialog) .menu > button::before { order: 2; width: 20px; height: 20px; }
html.ios :is(#chat-more-dialog, #list-more-dialog) .menu > button:not([hidden]) ~ button:not([hidden]) { border-top: .5px solid var(--border); }
@keyframes menu-in { from { opacity: 0; transform: scale(.92); } }
@media (prefers-reduced-motion: reduce) { html :is(#chat-more-dialog, #list-more-dialog).dialog { animation: none; } }

/* UC-DS-2 §1 Select: picking chats (or messages), as Signal Android's multi-select. A first row with Cancel at the leading
   edge and "N selected" centred, then the actions in one row, each its icon above its label (Material navigation-bar
   item: 24 dp icon, 12 sp label); Delete in red. Wrapping capsules put Delete on a second line on a 390 pt screen. */
html .select-bar:not([hidden]) { display: grid; grid-auto-flow: column; grid-template-columns: repeat(var(--acts), minmax(0, 1fr)); grid-template-rows: auto auto;
  row-gap: 2px; column-gap: 0; padding: 4px 4px calc(6px + env(safe-area-inset-bottom)); }
html .select-bar > :is(#chats-count, #select-count) { grid-row: 1; grid-column: 1 / -1; align-self: center; text-align: center; font-weight: 600; }
html .select-bar > :is(#chats-cancel, #select-cancel) { grid-row: 1; grid-column: 1 / -1; justify-self: start; z-index: 1;
  min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--accent); font-weight: 600; box-shadow: none; }
html .select-bar > button:not(#chats-cancel, #select-cancel) { grid-row: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 0; min-height: 56px; padding: 4px 2px; border: 0; border-radius: var(--radius-md); background: none; box-shadow: none; color: var(--text);
  font-size: 12px; font-weight: 500; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
html .select-bar > button.danger:not(#chats-cancel, #select-cancel) { color: var(--danger); }
body:has(#chats-bar:not([hidden])) .tab-bar { display: none; } /* the selection bar takes the tab bar's place, as Signal */
html .select-bar > button:not(#chats-cancel, #select-cancel)::before { content: ""; flex: none; width: 24px; height: 24px; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
html .select-bar > button:disabled { opacity: .38; }
#chats-bar { --acts: 4; }
#select-bar { --acts: 2; }
#select-bar:has(> #select-forward[hidden]) { --acts: 1; }

/* UC-DS-2 D-DS2-4: on a touch screen the composer and the search field show focus by their caret and keyboard, as
   Signal's and Messenger's (and iOS's search field): no ring. Once Tab is pressed (html.kbd, app.js) the ring is back. */
/* …and so does everything else (device audit 2026-11-14: iOS WebKit rang a message after its menu handed focus back): a
   touch shows no ring anywhere until Tab is pressed (UC-DS-1 focus rule). */
@media (hover: none) and (pointer: coarse) { html:not(.kbd) :focus-visible { outline: none; } }

/* UC-DS-2 §2 composer (design canvas › Conversation): the emoji button sits inside the field's trailing end, the field
   keeping room for it; camera and mic follow, and give way to Send once something is typed. */
html body .composer textarea { padding-inline-end: 48px; min-height: 44px; } /* over the platform rules' padding-inline */
.composer .emoji-btn { flex: none; margin-inline-start: -54px; /* 44 + the row's gap (4 to 8): inside the field's end */ width: 44px; min-width: 44px; height: 44px; color: var(--muted); background: none; z-index: 1; align-self: flex-end; }
html.ios .composer .emoji-btn { width: 36px; min-width: 36px; height: 36px; margin-inline-start: -46px; }
html.ios body .composer textarea { padding-inline-end: 40px; }
/* The emoji drawer: a grid of 44 px targets */
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 2px; padding: 4px 0; }
#emoji-dialog { max-height: 45vh; max-height: 45dvh; } /* about a keyboard's height, as Signal's drawer: the chat stays in view */
html .emoji-grid button.emoji { min-width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: var(--radius-md); background: none; font-size: 1.6rem; line-height: 1; }
@media (min-width: 721px) { #emoji-dialog .emoji-grid { margin-top: 40px; } } /* clear of the sheet's ✕ on a wide screen */

/* ===== Design canvas, screen by screen (UC-DS-2), 2026-11-14 ===== */
/* iOS: rows that open another view carry a chevron (HIG lists-and-tables.md › disclosure indicator; design canvas) */
html.ios .dialog.page .menu > button:is(#chat-nickname, #chat-style, #chat-mute, #chat-custom-notify, #chat-safety, #gi-media)::after {
  content: ""; margin-inline-start: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: -45deg; flex: none; opacity: .7; }
html.ios .dialog.page #timer-row::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); rotate: -45deg; flex: none; opacity: .7; margin-inline-start: var(--space-2); }
/* iOS More is ellipsis.circle (design canvas › Conversation) */
#chat-menu-btn .ios-ring { display: none; }
html.ios #chat-menu-btn .ios-ring { display: inline; }
html.ios #chat-menu-btn svg .dot { transform: scale(.62); transform-origin: 12px 12px; }
/* Android: + sits in a tonal circle (design canvas › Conversation) */
html.android #attach-btn { background: var(--fill); border-radius: 50%; }
/* Chat settings: Block and Report end the page in a group of their own; no empty group in the row menu */
.menu:not(:has(> :not([hidden]))) { display: none; }
html.android .dialog.page #chat-danger-menu { margin-top: var(--space-2); border-top: 1px solid var(--border); padding-top: var(--space-2); }
html.ios .dialog.page #chat-danger-menu { margin-top: var(--space-5, 24px); }
/* Group info: the photo is the button; a camera badge when I may change it */
button#gi-photo { position: relative; border: 0; padding: 0; font-family: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; }
button#gi-photo:disabled { cursor: default; opacity: 1; }
button#gi-photo:not(:disabled)::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--bg);
  background: var(--fill) center / 16px no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23586165' stroke-width='2' stroke-linejoin='round'><path d='M4 8h3l2-3h6l2 3h3v11H4z'/><circle cx='12' cy='13' r='3.5'/></svg>"); }
#gi-leave { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M14 4h5v16h-5M10 8l-4 4 4 4M6 12h10'/></svg>"); } /* design canvas › GroupInfo: Leave leads with its icon */

/* UC-DS-2 §1 list bar (design canvas › ChatList): the camera is Android's only; the more button sits at the end */
html:not(.android) #list-camera { display: none; }
#list-more .ios-ring { display: none; }
html.ios #list-more .ios-ring { display: inline; }
html.ios #list-more svg .dot { transform: scale(.62); transform-origin: 12px 12px; }
.conv-status { display: inline-flex; vertical-align: -2px; margin-inline-end: 3px; color: var(--muted); }
.conv-status.status-read { color: var(--accent); }
#list-new-group { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='9' cy='9' r='3'/><path d='M3 19c.8-3 3-5 6-5s5.2 2 6 5M16 6a3 3 0 0 1 0 6M18 14c1.6.6 2.7 2.4 3 5'/></svg>"); }
#list-read-all { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 5h16v11H9l-5 4z'/><path d='M8.5 10.5l2.2 2.2 4.3-4.4'/></svg>"); }
#list-select { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='9'/><path d='M8 12l3 3 5-6'/></svg>"); }
#list-settings { --ico: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><circle cx='12' cy='12' r='3'/><path d='M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z'/></svg>"); }
/* Safety number: two long actions stack full width on a phone ("Quét mã của họ" wrapped to two lines on a 360 dp screen) */
@media (max-width: 720px) { #safety-dialog .dialog-actions:has(> #safety-scan:not([hidden])) { flex-direction: column-reverse; align-items: stretch; } }
/* Two panes (a phone turned sideways, a tablet): Android's New chat button stays in the list pane; pinned to the screen's
   right edge it covered the open chat's messages on a Samsung A03s in landscape (device audit 2026-11-14) */
@media (min-width: 721px) { .android .compose-btn { right: auto; left: calc(env(safe-area-inset-left) + 320px - 56px - var(--space-4)); } }

.row-lines { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: start; } /* a row's label with a second line (AC-MT-03) */

.link-btn { border: 0; background: none; padding: 0 2px; min-height: 44px; font: inherit; font-weight: 600; color: var(--accent); text-align: start; } /* "Use @colan" (AC-RG-06) */
