/* ==========================================
   DESIGN SYSTEM & VARIABLES
   ========================================== */
:root {
    /* Sweet Pink (Default) */
    --bg-1: #fdf2f4;
    --bg-2: #fce7f3;
    --bg-3: #fbcfe8;
    --mesh-1: #f9a8d4;
    --mesh-2: #f472b6;

    --primary: #e11d48;
    --primary-light: #fb7185;
    --primary-dark: #be123c;
    --primary-glow: rgba(225, 29, 72, 0.15);
    --primary-gradient: linear-gradient(135deg, #e11d48, #be123c);

    --text-dark: #1e1b2e;
    --text-body: #44415a;
    --text-muted: #9ca3af;
    --white: #ffffff;
    --paper: #fffbeb;

    --card-bg: rgba(255, 255, 255, 0.75);
    --card-border: rgba(255, 255, 255, 0.6);
    --input-bg: rgba(255, 255, 255, 0.7);
    --input-border: rgba(0, 0, 0, 0.08);
    --seg-bg: rgba(255, 255, 255, 0.65);
    --seg-border: rgba(255, 255, 255, 0.4);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 30px rgba(225, 29, 72, 0.08);
    --shadow-lg: 0 20px 60px rgba(225, 29, 72, 0.15);
    --shadow-glow: 0 0 40px rgba(225, 29, 72, 0.1);

    /* Fonts */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Outfit', -apple-system, sans-serif;
    --font-hand: 'Dancing Script', cursive;

    /* Spacing */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 32px;
    --radius-full: 50px;
}

/* ==========================================
   DARK ROMANCE THEME
   ========================================== */
[data-theme="dark"] {
    /* Unified Dark Theme (Ink Base) */
    --bg-1: #1a1218;
    --bg-2: #2d1f27;
    --bg-3: #1f1620;
    --mesh-1: rgba(225, 29, 72, 0.2);
    --mesh-2: rgba(139, 58, 98, 0.25);
    /* Plum hint */

    --primary: #ff4d6d;
    --primary-light: #ff758f;
    --primary-dark: #e11d48;
    --primary-glow: rgba(255, 77, 109, 0.2);
    --primary-gradient: linear-gradient(135deg, #ff4d6d, #e11d48);

    --text-dark: #f5f0f0;
    --text-body: #d4c8d0;
    /* Warmer grey */
    --text-muted: #9b8fa8;
    /* Silver/Purple tint */
    --white: #25191e;
    /* Warmer dark for cards */
    /* --paper: #1a1520; Keep paper light even in dark mode */
    --paper: #f0ead6;
    /* Eggshell/Vintage White for dark mode context */


    --card-bg: rgba(37, 25, 30, 0.85);
    --card-border: rgba(255, 77, 109, 0.12);
    --input-bg: rgba(255, 255, 255, 0.05);
    --input-border: rgba(255, 255, 255, 0.08);
    --seg-bg: rgba(255, 255, 255, 0.06);
    --seg-border: rgba(255, 255, 255, 0.05);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(255, 77, 109, 0.1);
}

/* ==========================================
   RESET & BASE
   ========================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-body);
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    padding: 2rem 1rem;
    transition: background 0.4s ease, color 0.4s ease;
}

/* ==========================================
   BACKGROUND MESH
   ========================================== */
.background-mesh {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    filter: blur(90px);
    opacity: 0.5;
    pointer-events: none;
    will-change: transform;
    transition: transform 0.3s ease-out;
}

.background-mesh::before,
.background-mesh::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    animation: meshFloat 25s infinite ease-in-out;
}

.background-mesh::before {
    top: -20%;
    left: -15%;
    width: 55vw;
    height: 55vw;
    background: radial-gradient(circle, var(--mesh-1) 0%, transparent 70%);
}

.background-mesh::after {
    bottom: -20%;
    right: -15%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--mesh-2) 0%, transparent 70%);
    animation-delay: -12s;
}

@keyframes meshFloat {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(40px, -20px) scale(1.05);
    }

    66% {
        transform: translate(-20px, 30px) scale(0.95);
    }
}

/* ==========================================
   THEME TOGGLE
   ========================================== */
.theme-toggle {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--input-border);
    background: var(--seg-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-body);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
    padding: 0;
}

.theme-toggle:hover {
    background: var(--primary-glow);
    color: var(--primary);
    transform: scale(1.08);
}

/* Show moon by default, sun when dark */
.theme-icon.sun {
    display: none;
}

.theme-icon.moon {
    display: block;
}

[data-theme="dark"] .theme-icon.sun {
    display: block;
}

[data-theme="dark"] .theme-icon.moon {
    display: none;
}

