/* ============ OneLove — premium reggae ============ */
:root {
  --bg: #0c0f0b;
  --bg2: #12160e;
  --ink: #f2f4ee;
  --ink-dim: #a8b09b;
  --green: #21b573;
  --gold: #f5c84c;
  --red: #ef4444;
  --glass: rgba(255, 255, 255, .055);
  --glass-brd: rgba(255, 255, 255, .1);
  --rasta: linear-gradient(90deg, var(--green), var(--gold), var(--red));
  --shadow: 0 24px 60px rgba(0, 0, 0, .45);
  font-size: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  background:
    radial-gradient(1200px 800px at 80% -10%, rgba(33,181,115,.08), transparent 60%),
    radial-gradient(1000px 700px at 10% 110%, rgba(245,200,76,.06), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- фон ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .16; will-change: transform;
}
.blob-g { width: 44vmax; height: 44vmax; background: var(--green); top: -12vmax; left: -8vmax; animation: drift 26s ease-in-out infinite alternate; }
.blob-y { width: 36vmax; height: 36vmax; background: var(--gold); bottom: -14vmax; right: -6vmax; animation: drift 32s ease-in-out infinite alternate-reverse; }
.blob-r { width: 26vmax; height: 26vmax; background: var(--red); top: 40%; left: 55%; opacity: .1; animation: drift 38s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmax, 4vmax) scale(1.15); }
}
.grain { position: absolute; inset: 0; opacity: .5; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .03 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: reduce) { .blob { animation: none !important; } * { transition-duration: .01ms !important; } }

/* ---------- экраны ---------- */
.screen { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }

/* ---------- карточка ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-brd);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
}
.card {
  width: min(420px, 100%);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 34px 30px 22px;
  position: relative;
}
.card::before {
  content: ""; position: absolute; inset-inline: 30px; top: 0; height: 3px;
  border-radius: 0 0 6px 6px; background: var(--rasta); opacity: .9;
}

.brand { text-align: center; margin-bottom: 26px; }
.emblem {
  display: inline-block; width: 58px; height: 58px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #141a12 0 31%, transparent 31.5%),
    linear-gradient(180deg, var(--green) 0 33%, var(--gold) 33% 66%, var(--red) 66% 100%);
  box-shadow: 0 0 0 2px rgba(255,255,255,.12), 0 8px 24px rgba(33,181,115,.25);
}
.brand h1 {
  font-size: 1.9rem; letter-spacing: .28em; font-weight: 800; margin-top: 12px;
}
.brand h1 em {
  font-style: normal;
  background: var(--rasta);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--ink-dim); font-size: .82rem; letter-spacing: .06em; margin-top: 6px; }

/* ---------- поля ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: .78rem; color: var(--ink-dim); margin-bottom: 7px; letter-spacing: .04em; }
input, textarea {
  width: 100%; padding: 13px 15px; border-radius: 14px;
  background: rgba(0, 0, 0, .28); border: 1px solid var(--glass-brd);
  color: var(--ink); font-size: 1rem; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245, 200, 76, .15); }
input::placeholder, textarea::placeholder { color: #5c6353; }
.field-hint { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--green); margin-top: 7px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-on { background: var(--green); box-shadow: 0 0 8px var(--green); animation: breathe 2s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .5; } }

.me-chip {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: .85rem; color: var(--ink-dim); margin-bottom: 18px; flex-wrap: wrap;
}
.me-chip b { color: var(--ink); }
.linklike {
  background: none; border: 0; cursor: pointer;
  color: var(--ink-dim); font-size: .78rem; text-decoration: underline dotted;
  padding: 2px 4px; transition: color .15s;
}
.linklike:hover { color: var(--gold); }

.notif-chip {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255,255,255,.05); border: 1px dashed rgba(255,255,255,.22);
  color: var(--ink-dim); border-radius: 12px; padding: 9px 12px;
  font-size: .8rem; cursor: pointer; margin-bottom: 18px;
  transition: color .15s, border-color .15s;
}
.notif-chip:hover { color: var(--ink); }
.notif-chip.on { border-style: solid; border-color: rgba(33,181,115,.45); color: var(--green); }

.hist-head {
  display: flex; align-items: center; gap: 10px;
  font-size: .72rem; color: var(--ink-dim); letter-spacing: .1em;
  text-transform: uppercase; margin: 24px 0 6px; padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.09);
}
.hist { max-height: 240px; overflow-y: auto; }
.hist-row {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid rgba(255,255,255,.05);
  color: var(--ink); padding: 10px 6px; font-size: .92rem;
  cursor: pointer; text-align: left; transition: background .12s;
}
.hist-row:hover { background: rgba(255,255,255,.045); }
.hist-row:last-child { border-bottom: 0; }
.hist-row[data-k="out"] svg { color: var(--gold); }
.hist-row[data-k="in"] svg { color: var(--green); }
.hist-row[data-k="missed"] svg { color: var(--red); }
.hist-row .hn { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-row .ht { font-size: .7rem; color: var(--ink-dim); }

/* ---------- кнопки ---------- */
.btn {
  border: 0; cursor: pointer; border-radius: 14px;
  font-size: .98rem; font-weight: 650; padding: 13px 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  transition: transform .12s, filter .15s, opacity .15s;
  color: var(--ink); background: rgba(255,255,255,.08);
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-primary {
  background: linear-gradient(135deg, #ffd95c, var(--gold));
  color: #201903; box-shadow: 0 10px 26px rgba(245, 200, 76, .22);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-call { background: linear-gradient(135deg, #2ecc85, var(--green)); color: #04160c; box-shadow: 0 10px 26px rgba(33, 181, 115, .25); }
.btn-ghost { background: rgba(255,255,255,.07); font-size: 1.05rem; padding: 13px 15px; }
.btn-install {
  margin-top: 14px;
  background: rgba(245, 200, 76, .1);
  border: 1px solid rgba(245, 200, 76, .45);
  color: var(--gold);
}
.btn-install:hover { background: rgba(245, 200, 76, .18); }
.row { display: flex; gap: 10px; }
.grow { flex: 1; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.card-foot {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--ink-dim); font-size: .74rem; letter-spacing: .03em;
}

/* ---------- табы ---------- */
.tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px;
  background: rgba(0,0,0,.28); padding: 4px; border-radius: 14px; margin-bottom: 18px;
}
.tab {
  border: 0; background: transparent; color: var(--ink-dim); cursor: pointer;
  padding: 10px; border-radius: 11px; font-size: .92rem; font-weight: 600;
  transition: all .18s;
}
.tab.active { background: rgba(255,255,255,.1); color: var(--ink); }
.pane-hint { color: var(--ink-dim); font-size: .78rem; text-align: center; margin-top: 12px; line-height: 1.45; }

/* ---------- оверлеи вызовов ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(8, 10, 7, .82);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.overlay h2 { font-size: 1.7rem; font-weight: 750; margin-top: 34px; }
.overlay-sub { color: var(--ink-dim); margin-top: 8px; letter-spacing: .08em; font-size: .9rem; }

.ring-wrap { position: relative; width: 150px; height: 150px; display: grid; place-items: center; }
.pulse-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--green); opacity: 0;
  animation: pulse 2.2s ease-out infinite;
}
.pulse-ring.r2 { animation-delay: 1.1s; border-color: var(--gold); }
#callingOverlay .pulse-ring { border-color: var(--gold); }
#callingOverlay .pulse-ring.r2 { border-color: var(--red); }
@keyframes pulse {
  0% { transform: scale(.72); opacity: .75; }
  100% { transform: scale(1.45); opacity: 0; }
}

.avatar {
  width: 84px; height: 84px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.6rem; color: #06130b;
  background: linear-gradient(135deg, #35d68d, var(--green));
  box-shadow: 0 14px 34px rgba(0,0,0,.4);
  user-select: none; flex: none; overflow: hidden; position: relative;
}
.avatar.big { width: 104px; height: 104px; font-size: 2rem; }
.avatar.gold { background: linear-gradient(135deg, #ffe27a, var(--gold)); color: #231a02; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.call-actions { display: flex; gap: 26px; margin-top: 42px; }
.btn-round {
  width: 74px; height: 74px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  transition: transform .12s, filter .15s;
}
.btn-round:active { transform: scale(.93); }
.btn-round svg { fill: currentColor; }
.btn-accept { background: linear-gradient(135deg, #2ecc85, var(--green)); box-shadow: 0 12px 30px rgba(33,181,115,.4); }
.btn-decline { background: linear-gradient(135deg, #f26d6d, var(--red)); box-shadow: 0 12px 30px rgba(239,68,68,.35); }

/* ---------- комната ---------- */
#room {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh; padding: 0 0 env(safe-area-inset-bottom);
  align-items: stretch; justify-content: flex-start;
}
#roomHeader {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
}
.brand-mini {
  display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: .22em; font-size: .8rem;
}
.emblem.small { width: 26px; height: 26px; box-shadow: none; }
.head-right { display: flex; align-items: center; gap: 9px; }
.chip {
  background: rgba(255,255,255,.08); border: 1px solid var(--glass-brd);
  border-radius: 999px; padding: 7px 14px; font-size: .8rem;
  letter-spacing: .12em; font-weight: 700;
}
.chip-count { letter-spacing: 0; color: var(--ink-dim); font-weight: 600; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--glass-brd);
  background: rgba(255,255,255,.07); color: var(--ink); cursor: pointer;
  display: grid; place-items: center; transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }

#grid {
  flex: 1; display: grid; gap: 12px; padding: 8px 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  grid-auto-rows: 1fr; min-height: 0; align-content: stretch;
}
.tile {
  position: relative; border-radius: 22px; overflow: hidden;
  background: linear-gradient(160deg, #171c12, #101408);
  border: 1px solid rgba(255,255,255,.07);
  transition: border-color .2s, box-shadow .2s;
  min-height: 120px;
}
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: transparent; }
.tile.speaking { border-color: var(--green); box-shadow: 0 0 0 2px rgba(33,181,115,.45), 0 0 30px rgba(33,181,115,.18); }
.tile-self { border-color: rgba(245,200,76,.28); }
.tile-placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: radial-gradient(closest-side at 50% 42%, rgba(255,255,255,.05), transparent);
}
.tile-name {
  position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 20px);
  display: flex; align-items: center; gap: 7px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 6px 12px; border-radius: 999px; font-size: .8rem; font-weight: 600;
}
.tile-name i { width: 7px; height: 7px; border-radius: 50%; background: #6b7460; flex: none; transition: background .15s; }
.tile-name i.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.tile-name .q {
  width: 7px; height: 7px; border-radius: 50%; background: #6b7460;
  margin-left: auto; flex: none; transition: background .3s, box-shadow .3s;
}
.tile-name .q.good { background: var(--green); box-shadow: 0 0 6px var(--green); }
.tile-name .q.mid { background: var(--gold); }
.tile-name .q.bad { background: var(--red); box-shadow: 0 0 6px var(--red); }
.tile-badge {
  position: absolute; right: 10px; top: 10px;
  background: rgba(0,0,0,.55); backdrop-filter: blur(8px);
  padding: 5px 10px; border-radius: 999px; font-size: .68rem; letter-spacing: .1em; font-weight: 700;
  color: var(--gold); display: none;
}
.tile-sharing .tile-badge { display: block; }

/* ---------- док ---------- */
#dock {
  position: sticky; bottom: calc(14px + env(safe-area-inset-bottom));
  margin: 0 auto 14px; width: max-content; max-width: calc(100% - 24px);
  display: flex; gap: 8px; padding: 9px;
  border-radius: 999px; box-shadow: var(--shadow); z-index: 20;
}
.ctl {
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--ink);
  background: rgba(255, 255, 255, .09);
  transition: background .15s, color .15s, transform .12s;
}
.ctl:hover { background: rgba(255,255,255,.16); }
.ctl:active { transform: scale(.94); }
.ctl svg { stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ctl.off { background: rgba(239, 68, 68, .16); color: #ff9c9c; }
.ctl-rec.on { background: var(--red); color: #fff; animation: recPulse 1.6s ease-in-out infinite; }
@keyframes recPulse { 50% { box-shadow: 0 0 0 9px rgba(239,68,68,.18); } }
.ctl-danger { background: linear-gradient(135deg, #f26d6d, var(--red)); color: #fff; }
.ctl-danger svg { stroke: #fff; }

#recBadge {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; align-items: center; gap: 8px;
  background: rgba(239, 68, 68, .14); border: 1px solid rgba(239, 68, 68, .4);
  color: #ffb4b4; border-radius: 999px; padding: 7px 15px;
  font-size: .72rem; font-weight: 800; letter-spacing: .18em;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#recBadge i { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: breathe 1.2s infinite; }

/* ---------- тосты ---------- */
#toastWrap {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); z-index: 100;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: 92vw;
}
.toast {
  background: rgba(18, 22, 14, .92); border: 1px solid var(--glass-brd);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--ink); border-radius: 14px; padding: 11px 18px;
  font-size: .86rem; box-shadow: var(--shadow);
  animation: toastIn .25s ease;
  max-width: 100%; text-align: left;
  display: flex; align-items: center; gap: 9px;
}
.t-ic { display: grid; place-items: center; color: var(--gold); flex: none; }
.toast.ok .t-ic { color: var(--green); }
.toast.err .t-ic { color: #ff9c9c; }
.toast.err { border-color: rgba(239, 68, 68, .5); }
.toast.ok { border-color: rgba(33, 181, 115, .5); }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- адаптив ---------- */
@media (max-width: 540px) {
  .card { padding: 28px 20px 18px; border-radius: 24px; }
  .brand h1 { font-size: 1.6rem; }
  #grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .tile { aspect-ratio: 3 / 4; min-height: unset; }
  @media (orientation: landscape) {
    #grid { grid-template-columns: 1fr 1fr; }
    .tile { aspect-ratio: auto; }
  }
  .ctl { width: 48px; height: 48px; }
}

/* ---------- сетевой индикатор ---------- */
.netmon {
  position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 12px;
  z-index: 45; display: flex; align-items: center; gap: 7px;
  border-radius: 999px; padding: 8px 13px;
  font-size: .78rem; font-weight: 700;
  color: var(--ink-dim); box-shadow: var(--shadow);
}
.netmon-sm { position: static; box-shadow: none; padding: 6px 11px; background: rgba(255,255,255,.07); border: 1px solid var(--glass-brd); }


.nm-sep { width: 3px; height: 3px; border-radius: 50%; background: rgba(255,255,255,.25); flex: none; }

.nm-srv { font-weight: 600; font-variant-numeric: tabular-nums; }
.nm-srv.srv-mid { color: var(--gold); }
.nm-srv.srv-bad { color: var(--red); }

.nm-item { display: flex; align-items: center; gap: 5px; }
.nm-l { font-size: .64rem; font-weight: 500; color: var(--ink-dim); letter-spacing: .05em; }
.nm-ping, .nm-srv, .nm-speed {
  font-size: .76rem; font-weight: 480;
  font-variant-numeric: tabular-nums; color: var(--ink-dim);
}
.netmon.q-good .nm-ping { color: var(--green); }
.netmon.q-mid .nm-ping { color: var(--gold); }
.netmon.q-bad .nm-ping { color: #ff8a8a; }
.nm-srv.srv-mid { color: var(--gold); }
.nm-srv.srv-bad { color: #ff8a8a; }
@media (max-width: 540px) {
  .netmon { padding: 6px 10px; gap: 7px; }
  .nm-l { font-size: .58rem; }
  .nm-ping, .nm-srv, .nm-speed { font-size: .68rem; }
  #countBadge { display: none; }
}
@media (max-width: 400px) { .nm-speed-item, .netmon .nm-sep:last-of-type { display: none; } }


/* ---------- режим помощи ---------- */
.ctl-help:not(.hidden) { background: rgba(245,200,76,.14); color: var(--gold); }
.assist-cv {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 3; cursor: crosshair; touch-action: none;
}
.assist-bar {
  position: absolute; top: 10px; left: 10px; z-index: 4;
  display: flex; gap: 6px; background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 999px; padding: 5px;
}
.ab-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center;
  background: rgba(255,255,255,.1); color: var(--ink);
}
.ab-btn:hover { background: rgba(255,255,255,.2); }
.ab-btn svg { stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ab-pen { color: var(--red) !important; }
.ab-exit { color: #ff9c9c; }
.assisted-chip {
  position: absolute; left: 50%; top: 54px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: rgba(245,200,76,.12); border: 1px solid rgba(245,200,76,.45);
  color: var(--gold); border-radius: 999px; padding: 7px 15px; font-size: .78rem;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 25;
}
.assisted-chip svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- мобильная шапка комнаты: два ряда без тесноты ---------- */
@media (max-width: 540px) {
  #roomHeader {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 4px 8px;
  }
  .head-right {
    width: 100%;
    justify-content: space-between;
    gap: 6px;
  }
  .chip { padding: 6px 11px; font-size: .72rem; }
  #grid { padding-top: 2px; }
}

@media (max-width: 540px) {
  .brand-word { font-size: .68rem; letter-spacing: .18em; }
}

/* активный режим показа */
.ctl-live { background: rgba(245,200,76,.28) !important; color: var(--gold) !important; box-shadow: 0 0 0 2px rgba(245,200,76,.35); }

/* ---------- индикатор чужой записи ---------- */
.tile-rec {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  background: rgba(239,68,68,.18); border: 1px solid rgba(239,68,68,.55);
  color: #ffb4b4; border-radius: 999px; padding: 4px 10px;
  font-size: .62rem; font-weight: 800; letter-spacing: .16em;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.tile-rec i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: breathe 1.2s infinite; }
.ctl { position: relative; }
.chat-unread {
  position: absolute; top: 1px; right: 1px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 6px rgba(239,68,68,.7);
}

/* ---------- чат и панель файлов ---------- */
.sidepanel {
  position: fixed; z-index: 40;
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: min(380px, calc(100vw - 24px));
  height: min(500px, 58dvh);
  border-radius: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
  animation: fadeIn .18s ease;
}
#chatPanel { right: 12px; }
#filesPanel { left: 12px; }
@media (max-width: 540px) {
  .sidepanel { width: calc(100vw - 24px); height: min(480px, 56dvh); }
}
/* на телефоне док в два ряда — поднимаем панели над ним */
@media (max-width: 720px) {
  .sidepanel { bottom: calc(146px + env(safe-area-inset-bottom)); }
}
.sp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: .92rem;
}
.sp-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px; }
.sp-foot { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.08); }

#chatMsgs { display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.msg {
  max-width: 85%; padding: 8px 12px; border-radius: 15px;
  font-size: .88rem; line-height: 1.35;
  background: rgba(255,255,255,.08);
  align-self: flex-start;
  word-break: break-word; white-space: pre-wrap;
}
.msg.own { align-self: flex-end; background: rgba(33,181,115,.22); }
.msg .who { display: block; font-size: .66rem; color: var(--gold); font-weight: 700; margin-bottom: 2px; letter-spacing: .03em; }
.msg.sys {
  align-self: center; background: none; color: var(--ink-dim);
  font-size: .72rem; padding: 1px 6px; text-align: center; max-width: 95%;
}
.chat-input-row {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.08);
}
#chatInput, #dmText { resize: none; min-height: 44px; max-height: 96px; line-height: 1.35; }
#chatSend { flex: none; border-radius: 12px; }

/* ---------- кабинет файлов ---------- */
.lib { margin-top: 4px; }
.lib-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 4px; border-bottom: 1px solid rgba(255,255,255,.05);
}
.lib-row:last-child { border-bottom: 0; }
.lib-ic {
  flex: none; width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  font-size: .58rem; font-weight: 800; letter-spacing: .04em;
  color: #201903; background: linear-gradient(135deg, #ffe27a, #e0a92f);
  overflow: hidden;
}
.lib-ic.t-img { background: linear-gradient(135deg, #35d68d, #159a63); color: #04160c; }
.lib-ic.t-pdf { background: linear-gradient(135deg, #ff9d9d, #d54545); color: #2b0505; }
.lib-ic.t-txt { background: linear-gradient(135deg, #7dd3fc, #2b8ec9); color: #04202f; }
.lib-ic.t-vid { background: linear-gradient(135deg, #c4b5fd, #7a5fd0); color: #150b33; }
.lib-ic.t-aud { background: linear-gradient(135deg, #f9a8d4, #c2589e); color: #33081f; }
.lib-meta { flex: 1; min-width: 0; }
.lib-name { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-sub { font-size: .68rem; color: var(--ink-dim); margin-top: 2px; }
.lib-acts { display: flex; gap: 5px; flex: none; }
.lib-empty { color: var(--ink-dim); font-size: .8rem; text-align: center; padding: 18px 0; }

/* ---------- просмотр файла ---------- */
.fv-card {
  width: min(980px, 94vw); height: min(86dvh, 900px);
  border-radius: 22px; padding: 0; overflow: hidden;
  display: flex; flex-direction: column;
}
.fv-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid rgba(255,255,255,.09);
  flex: none;
}
.fv-head .lib-ic { width: 34px; height: 34px; font-size: .54rem; }
.fv-name { font-weight: 650; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fv-from { font-size: .7rem; color: var(--ink-dim); margin-top: 1px; }
.fv-body {
  flex: 1; min-height: 0;
  display: grid; place-items: center;
  background: rgba(0,0,0,.35);
  overflow: auto;
}
.fv-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.fv-body pre {
  align-self: stretch; justify-self: stretch; margin: 0; padding: 18px;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: .84rem; color: var(--ink); line-height: 1.5;
}
.fv-body video, .fv-body audio { max-width: 100%; }
.fv-fallback { display: grid; gap: 16px; justify-items: center; color: var(--ink-dim); font-size: .88rem; padding: 30px; }

/* подпись «ты показываешь файл» */
.pres-chip {
  color: var(--green) !important;
  border-color: rgba(33,181,115,.45) !important;
  background: rgba(33,181,115,.12) !important;
}

/* ---------- док: две строки на узких экранах ---------- */
@media (max-width: 720px) {
  #dock {
    flex-wrap: wrap; justify-content: center;
    width: min(350px, calc(100vw - 24px));
    border-radius: 26px;
  }
}

/* ---------- личные сообщения (таб «Чат») ---------- */
.tab { position: relative; }
.dm-contacts {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 2px 0 10px; scrollbar-width: none;
}
.dm-contacts::-webkit-scrollbar { display: none; }
.dm-contacts:empty { display: none; }
.dm-chip {
  flex: none; cursor: pointer;
  border: 1px solid var(--glass-brd); border-radius: 999px;
  background: rgba(255,255,255,.06); color: var(--ink-dim);
  padding: 6px 13px; font-size: .8rem;
  transition: all .15s;
}
.dm-chip:hover { color: var(--ink); }
.dm-chip.on {
  color: var(--ink); border-color: rgba(245,200,76,.55);
  background: rgba(245,200,76,.12);
}
#dmLog {
  height: 240px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px; margin-bottom: 10px;
  background: rgba(0,0,0,.22);
  border: 1px solid var(--glass-brd); border-radius: 14px;
}
#dmLog .msg { max-width: 88%; }
