/* Inter с нашего сервера: без Google Fonts, быстро открывается в России без VPN */
/* cyrillic-ext */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

/* cyrillic */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

/* latin */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
*::-webkit-scrollbar {
    display: none;
}

html {
    overflow-x: clip;
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
}

:root {
    --bg: #f6f4ef;
    --bg-card: rgba(255, 255, 255, 0.72);
    --bg-card-hover: rgba(255, 255, 255, 0.94);
    --border-card-hover: rgba(67, 61, 94, 0.22);
    /* Подсветка активного элемента (thread/timecode current) — тонкий accent-фон + полупрозрачный accent бордер (--accent-glow) */
    --bg-card-active: rgba(91, 82, 176, 0.08);
    /* Элементы поверх карточки (бейджи, кнопки) — на чуть-чуть светлее карточки */
    --bg-elevated: rgba(255, 255, 255, 0.76);
    --bg-elevated-hover: rgba(91, 82, 176, 0.1);
    --border: rgba(50, 46, 72, 0.14);
    --border-elevated: rgba(50, 46, 72, 0.12);
    /* Универсальный hover-highlight для интерактивных контролов
       (поле поиска при фокусе, ховер тогглов/подсказок/кнопок-фильтров) */
    --bg-hover: rgba(91, 82, 176, 0.08);
    /* Accent (фиолетовая) подсветка для hover/active бейджей и кнопок */
    --bg-accent-hover: rgba(91, 82, 176, 0.12);
    --border-accent-hover: rgba(91, 82, 176, 0.3);
    --bg-accent-active: rgba(91, 82, 176, 0.13);   /* бейдж таймкода, mark, играющий */
    --bg-accent-strong: rgba(91, 82, 176, 0.24);   /* «сейчас идёт» */
    --bg-accent-soft: rgba(91, 82, 176, 0.1);      /* мягкая подсветка таймкода */
    --text: #252330;
    --text-muted: rgba(37, 35, 48, 0.65);
    --text-subtle: rgba(37, 35, 48, 0.78);
    --date-text: #726f7d;
    --accent: #5b52b0;
    --accent-glow: rgba(91, 82, 176, 0.38);
    --video: #c43d45;
    --site: #6950b6;
    --pev: #9a5b00;
    --lr: #087a55;
    --vzp: #b8327b;
    --periscope: #08788f;
    --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);
    --shadow-control: 0 1px 2px rgba(50, 46, 72, 0.05), 0 8px 24px rgba(50, 46, 72, 0.04);
    --shadow-control-focus: 0 0 0 3px rgba(91, 82, 176, 0.12), 0 10px 28px rgba(50, 46, 72, 0.07);
    --shadow-card: 0 1px 2px rgba(50, 46, 72, 0.04);
    --shadow-card-hover: 0 8px 24px rgba(50, 46, 72, 0.07);
    --orb-one: rgba(91, 82, 176, 0.11);
    --orb-two: rgba(137, 117, 194, 0.09);
    --orb-three: rgba(188, 158, 190, 0.08);
    --ambient-vignette: radial-gradient(ellipse at center, transparent 32%, rgba(220, 215, 207, 0.52) 100%);
    --logo-gradient: linear-gradient(120deg, #4f46a5 0%, #6950b6 15%, #725bb8 30%, #5b52b0 45%, #4f46a5 60%, #725bb8 75%, #5b52b0 90%, #4f46a5 100%);
    --sticky-bg-desktop: rgba(246, 244, 239, 0.78);
    --sticky-fade-desktop: linear-gradient(to bottom, rgba(246, 244, 239, 0.66) 0%, rgba(246, 244, 239, 0.3) 45%, rgba(246, 244, 239, 0) 100%);
    --sticky-bg-mobile: rgba(246, 244, 239, 0.82);
    --sticky-fade-mobile: linear-gradient(to bottom, rgba(246, 244, 239, 0.72) 0%, rgba(246, 244, 239, 0.34) 45%, rgba(246, 244, 239, 0) 100%);
    --input-bg: rgba(255, 255, 255, 0.82);
    --input-bg-focus: rgba(255, 255, 255, 0.96);
    --popover-bg: #fffdfa;
    --popover-text: var(--text-subtle);
    --popover-shadow: 0 12px 32px rgba(55, 48, 79, 0.14);
    --tooltip-shadow: 0 6px 18px rgba(55, 48, 79, 0.16);
    --drawer-shadow: 0 -8px 30px rgba(55, 48, 79, 0.16);
    --overlay-bg: rgba(37, 35, 48, 0.28);
    --drawer-handle: rgba(37, 35, 48, 0.2);
    --close-circle: rgba(37, 35, 48, 0.08);
    --player-bg: #fffdfa;
    --player-shadow: 0 -8px 24px rgba(55, 48, 79, 0.18);
    --accent-hover-solid: #4f46a5;
    --clarify-title-gradient: linear-gradient(120deg, #4f46a5 0%, #725bb8 50%, #4f46a5 100%);
    --on-accent: #ffffff;
    --danger-text: #a92f38;
    --site-quote-bg: rgba(105, 80, 182, 0.06);
    --site-quote-border: rgba(105, 80, 182, 0.48);
    --site-quote-text: rgba(37, 35, 48, 0.72);

    /* Отступы sticky header */
    --nav-gap: 1rem;
    --search-gap: 1.5rem;
    --sticky-padding: 20px;
    --center-offset: calc(25vh - 100px);

    /* Container layout — ширина и padding используются sticky-блоками,
       чтобы full-bleed фон растягивался на 100vw, а контент совпадал
       по ширине с обычным контентом .container */
    --container-max-width: 1000px;
    --container-padding-x: 3rem;
}

html[data-theme="dark"] {
    --bg: #0a0a0a;
    --bg-card: rgba(0, 0, 0, 0.1);
    --bg-card-hover: rgba(0, 0, 0, 0.2);
    --border-card-hover: rgba(255, 255, 255, 0.12);
    --bg-card-active: rgba(167, 139, 250, 0.015);
    --bg-elevated: rgba(255, 255, 255, 0.03);
    --bg-elevated-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-elevated: rgba(255, 255, 255, 0.05);
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-accent-hover: rgba(167, 139, 250, 0.15);
    --border-accent-hover: rgba(167, 139, 250, 0.3);
    --bg-accent-active: rgba(167, 139, 250, 0.1);
    --bg-accent-strong: rgba(167, 139, 250, 0.5);
    --bg-accent-soft: rgba(167, 139, 250, 0.12);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-subtle: rgba(255, 255, 255, 0.7);
    --date-text: #858591;
    --accent: #818cf8;
    --accent-glow: rgba(129, 140, 248, 0.5);
    --video: #ef4444;
    --site: #a78bfa;
    --pev: #f59e0b;
    --lr: #10b981;
    --vzp: #ec4899;
    --periscope: #06b6d4;
    --shadow-control: 0 1px 2px rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-control-focus: 0 0 0 3px rgba(129, 140, 248, 0.18), 0 10px 28px rgba(0, 0, 0, 0.28);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.18);
    --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.26);
    --orb-one: rgba(129, 140, 248, 0.13);
    --orb-two: rgba(99, 102, 241, 0.1);
    --orb-three: rgba(167, 139, 250, 0.07);
    --ambient-vignette: radial-gradient(ellipse at center, transparent 25%, rgba(0, 0, 0, 0.5) 95%);
    --logo-gradient: linear-gradient(120deg, #818cf8 0%, #6366f1 15%, #a5b4fc 30%, #818cf8 45%, #6366f1 60%, #a5b4fc 75%, #818cf8 90%, #6366f1 100%);
    --sticky-bg-desktop: rgba(10, 10, 10, 0.6);
    --sticky-fade-desktop: linear-gradient(to bottom, rgba(10, 10, 10, 0.5) 0%, rgba(10, 10, 10, 0.22) 45%, rgba(10, 10, 10, 0) 100%);
    --sticky-bg-mobile: rgba(10, 10, 10, 0.62);
    --sticky-fade-mobile: linear-gradient(to bottom, rgba(10, 10, 10, 0.55) 0%, rgba(10, 10, 10, 0.25) 45%, rgba(10, 10, 10, 0) 100%);
    --input-bg: var(--bg-card);
    --input-bg-focus: var(--bg-hover);
    --popover-bg: #1a1a1a;
    --popover-text: rgba(255, 255, 255, 0.75);
    --popover-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --tooltip-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    --drawer-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --drawer-handle: rgba(255, 255, 255, 0.2);
    --close-circle: rgba(255, 255, 255, 0.08);
    --player-bg: #141414;
    --player-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    --accent-hover-solid: #a5b4fc;
    --clarify-title-gradient: linear-gradient(120deg, #818cf8 0%, #a5b4fc 50%, #818cf8 100%);
    --on-accent: #0a0a0a;
    --danger-text: #fca5a5;
    --site-quote-bg: rgba(167, 139, 250, 0.07);
    --site-quote-border: rgba(167, 139, 250, 0.55);
    --site-quote-text: rgba(255, 255, 255, 0.68);
}

@media (max-width: 600px) {
    :root {
        --container-padding-x: 1rem;
    }
}

@media (max-width: 360px) {
    :root {
        --container-padding-x: 0.75rem;
    }
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: clip;
}

.theme-toggle {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 900;
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-card-hover);
    color: var(--text-subtle);
    box-shadow: var(--shadow-control);
    cursor: pointer;
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    transition: color 140ms var(--ease-out), border-color 140ms var(--ease-out), background-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.theme-toggle-icon {
    width: 20px;
    height: 20px;
}

.theme-toggle-sun {
    display: none;
}

html[data-theme="dark"] .theme-toggle-moon {
    display: none;
}

html[data-theme="dark"] .theme-toggle-sun {
    display: block;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--border-accent-hover);
    background: var(--bg-accent-hover);
    box-shadow: var(--shadow-card-hover);
}

@media (max-width: 600px) {
    .theme-toggle {
        top: max(12px, env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        width: 40px;
        height: 40px;
    }
}

/* Атмосферный фон: 3 размытых фиолетовых орба медленно дрейфуют — глубина без отвлечения. */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    contain: strict;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(130px);
    transform: translate(-50%, -50%);
}

.orb-1 {
    width: 60vmax;
    height: 60vmax;
    left: 20%;
    top: 25%;
    background: var(--orb-one);
}

.orb-2 {
    width: 50vmax;
    height: 50vmax;
    left: 85%;
    top: 70%;
    background: var(--orb-two);
}

.orb-3 {
    width: 42vmax;
    height: 42vmax;
    left: 60%;
    top: 45%;
    background: var(--orb-three);
}

