/* Онлайн-консультант Элдик Банка.
   Цвета — из логотипа банка (синий #166ce6, зелёный #8bc87e), текст — глубокий тёмно-синий.
   Шрифт: Golos Text (с кыргызскими ө ү ң). */
:root {
  --ink: #0f1d33;
  --ink-2: #44526b;
  --ink-3: #7b879b;
  --line: #e4e8ee;
  --line-2: #eef1f5;
  --canvas: #f6f7f9;
  --white: #ffffff;
  --blue: #166ce6;
  --blue-deep: #0d4fb3;
  --blue-wash: #edf3fd;
  --green: #8bc87e;
  --green-ink: #2f7d3a;
  --green-wash: #eef7ec;
  --col: 720px;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 6px; }

.app { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; }

/* --- шапка ------------------------------------------------------------------------ */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 68px; padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
}
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.logo { display: block; height: 36px; width: auto; }
.mark { display: none; }
.brand-sep { width: 1px; height: 24px; background: var(--line); }
.product { font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.bar-actions { display: flex; align-items: center; gap: 20px; }

.langs { display: flex; gap: 2px; }
.langs button {
  border: 0; background: none; cursor: pointer;
  padding: 6px 8px; font-size: 14px; color: var(--ink-3);
  border-bottom: 1.5px solid transparent; border-radius: 0;
}
.langs button:hover { color: var(--ink); }
.langs button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--blue); }

