/* ============================================================
   FinPulse — редизайн «строгий финтех + премиальный минимализм»
   Темы: Indigo Night (dark, по умолчанию) и Premium Light.
   Токены — из дизайн-пакета design_handoff_finpulse (hifi).
   ============================================================ */

:root, [data-theme="dark"] {
  --bg: oklch(0.165 0.022 265);
  --surface: oklch(0.215 0.026 265);
  --surface2: oklch(0.275 0.028 265);
  --border: oklch(1 0 0 / .09);
  --border2: oklch(1 0 0 / .05);
  --text: oklch(0.97 0.006 265);
  --dim: oklch(0.67 0.02 265);
  --faint: oklch(0.52 0.02 265);
  --accent: oklch(0.72 0.15 255);
  --accent-ink: #06122b;
  --accent-dim: oklch(0.72 0.15 255 / .16);
  --up: oklch(0.8 0.15 155);
  --down: oklch(0.7 0.19 25);
  /* цвета разделов */
  --cat-macro: oklch(0.72 0.15 292);
  --cat-comp: oklch(0.72 0.13 245);
  --cat-crypto: oklch(0.78 0.15 52);
  --cat-oil: oklch(0.78 0.12 68);
  --cat-mkt: oklch(0.74 0.12 268);
  --cat-fx: oklch(0.75 0.13 160);
  --cat-tech: oklch(0.75 0.12 210);
  --cat-geo: oklch(0.7 0.16 25);
  --cat-events: oklch(0.75 0.12 185);
  --cat-soc: oklch(0.73 0.14 340);
  --cat-misc: oklch(0.6 0.02 265);
  --cardsh: 0 1px 2px rgba(0,0,0,0);
  --knob: #fff;
  --overlay: rgba(0,0,0,.5);
}

[data-theme="light"] {
  --bg: oklch(0.965 0.004 265);
  --surface: oklch(1 0 0);
  --surface2: oklch(0.93 0.006 265);
  --border: oklch(0 0 0 / .09);
  --border2: oklch(0 0 0 / .055);
  --text: oklch(0.24 0.02 265);
  --dim: oklch(0.5 0.02 265);
  --faint: oklch(0.62 0.015 265);
  --accent: oklch(0.5 0.16 268);
  --accent-ink: #ffffff;
  --accent-dim: oklch(0.5 0.16 268 / .1);
  --up: oklch(0.52 0.15 155);
  --down: oklch(0.55 0.2 25);
  --cat-macro: oklch(0.5 0.17 292);
  --cat-comp: oklch(0.5 0.16 255);
  --cat-crypto: oklch(0.58 0.16 45);
  --cat-oil: oklch(0.55 0.12 68);
  --cat-mkt: oklch(0.5 0.14 268);
  --cat-fx: oklch(0.52 0.13 160);
  --cat-tech: oklch(0.52 0.12 215);
  --cat-geo: oklch(0.55 0.18 25);
  --cat-events: oklch(0.52 0.11 185);
  --cat-soc: oklch(0.55 0.16 340);
  --cat-misc: oklch(0.55 0.02 265);
  --cardsh: 0 1px 2px rgba(0,0,0,.05);
  --overlay: rgba(0,0,0,.4);
}

/* кривые анимаций: дефолтные CSS-изинги слабые, «резкий» ease-out
   даёт мгновенный отклик на входах (см. .claude/skills/emil-design-eng) */
:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1); /* iOS-подобная для панелей */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  /* CSS scroll anchoring иначе сам подвигает scrollY, когда где-то выше
     вьюпорта дорастает картинка (ленивая загрузка) — loadContent принимает
     этот сдвиг за ручной скролл пользователя и перестаёт поджимать ленту
     к низу дня в режиме «По дате» (см. stickToBottom); позиции скролла
     везде в приложении и так управляются вручную из JS */
  overflow-anchor: none;
}

.mono, code { font-family: "IBM Plex Mono", ui-monospace, monospace; }

button { font-family: inherit; }
a { color: inherit; }

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

::-webkit-scrollbar { width: 0; height: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  html { scroll-behavior: auto; }
}

/* ---------- шапка ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 6px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
  transition: box-shadow .2s;
}
body.scrolled .topbar { box-shadow: 0 1px 0 var(--border2); }

.logo {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-word {
  font: 700 19px "IBM Plex Sans";
  letter-spacing: -.02em;
  white-space: nowrap;
}
.logo-word b { color: var(--accent); font-weight: 700; }

.icon-btn {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 11px;
  background: var(--surface);
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform .12s var(--ease-out);
}
.icon-btn:active { transform: scale(.92); }

/* #menuBtn: бургер ⇄ стрелка «назад», когда пользователь углубился в разделы
   (актуально в браузере/десктопе, где нет системной BackButton Telegram) */
#menuBtn .mb-back { display: none; }
body.can-go-back #menuBtn .mb-burger { display: none; }
body.can-go-back #menuBtn .mb-back { display: block; }

.bell-dot {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
}

/* ---------- поиск (раскрывается по иконке) ---------- */
.search-row {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .22s var(--ease-out);
  padding: 0 16px;
}
body.search-open .search-row { grid-template-rows: 1fr; }
.search-wrap { overflow: hidden; min-height: 0; }
.search-input-wrap { position: relative; }

#search {
  width: 100%;
  padding: 10px 36px 10px 13px;
  margin: 6px 0 2px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 500 14px "IBM Plex Sans";
  outline: none;
}
#search:focus-visible { border-color: var(--accent); }
#search::placeholder { color: var(--faint); }
#search::-webkit-search-cancel-button { display: none; }

