/* ============ Aurora Chat — в стиле Aurora System ============ */
:root {
  --blue-900: #172554;
  --blue-800: #1e3a8a;
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --sky-500: #0ea5e9;
  --sky-400: #38bdf8;
  --sky-100: #e0f2fe;
  --sky-50: #f0f9ff;
  --ice-50: #f5faff;
  --white: #fff;
  --text-900: #0f172a;
  --text-700: #334155;
  --text-600: #475569;
  --text-400: #94a3b8;
  --line: #e6eefb;
  --radius: 18px;
  --shadow-sm: 0 2px 10px rgba(37, 99, 235, .08);
  --shadow-md: 0 10px 30px rgba(37, 99, 235, .12);
  --shadow-lg: 0 20px 50px rgba(37, 99, 235, .18);
  --gradient: linear-gradient(120deg, var(--blue-700), var(--sky-400));
  --transition: .3s cubic-bezier(.4, 0, .2, 1);
  --sidebar-w: 276px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text-900);
  background: var(--white);
  line-height: 1.55;
  overflow: hidden;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; flex-shrink: 0; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============ Кнопки ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: 50px;
  font-weight: 600; font-size: .95rem; border: none;
  transition: var(--transition); white-space: nowrap;
}
.btn-primary {
  background: var(--gradient); color: #fff;
  box-shadow: 0 8px 22px rgba(37, 99, 235, .32);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(37, 99, 235, .42); }
.btn-primary:disabled { opacity: .6; transform: none; cursor: default; }
.btn-block { width: 100%; }
.btn-ghost { background: var(--sky-50); color: var(--blue-700); }
.btn-ghost:hover { background: var(--sky-100); }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 8px 16px; font-size: .85rem; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-600); transition: var(--transition);
}
.icon-btn:hover { background: var(--sky-50); color: var(--blue-600); }

/* ============ Вход ============ */
.auth {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--sky-50), #fff);
  padding: 24px; overflow: auto;
}
.auth-glow { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55; pointer-events: none; }
.auth-glow.a1 { width: 460px; height: 460px; background: var(--sky-100); top: -140px; right: -120px; }
.auth-glow.a2 { width: 400px; height: 400px; background: #dbeafe; bottom: -160px; left: -120px; }

.auth-card {
  position: relative; z-index: 1; width: min(430px, 100%);
  background: #fff; border: 1px solid var(--line); border-radius: 24px;
  padding: 40px 36px; box-shadow: var(--shadow-lg);
}
.auth-logo { height: 76px; width: auto; margin: 0 auto 18px; }
.auth-card h1 { font-size: 1.55rem; font-weight: 800; text-align: center; letter-spacing: -.02em; }
.auth-sub { text-align: center; color: var(--text-600); font-size: .92rem; margin: 8px 0 26px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: .82rem; font-weight: 600; color: var(--text-600); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 14px; background: var(--ice-50); outline: none;
  transition: var(--transition); font-size: .95rem;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-500); background: #fff; box-shadow: 0 0 0 4px rgba(59, 130, 246, .12);
}
.auth-error {
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  padding: 10px 14px; border-radius: 12px; font-size: .88rem; margin-bottom: 14px;
}
.auth-note { text-align: center; color: var(--text-400); font-size: .8rem; margin-top: 18px; }
.field-note { display: block; margin-top: 5px; font-size: .74rem; color: var(--text-400); }
.field-note code { background: none; padding: 0; color: var(--text-600); }

