.hayha-auth-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background-color: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.hayha-auth-modal-backdrop.hayha-auth-modal--active {
    opacity: 1;
    visibility: visible;
}

.hayha-auth-modal-card {
    position: relative;
    background: var(--hayha-theme-surface);
    border-radius: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 468px;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 52px 32px 20px;
    box-sizing: border-box;
    transform: scale(0.96);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    color: var(--hayha-theme-text);
}

.hayha-auth-modal--active .hayha-auth-modal-card {
    transform: scale(1);
}

.hayha-auth-modal-close {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 32px;
    height: 32px;
    min-height: 0 !important;
    margin: 0 !important;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--hayha-theme-text);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
    z-index: 10;
}

.hayha-auth-modal-close:hover,
.hayha-auth-modal-close:focus-visible {
    background-color: var(--hayha-theme-soft);
    color: var(--hayha-theme-text);
    outline: none;
}

.hayha-auth-modal-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 24px;
}

.hayha-auth-modal-logo {
    height: 56px;
    max-width: 220px;
    object-fit: contain;
    display: block;
}

.hayha-auth-modal-title {
    font-size: 24px;
    font-weight: 500;
    line-height: 32px;
    color: var(--hayha-theme-heading);
    text-align: center;
    margin: 0 0 24px 0;
}

.hayha-auth-modal-subtitle {
    font-size: 14px;
    line-height: 20px;
    color: var(--hayha-theme-muted);
    text-align: center;
    margin: -12px 0 20px 0;
}

.hayha-auth-notice {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 20px;
    margin-bottom: 16px;
    text-align: left;
}

.hayha-auth-notice--error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.hayha-auth-notice--success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.hayha-auth-field-group {
    margin-bottom: 16px;
    text-align: left;
}

.hayha-auth-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--hayha-theme-text);
    margin-bottom: 8px;
    line-height: 20px;
}

.hayha-auth-required {
    color: #d70d00;
    margin-left: 2px;
    font-weight: 600;
}

.hayha-auth-input {
    width: 100% !important;
    height: 48px !important;
    border: 1px solid var(--hayha-theme-border) !important;
    border-radius: 6px !important;
    padding: 0 16px !important;
    font-size: 16px !important;
    color: var(--hayha-theme-text) !important;
    background: var(--hayha-theme-surface) !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    box-shadow: none !important;
    caret-color: var(--hayha-theme-accent) !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hayha-auth-input:focus {
    border-color: var(--hayha-theme-accent) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hayha-theme-accent) 15%, transparent) !important;
}

.hayha-auth-input.hayha-auth-input--error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15) !important;
}

.hayha-auth-btn-primary {
    width: 100% !important;
    height: 48px !important;
    min-height: 48px !important;
    background-color: var(--hayha-theme-accent) !important;
    color: var(--hayha-theme-contrast) !important;
    border: none !important;
    border-radius: 9999px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    line-height: 48px !important;
    text-align: center !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    cursor: pointer !important;
    padding: 0 20px !important;
    margin: 8px 0 16px !important;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: none !important;
}

.hayha-auth-btn-primary:hover,
.hayha-auth-btn-primary:focus-visible {
    background-color: var(--hayha-theme-hover) !important;
    outline: none !important;
}

.hayha-auth-btn-primary:disabled {
    background-color: var(--hayha-theme-disabled) !important;
    cursor: not-allowed !important;
}

.hayha-auth-helper-row {
    text-align: center;
    font-size: 14px;
    line-height: 20px;
    color: var(--hayha-theme-muted);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.hayha-auth-link-orange {
    color: var(--hayha-theme-accent) !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    cursor: pointer !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    font-size: 14px !important;
    line-height: inherit !important;
    display: inline !important;
    vertical-align: baseline !important;
}

.hayha-auth-link-orange:hover,
.hayha-auth-link-orange:focus-visible {
    text-decoration: underline !important;
    outline: none !important;
}

.hayha-auth-link-sm {
    font-size: 13px !important;
}

.hayha-auth-chip-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--hayha-theme-surface);
    border: 1px solid var(--hayha-theme-border);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 14px;
}

.hayha-auth-chip-label {
    color: var(--hayha-theme-muted);
}