/* ==========================================
   CARD CONTAINER
   ========================================== */
.card-container {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 3.5rem 3rem;
    width: 100%;
    max-width: 580px;
    text-align: center;
    box-shadow: var(--shadow-md), var(--shadow-glow);
    position: relative;
    z-index: 1;
    animation: cardEntrance 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
    transition: background 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

@keyframes cardEntrance {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-container:hover {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* ==========================================
   TYPOGRAPHY
   ========================================== */
.card-header {
    margin-bottom: 2.5rem;
}

.subtitle {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 0.75rem;
    opacity: 0;
    animation: fadeInDown 0.6s ease-out 0.3s forwards;
}

.title {
    font-family: var(--font-heading);
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.15;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out 0.5s forwards;
}

/* ==========================================
   PICKUP LINE AREA
   ========================================== */
.content-area {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2.5rem;
    position: relative;
}

.pickup-line {
    font-size: 1.35rem;
    font-weight: 400;
    color: var(--text-dark);
    line-height: 1.7;
    font-family: var(--font-heading);
    font-style: italic;
    transition: opacity 0.3s ease;
    padding: 0 0.5rem;
}

.placeholder {
    color: var(--text-muted);
    font-style: normal;
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 300;
}

/* Typing Cursor */
.cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: var(--primary);
    margin-left: 3px;
    animation: blink 0.8s step-end infinite;
    vertical-align: text-bottom;
    border-radius: 1px;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ==========================================
   BUTTONS
   ========================================== */
.action-area {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.love-btn {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 1rem 2.2rem;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(225, 29, 72, 0.3);
    position: relative;
    overflow: hidden;
    z-index: 1;
    letter-spacing: 0.3px;
    /* Smooth color and shadow transition */
    transition: background-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    /* Prevent any size change */
    flex-shrink: 0;
}

.love-btn.surprise {
    background: linear-gradient(135deg, #c8365e, #be123c);
    /* Matches valentine theme but vibrant */
    box-shadow: 0 4px 15px rgba(200, 54, 94, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.love-btn.surprise:hover {
    background: linear-gradient(135deg, #d64570, #c81d45);
    box-shadow: 0 6px 20px rgba(200, 54, 94, 0.4);
    transform: translateY(-1px);
}

.love-btn:hover {
    background: var(--primary-light);
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.4);
}

.love-btn:active {
    background: var(--primary-dark);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
    filter: brightness(0.9);
}

.love-btn:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 3px;
}

.love-btn span {
    position: relative;
    z-index: 2;
    pointer-events: none;
}

.heart-icon {
    position: relative;
    z-index: 2;
    pointer-events: none;
}

/* Secondary Button */
.secondary-btn {
    background: transparent;
    border: 1.5px solid rgba(225, 29, 72, 0.2);
    color: var(--primary);
    padding: 0.8rem 1.8rem;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.secondary-btn:hover {
    background: var(--primary-glow);
    border-color: var(--primary-light);
    transform: translateY(-1px);
}

.secondary-btn:active {
    transform: translateY(0);
}

.secondary-btn:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 3px;
}

.text-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 1.2rem;
    padding: 0.5rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
}

.text-btn:hover {
    color: var(--primary);
}

/* ==========================================
   INLINE SVG ICON HELPERS
   ========================================== */
.btn-icon,
.tab-icon,
.radio-icon,
.back-icon {
    flex-shrink: 0;
    vertical-align: middle;
    position: relative;
    top: -0.5px;
}

/* ==========================================
   HIDDEN UTILITY
   ========================================== */
.hidden {
    display: none !important;
}

/* ==========================================
   LETTER FORM
   ========================================== */
.letter-form {
    text-align: left;
    margin-top: 1.5rem;
    animation: fadeInUp 0.5s ease-out;
}

.form-title {
    font-family: var(--font-heading);
    color: var(--text-dark);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.8rem;
    text-align: center;
    letter-spacing: -0.01em;
}

.input-group {
    margin-bottom: 1.2rem;
    position: relative;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

input,
textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1.5px solid var(--input-border);
    border-radius: var(--radius-sm);
    background: var(--input-bg);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-dark);
    transition: all 0.25s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

textarea {
    resize: vertical;
    min-height: 100px;
    max-height: 200px;
    line-height: 1.6;
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: var(--white);
}

.char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.full-width {
    width: 100%;
    margin-top: 0.5rem;
    justify-content: center;
}

/* ==========================================
   LETTER VIEW (Paper Style)
   ========================================== */
.letter-view {
    animation: fadeInUp 0.6s ease-out;
}

.paper {
    background: var(--paper);
    padding: 2.5rem 2.5rem 2.5rem 3rem;
    border-radius: 2px;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 6px 24px rgba(0, 0, 0, 0.08),
        inset 0 0 60px rgba(255, 248, 220, 0.3);
    position: relative;
    margin: 1.5rem auto 1.5rem;
    max-width: 100%;
    transform: rotate(-0.5deg);
    transition: transform 0.4s ease;
    overflow: hidden;
}

.paper:hover {
    transform: rotate(0deg);
}

/* Red margin line */
.paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 2.2rem;
    height: 100%;
    width: 1.5px;
    background: rgba(225, 29, 72, 0.15);
    z-index: 1;
}

/* Ruled lines */
.paper-lines {
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(transparent,
            transparent 31px,
            rgba(0, 0, 0, 0.04) 31px,
            rgba(0, 0, 0, 0.04) 32px);
    pointer-events: none;
    z-index: 0;
}

.paper-content {
    font-family: var(--font-hand);
    font-size: 1.5rem;
    line-height: 2;
    color: #2d2a3e;
    text-align: left;
    position: relative;
    z-index: 2;
}

.greeting {
    font-weight: 700;
    font-size: 1.7rem;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.letter-body {
    margin: 0.5rem 0 1rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.signature {
    font-weight: 600;
    color: var(--primary-dark);
    margin-top: 1rem;
}

.from-name {
    font-size: 1.8rem;
    display: inline-block;
    margin-top: 0.3rem;
}

.heart-doodle {
    color: var(--primary);
    font-size: 1.2rem;
    margin-left: 6px;
    display: inline-block;
    animation: heartDoodle 2s ease-in-out infinite;
}

@keyframes heartDoodle {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }
}

.letter-actions {
    margin-top: 1.5rem;
    text-align: center;
}

/* ==========================================
   TOAST NOTIFICATION
   ========================================== */
.toast {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: var(--white);
    padding: 0.8rem 1.4rem;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
}

.toast.show {
    bottom: 2rem;
}

.toast-icon {
    display: flex;
    align-items: center;
    color: #4ade80;
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================
   NEW UI ELEMENTS
   ========================================== */
.secondary-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.form-instruction {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    margin-top: -1rem;
}

.code-display-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--bg-1);
    border: 2px dashed var(--primary-light);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 1.5rem;
    position: relative;
}

.generated-code {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary-dark);
    text-transform: uppercase;
}

.copy-btn {
    background: var(--white);
    border: 1px solid var(--primary-light);
    color: var(--primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--primary);
    color: var(--white);
    transform: scale(1.05);
}

.success-hint {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

#letter-code {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 4px;
    color: var(--primary);
    text-transform: uppercase;
}

/* === VISIBILITY OPTIONS (Segmented Control) === */
.visibility-options {
    display: flex;
    background: var(--seg-bg);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--seg-border);
    gap: 0;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.radio-label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 10px 14px;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid transparent;
    font-weight: 500;
    text-align: center;
    position: relative;
    z-index: 1;
}

.radio-label:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.3);
}

