:root {
    color-scheme: dark;
    --abyss: #111418;
    --night: #181b21;
    --night-2: #272c35;
    --line: #3a414d;
    --text: #eceef1;
    --mist: #aab1bc;
    --moon: #f1d96b;
    --on-moon: #1a1704;
}

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

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

/* Burbujas de fondo */
#bubbles {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.top,
.page,
footer {
    position: relative;
    z-index: 1;
}

/* ---------- Estructura ---------- */
.top {
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: 24px 24px 0;
}

.back {
    color: var(--mist);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.back:hover,
.help a:hover {
    background: var(--moon);
    color: var(--on-moon);
}

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

.page {
    flex: 1;
    width: min(720px, 100%);
    margin: 0 auto;
    padding: clamp(24px, 5vw, 48px) 24px 48px;
    text-align: center;
}

h1 {
    font-family: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
    font-weight: 800;
    font-size: clamp(3rem, 10vw, 5.5rem);
    line-height: 1;
    letter-spacing: -0.035em;
}

.lead {
    margin: 20px auto 0;
    max-width: 28ch;
    font-size: clamp(1.15rem, 2.4vw, 1.4rem);
    font-weight: 500;
    line-height: 1.4;
    color: var(--mist);
}

/* ---------- Chat ---------- */
.chat {
    margin-top: 40px;
    text-align: left;
    background: var(--night);
    border: 1px solid #2c323c;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.75);
}

#chat-messages {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: min(28rem, 55svh);
    padding: 24px 20px;
    overflow-y: auto;
    scroll-behavior: smooth;
}

.message {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 18px;
    overflow-wrap: anywhere;
}

.message p {
    margin: 0;
}

.user-message {
    align-self: flex-end;
    background: var(--moon);
    color: var(--on-moon);
    font-weight: 600;
    border-bottom-right-radius: 6px;
}

.bot-message {
    align-self: flex-start;
    background: var(--night-2);
    border-bottom-left-radius: 6px;
}

.loading-indicator {
    color: var(--mist);
}

/* Tarjeta de resultado */
.video-download-card img {
    display: block;
    width: 100%;
    max-height: 170px;
    margin-bottom: 10px;
    border-radius: 10px;
    object-fit: cover;
}

.card-badge {
    font-size: 0.85rem;
    color: var(--mist);
}

.card-title {
    margin: 2px 0 4px;
    font-weight: 600;
}

.download-link {
    display: inline-block;
    margin-top: 10px;
    padding: 9px 18px;
    border-radius: 999px;
    background: var(--moon);
    color: var(--on-moon);
    font-weight: 600;
    text-decoration: none;
}

.download-link:hover,
#send-button:hover {
    filter: brightness(1.08);
}

/* Selector de YouTube */
.yt-chooser span {
    display: block;
    margin-bottom: 10px;
}

.yt-buttons {
    display: flex;
    gap: 8px;
}

.yt-btn {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--night);
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s;
}

.yt-btn:hover:not(:disabled) {
    border-color: var(--moon);
}

.yt-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Barra de escritura */
.input-row {
    display: flex;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid #2c323c;
}

#user-input {
    flex: 1;
    min-width: 0;
    padding: 13px 20px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--night-2);
    color: var(--text);
    font: inherit;
}

#user-input::placeholder {
    color: var(--mist);
}

#send-button {
    padding: 0 22px;
    border: 0;
    border-radius: 999px;
    background: var(--moon);
    color: var(--on-moon);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

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

/* ---------- Debajo del chat ---------- */
.platforms {
    display: flex;
    flex-wrap: nowrap;
    justify-content: safe center;
    gap: 6px;
    margin: 28px 0 0;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    scrollbar-width: none;
}

.platforms::-webkit-scrollbar {
    display: none;
}

.platforms li {
    flex: none;
    padding: 3px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.85rem;
    white-space: nowrap;
    color: var(--mist);
}

.help {
    margin-top: 20px;
    color: var(--mist);
}

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

footer {
    padding: 0 24px 32px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--mist);
}

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

    .loading-indicator {
        animation: pulse 1.2s ease-in-out infinite;
    }
}

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

@keyframes pulse {
    50% { opacity: 0.5; }
}
