/* FIBER CHAT — RTL, mobile first */
:root {
  --bg: #0e1116;
  --bg-2: #151a22;
  --bg-3: #1c232e;
  --line: #252d3a;
  --fg: #e8edf5;
  --fg-dim: #97a3b6;
  --accent: #4f8cff;
  --accent-2: #2f6bff;
  --mine: #24406e;
  --peer: #1d242f;
  --ok: #3ddc97;
  --danger: #ff6b6b;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.7 "Vazirmatn", "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
ul { list-style: none; margin: 0; padding: 0; }
svg { width: 22px; height: 22px; fill: currentColor; }
.spacer { flex: 1; }

/* ---------------- auth ---------------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.auth-card {
  width: min(420px, 100%); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 22px; padding: 22px; box-shadow: var(--shadow);
}
.brand { text-align: center; margin-bottom: 14px; }
.brand h1 { margin: 10px 0 2px; font-size: 21px; }
.brand p { margin: 0; color: var(--fg-dim); font-size: 13px; }
.brand-mark {
  inline-size: 46px; block-size: 46px; margin-inline: auto; border-radius: 14px;
  display: grid; place-items: center; font-weight: 700; font-size: 22px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #7b5cff);
}
.brand-mark.big { inline-size: 76px; block-size: 76px; font-size: 36px; border-radius: 22px; }
.tabs { display: flex; gap: 6px; background: var(--bg-3); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tab { flex: 1; padding: 9px; border: 0; border-radius: 9px; background: transparent; color: var(--fg-dim); cursor: pointer; }
.tab.active { background: var(--bg-2); color: var(--fg); font-weight: 600; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--fg-dim); margin-bottom: 5px; }
.field input, .field textarea, .field select {
  inline-size: 100%; padding: 12px 14px; background: var(--bg-3);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-3); color: var(--fg); cursor: pointer; text-decoration: none;
}
.btn.block { inline-size: 100%; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #4a2630; }
.btn:disabled { opacity: .5; pointer-events: none; }
.auth-hint { min-height: 20px; font-size: 13px; color: var(--danger); margin: 10px 0 0; text-align: center; }
.auth-hint.ok { color: var(--ok); }

/* ---------------- shell ---------------- */
.app { display: grid; grid-template-columns: 330px 1fr; block-size: 100dvh; overflow: hidden; }
.sidebar { background: var(--bg-2); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-block-size: 0; }
.side-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.me { display: flex; align-items: center; gap: 10px; min-inline-size: 0; }
.me-text { display: flex; flex-direction: column; line-height: 1.25; min-inline-size: 0; }
.me-text strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--fg-dim); font-size: 12px; }
.side-actions { margin-inline-start: auto; display: flex; gap: 2px; }
.icon-btn {
  inline-size: 40px; block-size: 40px; border: 0; border-radius: 12px; background: transparent;
  color: var(--fg-dim); cursor: pointer; display: grid; place-items: center; flex: none;
}
.icon-btn:hover { background: var(--bg-3); color: var(--fg); }
.icon-btn.on { color: var(--ok); }
.icon-btn.round { background: var(--bg-3); color: var(--fg); }
.seg { display: flex; gap: 4px; padding: 10px 12px 6px; }
.seg-btn { flex: 1; padding: 8px; border: 0; border-radius: 10px; background: transparent; color: var(--fg-dim); cursor: pointer; font-size: 14px; }
.seg-btn.active { background: var(--bg-3); color: var(--fg); font-weight: 600; }
.install-bar {
  margin: 2px 10px 6px; padding: 10px; display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg-3);
}
.install-ico { inline-size: 38px; block-size: 38px; border-radius: 10px; flex: none; }
.install-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-inline-size: 0; }
.install-text strong { font-size: 13.5px; }
.install-text span { color: var(--fg-dim); font-size: 12.5px; line-height: 1.5; }
.install-bar .btn { padding: 8px 14px; font-size: 13px; flex: none; }
.install-bar .icon-btn { inline-size: 32px; block-size: 32px; flex: none; }
.install-bar .icon-btn svg { width: 17px; height: 17px; }
.pane { flex: 1; overflow-y: auto; padding: 4px 8px 8px; min-block-size: 0; }
.chat-list li { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; cursor: pointer; }
.chat-list li:hover { background: var(--bg-3); }
.chat-list li.active { background: var(--bg-3); }
.chat-main { flex: 1; min-inline-size: 0; }
.chat-top { display: flex; align-items: baseline; gap: 6px; }
.chat-top strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-top time { margin-inline-start: auto; color: var(--fg-dim); font-size: 11.5px; white-space: nowrap; }
.chat-bottom { display: flex; align-items: center; gap: 6px; color: var(--fg-dim); font-size: 13px; }
.chat-bottom span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.badge {
  background: var(--accent); color: #fff; border-radius: 999px; font-size: 11.5px;
  min-inline-size: 20px; block-size: 20px; display: grid; place-items: center; padding: 0 5px; font-weight: 700;
}
.side-foot { padding: 10px 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.side-foot svg { inline-size: 18px; block-size: 18px; }
.empty { color: var(--fg-dim); font-size: 13.5px; text-align: center; padding: 26px 16px; }

/* ---------------- thread ---------------- */
.main { position: relative; display: flex; flex-direction: column; min-inline-size: 0; min-block-size: 0; overflow: hidden; background: var(--bg); }
.placeholder { flex: 1; display: grid; place-items: center; color: var(--fg-dim); }
.placeholder-inner { text-align: center; display: grid; gap: 14px; justify-items: center; }
.thread { display: flex; flex-direction: column; flex: 1; min-block-size: 0; }
.thread-head {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--bg-2); border-bottom: 1px solid var(--line); z-index: 2;
}
.back { display: none; }
.back svg { transform: scaleX(-1); }
.t-info { flex: 1; min-inline-size: 0; border: 0; background: transparent; text-align: start; cursor: pointer; display: flex; flex-direction: column; line-height: 1.25; }
.t-info strong { font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-info small { color: var(--fg-dim); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-info small.live { color: var(--accent); }
.dot { inline-size: 9px; block-size: 9px; border-radius: 50%; background: var(--fg-dim); flex: none; }
.dot.on { background: var(--ok); }

.scroller {
  flex: 1; overflow-y: auto; padding: 14px 12px 4px; min-block-size: 0;
  overscroll-behavior: contain; scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.scroller::-webkit-scrollbar { inline-size: 10px; }
.scroller::-webkit-scrollbar-track { background: transparent; }
.scroller::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
.scroller::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); background-clip: content-box; }
.pane::-webkit-scrollbar { inline-size: 8px; }
.pane::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.msgs { display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; color: var(--fg-dim); font-size: 11.5px; background: var(--bg-2); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; margin: 10px auto 6px; }
.older { cursor: pointer; color: var(--accent); }
.audio-line { display: flex; justify-content: space-between; gap: 8px; }
.map-controls {
  position: absolute; inset-block-start: 8px; inset-inline-end: 8px;
  display: grid; gap: 6px; z-index: 2;
}
.msg { display: flex; flex-direction: column; max-inline-size: min(78%, 520px); gap: 2px; }
.msg.peer { align-self: flex-start; }
.msg.own { align-self: flex-end; align-items: flex-end; }
.msg.system { align-self: center; max-inline-size: 90%; }
.msg.system .bubble { background: transparent; color: var(--fg-dim); font-size: 12.5px; text-align: center; padding: 2px 6px; }
.sender { font-size: 12px; color: var(--accent); font-weight: 600; padding-inline: 4px; }
.bubble {
  position: relative; padding: 8px 11px; border-radius: var(--radius);
  background: var(--peer); border: 1px solid var(--line);
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.msg.own .bubble { background: var(--mine); border-color: transparent; }
.msg.pending .bubble { opacity: .55; }
.msg.failed .bubble { border-color: var(--danger); }
.meta { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--fg-dim); margin-top: 3px; }
.msg.own .meta { justify-content: flex-end; }
.ticks { letter-spacing: -3px; font-size: 12px; color: var(--fg-dim); }
.ticks.read { color: var(--ok); }
/* media inside bubbles */
.bubble .media-img { display: block; border-radius: 12px; max-inline-size: 100%; max-block-size: 300px; cursor: zoom-in; background: var(--bg-3); }
.bubble .with-caption { margin-bottom: 5px; }
.file-chip { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.file-ico { inline-size: 40px; block-size: 40px; border-radius: 11px; background: var(--bg-3); display: grid; place-items: center; color: var(--accent); flex: none; font-size: 11px; font-weight: 700; }
.file-meta { min-inline-size: 0; }
.file-meta b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-inline-size: 220px; }
.file-meta small { color: var(--fg-dim); font-size: 12px; }

/* audio player */
.audio { display: flex; align-items: center; gap: 9px; min-inline-size: 210px; }
.play { inline-size: 38px; block-size: 38px; border-radius: 50%; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.play svg { inline-size: 17px; block-size: 17px; }
.wave { flex: 1; display: flex; flex-direction: column; gap: 5px; }
.bar { block-size: 5px; border-radius: 999px; background: var(--bg-3); overflow: hidden; cursor: pointer; }
.fill { block-size: 100%; inline-size: 0; background: var(--accent); }
.wave-bars { display: flex; align-items: center; gap: 3px; block-size: 30px; cursor: pointer; padding-block: 2px; }
.wave-bars i { flex: 1 1 0; min-inline-size: 2.5px; block-size: calc(4px + var(--h, .3) * 24px); border-radius: 999px; background: var(--fg-dim); opacity: .6; }
.wave-bars i.on { background: var(--accent); opacity: 1; }
.audio small { color: var(--fg-dim); font-size: 11.5px; }

/* message menu */
.menu-list { display: grid; gap: 8px; }
.meta .edited { font-style: italic; }
.ticks.who { cursor: pointer; }
.seen-list { display: grid; gap: 9px; max-block-size: 50vh; overflow-y: auto; }
.seen-row { display: flex; align-items: center; gap: 10px; }
.seen-row > span:first-of-type { flex: 1; }
.seen-row .st { font-size: 12px; color: var(--fg-dim); font-weight: 400; }
.seen-row .st.on { color: var(--ok); }
.muted { color: var(--fg-dim); font-size: 13px; margin: 0; }
.field-input { inline-size: 100%; padding: 12px 14px; background: var(--bg-3); border: 1px solid var(--line); border-radius: 12px; outline: none; color: var(--fg); font: inherit; resize: vertical; }
.field-input:focus { border-color: var(--accent); }

/* location */
.loc { inline-size: 240px; }
.loc .map-box { inline-size: 100%; block-size: 130px; border-radius: 12px; overflow: hidden; position: relative; background: var(--bg-3); cursor: zoom-in; }
.loc .coords { font-size: 11.5px; color: var(--fg-dim); margin-top: 4px; direction: ltr; unicode-bidi: isolate; text-align: start; }
.map-tiles { position: absolute; inset: 0; }
.map-tiles img { position: absolute; inline-size: 256px; block-size: 256px; -webkit-user-select: none; user-select: none; }
.map-pin { position: absolute; inline-size: 26px; block-size: 26px; margin-inline-start: -13px; margin-block-start: -24px; color: var(--danger); }
.map-attr { position: absolute; inset-block-end: 0; inset-inline-end: 0; font-size: 9.5px; background: rgba(0,0,0,.45); color: #fff; padding: 1px 5px; border-start-start-radius: 6px; }

/* typing */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 8px 12px; background: var(--peer); border: 1px solid var(--line); border-radius: var(--radius); margin-block-start: 4px; width: fit-content; }
.typing span { inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--fg-dim); animation: bl 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes bl { 0%, 60%, 100% { opacity: .3; transform: translateY(0) } 30% { opacity: 1; transform: translateY(-3px) } }

/* composer */
.composer { position: relative; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 7px; padding: 9px 10px calc(9px + env(safe-area-inset-bottom)); background: var(--bg-2); border-top: 1px solid var(--line); }
#input {
  flex: 1; resize: none; max-block-size: 130px; padding: 10px 13px; border-radius: 15px;
  background: var(--bg-3); border: 1px solid var(--line); outline: none; line-height: 1.5;
}
#input:focus { border-color: var(--accent); }
.attach-menu {
  position: absolute; inset-block-end: calc(100% - 2px); inset-inline-start: 10px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 14px; padding: 5px;
  box-shadow: var(--shadow); display: grid; gap: 2px; z-index: 5;
}
.attach-menu button { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; text-align: start; }
.attach-menu button:hover { background: var(--bg-3); }
.bubble .media-video { display: block; inline-size: min(280px, 100%); max-block-size: 320px; border-radius: 12px; background: #000; }
.waiting { color: var(--fg-dim); font-size: 13px; }
.emoji-pop {
  position: absolute; inset-block-end: calc(100% - 2px); inset-inline-end: 8px;
  inline-size: min(340px, calc(100% - 16px)); background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); z-index: 6; display: flex; flex-direction: column;
}
.emoji-scroll { max-block-size: 40vh; overflow-y: auto; padding: 6px 10px; }
.emoji-cat { font-size: 13px; color: var(--fg-dim); margin: 8px 2px 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 2px; }
.emoji { border: 0; background: transparent; font-size: 24px; line-height: 1; padding: 6px 0; border-radius: 10px; cursor: pointer; color: inherit; }
.emoji:hover { background: var(--bg-3); }
.emoji-bar { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.emoji-tool { flex: 1; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-3); color: var(--fg); cursor: pointer; font-size: 15px; }
.emoji-tool.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; }
.mic.recording { background: var(--danger); color: #fff; }
.recbar { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--bg-2); border-top: 1px solid var(--line); }
.rec-dot { inline-size: 11px; block-size: 11px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25 } }
.rec-meter { flex: 1; display: flex; align-items: center; gap: 3px; block-size: 26px; min-inline-size: 60px; }
.rec-meter i { flex: 1; block-size: calc(4px + var(--h, .06) * 22px); border-radius: 999px; background: var(--accent); opacity: .85; transition: block-size .09s linear; }