.hayha-auth-chip-email {
    font-weight: 600;
    color: var(--hayha-theme-text);
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hayha-auth-sub-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 13px;
}

.hayha-auth-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--hayha-theme-muted);
    cursor: pointer;
    margin: 0;
}

.hayha-auth-checkbox-label input {
    margin: 0;
    cursor: pointer;
    accent-color: var(--hayha-theme-accent);
}

.hayha-auth-privacy-copy {
    font-size: 14px;
    line-height: 20px;
    color: var(--hayha-theme-text);
    text-align: center;
    margin-top: 24px;
}

.hayha-auth-privacy-copy a {
    color: var(--hayha-theme-accent);
    font-weight: 500;
    text-decoration: none;
}

.hayha-auth-privacy-copy a:hover {
    text-decoration: underline;
}

body.hayha-auth-modal-open {
    overflow: hidden !important;
}

@media (max-width: 480px) {
    .hayha-auth-modal-card {
        max-width: 375px;
        padding: 24px 24px 20px;
        border-radius: 20px;
    }
    .hayha-auth-modal-title {
        font-size: 20px;
        line-height: 28px;
        margin-bottom: 20px;
    }
    .hayha-auth-modal-close {
        top: 20px;
        right: 20px;
    }
    .hayha-auth-modal-logo {
        height: 48px;
        max-width: 200px;
    }
    .hayha-auth-privacy-copy {
        font-size: 13px;
        line-height: 18px;
        margin-top: 20px;
    }
}

