/* =========================================================
   Бекон — ИИ-помощник по Роблоксу
   ========================================================= */

:root {
  --bg: #0e0e13;
  --card: #141419;
  --card-2: #1a1a21;
  --text: #e8e8f6;
  --text-2: rgba(232, 232, 246, .78);
  --muted: #a8a8b6;
  --dim: rgba(168, 168, 182, .62);
  --accent: #6461f1;
  --accent-hi: #7774ff;
  --accent-soft: #b3b1ff;
  --accent-rgb: 100, 97, 241;
  --accent-ink: #fff;
  --warm: #ff9a5a;
  --edge-a: rgba(78, 78, 100, .5);       /* рамка карточки сверху */
  --edge-b: rgba(78, 78, 100, .2);       /* …и снизу */
  /* для админки */
  --fill-1: rgba(255, 255, 255, .055);
  --fill-2: rgba(255, 255, 255, .09);
  --fill-3: rgba(255, 255, 255, .14);

  --r: 12px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --col: 920px;
  --col-chat: 800px;
  --ease: cubic-bezier(.22, .8, .24, 1);
  --layout-dur: .75s;

  /* «сцена» с персонажем: кроп кадра 620×460 (см. config.js) */
  --stage-ratio: 1.3478;
  --stage-w-home: clamp(240px, min(620px, 94vw, calc((100svh - 430px) * var(--stage-ratio))), 620px);
  --stage-w-chat: clamp(220px, min(620px, 90vw, calc((100svh - 390px) * var(--stage-ratio))), 620px);
  --stage-overlap: 84px;
  --stage-lift: 0px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
}
button, textarea, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid rgba(var(--accent-rgb), .7); outline-offset: 2px; }

/* полосы прокрутки: тонкие, тёмные, без белых дорожек */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .14) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb { border: 3px solid transparent; border-radius: 10px; background: rgba(255, 255, 255, .14); background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .24); }
::-webkit-scrollbar-button { display: none; height: 0; width: 0; }
::selection { background: rgba(var(--accent-rgb), .4); }