.ambient-vignette {
    position: absolute;
    inset: 0;
    background: var(--ambient-vignette);
}

@keyframes orb-drift-1 {
    0%   { transform: translate(-50%, -50%); }
    25%  { transform: translate(-30%, -62%); }
    50%  { transform: translate(-58%, -38%); }
    75%  { transform: translate(-72%, -55%); }
    100% { transform: translate(-50%, -50%); }
}

@keyframes orb-drift-2 {
    0%   { transform: translate(-50%, -50%); }
    33%  { transform: translate(-65%, -38%); }
    66%  { transform: translate(-38%, -60%); }
    100% { transform: translate(-50%, -50%); }
}

@keyframes orb-drift-3 {
    0%   { transform: translate(-50%, -50%); }
    20%  { transform: translate(-58%, -42%); }
    50%  { transform: translate(-38%, -58%); }
    80%  { transform: translate(-62%, -52%); }
    100% { transform: translate(-50%, -50%); }
}

@media (prefers-reduced-motion: reduce) {
    .orb { animation: none; }
}

.container {
    position: relative;
    z-index: 1;
}

body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 2.5rem var(--container-padding-x);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.main-section {
    flex: 1;
}

/* Header */
.header {
    position: relative;
    text-align: center;
    margin-bottom: 1.5rem;
    overflow: visible;
}

.logo {
    font-size: 2.9rem;
    font-weight: 700;
    background: var(--logo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.header-link {
    text-decoration: none;
    color: inherit;
}

/* Logo wrapper for sparkles */
.logo-wrapper {
    position: relative;
    display: inline-block;
}

.sparkles-container {
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    bottom: 10px;
    pointer-events: none;
    overflow: hidden;
}

.sparkle {
    position: absolute;
    pointer-events: none;
    z-index: 2;
}

.sparkle svg {
    display: block;
    filter: drop-shadow(0 0 2px currentColor);
}

@keyframes sparkle-grow {
    0% { 
        transform: scale(0.75) rotate(0deg);
        opacity: 0;
    }
    50% { 
        transform: scale(1) rotate(90deg); 
        opacity: 1; 
    }
    100% { 
        transform: scale(0.75) rotate(180deg);
        opacity: 0;
    }
}

@keyframes sparkle-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(180deg); }
}


.tagline {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: -0.5rem;
    margin-bottom: 1.5rem;
}

/* Navigation */
.nav-menu {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.nav-item {
    position: relative;
    padding: 4px 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: color 160ms var(--ease-out);
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 180ms var(--ease-out);
}

.nav-item:hover {
    color: var(--text);
}

.nav-item.active {
    color: var(--text);
}

.nav-item.active::after {
    transform: scaleX(1);
}

/* === Sticky Header (общие стили для всех трёх вкладок) === */
.search-block,
.timecodes-sticky-header,
.clarify-sticky-header {
    margin-bottom: 1.25rem;
}

.search-block .nav-menu,
.timecodes-sticky-header .nav-menu,
.clarify-sticky-header .nav-menu {
    margin-bottom: var(--nav-gap);
}

.search-block .search-row,
.timecodes-sticky-header .search-row {
    margin-bottom: var(--search-gap);
}

/* Desktop (min-width: 601px) */
@media (min-width: 601px) {
    html {
        scroll-padding-top: 180px;
    }

    /* Центрирование — половина отступа на header, половина на search */
    .header {
        margin-top: calc(var(--center-offset) * 0.7);
    }

    .search-block,
    .timecodes-sticky-header,
    .clarify-sticky-header {
        margin-top: calc(var(--center-offset) * 0.3);
        padding-top: 16px;
        /* Full-bleed: блок шириной 100vw, выходит за границы .container.
           Padding выровнен так, чтобы внутренний контент строго совпадал
           с шириной контента .container (тот же left/right edge).
           Формула: max(container_padding, (viewport - container_max_width) / 2 + container_padding) */
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding-left: max(var(--container-padding-x),
                          calc((100vw - var(--container-max-width)) / 2 + var(--container-padding-x)));
        padding-right: max(var(--container-padding-x),
                           calc((100vw - var(--container-max-width)) / 2 + var(--container-padding-x)));
        background: transparent;
        transition: background-color 200ms ease, backdrop-filter 200ms ease;
    }

    /* Sticky состояние для поиска (когда есть результаты) */
    .search-block.has-results {
        position: sticky;
        top: 0;
        z-index: 100;
    }

    /* Sticky состояние для таймкодов и Прояснить — всегда */
    .timecodes-sticky-header,
    .clarify-sticky-header {
        position: sticky;
        top: 0;
        z-index: 100;
    }

    /* Одинаковый нижний воздух у всех трёх sticky-блоков (десктоп — вдвое меньше мобилы) */
    .search-block.has-results,
    .timecodes-sticky-header,
    .clarify-sticky-header {
        padding-bottom: 0.375rem;
        margin-bottom: 0.625rem;
    }


    /* В «Прояснить» под nav ничего нет — убираем дублирующий gap,
       чтобы итог совпадал с другими вкладками */
    .clarify-sticky-header .nav-menu {
        margin-bottom: 0;
    }

    /* На десктопе уменьшаем вдвое внутренние gap'ы sticky-блока:
       search-row → toggles (было 1.5rem) и toggles → низ (было 1rem).
       Через родительский селектор — иначе общие правила .toggles/.timecodes-toggles
       ниже в файле перебивают по каскаду при равной специфичности. */
    .search-block .search-row,
    .timecodes-sticky-header .search-row {
        margin-bottom: 0.75rem;
    }

    .search-block .toggles,
    .timecodes-sticky-header .timecodes-toggles {
        margin-bottom: 0.5rem;
    }

    /* Состояние "залипло" — лёгкое frosted-glass стекло */
    .search-block.has-results.is-stuck,
    .timecodes-sticky-header.is-stuck,
    .clarify-sticky-header.is-stuck {
        background: var(--sticky-bg-desktop);
        backdrop-filter: blur(26px) saturate(160%);
        -webkit-backdrop-filter: blur(26px) saturate(160%);
    }

    /* Длинный мягкий fade под хедером — плавно сливает стекло с контентом */
    .search-block.has-results.is-stuck::after,
    .timecodes-sticky-header.is-stuck::after,
    .clarify-sticky-header.is-stuck::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: -32px;
        height: 32px;
        background: var(--sticky-fade-desktop);
        pointer-events: none;
    }
}

.timecodes-toggles {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.timecodes-toggles .toggle-group {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.timecodes-toggles .toggle-group::-webkit-scrollbar { display: none; }

/* Search */
.search-wrapper {
    margin-bottom: 0.75rem;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 20px;
    top: 13px;
    width: 22px;
    height: 22px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.2s;
}

.search-box:focus-within .search-icon {
    color: var(--accent);
}

#searchInput,
#streamsSearchInput {
    width: 100%;
    padding: 14px 45px 14px 48px;
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    outline: none;
    box-shadow: var(--shadow-control);
    transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}

#searchInput::placeholder,
#streamsSearchInput::placeholder {
    color: var(--text-muted);
}

#searchInput:focus,
#streamsSearchInput:focus {
    background: var(--input-bg-focus);
    border-color: var(--accent);
    box-shadow: var(--shadow-control-focus);
}

/* Animated placeholder overlay */
.search-placeholder {
    position: absolute;
    left: 48px;
    right: 45px;
    top: 0;
    padding: 14px 0;
    pointer-events: none;
    display: block;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.5;
    color: var(--text-muted);
    z-index: 1;
    word-break: break-word;
}

.search-placeholder.hidden { display: none; }

.search-placeholder-cursor {
    display: inline-block;
    width: 1px;
    height: 1.1em;
    background: var(--text-muted);
    margin-left: 1px;
    animation: placeholder-blink 1s step-end infinite;
}

@keyframes placeholder-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.search-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out), transform 140ms var(--ease-out);
    z-index: 10;
}

.search-clear.visible {
    display: flex;
}

.search-clear:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.search-clear.hidden {
    display: none;
}

.search-loader {
    position: absolute;
    right: 20px;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.search-loader.active {
    opacity: 1;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Suggestions */
.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: var(--popover-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-height: 300px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: var(--popover-shadow);
}

.suggestions.active {
    display: block;
}

.suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-subtle);
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: var(--bg-hover);
    color: var(--text);
}

.suggestion-item mark,
.result-text mark,
.result-title mark,
.result-question mark,
.thread-item-text mark {
    background: var(--bg-accent-active);
    color: var(--text);
    border-radius: 2px;
    padding: 0 2px;
}

.search-wrapper {
    position: relative;
}

/* Search row (mobile: search + filter button) */
.search-row {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    overflow: visible;
}

.search-row .search-wrapper {
    flex: 1;
    margin-bottom: 0;
}

/* Filters Button (mobile only) */
.filters-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 48px;
    height: 48px;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: var(--shadow-control);
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
    flex-shrink: 0;
}

.filters-btn svg {
    stroke: currentColor;
}

.filters-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text);
}

.filters-btn {
    position: relative;
}

.filters-btn.has-active-filters::after {
    content: '';
    position: absolute;
    top: 7px;
    right: 7px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
}

/* Filters Panel (mobile only) - bottom sheet */
.filters-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg);
    z-index: 1000;
    flex-direction: column;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 280ms var(--ease-drawer);
    display: flex;
    max-height: 82vh;
    overflow: hidden;
    box-shadow: var(--drawer-shadow);
    padding-bottom: 24px;
}

.filters-panel.active {
    transform: translateY(0);
}

.filters-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms var(--ease-out), visibility 220ms var(--ease-out);
}