.search-clear[hidden] { display: none; }
.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--faint);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* подсказки по хештегам в поиске — были отдельным вечно видимым рядом чипов
   над лентой, теперь появляются только внутри открытого поиска, пока поле
   пустое (см. renderHashtags); тап фильтрует ленту, как раньше */
.search-tags-wrap:has(.tag-chips:empty) { display: none; }
.search-tags-label {
  padding: 2px 3px 6px;
  font: 700 10px "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
}
.search-tags-wrap .tag-chips { padding: 0 0 4px; }

/* ---------- сегмент-контролы ---------- */
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: 12px;
}
.seg button {
  flex: 1;
  padding: 7px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--dim);
  font: 600 12px "IBM Plex Sans";
  cursor: pointer;
  white-space: nowrap;
  transition: background .1s ease;
}
/* тапается десятками раз в день — фидбэк без transform, чтобы не утомлять анимацией */
.seg button:not(.active):active { background: var(--surface2); }
.seg button.active {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.seg-tabs { margin: 8px 16px 0; }
.seg-tabs[hidden] { display: none; }

/* ---------- хлебные крошки ---------- */
.crumb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 0;
}
.crumb-row:has(.crumb:empty) { display: none; }

.crumb {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 500 12px "IBM Plex Mono", monospace;
  color: var(--dim);
}
.crumb:empty { display: none; }
.crumb-head { font: 700 17px "IBM Plex Sans"; letter-spacing: -.02em; color: var(--text); }
.crumb-sep { margin: 0 5px; color: var(--faint); }
.crumb-part { font-weight: 600; }

.pin-btn[hidden] { display: none; }
.pin-btn {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform .12s var(--ease-out), background .15s, color .15s;
}
.pin-btn::after { content: ""; position: absolute; inset: -6px; }
.pin-btn:active { transform: scale(.9); }
.pin-btn.pinned { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- чипы ---------- */
.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 8px 16px 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--dim);
  border: none;
  font: 600 11px "IBM Plex Mono", monospace;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s var(--ease-out);
}
.chip:active { transform: scale(.94); }
.chip.active { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.chip .cnt { color: var(--faint); font-size: 10px; }
.chip.active .cnt { color: var(--accent-ink); opacity: .7; }

.cat-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cat, var(--accent));
  flex: 0 0 auto;
}

/* ---------- главная: «Моё» и «Сейчас обсуждают» ---------- */
.home:empty { display: none; }
.home { padding: 2px 0 0; }

.home-row { padding: 6px 0 0; }
.home-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 16px 6px;
  font: 700 10px "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
}
.home-label svg { color: var(--accent); }
.home-chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 16px 4px;
  scrollbar-width: none;
}
.home-chips::-webkit-scrollbar { display: none; }

.home-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: color-mix(in oklch, var(--cat, var(--accent)) 12%, transparent);
  color: var(--text);
  font: 600 12px "IBM Plex Sans";
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s var(--ease-out);
}
.home-chip:active { transform: scale(.94); }
.home-chip .hc-icon { display: flex; color: var(--dim); }
.home-chip.trend { background: var(--surface); font-weight: 500; }
.home-chip.trend .cnt { color: var(--faint); font: 600 10px "IBM Plex Mono", monospace; }

/* ---------- навигация по дням ---------- */
/* закреплена внизу экрана (над таббаром), а не в потоке ленты — см. body.date-open
   ниже: лента получает padding-bottom на высоту панели, чтобы последний пост
   дня не прятался под ней (день открывается прокрученным вниз, см. loadContent) */
.date-bar[hidden] { display: none; }
.date-bar {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--nav-h, 58px) + 10px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 32;
}
.date-nav {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 9px;
  background: var(--surface2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s var(--ease-out);
}
.date-nav:active { transform: scale(.9); }
.date-nav:disabled { opacity: .3; pointer-events: none; }
.date-current {
  flex: 1;
  border: none;
  background: none;
  color: var(--text);
  font: 700 14px "IBM Plex Sans";
  cursor: pointer;
  padding: 8px;
  text-transform: capitalize;
}

/* прозрачный поверх центра дат-бара (не перекрывает кнопки ‹ ›) — тап по нему
   открывает нативный календарь напрямую, без ненадёжного showPicker() */
.date-pick {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50px;
  right: 50px;
  opacity: 0;
  border: none;
  background: none;
  cursor: pointer;
  z-index: 2;
}

/* ---------- разделители ---------- */
.day-sep {
  font: 700 10px "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
  padding: 8px 4px 0;
}
.day-sep:first-child { padding-top: 0; }

.seen-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font: 600 10.5px "IBM Plex Mono", monospace;
  padding: 2px 0;
}
.seen-sep::before, .seen-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in oklch, var(--accent) 40%, transparent);
}

/* ---------- плашка новых постов ---------- */
.new-banner {
  display: none;
  position: sticky;
  top: calc(58px + env(safe-area-inset-top, 0px));
  z-index: 15;
  margin: 8px auto 0;
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 12px "IBM Plex Mono", monospace;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.22);
  animation: drop .25s var(--ease-out);
}
body.has-new .new-banner { display: block; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } }

/* ---------- pull-to-refresh ---------- */
.ptr {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  transition: height .18s ease;
}
.ptr svg { opacity: .5; transition: opacity .15s, transform .15s; }
.ptr.ready svg { opacity: 1; transform: rotate(180deg); color: var(--accent); }
.ptr.loading svg { animation: spin .8s linear infinite; opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- лента ---------- */
#feed { padding: 10px 16px; display: flex; flex-direction: column; gap: 10px; }
/* режим «По дате»: панель дат зафиксирована внизу — отодвигаем последний
   пост наверх на её высоту (--datebar-h считает syncDateBarHeight в app.js) */
body.date-open #feed { padding-bottom: calc(var(--datebar-h, 46px) + 20px); }

.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cat, var(--accent));
  border-radius: 15px;
  padding: 13px 14px;
  box-shadow: var(--cardsh);
  animation: fadeUp .2s var(--ease-out);
  /* карточки за экраном не рендерятся — длинная лента не тормозит */
  content-visibility: auto;
  contain-intrinsic-size: auto 160px;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

