/* ==========================================================================
   Blackbird AI — дизайн-система
   Без inline-стилей и внешних CDN: страница работает под строгим CSP.
   ========================================================================== */

/* ---------- шрифты (self-hosted, OFL) ---------- */
@font-face {
  font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/onest-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/onest-latin-ext-wght-normal.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Onest"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(../fonts/onest-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-display: swap; font-weight: 100 800;
  src: url(../fonts/jetbrains-mono-cyrillic-wght-normal.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono"; font-style: normal; font-display: swap; font-weight: 100 800;
  src: url(../fonts/jetbrains-mono-latin-wght-normal.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- токены ---------- */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0b0e;
  --bg-2: #101014;
  --surface: #15151a;
  --surface-2: #1b1b21;
  --surface-3: #232329;
  --border: #25252c;
  --border-strong: #34343d;
  --text: #ededf1;
  --text-2: #a3a3ad;
  --text-3: #6c6c77;
  --accent: #9486ff;
  --accent-strong: #6e5ceb;
  --accent-hover: #7b6af2;
  --accent-soft: rgba(148, 134, 255, .12);
  --accent-line: rgba(148, 134, 255, .35);
  --on-accent: #ffffff;
  --ok: #3ccf8e;       --ok-soft: rgba(60, 207, 142, .12);
  --warn: #f3b44b;     --warn-soft: rgba(243, 180, 75, .12);
  --err: #f4616a;      --err-soft: rgba(244, 97, 106, .12);
  --info: #6fb2ff;     --info-soft: rgba(111, 178, 255, .12);
  --user-bubble: #1f1d33;
  --code-bg: #0e0e12;
  --overlay: rgba(5, 5, 8, .72);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 20px 50px -12px rgba(0, 0, 0, .6), 0 0 0 1px var(--border);
  --glow: radial-gradient(60% 60% at 50% 0%, rgba(148, 134, 255, .18), transparent 70%);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #fafafb;
  --bg-2: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #f4f4f7;
  --surface-3: #ebebf0;
  --border: #e4e4ea;
  --border-strong: #d2d2da;
  --text: #121216;
  --text-2: #55555f;
  --text-3: #8b8b95;
  --accent: #5a46dc;
  --accent-strong: #5a46dc;
  --accent-hover: #4c39cc;
  --accent-soft: rgba(90, 70, 220, .08);
  --accent-line: rgba(90, 70, 220, .3);
  --on-accent: #ffffff;
  --ok: #148a57;       --ok-soft: rgba(20, 138, 87, .09);
  --warn: #a86a00;     --warn-soft: rgba(200, 130, 0, .1);
  --err: #d2323c;      --err-soft: rgba(210, 50, 60, .08);
  --info: #1f6fd1;     --info-soft: rgba(31, 111, 209, .08);
  --user-bubble: #efedff;
  --code-bg: #f6f6f9;
  --overlay: rgba(20, 20, 30, .4);
  --shadow-sm: 0 1px 2px rgba(20, 20, 40, .06);
  --shadow: 0 20px 50px -12px rgba(20, 20, 40, .18), 0 0 0 1px var(--border);
  --glow: radial-gradient(60% 60% at 50% 0%, rgba(90, 70, 220, .10), transparent 70%);
}
:root {
  --font: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-xs: 6px;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --side-w: 252px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- база ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}
::selection { background: var(--accent-soft); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, svg, video { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }

h1, h2, h3, h4, h5, h6 { margin: 0 0 .5em; line-height: 1.2; font-weight: 650; letter-spacing: -.02em; }
h1 { font-size: 2.2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.08rem; letter-spacing: -.01em; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- утилиты ---------- */
.container { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }
.narrow { width: min(780px, calc(100% - 40px)); margin: 0 auto; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: .86rem; }
.xs { font-size: .76rem; }
.amount { font-size: 1.75rem; font-weight: 700; letter-spacing: -.035em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .84em; }
code, pre, .mono, .copybox, .otp { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.center { text-align: center; }
.right { text-align: right; }
.strong { font-weight: 600; }
.ok-text { color: var(--ok); }
.err-text { color: var(--err); }
.warn-text { color: var(--warn); }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.row.bottom { align-items: flex-end; }
.row.tight { gap: 6px; }
.row.end { justify-content: flex-end; }
.row.centered { justify-content: center; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.shrink-0 { flex-shrink: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.stack.loose { gap: 20px; }

.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-5 { margin-top: 24px; } .mt-6 { margin-top: 32px; }
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 24px; }
.w-120 { width: 120px; } .w-160 { width: 160px; } .w-200 { width: 200px; } .maxw-220 { max-width: 220px; }
.minw-160 { min-width: 160px; }

.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.gap-sm { gap: 10px; }
.grid > *, .integr > *, .calc > *, .demo-body > *, .tickets > *, .plans > * { min-width: 0; }

/* ---------- иконки ---------- */
.i { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i.sm { width: 15px; height: 15px; vertical-align: -2px; }
.i.lg { width: 22px; height: 22px; }

/* ---------- логотип ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.03em; color: var(--text); font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand .mark { width: 30px; height: 30px; flex-shrink: 0; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(145deg, #2b2640, #0d0c14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09); }
:root[data-theme="light"] .brand .mark { background: linear-gradient(145deg, #1d1a2c, #0d0c14); }
.brand .mark svg { width: 20px; height: 20px; }
.brand .tag { font-size: .66rem; font-weight: 600; letter-spacing: .02em; padding: 2px 6px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 15px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; font-weight: 550;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, color .15s, transform .08s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); text-decoration: none; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 6px 18px -8px var(--accent-strong); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.outline { background: transparent; }
.btn.danger { color: var(--err); border-color: var(--err-soft); background: var(--err-soft); }
.btn.danger:hover:not(:disabled) { border-color: var(--err); background: var(--err-soft); }
.btn.sm { height: 32px; padding: 0 11px; font-size: .84rem; border-radius: 7px; }
.btn.lg { height: 46px; padding: 0 22px; font-size: .98rem; border-radius: var(--r); }
.btn.block { width: 100%; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-2) transparent var(--text-2) transparent; animation: spin .8s linear infinite; }
.btn.primary.loading::after { border-color: #fff transparent #fff transparent; }

.icon-btn { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: 6px; }
.icon-btn.bordered { border-color: var(--border-strong); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- формы ---------- */
label { display: block; font-size: .84rem; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 12px; min-height: 38px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--bg-2); color: var(--text);
  font: inherit; font-size: .92rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; margin: 2px 0 0; padding: 0; accent-color: var(--accent-strong); flex-shrink: 0; box-shadow: none; }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .8rem; color: var(--text-3); margin-top: 5px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; color: var(--text-2); cursor: pointer; margin: 0; font-weight: 450; }
fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: 16px; margin: 0 0 14px; min-width: 0; }
legend { padding: 0 6px; color: var(--text-2); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.input-group { display: flex; align-items: stretch; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .suffix { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); border-left: 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0; color: var(--text-2); background: var(--surface-2); font-size: .9rem; }

/* переключатель */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; color: var(--text); font-size: .9rem; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 38px; height: 22px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background .2s, border-color .2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--accent-strong); border-color: var(--accent-strong); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* сегментированный выбор */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.segmented button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: .84rem; font-weight: 550; padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; margin-bottom: 16px; }
.card.tight { padding: 14px 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flat { background: transparent; }
.card > h3:first-child, .card-head h3 { margin-bottom: 4px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head p { margin: 0; }
.card.flush .card-head { padding: 18px 20px 0; }
.card-section { padding-top: 16px; margin-top: 16px; border-top: 1px solid var(--border); }
.card.warn { border-color: rgba(243, 180, 75, .35); background: var(--warn-soft); }
.card.accent { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), transparent 70%), var(--surface); }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; position: relative; overflow: hidden; }
.stat .label { color: var(--text-2); font-size: .82rem; display: flex; align-items: center; gap: 7px; }
.stat .label .i { color: var(--text-3); }
.stat .value { font-size: 1.6rem; font-weight: 650; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .hint { color: var(--text-3); font-size: .8rem; margin-top: 4px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; height: 22px; border-radius: 99px; font-size: .74rem; font-weight: 550;
  border: 1px solid var(--border); color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: transparent; background: var(--ok-soft); }
.badge.warn { color: var(--warn); border-color: transparent; background: var(--warn-soft); }
.badge.err { color: var(--err); border-color: transparent; background: var(--err-soft); }
.badge.info { color: var(--accent); border-color: transparent; background: var(--accent-soft); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.count { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--accent-strong); color: #fff; font-size: .7rem; font-weight: 700; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.empty .i { width: 34px; height: 34px; color: var(--text-3); stroke-width: 1.5; margin-bottom: 10px; }
.empty h3 { color: var(--text); }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--r-sm); height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.card.flush .table-wrap { margin: 0; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-3); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--bg-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
td .sub { font-size: .78rem; color: var(--text-3); }
.card.flush th:first-child, .card.flush td:first-child { padding-left: 20px; }
.card.flush th:last-child, .card.flush td:last-child { padding-right: 20px; }

/* ---------- прогресс ---------- */
.progress { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent-strong); border-radius: 99px; transition: width .4s var(--ease); }
.progress.warn > div { background: var(--warn); }
.progress.err > div { background: var(--err); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: .9rem; margin: 0 0 18px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- код ---------- */
.code { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.code .code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--border); font-size: .76rem; color: var(--text-3); font-family: var(--mono); }
.code pre { margin: 0; padding: 14px; overflow-x: auto; font-family: var(--mono); font-size: .82rem; line-height: 1.6; color: var(--text); }
.copybox { display: flex; gap: 8px; align-items: center; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 8px 8px 8px 12px; font-family: var(--mono); font-size: .82rem; overflow-x: auto; word-break: break-all; }
.copybox > span { flex: 1; min-width: 0; }

/* ---------- тосты ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: var(--surface); color: var(--text);
  border-radius: var(--r); padding: 11px 14px; max-width: 380px; box-shadow: var(--shadow); font-size: .88rem; animation: toast-in .25s var(--ease); }
.toast .i { margin-top: 1px; color: var(--accent); }
.toast.err .i { color: var(--err); }
.toast.ok .i { color: var(--ok); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- модалки ---------- */
.modal-back { position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px); z-index: 200;
  display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--r-xl); width: min(480px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: var(--shadow); animation: pop .2s var(--ease); }
.modal.wide { width: min(860px, 100%); }
.modal .modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 4px; }
.modal .modal-head h3 { margin: 0; font-size: 1.12rem; padding-top: 4px; overflow-wrap: anywhere; }
.modal .modal-body { padding: 12px 22px 8px; overflow-y: auto; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 20px; flex-wrap: wrap; }
.modal .modal-foot:empty { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.otp { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .5em; text-align: center; height: 52px; }
.tg-wait { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2); font-size: .86rem; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; flex-shrink: 0; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-line); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- табы ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-2); padding: 10px 14px; margin-bottom: -1px; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 550; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