.radio-label input[type="radio"] {
    display: none;
}

/* Active State (supports both modern :has and JS fallback .active) */
.radio-label:has(input:checked),
.radio-label.active {
    background: var(--white);
    color: var(--primary);
    border-color: rgba(225, 29, 72, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

.radio-text {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 2;
}

/* === READ TABS (Segmented Control) === */
.read-tabs {
    display: flex;
    background: var(--seg-bg);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--seg-border);
    margin-bottom: 24px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px;
    border-radius: 8px;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tab-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.3);
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* === SORT BAR === */
.sort-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
}

.sort-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.sort-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--seg-bg);
    border: 1px solid var(--seg-border);
    border-radius: 8px;
    padding: 7px 28px 7px 10px;
    font-family: var(--font-body);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.25s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    min-width: 0;
    flex: 1;
    max-width: 180px;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.sort-select:hover {
    border-color: var(--primary-light);
}

.sort-select option {
    background: var(--white);
    color: var(--text-dark);
    padding: 6px;
}

[data-theme="dark"] .sort-select {
    background-color: #1e1528;
}

[data-theme="dark"] .sort-select option {
    background: #1e1528;
    color: #f0e6f6;
}

/* === PUBLIC LIST === */
.public-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

.public-list::-webkit-scrollbar {
    width: 4px;
}

.public-list::-webkit-scrollbar-track {
    background: transparent;
}

.public-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
}

.public-card {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    animation: fadeInCard 0.4s ease forwards;
}