/* ============ Каркас ============ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* --------- сайдбар --------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--sky-50), #fff);
  border-right: 1px solid var(--line); position: relative; z-index: 40;
  transition: margin var(--transition);
}
.app.sb-closed .sidebar { margin-left: calc(var(--sidebar-w) * -1); }

.sb-top { padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 12px; }
.sb-brand { display: block; padding: 2px 6px; }
.sb-brand img { height: 52px; width: auto; }
.btn-new { justify-content: center; padding: 11px 18px; font-size: .9rem; }

.sb-search {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  color: var(--text-400); transition: var(--transition);
}
.sb-search:focus-within { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(59, 130, 246, .1); }
.sb-search input { border: none; outline: none; background: none; width: 100%; font-size: .88rem; }

.sb-history { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.sb-empty { color: var(--text-400); font-size: .85rem; text-align: center; padding: 26px 10px; }

.conv-group { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-400); padding: 14px 8px 6px; }
.conv-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border-radius: 12px; font-size: .88rem; color: var(--text-700);
  transition: var(--transition); text-align: left;
}
.conv-item span.t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item:hover { background: #fff; box-shadow: var(--shadow-sm); }
.conv-item.active { background: var(--gradient); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, .3); }
.conv-item .del { opacity: 0; width: 24px; height: 24px; border-radius: 8px; display: flex; align-items: center; justify-content: center; color: inherit; }
.conv-item:hover .del { opacity: .7; }
.conv-item .del:hover { background: rgba(185, 28, 28, .16); opacity: 1; }
.conv-item.active .del:hover { background: rgba(255, 255, 255, .25); }
.conv-item .del .ico { width: 14px; height: 14px; }
/* правка тарифов модели в админке */
.price-row { display: flex; align-items: center; gap: 4px; }
.price-row + .price-row { margin-top: 3px; }
.price-row span { width: 22px; font-size: .66rem; color: #64748b; }
.price-row input {
  width: 56px; padding: 3px 5px; border: 1px solid var(--line); border-radius: 6px;
  font-size: .72rem; background: var(--ice-50); outline: none;
}
.price-row input:focus { border-color: var(--blue-500); }
/* ответ генерируется в фоне */
.conv-busy { width: 12px; height: 12px; flex: none; border-radius: 50%; border: 2px solid rgba(37, 99, 235, .25); border-top-color: #2563eb; animation: conv-spin .8s linear infinite; }
.conv-item.active .conv-busy { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
@keyframes conv-spin { to { transform: rotate(360deg); } }

.sb-user {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-top: 1px solid var(--line); cursor: pointer; transition: var(--transition);
}
.sb-user:hover { background: #fff; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--gradient);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
  font-size: .95rem; flex-shrink: 0;
}
.sb-user-meta { flex: 1; min-width: 0; line-height: 1.25; }
.sb-user-meta b { display: block; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; }
.sb-user-meta span { font-size: .74rem; color: var(--text-400); }
.sb-user .chev { color: var(--text-400); }

.user-menu {
  position: absolute; bottom: 66px; left: 12px; right: 12px; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 6px; overflow: hidden;
  animation: pop .16s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.user-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 10px; font-size: .88rem; font-weight: 500;
  color: var(--text-700); transition: var(--transition);
}
.user-menu button:hover { background: var(--sky-50); color: var(--blue-700); }
.user-menu button.danger { color: #b91c1c; }
.user-menu button.danger:hover { background: #fef2f2; }

/* --------- главная область --------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(12px); z-index: 30;
}
.topbar-title { flex: 1; font-weight: 700; font-size: .96rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.gw-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px;
  border-radius: 50px; background: var(--sky-50); border: 1px solid var(--line);
  font-size: .74rem; font-weight: 600; color: var(--text-600);
}
.gw-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-400); }
.gw-pill.on i { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }
.gw-pill.off i { background: #dc2626; box-shadow: 0 0 0 3px rgba(220, 38, 38, .16); }

/* --------- лента --------- */
.thread { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.msgs { max-width: 820px; margin: 0 auto; padding: 26px 20px 30px; }

.empty-state { max-width: 640px; margin: 0 auto; padding: 8vh 20px 20px; text-align: center; }
.es-logo { height: 92px; width: auto; margin: 0 auto 22px; animation: float 5s ease-in-out infinite; }

/*
 * Маскот на странице — page-mascot (MIT, © Kamran Ahmed)
 * https://koboyo.com/page-mascot · https://github.com/nilbuild/page-mascot
 * Спрайты: public/mascots/fox-*.webp
 */
.mascot {
  position: relative;
  display: block;
  width: 132px;
  height: 132px;
  margin: 0 auto 18px;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mascot-squash { position: relative; display: block; width: 100%; height: 100%; transform-origin: 50% 78%; }
.mascot-layer { position: absolute; inset: 0; background-size: 300% 300%; background-repeat: no-repeat; }
.mascot-dir { background-image: url('/mascots/fox-directions.webp'); }
.mascot-react { background-image: url('/mascots/fox-reactions.webp'); opacity: 0; }
@media (max-width: 640px) { .mascot { width: 108px; height: 108px; } }

/* питомец модели сидит над кнопкой «Отправить» */
.pet {
  position: absolute;
  right: 18px;
  bottom: calc(100% - 14px);
  width: 72px;
  height: 72px;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
  user-select: none;
  z-index: 3;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 6px 12px rgba(15, 23, 42, .14));
  transition: transform .15s ease;
}
.pet:hover { transform: translateY(-2px); }
.pet:active { transform: translateY(0) scale(.97); }
@media (max-width: 640px) { .pet { width: 58px; height: 58px; right: 12px; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.empty-state h2 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -.02em; }
.empty-state p { color: var(--text-600); margin-top: 8px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 30px; }
.sug {
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px;
  background: #fff; font-size: .88rem; color: var(--text-700); text-align: left;
  transition: var(--transition);
}
.sug:hover { border-color: var(--blue-500); box-shadow: var(--shadow-md); transform: translateY(-3px); }

/* --------- сообщения --------- */
.msg { display: flex; gap: 14px; margin-bottom: 26px; animation: fadeUp .28s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }
.msg .avatar { width: 34px; height: 34px; font-size: .82rem; }
.msg-avatar-img { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 1px solid var(--line); padding: 3px; }
.msg-body { flex: 1; min-width: 0; }
.msg-role { font-size: .76rem; font-weight: 700; color: var(--text-400); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.msg-meta {
  display: inline-block; margin: -2px 0 8px; padding: 3px 10px;
  border-radius: 8px; background: #fef3c7; color: #92400e;
  font-size: .72rem; font-weight: 600;
}
/* сообщение пользователя — справа, как в привычных чатах с нейронками */
.msg.user { justify-content: flex-end; }
.msg.user .avatar { display: none; }
.msg.user .msg-body {
  flex: 0 1 auto; max-width: 88%;
  display: flex; flex-direction: column; align-items: flex-end;
}
.msg.user .msg-body .text {
  background: var(--gradient); color: #fff; padding: 12px 16px;
  border-radius: 16px 4px 16px 16px; display: inline-block; max-width: 100%;
  white-space: pre-wrap; word-break: break-word; box-shadow: 0 6px 18px rgba(37, 99, 235, .22);
}
.msg.user .msg-imgs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.msg.user .msg-imgs img { max-height: 150px; border-radius: 12px; border: 2px solid #fff; box-shadow: var(--shadow-sm); }

/* блок рассуждений */
.reasoning {
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--sky-50), #fff);
  border-radius: 14px; margin-bottom: 12px; overflow: hidden;
}
.reasoning-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 14px; font-size: .82rem; font-weight: 600; color: var(--blue-700);
}
.reasoning-head .ico { width: 15px; height: 15px; }
.reasoning-head .rt { flex: 1; text-align: left; }
.reasoning-head .dur { color: var(--text-400); font-weight: 500; }
.reasoning-head .chev { transition: transform .25s; }
.reasoning.open .reasoning-head .chev { transform: rotate(180deg); }
.reasoning-body {
  display: none; padding: 0 16px 14px; font-size: .87rem; color: var(--text-600);
  white-space: pre-wrap; word-break: break-word; border-top: 1px dashed var(--line);
  padding-top: 12px; max-height: 380px; overflow-y: auto;
}
.reasoning.open .reasoning-body { display: block; }
.reasoning.thinking .reasoning-head { color: var(--blue-600); }
.thinking-anim { display: inline-flex; gap: 4px; align-items: center; }
.thinking-anim i { width: 6px; height: 6px; border-radius: 50%; background: var(--blue-500); animation: bounce 1.2s infinite; }
.thinking-anim i:nth-child(2) { animation-delay: .15s; }
.thinking-anim i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.msg-actions { display: flex; gap: 6px; margin-top: 8px; opacity: 0; transition: opacity .2s; }
.msg:hover .msg-actions { opacity: 1; }
.msg-actions button {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px;
  border-radius: 9px; font-size: .76rem; color: var(--text-600);
  border: 1px solid var(--line); background: #fff; transition: var(--transition);
}
.msg-actions button:hover { border-color: var(--blue-500); color: var(--blue-600); }
.msg-actions .ico { width: 13px; height: 13px; }

/* --------- markdown --------- */
.md p { margin: .5em 0; }
.md p:first-child { margin-top: 0; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.1em 0 .5em; line-height: 1.3; letter-spacing: -.01em; }
.md h1 { font-size: 1.5rem; } .md h2 { font-size: 1.3rem; } .md h3 { font-size: 1.14rem; } .md h4 { font-size: 1rem; }
.md ul, .md ol { margin: .6em 0; padding-left: 1.5em; }
.md li { margin: .28em 0; }
.md li.md-task { list-style: none; margin-left: -1.3em; }
.md li.md-task input { margin-right: 7px; accent-color: var(--blue-600); }
.md blockquote {
  margin: .8em 0; padding: 8px 16px; border-left: 3px solid var(--blue-500);
  background: var(--sky-50); border-radius: 0 12px 12px 0; color: var(--text-600);
}
.md hr { border: none; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md a { color: var(--blue-600); text-decoration: underline; text-underline-offset: 2px; }
.md img { margin: .6em 0; border-radius: 12px; }
.md mark { background: #fef08a; padding: 0 3px; border-radius: 4px; }
.md :not(pre) > code {
  background: var(--sky-100); color: var(--blue-800); padding: 2px 6px;
  border-radius: 6px; font-size: .87em; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.md-table-wrap { overflow-x: auto; margin: .9em 0; border: 1px solid var(--line); border-radius: 14px; }
.md table { border-collapse: collapse; width: 100%; font-size: .9rem; }
.md th, .md td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; }
.md thead th { background: var(--sky-50); font-weight: 700; color: var(--blue-800); white-space: nowrap; }
.md tbody tr:last-child td { border-bottom: none; }
.md tbody tr:hover { background: var(--ice-50); }

.md-code { margin: .9em 0; border-radius: 14px; overflow: hidden; border: 1px solid #1e293b; background: #0f172a; }
.md-code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; background: #1e293b; color: #94a3b8;
  font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
}
.md-copy { color: #cbd5e1; font-size: .74rem; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 3px 9px; border-radius: 7px; background: rgba(255, 255, 255, .08); transition: .2s; }
.md-copy:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.md-code pre { padding: 14px 16px; overflow-x: auto; }
.md-code code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .86rem; line-height: 1.6; color: #e2e8f0; white-space: pre; }
.tok-k { color: #7dd3fc; } .tok-s { color: #86efac; } .tok-c { color: #64748b; font-style: italic; } .tok-n { color: #fdba74; }

.cursor-blink::after {
  content: "▊"; color: var(--blue-500); animation: blink 1s steps(2) infinite; margin-left: 1px;
}
@keyframes blink { 50% { opacity: 0; } }

/* --------- composer --------- */
.composer-wrap { padding: 0 20px 12px; background: linear-gradient(180deg, transparent, #fff 30%); }
.composer {
  position: relative;
  max-width: 820px; margin: 0 auto; background: #fff;
  border: 1.5px solid var(--line); border-radius: 26px;
  box-shadow: var(--shadow-md); padding: 12px 14px 8px; transition: var(--transition);
}
.composer:focus-within { border-color: var(--blue-500); box-shadow: 0 10px 34px rgba(37, 99, 235, .18); }
.composer textarea {
  width: 100%; border: none; outline: none; resize: none; background: none;
  font-size: .98rem; line-height: 1.55; max-height: 220px; padding: 4px 6px 10px;
}
.composer textarea::placeholder { color: var(--text-400); }

.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cb-left { display: flex; align-items: center; gap: 8px; }

/* расход контекста */
.ctx-meter { display: inline-flex; align-items: center; gap: 7px; font-size: .72rem; color: var(--text-600); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ctx-bar { display: inline-block; width: 48px; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.ctx-bar i { display: block; height: 100%; width: 0; background: #16a34a; transition: width .25s ease, background .2s ease; }
.ctx-meter.warn .ctx-bar i { background: #f59e0b; }
.ctx-meter.crit .ctx-bar i { background: #dc2626; }
.ctx-meter.crit .ctx-text { color: #dc2626; }
.cb-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 50px; border: 1.5px solid var(--line);
  background: #fff; font-size: .82rem; font-weight: 600; color: var(--text-600);
  transition: var(--transition);
}
.chip .ico { width: 15px; height: 15px; }
.chip:hover:not(:disabled) { border-color: var(--blue-500); color: var(--blue-600); transform: translateY(-1px); }
.chip:disabled { opacity: .45; cursor: not-allowed; background: var(--ice-50); }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-400); transition: .2s; }
.chip.on { background: var(--gradient); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .3); }
.chip.on .chip-dot { background: #bbf7d0; box-shadow: 0 0 0 3px rgba(187, 247, 208, .35); }
.chip:disabled .chip-dot { display: none; }

/* ползунок уровня рассуждений */
.effort {
  display: flex; align-items: center; gap: 14px; padding: 8px 16px;
  border: 1.5px solid var(--line); border-radius: 50px; background: var(--ice-50);
  animation: pop .18s ease; transition: var(--transition);
}
.effort:hover { border-color: var(--sky-400); }
.effort-inner { display: flex; flex-direction: column; gap: 11px; width: 152px; }

.effort input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  background: linear-gradient(90deg, var(--blue-600) var(--p, 50%), #dbe6fb var(--p, 50%));
  border-radius: 50px; outline: none; cursor: pointer; margin: 0;
}
.effort input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; border: 3.5px solid var(--blue-600); cursor: grab;
  box-shadow: 0 1px 4px rgba(37, 99, 235, .3); transition: transform .15s;
}
.effort input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
.effort input[type="range"]::-webkit-slider-thumb:active { transform: scale(1.2); cursor: grabbing; }
.effort input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
  border: 3.5px solid var(--blue-600); cursor: grab; box-shadow: 0 1px 4px rgba(37, 99, 235, .3);
}

/* шкала под дорожкой: точки не пересекаются с бегунком */
.effort-ticks { display: flex; justify-content: space-between; padding: 0 5px; height: 5px; }
.effort-ticks i {
  width: 5px; height: 5px; border-radius: 50%; background: #cfd9e9;
  cursor: pointer; transition: .18s; display: block;
}
.effort-ticks i.done { background: #9dc4f0; }
.effort-ticks i.active { background: var(--blue-600); transform: scale(1.35); }
.effort-ticks i:hover { background: var(--blue-500); }

.effort-value {
  font-size: .78rem; font-weight: 800; color: var(--blue-700);
  min-width: 86px; text-align: right; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

/* переключалка модели */
.model-pick { position: relative; }
.model-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px;
  border-radius: 50px; border: 1.5px solid var(--line); background: var(--sky-50);
  font-size: .82rem; font-weight: 700; color: var(--blue-700); transition: var(--transition);
  max-width: 240px;
}
.model-btn:hover { border-color: var(--blue-500); box-shadow: var(--shadow-sm); }
.model-btn .ico { width: 14px; height: 14px; transition: transform .2s; }
.model-pick.open .model-btn .ico { transform: rotate(180deg); }
.model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.model-menu {
  position: absolute; bottom: calc(100% + 10px); right: 0; width: 340px; max-height: 60vh;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: var(--shadow-lg); overflow: hidden; z-index: 50;
  display: flex; flex-direction: column; animation: pop .16s ease;
}
.model-search {
  display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  border-bottom: 1px solid var(--line); color: var(--text-400);
}
.model-search input { border: none; outline: none; background: none; width: 100%; font-size: .88rem; }
.model-filters { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.model-filters select {
  flex: 1; padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--ice-50); font-size: .78rem; font-weight: 600; color: var(--text-700);
  outline: none; cursor: pointer;
}
.model-filters select:focus { border-color: var(--blue-500); background: #fff; }
.mo-logo {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 5px; object-fit: contain;
  color: var(--blue-700);
}
.mo-logo.mono {
  display: flex; align-items: center; justify-content: center;
  background: var(--sky-100); color: var(--blue-700); font-size: .62rem; font-weight: 800;
}
.model-list { overflow-y: auto; padding: 6px; }
.model-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  border-radius: 12px; text-align: left; transition: var(--transition);
}
.model-opt:hover { background: var(--sky-50); }
.model-opt.active { background: linear-gradient(120deg, rgba(29, 78, 216, .1), rgba(56, 189, 248, .12)); }
.model-opt .mo-main { flex: 1; min-width: 0; }
.model-opt .mo-main b { display: block; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-opt .mo-main span { font-size: .73rem; color: var(--text-400); }
.model-opt .mo-flags { display: flex; gap: 5px; }
.flag {
  font-size: .62rem; font-weight: 700; padding: 3px 7px; border-radius: 6px;
  text-transform: uppercase; letter-spacing: .04em;
}
.flag.v { background: #dcfce7; color: #15803d; }
.flag.r { background: #dbeafe; color: #1d4ed8; }
.flag.t { background: #fef3c7; color: #b45309; }
.flag.n { background: #fce7f3; color: #be185d; }
.flag.price { background: #f1f5f9; color: #475569; font-variant-numeric: tabular-nums; }
.flag.pause { background: #fee2e2; color: #b91c1c; }
.tier {
  width: 24px; height: 24px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800;
}
.tier-A { background: #dcfce7; color: #15803d; }
.tier-B { background: #dbeafe; color: #1d4ed8; }
.tier-C { background: #fef3c7; color: #b45309; }
.tier-U { background: #ffe4f0; color: #be126b; }
.tier-S { background: #ede9fe; color: #6d28d9; }
.keyval {
  font-family: ui-monospace, Consolas, monospace; font-size: .78rem;
  background: var(--sky-50); border: 1px solid var(--line); border-radius: 8px;
  padding: 3px 8px; user-select: all;
}
.model-opt.cooling { opacity: .55; }
.model-opt.cooling .mo-main b { text-decoration: line-through; text-decoration-color: rgba(185, 28, 28, .5); }
.model-opt .mo-check { color: var(--blue-600); opacity: 0; }
.model-opt.active .mo-check { opacity: 1; }
.model-opt .mo-check .ico { width: 16px; height: 16px; }
.model-empty { padding: 22px; text-align: center; color: var(--text-400); font-size: .85rem; }

.send {
  width: 40px; height: 40px; border-radius: 50%; background: var(--gradient);
  color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(37, 99, 235, .35); transition: var(--transition); flex-shrink: 0;
}
.send:hover:not(:disabled) { transform: translateY(-2px) scale(1.05); box-shadow: 0 10px 24px rgba(37, 99, 235, .5); }
.send:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
.send .ico { width: 19px; height: 19px; }
.send.busy { background: #ef4444; box-shadow: 0 6px 18px rgba(239, 68, 68, .4); }

.disclaimer { text-align: center; font-size: .72rem; color: var(--text-400); margin-top: 9px; }

.attach-strip { max-width: 820px; margin: 0 auto 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.attach-thumb { position: relative; }
.attach-thumb img { height: 64px; border-radius: 12px; border: 1.5px solid var(--line); }
.attach-thumb button {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  background: #ef4444; color: #fff; display: flex; align-items: center; justify-content: center;
}
.attach-thumb button .ico { width: 11px; height: 11px; }

/* ============ Модалки ============ */
.modal-root { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal {
  position: relative; background: #fff; border-radius: 22px; box-shadow: var(--shadow-lg);
  width: min(760px, 100%); max-height: 88vh; overflow-y: auto; animation: pop .2s ease;
}
.modal.wide { width: min(1040px, 100%); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 22px 26px 14px; position: sticky; top: 0; background: #fff; z-index: 2;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 1.2rem; font-weight: 800; letter-spacing: -.01em; }
.modal-body { padding: 22px 26px 26px; }

.tabs { display: flex; gap: 6px; padding: 0 26px; border-bottom: 1px solid var(--line); background: #fff; position: sticky; top: 61px; z-index: 2; }
.tab { padding: 11px 16px; font-size: .88rem; font-weight: 600; color: var(--text-600); border-bottom: 2.5px solid transparent; transition: .2s; }
.tab:hover { color: var(--blue-600); }
.tab.active { color: var(--blue-700); border-color: var(--blue-600); }

/* переключатели */
.switch-row {
  display: flex; align-items: flex-start; gap: 14px; padding: 16px;
  border: 1px solid var(--line); border-radius: 16px; margin-bottom: 14px; background: var(--ice-50);
}
.switch-row .sr-text { flex: 1; }
.switch-row b { display: block; font-size: .93rem; margin-bottom: 3px; }
.switch-row p { font-size: .82rem; color: var(--text-600); }
.switch {
  position: relative; width: 46px; height: 26px; border-radius: 50px; flex-shrink: 0;
  background: #cbd5e1; transition: .25s; margin-top: 2px;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; transition: .25s; box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
}
.switch.on { background: var(--gradient); }
.switch.on::after { transform: translateX(20px); }

/* статистика */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--ice-50); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat-card .sc-num { font-size: 1.7rem; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; line-height: 1.2; }
.stat-card .sc-label { font-size: .78rem; color: var(--text-600); }

.chart-box { background: var(--ice-50); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 18px; }
.chart-box h4 { font-size: .92rem; font-weight: 700; margin-bottom: 14px; color: var(--blue-900); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%; max-width: 34px; background: var(--gradient); border-radius: 6px 6px 3px 3px;
  min-height: 3px; transition: height .6s cubic-bezier(.4, 0, .2, 1); position: relative;
}
.bar:hover { filter: brightness(1.15); }
.bar-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--blue-900); color: #fff; font-size: .68rem; padding: 4px 8px; border-radius: 7px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: .2s; z-index: 3;
}
.bar:hover .bar-tip { opacity: 1; }
.bar-lbl { font-size: .62rem; color: var(--text-400); }

.hbar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; }
.hbar-name { width: 190px; font-size: .8rem; color: var(--text-700); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { flex: 1; height: 22px; background: #e8eefb; border-radius: 11px; overflow: hidden; }
.hbar-fill { height: 100%; background: var(--gradient); border-radius: 11px; transition: width .7s cubic-bezier(.4, 0, .2, 1); }
.hbar-val { width: 62px; font-size: .78rem; font-weight: 700; color: var(--blue-700); text-align: right; }

/* таблицы в админке/настройках */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.tbl th { background: var(--sky-50); text-align: left; padding: 10px 13px; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--blue-800); white-space: nowrap; }
table.tbl td { padding: 10px 13px; border-top: 1px solid var(--line); vertical-align: top; }
table.tbl tr:hover td { background: var(--ice-50); }
table.tbl tr.feat td { background: #f0f7ee; }
table.tbl tr[data-drag] { cursor: grab; }
table.tbl tr.dragging td { background: #eef4ff; opacity: .6; }
table.tbl tr.drop-target td { box-shadow: inset 0 2px 0 #3b82f6; }

/* панель фич модели в админке */
.model-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; padding: 16px 18px; background: var(--sky-50); }
.model-panel .bl { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--blue-800); margin-bottom: 8px; font-weight: 700; }
.model-panel .mp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.model-panel .mp-row select, .model-panel .mp-row input { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; font-size: .8rem; }
.model-panel .mp-row input[data-price] { width: 84px; }
.model-panel-row > td { padding: 0 !important; border-top: 0 !important; }

/* переключатель-тумблер */
.msw { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: .84rem; padding: 4px 0; user-select: none; }
.msw input { position: absolute; opacity: 0; pointer-events: none; }
.msw-track { width: 36px; height: 20px; border-radius: 20px; background: #cbd5e1; display: inline-flex; align-items: center; padding: 2px; transition: background .15s ease; flex: none; }
.msw-knob { width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s ease; box-shadow: 0 1px 2px rgba(15, 23, 42, .2); }
.msw input:checked + .msw-track { background: #16a34a; }
.msw input:checked + .msw-track .msw-knob { transform: translateX(16px); }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 7px; font-size: .7rem; font-weight: 700; }
.badge.admin { background: #ede9fe; color: #6d28d9; }
.badge.user { background: var(--sky-100); color: var(--blue-700); }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.err { background: #fee2e2; color: #b91c1c; }
.badge.yes { background: #dcfce7; color: #15803d; }
.badge.no { background: #f1f5f9; color: #64748b; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type="search"] {
  flex: 1; min-width: 180px; padding: 10px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; outline: none; background: var(--ice-50); font-size: .88rem;
}
.toolbar input[type="search"]:focus { border-color: var(--blue-500); background: #fff; }

.log-item { border: 1px solid var(--line); border-radius: 14px; padding: 13px 15px; margin-bottom: 10px; background: #fff; }
.log-item:hover { border-color: var(--blue-500); box-shadow: var(--shadow-sm); }
.log-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .76rem; color: var(--text-400); margin-bottom: 7px; }
.log-head b { color: var(--text-900); font-size: .84rem; }
.log-prompt { font-size: .87rem; color: var(--text-700); white-space: pre-wrap; word-break: break-word; max-height: 66px; overflow: hidden; }
.log-more { font-size: .76rem; color: var(--blue-600); font-weight: 600; margin-top: 5px; }
.log-more:hover { text-decoration: underline; }

.empty-box { text-align: center; color: var(--text-400); padding: 34px 16px; font-size: .9rem; }

/* ============ консоль: одно окно, секции меняются внутри ============ */
.console-root { position: fixed; inset: 0; z-index: 150; background: #fff; }
.console { display: flex; height: 100%; }
.console-side {
  width: 236px; flex: none; border-right: 1px solid var(--line); padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px; background: var(--ice-50); overflow-y: auto;
}
.console-brand { display: flex; align-items: center; gap: 8px; padding: 6px 10px 14px; font-weight: 800; letter-spacing: -.02em; }
.console-brand img { height: 22px; width: auto; }
.console-brand .tag { font-size: .68rem; font-weight: 700; color: var(--text-400); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.console-nav {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0;
  background: none; border-radius: 12px; font: inherit; font-size: .86rem; font-weight: 600;
  color: var(--text-700); cursor: pointer; text-align: left;
}
.console-nav:hover { background: #fff; }
.console-nav.active { background: #fff; color: var(--blue-900); box-shadow: var(--shadow-sm); }
.console-nav .ico { width: 16px; height: 16px; color: currentColor; }
.console-sep { height: 1px; background: var(--line); margin: 10px 10px; }
.console-foot { margin-top: auto; padding-top: 12px; }
.console-user { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); font-size: .84rem; font-weight: 700; }
.console-user .avatar { width: 28px; height: 28px; font-size: .8rem; }
.console-main { flex: 1; min-width: 0; padding: 26px 34px 44px; overflow-y: auto; animation: fade .18s ease; }
@keyframes fade { from { opacity: .4 } to { opacity: 1 } }
.console-main > h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 6px; }
@media (max-width: 820px) {
  .console { flex-direction: column; }
  .console-side { width: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .console-brand { width: 100%; }
  .console-main { padding: 20px; }
}

/* ============ страница «Биллинг» (каркас как в консоли) ============ */
.modal.full { width: 100vw; height: 100vh; max-height: none; border-radius: 0; }
.bill { display: flex; min-height: 100%; background: #fff; }
.bill-side {
  width: 232px; flex: none; border-right: 1px solid var(--line); padding: 16px 10px;
  display: flex; flex-direction: column; gap: 2px; background: var(--ice-50);
}
.bill-brand { display: flex; align-items: center; gap: 8px; padding: 6px 10px 16px; font-weight: 800; letter-spacing: -.02em; }
.bill-brand img { height: 22px; width: auto; }
.bill-brand .tag { font-size: .68rem; font-weight: 700; color: var(--text-400); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.bill-nav { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: 12px; font: inherit; font-size: .86rem; font-weight: 600; color: var(--text-700); cursor: pointer; text-align: left; }
.bill-nav:hover { background: #fff; }
.bill-nav.active { background: #fff; color: var(--blue-900); box-shadow: var(--shadow-sm); }
.bill-nav .ico { width: 16px; height: 16px; color: currentColor; }
.bill-side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.bill-user { display: flex; align-items: center; gap: 10px; padding: 12px 10px 4px; margin-top: 10px; border-top: 1px solid var(--line); font-size: .84rem; font-weight: 700; }
.bill-user .avatar { width: 28px; height: 28px; font-size: .8rem; }
.bill-main { flex: 1; min-width: 0; padding: 26px 34px 40px; overflow-y: auto; }
.bill-main h1 { font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; }
.bill-sub { color: var(--text-600); font-size: .82rem; margin-top: 8px; }
.bill-notice {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--sky-50); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; margin: 20px 0; font-size: .84rem; color: var(--blue-900); line-height: 1.5;
}
.bill-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.bill-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.bill-card .bl { display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; color: var(--text-600); }
.bill-card .bv { font-size: 2rem; font-weight: 800; margin-top: 10px; letter-spacing: -.02em; }
.bill-card .bv small { font-size: .78rem; font-weight: 600; color: var(--text-400); margin-left: 6px; }
.bill-card .brow { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.bill-sep { border-top: 1px solid var(--line); margin: 24px 0; }
.bill-filters { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 999px; padding: 9px 15px; background: var(--ice-50);
  font-size: .82rem; font-weight: 600; color: var(--text-700);
}
button.pill { cursor: pointer; font-family: inherit; }
button.pill:hover { background: #fff; }
.pill .k { color: var(--text-400); font-weight: 600; }
.pill select { border: 0; background: none; font: inherit; font-weight: 700; color: var(--text-900); outline: none; cursor: pointer; }
.bill-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.bill-chart { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px 10px; }
.bill-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.bill-chart-head b { font-size: .95rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--ice-50); }
.seg button { border: 0; background: none; font: inherit; font-size: .76rem; font-weight: 600; color: var(--text-600); padding: 6px 14px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--blue-900); }
.bill-chart svg { width: 100%; height: 260px; display: block; }
.bill-chart .empty-box { padding-top: 0; }
@media (max-width: 820px) {
  .bill { flex-direction: column; }
  .bill-side { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .bill-cards, .bill-metrics { grid-template-columns: 1fr; }
  .bill-main { padding: 20px; }
}
.modal-note { font-size: .8rem; color: var(--text-600); background: var(--sky-50); border: 1px solid var(--line); padding: 11px 14px; border-radius: 12px; margin-bottom: 16px; }

/* ============ Тосты ============ */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 500; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--blue-900); color: #fff; padding: 11px 20px; border-radius: 50px;
  font-size: .86rem; font-weight: 500; box-shadow: var(--shadow-lg); animation: toastIn .25s ease;
  max-width: 90vw;
}
.toast.err { background: #b91c1c; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px); } }

/* ============ Скроллбар ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: content-box; }

/* ============ Адаптив ============ */
@media (max-width: 900px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; box-shadow: var(--shadow-lg); }
  .app.sb-closed .sidebar { margin-left: calc(var(--sidebar-w) * -1 - 20px); }
  .suggestions { grid-template-columns: 1fr; }
  .composer-bar { gap: 8px; }
  .effort-inner { width: 104px; }
  .chip-label { display: none; }
  .chip { padding: 9px 11px; }
  .model-btn { max-width: 140px; }
  .send { width: 44px; height: 44px; }
}
@media (max-width: 560px) {
  .composer-wrap { padding: 0 10px 8px; }
  .msgs { padding: 18px 10px 24px; }
  .modal-head, .modal-body, .tabs { padding-left: 16px; padding-right: 16px; }
  .tabs { top: 57px; overflow-x: auto; }
  .hbar-name { width: 110px; }
  .msg { gap: 8px; margin-bottom: 18px; }

  /* ползунок рассуждений — отдельной строкой над кнопками, другим не мешает */
  .composer-bar { flex-wrap: wrap; row-gap: 8px; align-items: center; }
  .effort { order: -1; flex-basis: 100%; justify-content: space-between; }
  .effort-inner { flex: 1; width: auto; }
  .effort-value { min-width: 0; text-align: right; }

  /* меню моделей — как шторка снизу, чтобы не улетало за экран */
  .model-menu {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: auto; max-height: 70vh; border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -10px 40px rgba(15, 23, 42, .25);
  }
  .model-list { max-height: 46vh; }
  .model-opt .mo-flags { display: none; }
  .model-btn { max-width: 118px; }
  .composer { border-radius: 20px; padding: 10px 12px 6px; }
}

/* iOS не должен зумить страницу при фокусе на поле */
@media (max-width: 900px) {
  .composer textarea,
  .field input,
  .sb-search input,
  .model-search input,
  .toolbar input,
  .model-filters select { font-size: 16px; }
}

/* Code, math and small screens must scroll within the message, not the page. */
.app, .main, .thread, .msgs, .msg, .msg-body { min-width: 0; }
.app { height: 100dvh; }
.sidebar-backdrop, .sidebar-close { display: none; }
@media (max-width: 900px) {
  .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .4); }
  .sidebar { z-index: 100; }
  .app.sb-closed .sidebar-backdrop { display: none; }
  .sidebar-close { display: flex; position: absolute; top: 16px; right: 12px; }
}
.md { overflow-wrap: anywhere; }
.md-code, .md-table-wrap, .md-math { max-width: 100%; }
.md-code pre { margin: 0; tab-size: 4; overflow-wrap: normal; word-break: normal; }
.md-code code { display: block; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal { color: #c4b5fd; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #86efac; }
.hljs-comment, .hljs-quote { color: #94a3b8; font-style: italic; }
.hljs-number, .hljs-attr, .hljs-variable, .hljs-template-variable { color: #fdba74; }
.hljs-title, .hljs-built_in, .hljs-type { color: #7dd3fc; }
.hljs-meta, .hljs-symbol, .hljs-bullet { color: #f9a8d4; }
.hljs-tag, .hljs-name, .hljs-deletion { color: #fca5a5; }
.md-math { overflow-x: auto; overflow-y: hidden; padding: .25rem 0; }
.md .katex { font-size: 1.12em; overflow-wrap: normal; }
.md .katex-display { margin: .85em 0; }
.md .katex-display > .katex { text-align: left; }
.math-error { white-space: pre-wrap; }
.md-code:focus-within { outline: 2px solid var(--sky-400); outline-offset: 2px; }
button:focus-visible, a:focus-visible, pre:focus-visible { outline: 2px solid var(--blue-500); outline-offset: 3px; }
@media (hover: none) { .msg-actions { opacity: 1; } }
@media (max-width: 560px) {
  .md-code-head { gap: 12px; }
  .md-code pre { padding: 12px; }
  .modal-root { padding: 10px; }
  .modal { max-height: 92dvh; }
  .cb-left, .cb-right { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
