:root {
    --tg-accent: #2481cc;
    --tg-accent-hover: #1a6db3;
    --tg-bg: var(--tg-theme-bg-color, #ffffff);
    --tg-text: var(--tg-theme-text-color, #000000);
    --tg-hint: var(--tg-theme-hint-color, #999999);
    --tg-link: var(--tg-theme-link-color, #2481cc);
    --tg-button: var(--tg-theme-button-color, #2481cc);
    --tg-button-text: var(--tg-theme-button-text-color, #ffffff);
    --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #f5f5f5);
    --tg-header-bg: var(--tg-theme-header-bg-color, #ffffff);
    --tg-section-bg: var(--tg-theme-section-bg-color, #f5f5f5);
    --tg-section-header-text: var(--tg-theme-section-header-text-color, #6d6d6d);
    --tg-subtitle-text: var(--tg-theme-subtitle-text-color, #6d6d6d);
    --tg-destructive-text: var(--tg-theme-destructive-text-color, #e53935);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --tg-bg: var(--tg-theme-bg-color, #1c1c1e);
        --tg-text: var(--tg-theme-text-color, #ffffff);
        --tg-hint: var(--tg-theme-hint-color, #8e8e93);
        --tg-link: var(--tg-theme-link-color, #5ac8fa);
        --tg-button: var(--tg-theme-button-color, #5ac8fa);
        --tg-button-text: var(--tg-theme-button-text-color, #1c1c1e);
        --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #2c2c2e);
        --tg-header-bg: var(--tg-theme-header-bg-color, #1c1c1e);
        --tg-section-bg: var(--tg-theme-section-bg-color, #2c2c2e);
        --tg-section-header-text: var(--tg-theme-section-header-text-color, #8e8e93);
        --tg-subtitle-text: var(--tg-theme-subtitle-text-color, #8e8e93);
        --tg-destructive-text: var(--tg-theme-destructive-text-color, #ff453a);
        --shadow: 0 1px 3px rgba(0,0,0,0.25);
        --shadow-card: 0 2px 8px rgba(0,0,0,0.3);
    }
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--tg-bg);
    color: var(--tg-text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Loading spinner ── */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    gap: 12px;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--tg-section-bg);
    border-top-color: var(--tg-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 0.9rem;
    color: var(--tg-hint);
    margin: 0;
}

/* ── Empty state ── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    gap: 8px;
}

.empty-state__icon {
    font-size: 2.5rem;
    line-height: 1;
    opacity: 0.5;
    margin-bottom: 4px;
}

.empty-state__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--tg-subtitle-text);
    margin: 0;
}

.empty-state__subtitle {
    font-size: 0.85rem;
    color: var(--tg-hint);
    margin: 0;
    line-height: 1.4;
}

/* ── Error state ── */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    gap: 12px;
}

.error-icon {
    font-size: 2rem;
    line-height: 1;
    opacity: 0.6;
}

.error-text {
    font-size: 0.9rem;
    color: var(--tg-destructive-text);
    margin: 0;
    line-height: 1.4;
}

.retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-accent);
    color: var(--tg-button-text);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.retry-btn:active {
    background: var(--tg-accent-hover);
}

/* ── Header ── */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    padding: 0 16px;
    background: var(--tg-header-bg);
    border-bottom: 1px solid rgba(128,128,128,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.app-header h1 {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--tg-secondary-bg);
    color: var(--tg-text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    padding: 0;
    line-height: 1;
}

.icon-btn:active {
    background: var(--tg-hint);
    opacity: 0.7;
}

/* ── Content area ── */
.content {
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 64px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px 24px;
}

/* ── Pages ── */
.page {
    display: none;
    animation: fadeIn 0.18s ease-out;
}

.page.active {
    display: block;
}

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

/* ── Generic section container ── */
.section {
    margin-bottom: 16px;
}

.section h2 {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--tg-section-header-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.section__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

.section__header h2 {
    margin: 0;
}

.section-link {
    font-size: 0.85rem;
    color: var(--tg-link);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-weight: 500;
}

/* ── Stat cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--tg-secondary-bg);
    border-radius: var(--radius-md);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow-card);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--tg-text);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--tg-subtitle-text);
    margin-top: 4px;
}

/* ── Rating bars ── */
.rating-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rating-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rating-bar__label {
    width: 60px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--tg-subtitle-text);
    text-transform: capitalize;
    flex-shrink: 0;
}

.rating-bar__track {
    flex: 1;
    height: 22px;
    background: var(--tg-section-bg);
    border-radius: 11px;
    overflow: hidden;
}

.rating-bar__fill {
    height: 100%;
    border-radius: 11px;
    transition: width 0.4s ease;
}

.rating-bar__fill--critical { background: #e53935; }
.rating-bar__fill--high    { background: #43a047; }
.rating-bar__fill--medium  { background: #fdd835; }
.rating-bar__fill--low     { background: #fb8c00; }
.rating-bar__fill--info    { background: #1e88e5; }

.rating-bar__count {
    width: 32px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tg-text);
    text-align: right;
    flex-shrink: 0;
}

/* ── Report list ── */
.report-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-item {
    background: var(--tg-secondary-bg);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: background 0.15s ease;
}

.report-item:active {
    background: var(--tg-section-bg);
}

.report-item__header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.report-item__vendor {
    font-size: 0.8rem;
    color: var(--tg-subtitle-text);
    font-weight: 500;
}

.report-item__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--tg-text);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.report-item__year {
    font-size: 0.78rem;
    color: var(--tg-hint);
    margin-left: auto;
}

.report-item__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--tg-hint);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
    line-height: 1.4;
}

.badge--critical { background: #e5393520; color: #e53935; }
.badge--high    { background: #43a04720; color: #43a047; }
.badge--medium  { background: #fdd83520; color: #d4a017; }
.badge--low     { background: #fb8c0020; color: #fb8c00; }
.badge--info    { background: #1e88e520; color: #1e88e5; }

/* ── Search ── */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.search-bar input {
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-section-bg);
    color: var(--tg-text);
    font-size: 1rem;
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(128,128,128,0.15);
    transition: box-shadow 0.15s ease;
}

.search-bar input::placeholder {
    color: var(--tg-hint);
}

.search-bar input:focus {
    box-shadow: inset 0 0 0 2px var(--tg-accent);
}

.search-bar button {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-accent);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    padding: 0;
}

.search-bar button:active {
    background: var(--tg-accent-hover);
}

.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.reset-filters-btn {
    font-size: 0.8rem;
    color: var(--tg-destructive-text);
    background: none;
    border: none;
    padding: 0 2px 10px;
    cursor: pointer;
    font-weight: 500;
    display: none;
}

.filters select {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-section-bg);
    color: var(--tg-text);
    font-size: 0.9rem;
    outline: none;
    box-shadow: inset 0 0 0 1px rgba(128,128,128,0.15);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 12px;
}

.pagination button {
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-secondary-bg);
    color: var(--tg-text);
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.pagination button:active {
    background: var(--tg-section-bg);
}

.pagination button.active {
    background: var(--tg-accent);
    color: var(--tg-button-text);
}

.pagination .page-info {
    font-size: 0.8rem;
    color: var(--tg-hint);
    padding: 0 8px;
}

/* ── Vendors ── */
.vendor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.vendor-card {
    background: var(--tg-secondary-bg);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.vendor-card:active {
    background: var(--tg-section-bg);
}

.vendor-card__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--tg-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.vendor-card__info {
    flex: 1;
    min-width: 0;
}

.vendor-card__name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--tg-text);
    margin-bottom: 2px;
}

.vendor-card__count {
    font-size: 0.8rem;
    color: var(--tg-subtitle-text);
}

.vendor-card__arrow {
    font-size: 0.85rem;
    color: var(--tg-hint);
}

/* ── Vendor alphabet group ── */
.vendor-group-header {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--tg-hint);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 4px 4px;
}

.vendor-group-header:first-child {
    padding-top: 0;
}

/* ── Compare button on report card ── */
.report-item__compare-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1.5px solid var(--tg-hint);
    background: transparent;
    color: var(--tg-hint);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
    transition: all 0.15s ease;
    line-height: 1;
}

.report-item__compare-btn.active {
    background: var(--tg-accent);
    border-color: var(--tg-accent);
    color: #fff;
}

/* ── Compare chips ── */
.compare-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.compare-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--tg-secondary-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.compare-chip__label {
    font-size: 0.85rem;
    color: var(--tg-text);
    font-weight: 500;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.compare-chip__remove {
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--tg-hint);
    color: #fff;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    opacity: 0.7;
}

/* ── Compare result grid ── */
.compare-result {
    margin-top: 16px;
}

/* ── Compare ── */
.compare-empty {
    background: var(--tg-secondary-bg);
    border-radius: var(--radius-md);
    padding: 48px 24px;
    text-align: center;
    box-shadow: var(--shadow-card);
}

.compare-empty p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--tg-subtitle-text);
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.compare-card {
    background: var(--tg-secondary-bg);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-card);
}

.compare-card__rating {
    margin-bottom: 8px;
}

.compare-card__vendor {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tg-text);
    margin-bottom: 2px;
}

.compare-card__year {
    font-size: 0.75rem;
    color: var(--tg-hint);
    margin-bottom: 6px;
}

.compare-card__title {
    font-size: 0.78rem;
    color: var(--tg-subtitle-text);
    line-height: 1.4;
}

.compare-card--best {
    border: 2px solid var(--tg-accent);
}

.compare-card__crown {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--tg-accent);
    margin-bottom: 6px;
}

.compare-card__findings {
    font-size: 0.75rem;
    color: var(--tg-subtitle-text);
    line-height: 1.5;
    margin-top: 8px;
    white-space: pre-line;
}

.compare-card__open {
    margin-top: 10px;
    width: 100%;
    padding: 6px 0;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-secondary-bg);
    color: var(--tg-accent);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.compare-result__heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tg-section-header-text);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    padding-top: 4px;
}

.badge--lg {
    font-size: 1rem;
    padding: 4px 12px;
}

/* ── Bottom navigation ── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 64px;
    padding: 0 8px;
    background: var(--tg-header-bg);
    border-top: 1px solid rgba(128,128,128,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    border: none;
    background: transparent;
    color: var(--tg-hint);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background 0.15s ease;
    position: relative;
    padding: 0;
}

.nav-btn:active {
    background: rgba(128,128,128,0.1);
}

.nav-btn.active {
    color: var(--tg-accent);
}

.nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.nav-badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(calc(50% + 12px));
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--tg-destructive-text);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.report-modal {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 201;
    max-height: 92vh;
    background: var(--tg-bg);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--tg-hint);
    opacity: 0.35;
    border-radius: 2px;
    margin: 12px auto 4px;
}

.modal-content {
    padding: 20px 20px max(20px, env(safe-area-inset-bottom));
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--tg-secondary-bg);
    color: var(--tg-text);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease;
}

.modal-close:active {
    background: var(--tg-hint);
}

.modal-body h2 {
    margin: 0 0 12px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--tg-text);
    line-height: 1.3;
}

.modal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    color: var(--tg-hint);
}

.modal-vendor,
.modal-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-section {
    margin-bottom: 16px;
}

.modal-section h3 {
    margin: 0 0 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--tg-section-header-text);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.modal-section p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--tg-text);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ── Responsive ── */
@media (min-width: 600px) {
    .content,
    .app-header,
    .bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* ── Summary HTML content (trusted HTML from backend) ── */
.summary-html {
    font-size: 0.9rem;
    color: var(--tg-text);
    line-height: 1.6;
}

.summary-html p {
    margin: 0 0 8px;
}

.summary-html ul, .summary-html ol {
    margin: 4px 0 8px;
    padding-left: 20px;
}

.summary-html li {
    margin-bottom: 4px;
}

.summary-html h1, .summary-html h2, .summary-html h3, .summary-html h4 {
    margin: 12px 0 6px;
    font-weight: 600;
}

.summary-html strong {
    font-weight: 600;
}

.summary-html code {
    background: var(--tg-secondary-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.summary-html pre {
    background: var(--tg-secondary-bg);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.85em;
    margin: 8px 0;
}

/* ── Search mode toggle ── */
.search-mode-toggle {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.mode-btn {
    flex: 1;
    padding: 9px 0;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-section-bg);
    color: var(--tg-hint);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.mode-btn.active {
    background: var(--tg-accent);
    color: #fff;
}

/* ── Role selector ── */
.role-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.role-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 4px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--tg-section-bg);
    color: var(--tg-hint);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.role-btn.active {
    background: var(--tg-accent);
    color: #fff;
}

/* ── Semantic score badge ── */
.report-item__score {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--tg-link);
    background: rgba(36, 129, 204, 0.12);
    border-radius: 8px;
    padding: 2px 7px;
    flex-shrink: 0;
    margin-left: auto;
}

/* ── Button ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn-primary {
    background: var(--tg-button);
    color: var(--tg-button-text);
}

.btn-primary:active {
    opacity: 0.8;
}

/* ─── RAG: Chunk items ───────────────────────────────────────────── */

.chunk-item {
    background: var(--tg-secondary-bg);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
}

.chunk-item__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.chunk-item__vendor {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--tg-text);
}

.chunk-item__attrs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.chunk-item__page,
.chunk-item__rating,
.chunk-item__score {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    background: var(--tg-bg);
    color: var(--tg-hint);
}

.chunk-item__text {
    font-size: 0.82rem;
    color: var(--tg-hint);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── RAG: Synthesize bar ────────────────────────────────────────── */

.rag-synthesize-bar {
    position: sticky;
    bottom: 0;
    padding: 10px 0 6px;
    background: var(--tg-bg);
    z-index: 10;
}

.synthesize-btn {
    width: 100%;
    padding: 12px;
    background: var(--tg-button);
    color: var(--tg-button-text);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.synthesize-btn:active {
    opacity: 0.8;
}

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

/* ─── RAG: Synthesis panel ───────────────────────────────────────── */

.rag-synthesis-panel {
    background: var(--tg-secondary-bg);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
}

.rag-synthesis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.rag-synthesis-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.rag-synthesis-cost {
    font-size: 0.72rem;
    color: var(--tg-hint);
}

.rag-synthesis-close {
    background: none;
    border: none;
    color: var(--tg-hint);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 4px;
}

.rag-synthesis-body {
    font-size: 0.85rem;
    line-height: 1.55;
    color: var(--tg-text);
}

.rag-synthesis-body p {
    margin: 0 0 8px;
}

.rag-synthesis-body p:last-child {
    margin-bottom: 0;
}

.rag-synthesis-body strong {
    font-weight: 600;
}

.rag-citation {
    color: var(--tg-button);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

/* ─── Search mode hint ───────────────────────────────────────────── */

.search-mode-hint {
    font-size: 0.78rem;
    color: var(--tg-hint);
    padding: 6px 2px 2px;
    min-height: 1.2em;
    line-height: 1.4;
}