/* info panel */
.panel { position: absolute; inset: 0; background: var(--bg); z-index: 6; display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.panel-body { flex: 1; overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; padding: 13px; display: grid; gap: 9px; }
.card h3 { margin: 0; font-size: 14px; }
.card p { margin: 0; color: var(--fg-dim); font-size: 13px; }
.member { display: flex; align-items: center; gap: 10px; }
.member .st { margin-inline-start: auto; font-size: 12px; color: var(--fg-dim); }
.member .st.on { color: var(--ok); }
.code-box { display: flex; align-items: center; gap: 8px; }
.code {
  font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 19px; letter-spacing: 3px;
  background: var(--bg-3); border: 1px dashed var(--line); border-radius: 12px; padding: 9px 14px; direction: ltr;
}

/* avatars */
.avatar {
  inline-size: 40px; block-size: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: #fff; background: linear-gradient(135deg, #5c7cfa, #845ef7);
  overflow: hidden;
}
.avatar.sm { inline-size: 34px; block-size: 34px; font-size: 13px; }
.avatar.g { background: linear-gradient(135deg, #12b886, #0ca678); }
.avatar img { inline-size: 100%; block-size: 100%; object-fit: cover; display: block; }
.avatar.lg { inline-size: 76px; block-size: 76px; font-size: 28px; }
.av-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.av-text { display: flex; flex-direction: column; line-height: 1.3; min-inline-size: 0; }
.av-text strong { font-size: 16px; }
.av-text small { color: var(--fg-dim); }
.sec { margin: 18px 0 8px; font-size: 14px; color: var(--fg-dim); font-weight: 600; }
.field.ltr input { direction: ltr; text-align: left; }

/* sheets, modals, toast */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: grid; place-items: center; padding: 18px; z-index: 40; }
.sheet-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 18px; inline-size: min(430px, 100%); max-block-size: 86dvh; overflow-y: auto; box-shadow: var(--shadow); }
.sheet-card h2 { margin: 0 0 4px; font-size: 17px; }
.sheet-card .row { display: flex; gap: 8px; margin-top: 14px; }
.sheet-card .row .btn { flex: 1; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; cursor: pointer; }
.pick:hover { background: var(--bg-3); }
.pick input { inline-size: 18px; block-size: 18px; }
.notice { background: var(--bg-3); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--fg-dim); }
/* the generic sheet must sit above the map modal, which is a sheet itself */
#sheet { z-index: 45; }
.lightbox { position: fixed; inset: 0; background: rgba(0, 0, 0, .9); display: grid; place-items: center; z-index: 50; }
.lightbox img { max-inline-size: 96vw; max-block-size: 92vh; border-radius: 8px; }
.lb-close { position: fixed; inset-block-start: 14px; inset-inline-end: 14px; color: #fff; z-index: 2; }
.map-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; inline-size: min(560px, 100%); overflow: hidden; }
.map-card header, .map-card footer { display: flex; align-items: center; gap: 8px; padding: 11px 13px; }
.map-card footer { border-top: 1px solid var(--line); }
#map-coords { direction: ltr; unicode-bidi: isolate; color: var(--fg-dim); }
.map-stage { position: relative; inline-size: 100%; block-size: min(52vh, 380px); background: var(--bg-3); overflow: hidden; }
.map-stage .map-box { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; border-radius: 0; }
.toast {
  position: fixed; inset-block-end: calc(84px + env(safe-area-inset-bottom)); inset-inline: 14px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg); padding: 11px 14px;
  border-radius: 14px; box-shadow: var(--shadow); z-index: 60; opacity: 0; transform: translateY(14px);
  transition: .22s; pointer-events: none; text-align: center; font-size: 13.5px;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: var(--danger); color: #ffd9d9; }

/* small screens: one pane at a time */
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: absolute; inset: 0; z-index: 3; }
  .main { position: absolute; inset: 0; z-index: 4; visibility: hidden; }
  .app[data-view="thread"] .main { visibility: visible; }
  .app[data-view="thread"] .sidebar { z-index: 2; }
  .back { display: grid; }
  .msg { max-inline-size: 86%; }
}

