:root {
    color-scheme: dark;
    font-family: var(--font, Manrope, Inter, system-ui, sans-serif);
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    min-height: 100%;
    background: #071426;
}

body {
    min-height: 100svh;
    margin: 0;
    color: var(--primary);
    background: var(--page-bg);
    font-family: var(--font);
    font-size: var(--base-size);
    font-weight: var(--font-weight);
    line-height: 1.55;
    overflow-x: hidden;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.background,
.background::after,
.background-image,
.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
}

.background { z-index: -2; background: var(--page-bg); }
.background-image { opacity: var(--bg-opacity); background-position: center; background-size: cover; }
.background::after { content: ""; background: color-mix(in srgb, var(--overlay) 48%, transparent); }

.stars {
    opacity: .34;
    background-image:
        radial-gradient(circle at 18% 20%, var(--accent) 0 1px, transparent 1.7px),
        radial-gradient(circle at 78% 15%, rgba(255,255,255,.9) 0 1px, transparent 1.7px),
        radial-gradient(circle at 67% 71%, rgba(255,255,255,.72) 0 1px, transparent 1.6px),
        radial-gradient(circle at 27% 84%, var(--accent) 0 1px, transparent 1.7px);
    background-size: 220px 220px, 280px 280px, 340px 340px, 410px 410px;
}

.link-page {
    width: min(calc(100% - 28px), var(--content-width));
    min-height: 100svh;
    margin: 0 auto;
    padding: max(24px, env(safe-area-inset-top)) 0 max(34px, env(safe-area-inset-bottom));
    text-align: var(--text-align);
}

.top-actions { min-height: 48px; display: flex; justify-content: flex-end; }

.round-action {
    width: 46px;
    height: 46px;
    color: var(--primary);
    background: rgba(255,255,255,.09);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(var(--glass));
    transition: transform 180ms ease, background-color 180ms ease;
}

.round-action:hover { transform: translateY(-2px); background: rgba(255,255,255,.16); }

.profile-block { display: flex; flex-direction: column; align-items: center; }
.profile-logo { width: min(210px, 56vw); max-height: 96px; margin: 0 auto 18px; object-fit: contain; }

.profile-avatar {
    width: min(var(--avatar-size), 42vw);
    aspect-ratio: 1;
    margin: 0 auto 22px;
    object-fit: cover;
    background: rgba(255,255,255,.06);
    border: var(--avatar-border);
    border-radius: var(--avatar-radius);
    box-shadow: var(--avatar-shadow);
}

.profile-kicker {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .18em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--primary);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.15rem, 8vw, 3.5rem);
    line-height: 1.02;
    letter-spacing: -.035em;
    text-wrap: balance;
}

.secondary-name { margin: 9px 0 0; color: var(--accent); font-size: .82rem; letter-spacing: .11em; text-transform: uppercase; }
.bio { max-width: 560px; margin: 18px auto 0; color: var(--secondary); font-size: clamp(.98rem, 3.7vw, 1.08rem); text-wrap: pretty; }
.extra-text { margin: 10px auto 0; color: color-mix(in srgb, var(--secondary) 78%, transparent); font-size: .88rem; }

.link-list { display: grid; gap: var(--button-gap); margin: 34px 0 26px; }

.link-button {
    position: relative;
    min-height: var(--button-height);
    padding: 12px 58px 12px 18px;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    overflow: hidden;
    color: var(--button-text);
    border: var(--button-border-width) solid var(--button-border);
    border-radius: var(--button-radius);
    box-shadow: var(--button-shadow);
    text-align: left;
    text-decoration: none;
    isolation: isolate;
    backdrop-filter: blur(var(--glass));
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.link-button::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: var(--button-alpha);
    background: linear-gradient(135deg, var(--button-start), var(--button-end));
}

.link-button:hover,
.link-button:focus-visible {
    transform: translateY(var(--hover-lift));
    border-color: color-mix(in srgb, var(--accent) 78%, white);
    box-shadow: 0 20px 42px rgba(1, 5, 18, .38);
    outline: none;
}

.link-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    color: var(--button-text);
    background: rgba(255,255,255,.32);
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 16px;
    font-size: 1.15rem;
    font-weight: 850;
    overflow: hidden;
}

.link-icon svg { width: 60%; height: 60%; }

.link-icon.icon-whatsapp {
    color: #fff;
    background: #25d366;
    border-color: transparent;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.28);
}

.link-icon.icon-facebook {
    color: #fff;
    background: #1877f2;
    border-color: transparent;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.28);
}

.link-icon.icon-instagram {
    color: #fff;
    background: radial-gradient(circle at 30% 107%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285aeb 90%);
    border-color: transparent;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.22);
}

