:root {
  --bg: #12314e;
  --bg-sidebar: #163a5a;
  --bg-elevated: #1c4468;
  --bg-hover: #234f75;
  --bg-active: #2f7ac4;
  --bg-input: #1c4264;
  --accent: #34a5f5;
  --accent-hover: #52b4f8;
  --text: #ffffff;
  --text-secondary: #9bb4c8;
  --text-tertiary: #859fb5;
  --bubble-in: #1a4061;
  --bubble-out: #2b73ba;
  --divider: #0d2740;
  --unread: #34a5f5;
  --danger: #e05656;
  --online: #4dcd5e;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2a3948; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #35485a; }

/* ===================== AUTH ===================== */
/* While a saved session is being resumed: hide the login form, show the splash.
   app.js drops .resuming as soon as it knows which screen to land on. */
/* Shown only while .resuming is set — driven by a class, not the hidden
   attribute, because [hidden] here is !important and would always win. */
.splash { display: none; }
html.resuming #splash {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #2a659e 0%, var(--bg) 55%);
}
.splash img { border-radius: 20px; }
html.resuming #auth,
html.resuming #lang-btn { display: none; }

.auth-screen {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #2a659e 0%, var(--bg) 55%);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--bg-sidebar);
  border-radius: 18px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo {
  display: block;
  width: 84px; height: 84px; margin: 0 auto 18px;
  /* Matches the rounded-square app icon rather than the circular avatar shape. */
  border-radius: 24%;
  box-shadow: 0 8px 30px rgba(51,144,236,.4);
}
.auth-card h1 { font-size: 26px; font-weight: 600; }
.auth-sub { color: var(--text-secondary); font-size: 14px; margin-top: 6px; margin-bottom: 24px; }
.auth-tabs {
  display: flex; background: var(--bg-input);
  border-radius: 10px; padding: 4px; margin-bottom: 20px;
}
.auth-tab {
  flex: 1; padding: 9px; border-radius: 7px;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: .15s;
}
.auth-tab.active { background: var(--accent); color: #fff; }
.field { display: block; text-align: left; margin-bottom: 14px; }
.field span { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; padding-left: 4px; }
.field input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input); border: 1.5px solid transparent;
  border-radius: 10px; color: var(--text); font-size: 15px;
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--accent); }
/* Link field with an inline Copy button. The extra specificity overrides
   `.modal-body .btn-fill { width: 100% }`, which would otherwise stretch the button. */
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input { flex: 1 1 auto; min-width: 0; }
.modal-body .copy-row .copy-btn { flex: 0 0 auto; width: auto; margin-top: 0; white-space: nowrap; padding: 0 16px; border-radius: 10px; }
.btn-primary {
  width: 100%; padding: 13px; margin-top: 6px;
  background: var(--accent); color: #fff;
  border-radius: 10px; font-size: 15px; font-weight: 600;
  transition: .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; text-align: center; }
.auth-foot { margin-top: 22px; color: var(--text-tertiary); font-size: 12px; }

/* ===================== APP LAYOUT ===================== */
.app { height: 100%; display: flex; }

.avatar {
  flex-shrink: 0;
  width: 46px; height: 46px; border-radius: 30%;
  display: grid; place-items: center;
  color: #fff; font-weight: 600; font-size: 17px;
  background: hsl(210, 55%, 48%);
  background-size: cover; background-position: center;
  user-select: none; position: relative;
}
.avatar.sm { width: 38px; height: 38px; font-size: 14px; border-radius: 28%; }
.avatar.lg { width: 100px; height: 100px; font-size: 40px; border-radius: 26%; }
.avatar .presence-dot {
  position: absolute; bottom: -1px; right: -1px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--online); border: 2.5px solid var(--bg-sidebar);
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 360px; flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--divider);
  display: flex; flex-direction: column;
  position: relative;
}
.sidebar-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--divider);
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px;
  color: var(--text-secondary); transition: .15s; flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.search-wrap { flex: 1; }
.search-wrap input {
  width: 100%; padding: 9px 16px;
  background: var(--bg-input); border: none; border-radius: 20px;
  color: var(--text); font-size: 14px;
}
.search-wrap input:focus { outline: none; }

.chat-list, .search-results { flex: 1; overflow-y: auto; overflow-x: hidden; }
.search-results { position: absolute; inset: 61px 0 64px; background: var(--bg-sidebar); z-index: 5; }