/* ---------- Карточка: тёмная плашка с тонкой рамкой, рамка подсвечивается у курсора ---------- */
.chip, .blk-card, .blk-guide, .pack, .shop__custom, .gcard, .suggest, .composer, .newchat,
.gbtn:not(.gbtn--primary), .drawer__new, .icon-btn, .blk-btn, .gv__panel, .code, .gr__steps button.is-active {
  position: relative;
  background-color: var(--card);
  isolation: isolate;
}
.chip::before, .blk-card::before, .blk-guide::before, .pack::before, .shop__custom::before, .gcard::before,
.suggest::before, .composer::before, .newchat::before, .gbtn:not(.gbtn--primary)::before, .drawer__new::before, .icon-btn::before,
.blk-btn::before, .gv__panel::before, .code::before, .gr__steps button.is-active::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  border-radius: inherit; padding: 1px; pointer-events: none;
  background:
    radial-gradient(300px circle at var(--mx, -999px) var(--my, -999px), rgba(255, 255, 255, .32), transparent 45%),
    linear-gradient(180deg, var(--edge-a), var(--edge-b));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  transition: background .2s;
}
/* заголовок карточки — мягкий градиент, как в референсе */
.chip__label, .blk-card__title, .blk-guide__title, .gcard__title, .pack__amount {
  background: linear-gradient(180deg, #e8e8f6 0%, rgba(232, 232, 246, .76) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Фон ---------- */
.sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.bg-glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(34% 30% at 50% 30%, rgba(var(--accent-rgb), .07), transparent 70%),
    radial-gradient(55% 45% at 100% -10%, rgba(var(--accent-rgb), .1), transparent 70%),
    radial-gradient(40% 40% at 0% 0%, rgba(90, 86, 200, .07), transparent 70%);
}
/* точечная сетка за персонажем */
.bg-dots {
  position: fixed; left: 50%; top: 0; z-index: 0; pointer-events: none;
  width: 1100px; height: 640px; translate: -50% -18%;
  background-image: radial-gradient(circle at center, rgba(255, 255, 255, .3) 1px, transparent 1px);
  background-size: 8px 8px;
  -webkit-mask-image: radial-gradient(closest-side, #000, transparent 75%);
          mask-image: radial-gradient(closest-side, #000, transparent 75%);
  opacity: .32;
  transition: opacity var(--layout-dur) var(--ease);
}

/* ---------- Верхняя панель ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(24px + env(safe-area-inset-top)) calc(32px + env(safe-area-inset-right)) 0 calc(32px + env(safe-area-inset-left));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  color: var(--text); text-decoration: none;
  font-size: 20px; font-weight: 600; letter-spacing: -.015em;
}
.brand__logo { display: block; width: 38px; height: 38px; border-radius: 11px; overflow: hidden; }
.brand__logo svg, .brand__logo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.topbar__actions { display: flex; gap: 8px; }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  color: var(--muted);
  transition: color .2s, opacity .3s, visibility .3s;
}
.icon-btn svg { position: relative; z-index: 2; }
.icon-btn:hover { color: var(--text); }
.icon-btn--ghost { background: transparent; }
.icon-btn--ghost::before { display: none; }
.icon-btn[hidden] { display: none; }

/* ---------- Раскладка ---------- */
.app {
  position: relative; z-index: 1;
  height: 100vh; height: var(--app-h, 100dvh);
  display: flex; flex-direction: column; align-items: center;
  padding: calc(84px + env(safe-area-inset-top)) 24px calc(14px + env(safe-area-inset-bottom));
  transition: padding var(--layout-dur) var(--ease);
}
.spacer { flex: 1 1 0; min-height: 0; transition: flex-grow var(--layout-dur) var(--ease); }
.spacer--top { flex-grow: .45; }
.spacer--bottom { flex-grow: 1; }
.is-chat .spacer { flex-grow: 0.0001; }
.is-chat { --stage-lift: 30px; }
.is-chat .bg-dots { opacity: .18; }
@media (min-width: 1100px) {
  .is-chat .app { padding-top: calc(10px + env(safe-area-inset-top)); }
  .is-chat { --stage-lift: 8px; }
}

/* ---------- Сцена с персонажем ---------- */
.stage {
  position: relative; z-index: 2; flex: none;
  width: var(--stage-w-home);
  aspect-ratio: 620 / 460;
  margin-bottom: -30px;
  transition: width var(--layout-dur) var(--ease), margin var(--layout-dur) var(--ease);
  user-select: none; -webkit-user-select: none;
  pointer-events: none;
}
.is-chat .stage { width: var(--stage-w-chat); margin-top: calc(-1 * var(--stage-lift)); margin-bottom: calc(-1 * var(--stage-overlap)); }
.stage__mask {
  position: absolute; inset: 0;
  -webkit-mask-image:
    linear-gradient(to bottom, transparent 0%, #000 2.5%, #000 64%, rgba(0,0,0,.55) 80%, transparent 95.5%),
    linear-gradient(to right, transparent 0%, #000 8%, #000 92%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to bottom, transparent 0%, #000 2.5%, #000 64%, rgba(0,0,0,.55) 80%, transparent 95.5%),
    linear-gradient(to right, transparent 0%, #000 8%, #000 92%, transparent 100%);
          mask-composite: intersect;
}
.stage__canvas, .stage__poster { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage__canvas { transition: filter .35s ease; }
@media (hover: hover) and (min-width: 901px) {
  .stage[data-renderer="2d"] .stage__canvas { filter: drop-shadow(0 0 12px rgba(255, 112, 40, .36)); }
  .stage[data-renderer="2d"].is-holo .stage__canvas { filter: drop-shadow(0 0 12px rgba(90, 180, 255, .5)); }
}
.stage__poster { object-fit: contain; opacity: 0; transition: opacity .6s; filter: drop-shadow(0 0 12px rgba(255, 112, 40, .3)); }
.stage.is-fallback .stage__poster { opacity: 1; }
.stage.is-fallback .stage__canvas { display: none; }
.stage__halo {
  position: absolute; left: 50%; top: 42%;
  width: 62%; aspect-ratio: 1; translate: -50% -50%;
  background: radial-gradient(closest-side, rgba(255, 120, 55, .1), rgba(255, 120, 55, .03) 55%, transparent 76%);
  transition: background .4s;
}
.stage.is-holo .stage__halo { background: radial-gradient(closest-side, rgba(70, 160, 255, .16), rgba(70, 160, 255, .045) 55%, transparent 76%); }
.stage__beam {
  position: absolute; inset: 0;
  background: radial-gradient(40% 38% at 50% 58%, rgba(110, 200, 255, .15), transparent 100%);
  opacity: 0; transition: opacity .35s ease;
}
.stage.is-holo .stage__beam { opacity: 1; }
.stage__loader {
  position: absolute; left: 50%; top: 40%;
  width: 48px; height: 48px; translate: -50% -50%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .08);
  border-top-color: rgba(255, 255, 255, .6);
  animation: spin 1s linear infinite;
  transition: opacity .5s;
}
.stage.is-ready .stage__loader, .stage.is-fallback .stage__loader { opacity: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.stage__hit {
  position: absolute; left: 29%; right: 29%; top: 8%; bottom: 38%;
  border: 0; background: none; padding: 0; border-radius: 40%;
  cursor: pointer; pointer-events: auto;
}
.stage__hit:focus-visible { outline-offset: -6px; }


/* ---------- Приветствие ---------- */
.hero {
  position: relative; z-index: 3;
  display: grid; grid-template-rows: 1fr;
  width: 100%; text-align: center;
  transition: grid-template-rows var(--layout-dur) var(--ease), opacity .45s ease;
}
.hero__inner { min-height: 0; overflow: hidden; padding-bottom: 32px; }
.hero__title {
  margin: 0;
  font-size: clamp(32px, 3.3vw, 52px);
  line-height: 1.1;
  font-weight: 600;
  letter-spacing: -.03em;
  background: linear-gradient(180deg, #f2f2fb 30%, rgba(214, 212, 240, .8) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  padding-bottom: .06em;
}
.hero__subtitle { margin: 12px 0 0; font-size: clamp(16px, 1.3vw, 19px); color: var(--muted); }
.is-chat .hero { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }

/* ---------- Быстрые кнопки ---------- */
.chips {
  position: relative; z-index: 3;
  flex: none; width: 100%; max-width: var(--col);
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows var(--layout-dur) var(--ease), opacity .4s;
}
.chips[hidden] { display: none; }
.chips__inner {
  min-height: 0; overflow: hidden;
  display: grid; grid-template-columns: repeat(var(--chips, 3), minmax(0, 1fr)); gap: 12px;
  padding-bottom: 12px;
}
.chip {
  display: flex; align-items: center; gap: 12px;
  height: 60px; padding: 0 20px 0 16px;
  border: 0; border-radius: var(--r);
  box-shadow: 0 0 8px rgba(10, 10, 14, .4);
  font-size: 15px; font-weight: 500; text-align: left;
  transition: box-shadow .3s;
}
.chip > * { position: relative; z-index: 2; }
.chip__ico { flex: none; display: grid; place-items: center; width: 28px; height: 28px; color: #fff; opacity: .8; transition: opacity .3s; }
.chip__ico::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: currentColor; filter: blur(12px); opacity: .45; z-index: -1; }
.chip__ico[data-icon="studio"] { color: #6f9dff; }
.chip__ico[data-icon="gift"] { color: #ffb879; }
.chip__ico[data-icon="shield"] { color: #7fe3b6; }
.chip__ico[data-icon="book"] { color: var(--accent-soft); }
.chip__ico svg { width: 24px; height: 24px; display: block; }
.chip__ico--img { overflow: hidden; border-radius: 8px; }
.chip__ico--img::after { display: none; }
.chip__ico--img img { width: 100%; height: 100%; object-fit: cover; }
.chip__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; transition: opacity .3s; }
.chip__arrow { flex: none; color: var(--muted); opacity: 0; transform: translateX(-4px); transition: opacity .3s, transform .3s var(--ease); }
.chip:hover .chip__ico, .chip:hover .chip__label { opacity: 1; }
.chip:hover .chip__arrow { opacity: 1; transform: none; }
.is-chat .chips { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }

/* ---------- Сообщения ---------- */
.messages {
  position: relative; z-index: 1;
  flex: 0 1 0; min-height: 0; width: 100%;
  overflow-y: auto; overflow-x: hidden;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent 34px, #000 100px, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(to bottom, transparent 0, transparent 34px, #000 100px, #000 calc(100% - 14px), transparent 100%);
  transition: flex-grow var(--layout-dur) var(--ease);
  overscroll-behavior: contain;
}
.is-chat .messages { flex-grow: 1; }
.messages__inner { max-width: var(--col-chat); margin: 0 auto; padding: calc(var(--stage-overlap) + 20px) 4px 20px; }

.msg { display: flex; flex-direction: column; margin: 0 0 28px; animation: msgIn .4s var(--ease) both; }
.msg--user { align-items: flex-end; }
.msg--bot { align-items: stretch; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }

.bubble { position: relative; font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.msg--user .bubble {
  max-width: min(78%, 600px);
  padding: 10px 16px;
  border-radius: 16px 16px 4px 16px;
  background: var(--card-2);
  box-shadow: inset 0 0 0 1px var(--edge-b);
  color: var(--text);
  white-space: pre-wrap;
}
.msg--bot .bubble { color: var(--text-2); }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 .75em; }
.bubble h1, .bubble h2, .bubble h3 { margin: 1em 0 .45em; color: var(--text); font-size: 1.08em; line-height: 1.35; font-weight: 600; }
.bubble ul, .bubble ol { margin: .2em 0 .85em; padding-left: 1.4em; }
.bubble li { margin: .35em 0; }
.bubble li::marker { color: var(--dim); }
.bubble strong { font-weight: 600; color: var(--text); }
/* ссылки в тексте (у кнопок и карточек свои стили — у этих правил минимальный вес) */
:where(.bubble a:not(.blk-card, .blk-btn, .shop__buy)) {
  color: var(--accent-soft);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px; background-position: 0 100%; background-repeat: no-repeat;
  padding-bottom: 1px;
  transition: color .2s, background-size .25s var(--ease);
}
:where(.bubble a:not(.blk-card, .blk-btn, .shop__buy))::after { content: "↗"; display: inline-block; margin-left: 2px; font-size: .78em; vertical-align: .08em; opacity: .7; }
:where(.bubble a:not(.blk-card, .blk-btn, .shop__buy)):hover { color: #fff; }
.bubble code { font-family: var(--mono); font-size: .86em; padding: .12em .42em; border-radius: 6px; background: rgba(255, 255, 255, .07); color: var(--text); }
/* примечание */
.bubble blockquote {
  margin: .5em 0 .9em; padding: 12px 16px;
  border-radius: var(--r);
  background: rgba(255, 170, 100, .06);
  box-shadow: inset 0 0 0 1px rgba(255, 170, 100, .16);
  color: #eedcca;
}
.bubble blockquote p { margin: 0; }
.code { margin: .5em 0 1em; border-radius: var(--r); overflow: hidden; }
.code > * { position: relative; z-index: 2; }
.code__head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 16px; font-size: 12px; color: var(--dim); font-family: var(--mono); }
.code__copy { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); padding: 4px 8px; border-radius: 8px; font-size: 12px; }
.code__copy:hover { background: var(--fill-1); color: var(--text); }
.code pre { margin: 0; padding: 10px 16px 16px; overflow-x: auto; tab-size: 4; }
.code pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.65; white-space: pre; color: #e6e6f2; }
.tok-k { color: #c6a8ff; } .tok-s { color: #a6e3a8; } .tok-c { color: #6e6e8e; font-style: italic; }
.tok-n { color: #ffb878; } .tok-g { color: #82c4ff; } .tok-f { color: #ffd88a; }

.msg__actions { display: flex; gap: 4px; margin: 8px 0 0 -8px; opacity: 0; transition: opacity .2s; }
.msg--bot:hover .msg__actions, .msg__actions:focus-within { opacity: 1; }
.msg__action { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--dim); padding: 5px 8px; border-radius: 8px; font-size: 13px; }
.msg__action:hover { background: var(--fill-1); color: var(--text); }

.suggests { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.suggest {
  border: 0; border-radius: 999px;
  color: var(--text-2);
  padding: 7px 16px; font-size: 13.5px;
  transition: color .2s;
  animation: msgIn .4s var(--ease) both;
}
.suggest:hover { color: #fff; }
.suggests.is-used { display: none; }

.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 15px; }
.thinking__logo { flex: none; width: 18px; height: 18px; color: #fff; animation: rbxSpin 1.5s cubic-bezier(.65, 0, .35, 1) infinite; filter: drop-shadow(0 0 8px rgba(255, 255, 255, .25)); }
@keyframes rbxSpin { to { transform: rotate(360deg); } }
.thinking__dots i { font-style: normal; opacity: 0; }
.thinking__dots i:nth-child(1) { animation: dot1 1.8s ease infinite; }
.thinking__dots i:nth-child(2) { animation: dot2 1.8s ease infinite; }
.thinking__dots i:nth-child(3) { animation: dot3 1.8s ease infinite; }
@keyframes dot1 { 0%, 8% { opacity: 0; } 18%, 84% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes dot2 { 0%, 30% { opacity: 0; } 40%, 84% { opacity: 1; } 96%, 100% { opacity: 0; } }
@keyframes dot3 { 0%, 52% { opacity: 0; } 62%, 84% { opacity: 1; } 96%, 100% { opacity: 0; } }
.tw-hidden { display: none !important; }
/* слова ответа проявляются мягко: из прозрачности и лёгкого размытия */
.tw-w { opacity: 0; }
.tw-w.is-on { opacity: 1; animation: twIn .55s cubic-bezier(.22, .61, .36, 1) backwards; }
@keyframes twIn { from { opacity: 0; filter: blur(5px); } to { opacity: 1; filter: blur(0); } }
.tw-in { animation: twFade .45s ease-out backwards; }
@keyframes twFade { from { opacity: 0; } }
.tw-box { opacity: 0; transition: opacity .45s ease-out, background-size .5s var(--ease); }
.tw-box.is-on { opacity: 1; }
a.tw-box:not(.is-done) { background-size: 0% 1px; }
a.tw-box::after { transition: opacity .4s ease-out; }
a.tw-box:not(.is-done)::after { opacity: 0; }
.thinking { transition: opacity .2s ease, transform .2s ease; }
.thinking.is-leaving { opacity: 0; transform: translateY(-3px); }
.msg__actions.is-new { animation: fadeUp .5s var(--ease) backwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .tw-w.is-on { animation: none; } }

/* ---------- Поле ввода ---------- */
.composer-wrap {
  position: relative; z-index: 3; flex: none;
  display: flex; align-items: center; gap: 10px;
  width: 100%; max-width: var(--col);
  transition: max-width var(--layout-dur) var(--ease);
}
.is-chat .composer-wrap { max-width: var(--col-chat); }
/* «Новый чат» — отдельная кнопка слева от поля; на компьютере при наведении выезжает подпись */
.newchat {
  flex: none; display: inline-flex; align-items: center; gap: 0;
  height: 52px; max-width: 52px; padding: 0 16px;
  border: 0; border-radius: 999px;
  color: var(--muted); white-space: nowrap; overflow: hidden;
  box-shadow: 0 0 8px rgba(10, 10, 14, .4);
  transition: max-width .45s var(--ease), gap .45s var(--ease), color .2s, opacity .35s, visibility .35s, margin .45s var(--ease), padding .45s var(--ease);
}
.newchat > * { position: relative; z-index: 2; }
.newchat svg { flex: none; }
.newchat span { font-size: 14.5px; font-weight: 500; opacity: 0; transition: opacity .2s; }
.newchat:hover { color: var(--text); }
body:not(.is-chat) .newchat { max-width: 0; padding: 0; margin-right: -10px; opacity: 0; visibility: hidden; }
@media (hover: hover) {
  .newchat:hover { max-width: 160px; gap: 8px; padding: 0 20px 0 16px; }
  .newchat:hover span { opacity: 1; transition-delay: .1s; }
}
/* на широком экране кнопка стоит снаружи слева, поле ввода остаётся по центру под перепиской */
@media (min-width: 1000px) {
  .newchat { position: absolute; right: calc(100% + 12px); top: 50%; translate: 0 -50%; }
  body:not(.is-chat) .newchat { margin-right: 0; }
}
.composer {
  position: relative; flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  min-height: 72px;
  padding: 12px 12px 12px 24px;
  border-radius: 18px;
  box-shadow: 0 0 8px rgba(10, 10, 14, .4), 0 20px 50px -24px rgba(0, 0, 0, .8);
  transition: max-width var(--layout-dur) var(--ease), min-height var(--layout-dur) var(--ease);
}
.composer > * { position: relative; z-index: 2; }
.composer:focus-within::before { background: radial-gradient(300px circle at var(--mx, -999px) var(--my, -999px), rgba(255, 255, 255, .3), transparent 45%), linear-gradient(180deg, rgba(var(--accent-rgb), .75), rgba(var(--accent-rgb), .3)); }
.is-chat .composer { min-height: 64px; }
/* микрофон */
.composer__mic {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  transition: background .2s, color .2s;
}
.composer__mic[hidden] { display: none; }
.composer__mic:hover { background: #1d1d25; color: var(--text); }
.composer__wave { display: none; align-items: center; gap: 2px; height: 16px; }
.composer__wave i { display: block; width: 3px; height: 4px; border-radius: 2px; background: currentColor; animation: wave .9s ease-in-out infinite; }
.composer__wave i:nth-child(2) { animation-delay: .15s; } .composer__wave i:nth-child(3) { animation-delay: .3s; } .composer__wave i:nth-child(4) { animation-delay: .45s; }
@keyframes wave { 0%, 100% { height: 4px; } 50% { height: 15px; } }
.is-listening .composer__mic { background: #e5484d; color: #fff; animation: micPulse 1.4s ease-out infinite; }
.is-listening .composer__mic .ico-mic { display: none; }
.is-listening .composer__wave { display: flex; }
@keyframes micPulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .45); } 100% { box-shadow: 0 0 0 12px rgba(229, 72, 77, 0); } }
.composer.is-listening::before { background: linear-gradient(180deg, rgba(229, 72, 77, .75), rgba(229, 72, 77, .3)); }
.composer__input {
  flex: 1; min-width: 0;
  border: 0; outline: none; background: transparent; resize: none;
  font-size: 17px; line-height: 1.45;
  max-height: 168px; padding: 6px 0;
  color: var(--text);
}
.composer__input::placeholder { color: var(--dim); }
.composer__send {
  flex: none; display: grid; place-items: center;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: var(--accent); color: #fff;
  box-shadow: 0 6px 20px -6px rgba(var(--accent-rgb), .7), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .15s var(--ease), background .2s, opacity .2s, box-shadow .2s;
}
.composer__send:hover:not(:disabled) { background: var(--accent-hi); }
.composer__send:active:not(:disabled) { transform: scale(.94); }
.composer__send:disabled { background: #22222b; color: var(--dim); box-shadow: none; cursor: default; }
.composer__send .ico-stop { display: none; }
.is-busy .composer__send, .is-busy .composer__send:disabled { background: var(--accent); color: #fff; cursor: pointer; }
.is-busy .composer__send .ico-send { display: none; }
.is-busy .composer__send .ico-stop { display: block; }

.disclaimer { position: relative; z-index: 2; flex: none; padding-top: 14px; font-size: 12.5px; color: var(--dim); text-align: center; }
.is-chat .disclaimer { padding-top: 10px; font-size: 12px; }

/* ---------- Открыта клавиатура (телефон) ----------
   Видимая высота маленькая: прячем заголовок, быстрые кнопки и подпись, уменьшаем персонажа —
   поле ввода остаётся прямо над клавиатурой и не прячется под неё. */
.kb { --layout-dur: .32s; }
.kb .spacer--bottom { flex-grow: 0.0001; }
.kb .disclaimer { display: none; }
.kb .app { padding-bottom: 8px; }
.kb:not(.is-chat) .hero, .kb:not(.is-chat) .chips { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.kb:not(.is-chat) { --stage-w-home: clamp(110px, calc((var(--app-h, 100dvh) - 190px) * var(--stage-ratio)), 380px); }
.kb.is-chat { --stage-w-chat: clamp(110px, calc((var(--app-h, 100dvh) - 330px) * var(--stage-ratio)), 300px); }

/* ---------- История ---------- */
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(5, 5, 8, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); opacity: 0; transition: opacity .3s; }
.scrim.is-open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31;
  width: min(340px, 92vw);
  display: flex; flex-direction: column;
  padding: calc(20px + env(safe-area-inset-top)) 14px 14px;
  background: var(--bg);
  box-shadow: -1px 0 0 var(--edge-b), -30px 0 60px rgba(0, 0, 0, .5);
  transform: translateX(104%);
  transition: transform .45s var(--ease);
}
.drawer.is-open { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 16px 6px; }
.drawer__title { margin: 0; font-size: 18px; font-weight: 600; }
.drawer__new {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; border: 0; border-radius: 999px;
  color: var(--text); font-weight: 500; font-size: 14.5px;
}
.drawer__new > * { position: relative; z-index: 2; }
.drawer__list { flex: 1; overflow-y: auto; margin: 12px -4px 0; padding: 0 4px; }
.drawer__group { margin: 18px 0 6px 12px; font-size: 12px; color: var(--dim); }
.hist {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 8px 10px 12px;
  border: 0; border-radius: 10px;
  background: transparent; text-align: left;
  transition: background .15s;
}
.hist:hover { background: rgba(255, 255, 255, .04); }
.hist.is-active { background: var(--card); }
.hist__body { flex: 1; min-width: 0; }
.hist__title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14.5px; }
.hist__meta { display: block; margin-top: 2px; font-size: 12px; color: var(--dim); }
.hist__act { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: var(--dim); opacity: 0; cursor: pointer; transition: opacity .2s, background .2s, color .2s; }
.hist__act + .hist__act { margin-left: -8px; }
.hist:hover .hist__act, .hist:focus-within .hist__act { opacity: 1; }
.hist__act:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
.hist__del:hover { background: rgba(255, 90, 90, .12); color: #ff9b9b; }
.hist.is-pinned .hist__pin { opacity: 1; color: var(--accent-soft); }
.hist.is-pinned .hist__pin svg path { fill: currentColor; fill-opacity: .25; }
@media (hover: none) {
  .hist__act { opacity: .55; }
  .hist.is-pinned .hist__pin { opacity: 1; }
}
.drawer__empty { padding: 40px 10px; text-align: center; color: var(--dim); font-size: 14px; }
.drawer__clear {
  flex: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 10px; height: 42px; padding: 0 14px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--dim);
  font: inherit; font-size: 13.5px; cursor: pointer;
  transition: background .2s, color .2s;
}
.drawer__clear[hidden] { display: none; }
.drawer__clear:hover { background: rgba(255, 90, 90, .08); color: #ff9b9b; }
.drawer__clear.is-armed { background: rgba(229, 72, 77, .16); color: #ffb3b3; }

.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 80;
  translate: -50% 0;
  padding: 10px 16px; border-radius: 999px;
  background: var(--card-2);
  box-shadow: inset 0 0 0 1px var(--edge-a), 0 18px 40px -16px rgba(0, 0, 0, .8);
  font-size: 14px;
  opacity: 0; transform: translateY(10px);
  transition: opacity .25s, transform .25s var(--ease);
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: none; }

.video-pool { position: fixed; left: 0; top: 0; width: 4px; height: 4px; overflow: hidden; opacity: .001; pointer-events: none; z-index: -1; }
.video-pool video { width: 4px; height: 4px; }

/* ---------- Адаптив ---------- */
@media (max-width: 900px) {
  .topbar { padding: calc(16px + env(safe-area-inset-top)) 16px 0 18px; }
  .chip { height: 56px; font-size: 14.5px; padding-right: 14px; }
  .chip__arrow { display: none; }
}
@media (max-width: 640px) {
  :root {
    --stage-w-home: clamp(220px, min(calc(100vw - 20px), calc((100svh - 480px) * var(--stage-ratio))), 440px);
    --stage-w-chat: clamp(200px, min(86vw, calc((100svh - 470px) * var(--stage-ratio))), 340px);
    --stage-overlap: 60px;
  }
  .is-chat { --stage-lift: 20px; }
  .app { padding: calc(68px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom)); }
  .brand { font-size: 18px; gap: 10px; }
  .brand__logo { width: 34px; height: 34px; border-radius: 10px; }
  .icon-btn { width: 38px; height: 38px; }
  .topbar__actions { gap: 6px; }
  .stage { margin-bottom: -22px; }
  .hero__inner { padding-bottom: 20px; }
  .hero__subtitle { margin-top: 8px; }
  .spacer--top { flex-grow: 1; }
  .spacer--bottom { flex-grow: .5; }
  .chips__inner { grid-template-columns: minmax(0, 1fr); gap: 8px; padding-bottom: 10px; }
  .chip { height: 48px; padding: 0 14px 0 12px; gap: 10px; }
  .chip__ico { width: 24px; height: 24px; }
  .chip__ico svg { width: 21px; height: 21px; }
  .chip__arrow { display: block; opacity: .6; transform: none; }
  .composer { min-height: 58px; padding: 6px 6px 6px 18px; border-radius: 16px; }
  .is-chat .composer { min-height: 58px; }
  .composer-wrap { gap: 8px; }
  .newchat { height: 48px; max-width: 48px; padding: 0 14px; }
  body:not(.is-chat) .newchat { margin-right: -8px; }
  .composer__mic { width: 40px; height: 40px; }
  .composer__input { font-size: 16px; }
  .composer__send { width: 44px; height: 44px; }
  .messages { -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent 22px, #000 70px, #000 calc(100% - 12px), transparent 100%);
                      mask-image: linear-gradient(to bottom, transparent 0, transparent 22px, #000 70px, #000 calc(100% - 12px), transparent 100%); }
  .disclaimer { padding-top: 10px; }
  .bubble { font-size: 15.5px; }
  .msg--user .bubble { max-width: 88%; }
  .msg__actions { opacity: 1; }
  .bg-dots { width: 600px; height: 520px; }
}
@media (max-height: 700px) and (min-width: 641px) { .hero__inner { padding-bottom: 20px; } }

/* =========================================================
   Блоки ответа
   ========================================================= */
.msg--bot .bubble > * + * { margin-top: 16px; }
.blk-text > :first-child { margin-top: 0; }
.blk-text > :last-child { margin-bottom: 0; }
.blk-appear { animation: blkIn .45s var(--ease) both; }
@keyframes blkIn { from { opacity: 0; transform: translateY(8px); } }

/* карточки-варианты и карточка гайда: иконка с мягким свечением, заголовок, строка описания */
.blk-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.blk-card, .blk-guide {
  display: flex; align-items: center; gap: 14px;
  min-height: 72px; padding: 14px 20px 14px 16px;
  border: 0; border-radius: var(--r);
  box-shadow: 0 0 8px rgba(10, 10, 14, .4);
  color: var(--text); text-align: left; text-decoration: none;
}
.blk-card > *, .blk-guide > * { position: relative; z-index: 2; }
.blk-card__icon, .blk-card__thumb {
  flex: none; width: 36px; height: 36px;
  display: grid; place-items: center;
  color: #fff; opacity: .85; transition: opacity .3s;
}
.blk-card__icon::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: currentColor; filter: blur(14px); opacity: .5; z-index: -1; }
.blk-card__icon svg { width: 26px; height: 26px; }
.blk-card__thumb { border-radius: 10px; overflow: hidden; }
.blk-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.blk-card__icon[data-icon="gift"]   { color: #ffb879; }
.blk-card__icon[data-icon="studio"] { color: #6f9dff; }
.blk-card__icon[data-icon="star"], .blk-card__icon[data-icon="bolt"] { color: #ffd66b; }
.blk-card__icon[data-icon="shirt"]  { color: #ff9cbc; }
.blk-card__icon[data-icon="book"], .blk-card__icon[data-icon="code"] { color: var(--accent-soft); }
.blk-card__icon[data-icon="chat"], .blk-card__icon[data-icon="link"] { color: #9fd6ff; }
.blk-card__icon[data-icon="shield"] { color: #7fe3b6; }
.blk-card__icon[data-icon="rplus"]  { color: #fff; }
.blk-card__icon[data-icon="clothes"] { color: #ff9cbc; }
.blk-card__icon[data-icon="microsoft"] { color: #4aa8ff; }
.blk-card__icon[data-icon="microsoft"] svg { width: 22px; height: 22px; }
.blk-card__body, .blk-guide__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; opacity: .88; transition: opacity .3s; }
.blk-card__title, .blk-guide__title { font-size: 14.5px; font-weight: 500; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-card__text, .blk-guide__text { font-size: 12.5px; color: var(--muted); line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk-chev { flex: none; width: 14px; height: 14px; color: var(--muted); opacity: 0; transform: translateX(-4px); transition: opacity .3s, transform .3s var(--ease); }
.blk-card:hover .blk-card__icon, .blk-card:hover .blk-card__body, .blk-guide:hover .blk-guide__body { opacity: 1; }
.blk-card:hover .blk-chev, .blk-guide:hover .blk-chev { opacity: 1; transform: none; }

.blk-card--single { width: 100%; max-width: 520px; }

/* кнопки */
.blk-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.blk-btn {
  display: inline-flex; align-items: center;
  height: 38px; padding: 0 18px;
  border: 0; border-radius: 999px;
  color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none;
}

/* ---------- Промокоды ---------- */
.blk-promo { width: 100%; }
.promo { width: 100%; cursor: pointer; font: inherit; }
.promo__code { font-family: var(--mono); font-size: 14px; letter-spacing: .04em; }
.blk-card__icon[data-icon="ticket"] { color: #7fe3b6; }
.promo__copy { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin-right: -8px; border-radius: 8px; color: var(--muted); transition: color .2s, background .2s; }
.promo__copy svg { width: 18px; height: 18px; }
.promo:hover .promo__copy { color: var(--text); background: rgba(255, 255, 255, .06); }
.promo.is-copied .promo__copy { color: #7fe3b6; background: rgba(127, 227, 182, .1); }
.promo__foot { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 12px; }
.promo__upd { font-size: 12.5px; color: var(--dim); }
.promo__note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.promo__empty { margin: 0; color: var(--muted); }

/* ---------- Магазин ---------- */
.shop { max-width: 620px; container-type: inline-size; }
.shop__head { margin-bottom: 12px; }
.shop__title { font-size: 16px; font-weight: 600; color: var(--text); }
.shop__sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.shop__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@container (min-width: 520px) { .shop__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pack {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 14px;
  border: 0; border-radius: var(--r);
  box-shadow: 0 0 8px rgba(10, 10, 14, .4);
  color: var(--text); text-align: left;
  transition: background-color .2s;
}
.pack > * { position: relative; z-index: 2; }
.pack__ico { flex: none; display: grid; place-items: center; width: 28px; height: 28px; color: #fff; opacity: .7; transition: opacity .2s, color .2s; }
.pack__ico::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: currentColor; filter: blur(12px); opacity: .35; z-index: -1; }
.pack__ico svg { width: 24px; height: 24px; display: block; }
.pack__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pack__amount { font-size: 17px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pack__amount small { font-size: 12px; font-weight: 500; }
.pack__price { font-size: 13px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pack__price s { margin-left: 4px; color: var(--dim); opacity: .7; }
.pack__radio { flex: none; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(168, 168, 182, .35); transition: box-shadow .2s, background .2s; }
.pack:hover .pack__ico { opacity: 1; }
.pack[aria-checked="true"] { background-color: #18172a; }
.pack[aria-checked="true"]::before { background: linear-gradient(180deg, rgba(var(--accent-rgb), .95), rgba(var(--accent-rgb), .5)); }
.pack[aria-checked="true"] .pack__ico { opacity: 1; color: var(--accent-soft); }
.pack[aria-checked="true"] .pack__radio { background: var(--accent); box-shadow: inset 0 0 0 4.5px #18172a, 0 0 0 1.5px var(--accent); }
@container (max-width: 460px) { .pack__price s { display: none; } }
@container (max-width: 420px) { .pack { gap: 10px; padding: 12px; } .pack__radio { display: none; } }
.shop__custom {
  display: flex; align-items: center; gap: 12px;
  height: 56px; margin-top: 10px; padding: 0 18px 0 16px;
  border-radius: var(--r);
  box-shadow: 0 0 8px rgba(10, 10, 14, .4);
  cursor: text;
}
.shop__custom > * { position: relative; z-index: 2; }
.shop__custom:focus-within::before { background: linear-gradient(180deg, rgba(var(--accent-rgb), .95), rgba(var(--accent-rgb), .5)); }
.shop__rbx { flex: none; display: grid; place-items: center; width: 22px; height: 22px; color: #fff; opacity: .6; }
.shop__rbx svg { width: 20px; height: 20px; display: block; }
.shop__custom input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: none; background: transparent;
  color: var(--text); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.shop__custom input::placeholder { color: var(--dim); font-weight: 400; }
.shop__custom input::-webkit-outer-spin-button, .shop__custom input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.shop__buy {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 52px; margin-top: 14px;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  box-shadow: 0 10px 30px -12px rgba(var(--accent-rgb), .9), inset 0 1px 0 rgba(255, 255, 255, .2);
  font-size: 15.5px; font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums;
  transition: background .2s, transform .15s var(--ease), box-shadow .2s, color .2s;
}
.shop__buy span { opacity: .55; }
.shop__buy:hover { background: var(--accent-hi); }
.shop__buy:active { transform: scale(.99); }
.shop__buy[aria-disabled="true"] { background: #1a1a21; box-shadow: inset 0 0 0 1px var(--edge-b); color: var(--dim); font-weight: 500; cursor: default; }
/* вкладки способов */
.shop__tabs {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  margin-bottom: 12px; padding: 4px;
  border-radius: 999px;
  background: var(--card); box-shadow: inset 0 0 0 1px var(--edge-b);
}
.shop__tabs button {
  position: relative; z-index: 1;
  height: 36px; padding: 0 12px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .25s;
}
.shop__tabs button:hover, .shop__tabs button.is-on { color: var(--text); }
.shop__tab-bg {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  border-radius: 999px; background: #262630; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  transition: transform .35s var(--ease);
}
.shop[data-method="custom"] .shop__tab-bg { transform: translateX(100%); }
.shop__pane[hidden] { display: none; }
.shop__pane { animation: blkIn .3s var(--ease) both; }
/* как доставляем */
.shop__note { display: flex; align-items: center; gap: 8px; margin: 0 4px 12px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.shop__note[hidden] { display: none; }
.shop__note-ico { flex: none; display: grid; place-items: center; width: 16px; height: 16px; color: var(--accent-soft); }
.shop__note-ico svg { width: 16px; height: 16px; }
/* любое количество */
.shop__pane .shop__custom { margin-top: 0; }
.shop__custom-unit { flex: none; font-size: 14px; font-weight: 500; color: var(--dim); }
.shop__calc { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 4px 0; font-size: 13px; color: var(--dim); }
.shop__calc-hint.is-warn { color: #ffb38a; }
.shop__calc-price { font-size: 20px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* =========================================================
   Обложки гайдов (своя картинка или сгенерированная)
   ========================================================= */
.gart {
  --gc: 140, 132, 255;
  position: relative; overflow: hidden; isolation: isolate;
  display: grid; place-items: center;
  background: radial-gradient(70% 90% at 50% 100%, rgba(var(--gc), .2), transparent 70%), #16161c;
}
.gart[data-theme="ocean"] { --gc: 90, 170, 255; }
.gart[data-theme="lime"]  { --gc: 80, 220, 170; }
.gart[data-theme="rose"]  { --gc: 255, 120, 170; }
.gart[data-theme="amber"] { --gc: 255, 165, 90; }
.gart.has-img { background: #16161c; }
.gart.has-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.gart__grid {
  position: absolute; inset: 0; z-index: -1;
  background-image: radial-gradient(circle at center, rgba(255, 255, 255, .35) 1px, transparent 1px);
  background-size: 8px 8px;
  -webkit-mask-image: radial-gradient(closest-side, #000, transparent);
          mask-image: radial-gradient(closest-side, #000, transparent);
  opacity: .35;
}
.gart__icon { position: relative; display: grid; place-items: center; width: clamp(22px, 22%, 64px); aspect-ratio: 1; color: rgb(var(--gc)); }
.gart__icon::after { content: ""; position: absolute; inset: 10%; border-radius: 50%; background: currentColor; filter: blur(22px); opacity: .55; z-index: -1; }
.gart__icon svg { width: 100%; height: 100%; display: block; color: #fff; filter: drop-shadow(0 0 12px rgba(var(--gc), .6)); }
.gart__x { display: none; }
.gart--mini .gart__grid { display: none; }
.gart--mini .gart__icon { width: 50%; }
.gart--mini .gart__icon::after { filter: blur(8px); }

/* =========================================================
   Гайды
   ========================================================= */
.gv { position: fixed; inset: 0; z-index: 60; }
.gv[hidden] { display: none; }
.gv__scrim { position: absolute; inset: 0; background: rgba(5, 5, 8, .7); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity .3s; }
.gv.is-open .gv__scrim { opacity: 1; }
.gv__panel {
  position: absolute; inset: 28px; margin: auto;
  width: min(1100px, calc(100vw - 56px)); height: min(800px, calc(100dvh - 56px));
  display: flex; flex-direction: column;
  border-radius: 18px; overflow: hidden;
  background-color: var(--bg);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .9);
  opacity: 0; transform: translateY(14px);
  transition: opacity .3s ease, transform .4s var(--ease);
  outline: none;
}
.gv__panel::before { z-index: 10; }
.gv.is-open .gv__panel { opacity: 1; transform: none; }
.gv__bar {
  position: relative; z-index: 3; flex: none;
  display: flex; align-items: center; gap: 8px;
  height: 60px; padding: 0 12px;
}
.gv[data-view="library"] .gv__bar { position: absolute; top: 8px; right: 8px; left: auto; height: auto; padding: 0; }
.gv[data-view="library"] .gv__bar-title { display: none; }
.gv__bar-title { flex: 1; min-width: 0; padding: 0 6px; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gv__icon {
  flex: none; display: grid; place-items: center;
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted);
  transition: background .2s, color .2s;
}
.gv__icon:hover { background: var(--card); color: var(--text); }
.gv__icon[hidden] { display: none; }
.gv__mode { display: none; flex: none; padding: 3px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 1px var(--edge-b); }
.gv[data-view="guide"] .gv__mode { display: inline-flex; }
.gv__mode button { height: 30px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 500; transition: background .2s, color .2s; }
.gv__mode button:hover { color: var(--text); }
.gv__mode button.is-on { background: #262630; color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, .06) inset; }
.gv__body { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.gv[data-view="library"] .gv__body { padding-top: 8px; }
.gv[data-view="guide"] .gv__body { overflow: hidden; }

.gbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 22px;
  border: 0; border-radius: 999px;
  color: var(--text); font-size: 14.5px; font-weight: 500; white-space: nowrap;
  transition: background .2s, transform .15s var(--ease), color .2s;
}
.gbtn > * { position: relative; z-index: 2; }
.gbtn:active { transform: scale(.98); }
.gbtn--primary { background: var(--accent); color: #fff; box-shadow: 0 10px 26px -12px rgba(var(--accent-rgb), .9), inset 0 1px 0 rgba(255, 255, 255, .2); }
.gbtn--primary:hover { background: var(--accent-hi); }
.gbtn--ghost { background-color: transparent; color: var(--muted); }
.gbtn--ghost::before { opacity: 0; }
.gbtn--ghost:hover { color: var(--text); }
.gbtn--ghost:hover::before { opacity: 1; }

/* библиотека */
.glib { max-width: 1000px; margin: 0 auto; padding: 32px 40px calc(40px + env(safe-area-inset-bottom)); }
.glib__title { margin: 0; font-size: clamp(28px, 3vw, 36px); line-height: 1.1; font-weight: 600; letter-spacing: -.03em; }
.glib__sub { margin: 8px 0 22px; color: var(--muted); font-size: 15px; }
.glib__search {
  display: flex; align-items: center; gap: 10px;
  max-width: 380px; height: 44px; padding: 0 16px; margin-bottom: 24px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--edge-b);
  color: var(--dim);
  transition: box-shadow .2s;
}
.glib__search:focus-within { box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .7); }
/* 16px — иначе iPhone приближает страницу при фокусе */
.glib__search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 16px; }
.glib__search input::-webkit-search-cancel-button { filter: invert(1) opacity(.5); }
.glib__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.glib__empty { grid-column: 1 / -1; padding: 40px 0; text-align: center; color: var(--dim); }
.gcard {
  display: flex; flex-direction: column;
  padding: 0; border: 0; border-radius: 14px; overflow: hidden;
  box-shadow: 0 0 8px rgba(10, 10, 14, .4);
  color: var(--text); text-align: left;
  animation: blkIn .45s var(--ease) both;
}
.gcard > * { position: relative; z-index: 2; }
.gcard:nth-child(2) { animation-delay: .04s; } .gcard:nth-child(3) { animation-delay: .08s; } .gcard:nth-child(4) { animation-delay: .12s; }
.gcard__art { aspect-ratio: 16 / 9; width: 100%; z-index: 0; }
.gcard__body { display: flex; flex-direction: column; gap: 4px; padding: 14px 18px 18px; flex: 1; }
.gcard__title { font-size: 15.5px; font-weight: 500; line-height: 1.4; }
.gcard__text { font-size: 13px; line-height: 1.5; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gcard__state { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 10px; }
.gcard__bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.gcard__bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), var(--accent-soft)); }
.gcard__prog { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.gcard__done { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: #8fe8c0; }

/* прохождение */
.gg { position: relative; display: grid; grid-template-columns: 280px minmax(0, 1fr); height: 100%; }
.gg__rail {
  display: flex; flex-direction: column;
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 6px 14px 18px 16px;
}
.gr__steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.gr__steps li { position: relative; }
.gr__steps li:not(:last-child)::after { content: ""; position: absolute; left: 22px; top: 38px; bottom: -6px; width: 1px; background: rgba(255, 255, 255, .08); }
.gr__steps button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 8px 10px 8px 8px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted); text-align: left; font-size: 14px; line-height: 1.35;
  transition: background .15s, color .15s;
}
.gr__steps button > * { position: relative; z-index: 2; }
.gr__steps button:hover { background: rgba(255, 255, 255, .035); color: var(--text); }
.gr__steps button.is-active { color: var(--text); }
.gr__dot {
  position: relative; z-index: 2;
  flex: none; display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--bg); box-shadow: inset 0 0 0 1.5px rgba(168, 168, 182, .3);
  font-size: 12.5px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums;
}
.gr__dot svg { width: 14px; height: 14px; }
.is-active .gr__dot { box-shadow: inset 0 0 0 1.5px var(--accent-soft); color: var(--text); }
.is-done .gr__dot { background: var(--accent); box-shadow: none; color: #fff; }
.gr__name { flex: 1; min-width: 0; }
.gr__reset { align-self: flex-start; margin-top: auto; border: 0; background: none; padding: 14px 10px 4px; color: var(--dim); font-size: 13px; }
.gr__reset:hover { color: var(--text); }

.gg__stage { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.gg__segs { display: none; }
.gg__view { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; padding: 40px 56px; scroll-behavior: auto; }
.gg__inner { width: 100%; max-width: 720px; margin: auto; }
.gg__inner--full { margin: 0 auto; padding-bottom: 24px; }
.gg__view.slide-l .gg__content { animation: slideL .4s var(--ease) both; }
.gg__view.slide-r .gg__content { animation: slideR .4s var(--ease) both; }
@keyframes slideL { from { opacity: 0; transform: translateX(24px); } }
@keyframes slideR { from { opacity: 0; transform: translateX(-24px); } }
/* кнопки сразу под текстом шага */
.gg__nav { display: flex; align-items: center; gap: 10px; margin-top: 32px; }
.gg__nav .gbtn--primary { min-width: 140px; }
.gg__nav .gbtn--ghost { margin-left: -14px; }

/* интро */
.gi__art { aspect-ratio: 16 / 6; border-radius: 14px; margin-bottom: 28px; box-shadow: inset 0 0 0 1px var(--edge-b); }
.gi__art.has-img img { cursor: zoom-in; }
.gi__title { margin: 0; font-size: clamp(26px, 2.8vw, 36px); line-height: 1.15; font-weight: 600; letter-spacing: -.025em; }
.gi__sum { margin: 10px 0 0; font-size: 16px; line-height: 1.6; color: var(--muted); }
.gi__list { display: none; list-style: none; margin: 22px 0 0; padding: 0; }
.gi__list button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 2px; border: 0; border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: none; color: var(--text-2); text-align: left; font-size: 14.5px; line-height: 1.35;
}
.gi__list button > span { flex: none; width: 22px; font-size: 12.5px; color: var(--accent-soft); font-variant-numeric: tabular-nums; }
.gi__list button > span svg { width: 14px; height: 14px; display: block; }

/* шаг */
.gs__count { margin-bottom: 10px; font-size: 13px; font-weight: 600; color: var(--accent-soft); font-variant-numeric: tabular-nums; }
.gs__count span { color: var(--dim); font-weight: 500; }
.gs__title { margin: 0; font-size: clamp(22px, 2.3vw, 28px); line-height: 1.25; font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.gs__img { margin: 20px 0 0; }
.gs__img img { display: block; width: 100%; height: auto; max-height: 52vh; object-fit: contain; border-radius: 12px; background: var(--card); box-shadow: inset 0 0 0 1px var(--edge-b); cursor: zoom-in; }
.gs__text { margin-top: 16px; font-size: 16px; line-height: 1.75; color: var(--text-2); }
/* «целиком» */
.gg__inner--full .gi { margin-bottom: 8px; }
.gg__inner--full section.gs { padding-top: 36px; margin-top: 36px; box-shadow: 0 -1px 0 rgba(255, 255, 255, .06); scroll-margin-top: 16px; }
.gg__end { display: flex; justify-content: center; margin-top: 44px; }

/* финал */
.gf { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 20px 0; }
.gf__badge { position: relative; width: 76px; height: 76px; margin-bottom: 24px; }
.gf__badge > span {
  position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent); color: #fff;
  box-shadow: 0 0 0 10px rgba(var(--accent-rgb), .12), 0 0 60px rgba(var(--accent-rgb), .6);
  animation: pop .5s var(--ease) both;
}
.gf__badge > span svg { width: 34px; height: 34px; }
.gf__badge i { position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px; border-radius: 2px; background: var(--c, var(--accent-soft)); animation: burst 1s cubic-bezier(.15, .7, .3, 1) both .1s; opacity: 0; }
.gf__badge i:nth-of-type(1)  { --a: 0deg;   --c: #ffb879; }
.gf__badge i:nth-of-type(2)  { --a: 36deg; }
.gf__badge i:nth-of-type(3)  { --a: 72deg;  --c: #7fe3b6; }
.gf__badge i:nth-of-type(4)  { --a: 108deg; --c: #ff9cbc; }
.gf__badge i:nth-of-type(5)  { --a: 144deg; --c: #9fd6ff; }
.gf__badge i:nth-of-type(6)  { --a: 180deg; --c: #ffd66b; }
.gf__badge i:nth-of-type(7)  { --a: 216deg; }
.gf__badge i:nth-of-type(8)  { --a: 252deg; --c: #ffb879; }
.gf__badge i:nth-of-type(9)  { --a: 288deg; --c: #7fe3b6; }
.gf__badge i:nth-of-type(10) { --a: 324deg; --c: #9fd6ff; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
@keyframes burst {
  0% { opacity: 1; transform: rotate(var(--a)) translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(-84px) rotate(180deg); }
}
.gf__title { margin: 0; font-size: clamp(24px, 2.6vw, 32px); font-weight: 600; letter-spacing: -.025em; }
.gf__text { margin: 8px 0 0; font-size: 15.5px; color: var(--muted); }
.gf__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }

.lightbox { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(5, 5, 8, .92); cursor: zoom-out; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 12px; }

@media (min-width: 861px) { .gv__icon--rail { display: none !important; } }
@media (max-width: 860px) {
  .gv__panel { inset: 0; width: 100%; height: 100%; border-radius: 0; box-shadow: none; transform: translateY(20px); }
  .gv__panel::before { display: none; }
  .gv__bar { height: calc(56px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0; gap: 4px; }
  .gv__bar-title { display: none; }
  .gv[data-view="library"] .gv__bar { justify-content: flex-end; }
  .gv__mode { margin-right: auto; margin-left: 4px; }
  .gg { grid-template-columns: minmax(0, 1fr); }
  .gg__rail {
    position: absolute; inset: 0; z-index: 5;
    background: var(--bg); box-shadow: none;
    padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: opacity .2s, transform .3s var(--ease), visibility .2s;
  }
  .gg.show-rail .gg__rail { opacity: 1; visibility: visible; transform: none; }
  .gg__segs { display: flex; gap: 4px; padding: 10px 16px 0; }
  .gg__segs[hidden] { display: none; }
  .gg__segs button { flex: 1; height: 16px; padding: 6px 0; border: 0; background: none; }
  .gg__segs i { display: block; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .12); transition: background .3s; }
  .gg__segs .is-done i { background: rgba(var(--accent-rgb), .6); }
  .gg__segs .is-active i { background: var(--accent-soft); }
  .gg__view { padding: 20px 18px 0; }
  .gg__inner { display: flex; flex-direction: column; min-height: 100%; margin: 0 auto; }
  .gg__inner--full { display: block; min-height: 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  /* на телефоне кнопки — внизу экрана, под большим пальцем */
  .gg__nav {
    position: sticky; bottom: 0; z-index: 3;
    margin: auto -18px 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to bottom, rgba(14, 14, 19, 0), var(--bg) 30%);
  }
  .gg__content { padding-bottom: 20px; }
  .gg__nav .gbtn--primary { flex: 1; }
  .gg__nav .gbtn--ghost { width: 44px; padding: 0; margin-left: 0; background-color: var(--card); }
  .gg__nav .gbtn--ghost::before { opacity: 1; }
  .gg__nav .gbtn--ghost span { display: none; }
  .gi__art { aspect-ratio: 16 / 8; margin-bottom: 20px; }
  .gi__list { display: block; }
  .gs__img img { max-height: 44vh; }
  .glib { padding: 22px 16px calc(32px + env(safe-area-inset-bottom)); }
  .glib__grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .glib__search { max-width: none; }
}
@media (max-width: 640px) {
  .blk-cards { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .blk-card, .blk-guide { min-height: 64px; padding: 12px 14px 12px 12px; }
  .blk-guide { max-width: none; }
  .blk-chev { opacity: .5; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gg__view.slide-l .gg__content, .gg__view.slide-r .gg__content, .gcard { animation: none; }
}


/* ---------- Диалоговое облачко рядом с персонажем ---------- */
.stage__speech {
  position: absolute;
  left: calc(50% + 92px);
  top: 17%;
  z-index: 8;
  width: max-content;
  max-width: 248px;
  padding: 11px 28px 11px 14px;
  border-radius: 15px 15px 15px 4px;
  background: rgba(20, 20, 32, .93);
  border: 1px solid rgba(119, 116, 255, .44);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .55), 0 0 24px rgba(100, 97, 241, .22);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  pointer-events: auto;
  transform-origin: left bottom;
  opacity: 0;
  transform: translateY(6px) scale(.92);
  transition: opacity .24s var(--ease), transform .28s var(--ease);
}
.stage__speech.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.stage__speech[hidden] { display: none; }
.stage__speech::after {
  content: "";
  position: absolute;
  left: -7px;
  bottom: 14px;
  width: 12px;
  height: 12px;
  background: rgba(20, 20, 32, .95);
  border-left: 1px solid rgba(119, 116, 255, .44);
  border-bottom: 1px solid rgba(119, 116, 255, .44);
  transform: rotate(45deg);
  border-radius: 0 0 0 3px;
}
.stage__speech-text {
  color: var(--text);
}
.stage__speech-x {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background .15s, color .15s;
}
.stage__speech-x:hover {
  background: rgba(255, 255, 255, .1);
  color: #fff;
}
.stage__speech-act {
  margin-top: 7px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-soft);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
}
.stage__speech-act:hover { color: #fff; }
.is-chat .stage__speech { top: 14%; }
@media (max-width: 720px) {
  .stage__speech {
    left: auto;
    right: 6px;
    top: 8%;
    max-width: 205px;
    font-size: 12.5px;
    padding: 9px 26px 9px 12px;
  }
  .stage__speech::after {
    left: -6px;
    bottom: 18px;
    width: 10px;
    height: 10px;
  }
}

/* Счётчик лимита чатов в заголовке истории */
.drawer__title { display: flex; align-items: center; gap: 8px; }
.drawer__count {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.drawer__count.is-full {
  background: rgba(255, 154, 90, .16);
  color: #ffbe8f;
}