/* ==========================================================================
   ЛЕНДИНГ
   ========================================================================== */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid transparent; transition: border-color .2s; }
.site-header.scrolled { border-bottom-color: var(--border); }
.site-header .inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.site-nav { display: flex; gap: 2px; align-items: center; margin-left: 12px; }
.site-nav a { color: var(--text-2); padding: 7px 12px; border-radius: 8px; font-size: .9rem; font-weight: 500; }
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.site-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.menu-toggle { display: none; }

.hero { position: relative; padding: 84px 0 56px; text-align: center; overflow: hidden; }
.hero::before { content: ""; position: absolute; inset: -40px 0 auto; height: 520px; background: var(--glow); pointer-events: none; }
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(70% 60% at 50% 0%, #000 20%, transparent 70%); -webkit-mask-image: radial-gradient(70% 60% at 50% 0%, #000 20%, transparent 70%); }
.hero > * { position: relative; z-index: 1; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 99px; border: 1px solid var(--border-strong); background: var(--surface); font-size: .82rem; color: var(--text-2); margin-bottom: 22px; }
.eyebrow .badge { height: 20px; }
.hero h1 { font-size: clamp(2.2rem, 5.6vw, 3.7rem); line-height: 1.04; letter-spacing: -.045em; max-width: 880px; margin: 0 auto 20px; font-weight: 700; }
.hero h1 .hl { color: var(--accent); }
.hero .lead { font-size: clamp(1rem, 1.6vw, 1.14rem); color: var(--text-2); max-width: 620px; margin: 0 auto 30px; }
.hero .cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hero .trust { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; margin-top: 26px; color: var(--text-3); font-size: .84rem; }
.hero .trust span { display: inline-flex; align-items: center; gap: 7px; }
.hero .trust .i { color: var(--ok); }

/* демо-окно в hero */
.demo { max-width: 920px; margin: 56px auto 0; text-align: left; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.demo .demo-bar { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.demo .dots { display: flex; gap: 6px; }
.demo .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-3); }
.demo .demo-title { margin: 0 auto; font-size: .8rem; color: var(--text-3); font-family: var(--mono); }
.demo .demo-body { display: grid; grid-template-columns: 1.15fr 1fr; }
.demo .demo-chat { padding: 22px; display: flex; flex-direction: column; gap: 14px; border-right: 1px solid var(--border); }
.demo .demo-code { padding: 0; background: var(--code-bg); }
.demo .demo-code pre { margin: 0; padding: 20px; font-family: var(--mono); font-size: .78rem; line-height: 1.7; color: var(--text-2); overflow-x: auto; }
.demo .tok-k { color: var(--accent); } .demo .tok-s { color: var(--ok); } .demo .tok-c { color: var(--text-3); }
.demo .bubble-u { align-self: flex-end; background: var(--user-bubble); padding: 10px 14px; border-radius: 14px 14px 4px 14px; font-size: .88rem; max-width: 85%; }
.demo .bubble-a { font-size: .88rem; color: var(--text); }
.demo .bubble-a .meta { color: var(--text-3); font-size: .74rem; margin-top: 8px; display: flex; gap: 8px; align-items: center; }
.demo .demo-snippet { margin-top: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--code-bg); border: 1px solid var(--border); font-family: var(--mono); font-size: .76rem; line-height: 1.65; white-space: pre; overflow-x: auto; color: var(--text-2); }
.demo .model-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--text-2); padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 6px; font-family: var(--mono); }

