/* =========================================================
   SHELL — barra superior y vista de escritorio
   Se carga después de styles.css y styles-light-retro.css.
   Mismo lenguaje que la app: papel y tinta, tarjetas con borde fino
   y esquinas suaves, rótulos en versalitas, titulares con serifa en retro.
   Solo afecta a pantallas de más de 768 px; el móvil no cambia.
   ========================================================= */

/* === TOKENS === */
html {
    --app-bar-h: 56px;
    --chat-w: clamp(380px, 31vw, 470px);
    --sh-side-w: clamp(250px, 21vw, 320px);

    --sh-radius-sm: 6px;
    --sh-radius-md: 10px;
    --sh-radius-lg: 14px;

    /* Oscuro (por defecto) */
    --sh-bg: #05070c;
    --sh-surface: #0c111b;
    --sh-surface-2: #131a28;
    --sh-line: rgba(255, 255, 255, 0.09);
    --sh-line-strong: rgba(255, 255, 255, 0.22);
    --sh-ink: #f5f7fb;
    --sh-ink-2: #a9b2c2;
    --sh-ink-3: #717c8f;
    --sh-accent: var(--accent-color);
    --sh-on-accent: #04121f;
    --sh-globe-bg: #020617;
    --sh-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    --sh-font-display: 'Inter', system-ui, sans-serif;
    --sh-display-weight: 800;
    --sh-display-tracking: -0.02em;
}

html[data-theme="light"] {
    --sh-bg: #f4f6f9;
    --sh-surface: #ffffff;
    --sh-surface-2: #eef2f7;
    --sh-line: rgba(15, 23, 42, 0.1);
    --sh-line-strong: rgba(15, 23, 42, 0.26);
    --sh-ink: #0f172a;
    --sh-ink-2: #475569;
    --sh-ink-3: #8391a5;
    --sh-on-accent: #ffffff;
    --sh-globe-bg: #e2e8f0;
    --sh-shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
}

html[data-theme="retro"] {
    --sh-bg: #F4F0E8;
    --sh-surface: #FAF7F2;
    --sh-surface-2: #EFEAE0;
    --sh-line: rgba(26, 26, 26, 0.14);
    --sh-line-strong: #1A1A1A;
    --sh-ink: #1A1A1A;
    --sh-ink-2: #5C5C5C;
    --sh-ink-3: #8A8A8A;
    --sh-on-accent: #FAF7F2;
    --sh-globe-bg: #E8E2D6;
    --sh-shadow: 0 10px 28px rgba(26, 26, 26, 0.12);
    --sh-font-display: 'Playfair Display', Georgia, serif;
    --sh-display-weight: 900;
    --sh-display-tracking: -0.01em;
}

/* === BARRA SUPERIOR === */
.app-bar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--app-bar-h);
    z-index: 2500;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    padding: 0 16px 0 20px;
    background: color-mix(in srgb, var(--sh-surface) 90%, transparent);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    backdrop-filter: saturate(140%) blur(14px);
    border-bottom: 1px solid var(--sh-line);
    font-family: var(--font-family);
    color: var(--sh-ink);
}

html[data-theme="retro"] .app-bar {
    border-bottom-color: var(--sh-ink);
}

body.is-offline .app-bar {
    visibility: hidden;
}

.app-bar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

/* Prisma: un triángulo con el color de marca. */
.app-bar-mark {
    width: 16px;
    height: 14px;
    flex-shrink: 0;
    background: var(--sh-accent);
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.app-bar-wordmark {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: 1.05rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    line-height: 1;
}

/* Pestañas de panel */
.app-bar-tabs {
    display: flex;
    align-items: stretch;
    gap: 4px;
    height: var(--app-bar-h);
}

html:not([data-view-mode="desktop"]) .app-bar-tabs {
    visibility: hidden;
}

.app-bar-tab {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: none;
    background: none;
    color: var(--sh-ink-3);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color 0.15s ease;
}

.app-bar-tab svg {
    width: 16px;
    height: 16px;
}

.app-bar-tab::after {
    content: '';
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: -1px;
    height: 3px;
    background: var(--sh-accent);
    transform: scaleX(0);
    transition: transform 0.2s ease;
}

.app-bar-tab:hover {
    color: var(--sh-ink);
}

.app-bar-tab.active {
    color: var(--sh-accent);
}

.app-bar-tab.active::after {
    transform: scaleX(1);
}

/* Acciones */
.app-bar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.app-bar .corpus-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-bar .corpus-btn {
    height: 30px;
    padding: 0 14px;
    border: 1.5px solid var(--sh-line-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--sh-ink-2);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.app-bar .corpus-btn:hover {
    color: var(--sh-ink);
    border-color: var(--sh-ink);
}

.app-bar .corpus-btn.active {
    background: var(--sh-accent);
    border-color: var(--sh-accent);
    color: var(--sh-on-accent);
}

/* Selector de vista: control segmentado */
.view-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border-radius: var(--sh-radius-md);
    background: var(--sh-surface-2);
    border: 1px solid var(--sh-line);
}

.app-bar .mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 30px;
    min-width: 34px;
    padding: 0 8px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--sh-ink-3);
    font: inherit;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-bar .mode-btn[hidden] {
    display: none;
}

.app-bar .mode-btn svg {
    width: 17px;
    height: 17px;
}

.app-bar .mode-btn:hover {
    color: var(--sh-ink);
}

.view-switch .mode-btn.active {
    background: var(--sh-ink);
    color: var(--sh-bg);
}

.app-bar .theme-btn {
    border: 1px solid var(--sh-line);
    border-radius: var(--sh-radius-md);
    padding: 0 10px;
    color: var(--sh-ink-2);
}

.app-bar .theme-btn:hover {
    border-color: var(--sh-line-strong);
}

.theme-icon,
.theme-label {
    display: none;
}

html[data-theme="dark"] .theme-icon[data-theme-icon="dark"],
html[data-theme="light"] .theme-icon[data-theme-icon="light"],
html[data-theme="retro"] .theme-icon[data-theme-icon="retro"] {
    display: block;
}

