/* Idion - no external fonts or assets: loading them would leak your IP to a third party. */
:root {
  --bg: #0d0d15;
  --bg-2: #11111b;
  --panel: #161624;
  --panel-2: #1c1c2e;
  --line: #26263a;
  --text: #e7e5f4;
  --muted: #8e8aa8;
  --accent: #9b8afb;
  --accent-2: #b8abff;
  --accent-ink: #120f24;
  --out: #2c2552;
  --in: #1c1c2e;
  --ok: #6fd6a4;
  --warn: #f0c46b;
  --bad: #f2788a;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f3fa; --bg-2: #ecebf6; --panel: #ffffff; --panel-2: #f2f0fb; --line: #e1def0;
    --text: #17152a; --muted: #6c6889; --accent: #6b56f0; --accent-2: #5a45e0; --accent-ink: #ffffff;
    --out: #e6e0ff; --in: #ffffff; --ok: #1d9a63; --warn: #a8740c; --bad: #c8334b;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
button, input, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: .9em; }
.wrap { overflow-wrap: anywhere; }
.grow { flex: 1; }
.fine { color: var(--muted); font-size: 13px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); cursor: pointer; font-weight: 550; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }
.btn.wide { width: 100%; padding: 12px; }
.btn.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.btn.link.danger { color: var(--muted); margin-top: 12px; }
.btn.link.danger:hover { color: var(--bad); }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn.small .icon { width: 16px; height: 16px; }

input:not([type=checkbox]):not([type=radio]), textarea, select {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-2); outline: none; transition: border-color .15s;
}
select { font: inherit; color: inherit; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
input[type=radio] { accent-color: var(--accent); width: 18px; height: 18px; margin: 2px 0 0; flex: none; }

/* ------------------------------------------------------------ lock */
.lock {
  min-height: 100%; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), var(--bg);
}
.lock-card { width: min(400px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; }
.lock-logo { border-radius: 20px; margin-bottom: 14px; box-shadow: 0 10px 40px color-mix(in srgb, var(--accent) 30%, transparent); }
.lock h1 { font-size: 30px; }
.tagline { color: var(--muted); margin: 6px 0 26px; }
.lock-form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.lock-form .check { text-align: left; }
.lock-error { color: var(--bad); min-height: 1.2em; margin: 4px 0 0; font-size: 14px; }
.lock .fine { max-width: 340px; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 320px 1fr; height: 100%; }
.rail { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.rail-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 10px 16px; }
.rail-head img { border-radius: 8px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.rail-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; padding: 4px 12px 12px; }
.rail-actions .btn.icon-only { padding-left: 11px; padding-right: 11px; }
.rail-actions .btn { padding: 8px 10px; font-size: 14px; }

.contacts { list-style: none; margin: 0; padding: 4px 8px; overflow-y: auto; flex: 1; }
.contact {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 0; border-radius: 12px;
  background: none; text-align: left; cursor: pointer;
}
.contact:hover { background: var(--panel-2); }
.contact.active { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); }
.contact-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.contact-name { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize; }
.contact-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.verified { color: var(--ok); display: inline-flex; }
.verified .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.bot-badge {
  display: inline-block; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-2);
  border-radius: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 0 5px; line-height: 16px; vertical-align: 1px;
}
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 12px; font-weight: 700; padding: 1px 7px; }
.avatar {
  --h: 260; flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: hsl(var(--h) 80% 88%);
  background: linear-gradient(135deg, hsl(var(--h) 55% 42%), hsl(calc(var(--h) + 40) 55% 28%));
}
.empty-list { padding: 24px 12px; text-align: center; color: var(--text); }
.empty-list p { margin: 4px 0; }

/* ------------------------------------------------------------ net footer */
.net { border-top: 1px solid var(--line); padding: 12px 16px 14px; font-size: 13px; }
.net-row { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-online .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 20%, transparent); }
.status-connecting .dot, .status-verifying .dot { background: var(--warn); animation: pulse 1s infinite alternate; }
.status-untrusted .dot { background: var(--bad); }
.status-untrusted { color: var(--bad); }
@keyframes pulse { to { opacity: .3; } }
.net-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin: 8px 0 0; color: var(--muted); }
.net-grid dt { color: var(--muted); }
.net-grid dd { margin: 0; color: var(--text); text-align: right; }
.net-error { color: var(--bad); margin: 8px 0 0; }