.post-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}
.post-date {
  font: 600 10.5px "IBM Plex Mono", monospace;
  color: var(--faint);
  white-space: nowrap;
}

.post-category {
  padding: 3px 8px;
  border: none;
  border-radius: 7px;
  font: 700 9.5px "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: color-mix(in oklch, var(--cat, var(--accent)) 15%, transparent);
  color: var(--cat, var(--accent));
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}
.post-category::after { content: ""; position: absolute; inset: -8px; }

.post-src {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 600 10.5px "IBM Plex Mono", monospace;
  color: var(--dim);
}
.post-ai .post-src { color: var(--accent); font-weight: 700; }

.post-sum {
  margin-bottom: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--accent-dim);
  font: 500 12px "IBM Plex Sans";
  line-height: 1.45;
  color: var(--text);
}
.post-sum .ai-tag {
  color: var(--accent);
  font: 700 9px "IBM Plex Mono", monospace;
  letter-spacing: .08em;
}

.post-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
  font-size: 14px;
}
.post-text a { color: var(--accent); text-decoration: none; }

.tag-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
}

.post-text.clamped {
  max-height: 230px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 78%, transparent);
  mask-image: linear-gradient(180deg, #000 78%, transparent);
}
.post-expand {
  margin-top: 2px;
  background: none;
  border: none;
  color: var(--accent);
  font: 600 12.5px "IBM Plex Sans";
  cursor: pointer;
  padding: 8px 0;
  transition: opacity .12s ease;
}
.post-expand:active { opacity: .55; }

.post-img {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 10px;
  margin-top: 9px;
  background: var(--surface2);
  cursor: zoom-in;
}

.post-footer {
  margin-top: 9px;
  display: flex;
  align-items: center;
  gap: 14px;
  font: 600 11px "IBM Plex Mono", monospace;
  color: var(--faint);
}
.post-views { white-space: nowrap; }

/* хештеги в футере карточки (по дизайну: цвет --accent, моно) */
.post-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.post-tags .tag-link {
  font: 600 10.5px "IBM Plex Mono", monospace;
  white-space: nowrap;
}

.post-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }

.post-fav, .post-share, .post-open {
  border: none;
  background: none;
  color: var(--dim);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .15s var(--ease-out), color .15s;
}
.post-open {
  width: auto;
  padding: 0 6px;
  gap: 5px;
  white-space: nowrap;
  text-decoration: none;
  font: 600 10.5px "IBM Plex Mono", monospace;
}
.post-fav:active, .post-share:active, .post-open:active { transform: scale(.92); }
.post-fav.faved { color: var(--accent); }
.post-fav.faved svg { fill: var(--accent); stroke: var(--accent); animation: pop .25s ease; }
@keyframes pop { 40% { transform: scale(1.35); } }

/* ---------- детальный просмотр поста ---------- */
.post-view { padding: 4px 0 10px; }
.post-view .post-meta { margin-bottom: 6px; }
.pv-date {
  font: 600 11px "IBM Plex Mono", monospace;
  color: var(--faint);
  margin-bottom: 12px;
}
/* крупнее и свободнее, чем в карточке; текст можно выделять и копировать */
.pv-text {
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-user-select: text;
  user-select: text;
}
.post-view .post-sum { font-size: 13px; padding: 10px 12px; }
.post-view .post-img { max-height: none; }
.pv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 14px;
}
.pv-tags .tag-link { font: 600 12px "IBM Plex Mono", monospace; }
.post-dups {
  font: 700 10.5px "IBM Plex Mono", monospace;
  color: var(--accent);
  white-space: nowrap;
}

.pv-dups { margin-top: 16px; }
.pv-dup {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  margin-top: 7px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  transition: transform .12s var(--ease-out);
}
.pv-dup:active { transform: scale(.98); }
.pv-dup b { font: 700 12px "IBM Plex Mono", monospace; color: var(--accent); }
.pv-dup span {
  font: 500 13px/1.4 "IBM Plex Sans";
  color: var(--dim);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.pv-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.pv-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 600 12.5px "IBM Plex Sans";
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .12s var(--ease-out);
}
.pv-btn:active { transform: scale(.97); }
.pv-btn svg { color: var(--dim); flex: 0 0 auto; }

.post { cursor: pointer; }

/* ---------- лайтбокс ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .88);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 70;
  cursor: zoom-out;
}
body.lightbox-open .lightbox { opacity: 1; pointer-events: auto; }
.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* ---------- пустые состояния ---------- */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--dim);
  font-size: 14px;
}
.empty-icon { color: var(--faint); margin-bottom: 12px; }
.empty-icon svg { width: 40px; height: 40px; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: 600 14px "IBM Plex Sans";
  cursor: pointer;
  padding: 10px 12px;
  margin-top: 4px;
  transition: opacity .12s ease;
}
.link-btn:active { opacity: .55; }

/* ---------- топ тем ---------- */
.topics { display: flex; flex-direction: column; gap: 8px; }
.topics .seg { margin-bottom: 4px; }

.topic {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: var(--cardsh);
  transition: transform .12s var(--ease-out);
}
.topic:active { transform: scale(.98); }

