:root {
    --smoke: #d7dbe0;
    --ink: #14171c;
    --ink-soft: #434a54;
    --night: #181b21;
    --night-2: #272c35;
    --line: #3a414d;
    --mist: #aab1bc;
    --moon: #f1d96b;
}

* {
    box-sizing: border-box;
    margin: 0;
}

body {
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background: var(--smoke);
    color: var(--ink);
    font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 1.0625rem;
    line-height: 1.6;
}

/* ---------- Layout ---------- */
.page {
    flex: 1;
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: clamp(40px, 8vw, 96px) 24px;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: clamp(40px, 7vw, 96px);
    align-items: center;
}

/* ---------- Intro ---------- */
h1 {
    font-family: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
    font-weight: 800;
    font-size: clamp(3.4rem, 9vw, 6.5rem);
    line-height: 0.95;
    letter-spacing: -0.035em;
    max-width: 6ch;
}

.lead {
    margin-top: 28px;
    max-width: 30ch;
    font-size: clamp(1.25rem, 2.4vw, 1.55rem);
    font-weight: 500;
    line-height: 1.4;
}

.about {
    margin-top: 20px;
    max-width: 46ch;
    color: var(--ink-soft);
}

.about a {
    color: var(--ink);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.about a:hover {
    background: var(--moon);
}

a:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
    border-radius: 2px;
}

/* ---------- Columna derecha: chat + botón ---------- */
.side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.cta {
    display: block;
    padding: 16px 20px;
    background: var(--night);
    color: #eceef1;
    border: 1px solid var(--night);
    border-radius: 16px;
    text-decoration: none;
    box-shadow: 0 12px 24px -16px rgba(20, 23, 28, 0.55);
    transition: border-color 0.15s;
}

.cta:hover {
    border-color: var(--moon);
}

.cta:focus-visible {
    outline: 3px solid var(--ink);
    outline-offset: 3px;
}

.cta strong {
    display: block;
    font-weight: 600;
}

.cta span {
    font-size: 0.9rem;
    color: var(--mist);
}

/* ---------- Chat ---------- */
.chat {
    background: var(--night);
    color: #eceef1;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 48px -24px rgba(20, 23, 28, 0.55);
}

.chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #2c323c;
}

.chat-head h2 {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
}

.chat-head p {
    font-size: 0.85rem;
    line-height: 1.2;
    color: var(--mist);
}

.avatar {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--night-2);
    color: var(--moon);
    font-weight: 700;
    overflow: hidden;
}

/* Inicial que se ve solo si la imagen no existe */
.avatar::before {
    content: attr(data-initial);
}

.avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--night-2);
}

.thread {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 20px;
    min-height: 25rem;
}

.msg {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 18px;
}

.msg.me {
    align-self: flex-end;
    background: var(--moon);
    color: #1a1704;
    font-weight: 600;
    border-bottom-right-radius: 6px;
}

.msg.bot {
    align-self: flex-start;
    width: min(100%, 22rem);
    background: var(--night-2);
    border-bottom-left-radius: 6px;
}

.msg.bot > p {
    margin-bottom: 10px;
}

.menu {
    display: grid;
    gap: 8px;
    padding: 0;
    list-style: none;
}

.menu a {
    display: block;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--night);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s;
}

.menu a:hover {
    border-color: var(--moon);
}

.menu a:focus-visible {
    outline-color: var(--moon);
    border-radius: 12px;
}

.menu strong {
    display: block;
    font-weight: 600;
}

.menu span {
    font-size: 0.9rem;
    color: var(--mist);
}

/* Typing indicator */
.typing {
    display: none;
    align-self: flex-start;
    gap: 5px;
    padding: 16px 18px;
    background: var(--night-2);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.typing.is-in {
    display: flex;
}

.typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--mist);
}

/* Without JS everything is visible; with JS the thread plays once */
.js .step {
    display: none;
}

.js .step.is-in {
    display: block;
}

@media (prefers-reduced-motion: no-preference) {
    .js .step.is-in,
    .typing.is-in {
        animation: pop 0.25s ease-out;
    }

    .typing i {
        animation: blink 1s infinite;
    }

    .typing i:nth-child(2) { animation-delay: 0.15s; }
    .typing i:nth-child(3) { animation-delay: 0.3s; }
}

@keyframes pop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@keyframes blink {
    0%, 60%, 100% { opacity: 0.35; }
    30%           { opacity: 1; }
}

/* ---------- Footer ---------- */
footer {
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: 0 24px 32px;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
    .page {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .thread {
        min-height: 22rem;
    }
}