.section { padding: 76px 0 8px; }
.section-head { max-width: 640px; margin-bottom: 32px; }
.section-head.center { margin-left: auto; margin-right: auto; text-align: center; }
.section-head .kicker { color: var(--accent); font-size: .8rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.section-head h2 { font-size: clamp(1.6rem, 3.2vw, 2.25rem); letter-spacing: -.035em; margin-bottom: 12px; }
.section-head p { color: var(--text-2); font-size: 1.02rem; margin: 0; }

.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden; }
.feature { background: var(--surface); padding: 26px; }
.feature .ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 16px; }
.feature h3 { margin-bottom: 6px; }
.feature p { color: var(--text-2); font-size: .9rem; margin: 0; }

.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.model-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, transform .15s; }
.model-card:hover { border-color: var(--border-strong); }
.model-card .name { font-weight: 600; letter-spacing: -.01em; }
.model-card .slug { font-family: var(--mono); font-size: .76rem; color: var(--text-3); }
.model-card .prices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-top: 10px; border-top: 1px dashed var(--border); }
.model-card .prices div { font-size: .74rem; color: var(--text-3); }
.model-card .prices b { display: block; color: var(--text); font-size: .88rem; font-weight: 600; font-variant-numeric: tabular-nums; }

/* калькулятор */
.calc { display: grid; grid-template-columns: 1.2fr 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden; background: var(--surface); }
.calc .calc-in { padding: 26px; display: flex; flex-direction: column; gap: 18px; }
.calc .calc-out { padding: 26px; background: var(--bg-2); border-left: 1px solid var(--border); display: flex; flex-direction: column; justify-content: center; }
.calc .big { font-size: 2.5rem; font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.range-row { display: flex; align-items: center; gap: 14px; }
.range-row output { min-width: 86px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .9rem; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; min-height: 0; padding: 0; border: 0; border-radius: 99px; background: var(--surface-3); box-shadow: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--accent-strong); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 4px solid var(--accent-strong); cursor: pointer; }