/* ---------------- camera sheet ---------------- */
.cam { display: grid; gap: 10px; }
.cam-view { inline-size: 100%; max-block-size: 46vh; min-block-size: 180px; border-radius: 14px; background: #000; object-fit: cover; }
.cam-bar { display: flex; align-items: center; gap: 8px; }
.cam-shot { flex: 1; }
.cam-timer { color: var(--danger); font-variant-numeric: tabular-nums; }

/* ---------------- stamp editor ---------------- */
.stamp { display: grid; gap: 10px; }
.stamp-stage { position: relative; display: inline-block; max-inline-size: 100%; align-self: center; }
.stamp-preview { display: block; max-inline-size: 100%; max-block-size: 38vh; border-radius: 12px; background: #000; }
.stamp-overlay, .stamp-icon { position: absolute; white-space: pre-line; line-height: 1.35; text-shadow: 0 1px 4px rgba(0, 0, 0, .75); pointer-events: none; }
.stamp-icon { border-radius: 18%; }
.stamp-controls { display: grid; gap: 8px; }
.stamp-inner { display: grid; gap: 6px; padding-inline-start: 4px; }
.stamp-sub { color: var(--fg-dim); font-size: 12.5px; margin-block-start: 4px; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; cursor: pointer; }
.check-row input { inline-size: 18px; block-size: 18px; accent-color: var(--accent); flex: none; }
.pos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.pos-btn { padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); color: var(--fg-dim); font-size: 12px; cursor: pointer; }
.pos-btn.active { background: var(--accent); border-color: transparent; color: #fff; font-weight: 600; }
.stamp-style { display: grid; gap: 7px; }
.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch { inline-size: 26px; block-size: 26px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; }
.swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--bg-3); }
.stamp-style input[type="range"] { inline-size: 100%; accent-color: var(--accent); }
.stamp-style .btn.sm { padding: 6px 14px; min-inline-size: 40px; }
.stamp-style .btn.sm.on { background: var(--accent); color: #fff; }
.stamp-extra { display: grid; gap: 6px; border-block-start: 1px solid var(--line); padding-block-start: 9px; }
.stamp-lines { white-space: pre-line; font-size: 12.5px; line-height: 1.5; }
.save-btn { inline-size: 26px; block-size: 26px; border-radius: 8px; font-size: 13px; }
.typing .typing-who { color: var(--fg-dim); font-size: 12px; margin-inline-start: 4px; }

/* ---- calls ---- */
.call-btn svg { inline-size: 20px; block-size: 20px; }
.call {
  position: fixed; inset: 0; z-index: 60; background: #0a0d12; color: #e8edf5;
  display: flex; flex-direction: column;
}
.call-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px;
}
.call-top strong { display: block; font-size: 16px; }
.call-top small { color: #97a3b6; font-size: 12px; }
.call-timer { font-variant-numeric: tabular-nums; color: #3ddc97; font-size: 15px; }
.call-grid {
  flex: 1; position: relative; display: grid; gap: 8px;
  padding: 0 10px; overflow: hidden; grid-auto-rows: minmax(110px, 1fr);
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}
.call-grid[data-n="1"], .call-grid[data-n="2"] { grid-template-columns: 1fr; }
.call-grid[data-n="3"], .call-grid[data-n="4"] { grid-template-columns: repeat(2, 1fr); }
.call-tile {
  position: relative; min-block-size: 110px; border-radius: 14px; overflow: hidden;
  background: #151a22; display: grid; place-items: center;
}
.call-tile video { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; object-fit: cover; }
.call-grid[data-n="2"] .call-tile.me {
  position: absolute; inset-inline-start: 12px; inset-block-end: 12px; z-index: 2;
  inline-size: 30%; max-inline-size: 130px; aspect-ratio: 3 / 4;
  border: 2px solid rgba(255, 255, 255, .25);
}
.call-tag {
  position: absolute; inset-block-end: 6px; inset-inline-start: 8px; z-index: 3;
  font-size: 12px; background: rgba(0, 0, 0, .45); padding: 2px 8px; border-radius: 8px;
}
.call-avatar { inline-size: 62px; block-size: 62px; font-size: 22px; }
.call-wait { position: absolute; inset-block-start: calc(50% + 42px); color: #9fb6b2; font-size: 11.5px; }
.call-bar {
  display: flex; justify-content: center; gap: 14px;
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px));
}
.call-ctl {
  inline-size: 54px; block-size: 54px; border-radius: 50%; border: none; cursor: pointer;
  background: #222b38; color: #e8edf5; display: grid; place-items: center;
}
.call-ctl svg { inline-size: 24px; block-size: 24px; }
.call-ctl.off { background: #3a2427; color: #ff9d9d; }
.call-ctl.end { background: #ff6b6b; color: #fff; }
.ring { display: grid; gap: 10px; text-align: center; }
.ring-avatar { inline-size: 76px; block-size: 76px; font-size: 26px; margin: 6px auto; }
.ring-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-block-start: 8px; }
.call-log { display: flex; align-items: center; gap: 8px; }
.call-log.missed { color: var(--danger); }
.call-log-ico { font-size: 16px; }
.reply-preview-box {
  order: -1;                     /* own row above the input */
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  padding: 6px 10px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--accent);
  border-radius: 10px;
}
.reply-content { flex: 1; min-inline-size: 0; overflow: hidden; }
.reply-user { display: block; font-size: 12px; font-weight: 600; color: var(--accent); }
.reply-text {
  display: block; font-size: 12.5px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cancel-reply {
  border: 0; background: transparent; color: var(--fg-dim); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 8px;
}
.cancel-reply:hover { background: var(--bg); color: var(--fg); }

/* quoted reply inside a bubble */
.bubble .quote {
  display: block; inline-size: 100%; margin: 0 0 6px; padding: 5px 8px;
  text-align: start; font: inherit; color: inherit; cursor: pointer;
  background: rgba(79, 140, 255, .10);
  border: 0; border-inline-start: 3px solid var(--accent); border-radius: 8px;
}
.bubble .quote-name { display: block; font-size: 11.5px; font-weight: 600; color: var(--accent); }
.bubble .quote-text {
  display: block; font-size: 12.5px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bubble .quote.gone { opacity: .8; font-style: italic; }
.msg.flash .bubble { animation: flash-bubble 1.2s ease; }
@keyframes flash-bubble {
  0%, 100% { box-shadow: none; }
  25% { box-shadow: 0 0 0 3px rgba(79, 140, 255, .55); }
}

/* ------------------------------------------------------------------ *
 * forward stamp, forward sheet
 * ------------------------------------------------------------------ */
.msg { transition: transform .18s ease; }
.msg.swiping { transition: none; }
.bubble .fwd-head {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--fg-dim); margin-bottom: 4px;
  border-inline-start: 2px solid var(--line); padding-inline-start: 6px;
}
.bubble .fwd-head svg { inline-size: 13px; block-size: 13px; flex: none; }

.fwd-preview {
  border: 1px solid var(--line); background: var(--bg-3);
  border-inline-start: 3px solid var(--accent);
  border-radius: 12px; padding: 8px 10px; margin-bottom: 10px;
}
.fwd-preview-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.fwd-preview-who { color: var(--accent); font-weight: 600; }
.fwd-preview-kind { color: var(--fg-dim); }
.fwd-preview-txt {
  font-size: 13px; color: var(--fg-dim); margin-top: 3px;
  max-block-size: 46px; overflow: hidden;
}

.fwd-list {
  display: grid; gap: 4px; max-block-size: 42vh; overflow-y: auto;
  margin: 10px 0; padding: 2px;
}
.fwd-row {
  display: flex; align-items: center; gap: 10px; inline-size: 100%;
  padding: 9px 10px; border: 1px solid transparent; border-radius: 12px;
  background: transparent; color: inherit; text-align: start; cursor: pointer;
}
.fwd-row:hover { background: var(--bg-3); }
.fwd-row.on { background: rgba(79, 140, 255, .14); border-color: var(--accent); }
.fwd-row-text { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; line-height: 1.35; }
.fwd-row-text strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fwd-row-text small { color: var(--fg-dim); font-size: 12px; }
.fwd-tick {
  inline-size: 22px; block-size: 22px; border-radius: 50%; flex: none;
  border: 1px solid var(--line); display: grid; place-items: center;
  font-size: 13px; color: transparent;
}
.fwd-row.on .fwd-tick { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ------------------------------------------------------------------ *
 * voice: speed + scrubbing + paused recording
 * ------------------------------------------------------------------ */
.audio-line { align-items: center; gap: 8px; }
.audio-line .dur { margin-inline-start: auto; }
.speed {
  border: 1px solid var(--line); background: var(--bg-3); color: var(--fg-dim);
  border-radius: 999px; font-size: 11px; padding: 1px 7px; cursor: pointer; line-height: 1.6;
}
.speed.on { color: var(--accent); border-color: var(--accent); }
.wave-bars, .bar { touch-action: none; }
.recbar.paused .rec-dot { animation: none; background: var(--fg-dim); }
.recbar.paused #rec-time { color: var(--fg-dim); }
#rec-pause { font-size: 13px; padding: 8px 10px; }

/* ------------------------------------------------------------------ *
 * cable core key
 * ------------------------------------------------------------------ */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }
.chip {
  flex: 1 1 auto; min-inline-size: 64px; padding: 9px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-3);
  color: var(--fg-dim); font-size: 13.5px;
}
.chip.on {
  background: rgba(79, 140, 255, .16); border-color: var(--accent);
  color: var(--fg); font-weight: 600;
}
.lbl { display: block; margin-top: 12px; font-size: 12.5px; color: var(--fg-dim); }
.core-card {
  display: flex; gap: 14px; align-items: center; margin-top: 12px; padding: 12px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--bg-3);
}
.core-swatch {
  inline-size: 64px; block-size: 64px; border-radius: 16px; flex: none;
  border: 1px solid rgba(128, 128, 128, .45);
}
.core-info { display: flex; flex-direction: column; gap: 3px; min-inline-size: 0; }
.core-info strong { font-size: 18px; }
.core-color { font-size: 15px; font-weight: 600; }
.core-color b { font-weight: 500; color: var(--fg-dim); font-size: 12.5px; }
.core-meta { display: flex; gap: 10px; font-size: 12.5px; color: var(--fg-dim); flex-wrap: wrap; }
.core-lobe { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--fg-dim); }
.core-lobe i, .core-leg i {
  inline-size: 12px; block-size: 12px; border-radius: 4px; display: inline-block;
  border: 1px solid rgba(128, 128, 128, .45);
}
.core-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin-top: 8px; }
.core-cell {
  display: grid; justify-items: center; gap: 3px; padding: 7px 2px;
  border: 1px solid transparent; border-radius: 10px; background: var(--bg-2);
}
.core-cell.on { border-color: var(--accent); background: rgba(79, 140, 255, .12); }
.core-cell i {
  inline-size: 24px; block-size: 24px; border-radius: 7px;
  border: 1px solid rgba(128, 128, 128, .45);
}
.core-cell small { font-size: 10.5px; color: var(--fg-dim); }
.core-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 12px; }
.core-leg { display: inline-flex; align-items: center; gap: 5px; }
.core-leg small { font-size: 11.5px; color: var(--fg-dim); }
.muted.tiny { font-size: 11.5px; line-height: 1.6; margin-top: 10px; }
/* composer: one row, input takes the rest (send is the outermost button) */
.composer { flex-wrap: nowrap; }
#input { flex: 1 1 0; min-inline-size: 0; }
.composer .icon-btn { flex: none; }
/* group members: header row, role tag, per-row actions */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-head h3 { margin: 0; }
.member-name { display: flex; align-items: center; gap: 6px; flex: 1; min-inline-size: 0; }
.member-name .tag {
  font-size: 10.5px; font-weight: 600; color: var(--accent);
  background: rgba(79, 140, 255, .14); border-radius: 6px; padding: 0 5px; flex: none;
}
.member-acts { display: flex; gap: 2px; margin-inline-start: 4px; }
.icon-btn.tiny { inline-size: 30px; block-size: 30px; font-size: 14px; }
.icon-btn.tiny.danger { color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; }
/* core tool v2: two modes, range list, fusion pairs */
.core-tabs { margin-bottom: 2px; }
.core-tabs .chip { flex: 1; }
.core-pane { display: grid; gap: 2px; }
.core-picker { display: grid; gap: 2px; }
.core-input-card {
  border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  background: var(--bg-2); margin-top: 10px;
}
.core-input-card h3 { margin: 0 0 4px; font-size: 13.5px; color: var(--accent); }
.core-rows { display: grid; gap: 6px; max-block-size: 42vh; overflow-y: auto; margin-top: 8px; }
.core-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg-2);
}
.core-row > i { inline-size: 26px; block-size: 26px; border-radius: 8px; flex: none; border: 1px solid rgba(128,128,128,.45); }
.core-row-name { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-inline-size: 0; }
.core-row-name strong { font-size: 13.5px; }
.core-row-name small { color: var(--fg-dim); font-size: 11.5px; }
.core-row-color { font-size: 12px; color: var(--fg-dim); white-space: nowrap; }
.core-sum { font-size: 12.5px; color: var(--fg-dim); margin: 6px 0 0; }
.pair-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.pair-list { display: grid; gap: 6px; max-block-size: 46vh; overflow-y: auto; margin-top: 8px; }
.pair-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px;
  padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2);
}
.pair-side { display: flex; align-items: center; gap: 7px; min-inline-size: 0; }
.pair-dot { inline-size: 22px; block-size: 22px; border-radius: 7px; flex: none; border: 1px solid rgba(128,128,128,.45); }
.pair-text { display: flex; flex-direction: column; line-height: 1.25; min-inline-size: 0; }
.pair-tag { font-size: 9.5px; font-weight: 600; color: var(--fg-dim); }
.pair-text strong { font-size: 13px; }
.pair-text small { font-size: 10.5px; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pair-arrow { color: var(--accent); font-size: 15px; }
.pair-warn { color: #e9a23b; font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.pair-ok { color: var(--ok); font-size: 12px; margin: 8px 0 0; }
.pair-text small { font-size: 10px; line-height: 1.35; white-space: normal; overflow: visible; text-overflow: clip; }
.pair-row { align-items: start; }
.pair-side { align-items: flex-start; }
.pair-arrow { align-self: center; }
/* reply bar: one compact line above the composer; the input keeps its full row */
.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  align-items: end;
  row-gap: 6px;
}
.reply-preview-box {
  order: -1;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0 4px 0 9px;
  block-size: 31px;
  box-sizing: border-box;
  min-inline-size: 0;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--accent);
  border-radius: 9px;
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
}
.reply-preview-box:active { filter: brightness(.96); }
.reply-preview-box:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.reply-ico { flex: none; color: var(--accent); font-size: 13px; line-height: 1; }
.reply-content {
  flex: 1;
  min-inline-size: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.35;
}
.reply-user {
  display: block;
  flex: none;
  max-inline-size: 40%;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-sep { flex: none; color: var(--fg-dim); font-size: 12px; opacity: .7; }
.reply-text {
  display: block;
  flex: 1;
  min-inline-size: 0;
  font-size: 12.5px;
  color: var(--fg-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cancel-reply { flex: none; font-size: 16px; padding: 0 6px; }
@media (max-width: 360px) { .reply-user { max-inline-size: 34%; } }
/* the writing box never collapses below one comfortable line */
#input { min-block-size: 44px; }
/* ================= auth 2.0 — turquoise glass ================= */
#auth {
  position: relative;
  isolation: isolate;
  min-block-size: 100dvh;
  display: grid;
  place-items: center;
  padding: 26px 18px calc(26px + env(safe-area-inset-bottom));
  overflow: hidden;
  color: #e9fbf7;
  background:
    radial-gradient(120% 85% at 100% 0%, #0b3b38 0%, transparent 58%),
    radial-gradient(110% 90% at 0% 100%, #062b2e 0%, transparent 60%),
    linear-gradient(180deg, #04100f, #061a19 55%, #030c0c);
}
#auth::before {
  content: "";
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 255, 238, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 255, 238, .05) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(72% 62% at 50% 44%, #000 18%, transparent 76%);
  mask-image: radial-gradient(72% 62% at 50% 44%, #000 18%, transparent 76%);
}
#auth::after {
  content: "";
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 80% 70% at 50% 45%, transparent 35%, rgba(0, 0, 0, .45) 100%);
}
#auth .auth-scene { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
#auth .auth-scene::after {
  content: "";
  position: absolute;
  inset-block-start: 50%; inset-inline-start: 50%;
  inline-size: 78vmin; block-size: 78vmin;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 224, 196, .30), rgba(20, 184, 166, .12) 45%, transparent 70%);
  filter: blur(30px);
}