.public-card:hover {
    background: var(--white);
    border-color: rgba(225, 29, 72, 0.15);
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.08);
    transform: translateY(-2px);
}

.public-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.card-to {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
}

.card-msg {
    font-size: 0.8rem;
    color: var(--text-body);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
    font-style: italic;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--input-border);
}

.card-from {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.like-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 0.78rem;
    padding: 4px 8px;
    border-radius: 20px;
    transition: all 0.25s ease;
}

.like-btn:hover {
    color: var(--primary);
    background: var(--primary-glow);
}

.like-btn.liked {
    color: var(--primary);
}

.like-count {
    font-weight: 600;
}

@keyframes fadeInCard {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.loading-spinner {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.loading-spinner::before {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.06);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: btnSpin 0.8s linear infinite;
}

/* ==========================================
   RESPONSIVE
   ========================================== */

/* ==========================================
   RESPONSIVE & LAYOUTS
   ========================================== */

/* --- Desktop Logic (Split View) --- */
@media (min-width: 1024px) {
    body {
        padding: 0;
        height: 100vh;
        overflow: hidden;
        /* Prevent body scroll, handle in card */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .card-container {
        max-width: 100%;
        width: 100%;
        height: 100vh;
        /* Full viewport height */
        max-height: none;
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* Equal split */
        grid-template-rows: auto 1fr;
        gap: 0;
        /* No gap, use padding */
        padding: 4rem 6rem;
        /* Generous padding for content */
        text-align: left;
        border-radius: 0;
        /* No corners */
        background: rgba(255, 255, 255, 0.4);
        /* Lighter glass for full screen */
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: none;
        /* Remove drop shadow for full bleed */
    }

    /* Dark mode adjustment */
    [data-theme="dark"] .card-container {
        background: rgba(20, 15, 30, 0.75);
    }

    /* --- Left Column (Header & Content) --- */
    .card-header {
        grid-column: 1;
        grid-row: 1;
        margin-bottom: 2rem;
        z-index: 2;
    }

    .title {
        font-size: 3.5rem;
        line-height: 1.1;
    }

    .subtitle {
        font-size: 0.9rem;
        margin-left: 4px;
    }

    /* Force Content Area to stay visible on Desktop even if "hidden" class is added */
    .content-area,
    .content-area.hidden {
        display: flex !important;
        grid-column: 1;
        grid-row: 2;
        align-items: center;
        /* Center vertically */
        justify-content: center;
        /* Center horizontally */
        padding-top: 0;
        padding-right: 4rem;
        opacity: 1 !important;
        pointer-events: none;
        /* Let clicks pass through if needed, but text selectable */
        z-index: 1;
    }

    .pickup-line {
        font-size: 2rem;
        /* Larger for full screen */
        line-height: 1.4;
        padding: 0;
        text-align: left;
        max-width: 600px;
        /* Prevent too long lines */
    }

    /* --- Right Column (Actions & Forms) --- */
    .action-area,
    .letter-form,
    .read-letter-form,
    .letter-view,
    .success-view {
        grid-column: 2;
        grid-row: 1 / span 2;
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 100%;
        padding-left: 2rem;
        border-left: 1px solid rgba(0, 0, 0, 0.06);
        /* Subtle divider */
    }

    [data-theme="dark"] .action-area,
    [data-theme="dark"] .letter-form,
    [data-theme="dark"] .read-letter-form,
    [data-theme="dark"] .letter-view,
    [data-theme="dark"] .success-view {
        border-left-color: rgba(255, 255, 255, 0.08);
    }

    /* Center the initial action inputs */
    .action-area {
        align-items: center;
        /* Center buttons horizontally */
        justify-content: center;
        max-width: 500px;
        margin: 0 auto;
        width: 100%;
    }

    /* Forms should take full width of their column */
    .letter-form,
    .read-letter-form,
    .success-view {
        max-width: 480px;
        margin: 0 auto;
        width: 100%;
    }

    /* Paper view in desktop split */
    .letter-view {
        justify-content: flex-start;
        /* Align to top */
        overflow-y: auto;
        /* Scroll if letter is long */
        padding-right: 1rem;
    }

    .paper {
        margin-top: 0;
        transform: rotate(-1deg);
    }

    .paper:hover {
        transform: rotate(0deg);
    }

    /* Hide separate title in form since main title is always visible on left */
    .form-title {
        display: none;
    }

    /* Theme Toggle Position */
    .theme-toggle {
        top: 2rem;
        right: 2rem;
    }

    /* Scrollbar for right pane */
    .letter-view::-webkit-scrollbar {
        width: 6px;
    }

    .letter-view::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 4px;
    }
}

/* --- Tablet & Small Laptops (Portrait/Stack) --- */
@media (max-width: 1023px) {
    body {
        padding: 2rem 1rem;
        min-height: 100vh;
        overflow-y: auto;
    }

    .card-container {
        max-width: 600px;
        min-height: auto;
        padding: 3rem 2rem;
    }

    .content-area.hidden {
        display: none !important;
    }
}

/* --- Mobile Phones (Full Height App Feel) --- */
@media (max-width: 768px) {
    body {
        padding: 0;
        margin: 0;
        background: var(--bg-1);
        /* Solid bg for performance/safari bars */
    }

    .card-container {
        width: 100%;
        max-width: 100%;

        /* Full Viewport Height with Safe Areas */
        min-height: 100vh;
        min-height: 100dvh;
        /* Dynamic viewport height */

        padding:
            max(1.5rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));

        border-radius: 0;
        border: none;
        box-shadow: none;
        background: var(--card-bg);

        /* Flex Layout to fill space */
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        /* Header Top, Buttons Bottom */
    }

    /* SECTION 1: Header (Top) */
    .card-header {
        margin-bottom: 1rem;
        flex-shrink: 0;
        width: 100%;
        text-align: center;
    }

    .title {
        font-size: 2.5rem;
    }

    .theme-toggle {
        top: max(1rem, env(safe-area-inset-top));
        right: 1rem;
    }

    /* SECTION 2: Content (Middle - Grows) */
    .content-area {
        flex-grow: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0;
        padding: 1rem 0;
        width: 100%;
    }

    .pickup-line {
        font-size: 1.35rem;
        /* Larger on mobile for impact */
        padding: 0 1rem;
    }

    /* When content is hidden (forms open), simple hide */
    .content-area.hidden {
        display: none;
    }

    /* SECTION 3: Actions (Bottom) */
    .action-area,
    .letter-form,
    .read-letter-form,
    .letter-view,
    .success-view {
        width: 100%;
        flex-shrink: 0;
        margin-bottom: env(safe-area-inset-bottom);
    }

    /* Ensure forms take available space if needed, but prioritize bottom alignment */
    .letter-form,
    .read-letter-form,
    .success-view,
    .letter-view {
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        /* Align inputs to bottom for easy reach */
        animation: fadeInUp 0.4s ease-out;
        flex-grow: 1;
        /* Allow growing to fill middle if content hidden */
        justify-content: center;
        /* Actually center forms visually looks better */
    }

    /* Mobile Form Tweaks */
    .form-title {
        font-size: 1.5rem;
        margin-bottom: 2rem;
    }

    .input-group label {
        font-size: 0.8rem;
    }

    input,
    textarea {
        font-size: 16px;
        /* Prevent iOS zoom */
        padding: 12px;
    }

    .love-btn {
        width: 100%;
        padding: 1.1rem;
        /* Fatter buttons for touch */
    }

    .secondary-btn {
        width: 100%;
        padding: 1rem;
    }

    .secondary-actions {
        flex-direction: column;
        gap: 12px;
    }

    /* Adjust Paper View for Mobile */
    .letter-view {
        justify-content: flex-start;
        padding-top: 1rem;
    }

    .paper {
        margin: 0 auto 1.5rem;
        padding: 1.5rem;
        width: 100%;
    }
}