/* ------------------------------------------------------------ chat */
.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-empty { margin: auto; text-align: center; max-width: 420px; padding: 24px; color: var(--muted); }
.chat-empty img { opacity: .9; border-radius: 24px; margin-bottom: 18px; }
.chat-empty h2 { color: var(--text); font-size: 20px; margin-bottom: 8px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.chat-head .back { display: none; }
.chat-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 18px clamp(12px, 4vw, 48px); }
.messages-inner { display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; color: var(--muted); font-size: 12px; font-weight: 600; margin: 14px 0 6px; text-transform: uppercase; letter-spacing: .06em; }
.notice {
  align-self: center; max-width: 520px; text-align: center; font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px;
}
.msg { display: flex; }
.msg.out { justify-content: flex-end; }
.bubble {
  max-width: min(560px, 80%); padding: 8px 12px 6px; border-radius: 16px; background: var(--in); border: 1px solid var(--line);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--out); border-color: transparent; border-bottom-right-radius: 6px; }
.msg.in .bubble { border-bottom-left-radius: 6px; }
.meta { display: inline-flex; gap: 6px; float: right; margin: 6px 0 0 12px; font-size: 11px; color: var(--muted); }
.status.delivered { color: var(--accent-2); }
.status.failed { color: var(--bad); background: none; border: 0; padding: 0; cursor: pointer; font-size: 11px; text-decoration: underline; }

.composer { display: flex; align-items: flex-end; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--panel); }
.composer textarea { resize: none; max-height: 180px; border-radius: 20px; padding: 10px 16px; }
.send { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.send:hover { background: var(--accent-2); }

/* ------------------------------------------------------------ dialogs */
.dlg {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 1px solid var(--line);
  border-radius: 18px; background: var(--panel); color: var(--text); box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.dlg::backdrop { background: rgba(5, 5, 12, .6); backdrop-filter: blur(4px); }
.dlg > header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px 22px; position: sticky; top: 0; background: var(--panel); }
.dlg h2 { font-size: 18px; }
.dlg h3 { font-size: 14px; margin: 22px 0 6px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dlg-body { padding: 4px 22px 22px; }
.dlg-body > p:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }
.code { font-family: var(--mono); font-size: 13px; resize: none; word-break: break-all; }
.bullets { padding-left: 18px; margin: 16px 0 0; }
.bullets li { margin: 4px 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; margin-top: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.safety { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 12px; padding: 14px; border-radius: 12px; background: var(--bg-2); font-size: 16px; letter-spacing: .08em; text-align: center; }

.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.pill.active { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.partial { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.pill.app { color: var(--accent-2); background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* ------------------------------------------------------------ mobile */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .chat { display: none; }
  .shell.show-chat .rail { display: none; }
  .shell.show-chat .chat { display: flex; height: 100dvh; }
  .chat-head { padding: 10px 12px; }
  .chat-head .back { display: inline-grid; }
  .bubble { max-width: 86%; }
  .safety { grid-template-columns: repeat(3, 1fr); font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------ additions */
.ttl { opacity: .8; }
.ttl::before { content: "⏱ "; }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); }
.segmented button { border: 0; background: none; padding: 8px 6px; border-radius: 9px; font-size: 13px; cursor: pointer; color: var(--muted); }
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.net-grid dt[title] { cursor: help; text-decoration: underline dotted; text-underline-offset: 3px; }
@media (max-width: 720px) { .segmented { grid-template-columns: repeat(2, 1fr); } }
.relays { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 6px; }
.relays li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); font-size: 13.5px; }
.relay-name { font-weight: 600; text-transform: capitalize; }
.relay-host { color: var(--muted); }
.relay-pin { margin-left: auto; color: var(--muted); font-size: 12px; }
.warn { color: var(--warn); }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.stack .check { margin-top: 0; }

/* ------------------------------------------------------------ timers + attachments */
.ttl-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--panel-2); color: var(--muted); border-radius: 99px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.ttl-btn:hover { color: var(--text); border-color: var(--accent); }
.ttl-btn .icon { width: 15px; height: 15px; }
.ttl-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.ttl-options button { padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; font-weight: 550; }
.ttl-options button:hover { border-color: var(--accent); }
.ttl-options button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.notice.sys { display: inline-flex; align-items: center; gap: 8px; }
.notice.sys .icon { width: 15px; height: 15px; }

.composer .attach { flex: none; width: 42px; height: 42px; }
.chat.dropping .messages { outline: 2px dashed var(--accent); outline-offset: -10px; background: color-mix(in srgb, var(--accent) 6%, transparent); }
.bubble.has-file { padding: 6px; }
.bubble.has-file .text { display: block; padding: 6px 6px 0; }
.bubble.has-file .meta { margin-right: 6px; }
.file-card { display: flex; align-items: center; gap: 10px; min-width: min(280px, 60vw); padding: 10px 10px 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg) 40%, transparent); }
.file-card > .icon { width: 26px; height: 26px; color: var(--accent-2); }
.file-card.failed > .icon { color: var(--bad); }
.file-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 2px; }
.file-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { color: var(--muted); font-size: 12px; }
.bar { --p: 0; display: block; height: 4px; border-radius: 4px; margin-top: 4px; background: linear-gradient(90deg, var(--accent) calc(var(--p) * 1%), var(--line) 0); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.file-image { display: flex; flex-direction: column; gap: 4px; }
.file-img { display: block; max-width: min(360px, 70vw); max-height: 360px; min-height: 60px; border-radius: 12px; cursor: zoom-in; background: var(--bg-2); object-fit: contain; }
.file-caption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.35); font-size: 14px; }
@media (max-width: 720px) { .ttl-options { grid-template-columns: repeat(2, 1fr); } }

