/* ---------- Tokens ---------- */
:root {
  --ink: #1e1442;          /* text */
  --paper: #f8f5ff;        /* app background */
  --panel: #ffffff;        /* sidebar, header, composer */
  --line: #e7e0f6;         /* borders */
  --muted: #6e6690;
  --hover: #f3eefe;
  --violet: #6c3bff;       /* primary */
  --violet-ink: #ffffff;
  --violet-soft: #ece4ff;
  --blush: #ff4f86;        /* unread, alerts */
  --sun: #ffc83d;          /* random stranger */
  --mint: #18b98d;         /* online */
  --them: #ffffff;
  --night: #24135f;        /* auth hero */
  --danger: #d92d5c;
  --radius-bubble: 20px;
  --font-display: "Bricolage Grotesque", "Figtree", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f1ecff;
    --paper: #120c2b;
    --panel: #1a1338;
    --line: #2d2452;
    --muted: #a69cc9;
    --hover: #231a49;
    --violet: #8b65ff;
    --violet-soft: #2c2160;
    --them: #251c4a;
    --night: #1a0d4a;
    --danger: #ff6b93;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; }
svg { width: 22px; height: 22px; flex: none; }
.hidden { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.error { color: var(--danger); min-height: 1.3em; margin: 4px 0 0; font-weight: 500; }

button, input, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 9px 16px;
  font-weight: 600;
  transition: background .15s, transform .1s, border-color .15s;
}
button:active:not(:disabled) { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--violet); color: var(--violet-ink); border-color: var(--violet); }
button.primary:hover { filter: brightness(1.08); }
button.secondary { background: var(--violet-soft); border-color: transparent; color: var(--violet); }
button.ghost { background: none; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--hover); color: var(--ink); }
button.danger { color: var(--danger); }
button.big { padding: 14px 22px; font-size: 1rem; border-radius: 14px; }
.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: none; background: none; border-radius: 12px;
  color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn.on { color: var(--violet); }
:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }

input, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--panel);
  border-radius: 12px;
  padding: 11px 14px;
}
input:focus, textarea:focus { outline: none; border-color: var(--violet); }

/* ---------- Avatars ---------- */
.avatar {
  --a: #6c3bff; --b: #ff4f86;
  position: relative;
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--a), var(--b));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
}
.avatar.sm { width: 38px; height: 38px; font-size: .95rem; }
.avatar .dot {
  position: absolute; right: -1px; bottom: -1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--mint);
  border: 2.5px solid var(--panel);
}

/* ---------- Auth ---------- */
#auth {
  min-height: 100dvh;
  display: grid;
  /* minmax(0, …) so long content (like country names) can't widen the page */
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
}
.hero {
  position: relative;
  overflow: hidden;
  background: var(--night);
  color: #fff;
  padding: 48px clamp(32px, 6vw, 96px);
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; }
.brand svg { width: 30px; height: 30px; color: var(--sun); }
.hero h1 {
  margin-top: auto;
  font-size: clamp(2.6rem, 5.2vw, 5rem);
  line-height: 1.02;
  font-weight: 800;
  max-width: 11ch;
}
.hero-sub { font-size: 1.15rem; max-width: 34ch; opacity: .8; margin: 18px 0 0; }
.floating { display: flex; flex-direction: column; gap: 10px; margin: 40px 0 auto; max-width: 420px; }
.note {
  align-self: flex-start;
  background: #fff;
  color: #1e1442;
  padding: 10px 16px;
  border-radius: 18px 18px 18px 6px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(10, 0, 50, .35);
  opacity: 0;
  animation: note-in .5s cubic-bezier(.2, .9, .3, 1.3) forwards;
}
.note.me { align-self: flex-end; background: var(--sun); border-radius: 18px 18px 6px 18px; }
.n1 { animation-delay: .3s; rotate: -2deg; }
.n2 { animation-delay: 1.1s; rotate: 1.5deg; }
.n3 { animation-delay: 1.9s; rotate: -1deg; }
.n4 { animation-delay: 2.6s; rotate: 2deg; }
@keyframes note-in { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: none; } }

