:root {
    /* --- TYPE SYSTEM --- */
    --font-letter: 'Crimson Pro', serif;
    --font-ui: 'Inter', sans-serif;
    
    /* --- ANIMATION VARIABLES --- */
    --anim-letter-entry: 1100ms cubic-bezier(0.2, 0.8, 0.2, 1); 
    
    /* --- BASE VARIABLES (Defaults) --- */
    --bg-color: #F9F8F6;
    --text-primary: #363432;
    --text-secondary: #85817D;
    --line-color: rgba(0, 0, 0, 0.06);
    --input-bg: rgba(255, 255, 255, 0.5);
    --btn-color: #363432;
    
    /* Subtle Texture Overlay (Static) */
    --grain-url: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

/* --- THEME PALETTES (10 Variations) --- */

/* 1. Paper (Soft Cream) */
.theme-paper { 
    --bg-color: #F9F7F2; 
    --text-primary: #383533; 
    --text-secondary: #8F8B88; 
    --line-color: rgba(56, 53, 51, 0.08); 
}

/* 2. Rose (Muted Pink) */
.theme-rose { 
    --bg-color: #FDF7F7; 
    --text-primary: #4A3B3B; 
    --text-secondary: #9C8989; 
    --line-color: rgba(74, 59, 59, 0.06); 
}

/* 3. Mist (Calm Blue) */
.theme-mist { 
    --bg-color: #F4F7F9; 
    --text-primary: #343C42; 
    --text-secondary: #838C94; 
    --line-color: rgba(52, 60, 66, 0.07); 
}

/* 4. Sage (Green) */
.theme-sage { 
    --bg-color: #F5F7F5; 
    --text-primary: #3A423C; 
    --text-secondary: #87918A; 
    --line-color: rgba(58, 66, 60, 0.07); 
}

/* 5. Honey (Warm Yellow) */
.theme-honey { 
    --bg-color: #FDFAF2; 
    --text-primary: #474238; 
    --text-secondary: #969085; 
    --line-color: rgba(71, 66, 56, 0.07); 
}

/* 6. Lilac (Soft Purple) */
.theme-lilac { 
    --bg-color: #FAF8FC; 
    --text-primary: #403B45; 
    --text-secondary: #918B96; 
    --line-color: rgba(64, 59, 69, 0.06); 
}

/* 7. Dune (Sand/Brown) */
.theme-dune { 
    --bg-color: #F5F3EF; 
    --text-primary: #423D36; 
    --text-secondary: #918B83; 
    --line-color: rgba(66, 61, 54, 0.08); 
}

/* 8. Pool (Light Teal) */
.theme-pool { 
    --bg-color: #F2F7F7; 
    --text-primary: #2F3E3E; 
    --text-secondary: #859696; 
    --line-color: rgba(47, 62, 62, 0.07); 
}

/* 9. Canvas (Off-white Editorial) */
.theme-canvas { 
    --bg-color: #FAFAFA; 
    --text-primary: #1A1A1A; 
    --text-secondary: #757575; 
    --line-color: rgba(0, 0, 0, 0.05); 
}

/* 10. Clay (Earthy) */
.theme-clay { 
    --bg-color: #F7F5F4; 
    --text-primary: #453E3B; 
    --text-secondary: #968E8B; 
    --line-color: rgba(69, 62, 59, 0.07); 
}

/* --- GLOBAL RESET & BASE --- */
* { box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    margin: 0; padding: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-ui);
    min-height: 100vh;
    display: flex; 
    justify-content: center; 
    align-items: center;
    /* Slow fade for theme changes, though theme is usually fixed per day */
    transition: background-color 1.5s ease, color 1.5s ease;
    overflow: hidden; 
}

/* --- STATIC ATMOSPHERE (No Motion) --- */
.background-texture {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 1;
    background-image: var(--grain-url);
    opacity: 0.6; /* Balanced visibility */
}

/* --- LAYOUT --- */
#app {
    width: 100%; 
    max-width: 620px; /* Slightly wider for reading comfort */
    height: 100vh;
    overflow-y: auto; 
    overflow-x: hidden;
    padding: 60px 24px; 
    position: relative; 
    z-index: 10;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    scrollbar-width: none;
}
#app::-webkit-scrollbar { display: none; }

/* --- UTILITIES --- */
.hidden { display: none !important; }

.fade-out { 
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 800ms ease; 
}

/* --- ANIMATIONS (Single, Gentle Entry) --- */
.animate-entry { 
    animation: gentleReveal var(--anim-letter-entry) forwards; 
    will-change: opacity, transform;
}

