[hidden] { display:none !important; }   /* "hidden" must win over any display rule below */
/* theme: Automatic follows the phone; Settings can force Light or Dark (theme.js sets data-theme on <html>) */
:root { --bg:#f6f6f4; --panel:#fff; --ink:#1d1d1f; --muted:#6b6b70; --line:#e3e3e0; --accent:#2f6f5e; --mine:#e3f0eb; --err:#b3261e; --sw-off:#d1d1d6; --sw-on:#34c759; --ts:1; color-scheme:light; }
:root[data-theme="dark"] { --bg:#151517; --panel:#1f1f22; --ink:#ececec; --muted:#9a9aa0; --line:#333338; --accent:#6cc0a6; --mine:#22382f; --err:#ff8a80; --sw-off:#3a3a3e; --sw-on:#30d158; color-scheme:dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --bg:#151517; --panel:#1f1f22; --ink:#ececec; --muted:#9a9aa0; --line:#333338; --accent:#6cc0a6; --mine:#22382f; --err:#ff8a80; --sw-off:#3a3a3e; --sw-on:#30d158; color-scheme:dark; } }
/* text size (Settings): every text size below is multiplied by --ts */
:root[data-text="s"] { --ts:.9; } :root[data-text="l"] { --ts:1.15; } :root[data-text="xl"] { --ts:1.3; }
* { box-sizing: border-box; }
body { margin:0; font:calc(15px * var(--ts))/1.45 system-ui, sans-serif; background:var(--bg); color:var(--ink); }
main { max-width:1000px; margin:0 auto; height:100vh; height:100dvh; padding:16px; }
#setup { max-width:420px; margin:12vh auto; }
#app:not([hidden]) { display:grid; grid-template-columns:260px 1fr; gap:16px; height:100%; }
aside, .chat { background:var(--panel); border:1px solid var(--line); border-radius:10px; padding:12px; min-height:0; }
.chat { display:flex; flex-direction:column; min-width:0; }   /* min-width:0: long content can't widen the chat past the screen */
form { display:flex; gap:8px; }
input, textarea { flex:1; min-width:0; padding:8px 10px; border:1px solid var(--line); border-radius:6px; background:var(--bg); color:var(--ink); font:inherit; }
button { padding:8px 14px; border:0; border-radius:6px; background:var(--accent); color:#fff; font:inherit; cursor:pointer; }
.muted { color:var(--muted); } .error { color:var(--err); min-height:1.2em; font-size:calc(13px * var(--ts)); }
.me { margin-bottom:10px; }
#contacts { list-style:none; padding:0; margin:0; }
#contacts li { padding:8px; border-radius:6px; cursor:pointer; display:flex; justify-content:space-between; }
#contacts li.active { background:var(--mine); }
#contacts .badge { background:var(--accent); color:#fff; border-radius:9px; padding:0 7px; font-size:calc(12px * var(--ts)); }
#chat-header { font-weight:600; padding-bottom:8px; border-bottom:1px solid var(--line); display:flex; align-items:center; gap:8px; min-height:36px; }
#chat-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1 1 auto; min-width:0; }
.back { display:none; position:relative; background:none; color:var(--accent); font-size:calc(30px * var(--ts)); line-height:1; padding:0 10px 4px 2px; }
.back .badge { position:absolute; top:-2px; left:18px; font-size:calc(11px * var(--ts)); line-height:16px; }
.safety { font-size:calc(12px * var(--ts)); color:var(--muted); padding:6px 0; border-bottom:1px solid var(--line); }
.safety summary { cursor:pointer; padding:2px 0; }
#safety-num { font-family:ui-monospace, monospace; color:var(--ink); letter-spacing:.5px; }
.safety p { margin:6px 0 2px; line-height:1.4; }
#messages { list-style:none; overscroll-behavior:contain; flex:1; overflow-y:auto; padding:8px 8px 8px 4px; margin:0 -6px 0 -6px; display:flex; flex-direction:column; gap:6px; }
#messages li { max-width:75%; overflow-wrap:anywhere; padding:7px 11px; border-radius:10px; background:var(--bg); align-self:flex-start; white-space:pre-wrap; }   /* (no word-wrap:break-word after this: it is the same property and would cancel "anywhere") */
#messages li.mine { background:var(--mine); align-self:flex-end; }
#messages li.bad { color:var(--err); font-style:italic; }
#messages time { display:block; font-size:calc(11px * var(--ts)); color:var(--muted); }
.small { font-size:calc(13px * var(--ts)); margin:6px 0 0; }

/* ---- phones / narrow portrait: one pane at a time (list, or the open chat) ---- */
@media (max-width: 700px) {
  main { padding:0; }
  #setup { margin:8vh auto; padding:0 16px; }
  #app:not([hidden]) { grid-template-columns:1fr; gap:0; }
  #app:not(.in-chat) .chat, #app.in-chat aside { display:none; }
  aside, .chat { border:0; border-radius:0; padding:12px max(12px, env(safe-area-inset-right)) 12px max(12px, env(safe-area-inset-left)); }
  aside { overflow-y:auto; padding-top:max(12px, env(safe-area-inset-top)); }
  .chat { padding-top:max(8px, env(safe-area-inset-top)); padding-bottom:max(10px, env(safe-area-inset-bottom)); }
  .back { display:inline-block; }
  input, select, textarea { font-size:max(16px, calc(15px * var(--ts))); padding:10px 12px; }   /* 16px+ stops iOS zooming in on focus */
  button { padding:10px 16px; }
  #contacts li { padding:14px 10px; border-bottom:1px solid var(--line); border-radius:0; }
  #messages li { max-width:85%; }
  #messages { margin:0 calc(-1 * max(12px, env(safe-area-inset-right))) 0 -8px; padding-right:calc(max(12px, env(safe-area-inset-right)) - 4px); }   /* scrollbar at the screen edge, bubbles ~8px in */
  #send-form { padding-top:8px; }
}

/* ---- v0.3 accounts ---- */
form.stack, .stack { display:flex; flex-direction:column; gap:10px; }
.stack.small-gap { gap:6px; margin-bottom:10px; }
.field { font-size:calc(13px * var(--ts)); line-height:1.3; margin-bottom:-2px; }   /* label above a box: wraps, unlike a placeholder */
.field + input { margin-bottom:4px; }
.stack p { margin:0; }
.row { display:flex; gap:8px; }
.tabs { display:flex; gap:4px; margin-bottom:14px; border-bottom:1px solid var(--line); }
.tab { background:none; color:var(--muted); border-radius:6px 6px 0 0; border-bottom:2px solid transparent; }
.tab.on { color:var(--ink); border-bottom-color:var(--accent); font-weight:600; }
button.link { background:none; color:var(--accent); padding:2px 0; font-size:calc(13px * var(--ts)); text-align:left; }
button.alt { background:var(--bg); color:var(--ink); border:1px solid var(--line); }
button:disabled { opacity:.55; cursor:default; }
#rc-show { max-width:460px; margin:10vh auto; }
.rc { display:block; font:600 18px/1.6 ui-monospace, monospace; letter-spacing:1px; word-spacing:4px; padding:14px;
      margin:14px 0; background:var(--panel); border:1px solid var(--line); border-radius:8px; user-select:all; overflow-wrap:anywhere; }
.check { display:flex; gap:8px; align-items:center; }
.check input { flex:0 0 auto; width:18px; height:18px; }
.acct { display:flex; flex-wrap:wrap; justify-content:space-between; gap:4px 10px; margin:-4px 0 10px; }
.note { background:var(--bg); border:1px solid var(--line); border-radius:6px; padding:8px; color:var(--muted); }
@media (max-width: 700px) { #rc-show { margin:6vh auto; padding:0 16px; } }

/* ---- v0.4 invites ---- */
button.wide { width:100%; margin-bottom:10px; }
.panel { background:var(--bg); border:1px solid var(--line); border-radius:8px; padding:10px; }
.panel p { margin:0; }
.warn-box { border-color:#c0392b; margin:8px 0; }
.warn-box p + p { margin-top:6px; }
.warn-box button { margin-top:8px; }
.invite-pane { padding:14px 2px; display:flex; flex-direction:column; gap:10px; min-height:0; overflow-y:auto; }
.invite-pane p { margin:0; }
.linkbox { font-size:calc(13px * var(--ts)); font-weight:400; letter-spacing:0; word-spacing:0; margin:0; max-height:8.5em; overflow-y:auto; flex:none; }
.small-tag { font-size:calc(12px * var(--ts)); margin-left:auto; padding-left:8px; }
#contacts li span:first-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* chat list: name and time on top, the last message under them (on this device only) */
#contacts li { display:grid; grid-template-columns:minmax(0, 1fr) auto auto auto; column-gap:0; align-items:center; }   /* (no gaps: empty places take no room) */
#contacts li .c-name { grid-column:1; grid-row:1; font-weight:600; }
#contacts li .c-time { grid-column:2 / -1; grid-row:1; justify-self:end; font-size:calc(12px * var(--ts)); }
#contacts li .c-prev { grid-column:1; grid-row:2; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:calc(13px * var(--ts)); }
#contacts li .small-tag, #contacts li .c-muted { grid-row:2; margin-left:0; padding-left:0; font-size:calc(12px * var(--ts)); justify-self:end; }
#contacts li .small-tag { grid-column:2; margin-left:8px; } #contacts li .c-muted { grid-column:3; margin-left:6px; }
#contacts li .c-time { margin-left:8px; } #contacts li .badge { margin-left:6px; }   /* fixed places: the count always at the right edge */
/* the unread count: a pill with the number exactly in the middle (a round dot for 1-9) */
#contacts li .badge { grid-row:2; grid-column:4; justify-self:end; display:inline-flex; align-items:center; justify-content:center; box-sizing:border-box;
  min-width:calc(20px * var(--ts)); height:calc(20px * var(--ts)); padding:0 6px; border-radius:999px; line-height:1;
  font-size:calc(12px * var(--ts)); font-weight:600; font-variant-numeric:tabular-nums; }
#contacts li.active .c-prev, #contacts li.active .c-time { color:var(--ink); opacity:.7; }
#messages li.day { align-self:center; background:none; color:var(--muted); font-size:calc(12px * var(--ts)); font-weight:600; padding:6px 0 0; }
#messages li.jump-li { position:sticky; bottom:4px; align-self:flex-end; background:none; padding:0; margin:0; height:0; overflow:visible; z-index:5; }
.jump-btn { position:absolute; right:2px; bottom:0; min-width:40px; height:40px; border-radius:20px; padding:0 12px; box-shadow:0 2px 8px rgba(0,0,0,.25); font-weight:600; }
#messages li a { color:var(--accent); text-decoration:underline; overflow-wrap:anywhere; }
.quote { display:block; border-left:3px solid var(--accent); background:color-mix(in srgb, var(--panel) 60%, transparent); border-radius:6px;
  padding:3px 8px; margin:0 0 5px; font-size:calc(13px * var(--ts)); cursor:pointer; white-space:normal; max-width:100%; }
.quote b { display:block; color:var(--accent); font-size:calc(12px * var(--ts)); }
.quote span { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; color:var(--muted); }
#messages li.photo .quote, #messages li.file .quote { margin:2px 2px 5px; }
#messages li.sending { opacity:.7; }   /* the server hasn't answered after 2 s */
#messages li.pop { animation:msg-pop .14s ease-out; }   /* a message just sent slides in */
@keyframes msg-pop { from { transform:translateY(6px); } to { transform:none; } }   /* visible from the first frame: only a small slide */
@media (prefers-reduced-motion: reduce) { #messages li.pop { animation:none; } }
#messages li.flash { outline:2px solid var(--accent); outline-offset:2px; transition:outline-color 1.5s; }
.reply-bar { display:flex; align-items:center; gap:8px; margin:6px 0 0; padding:6px 8px; border-left:3px solid var(--accent); background:var(--bg); border-radius:6px; }
.reply-q { flex:1; min-width:0; font-size:calc(13px * var(--ts)); }
.reply-q b { display:block; color:var(--accent); font-size:calc(12px * var(--ts)); }
.reply-q span { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--muted); }
.reply-x { background:none; color:var(--muted); font-size:calc(22px * var(--ts)); line-height:1; padding:2px 8px; }
.safety-btn.open { color:var(--accent); background:var(--mine); }
#messages li.sys { align-self:center; background:none; color:var(--muted); font-size:calc(13px * var(--ts)); text-align:center; max-width:90%; }

/* ---- sign-up / sign-in progress panel ---- */
.prog { margin-top:16px; padding:14px 16px; background:var(--panel); border:1px solid var(--line); border-radius:10px; }
.prog-head { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.prog-shield { width:26px; height:30px; flex:0 0 auto; fill:var(--accent); animation:sc-pulse 1.6s ease-in-out infinite; }
#prog-steps { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
#prog-steps li { display:grid; grid-template-columns:20px 1fr; column-gap:10px; align-items:center; color:var(--muted); font-size:calc(14px * var(--ts)); }
#prog-steps li.on { color:var(--ink); font-weight:600; }
#prog-steps li.done { color:var(--ink); }
#prog-steps .dot { width:18px; height:18px; border-radius:50%; border:2px solid var(--line); box-sizing:border-box; position:relative; }
#prog-steps li.on .dot { border-color:var(--line); border-top-color:var(--accent); animation:sc-spin .8s linear infinite; }
#prog-steps li.done .dot { background:var(--accent); border-color:var(--accent); }
#prog-steps li.done .dot::after { content:""; position:absolute; left:4px; top:1px; width:4px; height:8px;
  border:solid #fff; border-width:0 2px 2px 0; transform:rotate(45deg); }
#prog-steps .bar { grid-column:2; display:block; height:6px; margin-top:6px; background:var(--bg); border:1px solid var(--line);
  border-radius:4px; overflow:hidden; }
#prog-steps li:not(.on) .bar, #prog-steps li:not(.on) .note-sm { display:none; }
#prog-steps .fill { display:block; height:100%; width:0; background:var(--accent); border-radius:4px; transition:width .25s ease-out; }
#prog-steps .note-sm { grid-column:2; font-size:calc(12px * var(--ts)); font-weight:400; color:var(--muted); margin-top:4px; }
@keyframes sc-spin { to { transform:rotate(360deg); } }
@keyframes sc-pulse { 50% { opacity:.55; transform:scale(.94); } }
@media (prefers-reduced-motion: reduce) { .icon-btn .plus { transition:none; } .prog-shield, #prog-steps li.on .dot { animation:none; } #prog-steps .fill { transition:none; } }
/* phones: the panel would sit below the form, under the keyboard; show it as a card over the page */
@media (max-width: 700px) {
  .prog { position:fixed; inset:0; z-index:50; margin:0; border:0; border-radius:0; background:rgba(0,0,0,.45);
          display:flex; align-items:center; justify-content:center;
          padding:max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .prog[hidden] { display:none !important; }
  .prog > * { width:100%; max-width:360px; }
  .prog-wrap { background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:18px 18px 20px; box-shadow:0 10px 30px rgba(0,0,0,.25); }
  #prog-steps li { font-size:calc(15px * var(--ts)); }
  #prog-steps .bar { height:8px; }
}

/* ---- photos ---- */
.icon-btn { flex:0 0 auto; padding:8px 10px; background:var(--bg); border:1px solid var(--line); display:flex; align-items:center; justify-content:center; }
/* the + button and its menu (icons are inline SVG: the page's security policy blocks data: images) */
.attach { position:relative; flex:0 0 auto; display:flex; }
.icon-btn { width:40px; padding:0; border-radius:50%; color:var(--accent); align-self:center; height:40px; }
.icon-btn:hover:not(:disabled), .icon-btn.open { background:var(--mine); border-color:var(--accent); }
.icon-btn .plus { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; transition:transform .15s ease-out; }
.icon-btn.open .plus { transform:rotate(45deg); }
.attach-menu { position:absolute; left:0; bottom:calc(100% + 8px); z-index:30; width:max-content; max-width:min(300px, calc(100vw - 24px));
  background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:6px; box-shadow:0 8px 24px rgba(0,0,0,.18);
  display:flex; flex-direction:column; gap:2px; }
.attach-menu button { display:flex; align-items:center; gap:12px; background:none; color:var(--ink); text-align:left; padding:9px 12px 9px 10px; border-radius:8px; }
.attach-menu button:hover, .attach-menu button:focus-visible { background:var(--mine); outline:none; }
.attach-menu svg { width:24px; height:24px; flex:0 0 auto; fill:none; stroke:var(--accent); stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.attach-menu b { display:block; font-weight:600; }
.attach-menu small { display:block; font-size:calc(12px * var(--ts)); color:var(--muted); line-height:1.3; }
/* files in the chat */
#messages li.file { padding:6px; white-space:normal; }
#messages li.file > span { display:block; padding:4px 6px 0; white-space:pre-wrap; }
#messages li.file time { padding:2px 6px 0; }
.fcard { display:flex; align-items:center; gap:10px; width:260px; max-width:100%; padding:8px 10px; border-radius:8px; text-align:left;
  background:var(--panel); color:var(--ink); border:1px solid var(--line); }
.fcard:hover:not(:disabled) { border-color:var(--accent); }
.fcard:disabled { opacity:1; }
.fic { flex:0 0 auto; width:38px; height:44px; border-radius:6px; background:var(--accent); color:var(--panel); display:flex; align-items:flex-end;
  justify-content:center; padding-bottom:6px; font:700 10px/1 system-ui, sans-serif; letter-spacing:.3px; overflow:hidden; }
.ftxt { min-width:0; display:flex; flex-direction:column; }
.fname { font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.fsub { font-size:calc(12px * var(--ts)); color:var(--muted); }
.fcard-fail .fsub { color:var(--err); }
.send-note { margin:4px 2px 0; font-size:calc(13px * var(--ts)); min-height:0; }
.send-note:empty { display:none; }
#messages li.photo { padding:4px; white-space:normal; }
#messages li.photo > span { display:block; padding:4px 6px 0; white-space:pre-wrap; }
#messages li.photo time { padding:2px 6px 0; }
.ph { max-width:100%; border-radius:8px; overflow:hidden; background:var(--line); display:flex; align-items:center; justify-content:center; cursor:pointer; }
.ph img { width:100%; height:100%; object-fit:cover; display:block; }
.ph-note { font-size:calc(13px * var(--ts)); color:var(--muted); padding:10px; text-align:center; }
.ph-fail .ph-note { color:var(--err); }
.viewer { position:fixed; inset:0; z-index:60; background:rgba(0,0,0,.88); display:flex; align-items:center; justify-content:center; cursor:zoom-out;
          padding:max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
.viewer img { max-width:100%; max-height:100%; object-fit:contain; border-radius:4px; transform-origin:center center; will-change:transform; }
.viewer { touch-action:none; user-select:none; -webkit-user-select:none; }
.viewer.zoomed { cursor:grab; }
.viewer-bar { position:absolute; top:max(10px, env(safe-area-inset-top)); right:max(10px, env(safe-area-inset-right)); display:flex; gap:8px; }
.viewer-bar button { background:rgba(255,255,255,.16); color:#fff; border-radius:18px; min-height:36px; padding:6px 14px; font-weight:600; }
#viewer-close { font-size:22px; line-height:1; padding:4px 12px; }
@media (max-width: 700px) { .icon-btn { width:44px; height:44px; padding:0; } .attach-menu button { padding:12px 14px 12px 12px; } }
/* settings: gear next to "Signed in as" opens the settings screen */
.me-row { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.me-row .me { margin:0; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.gear { flex:0 0 auto; width:36px; height:36px; padding:0; border-radius:50%; background:none; color:var(--muted);
  display:flex; align-items:center; justify-content:center; border:1px solid transparent; }
.gear svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.gear:hover { color:var(--accent); background:var(--mine); border-color:var(--line); }
/* the settings screen */
#settings:not([hidden]) { display:block; max-width:560px; margin:0 auto; height:100%; overflow-y:auto; padding-bottom:24px; }
.screen-head { position:relative; display:flex; align-items:center; justify-content:center; min-height:44px; margin-bottom:6px; }
.screen-head h1 { font-size:calc(18px * var(--ts)); margin:0; }
.back-btn { position:absolute; left:0; top:50%; transform:translateY(-50%); display:flex; align-items:center; gap:2px;
  background:none; color:var(--accent); padding:6px 8px 6px 0; font-size:calc(16px * var(--ts)); }
.back-btn svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; }
.set-who { text-align:center; font-size:calc(13px * var(--ts)); margin:0 0 14px; overflow-wrap:anywhere; }
.set-group { font-size:calc(12px * var(--ts)); font-weight:600; text-transform:uppercase; letter-spacing:.5px; color:var(--muted); margin:18px 4px 6px; }
.set-card { background:var(--panel); border:1px solid var(--line); border-radius:12px; padding:0 14px; }
.set-card > * + * { border-top:1px solid var(--line); }
.set-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 0; }
.set-row-in { padding:4px 0; }
.set-txt { display:flex; flex-direction:column; gap:2px; min-width:0; cursor:pointer; }
.set-txt b { font-weight:600; }
.set-txt .muted { font-size:calc(12px * var(--ts)); line-height:1.3; }
.set-txt .muted:empty { display:none; }
.set-item { display:flex; width:100%; align-items:center; justify-content:space-between; background:none; color:var(--ink);
  padding:14px 0; border-radius:0; text-align:left; font-size:calc(15px * var(--ts)); }
.set-item i { font-style:normal; color:var(--muted); font-size:calc(20px * var(--ts)); line-height:1; }
.set-item:hover span { color:var(--accent); }
.set-item.danger, .set-item.danger:hover span { color:var(--err); }
.set-form { padding:4px 0 12px; margin:0; border-top:0 !important; }
.set-ok { margin:0; padding:0 0 12px; font-size:calc(13px * var(--ts)); color:var(--accent); border-top:0 !important; }
button.danger-btn { background:var(--err); }
@media (max-width: 700px) {
  #settings:not([hidden]) { padding:max(8px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
}
/* the real checkbox sits invisibly on top of the drawn switch, so a tap anywhere on it toggles it */
.switch { flex:0 0 auto; position:relative; display:inline-block; width:51px; height:31px; cursor:pointer; -webkit-tap-highlight-color:transparent; }
.switch input { position:absolute; inset:0; width:100%; height:100%; margin:0; padding:0; opacity:0; z-index:1; cursor:pointer; border:0; }
.switch .slider { position:absolute; inset:0; border-radius:31px; background:var(--sw-off); transition:background .2s; pointer-events:none; }
.switch .slider::before { content:""; position:absolute; top:2px; left:2px; width:27px; height:27px; border-radius:50%; background:#fff;
  box-shadow:0 2px 4px rgba(0,0,0,.25); transition:transform .2s; }
.switch input:checked + .slider { background:var(--sw-on); }
.switch input:checked + .slider::before { transform:translateX(20px); }
.switch input:focus-visible + .slider { outline:2px solid var(--accent); outline-offset:2px; }
.switch input:disabled { cursor:not-allowed; }
.switch input:disabled + .slider { opacity:.45; }


/* ---- settings 2: selects, segmented choices, text preview ---- */
select { font:inherit; color:var(--ink); background:var(--bg); border:1px solid var(--line); border-radius:8px; padding:7px 10px; }
.set-select { flex:0 0 auto; max-width:48%; }
.set-row.set-col { flex-direction:column; align-items:stretch; gap:8px; }
.seg { display:flex; gap:0; background:var(--bg); border:1px solid var(--line); border-radius:9px; padding:2px; }
.seg button { flex:1; background:none; color:var(--ink); padding:7px 4px; border-radius:7px; font-size:calc(14px * var(--ts)); }
.seg button.on { background:var(--panel); box-shadow:0 1px 3px rgba(0,0,0,.18); font-weight:600; color:var(--accent); }
.seg .ts-s { font-size:13px; } .seg .ts-m { font-size:15px; } .seg .ts-l { font-size:17px; } .seg .ts-xl { font-size:19px; }
.preview { display:flex; flex-direction:column; gap:6px; padding:10px; background:var(--bg); border-radius:10px; }
.preview span { max-width:80%; padding:7px 11px; border-radius:10px; }
.pv-them { background:var(--panel); align-self:flex-start; border:1px solid var(--line); }
.pv-mine { background:var(--mine); align-self:flex-end; }
.set-card .set-form .rc { font-size:calc(16px * var(--ts)); margin:4px 0; }
.me-row .me { margin-right:auto; }

/* ---- disappearing messages: the timer button in the chat header ---- */
.timer-wrap { position:relative; margin-left:0; flex:0 0 auto; }   /* (the title takes the free room: the buttons sit right) */
.timer-btn { display:flex; align-items:center; gap:4px; background:none; color:var(--muted); padding:6px 8px; border-radius:16px;
  border:1px solid transparent; font-weight:600; font-size:calc(13px * var(--ts)); }
.timer-btn svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.timer-btn:hover, .timer-btn.open { background:var(--mine); border-color:var(--line); }
.timer-btn.on { color:var(--accent); }
.timer-menu { right:0; left:auto; top:calc(100% + 6px); bottom:auto; min-width:230px; }
.timer-menu .menu-head { margin:4px 10px 6px; font-weight:600; font-size:calc(14px * var(--ts)); }
.timer-menu .menu-head small { display:block; font-weight:400; color:var(--muted); font-size:calc(12px * var(--ts)); line-height:1.3; margin-top:2px; }
.timer-menu button { display:block; width:100%; padding:9px 12px; font-weight:400; }
.timer-menu button.on { font-weight:700; color:var(--accent); }
.timer-menu button.on::after { content:"  ✓"; }

/* ---- app lock screen ---- */
#lock:not([hidden]), #lost:not([hidden]) { display:flex; align-items:center; justify-content:center; height:100%; padding:16px; }
.lock-card { width:100%; max-width:320px; text-align:center; display:flex; flex-direction:column; align-items:center; gap:12px; }
.lost-why { text-align:left; margin:0; }
.lock-card h1 { font-size:calc(20px * var(--ts)); margin:0 0 6px; }
.lock-card form { width:100%; }
.lock-card input { text-align:center; letter-spacing:6px; font-size:calc(22px * var(--ts)); }
.lock-icon { width:56px; height:56px; fill:none; stroke:var(--accent); stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; }

/* password strength + suggested passphrase (create / recover / change password) */
.pw-tools { display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; margin-top:-2px; }
.pw-tools .link { margin-left:auto; }
.pw-meter { margin:0; }
.pw-meter.weak { color:var(--err); }
.pw-meter.ok, .pw-meter.strong { color:var(--accent, #2f6f5e); }
#sync-status.upd { color:var(--accent); font-weight:600; cursor:pointer; text-decoration:underline; }

/* ---- the message box (several lines), message and chat menus ---- */
#send-form { display:flex; gap:8px; align-items:flex-end; }   /* a div, not a form (see index.html) */
/* iPhone keyboard open while writing (app.js fitChat): the app is pinned to exactly the visible part above the keyboard.
   The bottom safe-area padding is under the keyboard then, so it would only leave a gap. */
html.kb-open, html.kb-open body { overflow:hidden; overscroll-behavior:none; }
html.kb-open main { position:fixed; left:0; right:0; top:var(--app-top, 0px); height:var(--app-h); }
@media (max-width: 700px) { html.kb-open .chat { padding-bottom:6px; } }
#send-text { resize:none; overflow-y:auto; max-height:150px; line-height:1.35; display:block; font-family:inherit; }
#messages { overflow-x:hidden; }
#messages li { position:relative; }
#messages li.older { align-self:center; background:none; padding:2px 0; max-width:100%; }
.msg-more { position:absolute; top:50%; transform:translateY(-50%); left:100%; margin:0 2px; padding:2px 8px; background:none; color:var(--muted);
  font-size:calc(18px * var(--ts)); line-height:1; border-radius:12px; opacity:0; }
#messages li.mine .msg-more { left:auto; right:100%; }
#messages li:hover .msg-more, .msg-more:focus-visible, #messages li.acting .msg-more { opacity:1; }
.msg-more:hover { background:var(--mine); color:var(--accent); }
@media (hover: none) { .msg-more { opacity:.55; } }
/* the ⋯ menu: a small card over the chat, under the bubble (or over it when there's no room below) */
.msg-acts { position:absolute; top:calc(100% + 4px); left:0; z-index:20; display:flex; flex-direction:column; gap:1px; min-width:190px;
  width:max-content; max-width:min(260px, calc(100vw - 40px)); padding:5px; background:var(--panel); border:1px solid var(--line);
  border-radius:12px; box-shadow:0 8px 24px rgba(0,0,0,.2); white-space:nowrap; animation:menu-in .12s ease-out; }
.msg-acts.up { top:auto; bottom:calc(100% + 4px); }
#messages li.mine .msg-acts { left:auto; right:0; }
#messages li.acting { z-index:30; }   /* the bubble with the open menu (and the menu) above the bubbles around it */
.msg-acts .link { display:flex; align-items:center; gap:11px; width:100%; padding:9px 12px 9px 10px; border-radius:8px; color:var(--ink);
  font-weight:500; font-size:calc(14px * var(--ts)); text-align:left; }
.msg-acts .link:hover, .msg-acts .link:focus-visible { background:var(--mine); outline:none; }
.msg-acts svg { width:19px; height:19px; flex:0 0 auto; fill:none; stroke:var(--accent); stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.msg-acts .act-me, .msg-acts .act-both { color:var(--err); }
.msg-acts .act-me svg, .msg-acts .act-both svg { stroke:var(--err); }
.msg-acts .act-cancel { color:var(--muted); font-weight:400; border-top:1px solid var(--line); border-radius:0 0 8px 8px; margin-top:3px; }
.msg-acts .act-cancel svg { stroke:var(--muted); }
@keyframes menu-in { from { opacity:0; transform:scale(.96); } to { opacity:1; transform:none; } }
@media (prefers-reduced-motion: reduce) { .msg-acts { animation:none; } }
@media (max-width: 700px) { .msg-acts .link { padding:11px 12px 11px 10px; font-size:calc(15px * var(--ts)); } }
.chat-menu-wrap { margin-left:0; }
.chat-menu-wrap svg { fill:currentColor; stroke:none; }
#chat-menu { min-width:170px; }
.attach-menu button.danger-item { color:var(--err); }
.chat-state { margin:8px 2px 0; font-size:calc(13px * var(--ts)); text-align:center; }

/* ---- search in a chat ---- */
.search-bar { display:flex; align-items:center; gap:4px; padding:6px 0; border-bottom:1px solid var(--line); }
.search-bar input { flex:1 1 auto; min-width:0; padding:7px 10px; border-radius:16px; -webkit-appearance:none; appearance:none; }
.search-bar input::-webkit-search-cancel-button { -webkit-appearance:none; display:none; }   /* (× at the end of the bar closes) */
.search-count { flex:0 0 auto; font-size:calc(12px * var(--ts)); padding:0 4px; white-space:nowrap; }
.search-nav { flex:0 0 auto; width:34px; height:34px; padding:0; border-radius:50%; background:none; color:var(--accent);
  display:flex; align-items:center; justify-content:center; }
.search-nav svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
.search-nav:hover:not(:disabled) { background:var(--mine); }
.search-nav:disabled { color:var(--muted); opacity:.45; }
#messages li.hit { box-shadow:0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
#messages li.hit-cur { box-shadow:0 0 0 2px var(--accent); }
#messages mark { background:color-mix(in srgb, #f5c518 55%, transparent); color:inherit; border-radius:3px; padding:0 1px; }
.safety-pq { color:var(--muted); }
.safety-pq.on { color:var(--accent); }

/* ---- chat list: pinned and archived ---- */
#contacts li .c-pin { width:.85em; height:.85em; margin-left:5px; vertical-align:-1px; fill:none; stroke:var(--muted); stroke-width:2.2; stroke-linecap:round; stroke-linejoin:round; transform:rotate(30deg); }
#contacts li.archived { opacity:.8; }
#contacts li.arch-row { color:var(--muted); }
#contacts li.arch-row .c-name { font-weight:600; font-size:calc(13px * var(--ts)); color:var(--muted); }
#contacts li.arch-row .badge { grid-row:1; }

/* ---- voice messages ---- */
.mic-btn svg { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; }
.rec-bar { flex:1 1 auto; min-width:0; display:flex; align-items:center; gap:10px; }
.rec-cancel { color:var(--err); }
.rec-cancel svg { width:21px; height:21px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.rec-dot { width:10px; height:10px; border-radius:50%; background:#e5484d; flex:0 0 auto; animation:rec-blink 1.2s ease-in-out infinite; }
.rec-time { font-variant-numeric:tabular-nums; font-weight:600; }
.rec-hint { flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:calc(13px * var(--ts)); }
@keyframes rec-blink { 50% { opacity:.25; } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation:none; } }
#messages li.voice { padding:6px 8px; white-space:normal; }
.vcard { display:flex; align-items:center; gap:10px; width:230px; max-width:100%; }
.vplay { flex:0 0 auto; width:38px; height:38px; padding:0; border-radius:50%; font-size:14px; line-height:1; display:flex; align-items:center; justify-content:center; }
.vbar { flex:1 1 auto; height:6px; border-radius:3px; background:var(--line); overflow:hidden; cursor:pointer; position:relative; }
.vfill { display:block; height:100%; width:0; background:var(--accent); border-radius:3px; }
.vtime { flex:0 0 auto; font-size:calc(12px * var(--ts)); color:var(--muted); font-variant-numeric:tabular-nums; min-width:34px; text-align:right; }
.vcard.vfail .vtime { color:var(--err); white-space:normal; text-align:left; }

/* ---- settings: small button in a row, notes under a card, hold-to-erase ---- */
.set-btn { flex:0 0 auto; padding:6px 12px; font-size:calc(14px * var(--ts)); }
.set-foot { font-size:calc(12px * var(--ts)); margin:6px 6px 0; line-height:1.35; }
.hold-btn { position:relative; overflow:hidden; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; touch-action:none; }
.hold-fill { position:absolute; inset:0; width:0; background:rgba(0,0,0,.28); pointer-events:none; }
.hold-btn.holding .hold-fill { width:100%; transition:width 1.5s linear; }
.hold-txt { position:relative; }
body.erasing main { visibility:hidden; }

/* a new version is out and this page is the old one (app.js appUpdated): visible in the open chat too */
.upd-bar { display:block; width:100%; margin:6px 0 0; padding:8px 10px; border-radius:8px; background:var(--mine); color:var(--accent); font-weight:600;
  font-size:calc(13px * var(--ts)); border:1px solid var(--accent); text-align:center; }
