:root {
    color-scheme: light;
    --lc-navy: #092b68;
    --lc-action: #1e5aa8;
    --lc-bg: #f4f7fc;
    --lc-surface: #ffffff;
    --lc-text: #10213d;
    --lc-muted: #53657f;
    --lc-border: #d6e2f3;
    --lc-chip: #eef3fb;
    --lc-focus: #c86d1a;
    --lc-warning-bg: #fff6db;
    --lc-warning-border: #f0d99c;
    --lc-warning-text: #5b4b1d;
    --lc-shadow-soft: 0 6px 24px rgb(9 43 104 / 8%);
    --lc-shadow-card: 0 12px 30px rgb(9 43 104 / 10%);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-width: 320px;
}

body {
    font-family: "Manrope", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--lc-text);
    background: linear-gradient(180deg, #eff4fd 0, var(--lc-bg) 180px);
    line-height: 1.55;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--lc-action);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button, textarea, input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: .62;
}

:focus-visible {
    outline: 3px solid var(--lc-focus);
    outline-offset: 2px;
}

.shell-width {
    width: min(100% - 2rem, 1040px);
    margin-inline: auto;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid var(--lc-border);
    background: color-mix(in srgb, var(--lc-surface) 96%, transparent);
    backdrop-filter: blur(8px);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: min(100% - 2rem, 1040px);
    margin-inline: auto;
    padding: .72rem 0;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: .65rem;
}

.brand-logo,
.footer-logo,
.avatar img {
    object-fit: contain;
}

.brand-logo {
    flex-shrink: 0;
    width: auto;
    height: clamp(34px, 6.8vw, 50px);
    max-width: min(62vw, 320px);
}

.brand-copy {
    display: grid;
    gap: .06rem;
}

.brand-name {
    margin: 0;
    font-size: 1.48rem;
    font-weight: 800;
    line-height: 1.04;
    color: var(--lc-navy);
}

.brand-tagline {
    margin: 0;
    color: var(--lc-muted);
    font-size: .75rem;
    letter-spacing: .03em;
    text-transform: uppercase;
}

.primary-button,
.secondary-button {
    min-height: 44px;
    padding: .58rem 1.05rem;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 700;
}

.primary-button {
    background: var(--lc-navy);
    color: #fff;
}

.primary-button:hover {
    background: #0b367f;
}

.secondary-button {
    border-color: #b9cdec;
    background: #fff;
    color: var(--lc-navy);
}

.secondary-button:hover {
    border-color: var(--lc-action);
    background: #f3f7fd;
}

.main-shell {
    display: grid;
    gap: 1rem;
    padding: 1rem 0 2.1rem;
}

.welcome-card {
    border-radius: 16px;
    background: var(--lc-surface);
    box-shadow: var(--lc-shadow-soft);
    padding: 1.6rem 1.35rem;
}

h1 {
    margin: 0;
    max-width: 24ch;
    font-size: clamp(1.4rem, 1.16rem + 1.2vw, 2.1rem);
    line-height: 1.22;
    letter-spacing: -.015em;
    text-wrap: balance;
}

.introduction {
    margin: .7rem 0 0;
    max-width: 54ch;
    font-size: clamp(1rem, .97rem + .18vw, 1.09rem);
    line-height: 1.55;
    color: var(--lc-text);
    text-wrap: pretty;
}

.introduction-note {
    margin: .5rem 0 0;
    max-width: 62ch;
    font-size: .94rem;
    line-height: 1.62;
    color: var(--lc-muted);
    text-wrap: pretty;
}

.journey {
    margin-top: 1.35rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
}

.journey-step {
    display: inline-flex;
    align-items: center;
    gap: .42rem;
    background: var(--lc-chip);
    color: var(--lc-navy);
    border: 1px solid #c9d9ef;
    border-radius: 999px;
    padding: .42rem .76rem;
    font-size: .9rem;
    font-weight: 600;
}

.journey-icon,
.journey-arrow,
.send-icon,
.trust-icon svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: currentColor;
}

.journey-arrow {
    color: #7b8ca6;
}

.section-title {
    margin: 0 0 .44rem;
    font-size: .95rem;
    color: var(--lc-muted);
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: .48rem;
}

