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

:root {
    --primary-color: #6566F1;
    --primary-hover: #885DF6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #0f0a2e;
    --surface-color: rgba(255,255,255,0.04);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: rgba(255,255,255,0.08);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    --radius: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(160deg, #0f0a2e 0%, #1a1050 30%, #15103a 60%, #0d0825 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Ambient background glow effects */
body::before {
    content: '';
    position: fixed;
    top: -30%;
    left: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(ellipse, rgba(136,93,246,0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    right: -15%;
    width: 50%;
    height: 50%;
    background: radial-gradient(ellipse, rgba(101,102,241,0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   MAIN LAYOUT: Sidebar + Content
   ============================================ */

.main-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: padding-left 0.3s ease;
    padding-left: 200px; /* sidebar width when open */
    flex: 1;
    min-width: 0;
}

.main-layout.sidebar-collapsed {
    padding-left: 0;
}

/* ============================================
   TOP NAVIGATION BAR (на всіх сторінках)
   ============================================ */
.top-nav-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px 10px 16px;
    background: rgba(15, 10, 46, 0.97);
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 150;
}

.top-nav-btn {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
    font-family: inherit;
}

.top-nav-btn-with-help {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.top-nav-btn-with-help .sp-help-icon {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    color: var(--text-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    cursor: help;
}

.top-nav-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}

.top-nav-btn.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* П.9: три стани кнопки AI чат — неактивна, активна, готова до активності */
.top-nav-btn.top-nav-btn-ai-chat {
    color: var(--text-secondary);
}
.top-nav-btn.top-nav-btn-ai-chat:not(.active):not(.top-nav-btn-ai-chat-ready) {
    opacity: 0.8;
    color: #94a3b8;
}
.top-nav-btn.top-nav-btn-ai-chat:hover,
.top-nav-btn.top-nav-btn-ai-chat.top-nav-btn-ai-chat-ready {
    color: var(--text-primary);
}
.top-nav-btn.top-nav-btn-ai-chat.active {
    opacity: 1;
}

.top-nav-btn.top-nav-btn-ai-chat-ready {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.5);
}

.top-nav-btn.top-nav-btn-ai-chat-ready::after {
    content: '';
    display: none;
}
.top-nav-btn .top-nav-ai-chat-badge {
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 9px;
    background: #f59e0b;
    color: #1e293b;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    vertical-align: middle;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.top-nav-btn.top-nav-btn-ai-chat-ready .top-nav-ai-chat-badge {
    display: inline-flex;
}

.top-nav-btn-lex {
    /* Без margin-left: auto — усі кнопки навігації центровані разом */
}

.rp-view-tabs-in-header {
    flex-shrink: 0;
}

/* Нижню панель режиму перегляду прибрано (п.1, п.2 ТЗ) */
#resultsArea .rp-perpage-wrapper,
#resultsArea .rp-view-tabs.rp-view-tabs-in-header,
#resultsArea .rp-filters-display.rp-filters-in-header {
    display: none !important;
}
#categoryResultsArea .rp-view-tabs.rp-cat-view-tabs {
    display: none !important;
}

.rp-perpage-in-header {
    flex-shrink: 0;
}

.rp-filters-in-header {
    width: 100%;
    margin-top: 8px;
}

.search-container {
    flex: 1;
    min-height: 0;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 24px;
}

/* ============================================
   LEFT SIDEBAR - Ліва бокова панель
   ============================================ */

.sidebar-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 200px;
    background: linear-gradient(180deg, #1a1050 0%, #130d3a 100%);
    color: #e2e8f0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.06);
    padding: 16px 12px;
    gap: 12px;
    overflow-y: auto;
    transition: transform 0.3s ease, width 0.3s ease;
    transform: translateX(0);
}

.sidebar-panel.collapsed {
    transform: translateX(-100%);
}

/* Прихований блок решти пунктів меню (Синоніми та Промпт зверху) */
.sidebar-rest-hidden {
    display: none !important;
}

/* Sidebar navigation buttons */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-align: left;
    line-height: 1.3;
    text-decoration: none;
}

.sidebar-nav-btn-primary {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #fff;
}

.sidebar-nav-btn-primary:hover {
    filter: brightness(1.15);
    box-shadow: 0 4px 16px rgba(37,99,235,0.3);
}

.sidebar-nav-btn-outline {
    background: transparent;
    color: #94a3b8;
    border: 1px solid rgba(255,255,255,0.12);
}

.sidebar-nav-btn-outline:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    border-color: rgba(255,255,255,0.2);
}

.sidebar-nav-btn-active {
    background: linear-gradient(135deg, rgba(136,93,246,0.25), rgba(101,102,241,0.25)) !important;
    border-color: rgba(136,93,246,0.5) !important;
    color: #c4b5fd !important;
}

/* Wrapper for history block (can be hidden by "Показати історію пошуку") */
.sidebar-history-block {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    overflow: hidden;
}
.sidebar-history-block.is-hidden {
    display: none;
}

/* Sidebar secondary nav group */
.sidebar-nav-secondary {
    margin-top: 4px;
}

/* Toggle "Показати історію пошуку" button */
.sidebar-toggle-history-btn .sidebar-toggle-history-text {
    white-space: normal;
    line-height: 1.25;
}

/* Sidebar history section */
.sidebar-history {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-history-header {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 4px 6px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 4px;
}

.sidebar-history-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* History items inside sidebar */
.sidebar-history-list .chat-history-item,
.sidebar-history-list > div {
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-history-list .chat-history-item:hover,
.sidebar-history-list > div:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}

.sidebar-history-list .chat-history-item.active,
.sidebar-history-list > div.active {
    background: rgba(101,102,241,0.15);
    color: #c4b5fd;
}

.sidebar-new-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: auto;
}

.sidebar-new-search-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    border-color: rgba(255,255,255,0.25);
}

/* Sidebar toggle button - always visible */
.sidebar-toggle-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1002;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: rgba(26, 16, 80, 0.95);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
}

.sidebar-toggle-btn:hover {
    background: rgba(101,102,241,0.25);
    border-color: rgba(101,102,241,0.4);
    color: #c4b5fd;
}

/* Animate toggle button position (no backdrop-filter to avoid blur) */
.sidebar-toggle-btn {
    transition: left 0.3s ease, background 0.2s, border-color 0.2s, color 0.2s;
}

/* When sidebar is open, shift toggle right of sidebar */
.sidebar-toggle-btn.shifted {
    left: 208px;
}

/* Hide old sidebar styles */
.chat-sidebar {
    display: none !important;
}
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
}

.chat-sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #334155;
}

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #f1f5f9;
}

.sidebar-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.sidebar-close-btn:hover {
    background: #334155;
    color: #f1f5f9;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 16px;
    padding: 12px 16px;
    background: #334155;
    border: 1px dashed #475569;
    border-radius: 8px;
    color: #e2e8f0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    background: #475569;
    border-style: solid;
}

.new-chat-btn svg {
    flex-shrink: 0;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
}

.chat-history-item:hover {
    background: #334155;
}

.chat-history-item.active {
    background: #3b82f6;
}

.chat-history-item .chat-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.chat-history-item.active .chat-icon {
    color: white;
}

.chat-history-item .chat-info {
    flex: 1;
    min-width: 0;
}