.filters-panel-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.filters-panel::before {
    content: '';
    width: 40px;
    height: 4px;
    background: var(--drawer-handle);
    border-radius: 2px;
    margin: 10px auto 0;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.filters-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.filters-close {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s;
}

.filters-close:hover {
    color: var(--text);
}

.filters-close:hover circle {
    fill: var(--bg-hover);
}

.filters-close circle,
.thread-close circle,
.timecodes-close circle {
    fill: var(--close-circle);
}

.filters-content {
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    align-items: flex-start;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.filters-content .toggle-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.filters-content .toggle-group {
    flex-wrap: wrap;
}

/* Toggles */
.toggles {
    display: flex;
    justify-content: center;
    gap: 0.6rem 0.7rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.toggle-section {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-label {
    color: var(--text-muted);
    font-size: 13px;
}

.toggle-group {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(50, 46, 72, 0.04);
}

.source-toggles {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.source-toggles::-webkit-scrollbar { display: none; }

.toggle {
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    word-spacing: 0.15em;
    cursor: pointer;
    transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.toggle:hover {
    color: var(--text-subtle);
    background: var(--bg-hover);
}

.toggle.active {
    background: var(--bg-accent-hover);
    color: var(--accent);
    box-shadow: 0 1px 2px rgba(50, 46, 72, 0.06);
}

/* Date trigger pill & Sort dropdown */
.date-trigger-wrap {
    display: inline-flex;
    align-items: center;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(50, 46, 72, 0.04);
    transition: border-color 140ms var(--ease-out);
}

.date-trigger-wrap.is-active {
    border-color: var(--border-accent-hover);
}

.date-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.date-trigger-btn:hover {
    color: var(--text-subtle);
    background: var(--bg-hover);
}

.date-trigger-wrap.is-active .date-trigger-btn,
.date-trigger-btn[aria-expanded="true"] {
    background: var(--bg-accent-hover);
    color: var(--accent);
}

.date-trigger-icon {
    flex: none;
    opacity: 0.78;
}

.date-trigger-wrap.is-active .date-trigger-icon,
.date-trigger-btn[aria-expanded="true"] .date-trigger-icon {
    opacity: 1;
}

.date-clear-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 2px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.date-trigger-wrap.is-active .date-clear-btn {
    display: inline-flex;
}

.date-clear-btn:hover {
    color: var(--accent);
    background: var(--bg-accent-hover);
}

/* Sort dropdown */
.sort-dropdown {
    position: relative;
    display: inline-flex;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(50, 46, 72, 0.04);
    transition: border-color 140ms var(--ease-out);
}

.sort-dropdown:has(.sort-trigger-btn.is-active),
.sort-dropdown.open {
    border-color: var(--border-accent-hover);
}

.sort-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 9px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    transition: color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.sort-trigger-btn:hover {
    color: var(--text-subtle);
    background: var(--bg-hover);
}

.sort-trigger-btn.is-active,
.sort-dropdown.open .sort-trigger-btn {
    background: var(--bg-accent-hover);
    color: var(--accent);
}

.sort-trigger-icon {
    flex: none;
    opacity: 0.78;
}

.sort-trigger-btn.is-active .sort-trigger-icon,
.sort-dropdown.open .sort-trigger-icon {
    opacity: 1;
}

.sort-trigger-chevron {
    flex: none;
    opacity: 0.65;
    transition: transform 160ms var(--ease-out);
}

.sort-dropdown.open .sort-trigger-chevron {
    transform: rotate(180deg);
}

.sort-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 224px;
    padding: 6px;
    border-radius: 14px;
    background: var(--popover-bg);
    border: 1px solid var(--border);
    box-shadow: var(--popover-shadow);
    z-index: 950;
    animation: f-range-in 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sort-dropdown.open .sort-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 130ms var(--ease-out);
}

.sort-option:hover {
    background: var(--bg-hover);
}

.sort-option.active {
    background: var(--bg-accent-hover);
}

.sort-option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sort-option-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.sort-option.active .sort-option-title {
    color: var(--accent);
}

.sort-option-sub {
    font-size: 11.5px;
    color: var(--text-muted);
}

.sort-option-check {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    opacity: 0;
}

.sort-option.active .sort-option-check {
    opacity: 1;
}

.date-trigger-btn:focus-visible,
.date-clear-btn:focus-visible,
.sort-trigger-btn:focus-visible,
.sort-option:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* === Clarida-style Date Range Picker Popover & Mobile Sheet === */
.f-range-scrim {
    position: fixed;
    inset: 0;
    z-index: 1190;
    background: var(--overlay-bg);
    backdrop-filter: blur(2px);
    animation: f-range-fade 160ms ease;
}

@keyframes f-range-fade {
    from { opacity: 0; }
}

@keyframes f-range-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.985); }
}

@keyframes f-range-up {
    from { transform: translateY(100%); }
}

.f-range-pop {
    --f-range-cell: 32px;
    position: fixed;
    z-index: 1200;
    width: max-content;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--popover-bg);
    box-shadow: var(--popover-shadow);
    color: var(--text);
    text-align: left;
    animation: f-range-in 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-origin: top center;
}

.f-range-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 12px 0 18px;
}

.f-range-heading {
    margin: 0;
    font-size: 15.5px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.f-range-close {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 140ms ease, color 140ms ease;
}

.f-range-close:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.f-range-body {
    display: flex;
    gap: 16px;
    padding: 9px 18px 4px;
}

.f-range-quick {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 174px;
    flex-shrink: 0;
    padding-right: 16px;
    border-right: 1px solid var(--border);
}

.f-range-eras {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.f-range-eras button {
    width: 100%;
    min-height: 30px;
    padding: 5px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-subtle);
    font: 500 13px/1.25 inherit;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 130ms ease, color 130ms ease;
}

.f-range-eras button:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.f-range-eras button[aria-pressed="true"] {
    background: var(--bg-accent-hover);
    color: var(--accent);
}

.f-range-quick-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0 2px;
}

.f-range-years-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.f-range-years {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.f-range-year-chip {
    padding: 5px 4px;
    border: 1px solid var(--border-elevated);
    border-radius: 8px;
    background: transparent;
    color: var(--text-subtle);
    font: 500 12px/1.2 inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color 130ms ease, border-color 130ms ease, color 130ms ease;
}

.f-range-year-chip:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    color: var(--text);
}

.f-range-year-chip[aria-pressed="true"] {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

.f-range-main {
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 0;
}

.f-range-fields {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.f-range-dash {
    padding-bottom: 7px;
    color: var(--text-muted);
}

.f-range-field {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.f-range-field span {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
}

.f-range-field input {
    width: 100%;
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--bg-elevated);
    color: var(--text);
    font: 500 13px/1.2 inherit;
    font-variant-numeric: tabular-nums;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

.f-range-field input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
    opacity: 0.7;
}

.f-range-field.is-active input,
.f-range-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--bg-accent-soft);
}

.f-range-field.is-bad input {
    border-color: var(--danger-text);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14);
}

.f-range-cal {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.f-range-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.f-range-nav > button {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-elevated);
    border-radius: 999px;
    background: var(--bg-elevated);
    color: var(--text-subtle);
    cursor: pointer;
    transition: background-color 130ms ease, border-color 130ms ease, color 130ms ease;
}

.f-range-nav > button:hover:not(:disabled) {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

.f-range-nav > button:disabled {
    opacity: 0.3;
    cursor: default;
}

.f-range-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.f-range-jump-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 5px 24px 5px 10px;
    border: 1px solid var(--border-elevated);
    border-radius: 8px;
    background-color: var(--bg-elevated);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c87a6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    color: var(--text);
    font: 500 13px/1.2 inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: border-color 130ms ease, background-color 130ms ease;
}

.f-range-jump-select:hover {
    border-color: var(--border-accent-hover);
    background-color: var(--bg-hover);
}

.f-range-jump-select option {
    background: var(--popover-bg);
    color: var(--text);
}

.f-range-months {
    display: flex;
    gap: 20px;
}

.f-range-month-title {
    margin: 0 0 3px;
    font-weight: 600;
    font-size: 13px;
    line-height: 18px;
    text-align: center;
    color: var(--text-subtle);
}

.f-range-week {
    display: grid;
    grid-template-columns: repeat(7, var(--f-range-cell));
}

.f-range-week.is-head span {
    padding-bottom: 4px;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    line-height: 18px;
    text-align: center;
}

.f-range-cell,
.f-range-empty {
    display: grid;
    place-items: center;
    height: calc(var(--f-range-cell) - 2px);
    margin: 1px 0;
}

/* Полоса выбранного диапазона + кружки на концах, как в Clarida */
.f-range-cell.is-in {
    background: var(--bg-accent-active);
}

.f-range-cell.is-in.is-preview {
    background: var(--bg-accent-soft);
}

.f-range-cell.is-in.is-start {
    background: linear-gradient(to right, transparent 50%, var(--bg-accent-active) 50%);
}

.f-range-cell.is-in.is-preview.is-start {
    background: linear-gradient(to right, transparent 50%, var(--bg-accent-soft) 50%);
}

.f-range-cell.is-in.is-end {
    background: linear-gradient(to left, transparent 50%, var(--bg-accent-active) 50%);
}

.f-range-cell.is-in.is-preview.is-end {
    background: linear-gradient(to left, transparent 50%, var(--bg-accent-soft) 50%);
}

.f-range-cell.is-in.is-start.is-end {
    background: none;
}

.f-range-cell.is-in.is-row-start:not(.is-start) {
    border-radius: 999px 0 0 999px;
}

.f-range-cell.is-in.is-row-end:not(.is-end) {
    border-radius: 0 999px 999px 0;
}

.f-range-cell.is-in.is-row-start.is-row-end:not(.is-start):not(.is-end) {
    border-radius: 999px;
}

.f-range-day {
    display: grid;
    place-items: center;
    width: calc(var(--f-range-cell) - 4px);
    height: calc(var(--f-range-cell) - 4px);
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: 500 13px/1 inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color 110ms ease, color 110ms ease;
}

.f-range-day:hover:not(:disabled):not(.is-edge) {
    background: var(--bg-hover);
}

.f-range-day.is-edge {
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.f-range-day:disabled {
    color: var(--text-muted);
    opacity: 0.28;
    cursor: default;
}

.f-range-day:focus-visible,
.f-range-eras button:focus-visible,
.f-range-year-chip:focus-visible,
.f-range-nav > button:focus-visible,
.f-range-jump-select:focus-visible,
.f-range-close:focus-visible,
.f-range-actions button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.f-range-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 4px;
    padding: 10px 18px 12px;
    border-top: 1px solid var(--border);
}

.f-range-summary {
    max-width: 440px;
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.4;
}

.f-range-summary .is-bad {
    color: var(--danger-text);
}

.f-range-actions {
    display: flex;
    flex: none;
    gap: 8px;
}

.f-range-actions button {
    min-height: 36px;
    padding: 7px 16px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: 500 13px/1.2 inherit;
    cursor: pointer;
    transition: background-color 130ms ease, border-color 130ms ease, opacity 130ms ease;
}

.f-range-actions .f-range-cancel:hover {
    background: var(--bg-hover);
}

.f-range-actions .f-range-apply {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
}

.f-range-actions .f-range-apply:hover:not(:disabled) {
    background: var(--accent-hover-solid);
    border-color: var(--accent-hover-solid);
}

.f-range-actions .f-range-apply:disabled {
    border-color: var(--border-elevated);
    background: var(--bg-elevated);
    color: var(--text-muted);
    opacity: 0.55;
    cursor: default;
}