.auth-panel { display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 32px; }
.auth-box { width: 100%; max-width: 400px; min-width: 0; }
select { max-width: 100%; }
.country-field select { width: 100%; text-overflow: ellipsis; }
.auth-box h2 { font-size: 2rem; }
.auth-box > p { margin: 6px 0 0; }
.tabs { display: flex; gap: 4px; margin: 24px 0 18px; background: var(--hover); padding: 4px; border-radius: 14px; }
.tabs button { flex: 1; border: none; background: none; padding: 9px; border-radius: 10px; color: var(--muted); }
.tabs button.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(30, 20, 66, .12); }
.tab-panel { display: flex; flex-direction: column; gap: 14px; }
.tab-panel label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.tab-panel .primary { margin-top: 4px; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.link-btn { border: none; background: none; padding: 4px 0; color: var(--violet); font-weight: 600; align-self: center; }
.link-btn:hover { text-decoration: underline; }
.notice { background: var(--violet-soft); color: var(--ink); padding: 12px 14px; border-radius: 12px; margin: 14px 0 0; }
.auth-box.no-tabs .tabs { display: none; }
.auth-box.no-tabs .tab-panel { margin-top: 22px; }

/* Gender + country pickers */
.gender-pick, .chip-pick { border: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.gender-pick legend, .chip-pick legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 6px; }
.gender-pick label, .chip-pick label { position: relative; }
.gender-pick input, .chip-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.gender-pick span, .chip-pick span:not(.hint) {
  display: inline-block; padding: 8px 14px; border-radius: 99px;
  border: 1.5px solid var(--line); background: var(--panel); font-weight: 500; font-size: .92rem;
}
.gender-pick input:checked + span, .chip-pick input:checked + span { border-color: var(--violet); background: var(--violet-soft); color: var(--violet); font-weight: 600; }
.gender-pick input:focus-visible + span, .chip-pick input:focus-visible + span { outline: 3px solid var(--violet); outline-offset: 2px; }
.chip-pick input:disabled + span { opacity: .45; }
.country-field { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 0 0 14px; background: var(--panel); }
.country-field:focus-within { border-color: var(--violet); }
.country-field select { flex: 1; border: none; background: none; padding: 11px 14px 11px 0; font: inherit; color: inherit; outline: none; min-width: 0; }
.country-field select option { background: var(--panel); color: var(--ink); }
.country-field .fi { flex: none; width: 1.4em; border-radius: 2px; }

/* "👧 🇱🇰" next to names */
.idbadge { display: inline-flex; align-items: center; gap: 5px; margin-left: 6px; font-size: .9em; vertical-align: -1px; }
.idbadge .fi { width: 1.25em; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08); }
.row-name { display: flex; align-items: center; min-width: 0; }
.row-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-title { cursor: pointer; }
#me-name, #me-avatar { cursor: pointer; }

