/* Messages Enhanced: dark, large-target layout for a ~1920x1200 landscape car screen.
   Nothing depends on :hover; every control is >= 72px tall. */
:root {
  --bg: #0d0f12;
  --panel: #15181d;
  --panel-2: #1c2027;
  --line: #262b33;
  --text: #f2f4f7;
  --muted: #9aa3ae;
  --accent: #3e8bff;
  --accent-2: #2a6fe0;
  --me: #2f6fe4;
  --them: #262b33;
  --danger: #e5484d;
  --ok: #30a46c;
  --warn: #f5a524;
  --radius: 22px;
  --touch: 88px;
  --z: 1; /* UI zoom (set on <html> by zoom.js); zoom also scales vh/vw, so divide */
  font-size: 26px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif, "Noto Color Emoji", "Apple Color Emoji"; }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--accent); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: 72px; padding: 0 32px; border-radius: 999px; border: 2px solid transparent;
  background: var(--panel-2); color: var(--text); font-size: 26px; font-weight: 600;
  text-decoration: none; cursor: pointer; user-select: none; touch-action: manipulation; }
.btn:active { transform: scale(0.97); filter: brightness(1.2); }
.btn-primary { background: var(--accent); }
.btn-primary:active { background: var(--accent-2); }
.btn-danger { background: var(--danger); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-lg { min-height: var(--touch); padding: 0 40px; font-size: 28px; }
.btn-xl { min-height: 100px; padding: 0 56px; font-size: 32px; }
.btn-block { width: 100%; }
.btn-icon { width: 72px; padding: 0; font-size: 48px; line-height: 1; }
.inline-form { margin: 0; }

/* ---------- layout ---------- */
.app { display: flex; flex-direction: column; height: calc(100vh / var(--z)); }
.topbar { flex: none; display: flex; align-items: center; gap: 18px; height: 104px; padding: 0 28px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-size: 34px; font-weight: 700; display: flex; gap: 12px; align-items: center; }
.topbar-spacer { flex: 1; }
/* connection status: a small dot (tap for the text) */
.conn-dot { flex: none; position: relative; width: 56px; height: 56px; margin-left: -6px; border: 0; border-radius: 50%; background: transparent;
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.conn-dot:active { background: var(--panel-2); }
.conn-dot-core { width: 22px; height: 22px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 5px rgba(139,148,158,.2); }
.conn-ok .conn-dot-core { background: #3ecf8e; box-shadow: 0 0 0 5px rgba(62,207,142,.22); }
.conn-warn .conn-dot-core { background: #f5a524; box-shadow: 0 0 0 5px rgba(245,165,36,.22); animation: pulse 1.6s ease-in-out infinite; }
.conn-bad .conn-dot-core { background: #e5484d; box-shadow: 0 0 0 5px rgba(229,72,77,.25); }
.conn-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.panes { flex: 1; display: flex; min-height: 0; }

/* ---------- conversation list ---------- */
.convlist { flex: none; width: 36%; min-width: 480px; max-width: 700px; background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; }
.conv { display: flex; align-items: center; gap: 22px; width: 100%; min-height: 124px; padding: 16px 26px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.conv:active { background: var(--panel-2); }
.conv.active { background: #1f2a3d; box-shadow: inset 8px 0 0 var(--accent); }
.avatar { flex: none; width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center;
  font-size: 32px; font-weight: 700; color: #fff; }
.avatar.has-photo { position: relative; overflow: hidden; }
.avatar-img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; user-select: none; pointer-events: none; }
.avatar.avatar-duo { overflow: visible; }
.avatar-duo .avatar-img { position: absolute; width: 56px; height: 56px; border: 3px solid var(--panel); background: var(--panel-2); }
.avatar-duo .duo-a { left: 0; top: 0; }
.avatar-duo .duo-b { right: 0; bottom: 0; }
.conv.active .avatar-duo .avatar-img { border-color: #1f2a3d; }
.conv-mid { flex: 1; min-width: 0; }
.conv-name { font-size: 30px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { margin-left: 14px; padding: 2px 12px; border-radius: 10px; background: var(--panel-2); color: var(--muted); font-size: 18px; font-weight: 600; vertical-align: middle; }
.conv-preview { margin-top: 6px; font-size: 24px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .conv-name, .conv.unread .conv-preview { color: var(--text); font-weight: 700; }
.conv-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.conv-time { font-size: 22px; color: var(--muted); }
.badge { min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px; background: var(--accent);
  display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.conv-empty { padding: 40px; color: var(--muted); }

/* ---------- thread ---------- */
.thread { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: 32px; }
.thread-empty-icon { font-size: 120px; opacity: .5; }
.thread-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.thread-header { flex: none; display: flex; align-items: center; gap: 16px; height: 96px; padding: 0 28px; border-bottom: 1px solid var(--line); }
.back-btn { display: none; }
.thread-title-box { flex: 0 1 auto; min-width: 0; min-height: 80px; display: flex; align-items: center; padding: 0 22px 0 8px; }
.thread-title { font-size: 34px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 24px 32px 12px; display: flex; flex-direction: column; gap: 14px; }
.day-sep { align-self: center; margin: 14px 0 4px; font-size: 22px; color: var(--muted); }
.msg-row { display: flex; }
.msg-row.me { justify-content: flex-end; }
.bubble { max-width: 72%; padding: 18px 26px 12px; border-radius: 30px; background: var(--them); font-size: 30px; line-height: 1.35; }
.me .bubble { background: var(--me); border-bottom-right-radius: 10px; }
.them .bubble { border-bottom-left-radius: 10px; }
.bubble .sender { font-size: 22px; font-weight: 700; color: #9cc3ff; margin-bottom: 4px; }
.bubble .body { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.has-media { width: min(640px, 100%); padding-top: 12px; }
.media-video video { display: block; width: 100%; max-height: 480px; border-radius: 20px; background: #000; }
.media-video + .body { margin-top: 10px; }
/* inline photos: fit the bubble, never taller than ~half the car screen */
.bubble.has-image { width: auto; max-width: min(760px, 72%); }
.media-image { display: block; margin: 0; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 20px; overflow: hidden; max-width: 100%; }
.media-image img { display: block; max-width: 100%; max-height: 520px; width: auto; height: auto; object-fit: contain; border-radius: 20px; }
.media-image:not(.loaded) { min-width: 320px; min-height: 240px; background: rgba(0,0,0,.28); }
.media-image + .body { margin-top: 10px; }
/* full-size photo viewer (tap anywhere / Escape closes) */
.image-viewer { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.94); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px; cursor: zoom-out; }
.image-viewer-img { display: block; max-width: 100%; max-height: calc(100vh / var(--z) - 64px); object-fit: contain; border-radius: 12px; }
.image-viewer-caption { margin: 18px 0 0; max-width: calc(80vw / var(--z)); color: var(--text); font-size: 28px; text-align: center; }
.image-viewer:has(.image-viewer-caption:not([hidden])) .image-viewer-img { max-height: calc(100vh / var(--z) - 160px); }
.image-viewer-close { position: absolute; top: 24px; right: 24px; width: var(--touch); height: var(--touch); border-radius: 50%; border: 0;
  background: rgba(255,255,255,.14); color: #fff; font-size: 40px; line-height: 1; cursor: pointer; }
.media-link { display: inline-block; min-height: 56px; padding: 8px 0; color: #cfe1ff; text-decoration: underline; overflow-wrap: anywhere; }
.bubble .msg-link { color: inherit; text-decoration: underline; text-underline-offset: 4px; overflow-wrap: anywhere; }
.them .bubble .msg-link { color: #9cc3ff; }
.link-card-slot:empty { display: none; }
.link-card { display: block; margin-top: 12px; min-width: min(420px, calc(60vw / var(--z))); border-radius: 20px; overflow: hidden; background: rgba(0,0,0,.28);
  color: var(--text); text-decoration: none; }
.link-card:active { filter: brightness(1.2); }
.link-card-media { background: #000; }
.link-card-media img { display: block; width: 100%; max-height: 300px; object-fit: cover; }
.link-card-copy { padding: 14px 20px 16px; }
.link-card-site { font-size: 20px; font-weight: 600; color: rgba(255,255,255,.7); text-transform: uppercase; letter-spacing: .03em; }
.link-card-title { margin-top: 4px; font-size: 26px; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-card-desc { margin-top: 6px; font-size: 22px; line-height: 1.3; color: rgba(255,255,255,.8);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bubble .meta { margin-top: 6px; font-size: 20px; color: rgba(255,255,255,.6); text-align: right; }

/* ---------- replies ---------- */
.msg-row.them, .msg-row.me { align-items: center; gap: 14px; }
.reply-btn { flex: none; width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel);
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.reply-btn svg { width: 38px; height: 38px; fill: var(--muted); }
.reply-btn:active { transform: scale(.92); background: var(--panel-2); }
.reply-quote { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 10px; padding: 8px 16px; border-left: 6px solid rgba(255,255,255,.45);
  border-radius: 12px; background: rgba(0,0,0,.22); color: rgba(255,255,255,.72); font-size: 22px; line-height: 1.3; cursor: pointer; }
.reply-quote-missing { cursor: default; font-style: italic; }
.reply-quote-name { font-weight: 700; color: rgba(255,255,255,.85); }
.reply-quote-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-row.flash .bubble { box-shadow: 0 0 0 4px rgba(255,255,255,.5); }
.reply-bar { flex: none; display: flex; align-items: center; gap: 20px; padding: 12px 24px 12px 30px; background: var(--panel);
  border-top: 1px solid var(--line); border-left: 8px solid var(--accent); }
.reply-bar-icon { flex: none; width: 40px; height: 40px; fill: var(--accent); }
.reply-bar-text { flex: 1; min-width: 0; }
.reply-bar-label { font-size: 22px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-name { color: var(--text); font-weight: 700; }
.reply-snippet { font-size: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-cancel { flex: none; font-size: 36px; }

/* ---------- recording bar ---------- */
.rec-bar { flex: none; display: flex; align-items: center; gap: 22px; padding: 14px 28px; background: #2a1215;
  border-top: 2px solid var(--danger); font-size: 28px; font-weight: 600; }
.rec-act { flex: none; display: inline-grid; place-items: center; width: 88px; height: 88px; min-width: 0; min-height: 0; padding: 0; border-radius: 50%; }
.rec-act svg { width: 44px; height: 44px; fill: currentColor; }
.rec-bar { min-width: 0; flex-wrap: nowrap; }
.rec-bar > * { flex-shrink: 0; }
.rec-bar #recLabel { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-bar .rec-engine { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rec-bar .topbar-spacer { flex: 1 1 0; min-width: 0; }
html.desk .rec-act { width: 64px; height: 64px; }
html.desk .rec-act svg { width: 32px; height: 32px; }
html.narrow .rec-bar { gap: 10px; padding: 12px 14px; }
html.narrow:not(.desk) .rec-act { width: 72px; height: 72px; }
html.narrow:not(.desk) .rec-act svg { width: 38px; height: 38px; }
html.narrow .rec-time { font-size: 22px; flex-shrink: 1; min-width: 0; overflow: hidden; }
html.narrow .rec-bar .rec-engine { display: none; }
.rec-act.pending { outline: 4px solid #fff; outline-offset: 2px; }
.rec-dot { width: 26px; height: 26px; border-radius: 50%; background: var(--danger); animation: pulse 1.1s ease-in-out infinite; }
.rec-time { font-variant-numeric: tabular-nums; color: #ffb3b5; }
.rec-engine { white-space: nowrap; padding: 4px 14px; border-radius: 10px; background: rgba(255,255,255,.08); color: #ffb3b5; font-size: 20px; font-weight: 600; }
.rec-engine:empty { display: none; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }


/* ---------- compose ---------- */
.compose { flex: none; display: flex; align-items: flex-end; gap: 18px; padding: 18px 24px 22px; background: var(--panel); border-top: 1px solid var(--line); }
.compose-input { flex: 1; min-height: 96px; max-height: 260px; resize: none; padding: 26px 30px; border-radius: 48px;
  border: 2px solid var(--line); background: var(--bg); font-size: 30px; line-height: 1.3; outline: none; }
.compose-input:focus { border-color: var(--accent); }
.btn-mic { flex: none; position: relative; width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--panel-2);
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.btn-mic svg { width: 50px; height: 50px; fill: var(--text); }
.btn-mic .stop-icon, .btn-mic .spinner { display: none; }
.btn-mic:active { transform: scale(.94); }
.btn-mic.recording { background: var(--danger); box-shadow: 0 0 0 10px rgba(229,72,77,.25); animation: ring 1.4s ease-out infinite; }
.btn-mic.recording .mic-icon { display: none; }
.btn-mic.recording .stop-icon { display: block; }
.btn-mic.busy .mic-icon { display: none; }
.btn-mic.busy .spinner { display: block; width: 46px; height: 46px; border: 6px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 100% { box-shadow: 0 0 0 26px rgba(229,72,77,0); } }
@keyframes spin { to { transform: rotate(360deg); } }
.no-stt .btn-mic { opacity: .45; }
.btn-attach { flex: none; width: 96px; height: 96px; border-radius: 50%; border: 0; background: var(--panel-2);
  display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.btn-attach svg { width: 48px; height: 48px; fill: var(--text); }
.btn-attach:active { transform: scale(.94); }
.btn-attach .spinner { display: none; }
.btn-attach.busy .attach-icon { display: none; }
.btn-attach.busy .spinner { display: block; width: 46px; height: 46px; border: 6px solid rgba(255,255,255,.25); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.btn-attach:disabled { cursor: default; }
.btn-send { flex: none; position: relative; width: 96px; height: 96px; padding: 0; border-radius: 50%; border: 0; background: var(--accent);
  color: #fff; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.btn-send .send-ico { position: relative; display: block; width: 46px; height: 46px; }
.btn-send .send-ico > svg:first-child { width: 46px; height: 46px; fill: currentColor; display: block; }
.btn-send .send-lock { position: absolute; right: -8px; bottom: -6px; width: 22px; height: 22px; fill: currentColor;
  background: inherit; border-radius: 50%; padding: 2px; }
.btn-send .send-lock[hidden], .btn-send .send-proto[hidden] { display: none; }
.btn-send .send-proto { font-size: 15px; font-weight: 700; letter-spacing: .04em; line-height: 1; }
.btn-send:has(.send-proto:not([hidden])) .send-ico, .btn-send:has(.send-proto:not([hidden])) .send-ico > svg:first-child { width: 38px; height: 38px; }
.btn-send:disabled { background: var(--panel-2); color: var(--muted); }
.btn-send:not(:disabled):active { background: var(--accent-2); }

/* ---------- pairing ---------- */
.pair-view { position: fixed; inset: 0; z-index: 20; background: rgba(8,9,11,.97); display: flex; align-items: center; justify-content: center; }
.pair-card { text-align: center; max-width: 1200px; padding: 40px; }
.pair-card h1 { font-size: 64px; margin: 0 0 24px; }
.pair-emoji-wrap { position: relative; width: 420px; height: 420px; margin: 0 auto 20px; border-radius: 60px; background: #fff; display: grid; place-items: center; }
.pair-emoji-img { width: 340px; height: 340px; display: none; }
.pair-emoji-text { font-size: 300px; line-height: 1; }
.pair-emoji-wrap.img-ok .pair-emoji-img { display: block; }
.pair-emoji-wrap.img-ok .pair-emoji-text { display: none; }
.pair-msg { font-size: 34px; color: var(--muted); margin: 10px 0 40px; min-height: 1.3em; }
.pair-actions { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; }

/* ---------- sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 25; background: rgba(8,9,11,.55); display: flex; align-items: flex-end; justify-content: flex-end; padding: 28px; }
.sheet { width: min(1100px, 100%); max-height: calc(100vh / var(--z) - 56px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 36px; padding: 32px 40px 36px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.sheet-head { display: flex; align-items: center; gap: 20px; margin-bottom: 8px; }
.sheet-title { flex: 1; min-width: 0; margin: 0; font-size: 36px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-label { margin: 22px 0 14px; color: var(--muted); font-size: 24px; font-weight: 600; }
.sheet-actions { margin-top: 30px; display: flex; gap: 20px; }

/* ---------- settings sheet ---------- */
.btn-gear { width: 72px; padding: 0; font-size: 36px; line-height: 1; }
.sheet-backdrop.sheet-top { align-items: flex-start; padding-top: 120px; }
.sheet-backdrop.sheet-top .sheet { max-height: calc(100vh / var(--z) - 148px); } /* fit under the top padding so the sheet scrolls */
.sheet-narrow { width: min(900px, 100%); }
.setting-row { display: flex; align-items: center; gap: 28px; width: 100%; min-height: 120px; padding: 18px 28px; border-radius: 28px;
  border: 2px solid var(--line); background: var(--bg); text-align: left; cursor: pointer; touch-action: manipulation; }
.setting-row:active { filter: brightness(1.2); }
.setting-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.setting-name { font-size: 30px; font-weight: 600; }
.setting-desc { font-size: 22px; color: var(--muted); }
.switch { flex: none; position: relative; width: 120px; height: 68px; border-radius: 34px; background: #3a404a; transition: background .15s; }
.switch-knob { position: absolute; top: 6px; left: 6px; width: 56px; height: 56px; border-radius: 50%; background: #fff; transition: transform .15s; }
.setting-row.on .switch { background: var(--ok); }
.setting-row.on .switch-knob { transform: translateX(52px); }
.zoom-row { cursor: default; gap: 18px; margin-top: 14px; }
.zoom-btn { flex: none; width: 96px; height: 96px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel-2); color: var(--text);
  font-size: 48px; font-weight: 700; line-height: 1; cursor: pointer; touch-action: manipulation; }
.zoom-btn:active { transform: scale(.94); filter: brightness(1.2); }
.zoom-btn:disabled { opacity: .35; cursor: default; transform: none; }
.zoom-value { flex: none; min-width: 130px; text-align: center; font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; }
.zoom-steps { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 0; }
.zoom-step { flex: 1; min-width: 96px; min-height: 72px; border-radius: 36px; border: 2px solid var(--line); background: transparent; color: var(--muted);
  font-size: 24px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.zoom-auto { flex-basis: 100%; }
.zoom-step.on { border-color: var(--accent); background: var(--accent); color: #fff; }
.signout-row .setting-name, .signout-row .folder-icon { color: #ff8589; }
.mic-recheck-row { margin-top: 14px; }
.mic-check-row { display: flex; align-items: center; gap: 22px; margin: 12px 0 0; padding: 0 4px; }
.mic-check-btn { flex: none; }
.mic-check-btn:disabled { opacity: .5; }
.mic-check-result { flex: 1; min-width: 0; font-size: 22px; line-height: 1.35; color: var(--muted); white-space: pre-line; }
.mic-check-result.ok { color: #6fdc9f; }
.mic-check-result.bad { color: #ff8589; }

/* ---------- conversation list header / folders ---------- */
.convlist { display: flex; flex-direction: column; }
.conv-items { flex: 1; }
.convlist-head { position: sticky; top: 0; z-index: 2; flex: none; display: flex; align-items: center; gap: 16px; min-height: 104px;
  padding: 12px 20px 12px 30px; background: var(--panel); border-bottom: 1px solid var(--line); }
.convlist-title { flex: 1; min-width: 0; font-size: 30px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new-chat-btn { flex: none; display: inline-flex; align-items: center; gap: 12px; height: 80px; padding: 0 26px; font-size: 26px; }
.new-chat-btn svg { width: 36px; height: 36px; fill: currentColor; }
.folder-banner { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; font-size: 30px; font-weight: 700; }
.folder-dot { color: var(--muted); }
.folder-back { min-height: 80px; padding: 0 24px; border-radius: 40px; border: 2px solid var(--line); background: var(--panel-2);
  color: var(--text); font-size: 26px; font-weight: 600; cursor: pointer; touch-action: manipulation; white-space: nowrap; }
.folder-back:active { background: var(--line); }
body.in-folder .new-chat-btn { display: none; }
.folder-rows { display: flex; flex-direction: column; gap: 14px; }
.folder-icon { flex: none; width: 56px; font-size: 40px; text-align: center; }
.folder-chev { flex: none; font-size: 48px; color: var(--muted); }
.readonly-note { flex: none; padding: 22px 30px; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted);
  font-size: 24px; text-align: center; }
body.readonly-thread .compose, body.readonly-thread .reply-bar, body.readonly-thread .reply-btn,
body.readonly-thread .msg-menu-btn { display: none; }
.conv-preview.typing { color: var(--accent); font-style: italic; }

/* ---------- message menu (⋮) + confirm ---------- */
.msg-menu-btn { flex: none; width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 40px; font-weight: 700; line-height: 1; display: grid; place-items: center; cursor: pointer; touch-action: manipulation; }
.msg-menu-btn:active, .msg-menu-btn.open { transform: scale(.94); background: var(--panel-2); color: var(--text); }
.msg-menu { position: fixed; z-index: 26; min-width: 300px; padding: 10px; border-radius: 28px; background: var(--panel-2);
  border: 1px solid var(--line); box-shadow: 0 16px 48px rgba(0,0,0,.6); }
.msg-menu-item { display: flex; align-items: center; gap: 22px; width: 100%; min-height: 96px; padding: 0 30px; border: 0; border-radius: 20px;
  background: transparent; color: var(--text); font-size: 30px; font-weight: 600; text-align: left; cursor: pointer; touch-action: manipulation; }
.msg-menu-item svg { width: 40px; height: 40px; fill: currentColor; }
.msg-menu-item:active { background: var(--line); }
.msg-menu-danger { color: #ff8589; }

/* ---------- pinned conversations ---------- */
.conv { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.conv-section { padding: 22px 30px 12px; font-size: 20px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--line); }
.conv-section svg { width: 22px; height: 22px; margin-right: 8px; vertical-align: -3px; fill: currentColor; }
.conv-time { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.conv-time.has-pin { display: grid; grid-template-columns: 30px minmax(5.4em, auto); align-items: center; column-gap: 8px; }
.conv-time.has-pin .conv-time-text { text-align: right; }
.conv-pin { flex: none; width: 26px; height: 26px; fill: var(--muted); justify-self: center; }
.conv-pin.conv-pin-phone { fill: var(--accent); }
.conv.pressing { background: var(--panel-2); }
.conv-menu-btn { margin-left: auto; }
.conv-mute-btn { margin-left: auto; }
body:not(.readonly-thread) .conv-mute-btn + .conv-menu-btn { margin-left: 12px; }
.conv-mute-btn svg { width: 40px; height: 40px; fill: currentColor; }
.conv-mute-btn .bell-off, .conv-mute-btn.muted .bell-on { display: none; }
.conv-mute-btn.muted .bell-off { display: inline; }
.conv-mute-btn.muted { color: var(--text); }
body.readonly-thread .conv-menu-btn { display: grid; }
.conv-menu { width: min(560px, calc(100vw / var(--z) - 32px)); }
.conv-menu-title { padding: 14px 30px 10px; font-size: 22px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-menu-item { padding: 14px 30px; }
.conv-menu-copy { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.conv-menu-note { font-size: 21px; font-weight: 500; color: var(--muted); line-height: 1.3; }
.conv-menu-note:empty { display: none; }
.msg-menu-item:disabled { cursor: default; color: var(--muted); }
.msg-menu-item:disabled:active { background: transparent; }
.msg-menu-item:disabled svg { fill: var(--accent); }
.confirm-backdrop { align-items: center; justify-content: center; z-index: 27; }
.confirm-sheet { width: min(820px, 100%); text-align: center; }
.confirm-title { margin: 6px 0 12px; font-size: 40px; }
.confirm-desc { margin: 0 0 34px; color: var(--muted); font-size: 26px; line-height: 1.4; }
.confirm-actions { display: flex; gap: 24px; justify-content: center; }
.confirm-actions .btn { flex: 1; max-width: 340px; }

/* ---------- read status + typing ---------- */
.msg-status { align-self: flex-end; margin: -4px 12px 4px 0; font-size: 22px; font-weight: 600; color: var(--muted); }
.msg-status.read { color: var(--accent); }
.msg-status.failed { color: #ff8589; }
.typing-row .bubble { padding: 22px 30px; }
.typing-dots { display: inline-flex; gap: 10px; align-items: center; height: 30px; }
.typing-dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--muted); animation: tm-typing 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
.typing-name { margin-left: 16px; font-size: 22px; color: var(--muted); }
@keyframes tm-typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-6px); } }

/* ---------- start chat panel ---------- */
.newchat-view { position: fixed; inset: 0; z-index: 22; background: var(--bg); display: flex; justify-content: center; }
.newchat-card { width: min(1200px, 100%); height: 100%; display: flex; flex-direction: column; padding: 20px 36px 0; }
.newchat-head { flex: none; display: flex; align-items: center; gap: 24px; min-height: 104px; }
.newchat-back { flex: none; }
.newchat-to { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; min-height: 104px; padding: 10px 24px;
  border-radius: 28px; border: 2px solid var(--line); background: var(--panel); }
.newchat-to:focus-within { border-color: var(--accent); }
.newchat-to-label { flex: none; font-size: 30px; font-weight: 700; color: var(--muted); }
.newchat-chips { display: contents; }
.newchat-chip { display: inline-flex; align-items: center; gap: 12px; height: 68px; padding: 0 12px 0 24px; border-radius: 34px;
  border: 0; background: var(--accent-2); color: #fff; font-size: 26px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.newchat-chip b { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: rgba(0,0,0,.25); font-size: 24px; }
.newchat-input { flex: 1; min-width: 280px; height: 80px; border: 0; background: transparent; color: var(--text); font-size: 30px; outline: none; }
.newchat-actions { flex: none; display: flex; gap: 18px; margin: 18px 0 8px; }
.newchat-group.on { border-color: var(--accent); color: var(--accent); }
.newchat-next { margin-left: auto; min-width: 200px; }
.newchat-next:disabled { background: var(--panel-2); color: var(--muted); }
.newchat-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 40px; }
.newchat-section { margin: 26px 8px 10px; color: var(--muted); font-size: 24px; font-weight: 700; }
.newchat-letter { position: sticky; top: 0; z-index: 1; margin: 0; padding: 10px 8px; background: var(--bg); color: var(--accent);
  font-size: 26px; font-weight: 700; }
.contact-row { display: flex; align-items: center; gap: 26px; width: 100%; min-height: 116px; padding: 12px 16px; border: 0;
  border-radius: 24px; background: transparent; color: var(--text); text-align: left; cursor: pointer; touch-action: manipulation; }
.contact-row:active { background: var(--panel-2); }
.contact-row.selected { background: #1f2a3d; }
.contact-row .avatar { flex: none; }
.contact-mid { flex: 1; min-width: 0; }
.contact-name { font-size: 30px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-num { margin-top: 4px; font-size: 22px; color: var(--muted); }
.contact-check { flex: none; width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--line); display: grid; place-items: center;
  font-size: 32px; color: transparent; }
.contact-row.selected .contact-check { border-color: var(--accent); background: var(--accent); color: #fff; }
.contact-send .avatar { background: var(--accent-2); font-size: 36px; }
.top-contacts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.top-contact { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px 8px; border: 0; border-radius: 24px;
  background: transparent; color: var(--text); cursor: pointer; touch-action: manipulation; }
.top-contact:active { background: var(--panel-2); }
.top-contact.selected { background: #1f2a3d; }
.top-contact .avatar { width: 104px; height: 104px; font-size: 36px; }
.top-contact-name { max-width: 100%; font-size: 24px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.newchat-empty { padding: 40px 8px; color: var(--muted); font-size: 26px; }

/* ---------- pinned messages ---------- */

/* ---------- chat theme (Google Messages-style) ---------- */
.ct-view { position: fixed; inset: 0; z-index: 24; display: flex; flex-direction: column; background: var(--bg); }
.ct-head { flex: none; display: flex; align-items: center; gap: 20px; min-height: 112px; padding: 8px 32px 8px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.ct-back svg { width: 44px; height: 44px; fill: currentColor; }
.ct-titles { flex: 1; min-width: 0; }
.ct-title { margin: 0; font-size: 38px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-sub { margin-top: 4px; font-size: 22px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-apply { min-width: 200px; background: var(--accent-light, #a8c7fa); color: #0b1a2e; }
.ct-apply:disabled { background: var(--panel-2); color: var(--muted); cursor: default; transform: none; filter: none; }
.ct-body { flex: 1; min-height: 0; display: flex; }
.ct-preview-col { flex: none; width: 40%; max-width: 760px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 28px 36px; }
.ct-preview { position: relative; width: 100%; max-width: 640px; aspect-ratio: 4 / 3.3; display: flex; flex-direction: column; border-radius: 36px; overflow: hidden;
  background: var(--bg) center / cover no-repeat; border: 2px solid var(--line); box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.ct-prev-msgs { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 14px; padding: 24px 24px 12px; }
.ct-prev-row { display: flex; }
.ct-prev-row.me { justify-content: flex-end; }
.ct-prev-bubble { max-width: 78%; padding: 16px 24px; border-radius: 28px; background: var(--them); color: #fff; font-size: 26px; line-height: 1.3; }
.ct-prev-row.me .ct-prev-bubble { background: var(--me); border-bottom-right-radius: 8px; }
.ct-prev-row.them .ct-prev-bubble { border-bottom-left-radius: 8px; }
.ct-prev-name { font-size: 20px; font-weight: 700; color: var(--accent-light, #9cc3ff); margin-bottom: 2px; }
.ct-prev-time { align-self: flex-end; font-size: 18px; color: rgba(255,255,255,.75); padding: 2px 10px; }
.ct-preview.has-wallpaper .ct-prev-time { background: rgba(0,0,0,.55); border-radius: 10px; color: #fff; }
.ct-prev-compose { flex: none; display: flex; align-items: center; gap: 14px; padding: 12px 18px 18px; }
.ct-prev-input { flex: 1; height: 72px; display: flex; align-items: center; padding: 0 28px; border-radius: 36px; background: rgba(20,23,28,.92); color: var(--muted); font-size: 24px; }
.ct-prev-mic { flex: none; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); }
.ct-prev-mic svg { width: 38px; height: 38px; fill: #fff; }
.ct-reset { display: inline-flex; align-items: center; gap: 14px; min-height: 80px; padding: 0 30px; border: 0; border-radius: 40px; background: transparent;
  color: var(--accent-light, #a8c7fa); font-size: 28px; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.ct-reset svg { width: 38px; height: 38px; fill: currentColor; }
.ct-reset:active { background: rgba(255,255,255,.08); }
.ct-reset:disabled { color: var(--muted); opacity: .5; cursor: default; }
.ct-options { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel); border-radius: 40px 0 0 0; transition: background .2s; }
.ct-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 40px 48px; }
.ct-label { margin: 22px 0 16px; font-size: 26px; font-weight: 700; }
.ct-colors { display: flex; gap: 18px; overflow-x: auto; padding: 6px 4px 12px; scrollbar-width: none; }
.ct-swatch { flex: none; width: 108px; height: 108px; padding: 8px; border: 4px solid transparent; border-radius: 50%; background: transparent; cursor: pointer; touch-action: manipulation; }
.ct-swatch.selected { border-color: var(--accent-light, #fff); border-radius: 30px; }
.ct-swatch:active { transform: scale(.94); }
.ct-swatch-dot { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.15); }
.ct-swatch.selected .ct-swatch-dot { border-radius: 22px; }
.ct-photo-actions { display: flex; gap: 18px; justify-content: center; margin: 4px 0 26px; }
.ct-choose { display: inline-flex; align-items: center; justify-content: center; gap: 16px; min-width: 420px; min-height: 96px; padding: 0 44px; border: 0; border-radius: 48px;
  background: var(--accent-light, #a8c7fa); color: #0b1a2e; font-size: 28px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.ct-choose svg { width: 40px; height: 40px; fill: currentColor; }
.ct-choose:active, .ct-remove:active { transform: scale(.97); }
.ct-remove { min-height: 96px; padding: 0 36px; border-radius: 48px; border: 2px solid rgba(255,255,255,.25); background: transparent; color: var(--text); font-size: 26px; font-weight: 600; cursor: pointer; }
.ct-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 26px 22px; }
.ct-cat { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 0; border: 0; background: none; color: var(--text); cursor: pointer; touch-action: manipulation; }
.ct-cat-img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 34px; background: rgba(255,255,255,.06); border: 4px solid transparent; }
.ct-cat.selected .ct-cat-img { border-color: var(--accent-light, #fff); }
.ct-cat:active .ct-cat-img { transform: scale(.97); }
.ct-cat-name { font-size: 24px; font-weight: 600; }
.ct-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; padding-top: 12px; }
.ct-photo { position: relative; padding: 0; border: 5px solid transparent; border-radius: 34px; overflow: hidden; background: rgba(255,255,255,.06); aspect-ratio: 3 / 4; cursor: pointer; touch-action: manipulation; }
.ct-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ct-photo.selected { border-color: var(--accent-light, #fff); }
.ct-photo.selected::after { content: ""; position: absolute; right: 12px; top: 12px; width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-light, #fff) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%230b1a2e' d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / 34px no-repeat; }
.ct-photo:active { transform: scale(.97); }
.ct-credit { min-height: 1.4em; margin-top: 22px; font-size: 20px; color: var(--muted); }
.ct-credits { display: inline-block; margin-top: 34px; padding: 12px 0; font-size: 20px; color: var(--muted); }
.ct-empty { grid-column: 1 / -1; padding: 30px 0; color: var(--muted); }

/* thread over a wallpaper: dark scrim (set inline), opaque bubbles, readable chrome */
.thread-view.has-wallpaper .messages { background: transparent; }
.thread-view.has-wallpaper { background-color: var(--bg); background-position: center; background-size: cover; background-repeat: no-repeat; }
.thread-view.has-wallpaper .thread-header { background: rgba(13,15,18,.86); border-bottom-color: rgba(255,255,255,.08); }
.thread-view.has-wallpaper .bubble { box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.thread-view.has-wallpaper .day-sep, .thread-view.has-wallpaper .msg-status, .thread-view.has-wallpaper .typing-name {
  padding: 4px 16px; border-radius: 14px; background: rgba(0,0,0,.6); color: #e6e9ee; }
.thread-view.has-wallpaper .msg-status.read { color: var(--accent-light, #9cc3ff); }
.thread-view.has-wallpaper .msg-status.failed { color: #ffb3b5; }
.thread-view.has-wallpaper .conv-empty, .thread-view.has-wallpaper .messages > .empty { background: rgba(0,0,0,.6); border-radius: 18px; }
.thread-view.themed .bubble .sender, .thread-view.themed .them .bubble .msg-link { color: var(--accent-light, #9cc3ff); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; top: 124px; transform: translateX(-50%); z-index: 30; max-width: calc(80vw / var(--z));
  padding: 22px 36px; border-radius: 24px; background: #2b313b; font-size: 28px; font-weight: 600; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.toast-error { background: #5a1d20; }

/* ---------- login / admin ---------- */
.admin-body { overflow: auto; display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 40px; }
.admin-card { width: 100%; max-width: 1100px; background: var(--panel); border: 1px solid var(--line); border-radius: 36px; padding: 56px; font-size: 24px; }
/* Login sits at the top: the car's on-screen keyboard covers the bottom
   ~60% of the screen, so the field and Sign in stay in the top third. With
   the keyboard up (login.js: focus or a shrunken visualViewport) the title
   row folds away and the page is pinned to the top. */
.login-body { overflow: auto; display: flex; align-items: flex-start; justify-content: center; min-height: 100vh;
  padding: max(16px, 2.5vh) 24px 24px; }
.login-card { width: 100%; max-width: 880px; background: var(--panel); border: 1px solid var(--line); border-radius: 28px;
  padding: 22px 32px 26px; transition: padding .18s ease; }
.login-head { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 0 0 14px;
  max-height: 80px; overflow: hidden; transition: max-height .18s ease, margin .18s ease, opacity .18s ease; }
.login-logo { font-size: 44px; line-height: 0; color: var(--accent); }
.login-logo svg { width: 1em; height: 1em; fill: currentColor; }
.login-card h1 { font-size: 34px; margin: 0; }
.login-card label { display: block; color: var(--muted); margin-bottom: 10px; font-size: 22px; }
.login-row { display: flex; gap: 16px; align-items: stretch; }
.login-card input[type=password] { flex: 1; min-width: 0; height: 84px; padding: 0 26px; border-radius: 20px; border: 2px solid var(--line);
  background: var(--bg); font-size: 32px; outline: none; }
.login-card input[type=password]:focus { border-color: var(--accent); }
.login-row .btn { flex: none; min-width: 200px; height: 84px; font-size: 28px; }
.login-error { color: #ff8589; font-weight: 600; margin: 12px 0 0; }
body.login-body.kb-open { padding-top: 10px; }
body.login-body.kb-open .login-card { padding-top: 16px; padding-bottom: 18px; }
body.login-body.kb-open .login-head { max-height: 0; margin: 0; opacity: 0; }
@media (max-width: 560px) {
  .login-row { flex-direction: column; }
  .login-row .btn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .login-card, .login-head { transition: none; } }
.admin-ok { color: #5dd39e; font-weight: 600; }
.admin-card textarea { width: 100%; padding: 20px; border-radius: 20px; border: 2px solid var(--line); background: var(--bg);
  font-family: ui-monospace, monospace; font-size: 20px; margin-bottom: 20px; }
.admin-card code { background: var(--panel-2); padding: 2px 8px; border-radius: 8px; font-size: 20px; overflow-wrap: anywhere; }
.admin-actions { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.admin-actions form { margin: 0; }

/* ---------- narrow layouts (phone / portrait / big zoom): one pane at a time ----------
   html.narrow is set by zoom.js when the layout width (window width / zoom in Car
   Mode, window width otherwise) is <= 1100px, so a shrunken car UI keeps two panes. */
html.narrow { font-size: 22px; }
@media (max-width: 1100px) { html:not(.car):not(.desk) { font-size: 22px; } } /* /login etc. (no zoom.js) */
html.narrow .convlist { width: 100%; max-width: none; min-width: 0; border-right: 0; }
html.narrow .thread { display: none; }
html.narrow .has-thread .convlist { display: none; }
html.narrow .has-thread .thread { display: flex; }
html.narrow .back-btn { display: inline-flex; }
html.narrow .ct-body { flex-direction: column; overflow-y: auto; }
html.narrow .ct-preview-col { width: 100%; max-width: none; padding: 18px 24px 6px; gap: 8px; }
html.narrow .ct-preview { max-width: 560px; aspect-ratio: auto; height: 300px; }
html.narrow .ct-options { flex: none; border-radius: 36px 36px 0 0; }
html.narrow .ct-scroll { overflow: visible; padding: 10px 24px 40px; }
html.narrow .ct-cats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 14px; }
html.narrow .ct-photos { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
html.narrow .ct-choose { min-width: 0; width: 100%; max-width: 520px; }
html.narrow .ct-swatch { width: 92px; height: 92px; }

/* ---------- Car Mode setting ---------- */
.car-mode-row { cursor: pointer; }
.setting-check { flex: none; width: 60px; height: 60px; margin: 0 6px; accent-color: var(--accent); cursor: pointer; }
/* Car Mode (default): no photo upload in the theme panel (the car browser
   has no file picker). */
html:not(.desk) #ctChoose { display: none !important; }

/* ---------- tablet / desktop layout (Car Mode off: html.desk) ----------
   The page is scaled by zoom.js (DESK_SCALE x UI zoom), so the px values
   below are "car px"; these rules only change density and layout. */
html.desk .topbar { height: 96px; }
html.desk .conv { min-height: 108px; padding: 12px 24px; gap: 20px; }
html.desk:not(.narrow) .convlist { width: 30%; min-width: 560px; max-width: 760px; }
html.desk .thread-header { height: 92px; }
html.desk .messages { padding: 24px 40px 12px; gap: 10px; }
/* wider bubbles on big screens */
html.desk .bubble { max-width: min(78%, 1600px); }
html.desk .bubble.has-image { max-width: min(900px, 78%); }
html.desk .compose { padding: 14px 24px 18px; }
html.desk .compose-input { min-height: 84px; padding: 22px 30px; }
html.desk .btn-mic, html.desk .btn-attach { width: 84px; height: 84px; }
html.desk .btn-send { width: 84px; height: 84px; }
/* Car Mode off: no visible scrollbar on the message box (still scrolls). */
html.desk .compose-input { scrollbar-width: none; }
html.desk .compose-input::-webkit-scrollbar { display: none; width: 0; height: 0; }
html.desk .setting-row { min-height: 104px; }
@media (hover: hover) {
  html.desk .conv:hover:not(.active) { background: var(--panel-2); }
  html.desk .btn:hover, html.desk .btn-send:hover:not(:disabled), html.desk .btn-mic:hover, html.desk .btn-attach:hover,
  html.desk .zoom-btn:hover:not(:disabled), html.desk .zoom-step:hover { filter: brightness(1.18); }
  html.desk .setting-row:hover, html.desk .msg-menu-item:hover:not(:disabled),
  html.desk .reply-btn:hover, html.desk .msg-menu-btn:hover { background: var(--line); }
  html.desk .ct-cat:hover, html.desk .ct-photo:hover, html.desk .ct-swatch:hover { filter: brightness(1.12); }
  html.desk .media-image:hover img, html.desk .link-card:hover { filter: brightness(1.08); }
  /* per-message Reply / ⋮ appear on hover (always shown on touch screens) */
  html.desk .msg-row .reply-btn, html.desk .msg-row .msg-menu-btn { opacity: 0; transition: opacity .12s; }
  html.desk .msg-row:hover .reply-btn, html.desk .msg-row:hover .msg-menu-btn, html.desk .msg-row:focus-within .reply-btn,
  html.desk .msg-row:focus-within .msg-menu-btn, html.desk .msg-row .msg-menu-btn.open { opacity: 1; }
}
html.desk :focus-visible { outline: 4px solid var(--accent); outline-offset: 2px; }

/* ---------- SVG icons (no symbol fonts needed) ---------- */
.ico-svg { display: block; width: 1em; height: 1em; fill: currentColor; flex: none; }
[data-icon] { display: inline-grid; place-items: center; line-height: 0; }
.brand-ico { font-size: 40px; color: var(--accent); }
.btn-gear .ico-svg { width: 44px; height: 44px; }
.btn-icon .ico-svg { width: 44px; height: 44px; }
.msg-menu-btn .ico-svg { width: 40px; height: 40px; }
.conv-menu-btn { display: grid; place-items: center; }
.thread-empty-icon .ico-svg { width: 140px; height: 140px; }
.thread-empty-icon { color: var(--muted); line-height: 0; }
.folder-icon .ico-svg { width: 40px; height: 40px; margin: 0 auto; }
.folder-chev .ico-svg { width: 44px; height: 44px; }
.zoom-btn { display: grid; place-items: center; }
.zoom-btn .ico-svg { width: 44px; height: 44px; }
.folder-back, .newchat-back, .newchat-group { display: inline-flex; align-items: center; gap: 10px; }
.folder-back .ico-svg, .newchat-back .ico-svg, .newchat-group .ico-svg { width: 32px; height: 32px; }
.image-viewer-close { display: grid; place-items: center; }
.image-viewer-close .ico-svg { width: 44px; height: 44px; }
.reply-cancel .ico-svg { width: 36px; height: 36px; }
.contact-check .ico-svg { width: 38px; height: 38px; }
.newchat-chip b .ico-svg { width: 26px; height: 26px; }
.avatar .avatar-ico { width: 52%; height: 52%; }
.media-link, .media-label { display: inline-flex; align-items: center; gap: 10px; }
.media-link .ico-svg, .media-label .ico-svg { width: 30px; height: 30px; }
.btn-emoji .ico-svg { width: 50px; height: 50px; }
.btn-emoji.on { background: var(--accent); }
.cookies-row { text-decoration: none; color: var(--text); }
.cookies-row.needed .setting-name { color: #ffc557; }
button.msg-status.failed { border: 0; background: transparent; padding: 6px 0; cursor: pointer; text-decoration: underline; font: inherit; font-size: 22px; font-weight: 700; color: #ff8589; }

/* ---------- Settings: Microphone & speech-to-text details ---------- */
.stt-info { margin: 0 0 14px; padding: 14px 24px; border-radius: 24px; background: var(--bg); border: 2px solid var(--line); }
.stt-info-row { display: flex; gap: 20px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 22px; line-height: 1.3; }
.stt-info-row:last-child { border-bottom: 0; }
.stt-info dt { flex: none; width: 230px; color: var(--muted); font-weight: 600; }
.stt-info dd { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }

/* ---------- emoji picker ---------- */
.emoji-panel { flex: none; display: flex; flex-direction: column; background: var(--panel); border-top: 1px solid var(--line);
  height: min(calc(42vh / var(--z)), 560px); min-height: 0; }
.emoji-top { flex: none; display: flex; align-items: center; gap: 14px; padding: 12px 20px 6px; }
.emoji-search { flex: 1; min-width: 0; height: 72px; padding: 0 26px; border-radius: 36px; border: 2px solid var(--line); background: var(--bg); font-size: 26px; outline: none; }
.emoji-search:focus { border-color: var(--accent); }
.emoji-close { flex: none; }
.emoji-tabs { flex: none; display: flex; gap: 6px; padding: 4px 14px; overflow-x: auto; scrollbar-width: none; }
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 104px; padding: 8px 10px 6px; border: 0;
  border-bottom: 4px solid transparent; background: transparent; color: var(--muted); cursor: pointer; touch-action: manipulation; }
.emoji-tab.on { border-bottom-color: var(--accent); color: var(--text); }
.emoji-tab-glyph { font-size: 38px; line-height: 1.15; }
.emoji-tab .ico-svg { width: 42px; height: 44px; }
.emoji-tab-label { font-size: 17px; font-weight: 600; }
.emoji-grid { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 14px 14px; }
.emoji-sec { position: sticky; top: 0; z-index: 1; padding: 10px 8px 6px; background: var(--panel); font-size: 20px; font-weight: 700; color: var(--muted); }
.emoji-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
.emoji-cell { height: 88px; border: 0; border-radius: 20px; background: transparent; font-size: 54px; line-height: 1; cursor: pointer; touch-action: manipulation;
  font-family: "Noto Color Emoji", "Apple Color Emoji", sans-serif; }
.emoji-cell:active { background: var(--panel-2); transform: scale(.92); }
.emoji-empty { grid-column: 1 / -1; padding: 14px 8px; font-size: 22px; color: var(--muted); }
html.desk .emoji-panel { height: min(calc(46vh / var(--z)), 520px); }
html.desk .emoji-cells { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
html.desk .emoji-cell { height: 64px; font-size: 40px; }
@media (hover: hover) { html.desk .emoji-cell:hover { background: var(--panel-2); } }

/* ---------- conversation menu: chat theme ---------- */
.conv-menu-ico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; }
.conv-menu-ico .ico-svg { width: 40px; height: 40px; }

/* ---------- composer float (Car Mode, box tapped to type) ---------- */
/* Moves the composer (and reply bar / emoji picker) right under the
   conversation header so the on-screen keyboard can't cover it. */
html:not(.desk) .thread-view.compose-float > .thread-header { order: 0; }
html:not(.desk) .thread-view.compose-float > .reply-bar { order: 1; }
html:not(.desk) .thread-view.compose-float > .compose { order: 2; position: relative; z-index: 2; border-top: 0;
  border-bottom: 1px solid var(--line); box-shadow: 0 12px 28px rgba(0, 0, 0, .45); }
html:not(.desk) .thread-view.compose-float > .compose .compose-input { max-height: 200px; }
html:not(.desk) .thread-view.compose-float > .emoji-panel { order: 3; border-top: 0; border-bottom: 1px solid var(--line); }
html:not(.desk) .thread-view.compose-float > .messages { order: 4; }
html:not(.desk) .thread-view.compose-float > .readonly-note,
html:not(.desk) .thread-view.compose-float > .rec-bar { order: 5; }

/* ---------- Settings: notifications / app ---------- */
.notif-row { cursor: default; }
.notif-row:active { filter: none; }
.notif-btn { flex: none; }
.setting-note { margin: 6px 6px 4px; font-size: 21px; line-height: 1.4; color: var(--muted); }
html.desk .setting-note { font-size: 18px; }

/* ---------- Group / Contact details ---------- */
.details-hero { display: flex; align-items: center; gap: 28px; padding: 8px 6px 4px; }
.details-avatar-slot { flex: none; }
.avatar.details-avatar { width: 128px; height: 128px; font-size: 48px; }
.avatar.details-avatar .ico-svg { width: 64px; height: 64px; }
.details-hero-text { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.details-name { font-size: 34px; font-weight: 700; overflow-wrap: anywhere; }
.details-sub { font-size: 24px; color: var(--muted); overflow-wrap: anywhere; }
.details-members { display: flex; flex-direction: column; gap: 6px; }
.details-member { display: flex; align-items: center; gap: 24px; min-height: 104px; padding: 10px 18px; border-radius: 24px; background: var(--panel-2); }
.details-member-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.details-member-name { font-size: 28px; font-weight: 600; overflow-wrap: anywhere; }
.details-member-num { font-size: 22px; color: var(--muted); }
.details-empty { padding: 12px 6px; font-size: 22px; color: var(--muted); }
html.desk .avatar.details-avatar { width: 104px; height: 104px; font-size: 40px; }
html.desk .details-member { min-height: 84px; }
html.desk .details-member-name { font-size: 22px; }
html.desk .details-name { font-size: 28px; }
.msg-menu-danger .conv-menu-ico { color: inherit; }

/* Notification sound row: switch + Test button side by side. */
.setting-pair { display: flex; gap: 16px; align-items: stretch; }
.setting-pair .setting-row { flex: 1; min-width: 0; }
.setting-test { flex: none; display: inline-flex; align-items: center; gap: 12px; min-height: 84px; align-self: center; }
.setting-test svg { width: 36px; height: 36px; fill: currentColor; }

/* Settings > Debug: collapsed fold at the bottom */
.debug-fold { margin: 26px 0 8px; border-top: 2px solid var(--line); }
.debug-summary { display: flex; flex-direction: column; gap: 4px; padding: 20px 4px; cursor: pointer; list-style: none; }
.debug-summary::-webkit-details-marker { display: none; }
.debug-summary-text { color: var(--muted); font-size: 24px; font-weight: 600; }
.debug-summary-text::before { content: "▸ "; }
.debug-fold[open] .debug-summary-text::before { content: "▾ "; }
.debug-fold .sheet-label:first-of-type { margin-top: 4px; }
