/* Phone first (iPhone 390 to 430 px wide), light and dark from the system. */

/* Colours, shape and the dark set come from tokens.css (generated from design.json). */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow: hidden; /* the document never scrolls; the thread does */
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* The shell fills the visible area: viewport.js sets --vv-top and
   --vv-height from window.visualViewport, so the iOS keyboard shrinks it
   instead of covering it. Without them, 100dvh; without dvh, top to bottom. */
.app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top, 0px);
  bottom: 0;
  height: var(--vv-height, 100dvh);
  overflow: hidden;
}
.view { display: none; height: 100%; }
.app[data-view="loading"] .view-loading,
.app[data-view="unpaired"] .view-unpaired { display: flex; }
.app[data-view="main"] .view-main { display: flex; }
.view-main .chats-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.view-main .thread-pane { flex: 1; min-width: 0; display: none; flex-direction: column; height: 100%; }
.app[data-pane="thread"] .thread-pane { display: flex; }
.app[data-pane="thread"] .chats-pane { display: none; }

/* Loading and unpaired */

.view-loading, .view-unpaired {
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.pair-card { width: 100%; max-width: 360px; text-align: center; }
/* Row 155: the footer link to the instructions for connecting an AI, and the mark on a message sent through one. */
.view-unpaired { flex-direction: column; }
.site-foot { margin-top: 32px; font-size: 15px; }
.site-foot a { color: var(--link); }
.via-line { display: block; font-size: 13px; color: var(--mine-muted); margin-bottom: 2px; }
.pair-icon { width: 88px; height: 88px; border-radius: 20px; }
.view-loading .pair-icon { opacity: 0.6; }
.pair-card h1 { font-size: 28px; margin: 20px 0 8px; }
.muted { color: var(--muted); margin: 0 0 28px; }
.error { color: var(--danger); margin: 16px 0 0; }

.big-button {
  display: block;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 18px;
  font-weight: 600;
}
.big-button:disabled { opacity: 0.5; }

.text-button {
  background: none;
  border: 0;
  color: var(--accent);
  padding: 10px 6px;
  min-height: 44px;
}
.text-button.strong { font-weight: 600; }
.text-button.danger { color: var(--danger); }

/* Bars */

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-right)) 6px max(8px, env(safe-area-inset-left));
  background: var(--bar);
  border-bottom: 0.5px solid var(--line);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  flex: none;
}
.bar-side { width: 64px; display: flex; justify-content: flex-end; }
.bar-side:first-child { justify-content: flex-start; }
.bar-title { flex: 1; text-align: center; min-width: 0; padding-top: 6px; }
.bar-title h1, .bar-title h2 { font-size: 17px; font-weight: 600; margin: 0; }
.sub { font-size: 12px; color: var(--muted); margin: 1px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub.down { color: var(--danger); }
/* The time in "Your Mac has not answered since ..." must always show. */
#last-answered { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.3; }

.icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.banner {
  flex: none;
  background: var(--banner);
  color: var(--banner-text);
  font-size: 14px;
  text-align: center;
  padding: 8px 16px;
}

/* Thread */

.thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  /* Vertical wins (the owner, 2026-11-20): a slanted thumb scrolls the thread; the thread has no sideways
     scroll of its own and its content never makes one. Pinch zoom stays. */
  overflow-x: hidden;
  overscroll-behavior-x: none;
  touch-action: pan-y pinch-zoom;
  -webkit-overflow-scrolling: touch;
  padding: 12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left));
}