/* Dialogs */
dialog {
  border: none; border-radius: 20px; padding: 0;
  background: var(--panel); color: var(--ink);
  width: min(460px, calc(100vw - 32px));
  box-shadow: 0 24px 60px rgba(20, 10, 60, .3);
}
dialog::backdrop { background: rgba(20, 10, 60, .45); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.profile-card { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 32px 24px 26px; gap: 6px; }
.profile-card .close { position: absolute; top: 8px; right: 8px; font-size: 1.4rem; }
.avatar.lg { width: 84px; height: 84px; font-size: 2rem; margin-bottom: 6px; }
.profile-card h2 { font-size: 1.6rem; }
.profile-card p { margin: 0; }
#pc-line .fi { width: 1.3em; border-radius: 2px; vertical-align: -2px; }
#pc-bio { margin-top: 8px; max-width: 34ch; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 6px; }
.chip { padding: 5px 12px; border-radius: 99px; background: var(--violet-soft); color: var(--violet); font-weight: 600; font-size: .85rem; }
.edit-form { display: flex; flex-direction: column; gap: 16px; padding: 18px 22px 22px; max-height: 88dvh; overflow-y: auto; }
.edit-form header { display: flex; align-items: center; justify-content: space-between; }
.edit-form header h2 { font-size: 1.4rem; }
.edit-form > label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.edit-form .error { margin: 0; min-height: 0; }
.edit-form .privacy, .edit-form .danger-zone { display: flex; flex-direction: column; gap: 12px; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 0; }
.edit-form .privacy legend, .edit-form .danger-zone legend { font-weight: 700; font-size: .9rem; padding: 0 4px; }
.edit-form .privacy p { margin: 0; }
.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.switch input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--violet); }
.switch span, .select-row > span { display: flex; flex-direction: column; gap: 2px; font-size: .92rem; }
.switch small { color: var(--muted); font-size: .8rem; line-height: 1.35; }
.select-row { display: flex; flex-direction: column; gap: 6px; }
.select-row select { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 14px; background: var(--panel); font: inherit; font-size: 16px; color: inherit; }
.select-row select:focus { outline: none; border-color: var(--violet); }
.edit-form .danger-zone { flex-direction: row; flex-wrap: wrap; gap: 8px; }
.edit-form .danger-zone button { flex: 1 1 140px; }
.close-form { display: flex; flex-direction: column; gap: 12px; padding: 20px 22px; max-width: 420px; }
.close-form h2 { font-size: 1.3rem; margin: 0; }
.close-form p { margin: 0; line-height: 1.45; }
.close-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.close-form .error:empty { display: none; }
button.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger-fill:hover { filter: brightness(1.08); }

/* Email reminder in the sidebar */
.banner {
  position: relative;
  margin: 0 16px 12px;
  padding: 12px 40px 10px 14px;
  border-radius: 14px;
  background: var(--violet-soft);
  font-size: .88rem;
}
.banner p { margin: 0 0 6px; }
.banner form { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.banner form input { flex: 1 1 140px; min-width: 0; }
.banner input { padding: 8px 10px; font-size: .88rem; }
.banner form button { padding: 8px 12px; }
#banner-actions { display: flex; gap: 14px; }
#banner-actions .link-btn { align-self: auto; font-size: .85rem; }
#profile-banner-close { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; font-size: 1.3rem; }
#profile-banner .link-btn { font-size: .85rem; }
#banner-close { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; font-size: 1.3rem; }

/* ---------- About (below the login, for new visitors and search engines) ---------- */
#about { background: var(--paper); border-top: 1px solid var(--line); }
.about-inner { max-width: 720px; margin: 0 auto; padding: 56px 24px 64px; }
#about h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 12px; }
#about h3 { font-family: var(--font-display); font-size: 1.2rem; margin: 32px 0 12px; }
#about p { line-height: 1.6; margin: 0; max-width: 65ch; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; display: flex; gap: 12px; align-items: baseline; line-height: 1.5; }
.steps li::before {
  content: counter(step); flex: none;
  width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--sun); color: #2a1a00; font-weight: 700; font-size: .85rem;
}
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.faq summary { cursor: pointer; font-weight: 600; list-style-position: outside; }
.faq details p { margin-top: 8px; color: var(--muted); }
.lang-nav { margin-top: 32px; color: var(--muted); font-size: .92rem; }
.lang-nav a { color: var(--violet); font-weight: 600; margin-left: 8px; }

/* ---------- App shell (full screen) ---------- */
#app {
  height: 100dvh;
  display: grid;
  grid-template-columns: clamp(320px, 26vw, 400px) 1fr;
}

