/* Skaylorgram — sky-at-dawn palette. The chat wallpaper is the sky itself. */

:root {
  --sky: #2E7FD6;
  --sky-strong: #1F66B5;
  --sky-soft: #E3EFFB;
  --dawn: #F2A865;
  --ink: #16202B;
  --muted: #6A798A;
  --line: #E2E8EF;
  --panel: #FFFFFF;
  --panel-2: #F4F7FA;
  --hover: #EEF3F8;
  --bubble-in: #FFFFFF;
  --bubble-out: #D9EAFB;
  --meta-out: #4E86BF;
  --danger: #D64545;
  --ok: #2FA35F;
  --online: #3DB36B;
  --pill: rgba(22, 32, 43, .32);
  --link-out: #1F66B5;
  --shadow: 0 1px 2px rgba(22, 32, 43, .12);
  --pop-shadow: 0 8px 28px rgba(22, 32, 43, .18);
  --wall: linear-gradient(180deg, #BFD9F3 0%, #DCEAF7 48%, #F1EBE3 82%, #F7DCC2 100%);
  --wall-clouds:
    radial-gradient(60% 18% at 18% 22%, rgba(255,255,255,.55), transparent 70%),
    radial-gradient(45% 14% at 78% 38%, rgba(255,255,255,.45), transparent 70%),
    radial-gradient(55% 16% at 35% 66%, rgba(255,255,255,.35), transparent 70%);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --sky: #5AA2EA; --sky-strong: #7BB6F0; --sky-soft: #1B2D42; --ink: #E5ECF3; --muted: #8C9BAC;
    --line: #223041; --panel: #131C26; --panel-2: #0F1720; --hover: #1A2532;
    --bubble-in: #1C2835; --bubble-out: #2A5584; --meta-out: #A9CBEE;
    --pill: rgba(255,255,255,.12); --link-out: #CFE5FF;
    --shadow: 0 1px 2px rgba(0,0,0,.35); --pop-shadow: 0 10px 30px rgba(0,0,0,.5);
    --wall: linear-gradient(180deg, #08101B 0%, #0F1B2C 55%, #1C2238 85%, #2E2638 100%);
    --wall-clouds:
      radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.7), transparent 60%),
      radial-gradient(1px 1px at 64% 9%, rgba(255,255,255,.55), transparent 60%),
      radial-gradient(1.5px 1.5px at 83% 27%, rgba(255,255,255,.6), transparent 60%),
      radial-gradient(1px 1px at 37% 34%, rgba(255,255,255,.45), transparent 60%),
      radial-gradient(1px 1px at 22% 52%, rgba(255,255,255,.35), transparent 60%),
      radial-gradient(1.5px 1.5px at 72% 61%, rgba(255,255,255,.3), transparent 60%);
  }
}
:root[data-theme="dark"] {
  --sky: #5AA2EA; --sky-strong: #7BB6F0; --sky-soft: #1B2D42; --ink: #E5ECF3; --muted: #8C9BAC;
  --line: #223041; --panel: #131C26; --panel-2: #0F1720; --hover: #1A2532;
  --bubble-in: #1C2835; --bubble-out: #2A5584; --meta-out: #A9CBEE;
  --pill: rgba(255,255,255,.12); --link-out: #CFE5FF;
  --shadow: 0 1px 2px rgba(0,0,0,.35); --pop-shadow: 0 10px 30px rgba(0,0,0,.5);
  --wall: linear-gradient(180deg, #08101B 0%, #0F1B2C 55%, #1C2238 85%, #2E2638 100%);
  --wall-clouds:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.7), transparent 60%),
    radial-gradient(1px 1px at 64% 9%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 83% 27%, rgba(255,255,255,.6), transparent 60%),
    radial-gradient(1px 1px at 37% 34%, rgba(255,255,255,.45), transparent 60%),
    radial-gradient(1px 1px at 22% 52%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1.5px 1.5px at 72% 61%, rgba(255,255,255,.3), transparent 60%);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body {
  font: 15px/1.4 var(--font);
  color: var(--ink);
  background: var(--panel-2);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--sky); outline-offset: 2px; }