/* Bottom anchor: a short thread sits at the bottom, newest just above the composer. */
.thread > * { flex: none; }
.messages { list-style: none; margin: auto 0 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
/* Row 220, build 21: the time is a muted token at full opacity, never text at 0.65 (that was 4.71 and
   4.57 to 1 on mine). mine-muted on mine 7.06 / 7.15, theirs-muted on theirs 8.15 / 8.77 (light / dark),
   held at 7 by design.json contrast. */
.bubble .time { display: block; text-align: right; font-size: 11px; line-height: 1.2; margin-top: 2px; }
.bubble.mine .time { color: var(--mine-muted); }
.bubble.theirs .time, .bubble.in .time { color: var(--theirs-muted); }

.bubble {
  max-width: var(--bubble-max-pct);
  padding: var(--bubble-pad-v) var(--bubble-pad-h);
  border-radius: var(--bubble-radius);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.bubble p { margin: 0; white-space: pre-wrap; }
/* Read more and Show less (fold.js): the height eases there, so the limit is a max-height, never a cut of the text. */
.bubble p.fold { line-height: 1.35; overflow: hidden; }
.bubble p.fold.folded { max-height: calc(12 * 1.35em); }
.bubble .fold-toggle { display: block; margin: 4px 0 0; padding: 4px 0; min-height: 28px; border: 0; background: none; color: inherit; font: inherit; font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .bubble p.fold { transition: none !important; } }
.bubble.mine { align-self: flex-end; background: var(--mine); color: var(--mine-text); }
.bubble.mine.tail { border-bottom-right-radius: var(--tail-radius); }
.bubble.theirs, .bubble.in { align-self: flex-start; background: var(--theirs); color: var(--theirs-text); }
.bubble.theirs.tail, .bubble.in.tail { border-bottom-left-radius: var(--tail-radius); }
/* Row 220, build 21: muted at full opacity, 9.35 / 9.46 to 1 on bg (it was 3.62 / 4.61 at 0.65). */
.stamp { font-size: 11px; color: var(--muted, inherit); margin: 3px 6px 0; }
.stamp.mine { align-self: flex-end; }
.stamp.theirs { align-self: flex-start; }
.day-line { align-self: center; font-size: 12px; opacity: 0.7; margin: 14px 0 8px; }
/* Build 22 finding 8: no opacity on a waiting bubble (0.6 gave 2.81:1 for the muted time on mine);
   at full opacity its words keep the bubble pairs (7.06 and up to 1). It is marked by a dashed ring in
   the muted token, outside the bubble on the page and its backdrop (3:1 and up, WCAG 1.4.11; the edge
   token is under 3 on the light backdrop's darkest pixel), and by its sending tick. */
.bubble.pending { cursor: pointer; outline: 1px dashed var(--muted); outline-offset: 2px; }
.bubble a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.waiting-menu { display: flex; gap: 8px; margin-top: 6px; justify-content: flex-end; }
.waiting-action { font: inherit; font-size: 13px; padding: 6px 12px; min-height: 32px; border: 0; border-radius: 14px; background: var(--accent-text); color: var(--accent); cursor: pointer; }
.unread-line { align-self: stretch; display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; color: var(--note); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.unread-line::before, .unread-line::after { content: ""; flex: 1; border-top: 0.5px solid var(--line); }
.to-latest-wrap { position: sticky; bottom: 0; height: 0; }
.to-latest { position: absolute; right: 4px; bottom: 10px; width: 44px; height: 44px; padding: 0; border: 0.5px solid var(--line); border-radius: 22px; background: var(--bar); color: var(--accent); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.18); }
.to-latest[hidden] { display: none; }
/* Row 34: the count of new answers, on the button's top corner. */
.to-latest-count { position: absolute; top: -8px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; box-sizing: border-box; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 600; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; pointer-events: none; }
.to-latest-count[hidden] { display: none; }
/* Narrow windows: while the button shows, the thread's bottom padding clears it (44px button plus 12px), so the last bubble's time is never under it. */
.thread:has(.to-latest:not([hidden])) { padding-bottom: calc(12px + 56px); }
/* Proof 2026-11-20: at phone width the button and its count badge sat over the time and ticks of the bubble under it.
   While the button shows, a right gutter holds it (the same gutter wide windows always keep). */
.thread:has(.to-latest:not([hidden])) { padding-right: max(56px, env(safe-area-inset-right)); }
.thread:has(.to-latest:not([hidden])) .to-latest { right: -48px; }
/* Wide windows: a gutter on the right holds the chevron, so it never sits over the time and ticks of the bubble under it. */
@media (min-width: 700px) {
  .thread { padding-right: max(56px, env(safe-area-inset-right)); }
  .to-latest { right: -48px; }
  .thread:has(.to-latest:not([hidden])) { padding-bottom: 12px; }
}
.bubble .foot { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 2px; }
.bubble .foot .time, .bubble .foot .meta { display: inline; margin-top: 0; }
.tick { display: inline-flex; align-items: center; line-height: 0; }
.tick[data-state="sending"], .tick[data-state="sent"] { color: var(--tick-sent); }
.tick[data-state="read"] { color: var(--tick-read); }
.bubble .meta { display: block; font-size: 11px; margin-top: 3px; opacity: 0.85; text-align: right; }

.app[data-people="1"] #messages, .app[data-people="1"] .composer { display: none; }
.note { align-self: center; color: var(--note); font-size: 13px; text-align: center; padding: 6px 12px; max-width: 90%; }

.patience { margin: 6px auto 0; }
.again { font: inherit; font-size: 13px; padding: 6px 12px; min-height: 32px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
.again[hidden] { display: none; }
.patience-again { align-self: center; margin: 0 auto 6px; }
.failed { margin: 6px 0 0; align-self: flex-end; text-align: right; color: var(--danger); }
.failed .again { margin-left: 6px; }
/* Row 47: Hide sits beside Ask again, quieter, so the one that resends stays the loud one. */
.again.again-quiet { background: var(--accent-soft); color: var(--accent); }
.row-tick { flex: none; }
/* The bubble ticks are pale because they sit on the blue bubble; the list row is white in light, so its ticks use text tokens (7:1, WCAG AAA, test/web/rows-1120d.test.ts). */
.chat-bottom .row-tick[data-state="sent"], .chat-bottom .row-tick[data-state="sending"] { color: var(--muted); }
.chat-bottom .row-tick[data-state="read"] { color: var(--accent); }
.working { display: inline-flex; gap: 5px; margin-top: 4px; padding: 13px 15px; }
.working .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); animation: pulse 1.2s infinite ease-in-out; }
.working .dot:nth-child(2) { animation-delay: 0.2s; }
.working .dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); } 40% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .working .dot { animation: none; opacity: 0.7; } }