.topic-rank {
  flex: 0 0 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface2);
  color: var(--dim);
  font: 700 14px "IBM Plex Mono", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topic.top3 .topic-rank { background: var(--accent); color: var(--accent-ink); }

.topic-main { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.topic-name { font: 700 15px "IBM Plex Sans"; }
.topic-count { font: 500 11px "IBM Plex Mono", monospace; color: var(--dim); white-space: nowrap; }
.topic-arrow { color: var(--faint); display: flex; }
.spark { display: block; }
.spark rect { fill: var(--dim); }
.topic.top3 .spark rect { fill: var(--accent); }

/* ---------- статистика архива ---------- */
.stats { display: flex; flex-direction: column; gap: 10px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 14px;
  box-shadow: var(--cardsh);
}
.stat-hero { text-align: center; padding: 22px 14px; }
.stat-big { font: 700 32px "IBM Plex Mono", monospace; letter-spacing: -.02em; }
.stat-sub { font: 500 12.5px "IBM Plex Sans"; color: var(--dim); margin-top: 4px; }

/* заголовок карточки «Активность» + сегмент-переключатель «По дням/неделям»
   в одну строку; сам .sheet-section переносит свой отступ на строку-обёртку,
   чтобы переключатель не задирался выше подписи */
.stat-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0 8px;
}
.stat-card-head .sheet-section { margin: 0; }
/* .stat-card уже на var(--surface) — переключателю нужен свой фон для контраста,
   как у .notif-card .seg */
.act-seg { width: auto; padding: 3px; gap: 3px; background: var(--surface2); }
.act-seg button { padding: 5px 10px; font-size: 11px; flex: 0 0 auto; }
.act-peak { font: 600 11.5px "IBM Plex Mono", monospace; color: var(--dim); margin-bottom: 6px; }
.act-peak b { color: var(--text); }
.act-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 64px;
}
.act-col { flex: 1; min-width: 0; }
.act-bar {
  width: 100%;
  border-radius: 2px 2px 1px 1px;
  background: color-mix(in oklch, var(--accent) 30%, transparent);
}
.act-col.act-peak-col .act-bar { background: var(--accent); }
.act-range {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font: 500 10px "IBM Plex Mono", monospace;
  color: var(--faint);
}

.year-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding-top: 6px;
}
.yc-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.yc-val { font: 500 9px "IBM Plex Mono", monospace; color: var(--faint); white-space: nowrap; }
.yc-bar {
  width: 100%;
  max-width: 26px;
  border-radius: 5px 5px 2px 2px;
  background: var(--accent);
  opacity: .85;
}
.yc-year { font: 600 10px "IBM Plex Mono", monospace; color: var(--dim); }

.cat-row { padding: 7px 0 2px; }
.cat-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
}
.cat-name { font-weight: 700; display: inline-flex; align-items: center; gap: 7px; }
.cat-name .cat-dot { width: 7px; height: 7px; }
.cat-cnt { font: 500 11px "IBM Plex Mono", monospace; color: var(--dim); white-space: nowrap; }
.cat-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface2);
  margin-top: 5px;
  overflow: hidden;
}
.cat-bar i { display: block; height: 100%; border-radius: 3px; background: var(--cat, var(--accent)); }

.stat-day { padding: 6px 0 0; font-size: 14px; }

/* ---------- скелетоны ---------- */
.skeleton {
  border-radius: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 40%,
    color-mix(in oklch, var(--text) 6%, transparent) 50%, transparent 60%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
.sk-line {
  height: 12px;
  border-radius: 6px;
  background: var(--surface2);
}
.sk-line.sk-badge { width: 90px; height: 18px; }
.sk-line.short { width: 55%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.status { text-align: center; color: var(--faint); padding: 18px; font: 500 12px "IBM Plex Mono", monospace; }

/* ---------- кнопка наверх ---------- */
.fab {
  position: fixed;
  right: 14px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
  z-index: 30;
}
body.show-fab .fab { opacity: 1; pointer-events: auto; transform: translateY(0); }
/* в режиме «По дате» кнопка «наверх» иначе перекрывается закреплённой снизу
   панелью дат — поднимаем её над панелью */
body.date-open .fab { bottom: calc(var(--nav-h, 58px) + var(--datebar-h, 46px) + 20px); }

/* ---------- нижняя навигация ---------- */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border2);
  background: var(--bg);
  z-index: 35;
}
.bottomnav button {
  flex: 1;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  color: var(--dim);
  padding: 2px 0;
  transition: color .15s;
}
.bottomnav button span { font: 700 9.5px "IBM Plex Sans"; }
.bottomnav button svg { transition: transform .12s var(--ease-out); }
.bottomnav button:active svg { transform: scale(.88); }
.bottomnav button.active { color: var(--accent); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 40;
  touch-action: none;
}
body.drawer-open .overlay { opacity: 1; pointer-events: auto; }

/* при открытых панелях фон не скроллится */
body.drawer-open, body.notif-open, body.rates-open,
body.premium-open, body.postview-open, body.onboard-open { overflow: hidden; }

/* ---------- drawer ---------- */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 82%;
  max-width: 300px;
  background: var(--bg);
  transform: translateX(-105%);
  /* закрытие быстрее открытия: система отвечает мгновенно */
  transition: transform .2s var(--ease-drawer);
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: none;
  border-right: 1px solid var(--border);
}
body.drawer-open .drawer { transform: translateX(0); transition-duration: .28s; box-shadow: 20px 0 60px rgba(0, 0, 0, .35); }