.chat-history-item .chat-title {
    font-size: 14px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item .chat-date {
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.chat-history-item.active .chat-title,
.chat-history-item.active .chat-date {
    color: white;
}

.chat-history-item .chat-delete {
    opacity: 0;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-history-item:hover .chat-delete {
    opacity: 1;
}

.chat-history-item .chat-delete:hover {
    background: #ef4444;
    color: white;
}

/* Кнопка відкриття sidebar */
.open-sidebar-btn {
    display: none !important; /* replaced by sidebar-toggle-btn */
}

.open-sidebar-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.open-sidebar-btn svg {
    color: inherit;
}

/* Overlay для sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Scrollbar для sidebar */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: #64748b;
}

/* Порожня історія */
.chat-history-empty {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.chat-history-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.chat-history-empty p {
    font-size: 14px;
    margin: 0;
}

/* Old search-container replaced by layout above */

/* Header */
.search-header {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

/* Fixed top panel: nav + search panel stay visible when scrolling */
.sticky-top-panel {
    position: sticky;
    top: 0;
    z-index: 200;
    background: linear-gradient(180deg, rgba(15, 10, 46, 0.98) 0%, #0f0a2e 8%, #151040 100%);
    margin-bottom: 0;
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.navigation-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 8px 16px;
    border: 2px solid var(--primary-color);
    background: var(--surface-color);
    color: var(--primary-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-btn:hover {
    background: var(--primary-color);
    color: white;
}

.nav-btn.dashboard-btn {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border-color: #8b5cf6;
}

.nav-btn.dashboard-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border-color: #7c3aed;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.mode-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.clarification-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    color: var(--text-primary);
}

.checkbox-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.checkbox-text {
    font-weight: 500;
}

.checkbox-label:hover .checkbox-text {
    color: var(--primary-color);
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-label {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.model-select {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    min-width: 140px;
}

.model-select:hover {
    border-color: var(--primary-color);
}

.model-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.mode-btn {
    padding: 6px 14px;
    border: 2px solid var(--border-color);
    background: var(--surface-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
}

.mode-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================
   SEARCH PANEL (SP) - Нова пошукова панель
   ============================================ */

.sp-panel {
    background: linear-gradient(135deg, #1a1145 0%, #2d1b69 30%, #1e1555 70%, #151040 100%);
    border-radius: 16px;
    padding: 18px 22px 14px;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(30, 17, 69, 0.45), 0 2px 8px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: visible;
}

/* --- Row 1: Search bar --- */
.sp-search-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    position: relative;
    margin-bottom: 14px;
}

.sp-search-btn {
    background: linear-gradient(90deg, #885DF6 0%, #6566F1 100%);
    color: #fff;
    border: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    letter-spacing: 0.3px;
    transition: filter 0.2s, box-shadow 0.2s;
    z-index: 2;
    height: 48px;
    display: flex;
    align-items: center;
    align-self: flex-start;
}

.sp-search-btn:hover {
    filter: brightness(1.12);
    box-shadow: 0 4px 16px rgba(136, 93, 246, 0.5);
}

.sp-search-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.sp-search-btn.searching {
    pointer-events: none;
    position: relative;
    overflow: hidden;
}

.sp-search-btn.searching::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 200%; height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.25) 50%, transparent 100%);
    animation: sp-search-shimmer 1.2s ease-in-out infinite;
}

@keyframes sp-search-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.sp-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: stretch;
    min-height: 48px;
}

.sp-input {
    width: 100%;
    min-height: 48px;
    max-height: 200px;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 12px 42px 12px 16px;
    background: linear-gradient(90deg, #FFEEFE 0%, #CCE5FF 100%);
    color: #1e293b;
    border-radius: 0;
    resize: none;
    overflow-y: auto;
    line-height: 1.5;
    font-family: inherit;
    box-sizing: border-box;
}

.sp-input::placeholder {
    color: #6b7280;
    font-weight: 400;
}

.sp-input:focus {
    box-shadow: inset 0 0 0 2px rgba(136, 93, 246, 0.4);
}

.sp-clear-btn {
    position: absolute;
    right: 8px;
    top: 14px;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    z-index: 3;
}

.sp-clear-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.sp-history-btn {
    background: none;
    border: none;
    color: #a0a0b8;
    cursor: pointer;
    padding: 10px 12px;
    border-radius: 0 8px 8px 0;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    background: linear-gradient(90deg, #CCE5FF 0%, #b8d4f0 100%);
    align-self: flex-start;
}

.sp-history-btn:hover {
    color: #6566F1;
    background: linear-gradient(90deg, #c0dbff 0%, #a8c8ee 100%);
}

/* --- Autocomplete dropdown --- */
.sp-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 100;
    display: none;
    max-height: 260px;
    overflow-y: auto;
}

.sp-autocomplete-dropdown.visible {
    display: block;
}

.sp-autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #1e293b;
    transition: background 0.15s;
    border-bottom: 1px solid #f1f5f9;
}

.sp-autocomplete-item:hover,
.sp-autocomplete-item.active {
    background: #f0f0ff;
    color: #6566F1;
}

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

/* --- History dropdown --- */
.sp-history-dropdown {
    position: absolute;
    top: 56px;
    right: 0;
    width: 360px;
    max-height: 400px;
    background: #1e1b3a;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    z-index: 200;
    display: none;
    overflow: hidden;
}

.sp-history-dropdown.visible {
    display: block;
}

.sp-history-dropdown-header {
    padding: 14px 18px;
    font-weight: 600;
    font-size: 15px;
    color: #e2e8f0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sp-history-dropdown-list {
    max-height: 340px;
    overflow-y: auto;
    padding: 6px;
}

.sp-history-dropdown-item {
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #c4b5fd;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sp-history-dropdown-item:hover {
    background: rgba(136, 93, 246, 0.2);
    color: #fff;
}

.sp-history-dropdown-item .history-icon {
    flex-shrink: 0;
    color: #818cf8;
}

.sp-history-dropdown-item .history-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-history-dropdown-item .history-date {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}

.sp-history-dropdown-empty {
    padding: 24px;
    text-align: center;
    color: #64748b;
    font-size: 14px;
}

/* --- Row 2: Settings --- */
.sp-settings-row {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.sp-settings-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sp-settings-label {
    color: #a855f7;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

/* --- Dropdown button --- */
.sp-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.sp-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.sp-dropdown-btn:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(136, 93, 246, 0.5);
}

.sp-dropdown-arrow {
    color: #a855f7;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.sp-dropdown-btn.open .sp-dropdown-arrow {
    transform: rotate(180deg);
}

.sp-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 220px;
    background: #1e1b3a;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    z-index: 300;
    display: none;
    padding: 6px;
    animation: sp-dropdown-fade-in 0.15s ease;
}

.sp-dropdown-menu.visible {
    display: block;
}

@keyframes sp-dropdown-fade-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.sp-dropdown-item {
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #c4b5fd;
    transition: background 0.15s, color 0.15s;
    text-align: center;
}

.sp-dropdown-item:hover {
    background: rgba(136, 93, 246, 0.2);
    color: #fff;
}

.sp-dropdown-item.selected {
    background: rgba(136, 93, 246, 0.35);
    color: #fff;
}

.sp-dropdown-item-all {
    font-size: 13px;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: 4px;
    padding-top: 12px;
}

/* --- Checkbox custom --- */
.sp-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Primary visualization badge — same visual style as "додаткова візуалізація" button */
.sp-primary-viz-row {
    flex-wrap: wrap;
    gap: 8px;
}
.sp-primary-viz-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    pointer-events: none;
    white-space: nowrap;
}
.sp-primary-viz-badge[aria-hidden="true"] {
    display: none;
}
.sp-primary-viz-badge[aria-hidden="false"] {
    display: inline-flex;
}

.sp-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.sp-checkbox {
    display: none;
}

.sp-checkbox-custom {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    border: 2px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    position: relative;
}

.sp-checkbox:checked + .sp-checkbox-custom {
    background: #6566F1;
    border-color: #6566F1;
}

.sp-checkbox:checked + .sp-checkbox-custom::after {
    content: '✓';
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.sp-checkbox-text {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
}

.sp-checkbox-label:hover .sp-checkbox-custom {
    border-color: #a855f7;
}

/* --- Help icon (?) --- */
.sp-help-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    color: #a855f7;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.sp-help-icon:hover {
    background: #a855f7;
    color: #fff;
    border-color: #a855f7;
}

/* --- Tooltip --- */
.sp-tooltip {
    position: fixed;
    max-width: 380px;
    padding: 14px 18px;
    background: #1e1b3a;
    color: #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    z-index: 10000;
    display: none;
    pointer-events: none;
    border: 1px solid rgba(136, 93, 246, 0.3);
}

.sp-tooltip.visible {
    display: block;
}

/* --- Additional Visualization words menu --- */
.sp-viz-menu {
    min-width: 300px;
    padding: 12px;
}

.sp-viz-words-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.sp-viz-word-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-viz-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.2);
}

.sp-viz-color-picker {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    flex-shrink: 0;
}

.sp-viz-color-picker::-webkit-color-swatch-wrapper { padding: 2px; }
.sp-viz-color-picker::-webkit-color-swatch { border-radius: 3px; border: none; }
.sp-viz-color-picker::-moz-color-swatch { border-radius: 3px; border: none; }

.sp-viz-word-input {
    flex: 1;
    padding: 6px 10px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.sp-viz-word-input:focus {
    border-color: #a855f7;
}

.sp-viz-word-input::placeholder {
    color: #64748b;
}

.sp-viz-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    background: rgba(101,102,241,0.25);
    color: #a78bfa;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
}

.viz-active {
    box-shadow: 0 0 0 2px rgba(168,139,250,0.5) !important;
    border-color: #a78bfa !important;
}

.sp-viz-remove-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
}

.sp-viz-remove-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.sp-viz-add-btn {
    width: 100%;
    padding: 8px;
    background: rgba(136, 93, 246, 0.15);
    border: 1px dashed rgba(136, 93, 246, 0.4);
    border-radius: 6px;
    color: #a855f7;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.sp-viz-add-btn:hover {
    background: rgba(136, 93, 246, 0.3);
    border-color: #a855f7;
}

/* --- Row 3: Search location --- */
.sp-location-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
}

.sp-location-label {
    color: #a855f7;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    padding: 6px 14px;
    background: rgba(168, 85, 247, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.sp-location-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.sp-location-tab:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(136, 93, 246, 0.3);
}

.sp-location-tab.active {
    background: linear-gradient(135deg, rgba(136, 93, 246, 0.25), rgba(101, 102, 241, 0.25));
    border-color: rgba(136, 93, 246, 0.5);
}

.sp-location-tab-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.sp-location-checkbox {
    display: none;
}

.sp-location-checkbox-custom {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sp-location-checkbox:checked + .sp-location-checkbox-custom {
    background: #6566F1;
    border-color: #6566F1;
}

.sp-location-checkbox:checked + .sp-location-checkbox-custom::after {
    content: '✓';
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.sp-location-tab-text {
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.sp-location-tab-dropdown-wrapper {
    position: relative;
}

.sp-location-tab-dropdown-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    color: #a855f7;
}

.sp-location-dropdown {
    right: 0;
    left: auto;
    min-width: 200px;
}

/* 8. Пошук за реквізитами СР — dropdown form */
.sp-requisites-menu {
    padding: 12px;
    min-width: 260px;
    right: 0;
    left: auto;
}
.sp-requisites-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.sp-requisites-input {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 14px;
    box-sizing: border-box;
}
.sp-requisites-input:focus {
    outline: none;
    border-color: #a855f7;
}
.sp-requisites-input::placeholder {
    color: #64748b;
}
.sp-requisites-search-btn {
    width: 100%;
    padding: 8px 14px;
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.sp-requisites-search-btn:hover {
    background: #6d28d9;
}

/* --- Search status (updated) --- */
.search-status {
    margin-top: 4px;
    padding: 6px 16px;
    font-size: 14px;
    color: var(--text-secondary);
    min-height: 20px;
}

/* --- Navigation bar --- */
.sp-nav-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 10px 0;
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .sp-settings-row {
        flex-direction: column;
        gap: 10px;
    }
    .sp-settings-group {
        width: 100%;
    }
    .sp-location-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 600px) {
    .sp-panel {
        padding: 12px 10px 10px;
        border-radius: 10px;
    }
    .sp-search-btn {
        padding: 10px 18px;
        font-size: 14px;
    }
    .sp-input {
        font-size: 14px;
    }
    .sp-history-dropdown {
        width: 280px;
        right: -40px;
    }
}

/* Hide old elements that are now replaced */
.search-input-area { display: none !important; }
.search-header.sticky-header { display: none !important; }
.results-area { display: none !important; }

/* ============================================
   RESULTS PANEL (RP) - Панель результатів
   ============================================ */

.rp-panel {
    background: linear-gradient(135deg, #1a1145 0%, #252060 40%, #1e1555 100%);
    border-radius: 16px;
    padding: 0;
    padding-bottom: 70px; /* Space for fixed bottom bar */
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(30, 17, 69, 0.45);
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.rp-panel.fullscreen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 5000;
    border-radius: 0;
    margin: 0;
    overflow-y: auto;
}

/* --- Dashboard header --- */
.rp-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.rp-dashboard-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.rp-title-label {
    color: #38bdf8;
    font-size: 24px;
    font-weight: 700;
    font-style: italic;
}

.rp-title-count {
    color: #c4b5fd;
    font-size: 28px;
    font-weight: 800;
}

.rp-fullscreen-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #885DF6, #6566F1);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rp-fullscreen-btn:hover {
    filter: brightness(1.15);
    box-shadow: 0 4px 16px rgba(136, 93, 246, 0.4);
}

/* --- Refinement row --- */
.rp-refinement-row {
    padding: 8px 16px;
    background: rgba(136, 93, 246, 0.08);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.rp-refinement-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rp-refinement-label {
    color: #a855f7;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}

.rp-refinement-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 200px;
}

.rp-refinement-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(136,93,246,0.25), rgba(101,102,241,0.3));
    border: 1px solid rgba(136,93,246,0.4);
    border-radius: 20px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 500;
}

.rp-refinement-tag-input {
    background: transparent;
    border: none;
    outline: none;
    color: #e2e8f0;
    font-size: 13px;
    width: 160px;
    min-width: 80px;
}

.rp-refinement-tag-input::placeholder {
    color: #818cf8;
    opacity: 0.7;
}

.rp-refinement-tag-remove {
    background: none;
    border: none;
    color: #c084fc;
    cursor: pointer;
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.2s;
}

.rp-refinement-tag-remove:hover {
    color: #ef4444;
}

.rp-refinement-apply-btn {
    padding: 7px 20px;
    background: linear-gradient(135deg, #885DF6, #6566F1);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rp-refinement-apply-btn:hover:not(:disabled) {
    filter: brightness(1.15);
}

.rp-refinement-apply-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    filter: grayscale(0.6);
    background: rgba(100, 100, 120, 0.5) !important;
    color: #94a3b8 !important;
    border: 1px solid rgba(255,255,255,0.1);
}

.rp-refinement-add-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #885DF6, #6566F1);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.rp-refinement-add-btn:hover {
    filter: brightness(1.15);
    transform: scale(1.1);
}

/* --- Exclusion tags --- */
.rp-exclusion-section {
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid rgba(255,255,255,0.1);
}

.rp-exclusion-label {
    color: #f87171 !important;
}

.rp-exclusion-tags {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 150px;
}

.rp-exclusion-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(239,68,68,0.2), rgba(220,38,38,0.25));
    border: 1px solid rgba(239,68,68,0.4);
    border-radius: 20px;
    color: #fca5a5;
    font-size: 13px;
    font-weight: 500;
}

.rp-exclusion-tag-input {
    background: transparent;
    border: none;
    outline: none;
    color: #fca5a5;
    font-size: 13px;
    width: 130px;
    min-width: 80px;
}

.rp-exclusion-tag-input::placeholder {
    color: #f87171;
    opacity: 0.6;
}

.rp-exclusion-tag-remove {
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.2s;
}

.rp-exclusion-tag-remove:hover {
    color: #ef4444;
}

.rp-exclusion-add-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
}

/* Add (+) buttons inactive until user has entered value in a field */
.rp-refinement-add-btn.rp-add-btn-inactive,
.rp-exclusion-add-btn.rp-add-btn-inactive {
    opacity: 0.5;
    filter: grayscale(0.7);
    background: rgba(100, 100, 120, 0.4) !important;
    color: #94a3b8 !important;
    cursor: default;
    pointer-events: none;
}