.text-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); cursor: pointer; font-size: 14px; color: var(--ink);
}
.text-btn:hover { border-color: #c9d1dc; background: var(--canvas); }
.text-btn svg, .icon-btn svg, .send svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; cursor: pointer; color: var(--ink-2);
}
.icon-btn:hover { background: var(--canvas); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.close-btn { display: none; }

/* --- лента ------------------------------------------------------------------------ */
.scroll { overflow-y: auto; overscroll-behavior: contain; }
.welcome, .thread { width: 100%; max-width: calc(var(--col) + 48px); margin: 0 auto; padding: 0 24px; }
.welcome[hidden] { display: none; }

/* --- пустой диалог: приветствие и поле ввода в центре --------------------------------- */
body.is-empty .app {
  background:
    radial-gradient(60% 45% at 50% -5%, rgba(22, 108, 230, .10), rgba(22, 108, 230, 0) 70%),
    radial-gradient(30% 30% at 82% 18%, rgba(139, 200, 126, .14), rgba(139, 200, 126, 0) 70%),
    var(--white);
}
body.is-empty .bar { background: transparent; border-bottom-color: transparent; }
body.is-empty .composer-wrap { display: none; }

.welcome { min-height: 100%; display: flex; align-items: center; justify-content: center; padding-top: 24px; padding-bottom: 48px; }
.hero { width: 100%; text-align: center; margin-top: -4vh; }
.hero-mark { display: block; width: 44px; height: 44px; margin: 0 auto 22px; }
.eyebrow { margin: 0 0 10px; font-size: 14px; color: var(--ink-3); }
.hero h1 {
  margin: 0 0 32px;
  font-family: var(--sans); font-weight: 600;
  font-size: clamp(34px, 5.2vw, 54px); line-height: 1.04; letter-spacing: -.035em;
  color: var(--ink);
}
.hero-slot { text-align: left; }
.hero-slot .composer {
  max-width: none; border-radius: 18px; padding: 10px 10px 10px 22px;
  border-color: #dde3eb;
  box-shadow: 0 1px 2px rgba(15, 29, 51, .04), 0 24px 56px -28px rgba(13, 79, 179, .40);
}
.hero-slot .composer:focus-within { box-shadow: 0 0 0 4px rgba(22, 108, 230, .10), 0 24px 56px -28px rgba(13, 79, 179, .40); }
.hero-slot .composer textarea { font-size: 17px; padding: 11px 0; }
.hero-slot .send { width: 44px; height: 44px; border-radius: 12px; }

.topics { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.topic {
  display: inline-flex; align-items: center; height: 36px; padding: 0 15px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, .75); cursor: pointer;
  font-size: 14px; color: var(--ink-2);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.topic:hover { border-color: rgba(22, 108, 230, .5); color: var(--blue-deep); background: var(--white); }
.hero-sub { margin: 32px auto 0; max-width: 32em; font-size: 13.5px; color: var(--ink-3); }

.thread { padding-top: 36px; padding-bottom: 32px; display: flex; flex-direction: column; gap: 28px; }
.thread:empty { padding: 0; }

.msg-user {
  align-self: flex-end; max-width: min(78%, 560px);
  background: var(--canvas); border: 1px solid var(--line-2);
  padding: 11px 16px; border-radius: 14px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}

.msg-bot { display: grid; grid-template-columns: 28px 1fr; gap: 16px; align-items: start; }
.msg-bot .avatar { width: 28px; height: 28px; margin-top: 1px; }
.msg-body { min-width: 0; }

.status { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: 15px; min-height: 28px; }
.status q { quotes: "«" "»"; color: var(--ink-2); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); opacity: .3; animation: pulse 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ответ */
.md { overflow-wrap: anywhere; font-size: 16px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 20px; }
.md li { margin: 4px 0; padding-left: 2px; }
.md li::marker { color: var(--ink-3); }
.md strong { font-weight: 600; }
.md h1, .md h2, .md h3, .md h4 { font-size: 16px; font-weight: 600; margin: 20px 0 8px; }
.md a { color: var(--blue-deep); text-decoration: underline; text-decoration-color: rgba(13, 79, 179, .3); text-underline-offset: 3px; }
.md a:hover { text-decoration-color: var(--blue-deep); }
.md code { background: var(--canvas); padding: 1px 5px; border-radius: 4px; font-size: 14px; }
.md .table-wrap { overflow-x: auto; margin: 8px 0 16px; border: 1px solid var(--line); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.md th, .md td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-2); }
.md tr:last-child td { border-bottom: 0; }
.md th, .md td { overflow-wrap: normal; word-break: normal; hyphens: auto; }
body.embed .md table { font-size: 13.5px; }
body.embed .md th, body.embed .md td { padding: 8px 10px; }
.md th { font-weight: 500; color: var(--ink-3); font-size: 13px; background: var(--white); border-bottom-color: var(--line); }
.md td:first-child { font-weight: 500; }

/* номер источника в тексте */
.md .cite {
  display: inline-block; min-width: 16px; padding: 0 4px; margin: 0 1px;
  border-radius: 4px; background: var(--blue-wash); color: var(--blue-deep);
  font-size: 11px; font-weight: 600; line-height: 16px; text-align: center;
  text-decoration: none; vertical-align: 2px;
}
.md a.cite:hover { background: var(--blue); color: var(--white); }
.caret::after { content: ""; display: inline-block; width: 2px; height: 16px; margin-left: 3px; background: var(--blue); vertical-align: -2px; animation: caret 1s steps(2) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.sources { margin-top: 20px; }
.sources-title { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.source {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--line-2);
  color: var(--ink); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.source:last-child { border-bottom: 1px solid var(--line-2); }
.source .n { flex: none; width: 18px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.source .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source .t small { font-size: 13px; color: var(--ink-3); margin-left: 8px; }
.source:hover .t { color: var(--blue-deep); }
.source .seg { flex: none; margin-left: auto; font-size: 12px; color: var(--ink-3); }
.source .seg-legal { color: var(--green-ink); }
.source .seg-individual { color: var(--blue-deep); }
.source .k { flex: none; margin-left: auto; font-size: 12px; color: var(--ink-3); }
.source .seg + .k { margin-left: 0; }
.source .seg + .k::before { content: "·"; margin-right: 12px; }

.msg-tools { display: flex; gap: 4px; margin-top: 10px; margin-left: -8px; }
.tool { border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 13px; padding: 4px 8px; border-radius: 6px; }
.tool:hover { background: var(--canvas); color: var(--ink); }

.error { color: #9b2c33; background: #fbf1f2; border-radius: 10px; padding: 10px 14px; font-size: 15px; }
.error button { margin-left: 10px; border: 0; background: none; color: var(--blue-deep); cursor: pointer; font-weight: 500; padding: 0; }

/* --- поле ввода ------------------------------------------------------------------- */
.composer-wrap { padding: 12px 24px calc(14px + env(safe-area-inset-bottom)); background: var(--white); }
.composer {
  max-width: var(--col); margin: 0 auto;
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--white); border: 1px solid #d7dde6; border-radius: 14px;
  padding: 8px 8px 8px 18px;
  box-shadow: 0 1px 2px rgba(15, 29, 51, .04), 0 8px 24px -16px rgba(15, 29, 51, .18);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.composer:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(22, 108, 230, .1); }
.composer textarea {
  flex: 1; border: 0; outline: 0; resize: none; background: none;
  padding: 9px 0; max-height: 180px; line-height: 1.5; font-size: 16px;
}
.composer textarea::placeholder { color: var(--ink-3); }
.send {
  flex: none; width: 40px; height: 40px; border-radius: 10px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: var(--blue); color: var(--white);
  transition: background .15s ease;
}
.send svg { width: 18px; height: 18px; stroke-width: 2; }
.send:hover:not(:disabled) { background: var(--blue-deep); }
.send:disabled { background: var(--line-2); color: var(--ink-3); cursor: default; }
.note { max-width: var(--col); margin: 10px auto 0; font-size: 12.5px; color: var(--ink-3); text-align: center; }
.note a { color: inherit; white-space: nowrap; }

/* --- мини-чат во фрейме (/embed) ---------------------------------------------------- */
body.embed { font-size: 15px; }
body.embed .bar { height: 60px; padding: 0 10px 0 16px; }
body.embed .logo, body.embed .brand-sep, body.embed .langs, body.embed .text-btn span { display: none; }
body.embed .mark { display: block; }
body.embed .brand { gap: 10px; }
body.embed .product { display: inline; color: var(--ink); font-weight: 500; font-size: 15px; }
body.embed .bar-actions { gap: 2px; }
body.embed .text-btn { border: 0; width: 36px; padding: 0; justify-content: center; color: var(--ink-2); background: transparent; }
body.embed .text-btn:hover { background: var(--canvas); }
body.embed .text-btn svg { width: 20px; height: 20px; }
body.embed .close-btn { display: grid; }
body.embed .welcome, body.embed .thread { padding-left: 18px; padding-right: 18px; }
body.embed .hero { margin-top: 0; }
body.embed .hero-mark { width: 36px; height: 36px; margin-bottom: 16px; }
body.embed .eyebrow { font-size: 13px; }
body.embed .hero h1 { font-size: 28px; margin-bottom: 22px; }
body.embed .hero-slot .composer { padding: 8px 8px 8px 16px; border-radius: 14px; }
body.embed .hero-slot .composer textarea { font-size: 15px; padding: 9px 0; }
body.embed .hero-slot .send { width: 40px; height: 40px; border-radius: 10px; }
body.embed .topics { margin-top: 14px; gap: 6px; }
body.embed .topic { height: 32px; padding: 0 12px; font-size: 13px; }
body.embed .hero-sub { margin-top: 20px; font-size: 12.5px; }
body.embed.is-empty .app { background: radial-gradient(80% 40% at 50% 0%, rgba(22, 108, 230, .08), rgba(22, 108, 230, 0) 70%), var(--white); }
body.embed .msg-bot { grid-template-columns: 1fr; }
body.embed .msg-bot .avatar { display: none; }
body.embed .md { font-size: 15px; }
body.embed .composer-wrap { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
body.embed .note { font-size: 11.5px; margin-top: 8px; }

@media (max-width: 640px) {
  .bar { padding: 0 16px; height: 60px; }
  .logo { height: 30px; }
  .brand-sep, .product { display: none; }
  .bar-actions { gap: 8px; }
  .text-btn span { display: none; }
  .text-btn { width: 36px; padding: 0; justify-content: center; }
  .welcome, .thread { padding: 0 16px; }
  .hero { margin-top: -2vh; }
  .hero h1 { font-size: 34px; margin-bottom: 24px; }
  .hero-slot .composer { padding: 8px 8px 8px 16px; }
  .topic { height: 34px; padding: 0 13px; font-size: 13.5px; }
  .msg-bot { grid-template-columns: 1fr; }
  .msg-bot .avatar { display: none; }
  .msg-user { max-width: 88%; }
  .composer-wrap { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .dots i, .caret::after { animation: none; }
  .topic { transition: none; }
}
