/* ===== Ollivo — тема ===== */
:root {
  --bg: #eef0e8;
  --panel: #ffffff;
  --panel-2: #f6f7f2;
  --line: #e2e5da;
  --text: #1c2117;
  --muted: #727a6a;
  --accent: #5b8a2b;
  --accent-2: #4a7322;
  --accent-soft: #e5efd6;
  --on-accent: #ffffff;
  --bubble-in: #ffffff;
  --bubble-out: #dcecc4;
  --bubble-out-text: #1c2117;
  --bubble-out-muted: #5d7445;
  --danger: #d6453d;
  --warn: #d98a1c;
  --chat-bg: #e4e8da;
  --chat-pattern: rgba(91, 138, 43, .07);
  --shadow: 0 1px 2px rgba(20, 30, 10, .08), 0 4px 18px rgba(20, 30, 10, .06);
  --shadow-lg: 0 10px 40px rgba(10, 20, 5, .22);
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d100b;
    --panel: #151a12;
    --panel-2: #1b2117;
    --line: #262d21;
    --text: #e7ece0;
    --muted: #8b9582;
    --accent: #95c45a;
    --accent-2: #a9d46f;
    --accent-soft: #24311a;
    --on-accent: #12180d;
    --bubble-in: #1e251a;
    --bubble-out: #3a5524;
    --bubble-out-text: #eef5e4;
    --bubble-out-muted: #a9c48a;
    --chat-bg: #0f130d;
    --chat-pattern: rgba(149, 196, 90, .05);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d100b;
  --panel: #151a12;
  --panel-2: #1b2117;
  --line: #262d21;
  --text: #e7ece0;
  --muted: #8b9582;
  --accent: #95c45a;
  --accent-2: #a9d46f;
  --accent-soft: #24311a;
  --on-accent: #12180d;
  --bubble-in: #1e251a;
  --bubble-out: #3a5524;
  --bubble-out-text: #eef5e4;
  --bubble-out-muted: #a9c48a;
  --chat-bg: #0f130d;
  --chat-pattern: rgba(149, 196, 90, .05);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  overflow: hidden;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
svg.i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

.btn {
  border: 0; border-radius: 12px; padding: 11px 18px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: filter .15s, transform .1s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field textarea {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px;
  padding: 11px 13px; outline: none; transition: border-color .15s, background .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); background: var(--panel); }
.field textarea { resize: vertical; min-height: 76px; }
.field .hint { font-size: 12px; color: var(--muted); }

/* ===== Аватарки ===== */
.avatar {
  --size: 44px;
  width: var(--size); height: var(--size); border-radius: 50%; flex: none;
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: calc(var(--size) * .38); letter-spacing: .02em;
  background: var(--av, #6b8f3c) center / cover no-repeat; user-select: none;
}
.avatar.online::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  width: calc(var(--size) * .26); height: calc(var(--size) * .26);
  border-radius: 50%; background: #4cc25a; border: 2px solid var(--panel);
}

/* ===== Раскладка ===== */
.app {
  height: 100%; display: grid; grid-template-columns: 380px 1fr;
  max-width: 1600px; margin: 0 auto; background: var(--panel);
}
@media (min-width: 1600px) { .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); } }