/* --- Volume row --- */
.rp-volume-row {
    padding: 10px 24px;
    background: rgba(0,0,0,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.rp-send-to-ai-in-volume {
    margin-left: 8px;
    padding-left: 16px;
    border-left: 1px solid rgba(255,255,255,0.1);
}

.rp-volume-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.rp-volume-label {
    color: #c4b5fd;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 16px;
    background: rgba(136,93,246,0.12);
    border: 1px solid rgba(136,93,246,0.3);
    border-radius: 8px;
    white-space: nowrap;
}

.rp-volume-controls {
    display: flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(101,102,241,0.4);
}

.rp-volume-btn {
    padding: 6px 14px;
    background: rgba(101,102,241,0.25);
    color: #818cf8;
    border: none;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.rp-volume-btn:hover {
    background: rgba(101,102,241,0.45);
    color: #fff;
}

.rp-volume-minus { border-right: 1px solid rgba(101,102,241,0.3); }

.rp-volume-dropdown-wrapper {
    position: relative;
}

.rp-volume-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rp-volume-dropdown-btn:hover {
    background: rgba(255,255,255,0.1);
}

.rp-volume-menu {
    bottom: calc(100% + 4px);
    top: auto;
    min-width: 180px;
}

/* --- Results list with optional density strip --- */
.rp-results-list-wrapper {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

/* Бічна панель маркерів — на повну висоту до кінця контейнера */
.rp-results-list-wrapper .sp-marker-density-window {
    height: 100%;
    max-height: 100%;
}

.rp-results-list-wrapper .rp-results-list {
    flex: 1;
    overflow-y: auto;
}

/* --- 5.4 Marker density window (бічна панель маркерів) --- */
.sp-marker-density-window {
    width: 90px;
    min-width: 90px;
    flex-shrink: 0;
    align-self: stretch;
    min-height: 0;
    background: #2d2d2d;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sp-marker-density-titlebar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    padding: 4px 4px;
    background: linear-gradient(180deg, #4a4a4a 0%, #3a3a3a 100%);
    border-bottom: 1px solid #444;
    cursor: move;
    user-select: none;
}

.sp-marker-density-title {
    font-size: 9px;
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-marker-density-close {
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: transparent;
    color: #bbb;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    border-radius: 2px;
}

.sp-marker-density-close:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* Панель перемикання між маркерами (X із Y, попередній/наступний) — завжди видима при відкритому вікні */
.sp-marker-density-nav {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 6px;
    background: #2a2a2a;
    border-bottom: 1px solid #444;
    font-size: 10px;
    color: #ccc;
}

.sp-marker-nav-prev,
.sp-marker-nav-next {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #555;
    background: #3a3a3a;
    color: #ddd;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    border-radius: 3px;
}

.sp-marker-nav-prev:hover,
.sp-marker-nav-next:hover {
    background: #4a4a4a;
    color: #fff;
}

.sp-marker-nav-prev:disabled,
.sp-marker-nav-next:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sp-marker-nav-counter {
    min-width: 50px;
    text-align: center;
}

.sp-marker-density-body {
    flex: 1;
    min-height: 0;
    padding: 4px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
}

.sp-marker-density-strip {
    width: 100%;
    min-height: 80px;
    background: #1a1a1a;
    border: none;
    border-radius: 2px;
    position: relative;
    flex-shrink: 0;
}

.sp-marker-density-strip .density-line {
    position: absolute;
    left: 1px;
    right: 2px;
    height: 2px;
    min-height: 8px; /* збільшена область кліку */
    border-radius: 1px;
    pointer-events: auto;
    z-index: 3; /* вище thumb — маркери завжди клікабельні */
}

.sp-marker-density-strip .density-line:hover {
    filter: brightness(1.2);
}

/* Прямокутник видимої області на смузі — навігація скролом (перетягування) */
.sp-marker-density-viewport-thumb {
    position: absolute;
    left: 0;
    right: 0;
    min-height: 12px;
    background: rgba(100, 120, 255, 0.35);
    border: 1px solid rgba(100, 120, 255, 0.6);
    border-radius: 3px;
    pointer-events: auto;
    cursor: grab;
    z-index: 2;
    box-sizing: border-box;
}

.sp-marker-density-viewport-thumb:active {
    cursor: grabbing;
}

.sp-marker-density-hint {
    font-size: 8px;
    color: #888;
    margin-top: 4px;
    text-align: center;
    line-height: 1.2;
    flex-shrink: 0;
}

/* Що виділено в тексті: помітна підсвітка по центру екрану */
.rp-card-content mark.marker-scroll-highlight {
    animation: markerScrollPulse 2s ease-out;
}

@keyframes markerScrollPulse {
    0%, 100% { box-shadow: none; background-color: inherit; }
    15%, 85% { box-shadow: 0 0 0 4px rgba(255, 249, 66, 0.7); background-color: rgba(255, 249, 66, 0.25) !important; }
    50% { box-shadow: 0 0 0 6px rgba(255, 249, 66, 0.5); background-color: rgba(255, 249, 66, 0.35) !important; }
}

/* Де виділено: підсвітка відповідного сегмента на смузі маркерів */
.sp-marker-density-strip .density-line.density-line-active {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
    filter: brightness(1.4);
    z-index: 3;
    animation: densityLineActivePulse 2s ease-out;
}

@keyframes densityLineActivePulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }
    50% { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9); }
}

/* --- Results list --- */
.rp-results-list {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- PP Card --- */
.rp-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.25s;
}

.rp-card:hover {
    border-color: rgba(136,93,246,0.3);
    box-shadow: 0 4px 20px rgba(136,93,246,0.15);
}

/* PP Card header (name panel) */
.rp-card-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 18px;
    background: rgba(0,0,0,0.12);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Top row inside header: rank, badges, actions */
.rp-card-header-top {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rp-card-checkbox-wrap {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.rp-card-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #6566F1;
    cursor: pointer;
}

/* Relevance percentage badge */
.rp-card-relevance {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.4;
}

.rp-card-relevance.high {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.rp-card-relevance.medium {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.rp-card-relevance.low {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.rp-card-rank {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6566F1, #885DF6);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rp-card-date {
    padding: 3px 10px;
    background: rgba(16,185,129,0.15);
    border: 1px solid rgba(16,185,129,0.3);
    border-radius: 6px;
    color: #34d399;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.rp-card-case-number {
    padding: 3px 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.rp-card-title {
    width: 100%;
    color: #e2e8f0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    display: block;
    min-height: 1.5em;
}

.rp-card-title mark {
    background: #FFF942;
    color: #000;
    padding: 1px 4px;
    border-radius: 3px;
}

/* Court decision type — single badge with hierarchy coloring (п.7.2.5)
   Колегія (lowest):    ККС ВС / КАС ВС / КЦС ВС / КГС ВС — neutral
   Об'єднана палата:    ОП ККС ВС / ОП КАС ВС / etc.       — purple
   Велика палата (top):  ВП ВС                                — gold */
.rp-card-court-type {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

/* Колегія суддів — default (e.g. "ККС ВС", "КАС ВС") */
.rp-card-court-type.court-kolegiya {
    background: rgba(100, 116, 139, 0.2);
    border: 1px solid rgba(100, 116, 139, 0.4);
    color: #cbd5e1;
}

/* Об'єднана палата — purple (e.g. "ОП ККС ВС") */
.rp-card-court-type.court-op {
    background: rgba(139, 92, 246, 0.2);
    border: 1px solid rgba(139, 92, 246, 0.5);
    color: #a78bfa;
}

/* Велика палата — gold (e.g. "ВП ВС") */
.rp-card-court-type.court-vp {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #fbbf24;
}

.rp-card-link {
    color: #818cf8;
    font-size: 11px;
    text-decoration: none;
    text-align: center;
    padding: 0 10px;
    transition: color 0.2s;
    word-break: break-all;
}

.rp-card-link:hover {
    color: #a78bfa;
    text-decoration: underline;
}

/* Card actions (copy, bookmark, download, share) */
.rp-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.rp-card-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.rp-card-action-btn:hover {
    background: rgba(136,93,246,0.2);
    border-color: rgba(136,93,246,0.4);
    color: #c4b5fd;
}

.rp-card-action-btn.active {
    background: rgba(250,204,21,0.15);
    border-color: rgba(250,204,21,0.4);
    color: #fbbf24;
}

/* PP Content panel */
.rp-card-content {
    padding: 16px 18px;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.8;
    word-wrap: break-word;
    transition: max-height 0.3s ease;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* Expanded state for full PP content */
.rp-card-content.pp-expanded {
    border-left: 3px solid rgba(var(--accent-rgb, 88,86,214), 0.4);
    padding-left: 15px;
    max-height: none !important;
}

/* "Читати детальніше" / "Згорнути" button on PP cards */
.rp-card-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(var(--accent-rgb, 88,86,214), 0.08);
    border: 1px solid rgba(var(--accent-rgb, 88,86,214), 0.2);
    color: var(--accent, #7c6ef6);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 14px;
    margin: 0 18px 12px 18px;
    border-radius: 6px;
    transition: all 0.2s;
}
.rp-card-expand-btn:hover {
    background: rgba(var(--accent-rgb, 88,86,214), 0.18);
    border-color: rgba(var(--accent-rgb, 88,86,214), 0.4);
}
.rp-card-expand-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.rp-card-content mark,
.rp-card-content mark.highlight-word {
    background: #FFF942;
    color: #000;
    padding: 1px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* PP Categories panel */
.rp-card-categories {
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.rp-card-categories-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.rp-card-categories-title {
    color: #38bdf8;
    font-size: 16px;
    font-weight: 700;
    font-style: italic;
}

.rp-card-categories-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.rp-card-cat-btn {
    padding: 4px 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    color: #94a3b8;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rp-card-cat-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

.rp-card-cat-path {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.1);
    border-radius: 6px;
    margin-bottom: 4px;
    flex-wrap: wrap;
    cursor: pointer;
    transition: background 0.15s;
}

.rp-card-cat-path:hover {
    background: rgba(255,255,255,0.05);
}

.rp-card-cat-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.rp-card-cat-badge.root { background: rgba(100,116,139,0.3); color: #94a3b8; }
.rp-card-cat-badge.article { background: rgba(100,116,139,0.2); color: #94a3b8; }
.rp-card-cat-badge.middle { background: rgba(59,130,246,0.15); color: #60a5fa; }
.rp-card-cat-badge.last { 
    background: rgba(16,185,129,0.15); 
    color: #34d399; 
    border: 1px solid rgba(16,185,129,0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.rp-card-cat-badge.last:hover {
    background: rgba(16,185,129,0.35);
    color: #6ee7b7;
    border-color: rgba(16,185,129,0.6);
    transform: scale(1.12);
    box-shadow: 0 3px 12px rgba(16,185,129,0.35);
    z-index: 2;
}

.rp-card-cat-sep {
    color: #475569;
    font-size: 10px;
}

/* Show only first 3 category paths when collapsed (header is child 1, so paths start from child 2) */
.rp-card-categories.collapsed .rp-card-cat-path:nth-child(n+5) {
    display: none;
}

/* PP Criteria / footer panel */
.rp-card-footer {
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(0,0,0,0.08);
}

.rp-card-found-by {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 6px 12px;
    background: rgba(136,93,246,0.08);
    border: 1px solid rgba(136,93,246,0.2);
    border-radius: 8px;
    flex: 1;
}

.rp-card-found-by-label {
    color: #34d399;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.rp-card-found-word {
    padding: 2px 10px;
    background: rgba(101,102,241,0.2);
    border: 1px solid rgba(101,102,241,0.35);
    border-radius: 12px;
    color: #c4b5fd;
    font-size: 12px;
    font-weight: 500;
}

.rp-card-match-info {
    padding: 4px 10px;
    font-size: 11px;
    border-radius: 6px;
    background: rgba(0,0,0,0.15);
}

.rp-card-match-info .match-name { color: #34d399; }
.rp-card-match-info .match-content { color: #38bdf8; }
.rp-card-match-info .match-category { color: #fbbf24; }

.rp-card-entity-badge {
    padding: 6px 16px;
    background: linear-gradient(135deg, #06b6d4, #3b82f6);
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    margin-left: auto;
    white-space: nowrap;
}

/* --- Bottom bar (fixed to bottom of viewport) --- */
.rp-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 24px;
    background: rgba(10, 10, 30, 0.97);
    border-top: 1px solid rgba(255,255,255,0.12);
    flex-wrap: wrap;
    position: fixed;
    bottom: 0;
    left: 200px; /* sidebar width */
    right: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
    transition: left 0.3s ease;
}
/* When sidebar is collapsed, bar spans full width */
.main-layout.sidebar-collapsed .rp-bottom-bar,
body:has(.sidebar-panel.collapsed) .rp-bottom-bar {
    left: 0;
}

.rp-perpage-wrapper {
    position: relative;
}

.rp-perpage-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(136,93,246,0.3);
    border-radius: 8px;
    color: #c4b5fd;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rp-perpage-btn:hover {
    background: rgba(255,255,255,0.1);
}

.rp-perpage-menu {
    bottom: calc(100% + 4px);
    top: auto;
    min-width: 100px;
}

/* View tabs */
.rp-view-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(101,102,241,0.15);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(101,102,241,0.3);
    position: relative;
}

.rp-view-tab {
    padding: 8px 20px;
    color: #94a3b8;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rp-view-tab:hover {
    color: #e2e8f0;
    background: rgba(255,255,255,0.05);
}

.rp-view-tab.active {
    background: #2563eb;
    color: #fff;
}

.rp-view-tabs-label {
    padding: 0 12px;
    color: #64748b;
    font-size: 12px;
    white-space: nowrap;
}

/* Filters display */
.rp-filters-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    flex-wrap: wrap;
}

.rp-filters-label {
    color: #a855f7;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.rp-filters-tags {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.rp-filter-tag {
    padding: 4px 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(136,93,246,0.3);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.rp-filter-tag.empty {
    border-style: dashed;
    color: #475569;
}

.rp-filter-editable {
    cursor: pointer;
    transition: all 0.2s;
}

.rp-filter-editable:hover {
    background: rgba(136,93,246,0.15);
    border-color: rgba(136,93,246,0.5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(136,93,246,0.2);
}

@keyframes filterPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(136,93,246,0); }
    50% { box-shadow: 0 0 0 8px rgba(136,93,246,0.3); }
}

.filter-highlight-pulse {
    animation: filterPulse 0.75s ease 2;
}

/* --- Category Results Panel --- */
.rp-category-panel .rp-dashboard-header {
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
}

.rp-cat-dashboard {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.rp-cat-stat {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.rp-cat-stat-label {
    color: #38bdf8;
    font-size: 20px;
    font-weight: 700;
    font-style: italic;
}

.rp-cat-stat-value {
    color: #34d399;
    font-size: 24px;
    font-weight: 800;
}

.rp-cat-show-pp-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rp-cat-show-pp-btn:hover:not(:disabled) {
    filter: brightness(1.15);
}

.rp-cat-show-pp-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rp-cat-view-tabs {
    align-self: flex-end;
}

/* Список категорій: світлий фон, рядки з тонким темним роздільником (має бути — скріншот 1) */
.rp-category-results-list {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

/* Category card — білий рядок, тонка темна лінія знизу */
.rp-cat-card {
    background: #fff;
    border: none;
    border-bottom: 1px solid #cbd5e1;
    border-radius: 0;
    padding: 14px 18px;
    transition: background 0.2s;
    position: relative;
    cursor: pointer;
}

.rp-cat-card:last-child {
    border-bottom: none;
}

.rp-cat-card:hover {
    background: #f1f5f9;
}

.rp-cat-card.expanded {
    background: #f8fafc;
    border-bottom-color: #cbd5e1;
}

.rp-cat-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rp-cat-card-checkbox {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 2px solid #cbd5e1;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.rp-cat-card-checkbox.checked {
    background: #10b981;
    border-color: #10b981;
}

.rp-cat-card-checkbox.checked::after {
    content: '✓';
    color: #fff;
    font-size: 15px;
    font-weight: 700;
}

.rp-cat-card-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e0e7ff;
    color: #4f46e5;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rp-cat-card-name {
    flex: 1;
    color: #1e293b;
    font-size: 15px;
    font-weight: 600;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rp-cat-card-pp-count {
    padding: 4px 12px;
    background: #e0e7ff;
    border-radius: 6px;
    color: #4f46e5;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Світло-синій квадрат з V (шеврон) справа — як на скріншоті 1 */
.rp-cat-card-expand-toggle {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: #93c5fd;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s, background 0.2s;
    color: #fff;
}

.rp-cat-card-expand-toggle:hover {
    background: #60a5fa;
}

.rp-cat-card-expand-toggle.expanded {
    background: #3b82f6;
    color: #fff;
    transform: rotate(180deg);
}

.rp-cat-card-viewpp-btn {
    padding: 6px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #475569;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.rp-cat-card-viewpp-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #1e293b;
}

.rp-cat-card-entity {
    padding: 6px 16px;
    background: #e0e7ff;
    color: #4f46e5;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}

/* --- Expandable paths area --- */
.rp-cat-card-paths-area {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e2e8f0;
}

.rp-cat-card-path-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}
.rp-cat-card-path-row .rp-cat-card-path { flex: 1; margin-bottom: 0; }

.rp-cat-card-paths-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    background: rgba(101,102,241,0.15);
    color: #a78bfa;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}

.rp-cat-card-path {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 8px 12px;
    background: #f1f5f9;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    line-height: 1.6;
}

.rp-cat-card-path.expanded .rp-card-cat-badge.middle,
.rp-cat-card-path.expanded .rp-card-cat-sep {
    display: inline;
}

/* При розкритті шляху — повний текст вміщається (перенос, без обрізання) */
.rp-cat-card-path.expanded .rp-card-cat-badge {
    white-space: normal;
    word-break: break-word;
    max-width: 100%;
}
.rp-cat-card-path.expanded .rp-cat-path-dots {
    display: none !important;
}
.rp-cat-card-path.expanded [id^="path_"] {
    display: inline !important;
}

.rp-cat-path-dots {
    cursor: pointer;
    background: rgba(101,102,241,0.2) !important;
    border: 1px solid rgba(101,102,241,0.3) !important;
    color: #a78bfa !important;
    font-weight: 600 !important;
}

.rp-cat-path-dots:hover {
    background: rgba(101,102,241,0.35) !important;
}

.rp-cat-card-bottom-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
}

.rp-cat-card-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.rp-cat-card-action {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.rp-cat-card-action.primary {
    background: #2563eb;
    color: #fff;
}

.rp-cat-card-action.primary:hover {
    filter: brightness(1.15);
}

.rp-cat-card-action.secondary {
    background: rgba(255,255,255,0.06);
    color: #94a3b8;
    border-color: rgba(255,255,255,0.12);
}

.rp-cat-card-action.secondary:hover {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

/* Responsive */
@media (max-width: 768px) {
    .rp-dashboard-header { padding: 12px 16px; }
    .rp-title-label { font-size: 18px; }
    .rp-title-count { font-size: 22px; }
    .rp-refinement-row, .rp-volume-row { padding: 10px 16px; }
    .rp-card-header { padding: 10px 14px; }
    .rp-card-content { padding: 12px 14px; }
    .rp-bottom-bar { flex-direction: column; align-items: stretch; padding: 12px 16px; }
    .rp-cat-dashboard { flex-direction: column; gap: 10px; }
    .rp-cat-stat-label { font-size: 16px; }
}

/* Dialog Area */
/* Hide old dialog-area class */
.dialog-area { display: none !important; }

/* Приховано з усіх сторінок: панель «Історія діалогу в чаті» */
#dialogArea.dialog-panel {
    display: none !important;
}

/* Приховано з усіх сторінок: форма «Пошук категорій з GPT фільтрацією» */
#categorySearchArea.category-search-area {
    display: none !important;
}

/* ============================================
   DIALOG PANEL - Dark themed chat
   ============================================ */
.dialog-panel {
    background: linear-gradient(135deg, #1a1145 0%, #201860 50%, #1a1145 100%);
    border-radius: 16px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(30, 17, 69, 0.35);
    overflow: hidden;
    max-height: 600px;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.dialog-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.dialog-panel-title {
    color: #e2e8f0;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.dialog-panel-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.dialog-panel-close:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
}

.dialog-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dialog-panel-messages::-webkit-scrollbar {
    width: 6px;
}
.dialog-panel-messages::-webkit-scrollbar-track {
    background: transparent;
}
.dialog-panel-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

/* Chat message bubbles */
.message {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s ease-in;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 14px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
}

.message-content {
    flex: 1;
    max-width: 85%;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
    border: 1px solid rgba(255,255,255,0.06);
    font-size: 14px;
    line-height: 1.6;
}

.message.user .message-bubble {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.2);
}

.message.assistant .message-bubble {
    background: rgba(6,182,212,0.08);
    border-color: rgba(6,182,212,0.15);
}

.message.user .message-bubble {
    background: var(--primary-color);
    color: white;
}

.message-time {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Results Area */
.results-area {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.results-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.results-meta {
    display: flex;
    gap: 12px;
    align-items: center;
}

.results-count {
    color: var(--text-secondary);
    font-size: 14px;
}

.relevance-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.relevance-badge.high {
    background: #d1fae5;
    color: #065f46;
}

.relevance-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.relevance-badge.low {
    background: #fee2e2;
    color: #991b1b;
}

/* Explanation Box - оптимізована висота */
.explanation-box {
    background: #f0f9ff;
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.explanation-header h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.explanation-content {
    color: var(--text-primary);
    line-height: 1.8;
}

/* Key Matches - оптимізована висота */
.key-matches-box {
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--radius);
}

.key-matches-box h4 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-weight: 600;
}

.key-matches-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.key-match-tag {
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: default;
}

.key-match-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Первинні (найважливіші) ключові збіги */
.key-match-tag.primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

/* Вторинні ключові збіги */
.key-match-tag.secondary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    opacity: 0.9;
}

/* "Ще X" бейдж */
.key-match-tag.more {
    background: #e5e7eb;
    color: #4b5563;
    font-weight: 600;
}

/* Results List */
.results-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Анімація появи карток */
@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-item {
    animation: cardSlideIn 0.4s ease forwards;
}

.result-item:nth-child(1) { animation-delay: 0.05s; }
.result-item:nth-child(2) { animation-delay: 0.1s; }
.result-item:nth-child(3) { animation-delay: 0.15s; }
.result-item:nth-child(4) { animation-delay: 0.2s; }
.result-item:nth-child(5) { animation-delay: 0.25s; }
.result-item:nth-child(6) { animation-delay: 0.3s; }
.result-item:nth-child(7) { animation-delay: 0.35s; }
.result-item:nth-child(8) { animation-delay: 0.4s; }
.result-item:nth-child(9) { animation-delay: 0.45s; }
.result-item:nth-child(10) { animation-delay: 0.5s; }

/* ============================================
   ПОКРАЩЕНІ КАРТКИ РЕЗУЛЬТАТІВ ПОШУКУ
   ============================================ */

.result-item {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 0;
    border: 1px solid var(--border-color);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary-color), #818cf8);
    opacity: 0;
    transition: opacity 0.25s;
}

.result-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 12px 35px -8px rgba(37, 99, 235, 0.2), 
                0 6px 15px -6px rgba(37, 99, 235, 0.15);
    transform: translateY(-3px);
}

.result-item:hover::before {
    opacity: 1;
}

.result-item:hover .result-rank {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.result-item:hover .result-title {
    color: var(--primary-color);
}

.result-rank {
    transition: all 0.25s ease;
}

/* Results Controls (Pagination) */
.results-controls {
    margin-top: 24px;
    padding: 16px;
    background: var(--surface-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-top: 2px solid var(--border-color);
}

.pagination-info {
    text-align: center;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.results-actions .btn {
    min-width: 180px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius);
    transition: all 0.2s;
    cursor: pointer;
    border: 2px solid transparent;
}

.results-actions .btn-primary {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.results-actions .btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.results-actions .btn-secondary {
    background: var(--surface-color);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.results-actions .btn-secondary:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.results-actions .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* --- HEADER КАРТКИ --- */
.result-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.result-rank {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    font-weight: 700;
    font-size: 14px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.result-title-wrapper {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.result-title mark,
.result-title .highlight-match {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    color: #78350f;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(250, 204, 21, 0.3);
}

.result-meta-right {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Індикатор релевантності */
.relevance-indicator {
    position: relative;
    width: 60px;
    height: 28px;
    background: #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.relevance-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    transition: width 0.5s ease;
}

.relevance-indicator.high .relevance-bar {
    background: linear-gradient(90deg, #10b981, #34d399);
    animation: relevancePulseHigh 1.5s ease-in-out infinite;
}

.relevance-indicator.medium .relevance-bar {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.relevance-indicator.low .relevance-bar {
    background: linear-gradient(90deg, #94a3b8, #cbd5e1);
}

@keyframes relevancePulseHigh {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.relevance-text {
    position: relative;
    z-index: 1;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
}

.result-date {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.result-type-badge {
    padding: 4px 10px;
    background: var(--primary-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- КАТЕГОРІЇ (BREADCRUMB) --- */
.result-categories-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
    border-bottom: 1px solid #fef08a;
    font-size: 13px;
    max-height: 200px;
    overflow-y: auto;
}

.result-categories-row::-webkit-scrollbar {
    width: 6px;
}

.result-categories-row::-webkit-scrollbar-track {
    background: #fef3c7;
    border-radius: 3px;
}

.result-categories-row::-webkit-scrollbar-thumb {
    background: #fcd34d;
    border-radius: 3px;
}

.result-categories-row::-webkit-scrollbar-thumb:hover {
    background: #f59e0b;
}

.category-path-item {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 8px;
    border: 1px solid #fde68a;
    flex-shrink: 1;
    min-width: 0;
    width: 100%;
    margin-bottom: 6px;
}

.category-separator {
    color: #d97706;
    font-weight: 600;
    margin: 0 2px;
}

.category-breadcrumb {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
    /* Дозволяємо перенос тексту */
    word-break: break-word;
    line-height: 1.3;
}

.category-breadcrumb:hover {
    transform: scale(1.01);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.category-breadcrumb.root {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-weight: 700;
    border: 1px solid #fcd34d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.category-breadcrumb.last {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    font-weight: 600;
    border: 1px solid #86efac;
}

/* Стаття в шляху категорій */
.category-breadcrumb.article {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
    color: #9d174d;
    font-weight: 600;
    border: 1px solid #f9a8d4;
}

/* Передкінцева категорія (синя) */
.category-breadcrumb.pre-last {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    font-weight: 600;
    border: 1px solid #93c5fd;
}

.category-breadcrumb-separator {
    color: #d97706;
    font-weight: 700;
    font-size: 18px;
    margin: 0 2px;
}

/* Роздільник у шляху категорій */
.category-separator {
    color: #9ca3af;
    font-weight: 400;
    font-size: 12px;
    margin: 0 4px;
}

.category-path-item:last-child {
    margin-bottom: 0;
}

/* Бейдж "ще X категорій" */
.category-more-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: #e5e7eb;
    color: #4b5563;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    margin-left: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.category-more-badge:hover {
    background: var(--primary-color);
    color: white;
}

.result-item:hover .category-breadcrumb {
    transform: translateY(-1px);
}

/* Підсвічування категорій де є збіг з пошуковим запитом */
.category-breadcrumb.has-match {
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.6), 0 2px 8px rgba(250, 204, 21, 0.4);
    animation: categoryMatchPulse 2s ease-in-out infinite;
}

.category-breadcrumb.root.has-match {
    background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
    border-color: #facc15;
}

.category-breadcrumb.last.has-match {
    background: linear-gradient(135deg, #bbf7d0 0%, #86efac 100%);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.5), 0 2px 8px rgba(34, 197, 94, 0.3);
}

.category-breadcrumb.pre-last.has-match {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5), 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Підсвічування mark тегів всередині категорій */
.category-breadcrumb mark,
.category-breadcrumb .highlight-match {
    background: rgba(250, 204, 21, 0.5);
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 700;
}

@keyframes categoryMatchPulse {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.6), 0 2px 8px rgba(250, 204, 21, 0.4);
    }
    50% {
        box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.8), 0 4px 12px rgba(250, 204, 21, 0.6);
    }
}

/* --- КЛІКАБЕЛЬНІ КАТЕГОРІЇ --- */
.category-breadcrumb.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.category-breadcrumb.clickable:hover {
    background: var(--success-color) !important;
    color: white !important;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    border-color: var(--success-color) !important;
}

.category-path-item.clickable-path {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    padding: 4px 6px;
    margin: -4px -6px;
}

.category-path-item.clickable-path:hover {
    background: rgba(37, 99, 235, 0.08);
}

.category-path-item.clickable-path:hover .category-separator {
    color: var(--primary-color);
}

/* Іконка стрілки при наведенні на кінцеву категорію */
.category-breadcrumb.last.clickable::after {
    content: ' →';
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 12px;
}

.category-breadcrumb.last.clickable:hover::after {
    opacity: 1;
}

/* --- ОПИС (ПОВНИЙ ТЕКСТ) --- */
.result-description-wrapper {
    padding: 16px 20px;
}

.result-description {
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.8;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

/* Повний текст - розгорнутий стан */
.result-description.expandable.expanded {
    max-height: none;
}

/* Повний текст - згорнутий стан */
.result-description.expandable.collapsed {
    max-height: 150px;
    overflow: hidden;
    position: relative;
}

.result-description.expandable.collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--surface-color));
    pointer-events: none;
}

/* Кнопка згортання/розгортання */
.description-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    margin-top: 12px;
    background: var(--bg-color);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius);
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.description-toggle-btn:hover {
    background: var(--primary-color);
    color: white;
    border-style: solid;
    border-color: var(--primary-color);
}

.description-toggle-btn .toggle-icon {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.result-description .highlight-word,
.result-description mark {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    color: #78350f;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(250, 204, 21, 0.4);
    animation: highlightGlow 2s ease-in-out infinite;
    display: inline;
}

@keyframes highlightGlow {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(250, 204, 21, 0.4);
    }
    50% {
        box-shadow: 0 2px 12px rgba(250, 204, 21, 0.7);
    }
}

.result-description .no-description {
    color: var(--text-secondary);
    font-style: italic;
}

/* --- FOOTER КАРТКИ --- */
.result-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
}

/* Контейнер для інформації про критерії пошуку */
.match-info-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

/* Слова, за якими знайдено */
.matched-words {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.match-label {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.matched-word {
    display: inline-block;
    padding: 3px 10px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-size: 12px;
    font-weight: 600;
    border-radius: 12px;
    border: 1px solid #fcd34d;
}

.matched-word.semantic {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4338ca;
    border-color: #a5b4fc;
    font-style: italic;
}

/* Де знайдено збіг */
.match-location-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: #dbeafe;
    color: #1e40af;
    font-size: 11px;
    font-weight: 500;
    border-radius: 16px;
    width: fit-content;
}

.match-location-badge svg {
    opacity: 0.7;
}

.result-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}

.result-tag {
    padding: 4px 10px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.result-tag.more {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.result-score {
    display: none; /* Приховуємо старий score */
}

/* Stage indicator */
.stage-indicator {
    font-size: 12px;
    color: var(--primary-color);
    padding: 4px 8px;
    background: #e0f2fe;
    border-radius: 4px;
    font-weight: 600;
    margin-left: 8px;
}

/* Highlight - покращена візуалізація (не тільки 100% співпадіння) */
.highlight {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    color: #92400e;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: highlightPulse 0.3s ease-in;
}

/* Підсвітка часткових збігів */
.highlight-partial {
    background: linear-gradient(120deg, #fef3c7 0%, #fde68a 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    color: #78350f;
}

/* Elasticsearch highlighting (як в Algolia) */
mark {
    background: #fef08a;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
    color: inherit;
}

/* Покращене підсвічування збігів */
mark.highlight-match {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    color: #92400e;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    animation: highlightPulse 0.3s ease-in;
}

mark.highlight-match.category {
    background: linear-gradient(120deg, #bfdbfe 0%, #93c5fd 100%);
    color: #1e40af;
}

/* Інформація про поля де знайшли збіги */
.matched-fields-info {
    margin-top: 8px;
    margin-bottom: 8px;
}

.matched-fields-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #bae6fd;
}

/* Підсвічені категорії */
.category-info {
    margin-top: 12px;
    padding: 10px 12px;
    background: #f1f5f9;
    border-left: 3px solid var(--primary-color);
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
}

.category-info strong {
    color: var(--text-primary);
    font-weight: 600;
    margin-right: 8px;
}

.root-category {
    color: var(--primary-color);
    font-weight: 600;
    padding: 2px 6px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 4px;
}

.last-category {
    color: var(--success-color);
    font-weight: 600;
    padding: 2px 6px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 4px;
}

.category-highlight {
    margin-top: 12px;
    padding: 12px;
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    border-radius: 4px;
    font-size: 14px;
    color: #1e40af;
}

.category-highlight strong {
    color: #1e3a8a;
}

/* Анімація підсвічування */
@keyframes highlightPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Clarification Box */
.clarification-box {
    background: #fff7ed;
    border: 2px solid var(--warning-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.clarification-header h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.clarification-header p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.clarification-questions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.clarification-question {
    padding: 16px;
    background: var(--surface-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.clarification-question label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.clarification-question input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
}

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

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Loading overlay - solid background, no blur, no transparency to avoid compositing blur */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f0a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: auto;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    filter: none !important;
    isolation: isolate;
}

.loading-overlay.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    left: -99999px !important;
    top: -99999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0,0,0,0) !important;
    clip-path: inset(50%) !important;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 16px;
    color: white;
    font-size: 16px;
}

/* Debug Info */
.debug-info {
    margin-top: 24px;
    padding: 16px;
    background: #f1f5f9;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.debug-info h4 {
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.debug-info pre {
    font-size: 12px;
    color: var(--text-primary);
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Scrollbar */
.dialog-area::-webkit-scrollbar,
.debug-info pre::-webkit-scrollbar {
    width: 8px;
}

.dialog-area::-webkit-scrollbar-track,
.debug-info pre::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.dialog-area::-webkit-scrollbar-thumb,
.debug-info pre::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.dialog-area::-webkit-scrollbar-thumb:hover,
.debug-info pre::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Categories Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background: linear-gradient(135deg, #1a1145 0%, #201860 50%, #1a1145 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    max-width: min(1200px, 96vw);
    width: 100%;
    min-height: 200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #e2e8f0;
}

/* Огляд категорій: ширина динамічно = 94% екрана, без фіксованого піксельного обмеження */
.modal-content-categories {
    width: 94vw;
    max-width: 94vw;
    min-width: 320px;
    height: 88vh;
    max-height: 88vh;
    min-height: 70vh;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: rgba(0,0,0,0.1);
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #38bdf8;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    font-size: 32px;
    color: #ef4444;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    overflow-x: auto;
    flex: 1;
    min-height: 0;
}

.categories-search {
    margin-bottom: 20px;
}

.categories-search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.categories-search-input:focus {
    border-color: var(--primary-color);
}

.categories-tree {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    min-width: 0;
}

.category-node {
    margin-bottom: 4px;
}

/* Підсвічування збігу при фільтрі в дереві категорій */
.category-node.has-match .category-header {
    background: linear-gradient(90deg, rgba(254, 243, 199, 0.5) 0%, var(--bg-color) 100%);
    border-left: 3px solid #f59e0b;
}
.category-node.has-match .category-name mark.highlight-match {
    background: linear-gradient(120deg, #fef08a 0%, #fde047 100%);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
    color: #92400e;
}

.category-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
}

.category-header:hover {
    background: #e2e8f0;
    transform: translateX(4px);
}

/* Візуалізація рядків, зафіксованих чекбоксом (обрані категорії) */
.category-node.category-row-selected .category-header {
    background: rgba(99, 102, 241, 0.15);
    border-left: 3px solid var(--primary-color, #6366f1);
}
.category-node.category-row-selected .category-header:hover {
    background: rgba(99, 102, 241, 0.25);
}

.category-expand-btn {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.category-expand-btn.expanded {
    transform: rotate(90deg);
}

.category-name-wrap {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    display: inline-flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 4px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.category-sub-title {
    font-weight: 600;
    color: #dc2626;
    font-size: 14px;
}

.category-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 15px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.category-pp-count {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.category-row-checkbox {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.category-type {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--border-color);
    padding: 4px 8px;
    border-radius: 12px;
}

.category-children {
    margin-top: 4px;
    margin-left: 16px;
    background: transparent !important;
}

/* Усунути білу смугу: дочірні рядки той самий фон що й батьківські */
.category-node .category-node .category-header {
    background: var(--bg-color) !important;
}

.no-categories {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 16px;
}

/* ============================================
   МОДАЛЬНЕ ВІКНО ПРАВОВИХ ПОЗИЦІЙ КАТЕГОРІЇ
   ============================================ */

.modal-large {
    max-width: 1100px;
}

.modal-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-path-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.category-articles-count {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.category-articles-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.category-article-item {
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    cursor: pointer;
}

.category-article-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
    transform: translateX(4px);
}

.category-article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.category-article-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    flex: 1;
}

.category-article-date {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.category-article-description {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.category-article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.category-article-tag {
    font-size: 11px;
    padding: 3px 8px;
    background: #e0e7ff;
    color: #4338ca;
    border-radius: 10px;
}

.category-articles-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    padding: 8px 16px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

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

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

.pagination-info-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.category-articles-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.category-articles-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.category-articles-empty p {
    font-size: 16px;
}

.category-articles-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.category-articles-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

/* Кнопка "Переглянути ПП" у категорії */
.category-view-articles-btn {
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: auto;
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-view-articles-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

.category-add-to-chat-btn {
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: 6px;
    padding: 6px 12px;
    background: rgba(101, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(101, 102, 241, 0.4);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-add-to-chat-btn:hover {
    background: rgba(101, 102, 241, 0.3);
    border-color: var(--primary-color);
    color: #e2e8f0;
}

/* Кнопка "Додати в AI чат" у шапці модалки ПП категорії */
.modal-header-btn.modal-add-to-chat-btn {
    padding: 6px 14px;
    background: rgba(101, 102, 241, 0.25);
    color: #a5b4fc;
    border: 1px solid rgba(101, 102, 241, 0.5);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-right: 10px;
    transition: all 0.2s;
}

.modal-header-btn.modal-add-to-chat-btn:hover {
    background: rgba(101, 102, 241, 0.4);
    border-color: var(--primary-color);
    color: #e2e8f0;
}

/* Scrollbar for modal */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-color);
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .search-container {
        padding: 12px;
    }

    .header-content {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .mode-switcher {
        width: 100%;
    }

    .clarification-checkbox {
        margin-top: 8px;
    }

    .clarification-checkbox {
        margin-top: 8px;
    }

    .model-selector {
        width: 100%;
    }

    .model-select {
        width: 100%;
    }

    .navigation-buttons {
        width: 100%;
        flex-direction: column;
    }

    .nav-btn {
        width: 100%;
    }

    .search-box-wrapper {
        flex-direction: column;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Адаптивні картки результатів */
    .result-header {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 16px;
    }

    .result-rank {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .result-title {
        font-size: 14px;
    }

    .result-meta-right {
        width: 100%;
        order: 3;
        justify-content: space-between;
        padding-top: 8px;
        border-top: 1px dashed var(--border-color);
    }

    .relevance-indicator {
        width: 50px;
        height: 24px;
    }

    .result-categories-row {
        padding: 10px 16px;
        gap: 6px;
        font-size: 12px;
    }

    .category-path-item {
        padding: 4px 8px;
    }

    .category-breadcrumb {
        padding: 3px 6px;
        font-size: 11px;
    }

    .result-description-wrapper {
        padding: 12px 16px;
    }

    .result-description {
        font-size: 13px;
    }

    .result-footer {
        flex-wrap: wrap;
        padding: 10px 16px;
    }

    .message-content {
        max-width: 85%;
    }

    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: 95vh;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .category-search-area {
        padding: 12px;
    }

    .category-search-input-wrapper {
        margin: 12px 0;
    }
}

/* ============================================
   CATEGORY SEARCH AREA
   ============================================ */

.category-search-area {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.category-search-header {
    text-align: center;
    margin-bottom: 40px;
}

.category-search-header h2 {
    font-size: 32px;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 12px;
}

.category-search-description {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.category-search-input-wrapper {
    margin: 30px 0;
}

.category-search-box {
    display: flex;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-lg);
    padding: 8px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.category-search-box:focus-within {
    border-color: rgba(136,93,246,0.5);
    box-shadow: 0 0 0 3px rgba(136, 93, 246, 0.15);
}

.category-search-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    padding: 12px 16px;
    background: transparent;
    color: #e2e8f0;
}

.category-search-input::placeholder {
    color: #64748b;
}

.category-search-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 12px 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: 500;
}

.category-search-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.category-search-btn:active {
    transform: translateY(0);
}

.category-search-status {
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    min-height: 20px;
}

.category-search-status.success {
    color: var(--success-color);
}

.category-search-status.error {
    color: var(--error-color);
}

.category-search-status.info {
    color: var(--primary-color);
}

/* Category Search Results */
.category-search-results {
    margin-top: 40px;
    animation: fadeIn 0.3s ease;
}

.category-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.category-results-header h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.category-results-meta {
    display: flex;
    gap: 16px;
    align-items: center;
}

.category-results-count {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.category-search-time {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 4px 8px;
    border-radius: 4px;
}

.category-results-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.category-result-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s ease;
}

.category-result-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

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

.category-result-rank {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.category-result-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.category-result-type-badge {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.category-result-path {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary-color);
}

.category-path-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.category-result-path .path-part {
    padding: 2px 6px;
    border-radius: 4px;
    background: white;
    transition: all 0.2s ease;
}

.category-result-path .path-root {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    font-weight: 700;
}

.category-result-path .path-middle {
    background: #e5e7eb;
    color: #4b5563;
}

.category-result-path .path-last {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    color: #166534;
    font-weight: 600;
}

.category-result-path .path-separator {
    color: #9ca3af;
    font-weight: 400;
    margin: 0 2px;
}

.category-result-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.category-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.category-action-btn.view-articles {
    background: var(--primary-color);
    color: white;
}

.category-action-btn.view-articles:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.category-action-btn.copy-path {
    background: white;
    color: var(--text-primary);
    border-color: var(--border-color);
}

.category-action-btn.copy-path:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Merged category badge and paths */
.category-merged-badge {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #4338ca;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    white-space: nowrap;
}

.category-result-paths-container {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary, #f9fafb);
    margin-bottom: 8px;
}

.merged-category-path-item {
    padding: 6px 0;
}

.merged-category-path-item:not(:first-child) {
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.merged-category-path-item .category-action-btn {
    padding: 4px 8px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Modal for category articles */
.category-articles-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.category-articles-modal .modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.category-articles-modal .modal-content {
    position: relative;
    background: linear-gradient(135deg, #1a1145 0%, #201860 50%, #1a1145 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
    color: #e2e8f0;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.category-articles-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.category-articles-modal .modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.category-articles-modal .modal-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-color);
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.category-articles-modal .modal-close-btn:hover {
    background: var(--error-color);
    color: white;
}

.category-articles-modal .modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.category-articles-modal .modal-pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--bg-color);
    border-radius: var(--radius);
}

.category-articles-modal .modal-articles-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-articles-modal .modal-article-item {
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--radius);
    border-left: 3px solid var(--primary-color);
}

.category-articles-modal .modal-article-item.rp-card-style {
    cursor: default;
    border-left: 3px solid var(--primary-color);
}

.category-articles-modal .modal-article-item.rp-card-style:hover {
    transform: none;
    border-left-color: var(--success-color);
    background: rgba(37, 99, 235, 0.05);
}

.category-articles-modal .modal-article-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.category-articles-modal .modal-article-header .rp-card-rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #885DF6, #6566F1);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.category-articles-modal .modal-article-header .rp-card-date {
    color: #94a3b8;
    font-size: 13px;
}

.category-articles-modal .modal-article-header .rp-card-case-number {
    background: rgba(255,255,255,0.08);
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
}

.category-articles-modal .modal-article-header .rp-card-court-type {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
/* In modal: inherit hierarchy colors from main court-type classes */
.category-articles-modal .modal-article-header .rp-card-court-type.court-kolegiya {
    background: rgba(100, 116, 139, 0.25);
    border: 1px solid rgba(100, 116, 139, 0.4);
    color: #cbd5e1;
}
.category-articles-modal .modal-article-header .rp-card-court-type.court-op {
    background: rgba(139, 92, 246, 0.25);
    border: 1px solid rgba(139, 92, 246, 0.5);
    color: #a78bfa;
}
.category-articles-modal .modal-article-header .rp-card-court-type.court-vp {
    background: rgba(245, 158, 11, 0.25);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #fbbf24;
}

.category-articles-modal .modal-article-header .rp-card-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.category-articles-modal .modal-article-header .rp-card-action-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    text-decoration: none;
}

.category-articles-modal .modal-article-header .rp-card-action-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #e2e8f0;
}

.category-articles-modal .modal-article-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    user-select: text;
    cursor: text;
}

.category-articles-modal .modal-article-description {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 6px;
    user-select: text;
    cursor: text;
    max-height: 80px;
    overflow: hidden;
    position: relative;
    transition: max-height 0.35s ease;
}

/* Expanded state: no height limit */
.category-articles-modal .modal-article-description.expanded {
    max-height: none;
    overflow: visible;
    padding-bottom: 8px;
    border-left: 3px solid rgba(var(--accent-rgb, 88,86,214), 0.4);
    padding-left: 12px;
    margin-top: 4px;
}

/* Fade overlay on collapsed description */
.category-articles-modal .modal-article-description:not(.expanded)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(transparent, var(--bg-card, rgba(30, 30, 60, 1)));
    pointer-events: none;
}

.modal-article-expand-btn {
    background: rgba(var(--accent-rgb, 88,86,214), 0.08);
    border: 1px solid rgba(var(--accent-rgb, 88,86,214), 0.2);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 5px 14px;
    margin-bottom: 6px;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.modal-article-expand-btn:hover {
    background: rgba(var(--accent-rgb, 88,86,214), 0.18);
    border-color: rgba(var(--accent-rgb, 88,86,214), 0.4);
}
.modal-article-expand-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Loading spinner for expand button */
.modal-expand-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(var(--accent-rgb, 88,86,214), 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: expandSpin 0.6s linear infinite;
}
@keyframes expandSpin {
    to { transform: rotate(360deg); }
}

.category-articles-modal .modal-article-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}

.category-articles-modal .modal-article-type {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

/* Клікабельний елемент статті */
.category-articles-modal .modal-article-item {
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-articles-modal .modal-article-item:hover {
    transform: translateX(4px);
    border-left-color: var(--success-color);
    background: rgba(37, 99, 235, 0.05);
}

/* Субтайтл модалу */
.category-articles-modal .modal-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
    max-width: 500px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Покращена інфо-панель */
.category-articles-modal .modal-pagination-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-articles-modal .modal-total-count {
    font-weight: 500;
}

.category-articles-modal .modal-total-count strong {
    color: var(--primary-color);
    font-size: 16px;
}

/* Пагінація модалу */
.category-articles-modal .modal-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 20px 0 0 0;
    margin-top: 16px;
    border-top: 1px solid var(--border-color);
}

.category-articles-modal .modal-page-btn {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.category-articles-modal .modal-page-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.category-articles-modal .modal-page-btn:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.category-articles-modal .modal-page-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Більший модал */
.category-articles-modal .modal-content.modal-large {
    max-width: 900px;
    max-height: 85vh;
}

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

/* ============================================
   КНОПКА ТА ПАНЕЛЬ УТОЧНЕННЯ (праворуч)
   ============================================ */

/* Кнопка уточнення (праворуч, як sidebar ліворуч) */
.open-clarification-btn {
    position: fixed;
    right: 16px;
    top: 16px;
    z-index: 999;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
    transition: all 0.2s;
    color: white;
}

.open-clarification-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.open-clarification-btn svg {
    color: inherit;
}

/* Панель уточнення (зліва, як sidebar) */
.clarification-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 350px;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    color: #e2e8f0;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 30px rgba(99, 102, 241, 0.3);
}

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

.clarification-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.clarification-panel-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
}

.clarification-panel-header h3::before {
    content: '?';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
}

.clarification-panel-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 28px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    line-height: 1;
}

.clarification-panel-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

.clarification-panel-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.clarification-panel-desc {
    font-size: 14px;
    color: #a5b4fc;
    line-height: 1.6;
    margin: 0;
}

.clarification-input-wrapper {
    position: relative;
}

.clarification-input {
    width: 100%;
    padding: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #f1f5f9;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    min-height: 120px;
    transition: all 0.2s;
}

.clarification-input::placeholder {
    color: #818cf8;
    opacity: 0.7;
}

.clarification-input:focus {
    outline: none;
    border-color: #8b5cf6;
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

.clarification-panel-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    font-size: 12px;
    color: #c4b5fd;
    line-height: 1.5;
}

.clarification-panel-hint svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: #a78bfa;
}

.clarification-panel-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.clarification-panel-actions .btn-primary {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.2s;
}

.clarification-panel-actions .btn-primary:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.clarification-panel-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 10px;
    transition: all 0.2s;
}

.clarification-panel-actions .btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Overlay для панелі уточнення */
.clarification-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.clarification-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Режими панелі уточнення */
.clarification-mode {
    display: block;
}

/* Список питань уточнення */
.clarification-questions-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.clarification-question-item {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 14px 16px;
    border-left: 3px solid #8b5cf6;
}

.clarification-question-label {
    font-size: 13px;
    font-weight: 500;
    color: #c4b5fd;
    margin-bottom: 10px;
    line-height: 1.5;
}

.clarification-question-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #f1f5f9;
    font-size: 14px;
    transition: all 0.2s;
}

.clarification-question-input::placeholder {
    color: #818cf8;
    opacity: 0.6;
}

.clarification-question-input:focus {
    outline: none;
    border-color: #8b5cf6;
    background: rgba(255, 255, 255, 0.15);
}

/* Select для так/ні питань */
.clarification-question-select {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #f1f5f9;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.clarification-question-select option {
    background: #1e1b4b;
    color: #f1f5f9;
}

.clarification-question-select:focus {
    outline: none;
    border-color: #8b5cf6;
}

/* Індикатор нових питань */
.clarification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    color: white;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.open-clarification-btn {
    position: relative;
}

/* Responsive для панелі уточнення */
@media (max-width: 480px) {
    .clarification-panel {
        width: 100%;
    }
    
    .open-clarification-btn {
        right: 12px;
        top: 12px;
        padding: 8px 10px;
    }
}

/* ============================================
   ЗГОРТАННЯ/РОЗГОРТАННЯ ШЛЯХІВ КАТЕГОРІЙ
   ============================================ */

/* Кнопка-тогл для згорнутого шляху */
.path-collapsed-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    margin: 0 2px;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border: 1px solid #a5b4fc;
    border-radius: 14px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #4f46e5;
    transition: all 0.25s ease;
    vertical-align: middle;
    user-select: none;
}

.path-collapsed-toggle:hover {
    background: linear-gradient(135deg, #c7d2fe, #a5b4fc);
    border-color: #818cf8;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.path-collapsed-toggle.expanded {
    background: linear-gradient(135deg, #818cf8, #6366f1);
    border-color: #6366f1;
    color: white;
}

.path-collapsed-toggle.expanded:hover {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.collapsed-dots {
    font-size: 14px;
    letter-spacing: 1px;
    line-height: 1;
}

.collapsed-count {
    font-size: 10px;
    background: rgba(79, 70, 229, 0.15);
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.path-collapsed-toggle.expanded .collapsed-count {
    background: rgba(255, 255, 255, 0.25);
}

/* Прихований вміст шляху */
.path-collapsed-content {
    display: none;
    animation: pathFadeIn 0.3s ease;
}

.path-collapsed-content[style*="display: inline"] {
    display: inline;
}

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

/* Сепаратор після "..." */
.path-after-dots {
    transition: opacity 0.2s;
}

/* Стилі для частин шляху */
.path-part {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.4;
    transition: all 0.2s;
}

.path-part.path-root {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.path-part.path-middle {
    background: #f1f5f9;
    color: #475569;
}

.path-part.path-pre-last {
    background: #e0e7ff;
    color: #4338ca;
}

.path-part.path-last {
    background: linear-gradient(135deg, #a855f7, #8b5cf6);
    color: white;
    font-weight: 600;
}

.path-separator {
    color: #94a3b8;
    margin: 0 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Hover ефекти для частин шляху */
.path-part:hover {
    filter: brightness(0.95);
}

.path-part.path-last:hover {
    filter: brightness(1.1);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

/* Адаптивність для мобільних */
@media (max-width: 768px) {
    .path-collapsed-toggle {
        padding: 3px 8px;
        font-size: 11px;
    }
    
    .collapsed-count {
        display: none;
    }
    
    .path-part {
        font-size: 11px;
        padding: 2px 5px;
    }
    
    .path-separator {
        margin: 0 2px;
    }
}

/* Disabled state for search panel elements during category mode */
.sp-checkbox-wrapper.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.sp-location-tab.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.sp-dropdown-wrapper.disabled {
    opacity: 0.35;
    pointer-events: none;
}

/* Refinement tag input active effects */
.rp-refinement-tag-input:focus {
    outline: none;
    color: #fff;
}

/* Volume menu fix */
.rp-volume-menu.show,
.rp-perpage-menu.show {
    display: block !important;
}

/* Card content selection */
.rp-card-content::selection {
    background: rgba(136, 93, 246, 0.3);
    color: #fff;
}

/* ---- Fullscreen overlay ---- */
.rp-fullscreen-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 4999;
    display: none;
}

/* Fullscreen button state */
.rp-panel.fullscreen .rp-fullscreen-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.rp-panel.fullscreen .rp-fullscreen-btn:hover {
    filter: brightness(1.15);
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

/* ---- Dashboard actions row ---- */
.rp-dashboard-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.rp-send-to-ai-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.rp-select-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    color: #6566F1;
    cursor: pointer;
    font-family: inherit;
}

.rp-select-link:hover {
    text-decoration: underline;
    color: #885DF6;
}

.rp-select-sep {
    color: #64748b;
    user-select: none;
}

.rp-send-to-ai-btn {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #e2e8f0;
    background: rgba(101, 102, 241, 0.25);
    border: 1px solid rgba(101, 102, 241, 0.5);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.rp-send-to-ai-btn:hover:not(:disabled) {
    background: rgba(101, 102, 241, 0.4);
    border-color: #6566F1;
}

.rp-send-to-ai-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Dashboard mode badge ---- */
.rp-dashboard-mode-badge {
    display: inline-block;
    padding: 4px 14px;
    background: linear-gradient(135deg, rgba(136,93,246,0.2), rgba(101,102,241,0.25));
    border: 1px solid rgba(136,93,246,0.35);
    border-radius: 20px;
    color: #c4b5fd;
    font-size: 13px;
    font-weight: 600;
    font-style: normal;
    margin-left: 8px;
    vertical-align: middle;
}

/* ---- Filter tag variants ---- */
.rp-filter-tag-mode {
    background: rgba(136,93,246,0.12);
    border-color: rgba(136,93,246,0.4);
    color: #c4b5fd;
}

.rp-filter-tag-cat {
    background: rgba(250,204,21,0.08);
    border-color: rgba(250,204,21,0.3);
    color: #fbbf24;
}

/* PP count per page badge */
.rp-perpage-btn span {
    text-align: center;
}

/* Category panel fullscreen btn position */
.rp-cat-fullscreen-btn {
    margin-left: auto;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet */
@media (max-width: 1100px) {
    .search-container {
        padding: 16px;
    }
    .rp-bottom-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        left: 0 !important; /* On tablet/mobile, sidebar overlays so bar is full width */
    }
    .rp-filters-display {
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .main-layout {
        padding-left: 0 !important;
    }
    .sidebar-panel {
        width: 260px;
        z-index: 2000;
        transform: translateX(-100%);
    }
    .sidebar-panel:not(.collapsed) {
        transform: translateX(-100%);
    }
    .sidebar-panel.mobile-open {
        transform: translateX(0) !important;
    }
    .sidebar-toggle-btn,
    .sidebar-toggle-btn.shifted {
        left: 12px !important;
        top: 10px;
    }
    .search-container {
        padding: 56px 10px 12px; /* top padding for toggle button */
    }
    .sp-search-row {
        flex-wrap: wrap;
    }
    .sp-settings-row {
        flex-direction: column;
        gap: 8px;
    }
    .rp-dashboard-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .rp-card-header {
        gap: 6px;
        padding: 10px 12px;
    }
    .rp-card-header-top {
        gap: 6px;
    }
    .rp-card-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .rp-refinement-section {
        flex-direction: column;
        align-items: stretch;
    }
    .rp-volume-section {
        flex-wrap: wrap;
    }
    .rp-cat-dashboard {
        flex-direction: column;
        gap: 8px;
    }
    .dialog-panel {
        max-height: 400px;
    }
    .message-content {
        max-width: 90%;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .search-container {
        padding: 54px 6px 8px;
    }
    .sp-panel {
        border-radius: 10px;
    }
    .rp-panel {
        border-radius: 10px;
    }
    .rp-title-label {
        font-size: 16px;
    }
    .rp-title-count {
        font-size: 20px;
    }
    .rp-card-content {
        font-size: 13px;
        line-height: 1.6;
    }
}

/* Mobile sidebar overlay */
.sidebar-mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1999;
}
.sidebar-mobile-overlay.visible {
    display: block;
}

/* Loading overlay - solid color only (no blur) */
.loading-overlay:not(.hidden) {
    background: #0f0a2e !important;
}
.loading-text {
    color: #c4b5fd !important;
}

/* Стару модалку/панель уточнень не показуємо — уточнення тільки через нову панель у результатах */
#clarificationBox,
.clarification-box,
#clarificationPanel,
.clarification-panel,
.clarification-overlay {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Disable blur on all overlays to prevent post-search blur */
#loadingOverlay,
.rp-fullscreen-overlay,
.sidebar-mobile-overlay,
.sidebar-overlay,
.modal {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
#loadingOverlay *,
.loading-overlay * {
    filter: none !important;
}

/* Buttons general dark theme */
.btn {
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background: linear-gradient(135deg, #6566F1, #885DF6) !important;
    color: #fff !important;
    border: none !important;
}
.btn-primary:hover {
    filter: brightness(1.15);
}
.btn-secondary {
    background: rgba(255,255,255,0.06) !important;
    color: #94a3b8 !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
}
.btn-secondary:hover {
    background: rgba(255,255,255,0.1) !important;
    color: #e2e8f0 !important;
}

/* На сторінці категоризатора закресленої панелі «Пошук» не має бути */
body.page-categorizer .search-container,
body.page-categorizer .sticky-top-panel .search-container {
    display: none !important;
}
body.page-categorizer #searchStatus {
    display: none !important;
}
/* Приховати окремі вкладки «Місце пошуку», якщо панель колись показується */
body.page-categorizer #searchModeCategory,
body.page-categorizer #searchModeRequisites {
    display: none !important;
}

/* ============================================
   КАТЕГОРИЗАТОР (окрема сторінка)
   ============================================ */
.categorizer-section {
    position: relative;
    min-height: 100vh;
    padding: 20px 24px 40px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.categorizer-panel {
    width: 96%;
    max-width: 1800px;
    min-width: 400px;
    height: calc(100vh - 100px);
    min-height: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
}

.categorizer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.categorizer-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.categorizer-close {
    flex-shrink: 0;
}

/* Панель пошуку НЕ зникає при скролі */
.categorizer-sticky-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    flex-shrink: 0;
}

.categorizer-search-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.categorizer-search-input {
    flex: 1;
    min-width: 200px;
}

.categorizer-refresh-btn {
    padding: 10px 16px;
    font-size: 14px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, border-color 0.2s;
}

.categorizer-refresh-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary-color);
}

.categorizer-group-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.categorizer-group-btn {
    padding: 8px 14px;
    font-size: 13px;
    background: var(--primary-color);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.categorizer-group-btn:hover {
    background: var(--primary-hover);
}

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

.categorizer-tree-wrap {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: auto;
    padding: 16px 20px;
    position: relative;
}

.categorizer-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: var(--text-secondary);
    font-size: 16px;
}

.categorizer-loading-spinner {
    display: block;
    width: 44px;
    height: 44px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.categorizer-loading-text {
    font-size: 15px;
    color: var(--text-secondary);
}

/* Усунути білу смугу у дочірніх категоріях */
.categorizer-tree-wrap .category-children {
    background: transparent !important;
    margin-top: 4px;
    margin-left: 16px;
}

.categorizer-tree-wrap .category-header {
    background: var(--bg-color) !important;
    border: 1px solid var(--border-color);
}

.categorizer-tree-wrap .category-node .category-node .category-header {
    background: var(--bg-color) !important;
}

/* Довгі назви: перенос блоками, щоб текст не виходив за межі */
.categorizer-tree-wrap .category-header {
    flex-wrap: wrap;
    align-items: center;
}
.categorizer-tree-wrap .category-name-wrap {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
    display: block;
}
.categorizer-tree-wrap .category-name {
    display: block;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.4;
}
.categorizer-tree-wrap .category-type,
.categorizer-tree-wrap .category-pp-count {
    flex-shrink: 0;
}

/* Візуалізація при розкритті категорії */
.category-header.category-expanding {
    opacity: 0.85;
    background: rgba(101, 102, 241, 0.12) !important;
    transition: opacity 0.15s ease, background 0.15s ease;
}

/* ============================================
   КАБІНЕТ (overview) + Закладки
   ============================================ */
.overview-section {
    position: relative;
    min-height: 100vh;
    padding: 60px 40px 40px;
    overflow: hidden;
}

.overview-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(101,102,241,0.18) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(136,93,246,0.14) 0%, transparent 50%),
        radial-gradient(ellipse at 60% 80%, rgba(59,130,246,0.1) 0%, transparent 50%),
        linear-gradient(180deg, #0e0b20 0%, #13102b 100%);
    z-index: 0;
}

.overview-content {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
}

.overview-title {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #6366f1, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.overview-subtitle {
    font-size: 16px;
    color: #94a3b8;
    margin-bottom: 40px;
}

.overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.overview-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.25s;
    cursor: default;
}

.overview-card-clickable {
    cursor: pointer;
}

.overview-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.overview-card:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(136,93,246,0.3);
    box-shadow: 0 8px 32px rgba(136,93,246,0.12);
    transform: translateY(-2px);
}

.overview-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(101,102,241,0.2), rgba(136,93,246,0.2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a78bfa;
    margin-bottom: 14px;
}

.overview-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
}

.overview-card-desc {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
}

.overview-stats {
    display: flex;
    gap: 32px;
    padding: 24px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.overview-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.overview-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #a78bfa;
}

.overview-stat-label {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Розділ Закладки в Кабінеті */
.overview-bookmarks {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.overview-bookmarks-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.overview-back-to-results-btn {
    padding: 6px 14px;
    background: rgba(136, 93, 246, 0.25);
    border: 1px solid rgba(136, 93, 246, 0.5);
    border-radius: 8px;
    color: #c4b5fd;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.overview-back-to-results-btn:hover {
    background: rgba(136, 93, 246, 0.4);
    color: #e2e8f0;
}

.overview-bookmarks-title {
    font-size: 20px;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.overview-bookmarks-title svg {
    color: #a78bfa;
    flex-shrink: 0;
}

.overview-bookmarks-desc {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 20px;
    line-height: 1.5;
}

.overview-bookmarks-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.overview-bookmarks-loading,
.overview-bookmarks-error {
    font-size: 14px;
    color: #94a3b8;
    padding: 16px 0;
}

.overview-bookmarks-empty {
    font-size: 14px;
    color: #64748b;
    padding: 24px;
    background: rgba(255,255,255,0.03);
    border-radius: 12px;
    border: 1px dashed rgba(255,255,255,0.1);
}

.overview-bookmark-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    transition: all 0.2s;
}

.overview-bookmark-item:hover {
    background: rgba(255,255,255,0.06);
    border-color: rgba(136,93,246,0.25);
}

.overview-bookmark-item-main {
    flex: 1;
    min-width: 0;
}

.overview-bookmark-item-meta {
    font-size: 12px;
    color: #64748b;
    display: block;
    margin-bottom: 4px;
}

.overview-bookmark-item-title {
    font-size: 14px;
    color: #e2e8f0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.overview-bookmark-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.overview-bookmark-btn {
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}

.overview-bookmark-btn-chat:hover {
    background: rgba(101,102,241,0.25);
    border-color: rgba(101,102,241,0.5);
    color: #a5b4fc;
}

.overview-bookmark-btn-remove:hover {
    background: rgba(239,68,68,0.15);
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}

.overview-bookmarks-missing {
    font-size: 12px;
    color: #64748b;
    padding: 8px 0;
}

/* ============================================
   PROMPT EDITOR MODAL
   ============================================ */
.prompt-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.prompt-modal-content {
    background: #1a1640;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.prompt-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.prompt-modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #e2e8f0;
    margin: 0;
}

.prompt-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.prompt-modal-desc {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 16px;
    line-height: 1.5;
}

.prompt-editor {
    width: 100%;
    min-height: 340px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: #e2e8f0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    padding: 16px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.prompt-editor:focus {
    border-color: rgba(136,93,246,0.5);
}

.prompt-modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

.prompt-status {
    font-size: 13px;
    color: #94a3b8;
    margin-left: auto;
    transition: opacity 0.3s;
}

.prompt-status.success {
    color: #34d399;
}

.prompt-status.error {
    color: #f87171;
}

/* Category bottom bar info */
.rp-cat-bottom-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.rp-cat-bottom-label {
    font-size: 13px;
    color: #a78bfa;
    font-weight: 600;
}

/* Clear button disabled */
.sp-clear-btn.disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Clear button hidden when nothing to clear */
.sp-clear-btn.sp-clear-btn--hidden {
    visibility: hidden;
    pointer-events: none;
}

/* ============================================
   Category card paths container
   ============================================ */
/* (old grouped path styles removed) */

.rp-cat-card-toggle-paths--unused {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid rgba(255,255,255,0.1);
    color: #a78bfa;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 4px;
    transition: all 0.2s;
}

.rp-cat-card-toggle-paths--unused:hover {
    background: rgba(136,93,246,0.1);
    border-color: rgba(136,93,246,0.3);
}

/* Entity color variants */
.rp-cat-card-entity.entity-criminal {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
}

.rp-cat-card-entity.entity-civil {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.rp-cat-card-entity.entity-admin {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.rp-cat-card-entity.entity-commercial {
    background: linear-gradient(135deg, #10b981, #059669);
}

.rp-cat-card-entity.entity-vp {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.rp-cat-card-entity.entity-espl {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

/* Debug button in category dashboard */
.rp-cat-debug-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.rp-cat-debug-btn:hover {
    background: rgba(251, 191, 36, 0.25);
    border-color: rgba(251, 191, 36, 0.5);
}

/* ============================================
   Category Prompt Debug Panel
   ============================================ */
.cat-prompt-debug-panel {
    background: #1a1640;
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    margin-top: 12px;
    overflow: hidden;
}

.cat-prompt-debug-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(251, 191, 36, 0.08);
    border-bottom: 1px solid rgba(251, 191, 36, 0.15);
}

.cat-prompt-debug-header h3 {
    margin: 0;
    font-size: 14px;
    color: #fbbf24;
    font-weight: 700;
}

.cat-prompt-debug-meta {
    flex: 1;
    font-size: 12px;
    color: #94a3b8;
}

.cat-prompt-debug-meta b {
    color: #e2e8f0;
}

.cat-prompt-debug-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.cat-prompt-debug-close:hover {
    color: #f87171;
}

.cat-prompt-debug-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
}

.cat-prompt-debug-section {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cat-prompt-debug-label {
    font-size: 12px;
    font-weight: 600;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cat-prompt-debug-textarea {
    width: 100%;
    box-sizing: border-box;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.5;
    padding: 10px;
    resize: vertical;
    outline: none;
}

.cat-prompt-debug-textarea:focus {
    border-color: rgba(251,191,36,0.4);
}

/* ============================================
   AI CHAT INTEGRATION STYLES
   ============================================ */

/* Chat button in sidebar - 3 states */
#goToAIChatBtnSidebar {
    position: relative;
}

.sidebar-chat-badge {
    background: var(--primary-color);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
    line-height: 1.4;
    margin-left: auto;
}

/* Ready state: PP loaded, pulsing glow */
.sidebar-nav-btn-ready {
    background: rgba(16,185,129,0.12) !important;
    color: #34d399 !important;
    border-color: rgba(16,185,129,0.3) !important;
    animation: chatBtnPulse 2s infinite;
}

@keyframes chatBtnPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.2); }
    50% { box-shadow: 0 0 8px 2px rgba(16,185,129,0.15); }
}

/* "Додати в AI чат" action button on PP cards */
.rp-card-action-btn-chat {
    color: #a5b4fc !important;
}

.rp-card-action-btn-chat:hover {
    color: var(--primary-color) !important;
    background: rgba(101,102,241,0.15) !important;
}

.rp-card-action-btn-chat-added {
    color: var(--success-color) !important;
    background: rgba(16,185,129,0.15) !important;
}

/* "Додати в AI чат" button in category dashboard */
.rp-cat-add-to-chat-btn {
    background: rgba(101,102,241,0.1) !important;
    color: #a5b4fc !important;
    border-color: rgba(101,102,241,0.25) !important;
}

.rp-cat-add-to-chat-btn:hover:not(:disabled) {
    background: rgba(101,102,241,0.2) !important;
    color: #c4b5fd !important;
}

.rp-cat-add-to-chat-btn:disabled {
    opacity: 0.4;
}