/* Sidebar */
#sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.me-bar { display: flex; align-items: center; gap: 10px; padding: 14px 12px 14px 18px; }
.me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me-text strong { font-family: var(--font-display); font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#random-cta {
  display: flex; align-items: center; gap: 14px;
  margin: 4px 16px 14px;
  padding: 14px 16px;
  text-align: left;
  background: var(--sun);
  color: #2a1a00;
  border: none;
  border-radius: 18px;
}
#random-cta:hover { filter: brightness(1.04); }
#random-cta strong { display: block; font-family: var(--font-display); font-size: 1.08rem; }
#random-cta.active { box-shadow: 0 0 0 3px var(--violet); }
.cta-mask { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: #2a1a00; color: var(--sun); flex: none; }
.cta-mask svg { width: 26px; height: 26px; }

.list-tabs { display: flex; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.list-tabs button {
  border: none; background: none; border-radius: 0;
  padding: 10px 0; margin-bottom: -1px;
  color: var(--muted);
  border-bottom: 2.5px solid transparent;
  display: flex; align-items: center; gap: 6px;
}
.list-tabs button.active { color: var(--ink); border-bottom-color: var(--violet); }
.pill { background: var(--blush); color: #fff; font-size: .72rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.pill.soft { background: var(--violet-soft); color: var(--violet); }
#search { margin: 12px 16px 6px; width: auto; padding: 9px 14px; background: var(--hover); border-color: transparent; }
#search:focus { border-color: var(--violet); }

#list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px;
  border: none; border-radius: 14px;
  background: none;
  text-align: left;
  font-weight: 400;
}
.row:hover { background: var(--hover); }
.row.active { background: var(--violet-soft); }
.row.is-blocked { opacity: .5; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-time { font-size: .75rem; color: var(--muted); }
.row-bottom { display: flex; align-items: center; gap: 8px; }
.row-preview { flex: 1; font-size: .87rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.unread .row-preview { color: var(--ink); font-weight: 600; }
.row.unread .row-time { color: var(--blush); font-weight: 600; }
.badge { background: var(--blush); color: #fff; font-size: .72rem; font-weight: 700; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: grid; place-items: center; }
.list-empty { padding: 28px 16px; text-align: center; color: var(--muted); }
/* People list sections */
.list-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 10px 6px;
  font-size: .78rem; font-weight: 700; color: var(--muted);
}
.list-head.online::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); }
.list-count { font-weight: 600; background: var(--hover); padding: 0 7px; border-radius: 99px; }
.list-note { margin: 2px 10px 8px; font-size: .86rem; color: var(--muted); line-height: 1.45; }
.list-empty button { margin-top: 12px; }

/* Conversation */
#conv { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
#thread { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.conv-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  min-height: 70px;
}
.conv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-title strong { font-family: var(--font-display); font-size: 1.15rem; }
#conv-status.online { color: var(--mint); font-weight: 600; }
#conv-name { display: flex; align-items: center; min-width: 0; white-space: nowrap; }
#conv-name .nm { overflow: hidden; text-overflow: ellipsis; }
#back { display: none; }

.center-state {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 32px;
  gap: 12px;
}
.center-state h2 { font-size: clamp(1.6rem, 2.6vw, 2.3rem); }
.center-state p { max-width: 40ch; margin: 0 0 8px; }
.big-mask { width: 96px; height: 96px; border-radius: 30px; background: var(--sun); color: #2a1a00; display: grid; place-items: center; rotate: -6deg; margin-bottom: 8px; }
.big-mask svg { width: 58px; height: 58px; }

.radar { position: relative; width: 150px; height: 150px; display: grid; place-items: center; margin-bottom: 12px; }
.radar svg { width: 56px; height: 56px; color: var(--violet); position: relative; }
.radar span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--violet); opacity: 0; }
.radar.go span { animation: ping 2.4s ease-out infinite; }
.radar.go span:nth-child(2) { animation-delay: .8s; }
.radar.go span:nth-child(3) { animation-delay: 1.6s; }
@keyframes ping { from { transform: scale(.35); opacity: .8; } to { transform: scale(1); opacity: 0; } }