.drawer-header { padding: calc(16px + env(safe-area-inset-top, 0px)) 18px 12px; flex: 0 0 auto; }
.drawer-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-brand .logo { flex: 1; }
.drawer-brand .logo-word { font-size: 20px; }
.drawer-total {
  font: 500 11px "IBM Plex Mono", monospace;
  color: var(--dim);
  margin-top: 7px;
}

.theme-btn { border: 1px solid var(--border); }
.theme-btn .th-sun { display: none; }
[data-theme="light"] .theme-btn .th-sun { display: block; }
[data-theme="light"] .theme-btn .th-moon { display: none; }

.menu { padding: 0 10px; flex: 1; overflow-y: auto; }

.menu-label {
  padding: 14px 12px 6px;
  font: 700 10px "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 11px;
  padding: 11px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 15px;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}
.menu-item:active { background: var(--surface); }
.menu-item.active { background: var(--accent); color: var(--accent-ink); }
.menu-item.current { background: var(--accent-dim); }

.menu-item .mi-icon {
  flex: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
}
.menu-item.active .mi-icon { color: var(--accent-ink); }
.menu-item .mi-icon .cat-dot { width: 9px; height: 9px; }
.menu-item .mi-name { flex: 1; font: 600 14.5px "IBM Plex Sans"; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item .mi-count { font: 600 11px "IBM Plex Mono", monospace; color: var(--dim); }
.menu-item.active .mi-count { color: var(--accent-ink); opacity: .75; }
.menu-item .mi-chevron {
  color: var(--faint);
  transition: transform .2s var(--ease-in-out);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: -7px -10px -7px 0;
  border-radius: 10px;
}
.menu-item.active .mi-chevron { color: var(--accent-ink); }
.menu-item.expanded .mi-chevron { transform: rotate(90deg); }

.menu-subs {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .22s var(--ease-in-out);
}
.menu-subs.open { grid-template-rows: 1fr; }
.menu-subs-inner { overflow: hidden; min-height: 0; }

.menu-sub {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 10px 12px 10px 43px;
  border: none;
  background: none;
  color: var(--text);
  font: 500 13.5px "IBM Plex Sans";
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
}
.menu-sub:active { background: var(--surface); }
.menu-sub.active { background: var(--accent); color: var(--accent-ink); }
.menu-sub .mi-name { flex: 1; }
.menu-sub .mi-count { font: 600 11px "IBM Plex Mono", monospace; color: var(--dim); }
.menu-sub.active .mi-count { color: var(--accent-ink); opacity: .75; }

.pin-row { cursor: pointer; user-select: none; }
.pin-row .pin-del {
  border: none;
  background: none;
  color: var(--faint);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: -7px -10px -7px 0;
  cursor: pointer;
  border-radius: 10px;
}
.pin-row.active .pin-del { color: var(--accent-ink); }

.drawer-footer {
  padding: 12px;
  flex: 0 0 auto;
  border-top: 1px solid var(--border2);
}
.drawer-footer:empty { display: none; }

.premium-cta {
  width: 100%;
  border: 1px solid color-mix(in oklch, var(--accent) 35%, transparent);
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  border-radius: 13px;
  cursor: pointer;
  font: 700 14px "IBM Plex Sans";
}

/* ---------- панели (уведомления / курсы / premium) ---------- */
.notif {
  position: fixed;
  inset: 0;
  background: var(--bg);
  transform: translateY(105%);
  /* закрытие быстрее открытия */
  transition: transform .22s var(--ease-drawer);
  z-index: 60;
  overflow-y: auto;
}
body.notif-open #notif,
body.rates-open #rates,
body.premium-open #premium,
body.postview-open #postView,
body.onboard-open #onboard { transform: translateY(0); transition-duration: .3s; }

/* ---------- онбординг ---------- */
.onboard-body {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 40px);
  padding-top: calc(30px + env(safe-area-inset-top, 0px));
}
.onboard-hero { margin-bottom: 22px; }
.onboard-title {
  font: 700 26px "IBM Plex Sans";
  letter-spacing: -.03em;
  margin: 14px 0 8px;
}
.onboard-desc {
  font: 400 14px/1.5 "IBM Plex Sans";
  color: var(--dim);
}
.onboard-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.ob-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: 600 14px "IBM Plex Sans";
  cursor: pointer;
  transition: transform .12s var(--ease-out), background .15s, color .15s;
}
.ob-chip:active { transform: scale(.95); }
.ob-chip.sel {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.ob-chip.sel .cat-dot { background: var(--accent-ink); }
.onboard-cta { margin-top: auto; padding: 24px 0 10px; }
.onboard-cta .link-btn {
  display: block;
  width: 100%;
  text-align: center;
  color: var(--dim);
  margin-top: 6px;
}

.notif-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.notif-title { font: 700 18px "IBM Plex Sans"; letter-spacing: -.02em; }

.notif-body { padding: 4px 18px calc(30px + env(safe-area-inset-bottom, 0px)); }

.notif-summary { font: 500 12.5px "IBM Plex Sans"; color: var(--dim); line-height: 1.45; margin: 6px 2px 12px; }

.notif-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px 14px;
  margin-bottom: 14px;
  box-shadow: var(--cardsh);
}
.notif-card .sheet-section { margin-top: 0; }

.sheet-hint { font: 500 12px "IBM Plex Sans"; color: var(--dim); line-height: 1.5; margin: 8px 0 0; }

.sheet-section {
  font: 700 10px "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
  margin: 16px 0 8px;
}

