/* EVERMIRA — диалог с памятью: крупный портрет-бюст слева, чат справа, выбор фона, футуристично. */

.chat-wrap { display: grid; grid-template-columns: 1fr 408px; min-height: 100vh; }
@media (max-width: 920px) { .chat-wrap { grid-template-columns: 1fr; } }

.chat-back { position: fixed; top: 18px; left: 18px; z-index: 20; display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); padding: 9px 14px; border-radius: 11px; border: 1px solid var(--line); background: rgba(12,14,19,0.55); backdrop-filter: blur(8px); }
.chat-back:hover { color: var(--text); border-color: var(--gold); }
.chat-back svg { width: 17px; height: 17px; }

/* ===== сцена аватара ===== */
.av-stage { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 28px; min-height: 100vh; }
@media (max-width: 920px) { .av-stage { min-height: 70vh; } }
.av-bg { position: absolute; inset: 0; z-index: 0; transition: opacity .6s; }
.av-stage > *:not(.av-bg) { position: relative; z-index: 2; }

.av-holder { position: relative; width: min(640px, 94%); aspect-ratio: 1 / 1.04; margin: 0 auto; }
.av-canvas, .av-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.av-3d canvas { width: 100% !important; height: 100% !important; display: block; }

/* переключатель 2D / 3D */
.av-render { display: inline-flex; gap: 4px; margin-bottom: 14px; background: rgba(12,14,19,0.6); border: 1px solid var(--line); border-radius: 11px; padding: 4px; backdrop-filter: blur(8px); }
.av-render button { padding: 8px 22px; border-radius: 8px; font-size: 13px; font-weight: 700; letter-spacing: .5px; color: var(--muted); }
.av-render button.sel { background: linear-gradient(180deg, var(--gold), var(--gold-soft)); color: #1a1308; }
.av-name { font-family: var(--serif); font-size: clamp(26px, 3vw, 34px); margin-top: 2px; text-shadow: 0 2px 20px rgba(0,0,0,0.6); }
.av-sim { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--azure); border: 1px solid rgba(143,176,212,0.4); padding: 5px 13px; border-radius: 20px; background: rgba(12,14,19,0.4); backdrop-filter: blur(6px); }
.av-sim svg { width: 13px; height: 13px; }
.av-modes { display: inline-flex; gap: 4px; margin: 18px auto 0; background: rgba(12,14,19,0.55); border: 1px solid var(--line); border-radius: 11px; padding: 4px; backdrop-filter: blur(8px); }
.av-modes button { padding: 9px 18px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.av-modes button.sel { background: var(--panel-2); color: var(--text); }
.av-foot { margin-top: 14px; text-align: center; }
.av-hint { font-size: 11.5px; color: var(--faint); max-width: 520px; margin: 14px auto 0; line-height: 1.55; }

/* выбор фона */
.bg-pick { display: flex; gap: 8px; margin-top: 20px; }
.bg-pick button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); cursor: pointer; transition: .2s; position: relative; }
.bg-pick button:hover { transform: translateY(-2px); }
.bg-pick button.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(224,177,115,0.3); }
.bg-pick button[data-bg="cosmos"] { background: radial-gradient(circle at 50% 35%, #1b2a4a, #06070b); }
.bg-pick button[data-bg="warm"]   { background: radial-gradient(circle at 50% 38%, #e0b173, #0c0a08); }
.bg-pick button[data-bg="holo"]   { background: linear-gradient(135deg, #0a2a3a, #2a1040); }
.bg-pick button[data-bg="river"]  { background: linear-gradient(135deg, #2a4d63, #102530); }
.bg-pick button[data-bg="studio"] { background: radial-gradient(circle at 50% 35%, #2a2f3a, #0c0e13); }

/* ===== пресеты фона ===== */
.chat-wrap[data-bg="cosmos"] .av-bg { background:
  radial-gradient(900px 760px at 50% 34%, #16223e 0%, transparent 60%),
  radial-gradient(620px 520px at 74% 82%, rgba(143,176,212,0.12), transparent 60%),
  radial-gradient(500px 460px at 20% 70%, rgba(224,177,115,0.08), transparent 60%), #06070b; }
.chat-wrap[data-bg="warm"] .av-bg { background:
  radial-gradient(760px 640px at 50% 38%, rgba(224,177,115,0.28), transparent 62%),
  radial-gradient(500px 420px at 60% 80%, rgba(217,118,46,0.12), transparent 60%), #0c0a08; }
.chat-wrap[data-bg="studio"] .av-bg { background: radial-gradient(820px 720px at 50% 30%, #222732, #0a0c11); }
.chat-wrap[data-bg="river"] .av-bg { background: linear-gradient(180deg, rgba(8,10,14,0.55), rgba(8,10,14,0.8)), url('https://images.unsplash.com/photo-1468581264429-2548ef9eb732?w=1200&q=80&auto=format&fit=crop') center/cover; }
.chat-wrap[data-bg="holo"] .av-bg { background: radial-gradient(700px 600px at 50% 36%, #0c2030, #05070d 70%); }
.chat-wrap[data-bg="holo"] .av-bg::before { content: ""; position: absolute; inset: -20%; background-image: linear-gradient(rgba(143,176,212,0.16) 1px, transparent 1px), linear-gradient(90deg, rgba(143,176,212,0.16) 1px, transparent 1px); background-size: 40px 40px; transform: perspective(560px) rotateX(62deg) translateY(24%); transform-origin: 50% 100%; mask: radial-gradient(closest-side at 50% 30%, #000, transparent 78%); }
.chat-wrap[data-bg="holo"] .av-bg::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(143,176,212,0.05) 0 2px, transparent 2px 5px); animation: scan 7s linear infinite; opacity: .5; }
@keyframes scan { from { background-position: 0 0; } to { background-position: 0 60px; } }

/* ===== чат справа ===== */
.chat-col { display: flex; flex-direction: column; min-height: 100vh; border-left: 1px solid var(--line); background: rgba(10,12,17,0.66); backdrop-filter: blur(16px); box-shadow: -20px 0 60px rgba(0,0,0,0.4); }
@media (max-width: 920px) { .chat-col { min-height: 60vh; border-left: none; border-top: 1px solid var(--line); } }
.chat-log { flex: 1; overflow-y: auto; padding: 70px 22px 22px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 86%; padding: 12px 16px; border-radius: 16px; font-size: 15px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: linear-gradient(180deg, var(--gold), var(--gold-soft)); color: #1a1308; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--line-soft); border-bottom-left-radius: 5px; }
.msg.bot .src { display: block; margin-top: 8px; font-size: 11px; color: var(--faint); }
.msg.typing span { display: inline-block; width: 7px; height: 7px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: td 1s infinite; }
.msg.typing span:nth-child(2) { animation-delay: .15s; } .msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes td { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.crisis-card { align-self: stretch; background: linear-gradient(160deg, rgba(143,176,212,0.12), var(--ink-2)); border: 1px solid rgba(143,176,212,0.4); border-radius: 16px; padding: 20px 22px; }
.crisis-card h4 { font-size: 16px; margin-bottom: 6px; }
.crisis-card p { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.crisis-card .btn { margin-right: 8px; }

.chat-input { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); background: rgba(10,12,17,0.8); }
.chat-input input { flex: 1; padding: 14px 16px; border-radius: 13px; background: var(--ink-2); border: 1px solid var(--line); color: var(--text); font-family: inherit; font-size: 15px; }
.chat-input input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(224,177,115,0.12); }
.chat-input button { width: 50px; flex: none; border-radius: 13px; background: linear-gradient(180deg, var(--gold), var(--gold-soft)); color: #1a1308; display: grid; place-items: center; }
.chat-input button svg { width: 20px; height: 20px; }
.chat-input button.mic.rec { background: #e07a7a; }
.chat-input .call { background: linear-gradient(180deg, #8fd4a3, #5fae7a); }
.chat-input .call.on { background: #e07a7a; animation: callpulse 1.3s infinite; }
@keyframes callpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(224,122,122,0.5); } 50% { box-shadow: 0 0 0 9px rgba(224,122,122,0); } }

/* статус живого разговора */
.conv-status { display: inline-flex; align-items: center; gap: 9px; margin-top: 14px; padding: 8px 16px; border-radius: 20px; background: rgba(224,177,115,0.12); border: 1px solid rgba(224,177,115,0.4); color: var(--gold); font-size: 13px; max-width: 90%; }
.conv-status .cs-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--gold); animation: csp 1.2s infinite; }
.conv-status .cs-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes csp { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.6); } }

.btn--sm { padding: 11px 16px; font-size: 14px; border-radius: 10px; }

/* модалка Telegram */
.tg-modal { position: fixed; inset: 0; z-index: 300; display: none; place-items: center; padding: 20px; background: rgba(6,7,10,0.74); backdrop-filter: blur(8px); }
.tg-modal.open { display: grid; }
.tg-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 30px; text-align: center; position: relative; }
.tg-x { position: absolute; top: 16px; right: 16px; color: var(--faint); }
.tg-x:hover { color: var(--text); }
.tg-ic { width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px; display: grid; place-items: center; background: linear-gradient(150deg, var(--gold), var(--gold-soft)); }
.tg-card h3 { font-size: 23px; margin-bottom: 8px; }
.tg-card > p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.tg-link { display: flex; gap: 8px; }
.tg-link input { flex: 1; padding: 11px 13px; border-radius: 10px; background: var(--ink-2); border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.tg-note { font-size: 12px; color: var(--faint); margin-top: 14px; }