html[data-theme="dark"] .theme-label[data-theme-slot="dark"],
html[data-theme="light"] .theme-label[data-theme-slot="light"],
html[data-theme="retro"] .theme-label[data-theme-slot="retro"] {
    display: inline;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Progreso de la precarga del día: una línea bajo la barra. */
.preload-bar {
    position: fixed;
    top: calc(var(--app-bar-h) - 1px);
    left: 0;
    right: 0;
    height: 2px;
    z-index: 2501;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.preload-bar-fill {
    height: 100%;
    width: 0;
    background: var(--sh-accent);
    transition: width 0.3s ease;
}

.preload-bar.is-done {
    opacity: 0;
}

.preload-bar.is-error {
    pointer-events: auto;
}

.preload-bar.is-error .preload-bar-fill {
    background: #f59e0b;
}

@media (max-width: 1100px) {
    .app-bar-tab span,
    .theme-label {
        display: none !important;
    }
}

/* En móvil el feed ocupa toda la pantalla y no hay barra. */
@media (max-width: 768px) {
    .app-bar,
    .preload-bar {
        display: none !important;
    }
}

/* =========================================================
   A partir de aquí, solo pantallas con barra superior.
   ========================================================= */
@media (min-width: 769px) {

    /* === HUECO DE LA BARRA === */
    html body #prismaSection,
    html body #prismaSection.desktop-mode {
        top: var(--app-bar-h) !important;
        height: calc(100vh - var(--app-bar-h)) !important;
    }

    html body #prismaSection.desktop-mode {
        padding: 0 !important;
        background: var(--sh-bg) !important;
    }

    html[data-view-mode="globe"] .left-panel {
        top: calc(var(--app-bar-h) + 16px);
        max-height: calc(100vh - var(--app-bar-h) - 32px);
    }

    .news-reader-panel {
        top: calc(var(--app-bar-h) + 16px);
        max-height: calc(100vh - var(--app-bar-h) - 32px);
    }


    /* Barras de scroll finas y sin flechas en las columnas. */
    #prismaSection.desktop-mode ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    #prismaSection.desktop-mode ::-webkit-scrollbar-track {
        background: transparent;
    }

    #prismaSection.desktop-mode ::-webkit-scrollbar-thumb {
        background: var(--sh-line);
        border-radius: 4px;
    }

    #prismaSection.desktop-mode ::-webkit-scrollbar-thumb:hover {
        background: var(--sh-ink-3);
    }

    @supports not selector(::-webkit-scrollbar) {
        #prismaSection.desktop-mode * {
            scrollbar-width: thin;
            scrollbar-color: var(--sh-line-strong) transparent;
        }
    }

    /* === ESCRITORIO: TRES COLUMNAS === */
    #prismaSection.desktop-mode .prisma-desktop-layout {
        background: var(--sh-bg) !important;
        box-shadow: none;
        perspective: none;
        font-family: var(--font-family);
    }

    #prismaSection.desktop-mode .desktop-panel {
        flex: 0 0 var(--sh-side-w);
        min-width: 0;
        min-height: 0;
        height: 100%;
        background: var(--sh-bg) !important;
        border-right: 1px solid var(--sh-line);
        box-shadow: none !important;
        filter: none !important;
        opacity: 1 !important;
        transform: none !important;
        cursor: default;
        transition: flex-grow 0.35s ease, flex-basis 0.35s ease;
    }

    #prismaSection.desktop-mode .desktop-panel.focused {
        flex: 1 1 0;
    }

    /* Orden fijo: el mismo que las pestañas de la barra. */
    #prismaSection.desktop-mode .panel-comparison { order: 1 !important; }
    #prismaSection.desktop-mode .panel-events { order: 2 !important; }
    #prismaSection.desktop-mode .panel-timeline { order: 3 !important; border-right: none; }

    #prismaSection.desktop-mode .desktop-panel > * {
        transition: none;
    }

    #prismaSection.desktop-mode .desktop-nav {
        display: none;
    }

    /* --- Cabecera de panel --- */
    #prismaSection.desktop-mode .desktop-panel .face-header-fixed {
        position: relative;
        padding: 18px 24px 16px !important;
        text-align: left;
        background: transparent !important;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border-bottom: 1px solid var(--sh-line) !important;
        box-shadow: none !important;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .face-header-fixed {
        padding: 18px 20px 16px !important;
        cursor: pointer;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .face-header-fixed:hover {
        background: var(--sh-surface) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .face-header-fixed::before {
        display: none;
    }

    #prismaSection.desktop-mode .desktop-panel .face-tag {
        display: block !important;
        margin: 0 0 10px;
        font-size: 0.66rem;
        font-weight: 700;
        letter-spacing: 0.2em;
        color: var(--sh-accent) !important;
        opacity: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #prismaSection.desktop-mode .desktop-panel .face-tag.face-tag-directo {
        color: #b7791f !important;
    }

    #prismaSection.desktop-mode .desktop-panel .face-tag::after {
        content: '';
        display: block;
        width: 28px;
        height: 2px;
        margin-top: 7px;
        background: currentColor;
    }

    #prismaSection.desktop-mode .desktop-panel .face-header-row {
        align-items: flex-start;
        margin-bottom: 0;
    }

    #prismaSection.desktop-mode .desktop-panel .face-header-fixed h2 {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
        white-space: normal;
        font-family: var(--sh-font-display);
        font-weight: var(--sh-display-weight);
        font-size: 1.5rem;
        line-height: 1.16;
        letter-spacing: var(--sh-display-tracking);
        text-transform: none;
        text-shadow: none;
        color: var(--sh-ink);
        opacity: 1;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .face-header-fixed h2 {
        font-size: 1.02rem;
        line-height: 1.22;
    }

    #prismaSection.desktop-mode .desktop-panel .face-subtitle {
        margin-top: 6px;
        font-size: 0.74rem;
        font-weight: 500;
        letter-spacing: 0.04em;
        color: var(--sh-ink-3);
    }

    /* En Eventos el titular ya se lee en la tarjeta activa. */
    #prismaSection.desktop-mode .panel-events .face-header-fixed h2,
    #prismaSection.desktop-mode .panel-events .face-header-fixed .face-subtitle {
        display: none;
    }

    #prismaSection.desktop-mode .panel-events .face-header-fixed .face-tag {
        margin-bottom: 0;
    }

    #prismaSection.desktop-mode .panel-events .face-header-row {
        align-items: center;
        min-height: 30px;
    }

    /* Editorial | Directo */
    #prismaSection.desktop-mode .feed-mode-toggle {
        gap: 2px;
        padding: 3px;
        border-radius: 999px;
        border: 1px solid var(--sh-line);
        background: var(--sh-surface-2);
    }

    #prismaSection.desktop-mode .feed-mode-btn {
        padding: 5px 12px;
        border: none;
        border-radius: 999px !important;
        background: transparent;
        color: var(--sh-ink-3);
        font-size: 0.62rem;
        font-weight: 800;
        letter-spacing: 0.1em;
    }

    #prismaSection.desktop-mode .feed-mode-btn:hover {
        color: var(--sh-ink);
        background: transparent;
    }

    #prismaSection.desktop-mode .feed-mode-btn.active[data-feed-mode="editorial"] {
        background: var(--sh-ink);
        color: var(--sh-bg);
    }

    #prismaSection.desktop-mode .feed-mode-btn.active[data-feed-mode="liveblog"] {
        background: #b7791f;
        color: #fff;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .feed-mode-toggle {
        display: none;
    }

    /* --- Barra de filtro AletheIA --- */
    #prismaSection.desktop-mode .aletheia-filter-bar-wrap {
        padding: 12px 20px 0;
    }

    #prismaSection.desktop-mode .aletheia-filter-pill {
        min-height: 40px;
        gap: 10px;
        padding: 6px 14px;
        border: 1.5px solid var(--sh-line-strong);
        border-radius: var(--sh-radius-md);
        background: var(--sh-surface);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        color: var(--sh-ink-3);
        font-size: 0.82rem;
        font-weight: 500;
    }

    #prismaSection.desktop-mode .aletheia-filter-pill:hover,
    #prismaSection.desktop-mode .aletheia-filter-pill.open {
        border-color: var(--sh-accent);
        color: var(--sh-ink);
    }

    #prismaSection.desktop-mode .aletheia-filter-pill .aletheia-pill-icon {
        width: 16px;
        height: 16px;
    }

    #prismaSection.desktop-mode .aletheia-filter-popover {
        left: 20px;
        right: 20px;
        border: 1px solid var(--sh-line-strong);
        border-radius: var(--sh-radius-lg);
        background: var(--sh-surface);
        box-shadow: var(--sh-shadow);
    }

    /* --- Panel de eventos: feed a la izquierda, globo a la derecha --- */
    #prismaSection.desktop-mode .desktop-panel.panel-events.focused {
        grid-template-columns: clamp(340px, 46%, 500px) minmax(0, 1fr);
        grid-template-rows: auto auto minmax(0, 1fr);
        grid-template-areas:
            "header header"
            "filter globe"
            "text globe";
    }

    #prismaSection.desktop-mode .panel-events.focused .aletheia-filter-bar-wrap {
        grid-area: filter;
    }

    #prismaSection.desktop-mode .desktop-panel .events-scroll-container {
        padding: 14px 20px 0 !important;
        margin: 0;
        background: transparent !important;
        border-right: none;
        box-shadow: none;
        opacity: 1 !important;
        filter: none !important;
        transform: none !important;
        -webkit-mask-image: none;
        mask-image: none;
        scroll-behavior: auto;
    }

    /* Hueco final: la última tarjeta llega a la línea de lectura. */
    #prismaSection.desktop-mode .desktop-panel .events-scroll-container::after {
        content: '';
        display: block;
        height: 70vh;
    }

    #prismaSection.desktop-mode .desktop-panel .mini-globe-wrapper,
    #prismaSection.desktop-mode #desktopMiniGlobeContainer {
        border-radius: 0;
        background: var(--sh-globe-bg) !important;
        transform: none !important;
    }

    #prismaSection.desktop-mode .panel-events.focused .mini-globe-wrapper,
    #prismaSection.desktop-mode .panel-events.focused #desktopMiniGlobeContainer {
        min-height: 0 !important;
        border-left: 1px solid var(--sh-line);
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .mini-globe-wrapper,
    #prismaSection.desktop-mode .desktop-panel:not(.focused) #desktopMiniGlobeContainer {
        flex-shrink: 0;
        height: 210px !important;
        min-height: 210px !important;
        border-bottom: 1px solid var(--sh-line);
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) #desktopMiniGlobe {
        min-height: 0 !important;
    }

    /* --- Tarjeta de evento --- */
    #prismaSection.desktop-mode .desktop-panel .event-card {
        display: flex;
        flex-direction: column;
        min-height: 0;
        margin: 0 0 14px !important;
        padding: 0 !important;
        overflow: hidden;
        background: var(--sh-surface) !important;
        border: 1px solid var(--sh-line) !important;
        border-radius: var(--sh-radius-lg) !important;
        box-shadow: none;
        opacity: 1 !important;
        transform: none !important;
        cursor: pointer;
        scroll-margin-top: 14px;
        transition: border-color 0.2s ease, box-shadow 0.2s ease;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card::before {
        display: none;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card:hover {
        border-color: var(--sh-line-strong) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card.active {
        padding: 0 !important;
        border-color: var(--sh-accent) !important;
        box-shadow: 0 0 0 1px var(--sh-accent), var(--sh-shadow);
    }

    #prismaSection.desktop-mode .desktop-panel .event-card-preview-img {
        margin: 0;
        border: none;
        border-radius: 0 !important;
        background: var(--sh-surface-2);
    }

    #prismaSection.desktop-mode .desktop-panel .event-card-content {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 16px 18px 14px;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card h3,
    #prismaSection.desktop-mode .desktop-panel .event-card h3 .event-card-title-btn {
        max-width: none;
        margin: 0;
        font-family: var(--sh-font-display) !important;
        font-weight: var(--sh-display-weight) !important;
        font-size: 1.18rem !important;
        line-height: 1.2 !important;
        letter-spacing: var(--sh-display-tracking) !important;
        color: var(--sh-ink) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card h3::before {
        display: none;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card h3 .event-card-title-btn:hover {
        color: var(--sh-accent) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card p {
        max-width: none;
        margin-top: 10px;
        font-size: 0.86rem;
        line-height: 1.55;
        text-align: left;
        hyphens: manual;
        color: var(--sh-ink-2);
    }

    #prismaSection.desktop-mode .desktop-panel .read-more-inline-btn {
        margin-left: 4px;
        padding: 0;
        border-bottom: none;
        font-family: var(--font-family);
        font-size: 0.68rem;
        font-weight: 800;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--sh-accent);
    }

    #prismaSection.desktop-mode .desktop-panel .read-more-inline-btn:hover {
        text-decoration: underline !important;
        text-underline-offset: 3px;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card-logos {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 8px 12px;
        margin-top: 14px;
        padding-top: 12px;
        border-top: 1px solid var(--sh-line);
    }

    #prismaSection.desktop-mode .desktop-panel .event-card-logos:empty {
        display: none;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card-logo {
        height: 16px;
        width: auto;
        max-width: 78px;
        object-fit: contain;
    }

    #prismaSection.desktop-mode .desktop-panel .event-card .event-date {
        margin-top: 12px;
        padding: 0;
        border: none;
        background: none;
        font-size: 0.66rem;
        font-weight: 700;
        letter-spacing: 0.12em;
        color: var(--sh-ink-3);
    }

    /* Columna estrecha: tipografía un punto menor. */
    #prismaSection.desktop-mode .desktop-panel:not(.focused) .events-scroll-container {
        padding: 12px 14px 0 !important;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .event-card h3,
    #prismaSection.desktop-mode .desktop-panel:not(.focused) .event-card h3 .event-card-title-btn {
        font-size: 1rem !important;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .event-card-content {
        padding: 12px 14px;
    }

    /* --- Timeline --- */
    #prismaSection.desktop-mode .desktop-panel .vertical-timeline {
        margin: 0;
        padding: 18px 20px 40px 26px;
        border-left: none;
        opacity: 1;
    }

    #prismaSection.desktop-mode .desktop-panel.focused .vertical-timeline {
        padding-left: max(26px, calc((100% - 760px) / 2));
        padding-right: max(20px, calc((100% - 760px) / 2));
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node {
        display: block;
        margin: 0;
        padding: 0 0 12px 22px;
        background: transparent !important;
        border: none !important;
        border-left: 2px solid var(--sh-line) !important;
        cursor: pointer;
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node::before {
        left: -7px;
        top: 16px;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        border: 2px solid var(--sh-ink-3);
        background: var(--sh-bg);
        box-shadow: none;
        transform: none;
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node:hover::before,
    #prismaSection.desktop-mode .desktop-panel .timeline-node.active::before {
        border-color: var(--sh-accent);
        background: var(--sh-accent);
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node.active::before {
        box-shadow: 0 0 0 4px var(--accent-subtle);
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node-content {
        gap: 6px;
        padding: 12px 14px;
        background: var(--sh-surface) !important;
        border: 1px solid var(--sh-line) !important;
        border-radius: var(--sh-radius-md);
        box-shadow: none !important;
        transition: border-color 0.2s ease;
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node:hover .timeline-node-content {
        border-color: var(--sh-line-strong) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node.active .timeline-node-content {
        border-color: var(--sh-accent) !important;
        box-shadow: 0 0 0 1px var(--sh-accent) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node h4 {
        font-family: var(--sh-font-display) !important;
        font-weight: 700 !important;
        font-size: 0.98rem;
        line-height: 1.28 !important;
        letter-spacing: 0;
        color: var(--sh-ink) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node span {
        font-size: 0.64rem;
        font-weight: 700;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--sh-ink-3) !important;
        opacity: 1 !important;
    }

    #prismaSection.desktop-mode .desktop-panel .timeline-node .timeline-node-time {
        align-self: flex-start;
        color: var(--sh-accent) !important;
    }

    /* --- Comparativa --- */
    #prismaSection.desktop-mode .face-header-fixed .comparison-tabs {
        display: flex;
        gap: 2px;
        margin-top: 14px;
        padding: 3px;
        border: 1px solid var(--sh-line) !important;
        border-radius: var(--sh-radius-md) !important;
        background: var(--sh-surface-2) !important;
        overflow-x: auto;
        scrollbar-width: none;
    }

    #prismaSection.desktop-mode .comp-tab {
        flex: 1 0 auto;
        justify-content: center;
        padding: 8px 12px;
        border: none;
        border-radius: 7px;
        font-size: 0.66rem;
        font-weight: 700;
        letter-spacing: 0.1em;
        text-transform: uppercase;
        color: var(--sh-ink-2) !important;
    }

    #prismaSection.desktop-mode .comp-tab:hover {
        background: transparent !important;
        color: var(--sh-ink) !important;
    }

    #prismaSection.desktop-mode .comp-tab.active {
        background: var(--sh-ink) !important;
        color: var(--sh-bg) !important;
    }

    #prismaSection.desktop-mode .comp-tab.active svg {
        color: var(--sh-bg) !important;
        stroke: var(--sh-bg) !important;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comp-tab {
        flex: 1 1 auto;
        padding: 7px 4px;
        font-size: 0.58rem;
        letter-spacing: 0.02em;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comp-tab svg {
        display: none;
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-columns {
        margin-top: 12px;
        border-top: 1px solid var(--sh-line);
        opacity: 1 !important;
        filter: none !important;
    }

    /* Enfocada: una columna por medio, con ancho de lectura y scroll lateral. */
    #prismaSection.desktop-mode .desktop-panel.focused .comparison-cols-row {
        overflow-x: auto;
        overflow-y: hidden;
    }

    #prismaSection.desktop-mode .desktop-panel.focused .comparison-col {
        flex: 1 0 300px;
        max-width: 460px;
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col {
        background: transparent !important;
        border-right: 1px solid var(--sh-line);
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .col-header {
        display: flex;
        align-items: center;
        min-height: 54px;
        padding: 10px 16px;
        background: var(--sh-surface);
        border-bottom: 1px solid var(--sh-line);
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .col-header img {
        height: 24px !important;
        max-width: 150px;
        object-fit: contain;
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .col-articles {
        padding: 14px;
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .prisma-article {
        margin-bottom: 12px;
        padding: 14px;
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md) !important;
        box-shadow: none;
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .prisma-article:hover {
        border-color: var(--sh-line-strong);
        transform: none;
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .comp-article-img {
        border-radius: var(--sh-radius-sm) !important;
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .prisma-article h4 {
        font-family: var(--sh-font-display);
        font-weight: 700;
        font-size: 0.98rem;
        line-height: 1.26;
        color: var(--sh-ink);
    }

    #prismaSection.desktop-mode .desktop-panel .comparison-col .prisma-article p {
        font-size: 0.8rem;
        line-height: 1.5;
        text-align: left;
        color: var(--sh-ink-2);
    }

    /* Estrecha: un medio debajo de otro, en una sola lista. */
    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comparison-cols-row {
        display: block;
        overflow-y: auto;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comparison-col {
        display: block;
        overflow: visible;
        border-right: none;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comparison-col .col-header {
        position: sticky;
        top: 0;
        z-index: 2;
        min-height: 44px;
        border-top: 1px solid var(--sh-line);
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comparison-col:first-child .col-header {
        border-top: none;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comparison-col .col-header img {
        height: 20px !important;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comparison-col .col-articles {
        overflow: visible;
        padding: 12px 14px 4px;
    }

    /* El desglose lingüístico se lee al enfocar; aquí bastan las notas. */
    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comparison-col .ling-card {
        display: none;
    }

    /* === VISTA GLOBO === */
    html[data-view-mode="globe"] .left-panel {
        left: 16px;
        gap: 16px;
        padding: 16px;
        background: color-mix(in srgb, var(--sh-surface) 94%, transparent);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-lg);
        box-shadow: var(--sh-shadow);
    }

    /* La marca ya está en la barra superior. */
    html[data-view-mode="globe"] .left-panel > .header {
        display: none;
    }

    html[data-view-mode="globe"] .left-panel .aletheia-filter-bar-globe {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        width: 100%;
        padding: 0;
    }

    html[data-view-mode="globe"] .left-panel .aletheia-filter-pill {
        min-height: 38px;
        padding: 6px 12px;
        border: 1.5px solid var(--sh-line-strong);
        border-radius: var(--sh-radius-md);
        background: var(--sh-surface);
        font-size: 0.78rem;
        font-weight: 500;
    }

    html[data-view-mode="globe"] .left-panel .aletheia-filter-popover {
        left: 0;
        right: 0;
    }

    /* El globo ocupa lo que queda bajo la barra. */
    #mainGlobeContainer {
        top: var(--app-bar-h);
        height: calc(100vh - var(--app-bar-h));
    }

    #globeViz {
        min-height: 0;
    }

    /* Calendario: el número del día y, debajo, cuántas noticias tiene. */
    html[data-view-mode="globe"] .left-panel .calendar-container {
        margin: 0;
        padding: 12px;
        background: var(--sh-surface-2);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
    }

    html[data-view-mode="globe"] .left-panel .calendar-header {
        font-family: var(--sh-font-display);
        font-weight: 700;
        font-size: 0.95rem;
        color: var(--sh-ink);
    }

    html[data-view-mode="globe"] .left-panel .weekdays-grid {
        gap: 3px;
        font-size: 0.6rem;
        font-weight: 700;
        letter-spacing: 0.1em;
        color: var(--sh-ink-3);
    }

    html[data-view-mode="globe"] .left-panel .calendar-grid {
        gap: 3px;
    }

    html[data-view-mode="globe"] .left-panel .calendar-day {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 38px;
        padding: 4px 0;
        border-radius: 8px;
        font-size: 0.82rem;
        font-variant-numeric: tabular-nums;
        line-height: 1;
        color: var(--sh-ink-3);
    }

    html[data-view-mode="globe"] .left-panel .calendar-day.has-news {
        font-weight: 600;
        color: var(--sh-ink);
    }

    html[data-view-mode="globe"] .left-panel .calendar-day:hover {
        background: var(--sh-surface);
    }

    html[data-view-mode="globe"] .left-panel .calendar-day.active {
        background: var(--sh-accent);
        color: var(--sh-on-accent);
        box-shadow: none;
    }

    html[data-view-mode="globe"] .left-panel .article-count {
        position: static;
        padding: 0;
        background: none;
        box-shadow: none;
        font-size: 0.52rem;
        font-weight: 600;
        color: var(--sh-ink-3);
    }

    html[data-view-mode="globe"] .left-panel .calendar-day.active .article-count {
        background: none;
        color: var(--sh-on-accent);
        opacity: 0.85;
    }

    html[data-view-mode="globe"] .left-panel .topic-select label {
        margin-bottom: 6px;
        font-size: 0.62rem;
        font-weight: 700;
        letter-spacing: 0.16em;
        color: var(--sh-ink-3);
    }

    html[data-view-mode="globe"] .left-panel .topic-select select {
        padding: 9px 10px;
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
        font-size: 0.85rem;
        color: var(--sh-ink);
    }

    /* === CHAT: panel acoplado a la derecha ===
       En escritorio el chat deja de ser una ventana flotante: es un panel
       fijo bajo la barra. Se abre desde el botón «Asistente» de la barra y
       las conversaciones se cambian con las pestañas numeradas de su
       cabecera. La posición que el JS escribe en línea (top/left del
       arrastre) queda anulada aquí. */
    .chatbot-container {
        position: static;
    }

    .chatbot-container .chatbot-toggle,
    .bubbles-dock {
        display: none !important;
    }

    .chatbot-window {
        top: calc(var(--app-bar-h) + 10px) !important;
        right: 10px !important;
        bottom: 10px !important;
        left: auto !important;
        width: var(--chat-w) !important;
        height: auto !important;
        min-width: 0;
        min-height: 0;
        max-width: none;
        max-height: none;
        resize: none;
        background: var(--sh-surface);
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        border: 1px solid var(--sh-line-strong);
        border-radius: var(--sh-radius-lg);
        box-shadow: var(--sh-shadow);
        overflow: hidden;
        color: var(--sh-ink);
        transform: translateX(14px);
        transition: opacity 0.18s ease, transform 0.18s ease;
    }

    .chatbot-window.open {
        transform: none;
    }

    /* Cabecera */
    .chatbot-window .chat-header {
        flex: 0 0 auto;
        height: 52px;
        padding: 0 8px 0 16px;
        gap: 10px;
        background: var(--sh-surface);
        border-bottom: 1px solid var(--sh-line);
        cursor: default;
    }

    .chatbot-window .chat-title {
        gap: 8px;
        flex: 0 0 auto;
    }

    .chatbot-window .chat-title svg,
    .chatbot-window .chat-title i {
        display: none;
    }

    .chatbot-window .chat-title::before {
        content: "";
        width: 13px;
        height: 12px;
        background: var(--sh-accent);
        clip-path: polygon(50% 0, 100% 100%, 0 100%);
    }

    .chatbot-window .chat-title span {
        font-family: var(--sh-font-display);
        font-weight: var(--sh-display-weight);
        font-size: 1rem;
        letter-spacing: 0.01em;
        color: var(--sh-ink);
    }

    .chat-conv-tabs {
        display: flex;
        align-items: center;
        gap: 4px;
        flex: 1 1 auto;
        min-width: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .chat-conv-tabs::-webkit-scrollbar {
        display: none;
    }

    .chat-conv-tab {
        position: relative;
        flex: 0 0 auto;
        width: 26px;
        height: 26px;
        padding: 0;
        border: 1px solid var(--sh-line);
        border-radius: 8px;
        background: transparent;
        color: var(--sh-ink-2);
        font-family: inherit;
        font-size: 0.74rem;
        font-weight: 700;
        cursor: pointer;
        transition: background 0.15s, color 0.15s, border-color 0.15s;
    }

    .chat-conv-tab:hover {
        border-color: var(--sh-ink-3);
        color: var(--sh-ink);
    }

    .chat-conv-tab.active {
        background: var(--sh-ink);
        border-color: var(--sh-ink);
        color: var(--sh-bg);
        cursor: default;
    }

    .chat-conv-new {
        border-style: dashed;
        font-size: 0.95rem;
        font-weight: 500;
        line-height: 1;
    }

    .chat-conv-tab.is-processing::after,
    .chat-conv-tab.has-unread::after {
        content: "";
        position: absolute;
        top: -3px;
        right: -3px;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--sh-accent);
        border: 2px solid var(--sh-surface);
    }

    .chat-conv-tab.is-processing::after {
        animation: shChatPulse 1.1s ease-in-out infinite;
    }

    .chatbot-window .header-actions {
        gap: 2px;
        flex: 0 0 auto;
    }

    .chatbot-window .header-icon-btn {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        color: var(--sh-ink-2);
    }

    .chatbot-window .header-icon-btn svg {
        width: 16px;
        height: 16px;
    }

    .chatbot-window .header-icon-btn:hover,
    .chatbot-window .header-icon-btn:active {
        background: var(--sh-surface-2);
        color: var(--sh-ink);
    }

    .chatbot-window .expediente-btn[aria-pressed="true"] {
        background: color-mix(in srgb, var(--sh-accent) 12%, transparent);
        color: var(--sh-accent);
    }

    /* Mensajes: el usuario en una píldora a la derecha; la respuesta, como
       texto de lectura a todo el ancho, sin burbuja. */
    .chatbot-window .chat-messages {
        padding: 18px 18px 10px;
        gap: 18px;
        scrollbar-width: thin;
        scrollbar-color: var(--sh-line) transparent;
    }

    .chatbot-window .message {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .chatbot-window .message.user {
        max-width: 86%;
        padding: 9px 13px;
        background: var(--sh-surface-2);
        border: 1px solid var(--sh-line);
        border-radius: 14px 14px 4px 14px;
        color: var(--sh-ink);
    }

    .chatbot-window .message.user p {
        margin: 0;
        overflow-wrap: anywhere;
    }

    .chatbot-window .message.bot {
        align-self: stretch;
        max-width: 100%;
        padding: 0;
        background: transparent;
        border-radius: 0;
        color: var(--sh-ink);
        overflow-wrap: anywhere;
    }

    .chatbot-window .message-body > p {
        margin: 0;
    }

    .chatbot-window .chat-messages strong {
        color: var(--sh-ink);
        font-weight: 700;
    }

    .chatbot-window .chat-messages em {
        color: var(--sh-ink-2);
        opacity: 1;
    }

    .chatbot-window .chat-messages h1,
    .chatbot-window .chat-messages h2,
    .chatbot-window .chat-messages h3 {
        margin: 14px 0 6px;
        padding: 0;
        border: none;
        font-family: var(--sh-font-display);
        font-weight: var(--sh-display-weight);
        letter-spacing: var(--sh-display-tracking);
        line-height: 1.25;
        color: var(--sh-ink);
    }

    .chatbot-window .chat-messages h1,
    .chatbot-window .chat-messages h2 {
        font-size: 1.08rem;
    }

    .chatbot-window .chat-messages h3 {
        font-size: 0.96rem;
    }

    .chatbot-window .chat-messages hr {
        height: 1px;
        margin: 12px 0;
        border: none;
        background: var(--sh-line);
    }

    .chatbot-window .chat-list-item {
        padding-left: 16px;
        margin-bottom: 5px;
        line-height: 1.55;
    }

    .chatbot-window .chat-list-item::before {
        color: var(--sh-accent);
    }

    .chatbot-window .chat-messages a,
    .chatbot-window .chat-messages a.chat-hecho-link {
        color: var(--sh-ink);
        font-weight: 600;
        text-decoration: underline;
        text-decoration-color: var(--sh-accent);
        text-decoration-thickness: 1.5px;
        text-underline-offset: 3px;
    }

    .chatbot-window .chat-messages a:hover,
    .chatbot-window .chat-messages a.chat-hecho-link:hover {
        color: var(--sh-accent);
    }

    .chatbot-window .chat-messages a[target="_blank"]::after {
        content: "\2197";
        margin-left: 2px;
        font-size: 0.8em;
        color: var(--sh-ink-3);
    }

    .chatbot-window .chat-table-wrap {
        margin: 10px 0;
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
    }

    .chatbot-window .chat-table {
        font-size: 0.8rem;
    }

    .chatbot-window .chat-table th,
    .chatbot-window .chat-table td {
        padding: 7px 10px;
        border-bottom: 1px solid var(--sh-line);
    }

    .chatbot-window .chat-table th {
        background: var(--sh-surface-2);
        border-bottom-width: 1px;
        color: var(--sh-ink-2);
        font-size: 0.68rem;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    /* Tarjeta de progreso y traza plegable */
    .chatbot-window .processing-box,
    .chatbot-window .chat-processing-card {
        margin: 0;
        padding: 12px;
        background: var(--sh-surface-2);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
        color: var(--sh-ink);
    }

    .chatbot-window .chat-processing-header {
        margin-bottom: 9px;
        padding-bottom: 0;
        border-bottom: none;
    }

    .chatbot-window .chat-processing-title {
        color: var(--sh-ink);
        letter-spacing: 0.08em;
    }

    .chatbot-window .chat-processing-badge,
    .chatbot-window .trace-badge {
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        color: var(--sh-ink-2);
    }

    .chatbot-window .chat-processing-spinner,
    .chatbot-window .step-indicator-active {
        border-color: var(--sh-line-strong);
        border-top-color: var(--sh-accent);
    }

    .chatbot-window .step-indicator,
    .chatbot-window .trace-item-check {
        color: var(--sh-accent);
    }

    .chatbot-window .chat-processing-step.is-done,
    .chatbot-window .chat-processing-trace-item,
    .chatbot-window .chat-processing-trace-summary {
        color: var(--sh-ink-2);
    }

    .chatbot-window .chat-processing-step.is-active {
        color: var(--sh-ink);
    }

    .chatbot-window .chat-processing-trace {
        margin-bottom: 10px;
        padding: 6px 10px;
        background: transparent;
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-sm);
    }

    .chatbot-window .chat-processing-trace-list {
        border-top-color: var(--sh-line);
    }

    /* Botones de acción, gráficas y hechos adjuntos */
    .chatbot-window .chat-action-bar {
        margin-top: 12px;
    }

    .chatbot-window .chat-action-btn {
        padding: 7px 12px;
        background: var(--sh-surface);
        border: 1px solid var(--sh-line-strong);
        border-radius: 999px;
        color: var(--sh-ink);
        font-size: 0.78rem;
        font-weight: 600;
    }

    .chatbot-window .chat-action-btn:hover {
        background: var(--sh-surface);
        border-color: var(--sh-accent);
        color: var(--sh-accent);
    }

    .chatbot-window .chat-action-btn.applied {
        background: color-mix(in srgb, var(--sh-accent) 10%, transparent);
        border-color: color-mix(in srgb, var(--sh-accent) 40%, transparent);
        color: var(--sh-accent);
    }

    .chatbot-window .chat-chart {
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
    }

    .chatbot-window .chat-attached-hechos {
        margin: 0 14px 8px;
        padding: 0;
        background: transparent;
        border: none;
    }

    .chatbot-window .chat-attached-label {
        color: var(--sh-ink-3);
    }

    .chatbot-window .chat-attached-chip {
        background: var(--sh-surface-2);
        border: 1px solid var(--sh-line);
        border-radius: 999px;
        color: var(--sh-ink);
    }

    /* Preguntas de arranque */
    .chat-suggestions {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .chat-suggestion {
        padding: 10px 12px;
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
        color: var(--sh-ink);
        font-family: inherit;
        font-size: 0.84rem;
        line-height: 1.35;
        text-align: left;
        cursor: pointer;
        transition: border-color 0.15s, background 0.15s;
    }

    .chat-suggestion:hover {
        background: var(--sh-surface-2);
        border-color: var(--sh-ink-3);
    }

    /* Campo de texto */
    .chatbot-window .chat-input-area {
        flex: 0 0 auto;
        align-items: flex-end;
        gap: 8px;
        margin: 4px 14px 0;
        padding: 5px 5px 5px 14px;
        background: var(--sh-surface);
        border: 1px solid var(--sh-line-strong);
        border-radius: 14px;
        transition: border-color 0.15s;
    }

    .chatbot-window .chat-input-area:focus-within {
        border-color: var(--sh-ink);
    }

    .chatbot-window .chat-input-area .chat-input {
        min-height: 34px;
        max-height: 140px;
        padding: 7px 0;
        background: transparent;
        border: none;
        border-radius: 0;
        color: var(--sh-ink);
        font-size: 0.9rem;
        line-height: 1.45;
    }

    .chatbot-window .chat-input-area .chat-input::placeholder {
        color: var(--sh-ink-3);
    }

    .chatbot-window .chat-input-area .chat-send {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: 34px;
        height: 34px;
        padding: 0;
        background: var(--sh-ink);
        border-radius: 10px;
        color: var(--sh-bg);
        transition: background 0.15s, opacity 0.15s;
    }

    .chatbot-window .chat-input-area .chat-send svg {
        width: 16px;
        height: 16px;
    }

    .chatbot-window .chat-input-area .chat-send:hover {
        background: var(--sh-accent);
        color: var(--sh-on-accent);
    }

    .chatbot-window .chat-input-area .chat-send:disabled {
        opacity: 0.35;
        cursor: default;
    }

    .chat-input-hint {
        flex: 0 0 auto;
        margin: 6px 16px 10px;
        color: var(--sh-ink-3);
        font-size: 0.66rem;
        text-align: right;
    }

    /* Expediente */
    .chatbot-window .chat-expediente {
        background: var(--sh-surface);
        color: var(--sh-ink);
    }

    .chatbot-window .chat-expediente .exp-head {
        border-bottom: 1px solid var(--sh-line);
    }

    .chatbot-window .chat-expediente .exp-title {
        font-family: var(--sh-font-display);
        font-weight: var(--sh-display-weight);
        color: var(--sh-ink);
    }

    .chatbot-window .chat-expediente .exp-card {
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
    }

    .chatbot-window .chat-expediente .exp-refresh,
    .chatbot-window .chat-expediente .exp-btn-secondary {
        background: transparent;
        border: 1px solid var(--sh-line-strong);
        border-radius: 999px;
        color: var(--sh-ink);
    }

    .chatbot-window .chat-expediente .exp-btn-primary {
        background: var(--sh-ink);
        border: 1px solid var(--sh-ink);
        border-radius: 999px;
        color: var(--sh-bg);
    }

    .chatbot-window .chat-expediente a {
        color: var(--sh-ink);
        text-decoration-color: var(--sh-accent);
    }
}

@keyframes shChatPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Con el chat abierto, el feed le deja sitio en vez de quedar debajo.
   Por debajo de 1100 px no hay ancho para repartir y el panel va encima. */
@media (min-width: 1100px) {
    html.chat-open[data-view-mode="desktop"] body #prismaSection.desktop-mode {
        width: calc(100% - var(--chat-w) - 20px) !important;
    }

    html.chat-open #prismaSection.desktop-mode .desktop-panel:not(.focused) .comp-tab {
        font-size: 0;
        padding: 7px 4px;
    }

    html.chat-open #prismaSection.desktop-mode .desktop-panel:not(.focused) .comp-tab svg {
        display: block;
        width: 15px;
        height: 15px;
        margin: 0;
    }
}

/* El feed, ya estrechado por el chat, pasa a la disposición de pantalla
   estrecha: laterales finos y el globo en una banda sobre el feed. */
@media (min-width: 1100px) and (max-width: 1640px) {
    html.chat-open {
        --sh-side-w: clamp(200px, 15vw, 240px);
    }

    html.chat-open #prismaSection.desktop-mode .desktop-panel.panel-events.focused {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 220px auto minmax(0, 1fr);
        grid-template-areas:
            "header"
            "globe"
            "filter"
            "text";
    }

    html.chat-open #prismaSection.desktop-mode .panel-events.focused .mini-globe-wrapper,
    html.chat-open #prismaSection.desktop-mode .panel-events.focused #desktopMiniGlobeContainer {
        border-left: none;
        border-bottom: 1px solid var(--sh-line);
    }

    html.chat-open #prismaSection.desktop-mode .panel-events.focused #desktopMiniGlobe {
        min-height: 0 !important;
    }
}

/* Columna estrecha de menos de ~290 px: las pestañas de la comparativa
   no caben con texto y quedan en icono. */
@media (min-width: 769px) and (max-width: 1380px) {
    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comp-tab {
        font-size: 0;
        padding: 7px 4px;
    }

    #prismaSection.desktop-mode .desktop-panel:not(.focused) .comp-tab svg {
        display: block;
        width: 15px;
        height: 15px;
        margin: 0;
    }
}

/* Pantallas estrechas: columnas laterales más finas y el globo pasa a ser
   una banda sobre el feed, porque al lado no le queda sitio. */
@media (min-width: 769px) and (max-width: 1100px) {
    html {
        --sh-side-w: clamp(200px, 22vw, 240px);
    }

    #prismaSection.desktop-mode .desktop-panel.panel-events.focused {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 220px auto minmax(0, 1fr);
        grid-template-areas:
            "header"
            "globe"
            "filter"
            "text";
    }

    #prismaSection.desktop-mode .panel-events.focused .mini-globe-wrapper,
    #prismaSection.desktop-mode .panel-events.focused #desktopMiniGlobeContainer {
        border-left: none;
        border-bottom: 1px solid var(--sh-line);
    }

    #prismaSection.desktop-mode .panel-events.focused #desktopMiniGlobe {
        min-height: 0 !important;
    }

    .app-bar-wordmark {
        font-size: 0.95rem;
        letter-spacing: 0.16em;
    }
}

