:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f1f2f6);
  --text: var(--tg-theme-text-color, #111);
  --hint: var(--tg-theme-hint-color, #8a8f98);
  --accent: var(--tg-theme-button-color, #6a5acd);
  --accent-text: var(--tg-theme-button-text-color, #fff);
  --bubble-in: var(--tg-theme-section-bg-color, #ffffff);
  --radius: 16px;
  /* safe area: системная (iPhone) и от Telegram (Bot API 8.0, полноэкранный режим) */
  --safe-b: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-t: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --vh: var(--tg-viewport-stable-height, 100vh);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg2); color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.screen { min-height: var(--vh); padding-bottom: calc(90px + var(--safe-b)); }
.top { padding: calc(16px + var(--safe-t)) 16px 4px; }
.top h1 { margin: 0; font-size: 22px; }

.list { padding: 8px 12px; display: flex; flex-direction: column; gap: 8px; }
.card { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--bg);
  border-radius: var(--radius); cursor: pointer; }
.card .name { font-weight: 600; }
.card .sub, .sub { color: var(--hint); font-size: 13px; }
.avatar { width: 54px; height: 54px; border-radius: 50%; object-fit: cover; background:
  linear-gradient(135deg, #6a5acd, #ff7eb3); flex-shrink: 0; }
.avatar.sm { width: 40px; height: 40px; }

.empty { text-align: center; padding: 60px 30px; color: var(--hint); }
.empty-icon { font-size: 56px; }

.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-size: 15px; background: var(--bg2);
  color: var(--text); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.wide { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .6; }
.floating { position: fixed; left: 16px; right: 16px; bottom: calc(16px + var(--safe-b)); z-index: 5; box-shadow: 0 6px 20px rgba(0,0,0,.18); }

.block { background: var(--bg); margin: 10px 12px; padding: 14px; border-radius: var(--radius); }
.label { font-weight: 600; margin: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 20px;
  padding: 6px 12px; font-size: 14px; cursor: pointer; }
.form label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--hint); }
.form input:not([type=checkbox]), .form textarea, .form select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(128,128,128,.25); background: var(--bg2); color: var(--text); font: inherit; resize: vertical; }
.row { display: flex; gap: 10px; } .row label { flex: 1; }
.hint { display: block; font-size: 12px; }
.check { display: flex !important; gap: 8px; align-items: flex-start; margin-top: 10px; }
.check input { margin-top: 3px; }
.note { color: var(--hint); font-size: 12px; }
.seg { display: flex; background: var(--bg2); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 10px; color: var(--text); font: inherit; }
.seg button.active { background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,.1); font-weight: 600; }
.previews { display: flex; gap: 8px; margin-top: 10px; }
.previews img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }

/* чат */
#screen-chat { display: flex; flex-direction: column; height: 100vh; height: var(--tg-viewport-height, 100dvh); min-height: 0; padding: 0; }
.chat-top { display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 12px 10px; background: var(--bg);
  border-bottom: 1px solid rgba(128,128,128,.15); }
