/* ============================================================
 * MODAL DE FORMULARIO — Ajustes y el primer paso del onboarding.
 * Vivía dentro de perfil.html, pero el wizard del shell necesita el mismo
 * chasis: cabecera con miga, nav numerada, paneles y pie con la acción.
 * Quien lo use solo pone el marcado; el aspecto sale de aquí.
 * Casa (26-09-2026): sin hairlines entre cabecera, nav, filas y pie (los
 * separa el espacio), campos en línea, idiomas como chips con la bandera
 * en el hexágono, ciclo como segmento, título elegido con luz.
 * ============================================================ */

    .settings-overlay {
        position: fixed; inset: 0; z-index: 10000;
        background: rgba(8, 9, 11, 0.55);
        backdrop-filter: blur(20px) saturate(1.1);
        -webkit-backdrop-filter: blur(20px) saturate(1.1);
        display: flex; align-items: center; justify-content: center;
        opacity: 0; pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .settings-overlay.active { opacity: 1; pointer-events: auto; }
    .settings-modal {
        position: relative;
        width: 720px; max-width: 94vw;
        height: auto; min-height: 448px; max-height: 88vh;
        display: flex; flex-direction: column;
        overflow: hidden; padding: 0;
        font-family: var(--rp-font);
        transform: translateY(20px); opacity: 0;
        transition: transform 0.3s var(--rp-ease, cubic-bezier(0.16, 1, 0.3, 1)), opacity 0.3s ease;
    }
    .settings-modal::before {
        content: '';
        position: absolute;
        inset: 0;
        background: var(--rp-dot-grid);
        -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
        mask-image: linear-gradient(180deg, #000 0%, transparent 100%);
        pointer-events: none;
        z-index: 0;
    }
    .settings-modal > * {
        position: relative;
        z-index: 1;
    }
    .settings-overlay.active .settings-modal { transform: translateY(0); opacity: 1; }
    .settings-close {
        position: absolute; top: 13px; right: 15px;
        background: none; border: none; color: rgba(255,255,255,0.4);
        font-size: 20px; cursor: pointer; line-height: 1; padding: 4px;
        font-family: var(--rp-font); z-index: 3;
        transition: color 0.2s, transform 0.15s;
    }
    .settings-close:hover { color: var(--rp-text); }
    .settings-close:active { transform: scale(0.92); }

    .stg-head {
        flex: 0 0 auto;
        display: flex; align-items: center; gap: 13px;
        padding: 15px 52px 14px 24px;
        background: linear-gradient(90deg,
            color-mix(in srgb, var(--theme-color, #b33131) 12%, transparent) 0%,
            transparent 58%);
    }
    .stg-title {
        font-family: var(--rp-font);
        font-size: 17px; font-weight: 800; font-style: italic;
        text-transform: uppercase; letter-spacing: var(--rp-ls-title);
        line-height: 1; color: var(--rp-text); margin: 0;
        flex: 0 0 auto;
    }
    .stg-head-slash {
        width: 1px; height: 16px; flex: 0 0 auto;
        background: rgba(255,255,255,0.2);
        transform: skewX(-18deg);
    }
    .stg-crumb {
        display: inline-flex; align-items: baseline; gap: 7px;
        min-width: 0; overflow: hidden;
    }
    .stg-crumb-num {
        font-size: 10px; font-weight: 800; font-style: italic; line-height: 1;
        color: var(--theme-color, #b33131);
    }
    .stg-crumb-txt {
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label-sm); font-weight: 600; line-height: 1;
        letter-spacing: var(--rp-ls-eyebrow); text-transform: uppercase;
        color: rgba(255,255,255,0.42);
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }

    .stg-body {
        flex: 1 1 auto; min-height: 0;
        display: grid; grid-template-columns: 168px minmax(0, 1fr);
    }
    .stg-nav {
        display: flex; flex-direction: column; align-items: stretch; gap: 2px;
        padding: 16px 8px 16px 12px;
    }
    .stg-nav-item {
        display: flex; align-items: baseline; gap: 8px;
        padding: 7px 12px; background: none; border: none; cursor: pointer;
        text-align: left;
        font-family: var(--rp-font);
        transition: background 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }
    .stg-nav-num {
        font-size: 10px; font-weight: 800; font-style: italic; line-height: 1;
        color: rgba(255,255,255,0.25);
        transition: color 0.2s;
    }
    .stg-nav-txt {
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label); font-weight: 600;
        letter-spacing: var(--rp-ls-eyebrow); text-transform: uppercase;
        color: rgba(255,255,255,0.42);
        transition: color 0.2s;
    }
    .stg-nav-item:hover .stg-nav-txt { color: var(--rp-text-2); }
    .stg-nav-item--on {
        background: linear-gradient(90deg,
            color-mix(in srgb, var(--theme-color, #b33131) 20%, transparent) 0%,
            transparent 84%);
    }
    .stg-nav-item--on .stg-nav-num { color: var(--theme-color, #b33131); }
    .stg-nav-item--on .stg-nav-txt { color: var(--rp-text); }

    .stg-pane-wrap {
        min-width: 0; overflow-y: auto; overflow-x: hidden;
        padding: 8px 24px 20px;
        scrollbar-width: thin;
        scrollbar-color: rgba(255,255,255,0.14) transparent;
    }
    .stg-pane-wrap::-webkit-scrollbar { width: 6px; }
    .stg-pane-wrap::-webkit-scrollbar-track { background: transparent; }
    .stg-pane-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); }
    .stg-pane { display: none; }
    .stg-pane--active { display: block; animation: stgPaneIn 0.3s var(--rp-ease, cubic-bezier(0.16, 1, 0.3, 1)); }
    .stg-pane[data-pane="belt"] { height: 100%; }
    .stg-pane[data-pane="belt"].stg-pane--active {
        display: flex; flex-direction: column; justify-content: center;
    }
    .stg-pane[data-pane="belt"] .stg-row {
        width: 100%; max-width: 380px; margin: 0 auto;
    }
    @keyframes stgPaneIn {
        from { opacity: 0; transform: translateY(4px); }
        to   { opacity: 1; transform: none; }
    }

    .stg-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 244px);
        align-items: center; gap: 20px;
        padding: 12px 0;
    }
    /* Sin esto el atributo `hidden` no hace nada: el display:grid de arriba le
       gana al display:none del navegador, y una fila oculta se veria igual. */
    .stg-row[hidden] { display: none; }
    /* Sin hairline entre filas: las separa el espacio (casa 26-09). */
    .stg-lbl-wrap { min-width: 0; }
    .stg-lbl {
        display: block;
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label); font-weight: 600;
        letter-spacing: var(--rp-ls-eyebrow); text-transform: uppercase;
        color: var(--rp-text); line-height: 1.35;
    }
    .stg-hint {
        margin: 3px 0 0;
        font-size: 10.5px; font-weight: 400; line-height: 1.4;
        letter-spacing: 0.1px; color: rgba(255,255,255,0.35);
    }
    .stg-ctl { min-width: 0; display: flex; align-items: center; }
    .stg-ctl > * { flex: 1 1 auto; min-width: 0; }
    .stg-ctl--end { justify-content: flex-end; }
    .stg-ctl--end > * { flex: 0 0 auto; }

    /* Campo en línea (casa 26-09): sin caja ni anillo. El input va desnudo
       sobre una línea tenue y, al enfocar, la línea del tema se DIBUJA de
       izquierda a derecha. Como el input no admite pseudoelementos, las dos
       líneas son capas de background y lo que se anima es background-size. */
    .stg-input {
        width: 100%; height: 34px;
        background:
            linear-gradient(var(--theme-color, #b33131), var(--theme-color, #b33131)) left bottom / 0 1px no-repeat,
            linear-gradient(rgba(255,255,255,0.12), rgba(255,255,255,0.12)) left bottom / 100% 1px no-repeat;
        border: none; border-radius: 0;
        box-shadow: none;
        padding: 0;
        color: var(--rp-text);
        font-family: var(--rp-font);
        font-size: 13px; font-weight: 400; letter-spacing: 0.2px;
        transition: background-size 0.3s var(--rp-ease, cubic-bezier(0.16, 1, 0.3, 1)), box-shadow 0.3s ease;
    }
    .stg-input:hover {
        background-image:
            linear-gradient(var(--theme-color, #b33131), var(--theme-color, #b33131)),
            linear-gradient(rgba(255,255,255,0.2), rgba(255,255,255,0.2));
    }
    .stg-input:focus {
        background-size: 100% 1px, 100% 1px;
        box-shadow: 0 10px 14px -12px color-mix(in srgb, var(--theme-color, #b33131) 70%, transparent);
    }
    .stg-input::placeholder { color: var(--rp-text-3); font-weight: 400; font-style: italic; }

    /* Fecha de nacimiento: texto DD/MM/AAAA, sin selector nativo */
    #settingsBirthdate { letter-spacing: 1px; font-variant-numeric: tabular-nums; }

    .stg-foot {
        flex: 0 0 auto;
        display: flex; align-items: center; justify-content: flex-end; gap: 16px;
        padding: 12px 24px 16px;
    }
    .settings-modal[data-pane="sub"] .stg-foot { display: none; }
    .settings-alias-feedback {
        flex: 1 1 auto; min-width: 0;
        font-size: 11px; font-weight: 500; line-height: 1.3;
        color: rgba(255,255,255,0.4);
    }
    .settings-alias-feedback.error { color: var(--rp-error, #ff6b6b); }
    .settings-alias-feedback.ok { color: var(--rp-success); }

    .stg-step { display: inline-flex; align-items: center; gap: 12px; }
    .stg-step-btn {
        width: 24px; height: 24px; padding: 0;
        display: inline-flex; align-items: center; justify-content: center;
        background: none; border: none; cursor: pointer;
        color: rgba(255,255,255,0.55); font-size: 15px; line-height: 1;
        font-family: var(--rp-font);
        transition: color 0.2s, transform 0.15s;
        -webkit-tap-highlight-color: transparent;
    }
    .stg-step-btn:hover { color: var(--rp-text); }
    .stg-step-btn:active { transform: scale(0.92); }
    .stg-step-val {
        min-width: 20px; text-align: center;
        font-family: var(--rp-font);
        font-size: 15px; font-weight: 800; font-style: italic;
        color: var(--rp-text);
    }

    .stg-belt-stage {
        display: flex; align-items: center; gap: 10px;
        width: 100%; max-width: 480px; margin: 0 auto;
        padding: 0 0 6px; user-select: none;
    }
    .belt-nav-btn {
        width: 32px; height: 32px; display: flex;
        align-items: center; justify-content: center;
        background: transparent; border: none;
        color: rgba(255,255,255,0.55); cursor: pointer;
        transition: color 0.2s, transform 0.15s; flex-shrink: 0; padding: 0;
    }
    .belt-nav-btn:hover { color: var(--rp-text); }
    .belt-nav-btn:active { transform: scale(0.9); }
    /* Sin recorte: el halo del cinturon (drop-shadow de hasta 26px, y el doble
       cuando asoma el siguiente color) se sale de la caja del cinturon y aqui
       se quedaba cortado. El deslizamiento entra con opacidad 0 y frena en 3px
       en el primer tercio, asi que no hace falta taparlo. */
    .settings-belt-display {
        flex: 1; display: flex; flex-direction: column;
        align-items: center; gap: 8px; position: relative;
        padding: 18px 0 10px; overflow: visible;
    }
    .settings-belt-img-wrap {
        position: relative; width: min(340px, calc(100% - 28px));
        padding: 26px 0; overflow: visible;
    }
    .settings-belt-img-wrap.stg-slide-left .rp-belt {
        animation: stgBeltSlideLeft 0.35s var(--rp-ease, cubic-bezier(0.16, 1, 0.3, 1));
    }
    .settings-belt-img-wrap.stg-slide-right .rp-belt {
        animation: stgBeltSlideRight 0.35s var(--rp-ease, cubic-bezier(0.16, 1, 0.3, 1));
    }
    @keyframes stgBeltSlideLeft {
        0% { transform: translateX(50px); opacity: 0; }
        100% { transform: translateX(0); opacity: 1; }
    }
    @keyframes stgBeltSlideRight {
        0% { transform: translateX(-50px); opacity: 0; }
        100% { transform: translateX(0); opacity: 1; }
    }
    .settings-belt-label {
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label-sm); font-weight: 600; letter-spacing: var(--rp-ls-eyebrow);
        color: rgba(255,255,255,0.6); text-transform: uppercase;
    }

    /* Selector de titulo: las mismas placas de iniciales del panel de Inicio
       (.rp-mono en components.css) y las mismas estelas en el elegido. */
    .stg-row--stack {
        display: block;
    }
    .stg-title-help,
    .stg-title-empty,
    .stg-title-warn {
        font-size: 11px; line-height: 1.5; margin: 6px 0 0;
        color: rgba(255,255,255,0.4);
    }
    .stg-title-warn { color: color-mix(in srgb, var(--rp-red, #b33131) 62%, #fff); }
    .stg-title-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 6px;
        margin-top: 12px;
    }
    .stg-title-opt {
        position: relative;
        display: flex; align-items: center; gap: 10px;
        padding: 8px; border: none; border-radius: var(--rp-radius-sm, 6px);
        background: rgba(255,255,255,0.025);
        font-family: var(--rp-font);
        text-align: left;
        transition: background 0.2s ease, box-shadow 0.2s ease;
    }
    .stg-title-opt:hover { background: rgba(255,255,255,0.05); }
    /* El elegido se enciende con luz (relleno del color y halo), no con el
       anillo que gira de .rp-pick-on (casa 26-09: fuera bordes que giran). */
    .stg-title-opt.rp-pick-on {
        background: color-mix(in srgb, var(--mono-a, var(--theme-color, #b33131)) 14%, transparent);
        box-shadow: 0 0 16px color-mix(in srgb, var(--mono-a, var(--theme-color, #b33131)) 22%, transparent);
    }
    .stg-title-opt.rp-pick-on::before { content: none; animation: none; }
    .stg-title-mono {
        display: block; width: 38px; height: 38px; flex-shrink: 0;
    }
    .stg-title-name {
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label); font-weight: 600; font-style: normal;
        letter-spacing: var(--rp-ls-eyebrow); text-transform: uppercase;
        color: var(--mono-a, var(--rp-text, #fff));
        overflow: hidden; text-overflow: ellipsis;
    }
.settings-lang-row {
        display: flex; gap: 8px; flex-wrap: wrap;
    }
    /* Idiomas como chips de la casa (.rp-chip): relleno suave, radio de 6 px
       y, delante, la bandera DENTRO del hexágono del nodo. La bandera es un
       <svg> de 640×480 que se dibuja a 31×23 (llena el alto) y se enmascara
       con el hexágono de 21×23 centrado; los 5 px sobrantes a cada lado se
       compensan con margen negativo. Sin borde: el elegido se enciende. */
    .settings-lang-btn {
        padding: 3px 10px 3px 4px;
        display: inline-flex; align-items: center; gap: 8px;
        background: rgba(255,255,255,0.05); border: none; border-radius: var(--rp-radius-sm, 6px);
        cursor: pointer;
        font-family: var(--rp-font-label); font-size: var(--rp-fs-label-sm); font-weight: 600;
        letter-spacing: var(--rp-ls-eyebrow); text-transform: uppercase;
        color: var(--rp-text-3);
        transition: color 0.2s, background 0.2s, transform 0.25s var(--rp-ease, cubic-bezier(0.16, 1, 0.3, 1));
        -webkit-tap-highlight-color: transparent;
    }
    .settings-lang-btn .flag-icon {
        width: 31px; height: 23px; margin: 0 -5px;
        flex-shrink: 0; display: block;
        -webkit-mask: var(--rp-hex) center / 21px 23px no-repeat;
                mask: var(--rp-hex) center / 21px 23px no-repeat;
        opacity: 0.55; transition: opacity 0.2s, filter 0.3s;
    }
    .settings-lang-btn:hover { color: var(--rp-text); background: rgba(255,255,255,0.1); transform: translateX(2px); }
    .settings-lang-btn:hover .flag-icon { opacity: 0.85; }
    .settings-lang-btn.active {
        color: var(--rp-text);
        background: rgba(255,255,255,0.1);
    }
    .settings-lang-btn.active .flag-icon {
        opacity: 1;
        filter: drop-shadow(0 0 5px color-mix(in srgb, var(--theme-color, #b33131) 70%, transparent)) brightness(1.08);
    }

    .sub-info-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center; gap: 20px;
        padding: 12px 0;
    }
    /* Sin hairline entre filas (casa 26-09). */
    .sub-info-label {
        font-family: var(--rp-font);
        font-size: 12.5px; font-weight: 500; letter-spacing: 0.1px;
        text-transform: none; color: var(--rp-text-2);
    }
    .sub-info-value {
        font-family: var(--rp-font);
        font-size: 13px; font-weight: 600; color: var(--rp-text);
    }
    .sub-info-value.free { color: rgba(255,255,255,0.45); }
    .sub-cta-row {
        display: flex; align-items: center; justify-content: flex-end;
        flex-wrap: wrap; gap: 18px;
        margin-top: 18px;
    }

    /* ---- La escalera de planes ----------------------------------------
       Tres botones sueltos en una fila se partian 2 + 1 en cuanto el pane
       bajaba de ~520px, y ninguno decia lo que costaba. Aqui cada tier es una
       fila con su nombre, su precio y su accion: no hay reflujo posible, se
       lee de arriba abajo como la escalera que es, y el metal (rojo de marca,
       plata, oro) es el mismo de las portadas de la tienda. */
    .sub-plans { margin-top: 22px; }
    .sub-plans-head {
        display: flex; align-items: center; justify-content: space-between;
        gap: 16px; margin-bottom: 12px;
    }
    .sub-plans-title {
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label-sm); font-weight: 600; letter-spacing: var(--rp-ls-eyebrow);
        text-transform: uppercase; color: rgba(255,255,255,0.38);
    }
    /* El segmento de la casa (.rp-seg): caja suave con radio de 6 px y la
       elegida blanca rellena con texto negro. Sin borde, nunca subrayado. */
    .sub-cycle {
        display: inline-flex; position: relative; gap: 0;
        background: rgba(255,255,255,0.05);
        border-radius: var(--rp-radius-sm, 6px);
        overflow: hidden; isolation: isolate;
    }
    .sub-cycle-btn {
        position: relative; z-index: 1;
        padding: 6px 12px;
        background: none; border: none;
        cursor: pointer;
        font-family: var(--rp-font-label); font-size: var(--rp-fs-label-sm); font-weight: 600;
        letter-spacing: var(--rp-ls-eyebrow); text-transform: uppercase;
        color: var(--rp-text-3);
        transition: color 0.25s, background 0.25s;
        -webkit-tap-highlight-color: transparent;
    }
    .sub-cycle-btn:hover:not(.is-on) { color: var(--rp-text); }
    .sub-cycle-btn.is-on {
        color: #000;
        background: #fff;
        border-radius: var(--rp-radius-sm, 6px);
    }

    .sub-plan {
        display: grid;
        grid-template-columns: 78px minmax(0, 1fr) auto;
        align-items: center; gap: 14px;
        padding: 12px 14px;
        background: rgba(255,255,255,0.02);
        clip-path: var(--rp-cut-btn, polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%));
        transition: background 0.2s ease;
    }
    .sub-plan + .sub-plan { margin-top: 8px; }
    .sub-plan:hover { background: rgba(255,255,255,0.04); }
    .sub-plan-name {
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label); font-weight: 600; font-style: normal;
        letter-spacing: var(--rp-ls-eyebrow); text-transform: uppercase;
        color: var(--rp-text);
    }
    /* Plata y oro se dicen con degradado, como en las portadas; ROLL va en
       blanco, que el nombre en rojo competiria con la accion. */
    .sub-plan--studio .sub-plan-name {
        background: linear-gradient(180deg, #ffffff 0%, #98a0ac 100%);
        -webkit-background-clip: text; background-clip: text; color: transparent;
    }
    .sub-plan--coach .sub-plan-name {
        background: linear-gradient(180deg, #f2d9a4 0%, #bf8a31 100%);
        -webkit-background-clip: text; background-clip: text; color: transparent;
    }
    .sub-plan-price {
        font-family: var(--rp-font);
        font-size: 13px; font-weight: 600; color: var(--rp-text-2);
        white-space: nowrap;
    }
    .sub-plan-price small {
        font-size: 11px; font-weight: 500; color: var(--rp-text-3);
        margin-left: 2px;
    }
    .sub-plan-state {
        font-family: var(--rp-font-label);
        font-size: var(--rp-fs-label-sm); font-weight: 600; letter-spacing: var(--rp-ls-eyebrow);
        text-transform: uppercase; color: var(--rp-text-3);
        white-space: nowrap;
    }
    .sub-plan.is-current { background: rgba(255,255,255,0.05); }
    .sub-plan.is-current .sub-plan-state { color: var(--rp-text-2); }
    .sub-plan.is-below { opacity: 0.45; }
    .sub-native-msg {
        font-size: 11px; color: rgba(255,255,255,0.4);
        padding: 12px 0 0; line-height: 1.5;
    }
    @media (max-width: 768px) {
        .settings-modal { height: auto; min-height: 0; }
        .stg-head { padding: 4px 52px 14px 20px; }
        .stg-head-slash, .stg-crumb { display: none; }
        .stg-body { display: flex; flex-direction: column; }
        .stg-nav {
            flex-direction: row; align-items: center; gap: 20px;
            padding: 12px 20px 0;
            overflow-x: auto; scrollbar-width: none;
        }
        .stg-nav::-webkit-scrollbar { display: none; }
        .stg-nav-item { flex: 0 0 auto; padding: 4px 0 10px; }
        .stg-pane-wrap { flex: 1 1 auto; min-height: 0; padding: 4px 20px 20px; }
        .stg-row {
            grid-template-columns: minmax(0, 1fr);
            gap: 8px; padding: 14px 0;
        }
        .stg-ctl--end { justify-content: flex-start; }
        /* La casilla con texto largo (modo ayuda) tiene que poder encoger:
           con flex 0 0 auto se salía del panel por la derecha. */
        .stg-ctl--end > .stg-help-check { flex: 1 1 auto; min-width: 0; }
        .stg-pane[data-pane="belt"] .stg-row { max-width: none; }
        .stg-input { height: 40px; font-size: 16px; }
        .stg-foot { padding: 14px 20px; flex-wrap: wrap; }
        .stg-foot .rp-btn { width: 100%; }
        .sub-info-row { padding: 14px 0; }
        .sub-cta-row { justify-content: flex-start; }
        .sub-cta-row .rp-btn { width: 100%; }
        /* El precio se va a su propia linea antes que estrechar el boton. */
        .sub-plan {
            grid-template-columns: minmax(0, 1fr) auto;
            gap: 4px 12px;
        }
        .sub-plan-name { grid-column: 1; }
        .sub-plan-price { grid-column: 1; grid-row: 2; }
        .sub-plan .rp-btn,
        .sub-plan-state { grid-column: 2; grid-row: 1 / span 2; }
        .sub-plans-head { flex-wrap: wrap; gap: 8px; }
    }

    @media (prefers-reduced-motion: reduce) {
        .settings-overlay, .settings-modal, .stg-input, .settings-lang-btn,
        .settings-lang-btn .flag-icon, .sub-cycle-btn, .stg-title-opt { transition: none; }
        .stg-pane--active,
        .settings-belt-img-wrap.stg-slide-left .rp-belt,
        .settings-belt-img-wrap.stg-slide-right .rp-belt { animation: none; }
    }