/* =========================================================
   FICHA DEL HECHO
   El HTML agrupa la ficha en dos bloques (.hds-col-main: lectura;
   .hds-col-side: artículos). En pantalla estrecha y en la imagen
   exportada los bloques se disuelven y `order` deja las secciones en el
   orden de siempre. En escritorio son dos columnas.
   ========================================================= */
.hds-main {
    display: flex;
    flex-direction: column;
}

.hds-col {
    display: contents;
}

.hds-sec-articles { order: 1; }
.hds-local-press { order: 2; }
.hds-sec-fuentes { order: 3; }
.hds-sec-actors { order: 4; }
.hds-watermark { order: 5; }

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

.hds-section-count {
    margin-left: 4px;
    font-weight: 600;
    opacity: 0.55;
}

/* Relato de cobertura y discrepancias, a la vista (como en la app). */
.hds-kicker {
    margin: 0 0 8px;
    color: var(--sh-accent);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.hds-kicker.warn {
    color: #d97706;
}

.hds-story {
    margin: 14px 0 18px;
}

.hds-story-text {
    margin: 0;
    color: var(--sh-ink);
    font-size: 0.95rem;
    line-height: 1.65;
    white-space: pre-wrap;
}

.hds-story-more {
    margin-top: 6px;
    padding: 0;
    background: none;
    border: none;
    color: var(--sh-accent);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}

.hds-story-meta {
    margin-top: 8px;
    color: var(--sh-ink-3);
    font-size: 0.76rem;
}

.hds-disc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hds-disc-card {
    padding: 12px 14px;
    background: var(--sh-surface);
    border: 1px solid var(--sh-line);
    border-radius: var(--sh-radius-md);
}

.hds-disc-dato {
    margin-bottom: 10px;
    color: var(--sh-ink);
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.35;
}

@media (min-width: 1000px) {

    /* Hoja casi a pantalla completa. Con el chat abierto se queda a su
       lado en vez de taparlo. */
    #descriptionModal.desc-modal-overlay {
        align-items: stretch;
        padding: 20px 28px;
        background: rgba(18, 16, 12, 0.42);
        -webkit-backdrop-filter: blur(3px);
        backdrop-filter: blur(3px);
    }

    html.chat-open #descriptionModal.desc-modal-overlay {
        width: calc(100vw - var(--chat-w) - 20px);
        padding-right: 12px;
    }

    #descriptionModal .hds-container {
        width: min(1360px, 100%);
        height: 100%;
        max-height: none;
        background: var(--sh-surface);
        border: 1px solid var(--sh-line-strong);
        border-radius: var(--sh-radius-lg);
        box-shadow: var(--sh-shadow);
    }

    #descriptionModal .hds-content {
        height: 100%;
        max-height: none;
    }

    /* Cabecera: rótulo a la izquierda, acciones con texto a la derecha. */
    #descriptionModal .hds-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
        padding: 10px 12px 10px 28px;
        border-bottom: 1px solid var(--sh-line);
    }

    #descriptionModal .desc-modal-tag {
        margin: 0;
        color: var(--sh-accent);
        font-size: 0.68rem;
        letter-spacing: 0.16em;
    }

    #descriptionModal .hds-header-actions {
        position: static;
        gap: 6px;
    }

    #descriptionModal .hds-action-btn {
        width: auto;
        height: 32px;
        gap: 6px;
        padding: 0 12px;
        background: transparent;
        border: 1px solid var(--sh-line-strong);
        border-radius: 999px;
        color: var(--sh-ink);
        font-family: inherit;
        font-size: 0.76rem;
        font-weight: 600;
    }

    #descriptionModal .hds-action-btn svg {
        width: 14px;
        height: 14px;
    }

    #descriptionModal .hds-action-btn:hover:not(:disabled) {
        background: transparent;
        border-color: var(--sh-accent);
        color: var(--sh-accent);
    }

    #descriptionModal .hds-action-label {
        display: inline;
    }

    #descriptionModal .desc-modal-close {
        width: 32px;
        height: 32px;
        margin-left: 4px;
        background: transparent;
        border-radius: 8px;
        color: var(--sh-ink-2);
    }

    #descriptionModal .desc-modal-close:hover {
        background: var(--sh-surface-2);
        color: var(--sh-ink);
    }

    /* Cuerpo: no se desplaza él, se desplaza cada columna. */
    #descriptionModal .hds-body {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        color: var(--sh-ink-2);
    }

    #descriptionModal .hds-loading {
        margin: auto;
        color: var(--sh-ink-3);
    }

    #descriptionModal .hds-export-bar {
        display: none;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) {
        flex: 1 1 auto;
        min-height: 0;
        display: grid;
        grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr);
        grid-template-rows: auto minmax(0, 1fr);
        background: var(--sh-surface);
    }

    /* Fondo de la columna derecha, detrás de la foto y los artículos. */
    #descriptionModal .hds-capture-root:not(.hds-export)::before {
        content: "";
        grid-column: 2;
        grid-row: 1 / 3;
        background: var(--sh-surface-2);
        border-left: 1px solid var(--sh-line);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-main {
        display: contents;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-col-main {
        display: block;
        grid-column: 1;
        grid-row: 1 / 3;
        padding: 32px 44px 40px;
        overflow-y: auto;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-col-main > * {
        max-width: 780px;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-hero {
        grid-column: 2;
        grid-row: 1;
        width: auto;
        height: auto;
        max-height: 34vh;
        aspect-ratio: 16 / 9;
        margin: 20px 20px 0;
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-hero.hds-hero-ph {
        display: none;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-col-side {
        display: block;
        grid-column: 2;
        grid-row: 2;
        margin-top: 16px;
        padding: 0 20px 28px;
        overflow-y: auto;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-col-main,
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-col-side {
        scrollbar-width: thin;
        scrollbar-color: var(--sh-line) transparent;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-watermark,
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-brand-row {
        display: none;
    }

    /* La imagen exportada conserva el formato de una columna. */
    #descriptionModal .hds-capture-root.hds-export {
        width: 560px;
        margin: 0 auto;
    }

    /* Cabeza de la ficha: tema, titular y datos básicos. */
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-head {
        display: flex;
        flex-direction: column;
        margin-bottom: 20px;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-macro {
        order: -1;
        margin: 0 0 12px;
        color: var(--sh-accent);
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.14em;
        text-transform: uppercase;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-title {
        margin: 0 0 16px;
        color: var(--sh-ink);
        font-family: var(--sh-font-display);
        font-size: clamp(1.6rem, 2.3vw, 2.3rem);
        font-weight: var(--sh-display-weight);
        letter-spacing: var(--sh-display-tracking);
        line-height: 1.15;
        text-wrap: balance;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-pills {
        gap: 8px;
        margin: 0;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-pill {
        padding: 5px 11px;
        font-size: 0.74rem;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-pill.muted {
        background: var(--sh-surface-2);
        border: 1px solid var(--sh-line);
        color: var(--sh-ink-2);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-desc {
        margin: 0 0 28px;
        color: var(--sh-ink);
        font-size: 1.02rem;
        line-height: 1.72;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-block {
        margin-bottom: 28px;
        padding: 14px 16px;
        border-radius: var(--sh-radius-md);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-block-item {
        color: var(--sh-ink);
        font-size: 0.9rem;
        line-height: 1.5;
    }

    /* Secciones */
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-section {
        margin: 0 0 28px;
        padding-top: 22px;
        border-top: 1px solid var(--sh-line);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-col-side > .hds-section:first-child {
        padding-top: 0;
        border-top: none;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-section-label {
        margin: 0 0 14px;
        color: var(--sh-ink);
        font-size: 0.7rem;
        letter-spacing: 0.14em;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-cov-chip {
        padding: 5px 11px;
        background: var(--sh-surface-2);
        border: 1px solid var(--sh-line);
        color: var(--sh-ink-2);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-acc {
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-acc-sum {
        flex-wrap: nowrap;
        align-items: baseline;
        padding: 12px 14px;
        color: var(--sh-ink);
        font-size: 0.9rem;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-cov-causa {
        flex-shrink: 0;
        margin-left: auto;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-acc-sum::before {
        color: var(--sh-accent);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-acc-body {
        padding: 0 14px 14px;
        color: var(--sh-ink-2);
        font-size: 0.9rem;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-cov-medio {
        color: var(--sh-accent);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-cov-afirma {
        color: var(--sh-ink);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-cov-cita {
        background: var(--sh-surface-2);
        border-left-color: var(--sh-accent);
    }

    /* En escritorio hay sitio: el relato sale entero, sin «Seguir leyendo». */
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-story {
        margin: 20px 0 24px;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-story-text {
        font-size: 1rem;
        line-height: 1.72;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-story-preview,
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-story-more {
        display: none;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-story-full {
        display: block;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-disc-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 12px;
    }

    /* Tarjetas de cobertura: dos a la vista. */
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-tarjetas {
        margin-bottom: 16px;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-tarjetas-track {
        gap: 12px;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-tarjeta {
        flex: 0 0 calc((100% - 12px) / 2);
        max-width: 360px;
        border-color: var(--sh-line);
        border-radius: var(--sh-radius-md);
        scroll-snap-align: start;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-tarjetas-arrow {
        border-color: var(--sh-line-strong);
        color: var(--sh-ink);
    }

    /* Artículos: lista vertical en la columna derecha. */
    #descriptionModal .hds-capture-root:not(.hds-export) .hds-articles {
        flex-direction: column;
        gap: 8px;
        padding: 0;
        overflow: visible;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-art-card {
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr);
        flex: none;
        width: auto;
        background: var(--sh-surface);
        border: 1px solid var(--sh-line);
        border-radius: var(--sh-radius-md);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-art-card:hover {
        background: var(--sh-surface);
        border-color: var(--sh-accent);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-art-thumb {
        width: 108px;
        height: 100%;
        min-height: 86px;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-art-body {
        gap: 5px;
        padding: 10px 12px;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-art-title {
        min-height: 0;
        color: var(--sh-ink);
        font-size: 0.84rem;
        line-height: 1.35;
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-local-country-label {
        color: var(--sh-ink-2);
    }

    #descriptionModal .hds-capture-root:not(.hds-export) .hds-entity {
        border-radius: 999px;
    }
}

/* =========================================================
   CHAT — piezas comunes a escritorio y móvil
   ========================================================= */
.app-bar-chat {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 14px;
    background: var(--sh-ink);
    border: 1px solid var(--sh-ink);
    border-radius: 999px;
    color: var(--sh-bg);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.app-bar-chat svg {
    width: 15px;
    height: 15px;
}

.app-bar-chat:hover,
.app-bar-chat.active {
    background: var(--sh-accent);
    border-color: var(--sh-accent);
    color: var(--sh-on-accent);
}

.app-bar-chat.is-processing::after,
.app-bar-chat.has-unread::after {
    content: "";
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    background: var(--sh-accent);
    border: 2px solid var(--sh-surface);
    border-radius: 50%;
}

.app-bar-chat.is-processing::after {
    animation: shChatPulse 1.1s ease-in-out infinite;
}

/* Progreso por agente: un carril por cada uno que trabaja en el turno. */
.chat-processing-lanes {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-processing-lane {
    padding: 8px 10px;
    background: var(--sh-surface);
    border: 1px solid var(--sh-line);
    border-radius: var(--sh-radius-sm);
}

.chat-processing-lane.is-active {
    border-color: color-mix(in srgb, var(--sh-accent) 45%, var(--sh-line));
}

.chat-processing-lane.is-done {
    opacity: 0.72;
}

.chat-processing-lane > summary {
    display: block;
    list-style: none;
    cursor: pointer;
}

.chat-processing-lane > summary::-webkit-details-marker {
    display: none;
}

.chat-processing-lane .lane-head {
    display: flex;
    align-items: center;
    gap: 7px;
}

.chat-processing-lane .step-indicator {
    margin-top: 0;
}

.chat-processing-lane .lane-label {
    flex: 1;
    min-width: 0;
    color: var(--sh-ink);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lane-count {
    color: var(--sh-ink-3);
    font-size: 0.66rem;
    font-variant-numeric: tabular-nums;
}

/* Flecha que indica que el carril o el bloque se despliega. */
.chat-processing-lane .lane-head::after,
.chat-processing-trace-group-head::after {
    content: "";
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    margin: 0 2px 2px 4px;
    border-right: 1.5px solid var(--sh-ink-3);
    border-bottom: 1.5px solid var(--sh-ink-3);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}

.chat-processing-lane[open] .lane-head::after,
.chat-processing-trace-group[open] > .chat-processing-trace-group-head::after {
    margin-bottom: -3px;
    transform: rotate(-135deg);
}

.chat-processing-lane .lane-step {
    display: -webkit-box;
    margin-top: 4px;
    padding-left: 20px;
    overflow: hidden;
    color: var(--sh-ink-2);
    font-size: 0.76rem;
    font-weight: 400;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

/* Abierto, el paso actual ya está en la lista. */
.chat-processing-lane[open] .lane-step {
    display: none;
}

.chat-processing-lane .lane-steps {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    padding: 8px 0 0 20px;
    border-top: 1px solid var(--sh-line);
}

.lane-step-item,
.chat-processing-trace-group .chat-processing-trace-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    color: var(--sh-ink-2);
    font-size: 0.74rem;
    line-height: 1.35;
}

.lane-step-item .step-indicator,
.lane-step-item .trace-item-check {
    flex: 0 0 13px;
    width: 13px;
    color: var(--sh-accent);
    font-weight: 800;
    text-align: center;
}

.lane-step-item .step-indicator {
    height: 13px;
    margin-top: 2px;
}

/* Traza de la respuesta: un bloque desplegable por agente. */
.chat-processing-trace-group {
    padding: 5px 0;
    border-top: 1px solid var(--sh-line);
}

.chat-processing-trace-group:first-child {
    padding-top: 0;
    border-top: none;
}

.chat-processing-trace-group-head {
    display: flex;
    align-items: center;
    gap: 7px;
    list-style: none;
    cursor: pointer;
}

.chat-processing-trace-group-head::-webkit-details-marker {
    display: none;
}

.chat-processing-trace-agent {
    flex: 1;
    color: var(--sh-ink-2);
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.chat-processing-trace-group[open] > .chat-processing-trace-item:first-of-type {
    margin-top: 6px;
}

.chat-processing-trace-group > .chat-processing-trace-item {
    padding-left: 2px;
    margin-bottom: 3px;
}

/* Bajo un informe de investigación web: qué se consultó. */
.chat-research-note {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-top: 12px;
    padding: 8px 10px;
    border: 1px dashed var(--sh-line-strong);
    border-radius: var(--sh-radius-sm);
    color: var(--sh-ink-2);
    font-size: 0.76rem;
    line-height: 1.35;
}

.chat-research-open {
    margin-left: auto;
    padding: 0;
    background: none;
    border: none;
    color: var(--sh-accent);
    font-family: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}

.chat-research-open:hover {
    text-decoration: underline;
}

/* En móvil el chat sigue a pantalla completa con sus burbujas: las piezas
   del panel de escritorio no se pintan. */
@media (max-width: 768px) {
    .chat-conv-tabs,
    .chat-input-hint,
    .chat-suggestions {
        display: none;
    }
}

/* =========================================================
   ANÁLISIS LINGÜÍSTICO — colores por tema
   El bloque original fija blancos translúcidos pensados para el tema
   oscuro; en claro y retro el texto quedaba sin contraste.
   ========================================================= */
.ling-card {
    background: var(--sh-surface-2);
    border: 1px solid var(--sh-line);
    border-left-width: 1px;
    border-radius: var(--sh-radius-md);
    overflow: hidden;
}

.ling-card-head {
    background: transparent;
    border-bottom: 1px solid var(--sh-line);
}

.ling-score-badge {
    border-radius: var(--sh-radius-sm) !important;
}

.ling-card-title {
    color: var(--sh-ink);
}

.ling-card-metrics,
.ling-beta-panel,
details.ling-more {
    background: transparent;
}

.ling-beta-panel {
    border: none;
    border-radius: 0;
}

details.ling-acc {
    border-bottom-color: var(--sh-line);
}

details.ling-acc summary.ling-acc-sum {
    color: var(--sh-ink-2);
}

details.ling-acc summary.ling-acc-sum:hover,
details.ling-more summary.ling-more-sum:hover {
    background: var(--sh-line);
}

details.ling-acc summary.ling-acc-sum::before {
    border-color: var(--sh-ink-3);
}

.ling-acc-num,
.ling-metric-val,
.ling-sesgo-actor,
.ling-e3-line {
    color: var(--sh-ink);
}

.ling-beta-hint,
.ling-metric-lbl,
.ling-sesgo-ev,
.ling-marco-line,
.ling-extra-line {
    color: var(--sh-ink-2);
}

.ling-beta-hint.ling-beta-muted,
.ling-metric-na,
.ling-sesgo-lbl,
.ling-extra-h {
    color: var(--sh-ink-3);
}

.ling-progress-track {
    background: var(--sh-line);
}

.ling-sesgo-card {
    background: var(--sh-surface);
    border-color: var(--sh-line);
}

.ling-marco-line,
details.ling-more {
    border-top-color: var(--sh-line);
}

.ling-tag {
    background: var(--sh-surface);
    border-color: var(--sh-line);
    color: var(--sh-ink-2);
}

html:not([data-theme="dark"]) .ling-beta-total,
html:not([data-theme="dark"]) .ling-e3-title,
html:not([data-theme="dark"]) details.ling-more summary.ling-more-sum {
    color: #1d5fa8;
}

html:not([data-theme="dark"]) .ling-beta-total.ling-total-enc,
html:not([data-theme="dark"]) .ling-tag.ling-tag-warn {
    color: #a16207;
}

html:not([data-theme="dark"]) .ling-e3-block {
    background: rgba(29, 95, 168, 0.06);
    border-color: rgba(29, 95, 168, 0.18);
}

.quality-score-chip {
    background: var(--sh-surface);
    border-color: var(--sh-line);
}

/* =========================================================
   FUENTES — colores por tema (mismo motivo que el bloque anterior)
   ========================================================= */
.src-section-stats,
details.src-medio-card {
    background: var(--sh-surface);
    border-color: var(--sh-line);
}

.src-section-stats .src-stat,
.src-stat-badge.src-stat-total {
    background: var(--sh-surface-2);
    border-color: var(--sh-line);
}

.src-empty-title,
.src-comun-item,
.src-medio-name,
.src-src-name {
    color: var(--sh-ink);
}

.src-section-stats .src-stat-num {
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--sh-ink);
    font-family: var(--sh-font-display);
}

.src-stat-badge.src-stat-total {
    color: var(--sh-ink-2);
}

.src-section-stats .src-stat-label,
.src-empty-txt,
.src-subsec-title,
.src-src-rol {
    color: var(--sh-ink-3);
}

.src-section-stats .src-type-bar {
    background: var(--sh-line);
}

details.src-medio-card summary.src-medio-summary:hover,
.src-source-row:hover {
    background: var(--sh-surface-2);
}

.src-medio-body {
    background: transparent;
    border-top-color: var(--sh-line);
}

.src-medio-sum-badges::after {
    border-top-color: var(--sh-ink-3);
}

/* =========================================================================
   BOTÓN DE PARAR LA RESPUESTA
   Mientras el asistente responde, el botón de enviar pasa a ser el de parar.
   Vale para el panel de escritorio y para el chat a pantalla completa del móvil.
   ========================================================================= */
.chat-send .chat-stop-glyph {
    display: none;
    width: 11px;
    height: 11px;
    border-radius: 2px;
    background: currentColor;
}

.chat-send.is-stop > svg,
.chat-send.is-stop > i {
    display: none;
}

.chat-send.is-stop .chat-stop-glyph {
    display: block;
}

.chat-send.is-stop:disabled {
    opacity: 0.5;
    cursor: progress;
}

/* Modo del asistente (ajuste del usuario): Investigador | Rápido */
.chatbot-window .chat-mode-btn {
    flex: 0 0 auto;
    margin-right: 4px;
    padding: 3px 9px;
    border: 1px solid var(--sh-line, rgba(127, 127, 127, 0.35));
    border-radius: 999px;
    background: transparent;
    color: var(--sh-ink-2, inherit);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
}

.chatbot-window .chat-mode-btn[data-mode="deep"] {
    border-color: var(--sh-accent, currentColor);
    color: var(--sh-accent, inherit);
}

.chatbot-window .chat-mode-btn:disabled {
    opacity: 0.5;
    cursor: progress;
}

/* =========================================================
   CUENTA — botón de la barra y pantalla de entrar / cuenta
   ========================================================= */
.app-bar-account {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    background: transparent;
    border: 1px solid var(--sh-line-strong);
    border-radius: 999px;
    color: var(--sh-ink);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.app-bar-account[hidden] {
    display: none;
}

.app-bar-account svg {
    width: 15px;
    height: 15px;
}

.app-bar-account:hover {
    border-color: var(--sh-ink);
}

/* Con cuenta: las iniciales en un círculo, sin icono. */
.app-bar-account.is-user {
    width: 34px;
    padding: 0;
    justify-content: center;
    background: var(--sh-ink);
    border-color: var(--sh-ink);
    color: var(--sh-bg);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.app-bar-account.is-user svg {
    display: none;
}

/* En escritorio la cuenta está en la barra; el botón del chat es para el móvil. */
@media (min-width: 769px) {
    .chatbot-window .chat-account-btn {
        display: none !important;
    }
}

.chatbot-window .chat-account-btn[hidden] {
    display: none;
}

.account-overlay {
    position: fixed;
    inset: 0;
    z-index: 20000; /* sobre el chat y los botones flotantes (≤ 12000), bajo la pantalla sin servidor */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: calc(var(--app-bar-h) + 16px) 16px 24px;
    background: color-mix(in srgb, var(--sh-ink) 28%, transparent);
    overflow-y: auto;
}

.account-overlay[hidden] {
    display: none;
}

.account-sheet {
    width: min(460px, 100%);
    background: var(--sh-surface);
    color: var(--sh-ink);
    border: 1px solid var(--sh-line-strong);
    border-radius: var(--sh-radius-lg);
    box-shadow: var(--sh-shadow);
    font-family: var(--font-family, "Inter", system-ui, sans-serif);
}

.acc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--sh-line);
}

.acc-head h2 {
    margin: 0;
    color: var(--sh-ink);
    font-family: var(--sh-font-display);
    font-weight: var(--sh-display-weight);
    letter-spacing: var(--sh-display-tracking);
    font-size: 1.35rem;
}

.acc-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--sh-ink-2);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.acc-close:hover {
    background: var(--sh-surface-2);
    color: var(--sh-ink);
}

.acc-body {
    padding: 4px 18px 18px;
}

.acc-section {
    padding: 14px 0;
    border-bottom: 1px solid var(--sh-line);
}

.acc-section:last-child {
    border-bottom: none;
}

.acc-h {
    margin: 0 0 10px;
    color: var(--sh-ink-2);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.acc-lead {
    margin: 0 0 4px;
    font-weight: 700;
}

.acc-muted {
    margin: 0;
    color: var(--sh-ink-2);
    font-size: 0.85rem;
    line-height: 1.45;
}

.acc-small {
    font-size: 0.76rem;
}

.acc-empty {
    padding: 18px 0;
}

.acc-notice {
    margin: 12px 0 0;
    padding: 9px 12px;
    border-radius: var(--sh-radius-sm);
    background: color-mix(in srgb, var(--sh-accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--sh-accent) 40%, transparent);
    font-size: 0.85rem;
}

.acc-warn {
    margin: 12px 0 0;
    padding: 8px 10px;
    border-left: 3px solid #d97706;
    background: color-mix(in srgb, #d97706 10%, transparent);
    color: var(--sh-ink);
    font-size: 0.78rem;
    line-height: 1.4;
}

.acc-tabs {
    display: flex;
    gap: 4px;
    margin: 14px 0 12px;
    padding: 3px;
    border-radius: var(--sh-radius-md);
    background: var(--sh-surface-2);
    border: 1px solid var(--sh-line);
}

.acc-tab {
    flex: 1;
    height: 32px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--sh-ink-2);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.acc-tab.is-active {
    background: var(--sh-surface);
    color: var(--sh-ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.acc-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.acc-form.is-busy {
    opacity: 0.7;
}

.acc-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--sh-ink-2);
}

.acc-field em {
    font-weight: 400;
    font-style: normal;
    color: var(--sh-ink-3);
}

.acc-field input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--sh-line-strong);
    border-radius: var(--sh-radius-sm);
    background: var(--sh-bg);
    color: var(--sh-ink);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 400;
}

.acc-field input:focus {
    outline: 2px solid var(--sh-accent);
    outline-offset: 1px;
}

.acc-error {
    margin: 0;
    color: #c2410c;
    font-size: 0.8rem;
}

.acc-error:empty {
    display: none;
}

html[data-theme="dark"] .acc-error {
    color: #fb923c;
}

.acc-primary,
.acc-secondary,
.acc-danger-btn {
    height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
}

.acc-primary {
    border: 1px solid var(--sh-ink);
    background: var(--sh-ink);
    color: var(--sh-bg);
}

.acc-primary:hover {
    background: var(--sh-accent);
    border-color: var(--sh-accent);
    color: var(--sh-on-accent);
}

.acc-secondary {
    border: 1px solid var(--sh-line-strong);
    background: transparent;
    color: var(--sh-ink);
}

.acc-secondary:hover {
    border-color: var(--sh-ink);
}

.acc-signout {
    width: 100%;
    margin-top: 10px;
}

.acc-danger-btn {
    border: 1px solid #b91c1c;
    background: #b91c1c;
    color: #fff;
}

.acc-danger-btn:hover {
    background: #991b1b;
}

.acc-more {
    margin-top: 6px;
    border: 1px solid var(--sh-line);
    border-radius: var(--sh-radius-sm);
}

.acc-more > summary {
    padding: 10px 12px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}

.acc-more[open] > summary {
    border-bottom: 1px solid var(--sh-line);
}

.acc-more > .acc-form {
    padding: 12px;
}

.acc-danger {
    margin-top: 12px;
}

.acc-danger > summary {
    color: #b91c1c;
}

html[data-theme="dark"] .acc-danger > summary {
    color: #f87171;
}

.acc-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.acc-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--sh-ink);
    color: var(--sh-bg);
    font-weight: 800;
    letter-spacing: 0.04em;
}

.acc-who {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.acc-who span {
    color: var(--sh-ink-2);
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-plan {
    padding: 4px 10px;
    border: 1px solid var(--sh-line-strong);
    border-radius: 999px;
    color: var(--sh-ink-2);
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.acc-plan.is-full {
    border-color: var(--sh-accent);
    color: var(--sh-accent);
}

.acc-meter {
    height: 8px;
    border-radius: 999px;
    background: var(--sh-surface-2);
    border: 1px solid var(--sh-line);
    overflow: hidden;
}

.acc-meter > span {
    display: block;
    height: 100%;
    background: var(--sh-accent);
}

.acc-meter.is-full > span {
    background: #c2410c;
}

.acc-quota-line {
    margin: 8px 0 0;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.acc-pref {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.acc-pref-label {
    font-size: 0.85rem;
    font-weight: 600;
}

.acc-seg {
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: var(--sh-radius-md);
    background: var(--sh-surface-2);
    border: 1px solid var(--sh-line);
}

.acc-seg-btn {
    height: 28px;
    padding: 0 10px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--sh-ink-2);
    font: inherit;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
}

.acc-seg-btn.is-active {
    background: var(--sh-ink);
    color: var(--sh-bg);
}

/* Móvil: la pantalla ocupa todo, como el chat. */
@media (max-width: 768px) {
    .account-overlay {
        padding: 0;
        background: var(--sh-surface);
    }

    .account-sheet {
        width: 100%;
        min-height: 100%;
        border: none;
        border-radius: 0;
        box-shadow: none;
        padding-top: env(safe-area-inset-top);
    }
}
