/* ============ Geosha — liquid glass ============ */

:root {
  --base: #E9ECFF;
  --ink: #17143D;
  --ink-soft: #5B5880;
  --ink-faint: #8C89AE;
  --blue: #3D5AFE;
  --violet: #B14BFF;
  --pink: #FF4FA3;
  --sun: #FFC23D;
  --mint: #1FD3A4;
  --danger: #E5385B;

  --brand: linear-gradient(135deg, var(--blue) 0%, var(--violet) 55%, var(--pink) 100%);

  --glass-fill: linear-gradient(140deg, rgba(255,255,255,.62), rgba(255,255,255,.28));
  --glass-edge: rgba(255,255,255,.75);
  --glass-shine: inset 0 1px 0 rgba(255,255,255,.95), inset 0 -1px 0 rgba(255,255,255,.25);
  --glass-shadow: 0 12px 40px -12px rgba(46, 33, 140, .28);
  --glass-blur: blur(26px) saturate(190%);
  --inset-fill: rgba(255,255,255,.35);
  --hover: rgba(255,255,255,.55);
  --active: rgba(255,255,255,.8);

  --user-bubble: linear-gradient(135deg, rgba(61,90,254,.92), rgba(177,75,255,.88));
  --code-bg: rgba(23, 20, 61, .88);

  --blob-opacity: .85;

  /* свечения и подсветки: в своей теме считаются от выбранного цвета */
  --glow: rgba(110,60,255,.85);
  --glow-soft: rgba(177,75,255,.6);
  --focus-ring: rgba(61,90,254,.22);
  --tint: rgba(61,90,254,.1);
  --shadow-ink: rgba(46,33,140,.32);
  --on-brand: #fff;               /* текст на ярких кнопках */

  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Unbounded", "Onest", system-ui, sans-serif;

  --r-panel: 28px;
  --r-bubble: 22px;
  --r-btn: 14px;

  --feed-w: 760px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --base: #0B0F2E;
    --ink: #F1F0FF;
    --ink-soft: #B6B3DA;
    --ink-faint: #7E7BA6;
    --glass-fill: linear-gradient(140deg, rgba(255,255,255,.13), rgba(255,255,255,.04));
    --glass-edge: rgba(255,255,255,.16);
    --glass-shine: inset 0 1px 0 rgba(255,255,255,.22), inset 0 -1px 0 rgba(255,255,255,.04);
    --glass-shadow: 0 16px 50px -16px rgba(0,0,0,.6);
    --inset-fill: rgba(255,255,255,.06);
    --hover: rgba(255,255,255,.09);
    --active: rgba(255,255,255,.16);
    --code-bg: rgba(5, 6, 22, .75);
    --blob-opacity: .55;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --base: #0B0F2E; --ink: #F1F0FF; --ink-soft: #B6B3DA; --ink-faint: #7E7BA6;
  --glass-fill: linear-gradient(140deg, rgba(255,255,255,.13), rgba(255,255,255,.04));
  --glass-edge: rgba(255,255,255,.16);
  --glass-shine: inset 0 1px 0 rgba(255,255,255,.22), inset 0 -1px 0 rgba(255,255,255,.04);
  --glass-shadow: 0 16px 50px -16px rgba(0,0,0,.6);
  --inset-fill: rgba(255,255,255,.06); --hover: rgba(255,255,255,.09); --active: rgba(255,255,255,.16);
  --code-bg: rgba(5, 6, 22, .75); --blob-opacity: .55; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--base);
  color: var(--ink);
  font: 400 16px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 10px; }

/* ---------- фон ---------- */
.backdrop { position: fixed; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: var(--blob-opacity);
  animation: drift 26s ease-in-out infinite alternate;
}
.blob-a { width: 46vmax; height: 46vmax; left: -12vmax; top: -14vmax; background: radial-gradient(circle at 40% 40%, #5C7CFF, transparent 68%); }
.blob-b { width: 40vmax; height: 40vmax; right: -10vmax; top: 4vmax;  background: radial-gradient(circle at 50% 50%, var(--pink), transparent 66%); animation-duration: 31s; animation-delay: -8s; }
.blob-c { width: 34vmax; height: 34vmax; left: 22vw; bottom: -16vmax; background: radial-gradient(circle at 50% 50%, var(--sun), transparent 64%); animation-duration: 35s; animation-delay: -14s; }
.blob-d { width: 26vmax; height: 26vmax; right: 12vw; bottom: 6vmax; background: radial-gradient(circle at 50% 50%, var(--mint), transparent 64%); animation-duration: 29s; animation-delay: -4s; }
@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(6vw, 4vh) scale(1.12); }
  100% { transform: translate(-4vw, 8vh) scale(.94); }
}

/* ---------- стекло ---------- */
.glass {
  position: relative;
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--glass-shine), var(--glass-shadow);
}
.glass-inset { background: var(--inset-fill); border: 1px solid var(--glass-edge); }

/* ---------- каркас ---------- */
.app {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 292px 1fr;
  height: 100vh; height: 100dvh;
}