.chat-title { flex: 1; } #chat-name { font-weight: 600; }
.icon-btn { border: 0; background: transparent; font-size: 20px; padding: 6px; cursor: pointer; color: var(--text); min-width: 40px; min-height: 40px; }
.icon-btn:disabled { opacity: .35; }
.icon-btn.more { font-size: 24px; line-height: 1; color: var(--hint); }
.messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 6px; }
.msg.media { padding: 4px; }
.msg.media img, .msg.media video { display: block; max-width: 240px; width: 100%; min-height: 120px; border-radius: 14px; cursor: pointer; background: var(--bg2); }
.msg .pending { width: 220px; height: 280px; border-radius: 14px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; color: var(--hint); background: var(--bg2); font-size: 13px; }
.spinner { width: 28px; height: 28px; border: 3px solid rgba(128,128,128,.3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.typing { align-self: flex-start; color: var(--hint); font-size: 13px; padding: 4px 8px; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px; background: var(--bg);
  border-top: 1px solid rgba(128,128,128,.15); padding-bottom: calc(8px + var(--safe-b)); }
.composer.kb { padding-bottom: 8px; }
.composer textarea { flex: 1; border: 0; border-radius: 18px; padding: 10px 14px; background: var(--bg2);
  color: var(--text); font: inherit; resize: none; max-height: 120px; outline: none; }
.send { border: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: var(--accent-text); font-size: 18px; flex-shrink: 0; transition: opacity .15s; }
.send:disabled { opacity: .4; }

/* голосовые */
.msg.voice audio { display: block; width: 230px; max-width: 100%; height: 40px; }
.msg.voice .voice-text { font-size: 13px; opacity: .85; margin-top: 4px; }
.voice-pending { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hint); }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
#btn-mic.recording { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.2); } }
#btn-voice-mode.on { filter: none; } #btn-voice-mode { filter: grayscale(1); }

/* подписка */
.plan-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg);
  margin: 10px 12px 0; padding: 10px 12px; border-radius: var(--radius); }
.plan-bar .name { font-weight: 600; }
.btn.small { padding: 8px 12px; font-size: 14px; flex-shrink: 0; }
.plan { background: var(--bg); border-radius: var(--radius); padding: 14px; border: 2px solid transparent; }
.plan.active { border-color: var(--accent); }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; }
.plan-title { font-weight: 700; font-size: 17px; }
.plan-price { font-weight: 700; color: var(--accent); }
.plan ul { margin: 8px 0 4px; padding-left: 20px; color: var(--text); }
.pad { padding: 0 16px; }
.note a { color: var(--accent); }

.viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: flex; align-items: center;
  justify-content: center; z-index: 10; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; }
.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); background: rgba(0,0,0,.8);
  color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 50; max-width: 90%; text-align: center; }