.suggestion-chip {
    min-height: 38px;
    border: 1px solid #c7d6ed;
    background: #fff;
    color: var(--lc-text);
    border-radius: 999px;
    padding: .48rem .78rem;
    font-size: .9rem;
    transition: .2s ease;
}

.suggestion-chip:hover {
    border-color: var(--lc-action);
    background: #f2f7ff;
}

.suggestion-chip:active {
    transform: translateY(1px);
}

.composer-panel {
    display: grid;
    gap: .42rem;
}

.composer {
    border: 1px solid #c6d7ef;
    border-radius: 14px;
    background: #fff;
    box-shadow: var(--lc-shadow-card);
    padding: .62rem;
}

.composer label {
    display: block;
    margin: .2rem .33rem .45rem;
    font-size: .85rem;
    font-weight: 650;
    color: var(--lc-muted);
}

.composer-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .58rem;
    align-items: end;
}

textarea {
    width: 100%;
    min-height: 56px;
    max-height: 220px;
    border: 1px solid var(--lc-border);
    border-radius: 10px;
    background: #fff;
    padding: .72rem;
    color: var(--lc-text);
    resize: vertical;
}

textarea:disabled {
    background: #f8fbff;
}

#submit {
    display: inline-flex;
    align-items: center;
    gap: .34rem;
}

.composer-meta {
    margin-top: .42rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem;
}

.helper-text,
.character-count,
.disclaimer {
    margin: 0;
    color: var(--lc-muted);
    font-size: .8rem;
}

.disclaimer {
    text-align: center;
}

.conversation {
    margin-top: .35rem;
    min-height: clamp(280px, 46vh, 560px);
    max-height: min(64vh, 720px);
    overflow-y: auto;
    border: 1px solid #c9d8ee;
    border-radius: 14px;
    background: linear-gradient(180deg, #f8fbff 0, #ffffff 50%);
    box-shadow: var(--lc-shadow-soft);
    padding: .72rem;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: .82rem;
}

.message {
    max-width: min(100%, 860px);
    border: 1px solid var(--lc-border);
    border-radius: 14px;
    background: #fff;
    padding: .76rem .92rem;
    box-shadow: var(--lc-shadow-soft);
    overflow-wrap: anywhere;
    scroll-margin-top: 82px;
}

body.chat-active .composer-panel {
    position: sticky;
    bottom: .55rem;
    z-index: 8;
}

body.chat-active .composer {
    box-shadow: 0 12px 28px rgb(9 43 104 / 14%);
}

.message.user {
    margin-left: auto;
    background: #e8f0ff;
    border-color: #bad0f1;
}

.message.loading,
.message.assistant,
.message.error {
    margin-right: auto;
}

.message.error {
    border-color: #f0d0a4;
    background: #fff8ea;
}

.message-header {
    display: inline-flex;
    align-items: center;
    gap: .44rem;
}

.avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid #bdd0eb;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .12rem;
}

.avatar img {
    width: 1.72rem;
    height: 1.72rem;
}

.message-role {
    font-size: .86rem;
    color: var(--lc-navy);
    font-weight: 700;
}

.message.user .message-role {
    color: #163261;
}

.message-text {
    margin: .46rem 0 0;
    white-space: pre-wrap;
}

.message-rich {
    white-space: normal;
}

.message-rich p,
.message-rich ul,
.message-rich ol {
    margin: 0 0 .68rem;
}

.message-rich p:last-child,
.message-rich ul:last-child,
.message-rich ol:last-child {
    margin-bottom: 0;
}

.message-rich ul,
.message-rich ol {
    padding-left: 1.3rem;
}

.answer-heading {
    font-weight: 800;
}

.article-reference,
.text-button {
    border: 1px solid #bfd2ee;
    border-radius: 8px;
    background: #fff;
    color: var(--lc-action);
    min-height: 34px;
    padding: .3rem .56rem;
    font-size: .82rem;
    font-weight: 650;
}

.article-reference {
    display: inline;
    margin: 0 .15rem;
    padding: .05rem .32rem;
    min-height: auto;
    background: #eaf2ff;
}

.article-reference:hover,
.text-button:hover {
    border-color: var(--lc-action);
    background: #ecf4ff;
}

.message-actions {
    margin-top: .72rem;
    display: flex;
    flex-wrap: wrap;
    gap: .42rem;
}