/* Мобильная нижняя шторка календаря (<= 820px), как в Clarida */
.f-range-pop.is-sheet {
    --f-range-cell: min(44px, calc((100vw - 32px) / 7));
    position: fixed;
    inset: auto 0 0;
    width: auto;
    max-width: none;
    max-height: 92dvh;
    overflow-y: auto;
    border-radius: 22px 22px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: f-range-up 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.f-range-pop.is-sheet .f-range-top {
    padding: 14px 12px 0 16px;
}

.f-range-pop.is-sheet .f-range-body {
    flex-direction: column;
    gap: 12px;
    padding: 10px 16px 4px;
}

.f-range-pop.is-sheet .f-range-quick {
    width: auto;
    padding-right: 0;
    border-right: 0;
    gap: 8px;
}

.f-range-pop.is-sheet .f-range-eras {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
}

.f-range-pop.is-sheet .f-range-eras button {
    width: auto;
    min-height: 32px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
}

.f-range-pop.is-sheet .f-range-quick-divider {
    display: none;
}

.f-range-pop.is-sheet .f-range-years {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 2px;
    -webkit-overflow-scrolling: touch;
}

.f-range-pop.is-sheet .f-range-year-chip {
    flex: 0 0 auto;
    padding: 6px 11px;
    border-radius: 999px;
}

.f-range-pop.is-sheet .f-range-months {
    justify-content: center;
}

.f-range-pop.is-sheet .f-range-foot {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px 16px;
}

.f-range-pop.is-sheet .f-range-actions button {
    flex: 1 1 0;
    min-height: 44px;
}

.empty-state-reset-btn {
    margin-top: 14px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--accent);
    background: var(--bg-accent-hover);
    border: 1px solid var(--border-accent-hover);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}

.empty-state-reset-btn:hover {
    background: var(--bg-accent-active);
    border-color: var(--accent);
}

/* Results */
.results-footer {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem 0;
}

.results-footer.visible {
    display: flex;
}

.results-footer .results-count {
    margin: 0;
    padding: 0;
}

.results-footer .limit-section {
    flex-direction: row;
    gap: 10px;
}

.results-count {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-x: clip;
}

/* Result Card */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
    transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out), transform 180ms var(--ease-out);
    cursor: default;
    overflow: visible;
    scroll-margin-top: 120px;
}

.result-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-card-hover);
    box-shadow: var(--shadow-card-hover);
}

.result-card:has(.fragment-badge.clickable:hover) {
    z-index: 10;
    position: relative;
}

.result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.badge {
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-video {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.badge-site {
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    color: var(--text);
    text-transform: none;
    text-decoration: none;
}

.badge-site.clickable {
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.badge-site.clickable:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}



.fragment-badge {
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
    position: relative;
    margin-left: auto;
}

.fragment-badge.clickable {
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
    z-index: 1;
}

.fragment-badge.clickable:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
    z-index: 2200;
}

.fragment-badge.clickable::after {
    content: "Фрагмент обсуждения";
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    transform: translateY(3px);
    background: var(--popover-bg);
    color: var(--popover-text);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 140ms var(--ease-out), visibility 140ms var(--ease-out), transform 140ms var(--ease-out);
    box-shadow: var(--tooltip-shadow);
    z-index: 2201;
    pointer-events: none;
    max-width: 90vw;
}

.fragment-badge.clickable::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%) translateY(3px);
    width: 8px;
    height: 8px;
    background: var(--popover-bg);
    rotate: 45deg;
    opacity: 0;
    visibility: hidden;
    transition: opacity 140ms var(--ease-out), visibility 140ms var(--ease-out), transform 140ms var(--ease-out);
    z-index: 2200;
    pointer-events: none;
}

.fragment-badge.clickable:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.fragment-badge.clickable:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.badge-stream {
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text);
    font-weight: 500;
}

.badge-stream.clickable {
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.badge-stream.clickable:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

.badge-folder {
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
    text-transform: none;
}

.badge-folder:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

.result-date {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--date-text);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    margin-left: 2px;
    transition: color 150ms var(--ease-out);
}

.result-card:hover .result-date,
.stream-card:hover .result-date,
.thread-item:hover .result-date {
    color: var(--text-subtle);
}


.result-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    text-decoration: none;
}

a.result-title:hover {
    color: var(--accent);
}

.result-question {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
    margin-bottom: 8px;
}

.result-title-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.result-title-row .timecode-badge {
    flex-shrink: 0;
    margin-top: 2px;
}

.result-title-row .result-title {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.result-text {
    color: var(--text-subtle);
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-line;
}

.result-text.has-more {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
}

.result-text.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-text.site-rich,
.thread-item-text.site-rich {
    white-space: normal;
}

.thread-item-text.site-rich {
    color: var(--text-subtle);
}

.result-text.site-rich.has-more,
.thread-item-text.site-rich.has-more {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    max-height: 7.2em;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 35%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 35%, transparent 100%);
}

.site-answer + .site-answer {
    margin-top: 0.85em;
}

.site-para {
    white-space: pre-line;
    margin: 0 0 0.85em 0;
}

.site-para:last-child {
    margin-bottom: 0;
}

.site-quote {
    margin: 16px 0 10px 0;
    padding: 10px 14px;
    border-left: 3px solid var(--site-quote-border);
    background: var(--site-quote-bg);
    border-radius: 0 8px 8px 0;
    color: var(--site-quote-text);
    font-size: 0.875rem;
    font-style: italic;
    line-height: 1.55;
}

.site-quote:first-child {
    margin-top: 0;
}

.site-quote:last-child {
    margin-bottom: 0;
}

.site-quote .site-para {
    margin-bottom: 0.6em;
}

.site-quote .site-para:last-child {
    margin-bottom: 0;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.result-actions > * {
    margin-top: 0 !important;
}

.btn-icon {
    margin-right: 6px;
}

.result-link,
.show-thread-btn {
    display: inline-flex;
    align-items: center;
    margin-top: 0;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.result-link:hover,
.show-thread-btn:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

/* Main content with thread panel */
.main-content {
    display: flex;
    gap: 16px;
}

.results {
    flex: 1;
    min-width: 0;
}

.thread-panel {
    display: none;
    width: 420px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 16px;
    max-height: calc(100vh - 220px);
    overflow: hidden;
    position: sticky;
    top: 200px;
}

.thread-panel.active {
    display: flex;
    flex-direction: column;
}

.thread-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.thread-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.thread-close {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s;
}

.thread-close:hover {
    color: var(--text);
}

.thread-close:hover circle {
    fill: var(--bg-hover);
}

.thread-items {
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.thread-items::-webkit-scrollbar {
    display: none;
}

.thread-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    scroll-margin-top: 16px;
}

.thread-item.current {
    border-color: var(--accent-glow);
    background: var(--bg-card-active);
}

.thread-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.thread-item-part {
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.thread-item-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    text-decoration: none;
    display: block;
}

a.thread-item-title:hover {
    color: var(--accent);
}

.thread-item-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    cursor: pointer;
    transition: color 0.15s;
}

.thread-item-text:hover {
    color: var(--text-subtle);
}

.thread-item-text.has-more {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
}

.thread-item-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}

.thread-item-link:hover {
    text-decoration: underline;
}



/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: auto;
    color: var(--text-muted);
    font-size: 13px;
}

.footer a {
    color: var(--text-muted);
    text-decoration: none;
    position: relative;
    transition: color 0.2s ease;
}

.footer .heart {
    color: var(--accent);
}

.footer a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 0.5px;
    background: var(--text-muted);
    transform-origin: right;
    transform: scaleX(1);
    transition: transform 180ms var(--ease-out), background-color 180ms var(--ease-out);
}

.footer a:hover {
    color: var(--text);
}

.footer a:hover::after {
    background: var(--accent);
}

/* === Streams & Timecodes === */
.streams-count {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 2rem;
    padding: 1rem 0;
}

.streams-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.stream-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow-card);
    transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
    scroll-margin-top: 120px;
}

.stream-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-card-hover);
    box-shadow: var(--shadow-card-hover);
}

.stream-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.stream-card > .badge {
    display: inline-block;
    margin-bottom: 8px;
}

.stream-title {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.4;
    text-decoration: none;
}

a.stream-title:hover {
    color: var(--accent);
}

.stream-preview {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, black 40%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, black 40%, transparent 100%);
    cursor: pointer;
}

.stream-timecode-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    padding: 2px 6px;
    margin: 0 -6px;
    text-decoration: none !important;
    transition: opacity 0.15s;
}

.stream-timecode-row:hover {
    text-decoration: none !important;
}

.stream-timecode-time {
    background: var(--bg-accent-active);
    color: var(--text);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    flex-shrink: 0;
    text-decoration: none;
}

.stream-timecode-time:hover {
    background: var(--bg-accent-strong);
}

@media (min-width: 601px) {
    .stream-preview .stream-timecode-time:hover {
        background: var(--bg-accent-active);
    }
    
    .stream-preview .timecode-goto-btn:hover {
        color: var(--text-muted);
    }
}

.stream-timecode-title {
    display: inline;
    color: var(--text-muted);
    text-decoration: none;
    line-height: 1.4;
    font-size: 0.85rem;
}



.stream-preview.hidden {
    display: none;
}

.stream-all-timecodes {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.stream-timecode-row-full {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    border-radius: 8px;
    padding: 2px 6px;
    margin: 0 -6px;
    transition: background 0.2s;
}

.stream-timecode-row-full.current {
    background: var(--bg-card-active);
    box-shadow: 0 0 0 1px var(--accent-glow);
}

.stream-timecode-row-full.current .stream-timecode-title-full {
    color: var(--text);
}

.stream-timecode-content {
    display: block;
    flex: 1;
    min-width: 0;
    line-height: 1.4;
    /* font-size: 0 убирает inline-пробел между span и button в HTML,
       чтобы стрелка прилипала к тексту без видимого зазора */
    font-size: 0;
    /* предотвращает «orphan» — одинокую стрелку на новой строке */
    text-wrap: pretty;
}

.stream-timecode-title-full {
    display: inline;
    color: var(--text-muted);
    line-height: 1.4;
    font-size: 0.85rem;
}

.stream-all-timecodes {
    cursor: pointer;
}

.timecode-goto-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    opacity: 1;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    margin: 0 0 0 4px;
    display: inline-block;
    vertical-align: -3px;
    flex-shrink: 0;
    transition: color 0.15s;
}

.timecode-goto-btn svg {
    opacity: 1;
    margin-top: 0 !important;
    display: inline-block;
    vertical-align: middle;
}

.timecode-goto-btn:hover {
    color: var(--accent);
}

.stream-timecodes-loading,
.stream-timecodes-error {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 8px 0;
}