.flash {
  flex: none;
  margin: 0;
  padding: 8px 16px;
  font-size: 14px;
  text-align: center;
  color: var(--danger);
  background: var(--surface);
  border-top: 0.5px solid var(--line);
}

/* Composer: sticky at the bottom, above the home indicator. */

.composer {
  position: sticky;
  bottom: 0;
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px; /* build 28: one 8 unit scale; plus to field equals field to mic or send */
  padding: 8px max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: var(--bar);
  border-top: 0.5px solid var(--line);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

.composer textarea {
  flex: 1;
  min-height: 36px; /* build 28: one line is the control size, so field and round controls share a centre */
  max-height: 180px;
  resize: none;
  /* Row 220, build 21: the field's only edge is the edge token, 3:1 or more on the surface and the
     bar in both modes (design.json contrast), never line (1.36 to 1.45 to 1). */
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 6px 11px; /* 1px border + 11 = a 12px text inset; 6 + 22 line + 6 + 2 = 36 */
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px; /* 16px or more keeps iOS from zooming in */
  line-height: 22px;
}
/* Build 28: ONE focus outline. Focused, the field's own border becomes the focus colour at 2px (4.70 / 8.91
   to 1 over the bar, WCAG 2.4.13); the padding gives back the extra 1px so the text does not move. */
.composer textarea:focus { outline: none; border: var(--focus-width) solid var(--focus); padding: 5px 10px; }

.send {
  flex: none;
  position: relative; /* build 28: 36px drawn, 44px target through ::after */
  width: 36px;
  height: 36px;
  min-width: 0;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
/* Row 30: with nothing to send the button is a grey disc, plainly not a button to press. */
.send:disabled { background: var(--line); color: var(--muted); opacity: 1; cursor: not-allowed; }
.send:active { opacity: 0.8; }
.send::after, .attach::after, .dictate::after, .dictate-lang::after { content: ''; position: absolute; inset: -4px; }

/* Settings sheet */

.sheet {
  position: absolute; /* inside the fixed shell, so it follows the keyboard too */
  inset: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.group-title { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--muted); margin: 24px 16px 6px; }
.group { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: 12px; overflow: hidden; }
.group-foot { font-size: 13px; color: var(--muted); margin: 6px 16px 0; }

.row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  min-height: 48px;
  padding: 8px 16px;
  border-bottom: 0.5px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-label { flex: 1; min-width: 0; }
.row-note { font-size: 13px; color: var(--muted); }
/* A device: the name takes the whole row, the meta and Revoke sit beneath. */
.row.device { align-items: baseline; }
.row.device .row-label { flex: 1 1 100%; overflow-wrap: anywhere; }
.row.device .row-note { flex: 1 1 0; min-width: 0; }
.row.device .text-button { flex: none; }
.row.disabled .row-label { color: var(--muted); }

.row-button {
  flex: 1;
  text-align: left;
  background: none;
  border: 0;
  color: var(--accent);
  padding: 6px 0;
  min-height: 36px;
}
.row-button.danger { color: var(--danger); }
.row-button:disabled { color: var(--muted); }

.switch {
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: var(--line);
  position: relative;
  opacity: 0.6;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #ffffff;
}

@media (min-width: 700px) {
  .sheet-body { max-width: 680px; margin: 0 auto; width: 100%; }
}
@media (min-width: 700px) and (max-width: 899px) {
  .thread-pane { max-width: 680px; margin: 0 auto; width: 100%; }
}

/* Chat list: one row per chat (WhatsApp's way of working, this app's own look). */
.chat-rows { list-style: none; margin: 0; padding: 0 0 env(safe-area-inset-bottom); overflow-y: auto; flex: 1; }
.chat-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: var(--row-height);
  padding: 0 0 0 max(16px, env(safe-area-inset-left)); border: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.chat-row:active, .chat-row[aria-current="true"] { background: var(--accent-soft); }
.chat-mono {
  flex: none; width: var(--monogram); height: var(--monogram); border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 600; color: var(--mono-text);
}
.chat-mono.avatar-0 { background: var(--avatar1); }
.chat-mono.avatar-1 { background: var(--avatar2); }
.chat-mono.avatar-2 { background: var(--avatar3); }
.chat-mono.avatar-3 { background: var(--avatar4); }
.chat-mono.avatar-4 { background: var(--avatar5); }
.chat-mono.avatar-5 { background: var(--avatar6); }
.chat-mono.fill-mono1 { background: var(--mono1); }
.chat-mono.fill-mono2 { background: var(--mono2); }
.chat-mono { position: relative; overflow: hidden; }
.chat-mono .avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.header-avatar { display: flex; align-items: center; margin-left: 4px; }
.header-avatar .chat-mono { width: 32px; height: 32px; font-size: 15px; }
.thread-pane .bar-side { width: 96px; }
.pair-card h2.pair-sub { font-size: 17px; font-weight: 500; margin: 0 0 8px; color: var(--muted); }
.chat-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding: 12px max(16px, env(safe-area-inset-right)) 12px 0; border-bottom: 0.5px solid var(--line); align-self: stretch; justify-content: center; }
.chat-top, .chat-bottom { display: flex; align-items: center; gap: 8px; }
.chat-name { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { flex: none; font-size: 13px; color: var(--muted); }
.chat-time.unread { color: var(--accent); }
.chat-line { flex: 1; min-width: 0; font-size: 15px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-badge { flex: none; min-width: var(--badge-min); height: var(--badge-min); padding: 0 6px; border-radius: 11px; background: var(--badge); color: var(--badge-text); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.back-button { margin-left: -6px; }

/* Wide screens: the list and the thread side by side, like WhatsApp desktop. */
@media (min-width: 900px) {
  .app[data-view="main"] .view-main { flex-direction: row; }
  .view-main .chats-pane, .app[data-pane="thread"] .chats-pane { display: flex; flex: none; width: 340px; border-right: 0.5px solid var(--line); }
  .view-main .thread-pane, .app[data-pane="list"] .thread-pane { display: flex; flex: 1; max-width: none; }
  .back-button { display: none; }
}

/* Attach button, upload progress, file chips */

.attach {
  flex: none;
  position: relative;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.attach:active { opacity: 0.6; }
.attach-menu { flex: none; padding: 8px 16px 4px; background: var(--surface); border-top: 0.5px solid var(--line); }
.attach-menu[hidden] { display: none; }
.attach-choices { display: flex; gap: 12px; padding: 4px 0 8px; }
.attach-choices button { flex: 1 1 0; min-width: 72px; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 10px 8px; border: 0; border-radius: 16px; background: var(--accent-soft, rgba(127, 127, 127, 0.14)); color: var(--accent); font: inherit; font-size: 15px; }
.attach-choices button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.attach-choices button:active { opacity: 0.6; }
.confirm { max-width: min(320px, calc(100vw - 32px)); padding: 20px; border: 0; border-radius: 16px; background: var(--surface); color: var(--text, inherit); }
.confirm::backdrop { background: rgba(0, 0, 0, 0.45); }
.confirm-title { margin: 0 0 6px; font-size: 17px; }
.confirm-body { margin: 0 0 16px; color: var(--muted); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 16px; }
.confirm-actions button { min-height: 44px; min-width: 44px; }
.attach[hidden] { display: none; }

.att { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.bubble .pic {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  --ar: 1;
  width: min(280px, calc(340px * var(--ar)));
  max-width: 100%;
  aspect-ratio: var(--ar);
}
.bubble .thumb { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.bubble .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; width: min(280px, 100%); border-radius: 12px; overflow: hidden; }
.bubble .grid.n3 .cell:first-child { grid-column: 1 / -1; }
.bubble .grid .cell { position: relative; display: block; padding: 0; border: 0; background: transparent; cursor: pointer; aspect-ratio: 1; overflow: hidden; }
.bubble .grid.n3 .cell:first-child { aspect-ratio: 2 / 1; }
.bubble .grid .thumb { border-radius: 0; }
.bubble .grid .more { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bar); color: var(--accent); font-size: 22px; font-weight: 600; opacity: 0.9; }
.bubble .chip.has-preview { flex-wrap: wrap; }
.bubble .chip-preview { width: 100%; max-height: 220px; object-fit: contain; object-position: top; border-radius: 8px; border: 0.5px solid var(--line); background: var(--bg); }
.bubble .caption { margin: 0; font-size: 16px; line-height: 1.3; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble .chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: inherit;
  text-decoration: none;
}
.bubble .chip-icon { flex: none; display: inline-flex; }
.bubble .vid { display: flex; flex-direction: column; gap: 4px; width: min(280px, 100%); }
.bubble .vid-player { display: block; width: 100%; max-height: 420px; border-radius: 12px; background: var(--bar); }
.bubble .vid-note { font-size: 13px; opacity: 0.8; }
.bubble .chip-name { overflow-wrap: anywhere; min-width: 0; }
.bubble .chip-size { flex: none; font-size: 13px; opacity: 0.8; }
.bubble.upload .upload-line { margin: 4px 0 0; font-size: 13px; }
.bubble.upload progress { width: 100%; height: 6px; display: block; margin-top: 4px; }
.bubble.upload progress[hidden] { display: none; }
.bubble.upload.failed .upload-line { font-weight: 600; }
.upload-actions { display: flex; gap: 8px; margin-top: 6px; }
.upload-actions button { min-height: 32px; padding: 0 14px; border: 1px solid currentColor; border-radius: 16px; background: transparent; color: inherit; font-size: 14px; cursor: pointer; }
.attach-bar .attach-name, .attach-bar .attach-size { display: block; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.lightbox-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox-nav { position: absolute; top: 50%; width: 44px; height: 44px; margin-top: -22px; border: 0.5px solid var(--line); border-radius: 22px; background: var(--bar); color: var(--accent); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lightbox-nav:disabled { opacity: 0.3; cursor: default; }
.lightbox-nav.prev { left: max(12px, env(safe-area-inset-left)); }
.lightbox-nav.next { right: max(12px, env(safe-area-inset-right)); }
.lightbox-count { position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 14px; color: var(--muted); }
.lightbox-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border: 0.5px solid var(--line);
  border-radius: 22px;
  background: var(--bar);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* Add to Home Screen guidance */

.addhome {
  flex: none;
  margin: 0;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--surface);
  border-top: 0.5px solid var(--line);
  font-size: 15px;
}
.addhome[hidden] { display: none; }
.addhome-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.addhome h2 { margin: 0; font-size: 17px; }
.addhome-steps { margin: 8px 0 6px; padding-left: 22px; }
.addhome-steps li { margin: 2px 0; }
.addhome-steps .share-glyph { vertical-align: -4px; margin-left: 4px; color: var(--accent); }
.addhome p { margin: 2px 0; }
.addhome .muted { margin: 2px 0; }
.pushask { overflow-wrap: anywhere; }
.pushask-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 16px; margin-top: 6px; }
.pushask-actions .text-button { min-height: 44px; min-width: 44px; }

/* Permission gate cards: one per tool call waiting for the owner's OK. */
.gate { list-style: none; margin: 0; padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.gate:empty { display: none; }
.gate-card { border: 1px solid var(--note); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.gate-card .gate-tool { font-weight: 600; }
.gate-card .gate-summary { margin: 0; font-family: ui-monospace, Menlo, monospace; font-size: 13px; overflow-wrap: anywhere; white-space: pre-wrap; }
.gate-card .gate-meta { color: var(--note); font-size: 13px; }
.gate-card .gate-actions { display: flex; gap: 8px; }
.gate-card .gate-actions button { flex: 1; min-height: 44px; border-radius: 10px; font: inherit; }
.gate-card.done { opacity: 0.7; }

/* Approval cards (card.js): the owner's step on the assistant's message. */
.bubble.has-card { background: var(--surface); color: var(--text); border: 1px solid var(--line); width: min(340px, 86%); }
.approval-card { display: flex; flex-direction: column; gap: 4px; }
.approval-card p { margin: 0; }
.approval-card .approval-title { font-weight: 600; font-size: 16px; }
.approval-card .approval-item { overflow-wrap: anywhere; }
.approval-card .approval-total { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.approval-card .approval-irreversible { color: var(--danger); font-size: 13px; }
.approval-card .approval-status { color: var(--muted); font-size: 13px; }
.approval-card .approval-note { color: var(--danger); font-size: 13px; }
.approval-card .approval-actions { display: flex; gap: 8px; margin-top: 6px; }
.approval-card .approval-actions button { flex: 1; min-height: 44px; border-radius: 12px; font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; }
.approval-card .approval-actions .approve { background: var(--accent); color: var(--accent-text); border: 0; }
.approval-card .approval-actions .decline { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.approval-card .approval-actions button:disabled { opacity: 0.5; cursor: default; }
.approval-card .approval-actions button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.approval-card.approved .approval-status { color: var(--accent); font-weight: 600; }
.approval-card.declined, .approval-card.expired { opacity: 0.8; }

/* reply and quote (slice 4) */
.bubble { position: relative; }
.quote { display: block; margin: 0 0 6px; padding: 6px 10px; border-left: 3px solid var(--quote-theirs-bar); border-radius: 6px; background: var(--quote-theirs); color: var(--theirs-text); cursor: pointer; font-size: 13px; line-height: 1.3; }
.bubble.mine .quote { border-left-color: var(--quote-mine-bar); background: var(--quote-mine); color: var(--mine-text); }
.quote.gone { cursor: default; font-style: italic; }
.quote-name { display: block; font-weight: 600; font-size: 12px; }
.quote-text { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; }
.bubble.flash { animation: quote-flash 1.4s ease-out; }
@keyframes quote-flash { 0%, 60% { outline: 2px solid var(--accent); outline-offset: 2px; } 100% { outline: 2px solid transparent; outline-offset: 2px; } }
@media (prefers-reduced-motion: reduce) { .bubble.flash { animation: none; outline: 2px solid var(--accent); } }
.reply-btn { position: absolute; top: 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: var(--bar); color: var(--accent); display: flex; opacity: 0; pointer-events: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.bubble.mine .reply-btn { left: -98px; }
.bubble.theirs .reply-btn { right: -98px; }
@media (hover: hover) { .bubble:hover .reply-btn, .bubble:focus-within .reply-btn { opacity: 1; pointer-events: auto; } }
.reply-btn:focus-visible { opacity: 1; pointer-events: auto; outline: 2px solid var(--accent); }
.react-btn { position: absolute; top: 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: var(--bar); color: var(--accent); display: flex; opacity: 0; pointer-events: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 3px var(--shadow-soft); }
.bubble.mine .react-btn { left: -146px; }
.bubble.theirs .react-btn { right: -146px; }
@media (hover: hover) { .bubble:hover .react-btn, .bubble:focus-within .react-btn { opacity: 1; pointer-events: auto; } }
.react-btn:focus-visible { opacity: 1; pointer-events: auto; outline: 2px solid var(--accent); }
.bubble.has-react { margin-bottom: 14px; }
.react-pill { position: absolute; bottom: -12px; min-width: 26px; height: 24px; padding: 0 6px; border: 1px solid var(--react-pill-line); border-radius: 12px; background: var(--react-pill); color: var(--react-pill-text); display: flex; align-items: center; justify-content: center; }
.react-pill svg { width: 16px; height: 16px; }
.bubble.mine .react-pill { left: 10px; }
.bubble.theirs .react-pill { right: 10px; }
.react-picker { position: fixed; z-index: 30; display: flex; gap: 2px; padding: 4px; border: 0.5px solid var(--line); border-radius: 24px; background: var(--bar); color: var(--react-pill-text); box-shadow: 0 4px 16px var(--shadow-lift); }
.react-opt { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.react-opt svg { width: 22px; height: 22px; }
.react-opt:hover, .react-opt:focus-visible { background: var(--quote-theirs); }
.react-opt[aria-checked="true"] { background: var(--quote-theirs); outline: 2px solid var(--react-pill-text); }
.bubble-menu { position: fixed; z-index: 30; min-width: 120px; padding: 4px; border: 0.5px solid var(--line); border-radius: 10px; background: var(--bar); color: var(--theirs-text); box-shadow: 0 4px 16px rgba(0,0,0,0.25); display: flex; flex-direction: column; }
.bubble-menu button { font: inherit; text-align: left; padding: 10px 12px; min-height: 44px; border: 0; background: transparent; color: inherit; border-radius: 6px; cursor: pointer; }
.bubble-menu button:hover, .bubble-menu button:focus-visible { background: var(--quote-theirs); }
.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-top: 0.5px solid var(--line); background: var(--bar); }
.reply-bar[hidden] { display: none; }
.reply-body { flex: 1; min-width: 0; padding-left: 10px; border-left: 3px solid var(--quote-theirs-bar); display: flex; flex-direction: column; }
.reply-name { font-size: 12px; font-weight: 600; color: var(--accent); }
.reply-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-close { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: transparent; color: var(--muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }

/* Voice notes: the mic beside the box, the recording bar, the voice bubble */

.send[hidden] { display: none; }
.rec-level { flex: 1; height: 6px; border-radius: 3px; background: var(--hairline, rgba(128,128,128,.25)); overflow: hidden; }
.rec-level i { display: block; height: 100%; width: 100%; background: var(--danger); transform-origin: left center; transform: scaleX(var(--lv, 0)); transition: transform 0.12s linear; }
.rec-bar.paused .rec-dot { animation: none; opacity: 0.5; }
.voice-speed { flex: none; min-width: 38px; height: 26px; padding: 0 8px; border: 0; border-radius: 13px; background: var(--hairline, rgba(128,128,128,.25)); color: inherit; font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
.voice-bar { cursor: pointer; }
.send.mic.recording { background: var(--danger); color: var(--accent-text); }
.rec-bar { gap: 10px; }
.rec-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: rec-pulse 1.2s ease-in-out infinite; }
.rec-time { min-width: 44px; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--text); }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

.voice { display: flex; flex-direction: column; gap: 6px; min-width: 220px; max-width: 100%; }
.voice-row { display: flex; align-items: center; gap: 10px; }
.voice-play {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--mine-text);
  color: var(--mine);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.voice-play:disabled { opacity: 0.55; cursor: default; }
.voice-bar { flex: 1; height: 6px; border-radius: 3px; background: var(--quote-mine); overflow: hidden; min-width: 60px; }
.voice-fill { height: 100%; width: calc(var(--p, 0) * 100%); background: var(--mine-text); border-radius: 3px; }
.voice-length { flex: none; font-size: 13px; font-variant-numeric: tabular-nums; opacity: 0.85; }
.voice-words { margin: 0; font-size: 15px; line-height: 1.3; overflow-wrap: anywhere; }
.voice-words.pending { font-style: italic; opacity: 0.85; }

.undo-host { flex: none; }
.undo-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 16px; font-size: 15px; background: var(--bar); color: var(--theirs-text); border-top: 0.5px solid var(--line); }
.undo-btn { font: inherit; font-weight: 700; min-height: 44px; min-width: 44px; padding: 0 8px; border: 0; background: transparent; color: var(--accent); cursor: pointer; }
.more-btn { position: absolute; top: 0; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: var(--bar); color: var(--accent); display: flex; opacity: 0; pointer-events: none; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 3px var(--shadow-soft); }
.bubble.mine .more-btn { left: -50px; }
.bubble.theirs .more-btn { right: -50px; }
@media (hover: hover) { .bubble:hover .more-btn, .bubble:focus-within .more-btn { opacity: 1; pointer-events: auto; } }
.more-btn:focus-visible { opacity: 1; pointer-events: auto; outline: 2px solid var(--accent); }
/* Proof 2026-11-20: on a wide window a wide incoming bubble put its rail (Reply, React, More: 146 px plus the 44 px
   button) past the pane edge, clipped. Where hover exists the bubble leaves that room, so the rail stays whole. */
@media (hover: hover) and (min-width: 700px) {
  .bubble { max-width: min(var(--bubble-max-pct), calc(100% - 200px)); }
}
/* Rows 77 and 78: the three controls stay in the accessibility tree and the tab order while
   invisible (opacity, not display: none), so a screen reader and a keyboard reach them. */

/* ---- Group G4: backdrop (row 168), Dynamic Type (row 76), tap targets (rows 80, 82, 83, 156) ---- */

/* Row 168: a blue-toned image, low on every view, never repeating. The fade is in the
   image's own alpha, so no opacity is set here. Rosenthal's 1870 Bach family painting, blue
   toned (design.json backdrop.note). Declared per look, the same
   way tokens.css does it: the system look, then the Light and Dark choices. */
:root { --backdrop: url("/backdrop-light.webp"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --backdrop: url("/backdrop-dark.webp"); } }
:root[data-theme="dark"] { --backdrop: url("/backdrop-dark.webp"); }
:root[data-theme="light"] { --backdrop: url("/backdrop-light.webp"); }
body {
  background-image: var(--backdrop);
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: min(100vw, 1100px) auto;
}
.view-main .chats-pane { background: transparent; }
/* The settings sheet is a surface of its own: the thread never shows through it. */
.sheet { background: var(--surface); }
.chat-line .draft-tag { color: var(--danger); }

/* Row 162: the Appearance choice, three buttons in a radio group; the chosen one
   carries a check mark as well as the fill, so colour is never the only signal. */
.segments { display: flex; gap: 8px; padding: 8px 16px; }
.segment { flex: 1 1 0; min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
.segment[aria-checked="true"] { border-color: var(--accent); border-width: 2px; font-weight: 600; }
.segment[aria-checked="true"]::before { content: ""; display: inline-block; width: 0.35em; height: 0.7em; margin-right: 0.5em; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg) translateY(-0.12em); }
.segment:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Row 76: text follows the browser's text size up to its largest. Sizes are rem
   (16 px root, so 1rem is the old 16 px); heights give way with min-height. */
body { font-size: 1.0625rem; }
.bar-title h1, .bar-title h2, .chat-name, .confirm-title, .addhome h2, .pair-card h2.pair-sub { font-size: 1.0625rem; }
.pair-card h1 { font-size: 1.75rem; }
.sub, .day-line, .unread-line, .quote-name, .reply-name { font-size: 0.75rem; }
.bubble .time, .stamp, .bubble .meta { font-size: 0.6875rem; }
.row-note, .group-title, .group-foot, .chat-time, .note, .via-line, .quote, .reply-text, .gate-summary, .gate-meta, .bubble .vid-note, .bubble .chip-size, .bubble.upload .upload-line, .voice-length, .voice-speed, .chat-badge, .waiting-action, .again, .approval-card .approval-irreversible, .approval-card .approval-status, .approval-card .approval-note { font-size: 0.8125rem; }
.chat-line, .fold-toggle, .attach-choices button, .voice-words, .undo-bar, .site-foot { font-size: 0.9375rem; }
.bubble .caption, .approval-card .approval-title { font-size: 1rem; }
.rec-time, .composer textarea { font-size: 1.0625rem; }

/* Rows 80, 82, 83: every control is at least 44 by 44 CSS px. */
.voice-play, .more-btn, .lightbox-nav { min-width: 44px; min-height: 44px; }
.voice-play { width: auto; height: auto; }
.site-foot a, .group-foot a { display: inline-flex; align-items: center; min-height: 44px; }
.quote:not(.gone) { min-height: 44px; box-sizing: border-box; }
.quiet-row input { min-height: 44px; box-sizing: border-box; }
/* Row 52: the no connection banner sits under the paused one. Row 56: the empty thread's one line. */
.conn-banner { border-top: 0.5px solid var(--line); }
.empty-line { color: var(--muted); font-size: 0.9375rem; padding: 16px; }
/* Row 122: the thread dimmed behind the bubble menu, four panes around the bubble. */
.bubble-scrim { position: fixed; z-index: 25; background: var(--shadow-soft); }
.composer textarea { min-height: 36px; }
.row-button, .fold-toggle, .waiting-action, .again, .upload-actions button, .voice-speed, .undo-bar button { min-height: 44px; }
.voice-speed { min-width: 44px; height: auto; }
.more-btn { width: 44px; height: 44px; border-radius: 22px; }
.bubble.mine .more-btn { left: -50px; }
.bubble.theirs .more-btn { right: -50px; }
