html,
body {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

:root {
    --primary: #4A3B32;
    --secondary: #8C7E72;
    --accent: #C5B398;
    --background: #FDFBF7;
    --surface: #EFEBE2;
    --stone-50: #F9F8F6;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --terracotta: #C87F66;
}

body {
    font-family: 'Apple SD Gothic Neo', 'Inter', sans-serif;
    background-color: #F3F1ED;
    color: var(--primary);
}

.premium-serif {
    font-family: 'DM Serif Display', 'Playfair Display', serif;
}

.glass-card {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
}

.section-title {
    position: relative;
    padding-left: 1rem;
    margin-bottom: 1.5rem;
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
}

.section-title::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    border-radius: 2px;
    background: var(--accent);
}

.timeline-scroll {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.timeline-scroll::-webkit-scrollbar {
    display: none;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

/* Specific Gradients for Sections */
.bg-gradient-outer {
    background: linear-gradient(135deg, #FFB800 0%, #FF9900 100%);
}

.bg-gradient-inner {
    background: linear-gradient(135deg, #1E40AF 0%, #3B82F6 100%);
}

.animate-fade-in {
    animation: fadeInUp 0.5s ease-out forwards;
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fade-in-down {
    animation: fadeInDown 0.6s ease-out forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Skeleton Ink-Spread Effect */
.skeleton-ink {
    animation: ink-spread 1.2s ease-in-out infinite;
    background: linear-gradient(90deg, #e7e0d9 25%, #d6cfc7 50%, #e7e0d9 75%) !important;
    background-size: 200% 100% !important;
    color: transparent !important;
}

@keyframes ink-spread {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Auth Buttons */
.auth-nav {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    z-index: 100;
}

.btn-auth-login {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--secondary);
    transition: color 0.2s;
}

.btn-auth-login:hover {
    color: var(--primary);
}

.btn-auth-signup {
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background-color: var(--accent);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(200, 127, 102, 0.2);
    transition: all 0.2s;
}

.btn-auth-signup:hover {
    background-color: #B06A55;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(200, 127, 102, 0.3);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(45, 36, 30, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}


.modal-content {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 251, 246, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 32px;
    padding: 2.5rem;
    box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.form-input {
    width: 100%;
    background: white;
    border: 1px solid #E6DCCF;
    border-radius: 16px;
    padding: 0.875rem 1.25rem;
    font-size: 0.9375rem;
    transition: all 0.2s;
    color: var(--primary);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(200, 127, 102, 0.1);
}

/* Physiognomy Styles */
.face-guide {
    width: 280px;
    height: 380px;
    border: 2px dashed rgba(200, 127, 102, 0.3);
    border-radius: 140px 140px 100px 100px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(4px);
    margin: 2rem auto;
    overflow: hidden;
    transition: all 0.5s ease;
}

.face-guide::before {
    content: '';
    position: absolute;
    top: 45%;
    width: 80%;
    height: 1px;
    background: rgba(200, 127, 102, 0.2);
}

.face-guide-inner {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.5s;
}

.fiber-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.fiber-line {
    position: absolute;
    height: 2px;
    border-radius: 1px;
    opacity: 0;
    box-shadow: 0 0 8px currentColor;
    transform-origin: left center;
}

@keyframes fiberGrow {
    0% {
        width: 0;
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        width: var(--w);
        opacity: 0;
    }
}

/* Pentagon Chart */
.pentagon-svg {
    width: 240px;
    height: 240px;
    transform: rotate(-18deg);
}

.pentagon-grid {
    fill: none;
    stroke: #E6DCCF;
    stroke-width: 1;
}

.pentagon-data {
    fill: rgba(200, 127, 102, 0.2);
    stroke: var(--accent);
    stroke-width: 2;
    filter: drop-shadow(0 0 4px rgba(200, 127, 102, 0.4));
}

/* Aura Card */
.aura-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: blur(40px);
    opacity: 0.3;
    z-index: -1;
    border-radius: 24px;
}

.aura-fire {
    background: radial-gradient(circle, #FF4D4D, transparent);
}

.aura-water {
    background: radial-gradient(circle, #4D79FF, transparent);
}

.aura-wood {
    background: radial-gradient(circle, #4DFF79, transparent);
}

/* Scrollbar Hiding Utility */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.aura-metal {
    background: radial-gradient(circle, #E6E6E6, transparent);
}

.aura-earth {
    background: radial-gradient(circle, #FFB84D, transparent);
}

.physio-accordion {
    border-bottom: 1px solid #F1ECE6;
}

.physio-accordion:last-child {
    border-bottom: none;
}

.physio-accordion-header {
    width: 100%;
    padding: 1.25rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: var(--primary);
    transition: all 0.2s;
}

.physio-accordion-header.active {
    color: var(--accent);
}

.physio-accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    color: var(--secondary);
    font-size: 0.8125rem;
    line-height: 1.6;
}

/* Banner & Guide Styles */
.notice-banner {
    height: 40px;
    overflow: hidden;
    position: relative;
}

.notice-item {
    height: 40px;
    line-height: 40px;
    transition: transform 0.5s ease-in-out;
}

.guide-step {
    position: relative;
    padding-left: 3rem;
}

.guide-number {
    position: absolute;
    left: 0;
    top: 0;
    width: 2rem;
    height: 2rem;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
    box-shadow: 0 4px 10px rgba(200, 127, 102, 0.2);
}

/* Custom Animations */
@keyframes scanLaser {
    0% {
        top: 0%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 100%;
        opacity: 0;
    }
}

.animate-scan {
    animation: scanLaser 2s linear infinite;
}

.bg-ink-black {
    background: linear-gradient(135deg, #0F0F10 0%, #1A1A1D 100%);
}

/* Infinite Marquee */
@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

.animate-marquee {
    display: inline-flex;
    animation: marquee 40s linear infinite;
}

.animate-marquee:hover {
    animation-play-state: paused;
}

/* --- Onboarding v2 Styles --- */
#onboarding-container {
    position: fixed;
    inset: 0;
    background-color: #FDFBF9;
    transition: background-color 1s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    display: none;
    overflow-y: auto;
}

#onboarding-container.active {
    display: block;
}

.onboarding-step {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
}

.onboarding-step.active {
    display: flex;
    animation: onboardingFadeIn 0.8s ease-out forwards;
}

@keyframes onboardingFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.onboarding-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.05);
    z-index: 2100;
}

.onboarding-progress-bar {
    height: 100%;
    background: var(--terracotta);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

}

50% {
    opacity: 1;
}

100% {
    transform: translateY(-100%) translateX(20px);
    opacity: 0;
}
}

/* MBTI Card Slider */
.mbti-stage {
    position: relative;
    width: 100%;
    height: 380px;
    margin-top: 2rem;
    perspective: 1000px;
}

.mbti-card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 32px;
    padding: 2.5rem;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.mbti-card.current {
    z-index: 10;
    transform: translateZ(0);
    opacity: 1;
}

.mbti-card.prev {
    transform: translateY(-120%) rotate(-10deg) translateZ(-100px);
    opacity: 0;
    pointer-events: none;
}

.mbti-card.next {
    transform: translateY(15px) scale(0.92) translateZ(-50px);
    z-index: 5;
    opacity: 0.6;
    pointer-events: none;
}

.mbti-card.stack {
    transform: translateY(30px) scale(0.85) translateZ(-100px);
    z-index: 0;
    opacity: 0.3;
}

/* Element Themes */
.theme-wood {
    background-color: #F3F9F4 !important;
}

.theme-fire {
    background-color: #FFF5F5 !important;
}

.theme-earth {
    background-color: #FAF7F2 !important;
}

.theme-metal {
    background-color: #F8F9FA !important;
}

.theme-water {
    background-color: #F0F4F8 !important;
}

/* Dark Overlays for high contrast steps if needed */
.onboarding-dark {
    color: #FFFBF6;
}

.onboarding-dark .form-input {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Moon Phase Gauge */
.gauge-moon-mask {
    mask-image: linear-gradient(to top, black var(--fill-percent), transparent var(--fill-percent));
    -webkit-mask-image: linear-gradient(to top, black var(--fill-percent), transparent var(--fill-percent));
    transition: --fill-percent 2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Smart Header & Footer Transitions */
#global-main-header,
#global-bottom-nav {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.header-hidden {
    transform: translateY(-100%);
}

.footer-hidden {
    transform: translateY(100%);
}

/* Ensure header is COMPLETELY hidden in chat section regardless of scroll */
body.chat-section-active #global-main-header,
body:has(#chat-section:not(.hidden)) #global-main-header {
    display: none !important;
}

/* Marquee */
@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

.animate-marquee {
    display: inline-flex;
    animation: marquee 40s linear infinite;
}

.animate-marquee:hover {
    animation-play-state: paused;
}