/* --- Very Small Phones (SE/Mini) --- */
@media (max-width: 375px) {
    .title {
        font-size: 2rem;
    }

    .pickup-line {
        font-size: 1.15rem;
    }

    .card-container {
        padding-left: 1.2rem;
        padding-right: 1.2rem;
    }
}

/* --- Privacy / Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Utilities --- */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: btnSpin 1s infinite linear;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes btnSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================
   BUFFERING ANIMATION (Restored)
   ========================================== */
.loader-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 13, 26, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loader-overlay.show {
    opacity: 1;
    visibility: visible;
}

.heart-loader {
    position: relative;
    width: 60px;
    height: 60px;
}

.heart-loader::before,
.heart-loader::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.6;
    animation: ripple 2s cubic-bezier(0, 0.2, 0.8, 1) infinite;
}

.heart-loader::after {
    animation-delay: -1s;
}

.heart-icon-loader {
    position: relative;
    z-index: 10;
    color: var(--primary);
    filter: drop-shadow(0 0 10px var(--primary));
    animation: heartBeat 1.2s infinite ease-in-out;
}

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

@keyframes heartBeat {
    0% {
        transform: scale(0.95);
    }

    5% {
        transform: scale(1.1);
    }

    39% {
        transform: scale(0.85);
    }

    45% {
        transform: scale(1);
    }

    60% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(0.9);
    }
}