/* строка темы с тумблером */
.nrow {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  cursor: pointer;
  user-select: none;
}
.nrow + .nrow { border-top: 1px solid var(--border2); }
.nrow .mi-icon { flex: 0 0 14px; display: flex; align-items: center; justify-content: center; }
.nrow .mi-icon .cat-dot { width: 8px; height: 8px; }
.nrow-name { flex: 1; font: 600 14px "IBM Plex Sans"; min-width: 0; }
.nrow .mi-count { font: 600 11px "IBM Plex Mono", monospace; color: var(--dim); }
.nrow .mi-chevron { color: var(--faint); display: flex; transition: transform .2s var(--ease-in-out); }
.nrow .mi-chevron.open { transform: rotate(90deg); }
.nrow-sub { padding-left: 25px; cursor: default; }
.nrow-sub .nrow-name { font-weight: 500; font-size: 13.5px; }

/* тумблер */
.switch {
  flex: 0 0 44px;
  height: 27px;
  border: none;
  border-radius: 14px;
  background: var(--surface2);
  position: relative;
  cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--knob, #fff);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transition: transform .2s var(--ease-in-out);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(17px); }

/* чипы ключевых слов — pill-теги */
.kw-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.kw-chip {
  border: none;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 600 12.5px "IBM Plex Sans";
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform .12s var(--ease-out);
}
.kw-chip:active { transform: scale(.94); }
.kw-chip span { opacity: .65; display: flex; }

.sheet-row { display: flex; gap: 8px; margin: 10px 0 0; }
.sheet-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font: 500 13px "IBM Plex Sans";
  outline: none;
}
.sheet-row input:focus-visible { border-color: var(--accent); border-style: solid; }
.sheet-row input::placeholder { color: var(--faint); }
.sheet-row button {
  flex: 0 0 46px;
  border: none;
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.notif-card .seg { background: var(--surface2); }
.notif-card .seg button.active { background: var(--accent); color: var(--accent-ink); }
.notif-card .seg button { padding: 9px; font-size: 13px; }

.delivery-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  font: 600 13px "IBM Plex Sans";
  color: var(--text);
}
.delivery-row select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--text);
  font: 600 13px "IBM Plex Mono", monospace;
  outline: none;
}

/* ---------- бегущая строка курсов ---------- */
.ticker[hidden] { display: none; }
.ticker {
  position: sticky;
  top: 0;
  z-index: 21;
  background: var(--bg);
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
  border-bottom: 1px solid var(--border2);
  cursor: pointer;
}
.ticker-track {
  display: flex;
  width: max-content;
  animation: tickerScroll var(--tk-dur, 40s) linear infinite;
}
.ticker:active .ticker-track { animation-play-state: paused; }
.tk-set { display: flex; gap: 18px; padding: 7px 9px; }
.tk { font: 500 11px "IBM Plex Mono", monospace; white-space: nowrap; color: var(--dim); }
.tk b { color: var(--text); font-weight: 700; }
.tk i { font-style: normal; font-size: 10.5px; font-weight: 700; }
.tk i.up { color: var(--up); }
.tk i.down { color: var(--down); }
@keyframes tickerScroll { to { transform: translateX(-50%); } }

body.has-ticker .topbar {
  top: calc(30px + env(safe-area-inset-top, 0px));
  padding-top: 8px;
}
body.has-ticker .new-banner {
  top: calc(88px + env(safe-area-inset-top, 0px));
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; overflow-x: auto; }
}

/* ---------- экран источников ---------- */
.sources-list { display: flex; flex-direction: column; gap: 9px; }
.sources-intro { font: 500 12.5px "IBM Plex Sans"; color: var(--dim); line-height: 1.45; padding: 0 2px 4px; }

.source-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--cardsh);
  transition: transform .12s var(--ease-out);
}
.source-row:active { transform: scale(.98); }
.source-ico {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 11px;
  background: color-mix(in oklch, var(--cat, var(--accent)) 18%, transparent);
  color: var(--cat, var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 16px "IBM Plex Sans";
}
.source-main { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.source-name { font: 700 14.5px "IBM Plex Sans"; }
.source-meta { font: 500 11px "IBM Plex Mono", monospace; color: var(--dim); }
.source-arrow { flex: 0 0 auto; color: var(--faint); display: flex; }

/* ---------- панель курсов ---------- */
/* в отличие от остальных полноэкранных панелей (.notif { inset:0 }) — курсы
   останавливаются над нижней навигацией, чтобы таббар оставался видимым и
   кликабельным (переключение вкладок без предварительного закрытия панели) */
.ratesheet {
  bottom: var(--nav-h, 58px);
  top: 0; left: 0; right: 0;
  /* панель короче вьюпорта на высоту таббара, поэтому базового translateY(105%)
     (.notif) не хватает, чтобы увезти её за экран — в закрытом виде сверху
     торчала полоска; добавляем высоту таббара к сдвигу */
  transform: translateY(calc(105% + var(--nav-h, 58px)));
}
.ratesheet .notif-body { padding-top: 10px; padding-bottom: 18px; }

.rates-group-title {
  font: 700 10px "IBM Plex Mono", monospace;
  color: var(--faint);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0 4px 8px;
}
.rates-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--cardsh);
  margin-bottom: 16px;
  padding: 0;
}
/* .rate-row несёт свой инсет (14px), но .sheet-section — нет: без этого
   заголовок группы («Валюты · ЦБ РФ» и т.п.) прижимается к скруглённому
   углу карточки почти без отступа */
.rates-card .sheet-section { margin: 0; padding: 12px 14px 4px; }