#log {
  flex: 1;
  overflow-y: auto;
  padding: 24px clamp(16px, 4vw, 64px) 8px;
  display: flex;
  flex-direction: column;
}
.day { align-self: center; margin: 18px 0 10px; font-size: .78rem; font-weight: 600; color: var(--muted); background: var(--hover); padding: 3px 12px; border-radius: 99px; }
.sys { align-self: center; text-align: center; margin: 12px 0; font-size: .86rem; color: var(--muted); max-width: 48ch; }
.msg {
  max-width: min(70%, 620px);
  padding: 9px 14px;
  border-radius: var(--radius-bubble);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin-top: 3px;
  animation: pop .22s ease-out;
}
.msg.first { margin-top: 12px; }
.msg.me { align-self: flex-end; background: var(--violet); color: #fff; border-bottom-right-radius: 6px; }
.msg.them { align-self: flex-start; background: var(--them); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.me:not(.last) { border-bottom-right-radius: 6px; border-top-right-radius: 6px; }
.msg.me.first { border-top-right-radius: var(--radius-bubble); }
.msg.them:not(.last) { border-top-left-radius: 6px; }
.msg.them.first { border-top-left-radius: var(--radius-bubble); }
.msg.emoji-only { background: none; border: none; font-size: 2.4rem; line-height: 1.1; padding: 2px 4px; }
.msg .time { font-size: .7rem; opacity: .65; margin-left: 8px; float: right; margin-top: 6px; }
.seen { align-self: flex-end; font-size: .74rem; color: var(--muted); margin-top: 3px; }
@keyframes pop { from { transform: translateY(6px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* Replies */
.msg { position: relative; }
.quote {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; min-width: 120px; margin: 0 0 6px; padding: 6px 10px;
  border: none; border-left: 3px solid var(--violet); border-radius: 8px;
  background: rgba(108, 59, 255, .08); color: inherit; text-align: left; font-weight: 400; font-size: .85rem;
}
.quote strong { color: var(--violet); font-size: .8rem; }
.quote span { opacity: .85; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.msg.me .quote { background: rgba(255, 255, 255, .16); border-left-color: #fff; }
.msg.me .quote strong { color: #fff; }
.reply-btn, .del-btn {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 32px; height: 32px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  opacity: 0; transition: opacity .12s;
}
.reply-btn svg, .del-btn svg { width: 16px; height: 16px; }
.msg.me .reply-btn { right: calc(100% + 8px); }
.msg.them .reply-btn { left: calc(100% + 8px); }
.msg.me .del-btn { right: calc(100% + 46px); }
.msg.them .del-btn { left: calc(100% + 46px); }
.del-btn:hover { color: var(--danger); }
.msg:hover .reply-btn, .reply-btn:focus-visible, .msg:hover .del-btn, .del-btn:focus-visible { opacity: 1; }
@media (hover: none) { .reply-btn, .del-btn { display: none; } }
.msg.deleted { background: none !important; color: var(--muted) !important; border: 1px dashed var(--line); font-style: italic; }
.msg.deleted .time { font-style: normal; }

/* Message actions sheet */
#msg-actions .sheet { display: flex; flex-direction: column; gap: 6px; padding: 16px; }
#msg-actions .sheet p { margin: 0 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#msg-actions .sheet button { display: flex; align-items: center; gap: 10px; justify-content: flex-start; padding: 12px 14px; }
#msg-actions .sheet button svg { width: 18px; height: 18px; }
#msg-actions .sheet button[data-close] { justify-content: center; margin-top: 4px; }
@media (max-width: 760px) {
  #msg-actions { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.swipe-hint {
  position: absolute; top: 50%; right: calc(100% + 10px); translate: 0 -50%;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--violet-soft); color: var(--violet);
  opacity: var(--swipe, 0); scale: calc(.6 + var(--swipe, 0) * .4); pointer-events: none;
}
.swipe-hint svg { width: 15px; height: 15px; }
.msg { transition: transform .2s ease-out; }
.msg.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--sun); } 100% { box-shadow: 0 0 0 0 transparent; } }

#reply-bar {
  display: flex; align-items: center; gap: 10px;
  margin: 0 clamp(12px, 4vw, 64px) -2px; padding: 8px 6px 8px 14px;
  background: var(--panel); border: 1.5px solid var(--line); border-bottom: none; border-radius: 16px 16px 0 0;
}
#reply-bar > svg { color: var(--violet); width: 18px; height: 18px; }
.reply-bar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; border-left: 3px solid var(--violet); padding-left: 10px; }
.reply-bar-text strong { font-size: .82rem; color: var(--violet); }
.reply-bar-text span { font-size: .88rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#reply-bar:not(.hidden) + #composer { border-top-left-radius: 0; border-top-right-radius: 0; margin-top: 0; }

/* View-once photos */
.photo-once {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; background: none; padding: 2px 0; color: inherit; font-weight: 600; text-align: left;
}
.photo-once .once-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(108, 59, 255, .14); color: var(--violet); }
.msg.me .photo-once .once-icon { background: rgba(255, 255, 255, .2); color: #fff; }
.photo-once .once-icon svg { width: 18px; height: 18px; }
.photo-once:not(:disabled):hover span:last-child { text-decoration: underline; }
.photo-once:disabled { cursor: default; opacity: 1; }
.photo-once[data-state="opened"] span:last-child, .photo-once[data-state="expired"] span:last-child { font-weight: 500; opacity: .75; font-style: italic; }
.photo-confirm { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.photo-confirm img { width: 100%; max-height: 55dvh; object-fit: contain; border-radius: 12px; background: var(--hover); }
.photo-confirm p { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.photo-confirm p svg { width: 20px; height: 20px; color: var(--violet); }
#viewer {
  position: fixed; inset: 0; z-index: 50;
  background: #000; color: #fff;
  display: flex; flex-direction: column;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.viewer-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; font-size: .9rem; }
.viewer-top span { display: flex; align-items: center; gap: 8px; opacity: .85; }
.viewer-top svg { width: 18px; height: 18px; }
#viewer-close { color: #fff; font-size: 1.8rem; }
#viewer-stage {
  position: relative; flex: 1; min-height: 0;
  display: grid; place-items: center;
  touch-action: none; cursor: pointer; outline: none;
}
#viewer-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; visibility: hidden; }
#viewer-hint { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 24px; max-width: 30ch; }
#viewer-hint svg { width: 56px; height: 56px; opacity: .9; }
#viewer-hint strong { font-family: var(--font-display); font-size: 1.4rem; }
#viewer-hint span { opacity: .7; font-size: .9rem; }
#viewer-stage:focus-visible #viewer-hint { outline: 2px solid #fff; outline-offset: 8px; border-radius: 12px; }
/* only while held */
#viewer.showing #viewer-img { visibility: visible; }
#viewer.showing #viewer-hint { visibility: hidden; }
#viewer-time { font-variant-numeric: tabular-nums; }

#icebreakers { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px clamp(16px, 4vw, 64px); }
#icebreakers button { border-radius: 99px; padding: 7px 14px; font-weight: 500; background: var(--panel); }
#icebreakers button:hover { border-color: var(--violet); color: var(--violet); }
#typing { min-height: 1.5em; padding: 0 clamp(16px, 4vw, 64px); }
#typing:not(:empty)::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--violet); margin-right: 8px; animation: blink 1s infinite; vertical-align: middle; }
@keyframes blink { 50% { opacity: .2; } }

#composer {
  position: relative;
  display: flex; align-items: flex-end; gap: 8px;
  margin: 6px clamp(12px, 4vw, 64px) calc(18px + env(safe-area-inset-bottom));
  padding: 6px 6px 6px 8px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 22px;
}
#composer:focus-within { border-color: var(--violet); }
#msg { border: none; background: none; resize: none; padding: 9px 4px; max-height: 160px; line-height: 1.4; }
#msg:disabled { cursor: not-allowed; }
.send-btn { width: 42px; height: 42px; padding: 0; display: grid; place-items: center; border-radius: 50%; background: var(--violet); color: #fff; border: none; flex: none; }
.send-btn svg { width: 20px; height: 20px; }

#emoji-panel {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  width: 320px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(30, 20, 66, .18);
  z-index: 5;
}
#emoji-panel button { border: none; background: none; font-size: 1.35rem; padding: 4px; border-radius: 8px; }
#emoji-panel button:hover { background: var(--hover); }

/* Invite to a random chat */
#invite {
  position: fixed; top: 16px; left: 50%; translate: -50% 0;
  width: min(520px, calc(100vw - 32px));
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px 10px 12px;
  background: var(--panel); color: var(--ink);
  border: 2px solid var(--sun); border-radius: 18px;
  box-shadow: 0 16px 40px rgba(30, 20, 66, .25);
  z-index: 30;
  animation: pop .25s ease-out;
}
#invite p { flex: 1; margin: 0; font-size: .92rem; line-height: 1.35; }
#invite .primary { padding: 9px 16px; }
.invite-mask { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--sun); color: #2a1a00; }
#random-cta.has-waiting #cta-sub { font-weight: 700; }
#random-cta.has-waiting .cta-mask { animation: nudge 1.6s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: scale(1.08) rotate(-4deg); } }
#search-help { margin-top: 18px; max-width: 420px; text-align: left; }
#search-help p { text-align: center; margin: 0 0 10px; color: var(--muted); }
#search-help .row { background: var(--panel); border: 1px solid var(--line); margin-bottom: 6px; }

#announcement {
  position: fixed; top: 16px; left: 50%; translate: -50% 0;
  width: min(560px, calc(100vw - 32px));
  display: grid; grid-template-columns: 1fr auto; align-items: start;
  padding: 12px 8px 12px 18px;
  background: var(--sun); color: #2a1a00;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(30, 20, 66, .25);
  z-index: 30;
  animation: pop .25s ease-out;
}
.announcement-label { grid-column: 1; font-size: .78rem; font-weight: 700; opacity: .7; }
#announcement p { grid-column: 1; margin: 2px 0 0; font-weight: 600; }
#announcement .icon-btn { grid-column: 2; grid-row: 1 / 3; color: #2a1a00; font-size: 1.4rem; }
a.icon-btn { text-decoration: none; }