.sidebar {
  display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line);
  background: var(--panel); padding-top: env(safe-area-inset-top);
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px 14px; }
.side-head .me-btn { border: 0; background: none; padding: 0; border-radius: 50%; }
.brand { font-weight: 750; font-size: 21px; letter-spacing: -.02em; flex: 1; display: flex; align-items: center; gap: 8px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.conn-state { font-size: 12px; color: var(--muted); font-weight: 400; }

.search { position: relative; margin: 4px 12px 8px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input {
  width: 100%; border: 0; border-radius: 12px; padding: 10px 36px 10px 38px;
  background: var(--panel-2); outline: none; transition: box-shadow .15s;
}
.search input:focus { box-shadow: 0 0 0 2px var(--accent); }
.search .clear { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; }

.banner {
  margin: 4px 12px 8px; padding: 12px 14px; border-radius: 14px;
  background: var(--accent-soft); display: flex; gap: 12px; align-items: center; font-size: 14px;
}
.banner svg { color: var(--accent); }
.banner .grow { flex: 1; }
.banner b { display: block; margin-bottom: 2px; }

.list { flex: 1; overflow-y: auto; padding: 2px 6px 12px; overscroll-behavior: contain; }
.list-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 10px 6px; }
.list-empty { color: var(--muted); text-align: center; padding: 40px 24px; font-size: 14px; line-height: 1.5; }
.list-empty svg { width: 54px; height: 54px; color: var(--accent); opacity: .6; margin-bottom: 8px; }

.row {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 14px;
  cursor: pointer; user-select: none; transition: background .12s;
}
.row:hover { background: var(--panel-2); }
.row.active { background: var(--accent); color: var(--on-accent); }
.row.active .sub, .row.active .time { color: var(--on-accent); opacity: .85; }
.row .body { flex: 1; min-width: 0; }
.row .top { display: flex; align-items: baseline; gap: 8px; }
.row .name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .time { font-size: 12px; color: var(--muted); flex: none; display: flex; align-items: center; gap: 3px; }
.row .bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.row .sub { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub .typing { color: var(--accent); }
.row.active .sub .typing { color: var(--on-accent); }
.badge {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; flex: none;
  background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.row.active .badge { background: var(--on-accent); color: var(--accent); }
.ticks { width: 17px; height: 17px; color: var(--accent); }
.row.active .ticks { color: var(--on-accent); }

/* ===== Чат ===== */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--chat-bg); }
.main::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(var(--chat-pattern) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
}
.placeholder { margin: auto; text-align: center; color: var(--muted); position: relative; padding: 24px; }
.placeholder .pill { display: inline-block; background: var(--panel); padding: 8px 16px; border-radius: 20px; box-shadow: var(--shadow); font-size: 14px; }

.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; position: relative; }
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line); z-index: 2;
}
.chat-head .who { flex: 1; min-width: 0; cursor: pointer; display: flex; align-items: center; gap: 11px; }
.chat-head .who .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .who .status { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .who .status.on { color: var(--accent); }
.back-btn { display: none; }

.messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 0 6px; overscroll-behavior: contain; position: relative; }
.messages-inner { max-width: 820px; margin: 0 auto; padding: 0 14px; display: flex; flex-direction: column; }
.day { align-self: center; margin: 12px 0 8px; padding: 4px 12px; border-radius: 12px; font-size: 13px; font-weight: 500;
  background: color-mix(in srgb, var(--panel) 80%, transparent); color: var(--muted); backdrop-filter: blur(6px); position: sticky; top: 4px; z-index: 1; }
.load-more { align-self: center; color: var(--muted); font-size: 13px; padding: 8px; }

.msg { display: flex; margin-top: 2px; position: relative; }
.msg.first { margin-top: 8px; }
.msg.out { justify-content: flex-end; }
.bubble {
  max-width: min(78%, 520px); padding: 7px 11px 6px; border-radius: var(--radius);
  background: var(--bubble-in); box-shadow: var(--shadow); position: relative;
  word-wrap: break-word; overflow-wrap: anywhere; white-space: pre-wrap;
}
.msg.out .bubble { background: var(--bubble-out); color: var(--bubble-out-text); }
.msg.in.last .bubble { border-bottom-left-radius: 6px; }
.msg.out.last .bubble { border-bottom-right-radius: 6px; }
.msg.highlight .bubble { animation: hl 1.4s ease; }
@keyframes hl { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: var(--shadow); } }
.msg.pending .bubble { opacity: .85; }
.msg.failed .bubble { box-shadow: 0 0 0 1.5px var(--danger); cursor: pointer; }

.spacer { display: inline-block; height: 1px; }
.meta-line.static { position: static; }
.meta-line { position: absolute; right: 10px; bottom: 6px; font-size: 11.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; line-height: 1; user-select: none; }
.msg.out .meta-line { color: var(--bubble-out-muted); }
.msg.out .meta-line .ticks { color: var(--bubble-out-muted); width: 16px; height: 16px; }
.msg.out .meta-line .ticks.read { color: var(--accent); }
:root[data-theme="dark"] .msg.out .meta-line .ticks.read { color: #c6eb94; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .msg.out .meta-line .ticks.read { color: #c6eb94; } }
.meta-line .edited { font-style: italic; }
.text a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.deleted-text { font-style: italic; color: var(--muted); }

.quote {
  display: block; border-left: 3px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 6px 10px 10px 6px; padding: 4px 8px; margin: 2px 0 5px; cursor: pointer; font-size: 13.5px; white-space: normal;
}
.quote .qn { font-weight: 600; color: var(--accent); font-size: 13px; }
.quote .qt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; opacity: .85; max-width: 380px; }