.stream-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stream-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.stream-btn:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

/* Timecodes Panel */
.timecodes-panel {
    display: none;
    width: 480px;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 16px;
    max-height: calc(100vh - 220px);
    overflow: hidden;
    position: sticky;
    top: 200px;
}

/* Thread panel for timecodes section (desktop) - replaces timecodes panel */
#timecodesThreadPanel {
    width: 480px;
}

#timecodes-section .timecodes-panel.active:has(~ #timecodesThreadPanel.active) {
    display: none;
}

.timecodes-panel.active {
    display: flex;
    flex-direction: column;
}

.timecodes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}

.timecodes-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    min-width: 0;
    flex: 1;
}

.timecodes-title a {
    color: inherit;
    text-decoration: none;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timecodes-title a:hover {
    color: var(--accent);
}

.timecodes-close {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s;
}

.timecodes-close:hover {
    color: var(--text);
}

.timecodes-close:hover circle {
    fill: var(--bg-hover);
}

.timecodes-items {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.timecodes-items::-webkit-scrollbar {
    display: none;
}

.timecode-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-card);
    transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
    scroll-margin-top: 16px;
    min-width: 0;
}

.timecode-item:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-card-hover);
    box-shadow: var(--shadow-card-hover);
}

.timecode-item.current {
    border-color: var(--accent-glow);
    background: var(--bg-card-active);
}

.timecode-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.timecode-badge {
    background: var(--bg-accent-active);
    color: var(--text);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), transform 140ms var(--ease-out);
    flex-shrink: 0;
    text-decoration: none;
}

.timecode-badge:hover {
    background: var(--bg-accent-strong);
}

.timecode-topic {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
    text-decoration: none;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: break-word;
}

.timecode-topic:hover {
    color: var(--accent);
}

.timecode-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 10px;
    cursor: pointer;
    transition: color 0.15s;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.timecode-text:hover {
    color: var(--text-subtle);
}

.timecode-text.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-mask-image: none;
    mask-image: none;
}

.timecode-text.has-more {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 0%, transparent 100%);
}

.timecode-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.timecode-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.timecode-btn:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

/* Mobile */
@media (max-width: 600px) {
    .container {
        padding: 2rem var(--container-padding-x);
        max-width: 100%;
    }
    
    .logo {
        font-size: 2.2rem;
    }
    
    /* Sticky-хедер на мобиле — full-bleed с контентом ровно по ширине контейнера.
       Та же формула что на десктопе, через CSS-переменные. */
    .search-block,
    .timecodes-sticky-header,
    .clarify-sticky-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: transparent;
        margin-top: 0;
        margin-bottom: 1.5rem;
        padding-top: 1.25rem;
        padding-bottom: 0.75rem;
        width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding-left: max(var(--container-padding-x),
                          calc((100vw - var(--container-max-width)) / 2 + var(--container-padding-x)));
        padding-right: max(var(--container-padding-x),
                           calc((100vw - var(--container-max-width)) / 2 + var(--container-padding-x)));
        display: flow-root;
        transition: background-color 200ms ease, backdrop-filter 200ms ease;
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }

    /* Frosted-glass фон только при залипании */
    .search-block.is-stuck,
    .timecodes-sticky-header.is-stuck,
    .clarify-sticky-header.is-stuck {
        background: var(--sticky-bg-mobile);
        backdrop-filter: blur(24px) saturate(160%);
        -webkit-backdrop-filter: blur(24px) saturate(160%);
    }

    /* Растушёвка нижнего края при залипании */
    .search-block.is-stuck::after,
    .timecodes-sticky-header.is-stuck::after,
    .clarify-sticky-header.is-stuck::after {
        content: "";
        position: absolute;
        left: 0;
        right: 0;
        bottom: -28px;
        height: 28px;
        background: var(--sticky-fade-mobile);
        pointer-events: none;
    }

    /* Гэп между nav и следующим элементом (search-row для Поиск/Таймкоды),
       либо между nav и низом блока (для Прояснить — там переопределим до 0). */
    .search-block .nav-menu,
    .timecodes-sticky-header .nav-menu,
    .clarify-sticky-header .nav-menu {
        margin-bottom: 0.75rem;
    }

    /* В «Прояснить» под nav ничего нет — убираем дублирующий gap */
    .clarify-sticky-header .nav-menu {
        margin-bottom: 0;
    }

    /* На мобиле во вкладке Таймкоды search-row — последний элемент в блоке */
    .timecodes-sticky-header .search-row {
        margin-bottom: 0;
    }

    /* Тогглы стримов на мобиле прячем (вместо них — кнопка-фильтр в шапке) */
    .timecodes-toggles {
        display: none;
    }

    .search-block::after {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    
    .filters-btn {
        display: flex;
    }
    
    .search-wrapper {
        margin-bottom: 0.5rem;
    }
    
    .toggles {
        display: none;
    }
    
    .results-footer .limit-section {
        display: none;
    }
    
    .toggle {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    
    
    .result-card {
        padding: 16px 18px;
    }
    
    .thread-panel.active {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        z-index: 1001;
        background: var(--bg);
    }
    
    .thread-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--bg);
    }
    

    
    .thread-items {
        flex: 1;
        padding-bottom: 2rem;
    }
    
    .timecodes-panel.active {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        z-index: 1000;
        background: var(--bg);
    }
    
    .timecodes-header {
        padding: 1rem;
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--bg);
    }
    
    .timecodes-items {
        flex: 1;
        padding-bottom: 2rem;
    }
    
    #timecodesThreadPanel.active {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        z-index: 1001;
        background: var(--bg);
    }
    
    .timecode-goto-btn {
        margin-left: auto;
        margin-right: 0;
    }
}


/* Small screens - toggle layout fix */
@media (max-width: 395px) {
    .toggle-section {
        flex-direction: column;
        gap: 6px;
    }
    
    .result-header {
        flex-wrap: wrap;
        gap: 6px;
    }
}

/* Extra small screens (320px) */
@media (max-width: 360px) {
    body {
        overflow-x: clip;
    }

    .container {
        padding: 1.5rem var(--container-padding-x);
        max-width: 100%;
    }

    /* sticky-блок full-bleed уже задан в @media (max-width: 600px),
       здесь ничего переопределять не нужно — переменная --container-padding-x
       автоматически даёт корректный padding на узких экранах */

    .logo {
        font-size: 1.8rem;
    }

    .tagline {
        font-size: 0.75rem;
    }

    .header {
        margin-bottom: 1.5rem;
    }

    .filters-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .filters-btn svg {
        width: 20px;
        height: 20px;
    }

    .filters-close svg {
        width: 32px;
        height: 32px;
    }

    .filters-header {
        padding: 1rem 1rem;
    }

    .filters-content {
        padding: 1rem 1rem 1rem;
    }

    .filters-title {
        font-size: 16px;
    }

    .nav-item {
        font-size: 13px;
    }

    .search-placeholder {
        left: 44px;
        right: 40px;
        padding: 12px 0;
        font-size: 0.8rem;
    }

    #searchInput,
    #streamsSearchInput {
        height: 44px;
        padding: 0 40px 0 44px;
        font-size: 0.8rem;
        border-radius: 12px;
    }

    .suggestion-item {
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .search-icon {
        left: 16px;
        top: 13px;
        width: 18px;
        height: 18px;
    }

    .search-loader {
        right: 14px;
    }

    .toggles {
        gap: 0.75rem;
        margin-bottom: 1.5rem;
    }

    .toggle-section {
        flex-direction: column;
        gap: 6px;
    }

    .toggle-label {
        font-size: 12px;
    }

    .toggle-group {
        padding: 3px;
        border-radius: 8px;
    }

    .toggle {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 6px;
    }

    .result-card {
        padding: 12px 14px;
        border-radius: 10px;
    }

    .result-header {
        gap: 6px;
        margin-bottom: 10px;
        flex-wrap: wrap;
    }

    .badge {
        padding: 4px 8px;
        font-size: 10px;
    }

    .fragment-badge {
        padding: 4px 8px;
        font-size: 10px;
    }

    .result-date {
        font-size: 10.5px;
    }

    .result-title {
        font-size: 0.9rem;
    }

    .result-text {
        font-size: 0.85rem;
    }

    .result-question {
        font-size: 0.8rem;
    }

    .site-quote {
        margin: 14px 0 9px 0;
        padding: 9px 12px;
        font-size: 0.82rem;
    }

    .result-link,
    .show-thread-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    .results-count {
        font-size: 12px;
    }
}

/* === YouTube Player === */
.player-container {
    position: fixed;
    bottom: 0;
    right: 20px;
    width: 400px;
    background: var(--player-bg);
    border-radius: 12px 12px 0 0;
    box-shadow: var(--player-shadow);
    z-index: 1100;
    display: none;
    overflow: visible;
    border: 1px solid var(--border);
    border-bottom: none;
    touch-action: none;
    box-sizing: border-box;
}

/* Resize handles */
.player-resize-handle {
    position: absolute;
    z-index: 20;
}
.player-resize-handle[data-dir="n"] { top: 0; left: 8px; right: 8px; height: 4px; cursor: n-resize; }
.player-resize-handle[data-dir="s"] { bottom: 0; left: 8px; right: 8px; height: 4px; cursor: s-resize; }
.player-resize-handle[data-dir="e"] { right: 0; top: 8px; bottom: 8px; width: 4px; cursor: e-resize; }
.player-resize-handle[data-dir="w"] { left: 0; top: 8px; bottom: 8px; width: 4px; cursor: w-resize; }
.player-resize-handle[data-dir="nw"] { top: 0; left: 0; width: 10px; height: 10px; cursor: nw-resize; }
.player-resize-handle[data-dir="ne"] { top: 0; right: 0; width: 10px; height: 10px; cursor: ne-resize; }
.player-resize-handle[data-dir="sw"] { bottom: 0; left: 0; width: 10px; height: 10px; cursor: sw-resize; }
.player-resize-handle[data-dir="se"] { bottom: 0; right: 0; width: 10px; height: 10px; cursor: se-resize; }

.player-container.active {
    display: block;
    animation: playerSlideIn 0.3s ease;
}

@keyframes playerSlideIn {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.player-container.minimized .player-wrapper {
    display: none;
}

.player-container.minimized {
    width: auto;
    min-width: 250px;
    max-width: min(400px, calc(100vw - 20px));
}

.player-container.minimized .player-title {
    max-width: 220px;
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    gap: 10px;
    cursor: grab;
    user-select: none;
}

.player-header:active {
    cursor: grabbing;
}

.player-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.player-controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.player-btn {
    background: var(--bg-elevated);
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.player-btn:hover {
    background: var(--bg-elevated-hover);
    color: var(--text);
}

.player-close:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.player-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    background: #000;
}

.player-vpn-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.4);
    font-size: 13px;
    text-align: center;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    animation: vpnHintFadeIn 0.5s ease 3s forwards;
}