/* ---------- сайдбар ---------- */
.sidebar {
  margin: 14px 0 14px 14px;
  border-radius: var(--r-panel);
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 14px 14px;
  min-height: 0;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.logo-orb {
  width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff 0 12%, #7FA0FF 30%, var(--violet) 62%, var(--pink) 100%);
  box-shadow: 0 4px 14px -2px var(--glow-soft), inset 0 -2px 4px rgba(0,0,0,.12);
}
.logo-word { font: 700 19px/1 var(--font-display); letter-spacing: -.01em; }

.new-chat {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; border-radius: 16px;
  font-weight: 600; color: var(--on-brand);
  background: var(--brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 10px 24px -10px var(--glow);
  transition: transform .15s ease, filter .15s ease;
}
.new-chat:hover { filter: brightness(1.06); }
.new-chat:active { transform: scale(.98); }

.history { flex: 1; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.history-empty { color: var(--ink-faint); font-size: 14px; padding: 8px 10px; margin: 0; }
.history-group { font-size: 12.5px; font-weight: 600; color: var(--ink-faint); margin: 14px 10px 4px; }
.history-group:first-child { margin-top: 4px; }

.chat-item {
  position: relative; display: flex; align-items: center;
  border-radius: 12px; min-height: 40px;
}
.chat-item:hover, .chat-item:focus-within { background: var(--hover); }
.chat-item.active { background: var(--active); box-shadow: inset 0 1px 0 rgba(255,255,255,.6); }
.chat-link {
  flex: 1; min-width: 0; padding: 9px 10px; text-align: left;
  font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
  height: 30px; min-width: 30px; border-radius: 9px; display: grid; place-items: center;
  color: var(--ink-soft); font-size: 13px; font-weight: 600;
}
.rename-input {
  flex: 1; min-width: 0; margin: 4px; padding: 6px 8px; border-radius: 9px;
  border: 1px solid var(--blue); background: var(--active); font-size: 14.5px; outline: none;
}

.chat-more {
  width: 30px; height: 30px; margin-right: 4px; border-radius: 9px; display: none; place-items: center; color: var(--ink-soft); flex: none;
}
.chat-more svg { width: 18px; height: 18px; }
.chat-more:hover, .chat-more.open { background: var(--hover); color: var(--ink); }
.chat-item:hover .chat-more, .chat-item:focus-within .chat-more, .chat-item.active .chat-more, .chat-more.open { display: grid; }
.pin-mark { display: grid; place-items: center; color: var(--violet); margin-right: 4px; flex: none; }
.pin-mark svg { width: 14px; height: 14px; }
.chat-item:hover .pin-mark, .chat-item:focus-within .pin-mark { display: none; }

.chat-menu {
  position: fixed; z-index: 70; min-width: 210px; padding: 6px; border-radius: 16px;
  display: flex; flex-direction: column; gap: 2px;
}
.chat-menu[hidden] { display: none; }
.chat-menu button {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  font-size: 14.5px; text-align: left;
}
.chat-menu button svg { width: 17px; height: 17px; color: var(--ink-soft); }
.chat-menu button:hover, .chat-menu button:focus-visible { background: var(--hover); }
.chat-menu .danger, .chat-menu .danger svg { color: var(--danger); }
.chat-menu .danger-armed { background: rgba(229,56,91,.12); font-weight: 600; }

.archive-link {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 14px; padding: 10px;
  border-radius: 12px; font-size: 14px; color: var(--ink-soft);
}
.archive-link svg { width: 17px; height: 17px; }
.archive-link .count { margin-left: auto; font-size: 12.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--inset-fill); }
.archive-link:hover { background: var(--hover); color: var(--ink); }
.archive-head { padding: 0 4px 2px; }
.archive-back { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 10px; font-size: 14px; color: var(--ink-soft); }
.archive-back svg { width: 16px; height: 16px; }
.archive-back:hover { background: var(--hover); color: var(--ink); }

.memory-note {
  display: flex; align-items: center; gap: 12px; font-size: 12.5px; color: var(--ink-faint); text-align: center;
}
.memory-note::before, .memory-note::after { content: ""; flex: 1; height: 1px; background: var(--glass-edge); }
.memory-note span { max-width: 440px; }

.archived-bar {
  max-width: var(--feed-w); margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 18px; border-radius: 22px; font-size: 14.5px; flex-wrap: wrap;
}
.archived-bar[hidden], .composer[hidden] { display: none; }
.archived-restore {
  padding: 9px 16px; border-radius: 14px; font-weight: 600; color: var(--on-brand); background: var(--brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45);
}
.toast { display: flex; align-items: center; gap: 14px; }
.toast[hidden] { display: none; }
.toast-action { font-weight: 600; color: var(--blue); }

.profile { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 18px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font: 700 14px var(--font-display); color: #fff;
  background: linear-gradient(135deg, var(--mint), var(--blue));
}
.profile-text { display: flex; flex-direction: column; line-height: 1.25; }
.profile-name { font-weight: 600; font-size: 14.5px; }
.profile-sub { font-size: 12.5px; color: var(--ink-faint); }

/* ---------- основная колонка ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 24px 8px;
}
.chat-title {
  flex: 1; min-width: 0; margin: 0;
  font: 600 16px/1.3 var(--font-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink-soft);
}
.model-pill { font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 999px; color: var(--ink-soft); white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-btn); display: grid; place-items: center; }
.only-mobile { display: none; }

.feed { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 20px; scroll-behavior: auto; }
.messages { max-width: var(--feed-w); margin: 0 auto; padding: 12px 0 28px; display: flex; flex-direction: column; gap: 22px; }

/* ---------- приветствие ---------- */
.welcome {
  max-width: var(--feed-w); margin: 0 auto; min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 0 40px;
}
.welcome[hidden] { display: none; }
.welcome-orb {
  width: 96px; height: 96px; border-radius: 50%; margin-bottom: 22px;
  background: radial-gradient(circle at 34% 28%, #fff 0 10%, #8EA8FF 28%, var(--violet) 60%, var(--pink) 100%);
  box-shadow: 0 24px 60px -16px var(--glow-soft), inset 0 -8px 18px rgba(40,0,90,.25), inset 0 6px 12px rgba(255,255,255,.6);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: translateY(-6px) scale(1.04); } }
.welcome-word {
  margin: 0; font: 700 clamp(44px, 8vw, 76px)/1 var(--font-display); letter-spacing: -.035em;
  background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.welcome-sub { margin: 14px 0 30px; color: var(--ink-soft); font-size: 17px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 620px; }
.chip {
  text-align: left; padding: 14px 16px; border-radius: 18px; font-size: 14.5px; line-height: 1.4;
  transition: transform .15s ease, background .15s ease;
}
.chip:hover { transform: translateY(-1px); background: var(--active); }

/* ---------- сообщения ---------- */
.msg { display: flex; gap: 12px; min-width: 0; }
.msg-user { justify-content: flex-end; }
.msg-user .bubble {
  max-width: min(78%, 600px);
  padding: 11px 16px; border-radius: var(--r-bubble) var(--r-bubble) 6px var(--r-bubble);
  background: var(--user-bubble); color: var(--on-brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 10px 26px -12px var(--glow);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-bot .orb {
  width: 30px; height: 30px; border-radius: 50%; margin-top: 4px; flex: none;
  background: radial-gradient(circle at 34% 28%, #fff 0 12%, #7FA0FF 30%, var(--violet) 62%, var(--pink) 100%);
  box-shadow: 0 4px 12px -3px var(--glow-soft);
}
.msg-bot.streaming .orb { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.86); opacity: .75; } }
.msg-bot .body { flex: 1; min-width: 0; }
.msg-bot .bubble {
  padding: 14px 18px; border-radius: 6px var(--r-bubble) var(--r-bubble) var(--r-bubble);
  overflow-wrap: anywhere;
}
.msg-tools { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg-bot:hover .msg-tools, .msg-tools:focus-within { opacity: 1; }
.msg-tools button {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
  border-radius: 10px; font-size: 13px; color: var(--ink-soft);
}
.msg-tools button:hover { background: var(--hover); color: var(--ink); }
.msg-tools svg { width: 15px; height: 15px; }

.typing { display: inline-flex; gap: 5px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--violet); animation: dot 1s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; background: var(--blue); }
.typing i:nth-child(3) { animation-delay: .3s; background: var(--pink); }
@keyframes dot { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

.msg-error .bubble { border-color: rgba(229,56,91,.45); color: var(--danger); font-weight: 500; }

/* markdown внутри ответа */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .75em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-body); font-weight: 600; line-height: 1.3; margin: 1.1em 0 .45em; }
.md h1 { font-size: 1.3em; } .md h2 { font-size: 1.18em; } .md h3 { font-size: 1.06em; }
.md ul, .md ol { margin: 0 0 .75em; padding-left: 1.35em; }
.md li { margin: .2em 0; }
.md a { color: var(--blue); text-underline-offset: 2px; }
.md blockquote { margin: 0 0 .75em; padding: 2px 14px; border-left: 3px solid var(--violet); color: var(--ink-soft); }
.md code { font: .9em/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--hover); padding: .1em .35em; border-radius: 6px; }
.md pre { position: relative; margin: 0 0 .9em; background: var(--code-bg); color: #ECEBFF; border-radius: 16px; overflow: hidden; }
.md pre code { display: block; padding: 40px 16px 14px; background: none; overflow-x: auto; font-size: 13.5px; }
.code-head { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 0 14px; font-size: 12px; color: #A9A6D6; }
.code-head button { color: #D7D5FF; font-size: 12px; padding: 4px 8px; border-radius: 8px; }
.code-head button:hover { background: rgba(255,255,255,.1); }
.md table { border-collapse: collapse; margin: 0 0 .9em; display: block; overflow-x: auto; font-size: .94em; }
.md th, .md td { border: 1px solid var(--glass-edge); padding: 6px 10px; text-align: left; }
.md th { background: var(--hover); font-weight: 600; }
.md hr { border: 0; height: 1px; background: var(--glass-edge); margin: 1.2em 0; }

/* ---------- поле ввода ---------- */
.composer-wrap { padding: 6px 20px max(14px, env(safe-area-inset-bottom)); }
.composer {
  max-width: var(--feed-w); margin: 0 auto;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 8px 8px 20px; border-radius: 28px;
}
.composer:focus-within { box-shadow: var(--glass-shine), var(--glass-shadow), 0 0 0 3px var(--focus-ring); }
.composer textarea {
  flex: 1; resize: none; border: 0; outline: none; background: transparent;
  padding: 9px 0; max-height: 200px; line-height: 1.5; font-size: 16px;
}
.composer textarea::placeholder { color: var(--ink-faint); }
.send {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--on-brand);
  background: var(--brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 8px 18px -8px var(--glow);
  transition: transform .15s ease, opacity .15s ease, filter .15s ease;
}
.send:hover:not(:disabled) { filter: brightness(1.08); }
.send:active:not(:disabled) { transform: scale(.94); }
.send:disabled { opacity: .35; cursor: default; box-shadow: none; }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.send.is-stop .i-send { display: none; }
.send.is-stop .i-stop { display: block; }
.disclaimer { text-align: center; font-size: 12px; color: var(--ink-faint); margin: 8px 0 0; }

/* ---------- тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 50;
  padding: 10px 16px; border-radius: 14px; font-size: 14px; max-width: calc(100vw - 32px);
}

/* ---------- мобильная версия ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .only-mobile { display: grid; }
  .sidebar {
    position: fixed; z-index: 40; top: 10px; bottom: 10px; left: 10px;
    width: min(320px, calc(100vw - 48px)); margin: 0;
    transform: translateX(calc(-100% - 24px));
    transition: transform .32s cubic-bezier(.2,.8,.2,1);
  }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; z-index: 30; background: rgba(15, 10, 50, .25); }
  .scrim[hidden] { display: none; }
  .topbar { padding: 12px 16px 6px; }
  .chat-title { text-align: center; }
  .model-pill { display: none; }
  .feed { padding: 0 16px; }
  .composer-wrap { padding: 4px 12px max(10px, env(safe-area-inset-bottom)); }
  .suggestions { grid-template-columns: 1fr; }
  .welcome-sub { font-size: 16px; margin-bottom: 22px; }
  .chat-more { display: grid; }
  .pin-mark { display: none; }
  .msg-tools { opacity: 1; }
  .msg-user .bubble { max-width: 88%; }
  .msg-bot .orb { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- сворачиваемые разделы списка чатов ---------- */
.history-section {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin: 12px 0 2px; padding: 6px 10px; border-radius: 10px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft); text-align: left;
}
.history-section:first-child { margin-top: 2px; }
.history-section:hover { background: var(--hover); color: var(--ink); }
.history-section .count { font-weight: 500; color: var(--ink-faint); }
.history-section .chev { width: 16px; height: 16px; margin-left: auto; transition: transform .2s ease; }
.history-section[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.history-section-body[hidden] { display: none; }
.history-group.sub { margin: 10px 10px 2px; font-size: 12px; font-weight: 500; }
.history-section-body > .history-group.sub:first-child { margin-top: 4px; }

/* ---------- поле ввода: скрепка, режим картинки, вложения ---------- */
.composer { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px; }
.composer-row { display: flex; align-items: flex-end; gap: 4px; }
.composer textarea { padding: 9px 6px 9px 8px; }
.tool-btn {
  height: 42px; min-width: 42px; padding: 0 10px; border-radius: 21px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--ink-soft); font-size: 14px; font-weight: 500;
}
.tool-btn:hover { background: var(--hover); color: var(--ink); }
.mode-btn[aria-pressed="true"] {
  color: var(--on-brand); background: var(--brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 6px 14px -8px var(--glow);
}
.aspect { flex: none; align-self: center; }
.aspect[hidden] { display: none; }
.aspect select {
  height: 32px; padding: 0 8px; border-radius: 10px; font: 500 13px var(--font-body); color: var(--ink);
  border: 1px solid var(--glass-edge); background: var(--inset-fill); cursor: pointer;
}

.attach-tray { display: flex; gap: 8px; overflow-x: auto; padding: 4px 4px 2px; }
.attach-tray[hidden] { display: none; }
.tray-item {
  position: relative; flex: none; height: 64px; border-radius: 14px; overflow: hidden;
  display: flex; align-items: center; gap: 8px; padding: 0 30px 0 12px; max-width: 220px;
  background: var(--inset-fill); border: 1px solid var(--glass-edge); font-size: 13px;
}
.tray-item.is-image { width: 64px; padding: 0; }
.tray-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tray-item svg { width: 20px; height: 20px; color: var(--blue); flex: none; }
.tray-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-item.is-loading img { filter: blur(2px) brightness(.85); }
.tray-spinner {
  position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.5); border-top-color: var(--blue); animation: spin .8s linear infinite;
}
.tray-item:not(.is-image) .tray-spinner { inset: auto 34px auto auto; position: relative; margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.tray-remove {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(20,18,58,.6); color: #fff;
}
.tray-remove svg { width: 13px; height: 13px; stroke-width: 2.5; color: #fff; }

.drop-hint {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; pointer-events: none;
  background: var(--tint); border: 3px dashed var(--blue); border-radius: 24px; margin: 10px;
}
.drop-hint[hidden] { display: none; }
.drop-hint span { font: 700 20px var(--font-display); color: var(--blue); padding: 14px 22px; border-radius: 18px; background: var(--active); }

/* вложения в сообщениях */
.user-col { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: min(78%, 600px); }
.user-col .bubble { max-width: 100%; }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 280px; padding: 8px 12px; border-radius: 14px;
  background: var(--active); border: 1px solid var(--glass-edge); color: var(--ink); text-decoration: none; font-size: 14px;
}
.file-chip svg { width: 18px; height: 18px; color: var(--blue); }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 11.5px; font-weight: 600; color: var(--ink-faint); }

.img-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; width: min(100%, 420px); }
.img-grid.single { grid-template-columns: 1fr; width: min(100%, 300px); }
.img-grid.generated, .img-grid.generated.single { width: min(100%, 460px); }
.img-item { margin: 0; position: relative; }
.img-item a { display: block; border-radius: 16px; overflow: hidden; background: var(--inset-fill); }
.img-item img { display: block; width: 100%; height: auto; max-height: 520px; object-fit: cover; }
.img-tools { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.img-tool {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 10px;
  font-size: 13px; color: var(--ink-soft); text-decoration: none;
}
.img-tool:hover { background: var(--hover); color: var(--ink); }
.img-tool svg { width: 15px; height: 15px; }
.bubble.bubble-images { padding: 10px; }
.img-skeleton {
  width: min(100%, 360px); aspect-ratio: 1; border-radius: 16px; display: grid; place-items: end start; padding: 14px;
  background: linear-gradient(110deg, var(--focus-ring), rgba(177,75,255,.22), rgba(255,79,163,.18), var(--focus-ring));
  background-size: 300% 100%; animation: shimmer 2.4s linear infinite;
}
.img-status { font-size: 13.5px; font-weight: 500; color: var(--ink); background: var(--active); padding: 6px 10px; border-radius: 10px; }
@keyframes shimmer { to { background-position: -300% 0; } }
.status-line { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 14.5px; }

/* ---------- Premium ---------- */
.premium-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; height: 42px; border-radius: 15px;
  font-weight: 600; font-size: 14.5px; color: #4A2A00;
  background: linear-gradient(135deg, #FFE08A 0%, #FFC23D 45%, #FF9E57 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 10px 22px -12px rgba(255,150,40,.9);
  transition: filter .15s ease, transform .15s ease;
}
.premium-btn[hidden] { display: none; }
.premium-btn svg { width: 18px; height: 18px; }
.premium-btn:hover { filter: brightness(1.05); }
.premium-btn:active { transform: scale(.98); }

.crown-btn { display: grid; color: #FFB020; }
.crown-btn[hidden] { display: none; }
.crown-btn svg { width: 21px; height: 21px; fill: rgba(255,194,61,.25); }
.crown-btn:hover { color: #FF9E20; }
/* покачивание раз в ~9 секунд, чтобы мягко напомнить о себе */
.crown-btn svg { animation: crown-wiggle 9s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes crown-wiggle {
  0%, 88%, 100% { transform: rotate(0); }
  90% { transform: rotate(-14deg) scale(1.08); }
  92% { transform: rotate(12deg) scale(1.08); }
  94% { transform: rotate(-8deg); }
  96% { transform: rotate(5deg); }
  98% { transform: rotate(0); }
}

.promo-layer { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 20px; }
.promo-layer[hidden] { display: none; }
.promo-scrim { position: absolute; inset: 0; background: rgba(15,10,50,.3); opacity: 0; transition: opacity .2s ease; }
.promo {
  position: relative; width: min(440px, 100%); max-height: min(760px, calc(100dvh - 40px)); border-radius: 30px;
  padding: 0; text-align: center; display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: translateY(14px) scale(.97); transition: opacity .2s ease, transform .28s cubic-bezier(.2,.8,.2,1);
}
.promo.glass {
  background: radial-gradient(120% 60% at 50% 0%, rgba(177,75,255,.16), transparent 70%), var(--menu-bg);
  -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
}
.promo-scroll { overflow-y: auto; overscroll-behavior: contain; padding: 28px 24px 18px; scrollbar-width: thin; }
.promo-layer.visible .promo-scrim { opacity: 1; }
.promo-layer.visible .promo { opacity: 1; transform: none; }
.promo-close { position: absolute; top: 12px; right: 12px; z-index: 3; background: var(--menu-bg); box-shadow: 0 4px 14px -6px var(--shadow-ink); }
.promo-close:hover { background: var(--hover); }
.promo-fog {
  position: absolute; left: 0; right: 0; bottom: 0; height: 56px; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: linear-gradient(to top, var(--menu-bg, rgba(250,250,255,.94)), transparent); border-radius: 0 0 30px 30px;
}
.promo-layer.has-more .promo-fog { opacity: 1; }

/* блоки появляются по очереди, как в neurosha */
.promo-layer.visible .pr-block { animation: prIn .5s cubic-bezier(.22,.68,0,1.2) var(--d, 0s) both; }
@keyframes prIn { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }

.promo-crown {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 21px; display: grid; place-items: center; color: #5A3300;
  background: linear-gradient(135deg, #FFE08A, #FFC23D 50%, #FF9E57);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.7), 0 18px 40px -14px rgba(255,150,40,.9);
}
.promo-crown svg { width: 34px; height: 34px; fill: rgba(255,255,255,.35); }
.promo-title { margin: 0; font: 700 24px/1.2 var(--font-display); letter-spacing: -.02em; }
.promo-sub { margin: 6px 0 16px; color: var(--ink-soft); font-size: 15px; }

.promo-feats { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; text-align: left; }
.promo-feats li {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 11px; border-radius: 16px;
  background: var(--inset-fill); border: 1px solid var(--glass-edge);
}
.pf-ico { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: var(--on-brand); background: var(--brand); }
.pf-ico svg { width: 17px; height: 17px; }
.promo-feats b { display: block; font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.promo-feats small { display: block; font-size: 12px; line-height: 1.3; color: var(--ink-soft); margin-top: 2px; }

/* главная карточка — пробный день */
.pr-hot {
  position: relative; text-align: left; padding: 16px 16px 13px; border-radius: 20px; cursor: pointer; isolation: isolate;
  background: linear-gradient(135deg, rgba(255,224,138,.38), rgba(255,158,87,.22) 55%, rgba(255,79,163,.18));
  border: 1.5px solid rgba(255,170,60,.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 14px 30px -18px rgba(255,140,40,.9);
  transition: transform .15s ease, box-shadow .2s ease;
}
.pr-hot:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 18px 34px -16px rgba(255,140,40,1); }
.pr-hot:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.pr-sparks { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; pointer-events: none; z-index: -1; opacity: .8; }
.pr-flame {
  position: absolute; top: -16px; left: -10px; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center;
  transform: rotate(-14deg); color: #fff; background: linear-gradient(160deg, #FFC23D, #FF6A3D 60%, #FF4FA3);
  box-shadow: 0 8px 18px -6px rgba(255,90,40,.8); animation: prFlame 2.4s ease-in-out infinite;
}
.pr-flame svg { width: 20px; height: 20px; fill: rgba(255,255,255,.3); }
@keyframes prFlame { 0%,100% { transform: rotate(-14deg) scale(1); } 50% { transform: rotate(-8deg) scale(1.07); } }
.pr-badge {
  display: inline-block; margin-left: 22px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase; color: #8A3B00; background: rgba(255,194,61,.4); transition: opacity .25s;
}
.pr-badge.swap { opacity: 0; }
.pr-hot-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 8px; }
.pr-price-line { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.pr-price { font: 700 30px/1.1 var(--font-display); letter-spacing: -.02em; }
.pr-circle { position: relative; display: inline-block; padding: 2px 8px; }
.pr-circle svg { position: absolute; left: 50%; top: 50%; width: 112%; height: 170%; transform: translate(-50%, -50%); overflow: visible; pointer-events: none; }
.pr-circle ellipse { fill: none; stroke: #FF4FA3; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 330; stroke-dashoffset: 330; }
.promo-layer.visible .pr-circle ellipse { animation: prDraw .9s cubic-bezier(.4,0,.2,1) .55s forwards; }
@keyframes prDraw { to { stroke-dashoffset: 0; } }
.pr-period { font-size: 13px; color: var(--ink-soft); }
.pr-desc { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.pr-pay {
  flex: none; height: 44px; padding: 0 20px; border-radius: 14px; font-weight: 700; font-size: 15px; color: #4A2A00;
  background: linear-gradient(135deg, #FFE08A 0%, #FFC23D 45%, #FF9E57 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 10px 22px -10px rgba(255,150,40,.95);
  animation: prWobble 2.2s ease-in-out infinite;
}
@keyframes prWobble {
  0%,100% { transform: none; } 20% { transform: scale(1.04) rotate(-1deg); }
  40% { transform: scale(1.06) rotate(1deg); } 60% { transform: scale(1.04) rotate(-.5deg); } 80% { transform: scale(1.02) rotate(.5deg); }
}
.pr-renew { margin-top: 10px; font-size: 11.5px; line-height: 1.35; color: var(--ink-faint); }

.pr-others { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.pr-others[hidden] { display: none; }
.pr-row {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 13px 14px; border-radius: 16px; text-align: left; background: var(--inset-fill); border: 1px solid var(--glass-edge);
  transition: border-color .15s, background .15s; animation: prIn .35s cubic-bezier(.22,.68,0,1.2) both;
}
.pr-row:nth-child(2) { animation-delay: .06s; }
.pr-row:hover { border-color: var(--blue); background: var(--hover); }
.pr-row.best { border-color: rgba(177,75,255,.55); }
.pr-row-badge { position: absolute; top: -9px; left: 14px; padding: 2px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 700; color: var(--on-brand); background: var(--brand); }
.pr-row-main, .pr-row-price { display: flex; flex-direction: column; }
.pr-row-main b { font-weight: 700; font-size: 15px; }
.pr-row-main small { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.pr-row-price { text-align: right; flex: none; }
.pr-row-price b { font-weight: 700; font-size: 15px; background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pr-row-price small { font-size: 11.5px; color: var(--ink-faint); }
.pr-more {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 100%; margin-top: 12px; height: 36px;
  border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft); border: 1px solid var(--glass-edge);
}
.pr-more:hover { color: var(--ink); background: var(--hover); }
.pr-more svg { width: 15px; height: 15px; transition: transform .2s; }
.pr-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.pr-manage {
  display: block; padding: 13px; border-radius: 16px; font-weight: 600; color: var(--ink); text-decoration: none;
  background: var(--inset-fill); border: 1px solid var(--glass-edge);
}
.pr-manage:hover { background: var(--hover); }
.pr-partial { margin: 12px 4px 0; font-size: 11.5px; line-height: 1.4; color: var(--ink-faint); }
.pr-partial a { color: inherit; }
.pr-note { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0 2px; font-size: 12px; color: var(--ink-faint); }
.pr-note svg { width: 14px; height: 14px; flex: none; }
.pr-note a { color: inherit; }
.promo-later { margin-top: 6px; padding: 8px 14px; border-radius: 12px; color: var(--ink-soft); font-size: 14.5px; }
.promo-later:hover { background: var(--hover); color: var(--ink); }
@media (max-width: 560px) {
  .promo-layer { padding: 12px; }
  .promo-scroll { padding: 24px 16px 14px; }
  .promo-feats li { padding: 9px; gap: 8px; }
  .pf-ico { width: 26px; height: 26px; border-radius: 9px; }
  .pf-ico svg { width: 15px; height: 15px; }
  .pr-price { font-size: 26px; }
  .pr-pay { padding: 0 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .pr-pay, .pr-flame { animation: none; }
  .promo-layer.visible .pr-block, .pr-row { animation: none; }
}

@media (max-width: 860px) {
  .mode-btn span { display: none; }
  .mode-btn { padding: 0; }
  .user-col { max-width: 88%; }
}
@media (prefers-reduced-motion: reduce) {
  .crown-btn svg { animation: none; }
}
.msg-bot .bubble.bubble-images { width: fit-content; max-width: 100%; }

/* ---------- своя тема: насыщенный серый + один яркий цвет с ползунка ---------- */
:root[data-theme="custom"] {
  --accent-h: 265;
  --base: #2A2C31;
  --ink: #F3F3F5;
  --ink-soft: #CDCED5;
  --ink-faint: #A3A4AD;
  --blue: hsl(var(--accent-h) 92% 64%);
  --violet: hsl(calc(var(--accent-h) + 20) 92% 66%);
  --pink: hsl(calc(var(--accent-h) - 20) 92% 66%);
  --sun: hsl(var(--accent-h) 95% 72%);
  --mint: hsl(var(--accent-h) 80% 52%);
  --brand: linear-gradient(135deg, hsl(var(--accent-h) 92% 56%) 0%, hsl(calc(var(--accent-h) + 28) 92% 66%) 100%);
  --user-bubble: linear-gradient(135deg, hsl(var(--accent-h) 85% 52% / .95), hsl(calc(var(--accent-h) + 28) 85% 60% / .92));
  --glass-fill: linear-gradient(140deg, rgba(58,60,66,.78), rgba(40,42,47,.72));
  --glass-edge: rgba(255,255,255,.14);
  --glass-shine: inset 0 1px 0 rgba(255,255,255,.2), inset 0 -1px 0 rgba(255,255,255,.04);
  --glass-shadow: 0 16px 50px -16px rgba(0,0,0,.55);
  --inset-fill: rgba(255,255,255,.05);
  --hover: rgba(255,255,255,.08);
  --active: rgba(255,255,255,.14);
  --code-bg: rgba(10,10,14,.7);
  --blob-opacity: .42;
  --orb: radial-gradient(circle at 34% 28%, #fff 0 12%, hsl(var(--accent-h) 95% 78%) 30%, hsl(var(--accent-h) 90% 58%) 62%, hsl(calc(var(--accent-h) + 28) 90% 52%) 100%);
  /* тени и подсветки — того же цвета, что и тема (а не фиолетовые) */
  --glow: hsl(var(--accent-h) 90% 50% / .6);
  --glow-soft: hsl(var(--accent-h) 90% 55% / .55);
  --focus-ring: hsl(var(--accent-h) 90% 60% / .3);
  --tint: hsl(var(--accent-h) 90% 60% / .14);
  --shadow-ink: rgba(0,0,0,.45);
  color-scheme: dark;
}
:root[data-theme="custom"] .img-skeleton {
  background: linear-gradient(110deg, hsl(var(--accent-h) 90% 60% / .12), hsl(calc(var(--accent-h) + 28) 90% 62% / .28), hsl(var(--accent-h) 90% 60% / .12));
  background-size: 300% 100%;
}
:root[data-theme="custom"] .drop-hint span { color: var(--blue); }
:root[data-theme="custom"] .welcome-word { background: var(--brand); -webkit-background-clip: text; background-clip: text; }
:root[data-theme="custom"] .blob-a { background: radial-gradient(circle at 40% 40%, hsl(var(--accent-h) 95% 60%), transparent 68%); }
:root[data-theme="custom"] .blob-b { background: radial-gradient(circle, hsl(calc(var(--accent-h) + 28) 95% 62%), transparent 66%); }
:root[data-theme="custom"] .blob-c { background: radial-gradient(circle, hsl(var(--accent-h) 90% 70%), transparent 64%); opacity: .28; }
:root[data-theme="custom"] .blob-d { background: radial-gradient(circle, hsl(calc(var(--accent-h) - 18) 90% 55%), transparent 64%); }
:root[data-theme="custom"] .logo-orb,
:root[data-theme="custom"] .welcome-orb,
:root[data-theme="custom"] .msg-bot .orb,
:root[data-theme="custom"] .settings-title.is-root::before { background: var(--orb); }
:root[data-theme="custom"] .welcome-orb { box-shadow: 0 24px 60px -16px hsl(var(--accent-h) 90% 55% / .7), inset 0 -8px 18px rgba(0,0,0,.25), inset 0 6px 12px rgba(255,255,255,.5); }
:root[data-theme="custom"] .md a, :root[data-theme="custom"] .toast-action { color: hsl(var(--accent-h) 95% 75%); }
:root[data-theme="custom"] .typing i { background: hsl(var(--accent-h) 92% 66%); }
:root[data-theme="custom"] .composer:focus-within { box-shadow: var(--glass-shine), var(--glass-shadow), 0 0 0 3px hsl(var(--accent-h) 92% 60% / .3); }
:root[data-theme="custom"] .scrim { background: rgba(0,0,0,.4); }

/* идёт генерация в чате */
.gen-dot {
  width: 9px; height: 9px; margin: 0 12px 0 4px; border-radius: 50%; flex: none;
  background: var(--brand); box-shadow: 0 0 0 0 var(--glow-soft); animation: gen-pulse 1.4s ease-out infinite;
}
.chat-item:hover .gen-dot, .chat-item:focus-within .gen-dot { margin-right: 4px; }
@keyframes gen-pulse { 0% { box-shadow: 0 0 0 0 var(--glow-soft); } 100% { box-shadow: 0 0 0 8px transparent; } }

/* своя тема: текст поверх цветных элементов — тёмный или белый по яркости цвета */
:root[data-theme="custom"] .avatar { color: var(--on-brand); background: var(--brand); }
:root[data-theme="custom"] .avatar img { background: none; }
:root[data-theme="custom"] .chat-item.active { background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
:root[data-theme="custom"] .chat-item:hover, :root[data-theme="custom"] .chat-item:focus-within { background: rgba(255,255,255,.07); }
:root[data-theme="custom"] .model-pill, :root[data-theme="custom"] .chat-title { color: var(--ink-soft); }
:root[data-theme="custom"] .chip { color: var(--ink); }
:root[data-theme="custom"] .md code { background: rgba(255,255,255,.1); }
:root[data-theme="custom"] .md blockquote { border-left-color: var(--blue); }
:root[data-theme="custom"] .img-status { background: rgba(30,31,36,.85); color: var(--ink); }
:root[data-theme="custom"] .archive-link .count { background: rgba(255,255,255,.1); }

/* ---------- меню скрепки ---------- */
.tools-menu {
  position: absolute; left: 6px; bottom: calc(100% + 10px); z-index: 30;
  width: min(330px, calc(100vw - 32px)); padding: 6px; border-radius: 20px;
  display: flex; flex-direction: column; gap: 2px;
  animation: menu-in .16s ease-out;
}
.tools-menu[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(6px); } }
.tools-heading { font-size: 12.5px; font-weight: 600; color: var(--ink-faint); padding: 10px 12px 4px; }
.tools-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border-radius: 14px; text-align: left;
}
.tools-item:hover, .tools-item:focus-visible { background: var(--hover); outline: none; }
.tools-item.is-active { background: var(--active); }
.tools-icon {
  width: 36px; height: 36px; border-radius: 12px; flex: none; display: grid; place-items: center;
  color: var(--blue); background: var(--tint);
}
.tools-icon svg { width: 19px; height: 19px; }
.tools-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.tools-text b { font-weight: 600; font-size: 14.5px; }
.tools-text span { font-size: 12.5px; color: var(--ink-faint); }

/* ---------- плашка активного режима ---------- */
.mode-bar { display: flex; align-items: center; gap: 8px; padding: 2px 2px 0; flex-wrap: wrap; }
.mode-bar[hidden] { display: none; }
.mode-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 4px 0 10px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; color: var(--on-brand); background: var(--brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 6px 14px -8px var(--glow);
}
.mode-chip-icon { display: grid; }
.mode-chip-icon svg { width: 17px; height: 17px; }
.mode-clear { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: inherit; }
.mode-clear:hover { background: rgba(255,255,255,.22); }
.mode-clear svg { width: 15px; height: 15px; stroke-width: 2.4; }
.mode-bar .aspect { display: inline-flex; align-items: center; gap: 6px; }
.mode-bar .aspect[hidden] { display: none; }
.aspect-label { font-size: 13px; color: var(--ink-faint); }

/* ---------- стартовые карточки действий ---------- */
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 640px; }
.action-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 20px; text-align: left;
  transition: transform .15s ease, background .15s ease;
}
.action-card:hover { transform: translateY(-1px); background: var(--active); }
.action-icon {
  width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center;
  color: var(--on-brand); background: var(--brand);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 8px 18px -10px var(--glow);
}
.action-icon svg { width: 22px; height: 22px; }
.action-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.action-text b { font-weight: 600; font-size: 15px; }
.action-text span { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

@media (max-width: 860px) {
  .actions { gap: 8px; }
  .action-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .action-icon { width: 38px; height: 38px; border-radius: 12px; }
  .action-text b { font-size: 14.5px; }
}

/* всплывающие меню — плотный фон, чтобы под ними не просвечивал текст */
:root { --menu-bg: rgba(250, 250, 255, .94); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --menu-bg: rgba(28, 30, 52, .95); } }
:root[data-theme="dark"] { --menu-bg: rgba(28, 30, 52, .95); }
:root[data-theme="custom"] { --menu-bg: rgba(40, 42, 47, .96); }
.tools-menu, .chat-menu { background: var(--menu-bg); }

/* плитка «добавить фото» в режиме редактирования */
.tray-add {
  flex: none; width: 64px; height: 64px; border-radius: 14px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; line-height: 1.15;
  color: var(--ink-soft); border: 1.5px dashed var(--glass-edge); background: transparent; text-align: center;
}
.tray-add svg { width: 20px; height: 20px; }
.tray-add:hover { color: var(--ink); background: var(--hover); border-color: var(--blue); }
.tray-add.is-empty { width: auto; flex-direction: row; gap: 8px; padding: 0 16px; font-size: 13.5px; }
.tray-hint { align-self: center; font-size: 12.5px; color: var(--ink-faint); padding: 0 4px; white-space: nowrap; }

/* выбор формата: своё оформление вместо системного */
.mode-bar .aspect { position: relative; height: 34px; padding-left: 10px; border-radius: 12px;
  border: 1px solid var(--glass-edge); background: var(--inset-fill); }
.mode-bar .aspect select {
  -webkit-appearance: none; appearance: none; height: 100%; padding: 0 30px 0 2px; border: 0; border-radius: 0 12px 12px 0;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238C89AE' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 14px;
  font: 600 13.5px var(--font-body); color: var(--ink); cursor: pointer; outline: none;
}
.mode-bar .aspect select option { color: #17143D; background: #fff; }
.mode-bar .aspect:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--focus-ring); }
.mode-bar .aspect-label { font-size: 13px; line-height: 1; color: var(--ink-faint); padding-top: 1px; }

/* ---------- время сообщений и разделители дней ---------- */
.msg-time { font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; padding: 0 6px; white-space: nowrap; }
.user-col .msg-time { padding: 0 4px; margin-top: -2px; }
.msg-tools { opacity: 1; align-items: center; min-height: 30px; }
.msg-tools button { opacity: 0; transition: opacity .15s; }
.msg-bot:hover .msg-tools button, .msg-tools:focus-within button { opacity: 1; }
.day-divider { display: flex; justify-content: center; margin: 4px 0 -6px; }
.day-divider span {
  font-size: 12.5px; font-weight: 500; color: var(--ink-soft); padding: 4px 12px; border-radius: 999px;
  background: var(--inset-fill); border: 1px solid var(--glass-edge);
}
@media (max-width: 860px) {
  .msg-tools button { opacity: 1; }
}

/* ---------- поле ввода на телефоне ---------- */
.composer textarea { min-height: 42px; }
.composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .composer { padding: 6px; gap: 4px; border-radius: 24px; }
  .composer-row { align-items: flex-end; gap: 2px; }
  .composer textarea { font-size: 16px; padding: 9px 4px; }
  .tool-btn { min-width: 40px; height: 42px; padding: 0 8px; }

  /* плашка режима и формат — одной строкой */
  .mode-bar { flex-wrap: nowrap; gap: 6px; padding: 0; }
  .mode-chip { height: 32px; gap: 6px; padding: 0 2px 0 9px; font-size: 13px; min-width: 0; flex: 0 1 auto; }
  .mode-chip > span:not(.mode-chip-icon) { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mode-chip-icon svg { width: 16px; height: 16px; }
  .mode-bar .aspect { height: 32px; padding-left: 0; flex: none; }
  .mode-bar .aspect-label { display: none; }
  .mode-bar .aspect select { padding: 0 26px 0 10px; border-radius: 12px; background-position: right 7px center; font-size: 13px; }

  /* вложения: компактнее, подсказка переносится, а не обрезается */
  .attach-tray { gap: 6px; padding: 2px; flex-wrap: wrap; overflow-x: visible; }
  .tray-item, .tray-add { height: 56px; }
  .tray-item.is-image, .tray-add { width: 56px; }
  .tray-add.is-empty { height: 44px; padding: 0 12px; font-size: 13px; }
  .tray-hint { white-space: normal; flex: 1 1 120px; font-size: 12px; line-height: 1.3; }
}

/* ---------- готовая картинка в ответе ---------- */
.msg-bot .bubble.bubble-images { width: fit-content; max-width: 100%; padding: 10px; }
.img-grid.generated, .img-grid.generated.single { width: min(460px, calc(100vw - 140px)); }
.img-grid.generated:not(.single) { width: min(560px, calc(100vw - 140px)); }
@media (max-width: 860px) {
  .img-grid.generated, .img-grid.generated.single, .img-grid.generated:not(.single) { width: min(460px, calc(100vw - 60px)); }
}
.img-tools { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.md .img-tool, .img-tool {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 10px;
  font: 500 13.5px/1 var(--font-body); color: var(--ink-soft); text-decoration: none; background: none;
}
.md .img-tool:hover, .img-tool:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.img-tool svg { width: 16px; height: 16px; flex: none; }

/* уведомления — поверх всех окон (настройки, промо, меню) */
.toast { z-index: 200; background: var(--menu-bg); box-shadow: 0 14px 40px -12px rgba(0,0,0,.45); }

/* «Запомнила: …» под ответом */
.mem-saved {
  display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 10px 8px 12px; border-radius: 14px;
  font-size: 13px; color: var(--ink-soft); background: var(--inset-fill); border: 1px solid var(--glass-edge);
  width: fit-content; max-width: 100%; animation: menu-in .25s ease-out;
}
.mem-saved svg { width: 17px; height: 17px; color: var(--violet); flex: none; }
.mem-saved-text { min-width: 0; }
.mem-saved-text b { font-weight: 600; color: var(--ink); }
.mem-saved button { flex: none; padding: 4px 8px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--blue); }
.mem-saved button:hover { background: var(--hover); }
:root[data-theme="custom"] .mem-saved svg, :root[data-theme="custom"] .mem-saved button { color: hsl(var(--accent-h) 95% 72%); }

/* «Учла прошлые чаты» */
.ref-note a { color: var(--blue); font-weight: 500; text-decoration: none; }
.ref-note a:hover { text-decoration: underline; text-underline-offset: 2px; }
:root[data-theme="custom"] .ref-note a { color: hsl(var(--accent-h) 95% 75%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ref-note a { color: #9DB0FF; } }
:root[data-theme="dark"] .ref-note a { color: #9DB0FF; }

/* режим ответа: Быстрая / Умная / Максимум */
.tier-wrap { position: relative; }
.tier-btn { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; font-weight: 600; color: var(--ink); }
.tier-btn svg { width: 15px; height: 15px; color: var(--ink-faint); }
.tier-btn:hover { background: var(--hover); }
.tier-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(340px, calc(100vw - 24px));
  padding: 6px; border-radius: 20px; background: var(--menu-bg); border: 1px solid var(--glass-edge);
  box-shadow: 0 18px 50px -16px rgba(0,0,0,.35); display: flex; flex-direction: column; gap: 2px;
  animation: menu-in .16s ease-out; -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
}
.tier-menu[hidden] { display: none; }
.tier-head { margin: 0; padding: 8px 12px 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-faint); }
.tier-foot { margin: 4px 0 0; padding: 8px 12px 6px; border-top: 1px solid var(--glass-edge); font-size: 12px; color: var(--ink-faint); }
.tier-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 14px; text-align: left; }
.tier-menu button:hover { background: var(--hover); }
.tier-menu button[aria-checked="true"] { background: var(--active); }
.tier-ico { flex: none; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: var(--on-brand); background: var(--brand); }
.tier-ico svg { width: 18px; height: 18px; }
.tier-menu button.locked .tier-ico { background: var(--inset-fill); color: var(--ink-faint); border: 1px solid var(--glass-edge); }
.tier-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tier-text b { font-size: 14.5px; font-weight: 600; }
.tier-text small { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; }
.tier-badge { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px; margin-left: 4px; color: #A86A00; background: rgba(255,194,61,.22); vertical-align: 1px; }
.tier-check { width: 18px; height: 18px; color: var(--violet); flex: none; }
.tier-menu .soon { flex: none; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; color: var(--violet); background: rgba(177,75,255,.13); }
@media (max-width: 860px) {
  .model-pill.tier-btn { display: inline-flex; padding: 6px 10px; font-size: 13px; }
  .tier-menu { position: fixed; right: 12px; left: 12px; top: 60px; width: auto; }
}
