/* Палитра Ruwiki (спаршена из reader-assets/entry.D7JxUNE1.css):
   #702ffc — основной фиолетовый (кнопки)
   #511cc4 — hover
   #6024e0 — ссылка
   #221e78 — тёмно-фиолетовый
   #dadcf9 — светло-фиолетовый фон
   #17e3ad — мятный акцент
   #f4f4f5 — светлый фон
   #ece9df — сепия
   #1e1e1e — основной текст
   #4f5156 — вторичный текст
   #e6e6e6 — рамки */

:root {
  --brand: #702ffc;
  --brand-strong: #511cc4;
  --brand-dark: #221e78;
  --brand-soft: #dadcf9;
  --brand-softer: #ebecff;
  --link: #6024e0;
  --link-hover: #511cc4;
  --accent: #17e3ad;
  --bg: #f4f4f5;
  --bg-panel: #ffffff;
  --bg-sepia: #ece9df;
  --text: #1e1e1e;
  --text-mute: #4f5156;
  --text-faint: #7b7c80;
  --border: #e6e6e6;
  --border-strong: #d3d3d3;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --serif: "PT Serif", Georgia, "Noto Serif", "Times New Roman", serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;

  --shadow: 0 1px 2px rgba(24,24,27,.06), 0 4px 12px rgba(24,24,27,.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Хедер ─────────────────────────────────────────────────────────────── */

.site-header {
  background: linear-gradient(180deg, var(--brand-dark) 0%, var(--brand) 100%);
  color: #fff;
  border-bottom: 1px solid var(--brand-strong);
}
.header-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: #fff; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #fff;
  color: var(--brand);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .5px;
  box-shadow: inset 0 -2px 0 var(--accent);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 600; font-size: 17px; }
.brand-sub { font-size: 12px; opacity: .8; }

.header-nav .kb-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.24);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
}
.header-nav .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(23,227,173,.22);
}

/* ── Основной блок ──────────────────────────────────────────────────────── */

.main {
  padding-top: 28px;
  padding-bottom: 40px;
}

.lead {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px 28px 20px;
  box-shadow: var(--shadow);
}
.lead h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: -.01em;
}
.lead p {
  margin: 0 0 16px;
  color: var(--text-mute);
  font-size: 15px;
}
.lead p strong { color: var(--text); }

.mode-toggle {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.mode-opt {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  background: #fff;
}
.mode-opt input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.mode-opt span { font-weight: 600; font-size: 14px; color: var(--text); }
.mode-opt em { font-style: normal; font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.mode-opt:hover { border-color: var(--brand); }
.mode-opt:has(input:checked) {
  border-color: var(--brand);
  background: var(--brand-softer);
  box-shadow: 0 0 0 3px rgba(112,47,252,.12);
}
.mode-opt:has(input:checked) span { color: var(--brand-dark); }

/* ── Чат-лента ─────────────────────────────────────────────────────────── */

.chat {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.chat:empty { display: none; }

.msg {
  display: flex;
  gap: 12px;
}
.msg-avatar {
  flex: 0 0 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .3px;
}
.msg-body { flex: 1 1 auto; min-width: 0; }
.msg-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.msg.user .msg-avatar { background: var(--brand-soft); color: var(--brand-dark); }
.msg.user .msg-bubble {
  background: var(--brand-softer);
  border: 1px solid var(--brand-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.bot .msg-avatar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
}
.msg.bot .msg-bubble {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-md);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.msg.bot .answer {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.bot .answer a { color: var(--link); text-decoration: underline; text-decoration-color: rgba(96,36,224,.35); }

.msg.bot .sources {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
}
.msg.bot .sources h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-mute);
}
.msg.bot .sources ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: src;
}
.msg.bot .sources li {
  counter-increment: src;
  position: relative;
  padding: 8px 10px 8px 34px;
  margin-bottom: 6px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}
.msg.bot .sources li::before {
  content: counter(src);
  position: absolute;
  left: 8px;
  top: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.msg.bot .sources .fname {
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.35;
}
.msg.bot .sources .cid {
  margin-top: 2px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text-faint);
  font-size: 11.5px;
  word-break: break-all;
}
.msg.bot .sources .snippet {
  margin-top: 6px;
  color: var(--text-mute);
  font-size: 12.5px;
  line-height: 1.5;
  font-family: var(--serif);
}
.msg.bot .sources .score {
  float: right;
  font-size: 11px;
  color: var(--text-faint);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 8px;
}

.msg.bot.error .msg-bubble { border-left-color: #d64545; }
.msg.bot.error .answer { color: #a12727; font-family: var(--sans); font-size: 14px; }

.msg.bot.pending .answer::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.1s ease-in-out infinite;
}
.msg.bot.pending .answer::before {
  content: "Ищу в базе знаний";
  color: var(--text-mute);
  font-family: var(--sans);
  font-size: 14px;
  font-style: italic;
}
@keyframes pulse {
  0%, 100% { opacity: .3; transform: scale(.85); }
  50%      { opacity: 1;  transform: scale(1); }
}

/* ── Форма ─────────────────────────────────────────────────────────────── */

.ask {
  margin-top: 22px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.ask textarea {
  width: 100%;
  resize: vertical;
  min-height: 60px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.ask textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(112,47,252,.14);
}
.ask-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  gap: 12px;
}
.hint { font-size: 12px; color: var(--text-faint); }
#send {
  appearance: none;
  border: 0;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 22px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background .15s, transform .05s;
}
#send:hover { background: var(--brand-strong); }
#send:active { transform: translateY(1px); }
#send:disabled { background: var(--border-strong); color: #fff; cursor: not-allowed; }

/* ── Примеры ───────────────────────────────────────────────────────────── */

.samples {
  margin-top: 20px;
  background: var(--bg-sepia);
  border: 1px solid #e0dccb;
  border-radius: var(--r-md);
  padding: 10px 16px;
}
.samples summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--brand-dark);
  padding: 4px 0;
}
.samples ul {
  margin: 8px 0 6px;
  padding-left: 22px;
  columns: 2;
  column-gap: 24px;
}
.samples li { margin-bottom: 4px; font-size: 14px; break-inside: avoid; }

/* ── Футер ─────────────────────────────────────────────────────────────── */

.site-footer {
  margin-top: 40px;
  padding: 22px 0 34px;
  background: transparent;
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: 12.5px;
}
.footer-wrap {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-wrap code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--brand-dark);
  background: var(--brand-softer);
  padding: 1px 6px;
  border-radius: 4px;
}

@media (max-width: 640px) {
  .lead { padding: 20px; }
  .lead h1 { font-size: 24px; }
  .samples ul { columns: 1; }
  .brand-sub { display: none; }
  .kb-badge { font-size: 12px; }
}