/* Shared header shell: a stable width prevents name/auth changes moving siblings. */
.hayha-account-menu { display: inline-flex; width: 144px; max-width: 100%; position: relative; vertical-align: middle; font-family: inherit; text-align: left; }
.hayha-account-menu .hayha-account-menu__trigger { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 34px; min-height: 34px; padding: 0 8px; margin: 0; border: 1px solid transparent; border-radius: 4px; background: var(--hayha-theme-accent); color: var(--hayha-theme-contrast); font: inherit; font-size: 14px; font-weight: 500; line-height: 20px; text-transform: none; letter-spacing: normal; cursor: pointer; box-shadow: none; }
.hayha-account-menu .hayha-account-menu__trigger[data-hayha-menu-toggle] { background: var(--hayha-theme-surface); color: var(--hayha-theme-text); border-color: var(--hayha-theme-border); }
.hayha-account-menu .hayha-account-menu__trigger[aria-expanded="true"] { border-color: var(--hayha-theme-accent); }
.hayha-account-menu__trigger svg { flex: 0 0 20px; }
.hayha-account-menu__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hayha-account-menu__avatar { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; background: var(--hayha-theme-soft); color: var(--hayha-theme-muted); text-transform: uppercase; }
.hayha-account-menu__dropdown { position: fixed; z-index: 1000000; width: min(234px, calc(100vw - 24px)); overflow: auto; overscroll-behavior: contain; border: 1px solid var(--hayha-theme-border); border-radius: 6px; background: var(--hayha-theme-surface); color: var(--hayha-theme-text); box-shadow: 0 4px 16px #0002; font-size: 14px; line-height: 20px; }
.hayha-account-menu [hidden], .hayha-account-menu__dropdown[hidden] { display: none !important; }
.hayha-account-menu__identity { display: flex; align-items: center; gap: 10px; padding: 12px 12px 24px; }
.hayha-account-menu__avatar--identity { flex-basis: 40px; width: 40px; height: 40px; font-size: 18px; color: var(--hayha-theme-text); }
.hayha-account-menu__identity-name { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.hayha-account-menu__member { margin: 0 12px 12px; border: 1px solid var(--hayha-theme-border); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px #0001; }
.hayha-account-menu__dropdown .hayha-account-menu__tier { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 8px; background: linear-gradient(110deg, var(--hayha-theme-accent), #cb402f); color: var(--hayha-theme-contrast); text-decoration: none; }
.hayha-account-menu__tier-label { display: block; font-size: 12px; line-height: 16px; }
.hayha-account-menu__tier strong { font-size: 14px; line-height: 20px; font-weight: 600; }
.hayha-account-menu__dropdown .hayha-account-menu__tier--silver { background: linear-gradient(110deg, var(--hayha-theme-muted), var(--hayha-theme-muted)); }
.hayha-account-menu__dropdown .hayha-account-menu__tier--gold { background: linear-gradient(110deg, #c8a05e, #946328); }
.hayha-account-menu__dropdown .hayha-account-menu__tier--platinum { background: linear-gradient(110deg, var(--hayha-theme-muted), var(--hayha-theme-heading)); }
.hayha-account-menu__stats { display: grid; grid-template-columns: 1fr 1fr; padding: 8px 0; color: var(--hayha-theme-muted); font-size: 12px; line-height: 18px; }
.hayha-account-menu__stats > span { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 8px; }
.hayha-account-menu__stats > span + span { border-left: 1px solid var(--hayha-theme-border); }
.hayha-account-menu__stats strong { font-size: 14px; font-weight: 500; color: var(--hayha-theme-accent); }
.hayha-account-menu__dropdown .hayha-account-menu__link { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; padding: 8px 12px; color: var(--hayha-theme-text); text-decoration: none; }
.hayha-account-menu__chevron { flex: 0 0 6px; color: var(--hayha-theme-muted); }
.hayha-account-menu__tier .hayha-account-menu__chevron { color: var(--hayha-theme-contrast); }
.hayha-account-menu__link:hover { background: #fff5ef; }
.hayha-account-menu__dropdown .hayha-account-menu__link--membership { border-top: 1px solid var(--hayha-theme-border); margin-top: 8px; padding-top: 12px; padding-bottom: 12px; }
.hayha-account-menu__dropdown .hayha-account-menu__logout { border-top: 1px solid var(--hayha-theme-border); margin-top: 4px; padding-top: 12px; padding-bottom: 12px; justify-content: flex-start; gap: 10px; color: #d70d00; }
.hayha-account-menu__logout svg { flex: 0 0 16px; }
.hayha-account-menu__dropdown a:focus-visible, .hayha-account-menu a:focus-visible, .hayha-account-menu button:focus-visible { outline: 2px solid var(--hayha-theme-accent); outline-offset: -3px; }
.hayha-auth-modal-card { overscroll-behavior: contain; scroll-padding: 24px; max-height: calc(var(--hayha-auth-viewport-height, 100dvh) - 32px); }
.hayha-auth-modal-card input { scroll-margin: 24px; }
.hayha-auth-modal-logo { height: 80px; max-width: 240px; width: auto; }
.hayha-auth-modal-logo-wrap { margin-bottom: 24px; }
.hayha-auth-modal-title { font-family: inherit; }
.hayha-auth-field-group { margin-bottom: 32px; }
@media (max-width: 767px) {
 .hayha-auth-modal-backdrop { padding: 16px 8px; }
 .hayha-auth-modal-card { max-width: 375px; padding: 44px 24px 20px; border-radius: 24px; max-height: calc(var(--hayha-auth-viewport-height, 100dvh) - 32px); }
 .hayha-auth-modal-title { font-size: 20px; line-height: 28px; }
 .hayha-auth-modal-logo { height: 64px; max-width: 220px; }
 .hayha-auth-modal-close { top: 16px; right: 16px; }
 .hayha-account-menu { width: 144px; }
}
@media (prefers-reduced-motion: reduce) {
 .hayha-auth-modal-backdrop, .hayha-auth-modal-card { transition: none; }
}

/* Cache-safe neutral shell until the private session response arrives. */
.hayha-account-menu[aria-busy="true"] .hayha-account-menu__trigger { opacity: 1; background: var(--hayha-theme-surface); color: var(--hayha-theme-muted); border-color: var(--hayha-theme-border); cursor: wait; }
.hayha-account-menu[aria-busy="true"] .hayha-account-menu__name { width: 72px; height: 10px; border-radius: 5px; background: var(--hayha-theme-soft); color: transparent; font-size: 0; }

@media(max-width:768px){
 .hayha-account-menu{width:34px;flex:0 0 34px}
 .hayha-account-menu .hayha-account-menu__trigger{width:34px;padding:0}
 .hayha-account-menu__trigger>.hayha-account-menu__name{display:none}
}
