:root {
    --transition-duration: 0.3s;
    --color-bg: #ffffff;
    --color-text: #333333;
    --color-shadow: rgba(0, 0, 0, 0.1);
    --color-shadow-hard: rgba(0, 0, 0, 0.2);
    --show-more-btn-background: #000409;
    --show-more-btn-text-color: #ffffff;
    --show-more-btn-hover-background: #5a5b5d;
    --show-more-btn-active-background: #000409;
    
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
    --text-muted: #64748b;
}

:root[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-text: #f8fafc;
    --color-shadow: rgba(0, 0, 0, 0.4);
    --show-more-btn-background: #f9f9fa;
    --show-more-btn-text-color: #040404;
    --show-more-btn-hover-background: #656566;
    --show-more-btn-active-background: #f9f9fa;

    --card-bg: #1e293b;
    --border-color: #334155;
    --accent-color: #60a5fa;
    --text-muted: #94a3b8;
}

html {
    overflow-x: hidden;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-weight: 500;
    background-color: var(--color-bg);
    color: var(--color-text);
}

body.fonts-loaded {
    font-family: "Zen Kaku Gothic New", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
}

body.no-gsap .spin-btn:hover {
    transform: scale(1.05) rotate(3deg);
    transition: transform 0.2s ease;
}

.background-auto {
    background-color: var(--color-bg);
    color: #2d3748;
}

/* Background Animations */
.bg-gradient {
    width: 100%;
    height: 300px;
    background-size: 400% 400%;
    z-index: 0;
}

.bg-wave {
    max-height: 300px;
    height: 300px;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    overflow: hidden;
    z-index: 1;
    pointer-events: none;
}

.bg-wave-inner {
    position: absolute;
    inset: 0;
    width: 200%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
    mix-blend-mode: overlay;
    will-change: transform;
}

/* Header & Nav */
#nav1 {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 30px 0;
    margin: 0 auto;
    max-width: 1280px;
    z-index: 1000;
    position: relative;
}

.logo {
    width: 250px;
    display: flex;
    justify-content: center;
    transform: rotate(-4deg);
    cursor: pointer;
}

.logo img {
    width: 100%;
    height: auto;
    filter: drop-shadow(2px 2px 1px rgba(0, 0, 0, 0.2));
}

.slogan {
    margin: 15px;
    font-size: clamp(18px, 6vw, 26px);
    color: white;
    font-weight: 500;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-height: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Menu Styles */
.menu {
    width: 100%;
    max-width: 1000px !important; /* Increase width to accommodate dropdown */
    display: flex;
    justify-content: space-between !important; /* Push dropdown to right */
    align-items: baseline;
    gap: 20px;
    filter: drop-shadow(2px 2px 1px rgba(0, 0, 0, 0.2));
    position: relative;
    padding: 0 20px; /* Add side padding */
    box-sizing: border-box;
    margin: 0 auto;
}

/* Glassmorphism Button Styles - Liquid Wave Effect */
.menu .titleButton {
    display: flex;
    flex-direction: row;
    align-items: center;
    text-decoration: none;
    gap: 10px;
    padding: 10px 20px;
    background: transparent;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* The Liquid Glass Layer */
.menu .titleButton::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 85%; /* Initial water level */
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: -1;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s;
    
    /* Wave Mask */
    /* --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cpath d='M0,30 Q100,0 200,30 T400,30 V60 H0 Z' fill='black'/%3E%3C/svg%3E"); */
    --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 60' preserveAspectRatio='none'%3E%3Cpath d='M0,30 Q100,10 200,30 T400,30 V60 H0 Z' fill='black'/%3E%3C/svg%3E");

    -webkit-mask: var(--wave) repeat-x;
    mask: var(--wave) repeat-x;
    -webkit-mask-size: 200% 100%;
    mask-size: 200% 100%;
    -webkit-mask-position: 0 bottom;
    mask-position: 0 bottom;
    
    animation: waveFlow 4s linear infinite;
}

/* Second subtle wave layer for depth (optional, keeping it simple for now) */

@keyframes waveFlow {
    0% {
        -webkit-mask-position: 0 bottom;
        mask-position: 0 bottom;
    }
    100% {
        -webkit-mask-position: -200% bottom; /* Move left by 200% width */
        mask-position: -200% bottom;
    }
}

.menu .titleButton:hover {
    transform: translateY(-5px);
}

.menu .titleButton:hover::before {
    height: 85%; /* Water level rises */
    background: rgba(255, 255, 255, 0.25);
    animation: waveFlow 4s linear infinite; 
}

.menu a img {
    display: block;
    height: 40px;
    width: auto;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15)); /* Enhanced shadow for depth */
}

.menu-label {
    font-size: 16px;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    z-index: 2;
}

/* Read Menu Dropdown - Glass Style */
.read-menu-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.read-menu-items {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 10px;
    transform: translateY(10px);
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    z-index: 1001;
}

/* Invisible bridge to prevent menu from closing when moving mouse */
.read-menu-items::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%;
    height: 20px;
    background: transparent;
}

/* Open State */
.read-menu-container.open .read-menu-items {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.read-item {
    display: block;
    padding: 10px 0;
    color: #1e293b;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    background: transparent;
    border-radius: 10px;
    margin-bottom: 2px;
    width: 100%;
    white-space: nowrap;
}

.read-item:last-child {
    margin-bottom: 0;
}

.read-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

/* Dark Theme Overrides */
:root[data-theme="dark"] .read-menu-items {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] .new-article-card {
    margin: 10px;
}

:root[data-theme="dark"] .read-item {
    color: #f8fafc;
}

:root[data-theme="dark"] .read-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Icon IDs & Buttons */
#flashcard, #read, #game, #login {
    object-fit: contain;
    filter: drop-shadow(2px 2px 1px var(--color-shadow));
}

.titleButton {
    z-index: 1002;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    #nav1 { padding: 20px 16px; }
    .menu { gap: 10px; flex-wrap: wrap; }
    .menu-label { font-size: 14px; }
    .menu a img { height: 36px; }
    .slogan { font-size: 20px; }
}
.menu-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Dropdown Styling in Menu */
#dropdown {
    position: relative;
    z-index: 1001;
}

#dropdown .dropdown-toggle {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

#dropdown .dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

#dropdown .dropdown-toggle .arrow {
    border-color: white;
    margin-left: 8px;
    margin-top: -2px;
}

#dropdown .dropdown-options {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    min-width: 180px;
    right: 0;
    left: auto;
    padding: 6px;
    margin-top: 10px;
    overflow: hidden;
    display: none;
    position: absolute;
    z-index: 1002;
    flex-direction: column;
}