/* Таймер удаления файла */
.ttl {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 3px 8px 3px 6px; border-radius: 10px; background: rgba(0, 0, 0, .5); color: #fff; line-height: 1; white-space: nowrap;
}
.ttl svg { width: 13px; height: 13px; }
.ttl.soon { background: var(--danger); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .75; } }
.ttl.inline { background: var(--accent-soft); color: var(--accent); }
.msg.out .ttl.inline { background: color-mix(in srgb, var(--bubble-out-muted) 22%, transparent); color: var(--bubble-out-text); }
.ttl.inline.soon { background: var(--danger); color: #fff; }

/* Фото/видео */
.bubble.media { padding: 3px; overflow: hidden; }
.media-box { position: relative; border-radius: calc(var(--radius) - 3px); overflow: hidden; background: var(--panel-2); cursor: pointer; line-height: 0; }
.media-box img, .media-box video { display: block; max-width: 100%; width: 100%; max-height: 380px; object-fit: cover; }
.media-box { width: min(320px, 68vw); min-height: 120px; }
.media-box .ttl { position: absolute; left: 8px; top: 8px; }
.media-box .media-meta { position: absolute; right: 8px; bottom: 8px; }
.media-box .play-ov { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.media-box .play-ov span { width: 54px; height: 54px; border-radius: 50%; background: rgba(0, 0, 0, .5); display: flex; align-items: center; justify-content: center; color: #fff; backdrop-filter: blur(4px); }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; line-height: 1; padding: 4px 7px; border-radius: 10px; background: rgba(0, 0, 0, .45); color: #fff; }
.chip .ticks { color: #fff !important; width: 15px; height: 15px; }
.bubble.media .caption-meta { padding: 0 8px 4px; }

.gone {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: var(--muted); font-size: 14px; white-space: normal;
}
.gone svg { width: 26px; height: 26px; opacity: .7; }
.media-box.gone-box { cursor: default; display: flex; align-items: center; justify-content: center; min-height: 140px; line-height: 1.4; }

/* Файл */
.file-card { display: flex; align-items: center; gap: 11px; min-width: 220px; max-width: 320px; white-space: normal; padding: 2px 0; }
.file-ico {
  width: 46px; height: 46px; border-radius: 12px; flex: none; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; text-transform: uppercase; text-decoration: none;
}
.msg.out .file-ico { background: var(--accent-2); }
.file-card .fi { min-width: 0; flex: 1; }
.file-card .fn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .fs { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 3px; flex-wrap: wrap; }
.msg.out .file-card .fs { color: var(--bubble-out-muted); }

/* Голосовое */
.voice { display: flex; align-items: center; gap: 10px; min-width: 230px; white-space: normal; padding: 2px 0; }
.voice .pp {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none; background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
}
.voice .pp svg { fill: currentColor; stroke: none; }
.voice .vb { flex: 1; min-width: 0; }
.wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.wave i { flex: 1; min-width: 2px; max-width: 4px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.wave i.on { background: var(--accent); }
.msg.out .wave i { background: color-mix(in srgb, var(--bubble-out-muted) 45%, transparent); }
.msg.out .wave i.on { background: var(--bubble-out-text); }
.voice .vs { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg.out .voice .vs { color: var(--bubble-out-muted); }
.voice .speed { border: 0; background: color-mix(in srgb, var(--accent) 18%, transparent); color: inherit; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; }

/* Кружок */
.bubble.circle-b { background: none !important; box-shadow: none; padding: 0; white-space: normal; }
.bubble.media { white-space: normal; }
.circle {
  --d: min(240px, 62vw); width: var(--d); height: var(--d); border-radius: 50%; position: relative; cursor: pointer;
  overflow: visible;
}
.circle video { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; background: var(--panel-2); box-shadow: var(--shadow); }
.circle svg.ring circle[stroke-dashoffset="100"] { opacity: 0; }
.circle .c-load {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 76px; height: 76px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .5); color: #fff; backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.circle .c-load b { font-size: 17px; font-variant-numeric: tabular-nums; }
.circle .c-load small { font-size: 10.5px; opacity: .85; }
.progress-ring { flex-direction: column; gap: 6px; }
.progress-ring .pct { color: #fff; font-size: 13px; font-weight: 700; line-height: 1; text-shadow: 0 1px 3px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
.voice .pct { font-variant-numeric: tabular-nums; }
.voice .pp.loading { animation: pulse 1s ease-in-out infinite; }
.circle svg.ring { position: absolute; inset: -5px; width: calc(100% + 10px); height: calc(100% + 10px); transform: rotate(-90deg); pointer-events: none; }
.circle svg.ring circle { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; transition: stroke-dashoffset .1s linear; }
.circle .ttl { position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%); }
.circle .chip.dur { position: absolute; left: 8px; top: 8px; }
.circle .chip.when { position: absolute; right: 2px; bottom: 6px; }
.circle .mute-ic { position: absolute; right: 18px; top: 18px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; display: flex; align-items: center; justify-content: center; }
.circle .mute-ic svg { width: 15px; height: 15px; }
.circle.gone-c { display: flex; align-items: center; justify-content: center; background: var(--panel-2); color: var(--muted); text-align: center; font-size: 13px; padding: 30px; line-height: 1.35; cursor: default; }

/* Загрузка */
.progress-ring { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); }
.progress-ring .pr {
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); color: #fff; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.progress-ring svg.arc { position: absolute; inset: 0; width: 56px; height: 56px; transform: rotate(-90deg); }
.progress-ring svg.arc circle { fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.upl-line { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.upl-bar { height: 4px; border-radius: 2px; background: color-mix(in srgb, var(--accent) 20%, transparent); overflow: hidden; margin-top: 6px; }
.upl-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.to-bottom {
  position: absolute; right: 16px; bottom: 84px; width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--panel); color: var(--muted); box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center; z-index: 3;
}
.to-bottom .badge { position: absolute; top: -6px; right: -4px; }

/* ===== Поле ввода ===== */
.composer-wrap { background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 2; }
.ctx-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px 0 16px; max-width: 860px; margin: 0 auto; }
.ctx-bar svg.lead { color: var(--accent); }
.ctx-bar .cb { flex: 1; min-width: 0; border-left: 2px solid var(--accent); padding-left: 10px; }
.ctx-bar .cb b { color: var(--accent); font-size: 13px; display: block; }
.ctx-bar .cb span { font-size: 14px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { display: flex; align-items: flex-end; gap: 4px; padding: 8px 8px; max-width: 860px; margin: 0 auto; }
.composer textarea {
  flex: 1; border: 0; outline: none; resize: none; background: var(--panel-2); border-radius: 20px;
  padding: 10px 15px; max-height: 160px; min-height: 42px; line-height: 1.4; margin: 0 2px;
}
.send-btn { background: var(--accent) !important; color: var(--on-accent) !important; }
.send-btn svg { margin-left: 2px; }
.composer .icon-btn { width: 42px; height: 42px; }

.rec-bar { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; max-width: 860px; margin: 0 auto; min-height: 58px; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex: none; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 44px; }
.rec-wave { flex: 1; height: 34px; min-width: 0; }
.rec-hint { color: var(--muted); font-size: 13px; }

/* Запись кружка */
.circle-rec {
  position: fixed; inset: 0; z-index: 50; background: rgba(5, 8, 4, .82); backdrop-filter: blur(10px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; color: #fff;
}
.circle-rec .cr-view { width: min(78vw, 360px); height: min(78vw, 360px); position: relative; }
.circle-rec video { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #000; }
.circle-rec video.mirror { transform: scaleX(-1); }
.circle-rec svg.ring { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); transform: rotate(-90deg); }
.circle-rec svg.ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.circle-rec .cr-bg { stroke: rgba(255,255,255,.15); }
.circle-rec .cr-fg { stroke: var(--accent); }
.circle-rec .cr-top { display: flex; align-items: center; gap: 10px; font-weight: 600; font-variant-numeric: tabular-nums; }
.circle-rec .cr-actions { display: flex; align-items: center; gap: 22px; }
.circle-rec .cr-actions .icon-btn { width: 56px; height: 56px; background: rgba(255,255,255,.12); color: #fff; }
.circle-rec .cr-actions .send-btn { width: 68px; height: 68px; }
.circle-rec .cr-actions svg { width: 26px; height: 26px; }

/* ===== Модалки, меню ===== */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(5, 10, 3, .45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(440px, 100%); max-height: calc(100% - 20px); overflow-y: auto; background: var(--panel); border-radius: 22px;
  box-shadow: var(--shadow-lg); animation: up .2s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes up { from { transform: translateY(16px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 0 18px; }
.sheet-head h3 { flex: 1; margin: 0; font-size: 18px; }
.sheet-body { padding: 8px 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.profile-top { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 8px 0 4px; text-align: center; }
.profile-top .pname { font-size: 21px; font-weight: 700; }
.profile-top .pnick { color: var(--muted); }
.profile-top .pstatus { font-size: 13px; color: var(--muted); }
.profile-top .pstatus.on { color: var(--accent); }
.profile-bio { background: var(--panel-2); border-radius: 14px; padding: 12px 14px; white-space: pre-wrap; word-wrap: break-word; }
.profile-bio small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 3px; }
.av-edit { position: relative; border: 0; background: none; padding: 0; border-radius: 50%; }
.av-edit .cam { position: absolute; right: -2px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; border: 3px solid var(--panel); }
.av-edit .cam svg { width: 17px; height: 17px; }
.section { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.section h4 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.set-row { display: flex; align-items: center; gap: 12px; }
.set-row .grow { flex: 1; min-width: 0; }
.set-row .grow small { display: block; color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 8px; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.err { color: var(--danger); font-size: 14px; min-height: 0; }
.ok-msg { color: var(--accent); font-size: 14px; }

.menu {
  position: fixed; z-index: 60; min-width: 190px; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; animation: fade .12s ease; border: 1px solid var(--line);
}
.menu button { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 9px 12px; border-radius: 9px; text-align: left; }
.menu button:hover { background: var(--panel-2); }
.menu button svg { width: 19px; height: 19px; color: var(--muted); }
.menu button.danger { color: var(--danger); }
.menu button.danger svg { color: var(--danger); }

.viewer { position: fixed; inset: 0; z-index: 55; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; animation: fade .15s; }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 10px; padding-top: calc(10px + env(safe-area-inset-top)); color: #fff; }
.viewer-bar .grow { flex: 1; min-width: 0; font-size: 14px; }
.viewer-bar .icon-btn { color: #fff; }
.viewer-bar .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px calc(8px + env(safe-area-inset-bottom)); }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }

.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 70;
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); border-radius: 14px; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; max-width: min(420px, calc(100% - 24px)); cursor: pointer; animation: drop .25s ease;
  border: 1px solid var(--line);
}
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } }
.toast .tb { min-width: 0; }
.toast .tb b { display: block; font-size: 14px; }
.toast .tb span { display: block; font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.plain { cursor: default; }

.drop-zone {
  position: absolute; inset: 10px; z-index: 20; border: 3px dashed var(--accent); border-radius: 22px;
  background: color-mix(in srgb, var(--panel) 85%, transparent); display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; color: var(--accent); pointer-events: none;
}

/* ===== Телефон ===== */
@media (max-width: 799px) {
  .app { grid-template-columns: 1fr; position: relative; overflow: hidden; }
  .sidebar, .main { grid-area: 1 / 1; transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
  .main { transform: translateX(100%); }
  .app.chat-open .main { transform: none; }
  .app.chat-open .sidebar { transform: translateX(-28%); }
  .back-btn { display: inline-flex; }
  .bubble { max-width: 86%; }
  .to-bottom { bottom: 78px; right: 12px; }
  .messages-inner { padding: 0 8px; }
  .overlay.bottom { align-items: flex-end; padding: 0; }
  .overlay.bottom .sheet { border-radius: 22px 22px 0 0; max-height: 92%; padding-bottom: env(safe-area-inset-bottom); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===== Вход ===== */
.auth-page { overflow: auto; display: flex; min-height: 100%; }
.auth {
  margin: auto; width: min(400px, 100%); padding: 32px 22px calc(32px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 18px;
}
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.auth-logo img { width: 76px; height: 76px; border-radius: 22px; box-shadow: var(--shadow-lg); }
.auth-logo h1 { margin: 0; font-size: 30px; letter-spacing: -.03em; }
.auth-logo p { margin: 0; color: var(--muted); }
.auth-card { background: var(--panel); border-radius: 22px; padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--panel-2); border-radius: 12px; padding: 4px; }
.tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-card .btn { margin-top: 4px; padding: 13px; }
.auth-foot { text-align: center; color: var(--muted); font-size: 13px; }