@keyframes vpnHintFadeIn {
    to { opacity: 1; }
}

.player-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}


/* Mobile player */
@media (max-width: 600px) {
    .player-container {
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 12px 12px 0 0;
    }

    .player-container.minimized {
        min-width: unset;
    }
}

/* Small screens player */
@media (max-width: 460px) {
    .player-container:not(.minimized) {
        right: 0;
        left: 0;
        width: 100%;
    }
}

/* === Toast уведомление (copy-to-clipboard и т.п.) === */
.app-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--accent);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 10px 18px;
    border-radius: 24px;
    box-shadow: 0 8px 24px rgba(129, 140, 248, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10000;
}

.app-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Кликабельный баннер обновления — остаётся видимым до клика */
.app-toast-action {
    pointer-events: auto;
    background: var(--accent);
    box-shadow: 0 8px 32px rgba(129, 140, 248, 0.45);
}
.app-toast-action:hover {
    transform: translateX(-50%) translateY(-2px);
}

/* === Подсветка карточки результата при deep-link / переходе из clarify === */
@keyframes result-card-flash {
    0% { box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.0); border-color: var(--border); }
    20% { box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.5); border-color: var(--accent); }
    100% { box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.0); border-color: var(--border); }
}

.result-card.result-card-highlight {
    animation: result-card-flash 2.6s ease-out;
}

/* === Вкладка «Прояснить» === */

#clarify-section {
    padding-top: 0.5rem;
}

#clarify-section .nav-menu {
    margin-bottom: 0;
}

.clarify-wrap {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 4px 80px;
}

.clarify-intro {
    text-align: center;
    margin-bottom: 1.5rem;
}

.clarify-intro.is-hidden {
    display: none;
}

.clarify-title {
    font-size: 1.7rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    background: var(--clarify-title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.clarify-subtitle {
    color: var(--text-subtle);
    font-size: 0.95rem;
    max-width: 480px;
    margin: 0 auto 2rem;
    line-height: 1.55;
}

.clarify-starters {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 700px;
    margin: 0 auto;
}

.emo-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 76px;
    padding: 14px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: transform 140ms var(--ease-out), border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}

.emo-card:hover {
    border-color: rgba(129, 140, 248, 0.4);
    background: rgba(129, 140, 248, 0.06);
    box-shadow: var(--shadow-card-hover);
}

.emo-card:active {
    transform: scale(0.97);
}

.emo-glyph {
    font-size: 22px;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    color: var(--accent);
    line-height: 1;
    transition: transform 160ms var(--ease-out), color 160ms var(--ease-out);
    filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.25));
}

.emo-card:hover .emo-glyph {
    color: var(--accent-hover-solid);
}

.emo-label {
    color: var(--text-subtle);
    font-size: 0.85rem;
}

.emo-card:hover .emo-label {
    color: var(--text);
}

/* Чат */

.clarify-chat {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin: 1.25rem 0 1.5rem;
}

.clarify-message {
    max-width: 90%;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: clarify-msg-in 220ms var(--ease-out);
}

@keyframes clarify-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.clarify-message.user {
    align-self: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-right-radius: 4px;
}

.clarify-message.assistant {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.clarify-message.thinking {
    color: var(--text-muted);
    font-style: italic;
}

.clarify-thinking-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.clarify-thinking-dots span {
    width: 5px;
    height: 5px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: clarify-dot 1.2s ease-in-out infinite;
}

.clarify-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.clarify-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes clarify-dot {
    0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
    40% { opacity: 1; transform: scale(1); }
}

/* Кнопки-варианты ответов под вопросом */

.clarify-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    padding: 0 2px;
}

.clarify-option-btn {
    padding: 8px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-elevated);
    border-radius: 20px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), box-shadow 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.clarify-option-btn:hover {
    background: rgba(129, 140, 248, 0.12);
    border-color: rgba(129, 140, 248, 0.4);
}

/* Кнопка-вариант, добавленная в активную форму «Своё…».
   Видно с одного взгляда, что она уже учтена в собираемом ответе. */
.clarify-option-btn.collected {
    background: rgba(129, 140, 248, 0.18);
    border-color: var(--accent);
    color: var(--text);
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.35);
}

.clarify-option-btn.collected::before {
    content: '✓ ';
    color: var(--accent);
    font-weight: 600;
}

/* Когда активна форма «Своё…» — варианты в любом сообщении мягко подсвечиваются,
   чтобы юзер понял: их можно докликивать в собираемый ответ. */
.clarify-collecting .clarify-option-btn:not(.clarify-option-custom) {
    border-color: rgba(129, 140, 248, 0.3);
}

.clarify-option-custom {
    border-style: dashed;
    color: var(--text-muted);
}

.clarify-option-custom:hover {
    color: var(--text);
}

/* «Перейти к поиску» — это НЕ кнопка-ответ, а текстовая ссылка-meta.
   Сознательно отличается от .clarify-option-btn (без рамки, без фона) —
   чтобы юзер видел: это переход, а не вариант ответа. */
.clarify-skip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    flex-wrap: wrap;
}

/* Когда есть только одна ссылка (на ранних ходах — только «Ещё варианты»),
   она остаётся слева. Когда две — обе по краям. */
.clarify-skip-row:has(> .clarify-skip-link:only-child) {
    justify-content: flex-start;
}

.clarify-skip-link {
    background: none;
    border: none;
    padding: 4px 0;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.clarify-skip-link:hover {
    color: var(--accent);
}

.clarify-skip-arrow {
    display: inline-block;
    transition: transform 140ms var(--ease-out);
    font-size: 0.95rem;
    line-height: 1;
}

.clarify-more-icon {
    display: inline-block;
    font-size: 0.95rem;
    line-height: 1;
    transition: transform 180ms var(--ease-out);
}

.clarify-more-link.is-loading .clarify-more-icon {
    animation: clarify-spin 0.8s linear infinite;
}

@keyframes clarify-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Инлайн-форма «Своё…» — превращается из кнопки */

.clarify-inline-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 12px;
    background: rgba(129, 140, 248, 0.08);
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 20px;
    min-width: 200px;
    max-width: 100%;
    flex: 0 1 280px;
    transition: border-color 0.2s ease;
}

.clarify-inline-form:focus-within {
    border-color: var(--accent);
    background: rgba(129, 140, 248, 0.14);
    box-shadow: 0 0 0 3px rgba(91, 82, 176, 0.1);
}

.clarify-inline-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.88rem;
    line-height: 1.4;
    padding: 4px 0;
    min-width: 0;
}

.clarify-inline-input::placeholder {
    color: var(--text-muted);
}

.clarify-inline-send {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 140ms var(--ease-out), background-color 160ms var(--ease-out), opacity 160ms var(--ease-out);
}

.clarify-inline-send:hover:not(:disabled) {
    background: var(--accent-hover-solid);
}

.clarify-inline-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

/* Карточки-предложения с превью */

.clarify-suggestions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.clarify-suggestion-card {
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
    box-shadow: var(--shadow-card);
    transition: transform 140ms var(--ease-out), border-color 160ms var(--ease-out), background-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
    width: 100%;
    display: block;
}

.clarify-suggestion-card:hover {
    border-color: rgba(129, 140, 248, 0.45);
    background: rgba(129, 140, 248, 0.04);
    box-shadow: var(--shadow-card-hover);
}

.clarify-suggestion-query {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
    line-height: 1.35;
}

.clarify-suggestion-arrow {
    color: var(--text-muted);
    font-size: 0.85rem;
    transition: transform 160ms var(--ease-out), color 160ms var(--ease-out);
}

.clarify-suggestion-card:hover .clarify-suggestion-arrow {
    color: var(--accent);
}

.clarify-suggestion-preview {
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-top: 4px;
}

.clarify-suggestion-source {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.clarify-suggestion-source.video    { background: rgba(239, 68, 68, 0.15); color: var(--video); }
.clarify-suggestion-source.site     { background: var(--bg-accent-hover); color: var(--site); }
.clarify-suggestion-source.pev      { background: rgba(245, 158, 11, 0.15); color: var(--pev); }
.clarify-suggestion-source.lr       { background: rgba(16, 185, 129, 0.15); color: var(--lr); }
.clarify-suggestion-source.vzp      { background: rgba(236, 72, 153, 0.15); color: var(--vzp); }
.clarify-suggestion-source.periscope{ background: rgba(6, 182, 212, 0.15); color: var(--periscope); }

.clarify-suggestion-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
    line-height: 1.4;
}

.clarify-suggestion-snippet {
    font-size: 0.85rem;
    color: var(--text-subtle);
    line-height: 1.5;
}

.clarify-suggestion-empty {
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    margin-top: 4px;
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Кнопка «Уточнить ещё» — после suggestions, чтобы продолжить диалог */
.clarify-continue-row {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

.clarify-continue-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px dashed rgba(129, 140, 248, 0.4);
    border-radius: 20px;
    color: var(--text-subtle);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.clarify-continue-btn:hover {
    background: rgba(129, 140, 248, 0.08);
    border-color: var(--accent);
    border-style: solid;
    color: var(--text);
}

.clarify-continue-btn svg {
    flex-shrink: 0;
}

/* Поле ввода */

.clarify-input-row {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clarify-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.2s ease, background 0.2s ease;
    min-height: 56px;
}

.clarify-input-wrapper:focus-within {
    border-color: var(--accent);
    background: rgba(129, 140, 248, 0.04);
    box-shadow: var(--shadow-control-focus);
}

.clarify-input-stack {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    min-height: 40px;
}

#clarifyInput {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.45;
    padding: 0;
    margin: 0;
    resize: none;
    max-height: 160px;
    overflow-y: auto;
    /* центрирование короткого текста по вертикали */
    display: block;
}

/* Анимированный overlay-плейсхолдер (как в основном поиске) */
.clarify-placeholder {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.45;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    max-width: 100%;
    text-overflow: clip;
    transition: opacity 0.15s ease;
}

.clarify-placeholder.hidden {
    opacity: 0;
}

.clarify-placeholder-cursor {
    display: inline-block;
    width: 1px;
    height: 1em;
    background: var(--text-muted);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: clarify-caret 1s steps(2, end) infinite;
}

@keyframes clarify-caret {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.clarify-send {
    flex-shrink: 0;
    align-self: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 140ms var(--ease-out), background-color 160ms var(--ease-out), opacity 160ms var(--ease-out);
}

.clarify-send:hover {
    background: var(--accent-hover-solid);
}

.clarify-send:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

.clarify-reset {
    align-self: flex-end;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    padding: 4px 8px;
}

.clarify-reset:hover {
    color: var(--text);
}

.clarify-disclaimer {
    margin-top: 1.25rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.clarify-disclaimer a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed rgba(129, 140, 248, 0.4);
}

.clarify-disclaimer a:hover {
    border-bottom-style: solid;
}

/* Кнопка «Попробовать ещё раз» под error-сообщением (и rate-limit) */

.clarify-message-error {
    background: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.25);
}

.clarify-retry-row {
    margin-top: 10px;
    display: flex;
    justify-content: flex-start;
}

.clarify-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 18px;
    color: var(--accent);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.clarify-retry-btn:hover:not(:disabled) {
    background: rgba(129, 140, 248, 0.12);
    border-color: var(--accent);
    color: var(--accent-hover-solid);
}

.clarify-retry-btn:disabled {
    opacity: 0.5;
    cursor: default;
    color: var(--text-muted);
    border-color: var(--border);
}

.clarify-retry-btn svg {
    flex-shrink: 0;
}

/* Crisis screen */

.clarify-crisis {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 14px;
    padding: 18px 20px;
    margin-top: 1rem;
}

.clarify-crisis-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--danger-text);
    margin-bottom: 8px;
}