.rate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.rate-row:active { background: var(--surface2); }
.rate-row + .rate-row { border-top: 1px solid var(--border2); }
.rate-label { flex: 0 0 60px; font: 700 14px "IBM Plex Mono", monospace; }
.rate-price { flex: 1 1 auto; min-width: 0; font: 500 14px "IBM Plex Mono", monospace; }
.rate-spark { flex: 0 0 auto; display: block; }
.rate-spark path {
  fill: none;
  stroke: var(--rc, var(--dim));
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.rate-spark-empty { flex: 0 0 58px; }
.rate-chg { flex: 0 0 auto; min-width: 54px; text-align: right; font: 700 12.5px "IBM Plex Mono", monospace; }
.rate-chg .up, .rate-chg.up { color: var(--up); }
.rate-chg .down, .rate-chg.down { color: var(--down); }
.rate-row .up { color: var(--up); }
.rate-row .down { color: var(--down); }
.rate-arrow { flex: 0 0 auto; color: var(--faint); display: flex; }

.rates-updated {
  font: 500 11px "IBM Plex Mono", monospace;
  color: var(--faint);
  padding: 2px 4px 12px;
}

/* детальный экран курса */
.rate-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: none;
  color: var(--accent);
  font: 700 13px "IBM Plex Sans";
  cursor: pointer;
  padding: 6px 6px 6px 0;
  margin-bottom: 6px;
}
.rate-back svg { transform: rotate(180deg); }

.rate-hero { padding: 4px 4px 14px; }
.rate-hero-sym { font: 700 12px "IBM Plex Mono", monospace; color: var(--dim); letter-spacing: .03em; margin-bottom: 6px; }
.rate-hero-price {
  font: 700 38px "IBM Plex Mono", monospace;
  letter-spacing: -.02em;
}
.rate-unit { font: 600 20px "IBM Plex Mono", monospace; color: var(--dim); margin-left: 3px; }
.rate-hero-chg { font: 700 15px "IBM Plex Mono", monospace; margin-top: 2px; }
.rate-hero-chg.up { color: var(--up); }
.rate-hero-chg.down { color: var(--down); }
.rate-hero-sub { color: var(--faint); font-weight: 500; font-size: 13px; }

.rate-tf { margin-bottom: 12px; }
.rate-tf button { font-family: "IBM Plex Mono", monospace; font-size: 12px; }

.rate-chart-wrap {
  position: relative;         /* для плавающей подписи скраба */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 12px 10px;
  margin-bottom: 12px;
  box-shadow: var(--cardsh);
}
.rate-chart {
  display: block;
  width: 100%;
  height: auto;               /* высота из viewBox — подписи чёткие при масштабе */
  touch-action: none;         /* скраб пальцем не прокручивает панель */
}
.rc-line { fill: none; stroke: var(--rc, var(--accent)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke; }
.rc-area { fill: var(--rc, var(--accent)); opacity: .1; stroke: none; }
.rc-grid { stroke: var(--border2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.rc-plabel, .rc-tlabel {
  fill: var(--faint);
  font: 500 8.5px "IBM Plex Mono", monospace;
}
.rc-dot { fill: var(--rc, var(--accent)); }
.rc-dot-ring { fill: var(--surface); }
/* интерактивный курсор скраба — сплошная вертикаль на всю высоту графика,
   цвет линии графика с прозрачностью (не пунктир — тот был еле заметен) */
.rc-cursor { stroke: var(--rc, var(--accent)); stroke-width: 1.5; stroke-opacity: .55; vector-effect: non-scaling-stroke; }
.rc-cursor-dot { fill: var(--rc, var(--accent)); stroke: var(--surface); stroke-width: 1.5; }
.rc-cursor[hidden], .rc-cursor-dot[hidden] { display: none; }
.rate-scrub-badge {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
.rate-scrub-badge[hidden] { display: none; }
.rate-scrub-badge b { font: 700 12px "IBM Plex Mono", monospace; }
.rate-scrub-badge span { font: 500 9px "IBM Plex Mono", monospace; color: var(--faint); }
.rate-chart-empty {
  color: var(--dim);
  font: 500 12.5px "IBM Plex Sans";
  text-align: center;
  padding: 30px 16px;
  line-height: 1.5;
}

.rate-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2px 14px;
  box-shadow: var(--cardsh);
}
.rate-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  font: 600 13px "IBM Plex Sans";
}
.rate-info-row + .rate-info-row { border-top: 1px solid var(--border2); }
.rate-info-row span { color: var(--dim); }
.rate-info-row b, .rate-info-row a { font-family: "IBM Plex Mono", monospace; font-weight: 600; }
.rate-src { color: var(--accent); text-decoration: none; }

.rate-alerts {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px 14px;
  margin-top: 12px;
  box-shadow: var(--cardsh);
}
.rate-alerts .sheet-section {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 0;
}
.rate-alerts .sheet-section svg { width: 12px; height: 12px; }

.alert-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 11px;
  background: var(--surface2);
}
.alert-cond { font: 700 13px "IBM Plex Mono", monospace; }
.alert-del {
  border: none;
  background: none;
  color: var(--faint);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  cursor: pointer;
}
.alert-del:active { color: var(--down); }

.alert-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: none;
  color: var(--accent);
  font: 600 13px "IBM Plex Sans";
  cursor: pointer;
}
.alert-add-btn svg { width: 15px; height: 15px; }
.alert-add-btn:active { background: var(--surface2); }

.alert-form { margin-top: 10px; }
.alert-form .seg { background: var(--surface2); margin-bottom: 8px; }
.alert-form-hint { color: var(--down); min-height: 0; }
.alert-form-hint:empty { margin: 0; }

/* ---------- ИИ-сводки ---------- */
.digests { display: flex; flex-direction: column; gap: 12px; }