/* Swipe-to-reveal: the actions sit underneath and the row slides off them. */
.chat-row-wrap {
  position: relative; overflow: hidden;
  touch-action: pan-y;            /* vertical scrolling stays with the list */
}
.chat-actions {
  position: absolute; inset: 0 0 0 auto;
  width: 152px; display: flex;
}
.chat-action {
  flex: 1; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: #fff; font-size: 19px; font-family: inherit;
}
.chat-action span { font-size: 11px; font-weight: 600; }
.chat-action.pin { background: #3a7bd5; }
.chat-action.del { background: #d64545; }
.chat-item {
  position: relative;             /* stack above .chat-actions */
  background: var(--bg-sidebar);
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; cursor: pointer;
  transition: background .12s, transform .18s ease;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }
.chat-item.active .chat-sub, .chat-item.active .chat-time { color: rgba(255,255,255,.75); }
.chat-main { flex: 1; min-width: 0; }
.chat-row { display: flex; align-items: baseline; gap: 8px; }
.chat-title {
  font-size: 15px; font-weight: 500; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-time { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }
.chat-bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.chat-sub {
  flex: 1; min-width: 0; font-size: 14px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-sub .sub-sender { color: var(--text); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--unread); color: #fff;
  border-radius: 10px; font-size: 12px; font-weight: 600;
  display: grid; place-items: center; flex-shrink: 0;
}
.badge.muted { background: #4a5a6a; }

.section-label { padding: 12px 16px 6px; font-size: 12px; color: var(--text-tertiary); font-weight: 600; }

.me-bar {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-top: 1px solid var(--divider);
  background: var(--bg-sidebar);
}
.me-info { flex: 1; min-width: 0; }
.me-name { font-size: 14px; font-weight: 500; }
.me-username { font-size: 12px; color: var(--text-secondary); }

/* ---------- Conversation ---------- */
.conversation {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background:
    linear-gradient(rgba(18,49,78,.91), rgba(18,49,78,.91)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Ctext y='40' font-size='40' opacity='.5'%3E💬%3C/text%3E%3Ctext x='60' y='100' font-size='40' opacity='.5'%3E✈️%3C/text%3E%3C/svg%3E");
  position: relative;
}
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-secondary); gap: 14px;
}
.empty-icon { font-size: 60px; opacity: .5; }
.empty-state p { background: var(--bg-elevated); padding: 8px 18px; border-radius: 16px; font-size: 14px; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--divider);
  z-index: 2;
}
.back-btn { display: none; }
.back-chevron { font-size: 26px; line-height: 1; }
.back-label { display: none; font-size: 13px; font-weight: 600; }
.head-info { flex: 1; min-width: 0; cursor: pointer; }
.head-title { font-size: 16px; font-weight: 500; }
.head-status { font-size: 13px; color: var(--text-secondary); }
.head-status.online { color: var(--accent); }

.messages {
  flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden;
  padding: 16px 8%;
  display: flex; flex-direction: column; gap: 2px;
}
.day-sep { align-self: center; margin: 12px 0; }
.day-sep span {
  background: rgba(28,39,51,.85); color: var(--text-secondary);
  font-size: 12px; padding: 4px 12px; border-radius: 12px;
}
.msg-row { display: flex; flex-direction: column; max-width: 72%; }
.msg-row.out { align-self: flex-end; align-items: flex-end; }
.msg-row.in { align-self: flex-start; align-items: flex-start; }
/* "Signed" operator reply in the shared channel inbox — operators only. */
.op-sig { font-size: 11px; color: var(--text-tertiary); margin: 2px 6px 0; }
.msg-row.grouped { margin-top: -1px; }

.bubble {
  position: relative;
  padding: 7px 11px 8px; border-radius: 12px;
  font-size: 15px; line-height: 1.35; word-wrap: break-word;
  max-width: 100%;
  /* Disable native text selection / long-press callout so iOS doesn't pop the
     selection loupe and zoom the WKWebView. Copying is done via the Copy action. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.msg-row.in .bubble { background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg-row.out .bubble { background: var(--bubble-out); border-bottom-right-radius: 4px; }
.msg-row.grouped.in .bubble { border-bottom-left-radius: 4px; border-top-left-radius: 4px; }
.msg-row.grouped.out .bubble { border-bottom-right-radius: 4px; border-top-right-radius: 4px; }
.bubble .sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
/* break long unbroken strings (e.g. URLs) so a bubble never widens past the
   viewport, which was pushing the chat sideways and clipping message edges. */
.bubble .body { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; }
.bubble .body a { color: #62b0f5; word-break: break-all; }
.bubble .meta {
  float: right; margin: 6px -3px -2px 10px;
  font-size: 11px; color: var(--text-tertiary);
  display: flex; align-items: center; gap: 3px; user-select: none;
}
.msg-row.out .bubble .meta { color: rgba(255,255,255,.6); }
.bubble .meta .tick { font-size: 13px; line-height: 1; }
.bubble .meta .tick.read { color: #62d9ff; }
.bubble .edited { font-style: italic; opacity: .7; }
.bubble.deleted .body { font-style: italic; color: var(--text-tertiary); }
.bubble .msg-actions {
  position: absolute; top: -10px; display: none; gap: 2px;
  background: var(--bg-elevated); border-radius: 8px; padding: 2px;
  box-shadow: var(--shadow);
}
.msg-row.out .bubble .msg-actions { right: 0; }
.msg-row.in .bubble .msg-actions { left: 0; }
.bubble:hover .msg-actions { display: flex; }
.msg-actions button { padding: 4px 7px; font-size: 12px; border-radius: 6px; color: var(--text-secondary); }
.msg-actions button:hover { background: var(--bg-hover); color: var(--text); }

.sys-msg { align-self: center; margin: 8px 0; }
.sys-msg span {
  background: rgba(28,39,51,.8); color: var(--text-secondary);
  font-size: 12px; padding: 5px 14px; border-radius: 14px;
}

.typing-bar { height: 0; padding: 0 8%; color: var(--accent); font-size: 13px; transition: height .15s; overflow: hidden; }
.typing-bar.show { height: 22px; padding-bottom: 4px; }

/* ---------- Attachments in bubbles ---------- */
.bubble .att { display: block; margin: -1px -3px 4px; border-radius: 10px; overflow: hidden; }
.bubble .att.att-image img,
.bubble .att.att-video video {
  display: block; max-width: min(340px, 62vw); max-height: 380px;
  width: auto; height: auto; border-radius: 10px; cursor: pointer; background: #000;
}
.bubble .att.att-video video { cursor: default; }
.bubble .att-file {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: rgba(0,0,0,.22);
  border-radius: 10px; text-decoration: none; color: inherit;
  min-width: 170px; max-width: 250px;
}
.msg-row.in .att-file { background: rgba(255,255,255,.06); }
.att-file .file-icon {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); display: grid; place-items: center; font-size: 17px;
}
.att-file .file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.att-file .file-name { display: block; max-width: 100%; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-file .file-size { font-size: 11.5px; color: var(--text-tertiary); }
.msg-row.out .att-file .file-size { color: rgba(255,255,255,.6); }
/* Audio file + voice message players */
.bubble .att-audio { padding: 8px 10px; background: rgba(0,0,0,.22); border-radius: 10px; min-width: 210px; max-width: 280px; }
.msg-row.in .att-audio { background: rgba(255,255,255,.06); }
.att-audio .att-audio-name { font-size: 13px; font-weight: 500; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble .att-voice { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: rgba(0,0,0,.22); border-radius: 10px; min-width: 210px; max-width: 280px; }
.msg-row.in .att-voice { background: rgba(255,255,255,.06); }
.att-voice .voice-mic { font-size: 18px; flex-shrink: 0; }
.att-audio audio, .att-voice audio { width: 100%; height: 34px; }
.bubble.media-only { padding: 3px 3px 3px; background: transparent !important; }
.bubble.media-only .meta { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.5); padding: 2px 7px; border-radius: 10px; margin: 0; color: #fff; }
.msg-row.flash .bubble { animation: flash 1.6s ease; }
@keyframes flash { 0%,70% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: none; } }

/* ---------- Attach preview strip ---------- */
.attach-preview {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px; background: var(--bg-sidebar);
  border-top: 1px solid var(--divider);
}
.attach-preview .preview-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.protect-toggle {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  font-size: 13px; color: var(--text-secondary); cursor: pointer;
  background: var(--bg-input); padding: 6px 12px; border-radius: 16px;
}
.protect-toggle.locked { color: var(--accent); }
.protect-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }
/* Save-protected media: watermark overlay + download button */
.bubble .att.att-image, .bubble .att.att-video, .lb-protected { position: relative; }
.att-file.viewable { cursor: pointer; }
.wm {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 3;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  transform: rotate(-24deg) scale(1.5); transform-origin: center;
  color: rgba(255,255,255,.30); font-size: 12px; font-weight: 700; line-height: 2.5;
  white-space: nowrap; text-align: center; user-select: none;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}
/* View-only protected viewer (nosave images / PDFs) */
.lb-protected { display: flex; align-items: center; justify-content: center; max-width: 92vw; max-height: 88vh; }
.lb-protected img { max-width: 92vw; max-height: 88vh; -webkit-touch-callout: none; user-select: none; }
.lb-protected video { max-width: 92vw; max-height: 88vh; }
.lb-protected .wm { color: rgba(255,255,255,.34); font-size: 15px; }
/* Protected PDF: pages rendered to canvas (no native viewer → no share/save/open-in) */
.lb-pdf-wrap { width: 92vw; height: 88vh; overflow: hidden; }
.lb-pdf-wrap .pdf-scroll {
  width: 100%; height: 100%; overflow: auto; -webkit-overflow-scrolling: touch;
  padding: 12px; text-align: center; background: #333; touch-action: pan-x pan-y;
}
.lb-pdf-wrap .pdf-page {
  display: block; margin: 0 auto 12px; height: auto; max-width: none;
  width: calc(96% * var(--pdf-scale, 1)); box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
/* Zoomable protected image viewport (pinch / double-tap / wheel) */
.lb-protected.zoom-img { width: 92vw; height: 88vh; max-width: none; max-height: none; overflow: hidden; touch-action: none; }
.lb-protected.zoom-img img { max-width: 92vw; max-height: 88vh; }
.lb-pdf-wrap .wm { z-index: 5; }
.pdf-loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 14px; pointer-events: none; }
/* Protected video player: custom controls, no native fullscreen, watermark always on top */
.pvid { position: relative; max-width: 280px; border-radius: 10px; overflow: hidden; background: #000; }
.pvid.pvid-lb { max-width: 92vw; max-height: 88vh; border-radius: 8px; }
.pvid video { display: block; width: 100%; max-height: 60vh; }
.pvid.pvid-lb video { max-height: 84vh; width: auto; max-width: 92vw; margin: 0 auto; }
.pvid .wm { z-index: 2; }
.pvid-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px; padding: 6px 9px;
  background: linear-gradient(transparent, rgba(0,0,0,.65));
}
.pvid-bar .pvid-play, .pvid-bar .pvid-expand { color: #fff; font-size: 15px; background: none; flex-shrink: 0; line-height: 1; }
.pvid-bar .pvid-seek { flex: 1; accent-color: var(--accent); height: 4px; min-width: 0; }
.pvid-bar .pvid-time { color: #fff; font-size: 11px; flex-shrink: 0; min-width: 36px; }
/* Protected video in fullscreen: fill the screen with the watermark still on top */
.att.att-video:fullscreen, .lb-protected:fullscreen,
.att.att-video:-webkit-full-screen, .lb-protected:-webkit-full-screen {
  width: 100vw; height: 100vh; margin: 0; background: #000;
  display: flex; align-items: center; justify-content: center;
}
.att.att-video:fullscreen video, .lb-protected:fullscreen video,
.att.att-video:-webkit-full-screen video, .lb-protected:-webkit-full-screen video {
  width: auto; height: auto; max-width: 100vw; max-height: 100vh;
}
.att.att-video:fullscreen .wm, .lb-protected:fullscreen .wm,
.att.att-video:-webkit-full-screen .wm, .lb-protected:-webkit-full-screen .wm { font-size: 22px; }
.att.nosave img, .att.nosave video { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.att-save {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.55);
  color: #fff; display: grid; place-items: center; font-size: 16px; text-decoration: none;
  opacity: 0; transition: opacity .15s;
  border: none; padding: 0; cursor: pointer; font-family: inherit; /* button variant reset */
}
.att.att-image:hover .att-save, .att.att-video:hover .att-save { opacity: 1; }
@media (hover: none) { .att-save { opacity: .85; } }

/* Voice-record mic button: pulses red while held. */
.mic-btn { transition: color .15s, transform .1s; }
.mic-btn.recording { color: #ff4d4f; animation: mic-pulse .9s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.22); } }
.preview-chip {
  position: relative; width: 72px; height: 72px; border-radius: 10px;
  overflow: hidden; background: var(--bg-input);
  display: grid; place-items: center; flex-shrink: 0;
}
.preview-chip img, .preview-chip video { width: 100%; height: 100%; object-fit: cover; }
.preview-chip .file-badge { font-size: 26px; }
.preview-chip .chip-name { position: absolute; bottom: 0; left: 0; right: 0; font-size: 9px; padding: 2px 3px; background: rgba(0,0,0,.6); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-chip .chip-remove {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0,0,0,.65); color: #fff;
  font-size: 12px; display: grid; place-items: center; z-index: 2;
}
.preview-chip.uploading::after {
  content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.55);
  border: 3px solid transparent; border-top-color: #fff; border-radius: 10px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,.9);
  display: grid; place-items: center; padding: 40px;
}
.lightbox-content img, .lightbox-content video { max-width: 92vw; max-height: 88vh; border-radius: 8px; }
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.12); color: #fff; font-size: 20px;
}
.lightbox-close:hover { background: rgba(255,255,255,.22); }

/* ---------- Search: message results ---------- */
.result-msg { display: flex; align-items: flex-start; gap: 11px; padding: 9px 12px; cursor: pointer; }
.result-msg:hover { background: var(--bg-hover); }
.result-body { flex: 1; min-width: 0; }
.result-row { display: flex; align-items: baseline; gap: 8px; }
.result-title { font-size: 14px; font-weight: 500; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-time { font-size: 11px; color: var(--text-tertiary); }
.result-text { font-size: 13px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-text mark { background: transparent; color: var(--accent); font-weight: 600; }

.composer {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 10px;
  background: var(--bg-sidebar);
  border-top: 1px solid var(--divider);
}
/* Tighten the composer's own icon buttons so the text field gets the width it needs —
   otherwise the placeholder wraps onto a second line on narrow phones. */
.composer .icon-btn { width: 38px; height: 38px; }
.composer input,
.composer textarea {
  flex: 1; min-width: 0; padding: 12px 14px;
  background: var(--bg-input); border: none; border-radius: 22px;
  /* 16px keeps iOS from zooming the page when the input gains focus. */
  color: var(--text); font-size: 16px;
}
/* Multi-line composer: Enter inserts a newline, grows up to ~5 lines then
   scrolls. No native resize handle; text stays vertically centred at 1 line. */
.composer textarea {
  resize: none;
  font-family: inherit;
  line-height: 1.35;
  max-height: 120px;
  overflow-y: auto;
}
.composer input:focus,
.composer textarea:focus { outline: none; }
.send-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; flex-shrink: 0;
  transition: .15s; transform: scale(1);
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:active { transform: scale(.9); }

/* ---------- Info panel ---------- */
.info-panel {
  width: 340px; flex-shrink: 0;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--divider);
  display: flex; flex-direction: column;
}
.info-head {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; border-bottom: 1px solid var(--divider);
  font-size: 16px; font-weight: 500;
}
.info-body { flex: 1; overflow-y: auto; padding: 20px 0; }
.info-profile { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 0 20px 20px; border-bottom: 1px solid var(--divider); }
.info-profile .name { font-size: 20px; font-weight: 600; }
.info-profile .sub { color: var(--text-secondary); font-size: 14px; }
.info-profile .bio { color: var(--text); font-size: 14px; text-align: center; margin-top: 4px; }
.info-members { padding: 8px 0; }
.member-item { display: flex; align-items: center; gap: 12px; padding: 9px 20px; cursor: pointer; }
.member-item:hover { background: var(--bg-hover); }
.member-item .m-name { font-size: 15px; }
.member-item .m-role { font-size: 12px; color: var(--accent); }
.member-item .m-status { font-size: 12px; color: var(--text-secondary); }
.member-item .m-note-btn { flex:none; background:none; border:none; cursor:pointer; font-size:17px; padding:4px 6px; border-radius:8px; opacity:.75; }
.member-item .m-note-btn:hover { opacity:1; background: var(--bg-hover); }
/* ---------- Reminders ---------- */
.rem-modal { font-size: 15px; }
.rem-field { margin-bottom: 16px; }
.rem-label { display:block; font-size:13px; color:var(--text-secondary); margin:0 0 6px 2px; }
/* Own input styling so the shared `.field input { width:100% }` rule can't turn the
   radio buttons into full-width blocks (which squashed their labels into vertical text). */
.rem-input { width:100%; box-sizing:border-box; padding:12px 14px; font-size:16px; color:var(--text);
  background:var(--bg-input); border:1.5px solid transparent; border-radius:12px; font-family:inherit; }
.rem-input:focus { outline:none; border-color:var(--accent); }
.rem-textarea { resize:vertical; min-height:64px; line-height:1.45; }
select.rem-input { -webkit-appearance:none; appearance:none; }
/* Date/time field: tidy the native control so it matches the other inputs — full-width,
   left-aligned value, and a calendar icon that's actually visible on the dark background. */
input[type="datetime-local"].rem-input {
  -webkit-appearance:none; appearance:none; min-height:52px;
  display:flex; align-items:center; text-align:left;
}
input[type="datetime-local"].rem-input::-webkit-date-and-time-value { text-align:left; margin:0; }
input[type="datetime-local"].rem-input::-webkit-calendar-picker-indicator {
  filter:invert(1); opacity:.55; cursor:pointer; margin-left:auto;
}
input[type="datetime-local"].rem-input::-webkit-calendar-picker-indicator:hover { opacity:.85; }
.rem-opts { display:flex; flex-direction:column; gap:8px; }
.rem-opt { display:flex; align-items:center; gap:12px; width:100%; box-sizing:border-box;
  padding:13px 14px; background:var(--bg-input); border:1.5px solid transparent; border-radius:12px;
  font-size:15px; line-height:1.3; cursor:pointer; text-align:left; }
.rem-opt input[type=radio] { width:20px; height:20px; flex:none; margin:0; accent-color:var(--accent); }
.rem-opt span { flex:1; min-width:0; }
.rem-opt:has(input:checked) { border-color:var(--accent); background:var(--bg-hover); }
/* list */
.rem-item { display:flex; align-items:center; gap:12px; padding:13px 4px; border-bottom:1px solid var(--border); }
.rem-item:last-child { border-bottom:none; }
.rem-item-main { flex:1; min-width:0; }
.rem-item-body { font-size:15px; word-break:break-word; }
.rem-item-meta { font-size:13px; color:var(--text-secondary); margin-top:3px; }
.rem-item .rem-del { flex:none; }
/* ---------- Share picker (multi-select) ---------- */
.share-list { display:flex; flex-direction:column; }
.share-row { display:flex; align-items:center; gap:14px; padding:14px 6px; border-bottom:1px solid var(--border); cursor:pointer; }
.share-row:last-child { border-bottom:none; }
.share-row input[type=checkbox] { width:22px; height:22px; flex:none; accent-color:var(--accent); margin:0; }
.share-name { flex:1; font-size:16px; word-break:break-word; }
.share-nosave { display:flex; align-items:center; gap:10px; padding:12px 22px 4px; font-size:14px; color:var(--text); cursor:pointer; }
.share-nosave input { width:20px; height:20px; flex:none; accent-color:var(--accent); margin:0; }
.share-nosave.locked { color:var(--text-secondary); opacity:.8; cursor:default; }
.info-action { display: block; width: 100%; text-align: left; padding: 13px 20px; font-size: 15px; color: var(--danger); }
.info-action:hover { background: var(--bg-hover); }
.info-action.accent { color: var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.55);
  display: grid; place-items: center; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 420px;
  background: var(--bg-sidebar); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.modal-head { padding: 18px 22px 4px; font-size: 19px; font-weight: 600; }
.modal-desc { padding: 4px 22px 14px; color: var(--text-secondary); font-size: 13px; }
.modal-body { padding: 0 22px 12px; max-height: 50vh; overflow-y: auto; }
.modal-body .field input { background: var(--bg-input); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 18px; }
.modal-foot button { padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.btn-ghost { color: var(--accent); }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-fill { background: var(--accent); color: #fff; }
.btn-fill:hover { background: var(--accent-hover); }
.btn-fill:disabled { opacity: .5; cursor: default; }

.pick-item { display: flex; align-items: center; gap: 12px; padding: 9px 4px; cursor: pointer; }
.pick-item:hover { background: var(--bg-hover); border-radius: 8px; }
.pick-item .pick-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--text-tertiary); flex-shrink: 0;
  display: grid; place-items: center; color: #fff; font-size: 13px;
}
.pick-item.selected .pick-check { background: var(--accent); border-color: var(--accent); }
.pick-name { flex: 1; }
.hint { color: var(--text-tertiary); font-size: 13px; text-align: center; padding: 20px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 820px) {
  .info-panel { position: absolute; inset: 0; z-index: 20; width: 100%; }
  .sidebar { width: 100%; }
  .app.chat-open .sidebar { display: none; }
  .app:not(.chat-open) .conversation { display: none; }
  /* Labelled back-to-chats control so returning to the talk list is obvious on phones. */
  .back-btn { display: inline-flex; align-items: center; gap: 1px; width: auto; padding: 0 10px 0 2px; border-radius: 20px; }
  .back-label { display: inline; }
  .messages { padding: 12px 12px; }
  .msg-row { max-width: 85%; }
}

/* ===================== PREMIUM / SUBSCRIPTION ===================== */
.premium-badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  color: #ffd66b; background: rgba(255,190,60,.14);
  padding: 2px 8px; border-radius: 10px; vertical-align: middle;
}
.info-profile .name .premium-badge { font-size: 12px; }

/* Upgrade CTA in profile */
.premium-cta {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start;
  gap: 2px; padding: 13px 16px; margin: 6px 0 14px;
  border-radius: 12px; text-align: left; color: #1a1207;
  background: linear-gradient(135deg, #ffd66b, #f0a93c);
  font-size: 15px; font-weight: 700;
}
.premium-cta:hover { filter: brightness(1.05); }
.premium-cta-sub { font-size: 12px; font-weight: 500; opacity: .8; }

.premium-status {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; margin: 6px 0 14px; border-radius: 12px;
  background: rgba(255,190,60,.1); border: 1px solid rgba(255,190,60,.25);
}
.premium-status-title { font-size: 13px; color: #ffd66b; font-weight: 600; }
.btn-text { color: var(--text-secondary); font-size: 13px; }
.btn-text:hover { color: var(--danger); }

/* Privacy box */
.privacy-box { border-top: 1px solid var(--divider); padding-top: 14px; margin-top: 4px; }
.privacy-box.locked { opacity: .55; }
.privacy-title { font-size: 13px; color: var(--text-secondary); font-weight: 600; margin-bottom: 8px; }
.lock-tag { color: #ffd66b; font-weight: 500; margin-left: 4px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; font-size: 14px; cursor: pointer;
}
.toggle-row input[type=checkbox] {
  appearance: none; width: 42px; height: 24px; border-radius: 12px;
  background: var(--bg-input); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0;
}
.toggle-row input[type=checkbox]::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.toggle-row input[type=checkbox]:checked { background: var(--accent); }
.toggle-row input[type=checkbox]:checked::after { transform: translateX(18px); }
.toggle-row input[type=checkbox]:disabled { cursor: not-allowed; }

/* Premium modal */
.premium-features { list-style: none; margin: 4px 0 16px; padding: 0; }
.premium-features li { font-size: 14px; padding: 5px 0; color: var(--text); }
.plan-grid { display: flex; gap: 12px; }
.plan-card {
  flex: 1; position: relative; padding: 18px 14px; border-radius: 14px;
  background: var(--bg-input); border: 2px solid transparent; text-align: center;
  transition: .15s;
}
.plan-card:hover { border-color: var(--accent); background: var(--bg-hover); }
.plan-card.featured { border-color: #ffd66b; }
.plan-card:disabled { opacity: .6; }
.plan-tag {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: #ffd66b; color: #1a1207; font-size: 11px; font-weight: 700;
  padding: 2px 10px; border-radius: 10px; white-space: nowrap;
}
.plan-tag.trial { background: #34c759; color: #05230f; }
.plan-name { font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; }
.plan-price { font-size: 16px; font-weight: 700; }
.mock-note {
  margin-top: 14px; padding: 10px 12px; border-radius: 10px;
  background: rgba(51,144,236,.1); color: var(--text-secondary); font-size: 12px; line-height: 1.5;
}

/* ===================== ADS (free tier) ===================== */
.ad-slot {
  border-top: 1px solid var(--divider);
  background: var(--bg-sidebar);
  padding: 8px 10px 6px;
}
.ad-card {
  position: relative; display: flex; align-items: center; gap: 11px;
  padding: 10px 11px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(51,144,236,.14), rgba(142,68,173,.14));
  border: 1px solid rgba(255,255,255,.06);
  cursor: pointer; transition: filter .15s;
}
.ad-card:hover { filter: brightness(1.08); }
.ad-icon {
  width: 40px; height: 40px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 22px;
  background: rgba(255,255,255,.06);
}
.ad-main { flex: 1; min-width: 0; }
.ad-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-desc { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-cta {
  flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--accent);
  padding: 5px 10px; border-radius: 8px; background: rgba(51,144,236,.14);
}
.ad-tag {
  position: absolute; top: -7px; left: 9px;
  font-size: 9px; font-weight: 700; letter-spacing: .5px;
  color: var(--text-tertiary); background: var(--bg-sidebar);
  padding: 0 5px; border-radius: 4px; border: 1px solid var(--divider);
}
.ad-remove {
  display: block; width: 100%; text-align: center;
  font-size: 11px; color: var(--text-tertiary); padding: 6px 0 2px;
}
.ad-remove:hover { color: var(--accent); }

/* ===================== AUTO-DELETE + STATS ===================== */
#autodelete-btn { font-size: 16px; }
#autodelete-btn.active { color: var(--accent); font-weight: 700; font-size: 13px; background: rgba(51,144,236,.14); }

.timer-opt {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 13px 14px; margin-bottom: 6px;
  background: var(--bg-input); border-radius: 10px; font-size: 15px; color: var(--text);
  transition: background .12s;
}
.timer-opt:hover { background: var(--bg-hover); }
.timer-opt.sel { background: rgba(51,144,236,.16); }
.timer-check { color: var(--accent); font-weight: 700; }

/* Ad report */
.stats-link {
  display: block; width: 100%; text-align: center; margin-top: 14px;
  padding: 10px; border-radius: 10px; font-size: 13px;
  color: var(--text-secondary); background: var(--bg-input);
}
.stats-link:hover { background: var(--bg-hover); color: var(--text); }
/* Notifications confirmed working — green so "on" is readable at a glance. */
.stats-link.is-on { color: #4fd18b; background: rgba(79, 209, 139, .12); }
/* Secondary line telling the user what tapping the row will do. */
.stats-link .row-hint { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }

/* ---- Multi-device: account switcher & linked devices ---- */
.acct-list { display: flex; flex-direction: column; gap: 8px; }
.acct-row {
  display: flex; align-items: center; gap: 12px; text-align: left;
  margin-top: 0; padding: 10px 12px;
}
.acct-row.active { outline: 1.5px solid var(--accent); }
.acct-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.acct-name { color: var(--text); font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acct-un { color: var(--text-tertiary); font-size: 12px; }
.acct-cur { color: var(--accent); font-size: 12px; }
.link-code { text-align: center; margin-top: 12px; font-size: 14px; color: var(--text-secondary); letter-spacing: 1px; }
.link-code b { color: var(--text); font-size: 18px; letter-spacing: 3px; }
.dev-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 6px; border-bottom: 1px solid var(--divider);
}
.dev-label { color: var(--text); font-size: 14px; }
.dev-cur { color: var(--text-tertiary); font-size: 12px; }
.btn-text.danger { color: var(--danger, #ff4d4f); background: none; font-size: 13px; }
.stats-link:disabled { opacity: .5; cursor: default; }
.stats-tiles { display: flex; gap: 10px; margin-bottom: 16px; }
.stat-tile { flex: 1; background: var(--bg-input); border-radius: 12px; padding: 14px 8px; text-align: center; }
.stat-val { font-size: 22px; font-weight: 700; }
.stat-key { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stats-table th { text-align: left; color: var(--text-secondary); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--divider); }
.stats-table td { padding: 9px 6px; border-bottom: 1px solid var(--divider); }
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ===================== iOS/Android SAFE AREAS (notch, Dynamic Island, home indicator) ===================== */
/* env() is 0 on desktop browsers, so these have no effect on the web version. */
html, body { background: var(--bg-sidebar); }
.sidebar-head { padding-top: calc(10px + env(safe-area-inset-top)); }
.chat-head    { padding-top: calc(9px  + env(safe-area-inset-top)); }
.info-head    { padding-top: calc(14px + env(safe-area-inset-top)); }
.me-bar       { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.composer     { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.search-results { top: calc(61px + env(safe-area-inset-top)); bottom: calc(64px + env(safe-area-inset-bottom)); }
.lightbox-close { top: calc(20px + env(safe-area-inset-top)); }

/* ===================== LANGUAGE SELECTOR ===================== */
.lang-btn {
  position: fixed; z-index: 40;
  top: calc(12px + env(safe-area-inset-top)); right: calc(14px + env(safe-area-inset-right));
  display: flex; align-items: center; gap: 5px;
  background: rgba(0,0,0,.28); color: #fff; font-size: 13px; font-weight: 600;
  padding: 7px 12px; border-radius: 20px; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.lang-btn:hover { background: rgba(0,0,0,.45); }
.lang-opt {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 13px 14px; margin-bottom: 6px;
  background: var(--bg-input); border-radius: 10px; font-size: 15px; color: var(--text);
  transition: background .12s;
}
.lang-opt:hover { background: var(--bg-hover); }
.lang-opt.sel { background: rgba(51,144,236,.16); }

/* ===================== CONSENT + DELETE ACCOUNT ===================== */
.consent {
  margin-top: 14px; text-align: center;
  font-size: 12px; color: var(--text-tertiary); line-height: 1.6;
}
.consent a { color: var(--accent); text-decoration: none; }
.consent a:hover { text-decoration: underline; }
.danger-link {
  display: block; width: 100%; text-align: center; margin-top: 8px;
  padding: 10px; border-radius: 10px; font-size: 13px;
  color: var(--danger); background: rgba(224,86,86,.08);
}
.danger-link:hover { background: rgba(224,86,86,.16); }

/* ===================== CALLS ===================== */
.call-btn { font-size: 17px; }
.call-overlay {
  position: fixed; inset: 0; z-index: 70; background: #0a1119;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.call-overlay .remote-video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #0a1119;
}
.call-overlay .local-video {
  position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 16px;
  width: 110px; height: 150px; object-fit: cover; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.25); background: var(--bg-sidebar); z-index: 2; transform: scaleX(-1);
}
.call-top {
  position: absolute; top: calc(30px + env(safe-area-inset-top)); left: 0; right: 0;
  text-align: center; z-index: 2; text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.call-peer { font-size: 24px; font-weight: 600; color: #fff; }
.call-status { font-size: 15px; color: rgba(255,255,255,.8); margin-top: 6px; }
.call-controls {
  position: absolute; bottom: calc(40px + env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex; justify-content: center; gap: 22px; z-index: 2;
}
.call-ctrl {
  width: 62px; height: 62px; border-radius: 50%; font-size: 24px;
  background: rgba(255,255,255,.18); color: #fff; display: grid; place-items: center;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: .15s;
}
.call-ctrl:hover { background: rgba(255,255,255,.28); }
.call-ctrl.off { background: #fff; color: var(--bg-sidebar); }
/* Speaker engaged — filled the same way "off" states are, so the active control
   reads at a glance while the phone is away from the ear. */
.call-ctrl.on { background: #fff; color: var(--bg-sidebar); }
.call-ctrl.hangup { background: var(--danger); }
.call-ctrl.hangup:hover { background: #f06767; }

.incoming-call {
  position: fixed; z-index: 75; left: 50%; transform: translateX(-50%);
  top: calc(16px + env(safe-area-inset-top));
  width: min(360px, 92vw); background: var(--bg-elevated);
  border-radius: 18px; box-shadow: var(--shadow); padding: 22px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: incoming-in .25s ease;
}
@keyframes incoming-in { from { transform: translate(-50%, -20px); opacity: 0; } }
.incoming-avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.incoming-name { font-size: 19px; font-weight: 600; }
.incoming-sub { font-size: 14px; color: var(--text-secondary); }
.incoming-actions { display: flex; gap: 40px; margin-top: 14px; }
.incoming-actions button { width: 60px; height: 60px; border-radius: 50%; font-size: 26px; color: #fff; transition: .15s; }
.incoming-decline { background: var(--danger); }
.incoming-decline:hover { background: #f06767; }
.incoming-accept { background: var(--online); }
.incoming-accept:hover { filter: brightness(1.1); }

/* ---------- Safety: block banner ---------- */
.block-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 8%; padding: 9px 14px; border-radius: 10px;
  background: rgba(224,86,86,.14); color: var(--text-secondary); font-size: 13px;
}
.block-banner button {
  color: var(--accent); font-weight: 600; font-size: 13px; padding: 4px 8px; border-radius: 6px;
}
.block-banner button:hover { background: var(--bg-hover); }

/* ---------- Snackbar ---------- */
.snackbar {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; z-index: 400;
  max-width: 92vw; padding: 12px 18px; border-radius: 12px;
  background: var(--bg-elevated); color: var(--text); font-size: 14px;
  box-shadow: var(--shadow);
}
.snackbar button { color: var(--accent); font-weight: 700; font-size: 14px; white-space: nowrap; }
.snackbar button:hover { text-decoration: underline; }

/* ---------- Report modal ---------- */
.report-reasons { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.radio-row { display: flex; align-items: center; gap: 10px; padding: 10px 6px; cursor: pointer; border-radius: 8px; font-size: 15px; }
.radio-row:hover { background: var(--bg-hover); }
.radio-row input { accent-color: var(--accent); width: 18px; height: 18px; }
.field textarea {
  width: 100%; padding: 12px 14px; resize: vertical; min-height: 44px;
  background: var(--bg-input); border: 1.5px solid transparent;
  border-radius: 10px; color: var(--text); font-size: 15px; font-family: inherit;
}
.field textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- Add-friend / QR ---------- */
.af-tabs { display: flex; gap: 6px; padding: 4px 20px 0; }
.af-tab {
  flex: 1; padding: 9px 0; border-radius: 8px; font-size: 14px; font-weight: 500;
  color: var(--text-secondary); background: var(--bg-input);
}
.af-tab.active { background: var(--accent); color: #fff; }
.modal-body .btn-fill { width: 100%; margin-top: 10px; }
.qr-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.qr-box { width: 280px; max-width: 82vw; background: #fff; padding: 12px; border-radius: 14px; }
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-name { font-size: 15px; font-weight: 600; color: var(--text); }

/* Hide the floating language button inside the app on every screen size — it
   overlaps the sidebar/chat header buttons. Language is available via the ☰ menu. */
body.in-app .lang-btn { display: none; }

/* ---------- Compose menu (new chat / new group) ---------- */
.compose-opt {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 13px 12px; border-radius: 12px; text-align: left; transition: background .12s;
}
.compose-opt:hover { background: var(--bg-hover); }
.compose-ic {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); display: grid; place-items: center; font-size: 21px;
}
.compose-txt { display: flex; flex-direction: column; gap: 2px; }
.compose-name { font-size: 15px; font-weight: 600; color: var(--text); }
.compose-sub { font-size: 13px; color: var(--text-secondary); }

/* ---------- Profile photo (avatar upload) ---------- */
.pf-avatar-btn { position: relative; display: inline-block; border-radius: 26%; }
.pf-avatar-cam {
  position: absolute; right: -2px; bottom: -2px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg-elevated);
  display: grid; place-items: center; font-size: 14px;
}
.btn-text-accent { color: var(--accent); font-size: 13px; font-weight: 600; }
.btn-text-accent:hover { text-decoration: underline; }

/* Renewal terms + legal links shown next to the plans (App Store 3.1.2). */
.sub-terms {
  color: var(--text-tertiary); font-size: 11px; line-height: 1.6;
  margin: 14px 2px 8px;
}
.sub-terms.trial-note {
  color: var(--text-secondary); font-size: 12px; font-weight: 600;
  background: rgba(52,199,89,.1); border: 1px solid rgba(52,199,89,.3);
  border-radius: 10px; padding: 10px 12px; margin: 14px 2px 8px;
}
.sub-links { display: flex; gap: 8px; justify-content: center; font-size: 12px; margin: 0 0 10px; }
.sub-links a { color: var(--accent); }

/* Avatar cropper: the stage is the exact rounded square the avatar renders in,
   so what the user frames here is what they get. */
.crop-stage {
  position: relative;
  width: min(260px, 72vw);
  aspect-ratio: 1;
  margin: 4px auto 14px;
  border-radius: 26%;
  overflow: hidden;
  background: var(--bg-sidebar);
  cursor: grab;
  touch-action: none;      /* we handle drag + pinch ourselves */
  user-select: none;
}
.crop-stage:active { cursor: grabbing; }
.crop-canvas { display: block; width: 100%; height: 100%; }
/* Non-interactive rim so the rounded edge reads clearly against the photo. */
.crop-mask {
  position: absolute; inset: 0; pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5);
}
.crop-zoom {
  display: flex; align-items: center; gap: 10px;
  padding: 0 4px 4px; color: var(--text-tertiary); font-size: 13px;
}
.crop-zoom input[type="range"] {
  flex: 1; min-width: 0; accent-color: var(--accent); cursor: pointer;
}

/* ---------- Admin: report moderation ---------- */
.rep-card {
  border: 1px solid var(--divider); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 10px; background: var(--bg-input);
}
.rep-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.rep-reason { font-size: 15px; font-weight: 600; }
.rep-badge { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 10px; }
.rep-badge.open { color: #ffd66b; background: rgba(255,190,60,.16); }
.rep-badge.done { color: var(--text-secondary); background: var(--bg-hover); }
.rep-meta { font-size: 13px; color: var(--text-secondary); }
.rep-time { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
/* Admin dashboard stat tiles: current users / premium / monthly / yearly / banned. */
.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 4px 0 12px; }
.astat { background: var(--bg-input); border-radius: 10px; padding: 10px 6px; text-align: center; }
.astat-n { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1; }
.astat-l { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }
@media (max-width: 480px) { .admin-stats { grid-template-columns: repeat(3, 1fr); } }

/* ===== App lock (passcode / biometric) ===== */
.lock-screen {
  position: fixed; inset: 0; z-index: 4000;
  background: var(--bg-sidebar);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.lock-inner { width: 100%; max-width: 300px; display: flex; flex-direction: column; align-items: center; }
.lock-logo { font-size: 40px; margin-bottom: 10px; }
.lock-title { font-size: 17px; color: var(--text); margin-bottom: 20px; }
.lock-dots { display: flex; gap: 14px; height: 16px; margin-bottom: 8px; }
.lock-dots .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--text-secondary); box-sizing: border-box; }
.lock-dots .dot.filled { background: var(--accent); border-color: var(--accent); }
.lock-error { min-height: 18px; font-size: 13px; color: var(--danger); margin-bottom: 12px; }
.lock-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: 100%; }
.lock-key {
  aspect-ratio: 1; border-radius: 50%; background: var(--bg-input); color: var(--text);
  font-size: 24px; font-weight: 500; display: grid; place-items: center;
  user-select: none; transition: background .1s;
}
.lock-key:active { background: var(--bg-hover); }
.lock-key.blank { background: transparent; pointer-events: none; }
.lock-key.action { font-size: 15px; color: var(--text-secondary); background: transparent; }
.lock-bio-btn { margin-top: 20px; color: var(--accent); font-size: 15px; padding: 8px 14px; }

/* ===== Friends list + LINE-style add flow ===== */
.friend-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 6px;
  border-radius: 10px; cursor: pointer;
}
.friend-item:hover { background: var(--bg-hover); }
.friend-meta { flex: 1; min-width: 0; }
.friend-name { font-size: 15px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-sub { font-size: 13px; color: var(--text-tertiary); }
.friend-go { font-size: 18px; opacity: .7; }
.add-flow { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 8px 0; }
.add-flow-id { font-size: 20px; font-weight: 600; color: var(--text); word-break: break-all; }
.add-flow-name { font-size: 18px; font-weight: 600; color: var(--text); margin-top: 6px; }
.add-flow-done { font-size: 15px; color: var(--accent); margin-top: 4px; }
.rep-note { margin: 8px 0 4px; font-size: 14px; color: var(--text); }
.rep-msg {
  margin: 8px 0 4px; padding: 8px 11px; border-radius: 8px;
  background: var(--bg-hover); font-size: 14px; word-break: break-word;
}
.rep-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rep-actions button {
  padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 500;
  color: var(--accent); background: var(--bg-hover);
}
.rep-actions button:hover { background: var(--bg-active); color: #fff; }
.rep-actions button.danger { color: var(--danger); }
.rep-actions button.danger:hover { background: var(--danger); color: #fff; }

/* Native AdMob banner sits at the bottom of the screen — reserve its ACTUAL height
   (reported by the SDK into --ad-h; 56px fallback) so the composer / me-bar / the
   channel "contact" button aren't covered while a banner is shown (free tier only). */
body.has-adbanner .app { height: calc(100% - var(--ad-h, 56px)); }

/* Registration consent checkbox (must be ticked before signing up) */
.consent-check { display: flex; align-items: flex-start; gap: 9px; text-align: left; cursor: pointer; }
.consent-check input { margin-top: 2px; width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--accent); }
.consent-check span { line-height: 1.5; }
.forgot-link {
  display: block; margin: 12px auto 0; background: none; border: none;
  color: var(--accent); font-size: 13px; cursor: pointer; padding: 4px;
}
.forgot-link:hover { text-decoration: underline; }
.invite-stats { display: flex; gap: 12px; margin-top: 14px; }
.invite-stats > div { flex: 1; text-align: center; background: var(--bg-input, #1c4264); border: 1px solid var(--divider, #0d2740); border-radius: 12px; padding: 12px 8px; }
.invite-stats b { display: block; font-size: 22px; font-weight: 800; color: var(--accent); }
.invite-stats span { font-size: 12px; color: var(--text-secondary, #9bb4c8); }

/* Password field with show/hide toggle */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 8px; font-size: 17px; line-height: 1;
  display: grid; place-items: center; opacity: .75;
}
.pw-toggle:hover { opacity: 1; background: var(--bg-hover); }

/* ===================== Broadcast channels ===================== */
/* Channel create/settings modals reuse the app's switch (.toggle-row) — this
   only adds the two-line label (title + hint). It must NOT restyle the switch
   checkbox, or it would break every .toggle-row across the app. */
.chtoggle { align-items: center; padding: 11px 2px; }
.chtoggle + .chtoggle { border-top: 1px solid var(--divider); }
.chtoggle > span { display: flex; flex-direction: column; gap: 2px; }
.chtoggle small { color: var(--text-tertiary); font-size: 12px; }
.chtoggle.disabled { opacity: .55; }

/* Read-only footer for subscribers / view-only admins. */
.channel-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 14px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--divider); background: var(--bg-input);
}
.channel-bar .btn-fill { width: 100%; }
.channel-readonly { color: var(--text-tertiary); font-size: 14px; }

/* Admin list + invite buttons. */
.admin-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.admin-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px; border-bottom: 1px solid var(--divider);
}
.admin-name { font-size: 15px; }
.admin-role { font-size: 12px; color: var(--text-tertiary); background: var(--bg-input); padding: 2px 10px; border-radius: 999px; }
.ch-invite-btns { display: flex; gap: 10px; margin: 6px 0; }
.ch-invite-btns .btn-fill, .ch-invite-btns .btn-ghost { flex: 1; }

/* Operator inbox of subscriber threads. */
.inbox-list { display: flex; flex-direction: column; gap: 2px; }
.inbox-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px;
  width: 100%; text-align: left; padding: 12px 6px; border-bottom: 1px solid var(--divider);
  background: none; border-left: none; border-right: none; border-top: none; cursor: pointer;
}
.inbox-name { grid-column: 1; font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-last { grid-column: 1 / 2; color: var(--text-tertiary); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-badge {
  grid-column: 2; grid-row: 1 / 3; justify-self: end; align-self: center;
  min-width: 20px; width: max-content; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px;
  display: grid; place-items: center;
}
.compose-opt.danger .compose-name { color: var(--danger); }

/* Header Channels button: red dot when the operator has unread channel activity. */
.icon-btn.has-unread { position: relative; }
.icon-btn.has-unread::after {
  content: ''; position: absolute; top: 5px; right: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--danger); border: 2px solid var(--bg);
}
/* Channel hub: the pinned broadcast thread sits above the subscriber inbox. */
.ch-hub-cast {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  width: 100%; text-align: left; padding: 14px 12px; cursor: pointer;
  border: 1px solid var(--accent); border-radius: 12px; background: var(--bg-hover);
}
.ch-hub-cast:hover { background: var(--bg-active, var(--bg-hover)); }
.ch-hub-ic { font-size: 22px; }
.ch-hub-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ch-hub-txt b { font-size: 15px; color: var(--text); }
.ch-hub-txt small { font-size: 13px; color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== Free-trial promo banner (chat list top) ===================== */
.trial-banner {
  display: flex; align-items: center; gap: 10px; width: calc(100% - 16px);
  margin: 8px; padding: 11px 14px; border: none; cursor: pointer;
  border-radius: 12px; text-align: left; color: #fff;
  background: linear-gradient(100deg, #2b73ba, #34a5f5);
  box-shadow: 0 4px 16px rgba(52,165,245,.28);
}
.trial-banner:hover { filter: brightness(1.06); }
.trial-banner:active { transform: scale(.99); }
.trial-banner-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.trial-banner-main { font-size: 14px; font-weight: 700; }
.trial-banner-sub { font-size: 11.5px; opacity: .9; }
.trial-banner-cta {
  flex: none; font-size: 13px; font-weight: 700; padding: 6px 12px;
  background: rgba(255,255,255,.22); border-radius: 999px;
}

/* "Channel subscriber" tag — distinguishes a channel subscriber's DM from a
   normally-added friend, in the chat list row. */
.chan-sub-tag {
  flex: none; font-size: 10px; font-weight: 700; line-height: 1.4;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
  color: var(--accent); background: rgba(52,165,245,.14); border: 1px solid rgba(52,165,245,.35);
}
.channel-join-meta { color: var(--text-secondary); font-size: 13px; text-align: center; }
