/*
 * Компоненты дизайн-системы (классы ui-*): карточка, заголовок раздела, вкладки, «таблетки», сегментный переключатель, период, чипы, аватар,
 * пустое состояние, скелетон, KPI-карточка, плитка-метрика, лента событий, переключатель, подсказка «?», кнопка-значок, всплывающая панель.
 * Цвета — только токены styles/theme.css. Разметку строят функции lib/ui-kit.js; описание — docs/ui/design-system.md.
 */

/* Цветовые семейства: .ui-tone-<имя> задаёт --tone (насыщенный) и --tone-soft (пастельный фон) для чипов, плиток, аватаров, ленты */
.ui-tone-green { --tone: var(--green); --tone-soft: var(--green-soft); }
.ui-tone-blue { --tone: var(--blue); --tone-soft: var(--blue-soft); }
.ui-tone-orange { --tone: var(--orange); --tone-soft: var(--orange-soft); }
.ui-tone-red { --tone: var(--red); --tone-soft: var(--red-soft); }
.ui-tone-purple { --tone: var(--purple); --tone-soft: var(--purple-soft); }
.ui-tone-teal { --tone: var(--teal); --tone-soft: var(--teal-soft); }
.ui-tone-amber { --tone: var(--amber); --tone-soft: var(--amber-soft); }
.ui-tone-gray { --tone: var(--gray); --tone-soft: var(--gray-soft); }

/* Раскладка: сетка карточек и колонок */
.ui-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(var(--ui-min, 260px), 1fr)); margin-bottom: var(--space-4); }
.ui-grid--kpi { --ui-min: 270px; }
.ui-grid--tiles { --ui-min: 200px; }
.ui-grid--wide { --ui-min: 420px; }
.ui-stack { display: grid; gap: var(--space-4); }
.ui-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); }
.ui-section-title { margin: var(--space-5) 0 var(--space-3); font-size: var(--fs-xl); font-weight: 600; }

/* ---------- Всплывающая панель ---------- */
.ui-pop {
  position: absolute; z-index: 30; background: var(--surface); border: 1px solid var(--card-border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); transform: translateX(var(--pop-dx, 0px));
}
/* панель выровнена по правому краю кнопки; если слева не хватает места, lib/ui-kit.js (fitPanel) ставит is-start — по левому краю — и добавляет сдвиг --pop-dx */
.ui-pop.is-start { left: 0; right: auto; }

/* ---------- Кнопка-значок ---------- */
.ui-iconbtn {
  position: relative; display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; padding: 0;
  border: 0; border-radius: 12px; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none; font: inherit;
  transition: background var(--transition), color var(--transition);
}
.ui-iconbtn .icon { width: 22px; height: 22px; }
.ui-iconbtn:hover { background: var(--surface-2); color: var(--text); }
.ui-iconbtn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.ui-iconbtn-badge {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--radius-pill);
  background: var(--danger); color: var(--surface); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.ui-theme-switch { display: inline-flex; }
/* колокольчик уведомлений (notify.js) использует .btn.ghost.notify-btn: приводим к виду кнопки-значка */
.topbar .notify-btn { min-height: 40px; width: 40px; padding: 0; border-radius: 12px; color: var(--muted); }
.topbar .notify-btn .icon { width: 22px; height: 22px; }
.topbar .notify-btn:hover { color: var(--text); }

/* ---------- Подсказка «?» ---------- */
.ui-help-wrap { position: relative; display: inline-flex; vertical-align: middle; }
.ui-help { display: inline-grid; place-items: center; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: help; }
.ui-help .icon { width: 16px; height: 16px; }
.ui-help:hover, .ui-help:focus-visible { color: var(--primary); }
/* Подсказка центрируется над значком; у края экрана lib/ui-kit.js (placeTip) задаёт сдвиг --tip-dx внутрь окна, а у верха — класс is-below (под значком) */
.ui-tip {
  position: absolute; z-index: 40; left: 50%; bottom: calc(100% + 8px); transform: translateX(calc(-50% + var(--tip-dx, 0px))); width: max-content; max-width: min(280px, calc(100vw - 24px));
  padding: 8px 12px; border-radius: 10px; background: var(--text); color: var(--bg); font-size: var(--fs-sm); font-weight: 500; line-height: 1.4;
  box-shadow: var(--shadow-lg); pointer-events: none; display: none; text-transform: none; letter-spacing: 0; text-align: left; overflow-wrap: break-word;
}
.ui-help-wrap.is-below .ui-tip { bottom: auto; top: calc(100% + 8px); }
/* пока подсказка скрыта, её нет в раскладке (не растягивает страницу); скринридер читает её через aria-describedby и скрытой */
.ui-help-wrap:hover .ui-tip, .ui-help-wrap:focus-within .ui-tip { display: block; }
.ui-help-wrap.is-dismissed .ui-tip { display: none; }
/* замер размера перед показом: блок занимает место, но не виден */
.ui-help-wrap.is-measuring .ui-tip { display: block; visibility: hidden; }