/* этап 1: состояния, карточка лимита, тарифы */
.grow { flex: 1; min-width: 0; }
.skel, .skel-line, .skel-card { background: linear-gradient(90deg, rgba(128,128,128,.12) 25%, rgba(128,128,128,.22) 50%, rgba(128,128,128,.12) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.skel-line { height: 12px; border-radius: 6px; margin: 6px 0; }
.skel-line.w25 { width: 25%; } .skel-line.w40 { width: 40%; } .skel-line.w60 { width: 60%; } .skel-line.w90 { width: 90%; }
#chat-name.skel-line { height: 14px; }
.card.skel-card { cursor: default; min-height: 78px; }
.card.skel-card .avatar { background: rgba(128,128,128,.18); }
.plan.skel-card { min-height: 180px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.chat-loading { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 200px; }
.state-error { text-align: center; padding: 48px 24px; color: var(--hint); }
.state-error p { margin: 0 0 14px; }
.limit-card { display: flex; align-items: center; gap: 12px; margin: 0 8px 8px; padding: 12px 14px; background: var(--bg);
  border: 1.5px solid var(--accent); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.limit-card .name { font-weight: 600; font-size: 14px; }
.limit-card .sub { margin-top: 2px; }
.composer.busy textarea { opacity: .85; }
.plan-bar.expired { border: 1.5px solid var(--accent); }
.plan { position: relative; }
.plan.recommended { border-color: var(--accent); box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.plan.active { border-color: var(--accent); }
.badge { position: absolute; top: -10px; right: 14px; background: var(--accent); color: var(--accent-text); font-size: 11.5px;
  font-weight: 700; padding: 3px 9px; border-radius: 10px; }
.plan .sub { margin-top: 2px; }
.plan-cards-gap, #plan-cards { gap: 14px; padding-top: 14px; }
.btn.link { background: transparent; color: var(--accent); font-weight: 500; padding: 10px; margin-top: 2px; }
.btn.primary:disabled { opacity: .7; }

/* этап 2: мастер создания */
.wiz-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.wiz-bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(128,128,128,.2); overflow: hidden; }
.wiz-bar i { display: block; height: 100%; width: 25%; background: var(--accent); border-radius: 3px; transition: width .25s; }
.step-title { font-weight: 700; font-size: 18px; margin-bottom: 4px; }
.step-sub { margin: 0 0 12px; }
.form .block label { color: var(--hint); }
#f-name.invalid input { border-color: #e53935; }
.draft-line { text-align: center; font-size: 12px; color: var(--hint); margin: 4px 12px; }
.draft-line a { color: var(--accent); }
.wiz-nav { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 10px 12px calc(10px + var(--safe-b));
  background: linear-gradient(to top, var(--bg2) 70%, transparent); z-index: 4; }
.wiz-nav .btn { flex: 1; }
.wiz-nav #wiz-back { flex: 0 0 34%; }
#screen-create { padding-bottom: 0; }

/* знакомство */
.onb { position: fixed; inset: 0; z-index: 30; background: var(--bg2); display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-t)) 20px 0; overflow-y: auto; }
.onb-skip { align-self: flex-end; border: 0; background: transparent; color: var(--hint); font: inherit; padding: 8px; }
.onb-slide { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 12px; }
.onb-slide h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.onb-slide p { margin: 0; }
.onb-art { font-size: 64px; }
.onb-opts { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; text-align: left; }
.onb-opt { display: flex; flex-direction: column; gap: 2px; border: 1.5px solid rgba(128,128,128,.25); background: var(--bg);
  color: var(--text); border-radius: var(--radius); padding: 14px; font: inherit; text-align: left; cursor: pointer; }
.onb-opt.sel { border-color: var(--accent); }
.onb-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.onb-list li { display: flex; gap: 12px; align-items: center; background: var(--bg); border-radius: var(--radius); padding: 12px 14px; }
.onb-list b { font-size: 22px; }
.onb-foot { padding: 12px 0 calc(16px + var(--safe-b)); }
.onb-dots { display: flex; gap: 6px; justify-content: center; margin-bottom: 12px; }
.onb-dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(128,128,128,.3); transition: width .2s; }
.onb-dots i.on { width: 20px; background: var(--accent); }

/* приветствие, подсказки, служебные строки */
.typing-bubble { padding: 12px 14px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--hint); animation: blink 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.hints { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 10px 8px; }
.hint-chip { border: 1px solid rgba(128,128,128,.3); background: var(--bg); color: var(--text); border-radius: 18px;
  padding: 8px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.sys-note { align-self: center; display: flex; align-items: center; gap: 6px; max-width: 92%; text-align: center;
  font-size: 12.5px; color: var(--hint); background: var(--bg); border-radius: 12px; padding: 6px 10px; margin: 4px 0; }
.sys-note .btn.link { padding: 2px 4px; margin: 0; font-size: 12.5px; width: auto; }

/* голос: переключатель, запись, плеер */
.voice-pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid rgba(128,128,128,.3); background: var(--bg2);
  color: var(--text); border-radius: 16px; padding: 5px 10px 5px 6px; font: inherit; font-size: 13px; cursor: pointer; flex-shrink: 0; }
.voice-pill .sw { width: 26px; height: 16px; border-radius: 8px; background: rgba(128,128,128,.35); position: relative; transition: background .2s; }
.voice-pill .sw i { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left .2s; }
.voice-pill.on { border-color: var(--accent); }
.voice-pill.on .sw { background: var(--accent); }
.voice-pill.on .sw i { left: 12px; }
.voice-pill.locked { color: var(--hint); }
.rec-bar { flex: 1; display: flex; align-items: center; gap: 8px; min-height: 40px; }
.rec-bar .icon-btn { color: #e53935; font-size: 18px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e53935; animation: blink 1s infinite; flex-shrink: 0; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-max { color: var(--hint); font-size: 13px; }
.rec-track { flex: 1; height: 4px; border-radius: 2px; background: rgba(128,128,128,.2); overflow: hidden; }
.rec-track i { display: block; height: 100%; width: 0; background: #e53935; }
.composer.recording > textarea, .composer.recording > #btn-photo-req, .composer.recording > #btn-mic,
.composer.recording > #btn-send { display: none; }
.vp { display: flex; align-items: center; gap: 10px; min-width: 210px; }
.vp audio { display: none; }
.vp-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; flex-shrink: 0; font-size: 13px; cursor: pointer;
  background: var(--accent); color: var(--accent-text); }
.msg.user .vp-btn { background: var(--accent-text); color: var(--accent); }
.vp-track { flex: 1; height: 4px; border-radius: 2px; background: currentColor; opacity: .35; position: relative; cursor: pointer; }
.vp-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: currentColor; border-radius: 2px; }
.vp.on .vp-track { opacity: .6; }
.vp-time { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .85; min-width: 30px; text-align: right; }

/* paywall */
.pw-head { text-align: center; }
.pw-head h1 { font-size: 22px; line-height: 1.25; margin: 6px 0 4px; }
.pw-ava { width: 64px; height: 64px; margin: 4px auto 0; display: block; }
.pw-sub { max-width: 320px; margin: 0 auto; }
.perks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 12px 12px 0; }
.perks div { background: var(--bg); border-radius: 12px; padding: 8px 4px; text-align: center; font-size: 11.5px; color: var(--hint); line-height: 1.25; }
.perks b { display: block; font-size: 20px; margin-bottom: 2px; }
.plan-current { padding: 10px 14px; }
.plan-current .name { font-size: 14px; font-weight: 600; }
.pw-autorenew .btn.wide { margin-top: 8px; }
button.plan { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; font: inherit; color: var(--text);
  cursor: pointer; border: 2px solid rgba(128,128,128,.18); }