.link-icon.icon-ebook {
    padding: 0;
    background: var(--accent, #f3c85d);
    border: 2px solid var(--accent, #f3c85d);
    box-shadow: 0 6px 16px rgba(243, 200, 93, .4);
}

.link-icon.icon-ebook video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* El color pedido es para la tarjeta completa, no solo el ícono */
.link-button.link-whatsapp { background: linear-gradient(135deg, #eafcf1, #dcf5e3); border-color: rgba(37, 211, 102, .32); }
.link-button.link-facebook { background: linear-gradient(135deg, #eef5ff, #e1ecff); border-color: rgba(24, 119, 242, .32); }
.link-button.link-instagram { background: linear-gradient(135deg, #fff6e4, #ffe9ee); border-color: rgba(214, 36, 159, .22); }
.link-button.link-ebook { background: linear-gradient(135deg, #fffaf0, #fff1cf); border-color: rgba(243, 200, 93, .45); }

.link-title { overflow: hidden; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.link-arrow { position: absolute; right: 20px; font-size: 1.1rem; }

/* El ebook siempre es el destacado: ocupa su propio espacio y es más grande, en cualquier tamaño de pantalla */
.link-button.link-ebook {
    min-height: calc(var(--button-height) + 46px);
    padding: 16px 62px 16px 16px;
    gap: 16px;
    grid-template-columns: 92px minmax(0, 1fr);
}

.link-button.link-ebook .link-icon { width: 92px; height: 92px; border-radius: 20px; }
.link-button.link-ebook .link-title { white-space: normal; font-size: 1.05rem; line-height: 1.25; }

.empty-public {
    padding: 28px;
    color: var(--secondary);
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.13);
    border-radius: var(--button-radius);
    backdrop-filter: blur(var(--glass));
}
.empty-public span { color: var(--accent); }
.empty-public p { margin: 8px 0 0; }

.social-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 18px 0 28px; }
.social-list a {
    width: 44px; height: 44px; display: grid; place-items: center;
    color: var(--primary); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
    border-radius: 50%; font-weight: 850; text-decoration: none; backdrop-filter: blur(12px); transition: transform 160ms ease;
}
.social-list a:hover { transform: translateY(-3px); }

.public-footer { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--secondary); font-size: .78rem; }
.public-footer button { padding: 0; color: var(--secondary); background: none; border: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.public-footer p { margin: 0; }

.share-dialog {
    width: min(400px, calc(100% - 28px));
    padding: 30px;
    color: #14223b;
    background: rgba(255,255,255,.97);
    border: 0;
    border-radius: 28px;
    box-shadow: 0 34px 90px rgba(0,0,0,.45);
    text-align: center;
}
.share-dialog::backdrop { background: rgba(1,6,18,.72); backdrop-filter: blur(8px); }
.share-dialog > img { width: 66px; height: 66px; margin: 0 auto 12px; object-fit: contain; border-radius: 18px; }
.share-dialog h2 { margin: 0; font: 700 1.65rem Georgia, serif; }
.share-dialog > p { margin: 8px 0 18px; color: #657188; }
.dialog-close { position: absolute; top: 13px; right: 15px; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #edf0f5; cursor: pointer; font-size: 1.3rem; }
.qr-canvas { width: 228px; min-height: 228px; margin: 0 auto 18px; padding: 4px; display: grid; place-items: center; background: white; border-radius: 18px; }
.qr-canvas img, .qr-canvas canvas { max-width: 220px; border-radius: 12px; }
.copy-button { width: 100%; min-height: 48px; color: #15223b; background: #f3c85d; border: 0; border-radius: 14px; font-weight: 850; cursor: pointer; }
.copy-status { min-height: 20px; margin-bottom: 0 !important; font-size: .8rem; }

.animations-on .profile-block { animation: enter 620ms ease both; }
.animations-on .link-button { animation: enter 520ms ease both; animation-delay: var(--delay); }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 520px) {
    .link-page { width: min(calc(100% - 20px), var(--content-width)); padding-top: max(14px, env(safe-area-inset-top)); }
    .top-actions { min-height: 42px; }
    .round-action { width: 42px; height: 42px; }
    .profile-avatar { margin-bottom: 18px; }
    .profile-kicker { max-width: 270px; }
    .link-list { margin-top: 28px; }
    .link-button { padding-left: 13px; padding-right: 48px; gap: 9px; grid-template-columns: 48px minmax(0, 1fr); }
    .link-icon { width: 48px; height: 48px; }
    .link-arrow { right: 16px; }
}

/* En pantallas de PC/laptop/tablet: el ebook ocupa su propia fila y los otros tres van uno al lado del otro, un poco más grandes */
@media (min-width: 720px) {
    .link-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    .link-button.link-ebook { grid-column: 1 / -1; }

    .link-button:not(.link-ebook) {
        min-height: calc(var(--button-height) + 16px);
        padding: 12px 16px 12px 14px;
        gap: 10px;
        grid-template-columns: 52px minmax(0, 1fr);
    }

    .link-button:not(.link-ebook) .link-icon { width: 52px; height: 52px; }
    .link-button:not(.link-ebook) .link-title { white-space: normal; font-size: .92rem; line-height: 1.2; }
    .link-button:not(.link-ebook) .link-arrow { display: none; }
}

.tiktok-browser-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(3, 8, 20, .62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: enter 280ms ease both;
}

.tiktok-browser-arrow {
    position: fixed;
    top: 0;
    right: 0;
    width: min(40vw, 160px);
    height: auto;
    pointer-events: none;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,.45));
}

.tiktok-browser-card {
    position: relative;
    width: min(360px, 100%);
    padding: 30px 24px 26px;
    color: #17324a;
    text-align: center;
    background: rgba(255,255,255,.98);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,.5);
}

.tiktok-browser-card-icon {
    display: inline-grid;
    place-items: center;
    width: 46px;
    height: 46px;
    margin-bottom: 14px;
    color: #17324a;
    background: #f3c85d;
    border-radius: 50%;
    font-size: 1.35rem;
    font-weight: 900;
}

.tiktok-browser-card h2 {
    margin: 0 0 10px;
    font: 700 1.32rem Georgia, "Times New Roman", serif;
}

.tiktok-browser-card p { margin: 0 0 22px; color: #4a5c72; font-size: .93rem; line-height: 1.55; }
.tiktok-browser-card strong { color: #b6822c; }

.tiktok-browser-dismiss {
    min-height: 46px;
    padding: 0 28px;
    color: #17324a;
    background: #f3c85d;
    border: 0;
    border-radius: 999px;
    font-weight: 800;
    cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