@keyframes gentleReveal {
    0% { 
        opacity: 0; 
        transform: translateY(8px) scale(0.985); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

/* --- UI: BRANDING & PAYMENT --- */
.payment-container {
    width: 100%; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 2.5rem;
    transition: opacity 0.5s ease;
}

.brand-mark {
    font-family: var(--font-letter); 
    font-style: italic; 
    font-size: 1.25rem;
    color: var(--text-secondary); 
    letter-spacing: 0.02em;
}

.qr-frame {
    background: #fff; 
    padding: 16px; 
    border-radius: 2px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.03); /* Softer shadow */
}

.qr-placeholder {
    width: 160px; height: 160px; 
    background-color: #FAFAFA;
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}

.qr-placeholder::before {
    content: ''; position: absolute; top: 12px; left: 12px; right: 12px; bottom: 12px;
    background-image: radial-gradient(var(--text-secondary) 1.5px, transparent 1.5px);
    background-size: 6px 6px; opacity: 0.3;
}

.price-tag { 
    font-size: 0.85rem; 
    margin-top: -1rem; 
    color: var(--text-secondary); 
    font-weight: 400; 
    letter-spacing: 0.02em;
}

.input-group { width: 100%; max-width: 280px; text-align: left; }

.input-label { 
    display: block; 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    letter-spacing: 0.08em;
    color: var(--text-secondary); 
    margin-bottom: 0.75rem; 
    font-weight: 500; 
}

.utr-input {
    width: 100%; 
    padding: 12px 0; 
    font-family: var(--font-ui); 
    font-size: 1.1rem;
    background: transparent; 
    border: none;
    border-bottom: 1px solid var(--line-color);
    color: var(--text-primary); 
    outline: none; 
    border-radius: 0;
    transition: border-color 0.4s ease;
}

.utr-input::placeholder { color: var(--text-secondary); opacity: 0.4; }
.utr-input:focus { border-bottom-color: var(--text-secondary); }

.helper-text { 
    font-size: 0.75rem; 
    color: var(--text-secondary); 
    margin-top: 0.75rem; 
    line-height: 1.5; 
    opacity: 0.8;
}

.confirm-btn {
    background: transparent; 
    border: none; 
    color: var(--text-primary); 
    font-size: 0.95rem;
    margin-top: 1.5rem; 
    cursor: pointer; 
    border-bottom: 1px solid transparent; 
    padding-bottom: 4px;
    transition: all 0.4s ease; 
    opacity: 0.3; 
    pointer-events: none;
    font-family: var(--font-ui);
}

.confirm-btn.active { 
    opacity: 1; 
    pointer-events: auto; 
    border-bottom-color: var(--text-secondary); /* Soft underline */
}

/* --- UI: LETTER CONTENT (Reading Mode) --- */
.letter-container { 
    width: 100%; 
    opacity: 0; /* Starts hidden, animates in */
    padding-bottom: 120px; 
    max-width: 540px; /* Optimal reading width */
    margin: 0 auto;
}

/* New Date Display (Replaces old meta-header) */
.date-display {
    text-align: center;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 0.05em; /* Slightly increased */
    margin-bottom: 3.5rem; /* Matches old spacing */
    margin-top: 2rem;
    opacity: 0.8;
    font-weight: 400;
}

.letter-body { 
    font-family: var(--font-letter); 
    font-size: 1.35rem; /* Larger, clearer */
    line-height: 1.7; 
    color: var(--text-primary);
    font-weight: 400;
}

.letter-body p { margin-bottom: 2rem; }
.letter-body p:last-child { margin-bottom: 0; }

/* Support Section */
.support-section {
    text-align: center; 
    border-top: 1px solid var(--line-color); 
    padding-top: 3rem; 
    margin-top: 4rem;
    font-size: 0.9rem; 
    color: var(--text-secondary); 
    opacity: 0; 
    animation: gentleReveal 2s ease forwards; 
    animation-delay: 2s; /* Appears late */
}

.support-btn {
    background: transparent; 
    border: 1px solid var(--line-color);
    padding: 12px 24px; 
    border-radius: 2px;
    color: var(--text-primary); 
    margin-top: 1.5rem; 
    cursor: pointer; 
    font-family: var(--font-ui);
    font-size: 0.8rem; 
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
}
.support-btn:hover { 
    border-color: var(--text-secondary);
    background: rgba(255,255,255,0.3);
}

/* --- LOADING STATE --- */
.loader { 
    color: var(--text-secondary); 
    font-size: 0.85rem; 
    font-style: italic; 
    opacity: 0.6;
    font-family: var(--font-letter);
}

/* Mobile tweaks */
@media (max-width: 480px) {
    #app { padding: 40px 24px; display: block; } /* Allow natural flow */
    .payment-container { min-height: 80vh; justify-content: center; }
    .letter-body { font-size: 1.2rem; line-height: 1.65; }
}
