* { box-sizing: border-box }

/* HTML `hidden` attribute should always win, even against display:flex
 * rules elsewhere. (Browser default specificity is zero — any class
 * override would otherwise unhide the element by accident.) */
[hidden] { display: none !important; }

/* Colors come from lui (lui.css CSS variables); the whole app follows
 * lui.theme() (light/dark). We only keep telefon-specific layout here and
 * paint with var(--bg/--ink/--accent/...). Status dots stay semantic
 * (green/grey/yellow), the video stage stays black. */

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;     /* off-screen siblings (translateX) must not extend scroll area */
}

button {
  font: inherit;
  padding: .55rem 1.1rem;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}
button.primary   { background: var(--accent); color: #fff; border-color: transparent }
button.primary:hover   { box-shadow: var(--sh-1); filter: brightness(1.05) }
button.secondary { background: var(--bg-soft); color: var(--ink); border-color: var(--line) }
button.secondary:hover { border-color: var(--ink-soft) }
button.danger    { background: var(--danger); color: #fff; border-color: transparent }
button.danger:hover { filter: brightness(1.05) }
button.iconbtn   { background: transparent; border: 0; padding: .3rem .55rem; font-size: 1.25rem; color: var(--ink) }
button.iconbtn:hover { color: var(--accent) }

input[type=text], textarea#text-input {
  font: inherit; padding: .55rem .7rem;
  background: var(--bg-soft); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, textarea#text-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255,98,0,.12);
}
/* Auto-growing composer: JS sets height to fit content up to max-height, then
 * the textarea scrolls internally. resize:none hides the manual drag handle. */
textarea#text-input { resize: none; max-height: 120px; overflow-y: auto; line-height: 1.3; }

/* ============================== screens ============================== */

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}
.screen.active { display: flex; }

.topbar {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; background: var(--bg-soft);
  /* Clear the status bar (clock / signal icons) at the top. */
  padding-top: calc(.6rem + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.topbar .title {
  flex: 1; font-weight: 600; font-size: 1.05rem;
  display: flex; align-items: baseline; gap: .5rem; min-width: 0;
}
.topbar .title .muted { font-weight: normal; font-size: .8rem }
#my-nickname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.muted-line {
  padding: .25rem 1rem; background: var(--bg-soft); color: var(--ink-soft);
  font-size: .8rem;
}
.muted { color: var(--ink-soft); font-size: .85rem }

.fatal {
  background: var(--danger); border-bottom: 1px solid var(--danger-d);
  padding: .8rem 1rem; color: #fff; font-weight: 500;
}

/* ============================== contacts ============================== */

.contacts {
  list-style: none; padding: 0; margin: 0;
  flex: 1; overflow-y: auto;
}
.contact {
  display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.contact:hover { background: var(--bg-soft) }
.contact .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .9rem; flex: 0 0 auto;
}
.contact .avatar.off { background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--line) }
/* Info contact: a neutral blue tint distinct from the orange person avatar;
 * the ℹ️ emoji is the content. */
