/* Neon Glass: только тёмная тема, mobile-first, без сборки и внешних ресурсов (CSP).
   Производительность: размытие (backdrop-filter) только у плавающих слоёв — шапка, док, шторка.
   Фон неподвижный и рисуется один раз; бесконечные анимации — лишь opacity/transform мелких элементов. */
:root {
  --bg: #07070c; --bg-2: #0d0c16;
  --text: #eceaf6; --text-2: #dcd8ee; --muted: #a09cb8; --faint: #8e89a8; --dim: #77738f;
  --accent: #a78bfa; --accent-hi: #c4b5fd; --accent-lo: #8b5cf6; --accent-text: #0b0614;
  --info: #67e8f9; --ok: #6ee7b7; --warn: #fcd34d; --bad: #fb7185;
  --focus: #c4b5fd;
  --line: rgba(255,255,255,.08); --line-2: rgba(255,255,255,.12); --edge: rgba(255,255,255,.16);
  --fill: rgba(255,255,255,.06); --sink: rgba(0,0,0,.32);
  /* Стекло карточек: без backdrop-filter — над неподвижным фоном размытие не видно, а стоит дорого */
  --glass: linear-gradient(160deg, rgba(255,255,255,.075), rgba(255,255,255,.02) 60%), rgba(16,14,28,.55);
  --glass-shadow: inset 0 1px 0 rgba(255,255,255,.13), 0 18px 40px -22px rgba(0,0,0,.9);
  --lens: radial-gradient(120% 90% at 20% 0%, rgba(255,255,255,.17), rgba(255,255,255,.04) 45%, rgba(255,255,255,.015)),
          linear-gradient(180deg, rgba(167,139,250,.10), rgba(34,211,238,.04)), rgba(16,14,30,.6);
  --lens-shadow: inset 0 1px 1px rgba(255,255,255,.32), inset 0 -10px 22px rgba(0,0,0,.28), 0 26px 50px -24px rgba(0,0,0,.95);
  --r-s: 12px; --r-m: 16px; --r-l: 22px; --r-xl: 28px;
  --ease: cubic-bezier(.2,.8,.2,1); --spring: cubic-bezier(.34,1.4,.5,1);
  --dock-h: 68px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh; color: var(--text); background: var(--bg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
/* Фон: неон-туман + точечная текстура. Отдельный fixed-слой — не перерисовывается при прокрутке */
body::before {
  content: ""; position: fixed; inset: -10vmax; z-index: -1; pointer-events: none;
  background:
    radial-gradient(rgba(255,255,255,.045) 1px, transparent 1.2px) 0 0 / 4px 4px,
    radial-gradient(48vmax 34vmax at 22% 12%, rgba(139,92,246,.38), transparent 70%),
    radial-gradient(38vmax 30vmax at 96% 34%, rgba(34,211,238,.16), transparent 70%),
    radial-gradient(46vmax 32vmax at 50% 100%, rgba(236,72,153,.17), transparent 70%),
    var(--bg);
  animation: aurora-in 1.6s var(--ease) backwards;
}
a { color: var(--accent-hi); text-decoration: none; transition: color .2s; }
a:hover { color: #ede9fe; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: rgba(167,139,250,.4); }
h1 { font-size: 1.9rem; line-height: 1.1; letter-spacing: -.03em; font-weight: 800; margin: 6px 0 14px; }
h2 { font-size: .78rem; margin: 22px 0 10px; color: var(--muted); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.card > h2:first-child { margin-top: 2px; }
h3 { font-size: 1.05rem; margin: 0 0 6px; font-weight: 650; }
p { margin: 6px 0; }
code { font: .88em ui-monospace, Consolas, monospace; background: var(--fill); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
.card, .list > li { overflow-wrap: anywhere; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.ttl { background: linear-gradient(180deg, #fff, #c9c3e6); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ic { flex: none; display: block; }

/* ===== Каркас ===== */
main { max-width: 1120px; margin: 0 auto; padding: 8px 16px calc(var(--dock-h) + 48px + env(safe-area-inset-bottom)); }
body.guest main { padding-bottom: 48px; }
.side { display: none; }

/* Орб-логотип: блик вращается — крошечный элемент, только transform */
.orb {
  position: relative; display: inline-block; width: 30px; height: 30px; border-radius: 50%; flex: none; overflow: hidden;
  background: radial-gradient(circle at 30% 25%, #fff 0, #e9d5ff 12%, #a78bfa 38%, #5b21b6 70%, #1e1036 100%);
  box-shadow: 0 0 18px rgba(167,139,250,.55), inset 0 -3px 6px rgba(0,0,0,.4);
}
.orb::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; /* круг вращается внутри круга — углы не вылезают */
  background: conic-gradient(from 0deg, transparent 0 60%, rgba(103,232,249,.55) 70%, transparent 80%);
  mix-blend-mode: screen; animation: spin 9s linear infinite;
}
.orb-xl { width: 84px; height: 84px; box-shadow: 0 0 50px rgba(167,139,250,.65), 0 0 120px rgba(139,92,246,.3), inset 0 -8px 16px rgba(0,0,0,.45); animation: float 6s ease-in-out infinite; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--text); font-weight: 700; }
.brand:hover { color: #fff; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flags { display: flex; gap: 6px; flex-wrap: wrap; }

/* Шапка телефона */
.mtop {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(180deg, rgba(7,7,12,.82), rgba(7,7,12,.55));
  backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-bottom: 1px solid var(--line);
}
.mtop .brand { flex: 1; }

/* Док — нижняя панель телефона, жидкое стекло */
.dock {
  position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom));
  height: var(--dock-h); padding: 6px; border-radius: 26px;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px;
}
/* Стекло дока — на ::before: backdrop-filter на самом доке сделал бы его контейнером для fixed-шторки */
.dock::before {
  content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(120% 90% at 20% 0%, rgba(255,255,255,.18), rgba(255,255,255,.05) 45%, rgba(255,255,255,.03)), rgba(18,16,32,.62);
  border: 1px solid var(--edge); box-shadow: var(--lens-shadow);
  backdrop-filter: blur(22px) saturate(180%); -webkit-backdrop-filter: blur(22px) saturate(180%);
  animation: dock-in .6s var(--spring) .1s backwards;
}
.dock > a, .dock summary { z-index: 2; animation: dock-in .6s var(--spring) .1s backwards; }
.dock > a, .dock summary {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 20px; color: #a9a4c4; font-size: 11px; line-height: 1.1; text-align: center; min-width: 0;
  transition: color .25s, background-color .25s, transform .2s var(--spring);
}
.dock > a span:not(.count), .dock summary span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dock > a:active, .dock summary:active { transform: scale(.92); }
.dock > a::before, .dock summary::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; opacity: 0; transform: scale(.7);
  background: radial-gradient(100% 100% at 50% 0%, rgba(196,181,253,.38), rgba(167,139,250,.12));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 0 20px -2px rgba(167,139,250,.6);
  transition: opacity .3s var(--ease), transform .4s var(--spring);
}
.dock > a > *, .dock summary > * { position: relative; }
.dock [aria-current="page"] { color: #fff; }
.dock [aria-current="page"]::before { opacity: 1; transform: none; }
.dock .count { position: absolute; top: 2px; right: 50%; margin-right: -24px; }
.more { display: contents; }
.more summary { list-style: none; cursor: pointer; }
.more summary::-webkit-details-marker { display: none; }
.more[open] summary { color: #fff; }
.more[open] summary::before { opacity: 1; transform: none; }
/* Шторка «Ещё» */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 0;
  padding: 10px 16px calc(var(--dock-h) + 30px + env(safe-area-inset-bottom));
  border-radius: 32px 32px 0 0; max-height: 85vh; overflow-y: auto;
  background: radial-gradient(120% 60% at 20% 0%, rgba(255,255,255,.16), rgba(255,255,255,.04) 45%, transparent),
              linear-gradient(180deg, rgba(40,30,72,.72), rgba(14,12,26,.92));
  border: 1px solid var(--edge); border-bottom: 0;
  box-shadow: inset 0 1px 1px rgba(255,255,255,.3), 0 -30px 80px -10px rgba(0,0,0,.9), 0 0 0 100vmax rgba(4,3,10,.6);
  backdrop-filter: blur(24px) saturate(170%); -webkit-backdrop-filter: blur(24px) saturate(170%);
  animation: sheet-up .45s var(--spring) backwards;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: rgba(255,255,255,.3); margin: 0 auto 16px; }
.sheet-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.sheet-tiles a {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 6px 12px; border-radius: 20px;
  color: var(--text); font-size: 13px; text-align: center; background: var(--glass); border: 1px solid var(--line-2);
  box-shadow: var(--glass-shadow); animation: rise .4s var(--ease) backwards;
  transition: transform .2s var(--spring), border-color .2s;
}
.sheet-tiles a:nth-child(2) { animation-delay: .03s; } .sheet-tiles a:nth-child(3) { animation-delay: .06s; }
.sheet-tiles a:nth-child(4) { animation-delay: .09s; } .sheet-tiles a:nth-child(5) { animation-delay: .12s; }
.sheet-tiles a:nth-child(6) { animation-delay: .15s; } .sheet-tiles a:nth-child(n+7) { animation-delay: .18s; }
.sheet-tiles a:active { transform: scale(.95); }
.sheet-tiles a[aria-current="page"] { border-color: rgba(167,139,250,.6); box-shadow: var(--glass-shadow), 0 0 26px -8px rgba(167,139,250,.8); }
.tile-ic {
  width: 44px; height: 44px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; color: #ede9fe;
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.35), rgba(167,139,250,.22) 45%, rgba(91,33,182,.25));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 0 18px -4px rgba(167,139,250,.6);
}

/* ПК: сайдбар вместо дока */
@media (min-width: 900px) {
  .mtop, .dock { display: none; }
  .shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 24px; padding: 20px 24px 0; max-width: 1440px; margin: 0 auto; }
  .shell > main { padding: 12px 0 56px; margin: 0; max-width: 1120px; width: 100%; }
  .side {
    position: sticky; top: 20px; align-self: start; max-height: calc(100vh - 40px); overflow-y: auto;
    display: flex; flex-direction: column; gap: 4px; padding: 18px 12px; border-radius: var(--r-xl);
    background: var(--lens); border: 1px solid var(--edge); box-shadow: var(--lens-shadow);
    scrollbar-width: none; animation: slide-in .6s var(--ease) backwards;
  }
  .side::-webkit-scrollbar { display: none; }
  .side .brand { padding: 4px 8px 12px; font-size: 1rem; }
  .side .orb { width: 36px; height: 36px; }
  .side .flags { padding: 0 8px 6px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .nav-group { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); padding: 14px 12px 6px; }
  .side-nav a {
    position: relative; display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 12px; border-radius: 14px;
    color: #bdb8d6; font-size: .95rem; transition: color .2s, background-color .2s, transform .2s var(--ease);
  }
  .side-nav a span:not(.count) { flex: 1; }
  .side-nav a:hover { color: #fff; background: rgba(255,255,255,.05); transform: translateX(2px); }
  .side-nav a[aria-current="page"] {
    color: #f4f2ff; background: linear-gradient(90deg, rgba(167,139,250,.24), rgba(167,139,250,.04));
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 0 22px -8px rgba(167,139,250,.7);
  }
  .side-nav a[aria-current="page"]::before {
    content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px;
    background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: grow-y .5s var(--spring) .2s backwards;
  }
  .side-out { margin-top: auto; padding-top: 16px; }
  h1 { font-size: 2.6rem; }
}

/* ===== Появление страницы: первые блоки по очереди, только opacity+transform ===== */
main > * { animation: rise .5s var(--ease) backwards; }
main > :nth-child(2) { animation-delay: .04s; } main > :nth-child(3) { animation-delay: .08s; }
main > :nth-child(4) { animation-delay: .12s; } main > :nth-child(5) { animation-delay: .16s; }
main > :nth-child(6) { animation-delay: .2s; } main > :nth-child(n+7) { animation-delay: .24s; }
.cols > .col > * { animation: rise .55s var(--ease) backwards; }
.cols > .col > :nth-child(2) { animation-delay: .08s; } .cols > .col > :nth-child(n+3) { animation-delay: .14s; }
.cols > .col:nth-child(2) > * { animation-delay: .12s; }
/* Блок, пришедший через htmx (класс ставит app.js) */
.swap-in { animation: swap-in .5s var(--ease) backwards !important; }
.swap-in.card::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  border: 1px solid rgba(196,181,253,.8); box-shadow: 0 0 30px rgba(167,139,250,.55);
  animation: flash 1.1s var(--ease) both;
}

/* ===== Карточки ===== */
.card {
  position: relative; background: var(--glass); border: 1px solid var(--line-2); border-radius: var(--r-l);
  box-shadow: var(--glass-shadow); padding: 18px; margin: 14px 0;
}
.card.lens, .lens { background: var(--lens); border-color: var(--edge); box-shadow: var(--lens-shadow); }
a.card { display: flex; color: var(--text); transition: transform .25s var(--ease), border-color .25s, box-shadow .25s; }
@media (hover: hover) {
  a.card:hover { transform: translateY(-2px); border-color: rgba(167,139,250,.5); box-shadow: var(--glass-shadow), 0 0 34px -12px rgba(167,139,250,.7); color: var(--text); }
}
a.card:active { transform: scale(.985); }
.list { list-style: none; margin: 0; padding: 0; }
/* ul.list.card: .list обнуляет padding, поэтому отступ карточки возвращаем явно */
.list.card { padding: 8px 18px; }
.list.card > li:first-child { padding-top: 12px; }
.list.card > li:last-child { padding-bottom: 12px; }
.list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:first-child { padding-top: 4px; }
.list > li:last-child { border-bottom: 0; padding-bottom: 2px; }
.card > .list:only-child > li:first-child { padding-top: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
/* Ряд кнопок после текста в карточке — не вплотную */
.card > .row:not(:first-child), .card > form.row, .card form > .row:last-child { margin-top: 12px; }
.list .row.between { row-gap: 6px; }
.row.between { justify-content: space-between; }
.row > .field { flex: 1 1 200px; min-width: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 12px 0; }
.stat {
  position: relative; background: var(--glass); border: 1px solid var(--line-2); border-radius: 18px; padding: 12px 14px;
  box-shadow: var(--glass-shadow); display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 14px; right: 14px; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(196,181,253,.6), transparent); }
.stat b { display: block; font-size: 1.5rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.quote { border-radius: var(--r-s); background: var(--sink); box-shadow: inset 2px 0 0 rgba(103,232,249,.7); padding: 8px 12px; margin: 8px 0; color: var(--text-2); }
.quote b { color: var(--info); }
.draft { background: var(--sink); border-radius: var(--r-s); padding: 8px 10px; }

/* «Сегодня» */
.hero { padding-top: 6px; }
.hero h1 { margin-bottom: 14px; }
.ask {
  display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 20px;
  background: var(--lens); border: 1px solid var(--edge); box-shadow: var(--lens-shadow);
  transition: border-color .3s, box-shadow .3s;
}
.ask:focus-within { border-color: rgba(167,139,250,.6); box-shadow: var(--lens-shadow), 0 0 0 4px rgba(167,139,250,.12), 0 0 40px -10px rgba(167,139,250,.7); }
.ask-ic { color: var(--accent-hi); display: none; }
/* Поиск по истории — такая же «линза», как вопрос к базе */
.search { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 20px; margin: 4px 0 14px;
  background: var(--lens); border: 1px solid var(--edge); box-shadow: var(--lens-shadow); transition: border-color .3s, box-shadow .3s; }
.search:focus-within { border-color: rgba(167,139,250,.6); box-shadow: var(--lens-shadow), 0 0 0 4px rgba(167,139,250,.12), 0 0 40px -10px rgba(167,139,250,.7); }
.search .field { flex: 1; min-width: 0; background: transparent; border: 0; box-shadow: none; padding-left: 0; }
.search .field:focus { outline: none; }
.search .ask-ic { color: var(--muted); }
.back { margin: 0 0 10px; }
/* История вопросов: вопрос — ответ — факты */
.qa-list { display: flex; flex-direction: column; }
.qa-list > .qa { animation: rise .5s var(--ease) backwards; }
.qa-list > .qa:nth-child(2) { animation-delay: .05s; } .qa-list > .qa:nth-child(3) { animation-delay: .1s; }
.qa-list > .qa:nth-child(n+4) { animation-delay: .15s; }
.qa-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 10px; }
.pill.llm { color: var(--accent-hi); border-color: rgba(167,139,250,.45); background: rgba(167,139,250,.08); }
.qa-q { display: flex; gap: 12px; align-items: flex-start; font-size: 1.05rem; line-height: 1.4; }
.qa-q strong { font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.qa-mark { flex: none; width: 26px; height: 26px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 800; color: var(--accent-text); background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 0 14px -2px rgba(167,139,250,.8); }
.qa-a { margin: 10px 0 0 38px; padding: 10px 14px; border-radius: var(--r-m); background: var(--sink); color: var(--text-2);
  box-shadow: inset 2px 0 0 rgba(103,232,249,.6); line-height: 1.55; overflow-wrap: anywhere; }
.qa-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 0 38px; }
.chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: .8rem;
  background: rgba(167,139,250,.10); border: 1px solid rgba(167,139,250,.28); color: var(--accent-hi); transition: background-color .2s, border-color .2s; }
.chip:hover { background: rgba(167,139,250,.2); border-color: rgba(167,139,250,.55); color: #fff; }
@media (max-width: 599px) { .qa-a, .qa-facts { margin-left: 0; } }
@media (min-width: 600px) { .ask-ic { display: block; } .ask { padding-left: 18px; gap: 12px; } }
.ask .field { flex: 1; min-width: 0; background: transparent; border: 0; box-shadow: none; padding-left: 0; font-size: 1.05rem; }
.ask .field:focus { outline: none; }
.ask button { flex: none; }
#answer.card { animation: swap-in .5s var(--ease) backwards; }
.cta { align-items: center; gap: 14px; border-color: rgba(167,139,250,.45); box-shadow: var(--glass-shadow), 0 0 40px -14px rgba(167,139,250,.6); }
.cta .grow { display: flex; flex-direction: column; }
.cta-ic { width: 44px; height: 44px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: rgba(167,139,250,.16); color: var(--accent-hi); flex: none; }
.cta-go { color: var(--muted); transition: transform .25s var(--spring); }
a.cta:hover .cta-go { transform: translateX(4px); color: var(--text); }
.cols { display: grid; gap: 0 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) { .cols { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
.events > li { display: grid; grid-template-columns: minmax(52px, max-content) minmax(0, 1fr) auto; gap: 4px 14px; align-items: baseline; }
.ev-time { font-variant-numeric: tabular-nums; color: #f4f2ff; text-shadow: 0 0 14px rgba(167,139,250,.55); white-space: nowrap; }
.ev-time:empty::before { content: "—"; color: var(--dim); text-shadow: none; }
.ev-body { min-width: 0; }
.ev-src { display: block; color: var(--faint); margin-top: 2px; }
.ev-id { color: var(--faint); }

/* ===== Метки ===== */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .78rem; line-height: 1.5;
  border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; background: rgba(255,255,255,.03);
}
.pill.ok, .lvl1 { color: var(--ok); border-color: rgba(110,231,183,.45); background: rgba(110,231,183,.06); }
.pill.warn, .lvl2 { color: var(--warn); border-color: rgba(252,211,77,.45); background: rgba(252,211,77,.06); }
.pill.bad, .lvl3 { color: var(--bad); border-color: rgba(251,113,133,.45); background: rgba(251,113,133,.07); }
.flags .pill { font-size: 11px; font-weight: 700; letter-spacing: .05em; }
/* Пульс-точка у «живых» меток: кольцо на transform/opacity */
.pill.ok::before, .glowing::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.glowing::before { animation: ping 2.4s var(--ease) infinite; }
.count {
  position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text); font-size: .72rem; font-weight: 800; line-height: 1;
}
.count::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 0 14px 2px rgba(167,139,250,.85); opacity: .5; animation: breathe 2.6s ease-in-out infinite; }
.count.big { min-width: 38px; height: 38px; border-radius: 12px; font-size: 1.05rem; }

/* ===== Формы и кнопки: цели касания ≥ 44px ===== */
input, select, textarea, button {
  font: inherit; color: var(--text); background: var(--sink); border: 1px solid var(--line-2); border-radius: var(--r-s);
  padding: 9px 12px; min-height: 44px; transition: border-color .2s, box-shadow .2s, background-color .2s, transform .15s var(--ease), opacity .2s;
}
input, select, textarea { box-shadow: inset 0 2px 8px rgba(0,0,0,.35); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: rgba(167,139,250,.65); box-shadow: inset 0 2px 8px rgba(0,0,0,.35), 0 0 0 4px rgba(167,139,250,.14); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background: var(--sink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a09cb8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
}
option { background: #15131f; color: var(--text); }
textarea { width: 100%; min-height: 110px; resize: vertical; line-height: 1.45; }
input[type="checkbox"] { min-height: 0; width: 20px; height: 20px; flex: none; accent-color: var(--accent); box-shadow: none; padding: 0; }
input[type="datetime-local"] { color-scheme: dark; }
label { display: block; margin: 10px 0 5px; color: var(--muted); font-size: .85rem; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; }
.filters label.check { font-size: .875rem; min-height: 44px; margin: 0; }
.field { width: 100%; }
fieldset { border: 1px solid var(--line-2); border-radius: var(--r-m); }
button {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; overflow: hidden;
  background: var(--fill); border-color: var(--line-2); box-shadow: inset 0 1px 0 rgba(255,255,255,.1); padding: 9px 16px; font-weight: 500;
}
@media (hover: hover) { button:hover:not(:disabled) { background-color: rgba(255,255,255,.1); border-color: rgba(255,255,255,.22); } }
button:active:not(:disabled) { transform: scale(.96); }
button.primary {
  background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo)); border-color: transparent; color: var(--accent-text); font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 10px 26px -10px rgba(139,92,246,.85);
}
/* Блик пробегает по главной кнопке при наведении */
button.primary::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 50%; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent); transform: skewX(-20deg) translateX(0);
}
@media (hover: hover) {
  button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #d4c8fe, #9466f7); box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 12px 32px -8px rgba(139,92,246,.95); }
  button.primary:hover::after { animation: shine .8s var(--ease); }
}
button.danger { color: var(--bad); border-color: rgba(251,113,133,.45); background: rgba(251,113,133,.08); }
button.danger:hover:not(:disabled) { background-color: rgba(251,113,133,.16); border-color: rgba(251,113,133,.7); box-shadow: 0 0 20px -6px rgba(251,113,133,.8); }
button.ok, .tail-acts button.ok { color: var(--ok); border-color: rgba(110,231,183,.4); }
button.ok:hover:not(:disabled) { background-color: rgba(110,231,183,.12); }
button.ghost { background: transparent; color: #bdb8d6; }
button.wide { width: 100%; }
button.icon { min-width: 44px; padding: 6px; background: transparent; border-color: transparent; color: var(--muted); }
button.sq { width: 38px; min-height: 38px; padding: 0; border-radius: 12px; }
button.sq.good { color: var(--ok); } button.sq.bad { color: var(--bad); }
button:disabled { opacity: .45; cursor: default; }
button.small { font-size: .85rem; }
.inline { display: inline; margin: 0; }
.filters { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.filters input, .filters select { width: 100%; }
.filters > div > label:first-child { margin-top: 0; }
.acts { margin-top: 12px; }
@media (max-width: 599px) {
  .approval .acts { display: grid; grid-template-columns: 1fr 1fr; }
  .approval .acts .primary { grid-column: 1 / -1; min-height: 50px; font-size: 1rem; }
}
.page-head { margin-bottom: 6px; } .page-head h1 { margin: 6px 0; }

/* Ожидание ответа htmx: мерцающая полоса вместо простого затемнения */
.htmx-request { opacity: .85; }
button.htmx-request, .htmx-request button.primary { pointer-events: none; }
button.htmx-request::before, .htmx-request > button.primary::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent); transform: translateX(-100%);
  animation: loading 1s linear infinite;
}

/* details */
details > summary { cursor: pointer; color: var(--accent-hi); padding: 6px 0; list-style: none; display: flex; align-items: center; gap: 6px; }
details > summary::-webkit-details-marker { display: none; }
details:not(.more):not(.multi) > summary::before {
  content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .25s var(--spring); margin: 0 4px 0 2px;
}
details[open]:not(.more):not(.multi) > summary::before { transform: rotate(45deg); }
details[open]:not(.more):not(.multi) > summary { margin-bottom: 6px; }
details[open]:not(.more):not(.multi) > :not(summary) { animation: rise .35s var(--ease) backwards; }

.flash { padding: 10px 14px; border-radius: var(--r-s); background: rgba(252,211,77,.06); border: 1px solid rgba(252,211,77,.28); color: var(--warn); margin: 10px 0; }
.flash.bad { border-color: rgba(251,113,133,.45); background: rgba(251,113,133,.08); color: #fecdd3; }
.flash.ok { border-color: rgba(110,231,183,.45); background: rgba(110,231,183,.07); color: #d1fae5; }

/* Таблицы: на узком экране листаются внутри своего блока */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr { transition: background-color .2s; }
tbody tr:hover { background: rgba(255,255,255,.03); }
th { color: var(--muted); font-weight: 600; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Полоски — <progress>: CSP запрещает inline-стили, ширину задаёт сам элемент */
progress { width: 100%; height: 10px; border: 0; border-radius: 6px; background: rgba(255,255,255,.07); appearance: none; -webkit-appearance: none; overflow: hidden; margin: 8px 0 4px; }
progress::-webkit-progress-bar { background: rgba(255,255,255,.07); border-radius: 6px; box-shadow: inset 0 1px 3px rgba(0,0,0,.5); }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent-lo), var(--accent-hi)); border-radius: 6px; box-shadow: 0 0 12px rgba(167,139,250,.7); }
progress::-moz-progress-bar { background: linear-gradient(90deg, var(--accent-lo), var(--accent-hi)); border-radius: 6px; }
progress.warn::-webkit-progress-value { background: linear-gradient(90deg, #f59e0b, var(--warn)); }
progress.warn::-moz-progress-bar { background: linear-gradient(90deg, #f59e0b, var(--warn)); }
progress.bad::-webkit-progress-value { background: linear-gradient(90deg, #e11d48, var(--bad)); }
progress.bad::-moz-progress-bar { background: linear-gradient(90deg, #e11d48, var(--bad)); }

/* Вход */
.login { max-width: 380px; margin: 10vh auto 0; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-bottom: 22px; }
.login-head h1 { margin: 0; text-align: center; }
.login .card { padding: 20px 18px; }
.login input { width: 100%; min-height: 50px; }
.login #code { letter-spacing: .3em; font-size: 1.15rem; }
.login button { width: 100%; margin-top: 18px; min-height: 52px; font-size: 1rem; }
.login label:first-of-type { margin-top: 0; }

/* Хвосты (D-046): форма + цвет, срочность читается за секунду */
.t-overdue { color: var(--bad); } .t-h48 { color: var(--warn); } .t-week { color: var(--info); }
.t-later { color: var(--text); } .t-nodate { color: var(--faint); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 0; }
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); gap: 2px; padding: 4px; margin: 12px 0;
  border-radius: var(--r-m); background: var(--glass); border: 1px solid var(--line-2); box-shadow: var(--glass-shadow);
  overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
@media (max-width: 479px) { .seg { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.seg-item { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 12px; border-radius: 12px; color: #a9a4c4; font-size: .85rem; white-space: nowrap; transition: color .2s, background-color .25s; }
.seg-item:hover { color: #fff; }
.seg-item[aria-current="page"] { color: #fff; background: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,.06)); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 14px -4px rgba(0,0,0,.6); }
.tails { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.tail {
  position: relative; display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; padding: 14px;
  background: var(--glass); border: 1px solid var(--line-2); border-radius: var(--r-l); box-shadow: var(--glass-shadow);
  animation: rise .5s var(--ease) backwards;
}
.tails > .tail:nth-child(2) { animation-delay: .05s; } .tails > .tail:nth-child(3) { animation-delay: .1s; }
.tails > .tail:nth-child(4) { animation-delay: .15s; } .tails > .tail:nth-child(n+5) { animation-delay: .2s; }
.tail:has(.t-overdue) { border-color: rgba(251,113,133,.38); box-shadow: var(--glass-shadow), 0 0 36px -16px rgba(251,113,133,.8); }
.tail:has(.t-h48) { border-color: rgba(252,211,77,.3); }
.tail-mark { text-align: center; align-self: start; padding: 10px 0 8px; border-radius: var(--r-m); background: rgba(255,255,255,.05); }
.tail-mark.t-overdue { background: rgba(251,113,133,.12); } .tail-mark.t-h48 { background: rgba(252,211,77,.10); }
.tail-mark.t-week { background: rgba(103,232,249,.10); }
.tail-shape { display: block; font-size: 1.5rem; line-height: 1; text-shadow: 0 0 12px currentColor; }
.t-overdue .tail-shape { animation: breathe 1.8s ease-in-out infinite; }
.tail-left { display: block; font-size: .72rem; font-weight: 800; margin-top: 4px; }
.tail-title { font-weight: 650; word-break: break-word; line-height: 1.35; }
.tail-acts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.tail-acts button { font-size: .82rem; padding: 6px 4px; }
.tail-state { margin-top: 10px; }
.tail details { margin-top: 6px; }
label.inline { display: inline; margin: 0; }

/* Сборы (D-047) */
.collection-card .grow { flex: 1; min-width: 0; }
.people-pick { border: 1px solid var(--line-2); border-radius: var(--r-m); margin: 12px 0; padding: 6px 12px; max-height: 50vh; overflow-y: auto; background: var(--sink); }
.people-pick label.check { margin: 2px 0; min-height: 40px; }
.fb { gap: 8px; }

/* ===== Ключевые кадры: только transform и opacity (кроме разовых вспышек) ===== */
/* ===== Фильтры «Базы знаний»: выпадающие списки с галочками ===== */
.fact-filters { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
@media (min-width: 900px) { .fact-filters .f-search { grid-column: span 2; } }
.f-go button { width: 100%; }
.filters .label, .filters label[for] { display: block; margin: 0 0 6px; color: var(--muted); font-size: .85rem; }
.multi { position: relative; }
.multi > summary {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 36px 0 12px; margin: 0; position: relative;
  color: var(--text); background: var(--sink); border: 1px solid var(--line-2); border-radius: var(--r-s);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.35); transition: border-color .2s, box-shadow .2s;
}
.multi > summary::after {
  content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .25s var(--spring), margin .25s;
}
.multi[open] > summary::after { transform: rotate(-135deg); margin-top: -2px; }
.multi > summary:hover { border-color: rgba(255,255,255,.22); }
.multi[open] > summary, .multi > summary:focus-visible { outline: none; border-color: rgba(167,139,250,.65); box-shadow: inset 0 2px 8px rgba(0,0,0,.35), 0 0 0 4px rgba(167,139,250,.14); }
.multi-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-n { flex: none; }
.multi-n[hidden] { display: none; }
/* Выбранный фильтр (не «все») подсвечен акцентом */
.multi:has(input:checked) > summary { border-color: rgba(167,139,250,.45); background: linear-gradient(180deg, rgba(167,139,250,.12), rgba(167,139,250,.04)), var(--sink); }
.multi-panel {
  position: absolute; z-index: 15; top: calc(100% + 8px); left: 0; min-width: 100%; width: max-content; max-width: min(340px, 86vw);
  max-height: 320px; overflow-y: auto; padding: 6px; border-radius: var(--r-m);
  background: radial-gradient(120% 70% at 20% 0%, rgba(255,255,255,.12), transparent 50%), rgba(22,19,38,.94);
  border: 1px solid var(--edge); box-shadow: inset 0 1px 1px rgba(255,255,255,.25), 0 24px 50px -12px rgba(0,0,0,.95), 0 0 40px -16px rgba(167,139,250,.5);
  backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  animation: pop .22s var(--ease) backwards; transform-origin: top left; scrollbar-width: thin;
}
.fact-filters > div:nth-last-child(-n+3) .multi-panel { left: auto; right: 0; transform-origin: top right; }
label.opt {
  display: flex; align-items: center; gap: 10px; margin: 0; min-height: 40px; padding: 6px 10px; border-radius: 10px;
  color: var(--text-2); font-size: .92rem; cursor: pointer; transition: background-color .15s, color .15s;
}
label.opt:hover { background: rgba(255,255,255,.06); color: #fff; }
label.opt:has(input:checked) { color: #fff; background: rgba(167,139,250,.12); }
label.opt input {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 0; border-radius: 6px; flex: none; cursor: pointer;
  background: rgba(0,0,0,.35); border: 1.5px solid rgba(255,255,255,.25); box-shadow: none; transition: background-color .15s, border-color .15s, transform .15s var(--spring);
}
label.opt input:checked {
  border-color: transparent; transform: scale(1.06);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b0614' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 14px no-repeat, linear-gradient(180deg, var(--accent-hi), var(--accent-lo));
  box-shadow: 0 0 12px -2px rgba(167,139,250,.8);
}
label.opt input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Телефон: список раскрывается прямо в форме на всю ширину, а не всплывает поверх */
@media (max-width: 599px) {
  .fact-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .fact-filters .f-search, .fact-filters .f-go, .fact-filters > div:has(.multi[open]) { grid-column: 1 / -1; }
  .multi-panel, .fact-filters > div:nth-last-child(-n+3) .multi-panel { position: static; width: auto; max-width: none; margin-top: 8px; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes swap-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes flash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes dock-in { from { opacity: 0; transform: translateY(30px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes aurora-in { from { opacity: 0; transform: scale(1.08); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 currentColor; } 70%, 100% { box-shadow: 0 0 0 6px transparent; } }
@keyframes shine { from { transform: skewX(-20deg) translateX(0); } to { transform: skewX(-20deg) translateX(420%); } }
@keyframes loading { to { transform: translateX(100%); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: none; } }

/* Кто просил меньше движения — без анимаций */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