[hidden] { display: none !important; }
img, video { max-width: 100%; }
h2, h3 { margin: 0; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.small { width: 15px; height: 15px; }
svg.i.rot { transform: rotate(180deg); opacity: .5; }
.accent { color: var(--sky); }
.danger-text { color: var(--danger); }
.hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 14px; }
.hint.center { text-align: center; margin-top: 18px; }
.stack { display: grid; gap: 10px; }
.bullets { margin: 6px 0 12px 18px; padding: 0; color: var(--muted); }
.bullets li { margin-bottom: 4px; }

#app { height: 100dvh; }
.boot { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 18px; }

/* ---------- controls ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); }
.input, .textarea { width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); outline: none; transition: border-color .15s; }
.input:focus, .textarea:focus { border-color: var(--sky); }
.textarea { resize: vertical; min-height: 64px; }
.prefix-input { position: relative; }
.prefix-input > b { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 400; }
.prefix-input .input { padding-left: 28px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 10px; background: var(--sky); color: #fff; font-weight: 600; transition: background .15s; }
.btn:hover { background: var(--sky-strong); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13.5px; border-radius: 9px; }
.btn.ghost { background: var(--sky-soft); color: var(--sky); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #bb3a3a; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.link-btn { color: var(--sky); font-size: 13.5px; }
.plain-btn { display: block; margin: 0 auto; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: var(--sky-soft); color: var(--sky); font-size: 12px; font-weight: 600; vertical-align: middle; }
.tag.danger { background: rgba(214, 69, 69, .12); color: var(--danger); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.tabs.three { grid-template-columns: repeat(3, 1fr); }
.tabs.four { grid-template-columns: repeat(4, 1fr); }
.tabs.four button { padding: 8px 2px; font-size: 14px; }
.tabs.five { grid-template-columns: repeat(5, 1fr); }
.tabs.five button { padding: 8px 1px; font-size: 13px; }
.call-log { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 12.5px; }
.call-log-line { padding: 6px 8px; border-radius: 8px; background: var(--panel-2); overflow-wrap: anywhere; }
.tabs button { padding: 8px; border-radius: 8px; color: var(--muted); font-weight: 600; text-align: center; }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.seg { display: flex; gap: 4px; background: var(--panel-2); border-radius: 10px; padding: 3px; }
.seg.wrap { flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 28%; }
.seg button { flex: 1; padding: 8px; border-radius: 8px; text-align: center; color: var(--muted); font-weight: 500; }
.seg button[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.switch-row small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.switch-row input { width: 44px; height: 26px; margin: 0; flex: none; appearance: none; background: var(--line); border-radius: 13px; position: relative; transition: background .15s; cursor: pointer; }
.switch-row input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow); }
.switch-row input:checked { background: var(--sky); }
.switch-row input:checked::after { transform: translateX(18px); }
.radio-list { display: grid; gap: 2px; margin-bottom: 12px; }
.radio-row { display: flex; gap: 10px; align-items: center; padding: 9px 4px; border-radius: 8px; cursor: pointer; }
.radio-row:hover { background: var(--hover); }
.radio-row input { accent-color: var(--sky); width: 18px; height: 18px; }
.error { color: var(--danger); font-size: 13.5px; min-height: 18px; margin: -4px 0 10px; }
.confirm-text { margin: 0 0 16px; color: var(--muted); }
.section-h { margin: 22px 0 12px; font-size: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- auth ---------- */
.auth { height: 100%; overflow: auto; display: grid; place-items: center; padding: 24px; background: var(--wall-clouds), var(--wall); }
.auth-card { width: min(380px, 100%); background: var(--panel); border-radius: 20px; padding: 32px 28px 24px; box-shadow: var(--pop-shadow); }
.auth-logo { width: 84px; height: 84px; display: block; margin: 0 auto 14px; }
.auth h1 { text-align: center; font-size: 30px; letter-spacing: -.02em; }
.auth-sub { text-align: center; color: var(--muted); margin: 4px 0 22px; }
.auth-note { font-size: 12.5px; color: var(--muted); margin: 16px 0 0; text-align: center; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; height: 100dvh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; position: relative; }
.side-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--panel-2); border-radius: 22px; padding: 0 12px; height: 40px; color: var(--muted); border: 1px solid transparent; }
.search:focus-within { border-color: var(--sky); background: var(--panel); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--ink); }
.search svg.i { width: 18px; height: 18px; }
.conn { font-size: 12.5px; color: var(--muted); text-align: center; padding-bottom: 6px; }
.side-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.fab-wrap { position: absolute; right: 18px; bottom: 18px; }
.fab { width: 56px; height: 56px; border-radius: 50%; background: var(--sky); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(46,127,214,.4); }
.fab:hover { background: var(--sky-strong); }