.contact .avatar.avatar-info {
  background: color-mix(in srgb, #3b82f6 70%, var(--bg-soft));
  color: #fff; font-size: 1.1rem;
}
/* Claude contact: a light circle carrying the Claude brand mark in its own
 * orange (logo.svg is a black single-path silhouette → recolour via mask). */
.contact .avatar.avatar-claude {
  background: var(--bg-soft); border: 1px solid var(--line);
}
.contact .avatar.avatar-claude .type-logo {
  width: 66%; height: 66%; display: block;
  background: #d97757;                                  /* Claude orange */
  -webkit-mask: url(./logo.svg) center / contain no-repeat;
          mask: url(./logo.svg) center / contain no-repeat;
}
/* Offline type avatars: just mute them — KEEP their coloured background, else the
 * white ℹ️ glyph would land on the light --bg-soft and vanish (the bug Leo saw). */
.contact .avatar.avatar-info.off, .contact .avatar.avatar-claude.off {
  filter: grayscale(.4) opacity(.85);
}
.contact .name { flex: 1; font-weight: 500 }
.contact .id   { color: var(--ink-soft); font-size: .8rem; font-family: ui-monospace, monospace; }
.contact .dot  { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto }

/* Status dots stay semantic (not brand): green=online, grey=offline,
 * yellow=warning. Don't map these to lui accent. */
.dot-on   { background: #3c3; box-shadow: 0 0 5px #3c3 }
.dot-off  { background: #888 }
.dot-warn { background: #c93; box-shadow: 0 0 5px #c93 }

/* Unread-message count, shown just before the online dot in the list. */
.contact .unread-badge {
  flex: 0 0 auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px;
  background: var(--accent); color: #fff;
  font-size: .72rem; font-weight: 700; line-height: 18px;
  text-align: center;
}

/* Missed-call count, shown next to the unread badge. Same pill shape as the
 * unread badge but red (a missed call, not a new message) and carries a 📞
 * glyph + count. Cleared when the chat is opened or the call log is viewed. */
.contact .missed-badge {
  flex: 0 0 auto;
  height: 18px; padding: 0 6px;
  border-radius: 9px;
  background: #d33; color: #fff;
  font-size: .72rem; font-weight: 700; line-height: 18px;
  white-space: nowrap; text-align: center;
}

.empty {
  padding: 2rem 1rem; color: var(--ink-soft); font-size: .9rem; text-align: center;
}

.bottombar {
  display: flex; gap: .5rem; padding: .75rem 1rem;
  /* Keep clear of the Android/iOS bottom navigation bar. */
  padding-bottom: calc(.75rem + env(safe-area-inset-bottom));
  background: var(--bg-soft); border-top: 1px solid var(--line);
}
.bottombar button { flex: 1 }

/* ============================== call window ============================== */

/* The video call lives in a floating, screen-independent window (#call-window).
 * Expanded: near-fullscreen on mobile, centered window on desktop.
 * Minimized (.mini): a small draggable PiP square showing only the peer video. */

.video-stage {
  position: relative; flex: 1;
  background: #000;
  min-height: 0;
}
.peer-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: contain;
  background: #000;
}
.my-video {
  position: absolute; right: 12px; bottom: 12px;
  width: 30%; max-width: 180px; aspect-ratio: 3/4;
  border-radius: var(--r-sm); border: 2px solid var(--bg-soft);
  object-fit: cover; background: #111;
  z-index: 2;
  transform: scaleX(-1);   /* mirror the self-view, like a real mirror */
}
/* Before the peer's video arrives, the self-view fills the whole window so you
   can clearly see and prepare yourself; it shrinks to the corner PiP on connect. */
.call-window.no-remote .my-video {
  inset: 0; right: auto; bottom: auto;
  width: 100%; height: 100%; max-width: none; aspect-ratio: auto;
  border: 0; border-radius: 0; z-index: 1;
}
.call-window.no-remote .peer-video { display: none; }
/* Draggable PiP: touch-action:none stops the browser from scrolling the
 * page while the finger drags the mini-preview. */
#my-video { touch-action: none; cursor: grab; }
#my-video.dragging { cursor: grabbing; }
.stats-toggle {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 32px; height: 32px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,.6); color: #fff;
  font-size: 1.1rem; line-height: 30px;
  cursor: pointer; border: 0;
}
.stats-overlay {
  position: absolute; top: 12px; left: 12px; z-index: 3;
  background: rgba(0,0,0,.7); color: #ddd;
  font-family: ui-monospace, monospace; font-size: .78rem;
  padding: .5rem .7rem; border-radius: var(--r-sm);
  white-space: pre; pointer-events: none;
}

/* ── floating call window ─────────────────────────────────────────────────── */
.call-window {
  position: fixed; z-index: 500;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); box-shadow: 0 18px 50px rgba(0,0,0,.4);
  overflow: hidden;
  inset: env(safe-area-inset-top) 0 0 0;            /* mobile: near-fullscreen */
  border-radius: 16px 16px 0 0;
}
@media (min-width: 760px) {                          /* desktop: maximised window */
  .call-window {
    /* all four edges anchored → fills the screen minus a small margin.
       (Do NOT set top/left:auto here — that unsets two anchors and the
       window collapses to its content size in the bottom-right corner.) */
    inset: 2.5vh 2.5vw;
    transform: none;
    border-radius: 16px;
  }
}
.call-window[hidden] { display: none; }
.call-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg-soft); border-bottom: 1px solid var(--line);
}
.call-head .call-peer { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Connection-type label, shown small on its own line in the controls row:
   green "direct" (P2P) / red "stun" (relayed via TURN). */
.net-label {
  flex-basis: 100%; text-align: center; font-size: .72rem;
  font-family: ui-monospace, monospace; letter-spacing: .04em; order: -1;
}
.net-label.direct { color: #3c3; }
.net-label.relay  { color: #e53935; }
.call-state-pill { color: var(--ink-soft); font-size: .85rem; }
.call-iconbtn {
  border: 0; background: transparent; cursor: pointer; font-size: 1.1rem;
  width: 38px; height: 38px; border-radius: var(--r-sm); color: var(--ink);
}
.call-iconbtn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.call-iconbtn-danger:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
/* Compact single-row controls: hang up + mic/video toggles + flip + settings.
   flex-wrap is a safety net for very narrow screens; normally it's one line. */
.call-controls {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  padding: .6rem 1.25rem; flex-wrap: wrap;
  background: var(--bg-soft); border-top: 1px solid var(--line);
  padding-bottom: calc(.6rem + env(safe-area-inset-bottom));
}
/* Round icon-only control button. */
.callbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 auto; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--ink);
  font-size: 1.2rem; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.callbtn:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
/* Hang up: bright red — a wider rounded pill (a tight circle was awkward to hit). */
.callbtn-end {
  width: auto; min-width: 72px; padding: 0 20px; border-radius: 22px;
  background: var(--danger); color: #fff;
  box-shadow: 0 4px 14px rgba(229,57,53,.4);
}
.callbtn-end:hover { background: var(--danger); filter: brightness(1.08); }
/* Icon + slider group for mic / video on-off toggles. */
.calltoggle {
  display: inline-flex; align-items: center; gap: .25rem; flex: 0 0 auto;
  cursor: pointer; user-select: none;
}
.calltoggle .cic { font-size: 1.1rem; line-height: 1; }
/* Slightly smaller toggle so two of them fit alongside the buttons on ~360px. */
.calltoggle .toggle .track { width: 34px; height: 19px; }
.calltoggle .toggle .track::after { width: 15px; height: 15px; }
.calltoggle .toggle > input:checked + .track::after { transform: translateX(15px); }
/* Section heading inside the call-settings window. */
.dlg-section {
  font-size: .8rem; font-weight: 600; color: var(--ink-soft);
  margin-top: .6rem; text-transform: uppercase; letter-spacing: .03em;
}

/* Direct hang-up shown only on the minimized PiP (so you can always stop). */
.cw-mini-end { display: none; }
.call-window.mini .cw-mini-end {
  display: flex; align-items: center; justify-content: center;
  position: absolute; top: 5px; right: 5px; z-index: 4;
  width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: var(--danger); color: #fff; font-size: .85rem; line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

/* ── minimized call window (draggable PiP square, tap to expand) ──────────── */
.call-window.mini {
  inset: auto; top: auto; left: auto;
  right: 12px; bottom: 12px; transform: none;
  width: 116px; height: 160px;
  border-radius: 14px; border: 2px solid var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  cursor: grab; touch-action: none;
}
.call-window.mini.dragging { cursor: grabbing; }
.call-window.mini .call-head,
.call-window.mini .call-controls,
.call-window.mini .my-video,
.call-window.mini .stats-overlay,
.call-window.mini .stats-toggle { display: none; }   /* mini shows only peer video */
.call-window.mini .video-stage { min-height: 0; }
.call-window.mini .peer-video { object-fit: cover; }

.chat-wrap {
  display: flex; flex-direction: column;
  flex: 1; max-height: none; min-height: 100px;
  background: var(--bg);
  border-top: 1px solid var(--line);
}

#chat {
  flex: 1; overflow-y: auto;
  padding: .5rem .75rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.msg {
  max-width: 75%; padding: .4rem .65rem;
  border-radius: var(--r-md); font-size: .9rem; word-wrap: break-word;
  display: inline-flex; align-items: flex-end; gap: .35rem;
}
/* Outgoing = soft orange TINT + orange OUTLINE (calm in BOTH themes, no
 * full-screen orange fill); incoming = neutral. Text stays ink-coloured. */
.msg.me   { background: rgba(255,98,0,.10); color: var(--ink); border: 1.5px solid var(--accent); align-self: flex-end; border-bottom-right-radius: var(--r-sm) }
.msg.them { background: var(--bg-soft); color: var(--ink); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: var(--r-sm) }
.msg.me .msg-status, .msg.me .msg-edited { color: var(--ink-soft); }
/* Read receipt: ✓✓ turns blue once the peer has read it (delivered stays grey),
 * so delivered vs read is distinguishable (WhatsApp/Telegram convention). */
.msg.me .msg-status.read { color: #2e9bff; }
.msg.me .msg-link { color: var(--accent); }

/* Dark theme chat: greyish (not black) canvas; incoming a shade lighter so it
 * reads; outgoing tint a touch stronger on the darker canvas. */
html[data-theme="dark"] #chat,
html[data-theme="dark"] .chat-wrap { background: #20232a; }
html[data-theme="dark"] .msg.them  { background: #2b3039; border-color: #363c46; }
html[data-theme="dark"] .msg.me    { background: rgba(255,98,0,.14); }
.msg-status {
  font-size: .7rem; color: rgba(255,255,255,.65);
  flex: 0 0 auto;
  -webkit-user-select: none; user-select: none;   /* don't grab ticks when selecting text */
}
.msg { cursor: default; }
.msg.editing { outline: 2px solid var(--accent); outline-offset: 1px; }
.msg-edited {
  font-size: .7rem; color: rgba(255,255,255,.5);
  -webkit-user-select: none; user-select: none;   /* time/edited mark not part of the text */
}
/* On the neutral incoming bubble the ticks/time need ink-based muting, not
 * white-on-light. */
.msg.them .msg-status, .msg.them .msg-edited { color: var(--ink-soft); }

/* The text must stay user-selectable (WebView often disables selection
 * globally) so links can be selected/copied natively. */
.msg-text {
  -webkit-user-select: text; user-select: text;
  white-space: pre-wrap;        /* render embedded newlines + wrap long lines */
  overflow-wrap: anywhere;      /* break very long words/URLs instead of overflowing */
}

/* Floating "Copy" button shown above a text selection. WebView often fails to
 * raise the native selection ActionMode, so we provide our own. */
.sel-copy-btn {
  position: fixed; z-index: 1000;
  transform: translate(-50%, 0);
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-sm);
  padding: .35rem .7rem; font: inherit; font-size: .85rem;
  box-shadow: var(--sh-2);
  cursor: pointer;
}

/* Per-message actions handle (⋮). */
.msg-actions {
  background: transparent; border: 0; padding: 0 .1rem; margin: 0;
  color: rgba(255,255,255,.55); font-size: 1.05rem; line-height: 1;
  cursor: pointer; flex: 0 0 auto; align-self: center;
  -webkit-user-select: none; user-select: none;
}
.msg-actions:hover { color: #fff }
.msg.them .msg-actions { color: var(--ink-soft); }
.msg.them .msg-actions:hover { color: var(--ink); }

.edit-banner {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .35rem .75rem;
  background: var(--bg-soft); color: var(--ink);
  border-top: 1px solid var(--line); border-left: 3px solid var(--accent);
  font-size: .85rem;
}

/* Search-over-history bar, shown above the chat while in search mode. */
.search-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .75rem;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.search-bar #search-input {
  flex: 1; min-width: 0;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: .35rem .55rem; font-size: .9rem;
}
.search-bar #search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,98,0,.12); }
.search-info { color: var(--ink-soft); font-size: .8rem; flex: 0 0 auto; }

/* Search-result highlight inside a message bubble. */
.msg-text mark {
  background: var(--accent); color: #fff;
  border-radius: 3px; padding: 0 1px;
}

.msg-menu {
  position: fixed; z-index: 40;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: .25rem;
  box-shadow: var(--sh-3);
  display: flex; flex-direction: column; min-width: 150px;
}
.msg-menu-item {
  background: transparent; border: 0; color: var(--ink);
  text-align: left;
  padding: .55rem .8rem; border-radius: var(--r-sm); font-size: .9rem;
}
.msg-menu-item:hover { background: var(--bg-soft) }
/* Keep menu items plain — no red fill/text (the global button.danger styling
   made them red-on-red and invisible). The 🗑/🚫 emoji already mark these as
   destructive; simpler reads better. */
.msg-menu-item.danger { color: var(--ink); background: transparent }

/* The `display: flex` below would otherwise override the [hidden] attribute,
 * so the composer never disappears for read-only (info) chats. Force it. */
.chat-input[hidden] { display: none; }
.chat-input {
  display: flex; gap: .5rem; padding: .5rem .75rem;
  /* Keep the text field above the Android/iOS bottom navigation bar. */
  padding-bottom: calc(.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); align-items: center;
  background: var(--bg-soft);
}
.chat-input #text-input {
  flex: 1; resize: none;
  line-height: 1.3; max-height: 120px;
  overflow-y: auto;
  background: var(--bg);
}
.chat-input button { flex: 0 0 auto }
#attach-btn { padding: .55rem .8rem }

.msg-file {
  display: flex; flex-direction: column; gap: .25rem;
  min-width: 180px; max-width: 260px;
}
.msg-file img.thumb {
  max-width: 100%; max-height: 200px; border-radius: var(--r-sm);
  cursor: pointer; display: block;
}
.msg-file audio, .msg-file video {
  width: 100%; max-height: 200px; border-radius: var(--r-sm);
}
.msg-file .filemeta {
  font-size: .75rem; opacity: .8;
  display: flex; align-items: center; gap: .35rem;
}
.msg-file .filemeta a,
.msg-file .filemeta .filelink {
  color: inherit; text-decoration: underline;
}
/* Native-shell file row: a tappable span (no <a download>) opening the chooser. */
.msg-file .filemeta .filelink { cursor: pointer; }

/* Links: white-underlined inside the accent (outgoing) bubble, accent-colored
 * inside the neutral (incoming) one. */
.msg-link { color: #fff; text-decoration: underline; word-break: break-all; }
.msg.them .msg-link { color: var(--accent); }

/* ============================== link previews ============================== */

.preview-card {
  display: block; text-decoration: none; color: inherit;
  max-width: 75%; margin: -.05rem 0 .2rem;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md); overflow: hidden;
}
.preview-card.me   { align-self: flex-end }
.preview-card.them { align-self: flex-start }
.preview-card:hover { border-color: var(--ink-soft) }
.preview-img {
  display: block; width: 100%; max-height: 180px;
  object-fit: cover; background: var(--line);
}
.preview-body { padding: .45rem .6rem; display: flex; flex-direction: column; gap: .15rem }
.preview-site  { font-size: .7rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em }
.preview-title { font-size: .9rem; font-weight: 600; line-height: 1.25; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden }
.preview-desc  { font-size: .8rem; color: var(--ink-soft); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden }

/* ============================== dialogs ============================== */

.dialog {
  /* Above lui windows/confirms (which sit at 500–950): a modal dialog is always
     the newest, topmost layer — e.g. the password prompt over the settings window. */
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(28,26,24,.5);
  display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.dialog:not([hidden]) { display: flex; }
.dialog-box {
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.25rem; max-width: 420px; width: 100%;
  display: flex; flex-direction: column; gap: .5rem;
  box-shadow: var(--sh-3);
}
.dialog-title { font-size: 1.1rem; font-weight: 600; margin-bottom: .25rem }
.dialog-text  { color: var(--ink-soft); font-size: .9rem }
.dialog-box label { font-size: .8rem; color: var(--ink-soft); margin-top: .25rem }
.dialog-error { background: var(--danger); color: #fff; padding: .5rem .75rem; border-radius: var(--r-sm); font-size: .85rem }
/* Device-picker list inside a .dialog (camera/mic/speaker choice). */
.dev-list { display: flex; flex-direction: column; gap: 2px; margin: .5rem 0; max-height: 50vh; overflow-y: auto; }
.dev-list .msg-menu-item { white-space: normal; word-break: break-word; }
.dialog-buttons {
  display: flex; gap: .5rem; justify-content: flex-end; margin-top: .75rem;
}

/* ============================== lightbox / toasts ============================== */

.lightbox {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, .95);
  display: none; align-items: center; justify-content: center;
}
.lightbox:not([hidden]) { display: flex; }
.lightbox img {
  max-width: 100vw; max-height: 100vh;
  object-fit: contain; user-select: none;
  cursor: pointer;
}
.lightbox-close {
  position: absolute; top: max(env(safe-area-inset-top), 12px); right: 12px;
  width: 40px; height: 40px; padding: 0; z-index: 31;
  border-radius: 50%; background: rgba(0, 0, 0, .6);
  color: #fff; font-size: 1.4rem; line-height: 38px; cursor: pointer; border: 0;
}

.toasts {
  /* Top of the screen (under the status bar) so toasts never cover the
   * bottom action buttons (e.g. "Update"). Container ignores pointer
   * events; individual toasts re-enable them to stay tap-to-dismiss. */
  position: fixed; z-index: 70;
  top: calc(.6rem + env(safe-area-inset-top)); left: 1rem; right: 1rem;
  display: flex; flex-direction: column; gap: .5rem; align-items: center;
  pointer-events: none;
}
/* Scoped to the #toasts container so it never collides with lui's own
 * body-level .toast (lui appends its toast directly to <body>). */
.toasts .toast {
  background: var(--bg-soft); color: var(--ink);
  border: 1px solid var(--line);
  padding: .6rem 1rem; border-radius: var(--r-sm);
  border-left: 3px solid var(--accent);
  box-shadow: var(--sh-2);
  font-size: .9rem; min-width: 200px; max-width: 360px;
  animation: toast-in .2s ease-out;
  pointer-events: auto; cursor: pointer;
}
.toasts .toast.error   { border-left-color: var(--danger) }
.toasts .toast.success { border-left-color: #3a9a3a }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0 }
  to   { transform: translateX(0);    opacity: 1 }
}

@media (max-width: 600px) {
  .my-video { width: 35%; max-width: 140px }
  .contact .id { display: none }
}

/* ============================== lui settings window ==============================
 * Layout helpers for the settings window content (built in openSettings()).
 * Colors come from lui (the window follows lui.theme()); these only handle
 * spacing/flow. Scoped under .win-body so they never touch the main telefon UI. */
.win-body .set-sec { margin: 0 0 22px; }
.win-body .set-sec:last-child { margin-bottom: 4px; }
.win-body .set-sec > h3 { margin: 0 0 10px; }

/* Unified setting row: label on the left, control(s)/value on the right, one
   thin divider between rows. Same height as a toggle so the list reads evenly. */
.win-body .set-line {
  display: flex; align-items: center; gap: .75rem; min-height: 44px;
  padding: .5rem 0; border-bottom: 1px solid var(--line);
}
.win-body .set-line:last-child { border-bottom: 0; }
.win-body .set-line > .set-label { flex: 1; min-width: 0; color: var(--ink); }
/* Compact buttons sized to about the toggle height (Leonid). */
.win-body .set-line .btn { padding: .4em .8em; }
/* Inline-edit value (name / server URL) sits on the right, not stretched. */
.win-body .set-line > .inline-edit { flex: 0 1 auto; max-width: 60%; text-align: right; }
.win-body .set-line > .input { flex: 1 1 auto; min-width: 0; }
/* Update status line lives just under its row, indented slightly, compact. */
.win-body .set-update-status { margin: -2px 0 6px; line-height: 1.3; min-height: 1em; }
/* Blacklist window rows reuse .set-line; keep the list tight. */
.win-body .set-blacklist { display: flex; flex-direction: column; }
.win-body .set-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.win-body .set-row > .input { flex: 1; min-width: 0; }
.win-body .set-row > .btn { white-space: nowrap; }

/* Inline-editable name: plain text with a pencil hint; click turns it into the
   input next to it (no OK button — committed on blur/Enter). */
.win-body .inline-edit {
  flex: 1; min-width: 0; cursor: pointer; user-select: none;
  padding: .5em .2em; font-weight: 600;
  border-bottom: 1px dashed var(--line);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.win-body .inline-edit::after { content: ' ✏️'; opacity: .5; font-weight: 400; font-size: .85em; }
.win-body .inline-edit:hover, .win-body .inline-edit:focus-visible {
  border-bottom-color: var(--accent); outline: none;
}
.win-body .set-adv { margin-top: 12px; }
.win-body .set-adv > summary { cursor: pointer; color: var(--ink-soft); font-size: .9rem; }
.win-body .set-adv > label { display: block; margin: 10px 0 4px; font-size: .85rem; }
.win-body .set-adv > .input { margin-bottom: 4px; }

/* Danger zone: collapsed by default, wipe is a small inline link — never a
   full-width red button sitting where the eye expects "Save". */
.win-body .set-danger > summary {
  cursor: pointer; color: var(--ink-soft); font-size: .9rem;
  list-style: none; user-select: none;
}
.win-body .set-danger > summary::-webkit-details-marker { display: none; }
.win-body .set-danger > summary::before { content: "⚠ "; opacity: .7; }
.win-body .set-danger[open] > summary { color: var(--danger); }
.win-body .set-danger-note { margin: 8px 0 12px; font-size: .85rem; line-height: 1.4; }
.win-body .set-wipe-link {
  display: inline-block; cursor: pointer;
  color: var(--danger); font-size: .9rem; font-weight: 600;
  padding: 6px 12px; border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: var(--r-sm, 8px); background: transparent;
  text-decoration: none;
}
.win-body .set-wipe-link:hover,
.win-body .set-wipe-link:focus-visible {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  outline: none;
}
/* Two account-management actions stacked with breathing room. */
.win-body .set-danger > .set-wipe-link { display: block; width: fit-content; margin-top: 10px; }