/* ---------- Карточка ---------- */
.ui-card { background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-5); min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.ui-card--flush { padding: 0; gap: 0; overflow: hidden; }
.ui-card--flush > .ui-card-head { padding: var(--space-4) var(--space-5); }
.ui-card--green { border-color: var(--green); }
.ui-card--blue { border-color: var(--blue); }
.ui-card--orange { border-color: var(--orange); }
.ui-card--red { border-color: var(--red); }
.ui-card--gray { border-color: var(--gray); }
.ui-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2) var(--space-4); padding-bottom: var(--space-3); border-bottom: 1px solid var(--line); }
.ui-card--flush > .ui-card-head { padding-bottom: var(--space-3); }
.ui-card-titlebox { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ui-card-title { margin: 0; font-size: var(--fs-lg); font-weight: 600; overflow-wrap: anywhere; }
.ui-card-side { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.ui-card-body { min-width: 0; }
.ui-card--flush > .ui-card-body { padding: 0; }
.ui-card-foot { padding-top: var(--space-3); border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-sm); }
.ui-card--flush > .ui-card-foot { padding: var(--space-3) var(--space-5); }

/* ---------- Заголовок раздела ---------- */
.ui-page-head { margin-bottom: var(--space-4); }
.ui-crumbs { margin-bottom: var(--space-2); }
.ui-crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); }
.ui-crumbs li + li::before { content: "›"; padding: 0 10px; color: var(--muted); }
.ui-crumbs a { color: var(--primary); text-decoration: none; font-weight: 600; }
.ui-crumbs a:hover { text-decoration: underline; }
.ui-crumbs li[aria-current="page"] { color: var(--text); font-weight: 600; }
.ui-page-head-row { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: var(--space-3) var(--space-4); }
.ui-page-head-text { display: flex; align-items: center; gap: var(--space-3); min-width: 0; flex: 1 1 320px; }
.ui-page-ico { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; background: var(--primary-soft); color: var(--primary); flex: none; }
.ui-page-ico .icon { width: 24px; height: 24px; }
.ui-page-title { margin: 0; font-size: var(--fs-2xl); font-weight: 700; overflow-wrap: anywhere; }
.ui-page-sub { margin: 2px 0 0; color: var(--muted); max-width: 70ch; }

/* ---------- Вкладки с иконками ---------- */
.ui-tabs { display: flex; flex-wrap: wrap; gap: 0 var(--space-1); border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); }
.ui-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted);
  cursor: pointer; text-align: left; position: relative; transition: color var(--transition);
}
.ui-tab::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.ui-tab:hover { color: var(--text); }
.ui-tab[aria-selected="true"] { color: var(--primary); }
.ui-tab[aria-selected="true"]::after { background: linear-gradient(90deg, var(--primary), var(--primary-soft)); }
.ui-tab[disabled] { opacity: 0.5; cursor: default; }
.ui-tab-count { min-width: 22px; padding: 1px 7px; border-radius: var(--radius-pill); background: var(--surface-2); color: var(--muted); font-size: var(--fs-xs); font-weight: 700; text-align: center; }
.ui-tab[aria-selected="true"] .ui-tab-count { background: var(--primary-soft); color: var(--primary); }