.text-button-primary {
    margin-left: auto;
    color: var(--lc-navy);
    background: #eef4ff;
}

.report-status {
    margin: .6rem 0 0;
    max-width: 58ch;
    font-size: .86rem;
    line-height: 1.55;
    color: var(--lc-muted);
    text-wrap: pretty;
}

.report-status.is-ok {
    color: #1f6b3f;
    font-weight: 600;
}

.report-status.is-fail {
    color: #9a3412;
}

.source-list {
    margin-top: .78rem;
    display: grid;
    gap: .55rem;
}

.source-card {
    border: 1px solid #c7d8ef;
    border-radius: 12px;
    background: #f9fbff;
    padding: .74rem;
}

.source-label {
    margin: 0;
    font-size: .77rem;
    color: var(--lc-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.source-title {
    margin: .2rem 0 .5rem;
    font-size: 1rem;
    color: var(--lc-navy);
}

.source-excerpt {
    margin: 0;
    border-left: 3px solid #b5caea;
    padding: .46rem .64rem;
    background: #fff;
    color: #2e3f59;
    font-style: italic;
}

.source-actions {
    margin-top: .6rem;
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.reference-note {
    margin: .72rem 0 0;
    color: var(--lc-muted);
    font-size: .85rem;
}

.context-warning {
    border: 1px solid var(--lc-warning-border);
    background: var(--lc-warning-bg);
    color: var(--lc-warning-text);
    border-radius: 12px;
    padding: .85rem 1rem;
}

.context-warning p {
    margin: 0;
}

.trust-section {
    padding-top: .55rem;
}

.trust-section h2,
.faq h2 {
    margin: 0 0 .86rem;
    font-size: 1.1rem;
}

.trust-grid {
    display: grid;
    gap: .62rem;
}

.trust-card {
    border: 1px solid var(--lc-border);
    border-radius: 12px;
    background: #fff;
    padding: .9rem;
    text-align: center;
}

.trust-icon {
    width: 2.3rem;
    height: 2.3rem;
    margin: 0 auto .5rem;
    border-radius: 50%;
    background: #edf4ff;
    color: var(--lc-action);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.trust-card h3 {
    margin: 0;
    font-size: 1rem;
}

.trust-card p {
    margin: .42rem 0 0;
    color: var(--lc-muted);
    font-size: .9rem;
}

.faq {
    display: grid;
    gap: .45rem;
}

.faq-item {
    border: 1px solid var(--lc-border);
    border-radius: 12px;
    background: #fff;
    overflow: clip;
}

.faq-toggle {
    width: 100%;
    text-align: left;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--lc-text);
    font-weight: 700;
    padding: .85rem 1rem;
}

.faq-toggle::after {
    content: "+";
    float: right;
    color: var(--lc-muted);
}

.faq-toggle[aria-expanded="true"]::after {
    content: "−";
}

.faq-panel {
    padding: 0 1rem .85rem;
    color: var(--lc-muted);
}

.faq-panel p {
    margin: 0;
}

.site-footer {
    border-top: 1px solid var(--lc-border);
    background: #fff;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .8rem 1.2rem;
    flex-wrap: wrap;
    width: min(100% - 2rem, 1040px);
    margin-inline: auto;
    padding: 1rem 0 1.1rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: .45rem;
}

.footer-logo {
    width: auto;
    height: 1.45rem;
    max-width: 150px;
}

.footer-legal {
    margin: 0;
    color: var(--lc-muted);
    font-size: .9rem;
}

.footer-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--lc-muted);
    font-weight: 600;
}

.footer-links a:hover {
    color: var(--lc-action);
    text-decoration: none;
}

dialog {
    width: min(calc(100% - 1.4rem), 40rem);
    max-height: min(80vh, 760px);
    border: 1px solid var(--lc-border);
    border-radius: 14px;
    background: #fff;
    color: var(--lc-text);
    padding: 1.25rem 1.35rem;
    box-shadow: 0 24px 80px rgb(11 36 85 / 30%);
}

dialog::backdrop {
    background: rgb(11 33 74 / 55%);
}

.dialog-header,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .7rem;
}

.dialog-header {
    border-bottom: 1px solid var(--lc-border);
    padding-bottom: .7rem;
}

.dialog-header h2 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.3;
    letter-spacing: -.01em;
    color: var(--lc-navy);
}

