/* ---------- шрифт ---------- */
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url(fonts/manrope-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url(fonts/manrope-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ---------- токены ---------- */
@property --c1 { syntax: '<color>'; inherits: true; initial-value: #ff9a4a; }
@property --c2 { syntax: '<color>'; inherits: true; initial-value: #ff5f2e; }
@property --c3 { syntax: '<color>'; inherits: true; initial-value: #ffd39a; }

:root {
  color-scheme: dark;
  --bg: #0b0a09;
  --main: #100e0d;
  --panel: #141211;
  --surface: #191715;
  --surface-2: #211e1b;
  --surface-3: #2a2522;
  --text: #f4efea;
  --muted: #a69d95;
  --faint: #6c645d;
  --line: rgba(255, 236, 220, .075);
  --line-2: rgba(255, 236, 220, .13);
  --accent: #ff9a4a;
  --accent-2: #ff6a2b;
  --accent-soft: rgba(255, 154, 74, .13);
  --on-light: #141211;
  --light-btn: #fbf8f5;
  --danger: #ff7a6b;
  --ok: #7fdc9a;
  --glow-a: rgba(255, 178, 110, .62);
  --glow-b: rgba(255, 112, 40, .32);
  --glow-c: rgba(120, 45, 10, .25);
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, .75), 0 2px 8px rgba(0, 0, 0, .35);
  --radius: 18px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #ece6e0;
    --main: #faf7f4;
    --panel: #fdfbf9;
    --surface: #ffffff;
    --surface-2: #f4eee8;
    --surface-3: #ece3da;
    --text: #1d1713;
    --muted: #6f655c;
    --faint: #a3988e;
    --line: rgba(70, 40, 15, .09);
    --line-2: rgba(70, 40, 15, .16);
    --accent: #e8711f;
    --accent-2: #d4520f;
    --accent-soft: rgba(232, 113, 31, .11);
    --light-btn: #1d1713;
    --on-light: #fdfbf9;
    --danger: #d13b2f;
    --ok: #1f9a4c;
    --glow-a: rgba(255, 176, 110, .55);
    --glow-b: rgba(255, 140, 70, .22);
    --glow-c: rgba(255, 210, 170, .25);
    --shadow: 0 18px 50px -24px rgba(80, 40, 10, .35), 0 2px 8px rgba(80, 40, 10, .06);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ece6e0;
  --main: #faf7f4;
  --panel: #fdfbf9;
  --surface: #ffffff;
  --surface-2: #f4eee8;
  --surface-3: #ece3da;
  --text: #1d1713;
  --muted: #6f655c;
  --faint: #a3988e;
  --line: rgba(70, 40, 15, .09);
  --line-2: rgba(70, 40, 15, .16);
  --accent: #e8711f;
  --accent-2: #d4520f;
  --accent-soft: rgba(232, 113, 31, .11);
  --light-btn: #1d1713;
  --on-light: #fdfbf9;
  --danger: #d13b2f;
  --ok: #1f9a4c;
  --glow-a: rgba(255, 176, 110, .55);
  --glow-b: rgba(255, 140, 70, .22);
  --glow-c: rgba(255, 210, 170, .25);
  --shadow: 0 18px 50px -24px rgba(80, 40, 10, .35), 0 2px 8px rgba(80, 40, 10, .06);
}

/* ---------- база ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  border: 0; background: transparent; color: var(--muted); transition: background .2s, color .2s, transform .2s var(--spring);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.92); }

.btn-light {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border: 0; border-radius: 12px;
  background: var(--light-btn); color: var(--on-light); font-weight: 650;
  transition: transform .25s var(--spring), box-shadow .25s, filter .2s; box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .6);
}
.btn-light svg { width: 16px; height: 16px; transition: transform .25s var(--ease); }
.btn-light:hover { transform: translateY(-1px); filter: brightness(.97); }
.btn-light:hover svg { transform: translateX(2px); }
.btn-light:active { transform: scale(.97); }

/* плитка с ядром */
.tile {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: linear-gradient(160deg, var(--surface-3), var(--surface-2)); border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}
.tile-lg { width: 76px; height: 76px; border-radius: 22px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), 0 12px 40px -14px color-mix(in srgb, var(--accent) 55%, transparent); }

/* ---------- ядро ---------- */
.orb {
  --size: 40px; --level: 0; --spin: 14s; --breath: 4.5s;
  --c1: #ff9a4a; --c2: #ff5f2e; --c3: #ffd39a;
  position: relative; width: var(--size); height: var(--size); flex: none;
  transition: --c1 .9s, --c2 .9s, --c3 .9s;
}
.orb-xs { --size: 18px; } .orb-sm { --size: 26px; } .orb-md { --size: 40px; } .orb-lg { --size: 48px; }
.orb-glow {
  position: absolute; inset: -45%; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c1) 55%, transparent) 0%, transparent 62%);
  filter: blur(calc(var(--size) * .1));
  opacity: calc(.4 + var(--level) * .6);
  animation: breathe var(--breath) ease-in-out infinite;
}
.orb-body { position: absolute; inset: 0; animation: breathe var(--breath) ease-in-out infinite; }
.orb-core {
  position: absolute; inset: 0; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--c1) 65%, #1a0903) 0%, #1c0b04 100%);
  box-shadow: inset 0 0 calc(var(--size) * .18) rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .06);
  transform: scale(calc(1 + var(--level) * .09));
  transition: transform .08s linear;
}
.blob { position: absolute; border-radius: 50%; mix-blend-mode: screen; filter: blur(calc(var(--size) * .09)); animation: orbit var(--spin) linear infinite; }
.b1 { background: var(--c1); width: 75%; height: 75%; top: -12%; left: -12%; }
.b2 { background: var(--c2); width: 70%; height: 70%; bottom: -18%; right: -10%; animation-duration: calc(var(--spin) * .72); animation-direction: reverse; }
.b3 { background: var(--c3); width: 46%; height: 46%; top: 30%; left: 28%; animation-duration: calc(var(--spin) * 1.35); opacity: .85; }
.orb-shine {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, 0) 32%),
              radial-gradient(circle at 70% 85%, rgba(255, 255, 255, .12) 0%, transparent 40%);
}
.orb-ring {
  position: absolute; inset: -12%; border-radius: 50%; opacity: 0; transition: opacity .4s;
  background: conic-gradient(from 0deg, transparent 0 62%, var(--c2) 85%, var(--c3) 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
          mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 2px));
  animation: spin 1.1s linear infinite;
}
.orb-burst { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--c3); pointer-events: none; animation: burst 1s var(--ease) forwards; }
.orb-burst + .orb-burst { animation-delay: .15s; }