#dropdown.open .dropdown-options {
    display: flex;
    animation: fadeIn 0.2s ease;
}

/* 移动端修复：确保下拉选项保持居中 */
@media (max-width: 768px) {
    #dropdown.open .dropdown-options {
        animation: fadeInMobile 0.2s ease;
    }
}

@keyframes fadeInMobile {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#dropdown .dropdown-group-title {
    color: #64748b;
    font-size: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    margin-bottom: 4px;
    font-weight: 600;
}

#dropdown .dropdown-option {
    color: #1e293b;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    border-radius: 10px;
    margin-bottom: 2px;
    cursor: pointer;
    text-align: left;
}

#dropdown .dropdown-option:last-child {
    margin-bottom: 0;
}

#dropdown .dropdown-option:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #0f172a;
    transform: translateX(4px);
}

/* Dark Theme Dropdown Overrides */
:root[data-theme="dark"] #dropdown .dropdown-options {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] #dropdown .dropdown-option {
    color: #f8fafc;
}

:root[data-theme="dark"] #dropdown .dropdown-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

:root[data-theme="dark"] #dropdown .dropdown-group-title {
    color: #94a3b8;
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .menu {
        flex-direction: column;
        height: auto;
        padding: 20px 0;
        align-items: center; /* 确保dropdown居中 */
    }

    .menu-left {
        justify-content: center;
        width: 100%;
    }

    #dropdown {
        margin-top: 10px;
        align-self: center; /* 确保dropdown本身居中 */
    }

    #dropdown .dropdown-options {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}

@media (max-width: 900px) {
    .menu-left {
        display: none;
    }
    .menu { display: none !important; }
    .mobile-nav-container { display: flex !important; }

}

/* Main Content and Articles Grid Layout (Ported from pages/stories/styles.css) */
.main-content {
    padding: 2rem 0;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 2rem auto;
    width: 100%;
    max-width: 400px;
}

.pagination-sub-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background-color: var(--card-bg);
    color: var(--color-text);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px var(--color-shadow);
}

.pagination-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--color-shadow);
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.pagination-btn:hover img {
    filter: brightness(0) invert(1);
}

.pagination-btn:active {
    transform: translateY(0);
}

.pagination-btn img {
    width: 20px;
    height: 20px;
    transition: all 0.2s ease;
}

.pagination-btn:disabled, .pagination-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    background-color: rgba(0,0,0,0.05);
}

.page-indicator {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-muted);
    font-family: monospace;
}

/* Dark theme adjustments */
:root[data-theme="dark"] .pagination-btn {
    background-color: var(--card-bg);
    color: var(--color-text);
}

:root[data-theme="dark"] .pagination-btn:hover {
    color: white;
}

:root[data-theme="dark"] .pagination-btn img {
    filter: invert(1);
}

.articles-grid {
    column-count: 1;
    column-gap: 2rem;
    padding: 1rem;
    display: block;
}

@media (min-width: 769px) {
    .articles-grid {
        column-count: 2;
    }
}

/* Article Card Styles */
.article-card {
    height: auto;
    display: flex;
    flex-direction: column;
    justify-content: left;
    align-items: center;
    position: relative;
    break-inside: avoid;
    margin-bottom: 0;
    width: 100%;
    background: transparent;
    padding-bottom: 1.5rem;
    cursor: default;
}

@media (min-width: 769px) {
    .article-card {
        cursor: default;
    }
}

/* Separator line between articles - not touching edges */
.article-card:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 24px;
    right: 24px;
    height: 1px;
    background-color: var(--color-text);
    opacity: 1;
}

.article-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: left;
    align-items: center;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
    box-shadow: none;
    transform-origin: center bottom;
    border-radius: 0;
    background: transparent;
}

.article-content.collapsed {
    max-height: 200px;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.collapse-btn {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 10px 0;
    cursor: pointer;
    background: transparent;
    border: none;
    outline: none;
    margin-top: 0;
    z-index: 2;
    position: relative;
}

.article-content.collapsed + .collapse-btn {
    margin-top: -40px;
}

.collapse-btn img {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
    opacity: 0.6;
    filter: invert(0); /* Default for light theme */
}

:root[data-theme="dark"] .collapse-btn img {
    filter: invert(1);
}

.collapse-btn:hover img {
    opacity: 1;
    transform: scale(1.2);
}

/* When content is NOT collapsed (Expanded), arrow points UP */
.article-content:not(.collapsed) + .collapse-btn img {
    transform: rotate(180deg);
}

/* When content IS collapsed, arrow points DOWN (default icon orientation) */
.article-content.collapsed + .collapse-btn img {
    transform: rotate(0deg);
}


/* Skeleton Loader Styles */
.skeleton-card {
    background: var(--color-bg);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--color-shadow);
    box-shadow: 0 2px 8px var(--color-shadow);
    animation: skeleton-pulse 1.5s ease-in-out infinite alternate;
    break-inside: avoid;
    margin-bottom: 2rem;
}

.skeleton-content {
    margin-bottom: 1rem;
}

.skeleton-line {
    height: 1rem;
    border-radius: 4px;
    background: linear-gradient(90deg, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
    margin-bottom: 0.8rem;
}

.skeleton-title { height: 1.4rem; width: 85%; }
.skeleton-text { width: 100%; }
.skeleton-text.short { width: 60%; }

.skeleton-footer {
    display: flex;
    gap: 0.8rem;
    margin-top: 1rem;
}

.skeleton-badge {
    height: 1.2rem;
    width: 4rem;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(0,0,0,0.05) 25%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes skeleton-pulse {
    0% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* Dark Theme Skeleton */
:root[data-theme="dark"] .skeleton-card {
    background: #1e293b;
    border-color: #334155;
}

:root[data-theme="dark"] .skeleton-line,
:root[data-theme="dark"] .skeleton-badge {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
}

/* Novel & Drama Icons - Hidden */
.novel-icon, .drama-icon {
    display: none;
}

/* Mobile Simplification */
@media (max-width: 768px) {
    .articles-grid {
        column-count: 1;
        padding: 0.5rem 0;
    }

    .article-card {
        padding: 1rem 0;
        cursor: pointer;
        transition: background-color 0.2s ease, opacity 0.2s ease;
    }

    .article-card:active {
        opacity: 0.7;
    }

    .article-content {
        margin-top: 0;
        padding: 0 1rem;
    }

    .article-content.collapsed + .collapse-btn {
        margin-top: 0;
    }

    /* Mobile layout for split card */
    .new-article-content.has-image {
        flex-direction: column; /* 图片在上,内容在下 */
        gap: 12px;
    }

    /* 移动端隐藏图片 */
    .new-article-content.has-image .new-article-image {
        display: none !important;
    }

    .new-article-content.has-image .new-article-text {
        width: 100%;
        order: 0; /* 内容在下方 */
    }

    /* 移动端调小summary字体 */
    .new-article-summary {
        font-size: 0.85rem; /* 从0.95rem调小到0.85rem */
    }
}

/* Timeline & Empty State */
.timeline-container {
    width: 100%;
    overflow-x: hidden;
    padding: 20px 0;
}

.timeline {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 48px;
}

.timeline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 5%;
    right: 5%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(148, 163, 184, 0.4) 12%, rgba(148, 163, 184, 0.55) 50%, rgba(148, 163, 184, 0.4) 88%, transparent 100%);
}

.time-point {
    position: relative;
    z-index: 1;
    padding: 4px 28px;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--color-bg);
    border-radius: 999px;
    box-shadow: 0 2px 10px var(--color-shadow);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    animation: fadeIn 0.3s ease;
}