/* moving light bars */
#auth .beam {
  position: absolute;
  inset-block: -30%;
  inset-inline-start: -30%;
  inline-size: 120px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(120, 255, 238, .10) 38%,
    rgba(190, 255, 246, .30) 48%,
    rgba(255, 255, 255, .38) 50%,
    rgba(190, 255, 246, .30) 52%,
    rgba(120, 255, 238, .10) 62%,
    transparent 100%);
  transform: rotate(14deg);
  filter: blur(7px);
  mix-blend-mode: screen;
  animation: beam-run 13s linear infinite;
  will-change: transform;
}
#auth .b1 { animation-duration: 14s; animation-delay: -2s; }
#auth .b2 {
  inline-size: 2px;
  filter: blur(.2px) drop-shadow(0 0 10px rgba(47, 224, 196, .8));
  background: linear-gradient(180deg, transparent, rgba(210, 255, 248, .85) 22%, rgba(255, 255, 255, .95) 50%, rgba(160, 255, 240, .7) 78%, transparent);
  animation-duration: 17s;
  animation-delay: -8s;
}
#auth .b3 { animation-duration: 20s; animation-delay: -13s; inline-size: 70px; opacity: .8; }
@keyframes beam-run {
  0%   { transform: translate3d(-24vw, 0, 0) rotate(14deg); }
  100% { transform: translate3d(112vw, 0, 0) rotate(14deg); }
}

/* drifting glow blobs */
#auth .orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .6; }
#auth .o1 {
  inline-size: 46vmax; block-size: 46vmax;
  inset-block-start: -18vmax; inset-inline-end: -12vmax;
  background: radial-gradient(circle at 40% 40%, rgba(47, 224, 196, .55), transparent 66%);
  animation: drift 22s ease-in-out infinite alternate;
}
#auth .o2 {
  inline-size: 40vmax; block-size: 40vmax;
  inset-block-end: -16vmax; inset-inline-start: -14vmax;
  background: radial-gradient(circle at 60% 50%, rgba(14, 165, 165, .5), transparent 68%);
  animation: drift 27s ease-in-out infinite alternate-reverse;
}
@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-4vmax, 4vmax, 0) scale(1.14); }
}