.digest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px 16px;
  box-shadow: var(--cardsh);
}
.digest-card + .digest-card { opacity: .8; }
.digest-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.digest-kind { font: 700 15px "IBM Plex Sans"; letter-spacing: -.01em; }
.digest-date { font: 600 11px "IBM Plex Mono", monospace; color: var(--dim); white-space: nowrap; }
.digest-card .post-text { font-size: 13px; line-height: 1.5; }

/* ---------- премиум ---------- */
.premium-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 13px 14px;
  border: 1px solid color-mix(in oklch, var(--accent) 35%, transparent);
  border-radius: 15px;
  background: var(--accent-dim);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform .12s var(--ease-out);
}
.premium-btn:active { transform: scale(.98); }
.pb-star { color: var(--accent); display: flex; }
.pb-main { flex: 1; font: 500 12.5px "IBM Plex Sans"; line-height: 1.35; color: var(--dim); }
.pb-main b { display: block; font: 700 14px "IBM Plex Sans"; color: var(--accent); }
.pb-price { font: 700 12px "IBM Plex Mono", monospace; color: var(--accent); white-space: nowrap; }

/* экран Premium */
.premium-body { display: flex; flex-direction: column; min-height: calc(100vh - 70px); }

.premium-badge svg { width: 13px; height: 13px; }
.premium-badge {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--accent-dim);
  border: 1px solid color-mix(in oklch, var(--accent) 30%, transparent);
  color: var(--accent);
  font: 700 11px "IBM Plex Mono", monospace;
  letter-spacing: .05em;
  margin: 4px 0 20px;
}
.premium-title {
  font: 700 27px "IBM Plex Sans";
  line-height: 1.15;
  letter-spacing: -.03em;
  margin-bottom: 10px;
}
.premium-desc {
  font: 400 14px "IBM Plex Sans";
  line-height: 1.55;
  color: var(--dim);
  margin-bottom: 22px;
}
.premium-feats { display: flex; flex-direction: column; gap: 14px; margin-bottom: 24px; }
.premium-feat { display: flex; align-items: center; gap: 12px; font: 600 14px "IBM Plex Sans"; }
.premium-feat .pf-check {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.premium-cta-block { margin-top: auto; padding-bottom: 10px; }
.premium-price { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.premium-price b { font: 700 30px "IBM Plex Mono", monospace; }
.premium-price span { font: 500 14px "IBM Plex Sans"; color: var(--dim); }
.premium-buy {
  width: 100%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  border-radius: 16px;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 16px "IBM Plex Sans";
  cursor: pointer;
  transition: transform .12s var(--ease-out);
}
.premium-buy:active { transform: scale(.98); }
.premium-note {
  text-align: center;
  font: 500 11px "IBM Plex Mono", monospace;
  color: var(--faint);
  margin-top: 12px;
}
.premium-active-note {
  font: 600 13px "IBM Plex Sans";
  color: var(--up);
  margin-bottom: 14px;
}

/* ---------- админка ---------- */

/* видимость целиком на CSS: элемент рендерится в DOM всегда, но появляется
   только когда на body есть .is-admin (ставится после успешного пинга
   /api/admin/ping) — так не нужно перерисовывать меню/просмотр поста,
   когда ответ придёт позже первого рендера */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: flex !important; }

.admin-screen { display: flex; flex-direction: column; }

.admin-textarea {
  width: 100%;
  min-height: 110px;
  padding: 11px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font: 500 16px/1.45 "IBM Plex Sans"; /* >=16px — iOS не зумит инпут */
  outline: none;
  resize: vertical;
}
.admin-textarea:focus-visible { border-color: var(--accent); border-style: solid; }

.admin-row { display: flex; gap: 8px; margin-top: 8px; }
.admin-select {
  flex: 1;
  min-width: 0;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font: 600 14px "IBM Plex Sans";
  outline: none;
}

.admin-input {
  width: 100%;
  margin-top: 8px;
  padding: 11px 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface2);
  color: var(--text);
  font: 500 16px "IBM Plex Sans"; /* >=16px — iOS не зумит инпут */
  outline: none;
}
.admin-input:focus-visible { border-color: var(--accent); border-style: solid; }
.admin-input::placeholder, .admin-textarea::placeholder { color: var(--faint); }

.admin-new-actions { margin-top: 12px; }

.pv-btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pv-btn-accent svg { color: var(--accent-ink); }
.pv-btn:disabled { opacity: .5; cursor: default; }

.pv-btn.danger { border-color: var(--down); color: var(--down); }
.pv-btn.danger svg { color: var(--down); }

/* ряд админ-действий под постом в детальном просмотре — компактный, в два ряда */
.pv-admin { flex-wrap: wrap; margin-top: 8px; }
.pv-admin .pv-btn { flex: 1 1 calc(50% - 4px); font-size: 11.5px; padding: 10px 6px; }

.post-edit { display: flex; flex-direction: column; }

.admin-hidden-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
}
.admin-hidden-row + .admin-hidden-row { border-top: 1px solid var(--border2); }
.admin-hidden-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.admin-hidden-date { font: 600 11px "IBM Plex Mono", monospace; color: var(--dim); }
.admin-hidden-text {
  font: 500 13px "IBM Plex Sans";
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-hidden-actions { display: flex; gap: 2px; flex: 0 0 auto; }
.admin-hidden-actions .link-btn { padding: 6px 8px; margin: 0; font-size: 12.5px; white-space: nowrap; }
.admin-hidden-actions .link-btn.danger { color: var(--down); }

.admin-source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
}
.admin-source-row + .admin-source-row { border-top: 1px solid var(--border2); }
.admin-source-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-source-name { font: 700 13.5px "IBM Plex Sans"; }
.admin-source-meta { font: 500 11px "IBM Plex Mono", monospace; color: var(--dim); }
