/*
 * Connected apps in the chat and in the call window: preview cards, the
 * header button, the empty-chat line, the sharing warning and the call
 * status. The manager modal lives in connected-apps.css.
 *
 * Sizes are relative to the inherited font size so the font-size setting
 * scales every card; buttons keep a 46px touch target.
 */

.app-action-card {
    --apps-card-surface: var(--primary, #ffffff);
    --apps-card-ink: #17243a;
    --apps-card-muted: #5c6b7e;
    --apps-card-rule: #d7e0e9;
    --apps-card-field: #f5f7fa;
    --apps-card-accent: var(--theme-primary, #0970e6);
    --apps-card-accent-strong: var(--theme-primary-focus, #0053b3);
    --apps-card-on-accent: #ffffff;
    --apps-card-pending: #8a5a00;
    --apps-card-pending-surface: #fff8e8;
    --apps-card-success: #137a55;
    --apps-card-success-surface: #eefaf4;
    --apps-card-attention: #b42318;
    --apps-card-attention-surface: #fff1ef;
    --apps-card-progress: #1c5fa8;
    --apps-card-progress-surface: #eef5fd;
    --apps-card-muted-surface: #f1f3f6;
    box-sizing: border-box;
    width: min(100%, 44em);
    max-width: 100%;
    min-width: 0;
    margin: 0.85em 0 1em;
    padding: 1em 1.1em;
    color: var(--apps-card-ink);
    background: var(--apps-card-surface);
    border: 1px solid var(--apps-card-rule);
    border-left: 4px solid var(--apps-card-pending);
    border-radius: 4px 14px 14px 4px;
    box-shadow: 0 8px 24px rgba(23, 36, 58, 0.07);
    font-family: 'Poppins', sans-serif;
    font-size: 0.95em;
    line-height: 1.5;
    overflow-wrap: anywhere;
    text-align: left;
}

.app-action-card *,
.app-action-card *::before,
.app-action-card *::after {
    box-sizing: border-box;
}

.app-action-card--success { border-left-color: var(--apps-card-success); }
.app-action-card--attention,
.app-action-card--warning { border-left-color: var(--apps-card-attention); }
.app-action-card--progress { border-left-color: var(--apps-card-progress); }
.app-action-card--muted { border-left-color: var(--apps-card-muted); box-shadow: none; }

/*
 * In the chat a card belongs to the reply above it, so it starts where the
 * reply's text starts: the reply's padding (1.25rem), the assistant icon
 * (40px) and the gap after it (1rem), see BotMessage.js. A message narrower
 * than 30rem (a phone, a narrow side panel) keeps the card at full width; the
 * percentages are the message's width, so the clamp switches between 0 and
 * the indent there.
 */
[data-tour="chat-response-content"] ~ .app-action-card {
    --apps-card-reply-indent: clamp(0px, (100% - 30rem) * 1000, 1.25rem + 40px + 1rem);
    margin-left: var(--apps-card-reply-indent);
    max-width: calc(100% - var(--apps-card-reply-indent));
}

/* Dark mode and the dark color themes share one palette. */
body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .app-action-card {
    --apps-card-surface: #182132;
    --apps-card-ink: #eef4fb;
    --apps-card-muted: #afbdd0;
    --apps-card-rule: #344155;
    --apps-card-field: #182234;
    --apps-card-accent: #3d8bf2;
    --apps-card-accent-strong: #62a3f7;
    --apps-card-on-accent: #0b1220;
    --apps-card-pending: #f0c36a;
    --apps-card-pending-surface: rgba(151, 100, 16, 0.2);
    --apps-card-success: #6fd1a4;
    --apps-card-success-surface: rgba(19, 122, 85, 0.22);
    --apps-card-attention: #ff9c8f;
    --apps-card-attention-surface: rgba(180, 35, 24, 0.24);
    --apps-card-progress: #8fc0ff;
    --apps-card-progress-surface: rgba(28, 95, 168, 0.26);
    --apps-card-muted-surface: #1c2638;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.app-action-card__header {
    display: flex;
    align-items: center;
    gap: 0.75em;
    min-width: 0;
}

.app-action-card__logo {
    flex: 0 0 auto;
    width: 2.25em;
    height: 2.25em;
    padding: 0.2em;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid var(--apps-card-rule);
    border-radius: 0.6em;
}

.app-action-card__logo--glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--apps-card-accent);
    font-size: 1em;
}

/* A document drafted by the Abogado Virtual: LEXIUS's own glyph, no app logo. */
.app-action-card__logo--document {
    color: var(--apps-card-accent);
    background: var(--apps-card-progress-surface);
    border-color: transparent;
    font-size: 1.1em;
}

.app-action-card__heading {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.app-action-card__title {
    font-size: 1.05em;
    font-weight: 600;
    line-height: 1.35;
}

.app-action-card__from {
    color: var(--apps-card-muted);
    font-size: 0.86em;
}

.app-action-card__status {
    display: flex;
    align-items: flex-start;
    gap: 0.5em;
    margin: 0.75em 0 0;
    padding: 0.45em 0.7em;
    color: var(--apps-card-pending);
    background: var(--apps-card-pending-surface);
    border-radius: 0.6em;
    font-size: 0.9em;
    font-weight: 600;
    line-height: 1.45;
}

.app-action-card__status .anticon {
    margin-top: 0.25em;
}

.app-action-card__status--success { color: var(--apps-card-success); background: var(--apps-card-success-surface); }
.app-action-card__status--attention,
.app-action-card__status--warning { color: var(--apps-card-attention); background: var(--apps-card-attention-surface); }
.app-action-card__status--progress { color: var(--apps-card-progress); background: var(--apps-card-progress-surface); }
.app-action-card__status--muted { color: var(--apps-card-muted); background: var(--apps-card-muted-surface); }

.app-action-card__progress {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25em 0.75em;
    margin: 0.5em 0 0;
    color: var(--apps-card-muted);
    font-size: 0.9em;
}

.app-action-card__progress-value {
    color: var(--apps-card-progress);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* How far a long file (OCR, transcription) has come. */
.app-action-card__meter {
    position: relative;
    height: 0.4em;
    margin: 0.6em 0 0;
    overflow: hidden;
    background: var(--apps-card-progress-surface);
    border-radius: 999px;
}

.app-action-card__meter-fill {
    position: absolute;
    inset: 0 auto 0 0;
    min-width: 0.4em;
    background: var(--apps-card-progress);
    border-radius: inherit;
    transition: width 0.4s ease;
}

.app-action-card__hint-line {
    margin: 0.5em 0 0;
    color: var(--apps-card-muted);
    font-size: 0.86em;
}

@media (prefers-reduced-motion: reduce) {
    .app-action-card__meter-fill {
        transition: none;
    }
}

.app-action-card__fields {
    display: block;
    margin: 0.85em 0 0;
    padding: 0;
}

.app-action-card__field {
    display: grid;
    grid-template-columns: minmax(4.5em, 6.5em) minmax(0, 1fr);
    align-items: start;
    gap: 0.15em 0.85em;
    padding: 0.4em 0;
    border-top: 1px solid var(--apps-card-rule);
}

.app-action-card__field > dt {
    margin: 0;
    padding-top: 0.65em;
    color: var(--apps-card-muted);
    font-size: 0.82em;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.app-action-card__field > dd {
    min-width: 0;
    margin: 0;
}

.app-action-card__value-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5em;
}

.app-action-card__value,
.app-action-card__chips {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.6em 0;
}

.app-action-card__value--multiline {
    max-height: 22em;
    overflow-y: auto;
    white-space: pre-wrap;
}

.app-action-card__document {
    max-height: 22em;
    overflow: auto;
    font-size: inherit;
}

.app-action-card__document :is(ul, ol) {
    padding-left: 1.4em;
    list-style-position: outside;
}

/* The page styles every heading with !important sizes made for full pages; a
   document inside a card (a call draft, a preview before saving) keeps the
   proportions of the call's document note. */
.app-action-card__document :is(h1, h2, h3, h4) {
    font-weight: 600 !important;
    line-height: 1.3;
}

.app-action-card__document h1 {
    font-size: 1.45rem !important;
}

.app-action-card__document h2 {
    font-size: 1.2rem !important;
}

.app-action-card__document :is(h3, h4) {
    font-size: 1.05rem !important;
}

.app-action-card__value--empty {
    color: var(--apps-card-muted);
}

.app-action-card__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35em;
}

.app-action-card__chip {
    max-width: 100%;
    padding: 0.15em 0.6em;
    background: var(--apps-card-field);
    border: 1px solid var(--apps-card-rule);
    border-radius: 999px;
    font-size: 0.92em;
}

/* The page's button reset ([type='button']) is injected after this file, so
   controls are addressed through the card to keep their own background. */
.app-action-card .app-action-card__edit {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 0.35em;
    min-width: 46px;
    min-height: 46px;
    padding: 0 0.6em;
    color: var(--apps-card-accent);
    background: transparent;
    border: 0;
    border-radius: 0.6em;
    font: inherit;
    font-size: 0.86em;
    font-weight: 600;
    cursor: pointer;
}

.app-action-card .app-action-card__edit:hover,
.app-action-card .app-action-card__edit:focus-visible {
    background: var(--apps-card-field);
}

.app-action-card .app-action-card__editor {
    display: flex;
    flex-direction: column;
    gap: 0.5em;
    padding: 0.4em 0;
}

.app-action-card .app-action-card__input {
    width: 100%;
    min-height: 46px;
    padding: 0.6em 0.75em;
    color: var(--apps-card-ink);
    background: var(--apps-card-surface);
    border: 1px solid var(--apps-card-muted);
    border-radius: 0.6em;
    font: inherit;
    /* Mobile browsers zoom into inputs below 16px. */
    font-size: max(1em, 16px);
    line-height: 1.45;
}

.app-action-card .app-action-card__input--multiline {
    min-height: 9em;
    resize: vertical;
}

.app-action-card__hint {
    color: var(--apps-card-muted);
    font-size: 0.82em;
}

.app-action-card .app-action-card__editor-actions,
.app-action-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6em;
}

.app-action-card__actions {
    margin: 0.9em 0 0;
}

.app-action-card .app-action-card__button {
    display: inline-flex;
    flex: 0 1 auto;
    align-items: center;
    justify-content: center;
    gap: 0.45em;
    max-width: 100%;
    min-height: 46px;
    padding: 0.5em 1.1em;
    color: var(--apps-card-accent);
    background: transparent;
    border: 1px solid var(--apps-card-accent);
    border-radius: 0.7em;
    font: inherit;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-action-card .app-action-card__button:hover,
.app-action-card .app-action-card__button:focus-visible {
    color: var(--apps-card-accent-strong);
    border-color: var(--apps-card-accent-strong);
    text-decoration: none;
}

.app-action-card .app-action-card__button--primary {
    color: var(--apps-card-on-accent);
    background: var(--apps-card-accent);
}

.app-action-card .app-action-card__button--primary:hover,
.app-action-card .app-action-card__button--primary:focus-visible {
    color: var(--apps-card-on-accent);
    background: var(--apps-card-accent-strong);
}

.app-action-card .app-action-card__button--armed,
.app-action-card .app-action-card__button--armed:hover,
.app-action-card .app-action-card__button--armed:focus-visible {
    color: #ffffff;
    background: var(--apps-card-attention);
    border-color: var(--apps-card-attention);
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .app-action-card .app-action-card__button--armed {
    color: #0b1220;
}

.app-action-card .app-action-card__button--quiet {
    color: var(--apps-card-muted);
    border-color: transparent;
}

.app-action-card .app-action-card__button--quiet:hover,
.app-action-card .app-action-card__button--quiet:focus-visible {
    color: var(--apps-card-ink);
    background: var(--apps-card-field);
    border-color: transparent;
}

.app-action-card .app-action-card__button--done,
.app-action-card .app-action-card__button--done:disabled {
    color: var(--apps-card-success);
    background: var(--apps-card-success-surface);
    border-color: transparent;
    opacity: 1;
}

.app-action-card .app-action-card__button:focus-visible,
.app-action-card .app-action-card__edit:focus-visible,
.app-action-card .app-action-card__input:focus-visible {
    outline: 2px solid var(--apps-card-accent);
    outline-offset: 2px;
}

.app-action-card .app-action-card__button:disabled,
.app-action-card .app-action-card__edit:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.app-action-card__warnings {
    display: grid;
    gap: 0.35em;
    margin: 0.75em 0 0;
    padding: 0;
    list-style: none;
}

.app-action-card__warnings li {
    display: flex;
    gap: 0.5em;
    margin: 0;
    padding: 0.45em 0.7em;
    color: var(--apps-card-pending);
    background: var(--apps-card-pending-surface);
    border-radius: 0.6em;
    font-size: 0.9em;
}

.app-action-card__warnings .anticon {
    margin-top: 0.3em;
}

.app-action-card__notice {
    margin: 0.75em 0 0;
    padding: 0.5em 0.7em;
    color: var(--apps-card-attention);
    background: var(--apps-card-attention-surface);
    border-radius: 0.6em;
    font-size: 0.92em;
    font-weight: 600;
}

.app-action-card__footer {
    margin: 0.75em 0 0;
    color: var(--apps-card-muted);
    font-size: 0.86em;
}

@media (max-width: 575.98px) {
    .app-action-card {
        padding: 0.85em 0.8em;
    }

    .app-action-card__field {
        grid-template-columns: minmax(0, 1fr);
    }

    .app-action-card__field > dt {
        padding-top: 0.3em;
    }

    .app-action-card__value,
    .app-action-card__chips {
        padding: 0.2em 0 0.5em;
    }

    .app-action-card__actions .app-action-card__button,
    .app-action-card__editor-actions .app-action-card__button {
        flex: 1 1 100%;
    }
}

/* ------------------------------------------------------------ chat header */

.chat-apps-trigger {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    min-width: 34px;
    margin-left: 6px;
    padding: 0 10px;
    color: var(--text-third);
    background: transparent;
    border: 1px solid var(--border-fourth);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.chat-apps-trigger:first-child {
    margin-left: 0;
}

.chat-apps-trigger:hover,
.chat-apps-trigger:focus-visible,
.chat-apps-trigger.is-active {
    color: var(--theme-color);
    background: rgba(var(--theme-color-rgb, 0, 110, 255), 0.1);
    border-color: rgba(var(--theme-color-rgb, 0, 110, 255), 0.38);
}

.chat-apps-trigger:focus-visible {
    outline: 2px solid rgba(var(--theme-color-rgb, 0, 110, 255), 0.28);
    outline-offset: 2px;
}

.chat-apps-trigger .anticon {
    font-size: 15px;
}

.chat-apps-trigger__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    color: #ffffff;
    background: var(--theme-primary, #0970e6);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

/* Narrow header: the icon alone, with the count on its corner. */
@media (max-width: 991.98px) {
    .chat-apps-trigger {
        position: relative;
        width: 32px;
        height: 32px;
        min-width: 32px;
        margin-left: 5px;
        padding: 0;
    }

    .chat-apps-trigger__label {
        display: none;
    }

    .chat-apps-trigger__count {
        position: absolute;
        top: -6px;
        right: -6px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        font-size: 10px;
    }
}

/* ------------------------------------------------------------- empty chat */

.chat-empty-apps-link {
    display: inline;
    padding: 0;
    color: var(--theme-color);
    background: transparent;
    border: 0;
    font: inherit;
    text-align: center;
    cursor: pointer;
}

.chat-empty-apps-link:hover,
.chat-empty-apps-link:focus-visible {
    text-decoration: underline;
}

/* ---------------------------------------------------------------- sharing */

.collaboration-app-warning {
    margin-top: 10px;
    padding: 12px;
    color: #6b4500;
    background: #fff8e8;
    border: 1px solid #ecd28f;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .collaboration-app-warning {
    color: #f6dfa6;
    background: rgba(151, 100, 16, 0.2);
    border-color: rgba(232, 184, 90, 0.4);
}

.collaboration-app-warning p {
    margin: 0;
}

.collaboration-app-warning__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.collaboration-app-warning__actions button {
    min-height: 46px;
    padding: 0 14px;
    color: inherit;
    background: transparent;
    border: 1px solid currentColor;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}

.collaboration-app-warning__actions button.is-primary {
    color: #ffffff;
    background: #8a5a00;
    border-color: #8a5a00;
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .collaboration-app-warning__actions button.is-primary {
    color: #1b1404;
    background: #f0c36a;
    border-color: #f0c36a;
}

/* ------------------------------------------------------------ call window */

.call-apps-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    margin: 0.5em 0;
    color: var(--theme-primary, #0970e6);
    font-weight: 600;
    text-align: center;
}

.call-apps-status[hidden],
.call-apps-cards[hidden] {
    display: none !important;
}

.call-apps-status__spinner {
    flex: 0 0 auto;
    width: 1em;
    height: 1em;
    border: 0.15em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: call-apps-spin 0.75s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .call-apps-status__spinner {
        animation-duration: 2.5s;
    }
}

/* The call window's own stylesheet sizes and scrolls this container. */
.call-apps-cards {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75em;
    min-width: 0;
    text-align: left;
}

.call-apps-cards .app-action-card {
    width: 100%;
    margin: 0;
}

.call-apps-result,
.call-apps-notice {
    min-width: 0;
    padding: 0.85em 1em;
    color: var(--text-secondary);
    background: var(--primary, #ffffff);
    border: 1px solid var(--border-fourth);
    border-radius: 12px;
    overflow-wrap: anywhere;
}

/* Fit each draft inside the call's scrollable card list. Only the reader
   scrolls or collapses, so its footer stays available for long documents. */
.call-draft-card {
    display: flex;
    flex-direction: column;
    max-height: inherit;
}

.call-draft-card > details {
    min-height: 0;
    overflow: auto;
}

.call-draft-card > details > summary {
    cursor: pointer;
    padding: 0.2em;
}

.call-draft-card > details > summary:focus-visible {
    outline: 2px solid var(--apps-card-accent);
    outline-offset: -2px;
}

.call-draft-card > details > summary::-webkit-details-marker {
    display: none;
}

.call-draft-card > details > summary::after {
    content: '';
    flex: none;
    width: 0.55em;
    height: 0.55em;
    margin-inline: 0.45em;
    border-right: 2px solid var(--apps-card-muted);
    border-bottom: 2px solid var(--apps-card-muted);
    transform: rotate(-45deg);
}

.call-draft-card > details[open] > summary::after {
    transform: rotate(45deg);
}

.call-draft-card .app-action-card__document {
    max-height: none;
    overflow: visible;
    margin-top: 0.75em;
    padding-top: 0.75em;
    border-top: 1px solid var(--apps-card-rule);
}

.call-draft-card > footer {
    flex: none;
    margin-top: 0.75em;
    border-top: 1px solid var(--apps-card-rule);
}

.call-apps-result__title {
    display: block;
    margin-bottom: 0.4em;
    font-weight: 600;
}

.call-apps-result__app {
    color: var(--text-third);
    font-weight: 400;
}

.call-apps-result__list {
    display: grid;
    gap: 0.4em;
    margin: 0;
    padding: 0;
    list-style: none;
}

.call-apps-result__item {
    display: flex;
    flex-direction: column;
    padding-top: 0.4em;
    border-top: 1px solid var(--border-fourth);
}

.call-apps-result__item-title {
    font-weight: 600;
}

.call-apps-result__item-meta {
    color: var(--text-third);
    font-size: 0.88em;
}

.call-apps-notice {
    color: #8f2219;
    background: #fff1ef;
    border-color: #f3c3bd;
    font-weight: 600;
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .call-apps-notice {
    color: #ffb4a9;
    background: rgba(180, 35, 24, 0.24);
    border-color: rgba(255, 156, 143, 0.4);
}

/* ------------------------------------------------------------------------
 * Connected apps in "Investigación y Razonamiento"
 *
 * Three places share one element, the app's catalog logo on a white tile
 * (the logos are opaque, so the tile is white in every theme):
 *   - "Aplicaciones consultadas", the strip under the section's title;
 *   - the step of a read in the timeline, in place of the plain dot;
 *   - the open step, with the app's color as its rule and wash.
 * A saved voice call transcript reuses the open step for each app it used
 * (`.call-app-note`). `--app-accent` is set inline per app.
 * ---------------------------------------------------------------------- */

.research-history-section,
.research-app-tooltip,
.call-app-note {
    --research-app-ink: #17243a;
    --research-app-muted: #5c6b7e;
    --research-app-rule: rgba(23, 36, 58, 0.14);
    --research-app-surface: #ffffff;
    --research-app-tile: #ffffff;
    --research-app-progress: #1c5fa8;
    --research-app-progress-surface: #eef5fd;
    --research-app-success: #137a55;
    --research-app-success-surface: #eefaf4;
    --research-app-attention: #b42318;
    --research-app-attention-surface: #fff1ef;
    --research-app-quiet-surface: #f1f3f6;
}

/* The app's color as it is drawn, resolved on the element that names the app. */
.research-apps__app,
.history-indicator--app,
.research-activity-display--app {
    --research-app-accent: var(--app-accent, #5b6577);
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) :is(.research-history-section, .research-app-tooltip, .call-app-note) {
    --research-app-ink: #eef4fb;
    --research-app-muted: #afbdd0;
    --research-app-rule: rgba(226, 234, 245, 0.16);
    --research-app-surface: #182132;
    --research-app-progress: #8fc0ff;
    --research-app-progress-surface: rgba(28, 95, 168, 0.26);
    --research-app-success: #6fd1a4;
    --research-app-success-surface: rgba(19, 122, 85, 0.22);
    --research-app-attention: #ff9c8f;
    --research-app-attention-surface: rgba(180, 35, 24, 0.24);
    --research-app-quiet-surface: #1c2638;
}

/* Dark brand colors (Notion, Slack…) are lifted so they stay visible. */
body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) :is(.research-apps__app, .history-indicator--app, .research-activity-display--app) {
    --research-app-accent: color-mix(in srgb, var(--app-accent, #5b6577) 62%, #ffffff);
}

/* --- Aplicaciones consultadas ------------------------------------------ */

.research-apps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    min-width: 0;
    padding: 9px 16px 10px;
    border-top: 1px solid rgba(var(--theme-color-rgb), 0.1);
}

.research-apps__label {
    flex: 0 0 auto;
    color: var(--research-app-muted);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
}

.research-apps__list {
    display: flex;
    flex: 1 1 0;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.research-apps__list > li {
    display: flex;
    margin: 0;
    padding: 0;
}

.research-history-section .research-apps__app {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    background: var(--research-app-tile);
    border: 1px solid var(--research-app-rule);
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.research-apps__app > img {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 6px;
}

.research-history-section .research-apps__app:hover {
    border-color: var(--research-app-accent);
    box-shadow: 0 5px 12px color-mix(in srgb, var(--research-app-accent) 26%, transparent);
    transform: translateY(-2px);
}

.research-history-section .research-apps__app:focus-visible {
    outline: 2px solid var(--research-app-accent);
    outline-offset: 2px;
}

/* How many times the app was read, when more than once. */
.research-apps__count {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    color: var(--research-app-surface);
    background: var(--research-app-ink);
    border-radius: 8px;
    box-shadow: 0 0 0 1.5px var(--research-app-surface);
    font-size: 0.6rem;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
    pointer-events: none;
}

/* A finger gets a 44px target without the logos growing. */
@media (pointer: coarse) {
    .research-apps__list {
        gap: 10px;
    }

    .research-apps__app::before {
        position: absolute;
        inset: -8px;
        content: '';
    }
}

/* The name of an app, shown on `body` so the section cannot clip it. */
.research-app-tooltip {
    position: fixed;
    z-index: 1000001;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-width: min(17rem, calc(100vw - 16px));
    padding: 7px 10px 7px 12px;
    color: #f4f7fb;
    background: #17243a;
    border-left: 3px solid color-mix(in srgb, var(--app-accent, #5b6577) 70%, #ffffff);
    border-radius: 3px 8px 8px 3px;
    box-shadow: 0 8px 22px rgba(13, 22, 38, 0.28);
    font-family: 'Poppins', sans-serif;
    font-size: 0.78rem;
    line-height: 1.4;
    pointer-events: none;
}

.research-app-tooltip[hidden] {
    display: none;
}

.research-app-tooltip > strong {
    font-weight: 600;
}

.research-app-tooltip > span {
    color: #c3cedd;
    font-size: 0.72rem;
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .research-app-tooltip {
    background: #0c1322;
    box-shadow: 0 0 0 1px rgba(226, 234, 245, 0.14), 0 8px 22px rgba(0, 0, 0, 0.5);
}

/* --- The step of a read in the timeline -------------------------------- */

.research-history-indicators .history-indicator--app {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--research-app-progress);
    background: var(--research-app-tile);
    border: 1px solid var(--research-app-rule);
    border-radius: 6px;
    box-shadow: none;
    animation: none;
}

.research-history-indicators .history-indicator--app > .history-indicator__logo {
    display: block;
    width: 18px;
    height: 18px;
    object-fit: contain;
    border-radius: 5px;
}

.research-history-indicators .history-indicator--app > .history-indicator__glyph {
    font-size: 11px;
    line-height: 1;
}

.research-history-indicators .history-indicator--app:hover {
    border-color: var(--research-app-accent);
    transform: translateY(-1px);
}

.research-history-indicators .history-indicator--app.active {
    border-color: var(--research-app-accent);
    box-shadow: 0 0 0 2px var(--research-app-accent),
        0 5px 12px color-mix(in srgb, var(--research-app-accent) 30%, transparent);
    transform: scale(1.15);
    animation: none;
}

.research-history-indicators .history-indicator--app:focus-visible {
    outline: 2px solid var(--research-app-accent);
    outline-offset: 3px;
    transform: none;
}

/* The corner mark says how the read ended; a finished read needs none. */
.research-history-indicators .history-indicator--app::after {
    content: none;
}

.research-history-indicators .history-indicator--app:is(.is-running, .is-failed, .is-blocked, .is-stopped)::after {
    position: absolute;
    top: auto;
    right: -3px;
    bottom: -3px;
    left: auto;
    width: 8px;
    height: 8px;
    background: var(--research-app-progress);
    border-radius: 50%;
    box-shadow: 0 0 0 1.5px var(--research-app-surface);
    transform: none;
    content: '';
}

.research-history-indicators .history-indicator--app.is-running::after {
    animation: research-app-running 1.1s ease-in-out infinite;
}

.research-history-indicators .history-indicator--app.is-failed::after {
    background: var(--research-app-attention);
}

.research-history-indicators .history-indicator--app:is(.is-blocked, .is-stopped)::after {
    background: var(--research-app-muted);
}

.research-history-indicators .history-indicator--app:is(.is-blocked, .is-stopped) > :is(img, i) {
    filter: grayscale(1);
    opacity: 0.6;
}

@keyframes research-app-running {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.7); }
}

/* --- The open step ----------------------------------------------------- */

.research-history-section .research-activity-display--app {
    position: relative;
    overflow: hidden;
    padding-left: 20px;
    background: color-mix(in srgb, var(--research-app-accent) 5%, var(--research-app-surface));
    border-color: color-mix(in srgb, var(--research-app-accent) 24%, var(--research-app-rule));
    border-radius: 4px 12px 12px 4px;
}

.research-activity-display--app::before {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    background: var(--research-app-accent);
    content: '';
}

.research-app-header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid color-mix(in srgb, var(--research-app-accent) 18%, var(--research-app-rule));
}

.research-app-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: var(--research-app-progress);
    background: var(--research-app-tile);
    border: 1px solid var(--research-app-rule);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(23, 36, 58, 0.08);
    font-size: 18px;
}

.research-app-logo > img {
    display: block;
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
}

.research-app-heading {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.research-app-name {
    color: var(--research-app-ink);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.research-app-label {
    color: var(--research-app-muted);
    font-size: 0.82rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.research-app-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
    min-width: 0;
}

.research-app-status {
    padding: 3px 9px;
    color: var(--research-app-success);
    background: var(--research-app-success-surface);
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.research-activity-display--app-running .research-app-status {
    color: var(--research-app-progress);
    background: var(--research-app-progress-surface);
}

.research-activity-display--app-failed .research-app-status {
    color: var(--research-app-attention);
    background: var(--research-app-attention-surface);
}

.research-activity-display--app-blocked .research-app-status,
.research-activity-display--app-stopped .research-app-status {
    color: var(--research-app-muted);
    background: var(--research-app-quiet-surface);
}

.research-app-time {
    color: var(--research-app-muted);
    font-size: 0.72rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.research-activity-display--app .research-activity-message {
    color: var(--research-app-ink);
}

/* Narrow sections (a phone, the chat beside an open document). */
@container source-research (max-width: 24rem) {
    .research-apps {
        gap: 7px;
        padding: 9px 12px 11px;
    }

    .research-apps__label {
        flex: 1 0 100%;
    }

    .research-history-section .research-activity-display--app {
        padding-left: 15px;
    }

    .research-app-header {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .research-app-meta {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-top: 4px;
    }
}

/* --- A connected app used during a voice call ------------------------- */

/* One note of the saved transcript: the header of the open step, alone. */
.call-app-note {
    position: relative;
    overflow: hidden;
    margin: 0 0 0.75rem;
    padding: 10px 14px 10px 18px;
    background: color-mix(in srgb, var(--research-app-accent) 5%, var(--research-app-surface));
    border: 1px solid color-mix(in srgb, var(--research-app-accent) 24%, var(--research-app-rule));
    border-radius: 4px 12px 12px 4px;
    container: call-app-note / inline-size;
}

.call-app-note .research-app-header {
    margin: 0;
    padding: 0;
    border-bottom: 0;
}

/* A card left on screen that the user has not confirmed (yet). */
.call-app-note--prepared .research-app-status {
    color: var(--research-app-progress);
    background: var(--research-app-progress-surface);
}

/* «Mis archivos»: LEXIUS's own glyph instead of an app logo. */
.call-app-note .call-app-note__logo--library {
    color: var(--research-app-accent);
    background: var(--research-app-progress-surface);
    border-color: transparent;
}

/* --- A document written during a voice call --------------------------- */

/* The chat's document card (.lexiusdoc-card); a long document opens as a
   preview. Scoped to the card so it outranks Tailwind's resets. */
.lexiusdoc-card.call-document-note {
    --call-document-accent: var(--theme-primary, #0970e6);
    --call-document-accent-rgb: var(--theme-primary-rgb, 9, 112, 230);
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .lexiusdoc-card.call-document-note {
    --call-document-accent: #62a3f7;
    --call-document-accent-rgb: 98, 163, 247;
}

.call-document-note .call-document-note__body {
    position: relative;
}

.call-document-note .call-document-note__body.is-collapsed {
    max-height: 15rem;
    overflow: hidden;
}

.call-document-note .call-document-note__body.is-collapsed::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 4.5rem;
    background: linear-gradient(to bottom, transparent, var(--primary, #ffffff));
    content: '';
    pointer-events: none;
}

/* The page styles every h1, h4 and p with !important margins and sizes; the
   card keeps the proportions of the chat's document cards. */
.call-document-note .lexiusdoc-card__title,
.call-document-note .lexiusdoc-card__hint {
    margin: 0 !important;
}

.call-document-note .lexiusdoc-card__title {
    overflow-wrap: anywhere;
}

.call-document-note .lexiusdoc-card__content :is(h1, h2, h3, h4) {
    font-weight: 600 !important;
    line-height: 1.3;
}

.call-document-note .lexiusdoc-card__content h1 {
    font-size: 1.45rem !important;
}

.call-document-note .lexiusdoc-card__content h2 {
    font-size: 1.2rem !important;
}

.call-document-note .lexiusdoc-card__content :is(h3, h4) {
    font-size: 1.05rem !important;
}

.call-document-note .lexiusdoc-card__content p {
    margin: 0 0 0.85em !important;
}

.call-document-note .lexiusdoc-card__content ul {
    list-style: disc outside;
}

.call-document-note .lexiusdoc-card__content ol {
    list-style: decimal outside;
}

.lexiusdoc-card.call-document-note .call-document-note__toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 5px 12px;
    color: var(--call-document-accent);
    background: transparent;
    border: 1px solid rgba(var(--call-document-accent-rgb), 0.4);
    border-radius: 8px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.lexiusdoc-card.call-document-note .call-document-note__toggle:hover {
    background: rgba(var(--call-document-accent-rgb), 0.08);
    border-color: var(--call-document-accent);
}

.lexiusdoc-card.call-document-note .call-document-note__toggle:focus-visible {
    outline: 2px solid var(--call-document-accent);
    outline-offset: 2px;
}

.call-document-note .call-document-note__toggle .anticon {
    font-size: 11px;
}

.call-document-note .call-document-note__notice {
    margin: 12px 0 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
}

.call-document-note .call-document-note__notice--error {
    color: #c53030;
}

body:is(.darkmode, .mezenta, .purple, .dark-greeny, .light-greeny, .red-dark, .blue-green-gradient, .pink-purple-gradient) .call-document-note .call-document-note__notice--error {
    color: #ff9c8f;
}

@media (prefers-reduced-motion: reduce) {
    .lexiusdoc-card.call-document-note .call-document-note__toggle {
        transition: none;
    }
}

@container call-app-note (max-width: 24rem) {
    .call-app-note .research-app-header {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .call-app-note .research-app-meta {
        grid-column: 1 / -1;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-top: 4px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .research-history-section .research-apps__app,
    .research-history-indicators .history-indicator--app,
    .research-history-indicators .history-indicator--app::after {
        animation: none !important;
        transition: none !important;
    }

    .research-history-section .research-apps__app:hover,
    .research-history-indicators .history-indicator--app:hover,
    .research-history-indicators .history-indicator--app.active {
        transform: none;
    }
}

@media (prefers-contrast: more) {
    .research-history-section .research-apps__app,
    .research-history-indicators .history-indicator--app,
    .research-app-logo {
        border-color: var(--research-app-ink);
    }
}