button.plan.selected { border-color: var(--accent); }
.plan .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(128,128,128,.45); flex-shrink: 0; margin-top: 2px; }
.plan.selected .radio { border: 6px solid var(--accent); }
.plan-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plan-body .plan-head { display: flex; }
.feats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.feats span { font-size: 12.5px; padding: 3px 8px; border-radius: 8px; background: var(--bg2); }
.pw-cta { position: sticky; bottom: 0; padding: 12px 12px calc(12px + var(--safe-b)); background: linear-gradient(to top, var(--bg2) 75%, transparent); z-index: 4; }
.pw-cta .btn.wide { margin-top: 0; }
.pw-note { text-align: center; margin-top: 6px; }
#screen-plans { padding-bottom: 16px; }

/* свой голос собеседника */
.vc-tip { margin: 0 0 12px; }
.vc-src { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.vc-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 6px; border-radius: 14px;
  border: 1.5px solid rgba(128,128,128,.25); background: var(--bg2); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.vc-opt b { font-size: 24px; }
.vc-recbar { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 14px; background: var(--bg2); margin-bottom: 12px; }
.vc-recbar .icon-btn { color: #e53935; font-size: 18px; }
.btn.small { padding: 8px 12px; font-size: 14px; width: auto; margin: 0; }
.vc-botinfo { background: var(--bg2); border-radius: 14px; padding: 10px 14px 14px; margin-bottom: 12px; font-size: 14px; }
.vc-botinfo ol { margin: 0 0 10px; padding-left: 18px; line-height: 1.45; }
.vc-botinfo a { color: var(--accent); }
.vc-chosen { background: var(--bg2); border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; }
.vc-chosen-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 600; }
.vc-chosen .vp { margin-top: 8px; color: var(--text); }
.vc-locked { text-align: center; padding: 6px 4px 4px; }
.vc-lock-ico { font-size: 34px; }
.vc-locked p { color: var(--hint); margin: 6px 0 12px; }
.vs-status .vp { margin: 12px 0 4px; color: var(--text); }
.vs-row { display: flex; gap: 12px; align-items: center; }
.vs-ok { width: 36px; height: 36px; border-radius: 50%; background: #2e7d32; color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; flex-shrink: 0; }
.vs-ok.off { background: rgba(128,128,128,.3); }
.vs-err { color: #e53935; font-size: 13.5px; margin: 10px 0 0; }
.btn.link.danger { color: #e53935; margin-top: 8px; }
#screen-voice { padding-bottom: 16px; }

/* ---- настройки собеседника (этап 2b) ---- */
.set-head { display: flex; align-items: center; gap: 12px; padding-bottom: 8px; }
.set-head .avatar { width: 56px; height: 56px; }
.set-head h1 { font-size: 21px; }
.set-row, .set-std { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 0; border: 0; background: none;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.set-row .grow, .set-std .grow { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.set-row .sub, .set-std .sub { font-size: 13px; }
.set-std { border-top: 1px solid rgba(128,128,128,.18); margin-top: 8px; padding-top: 12px; }
.set-std select { max-width: 48%; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(128,128,128,.3); background: var(--bg2);
  color: var(--text); font: inherit; font-size: 14px; }
.set-row .sw { flex: none; width: 44px; height: 26px; border-radius: 13px; background: rgba(128,128,128,.35); position: relative; transition: background .2s; }
.set-row .sw i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.set-row[aria-checked="true"] .sw { background: var(--accent); }
.set-row[aria-checked="true"] .sw i { left: 21px; }
.set-row.locked .sw { opacity: .45; }
.set-gap { margin-top: 8px; }
.set-danger { background: transparent; padding-top: 4px; }
.set-danger .sub { text-align: center; margin: 8px 0 0; font-size: 13px; }
.btn.danger { background: rgba(229,57,53,.12); color: #e53935; font-weight: 600; }
.btn.danger.outline { background: transparent; border: 1px solid rgba(229,57,53,.45); }
.vs-actions { display: flex; gap: 8px; margin-top: 12px; }
.vs-actions .btn { flex: 1; margin: 0; padding: 11px 8px; font-size: 14.5px; }
.vs-quota { font-size: 13px; color: var(--hint); margin: 10px 0 0; }
.card .card-more { margin-left: auto; flex: none; }
.chat-top .chat-title, .chat-top #chat-avatar { cursor: pointer; }

/* ---- редактирование собеседника ---- */
.set-profile .sub { margin: 0 0 4px; font-size: 13.5px; }
.set-profile .btn.wide { margin-top: 4px; }
.ed-photo { display: flex; align-items: center; gap: 12px; }
.ed-photo .avatar { width: 64px; height: 64px; }
.ed-photo .grow { display: flex; flex-direction: column; gap: 2px; }
.ed-photo-actions { display: flex; gap: 8px; margin-top: 12px; }
.ed-photo-actions .btn { flex: 1; padding: 11px 8px; font-size: 14.5px; }
.ed-note { font-size: 12.5px; margin: 8px 0 0; }
#ed-upload { margin-top: 10px; }
.ed-count { text-align: right; font-size: 12px; margin-top: -4px; }

/* ===== Тёплая тема V1 (T-9): своя палитра поверх Telegram, единые кнопки, значки ===== */
:root, [data-scheme=light] {
  --bg: #fffaf5; --bg2: #f6efe8; --text: #2b2420; --hint: #6f6258; --accent: #b9533a; --accent-text: #fff;
  --bubble-in: #ffffff; --line: rgba(90,60,40,.14); --danger: #c62828; --btn2: #efe4da; --dis-bg: #e6dcd3; --dis-text: #8f8378;
  --shadow: 0 1px 2px rgba(80,50,30,.08);
}
[data-scheme=dark] {
  --bg: #2a2320; --bg2: #1d1816; --text: #f3ebe4; --hint: #b0a294; --accent: #ee8b6f; --accent-text: #1d1816;
  --bubble-in: #2f2724; --line: rgba(255,235,220,.12); --danger: #ff8a80; --btn2: #3a302c; --dis-bg: #3a302c; --dis-text: #8f8378;
  --shadow: none;
}
html, body { font-size: 16px; line-height: 1.45; }
.top-sub { margin: 2px 0 0; color: var(--hint); font-size: 14px; }
.top h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: -.01em; }
.card, .block, .msg.assistant { box-shadow: var(--shadow); }
.card .sub, .sub { font-size: 14px; }
.note, .hint, .draft-line { font-size: 13px; }
.avatar { background: linear-gradient(135deg, #f3c9a8, #d98b73); }

/* кнопки: одна высота, один радиус */
.btn { min-height: 50px; border-radius: 14px; font-size: 16px; background: var(--btn2); }
.btn.small { min-height: 36px; padding: 8px 14px; font-size: 14px; border-radius: 12px; }
.btn.link { background: transparent; min-height: 44px; }
.btn.primary:disabled, .btn:disabled { opacity: 1; background: var(--dis-bg); color: var(--dis-text); }
.btn.link.danger, .btn.danger { background: transparent; color: var(--danger); font-weight: 500; border: 0; }
.btn.danger.outline { border: 1px solid var(--danger); }
.btn:active:not(:disabled) { transform: scale(.985); filter: brightness(.96); }
.floating { left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); box-shadow: 0 4px 14px rgba(80,50,30,.18); }
.screen { padding-bottom: calc(96px + var(--safe-b)); }
/* нижние панели: сплошная подложка, без просвечивающего текста */
.wiz-nav, .pw-cta { background: var(--bg2); border-top: 1px solid var(--line); padding-top: 10px; }
.wiz-nav #wiz-back { background: transparent; border: 1px solid var(--line); }
/* мастер: «Далее» всегда внизу экрана */
#screen-create:not(.hidden) { display: flex; flex-direction: column; }
#create-form { flex: 1; display: flex; flex-direction: column; }
#create-form .wiz-nav { margin-top: auto; }

/* чат: значки вместо эмодзи */
.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; margin: auto; }
.ic .fill, .send .ic path { fill: currentColor; stroke: none; }
.send .ic { width: 20px; height: 20px; }
.composer { gap: 4px; padding: 6px 8px calc(6px + var(--safe-b)); border-top-color: var(--line); }
.composer .icon-btn { width: 44px; height: 44px; min-width: 44px; color: var(--hint); padding: 0; border-radius: 50%; }
.composer .icon-btn:active { background: var(--bg2); }
.composer textarea { min-height: 44px; padding: 11px 14px; font-size: 16px; border-radius: 22px; }
.send { width: 44px; height: 44px; }
.rec-bar .icon-btn { color: var(--danger); }
.chip { border-color: var(--accent); color: var(--accent); }

/* видео по кнопке (T-11) */
.sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.62); display: flex; align-items: flex-end;
  overscroll-behavior: contain; touch-action: none; }
/* лист непрозрачный (фон — цвет темы, без прозрачности) и прокручивается сам; страница под ним заблокирована (.scroll-lock) */
.sheet-box { width: 100%; background-color: var(--bg); color: var(--text); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(12px + var(--safe-b)); box-shadow: 0 -6px 24px rgba(0,0,0,.28); border-top: 1px solid var(--line, rgba(128,128,128,.22));
  max-height: 92vh; max-height: calc(var(--vh) * .92); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  -webkit-overflow-scrolling: touch; }
html.scroll-lock, html.scroll-lock body { overflow: hidden; overscroll-behavior: none; }
html.scroll-lock body { position: fixed; left: 0; right: 0; width: 100%; }
.sheet-title { font-family: Georgia, "Times New Roman", serif; font-weight: 600; font-size: 20px; margin-bottom: 6px; }
.sheet-text { margin: 0 0 12px; color: var(--hint); font-size: 15px; }
.sheet-box textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--bg2);
  color: var(--text); font: inherit; font-size: 16px; resize: none; outline: none; }
.sheet-count { margin: 8px 0 4px; font-size: 14px; color: var(--hint); }
.composer .icon-btn { width: 42px; min-width: 42px; }

/* «Сохранить» / «Переслать» под медиа собеседника (24.11) */
.msg-acts { display: flex; gap: 6px; margin-top: 6px; white-space: normal; }
.msg.media .msg-acts { padding: 0 2px 2px; }
.msg-acts .act { flex: 1; min-height: 34px; border: 1px solid var(--line, rgba(128,128,128,.25)); border-radius: 12px;
  background: var(--bg2); color: var(--text); font: inherit; font-size: 13px; padding: 6px 4px; cursor: pointer; white-space: nowrap; }
.msg.media .msg-acts { min-width: 232px; }
.msg-acts .act:active { opacity: .7; }
.msg-acts .act:disabled { opacity: .5; }
.sheet-check { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; color: var(--hint); }
.sheet-check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* полноэкранный просмотр фото/видео (24.11): ✕, медиа по центру, «Сохранить»/«Переслать» снизу */
.viewer { flex-direction: column; z-index: 30; padding: calc(8px + var(--safe-t)) 0 calc(12px + var(--safe-b)); }
.viewer .vw-media { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.viewer .vw-media img, .viewer .vw-media video { width: 100%; height: 100%; object-fit: contain; }
.viewer .vw-close { position: absolute; top: calc(10px + var(--safe-t)); right: 12px; z-index: 1; width: 44px; height: 44px;
  border: 0; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; font-size: 20px; line-height: 44px; cursor: pointer; }
.viewer .vw-acts { width: 100%; max-width: 420px; padding: 10px 16px 0; }
.viewer .vw-acts .msg-acts { margin: 0; }
.viewer .vw-acts .act { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.22); min-height: 44px; font-size: 14px; }
.vthumb { position: relative; cursor: pointer; }
.vthumb video { pointer-events: none; }
.vplay { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; font-size: 22px; line-height: 56px; text-align: center; padding-left: 4px; pointer-events: none; }

/* «Отправить» чуть дальше от кнопок фото/видео/микрофона — меньше промахов (24.11) */
.composer > #btn-send { margin-left: 8px; }

/* Видеосообщение с голосом (28.11): значок звука на превью, реплика под роликом, выбор режима в листе */
.vsound { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.55); color: #fff; border-radius: 12px;
  padding: 3px 7px; line-height: 0; pointer-events: none; }
.msg.media .vcap { padding: 6px 10px 2px; font-size: 13px; line-height: 1.35; opacity: .9; max-width: 220px; }
.msg .pending small { display: block; font-size: 12px; opacity: .8; margin-top: -6px; }
#vsh-mode { margin: 4px 0 10px; }
#vsh-mode button { min-height: 44px; }

/* язык: кнопка на главной и переключатель в настройках */
.top { position: relative; }
/* Готовые собеседники (T-22): витрина на главном экране и карточка-лист */
.empty.compact { padding: 14px 28px 0; }
.empty.compact .empty-icon { display: none; }
.empty.compact p { margin: 8px 0 0; }
.cast { padding: 4px 0 0; }
.cast-title { font-family: Georgia, "Times New Roman", serif; font-weight: 600; font-size: 19px; margin: 14px 16px 2px; }
.cast-sub { margin: 0 16px 10px; color: var(--hint); font-size: 13px; }
.cast-list { padding: 2px 12px 8px; }
.cast-list.strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.cast-list.strip::-webkit-scrollbar { display: none; }
.cast-list.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.cast-card { border: 0; padding: 0; background: var(--bg); color: var(--text); font: inherit; text-align: left; cursor: pointer;
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-width: 0; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.cast-list.strip .cast-card { flex: 0 0 148px; scroll-snap-align: start; }
.cc-pic { position: relative; display: block; aspect-ratio: 3 / 4; background: var(--bg2); }
.cc-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-added { position: absolute; top: 6px; right: 6px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent);
  color: var(--accent-text); font-size: 13px; line-height: 22px; text-align: center; font-style: normal; }
.cc-info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cc-name { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.cc-meta { font-size: 12.5px; color: var(--hint); overflow-wrap: anywhere; }
.cc-traits { font-size: 12px; color: var(--hint); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.cs-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.cs-pic-btn { position: relative; flex: none; width: 112px; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 14px; }
.cs-pic { display: block; width: 112px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; background: var(--bg2); }
.cs-zoom { position: absolute; right: 6px; bottom: 6px; width: 26px; height: 26px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-style: normal; font-size: 16px; line-height: 26px; text-align: center; pointer-events: none; }
.cs-main { min-width: 0; flex: 1; }
.cs-main .sheet-title { margin: 0 0 4px; overflow-wrap: anywhere; }
.cs-meta { font-size: 13.5px; color: var(--hint); overflow-wrap: anywhere; }
.cs-traits { margin-top: 8px; font-size: 13px; color: var(--accent); overflow-wrap: anywhere; }
.cs-added { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--accent); }
.cs-bio { margin: 0 0 8px; font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere; }
.cs-note { margin: 4px 0 10px; }
.lang-chip { position: absolute; top: calc(14px + var(--safe-t)); right: 14px; border: 0; background: var(--bg); color: var(--hint, #8a7d74); font: inherit; font-size: 13px; padding: 5px 10px; border-radius: 999px; box-shadow: 0 1px 3px rgba(0,0,0,.08); cursor: pointer; }
.lang-chip:disabled { opacity: .6; }
.lang-chip { max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top { padding-right: 14px; }
.lang-cur { flex: none; color: var(--hint); font-size: 14px; white-space: nowrap; max-width: 45%; overflow: hidden; text-overflow: ellipsis; }
.lang-list { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.lang-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line, rgba(128,128,128,.25)); border-radius: 14px; background: var(--bg2); color: var(--text); font: inherit; font-size: 16px; text-align: left; cursor: pointer; }
.lang-opt .lo-name { min-width: 0; overflow-wrap: anywhere; }
.lang-opt .lo-check { visibility: hidden; color: var(--accent); font-weight: 700; }
.lang-opt.active { border-color: var(--accent); background: var(--bg); font-weight: 600; }
.lang-opt.active .lo-check { visibility: visible; }
.lang-opt:disabled { opacity: .6; }

/* фото из карточки готового собеседника: поверх листа, без касаний-прокруток страницы; зум щипком/двойным тапом (attachZoom) */
.viewer.over-sheet { z-index: 45; }
.viewer { overscroll-behavior: contain; touch-action: none; }
.viewer img[data-zoom] { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; transform-origin: 50% 50%; will-change: transform; }

/* «Пожаловаться» (30.11): в одном блоке с «Язык приложения», под ним — через разделитель */
.set-row-sep { border-top: 1px solid rgba(128,128,128,.18); margin-top: 8px; padding-top: 12px; }

/* смена подписки (30.11): более дешёвая при действующей дорогой — недоступна до её окончания */
.plan.locked { opacity: .6; }
.plan .badge.muted { background: rgba(128,128,128,.25); color: var(--text); }
.pw-why { margin: 0 2px 8px; font-size: 13px; }

/* возраст 18+ (30.11): экран при первом входе, поверх всего, кроме листа выбора языка */
.age-gate { z-index: 35; }
.banned { z-index: 80; }  /* выше листов, просмотра и тоста */
.banned-deleted { margin-top: 12px; font-weight: 600; color: var(--text); }
.age-gate .age-lang { position: static; align-self: flex-end; max-width: 70%; }
.age-body { flex: 1; display: flex; flex-direction: column; justify-content: center; text-align: center; gap: 12px; }
.age-body h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.age-body p { margin: 0; }
.age-no { color: var(--danger); font-weight: 500; }
.age-gate[data-mode="age"] .terms-only, .age-gate[data-mode="terms"] .age-only { display: none; }
.age-terms { margin: 0 0 12px; text-align: left; font-size: 14px; line-height: 1.35; cursor: pointer; }
.age-terms input { width: 20px; height: 20px; flex: none; margin-top: 0; accent-color: var(--accent); }
.age-offer { display: block; text-align: center; margin-top: 6px; font-size: 13px; color: var(--hint); }