.clarify-crisis-msg {
    color: var(--text-subtle);
    line-height: 1.55;
    margin-bottom: 14px;
}

.clarify-crisis-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.clarify-crisis-list li {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.clarify-crisis-list .crisis-label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.clarify-crisis-list .crisis-value {
    font-weight: 600;
    color: var(--text);
}

.clarify-crisis-list a.crisis-value {
    color: var(--accent);
    text-decoration: none;
}

.clarify-crisis-list a.crisis-value:hover {
    text-decoration: underline;
}

/* Адаптив */

@media (max-width: 600px) {
    .clarify-title {
        font-size: 1.4rem;
    }

    .clarify-subtitle {
        font-size: 0.9rem;
        margin-bottom: 1.5rem;
    }

    .clarify-starters {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
    }

    .emo-card {
        min-height: 64px;
        padding: 10px 8px;
        font-size: 0.82rem;
    }

    .clarify-wrap {
        padding: 0 0 60px;
    }

    .clarify-message {
        max-width: 95%;
        font-size: 0.92rem;
    }

    .clarify-suggestion-query {
        font-size: 0.94rem;
    }

    #clarify-section .nav-menu {
        margin-bottom: 0;
    }
}

/* Когда диалог стартовал — прижимаем стартеры в одну строку */

.clarify-intro.is-collapsed {
    margin-bottom: 0.5rem;
}

.clarify-intro.is-collapsed .clarify-title,
.clarify-intro.is-collapsed .clarify-subtitle {
    display: none;
}

.clarify-intro.is-collapsed .clarify-starters {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    gap: 6px;
    /* Вертикальный padding оставляет место для мягкой тени карточек. */
    padding: 6px 0;
    -webkit-overflow-scrolling: touch;
}

.clarify-intro.is-collapsed .emo-card {
    min-height: 36px;
    padding: 8px 14px;
    flex-direction: row;
    gap: 8px;
}

.clarify-intro.is-collapsed .emo-glyph {
    font-size: 16px;
}

/* Ясная обратная связь без лишнего движения */
.theme-toggle:active,
.filters-btn:active,
.toggle:active,
.result-link:active,
.show-thread-btn:active,
.stream-btn:active,
.timecode-badge:active,
.timecode-btn:active,
.player-btn:active,
.clarify-option-btn:active,
.clarify-inline-send:active:not(:disabled),
.clarify-suggestion-card:active,
.clarify-continue-btn:active,
.clarify-send:active:not(:disabled),
.clarify-retry-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.search-clear:active {
    transform: translateY(-50%) scale(0.92);
}

.nav-item:focus-visible,
.theme-toggle:focus-visible,
.search-clear:focus-visible,
.filters-btn:focus-visible,
.filters-close:focus-visible,
.toggle:focus-visible,
.result-link:focus-visible,
.show-thread-btn:focus-visible,
.stream-btn:focus-visible,
.timecode-badge:focus-visible,
.timecode-btn:focus-visible,
.timecodes-close:focus-visible,
.player-btn:focus-visible,
.emo-card:focus-visible,
.clarify-option-btn:focus-visible,
.clarify-skip-link:focus-visible,
.clarify-inline-send:focus-visible,
.clarify-suggestion-card:focus-visible,
.clarify-continue-btn:focus-visible,
.clarify-send:focus-visible,
.clarify-reset:focus-visible,
.clarify-retry-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
    .theme-toggle:hover {
        transform: translateY(-1px);
    }

    .nav-item:hover::after {
        transform: scaleX(1);
    }

    .result-card:hover {
        transform: translateY(-1px);
    }

    .emo-card:hover,
    .clarify-suggestion-card:hover {
        transform: translateY(-2px);
    }

    .emo-card:hover .emo-glyph {
        transform: scale(1.06);
    }

    .clarify-skip-link:hover .clarify-skip-arrow,
    .clarify-suggestion-card:hover .clarify-suggestion-arrow {
        transform: translateX(3px);
    }

    .clarify-more-link:hover .clarify-more-icon {
        transform: rotate(180deg);
    }

    .clarify-inline-send:hover:not(:disabled) {
        transform: scale(1.06);
    }

    .clarify-send:hover:not(:disabled) {
        transform: scale(1.04);
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto !important;
    }

    .sparkle,
    .search-placeholder-cursor,
    .clarify-placeholder-cursor,
    .clarify-thinking-dots span,
    .clarify-message,
    .player-vpn-hint {
        animation: none !important;
    }

    .filters-panel,
    .filters-panel-backdrop,
    .theme-toggle,
    .nav-item::after,
    .result-card,
    .stream-card,
    .timecode-item,
    .emo-card,
    .clarify-suggestion-card,
    .clarify-inline-send,
    .clarify-send {
        transition-duration: 0.01ms !important;
    }

    .result-card:hover,
    .emo-card:hover,
    .emo-card:hover .emo-glyph,
    .clarify-suggestion-card:hover,
    .clarify-suggestion-card:hover .clarify-suggestion-arrow,
    .clarify-skip-link:hover .clarify-skip-arrow,
    .clarify-more-link:hover .clarify-more-icon {
        transform: none !important;
    }
}

/* =====================================================================
   Волна 2А: закладки, вход по почте, честное качество выдачи, лимит
   ===================================================================== */

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Кнопки «Закладки» и «Войти» рядом с переключателем темы --- */
.top-actions {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    right: calc(max(16px, env(safe-area-inset-right)) + 50px);
    z-index: 900;
    display: flex;
    gap: 8px;
}

.top-action-btn {
    position: relative;
    height: 42px;
    min-width: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 21px;
    background: var(--bg-card-hover);
    color: var(--text-subtle);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-control);
    cursor: pointer;
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    transition: color 140ms var(--ease-out), border-color 140ms var(--ease-out), background-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out), transform 140ms var(--ease-out);
}

.top-action-btn:hover {
    color: var(--accent);
    border-color: var(--border-accent-hover);
    background: var(--bg-accent-hover);
}

.top-action-btn:active {
    transform: scale(0.97);
}

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

