:root {
    --ixchel-ink: #172033;
    --ixchel-muted: #687287;
    --ixchel-paper: #ffffff;
    --ixchel-mist: #f4f6f9;
    --ixchel-line: #e3e8ef;
    --ixchel-accent: #b66d49;
}

body.ixchel-page {
    min-width: 320px;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow: hidden;
    color: var(--ixchel-ink);
    background:
        radial-gradient(circle at 9% 12%, color-mix(in srgb, var(--ixchel-brand, #142b5c) 12%, transparent) 0, transparent 30%),
        linear-gradient(145deg, #f8fafc 0%, #eef2f6 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.ixchel-page * {
    box-sizing: border-box;
}

.ixchel-app {
    width: min(760px, calc(100% - 32px));
    height: calc(100vh - 32px);
    height: calc(100dvh - 32px);
    margin: 16px auto;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid rgba(23, 32, 51, 0.08);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 24px 80px rgba(21, 35, 58, 0.14);
    backdrop-filter: blur(16px);
}

.ixchel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--ixchel-line);
    background: rgba(255, 255, 255, 0.92);
}

.ixchel-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ixchel-eyebrow,
.ixchel-event-name,
.ixchel-intro-kicker,
.ixchel-disclaimer {
    margin: 0;
}

.ixchel-eyebrow {
    color: var(--ixchel-brand, #142b5c);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.ixchel-event-name {
    max-width: 520px;
    margin-top: 2px;
    overflow: hidden;
    color: var(--ixchel-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ixchel-avatar {
    flex: 0 0 auto;
    display: grid;
    overflow: hidden;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background:white;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    font-family: Georgia, serif;
    font-weight: 700;
    letter-spacing: -0.05em;
}

.ixchel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ixchel-avatar--header {
    width: 42px;
    height: 42px;
    font-size: 16px;
}

.ixchel-avatar--large {
    width: 74px;
    height: 74px;
    font-size: 25px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.ixchel-status {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    border-radius: 999px;
    color: #42604e;
    background: #edf8f1;
    font-size: 12px;
    font-weight: 700;
}

.ixchel-header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 9px;
}

.ixchel-clear {
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--ixchel-line);
    border-radius: 999px;
    color: #586276;
    background: #fff;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.ixchel-clear:hover {
    color: #923f3f;
    border-color: #e8caca;
    background: #fff8f8;
}

.ixchel-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3ba66a;
    box-shadow: 0 0 0 4px rgba(59, 166, 106, 0.12);
}

.ixchel-chat {
    display: flex;
    flex-direction: column;
    gap: 13px;
    overflow-y: auto;
    padding: 34px 26px 25px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

.ixchel-intro {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 11px;
    margin: 5px 0 10px;
}

.ixchel-intro-kicker {
    color: var(--ixchel-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ixchel-bubble {
    width: fit-content;
    max-width: min(88%, 560px);
    padding: 13px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.55;
    animation: ixchel-bubble-in 180ms ease-out both;
}

.ixchel-bubble p {
    margin: 0;
    white-space: pre-wrap;
}

.ixchel-heading {
    display: block;
    margin: 7px 0 3px;
    font-size: 1.12em;
    line-height: 1.35;
}

.ixchel-heading:first-child {
    margin-top: 0;
}

.ixchel-bubble a {
    color: var(--ixchel-brand, #142b5c);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ixchel-bubble--user a {
    color: #fff;
}

.ixchel-bubble--assistant {
    align-self: flex-start;
    border: 1px solid var(--ixchel-line);
    border-bottom-left-radius: 5px;
    background: var(--ixchel-paper);
    box-shadow: 0 5px 20px rgba(23, 32, 51, 0.04);
}

.ixchel-bubble--user {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    color: #fff;
    background: var(--ixchel-brand, #142b5c);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--ixchel-brand, #142b5c) 22%, transparent);
}

.ixchel-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
}

.ixchel-history {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.ixchel-chip {
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid color-mix(in srgb, var(--ixchel-brand, #142b5c) 20%, white);
    border-radius: 999px;
    color: var(--ixchel-brand, #142b5c);
    background: color-mix(in srgb, var(--ixchel-brand, #142b5c) 6%, white);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 150ms ease, background 150ms ease;
}

.ixchel-chip:hover {
    transform: translateY(-1px);
    background: color-mix(in srgb, var(--ixchel-brand, #142b5c) 11%, white);
}


.ixchel-typing {
    display: flex;
    gap: 5px;
    padding: 16px 18px;
}

.ixchel-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aab2c1;
    animation: ixchel-pulse 1.1s ease-in-out infinite;
}

.ixchel-typing span:nth-child(2) {
    animation-delay: 120ms;
}

.ixchel-typing span:nth-child(3) {
    animation-delay: 240ms;
}

.ixchel-composer-wrap {
    padding: 14px 18px 16px;
    border-top: 1px solid var(--ixchel-line);
    background: rgba(255, 255, 255, 0.96);
}

.ixchel-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 7px 7px 7px 16px;
    border: 1px solid #dbe1e9;
    border-radius: 22px;
    background: var(--ixchel-mist);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.ixchel-composer:focus-within {
    border-color: color-mix(in srgb, var(--ixchel-brand, #142b5c) 38%, white);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--ixchel-brand, #142b5c) 7%, transparent);
}

.ixchel-composer textarea {
    width: 100%;
    max-height: 120px;
    min-height: 38px;
    overflow-y: auto;
    resize: none;
    border: 0;
    outline: 0;
    color: var(--ixchel-ink);
    background: transparent;
    font: inherit;
    font-size: 15px;
    line-height: 1.45;
}

.ixchel-composer textarea::placeholder {
    color: #8e97a7;
}

.ixchel-send {
    flex: 0 0 auto;
    display: grid;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    place-items: center;
    color: #fff;
    background: var(--ixchel-brand, #142b5c);
    cursor: pointer;
    transition: opacity 150ms ease, transform 150ms ease;
}

.ixchel-send:not(:disabled):hover {
    transform: scale(1.04);
}

.ixchel-send:disabled {
    cursor: default;
    opacity: 0.35;
}

.ixchel-disclaimer {
    margin-top: 9px;
    color: #8a93a3;
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
}

.ixchel-dialog {
    width: min(420px, calc(100% - 32px));
    padding: 24px;
    border: 0;
    border-radius: 22px;
    color: var(--ixchel-ink);
    background: #fff;
    box-shadow: 0 24px 80px rgba(21, 35, 58, 0.3);
    box-sizing: border-box;
}

.ixchel-dialog::backdrop {
    background: rgba(18, 27, 45, 0.45);
    backdrop-filter: blur(3px);
}

.ixchel-dialog-content {
    padding: 0;
}

.ixchel-dialog-content h2 {
    margin: 0 0 12px;
    font-family: Georgia, serif;
    font-size: 24px;
    line-height: 1.2;
}

.ixchel-dialog-content p {
    margin: 0 0 12px;
    color: #525d70;
    font-size: 14px;
    line-height: 1.55;
}

.ixchel-dialog-content .ixchel-dialog-note {
    color: #737d8d;
    font-size: 12px;
}

.ixchel-dialog-content .ixchel-dialog-error {
    color: #a33d3d;
    font-weight: 700;
}

.ixchel-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 20px;
}

.ixchel-dialog-actions button {
    min-height: 42px;
    padding: 9px 15px;
    border-radius: 12px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.ixchel-dialog-cancel {
    border: 1px solid var(--ixchel-line);
    color: var(--ixchel-ink);
    background: #fff;
}

.ixchel-dialog-confirm {
    border: 1px solid #9f4141;
    color: #fff;
    background: #9f4141;
}

.ixchel-dialog-actions button:disabled {
    cursor: wait;
    opacity: 0.55;
}

@keyframes ixchel-bubble-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes ixchel-pulse {
    0%,
    70%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    35% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

@media (max-width: 640px) {
    body.ixchel-page {
        background: #fff;
    }

    .ixchel-app {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        border: 0;
        border-radius: 0;
    }

    .ixchel-header {
        padding: 13px 16px;
    }

    .ixchel-event-name {
        max-width: 195px;
    }

    .ixchel-status {
        display: none;
    }

    .ixchel-chat {
        padding: 25px 16px 18px;
    }

    .ixchel-intro {
        margin-top: 0;
    }

    .ixchel-avatar--large {
        width: 64px;
        height: 64px;
    }

    .ixchel-bubble {
        max-width: 92%;
        font-size: 14px;
    }

    .ixchel-composer-wrap {
        padding: 10px 12px max(12px, env(safe-area-inset-bottom));
    }

    .ixchel-disclaimer {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