.icon-button {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid #c4d5eb;
    border-radius: 50%;
    background: #f5f9ff;
    color: var(--lc-navy);
    font-size: 1.3rem;
}

.article-text {
    max-height: 50vh;
    overflow-y: auto;
    /* Sin esto, al llegar al final del articulo el scroll sigue en la pagina
       de atras y el modal parece que "salta". */
    overscroll-behavior: contain;
    border-left: 3px solid #b8cced;
    border-radius: 4px 10px 10px 4px;
    background: #f7fbff;
    margin: .85rem 0;
    padding: 1.05rem 1.15rem;
}

.article-paragraph {
    /* Prosa juridica: sin limitar la medida el dialogo de 42rem da lineas de
       ~76 caracteres, muy por encima del rango comodo de lectura. */
    max-width: 64ch;
    margin: 0 0 .95rem;
    font-size: 1rem;
    line-height: 1.72;
    color: var(--lc-text);
    text-wrap: pretty;
}

.article-paragraph:last-child {
    margin-bottom: 0;
}

.dialog-status {
    min-height: 1.3em;
    margin: 0;
    color: var(--lc-muted);
    font-size: .9rem;
}

.dialog-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: .65rem;
}

.page-shell {
    width: min(100% - 1.5rem, 860px);
    margin: 0 auto;
    padding: clamp(1.4rem, 3vw, 2.3rem) 0 2rem;
}

.page-card {
    border: 1px solid var(--lc-border);
    border-radius: 14px;
    background: var(--lc-surface);
    box-shadow: var(--lc-shadow-soft);
    padding: clamp(1rem, 2vw, 1.5rem);
    margin-bottom: 1rem;
}

.page-card h1,
.page-card h2,
.page-card h3 {
    margin: 0 0 .65rem;
    color: var(--lc-navy);
}

.page-card p,
.page-card li {
    color: #2b3a52;
}

.page-card ul,
.page-card ol {
    margin: 0 0 1rem;
    padding-left: 1.3rem;
}

.contact-form {
    display: grid;
    gap: .9rem;
}

.form-row label {
    display: block;
    margin-bottom: .35rem;
    font-size: .9rem;
    font-weight: 700;
}

.form-row input,
.form-row textarea {
    width: 100%;
    border: 1px solid var(--lc-border);
    border-radius: 10px;
    padding: .65rem .7rem;
    background: #fff;
    color: var(--lc-text);
}

.form-row textarea {
    min-height: 140px;
    max-height: 280px;
    resize: vertical;
}

.form-row input[aria-invalid="true"],
.form-row textarea[aria-invalid="true"] {
    border-color: #b33d3d;
}

.form-error {
    margin: .35rem 0 0;
    color: #8a2c2c;
    font-size: .84rem;
}

.form-status {
    min-height: 1.5em;
    margin: 0;
    color: var(--lc-muted);
}

.form-status.success {
    color: #185f32;
}

.form-status.error {
    color: #8a2c2c;
}

.honeypot-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

@media (min-width: 900px) {
    .main-shell {
        gap: 1.1rem;
        padding-top: 1.1rem;
    }

    .composer {
        padding: .75rem;
    }

    .trust-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .welcome-card {
        padding: 1.35rem 1.15rem;
    }

    /* Los tres pasos no caben en una fila: sin las flechas el salto de
       línea no deja un conector suelto al final. */
    .journey-arrow {
        display: none;
    }

    .journey {
        gap: .4rem;
    }

    .journey-step {
        font-size: .86rem;
        padding: .38rem .7rem;
    }
}

@media (max-width: 760px) {
    .header-content {
        align-items: flex-start;
    }

    .brand-tagline {
        display: none;
    }

    .composer-row {
        grid-template-columns: 1fr;
    }

    #submit {
        justify-content: center;
    }

    .text-button-primary {
        margin-left: 0;
    }

    .footer-content {
        justify-content: center;
        text-align: center;
    }

    .footer-links {
        justify-content: center;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .message {
        animation: message-in .16s ease-out;
    }

    .faq-panel {
        animation: faq-in .18s ease-out;
    }

    @keyframes message-in {
        from {
            opacity: 0;
            transform: translateY(4px);
        }
    }

    @keyframes faq-in {
        from {
            opacity: 0;
            transform: translateY(-2px);
        }
    }
}