/* glass card */
#auth .auth-card {
  position: relative;
  z-index: 2;
  inline-size: min(428px, 100%);
  padding: 24px 22px 16px;
  border-radius: 26px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, .045) 44%, rgba(20, 184, 166, .10) 100%);
  border: 1px solid rgba(196, 255, 246, .22);
  box-shadow:
    0 40px 90px -32px rgba(0, 0, 0, .95),
    0 0 70px -34px rgba(47, 224, 196, .75),
    inset 0 1px 0 rgba(255, 255, 255, .26),
    inset 0 -1px 0 rgba(255, 255, 255, .05);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  backdrop-filter: blur(24px) saturate(140%);
  overflow: hidden;
}
#auth .auth-card::before {
  content: "";
  position: absolute; inset-block-start: 0; inset-inline: 16%;
  block-size: 1px;
  background: linear-gradient(90deg, transparent, rgba(190, 255, 246, .85), transparent);
}
/* a slow sheen travelling over the glass */
#auth .auth-card::after {
  content: "";
  position: absolute;
  inset-block: -30%;
  inset-inline: -45%;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(104deg,
    transparent 42%,
    rgba(255, 255, 255, .07) 47%,
    rgba(190, 255, 246, .16) 50%,
    rgba(255, 255, 255, .06) 53%,
    transparent 58%);
  animation: card-sheen 9s ease-in-out infinite;
}
@keyframes card-sheen {
  0%   { transform: translateX(-55%); opacity: 0; }
  12%  { opacity: 1; }
  78%  { opacity: 1; }
  100% { transform: translateX(55%); opacity: 0; }
}
#auth .auth-card > * { position: relative; z-index: 1; }
#auth .brand { text-align: center; margin: 0 0 16px; }
#auth .brand-mark {
  inline-size: 52px; block-size: 52px; margin: 2px auto 0; border-radius: 17px;
  display: grid; place-items: center;
  color: #03211e;
  background: linear-gradient(140deg, #8bf7e6, #2fe0c4 46%, #10b3a9);
  box-shadow:
    0 12px 30px -10px rgba(47, 224, 196, .85),
    inset 0 1px 0 rgba(255, 255, 255, .65),
    inset 0 -6px 14px -8px rgba(0, 60, 52, .5);
}
#auth .brand-mark svg { inline-size: 27px; block-size: 27px; fill: none; stroke: currentColor; stroke-width: 1.8; }
#auth .brand h1 { margin: 10px 0 2px; font-size: 21px; letter-spacing: -.2px; color: #f2fffc; }
#auth .brand p { margin: 0; font-size: 12.5px; color: #9ec8c1; }

/* segmented glass tabs */
#auth .tabs {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(190, 255, 245, .12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
#auth .tab-glide {
  position: absolute;
  z-index: 0;
  inset-block: 4px;
  inset-inline-start: 4px;
  inline-size: calc(50% - 6px);
  border-radius: 11px;
  background: linear-gradient(140deg, #8bf7e6, #2fe0c4 60%, #12bdb1);
  box-shadow: 0 8px 20px -8px rgba(47, 224, 196, .9), inset 0 1px 0 rgba(255, 255, 255, .55);
  transition: inset-inline-start .28s cubic-bezier(.4, 0, .2, 1);
}
#auth .tabs.reg .tab-glide { inset-inline-start: calc(50% + 2px); }
#auth .tab {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 9px 0;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #9ec8c1;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: color .2s;
}
#auth .tab.active { color: #04211e; }

/* glass fields */
#auth .field { display: block; margin: 0 0 12px; }
#auth .field-label { display: block; margin: 0 4px 6px; font-size: 12px; color: #9ec8c1; }
#auth .input-wrap {
  display: grid;
  grid-template-columns: 21px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  block-size: 52px;
  padding-inline: 14px 6px;
  border-radius: 15px;
  border: 1px solid rgba(190, 255, 245, .16);
  background: rgba(255, 255, 255, .045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
  transition: border-color .2s, box-shadow .24s, background .2s;
}
#auth .field.auth-field .input-wrap { display: grid; }
#auth .input-wrap:focus-within {
  border-color: rgba(47, 224, 196, .7);
  background: rgba(47, 224, 196, .075);
  box-shadow: 0 0 0 3px rgba(47, 224, 196, .14), inset 0 1px 0 rgba(255, 255, 255, .1);
}
#auth .field-icon { inline-size: 20px; block-size: 20px; fill: none; stroke: #7fbcb4; stroke-width: 1.7; }
#auth .input-wrap:focus-within .field-icon { stroke: #2fe0c4; }
#auth .input-wrap input {
  inline-size: 100%;
  min-inline-size: 0;
  block-size: 100%;
  padding: 0;
  border: 0;
  outline: none;
  background: none;
  color: #eafffb;
  font-size: 14.5px;
}
#auth .input-wrap input::placeholder { color: #6f9d97; opacity: 1; }
#auth #a-pass, #auth #a-user { padding-inline-start: 0; }
#auth input[dir="ltr"] { text-align: left; letter-spacing: .2px; }

#auth .eye-toggle {
  inline-size: 40px; block-size: 40px;
  display: grid; place-items: center;
  border: 0; border-radius: 11px;
  background: transparent;
  color: #8fc7c0;
  cursor: pointer;
  transition: color .2s, background .2s;
}
#auth .eye-toggle:hover, #auth .eye-toggle.on { color: #2fe0c4; background: rgba(47, 224, 196, .12); }
#auth .eye-toggle svg { inline-size: 21px; block-size: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; }

#auth .caps-hint {
  display: inline-flex; align-items: center; gap: 5px;
  margin: 6px 4px 0;
  font-size: 11.5px; color: #ffd08a;
}
#auth .caps-hint svg { inline-size: 13px; block-size: 13px; fill: none; stroke: currentColor; stroke-width: 1.7; }

/* password strength (register) */
#auth .strength { display: flex; align-items: center; gap: 6px; margin: -2px 0 12px; }
#auth .strength i {
  flex: 1; block-size: 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .13);
  transition: background .25s, box-shadow .25s;
}
#auth .strength-label { flex: none; font-size: 10.5px; color: #7fb3ac; min-inline-size: 52px; text-align: end; }
#auth .strength[data-score="1"] i:nth-child(-n+1) { background: #ff8a8a; box-shadow: 0 0 8px rgba(255, 138, 138, .5); }
#auth .strength[data-score="2"] i:nth-child(-n+2) { background: #ffcc7a; box-shadow: 0 0 8px rgba(255, 204, 122, .45); }
#auth .strength[data-score="3"] i:nth-child(-n+3) { background: #7fe3cf; box-shadow: 0 0 8px rgba(127, 227, 207, .45); }
#auth .strength[data-score="4"] i:nth-child(-n+4) { background: #2fe0c4; box-shadow: 0 0 10px rgba(47, 224, 196, .6); }

/* submit */
#auth .auth-submit {
  position: relative;
  inline-size: 100%;
  block-size: 52px;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border: 1px solid rgba(160, 255, 240, .55);
  border-radius: 15px;
  background: linear-gradient(135deg, #8bf7e6 0%, #35e3c8 46%, #10b3a9 100%);
  color: #03211e;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  box-shadow:
    0 16px 36px -16px rgba(47, 224, 196, .95),
    inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .16s, box-shadow .22s, filter .2s;
}
#auth .auth-submit:hover { filter: brightness(1.05); transform: translateY(-1px); }
#auth .auth-submit:active { transform: translateY(1px) scale(.996); }
#auth .auth-submit:disabled { opacity: .8; cursor: default; }
#auth .auth-submit .spinner {
  display: none;
  inline-size: 17px; block-size: 17px;
  border-radius: 50%;
  border: 2px solid rgba(3, 33, 30, .28);
  border-top-color: #03211e;
  animation: auth-spin .7s linear infinite;
}
#auth .auth-submit.is-loading .spinner { display: block; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

#auth .auth-hint {
  min-block-size: 18px;
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.8;
  text-align: center;
  color: #ff9aa6;
}
#auth .auth-hint.ok { color: #4ee6c9; }
#auth .auth-hint.shake { animation: auth-shake .34s ease; }
@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-3px); }
  85% { transform: translateX(2px); }
}

#auth .auth-foot {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 12px 0 0;
  font-size: 11px;
  color: #79a8a1;
}
#auth .auth-foot .dot {
  inline-size: 5px; block-size: 5px; border-radius: 50%;
  background: #2fe0c4;
  box-shadow: 0 0 8px rgba(47, 224, 196, .9);
}

#auth .tab:focus-visible, #auth .auth-submit:focus-visible,
#auth .eye-toggle:focus-visible, #auth .input-wrap input:focus-visible {
  outline: 2px solid rgba(47, 224, 196, .85);
  outline-offset: 3px;
}
#auth .input-wrap input:focus-visible { outline: none; }

@media (max-width: 420px) {
  #auth { padding: 18px 12px calc(18px + env(safe-area-inset-bottom)); }
  #auth .auth-card { padding: 20px 16px 14px; border-radius: 22px; }
  #auth .brand h1 { font-size: 19px; }
  #auth .field-input, #auth .input-wrap { block-size: 50px; }
}
@media (max-height: 680px) {
  #auth .brand { margin-bottom: 12px; }
  #auth .brand-mark { inline-size: 44px; block-size: 44px; border-radius: 14px; }
  #auth .brand h1 { font-size: 18px; margin-top: 8px; }
  #auth .field { margin-bottom: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  #auth .beam, #auth .orb, #auth .tab-glide, #auth .auth-hint.shake { animation: none !important; transition: none !important; }
  #auth .beam { opacity: .35; }
}
/* the old .field > span rule must not shrink the glass input wrapper */
#auth .field > .input-wrap { margin-bottom: 0; font-size: inherit; }
/* keep the auth scene dark even when the app follows a light colour scheme */
#auth { color-scheme: dark; }
#auth .input-wrap input:-webkit-autofill,
#auth .input-wrap input:-webkit-autofill:hover,
#auth .input-wrap input:-webkit-autofill:focus {
  -webkit-text-fill-color: #eafffb;
  caret-color: #eafffb;
  box-shadow: inset 0 0 0 100px rgba(47, 224, 196, .10);
  transition: background-color 9999s ease-in-out 0s;
}
/* connection problems: say what is wrong instead of a bare "Failed to fetch" */
#auth .auth-net {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 138, 148, .35);
  background: rgba(255, 90, 100, .09);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  color: #ffd4d8;
  text-align: start;
}
#auth .auth-net-head { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: #ffb3ba; }
#auth .auth-net-head svg { inline-size: 16px; block-size: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; }
#auth .auth-net p { margin: 5px 0 8px; font-size: 11.5px; line-height: 1.85; color: #f3c3c8; }
#auth .auth-net-retry {
  padding: 5px 12px;
  border-radius: 9px;
  border: 1px solid rgba(255, 160, 168, .45);
  background: rgba(255, 255, 255, .07);
  color: #ffe3e6;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