/* ------------------------------------------------------------ composer extras */
.composer { position: relative; }
.composer .emoji-btn, .composer .timer-btn { flex: none; width: 42px; height: 42px; }
.composer .timer-btn { position: relative; width: auto; min-width: 42px; padding: 0 8px; gap: 4px; }
.composer .timer-btn.on { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 12px; }
.timer-btn .chip { font-size: 12px; font-weight: 700; }
.composer-status { align-self: flex-start; padding: 6px 12px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; color: var(--muted); box-shadow: 0 6px 20px rgba(0,0,0,.25); }

.popover { position: fixed; z-index: 40; max-width: calc(100vw - 16px); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.4); padding: 8px; animation: pop .12s ease-out; }
@keyframes pop { from { transform: translateY(6px); } }
.menu { display: flex; flex-direction: column; gap: 2px; min-width: 260px; max-width: 300px; }
.menu > button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); cursor: pointer; font: inherit; }
.menu > button:hover, .menu > button:focus-visible { background: var(--panel-2); }
.menu > button span { color: var(--muted); font-size: 12.5px; }
.menu > button.on { color: var(--accent); font-weight: 650; }
.menu .fine { margin: 6px 12px 4px; }
.menu-title { margin: 4px 8px 6px; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.timer-menu { min-width: 220px; }

.emoji-picker { width: min(352px, calc(100vw - 32px)); }
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; padding-bottom: 6px; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.emoji-tabs button { flex: none; width: 34px; height: 34px; border: 0; border-radius: 9px; background: none; font-size: 19px; cursor: pointer; opacity: .6; }
.emoji-tabs button:hover { opacity: 1; background: var(--panel-2); }
.emoji-tabs button.on { opacity: 1; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); height: 248px; overflow-y: auto; align-content: start; }
.emoji { width: 38px; height: 38px; border: 0; border-radius: 9px; background: none; font-size: 24px; line-height: 1; cursor: pointer; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }
.emoji:hover, .emoji:focus-visible { background: var(--panel-2); transform: scale(1.12); }

