        :root {
            /* The palette is intentionally fixed: it does not read
               Telegram's --tg-theme-* variables, so the app always renders
               with the same light colors regardless of the Telegram
               client's theme (including dark mode) or whether it's opened
               outside Telegram. */
            --tg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

            --bg-color: #ffffff;
            --card-bg: #ffffff;
            --surface-muted: #f5f7fb;
            --card-border: #E1E1E1;
            --card-border: color-mix(in srgb, #999999 28%, transparent);
            --card-border-accent: #4F77F1;
            --text-main: #200f07;
            --text-heading: #1032A1;
            --text-muted: #666666;
            --primary: #1032A1;
            --primary-glow: rgba(16, 50, 161, 0.15);
            --primary-glow: color-mix(in srgb, var(--primary) 15%, transparent);
            --primary-tint: #E8EDFB;
            --primary-tint: color-mix(in srgb, var(--primary) 12%, var(--bg-color));
            --accent: #0882ff;
            --accent-text: #ffffff;
            --accent-glow: rgba(8, 130, 255, 0.2);
            --accent-glow: color-mix(in srgb, var(--accent) 20%, transparent);
            --success: #10b981;
            --success-bg: #ADFFC6;
            --success-bg: color-mix(in srgb, var(--success) 20%, var(--bg-color));
            --danger: #ef4444;
            --danger-bg: #ffd7d7;
            --danger-bg: color-mix(in srgb, var(--danger) 18%, var(--bg-color));
            --warning: #f59e0b;
            --warning-bg: #ffe8b8;
            --warning-bg: color-mix(in srgb, var(--warning) 20%, var(--bg-color));
            --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        }

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

        body {
            font-family: var(--tg-font);
            background-color: var(--bg-color);
            color: var(--text-main);
            min-height: 100vh;
            overflow-x: hidden;
            padding-bottom: 80px; /* Safe space for nav bar */
        }

        h1, h2, h3, h4 {
            font-family: var(--tg-font);
            font-weight: 700;
            color: var(--text-heading);
        }

        /* Flat cards */
        .glass-card {
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 12px;
            padding: 16px;
            margin-bottom: 12px;
            box-shadow: none;
            transition: var(--transition);
        }

        .glass-card:hover {
            border-color: var(--card-border-accent);
            box-shadow: 0 5px 15px rgba(79, 119, 241, 0.15);
            transform: translateY(-2px);
        }

        /* Top Navigation Header — shares the page background so it blends
           into Telegram's own chrome instead of reading as a separate bar */
        header {
            background: var(--bg-color);
            padding: 16px 20px;
            position: sticky;
            top: 0;
            z-index: 100;
            border-bottom: 1px solid var(--card-border);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        header h1 {
            font-size: 1.3rem;
            color: var(--text-heading);
        }

        .status-badge-header {
            font-size: 0.75rem;
            padding: 4px 8px;
            border-radius: 12px;
            background: var(--primary-tint);
            color: var(--primary);
            border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
            font-weight: 500;
        }

        /* Container & Tabs */
        .container {
            max-width: 600px;
            margin: 0 auto;
            padding: 16px;
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
            animation: fadeIn 0.3s ease-out;
        }

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

        /* Bottom Tab Navigator */
        .nav-bar {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--card-bg);
            border-top: 1px solid var(--card-border);
            display: flex;
            justify-content: space-around;
            padding: 10px 0;
            padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
            z-index: 200;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: var(--text-muted);
            text-decoration: none;
            font-size: 0.75rem;
            font-weight: 500;
            cursor: pointer;
            transition: var(--transition);
            width: 33%;
        }

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

        .nav-icon {
            display: flex;
            margin-bottom: 4px;
        }

        .nav-icon svg {
            width: 22px;
            height: 22px;
        }

        /* Favorite toggle button */
        .fav-btn {
            background: none;
            border: none;
            cursor: pointer;
            width: 44px;
            height: 44px;
            padding: 0;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            color: var(--text-muted);
            transition: var(--transition);
            flex-shrink: 0;
            margin: -8px -8px -8px 0;
        }

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

        .fav-btn.active {
            color: var(--warning);
        }

        .fav-btn:disabled {
            opacity: 0.5;
            cursor: default;
        }

        .provider-header-controls {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .history-item {
            cursor: pointer;
        }

        .history-item .provider-footer {
            border-top: none;
            padding-top: 4px;
        }

        /* Search input styling */
        .search-container {
            margin-bottom: 16px;
            position: relative;
        }

        .search-input {
            width: 100%;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 12px;
            padding: 12px 16px 12px 40px;
            color: var(--text-main);
            font-size: 0.9rem;
            outline: none;
            transition: var(--transition);
        }

        .search-input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-glow);
        }

        .search-icon {
            position: absolute;
            left: 14px;
            top: 50%;
            transform: translateY(-50%);
            color: var(--text-muted);
            pointer-events: none;
        }

        /* Facet filters */
        .filters-bar {
            display: flex;
            align-items: center;
            gap: 12px;
            margin-bottom: 16px;
        }

        .filter-toggle-btn {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 10px;
            padding: 8px 14px;
            font-size: 0.85rem;
            font-weight: 500;
            color: var(--text-main);
            cursor: pointer;
            transition: var(--transition);
        }

        .filter-toggle-btn svg {
            width: 16px;
            height: 16px;
        }

        .filter-toggle-btn.active {
            border-color: var(--primary);
            color: var(--primary);
            background: var(--primary-tint);
        }

        .filter-count-badge {
            background: var(--primary);
            color: #fff;
            font-size: 0.7rem;
            font-weight: 700;
            min-width: 18px;
            height: 18px;
            border-radius: 9px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0 5px;
        }

        .filter-reset-btn {
            background: none;
            border: none;
            color: var(--danger);
            font-size: 0.8rem;
            font-weight: 600;
            cursor: pointer;
        }

        .filters-panel {
            display: none;
            background: var(--surface-muted);
            border: 1px solid var(--card-border);
            border-radius: 12px;
            padding: 14px;
            margin-bottom: 16px;
        }

        .filters-panel.active {
            display: block;
            animation: fadeIn 0.2s ease-out;
        }

        .filter-group {
            margin-bottom: 14px;
        }

        .filter-group:last-child {
            margin-bottom: 0;
        }

        .filter-group-label {
            font-size: 0.75rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 8px;
            font-weight: 600;
        }

        .chip-group {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }

        .chip {
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 20px;
            padding: 6px 12px;
            font-size: 0.8rem;
            color: var(--text-main);
            cursor: pointer;
            transition: var(--transition);
            user-select: none;
        }

        .chip:hover {
            border-color: var(--card-border-accent);
        }

        .chip.selected {
            background: var(--primary);
            border-color: var(--primary);
            color: #fff;
        }

        /* Provider cards styling */
        .provider-card {
            cursor: pointer;
        }

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

        .provider-name {
            font-size: 1.1rem;
            color: var(--text-main);
        }

        /* provider_type badge + audience/city meta line, shown in the list
           card header when that facet data is available (see renderProviderCards) */
        .provider-title-row {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .provider-type-badge {
            font-size: 0.68rem;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.03em;
            background: var(--primary-tint);
            color: var(--primary);
            border-radius: 6px;
            padding: 2px 7px;
            white-space: nowrap;
        }

        .provider-meta {
            font-size: 0.78rem;
            color: var(--text-muted);
            margin-top: 3px;
        }

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

        .provider-tags .more-tag {
            font-size: 0.75rem;
            color: var(--text-muted);
            align-self: center;
        }

        .badge {
            font-size: 0.7rem;
            padding: 3px 8px;
            border-radius: 8px;
            font-weight: 600;
            text-transform: uppercase;
        }

        .badge-deep {
            background: var(--primary-tint);
            color: var(--primary);
            border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
        }

        .badge-primary {
            background: var(--surface-muted);
            color: var(--text-muted);
            border: 1px solid var(--card-border);
        }

        .provider-spec {
            font-size: 0.85rem;
            color: var(--text-muted);
            line-height: 1.4;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            margin-bottom: 12px;
        }

        /* LLM reasoning block on provider cards & modal */
        .provider-reason {
            background: var(--primary-tint);
            border-left: 3px solid var(--primary);
            border-radius: 6px;
            padding: 8px 12px;
            margin: 8px 0 12px 0;
            font-size: 0.83rem;
            color: var(--text-main);
            line-height: 1.4;
        }

        .llm-reasoning-card {
            background: var(--primary-tint);
            border: 1px solid color-mix(in srgb, var(--primary) 20%, transparent);
            border-radius: 12px;
            padding: 12px 14px;
            margin-bottom: 16px;
        }

        .provider-footer {
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-size: 0.75rem;
            color: var(--text-muted);
            border-top: 1px solid var(--card-border);
            padding-top: 8px;
        }

        .provider-link {
            color: var(--primary);
            text-decoration: none;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            max-width: 60%;
            padding: 15px 0;
            margin: -15px 0;
            display: inline-block;
        }

        /* Provider detail — full-screen view (openspec change
           provider-detail-full-screen). Fixed + covers the full viewport
           at a higher z-index than the header (100) and nav-bar (200),
           the same technique the old bottom-sheet modal already used to
           sit above them — no separate JS show/hide of the nav bar or
           header is needed, this stacking already hides both from view. */
        .detail-screen {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 500;
            background: var(--bg-color);
            flex-direction: column;
        }

        .detail-screen.active {
            display: flex;
            animation: fadeIn 0.2s ease-out;
        }

        .detail-topbar {
            flex-shrink: 0;
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 16px 16px 14px;
            border-bottom: 1px solid var(--card-border);
            background: var(--bg-color);
        }

        .detail-back-btn {
            flex-shrink: 0;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background: var(--surface-muted);
            border: none;
            color: var(--text-main);
            font-size: 1.4rem;
            line-height: 1;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: var(--transition);
        }

        .detail-back-btn:hover {
            background: var(--card-border);
        }

        .detail-topbar-title {
            flex: 1;
            min-width: 0;
            font-size: 1rem;
            font-weight: 600;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .detail-tabs {
            flex-shrink: 0;
            display: flex;
            gap: 8px;
            padding: 10px 16px;
            border-bottom: 1px solid var(--card-border);
            background: var(--bg-color);
        }

        .detail-tab-btn {
            flex: 1;
            padding: 8px 0;
            border: none;
            border-radius: 10px;
            background: var(--surface-muted);
            color: var(--text-muted);
            font-size: 0.9rem;
            font-weight: 500;
            cursor: pointer;
            transition: var(--transition);
        }

        .detail-tab-btn.active {
            background: var(--primary-tint);
            color: var(--primary);
        }

        .detail-body {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        .detail-tab-content {
            display: none;
        }

        .detail-tab-content.active {
            display: block;
            animation: fadeIn 0.3s ease-out;
        }

        /* Section dividers use the same thin-hairline language approved
           for the catalog list ("Compact List" design-shotgun variant)
           rather than boxed/shadowed cards. */
        .info-group {
            padding-bottom: 16px;
            margin-bottom: 16px;
            border-bottom: 1px solid var(--card-border);
        }

        .info-group:last-child {
            border-bottom: none;
            margin-bottom: 0;
            padding-bottom: 0;
        }

        .info-label {
            font-size: 0.75rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.05em;
            margin-bottom: 4px;
            font-weight: 600;
        }

        .info-value {
            font-size: 0.95rem;
            line-height: 1.5;
        }

        /* Lists formatting */
        .tag-list {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            margin-top: 6px;
        }

        .tag-item {
            background: var(--surface-muted);
            border: 1px solid var(--card-border);
            border-radius: 8px;
            padding: 4px 10px;
            font-size: 0.8rem;
            color: var(--text-main);
        }

        .accent-tag {
            background: var(--primary-tint);
            border-color: color-mix(in srgb, var(--primary) 20%, transparent);
            color: var(--primary);
        }

        /* Distinguishes target_audience chips from provider_type/services/topics
           chips when they sit in the same row (modal "Категории" group) */
        .audience-tag {
            background: rgba(109, 95, 216, 0.1);
            border-color: rgba(109, 95, 216, 0.25);
            color: #6d5fd8;
        }

        .bullet-list {
            list-style: none;
            margin-top: 6px;
        }

        .bullet-list li {
            position: relative;
            padding-left: 16px;
            margin-bottom: 8px;
            font-size: 0.9rem;
            color: var(--text-main);
            line-height: 1.4;
        }

        /* Same round marker as .status-dot (8px, centered on the first
           line) so every list in the modal — courses, certificates,
           negatives, quality checklist — uses one consistent dot style. */
        .bullet-list li::before {
            content: "";
            position: absolute;
            left: 4px;
            top: 6px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: var(--text-muted);
        }

        /* Quality rows already carry their own .status-dot marker (see
           addQualityRow) — suppress the generic bullet-list dot here so
           each row doesn't show two markers. */
        #detail-positives.bullet-list li {
            padding-left: 0;
        }

        #detail-positives.bullet-list li::before {
            content: none;
        }

        /* Negatives/warnings list sits in a red-tinted panel — match the
           panel's danger color instead of the default neutral gray. */
        #detail-negatives.bullet-list li::before {
            background: var(--danger);
        }

        /* Catalog offering rows (renderOfferingsList) carry a title plus a
           muted price/duration/format sub-line — a bit more breathing
           room than the single-line default so the two lines don't feel
           cramped, matching the quality checklist's multi-line rows. */
        #detail-offerings-list.bullet-list li:not(.list-toggle-item) {
            margin-bottom: 12px;
        }

        /* "Show more" row appended by renderExpandableList (trainers,
           clients) — a plain toggle button, not a bulleted item. */
        .bullet-list li.list-toggle-item {
            padding-left: 0;
            margin-bottom: 0;
        }

        .bullet-list li.list-toggle-item::before {
            content: none;
        }

        /* Quality details */
        .metric-score {
            display: flex;
            align-items: center;
            margin-bottom: 12px;
        }

        .score-value {
            font-size: 2rem;
            font-weight: 700;
            font-family: 'Montserrat', sans-serif;
            color: var(--text-heading);
            margin-right: 12px;
        }

        .score-explanation {
            font-size: 0.85rem;
            color: var(--text-muted);
            line-height: 1.4;
        }

        .assessment-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 12px;
            margin-top: 12px;
        }

        .indicators-block {
            padding: 12px;
            border-radius: 12px;
        }

        .positives {
            background: rgba(173, 255, 198, 0.35);
            border: 1px solid rgba(16, 185, 129, 0.3);
        }

        .positives h4 {
            color: #0d7a56;
            font-size: 0.85rem;
            margin-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .negatives {
            background: rgba(255, 215, 215, 0.5);
            border: 1px solid rgba(239, 68, 68, 0.3);
        }

        .negatives h4 {
            color: #b91c1c;
            font-size: 0.85rem;
            margin-bottom: 8px;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        /* Unified status indicators — replaces raw 🟢/🔴/⚪ emoji, which don't
           adapt to theme and read inconsistently across the modal. */
        .status-pill {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 0.85rem;
            font-weight: 600;
        }

        .status-pill::before {
            content: "";
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: currentColor;
            flex-shrink: 0;
        }

        .status-pill--positive {
            background: rgba(16, 185, 129, 0.14);
            color: #0d7a56;
        }

        .status-pill--negative {
            background: rgba(239, 68, 68, 0.14);
            color: #b91c1c;
        }

        .status-pill--neutral {
            background: rgba(102, 102, 102, 0.12);
            color: var(--text-muted);
        }

        .status-dot {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            flex-shrink: 0;
        }

        .status-dot--positive {
            background: var(--success);
        }

        /* Statistics grid boxes (years of experience, clients, etc.) */
        .stat-box {
            background: var(--surface-muted);
            padding: 8px;
            border-radius: 8px;
            border: 1px solid var(--card-border);
            min-width: 0;
        }

        .stat-box-label {
            font-size: 0.7rem;
            color: var(--text-muted);
            text-transform: uppercase;
        }

        .stat-box-value {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--text-main);
            margin-top: 2px;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        /* Form Controls */
        .form-group {
            margin-bottom: 16px;
        }

        .form-label {
            display: block;
            font-size: 0.85rem;
            font-weight: 500;
            color: var(--text-muted);
            margin-bottom: 8px;
        }

        .form-input {
            width: 100%;
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 10px;
            padding: 12px;
            color: var(--text-main);
            font-size: 0.95rem;
            outline: none;
            transition: var(--transition);
        }

        .form-input:focus {
            border-color: var(--primary);
            box-shadow: 0 0 0 3px var(--primary-glow);
        }

        .radio-group {
            display: flex;
            gap: 12px;
            margin-top: 6px;
        }

        .radio-btn {
            flex: 1;
            position: relative;
        }

        .radio-btn input {
            position: absolute;
            opacity: 0;
            width: 0;
            height: 0;
        }

        .radio-btn label {
            display: block;
            text-align: center;
            background: var(--surface-muted);
            border: 1px solid var(--card-border);
            border-radius: 10px;
            padding: 12px;
            font-size: 0.85rem;
            font-weight: 500;
            cursor: pointer;
            color: var(--text-muted);
            transition: var(--transition);
        }

        .radio-btn input:checked + label {
            background: var(--primary-tint);
            border-color: var(--primary);
            color: var(--primary);
            box-shadow: none;
        }

        .accordion-btn {
            width: 100%;
            background: none;
            border: none;
            color: var(--primary);
            font-size: 0.85rem;
            font-weight: 600;
            cursor: pointer;
            text-align: left;
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .accordion-content {
            display: none;
            padding: 12px;
            background: var(--surface-muted);
            border-radius: 12px;
            border: 1px solid var(--card-border);
            margin-bottom: 16px;
        }

        .accordion-content.active {
            display: block;
        }

        /* Action buttons — flat, single-color, matching Telegram's own
           button_color/button_text_color rather than a branded gradient */
        .btn-submit {
            width: 100%;
            background: var(--accent);
            border: none;
            border-radius: 12px;
            padding: 14px;
            color: var(--accent-text);
            font-size: 1rem;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
        }

        .btn-submit:hover {
            filter: brightness(1.05);
        }

        .btn-submit:active {
            transform: translateY(1px);
        }

        /* Task styling */
        .task-list {
            margin-top: 12px;
        }

        .task-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .task-info h4 {
            font-size: 0.95rem;
            font-weight: 500;
            margin-bottom: 4px;
            max-width: 250px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .task-info p {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        .task-status {
            font-size: 0.75rem;
            padding: 4px 10px;
            border-radius: 8px;
            font-weight: 600;
            text-transform: uppercase;
        }

        .status-pending {
            background: var(--warning-bg);
            color: #92620a;
            border: 1px solid rgba(245, 158, 11, 0.4);
        }

        .status-running {
            background: var(--primary-tint);
            color: var(--primary);
            border: 1px solid rgba(16, 50, 161, 0.3);
            animation: pulse 1.5s infinite alternate;
        }

        .status-completed {
            background: var(--success-bg);
            color: #0d7a56;
            border: 1px solid rgba(16, 185, 129, 0.4);
        }

        .status-failed {
            background: var(--danger-bg);
            color: #b91c1c;
            border: 1px solid rgba(239, 68, 68, 0.4);
        }

        @keyframes pulse {
            from { opacity: 0.6; }
            to { opacity: 1; }
        }

        /* Empty states */
        .empty-state {
            text-align: center;
            padding: 40px 20px;
            color: var(--text-muted);
        }

        .empty-icon {
            margin-bottom: 12px;
            opacity: 0.7;
        }

        .empty-icon svg {
            width: 48px;
            height: 48px;
            color: var(--text-muted);
        }

        /* Spinner */
        .spinner {
            border: 3px solid var(--card-border);
            width: 24px;
            height: 24px;
            border-radius: 50%;
            border-left-color: var(--primary);
            animation: spin 1s linear infinite;
            display: inline-block;
            vertical-align: middle;
            margin-right: 8px;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .loading-container {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 40px;
        }

        /* Dialog tab */
        .dialog-messages {
            display: flex;
            flex-direction: column;
            gap: 10px;
            min-height: 200px;
            max-height: 60vh;
            overflow-y: auto;
            padding-bottom: 12px;
        }

        .dialog-bubble {
            max-width: 85%;
            padding: 10px 14px;
            border-radius: 14px;
            font-size: 0.9rem;
            line-height: 1.5;
            word-break: break-word;
        }

        .dialog-bubble strong {
            font-weight: 700;
        }

        .dialog-bubble--agent strong {
            color: #0f172a;
        }

        .dialog-bubble--user strong {
            color: var(--accent-text);
        }

        /* Elements produced by the `marked` parser (see renderFormattedText
           in app.js) inside a chat bubble. */
        .dialog-bubble p {
            margin: 8px 0;
        }

        .dialog-bubble p:first-child {
            margin-top: 0;
        }

        .dialog-bubble p:last-child {
            margin-bottom: 0;
        }

        .dialog-bubble ul,
        .dialog-bubble ol {
            margin: 4px 0;
            padding-left: 1.2em;
        }

        .dialog-bubble li {
            margin: 4px 0;
        }

        .dialog-bubble li::marker {
            color: var(--primary);
            font-weight: 700;
        }

        .dialog-bubble--user li::marker {
            color: var(--accent-text);
        }

        .dialog-bubble h1,
        .dialog-bubble h2,
        .dialog-bubble h3,
        .dialog-bubble h4,
        .dialog-bubble h5,
        .dialog-bubble h6 {
            font-size: 1em;
            font-weight: 700;
            margin: 8px 0 4px;
        }

        .dialog-bubble--agent {
            align-self: flex-start;
            background: var(--surface-muted);
            border: 1px solid var(--card-border);
            color: var(--text-main);
        }

        .dialog-bubble--user {
            align-self: flex-end;
            background: var(--accent);
            color: var(--accent-text);
        }

        .dialog-widgets {
            margin-bottom: 12px;
        }

        .dialog-widget-group {
            margin-bottom: 8px;
        }

        .dialog-widget-label {
            font-size: 0.8rem;
            color: var(--text-muted);
            margin-bottom: 4px;
        }

        .dialog-error {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            background: rgba(220, 53, 69, 0.08);
            border: 1px solid var(--danger);
            color: var(--danger);
            border-radius: 10px;
            padding: 10px 12px;
            font-size: 0.85rem;
            margin-bottom: 12px;
        }

        .dialog-retry-btn {
            background: var(--danger);
            color: #fff;
            border: none;
            border-radius: 8px;
            padding: 6px 12px;
            font-size: 0.8rem;
            cursor: pointer;
            white-space: nowrap;
        }

        .dialog-loading {
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--text-muted);
            font-size: 0.85rem;
            margin-bottom: 12px;
        }

        .dialog-input-row {
            display: flex;
            gap: 8px;
            position: fixed;
            left: 0;
            right: 0;
            bottom: 64px; /* rests above the bottom nav bar by default; JS adjusts on focus/keyboard */
            max-width: 600px;
            margin: 0 auto;
            z-index: 250;
            background: var(--card-bg);
            padding: 8px 16px;
            box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
        }

        #tab-dialog {
            padding-bottom: 90px; /* keeps the last message clear of the fixed input bar */
        }

        .dialog-input {
            flex: 1;
            border: 1px solid var(--card-border);
            border-radius: 12px;
            padding: 10px 14px;
            font-size: 0.9rem;
        }

        .dialog-send-btn {
            background: var(--accent);
            color: var(--accent-text);
            border: none;
            border-radius: 12px;
            width: 44px;
            font-size: 1.1rem;
            cursor: pointer;
        }

        .dialog-send-btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        /* Quality Badges & Justifications System — a single horizontally
           scrollable row (like Telegram's own chip/reaction rows) instead
           of stacking one badge per line, since the full-text labels are
           wider than a phone screen fits two abreast. */
        .provider-badges-strip {
            display: flex;
            flex-wrap: nowrap;
            gap: 6px;
            margin: 10px 0;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
            padding-bottom: 2px;
        }

        .provider-badges-strip::-webkit-scrollbar {
            display: none;
        }

        .badge-item {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            font-size: 0.72rem;
            font-weight: 600;
            padding: 4px 8px;
            border-radius: 8px;
            background: #f0f3fa;
            color: #2b3a67;
            border: 1px solid #dce2f0;
            position: relative;
            flex-shrink: 0;
            white-space: nowrap;
        }

        .badge-item.badge-reliability-top {
            background: #e6f9f2;
            color: #047857;
            border-color: #a7f3d0;
        }

        .badge-item.badge-enterprise-ready {
            background: #eff6ff;
            color: #1d4ed8;
            border-color: #bfdbfe;
        }

        .badge-item.badge-exp-leader {
            background: #fef3c7;
            color: #b45309;
            border-color: #fde68a;
        }

        .badge-item.badge-trainer-accredited {
            background: #f3e8ff;
            color: #7e22ce;
            border-color: #e9d5ff;
        }

        .badge-item.badge-match-reason {
            background: #fefce8;
            color: #854d0e;
            border-color: #fef08a;
        }

        .badge-info-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: rgba(0, 0, 0, 0.08);
            font-size: 0.65rem;
            cursor: pointer;
            transition: var(--transition);
            margin-left: 2px;
        }

        .badge-info-icon:hover {
            background: rgba(0, 0, 0, 0.18);
            transform: scale(1.15);
        }

        .badge-collapsible-reasoning {
            display: none;
            background: var(--surface-muted);
            border: 1px solid var(--card-border);
            border-radius: 8px;
            padding: 10px 12px;
            margin-top: 8px;
            font-size: 0.8rem;
            color: var(--text-main);
            line-height: 1.45;
            animation: fadeIn 0.2s ease-out;
        }

        .badge-collapsible-reasoning.active {
            display: block;
        }

        .badge-reasoning-title {
            font-weight: 700;
            font-size: 0.75rem;
            color: var(--text-main);
            margin-bottom: 4px;
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .dialog-header-row {
            display: flex;
            justify-content: flex-end;
            margin-bottom: 10px;
        }

        .dialog-new-btn {
            background: transparent;
            color: var(--text-muted);
            border: 1px solid var(--card-border);
            border-radius: 10px;
            padding: 6px 12px;
            font-size: 0.8rem;
            cursor: pointer;
        }

        /* Recommendation cards (history-detail / dialog completion) — one
           unified look regardless of whether the match came from the local
           database or a web search, by design: nothing here should let the
           user tell the two sources apart. */
        .rec-card {
            background: var(--card-bg);
            border: 1px solid var(--card-border);
            border-radius: 16px;
            padding: 16px;
            margin-bottom: 14px;
            box-shadow: 0 2px 10px rgba(16, 50, 161, 0.06);
        }

        .rec-card-header {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 10px;
            cursor: pointer;
        }

        .rec-avatar {
            flex: 0 0 auto;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: linear-gradient(135deg, var(--primary), var(--accent));
            color: #fff;
            font-weight: 700;
            font-size: 0.95rem;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .rec-name {
            font-size: 1rem;
            font-weight: 600;
            color: var(--text-main);
        }

        .rec-reason {
            font-size: 0.85rem;
            color: var(--text-muted);
            line-height: 1.45;
            margin-bottom: 14px;
        }

        .rec-actions {
            display: flex;
            justify-content: flex-end;
            gap: 8px;
        }

        .rec-link {
            font-size: 0.78rem;
            font-weight: 600;
            color: var(--primary);
            border: 1px solid var(--primary);
            border-radius: 10px;
            padding: 7px 14px;
            text-decoration: none;
            background: transparent;
        }

        .rec-link-disabled {
            font-size: 0.78rem;
            font-weight: 600;
            color: var(--text-muted);
            border: 1px solid var(--card-border);
            border-radius: 10px;
            padding: 7px 14px;
            background: transparent;
            cursor: default;
        }

        .provider-clients-row {
            display: flex;
            align-items: baseline;
            flex-wrap: wrap;
            gap: 4px 6px;
            font-size: 0.78rem;
            color: var(--text-main);
            margin: 6px 0 8px 0;
            background: var(--surface-muted);
            padding: 6px 8px;
            border-radius: 6px;
            border: 1px solid var(--card-border);
        }

        .clients-label {
            font-weight: 700;
            color: var(--primary);
            flex-shrink: 0;
        }

        /* Full list wraps onto its own lines instead of clipping mid-word
           with an ellipsis — the names are the point of this row. */
        .clients-list {
            font-weight: 500;
            color: var(--text-main);
            min-width: 0;
            flex: 1;
            overflow-wrap: anywhere;
        }