.top-action-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.top-action-label {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-action-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

.top-action-auth.is-signed-in .top-action-label {
    max-width: 150px;
}

@media (max-width: 900px) {
    .top-action-btn {
        width: 42px;
        padding: 0;
        border-radius: 50%;
    }

    .top-action-label {
        display: none;
    }

    .top-action-count {
        position: absolute;
        top: -4px;
        right: -4px;
    }
}

@media (max-width: 600px) {
    .top-actions {
        top: max(12px, env(safe-area-inset-top));
        left: max(12px, env(safe-area-inset-left));
        right: auto;
    }

    .top-action-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .top-actions {
        gap: 6px;
        align-items: center;
    }

    /* Компактная круглая кнопка входа рядом с закладками. Когда шапка
       прилипает к верху, прячем её, чтобы не наезжала на меню вкладок */
    .top-action-auth {
        width: 36px;
        height: 36px;
        min-width: 36px;
        transition: opacity 160ms var(--ease-out), visibility 160ms var(--ease-out), transform 140ms var(--ease-out);
    }

    .top-action-auth .top-action-icon {
        width: 16px;
        height: 16px;
    }

    html.header-stuck .top-action-auth {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }
}

/* --- Фильтры источников: все серии видео, без горизонтальной прокрутки --- */
.source-filter-group {
    flex-wrap: wrap;
    justify-content: center;
}

.filters-content .source-filter-group {
    justify-content: flex-start;
}

.results-column {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.results-column > .results {
    flex: none;
}

.search-notice-slot:empty,
.shared-chunk:empty {
    display: none;
}

/* --- Честное качество: бейдж только у точного совпадения --- */
.tier-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.35;
}

.tier-badge-exact {
    color: var(--accent);
    background: var(--bg-accent-active);
    border: 1px solid var(--border-accent-hover);
}

.tier-badge-exact::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.result-card.tier-exact {
    border-color: var(--border-accent-hover);
}

/* --- Цитаты читателей и зрителей в blocks[] --- */
.quote-label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-style: normal;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.result-text.site-rich .site-answer + .site-quote {
    margin-top: 14px;
}

/* --- «Читать полностью» под текстом карточки --- */
.read-more-btn {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    padding: 4px 0;
    border: none;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.read-more-btn:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.read-more-btn:disabled {
    color: var(--text-muted);
    cursor: progress;
}

.read-more-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.card-stale-note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Инструменты карточки: сохранить, цитата, оценка --- */
.card-tool {
    gap: 6px;
}

.card-tool-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.card-tool.is-saved {
    color: var(--accent);
    border-color: var(--border-accent-hover);
    background: var(--bg-accent-active);
}

.card-tool.is-saved .card-tool-icon {
    fill: currentColor;
}

.card-feedback {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.card-vote {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.45;
    filter: grayscale(1);
    transition: opacity 140ms var(--ease-out), filter 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.card-vote:hover:not(:disabled) {
    opacity: 1;
    filter: none;
    background: var(--bg-hover);
}

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

.card-feedback.is-voted .card-vote {
    cursor: default;
}

.card-vote.is-active {
    opacity: 1;
    filter: none;
    background: var(--bg-accent-active);
    border-color: var(--border-accent-hover);
}

@media (max-width: 600px) {
    .result-actions {
        gap: 8px;
    }

    .card-tool-icon {
        width: 14px;
        height: 14px;
    }

    .card-vote {
        width: 32px;
        height: 32px;
    }
}

/* --- Плашки над выдачей и в «Прояснить» --- */
.search-notice,
.quota-notice {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    box-shadow: var(--shadow-card);
    color: var(--text-subtle);
    animation: noticeIn 220ms var(--ease-out);
}

.search-notice-empty {
    padding: 22px 18px;
    text-align: center;
}

.search-notice-empty .search-notice-actions {
    justify-content: center;
}

.search-notice-title,
.quota-notice-title {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
}

.search-notice-text,
.quota-notice-timer,
.quota-notice-note {
    margin-top: 4px;
    font-size: 0.875rem;
    line-height: 1.5;
}

.quota-notice-timer {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.quota-notice.is-ready .quota-notice-timer {
    color: var(--accent);
    font-weight: 500;
}

.quota-notice-note {
    color: var(--text-muted);
}

.search-notice-actions,
.quota-notice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.notice-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 7px 14px;
    border: 1px solid var(--border-elevated);
    border-radius: 8px;
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out), opacity 140ms var(--ease-out);
}

.notice-btn:hover:not(:disabled) {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
    color: var(--accent);
}

.notice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.notice-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}

.notice-btn-primary:hover:not(:disabled) {
    background: var(--accent-hover-solid);
    border-color: var(--accent-hover-solid);
    color: var(--on-accent);
}

.notice-btn-danger {
    color: var(--danger-text);
}

.notice-btn-danger:hover:not(:disabled) {
    color: var(--danger-text);
    border-color: var(--danger-text);
    background: transparent;
}

.clarify-message.clarify-quota {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    max-width: 100%;
}

.clarify-message.clarify-quota .quota-notice {
    text-align: left;
}

@keyframes noticeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Материал по ссылке ?chunk= --- */
.shared-chunk {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.shared-chunk-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px;
}

.shared-chunk-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.shared-chunk-close {
    border: none;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 2px;
}

.shared-chunk-close:hover {
    color: var(--accent);
}

.shared-chunk-loading {
    padding: 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Недавние запросы под пустым полем поиска --- */
.suggestions-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.suggestions-clear {
    border: none;
    background: none;
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 2px 0;
}

.suggestions-clear:hover {
    color: var(--accent);
}

.recent-suggestion {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.recent-suggestion-query {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-suggestion-meta {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Панель «Закладки / Недавние» --- */
.library-backdrop,
.auth-backdrop {
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    opacity: 0;
    transition: opacity 200ms var(--ease-out);
}

.library-backdrop {
    z-index: 1240;
}

.library-backdrop.open,
.auth-backdrop.open {
    opacity: 1;
}

.library-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1250;
    width: min(460px, 100vw);
    display: flex;
    flex-direction: column;
    background: var(--popover-bg);
    border-left: 1px solid var(--border);
    box-shadow: var(--popover-shadow);
    transform: translateX(100%);
    transition: transform 220ms var(--ease-drawer);
}

.library-panel.open {
    transform: translateX(0);
}

.library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(14px, env(safe-area-inset-top)) 16px 12px 18px;
    border-bottom: 1px solid var(--border);
}

.library-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
}

.library-tab {
    padding: 7px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.library-tab:hover {
    color: var(--text-subtle);
}

.library-tab.active {
    background: var(--bg-accent-hover);
    color: var(--accent);
}

.library-tab:focus-visible,
.library-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.library-close,
.auth-close {
    display: inline-flex;
    padding: 0;
    border: none;
    background: none;
    color: var(--text-subtle);
    cursor: pointer;
    border-radius: 50%;
}

.library-close svg,
.auth-close svg {
    width: 34px;
    height: 34px;
}

.library-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px max(20px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.library-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.library-cards .result-card {
    padding: 14px 14px;
    animation: none;
}

.library-empty {
    padding: 28px 12px;
    text-align: center;
}

.library-empty-title {
    color: var(--text);
    font-weight: 600;
    margin-bottom: 6px;
}

.library-empty-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.recent-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recent-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out);
}

.recent-item:hover {
    background: var(--bg-accent-hover);
    border-color: var(--border-accent-hover);
}

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

.recent-query {
    font-size: 0.92rem;
    line-height: 1.4;
    word-break: break-word;
}

.recent-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.recent-clear {
    margin-top: 10px;
}

.library-account {
    margin-top: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.library-account-note {
    color: var(--text-subtle);
    font-size: 0.875rem;
    line-height: 1.5;
}

.library-account-email {
    color: var(--text);
    font-weight: 600;
    word-break: break-all;
}

.library-account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.library-confirm {
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--text-subtle);
    line-height: 1.5;
}

@media (max-width: 600px) {
    .library-panel {
        top: auto;
        left: 0;
        width: 100%;
        height: min(92vh, 92dvh);
        border-left: none;
        border-top: 1px solid var(--border);
        border-radius: 18px 18px 0 0;
        box-shadow: var(--drawer-shadow);
        transform: translateY(100%);
    }

    .library-panel.open {
        transform: translateY(0);
    }

    .library-header {
        padding: 12px 12px 10px 14px;
    }

    .library-scroll {
        padding: 12px 10px max(20px, env(safe-area-inset-bottom));
    }

    .library-cards .result-card {
        padding: 12px;
    }
}

/* --- Окно входа: почта и 6 цифр --- */
.auth-backdrop {
    z-index: 1340;
}

.auth-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1350;
    width: min(400px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    padding: 28px 24px 22px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--popover-bg);
    box-shadow: var(--popover-shadow);
    color: var(--text);
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px));
    transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.auth-modal.open {
    opacity: 1;
    transform: translate(-50%, -50%);
}

.auth-close {
    position: absolute;
    top: 12px;
    right: 12px;
}

.auth-step {
    display: flex;
    flex-direction: column;
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    padding-right: 36px;
}

.auth-text {
    margin-top: 8px;
    color: var(--text-subtle);
    font-size: 0.9rem;
    line-height: 1.5;
}

.auth-email-value {
    color: var(--text);
    font-weight: 600;
    word-break: break-all;
}

.auth-label {
    margin-top: 18px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.auth-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
    font-size: 16px;
    transition: border-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}

.auth-input:focus,
.auth-cell:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--shadow-control-focus);
}

.auth-error {
    margin-top: 10px;
    color: var(--danger-text);
    font-size: 0.85rem;
    line-height: 1.45;
}

.auth-primary {
    margin-top: 16px;
    height: 48px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 140ms var(--ease-out), opacity 140ms var(--ease-out);
}

.auth-primary:hover:not(:disabled) {
    background: var(--accent-hover-solid);
}

.auth-primary:disabled {
    opacity: 0.6;
    cursor: progress;
}

.auth-primary:focus-visible,
.auth-link:focus-visible,
.auth-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.auth-consent {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.auth-consent a {
    color: var(--text-subtle);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-code {
    margin-top: 18px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.auth-cell {
    width: 100%;
    height: 54px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
    caret-color: var(--accent);
    transition: border-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}

.auth-cell.filled {
    border-color: var(--border-accent-hover);
}

.auth-cell:disabled {
    opacity: 0.5;
}

.auth-secondary-row {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
}

.auth-link {
    padding: 4px 0;
    border: none;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.auth-link:disabled {
    color: var(--text-muted);
    cursor: default;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
    .auth-modal {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 92vh;
        padding: 24px 18px max(20px, env(safe-area-inset-bottom));
        border-radius: 18px 18px 0 0;
        transform: translateY(16px);
    }

    .auth-modal.open {
        transform: translateY(0);
    }

    .auth-code {
        gap: 6px;
    }

    .auth-cell {
        height: 50px;
        font-size: 20px;
    }
}

/* --- Плеер: подсказка про VPN, если Ютуб не загрузился --- */
.player-container.yt-unavailable .player-vpn-hint {
    opacity: 1;
    animation: none;
    color: var(--text-subtle);
    padding: 0 16px;
    width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .library-panel,
    .auth-modal,
    .library-backdrop,
    .auth-backdrop {
        transition: none;
    }

    .search-notice,
    .quota-notice {
        animation: none;
    }
}

/* В свёрнутой карточке вопрос читателя занимает не больше двух строк,
   чтобы сразу было видно начало ответа Флома */
.result-text.site-rich.has-more {
    max-height: 10.5em;
}

.result-text.site-rich.has-more .site-quote {
    max-height: 5.2em;
    overflow: hidden;
}

.result-text.site-rich.has-more .site-quote .site-para {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-text.site-rich.has-more .site-quote .site-para + .site-para {
    display: none;
}


/* Закрытая шторка фильтров не должна существовать на странице:
   ни на длинной выдаче, ни на десктопе, ни при печати всей страницы */
.filters-panel {
    visibility: hidden;
    transition: transform 280ms var(--ease-drawer), visibility 0s linear 280ms;
}

.filters-panel.active {
    visibility: visible;
    transition: transform 280ms var(--ease-drawer), visibility 0s linear 0s;
}

.filters-panel-backdrop:not(.active) {
    visibility: hidden;
}

@media (min-width: 601px) {
    .filters-panel,
    .filters-panel-backdrop {
        display: none;
    }
}

/* Пока открыта шторка или окно входа, тост показываем сверху,
   чтобы он не закрывал кнопки внизу */
html.sheet-open .app-toast {
    top: max(16px, env(safe-area-inset-top));
    bottom: auto;
    transform: translateX(-50%) translateY(-20px);
    z-index: 10000;
}

html.sheet-open .app-toast.visible {
    transform: translateX(-50%) translateY(0);
}

/* Светлая тема: тихие 👍/👎 чуть заметнее, чтобы не сливались с карточкой */
html:not([data-theme="dark"]) .card-vote {
    opacity: 0.72;
    filter: grayscale(0.85);
}

html:not([data-theme="dark"]) .card-vote:hover:not(:disabled),
html:not([data-theme="dark"]) .card-vote.is-active {
    opacity: 1;
    filter: none;
}

/* Таймкоды с blocks[]: вопрос зрителя и абзацы ответа */
.timecode-text.site-rich {
    white-space: normal;
}

.timecode-text.site-rich.has-more {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    max-height: 8.5em;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}

.timecode-text.site-rich.has-more .site-quote .site-para {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* На телефоне круглая кнопка входа стоит над логотипом, поэтому при
   включённом входе чуть опускаем шапку, чтобы они не касались */
@media (max-width: 600px) {
    html.auth-enabled .header {
        padding-top: 22px;
    }
}

@media (max-width: 380px) {
    html.auth-enabled .header {
        padding-top: 30px;
    }
}