.chat-list, .search-results { padding: 4px 6px 90px; }
.chat-item { width: 100%; display: flex; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 12px; }
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--sky); color: #fff; }
.chat-item.active .time, .chat-item.active .preview, .chat-item.active .prefix, .chat-item.active .accent { color: rgba(255,255,255,.85); }
.chat-item.active .badge { background: #fff; color: var(--sky); }
.chat-item-body { flex: 1; min-width: 0; }
.row1, .row2 { display: flex; align-items: center; gap: 8px; }
.row1 { justify-content: space-between; margin-bottom: 2px; }
.name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.name svg.i { width: 16px; height: 16px; flex: none; }
.time { font-size: 12.5px; color: var(--muted); white-space: nowrap; display: flex; align-items: center; gap: 2px; }
.time svg.i { width: 16px; height: 16px; color: var(--sky); }
.chat-item.active .time svg.i { color: #fff; }
.preview { flex: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prefix { color: var(--ink); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--sky); color: #fff; font-size: 12.5px; font-weight: 600; display: grid; place-items: center; }
.section-title { font-size: 13px; color: var(--muted); padding: 14px 8px 4px; font-weight: 600; }
.empty-note { color: var(--muted); padding: 24px 18px; text-align: center; }
.list-empty { color: var(--muted); padding: 40px 28px; text-align: center; }
.list-empty b { display: block; color: var(--ink); margin-bottom: 6px; font-size: 16px; }

.avatar { width: var(--s); height: var(--s); border-radius: 50%; flex: none; object-fit: cover; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: calc(var(--s) * .38); user-select: none; background: var(--sky); }
.avatar.saved svg.i { width: 50%; height: 50%; }
.avatar-wrap { position: relative; flex: none; }
.online-dot { position: absolute; right: 1px; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: var(--online); border: 2px solid var(--panel); }

/* ---------- chat pane ---------- */
.chat { display: flex; flex-direction: column; min-width: 0; height: 100%; background: var(--wall-clouds), var(--wall); position: relative; overflow: hidden; }
.empty-pane { flex: 1; display: grid; place-items: center; }
.empty-pane span { background: var(--pill); color: #fff; padding: 6px 14px; border-radius: 16px; font-size: 14px; }
.chat-head { display: flex; align-items: center; gap: 2px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 58px; flex: none; }
.chat-head .back { display: none; }
.chat-head-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 4px 6px; border-radius: 10px; }
.chat-head-text { min-width: 0; }
.chat-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.chat-title svg.i { width: 16px; height: 16px; }
.chat-status { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-status.accent { color: var(--sky); }

.messages-wrap { flex: 1; position: relative; min-height: 0; }
.messages { height: 100%; overflow-y: auto; overscroll-behavior: contain; overflow-anchor: none; position: relative; padding: 8px 0; }
.messages-content { position: relative; }
.messages-inner { position: relative; max-width: 780px; margin: 0 auto; padding: 0 14px; }
.top-loader { text-align: center; color: #fff; font-size: 13px; padding: 8px 0; }
.item { display: flow-root; }
.jump { position: absolute; right: 18px; bottom: 16px; width: 46px; height: 46px; border-radius: 50%; background: var(--panel); color: var(--muted); display: grid; place-items: center; box-shadow: var(--pop-shadow); }
.jump-badge { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--sky); color: #fff; font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.day, .system, .unread-line { display: flex; justify-content: center; margin: 12px 0 8px; }
.day span, .system span, .unread-line span { background: var(--pill); color: #fff; font-size: 13px; padding: 3px 12px; border-radius: 12px; backdrop-filter: blur(6px); max-width: 84%; text-align: center; }
.unread-line span { background: var(--sky); }
.chat-hint { margin: 30px auto; text-align: center; background: var(--pill); color: #fff; padding: 16px 22px; border-radius: 16px; max-width: 300px; backdrop-filter: blur(6px); }
.chat-hint b { display: block; margin-bottom: 4px; }

.msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; }
.msg.cont { margin-top: 2px; }
.msg.out { justify-content: flex-end; }
.msg-avatar, .avatar-space { width: 34px; flex: none; align-self: flex-start; }
.bubble { position: relative; max-width: min(540px, 84%); padding: 6px 10px; border-radius: var(--radius); background: var(--bubble-in); box-shadow: var(--shadow); overflow-wrap: anywhere; min-width: 68px; }
.msg.in:not(.cont) .bubble { border-top-left-radius: 5px; }
.msg.out:not(.cont) .bubble { border-top-right-radius: 5px; }
.msg.out .bubble { background: var(--bubble-out); }
.msg.out .text a { color: var(--link-out); }
.msg.flash .bubble { animation: flash 1.2s ease; }
@keyframes flash { 0%, 60% { box-shadow: 0 0 0 3px var(--dawn); } 100% { box-shadow: var(--shadow); } }
.sender { display: block; font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.fwd { font-size: 13.5px; color: var(--sky); margin-bottom: 4px; }
.reply-quote { display: block; width: 100%; border-left: 3px solid var(--sky); background: color-mix(in srgb, var(--sky) 10%, transparent); border-radius: 6px; padding: 3px 8px; margin: 2px 0 5px; font-size: 13.5px; }
.reply-quote b { display: block; color: var(--sky); font-weight: 600; }
.reply-quote span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.text { white-space: pre-wrap; }
.meta { float: right; display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); margin: 8px -2px -4px 12px; white-space: nowrap; user-select: none; }
.msg.out .meta { color: var(--meta-out); }
.meta svg.i { width: 16px; height: 16px; }
.meta .views { display: inline-flex; align-items: center; gap: 2px; margin-right: 4px; }
.meta .views svg.i { width: 15px; height: 15px; }
.bubble.no-text .meta { float: none; display: flex; justify-content: flex-end; margin: 4px 0 0; }
.bubble.visual { padding: 3px; width: min-content; }
.bubble.visual.no-text .meta { position: absolute; right: 9px; bottom: 9px; margin: 0; background: rgba(0,0,0,.45); color: #fff; padding: 1px 7px; border-radius: 10px; }
.bubble.visual .text { padding: 4px 7px 3px; }
.bubble.visual .sender, .bubble.visual .fwd, .bubble.visual .reply-quote { margin-left: 7px; margin-right: 7px; width: auto; }
.media { display: block; border-radius: 11px; max-width: 100%; overflow: hidden; background: rgba(0,0,0,.12); padding: 0; }
.media img, video.media { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 11px; }
video.media { background: #000; object-fit: contain; }
.audio-box { padding: 4px 0; }
.audio-box audio { width: 260px; max-width: 100%; display: block; }
.audio-box small { color: var(--muted); }
.file { display: flex; align-items: center; gap: 10px; padding: 4px 0; color: inherit; min-width: 220px; }
.file:hover { text-decoration: none; }
.file-icon { width: 44px; height: 44px; border-radius: 50%; background: var(--sky); color: #fff; display: grid; place-items: center; flex: none; }
.file-info { flex: 1; min-width: 0; }
.file-info b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info small { color: var(--muted); }
.file > svg.i { color: var(--muted); }
.call-msg { display: flex; align-items: center; gap: 10px; padding: 2px 0; min-width: 180px; }
.call-msg-icon { width: 38px; height: 38px; border-radius: 50%; background: var(--sky-soft); color: var(--sky); display: grid; place-items: center; flex: none; }
.call-msg.missed .call-msg-icon { background: rgba(214,69,69,.14); color: var(--danger); }
.call-msg b { display: block; font-weight: 600; }
.call-msg small { color: var(--muted); }
.pending .bubble { opacity: .85; }
.pending-body { display: flex; align-items: center; gap: 10px; min-width: 230px; }
.pending-thumb { width: 54px; height: 54px; border-radius: 8px; object-fit: cover; flex: none; background: var(--panel-2); display: grid; place-items: center; color: var(--muted); }
.pending-info { flex: 1; min-width: 0; }
.pending-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pending-info small { color: var(--muted); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; width: 0; background: var(--sky); transition: width .2s; }

@media (pointer: coarse) {
  .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .bubble .text, .bubble a { -webkit-user-select: text; user-select: text; }
}

/* ---------- composer ---------- */
.composer-wrap { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
.composer-wrap.top { padding: 10px 12px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.composer-inner { max-width: 780px; margin: 0 auto; }
.composer { display: flex; align-items: flex-end; gap: 6px; background: var(--panel); border-radius: 22px; padding: 4px 4px 4px 6px; box-shadow: var(--shadow); }
.composer-wrap.top .composer { background: var(--panel-2); box-shadow: none; }
.composer textarea { flex: 1; resize: none; border: 0; outline: none; background: none; padding: 9px 4px; max-height: 180px; line-height: 1.35; }
.send { width: 40px; height: 40px; border-radius: 50%; background: var(--sky); color: #fff; display: grid; place-items: center; flex: none; }
.send:hover { background: var(--sky-strong); }
.send svg.i { width: 20px; height: 20px; }
.context-bar { display: flex; align-items: center; gap: 10px; background: var(--panel); border-radius: 14px; padding: 6px 6px 4px 12px; margin: 0 8px 4px; font-size: 13.5px; box-shadow: var(--shadow); }
.composer-wrap.top .context-bar { background: var(--panel-2); box-shadow: none; }
.context-bar > svg.i { color: var(--sky); }
.context-bar div { flex: 1; min-width: 0; border-left: 2px solid var(--sky); padding-left: 8px; }
.context-bar b { display: block; color: var(--sky); font-weight: 600; }
.context-bar span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.join-bar { display: flex; justify-content: center; }
.join-bar .btn { min-width: 220px; border-radius: 22px; }
.readonly-bar { text-align: center; color: var(--muted); background: var(--panel); border-radius: 22px; padding: 10px; font-size: 14px; box-shadow: var(--shadow); }
.composer-wrap.top .readonly-bar { background: var(--panel-2); box-shadow: none; }
.drop-hint { position: absolute; inset: 70px 16px 16px; border: 2px dashed var(--sky); border-radius: 20px; background: color-mix(in srgb, var(--panel) 80%, transparent); display: grid; place-items: center; font-size: 18px; color: var(--sky); font-weight: 600; z-index: 5; pointer-events: none; }

/* ---------- popups & modals ---------- */
.pop { position: fixed; z-index: 95; min-width: 220px; background: var(--panel); border-radius: 12px; box-shadow: var(--pop-shadow); padding: 6px; animation: pop .12s ease-out; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }
.pop-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.pop-head small { display: block; color: var(--muted); }
.pop-item { width: 100%; display: flex; align-items: center; gap: 14px; padding: 9px 12px; border-radius: 8px; white-space: nowrap; }
.pop-item:hover { background: var(--hover); }
.pop-item svg.i { color: var(--muted); width: 20px; height: 20px; }
.pop-item.danger, .pop-item.danger svg.i { color: var(--danger); }

.modal-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(10,16,24,.45); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal-wrap.over-call { align-items: start; padding-top: max(16px, env(safe-area-inset-top)); }
.modal-wrap.over-call .modal { max-height: 72dvh; }
.modal { width: min(460px, 100%); max-height: min(760px, 100%); background: var(--panel); border-radius: 18px; box-shadow: var(--pop-shadow); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 6px 20px; }
.modal-head h2 { font-size: 18px; }
.modal-body { padding: 8px 20px 20px; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.profile-top { text-align: center; padding: 6px 0 14px; }
.profile-top .avatar { margin: 0 auto 10px; }
.profile-top h3 { font-size: 20px; overflow-wrap: anywhere; }
.profile-top p { margin: 2px 0 0; color: var(--muted); }
.avatar-edit { position: relative; width: 104px; margin: 0 auto 10px; }
.avatar-edit .cam { position: absolute; right: -2px; bottom: -2px; width: 36px; height: 36px; border-radius: 50%; background: var(--sky); color: #fff; display: grid; place-items: center; border: 3px solid var(--panel); }
.avatar-edit .cam svg.i { width: 18px; height: 18px; }
.info-rows { border-top: 1px solid var(--line); padding: 6px 0; }
.info-row { display: flex; gap: 14px; align-items: center; padding: 9px 4px; }
.info-row.plain { padding: 12px 2px; border-top: 1px solid var(--line); }
.info-row > svg.i { color: var(--muted); }
.info-row div { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.info-row small { display: block; color: var(--muted); font-size: 12.5px; }
.info-row button.copy { color: var(--sky); text-align: left; }
.actions-col { display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.action { display: flex; align-items: center; gap: 14px; padding: 10px 6px; border-radius: 10px; color: var(--sky); font-weight: 500; width: 100%; }
.action:hover { background: var(--hover); }
.action.danger { color: var(--danger); }
.member { display: flex; align-items: center; gap: 12px; padding: 7px 6px; border-radius: 10px; width: 100%; }
.member:hover { background: var(--hover); }
.member > div:not(.avatar) { flex: 1; min-width: 0; }
.member b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member small { color: var(--muted); }
.member .role { font-size: 12.5px; color: var(--sky); }
.member.selected { background: var(--sky-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--sky-soft); color: var(--sky); border-radius: 16px; padding: 3px 4px 3px 10px; font-size: 13.5px; }
.chip svg.i { width: 16px; height: 16px; }
.picker-list { max-height: 240px; overflow-y: auto; margin: 0 -6px; }
.picker-list.tall { max-height: 50vh; }

/* ---------- settings & moderation ---------- */
.settings-head { display: flex; align-items: center; gap: 14px; padding: 4px 4px 18px; }
.settings-head b { display: block; font-size: 17px; }
.settings-head small { color: var(--muted); }
.nav-list { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
.nav-row { display: flex; align-items: center; gap: 14px; padding: 12px 6px; border-radius: 10px; width: 100%; }
.nav-row:hover { background: var(--hover); }
.nav-row > span { flex: 1; min-width: 0; }
.nav-row small { display: block; color: var(--muted); font-size: 12.5px; }
.nav-row > svg.i { color: var(--muted); }
.nav-row.danger, .nav-row.danger > svg.i { color: var(--danger); }
.about { text-align: center; padding: 8px 0 16px; }
.about h3 { font-size: 20px; margin: 10px 0 4px; }

.admin-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.admin-row-body { flex: 1; min-width: 0; }
.admin-row-body b { display: block; }
.admin-row-body small { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.report { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.report-head { display: flex; align-items: center; gap: 10px; }
.report-head b { display: block; }
.report-head small { color: var(--muted); font-size: 12.5px; }
.report-text { margin: 10px 0 4px; overflow-wrap: anywhere; }
.report-from { display: block; color: var(--muted); font-size: 12.5px; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.report-reason { margin: 10px 0 2px; color: var(--danger); font-weight: 600; }
.report-msg { margin: 8px 0; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); overflow-wrap: anywhere; }
.report-msg small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.report-msg a { font-size: 13px; }


/* ---------- video, voice, reactions, extras ---------- */
.video-preview { position: relative; }
.video-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 11px; }
.video-fallback { position: absolute; inset: 0; display: grid; place-items: center; background: #0d1620; color: rgba(255,255,255,.7); border-radius: 11px; }
.play-badge { position: absolute; inset: 0; margin: auto; width: 56px; height: 56px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; backdrop-filter: blur(4px); }
.play-badge svg.i { width: 26px; height: 26px; fill: currentColor; stroke: none; margin-left: 2px; }
.video-time { position: absolute; left: 9px; top: 9px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; padding: 1px 7px; border-radius: 10px; }

.voice { display: flex; align-items: center; gap: 10px; min-width: 210px; padding: 2px 0; }
.voice-play { width: 40px; height: 40px; border-radius: 50%; background: var(--sky); color: #fff; display: grid; place-items: center; flex: none; }
.voice-play svg.i { width: 20px; height: 20px; fill: currentColor; stroke: none; }
.voice-body { flex: 1; min-width: 0; }
.voice-track { height: 5px; border-radius: 3px; background: color-mix(in srgb, var(--sky) 25%, transparent); cursor: pointer; }
.voice-track i { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--sky); }
.voice-time { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.msg.out .voice-time { color: var(--meta-out); }

.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; background: color-mix(in srgb, var(--sky) 12%, transparent); font-size: 13px; }
.reaction.mine { background: var(--sky); color: #fff; }
.reaction span { font-size: 12px; font-weight: 600; }
.reaction-bar { display: flex; gap: 2px; padding: 4px 6px 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.reaction-pick { font-size: 22px; padding: 4px 6px; border-radius: 8px; line-height: 1; }
.reaction-pick:hover { background: var(--hover); transform: scale(1.15); }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-width: 320px; padding: 4px; }
.emoji { font-size: 22px; padding: 4px; border-radius: 8px; line-height: 1.1; }
.emoji:hover { background: var(--hover); }

.composer.recording { align-items: center; gap: 10px; padding-left: 10px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-hint { flex: 1; color: var(--muted); font-size: 13.5px; }

.search-hit { display: block; width: 100%; text-align: left; padding: 9px 8px; border-radius: 10px; }
.search-hit:hover { background: var(--hover); }
.search-hit b { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.search-hit span { display: block; overflow-wrap: anywhere; }

.muted-mark { color: var(--muted); opacity: .7; }
.badge.quiet { background: var(--muted); }

.notice { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.notice b { display: block; margin-bottom: 4px; }
.notice p { margin: 0; color: var(--muted); font-size: 13.5px; }
.notice.warn { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: color-mix(in srgb, var(--danger) 7%, transparent); }
.notice.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, transparent); }

.viewer-media { max-width: 94vw; max-height: 88vh; object-fit: contain; background: #000; border-radius: 8px; }
.viewer-fail { color: #fff; text-align: center; display: grid; gap: 14px; place-items: center; }

/* ---------- calls ---------- */
.call-screen { position: fixed; inset: 0; z-index: 80; background: radial-gradient(120% 90% at 50% 0%, #22456E 0%, #0B1422 60%, #060B12 100%); color: #fff; display: flex; align-items: center; justify-content: center; }
.call-remote { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s ease; background: #000; }
.call-remote.on { opacity: 1; }
.call-peer { position: relative; text-align: center; padding: 20px; }
.call-avatar { display: block; margin: 0 auto 18px; }
.call-avatar .avatar { box-shadow: 0 10px 40px rgba(0,0,0,.45); }
.call-peer h2 { font-size: 26px; margin: 0; }
.call-peer p { margin: 8px 0 0; color: rgba(255,255,255,.82); font-size: 16px; font-variant-numeric: tabular-nums; }
.call-peer small { display: block; margin-top: 6px; color: rgba(255,255,255,.55); }
.call-top { position: absolute; top: calc(18px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.call-top b { display: block; font-size: 18px; }
.call-top span { color: rgba(255,255,255,.85); font-size: 14px; font-variant-numeric: tabular-nums; }
.call-local { position: absolute; right: 16px; bottom: calc(110px + env(safe-area-inset-bottom)); width: 132px; aspect-ratio: 3/4; object-fit: cover; border-radius: 14px; background: #000; box-shadow: 0 6px 20px rgba(0,0,0,.5); }
.call-local.mirror { transform: scaleX(-1); }
.call-controls { position: absolute; left: 0; right: 0; bottom: calc(26px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 16px; }
.call-btn { width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px); transition: background .15s, transform .1s; }
.call-btn:hover { background: rgba(255,255,255,.26); }
.call-btn:active { transform: scale(.94); }
.call-btn svg.i { width: 26px; height: 26px; }
.call-btn.off { background: #fff; color: #16202B; }
.call-btn.active { background: var(--sky); }
.call-btn.end { background: #E0453E; }
.call-btn.end:hover { background: #c93b35; }
.call-btn.accept { background: #2FA35F; }
.call-btn.accept:hover { background: #268b50; }
.call-btn.quality { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.call-btn { position: relative; }
.mic-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(255,255,255,.55); transform: scale(1); transition: transform .08s linear; pointer-events: none; }
.call-btn.off .mic-ring { display: none; }
.call-audio { display: none; }
.call-sound { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(104px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; background: #fff; color: #16202B; border-radius: 22px; padding: 10px 18px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.call-sound svg.i { width: 20px; height: 20px; }
.call-warn { position: absolute; left: 50%; transform: translateX(-50%); top: calc(70px + env(safe-area-inset-top)); display: flex; gap: 8px; align-items: center; background: rgba(224,69,62,.92); color: #fff; border-radius: 18px; padding: 8px 16px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.call-warn b { text-decoration: underline; font-weight: 600; }
.check-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.check-row b { display: block; }
.check-row small { color: var(--muted); }
.check-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; color: #fff; }
.check-mark.ok { background: var(--ok); }
.check-mark.bad { background: var(--danger); }
.check-mark.unknown { background: var(--muted); }
.sound-panel { padding: 10px 12px 6px; min-width: 250px; }
.sound-panel label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.sound-panel .row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sound-panel input[type=range] { flex: 1; accent-color: var(--sky); }
.sound-panel b { min-width: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.sound-panel .hint { margin: 0 0 8px; }
.level { height: 12px; border-radius: 6px; background: var(--panel-2); overflow: hidden; margin: 6px 0 12px; }
.level i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--dawn)); transition: width .08s linear; }
.blocked-bar { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: var(--muted); background: var(--panel); border-radius: 20px; padding: 12px; box-shadow: var(--shadow); }
.composer-wrap.top .blocked-bar { background: var(--panel-2); box-shadow: none; }

.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.9); display: grid; place-items: center; animation: fade .15s; }
.viewer-bar { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.viewer-bar .icon-btn { color: #fff; background: rgba(255,255,255,.12); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; background: rgba(22,32,43,.94); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); animation: fade .15s; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .layout .chat { display: none; }
  .layout.chat-open .sidebar { display: none; }
  .layout.chat-open .chat { display: flex; }
  .chat-head .back { display: grid; }
  .bubble { max-width: 90%; }
  .messages-inner { padding: 0 8px; }
  .composer-wrap { padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
  .modal-wrap { align-items: end; padding: 0; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92dvh; width: 100%; }
  .modal-wrap.over-call { align-items: start; padding: 0; }
  .modal-wrap.over-call .modal { border-radius: 0 0 18px 18px; max-height: 68dvh; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
  .call-local { width: 104px; bottom: calc(104px + env(safe-area-inset-bottom)); }
  .call-btn { width: 56px; height: 56px; }
  .call-controls { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- видеосообщения (кружки) ---------- */
.round-box { position: relative; width: 240px; height: 240px; border-radius: 50%; overflow: hidden; padding: 0; border: 0; background: #000; display: block; cursor: pointer; }
.round-box .round-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.round-box .video-time { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(0,0,0,.45); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.round-box.playing { box-shadow: 0 0 0 3px var(--accent, #3a8ee6); }
.btn.small { padding: 6px 10px; font-size: 13px; }