#auth .auth-net-retry:hover { background: rgba(255, 255, 255, .12); }
#auth .auth-net-retry:disabled { opacity: .6; cursor: default; }
/* stamp preview: the stage is exactly the photo, so the text lands on the picture */
.stamp-stage {
  position: relative;
  display: block;
  margin-inline: auto;
  inline-size: 100%;
  max-inline-size: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.stamp-preview {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  max-inline-size: none;
  max-block-size: none;
  object-fit: fill;
  border-radius: 12px;
  background: #000;
}

/* map picker: search, zoom buttons, live centre */
.map-search { display: flex; gap: 8px; margin: 2px 0 8px; }
.map-search input {
  flex: 1;
  min-inline-size: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg);
  outline: none;
}
.map-search input:focus { border-color: var(--accent); }
.map-results {
  display: grid;
  gap: 3px;
  max-block-size: 176px;
  overflow-y: auto;
  margin-block-end: 8px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-2);
}
.map-results .notice { margin: 6px; }
.map-result {
  display: grid;
  gap: 2px;
  text-align: start;
  padding: 7px 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}
.map-result:hover, .map-result:focus-visible { background: var(--bg-3); }
.map-result strong { font-size: 13px; font-weight: 600; }
.map-result small { font-size: 11px; line-height: 1.5; color: var(--fg-dim); }
.map-pick { block-size: min(52vh, 360px); border-radius: 14px; }
.map-bar {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: 3;
  display: grid;
  gap: 6px;
}
.map-zoom {
  inline-size: 38px;
  block-size: 38px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .28);
}
.map-zoom:hover { background: var(--bg-3); }
.map-info { font-size: 11.5px; color: var(--fg-dim); margin: 7px 2px 0; line-height: 1.7; }
@media (max-width: 420px) {
  .map-pick { block-size: min(46vh, 320px); }
}
/* coordinates must read left-to-right inside the Persian sentence */
.map-info .map-coords { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.map-info .map-sep { color: var(--fg-dim); }
/* map modal controls must stay readable on top of the tiles */
.map-stage .map-controls .icon-btn.round,
.map-controls .icon-btn.round {
  inline-size: 38px; block-size: 38px; display: grid; place-items: center;
  border-radius: 11px; border: 1px solid rgba(0,0,0,.14);
  background: #fff; color: #1d2733; font-size: 18px; line-height: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); cursor: pointer;
}
.map-controls .icon-btn.round:hover { background: #eef3f7; }
/* keep the picker compact enough that the send button stays on screen */
.map-search input { font-size: 16px; }
.map-results { max-block-size: 150px; }
.map-pick { block-size: min(44vh, 320px); }

/* ---------------- message selection + floating toolbar ---------------- */
.bubble-text {
  -webkit-user-select: text;
  user-select: text;
  cursor: text;
}
.selbar {
  position: fixed;
  z-index: 80;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
  animation: selbar-in .13s ease-out;
}
@keyframes selbar-in { from { opacity: 0; transform: translateY(4px) scale(.97); } }
.sel-btn {
  border: 0;
  background: transparent;
  color: var(--fg);
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
}
.sel-btn:hover, .sel-btn:focus-visible { background: var(--bg-3); }
.sel-btn.more { font-weight: 700; letter-spacing: 1px; }

/* coordinates inside a message open the map */
.geo-link {
  display: inline;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
}
.geo-link:hover { text-decoration-style: solid; }

/* ---------------- map themes + my location dot ---------------- */
.map-themes { display: flex; gap: 6px; padding: 8px 0 6px; overflow-x: auto; }
.map-theme {
  flex: none;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg-dim);
  font-size: 12.5px;
  cursor: pointer;
}
.map-theme.on { background: var(--accent); border-color: transparent; color: #fff; }
.map-me {
  position: absolute;
  inline-size: 15px;
  block-size: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  background: #2f7cf6;
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(47, 124, 246, .5), 0 2px 6px rgba(0, 0, 0, .35);
  z-index: 2;
  pointer-events: none;
  animation: me-pulse 2.2s ease-out infinite;
}
@keyframes me-pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 124, 246, .55), 0 2px 6px rgba(0, 0, 0, .35); }
  70% { box-shadow: 0 0 0 14px rgba(47, 124, 246, 0), 0 2px 6px rgba(0, 0, 0, .35); }
  100% { box-shadow: 0 0 0 0 rgba(47, 124, 246, 0), 0 2px 6px rgba(0, 0, 0, .35); }
}