/* ---------- «Таблетки»-фильтры ---------- */
.ui-pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ui-pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 16px; border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--primary-soft); color: var(--primary); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; text-align: left;
  transition: background var(--transition), color var(--transition);
}
.ui-pill:hover { border-color: var(--primary); }
.ui-pill[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 12px var(--glow); }
.ui-pill-count { padding: 0 7px; border-radius: var(--radius-pill); background: var(--surface); color: var(--primary); font-size: 11px; font-weight: 700; line-height: 18px; }
.ui-pill[aria-pressed="true"] .ui-pill-count { background: var(--on-primary); color: var(--primary); }

/* ---------- Сегментный переключатель ---------- */
.ui-seg { display: inline-flex; width: fit-content; max-width: 100%; flex-wrap: wrap; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.ui-seg-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 16px; border: 0; border-left: 1px solid var(--line); background: transparent;
  color: var(--text); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; transition: background var(--transition), color var(--transition);
}
.ui-seg-btn:first-child { border-left: 0; }
.ui-seg-btn:hover { background: var(--surface-2); }
.ui-seg-btn[aria-checked="true"] { background: var(--primary); color: var(--on-primary); }
.ui-seg-btn:focus-visible { outline-offset: -3px; }
.ui-seg--sm .ui-seg-btn { min-height: 30px; padding: 3px 12px; }

/* ---------- Выбор периода ---------- */
.ui-period { position: relative; display: inline-block; }
.ui-period-btn, .ui-period-static { display: inline-flex; align-items: center; gap: 10px; color: var(--primary); }
.ui-period-btn { padding: 4px 6px; border: 0; border-radius: 10px; background: transparent; font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer; text-align: right; }
.ui-period-btn:hover, .ui-period-btn[aria-expanded="true"] { background: var(--primary-soft); }
.ui-period-static { font-size: var(--fs-sm); font-weight: 500; }
.ui-period-btn .icon, .ui-period-static .icon { width: 22px; height: 22px; }
.ui-period-pop { right: 0; top: calc(100% + 6px); width: min(280px, calc(100vw - 32px)); padding: var(--space-2); }
.ui-period-list { display: grid; gap: 2px; }
.ui-period-opt { display: flex; align-items: center; padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer; text-align: left; }
.ui-period-opt:hover { background: var(--surface-2); }
.ui-period-opt[aria-checked="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.ui-period-custom { display: grid; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-3); border-top: 1px solid var(--line); margin-top: var(--space-2); }
.ui-period-custom label { display: grid; gap: 4px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.ui-period-date { min-height: 38px; }
.ui-period-err { color: var(--danger); font-size: var(--fs-sm); }

/* ---------- Чипы и аватар ---------- */
.ui-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: var(--radius-pill); background: var(--tone-soft); color: var(--tone); font-size: var(--fs-xs); font-weight: 600; line-height: 1.5; overflow-wrap: break-word; }
.ui-chip .icon { width: 14px; height: 14px; }
.ui-avatar { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 11px; background: var(--tone-soft); color: var(--tone); font-weight: 700; font-size: var(--fs-md); letter-spacing: 0.02em; }
.ui-avatar--round { border-radius: 50%; }
.ui-avatar--sm { width: 28px; height: 28px; border-radius: 8px; font-size: var(--fs-xs); }
.ui-avatar--lg { width: 52px; height: 52px; border-radius: 14px; font-size: var(--fs-lg); }
.ui-avatar--xl { width: 96px; height: 96px; border-radius: 22px; font-size: 40px; background: var(--tone); color: var(--on-primary); }
.ui-avatar--round.ui-avatar--sm { border-radius: 50%; }

/* ---------- Пустое состояние и скелетон ---------- */
.ui-empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-6) var(--space-4); text-align: center; color: var(--muted); }
.ui-empty--compact { padding: var(--space-5) var(--space-4); }
.ui-empty-ico { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 16px; background: var(--surface-2); color: var(--muted); }
.ui-empty--compact .ui-empty-ico { width: 44px; height: 44px; border-radius: 12px; }
.ui-empty-ico .icon { width: 26px; height: 26px; }
.ui-empty-title { margin: 0; color: var(--text); font-weight: 600; max-width: 46ch; }
.ui-empty-text { margin: 0; max-width: 52ch; }