.orb[data-state="think"] { --c1: #ffb347; --c2: #ff5e62; --c3: #ffe1a8; --spin: 2.6s; --breath: 1.6s; }
.orb[data-state="think"] .orb-ring { opacity: 1; }
.orb[data-state="talk"] { --c1: #ff9a4a; --c2: #ff3d6e; --c3: #ffe7b0; --spin: 6s; --breath: 2.4s; }
.orb[data-state="success"] { --c1: #ffc857; --c2: #7fdc9a; --c3: #fff2b8; --spin: 4s; }
.orb[data-state="error"] { --c1: #ff4d4d; --c2: #b3132b; --c3: #ffb3a8; --spin: 9s; }
.orb[data-state="error"] .orb-body { animation: shake .5s ease-in-out 2, breathe var(--breath) ease-in-out 1s infinite; }
.orb[data-state="unsure"] { --c1: #f5c04a; --c2: #ff8a3d; --c3: #fff0b0; --spin: 7s; }
.orb[data-state="unsure"] .orb-body { animation: wobble 2.4s ease-in-out infinite; }

@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
@keyframes orbit { from { transform: rotate(0deg) translateX(14%) rotate(0deg); } to { transform: rotate(360deg) translateX(14%) rotate(-360deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes burst { from { transform: scale(1); opacity: .9; } to { transform: scale(2.3); opacity: 0; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6%); } 75% { transform: translateX(6%); } }
@keyframes wobble { 0%, 100% { transform: rotate(0) scale(1); } 30% { transform: rotate(-8deg) scale(1.02); } 60% { transform: rotate(6deg) scale(.99); } }

/* ---------- вход ---------- */
.login { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.login-glow { position: fixed; inset: 0; pointer-events: none; background:
  radial-gradient(50% 45% at 80% 0%, var(--glow-a), transparent 70%),
  radial-gradient(40% 40% at 10% 100%, var(--glow-b), transparent 70%); animation: glowDrift 18s ease-in-out infinite alternate; }
.login-card {
  position: relative; width: min(390px, 100%); padding: 34px 30px 24px; border-radius: 26px; text-align: center;
  background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--line-2); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px; animation: rise .7s var(--ease) both;
}
.login-card .tile-lg { margin: 0 auto 6px; animation: pop .9s var(--spring) both; }
.login-card.shake { animation: shakeX .45s ease-in-out; }
.login-card h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.02em; }
.login-card p { margin: -8px 0 6px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 13px; color: var(--muted); }
.field input {
  font-size: 15px; padding: 12px 14px; border-radius: 12px; color: var(--text);
  border: 1px solid var(--line-2); background: var(--surface); transition: border-color .2s, box-shadow .2s;
}
.field input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-card .btn-light { margin-top: 6px; padding: 13px; }
.form-error { color: var(--danger); min-height: 1.3em; margin: 0; font-size: 14px; }
@keyframes shakeX { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- раскладка ---------- */
.app {
  display: grid; grid-template-columns: 264px 1fr; column-gap: 14px; padding: 14px;
  height: 100vh; height: 100dvh; transition: grid-template-columns .4s var(--ease), column-gap .4s var(--ease);
}
.app.collapsed { grid-template-columns: 0 1fr; column-gap: 0; }

.sidebar {
  position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03); animation: slideIn .6s var(--ease) both;
}
.app.collapsed .sidebar { border-color: transparent; }
.sb-head { display: flex; align-items: center; gap: 2px; padding: 16px 10px 10px 16px; white-space: nowrap; }
.brand { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; min-width: 0; }
.sb-search { display: grid; grid-template-rows: 0fr; padding: 0 12px; transition: grid-template-rows .3s var(--ease), padding .3s var(--ease); }
.sb-search > input { min-height: 0; overflow: hidden; width: 100%; border: 1px solid transparent; border-radius: 11px; background: var(--surface-2); padding: 0 12px; font-size: 14px; outline: none; transition: border-color .2s, padding .3s; }
.sb-search.open { grid-template-rows: 1fr; padding: 2px 12px 6px; }
.sb-search.open > input { padding: 9px 12px; border-color: var(--line); }
.sb-search > input:focus { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

.new-chat {
  position: relative; display: flex; align-items: center; gap: 9px; margin: 8px 12px 6px; padding: 11px 14px; border-radius: 13px; white-space: nowrap;
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--surface-3), var(--surface-2)); color: var(--accent); font-weight: 600; font-size: 14px;
  transition: transform .25s var(--spring), box-shadow .25s, border-color .25s;
  box-shadow: 0 10px 24px -14px color-mix(in srgb, var(--accent) 70%, transparent);
}
.new-chat::after { content: ""; position: absolute; left: 14px; right: 30%; bottom: -1px; height: 1px; background: linear-gradient(90deg, var(--accent), transparent); transition: right .4s var(--ease); }
.new-chat:hover { border-color: color-mix(in srgb, var(--accent) 35%, transparent); transform: translateY(-1px); }
.new-chat:hover::after { right: 8%; }
.new-chat:active { transform: scale(.97); }
.new-chat svg { width: 16px; height: 16px; }

.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.sb-label { padding: 16px 10px 6px; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); white-space: nowrap; animation: fadeIn .4s var(--ease) both; }
.chat-item {
  position: relative; display: flex; align-items: center; gap: 6px; padding: 7px 6px 7px 10px; margin: 1px 0; border-radius: 10px;
  color: var(--muted); cursor: pointer; transition: background .2s, color .2s; animation: fadeIn .4s var(--ease) both;
}
.chat-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.chat-item:hover { background: var(--surface); color: var(--text); }
.chat-item.active { background: var(--surface-2); color: var(--text); }
.chat-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.chat-item .del { opacity: 0; width: 26px; height: 26px; border-radius: 7px; transition: opacity .2s, background .2s; }
.chat-item .del svg { width: 14px; height: 14px; }
.chat-item:hover .del, .chat-item:focus-within .del { opacity: 1; }
.chat-item .del:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.chat-empty { padding: 18px 10px; font-size: 13px; color: var(--faint); }

.sb-card {
  position: relative; overflow: hidden; margin: 0 10px 10px; padding: 18px 14px 14px; border-radius: 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); white-space: nowrap;
}
.sb-card-glow { position: absolute; inset: 0; pointer-events: none; background:
  radial-gradient(60% 55% at 0% 100%, var(--glow-a), transparent 70%),
  radial-gradient(50% 40% at 100% 100%, var(--glow-b), transparent 70%); opacity: .8; animation: glowDrift 12s ease-in-out infinite alternate; }
.sb-card > :not(.sb-card-glow) { position: relative; }
.sb-card-avatar {
  display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; margin-bottom: 8px;
  background: linear-gradient(140deg, #ffcf9a, var(--accent) 50%, var(--accent-2)); color: #2a1206; font-weight: 800; font-size: 18px; text-transform: uppercase;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--line-2), 0 10px 26px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.sb-card b { font-size: 16px; font-weight: 650; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sb-card small { color: var(--muted); font-size: 12px; margin-bottom: 12px; white-space: normal; line-height: 1.4; }
.sb-card .btn-light { width: 100%; padding: 10px; font-size: 14px; }
.backdrop { display: none; }

/* основная область */
.main {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--main); border: 1px solid var(--line); border-radius: 26px; isolation: isolate;
}
.main-glow {
  position: absolute; inset: 0; z-index: -1; pointer-events: none; transition: opacity .8s var(--ease);
  background:
    radial-gradient(42% 52% at 92% 4%, var(--glow-a), transparent 72%),
    radial-gradient(55% 65% at 78% 12%, var(--glow-b), transparent 75%),
    radial-gradient(40% 40% at 55% 30%, var(--glow-c), transparent 70%);
  animation: glowDrift 20s ease-in-out infinite alternate;
}
.main:not(.home) .main-glow { opacity: .38; }
@keyframes glowDrift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-3%, 2%) scale(1.06); } }

.topbar { display: flex; align-items: center; gap: 10px; padding: 16px 20px 10px 22px; min-height: 66px; }
#menu { display: none; }
.app.collapsed #menu { display: inline-grid; }
.topbar-title { flex: 1; min-width: 0; transition: opacity .3s; }
.main.home .topbar-title { opacity: 0; pointer-events: none; }
.topbar .title { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .subtitle { font-size: 12.5px; color: var(--muted); }
.topbar .subtitle.busy { background: linear-gradient(90deg, var(--muted) 0%, var(--accent) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.round-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 22%, var(--surface)); color: #ffe2b8; transition: transform .3s var(--spring), background .2s;
}
:root[data-theme="light"] .round-btn { color: var(--accent-2); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .round-btn { color: var(--accent-2); } }
.round-btn:hover { transform: rotate(-18deg) scale(1.05); }
.round-btn:active { transform: scale(.92); }
.top-avatar {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-weight: 800; text-transform: uppercase; color: #2a1206;
  background: linear-gradient(140deg, #ffcf9a, var(--accent) 50%, var(--accent-2)); box-shadow: 0 0 0 2px var(--main), 0 0 0 3px var(--line-2);
}
.i-sun { display: none; }
:root[data-theme="light"] .i-sun { display: block; } :root[data-theme="light"] .i-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .i-sun { display: block; }
  :root:not([data-theme="dark"]) .i-moon { display: none; }
}

.scroller { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.thread { max-width: 800px; margin: 0 auto; padding: 12px 24px 24px; display: flex; flex-direction: column; gap: 24px; min-height: 100%; }

/* ---------- приветствие ---------- */
.welcome { margin: auto 0; width: 100%; max-width: 640px; align-self: center; padding: 10px 0 30px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.welcome .tile-lg { margin-bottom: 22px; animation: pop .9s var(--spring) both; }
.welcome .hello { margin: 0; font-size: clamp(20px, 2.6vw, 28px); font-weight: 500; letter-spacing: -.015em; animation: rise .7s .08s var(--ease) both; }
.welcome .hello .spark { display: inline-block; color: #ffd27a; animation: twinkle 2.6s ease-in-out infinite; }
.welcome h1 { margin: 4px 0 28px; font-size: clamp(26px, 3.6vw, 40px); line-height: 1.2; font-weight: 500; letter-spacing: -.025em; animation: rise .7s .16s var(--ease) both; }
.welcome .slot { width: 100%; animation: rise .7s .24s var(--ease) both; }
.welcome h3 {
  align-self: stretch; text-align: left; margin: 52px 0 16px 6px; font-size: clamp(19px, 2.2vw, 24px); font-weight: 500; letter-spacing: -.015em;
  background: linear-gradient(90deg, var(--muted), color-mix(in srgb, var(--muted) 40%, transparent)); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: rise .7s .3s var(--ease) both;
}
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(1.18) rotate(12deg); opacity: .75; } }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; width: 100%; }
.card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 18px 20px 14px; border-radius: 20px;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 88%, transparent);
  transition: transform .3s var(--spring), border-color .3s, box-shadow .3s; animation: rise .6s var(--ease) both;
}
.card::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: radial-gradient(80% 90% at 100% 0%, var(--accent-soft), transparent 70%); }
.card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow); }
.card:hover::before { opacity: 1; }
.card:active { transform: translateY(-1px) scale(.99); }
.card b { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.card small { color: var(--muted); font-size: 13px; line-height: 1.5; flex: 1; }
.card .more { display: flex; align-items: center; gap: 6px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.card .more svg { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.card:hover .more { color: var(--accent); }
.card:hover .more svg { transform: translateX(4px); }

/* ---------- сообщения ---------- */
.msg { display: flex; gap: 14px; animation: rise .5s var(--ease) both; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  max-width: min(78%, 620px); padding: 11px 16px; border-radius: 20px 20px 6px 20px;
  background: var(--surface-2); border: 1px solid var(--line-2); white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 10px 30px -18px color-mix(in srgb, var(--accent) 60%, transparent);
}
.msg.bot .who { flex: none; padding-top: 2px; }
.msg.bot .who .dot { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line-2); }
.msg.bot .who .dot::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff0d8 0%, var(--accent) 45%, #6b2205 100%); box-shadow: 0 0 10px var(--accent); }
.msg.bot .who .dot.err::after { background: radial-gradient(circle at 35% 30%, #ffd9d4 0%, #ff4d4d 45%, #4a0f0a 100%); box-shadow: 0 0 10px #ff4d4d; }
.msg.bot .content { flex: 1; min-width: 0; padding-top: 2px; }
.answer { overflow-wrap: anywhere; }
.answer > :first-child { margin-top: 0; } .answer > :last-child { margin-bottom: 0; }
.answer p { margin: 0 0 .75em; }
.answer ul, .answer ol { padding-left: 1.4em; margin: 0 0 .75em; }
.answer li::marker { color: var(--accent); }
.answer h1, .answer h2, .answer h3 { font-size: 1.05em; font-weight: 650; margin: 1.1em 0 .5em; letter-spacing: -.01em; }
.answer strong { font-weight: 700; }
.answer a { color: var(--accent); }
.answer code { font: 13px/1.5 "Cascadia Code", Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.answer pre { background: var(--surface); padding: 12px 14px; border-radius: 12px; overflow-x: auto; border: 1px solid var(--line); }
.answer pre code { background: none; padding: 0; }
.answer table { border-collapse: separate; border-spacing: 0; width: max-content; max-width: 100%; display: block; overflow-x: auto; margin: 10px 0 14px; font-size: 13.5px; border: 1px solid var(--line-2); border-radius: 14px; background: color-mix(in srgb, var(--surface) 80%, transparent); }
.answer th, .answer td { padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.answer th { background: var(--surface-2); font-weight: 650; font-size: 12.5px; color: var(--muted); position: sticky; top: 0; }
.answer tr:last-child td { border-bottom: 0; }
.answer tbody tr { transition: background .15s; }
.answer tbody tr:hover { background: var(--accent-soft); }
.answer [align="right"] { text-align: right; font-variant-numeric: tabular-nums; } .answer [align="center"] { text-align: center; }
.msg.bot.err .answer { color: var(--danger); }
.caret { display: inline-block; width: 8px; height: 1.05em; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.thinking { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; height: 28px; }
.thinking .dots { display: inline-flex; gap: 4px; }
.thinking .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite var(--ease); }
.thinking .dots i:nth-child(2) { animation-delay: .15s; } .thinking .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .35; } 40% { transform: translateY(-5px); opacity: 1; } }

/* шаги выполнения */
.steps { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--surface) 75%, transparent); overflow: hidden; animation: fadeIn .35s var(--ease) both; }
.steps > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.steps > summary::-webkit-details-marker { display: none; }
.steps > summary > svg:first-child { color: var(--accent); }
.steps > summary .chev { margin-left: auto; transition: transform .25s var(--ease); width: 16px; height: 16px; }
.steps[open] > summary .chev { transform: rotate(180deg); }
.steps > summary:hover { color: var(--text); }
.step-list { padding: 2px 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.step { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; font-size: 13.5px; padding: 5px 0; animation: slideIn .35s var(--ease) both; }
.step .st { display: grid; place-items: center; width: 18px; height: 18px; }
.step .st svg { width: 15px; height: 15px; }
.step.active .st::before { content: ""; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .7s linear infinite; }
.step.done .st { color: var(--ok); }
.step.fail .st { color: var(--danger); }
.step .tx { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step.active .tx { background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.step .meta { font-size: 12px; color: var(--faint); }
.step.fail .meta { color: var(--danger); }
.step-sql { grid-column: 2 / -1; }
.step-sql summary { font-size: 12px; color: var(--faint); cursor: pointer; width: fit-content; }
.step-sql summary:hover { color: var(--accent); }
.step-sql pre { margin: 6px 0 4px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font: 12px/1.5 "Cascadia Code", Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto; }
.step-sql .err { color: var(--danger); }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* файлы */
.files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.file {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 10px; border-radius: 16px; min-width: 250px; max-width: 100%;
  border: 1px solid var(--line-2); background: var(--surface); text-decoration: none; color: var(--text);
  transition: transform .3s var(--spring), box-shadow .3s, border-color .3s; animation: pop .6s var(--spring) both;
}
.file:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.file .fi { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .03em; flex: none; }
.file .fi.xlsx { background: linear-gradient(135deg, #2fb36b, #127a43); }
.file .fi.pdf { background: linear-gradient(135deg, #ff6a55, #c2281e); }
.file .fn { min-width: 0; flex: 1; }
.file .fn b { display: block; font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .fn small { color: var(--muted); font-size: 12px; }
.file .dl { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--light-btn); color: var(--on-light); transition: transform .3s var(--spring); }
.file .dl svg { width: 16px; height: 16px; }
.file:hover .dl { transform: translateY(2px); }

.actions { display: flex; gap: 2px; margin-top: 8px; opacity: 0; transition: opacity .2s; }
.msg.bot:hover .actions, .actions:focus-within { opacity: 1; }
.actions .icon-btn { width: 30px; height: 30px; }
.actions .icon-btn svg { width: 15px; height: 15px; }
.actions .icon-btn.ok { color: var(--ok); }

/* ---------- ввод ---------- */
.composer-dock { padding: 4px 24px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
.main.home .composer-dock { display: none; }
.composer {
  max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; padding: 14px 12px 10px 18px; border-radius: 22px; text-align: left;
  background: color-mix(in srgb, var(--surface) 72%, transparent); backdrop-filter: blur(22px) saturate(1.3); -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid var(--line-2); box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .04);
  transition: border-color .3s, box-shadow .3s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); }
.composer textarea { resize: none; border: 0; outline: 0; background: transparent; color: var(--text); padding: 2px 6px 6px 0; min-height: 30px; max-height: 200px; line-height: 1.5; overflow-y: hidden; }
.welcome .composer textarea { min-height: 54px; }
.composer textarea::placeholder { color: var(--faint); }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-left: -6px; }
.bar-gap { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 12px; font-size: 13px; font-weight: 550;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); transition: background .2s, color .2s, border-color .2s, transform .25s var(--spring);
}
.chip svg { width: 15px; height: 15px; }
.chip:hover { color: var(--text); }
.chip:active { transform: scale(.95); }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.counter { font-size: 12px; color: var(--faint); }
.send {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; flex: none;
  background: var(--light-btn); color: var(--on-light); transition: transform .3s var(--spring), opacity .2s, box-shadow .3s;
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .6);
}
.send:hover:not(:disabled) { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 24px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
.send:active:not(:disabled) { transform: scale(.9); }
.send:disabled { opacity: .3; cursor: default; box-shadow: none; }
.send.busy svg { animation: spin 1s linear infinite; }
.hint { max-width: 800px; margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--faint); }

.to-bottom {
  position: absolute; left: 50%; bottom: 150px; z-index: 3; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--muted); box-shadow: var(--shadow);
  opacity: 0; transform: translate(-50%, 10px) scale(.9); pointer-events: none; transition: opacity .25s, transform .25s var(--spring);
}
.to-bottom.show { opacity: 1; transform: translate(-50%, 0) scale(1); pointer-events: auto; }
.to-bottom:hover { color: var(--text); }

/* ---------- общие анимации ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.8); } 100% { opacity: 1; transform: none; } }

/* ---------- планшеты и телефоны ---------- */
@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: 1fr; column-gap: 0; padding: 0; }
  .sidebar {
    position: fixed; top: 8px; bottom: 8px; left: 8px; width: min(300px, calc(100vw - 48px)); z-index: 20;
    transform: translateX(calc(-100% - 16px)); transition: transform .4s var(--ease); animation: none; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .5); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .3s; }
  .backdrop.show { opacity: 1; pointer-events: auto; }
  #menu { display: inline-grid; }
  #collapse { display: none; }
  .main { border: 0; border-radius: 0; }
  .topbar { padding: 10px 12px 6px; min-height: 58px; padding-top: max(10px, env(safe-area-inset-top)); }
  .round-btn, .top-avatar { width: 36px; height: 36px; }
  .thread { padding: 8px 14px 18px; gap: 20px; }
  .welcome { padding-bottom: 20px; }
  .welcome .tile-lg { width: 64px; height: 64px; border-radius: 19px; margin-bottom: 16px; }
  .welcome h1 { margin-bottom: 20px; }
  .welcome h3 { margin-top: 34px; }
  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 15px 16px 12px; }
  .card .more { margin-top: 10px; padding-top: 10px; }
  .composer-dock { padding: 4px 10px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .composer { padding: 12px 10px 8px 14px; border-radius: 20px; }
  .composer textarea { font-size: 16px; }
  .hint { display: none; }
  .msg.bot .who { display: none; }
  .msg.user .bubble { max-width: 88%; }
  .to-bottom { bottom: 110px; }
  .file { min-width: 0; width: 100%; }
}
@media (max-width: 380px) {
  .chip { padding: 7px 10px; }
  .top-avatar { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
