/* База знаний FLY — мини-аппа @flyznanyabot.
   Фирстиль FLY: IBM Plex Sans, фиолетовый #6D4BFF, радиусы 16/24, стеклянные 3D-иконки.
   Тема — как в Telegram у пользователя (светлая по брендбуку, тёмная — производная). */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-cyrillic-400-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-cyrillic-500-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-cyrillic-600-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-cyrillic-700-normal.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --violet: #6D4BFF;
  --violet-deep: #5232E6;
  --bg: #F6F4FC;
  --surface: #FFFFFF;
  --field: #FFFFFF;
  --ink: #0A0A0A;
  --muted: #5A5A5A;
  --soft: #8A8A8A;
  --line: #ECE7FA;
  --tint: #EDE7FF;
  --tint-ink: #5232E6;
  --shadow: 0 1px 2px rgba(20, 10, 60, .04), 0 8px 24px rgba(109, 75, 255, .06);
  --bar-bg: rgba(255, 255, 255, .84);
  --bar-line: rgba(109, 75, 255, .12);
  --bar-shadow: 0 12px 32px rgba(40, 20, 110, .14);
  --tab-idle: #8A8A8A;
  --tab-active: #6D4BFF;
  --safe-bottom: var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  color-scheme: light;
}
:root[data-theme="dark"] {
  --violet: #7B5CFF;
  --bg: #0E0C15;
  --surface: #191622;
  --field: #1C1927;
  --ink: #F4F2FB;
  --muted: #AAA5BD;
  --soft: #7D7891;
  --line: rgba(255, 255, 255, .07);
  --tint: rgba(138, 111, 255, .16);
  --tint-ink: #BCA9FF;
  --shadow: none;
  --bar-bg: rgba(28, 25, 39, .8);
  --bar-line: rgba(255, 255, 255, .08);
  --bar-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --tab-idle: #7D7891;
  --tab-active: #BCA9FF;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); }
body {
  color: var(--ink);
  font: 400 15px/1.45 "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }

.screen { max-width: 560px; margin: 0 auto; padding: 0 16px calc(112px + var(--safe-bottom)); }

/* ── шапка: поиск + ситуации ─────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 5; margin: 0 -16px; padding: 12px 16px 8px;
  background: linear-gradient(var(--bg) 82%, rgba(0, 0, 0, 0)); }
.search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 8px 0 16px;
  border-radius: 16px; background: var(--field); border: 1px solid var(--line); box-shadow: var(--shadow);
  color: var(--soft); }
.search:focus-within { border-color: var(--violet); color: var(--violet); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  color: var(--ink); font: 400 16px "IBM Plex Sans", sans-serif; }
.search input::placeholder { color: var(--soft); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { display: none; width: 36px; height: 36px; border: 0; border-radius: 12px; background: transparent;
  color: var(--soft); align-items: center; justify-content: center; }
.search.has-text .clear { display: flex; }

.chips { display: flex; align-items: center; gap: 4px; margin: 12px -16px 0; padding: 0 16px 4px;
  overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips[hidden] { display: none; }
.chip { flex: none; height: 38px; padding: 0 15px; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font: 500 15px "IBM Plex Sans", sans-serif; white-space: nowrap;
  transition: background .18s, color .18s; }
.chip.on { background: var(--violet); color: #fff; box-shadow: 0 6px 16px rgba(109, 75, 255, .28); }
.chips .sep { flex: none; width: 1px; height: 22px; margin: 0 6px; background: var(--line); }
:root[data-theme="dark"] .chips .sep { background: rgba(255, 255, 255, .14); }

/* ── шапка сервиса ───────────────────────────────────────────────────────── */
.hero { position: relative; overflow: hidden; margin-top: 6px; min-height: 152px; padding: 20px 20px 18px;
  border-radius: 24px; color: #fff;
  background: radial-gradient(130% 150% at 88% 12%, #8e76f4 0%, #5b3fe0 42%, #2c1a8c 100%); }
.hero .eyebrow { font: 600 12px/1 "IBM Plex Sans", sans-serif; letter-spacing: .14em; text-transform: uppercase;
  opacity: .78; }
.hero h1 { margin: 10px 0 6px; max-width: 62%; font: 700 24px/1.15 "IBM Plex Sans", sans-serif;
  letter-spacing: -.01em; }
.hero p { margin: 0; max-width: 58%; font-size: 14px; line-height: 1.4; opacity: .86; }
.hero .count { display: inline-block; margin-top: 14px; padding: 5px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .16); font: 600 12px "IBM Plex Sans", sans-serif; }
.hero img { position: absolute; right: -6px; bottom: -8px; width: 44%; max-width: 200px;
  filter: drop-shadow(0 18px 28px rgba(18, 6, 70, .45)); pointer-events: none; }
.hero.wide img { width: 50%; max-width: 230px; bottom: 6px; }
.hero.tall img { width: 30%; max-width: 132px; right: 8px; bottom: -6px; }
.hero.square img { width: 37%; max-width: 168px; right: -10px; bottom: -16px; }

.promo { display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 12px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow);
  text-align: left; }
.promo img { width: 46px; height: 58px; object-fit: contain; flex: none; }
.promo .txt { display: block; min-width: 0; }
.promo b { display: block; font: 600 16px/1.25 "IBM Plex Sans", sans-serif; }
.promo .sub { display: block; margin-top: 2px; color: var(--muted); font-size: 14px; line-height: 1.35; }
.promo .go { display: flex; margin-left: auto; color: var(--soft); }

/* ── карточки ответов ────────────────────────────────────────────────────── */
.found { margin: 8px 2px 0; color: var(--soft); font-size: 13px; }
.cards { display: grid; gap: 12px; margin-top: 12px; }
.card, .promo, .rel { color: inherit; text-decoration: none; }
.card { display: block; width: 100%; padding: 16px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow); text-align: left; transition: transform .12s; }
.card:active, .promo:active, .rel:active { transform: scale(.985); }
.tag { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; padding: 4px 10px;
  border-radius: 999px; background: var(--tint); color: var(--tint-ink); font: 600 12px/1.3 "IBM Plex Sans", sans-serif; }
.card h3 { margin: 0; font: 600 17px/1.3 "IBM Plex Sans", sans-serif; letter-spacing: -.005em; }
.card p { margin: 6px 0 0; color: var(--muted); font-size: 15px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card mark { background: transparent; color: var(--violet); }

.help { margin-top: 16px; padding: 18px; border-radius: 20px; background: var(--tint); }
.help b { display: block; font: 600 16px "IBM Plex Sans", sans-serif; }
.help span { display: block; margin: 4px 0 14px; color: var(--muted); font-size: 14px; }
.empty { margin: 36px 8px 8px; text-align: center; color: var(--muted); }
.empty b { display: block; margin-bottom: 4px; color: var(--ink); font: 600 17px "IBM Plex Sans", sans-serif; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px;
  border: 0; border-radius: 16px; font: 600 16px "IBM Plex Sans", sans-serif; text-align: center; }
.btn-primary { background: var(--violet); color: #fff; box-shadow: 0 8px 20px rgba(109, 75, 255, .28); }
.btn-soft { background: var(--surface); color: var(--tint-ink); border: 1px solid var(--line); }
.btn + .btn { margin-top: 10px; }

/* ── нижний бар: 4 сервиса ───────────────────────────────────────────────── */
.tabbar { position: fixed; z-index: 10; left: 12px; right: 12px; bottom: calc(10px + var(--safe-bottom));
  max-width: 536px; height: 68px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--bar-line); border-radius: 26px; background: var(--bar-bg); box-shadow: var(--bar-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; background: transparent; color: var(--tab-idle); font: 500 11.5px "IBM Plex Sans", sans-serif; }
.tab .ico { width: 24px; height: 24px; }
.tab.on { color: var(--tab-active); font-weight: 600; }

/* ── страницы поверх: ответ и партнёрская программа ──────────────────────── */
.page { position: fixed; inset: 0; z-index: 20; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); transform: translateX(104%); visibility: hidden;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .3s; }
.page.open { transform: none; visibility: visible; transition: transform .3s cubic-bezier(.2, .8, .2, 1); }
.page .inner { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(32px + var(--safe-bottom)); }
.back { display: none; align-items: center; gap: 6px; height: 36px; margin: -4px 0 8px -6px; padding: 0 10px;
  border: 0; border-radius: 12px; background: transparent; color: var(--violet); font: 500 15px "IBM Plex Sans", sans-serif; }
.no-tg .back { display: inline-flex; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs .tag { margin: 0; }
.crumbs .tag.svc { background: var(--violet); color: #fff; }
.article h1 { margin: 14px 0 16px; font: 700 24px/1.22 "IBM Plex Sans", sans-serif; letter-spacing: -.012em; }
.body { font-size: 16px; line-height: 1.55; }
.body > :first-child { margin-top: 0; }
.body p { margin: 0 0 12px; }
.body p.lead { margin-top: 18px; font-weight: 600; }
.body a { color: var(--violet); font-weight: 500; text-decoration: none; }
.steps { margin: 4px 0 14px; padding: 0; list-style: none; }
.steps li { display: flex; gap: 12px; padding: 7px 0; }
.steps .n { flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 9px; background: var(--tint);
  color: var(--tint-ink); font: 600 13px/26px "IBM Plex Sans", sans-serif; text-align: center; }
.dots { margin: 2px 0 14px; padding: 0; list-style: none; }
.dots li { position: relative; padding: 4px 0 4px 20px; }
.dots li::before { content: ""; position: absolute; left: 4px; top: 13px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--violet); }
.actions { margin: 20px 0 4px; }
.rel-title { margin: 28px 2px 10px; font: 600 17px "IBM Plex Sans", sans-serif; }
.rel { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface); text-align: left;
  font: 500 15px/1.35 "IBM Plex Sans", sans-serif; }
.rel span { flex: 1; }
.rel .ico { margin-left: auto; color: var(--soft); width: 18px; height: 18px; }
body.typing .tabbar { display: none; }

.loading { padding: 80px 20px; text-align: center; color: var(--soft); }
@media (prefers-reduced-motion: reduce) { .page, .page.open, .card, .chip { transition: none; } }

/* ── режимы: менеджерам / клиентам (видят только админы) ─────────────────── */
.modebar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.modebar[hidden] { display: none; }
.seg { display: flex; flex: 1; padding: 3px; border: 1px solid var(--line); border-radius: 14px; background: var(--field); }
.seg button { flex: 1; height: 34px; border: 0; border-radius: 11px; background: transparent; color: var(--muted);
  font: 600 14px "IBM Plex Sans", sans-serif; transition: background .18s, color .18s; }
.seg button.on { background: var(--violet); color: #fff; }
.gear { display: flex; align-items: center; justify-content: center; flex: none; width: 42px; height: 42px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--field); color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tags .tag { margin: 0; }
.tag.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
:root[data-theme="dark"] .tag.ghost { border-color: rgba(255, 255, 255, .14); }

/* ── страница ответа для менеджера ───────────────────────────────────────── */
.cond { display: inline-flex; margin: -4px 0 4px; padding: 6px 12px; border-radius: 10px; background: #FFF4E2;
  color: #8A5300; font: 600 13px "IBM Plex Sans", sans-serif; }
:root[data-theme="dark"] .cond { background: rgba(245, 158, 11, .14); color: #F5B454; }
.block { margin-top: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  box-shadow: var(--shadow); }
.block-title { margin-bottom: 12px; color: var(--soft); font: 600 12px/1 "IBM Plex Sans", sans-serif;
  letter-spacing: .08em; text-transform: uppercase; }
.phrases { display: flex; flex-wrap: wrap; gap: 6px; }
.phrase { padding: 6px 10px; border-radius: 10px; background: var(--tint); color: var(--tint-ink);
  font: 500 13px/1.3 "IBM Plex Sans", sans-serif; }
.phrase.outline { background: transparent; border: 1px solid var(--violet); color: var(--violet); }
.block.answer .body { margin-bottom: 14px; }
.block.notes { border-color: transparent; background: var(--tint); box-shadow: none; }
.block.notes .dots { margin: 0; }
.hint { margin: -4px 0 12px; color: var(--soft); font-size: 13px; }
mark.ph { padding: 1px 5px; border-radius: 6px; background: rgba(109, 75, 255, .14); color: var(--violet); font-weight: 600; }
:root[data-theme="dark"] mark.ph { background: rgba(138, 111, 255, .22); color: #CFC2FF; }

/* ── настройки владельца ─────────────────────────────────────────────────── */
.page-title { margin: 4px 0 4px; font: 700 26px/1.2 "IBM Plex Sans", sans-serif; letter-spacing: -.012em; }
.muted { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.addform { display: flex; gap: 8px; margin-bottom: 12px; }
.addform input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--bg); color: var(--ink); font: 400 16px "IBM Plex Sans", sans-serif; outline: 0; }
.addform input:focus { border-color: var(--violet); }
.addform .btn { width: auto; height: 48px; padding: 0 18px; box-shadow: none; }
.btn:disabled { opacity: .6; }
.err { margin: -4px 0 12px; color: #E5484D; font-size: 14px; }
.err[hidden] { display: none; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; padding-top: 4px; }
.ava { display: flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; border-radius: 50%;
  background: var(--tint); color: var(--tint-ink); font: 700 16px "IBM Plex Sans", sans-serif; }
.ava.own { background: var(--violet); color: #fff; }
.row .who { flex: 1; min-width: 0; }
.row .who b { display: block; overflow: hidden; font: 600 15px "IBM Plex Sans", sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.row .who span { display: block; margin-top: 1px; color: var(--soft); font-size: 13px; }
.del { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: transparent; color: var(--soft); }
.del .ico { width: 20px; height: 20px; }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-bottom)); z-index: 40; padding: 12px 18px;
  border-radius: 14px; background: #1A1724; color: #fff; font: 500 14px "IBM Plex Sans", sans-serif;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); opacity: 0; transform: translate(-50%, 12px); transition: opacity .2s, transform .2s;
  pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
:root[data-theme="dark"] .toast { background: #F4F2FB; color: #0E0C15; }