.ui-skel { display: grid; gap: var(--space-3); }
.ui-skel-bar {
  display: block; height: 14px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: ui-shimmer 1.4s ease-in-out infinite;
}
.ui-skel-col { display: grid; gap: 8px; flex: 1; }
.ui-skel .w-100 { width: 100%; }
.ui-skel .w-90 { width: 90%; }
.ui-skel .w-60 { width: 60%; }
.ui-skel .w-40 { width: 40%; }
.ui-skel .w-30 { width: 30%; }
.ui-skel-big { height: 30px; }
.ui-skel-spark { height: 56px; border-radius: 12px; }
.ui-skel-plot { height: 180px; border-radius: 12px; }
.ui-skel-head { height: 36px; }
.ui-skel-row { height: 28px; }
.ui-skel-sq { width: 44px; height: 44px; border-radius: 12px; flex: none; }
.ui-skel--tile { display: flex; align-items: center; gap: var(--space-3); }
@keyframes ui-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .ui-skel-bar { animation: none; background: var(--surface-2); } }

/* ---------- KPI-карточка ---------- */
.ui-kpi { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; padding: var(--space-4) var(--space-5) var(--space-3); background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: var(--shadow); }
.ui-kpi-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2); padding-bottom: var(--space-3); border-bottom: 1px solid var(--line); }
.ui-kpi-title { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.ui-kpi-period { display: flex; }
.ui-kpi-value { margin-top: var(--space-2); font-size: var(--fs-kpi); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ui-kpi-delta, .ui-kpi-caption { font-size: var(--fs-sm); color: var(--muted); }
.ui-kpi-spark { margin-top: auto; padding-top: var(--space-3); }
.ui-delta { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; font-weight: 600; }
.ui-delta .icon { width: 16px; height: 16px; }
.ui-delta-label { font-weight: 500; color: var(--muted); }
.ui-delta--good .ui-delta-value, .ui-delta--good .icon { color: var(--green); }
.ui-delta--bad .ui-delta-value, .ui-delta--bad .icon { color: var(--red); }
.ui-delta--neutral .ui-delta-value { color: var(--text); }

/* ---------- Плитка-метрика ---------- */
.ui-tile {
  display: flex; align-items: center; gap: var(--space-3); min-width: 0; padding: var(--space-4); border: 1.5px solid var(--tone); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); text-decoration: none; font: inherit; text-align: left; width: 100%;
}
.ui-tile.is-action { cursor: pointer; transition: box-shadow var(--transition), background var(--transition); }
.ui-tile.is-action:hover { background: var(--tone-soft); box-shadow: var(--shadow); color: var(--text); }
.ui-tile-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--tone-soft); color: var(--tone); }
.ui-tile-ico .icon { width: 22px; height: 22px; }
.ui-tile-text { display: grid; min-width: 0; gap: 2px; }
.ui-tile-label { color: var(--muted); font-size: var(--fs-sm); line-height: 1.35; overflow-wrap: anywhere; }
.ui-tile-value { font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ---------- Лента событий ---------- */
.ui-feed { list-style: none; margin: 0; padding: 0; display: grid; }
.ui-feed-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.ui-feed-item:last-child { border-bottom: 0; }
.ui-feed-dot { width: 12px; height: 12px; flex: none; margin-top: 5px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 4px var(--tone-soft); }
.ui-feed-body { min-width: 0; flex: 1; }
.ui-feed-row { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px var(--space-3); }
.ui-feed-title { font-weight: 600; overflow-wrap: anywhere; color: var(--text); text-decoration: none; }
a.ui-feed-title { color: var(--primary); }
a.ui-feed-title:hover { text-decoration: underline; }
.ui-feed-time { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.ui-feed-text { margin-top: 2px; color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* ---------- Переключатель-«тумблер» ---------- */
.ui-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; font-size: var(--fs-sm); }
.ui-switch-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ui-switch-track { position: relative; flex: none; width: 44px; height: 24px; border-radius: var(--radius-pill); background: var(--line-strong); transition: background var(--transition); }
.ui-switch-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform var(--transition); }
.ui-switch-input:checked + .ui-switch-track { background: var(--primary); }
.ui-switch-input:checked + .ui-switch-track .ui-switch-thumb { transform: translateX(20px); }
.ui-switch-input:focus-visible + .ui-switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.ui-switch-input:disabled + .ui-switch-track { opacity: 0.5; }
.ui-switch-wrap { display: grid; gap: 4px; }

/* ---------- Индикатор выполнения ---------- */
.ui-progress { display: flex; align-items: center; gap: var(--space-3); }
.ui-progress-track { flex: 1; height: 8px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.ui-progress-fill { display: block; width: var(--w, 0%); height: 100%; border-radius: inherit; background: var(--tone); }
.ui-progress-text { min-width: 56px; text-align: right; font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Мелочи под новый вид существующих экранов ---------- */
.content > .qr-banner { margin: 0 0 var(--space-3); }
.ui-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.ui-link:hover { text-decoration: underline; }

/* ---------- Опорные классы разметки (переносы, мелкие уточнения) ---------- */
.ui-tab-label { overflow-wrap: anywhere; }
.ui-period-label { white-space: nowrap; }
.ui-switch-text { overflow-wrap: anywhere; }
.ui-delta--none .ui-delta-label { color: var(--muted); }
.ui-theme-btn { color: var(--muted); }
.ui-theme-seg { max-width: 100%; }
.ui-theme-seg .ui-seg-btn { padding-left: 10px; padding-right: 10px; }

/* кнопка меню в верхней панели видна только на телефоне (перебивает display у .ui-iconbtn) */
.topbar .tb-menu { display: none; }
@media (max-width: 860px) { .topbar .tb-menu { display: inline-grid; } }

/* ---------- Поле поиска ---------- */
.ui-search { position: relative; display: flex; align-items: center; min-width: 0; }
.ui-search > .icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.ui-search-input { padding-left: 38px; }

/* ---------- Поиск пациента в верхней панели (lib/ui-search.js) ---------- */
.tb-search { position: relative; flex: 1 1 320px; max-width: 480px; min-width: 180px; }
.tb-search .tb-search-toggle { display: none; }
.tb-search-box { position: relative; }
.tb-search-field { position: relative; display: flex; align-items: center; }
.tb-search-field > .icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.tb-search-input { padding-left: 40px; padding-right: 36px; min-height: 40px; background: var(--surface-2); border-color: transparent; }
.tb-search-input:hover { border-color: var(--line-strong); }
.tb-search-input:focus-visible { background: var(--surface); }
.tb-search-key {
  position: absolute; right: 10px; min-width: 22px; padding: 0 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface);
  color: var(--muted); font: inherit; font-size: var(--fs-xs); font-weight: 600; line-height: 20px; text-align: center; pointer-events: none;
}
.tb-search-pop { left: 0; right: 0; top: calc(100% + 6px); max-height: min(420px, 70vh); overflow-y: auto; padding: var(--space-1); }
.tb-search-opt {
  display: flex; align-items: center; gap: var(--space-3); padding: 8px 10px; border-radius: 10px; color: var(--text); text-decoration: none; cursor: pointer;
}
.tb-search-opt:hover, .tb-search-opt.is-active { background: var(--primary-soft); color: var(--text); }
.tb-search-opt-text { display: grid; min-width: 0; flex: 1; gap: 1px; }
.tb-search-opt-name { font-weight: 600; overflow-wrap: anywhere; }
.tb-search-opt-meta { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.tb-search-opt.is-active .tb-search-opt-meta { color: var(--text); }
.tb-search-opt-tag { flex: none; }
.tb-search-note { display: grid; gap: var(--space-2); justify-items: start; padding: var(--space-3) var(--space-3); }
.tb-search-note .ui-skel { width: 100%; }
.tb-search-note.is-error { display: flex; align-items: flex-start; gap: var(--space-2); color: var(--danger); }
.tb-search-more { padding: var(--space-2) var(--space-3); border-top: 1px solid var(--line); }
@media (max-width: 860px) {
  /* на телефоне поиск — значок в панели; по нажатию строка поиска занимает отдельную строку под панелью */
  .topbar { flex-wrap: wrap; }
  .tb-search { display: contents; }
  .tb-search .tb-search-toggle { display: inline-grid; }
  .tb-search-box { display: none; order: 20; flex: 1 0 100%; min-width: 0; }
  .tb-search.is-open .tb-search-box { display: block; }
  .tb-search-key { display: none; }
}
@media (hover: none) { .tb-search-key { display: none; } }