/* тарифы */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; align-items: stretch; }
.plan { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 24px; }
.plan.featured { border-color: var(--accent-line); background: linear-gradient(180deg, var(--accent-soft), transparent 45%), var(--surface); box-shadow: 0 0 0 1px var(--accent-line), 0 30px 60px -30px var(--accent-strong); }
.plan.current { border-color: var(--ok); }
.plan .plan-name { font-weight: 650; font-size: 1.02rem; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan .plan-desc { color: var(--text-2); font-size: .86rem; margin: 6px 0 0; min-height: 1.2em; }
.plan .price { font-size: 2.3rem; font-weight: 700; letter-spacing: -.04em; margin-top: 18px; line-height: 1; font-variant-numeric: tabular-nums; }
.plan .price small { font-size: .9rem; font-weight: 500; color: var(--text-3); letter-spacing: 0; margin-left: 4px; }
.plan ul { list-style: none; padding: 0; margin: 20px 0 22px; display: flex; flex-direction: column; gap: 9px; }
.plan li { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: .88rem; }
.plan li .i { color: var(--ok); margin-top: 1px; }
.plan li.off { color: var(--text-3); }
.plan li.off .i { color: var(--text-3); }
.plan .plan-actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.plan .plan-actions .btn { flex: 1; }
.ribbon { font-size: .7rem; padding: 3px 9px; border-radius: 99px; font-weight: 650; background: var(--accent-strong); color: #fff; }

/* интеграции */
.integr { display: grid; grid-template-columns: 1fr 1.25fr; gap: 28px; align-items: start; }
.integr .steps { display: flex; flex-direction: column; gap: 4px; counter-reset: step; }
.integr .step { display: flex; gap: 14px; padding: 14px; border-radius: var(--r); }
.integr .step::before { counter-increment: step; content: counter(step); width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border-strong); font-size: .78rem; font-weight: 650; color: var(--text-2); }
.integr .step h4 { margin: 2px 0 4px; }
.integr .step p { margin: 0; color: var(--text-2); font-size: .88rem; }
.tool-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* FAQ */
.faq { display: flex; flex-direction: column; gap: 8px; max-width: 820px; margin: 0 auto; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 0 20px; transition: border-color .15s; }
.faq details[open] { border-color: var(--border-strong); }
.faq summary { list-style: none; cursor: pointer; padding: 17px 0; font-weight: 600; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary .i { color: var(--text-3); transition: transform .2s; }
.faq details[open] summary .i { transform: rotate(45deg); }
.faq details p { color: var(--text-2); margin: -4px 0 18px; font-size: .92rem; }

.cta-band { margin-top: 80px; padding: 48px 32px; border-radius: var(--r-xl); text-align: center; position: relative; overflow: hidden; border: 1px solid var(--border); background: var(--surface); }
.cta-band::before { content: ""; position: absolute; inset: 0; background: var(--glow); pointer-events: none; }
.cta-band > * { position: relative; }
.cta-band h2 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -.03em; }

footer.site { border-top: 1px solid var(--border); margin-top: 80px; padding: 32px 0 40px; color: var(--text-2); font-size: .86rem; }
footer.site .cols { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
footer.site nav { display: flex; gap: 18px; flex-wrap: wrap; }
footer.site a { color: var(--text-2); }
footer.site a:hover { color: var(--text); }

/* страница документа */
.doc { padding: 48px 0 20px; }
.doc h1 { font-size: 2rem; letter-spacing: -.035em; }
.doc .card h3 { margin-top: 22px; }
.doc .card h3:first-child { margin-top: 0; }
.doc .card p { color: var(--text-2); }

/* ==========================================================================
   ПРИЛОЖЕНИЕ (кабинет и админка)
   ========================================================================== */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.side { width: var(--side-w); flex-shrink: 0; background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 60; }
.side .side-top { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 10px 18px; }
.side .side-close { display: none; }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 10px 12px; }
.side-nav .group { color: var(--text-3); font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; margin: 18px 10px 6px; }
.side-nav .group:first-child { margin-top: 6px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--text-2); font-size: .9rem; font-weight: 500; margin-bottom: 1px; transition: background .12s, color .12s; }
.side-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.side-nav a.active .i { color: var(--accent); }
.side-nav a .count { margin-left: auto; }
.side-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.wallet { display: block; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.wallet:hover { text-decoration: none; border-color: var(--border-strong); }
.wallet .w-label { font-size: .74rem; color: var(--text-3); display: flex; justify-content: space-between; align-items: center; }
.wallet .w-value { font-size: 1.15rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.wallet .w-plan { font-size: .78rem; color: var(--text-2); margin-top: 6px; display: flex; gap: 6px; align-items: center; }
.wallet .progress { margin-top: 8px; height: 4px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 4px 2px 0 4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: #fff; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-strong), #3a2f8f); text-transform: uppercase; }
.user-row .who { flex: 1; min-width: 0; font-size: .82rem; }
.user-row .who .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.user-row .who .role { color: var(--text-3); font-size: .74rem; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile-bar { display: none; }
.page { padding: 28px 32px 48px; width: 100%; max-width: 1180px; margin: 0 auto; }
.page.full { padding: 0; max-width: none; flex: 1; display: flex; min-height: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.55rem; letter-spacing: -.03em; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-2); font-size: .92rem; }
.section-title { font-size: 1rem; font-weight: 650; margin: 28px 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.banner { display: flex; gap: 14px; align-items: center; padding: 12px 16px; border-radius: var(--r); margin-bottom: 18px; border: 1px solid var(--border); background: var(--surface); }
.banner .i { color: var(--text-2); }
.banner.warn { border-color: rgba(243, 180, 75, .35); background: var(--warn-soft); }
.banner.warn .i { color: var(--warn); }
.banner.ok { border-color: transparent; background: var(--ok-soft); }
.banner.ok .i { color: var(--ok); }
.banner.info { border-color: var(--accent-line); background: var(--accent-soft); }
.banner.info .i { color: var(--accent); }
.banner .b-text { flex: 1; min-width: 0; font-size: .88rem; }
.banner .b-text strong { display: block; font-size: .92rem; }
.banner .b-text span { color: var(--text-2); }
.app-banner { margin: 16px 32px 0; }

/* строки настроек */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid var(--border); }
.setting:first-of-type { border-top: 0; padding-top: 4px; }
.setting .s-text { min-width: 0; }
.setting .s-text strong { display: block; font-weight: 600; font-size: .92rem; }
.setting .s-text span { color: var(--text-2); font-size: .85rem; }

/* графики */
.bars { display: flex; align-items: stretch; gap: 4px; height: 160px; padding-top: 8px; }
.bars .bar { flex: 1; min-width: 4px; max-width: 42px; background: var(--accent-soft); border-radius: 5px 5px 2px 2px; position: relative; transition: background .15s; display: flex; align-items: flex-end; }
.bars .bar > span { display: block; width: 100%; background: var(--accent-strong); border-radius: 5px 5px 2px 2px; }
.bars .bar:hover > span { background: var(--accent); }
.bars-axis { display: flex; justify-content: space-between; font-size: .74rem; color: var(--text-3); margin-top: 8px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 200px) 1fr 150px; gap: 12px; align-items: center; font-size: .86rem; padding: 6px 0; }
.hbar .track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.hbar .track > span { display: block; height: 100%; background: var(--accent-strong); border-radius: 99px; }

/* ---------- чат ---------- */
.chat { display: flex; flex: 1; min-width: 0; width: 100%; min-height: 0; height: 100vh; height: 100dvh; }
.convs { width: 272px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg); }
.convs .convs-top { padding: 14px 12px 8px; display: flex; flex-direction: column; gap: 8px; }
.convs .search { position: relative; }
.convs .search .i { position: absolute; left: 10px; top: 10px; color: var(--text-3); }
.convs .search input { padding-left: 34px; min-height: 36px; height: 36px; font-size: .86rem; background: var(--surface); }
.convs .convs-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.convs .day { font-size: .7rem; color: var(--text-3); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; padding: 12px 10px 4px; }
.conv { display: flex; align-items: center; gap: 4px; padding: 8px 6px 8px 10px; border-radius: var(--r-sm); cursor: pointer; color: var(--text-2); font-size: .87rem; position: relative; }
.conv:hover { background: var(--surface-2); color: var(--text); }
.conv.active { background: var(--surface-2); color: var(--text); }
.conv .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .acts { display: none; gap: 0; }
.conv:hover .acts, .conv.active .acts { display: flex; }
.conv .acts .icon-btn { width: 24px; height: 24px; border-radius: 5px; }
.conv .acts .icon-btn .i { width: 14px; height: 14px; }
.conv input { min-height: 28px; height: 28px; padding: 2px 8px; font-size: .86rem; }

.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--bg); }
.chat-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); min-height: 56px; }
.chat-top .model-select { width: auto; min-width: 200px; max-width: 320px; font-weight: 550; background-color: var(--surface); }
.chat-top .price-hint { font-size: .8rem; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.chat-top .convs-toggle { display: none; }
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-wrap { max-width: 800px; margin: 0 auto; padding: 28px 24px 12px; }

.msg { margin-bottom: 26px; display: flex; flex-direction: column; min-width: 0; }
.msg .bubble { max-width: 100%; min-width: 0; }
.msg.user { align-items: flex-end; }
.msg.user .bubble { background: var(--user-bubble); border-radius: 18px 18px 4px 18px; padding: 10px 16px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.assistant .head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .8rem; color: var(--text-3); }
.msg.assistant .head .ava { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: linear-gradient(145deg, #2b2640, #0d0c14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09); }
.msg.assistant .head .ava svg { width: 15px; height: 15px; }
.msg.assistant .head .model { font-family: var(--mono); color: var(--text-2); }
.msg.assistant .bubble { overflow-wrap: anywhere; line-height: 1.65; }
.msg .bubble > :first-child { margin-top: 0; }
.msg .bubble > :last-child { margin-bottom: 0; }
.msg .bubble p { margin: 0 0 .85em; }
.msg .bubble h2, .msg .bubble h3, .msg .bubble h4 { margin: 1.2em 0 .5em; }
.msg .bubble h2 { font-size: 1.2rem; } .msg .bubble h3 { font-size: 1.06rem; }
.msg .bubble ul, .msg .bubble ol { padding-left: 1.4em; margin: 0 0 .85em; }
.msg .bubble li { margin: .25em 0; }
.msg .bubble blockquote { margin: 0 0 .85em; padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.msg .bubble code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 5px; border-radius: 5px; }
.msg .bubble .code { margin: 0 0 .85em; }
.msg .bubble .code pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.msg .bubble .table-wrap { margin: 0 0 .85em; padding: 0; }
.msg .bubble table { font-size: .86rem; }
.msg .bubble hr { margin: 1em 0; }
.msg .meta { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: .76rem; color: var(--text-3); flex-wrap: wrap; }
.msg .meta .sep { margin: 0 4px; }
.msg .meta .icon-btn { width: 28px; height: 28px; }
.msg .meta .icon-btn .i { width: 15px; height: 15px; }
.msg.user .meta { opacity: 0; transition: opacity .15s; }
.msg.user:hover .meta { opacity: 1; }
.msg .err-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--r); background: var(--err-soft); color: var(--err); font-size: .88rem; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: typing 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.cursor-blink { display: inline-block; width: 8px; height: 1.05em; background: var(--accent); vertical-align: text-bottom; margin-left: 2px; border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.chat-empty { max-width: 680px; margin: 0 auto; padding: 9vh 24px 24px; text-align: center; }
.chat-empty .mark-lg { width: 52px; height: 52px; border-radius: 15px; margin: 0 auto 18px; display: grid; place-items: center; background: linear-gradient(145deg, #2b2640, #0d0c14); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .09), 0 20px 40px -20px var(--accent-strong); }
.chat-empty .mark-lg svg { width: 32px; height: 32px; }
.chat-empty h2 { font-size: 1.6rem; letter-spacing: -.03em; }
.suggest { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 26px; text-align: left; }
.suggest button { font: inherit; text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; color: var(--text); font-size: .88rem; transition: border-color .15s, background .15s; }
.suggest button:hover { border-color: var(--border-strong); background: var(--surface-2); }
.suggest button span { display: block; color: var(--text-3); font-size: .8rem; margin-top: 2px; }

.composer-wrap { padding: 8px 24px 18px; }
.composer { max-width: 800px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; padding: 10px 10px 10px 16px; transition: border-color .15s, box-shadow .15s; box-shadow: 0 10px 30px -18px rgba(0, 0, 0, .5); }
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer textarea { border: 0; background: transparent; padding: 6px 0; min-height: 28px; max-height: 240px; resize: none; box-shadow: none; font-size: .95rem; }
.composer textarea:focus, .composer textarea:focus-visible { box-shadow: none; outline: none; }
.composer .c-bar { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.composer .c-bar .hint { font-size: .74rem; color: var(--text-3); margin-right: auto; }
.send-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--accent-strong); color: #fff; display: grid; place-items: center; cursor: pointer; transition: background .15s, opacity .15s; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.send-btn .i { width: 18px; height: 18px; stroke-width: 2.2; }
.composer-note { max-width: 800px; margin: 8px auto 0; text-align: center; font-size: .74rem; color: var(--text-3); }
.scroll-down { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); border-radius: 99px; box-shadow: var(--shadow); }

/* медиа */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.media-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; }
.media-card .m-preview { background: var(--bg-2); aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; }
.media-card .m-preview img, .media-card .m-preview video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-card .m-preview audio { width: calc(100% - 24px); }
.media-card .m-preview .i { width: 32px; height: 32px; color: var(--text-3); }
.media-card .m-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.media-card .m-prompt { font-size: .86rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.kind-tabs { margin-bottom: 14px; }

/* поддержка */
.tickets { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.ticket-list { display: flex; flex-direction: column; gap: 6px; }
.ticket-item { padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: border-color .15s; }
.ticket-item:hover { border-color: var(--border-strong); }
.ticket-item.active { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line); }
.ticket-item .ti-subj { font-weight: 600; font-size: .9rem; display: flex; gap: 8px; align-items: center; }
.ticket-item .ti-meta { font-size: .78rem; color: var(--text-3); margin-top: 6px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.thread { display: flex; flex-direction: column; min-height: 420px; }
.thread .th-head { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.thread .th-body { flex: 1; display: flex; flex-direction: column; gap: 12px; max-height: 56vh; overflow-y: auto; padding: 4px 2px 12px; }
.tmsg { display: flex; flex-direction: column; max-width: 80%; }
.tmsg .tb { padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .9rem; }
.tmsg .tt { font-size: .72rem; color: var(--text-3); margin-top: 4px; padding: 0 4px; }
.tmsg.me { align-self: flex-end; align-items: flex-end; }
.tmsg.me .tb { background: var(--user-bubble); border-bottom-right-radius: 4px; }
.tmsg.them { align-self: flex-start; }
.tmsg.them .tb { background: var(--surface-2); border-bottom-left-radius: 4px; }
.thread .th-reply { border-top: 1px solid var(--border); padding-top: 14px; }
.thread .th-reply textarea { min-height: 70px; }

/* ключи и пр. */
.key-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.key-row:first-child { border-top: 0; padding-top: 0; }
.k-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex-shrink: 0; }
.key-row.revoked { opacity: .55; }

/* ---------- адаптив ---------- */
@media (max-width: 1100px) {
  .convs { width: 240px; }
}
@media (max-width: 960px) {
  .features { grid-template-columns: 1fr 1fr; }
  .integr, .calc { grid-template-columns: 1fr; }
  .calc .calc-out { border-left: 0; border-top: 1px solid var(--border); }
  .demo .demo-body { grid-template-columns: 1fr; }
  .demo .demo-chat { border-right: 0; border-bottom: 1px solid var(--border); }
  .tickets { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .site-nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch; margin: 0; padding: 10px 16px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 12px; font-size: 1rem; }
  .menu-toggle { display: inline-grid; }
  .hide-m { display: none !important; }

  .side { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .side .side-close { display: inline-grid; }
  .scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 55; animation: fade .15s; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--bg); position: sticky; top: 0; z-index: 40; }
  .mobile-bar .brand { font-size: .95rem; }
  .mobile-bar .mb-balance { margin-left: auto; font-weight: 600; font-size: .86rem; font-variant-numeric: tabular-nums; padding: 5px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text); }
  .page { padding: 20px 16px 40px; }
  .app-banner { margin: 12px 16px 0; }
  .chat { height: calc(100vh - 56px); height: calc(100dvh - 56px); }
  .convs { position: fixed; top: 0; bottom: 0; left: 0; z-index: 70; width: min(300px, 86vw); transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow); background: var(--bg-2); }
  .convs.open { transform: none; }
  .chat-top { padding: 8px 12px; }
  .chat-top .convs-toggle { display: inline-grid; }
  .chat-top .model-select { min-width: 0; flex: 1; }
  .chat-top .price-hint { display: none; }
  .chat-wrap { padding: 20px 14px 8px; }
  .composer-wrap { padding: 6px 10px 12px; }
  .suggest { grid-template-columns: 1fr; }
  .composer .c-bar .hint { visibility: hidden; }
  .msg.user .bubble { max-width: 92%; }
  .scroll-down { bottom: 110px; }
  .hbar { grid-template-columns: 100px 1fr 90px; }
}
@media (max-width: 600px) {
  .container, .narrow { width: calc(100% - 32px); }
  .hero { padding: 56px 0 36px; }
  .features { grid-template-columns: 1fr; }
  .section { padding-top: 60px; }
  .modal .modal-head, .modal .modal-body, .modal .modal-foot { padding-left: 18px; padding-right: 18px; }
  .modal .modal-foot .btn { flex: 1; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .stat .value { font-size: 1.25rem; }
  .grid.c4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .page-head h1 { font-size: 1.35rem; }
  .setting { flex-direction: column; align-items: flex-start; }
  #toasts { left: 16px; right: 16px; }
  .toast { max-width: none; }
  .demo .demo-code { display: none; }
  .demo .demo-chat { border-bottom: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