/* ---------------- pro camera ---------------- */
.cam { display: grid; gap: 10px; }
.cam-head { display: flex; align-items: center; gap: 8px; }
.cam-icon {
  inline-size: 38px;
  block-size: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(10, 14, 20, .55);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.cam-icon.on { background: var(--accent); border-color: transparent; }
.cam-stage {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
  block-size: min(58vh, 560px);
  touch-action: none;
}
.cam-view {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  max-block-size: none;
  object-fit: cover;
  transform-origin: center;
  transition: transform .12s linear;
}
.cam-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, .32) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, .32) 1px, transparent 1px);
  background-size: 33.333% 33.333%;
}
.cam-top {
  position: absolute;
  inset-block-start: 10px;
  inset-inline: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.cam-zoom {
  position: absolute;
  inset-block-end: 10px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}
.cam-zoom-btn {
  min-inline-size: 44px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(8, 12, 18, .5);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.cam-zoom-btn.on { background: #fff; color: #111; border-color: #fff; }
.cam-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.cam-shutter {
  inline-size: 66px;
  block-size: 66px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, .9);
  background: var(--accent);
  justify-self: center;
  cursor: pointer;
}
.cam-shutter.busy { background: var(--danger); border-radius: 18px; }
.cam-timer { justify-self: end; color: var(--danger); font-variant-numeric: tabular-nums; font-size: 13px; }

/* ---------------- hold-to-record voice ---------------- */
.rec-hint { display: none; font-size: 11.5px; color: var(--fg-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recbar.hold .rec-hint { display: inline; }
.recbar.hold #rec-pause, .recbar.hold #rec-cancel, .recbar.hold #rec-send { display: none; }
.recbar.cancel { background: rgba(255, 79, 106, .14); border-top-color: rgba(255, 79, 106, .5); }
.recbar.cancel .rec-dot { background: var(--danger); }
.recbar.cancel #rec-hint, .recbar.cancel #rec-time { color: var(--danger); }
.mic.press { transform: scale(1.07); }
.mic:active { transform: scale(1.07); }
.composer.rec-live #input,
.composer.rec-live #btn-attach,
.composer.rec-live #btn-emoji { opacity: .4; }
.composer.rec-live #input { cursor: not-allowed; }

.geo-link { direction: ltr; unicode-bidi: isolate; }

.cam-top { inset-block-start: 10px; inset-inline: 10px; justify-content: flex-start; }
.cam-zoom { inset-inline-start: auto; left: 50%; transform: translateX(-50%); }

.msg { touch-action: pan-y; }
.msg.swiping { transition: none; }
.pick-badge { position: absolute; inset-block-start: 6px; inset-inline-start: 6px; inline-size: 20px; block-size: 20px; border-radius: 50%; border: 2px solid var(--accent); background: var(--bg-2); display: grid; place-items: center; font-size: 12px; color: #fff; z-index: 3; }
.msg.picked .pick-badge { background: var(--accent); }
.msg.picked .bubble { box-shadow: 0 0 0 2px var(--accent); }
.msg { position: relative; }
/* ---------------- chat tabs ---------------- */
.chat-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin: 0 12px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line);
}
.chat-tab {
  flex: 1;
  padding: 7px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--fg-dim);
  font-size: 12.5px;
  cursor: pointer;
}
.chat-tab.active { background: var(--accent); color: #04201d; font-weight: 700; }

.pin-mark { display: inline-grid; place-items: center; margin-inline-end: 5px; color: var(--accent); vertical-align: -2px; }
.chat-list li.pinned { background: rgba(47, 214, 192, .06); }

/* ---------------- add contact ---------------- */
.add-contact { display: flex; gap: 8px; padding: 0 12px 10px; }
.add-contact input {
  flex: 1;
  min-inline-size: 0;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg);
  font-size: 16px;
  outline: none;
}
.add-contact input:focus { border-color: var(--accent); }
.icon-btn.tiny { inline-size: 26px; block-size: 26px; font-size: 12px; opacity: .6; }

/* ---------------- picking several messages ---------------- */
.pickbar {
  position: fixed;
  inset-inline: 10px;
  inset-block-end: calc(76px + env(safe-area-inset-bottom));
  z-index: 75;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(8, 26, 25, .9);
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.pick-count { font-size: 12.5px; color: var(--accent); margin-inline-end: auto; }
.pick-btn {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
}
.pick-btn.danger { color: var(--danger); border-color: rgba(255, 107, 107, .35); }
.pick-btn.ghost { background: transparent; }

/* ---------------- bigger avatar on tap ---------------- */
.avatar.huge { inline-size: 132px; block-size: 132px; font-size: 46px; margin: 10px auto 16px; }
.avatar-big-box { text-align: center; }

/* ---------------- optical loss tool ---------------- */
.loss { display: grid; gap: 12px; }
.loss-result {
  display: grid;
  gap: 2px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  text-align: center;
}
.loss-result .loss-value { font-size: 26px; font-variant-numeric: tabular-nums; direction: ltr; }
.loss-result .loss-label { font-size: 13px; font-weight: 700; }
.loss-result .loss-detail { color: var(--fg-dim); font-size: 11.5px; }
.loss-note { font-size: 11.5px; color: var(--fg-dim); }
.loss-result.hot { border-color: #3ddc97; background: rgba(61, 220, 151, .16); }
.loss-result.hot .loss-label { color: #7cf0bb; }
.loss-result.hot .loss-note { color: #ffd166; font-weight: 600; }
.loss-result.good { border-color: #2fd6a0; background: rgba(47, 214, 160, .12); }
.loss-result.good .loss-label { color: #46e0ae; }
.loss-result.mid { border-color: #e7c94a; background: rgba(231, 201, 74, .12); }
.loss-result.mid .loss-label { color: #e7c94a; }
.loss-result.weak { border-color: #ffa62b; background: rgba(255, 166, 43, .14); }
.loss-result.weak .loss-label { color: #ffb457; }
.loss-result.bad { border-color: #ff5c5c; background: rgba(255, 92, 92, .14); }
.loss-result.bad .loss-label { color: #ff7b7b; }

.loss-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.num-field { display: grid; gap: 4px; min-inline-size: 0; }
.num-label { font-size: 11.5px; color: var(--fg-dim); }
.num-line { display: flex; align-items: center; gap: 4px; }
.num-btn {
  inline-size: 30px;
  block-size: 30px;
  flex: none;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.num-btn.danger { color: var(--danger); }
.num-input {
  flex: 1;
  min-inline-size: 0;
  inline-size: 100%;
  padding: 7px 6px;
  text-align: center;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  font: inherit;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.num-unit { font-size: 10.5px; color: var(--fg-dim); }
.loss-sub { display: flex; align-items: center; justify-content: space-between; }
.split-list { display: grid; gap: 8px; }
.split-row {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}
.split-top { display: flex; align-items: center; gap: 8px; }
.split-top .split-ratio { flex: 1; }
.split-nums { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.split-ratio {
  padding: 8px 6px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  font-size: 12.5px;
}

/* smaller action rows: five main actions, the rest behind ⋯ */
.menu-list { gap: 5px; }
.menu-list .btn.block {
  padding: 9px 12px;
  font-size: 13px;
  border-radius: 10px;
  text-align: start;
}
/* ---------------- theme: same turquoise glass as the login ---------------- */
:root {
  --bg: #04100f;
  --bg-2: #081a19;
  --bg-3: #0f2725;
  --line: #1b3a37;
  --fg: #e6fbf7;
  --fg-dim: #8fb3ae;
  --accent: #2fd6c0;
  --accent-2: #17a892;
  --mine: #0e3b36;
  --peer: #0c2220;
  --ok: #3ddc97;
  --danger: #ff6b6b;
  --shadow: 0 10px 28px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
body {
  background:
    radial-gradient(120% 85% at 100% 0%, #0a3330 0%, transparent 55%),
    radial-gradient(110% 90% at 0% 100%, #052a2b 0%, transparent 60%),
    linear-gradient(180deg, #04100f, #061a19 55%, #030c0c);
  background-attachment: fixed;
}
.sidebar, .thread-head, .composer, .side-head, .side-foot {
  background: rgba(8, 26, 25, .82);
  background: color-mix(in srgb, var(--bg-2) 82%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
/* the thread sits on its own glass layer: on a phone the sidebar is right behind it */
.main {
  background:
    radial-gradient(120% 85% at 100% 0%, #0a3330 0%, rgba(4, 16, 15, 1) 62%),
    radial-gradient(110% 90% at 0% 100%, #052a2b 0%, rgba(4, 16, 15, 1) 60%),
    linear-gradient(180deg, #04100f, #061a19 55%, #030c0c);
}
.brand-mark { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #032220; }
.btn.primary { color: #032220; }
.badge { background: var(--accent); color: #032220; }
.play { color: #032220; }
.chat-list li.active { background: rgba(47, 214, 192, .16); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.seg-btn.active { color: #032220; }
/* ---------------- call: audio sink, speaker, talking badge ---------------- */
.call-audio { position: absolute; inline-size: 0; block-size: 0; overflow: hidden; }
.call-bar { flex-wrap: wrap; gap: 10px; }
.call-ctl { inline-size: 48px; block-size: 48px; }
.call-ctl svg { inline-size: 22px; block-size: 22px; }
.call-ctl.hidden { display: none; }
.call-tile.talking { box-shadow: 0 0 0 2px #2fd6c0 inset, 0 0 16px rgba(47, 214, 192, .5); }
.call-wave { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; display: flex; align-items: flex-end; gap: 2px; height: 16px; opacity: 0; transition: opacity .18s; }
.call-tile.talking .call-wave { opacity: 1; }
.call-wave i { inline-size: 3px; border-radius: 999px; background: #2fd6c0; height: calc(4px + var(--lv, .2) * 12px); animation: callWave .7s ease-in-out infinite alternate; }
.call-wave i:nth-child(2) { animation-delay: .18s; height: calc(6px + var(--lv, .2) * 12px); }
.call-wave i:nth-child(3) { animation-delay: .36s; }
@keyframes callWave { from { transform: scaleY(.55); } to { transform: scaleY(1); } }
/* ---------------- accounts: email, codes, numeric id ---------------- */
.auth-link {
  display: block;
  margin: 2px auto 10px;
  border: 0;
  background: transparent;
  color: #8fe9dd;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-decoration: underline dotted;
  opacity: .9;
}
.code-input { letter-spacing: .5em; text-align: center; font-size: 19px; font-variant-numeric: tabular-nums; }
.captcha-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.captcha-q {
  padding: 9px 12px;
  border-radius: 11px;
  background: rgba(47, 214, 192, .12);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 15px;
  direction: ltr;
  font-variant-numeric: tabular-nums;
}
.captcha-a { flex: 1; min-inline-size: 0; max-inline-size: 110px; text-align: center; direction: ltr; }
.ok-text { color: var(--ok); }
.email-verify { display: grid; gap: 8px; margin-block-start: 8px; }

.uid-tag { color: var(--accent); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.mail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
  font-size: 12.5px;
  color: var(--fg-dim);
  direction: ltr;
  justify-content: flex-start;
}
.mail-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.mail-row b { color: var(--danger); font-weight: 600; }
.mail-row b.ok { color: var(--ok); }
.btn.sm { padding: 7px 10px; font-size: 12px; }
/* ---------------- swipe to reply: visible feedback under the bubble ---------------- */
.msg { position: relative; touch-action: pan-y; }
.msg.swiping { transition: none; }
.msg.swiping::before {
  content: "↩";
  position: absolute;
  inset-inline-start: -2px;
  inset-block-start: 50%;
  transform: translateY(-50%) scale(.7);
  inline-size: 26px;
  block-size: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(47, 214, 192, .18);
  color: var(--accent);
  font-size: 15px;
  opacity: 0;
  transition: opacity .12s, transform .12s;
  pointer-events: none;
}
.msg.swiping::before { opacity: 1; transform: translateY(-50%) scale(1); }
.lb-name {
  position: absolute;
  inset-block-end: calc(18px + env(safe-area-inset-bottom));
  inset-inline: 0;
  text-align: center;
  color: #fff;
  font-size: 14px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .7);
  pointer-events: none;
}
/* ---------------- secret compose sheet ---------------- */
.secret-sheet { display: grid; gap: 10px; }
.secret-real {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .03);
}
.secret-tag { font-size: 11px; color: var(--accent); font-weight: 700; }
.secret-real-text { margin-block-start: 4px; font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.secret-decoy { display: flex; gap: 8px; align-items: center; }
.secret-decoy .field-input { flex: 1; min-inline-size: 0; }
.secret-ttl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.secret-ttl .field-label { inline-size: 100%; margin-block-end: 2px; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg-dim);
  border-radius: 999px;
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.chip.on { background: var(--accent); border-color: transparent; color: #04201d; font-weight: 700; }

/* ---------------- stale server banner ---------------- */
.stale-bar {
  position: fixed;
  inset-inline: 10px;
  inset-block-start: 10px;
  margin-inline: auto;
  max-inline-size: 470px;
  z-index: 60;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 14px;
  background: #3f2a11;
  border: 1px solid #7a4d18;
  color: #ffd79a;
  font-size: 12.5px;
  line-height: 1.55;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.stale-bar .stale-text { display: grid; gap: 2px; flex: 1; min-inline-size: 0; }
.stale-bar strong { color: #ffc266; font-size: 13px; }
.stale-bar .icon-btn { flex: 0 0 auto; }

/* ------------------------------------------------------------------ *
 * multi-select: a small box beside the text
 * ------------------------------------------------------------------ */
.msg { position: relative; }
.msg-check {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: -2px;
  transform: translateY(-50%);
  inline-size: 19px;
  block-size: 19px;
  padding: 0;
  border-radius: 50%;
  border: 1.6px solid rgba(255, 255, 255, .35);
  background: rgba(9, 20, 24, .55);
  color: #04201d;
  font-size: 12px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, background .15s, border-color .15s;
  z-index: 2;
}
.msg.own .msg-check { inset-inline-end: auto; inset-inline-start: -2px; }
.msg:hover .msg-check,
#msgs.pick-hint .msg-check,
#msgs.picking .msg-check { opacity: 1; pointer-events: auto; }
.msg-check.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #04201d;
  font-weight: 800;
}
.msg.picked .bubble { box-shadow: 0 0 0 1.6px var(--accent) inset; }
@media (hover: none) {
  .msg-check { opacity: 0; }
  #msgs.picking .msg-check, #msgs.pick-hint .msg-check { opacity: 1; pointer-events: auto; }
}

/* ------------------------------------------------------------------ *
 * secret messages: the countdown under the text
 * ------------------------------------------------------------------ */
.msg .meta { flex-wrap: wrap; }
.count-down {
  flex: 0 0 100%;
  white-space: nowrap;
  margin-block-start: 2px;
  font-size: 10.5px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-align: start;
  opacity: .95;
}
.secret-msg .count-down { color: #ffcf7a; }

/* ------------------------------------------------------------------ *
 * camera: one chip per lens
 * ------------------------------------------------------------------ */
.cam-lenses {
  position: absolute;
  inset-block-end: 46px;   /* sits above the zoom chips, never on top of them */
  inset-inline: 8px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px;
  scrollbar-width: none;
}
.cam-lenses::-webkit-scrollbar { display: none; }
.cam-lens-btn {
  flex: 0 0 auto;
  inline-size: 28px;
  block-size: 28px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .3);
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.cam-lens-btn.on { background: #fff; color: #14212b; border-color: #fff; font-weight: 700; }

/* ------------------------------------------------------------------ *
 * route button over the map
 * ------------------------------------------------------------------ */
.map-route {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  border-radius: 11px;
  border: 1px solid rgba(0, 0, 0, .14);
  background: #fff;
  color: #16232e;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .3);
  cursor: pointer;
}
.map-route svg { inline-size: 14px; block-size: 14px; color: #1f7ae0; }
.map-card { max-block-size: 94dvh; display: flex; flex-direction: column; }
.map-card .map-stage { flex: 1 1 auto; min-block-size: 200px; }

/* ------------------------------------------------------------------ *
 * the call strip: the call stays alive when you leave the screen
 * ------------------------------------------------------------------ */
/* the strip takes real space: it must never sit on top of the chat header */
body.call-min .app {
  block-size: calc(100dvh - var(--callbar-h, 48px));
  margin-block-start: var(--callbar-h, 48px);
}
.callbar {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  padding-block-start: calc(7px + env(safe-area-inset-top));
  background: linear-gradient(180deg, #0e3b38, #0a2b29);
  border-block-end: 1px solid rgba(45, 212, 191, .35);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  color: #dffbf5;
  font-size: 12.5px;
  cursor: pointer;
}
.callbar.hidden { display: none; }
.callbar-dot {
  inline-size: 8px; block-size: 8px; border-radius: 50%;
  background: #34d399; flex: 0 0 auto;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: callPulse 1.8s infinite;
}
@keyframes callPulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); }
  70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
.callbar-text { display: grid; gap: 1px; flex: 1; min-inline-size: 0; }
.callbar-text strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.callbar-text small { color: #8fd8cd; font-size: 11px; }
.callbar-time { direction: ltr; font-variant-numeric: tabular-nums; color: #a7f3e6; font-size: 12px; }
.callbar-btn {
  flex: 0 0 auto;
  border: 1px solid rgba(45, 212, 191, .4);
  background: rgba(255, 255, 255, .07);
  color: #dffbf5;
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 11.5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.callbar-btn svg { inline-size: 15px; block-size: 15px; fill: currentColor; }
.callbar-btn.back { background: var(--accent); color: #04201d; border-color: transparent; font-weight: 700; }
.callbar-btn.end { background: #b3261e; border-color: transparent; }
.callbar-btn.off { opacity: .5; }

/* ------------------------------------------------------------------ *
 * voice note: the bin on the right, the lock above
 * ------------------------------------------------------------------ */
#btn-mic, .recbar { touch-action: none; }
.rec-targets { position: fixed; inset: 0; z-index: 58; pointer-events: none; display: none; }
.rec-targets.on { display: block; }
.rec-trash, .rec-lock {
  position: absolute;
  inset-inline-start: var(--tx, 50%);
  inset-block-start: var(--ty, 50%);
  inline-size: 54px;
  block-size: 54px;
  margin-inline-start: 46px;
  margin-block-start: -27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  gap: 0;
  color: #fff;
  background: rgba(24, 30, 38, .92);
  border: 1.5px solid rgba(255, 255, 255, .22);
  transform: scale(.7);
  opacity: 0;
  transition: opacity .16s, transform .16s, background .16s, border-color .16s;
}
.rec-trash svg, .rec-lock svg { inline-size: 22px; block-size: 22px; }
.rec-trash span, .rec-lock span { font-size: 9.5px; margin-block-start: -3px; }
.rec-trash.on { opacity: 1; transform: scale(1); }
.rec-trash.armed {
  background: #b3261e;
  border-color: #ff7a72;
  transform: scale(1.16);
}
.rec-lock {
  margin-inline-start: -27px;
  margin-block-start: -27px;
}
.rec-lock.on { opacity: 1; transform: scale(1); }
.rec-lock.armed {
  background: var(--accent);
  color: #04201d;
  border-color: transparent;
  transform: scale(1.12);
}
.recbar.arming { border-color: #ff8a80; }
.recbar.locked #rec-corner { display: none; }

/* ------------------------------------------------------------------ *
 * search: sidebar box, result rows, in-thread bar
 * ------------------------------------------------------------------ */
.side-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 10px 6px;
  padding: 0 10px;
  border-radius: 12px;
  background: var(--bg-3);
  border: 1px solid var(--line);
}
.side-search input {
  flex: 1;
  min-inline-size: 0;
  border: 0;
  background: none;
  padding: 9px 0;
  font-size: 13px;
  outline: none;
}
.side-search input::placeholder { color: var(--fg-dim); }
.side-search input::-webkit-search-cancel-button { display: none; }

.search-results { padding: 4px 8px 12px; overflow-y: auto; max-block-size: 100%; }
.sr-head { font-size: 11.5px; color: var(--fg-dim); padding: 4px 6px 8px; }
.sr-title {
  font-size: 11px; font-weight: 700; color: var(--accent);
  padding: 8px 6px 4px; letter-spacing: .2px;
}
.sr-row {
  display: flex;
  align-items: center;
  gap: 9px;
  inline-size: 100%;
  text-align: start;
  padding: 8px;
  border: 0;
  border-radius: 11px;
  background: none;
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.sr-row:hover { background: rgba(255, 255, 255, .05); }
.sr-row.msg-hit { display: block; }
.sr-top { display: flex; gap: 8px; align-items: baseline; }
.sr-top b { font-size: 12.5px; }
.sr-top time { font-size: 10.5px; color: var(--fg-dim); margin-inline-start: auto; }
.sr-text { font-size: 12.5px; color: var(--fg-dim); margin-block-start: 2px; line-height: 1.5; }
.sr-name { font-size: 13.5px; }

/* -------- inside one chat -------- */
.thread-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--bg-2);
  border-block-end: 1px solid var(--line);
}
.thread-search input {
  flex: 1;
  min-inline-size: 0;
  border: 1px solid var(--line);
  background: var(--bg-3);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}
.thread-search input::-webkit-search-cancel-button { display: none; }
.ts-count { font-size: 11px; color: var(--fg-dim); white-space: nowrap; }
.msg.hit .bubble { box-shadow: 0 0 0 1.5px rgba(45, 212, 191, .55) inset; }
.msg.hit-now .bubble { box-shadow: 0 0 0 2px var(--accent) inset; background: rgba(45, 212, 191, .10); }
.msg.flash .bubble { animation: flashMsg 1.4s ease-out 2; }
@keyframes flashMsg {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
  50% { box-shadow: 0 0 0 2.5px var(--accent); }
}

/* -------- a chat partner who is not in the friends list -------- */
.peer-add {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: linear-gradient(180deg, rgba(45, 212, 191, .12), rgba(45, 212, 191, .04));
  border-block-end: 1px solid var(--line);
  font-size: 12.5px;
}
.peer-add-text { flex: 1; min-inline-size: 0; color: var(--fg); }
.peer-add .btn { flex: 0 0 auto; }

.new-chat-btn {
  margin: 0 10px 8px;
  inline-size: calc(100% - 20px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.new-chat-btn svg { inline-size: 16px; block-size: 16px; fill: currentColor; }

/* ------------------------------------------------------------------ *
 * offline map pack sheet
 * ------------------------------------------------------------------ */
.pack { display: grid; gap: 10px; }
.pack-info { font-size: 12.5px; color: var(--fg-dim); line-height: 1.6; }
.pack-progress {
  block-size: 8px;
  border-radius: 999px;
  background: var(--bg-3);
  overflow: hidden;
  border: 1px solid var(--line);
}
.pack-progress i {
  display: block;
  block-size: 100%;
  inline-size: 0;
  background: linear-gradient(90deg, #22c7b0, #56e8cf);
  transition: inline-size .3s;
}
.map-themes .pack-btn { color: var(--accent); border-color: rgba(45, 212, 191, .45); }
.map-themes .offline-btn.on { background: var(--accent); color: #04201d; border-color: transparent; }

/* the route button floats on the map itself; the footer copy stays only as a
   data holder for lat/lon (an empty link keeps readCoords simple) */
.map-card footer #map-open { display: none; }

.btn.danger-on { background: #b3261e; color: #fff; border-color: transparent; }