#toast {
  position: fixed; left: 50%; bottom: 28px; translate: -50% 0;
  background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: 12px; font-weight: 500;
  z-index: 10;
  animation: pop .2s ease-out;
}

/* ---------- Smaller screens ---------- */
@media (max-width: 900px) {
  /* phones: a short header, then the form right away */
  #auth { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .hero { padding: calc(16px + env(safe-area-inset-top)) 20px 18px; }
  .hero h1 { margin-top: 14px; font-size: clamp(1.7rem, 7.5vw, 2.2rem); max-width: 16ch; }
  .hero-sub { font-size: .95rem; margin-top: 6px; }
  .floating { display: none; }
  .auth-panel { padding: 20px 20px calc(28px + env(safe-area-inset-bottom)); place-items: start center; }
  .auth-box h2 { font-size: 1.6rem; }
  .tabs { margin: 16px 0 14px; }
}
/* iPhones zoom in when you tap a box with text smaller than 16px */
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px; }
}
@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  #conv { display: none; }
  body.show-conv #sidebar { display: none; }
  body.show-conv #conv { display: flex; }
  #back { display: grid; }
  .conv-head { padding: 10px 12px; gap: 8px; }
  #block, #report { padding: 8px 6px; }
  #delete-chat { width: 34px; }
  .conv-head .avatar { width: 38px; height: 38px; font-size: .95rem; }
  .msg { max-width: 85%; }
  #log { overflow-x: hidden; }
  #emoji-panel { width: min(320px, calc(100vw - 32px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .note { opacity: 1; }
}