.empty-illustration img {
    width: 200px;
    opacity: 0.8;
}

.empty-text {
    font-size: 16px;
    font-weight: 500;
    margin-top: 20px;
}


/* =========================================
   DASHBOARD NEW BOARDS STYLES
   ========================================= */

.dashboard-section {
    width: 100%;
    margin-bottom: 2rem;
    padding: 0 1rem;
    box-sizing: border-box;
}

.section-header {
    margin-bottom: 1rem;
    padding-left: 0.5rem;
}

.section-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header h3::before {
    content: '';
    display: block;
    width: 4px;
    height: 1.2em;
    background: var(--accent-color);
    border-radius: 2px;
}

.history-header-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.history-tabs {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: 20px;
}

.history-tab {
    border: none;
    background: transparent;
    padding: 6px 16px;
    border-radius: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-tab.active {
    background: var(--card-bg);
    color: var(--color-text);
    box-shadow: 0 2px 4px var(--color-shadow);
}

:root[data-theme="dark"] .history-tabs {
    background: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   LETTERS BOARD - ADAPTIVE DESIGN
   ========================================================================== */

/* --- Common Scene Container --- */
.letters-scene {
    width: 100%;
    display: flex;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

/* --- Desktop Styles (3D Desk Scene) --- */
@media (min-width: 769px) {
    .letters-scene {
        perspective: 1000px;
        padding: 40px 10px;
    }

    .desk-container {
        position: relative;
        width: 100%;
        max-width: 1000px;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .letters-stack {
        position: relative;
        width: 100%;
        max-width: 600px;
        display: grid;
        grid-template-areas: "stack";
        z-index: 10;
    }

    .desk-decor {
        position: absolute;
        z-index: 5;
        pointer-events: none;
    }

    .left-decor { left: 0; top: 50%; transform: translateY(-50%) rotate(-5deg); }
    .right-decor { right: 20px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 20px; }

    /* Props Styling */
    .polaroid { background: white; padding: 12px 12px 30px 12px; box-shadow: 0 4px 10px rgba(0,0,0,0.15); transform: scale(0.9); transition: 0.3s; }
    .polaroid-img-wrapper { width: 140px; height: 140px; background: #eee; overflow: hidden; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; }
    .polaroid-img-wrapper img { width: 100%; height: 100%; object-fit: cover; }
    .polaroid-caption { font-family: var(--font-family-primary); text-align: center; color: #444; font-size: 1.1rem; }

    .pen-container { position: relative; width: 12px; height: 180px; transform: rotate(15deg); }
    .pen-body { position: absolute; top: 0; width: 100%; height: 85%; background: linear-gradient(to right, #444, #222, #444); border-radius: 2px; }
    .pen-cap { position: absolute; top: -10px; left: -2px; width: 16px; height: 40px; background: linear-gradient(to right, #666, #333, #666); border-radius: 2px; }
    .pen-tip { position: absolute; bottom: 0; left: 2px; width: 8px; height: 15%; background: #ddd; clip-path: polygon(0 0, 100% 0, 50% 100%); }
    .sticky-note { background: #fef08a; padding: 15px; width: 100px; font-family: var(--font-family-primary); color: #444; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); transform: rotate(3deg); font-size: 0.9rem; text-align: center; }

    /* Hide Mobile-only elements */
    .envelope-stack, .mobile-envelope-stage, .letter-modal { display: none !important; }

    /* Re-use original Letter Card styling for desktop 3D flip */
    .letter-card {
        grid-area: stack;
        background-color: #fcfcfc;
        background-image: linear-gradient(#f1f1f1 1px, transparent 1px), linear-gradient(90deg, #f1f1f1 1px, transparent 1px);
        background-size: 20px 20px;
        padding: 2.5rem;
        border-radius: 4px;
        box-shadow: 0 8px 16px rgba(0,0,0,0.05);
        font-family: var(--font-family-primary);
        border: 1px solid #e2e8f0;
        transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
        cursor: pointer;
        backface-visibility: hidden;
    }
    
    .letter-front { z-index: 2; transform: rotate(-1deg); }
    .letter-back { z-index: 1; transform: rotate(2deg) translateY(12px) scale(0.96); opacity: 0.9; }

    .letters-stack.flipped .letter-front { z-index: 1; transform: rotate(-2deg) translateY(12px) scale(0.96); opacity: 0.9; }
    .letters-stack.flipped .letter-back { z-index: 2; transform: rotate(1deg) scale(1); opacity: 1; }
}

/* --- Mobile Styles (Realistic Envelope with Pattern) --- */
@media (max-width: 768px) {
    .letters-scene { padding: 40px 10px; overflow: hidden; }
    .desk-container { width: 100%; max-width: 400px; padding: 0; }
    .desk-decor { display: none; }
    .letters-stack { display: none; } /* Hide 3D cards on mobile */

    /* The Stage */
    .mobile-envelope-stage {
        position: relative;
        width: 100%;
        height: 240px; 
        display: flex;
        justify-content: center;
        align-items: flex-end;
        margin-top: 10px;
    }

    .logo {
        width: 180px;
    }

    .mobile-envelope {
        position: relative;
        width: 100%;
        height: 100%;
    }

    /* Shared Pattern for Envelope Parts */
    .envelope-pattern-bg {
        background-color: #dbe4ef; /* Grayish Blue Base */
        background-image: 
            radial-gradient(circle, #ffffff 3px, transparent 3.5px),
            radial-gradient(circle, #94a3b8 3px, transparent 3.5px),
            radial-gradient(circle, #60a5fa 3px, transparent 3.5px);
        background-size: 40px 40px;
        background-position: 
            0 0,            /* White dot */
            13px 20px,      /* Gray dot staggered */
            26px 7px;       /* Blue dot staggered */
    }

    /* Back Flap (The inside back of the envelope - DARKER) */
    .envelope-back-flap {
        position: absolute;
        bottom: 0;
        left: 5%;
        width: 90%;
        height: 160px;
        background-color: #a9bbce; /* Darker Grayish Blue for inside */
        background-image: 
            radial-gradient(circle, rgba(255,255,255,0.4) 3px, transparent 3.5px),
            radial-gradient(circle, rgba(0,0,0,0.1) 3px, transparent 3.5px),
            radial-gradient(circle, rgba(96,165,250,0.4) 3px, transparent 3.5px);
        background-size: 40px 40px;
        background-position: 0 0, 13px 20px, 26px 7px;
        
        border-radius: 4px;
        z-index: 1;
        box-shadow: inset 0 10px 20px rgba(0,0,0,0.15); /* Stronger inner shadow */
        border: 1px solid #94a3b8;
    }

    /* Open Top Flap (The inner side of the open flap - DARKER) */
    .envelope-back-flap::before {
        content: '';
        position: absolute;
        top: -60px;
        left: -1px;
        width: calc(100% + 2px);
        height: 60px;
        
        background-color: #a9bbce; /* Matches inside */
        background-image: 
            radial-gradient(circle, rgba(255,255,255,0.4) 3px, transparent 3.5px),
            radial-gradient(circle, rgba(0,0,0,0.1) 3px, transparent 3.5px),
            radial-gradient(circle, rgba(96,165,250,0.4) 3px, transparent 3.5px);
        background-size: 40px 40px;
        background-position: 0 0, 13px 20px, 26px 7px;
        
        clip-path: polygon(0 100%, 50% 0, 100% 100%);
        filter: drop-shadow(0 -2px 3px rgba(0,0,0,0.1));
        z-index: 1;
    }

    /* The Letter Cards (Enhanced with Grid) */
    .mobile-letter-card {
        position: absolute;
        bottom: 20px;
        width: 75%;
        height: 180px;
        left: 50%;
        background-color: #fcfcfc;
        background-image: 
            linear-gradient(#f1f1f1 1px, transparent 1px),
            linear-gradient(90deg, #f1f1f1 1px, transparent 1px);
        background-size: 20px 20px;
        background-position: -2px -2px;
        
        border: 1px solid #cbd5e1;
        border-radius: 4px;
        padding: 12px 15px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
        transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
        cursor: pointer;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        transform-origin: bottom center;
    }

    /* SKEWED STATES */
    .letter-pos-front {
        z-index: 4;
        transform: translate(-50%, -40px) rotate(-3deg) scale(1);
        filter: brightness(1);
    }

    .letter-pos-middle {
        z-index: 3;
        transform: translate(calc(-50% + 6px), -25px) rotate(2deg) scale(0.97);
        filter: brightness(0.96);
    }

    .letter-pos-back {
        z-index: 2;
        transform: translate(calc(-50% + 14px), -5px) rotate(5deg) scale(0.93);
        filter: brightness(0.9); 
    }

    .mobile-letter-pwa {
        border-color: #eab308;
    }

    .mobile-letter-pwa .mob-letter-title {
        color: #b45309;
    }

    .mobile-letter-pwa-highlight {
        animation: pwaPulse 2.2s ease-in-out infinite;
        box-shadow: 0 18px 36px rgba(250, 204, 21, 0.35);
    }

    @keyframes pwaPulse {
        0% { box-shadow: 0 12px 26px rgba(250, 204, 21, 0.18); transform: translate(-50%, -42px) scale(1); }
        50% { box-shadow: 0 24px 44px rgba(250, 204, 21, 0.45); transform: translate(-50%, -48px) scale(1.03); }
        100% { box-shadow: 0 12px 26px rgba(250, 204, 21, 0.18); transform: translate(-50%, -42px) scale(1); }
    }

    /* Letter Content */
    .mob-letter-header { margin-bottom: 8px; width: 100%; }
    
    .mob-letter-title {
        display: block;
        font-family: var(--font-family-primary);
        font-size: 1.3rem;
        color: #1e293b !important;
        font-weight: 700;
        line-height: 1.4;
        text-align: left;
    }

    .mob-letter-content-preview {
        font-family: var(--font-family-primary);
        font-size: 1.05rem;
        color: #475569 !important;
        text-align: left;
        line-height: 1.4;
        width: 100%;
    }

    .highlight-preview {
        background: linear-gradient(120deg, rgba(255, 235, 59, 0.4) 0%, rgba(255, 235, 59, 0.1) 100%);
        padding: 0 2px;
        border-radius: 2px;
        color: #0f172a !important;
    }

    /* The Front Pocket (The outside face - LIGHTER) */
    .envelope-front-pocket {
        position: absolute;
        bottom: 0;
        left: 5%;
        width: 90%;
        height: 110px;
        z-index: 10;
        pointer-events: none;
        
        background-color: #dbe4ef; /* Lighter base */
        background-image: 
            radial-gradient(circle, #ffffff 3px, transparent 3.5px),
            radial-gradient(circle, #94a3b8 3px, transparent 3.5px),
            radial-gradient(circle, #60a5fa 3px, transparent 3.5px);
        background-size: 40px 40px;
        background-position: 0 0, 13px 20px, 26px 7px;
        
        clip-path: polygon(0 0, 50% 30%, 100% 0, 100% 100%, 0 100%);
        box-shadow: inset 0 0 0 1000px rgba(255,255,255,0.05);
        filter: drop-shadow(0 -4px 8px rgba(0,0,0,0.15));
    }

    /* "From L-feed" Label */
    .envelope-front-pocket::after {
        content: 'From L-feed';
        position: absolute;
        bottom: 5px;
        left: 5px;
        font-family: var(--font-family-primary);
        font-size: 0.9rem;
        color: #64748b;
        opacity: 0.8;
        pointer-events: none;
    }

    /* Switch Button */
    .envelope-switch-btn {
        position: absolute;
        bottom: 30px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 20;
        pointer-events: auto;
        
        background: white;
        color: #475569;
        border: 1px solid #cbd5e1;
        padding: 6px 16px;
        border-radius: 20px;
        font-size: 0.85rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 6px;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        cursor: pointer;
        transition: all 0.2s;
    }

    .envelope-switch-btn:active {
        transform: translateX(-50%) scale(0.95);
        background: #f1f5f9;
    }
    
    .envelope-switch-btn img {
        width: 18px;
        height: 18px;
        opacity: 1;
        filter: brightness(0.2); 
    }

    /* Modal Styles (Mobile) */
    .letter-modal {
        position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
        background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
        z-index: 9999; display: flex; justify-content: center; align-items: flex-end;
        opacity: 0; visibility: hidden; transition: 0.3s;
    }
    .letter-modal.active { opacity: 1; visibility: visible; }
    .letter-modal-content {
        width: 100%; height: 85vh; background: #fffdfa;
        border-top-left-radius: 20px; border-top-right-radius: 20px;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.3); display: flex; flex-direction: column;
        transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        background-image: 
            linear-gradient(#f1f1f1 1px, transparent 1px),
            linear-gradient(90deg, #f1f1f1 1px, transparent 1px);
        background-size: 20px 20px;
    }
    .letter-modal.active .letter-modal-content { transform: translateY(0); }

    .modal-header { padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px dashed #cbd5e1; }
    .modal-header h2 { margin: 0; font-size: 1.1rem; color: #334155; font-family: var(--font-family-primary); }
    .close-btn { background: rgba(0,0,0,0.05); width: 32px; height: 32px; border-radius: 50%; border: none; font-size: 1.2rem; color: #64748b; }
    .modal-scroll-area { flex: 1; overflow-y: auto; padding: 24px; overscroll-behavior: contain; font-family: var(--font-family-primary); }
}

/* Inline Switch Button (Global) */
.letter-switch-wrapper {
    display: flex; justify-content: flex-end; margin-top: 30px; opacity: 0.7; transition: opacity 0.3s;
}
.letter-switch-wrapper:hover { opacity: 1; }
.inline-switch-btn {
    display: flex; align-items: center; gap: 6px;
    background: none; border: none; padding: 5px;
    color: #64748b; font-family: var(--font-family-primary); font-size: 0.95rem; cursor: pointer;
}
.inline-switch-btn img { width: 16px; height: 16px; opacity: 0.6; }

/* --- Shared Letter Typography (Used in Desktop cards and Mobile modal) --- */
.modal-body-content .highlight, .letter-body .highlight {
    background: linear-gradient(120deg, rgba(255, 235, 59, 0.6) 0%, rgba(255, 235, 59, 0.2) 100%);
    padding: 0 4px; border-radius: 4px; font-weight: 700;
}
.letter-header { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; color: #2d3748; font-family: var(--font-family-primary); }
.letter-body p, .modal-body-content p { font-size: 1.2rem; line-height: 1.6; margin-bottom: 1.2rem; }
.letter-encouragement { font-style: italic; color: #4a5568; border-left: 3px solid var(--accent-color); padding-left: 1rem; margin-top: 1.5rem; }
.letter-footer { margin-top: 2rem; display: flex; justify-content: space-between; align-items: flex-end; }
.letter-sign { font-size: 1rem; line-height: 1.4; }
.letter-date { font-size: 0.85rem; color: #a0aec0; font-family: monospace; }

/* Dark Theme Adjustments */
:root[data-theme="dark"] .letter-card, :root[data-theme="dark"] .envelope-card, :root[data-theme="dark"] .letter-modal-content {
    background-color: #1e293b; color: #cbd5e1; border-color: #334155;
}
:root[data-theme="dark"] .letter-header, :root[data-theme="dark"] .envelope-info h3 { color: #f1f5f9; }
:root[data-theme="dark"] .letter-modal { background: rgba(0,0,0,0.7); }
:root[data-theme="dark"] .modal-header { border-color: #334155; background-color: #1e293b; }
:root[data-theme="dark"] .inline-switch-btn { color: #94a3b8; }
:root[data-theme="dark"] .inline-switch-btn img { filter: invert(1); opacity: 0.5; }
:root[data-theme="dark"] .close-btn { background: #334155; color: #cbd5e1; }


/* Desktop Defaults */
@media (min-width: 769px) {
    .letter-page-1, .letter-page-2 {
        display: block !important;
    }
    .next-page-btn, .letter-indicator, .mobile-next-hint {
        display: none;
    }
}

/* --- Letters Styling (Shared) --- */

/* --- Letters Styling (Shared) --- */

.letter-card {
    grid-area: stack;
    background-color: #fcfcfc;
    background-image:
        linear-gradient(#f1f1f1 1px, transparent 1px),
        linear-gradient(90deg, #f1f1f1 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -2px -2px;

    width: 100%;
    padding: 2.5rem;
    border-radius: 4px;
    box-shadow:
        0 1px 1px rgba(0,0,0,0.1),
        0 8px 16px rgba(0,0,0,0.05);
    font-family: var(--font-family-primary);
    color: #4a5568;
    border: 1px solid #e2e8f0;

    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
    cursor: pointer;
    box-sizing: border-box;
    backface-visibility: hidden;
    transform-origin: center bottom;
}

/* State: Default (Front Card is Letter 1, Back Card is Letter 2) */

/* Default State */
.letter-front {
    z-index: 2;
    transform: rotate(-1deg) translateY(0) scale(1);
}

.letter-back {
    z-index: 1;
    transform: rotate(2deg) translateY(12px) scale(0.96);
    opacity: 0.9;
    filter: brightness(0.95);
}

/* Flipped State */
.letters-stack.flipped .letter-front {
    z-index: 1;
    transform: rotate(-2deg) translateY(12px) scale(0.96);
    opacity: 0.9;
    filter: brightness(0.95);
}

.letters-stack.flipped .letter-back {
    z-index: 2;
    transform: rotate(1deg) translateY(0) scale(1);
    opacity: 1;
    filter: brightness(1);
}

/* Hover effects (only on the top card ideally, or both) */
.letters-stack:not(.flipped) .letter-front:hover {
    transform: rotate(0deg) scale(1.01);
}
.letters-stack.flipped .letter-back:hover {
    transform: rotate(0deg) scale(1.01);
}

/* Inner Letter Styling */
.letter-header {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: #2d3748;
}

.letter-body p {
    font-size: 1.15rem;
    line-height: 1.8;
    margin-bottom: 1.25rem;
}

.highlight {
    background: linear-gradient(120deg, rgba(255, 235, 59, 0.6) 0%, rgba(255, 235, 59, 0.2) 100%);
    padding: 0 4px;
    border-radius: 4px;
    font-weight: 700;
    color: #1a202c;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    display: inline-block;
    transform: rotate(-1deg);
    margin: 0 2px;
}

.letter-encouragement {
    font-style: italic;
    color: #4a5568;
    border-left: 3px solid var(--accent-color);
    padding-left: 1rem;
    margin-top: 2rem;
}

.letter-footer {
    margin-top: 3rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.letter-sign {
    font-size: 1.1rem;
}

.letter-date {
    font-size: 0.9rem;
    color: #a0aec0;
    font-family: monospace;
}

.letter-hint {
    position: absolute;
    bottom: 1rem;
    right: 50%;
    transform: translateX(50%);
    font-size: 0.8rem;
    color: #cbd5e1;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.letter-card:hover .letter-hint {
    opacity: 1;
}


/* Letter 2 Specifics (Word Lists & Button) */
.word-list-section {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.list-label {
    font-size: 1rem;
    color: #718096;
    margin-bottom: 0.5rem !important;
    font-weight: 600;
}

.mini-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.mini-tags span {
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.95rem;
    border: 1px dashed #cbd5e1;
}

.new-tags span {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--accent-color);
}

.action-area {
    margin-top: 2rem;
    text-align: center;
    border-top: 2px dashed #e2e8f0;
    padding-top: 1.5rem;
}

.action-area p {
    margin-bottom: 1rem;
    font-weight: 600;
}

.letter-btn {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    padding: 10px 24px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-family: -apple-system, sans-serif; /* Reset font for button */
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.letter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4);
}

.letter-secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 20px;
    border-radius: 20px;
    border: 1px dashed rgba(148, 163, 184, 0.8);
    background: transparent;
    color: var(--color-text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.letter-secondary-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.pwa-letter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 1.5rem;
}

.pwa-guide {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 12px;
    border: 1px dashed rgba(59, 130, 246, 0.4);
    background: rgba(59, 130, 246, 0.08);
}

.pwa-guide ol {
    margin: 0;
    padding-left: 1.2rem;
    color: #1e293b;
    font-weight: 600;
}

.pwa-guide-image {
    margin-top: 1rem;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.4);
    cursor: pointer;
    text-align: center;
}

.pwa-guide-image img {
    width: 100%;
    display: block;
}

.pwa-guide-image span {
    display: block;
    padding: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Dark Theme Adjustments for Letter */
:root[data-theme="dark"] .letter-card,
:root[data-theme="dark"] .letter-modal-content,
:root[data-theme="dark"] .mobile-letter-card {
    background-color: #1e293b;
    background-image: 
        linear-gradient(#334155 1px, transparent 1px),
        linear-gradient(90deg, #334155 1px, transparent 1px);
    border-color: #334155;
    color: #cbd5e1;
}

:root[data-theme="dark"] .letter-header {
    color: #f1f5f9;
}

:root[data-theme="dark"] .letter-body .highlight {
    background: linear-gradient(120deg, rgba(250, 204, 21, 0.4) 0%, rgba(250, 204, 21, 0.1) 100%);
    color: #f8fafc;
}

:root[data-theme="dark"] .letter-encouragement {
    color: #94a3b8;
}

:root[data-theme="dark"] .mini-tags span {
    background: rgba(255,255,255,0.05);
    border-color: #475569;
}

:root[data-theme="dark"] .letter-secondary-btn {
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.6);
}

:root[data-theme="dark"] .letter-secondary-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

:root[data-theme="dark"] .pwa-guide {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(96, 165, 250, 0.4);
}

:root[data-theme="dark"] .pwa-guide ol {
    color: #e2e8f0;
}

:root[data-theme="dark"] .pwa-guide-image {
    border-color: rgba(148, 163, 184, 0.3);
}

/* Dark Theme Adjustments for Desk Props */
:root[data-theme="dark"] .polaroid {
    background: #1e293b;
    color: #cbd5e1;
}
:root[data-theme="dark"] .polaroid-img-wrapper {
    background: #0f172a;
}
:root[data-theme="dark"] .polaroid-caption {
    color: #94a3b8;
}
:root[data-theme="dark"] .sticky-note {
    background: #ca8a04;
    color: #fef08a;
}
:root[data-theme="dark"] .sticky-note span {
    color: #fff;
}


/* ==========================================================================
   HISTORY BOARD (Horizontal Scroll)
   ========================================================================== */
.history-scroll-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.scroll-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px var(--color-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    padding: 0;
    opacity: 0.8;
}

.scroll-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.scroll-btn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 12px var(--color-shadow-hard);
    opacity: 1;
    background: var(--color-bg);
}

.scroll-btn img {
    width: 20px;
    height: 20px;
    filter: brightness(0.5);
}

:root[data-theme="dark"] .scroll-btn img {
    filter: invert(1);
}

.left-btn { left: -20px; }
.right-btn { right: -20px; }

@media (max-width: 768px) {
    .scroll-btn { display: none; }
    .history-scroll-wrapper { margin: 0 -1rem; padding: 0 1rem; }

    /* 移动端增加卡片整体高度 */
    .history-card {
        height: 240px !important; /* 从 200px 增加到 240px */
    }

    /* 确保 card-title 有足够高度显示两行文字 */
    .history-card .card-title {
        min-height: 2.8rem; /* 1.4 line-height × 2 lines = 2.8rem */
        line-height: 1.4;
    }
}

.horizontal-scroll-container {
    display: flex;
    overflow-x: auto;
    gap: 16px;
    padding: 10px 4px 20px 4px; /* Bottom padding for shadow */
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    width: 100%;
}

.horizontal-scroll-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.history-card {
    flex: 0 0 280px;
    height: 200px;
    background: var(--card-bg);
    border-radius: 14px;
    scroll-snap-align: start;
    padding: 1.25rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.history-card:hover {
    transform: translateY(-4px);
}

.history-card .card-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--color-text);
}

.history-card .card-summary {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.history-card .card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: auto;
}

.history-card .card-meta-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-card .time-label {
    color: var(--accent-color);
    font-weight: 600;
}

.card-last-read {
    font-size: 0.8rem;
    color: var(--accent-color);
    margin-top: auto;
    margin-bottom: 8px;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-card .tag-badge {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
}

.view-more-card {
    align-items: center;
    justify-content: center;
    background: var(--accent-color);
    color: white !important;
    text-align: center;
    cursor: pointer;
}

.view-more-card .card-title {
    color: white;
    font-size: 1.2rem;
    margin-bottom: 0;
}

.view-more-card:hover {
    filter: brightness(1.1);
}

/* Custom View More Card Backgrounds */
.view-more-card[data-type="novel"],
.view-more-card[data-type="drama"] {
    background-repeat: no-repeat;
    background-position: right bottom;
    background-size: auto 110%; /* Slightly larger to look good */
    align-items: flex-start; /* Align text to left */
    padding-left: 24px; /* Add spacing */
    text-align: left;
}

.view-more-card[data-type="novel"] {
    background-image: url('/assets/Qiang_half-C0mgOiPh.png');
}

.view-more-card[data-type="drama"] {
    background-image: url('/assets/Luna_half-4ZWhDyUm.png');
}


.discovery-header {
    margin-top: 2rem;
    padding: 0 1rem;
}

.discovery-header h3 {
    margin-left: 0.5rem;
}

/* =========================================
   NEW SIMPLIFIED ARTICLE CARD DESIGN
   ========================================= */

.new-article-card {
    /* background: var(--card-bg); */
    /* border-radius: 16px; */
    padding: 0px 24px 20px 24px;
    /* box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* First card should have no top padding */
.articles-grid > .new-article-card:first-child {
    padding-top: 0;

    /* border: 1px solid var(--border-color); */
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    /* Override previous article-card centering if any */
    align-items: stretch;
    cursor: default; /* 整个卡片默认不显示手型指针 */
    pointer-events: none; /* 整个卡片默认禁用点击 */
}



.new-article-card:hover {
    /* transform: translateY(-4px); */
    /* box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); */
}

/* Novel Card Adjustments */
.novel-card {
    border-left: 4px solid #d97706; /* Amber border for books */
    background: linear-gradient(to right, rgba(255, 251, 235, 0.5), var(--card-bg));
}

.novel-recommendation {
    font-size: 0.85rem;
    font-weight: 700;
    color: #d97706;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    display: inline-block;
    position: relative;
    font-family: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
}

/* Dark theme adjustments */
:root[data-theme="dark"] .novel-card {
    border-left-color: #fbbf24;
    background: linear-gradient(to right, rgba(251, 191, 36, 0.1), var(--card-bg));
}

:root[data-theme="dark"] .novel-recommendation {
    color: #fbbf24;
}

.new-article-content {
    width: 100%;
    position: relative;
    /* padding-top: 24px;  */
    pointer-events: none; /* 默认禁用所有点击 */
    cursor: default; /* 确保不显示手型指针 */
}

.new-article-content .new-article-title {
    pointer-events: auto !important; /* 只有标题可以点击 */
}

/* Re-enable clicks for drama scenes */
.new-article-content .drama-scenes-list {
    pointer-events: auto;
}

.new-article-content .drama-scene-item {
    pointer-events: auto;
}

/* Split layout when there's an image */
.new-article-content.has-image {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.new-article-content.has-image .new-article-text {
    flex: 1;
    min-width: 0; /* Allow text to shrink properly */
}

.new-article-content.has-image .new-article-image {
    flex: 0 0 140px;
    width: 140px;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    box-shadow: 0 2px 8px var(--color-shadow);
    margin-top: 32px; /* 向下移动,与标题对齐 */
    pointer-events: none; /* 禁用图片的点击 */
    cursor: default; /* 图片不显示手型指针 */
}

/* Desktop: Show image */
@media (min-width: 769px) {
    .new-article-content.has-image .new-article-image {
        display: flex !important;
    }
}

.new-article-content.has-image .new-article-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Regular layout (no image) */
.new-article-content:not(.has-image) {
    display: block;
}

/* Tag positioned at top-left - using relative position for proper spacing */
.new-article-text > .new-article-tag:first-child,
.new-article-text > .new-article-tag:nth-child(2) {
    position: relative;
    top: auto;
    left: auto;
    margin-bottom: 8px; /* Add spacing between tag and title */
    pointer-events: none; /* 禁用顶部标签的点击 */
    cursor: default; /* 顶部标签不显示手型指针 */
}

/* When in split layout, tags should be relative to text container */
.new-article-content.has-image .new-article-text > .new-article-tag:first-child,
.new-article-content.has-image .new-article-text > .new-article-tag:nth-child(2) {
    position: relative;
    top: auto;
    left: auto;
    pointer-events: none; /* 分栏布局时也禁用顶部标签的点击 */
    cursor: default;
}

/* Second tag styling - now inline with first tag */
.new-article-text > .new-article-tag:nth-child(2) {
    margin-left: 8px; /* Add spacing between two top tags */
    pointer-events: none; /* 第二个标签也禁用点击 */
    cursor: default;
}

.new-article-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 6px 0 12px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    pointer-events: auto;
}

.new-article-title {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: transparent;
    text-decoration-thickness: 2px;
    -webkit-text-decoration: underline;
    -webkit-text-decoration-style: dashed;
    -webkit-text-decoration-color: transparent;
    -webkit-text-decoration-thickness: 2px;
    text-underline-offset: 5px;
    -webkit-text-underline-offset: 5px;
    transition: text-decoration-color 0.2s ease;
}

.new-article-title:hover {
    text-decoration-color: var(--color-text);
    -webkit-text-decoration-color: var(--color-text);
}

.new-article-summary {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.new-article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    font-size: 0.75rem; /* Smaller font for bottom meta */
    color: var(--text-muted);
    pointer-events: none; /* 禁用底部元数据的点击 */
}

.new-article-tag {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-weight: 400;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: default; /* 标签不显示手型指针 */
    color: var(--text-muted);
    font-size: 0.85rem; /* Smaller than title (1.25rem) */
    pointer-events: none; /* 禁用标签的点击 */
}

/* Tags in meta area (bottom) should be smaller */
.new-article-meta .new-article-tag {
    font-size: 0.75rem;
}

.new-article-tag:hover {
    opacity: 0.8;
    transform: none; /* 移除上移效果 */
}

/* Tag Specific Colors - all muted */
.tag-1, .tag-2, .tag-8, .tag-16, .tag-novel {
    color: var(--text-muted);
    background-color: transparent;
}

.new-article-time {
    display: flex;
    align-items: center;
    font-size: 0.75rem; /* Smaller, simpler text */
    opacity: 0.7; /* More subtle */
}

.new-article-time::before {
    content: '⏱';
    margin-right: 4px;
    font-size: 0.9em;
}

.meta-separator {
    font-size: 0.75rem;
    opacity: 0.5;
    margin: 0 4px;
    user-select: none;
}

.new-article-fm {
    background: transparent;
    color: var(--text-muted);
    padding: 0;
    font-weight: 500;
    font-size: 0.75rem; /* Smaller, simpler text */
    opacity: 0.7; /* More subtle */
}

/* Dark Theme Adjustments for Meta */
:root[data-theme="dark"] .new-article-tag {
    background-color: transparent;
    color: var(--text-muted);
}

/* =========================================
   DRAMA SCENES LIST
   ========================================= */

.drama-scenes-list {
    margin-top: 16px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.drama-scene-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.02);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

.drama-scene-item:last-child {
    border-bottom: none;
}

.drama-scene-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateX(4px);
}

.drama-scene-item.latest-scene {
    background: rgba(219, 39, 119, 0.05);
    font-weight: 600;
}

.drama-scene-item.latest-scene:hover {
    background: rgba(219, 39, 119, 0.1);
}

.scene-label {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    white-space: nowrap;
}

.scene-episode {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
}

.scene-title {
    color: var(--color-text);
    font-size: 0.9rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Dark Theme Adjustments for Drama Scenes */
:root[data-theme="dark"] .drama-scenes-list {
    border-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .drama-scene-item {
    background: rgba(255, 255, 255, 0.03);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

:root[data-theme="dark"] .drama-scene-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .drama-scene-item.latest-scene {
    background: rgba(219, 39, 119, 0.15);
}

:root[data-theme="dark"] .drama-scene-item.latest-scene:hover {
    background: rgba(219, 39, 119, 0.25);
}

:root[data-theme="dark"] .scene-episode {
    color: #f472b6;
}

:root[data-theme="dark"] .scene-title {
    color: #e2e8f0;
}

/* =========================================
   MOBILE STICKER NAVIGATION (TRUE CONTOUR STYLE)
   ========================================= */

.mobile-nav-container {
    display: none; /* Hidden on desktop */
    width: 100%;
    justify-content: center; /* More spacing for organic shapes */
    align-items: center;
    padding: 20px 10px;
    margin-top: 10px;
    gap: 5px;
    box-sizing: border-box;
}

/* Sticker Button - The Contour Style */
.mobile-sticker-btn {
    /* 移除所有盒子背景，依靠滤镜生成轮廓 */
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 10px; /* 给滤镜的膨胀留出空间 */
    
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-width: 100px;
    position: relative;
    
    /* 核心：应用 SVG 滤镜生成描边 */
    filter: url(#sticker-outline);
    
    transform-origin: center center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* 解决Safari部分渲染问题 */
    -webkit-filter: url(#sticker-outline);
    will-change: transform;
}

.mobile-sticker-btn:hover, .mobile-sticker-btn:active {
    transform: scale(1.1) rotate(0deg) !important;
    z-index: 10;
}

.sticker-content {
    display: flex;
    flex-direction: row; /* 横向排列 */
    align-items: center;
    justify-content: center;
    gap: 4px; /* 图标和文字的间距 */
}

.sticker-content img {
    width: 44px; /* 稍微缩小图标以适应横向排列 */
    height: 44px;
    object-fit: contain;
    display: block;
}

.sticker-content span {
    font-family: 'Patrick Hand', cursive, sans-serif;
    font-size: 16px;
    color: #2d3748;
    font-weight: 800;
    margin-top: 0;
    white-space: nowrap;
}

/* Rotations for organic feel */
.rotate-left {
    transform: rotate(-4deg);
}

.rotate-right {
    transform: rotate(3deg);
}

/* 
   Dropdown Sticker 
   缩小整体尺寸和外边框感
*/
.sticker-dropdown {
    position: relative;
    /* flex: 0.8;  */
    z-index: 100;
}

.sticker-dropdown .dropdown-toggle {
    background: #fff !important;
    border: 2px solid #fff !important; /* 减薄白边 */
    border-radius: 12px !important;
    padding: 4px 8px !important; /* 显著减少内边距 */
    box-shadow: 
        0 2px 0px rgba(0,0,0,0.05),
        2px 4px 8px rgba(0,0,0,0.1) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #2d3748 !important;
    width: auto; /* 宽度自适应内容 */
    min-width: 60px;
    box-sizing: border-box;
    transform: rotate(1deg);
    height: 40px; /* 显著降低高度 */
    transition: all 0.2s;
}

.sticker-dropdown .dropdown-toggle:active {
    transform: scale(0.95);
}

.sticker-dropdown .dropdown-toggle span {
    font-family: 'Patrick Hand', cursive, sans-serif;
    font-weight: 700;
    font-size: 14px; /* 缩小字体 */
}

.sticker-dropdown .dropdown-toggle span:first-child {
    font-size: 11px;
    color: #718096;
    margin-right: 1px;
}

#mobile-level-selected-value {
    color: var(--accent-color);
    font-size: 16px !important; /* 缩小选中的等级字体 */
}

.sticker-dropdown .arrow {
    border-top: 4px solid #2d3748 !important; /* 缩小箭头 */
    border-left: 3px solid transparent !important;
    border-right: 3px solid transparent !important;
    margin-left: 2px;
}

.sticker-dropdown .dropdown-options {
    position: absolute;
    top: 110%;
    left: 50%;
    transform: translateX(-50%);
    width: 110px;
    background: #fff !important;
    /* 不规则边框模拟撕纸感 */
    border: 3px solid #fff !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15) !important;
    padding: 5px !important;
    display: none;
}

.sticker-dropdown.open .dropdown-options {
    display: flex;
    flex-direction: column;
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { opacity: 0; transform: translateX(-50%) scale(0.8); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
}

.sticker-dropdown .dropdown-option {
    font-family: 'Patrick Hand', cursive, sans-serif;
    font-size: 16px !important;
    color: #4a5568 !important;
    text-align: center !important;
    padding: 8px !important;
    border-bottom: 1px dashed #e2e8f0;
}

/* Dark Theme: 滤镜下的白边依然是白色的，这很好，因为贴纸通常有白边。
   但我们需要确保文字颜色在暗模式下也是深色的（因为底是白色的）？
   不对，我们的滤镜是把透明变白。如果文字是白色的，滤镜膨胀后也是白的，就看不清了。
   所以在暗模式下，文字必须设为深色，因为它们现在是在“白色贴纸底”上。
*/
:root[data-theme="dark"] .sticker-content span {
    color: #2d3748 !important; /* 强制深色文字，因为背景变成了白色膨胀区 */
}

/* 除非我们想做“夜光贴纸”，否则贴纸本身还是白底黑字比较真实 */
:root[data-theme="dark"] .sticker-dropdown .dropdown-toggle,
:root[data-theme="dark"] .sticker-dropdown .dropdown-options {
    background: #e2e8f0 !important; /* 稍微灰一点的白 */
    border-color: #e2e8f0 !important;
}
:root[data-theme="dark"] .sticker-dropdown .dropdown-toggle span, 
:root[data-theme="dark"] .sticker-dropdown .dropdown-option {
    color: #2d3748 !important;
}

/* Media Query Updates */
@media (max-width: 768px) {
    /* .menu { display: none !important; }
    .mobile-nav-container { display: flex; } */
    #nav1 { padding: 20px 10px 5px 10px; }
    .logo { transform: rotate(-3deg) scale(0.9); }
    .slogan { margin-top: 5px; margin-bottom: 10px; }
        .bg-gradient {
        height: 250px;
    }
    .bg-wave {
        height: 250px;
    }

    .new-article-card{
        padding: 0px 24px 18px 24px;
    }

    /* 移动端缩小 tabs */
    .history-tabs {
        padding: 3px;
        border-radius: 16px;
        gap: 6px;
    }

    .history-tab {
        padding: 6px 12px;
        font-size: 0.8rem;
        border-radius: 12px;
    }

}