.bubble .text.jumbo { font-size: 38px; line-height: 1.15; }
video.file-img { cursor: auto; background: #000; }
label.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 10px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
label.check input { margin-top: 3px; accent-color: var(--accent); }
label.check strong { color: var(--text); }
label.check:has(input:disabled) { opacity: .5; cursor: default; }

/* ------------------------------------------------------------ media sizing: caption wraps to the image */
.bubble.has-media { width: min-content; max-width: min(372px, 74vw); }
.bubble.has-media .file-image { width: min-content; }
.bubble.has-media .file-img { min-width: 180px; }
.bubble.has-media .file-caption { width: 100%; }
.bubble.has-media .file-caption .file-sub { min-width: 0; overflow-wrap: anywhere; }
.bubble.has-media .text { overflow-wrap: anywhere; }
.bubble.has-media .meta { white-space: nowrap; }

/* countdown */
.ttl { font-variant-numeric: tabular-nums; }
.ttl.soon { color: var(--bad); font-weight: 650; }

/* links */
.bubble a.link { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg.in .bubble a.link { color: var(--accent-2); }
.bubble.has-link { max-width: min(420px, 78vw); }
.link-card { display: flex; flex-direction: column; margin-top: 6px; border-radius: 12px; overflow: hidden; background: color-mix(in srgb, var(--bg) 45%, transparent); border-left: 3px solid var(--accent); color: inherit; text-decoration: none; position: relative; }
.link-card:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }
.link-thumb { display: block; width: 100%; max-height: 200px; object-fit: cover; background: var(--bg-2); }
.link-meta { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; min-width: 0; }
.link-site { font-size: 12px; color: var(--muted); text-transform: lowercase; }
.link-title { font-weight: 650; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-desc { font-size: 13px; color: var(--muted); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.composer-preview { }
.composer-preview .link-card { flex-direction: row; align-items: center; margin: 0; background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); box-shadow: 0 8px 24px rgba(0,0,0,.3); padding-right: 40px; }
.composer-preview .link-thumb { width: 72px; height: 72px; max-height: none; flex: none; }
.composer-preview .link-card.loading .link-site { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.link-close { position: absolute; top: 6px; right: 6px; }

/* recovery phrase: numbered words in columns, read top to bottom */
.phrase-grid { list-style: decimal inside; columns: 3 7.5em; column-gap: 16px; margin: 12px 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; line-height: 1.9; user-select: text; }
.phrase-grid li::marker { color: var(--muted); font-size: 12px; }
@media (max-width: 380px) { .phrase-grid { columns: 2; } }

/* message menu: right-click (desktop) or long-press (touch). The trash button beside the
   bubble only shows up for keyboard users, as the way into the same menu. */
.msg { align-items: center; gap: 4px; }
.msg.out .msg-delete { order: -1; }
.msg-delete:not(:focus-visible):not([aria-expanded="true"]) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.msg-delete { flex: none; }
.menu.compact { min-width: 190px; }
.menu.compact > button { padding-block: 8px; }
.menu > button.danger strong { color: var(--bad); }
.bubble.deleted .text { font-style: italic; color: var(--muted); }
.msg .bubble.deleted { background: transparent; border: 1px dashed var(--line); }

/* chat markdown */
.bubble .md-p { white-space: pre-wrap; }
.bubble code.md-code { font-family: var(--mono); font-size: .9em; padding: 1px 5px; border-radius: 5px; background: rgba(127,127,127,.18); white-space: pre-wrap; }
.bubble pre.md-pre { display: block; margin: 4px 0; padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,.22); font-family: var(--mono); font-size: 12.5px; line-height: 1.45; white-space: pre; overflow-x: auto; max-width: 100%; }
.bubble blockquote.md-quote { display: block; margin: 4px 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--accent); color: var(--muted); }
.bubble .md-list { display: block; margin: 4px 0; padding-left: 22px; white-space: normal; }
.bubble .md-list li { margin: 1px 0; }
.bubble del { opacity: .75; }

/* ------------------------------------------------------------ phones + installed app (PWA) */
/* The page itself never scrolls: #app is the one scroll container (lock, restore and landing screens
   scroll inside it, the chat scrolls its own lists). A scrolling page fought the keyboard handling in
   mobile.ts and jittered. text-size-adjust: no font inflation in landscape. */
html, body { overscroll-behavior: none; overflow: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#app { height: var(--app-h, 100%); overflow-y: auto; overscroll-behavior-y: none; }   /* height follows the on-screen keyboard (mobile.ts) */
.messages, .contacts, .dlg, .emoji-grid { overscroll-behavior: contain; }
button, .contact, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* notches and home indicators */
.rail-head { padding-top: calc(14px + env(safe-area-inset-top)); padding-left: calc(16px + env(safe-area-inset-left)); }
.net { padding-bottom: calc(14px + env(safe-area-inset-bottom)); padding-left: calc(16px + env(safe-area-inset-left)); }
.chat-head { padding-top: calc(12px + env(safe-area-inset-top)); padding-right: calc(16px + env(safe-area-inset-right)); }
.composer { padding-right: calc(16px + env(safe-area-inset-right)); }

@media (pointer: coarse) {
  /* 16 px or more in every field, at any width: iOS zooms in on focus below that (and stays zoomed) */
  input:not([type=checkbox]):not([type=radio]), textarea, textarea.code, select { font-size: 16px; }
  /* fingers, not cursors: 44 px targets */
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn.small { width: 36px; height: 36px; }
  .composer .attach, .composer .emoji-btn, .composer .timer-btn { width: 44px; height: 44px; min-width: 44px; }
  .send { width: 46px; height: 46px; }
  .btn { min-height: 44px; }
  .btn.link { min-height: 0; }
  .contact { padding: 12px 10px; }
  .menu > button { padding: 13px 14px; }
  .emoji { width: 44px; height: 44px; }
  .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .ttl-btn { padding: 9px 12px; }
  /* long-press opens the message menu (with Copy), instead of the OS text callout */
  .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .net-grid dt[title] { text-decoration: none; }
}

@media (max-width: 720px) {
  .shell, .shell.show-chat .chat { height: 100%; }
  .composer { gap: 6px; padding-left: calc(8px + env(safe-area-inset-left)); padding-right: calc(8px + env(safe-area-inset-right)); padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .composer textarea { font-size: 16px; padding: 10px 14px; }   /* 16 px: iOS doesn't zoom in on focus */
  input:not([type=checkbox]), textarea { font-size: 16px; }
  .chat-head { gap: 8px; padding-left: 6px; }
  .messages { padding: 12px 10px; }
  .bubble { max-width: 84%; }
  .rail-actions .btn { padding: 11px 10px; }

  /* menus, pickers and dialogs become bottom sheets */
  .popover {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important;
    max-width: none; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); animation: sheet .18s ease-out;
  }
  .popover::before { content: ""; display: block; width: 40px; height: 4px; margin: 0 auto 8px; border-radius: 4px; background: var(--line); }
  .menu, .timer-menu { min-width: 0; max-width: none; }
  .emoji-picker { width: 100%; }
  .emoji-grid { height: min(300px, 42vh); }
  .dlg {
    /* bottom sheet that stays above the keyboard: --app-h is the visible height (mobile.ts) */
    width: 100vw; max-width: 100vw; max-height: calc(var(--app-h, 100dvh) * .92);
    margin: auto 0 max(0px, calc(100dvh - var(--app-h, 100dvh)));
    border-radius: 20px 20px 0 0; border-bottom: 0; animation: sheet .2s ease-out;
  }
  .dlg-body { padding: 4px 18px calc(22px + env(safe-area-inset-bottom)); }
  .dlg > header { padding-left: 18px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { transform: translateY(40%); opacity: .4; } }

/* ---------------------------------------------------------- QR invites -- */
.center { text-align: center; }
.qr-wrap { display: flex; justify-content: center; margin: 4px 0 6px; }
.qr { width: min(240px, 70vw); height: auto; border-radius: 12px; display: block; }
.scan { margin: 10px 0 4px; }
.scan-frame { position: relative; width: min(280px, 78vw); aspect-ratio: 1; margin: 0 auto; border-radius: 16px; overflow: hidden; background: #000; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame::after { content: ""; position: absolute; inset: 14%; border: 2px solid rgba(255, 255, 255, .85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }

/* ------------------------------------------------------------- landing (first visit) */
.landing {
  height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: radial-gradient(900px 520px at 85% -5%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 65%), var(--bg);
  padding: 0 max(20px, env(safe-area-inset-left)) calc(56px + env(safe-area-inset-bottom));
}
.landing > * { max-width: 1040px; margin-left: auto; margin-right: auto; }
.land-top { display: flex; align-items: center; gap: 10px; padding: max(18px, env(safe-area-inset-top)) 0 0; }
.land-top img { border-radius: 9px; }
.btn.big { padding: 13px 22px; font-size: 16px; border-radius: 12px; }

.land-hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center; padding: 72px 0 64px; }
.land-pitch h1 { font-size: clamp(34px, 5.4vw, 58px); line-height: 1.04; letter-spacing: -.035em; font-weight: 750; max-width: 15ch; text-wrap: balance; }
.landing .row { justify-content: flex-start; }
.land-lede { font-size: 18px; line-height: 1.55; color: color-mix(in srgb, var(--text) 82%, var(--muted)); max-width: 52ch; margin: 22px 0 28px; }
.land-pitch .fine { margin-top: 12px; }

/* The crowd: 25 envelopes. A check sweeps across them once; only one opens. */
.land-crowd { margin: 0; }
.crowd { width: 100%; max-width: 380px; display: block; margin: 0 auto; overflow: visible; }
.env rect { fill: var(--panel-2); stroke: var(--line); stroke-width: 1.5; }
.env .flap { transform-box: fill-box; transform-origin: top; fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.env { animation: check 3.2s ease-in-out both; animation-delay: calc(var(--i) * 70ms + 400ms); transform-box: fill-box; transform-origin: center; }
.env.mine rect { animation: mine-fill .6s ease-out both 2.7s; }
.env.mine .flap { animation: mine-open .6s ease-out both 2.7s; }
.env.mine { animation-name: mine-pop; }
@keyframes check { 0%, 100% { opacity: 1; } 8% { opacity: .35; } 16% { opacity: 1; } }
@keyframes mine-pop { 0%, 70% { transform: none; } 80% { transform: scale(1.12); } 100% { transform: scale(1.06); } }
@keyframes mine-fill { to { fill: var(--accent); stroke: var(--accent); } }
@keyframes mine-open { to { stroke: var(--accent); opacity: 1; transform: scaleY(-1); } }
.land-crowd figcaption { max-width: 36ch; margin: 18px auto 0; text-align: center; }

.land-section { padding: 44px 0 8px; border-top: 1px solid var(--line); }
.land-section h2 { font-size: 24px; letter-spacing: -.02em; margin-bottom: 18px; }
.land-section > .fine { margin: -10px 0 16px; }
.land-section .row { margin-top: 28px; }

.offers { display: grid; grid-template-columns: 200px 1fr; gap: 0 40px; margin: 0; }
.offers dt { font-weight: 650; padding: 14px 0; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.offers dd { margin: 0; padding: 14px 0; border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.offers dt:first-of-type, .offers dd:first-of-type { border-top: 0; }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 70ch; }
.checks li { position: relative; padding-left: 28px; line-height: 1.5; }
.checks li::before {
  content: ""; position: absolute; left: 2px; top: .3em; width: 14px; height: 8px;
  border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg) translate(1px, 1px);
}
.checks.open li { color: color-mix(in srgb, var(--text) 80%, var(--muted)); }
.checks.open li::before { width: 10px; height: 10px; border: 2px solid var(--muted); border-radius: 50%; transform: none; top: .35em; }

.steps { margin: 0; padding-left: 22px; display: grid; gap: 12px; max-width: 70ch; line-height: 1.5; }
.steps li::marker { color: var(--accent-2); font-weight: 700; }

@media (max-width: 820px) {
  .land-hero { grid-template-columns: 1fr; gap: 36px; padding: 40px 0 44px; }
  .land-pitch h1 { max-width: 16ch; }
  .crowd { max-width: 300px; }
  .offers { grid-template-columns: 1fr; }
  .offers dt { padding-bottom: 6px; }
  .offers dd { border-top: 0; padding-top: 0; }
  .offers dt:first-of-type { padding-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .env.mine rect { fill: var(--accent); stroke: var(--accent); }
  .env.mine .flap { stroke: var(--accent); opacity: 1; transform: scaleY(-1); }
  .env.mine { transform: scale(1.06); }
}

/* ------------------------------------------------------------- updates */
.update-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60; bottom: calc(16px + env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 14px;
  background: var(--panel-2); border: 1px solid var(--accent); box-shadow: 0 12px 34px rgba(0, 0, 0, .4);
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 14px;
}
.update-bar > span { flex: 1 1 220px; }
.update-bar .row { margin: 0; }
.row.start { justify-content: flex-start; }
.land-text { max-width: 64ch; line-height: 1.55; margin: 0 0 4px; }
.checksums { margin-top: 14px; max-width: 70ch; }
.checksums summary { cursor: pointer; color: var(--accent-2); font-size: 14px; }
.checksums dl { margin-top: 10px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.land-section > .row { margin: 18px 0 10px; }
.checksums dd { text-align: left; word-break: break-all; font-size: 12.5px; }
.checksums .net-grid { grid-template-columns: max-content 1fr; }

/* ------------------------------------------------------- notifications */
select.inline-select { display: inline-block; width: auto; padding: 3px 8px; margin: 0 2px; border-radius: 8px; }
.fine.warn { color: var(--danger, #e5484d); }

/* above the composer: status, the message being replied to, the link preview (stacked) */
.composer-above { position: absolute; left: 12px; right: 12px; bottom: calc(100% + 6px); z-index: 5; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.composer-above > * { pointer-events: auto; }
.composer-above > [hidden] { display: none; }
.composer-reply { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 4px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.composer-reply .quote { flex: 1; margin: 0; }

/* replies: the quoted message inside a bubble */
.quote { display: flex; flex-direction: column; gap: 1px; min-width: 0; margin: 0 0 6px; padding: 4px 10px; border: 0; border-left: 3px solid var(--accent); border-radius: 6px; background: rgba(127,127,127,.14); color: inherit; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.quote strong { font-size: 12px; color: var(--accent); }
.quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.quote.gone span { font-style: italic; opacity: .6; }
.bubble .quote { width: 100%; }
.msg.flash .bubble { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }

/* swipe a bubble: right = reply, left = message menu */
.bubble.swiping { will-change: transform; }
.bubble.swipe-armed { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent); }

/* safety number by QR (contact details) */
.safety-qr { margin-top: 10px; }
.qr-wrap.small .qr { width: min(200px, 60vw); height: auto; }
.safety-qr .row { justify-content: center; }
p.bad { color: var(--bad); }

/* ---- group chats */
.avatar.group .icon { width: 20px; height: 20px; stroke-width: 2; }
.avatar.small { width: 32px; height: 32px; font-size: 12px; }
.contact-name.as-is { text-transform: none; }
.bubble .author { display: block; text-transform: capitalize; font-size: 12.5px; margin-bottom: 2px; color: hsl(var(--h) 70% 72%); }
@media (prefers-color-scheme: light) { .bubble .author { color: hsl(var(--h) 60% 38%); } }
.chat-title.as-button { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; color: inherit; font: inherit; min-width: 0; }
.chat-title.as-button:hover .contact-name { text-decoration: underline; text-underline-offset: 3px; }
.group-form .field > span { font-size: 13px; color: var(--muted); }
.pick-list, .member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; cursor: pointer; color: var(--text); }
.pick:hover { background: var(--panel-2); }
.pick input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.pick .avatar { width: 32px; height: 32px; font-size: 12px; }
.pick-name { flex: 1; display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize; min-width: 0; }
.member { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.member-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.member-name { font-weight: 600; display: inline-flex; align-items: center; gap: 6px; text-transform: capitalize; }
.member-list { max-height: none; }
