/* styles.css */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Tokens - Default Cool Tone Theme */
    --background: #f0f4f8;      /* Clean cool slate-white background */
    --foreground: #1e293b;      /* Cool slate deep gray text */
    --border: #cbd5e1;          /* Cool gray border */
    --primary: #0284c7;         /* Refreshing Ocean Blue */
    --primary-hover: #0369a1;
    --primary-foreground: #ffffff;
    --accent: #0d9488;          /* Cool Teal/Jade accent */
    --muted: #64748b;           /* Slate gray */
    --muted-light: #e2e8f0;     /* Cool light gray panel background */
    
    /* Tab Active States - Cyan to Blue Gradient */
    --tab-active-bg: linear-gradient(135deg, #0284c7, #6366f1);
    --tab-active-color: #ffffff;
    --tab-active-shadow: 0 4px 12px rgba(2, 132, 199, 0.35);
    
    /* Layout Tokens */
    --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-zh: 'STKaiti', 'Kaiti SC', '楷体', 'Microsoft YaHei', serif;
    --reader-text-size: 1.50rem;
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    color-scheme: light;
}

/* Warm / Sepia Theme override - Cool Lavender Sepia Mode */
[data-theme="warm"] {
    --background: #faf9fb;      /* Cool dusty lavender-white */
    --foreground: #2e2530;      /* Deep indigo-plum */
    --border: #e8e4ec;          /* Soft lavender border */
    --primary: #6366f1;         /* Cool Indigo */
    --primary-hover: #4f46e5;
    --muted-light: #f0eef4;     /* Soft lavender panel background */
    --muted: #5c4f62;
    
    /* Indigo to Purple Gradient */
    --tab-active-bg: linear-gradient(135deg, #6366f1, #a855f7);
    --tab-active-color: #ffffff;
    --tab-active-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* Dark Theme override - Abyssal Blue & Cyber Mint Mode */
[data-theme="dark"] {
    --background: #090d16;      /* Deep icy blue-black */
    --foreground: #f1f5f9;      /* Cool slate white text */
    --border: #1e293b;          /* Dark blue-gray border */
    --primary: #2dd4bf;         /* Glowing cool Mint/Teal */
    --primary-hover: #14b8a6;
    --muted-light: #1e293b;     /* Dark panel background */
    --muted: #94a3b8;           /* Cool gray */
    
    /* Teal to Mint Gradient */
    --tab-active-bg: linear-gradient(135deg, #0d9488, #2dd4bf);
    --tab-active-color: #090d16;
    --tab-active-shadow: 0 4px 12px rgba(45, 212, 191, 0.35);
    
    color-scheme: dark;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
    overflow-x: hidden;
    min-height: 100vh;
}

/* Desktop Watermarks (Faded Chinese characters floating in margins) */
.desktop-wm {
    position: fixed;
    color: var(--foreground);
    opacity: 0.035;
    font-family: var(--font-zh);
    font-weight: 800;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    transition: opacity 0.5s ease;
}

@media (max-width: 1200px) {
    .desktop-wm {
        display: none;
    }
}

/* Page Outer Layout Wrapper */
.desktop-surround {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
}

/* Centered content column */
.main-container {
    width: 100%;
    max-width: 800px;
    min-height: 100vh;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    background-color: var(--background);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.02);
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background-color: rgba(253, 251, 247, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.5rem;
    transition: var(--transition-smooth);
}

[data-theme="warm"] header {
    background-color: rgba(250, 249, 251, 0.95);
}

[data-theme="dark"] header {
    background-color: rgba(9, 13, 22, 0.95);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--primary);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    min-height: 3rem;
}

.brand svg {
    fill: var(--primary);
    transition: var(--transition-smooth);
}

.brand-text {
    font-family: var(--font-sans);
}

/* Navigation Links */
nav {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 550;
    color: var(--muted);
    text-decoration: none;
    transition: var(--transition-smooth);
}

.nav-link:hover {
    color: var(--foreground);
    background-color: var(--muted-light);
}

.nav-link.active {
    color: var(--foreground);
    background-color: var(--muted-light);
}

.nav-link svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.25;
}

/* Header Action Controls */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--muted);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.icon-btn:hover {
    color: var(--foreground);
    background-color: var(--muted-light);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--primary-foreground);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    margin-left: 0.5rem;
    cursor: pointer;
    user-select: none;
}

/* Main Reader Shell */
.reader-main {
    flex: 1;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
}

/* Chapter / Level Header strip */
.reader-header-strip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: var(--muted);
    margin-bottom: 2rem;
    border-bottom: 1px dashed var(--border);
    padding-bottom: 0.75rem;
}

.level-badge {
    background-color: var(--primary);
    color: var(--primary-foreground);
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.chapter-title-dropdown {
    font-family: var(--font-zh);
    font-weight: 600;
    color: var(--foreground);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chapter-title-dropdown:hover {
    color: var(--primary);
}

.chapter-title-dropdown svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

.rate-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: var(--transition-smooth);
}

.rate-btn:hover {
    border-color: var(--muted);
    color: var(--foreground);
}

/* Article & Typography Style */
article {
    line-height: 2.2;
    font-size: var(--reader-text-size);
    font-family: var(--font-zh);
    flex: 1;
}

article p {
    margin-bottom: 1.8rem;
    text-align: left;
}

/* Word (pw - pinyin word) wrapper */
.pw {
    display: inline-flex;
    align-items: center;
    vertical-align: bottom;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s ease;
}

.pw:hover {
    background-color: var(--muted-light);
}

/* Ruby Character Styling (Native Browser Alignment) */
ruby {
    font-size: inherit;
}

rt {
    font-family: var(--font-sans);
    font-size: 0.48em;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.05em;
    user-select: none;
    text-transform: lowercase;
    opacity: 0.5;
    transition: var(--transition-smooth);
}

rt::before {
    content: "/";
    opacity: 0.7;
}

rt::after {
    content: "/";
    opacity: 0.7;
}

/* Interactive Audio Highlight style */
.audio-highlight {
    background-color: rgba(255, 179, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 0 4px rgba(255, 179, 0, 0.2);
}

[data-theme="dark"] .audio-highlight {
    background-color: rgba(255, 179, 0, 0.25);
}

/* Tone Colors (Optional feature toggle) */
[data-tones="true"] [data-tone="1"] { color: #1e3a8a; } /* Blue tone */
[data-tones="true"] [data-tone="2"] { color: #047857; } /* Green tone */
[data-tones="true"] [data-tone="3"] { color: #7c2d12; } /* Orange tone */
[data-tones="true"] [data-tone="4"] { color: #b91c1c; } /* Red tone */
[data-tones="true"] [data-tone="5"] { color: var(--foreground); } /* Neutral tone */

/* Pinyin display rules (optimizes character kerning when hidden) */
[data-pinyin="hover"] rt {
    display: none;
}

[data-pinyin="hover"] .pw:hover rt {
    display: ruby-text;
}

[data-pinyin="off"] rt {
    display: none;
}

/* Reader Page Navigation (Prev/Next buttons) */
.page-controls-docked {
    border-top: 1px solid var(--border);
    padding: 1rem 0;
    display: grid;
    grid-template-cols: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    margin-top: auto;
    background-color: var(--background);
    z-index: 40;
}

.page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 36px;
    border: 1px solid var(--border);
    background-color: var(--background);
    color: var(--foreground);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.page-btn:hover:not(:disabled) {
    background-color: var(--muted-light);
    border-color: var(--muted);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-btn svg {
    width: 20px;
    height: 20px;
}

.page-status {
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

/* Bottom Bar - Floating Compact Audio Player */
.audio-player-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--background);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
    transition: var(--transition-smooth);
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.play-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--primary-foreground);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(127, 29, 29, 0.2);
    transition: var(--transition-smooth);
}

.play-toggle-btn:hover {
    background-color: var(--primary-hover);
    transform: scale(1.05);
}

.play-toggle-btn:active {
    transform: scale(0.95);
}

.play-toggle-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.skip-btn {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.skip-btn:hover {
    color: var(--foreground);
    background-color: var(--muted-light);
}

.skip-btn svg {
    width: 18px;
    height: 18px;
}

/* Audio Progress bar */
.player-progress-container {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.time-display {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
    min-width: 2rem;
}

.progress-bar-wrapper {
    flex: 1;
    height: 16px;
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
}

.progress-track {
    width: 100%;
    height: 4px;
    background-color: var(--border);
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    position: absolute;
    left: 0;
    top: 0;
    width: 0%;
    border-radius: 2px;
    transition: width 0.1s linear;
}

.progress-handle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--primary);
    border: 2px solid var(--background);
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 0%;
    opacity: 0;
    transition: opacity 0.15s ease, left 0.1s linear;
}

.progress-bar-wrapper:hover .progress-handle {
    opacity: 1;
}

.progress-bar-wrapper:hover .progress-track {
    height: 6px;
}

/* Audio Speed Control Dropdown */
.speed-select {
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    color: var(--muted);
    background-color: var(--card);
    cursor: pointer;
    outline: none;
    transition: var(--transition-smooth);
    font-family: inherit;
}

.speed-select:hover {
    color: var(--foreground);
    background-color: var(--muted-light);
    border-color: var(--muted);
}

/* Word Translation Panel / Dictionary Card Popup */
.dict-card-container {
    position: fixed;
    bottom: calc(54px + 1rem); /* Floats right above bottom player bar */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: calc(100% - 2rem);
    max-width: 760px;
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    z-index: 90;
    display: none; /* Controlled via JS */
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.dict-card-container.active {
    display: block;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.dict-header {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.dict-word-zh {
    font-family: var(--font-zh);
    font-size: 2rem;
    font-weight: 700;
}

.dict-word-pinyin {
    font-size: 1.15rem;
    color: var(--muted);
    font-weight: 550;
}

.dict-level-badge {
    background-color: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: auto;
}

.dict-definition {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    font-weight: 550;
}

.dict-example {
    font-size: 0.875rem;
    color: var(--muted);
    border-left: 3px solid var(--border);
    padding-left: 0.75rem;
    font-style: italic;
    line-height: 1.6;
}

.dict-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    border-radius: 50%;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.dict-close:hover {
    color: var(--foreground);
    background-color: var(--muted-light);
}

.dict-close svg {
    width: 16px;
    height: 16px;
}

/* Settings Modal Dropdown */
.settings-menu {
    position: absolute;
    top: 3.5rem;
    right: 1.5rem;
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 100;
    width: 280px;
    display: none;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition-smooth);
}

.settings-menu.active {
    display: flex;
}

.settings-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.05em;
}

.settings-options {
    display: grid;
    grid-template-cols: repeat(3, 1fr);
    gap: 0.35rem;
}

.settings-opt-btn {
    background-color: var(--background);
    border: 1px solid var(--border);
    color: var(--foreground);
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    transition: var(--transition-smooth);
}

.settings-opt-btn:hover {
    background-color: var(--muted-light);
}

.settings-opt-btn.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

.slider-setting {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.slider-setting input {
    flex: 1;
    accent-color: var(--primary);
    cursor: pointer;
}

.slider-val {
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 2rem;
    text-align: right;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.8; }
}

.loading-skeleton {
    animation: pulse 1.5s infinite ease-in-out;
}

/* Word highlight (Karaoke style word-by-word tracking) */
.word-highlight {
    background-color: var(--accent) !important;
    color: #000000 !important; /* High contrast black text on gold */
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(255, 179, 0, 0.5);
    transform: scale(1.02);
    transition: transform 0.1s ease, background-color 0.1s ease;
    z-index: 2;
}

.word-highlight rt {
    color: #374151 !important; /* Keep pinyin visible and dark on highlight */
}

[data-theme="dark"] .word-highlight rt {
    color: #1f2937 !important;
}

/* ==========================================
   LIBRARY DASHBOARD STYLING
   ========================================== */

.library-main {
    padding: 2rem 0;
    animation: fadeIn 0.4s ease-out;
}

.hero-section {
    text-align: center;
    margin-bottom: 2.5rem;
}

.hero-section h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

.hero-section p {
    color: var(--muted-foreground);
    font-size: 1.1rem;
}

.library-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
    background: var(--bg-card);
    padding: 0.75rem 1.25rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border: 1px solid var(--border);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--muted-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    flex: 1;
    min-width: 260px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-box svg {
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.search-box input {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    color: var(--foreground);
    font-size: 0.95rem;
}

.level-tabs {
    display: flex;
    gap: 0.5rem;
    background: var(--muted-light);
    padding: 0.3rem;
    border-radius: 8px;
}

.tab-btn {
    border: none;
    outline: none;
    background: transparent;
    color: var(--muted-foreground);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.tab-btn:hover {
    color: var(--foreground);
}

.tab-btn.active {
    background: var(--tab-active-bg) !important;
    color: var(--tab-active-color) !important;
    box-shadow: var(--tab-active-shadow) !important;
}

/* Stories Grid */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 1.5rem;
}

.story-card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.story-card-cover-container {
    height: 150px;
    width: 100%;
    overflow: hidden;
    border-bottom: 1px solid var(--border);
    position: relative;
    background-color: var(--muted-light);
}

.story-card-cover {
    height: 100%;
    width: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.story-card:hover .story-card-cover {
    transform: scale(1.08);
}

.story-card-header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-grow: 1;
}

.story-card-header .level-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    margin-bottom: 0.75rem;
}

.level-1 { background-color: rgba(34, 197, 94, 0.15); color: #16a34a; }
.level-2 { background-color: rgba(59, 130, 246, 0.15); color: #2563eb; }
.level-3 { background-color: rgba(239, 68, 68, 0.15); color: #dc2626; }
.level-4 { background-color: rgba(249, 115, 22, 0.15); color: #ea580c; }
.level-5 { background-color: rgba(168, 85, 247, 0.15); color: #9333ea; }
.level-6 { background-color: rgba(236, 72, 153, 0.15); color: #db2777; }
.level-7 { background-color: rgba(20, 184, 166, 0.15); color: #0d9488; }
.level-8 { background-color: rgba(99, 102, 241, 0.15); color: #4f46e5; }
.level-9 { background-color: rgba(234, 179, 8, 0.15); color: #ca8a04; }

.story-title {
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.story-synopsis {
    color: var(--muted-foreground);
    font-size: 0.88rem;
    line-height: 1.45;
}

.story-chapters-list {
    background: var(--muted-light);
    padding: 1rem 1.25rem;
}

.chapters-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    display: block;
    margin-bottom: 0.6rem;
}

.chapters-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.chapter-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--foreground);
    font-size: 0.88rem;
    font-weight: 500;
    transition: background-color 0.15s, border-color 0.15s;
}

.chapter-link:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
}

.chapter-link .ch-num {
    font-weight: 700;
    font-size: 0.78rem;
    color: var(--muted-foreground);
    background: var(--muted-light);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.chapter-link:hover .ch-num {
    background: var(--primary-light);
    color: var(--primary);
}

.chapter-link .ch-name {
    flex-grow: 1;
    margin-left: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chapter-link svg {
    color: var(--muted-foreground);
    transition: transform 0.15s;
}

.chapter-link:hover svg {
    transform: translateX(2px);
    color: var(--primary);
}

/* Skeleton Loading */
.card-skeleton {
    height: 250px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    animation: pulse 1.5s infinite ease-in-out;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--muted-foreground);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================
   READER TRANSLATION & DROPDOWN ENHANCEMENTS
   ========================================== */

.paragraph-block {
    margin-bottom: 2.2rem;
}

.paragraph-translation-vi {
    display: none; /* Controlled by .show-translations */
    margin-top: 0.55rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--muted-foreground);
    line-height: 1.6;
    padding-left: 0.75rem;
    border-left: 2px solid var(--primary-border);
    font-family: inherit;
    transition: background-color 0.2s ease, padding 0.2s ease;
}

.show-translations .paragraph-translation-vi {
    display: block;
}

.paragraph-translation-vi.audio-highlight {
    background-color: rgba(255, 179, 0, 0.15);
    border-radius: 4px;
    box-shadow: 0 0 4px rgba(255, 179, 0, 0.2);
    padding-top: 4px;
    padding-bottom: 4px;
    padding-right: 8px;
}

.vi-sentence {
    transition: background-color 0.2s ease, color 0.2s ease, font-weight 0.2s ease;
    border-radius: 4px;
    padding: 0 2px;
}

.vi-sentence.sentence-highlight {
    background-color: rgba(245, 158, 11, 0.35);
    color: var(--foreground) !important;
    font-weight: 600;
}

[data-theme="dark"] .vi-sentence.sentence-highlight {
    background-color: rgba(245, 158, 11, 0.5);
}

.translation-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--muted-foreground);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: auto;
}

.translation-toggle-btn:hover {
    color: var(--foreground);
    border-color: var(--muted-foreground);
}

.translation-toggle-btn.active {
    background-color: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
}

/* Chapter Dropdown */
.chapter-title-dropdown {
    position: relative;
    cursor: pointer;
}

.chapter-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    min-width: 250px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    animation: fadeIn 0.15s ease-out;
}

.chapter-dropdown-menu.active {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--foreground);
    font-size: 0.88rem;
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s;
}

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

.dropdown-item:hover {
    background: var(--muted-light);
}

.dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* ==========================================
   HSK FREE TOOLS STYLING
   ========================================== */

.tools-main {
    padding: 2rem 0;
    animation: fadeIn 0.4s ease-out;
}

.tools-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
    align-items: start;
}

@media (max-width: 768px) {
    .tools-layout {
        grid-template-columns: 1fr;
    }
}

.tools-sidebar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.tool-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: none;
    outline: none;
    color: var(--muted-foreground);
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
}

.tool-tab-btn:hover {
    color: var(--foreground);
    background: var(--muted-light);
}

.tool-tab-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.tool-tab-btn svg {
    flex-shrink: 0;
}

.tool-panel-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.02);
    min-height: 400px;
}

.tool-view-panel {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tool-view-panel.active {
    display: block;
}

.tool-view-panel h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--foreground);
}

.tool-view-panel > p {
    color: var(--muted-foreground);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.tool-intro {
    text-align: center;
    padding: 3rem 1.5rem;
    max-width: 550px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.tool-intro h2 {
    font-size: 1.75rem;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), #a855f7);
    color: #ffffff;
    border: none;
    outline: none;
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.35);
}

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

.secondary-btn {
    background: var(--muted-light);
    border: 1px solid var(--border);
    color: var(--foreground);
    outline: none;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.secondary-btn:hover {
    background: var(--border);
}

/* --- Quiz & Practice Test Game Controls --- */
.quiz-container, .practice-container {
    background: var(--muted-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
}

.quiz-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

.quiz-meta, .practice-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted-foreground);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quiz-question-card, .practice-question-card {
    text-align: center;
}

.quiz-word {
    font-family: var(--font-zh);
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--foreground);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.quiz-hint {
    font-size: 0.95rem;
    color: var(--muted-foreground);
    margin-bottom: 1.5rem;
    font-weight: 550;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

@media (max-width: 576px) {
    .quiz-options {
        grid-template-columns: 1fr;
    }
}

.quiz-opt-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--foreground);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.01);
}

.quiz-opt-btn:hover:not([disabled]) {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    background: var(--primary-light);
    color: var(--primary);
}

.quiz-opt-btn.correct {
    background-color: #22c55e !important;
    border-color: #22c55e !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.quiz-opt-btn.incorrect {
    background-color: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.quiz-opt-btn[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

.quiz-result {
    text-align: center;
    padding: 2.5rem 1rem;
    animation: fadeIn 0.4s ease;
}

.result-emoji {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.result-level {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    margin: 1rem 0;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-desc {
    font-size: 0.98rem;
    color: var(--muted-foreground);
    line-height: 1.5;
    max-width: 420px;
    margin: 0 auto 1.5rem auto;
    font-weight: 550;
}

/* --- Analyzer Controls --- */
#analyzer-input {
    width: 100%;
    height: 160px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--foreground);
    outline: none;
    resize: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
    margin-bottom: 1rem;
}

#analyzer-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.analyzer-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.analyzer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 0;
    color: var(--muted-foreground);
}

.analyzer-results {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.analyzer-summary-card, .analyzer-interactive-card, .diff-content-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    background: var(--muted-light);
}

.analyzer-summary-card h3, .analyzer-interactive-card h3, .diff-content-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--foreground);
    border-left: 3.5px solid var(--primary);
    padding-left: 0.6rem;
}

.chart-container {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.chart-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chart-label {
    width: 65px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted-foreground);
}

.chart-bar-wrapper {
    flex: 1;
    height: 14px;
    background: var(--border);
    border-radius: 7px;
    overflow: hidden;
    position: relative;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 7px;
    width: 0%;
    transition: width 0.8s ease-out;
}

.chart-value {
    width: 45px;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: right;
    color: var(--foreground);
}

/* Color definitions for HSK levels 1-9 */
.bar-hsk-1 { background-color: #22c55e; }
.bar-hsk-2 { background-color: #3b82f6; }
.bar-hsk-3 { background-color: #14b8a6; }
.bar-hsk-4 { background-color: #f97316; }
.bar-hsk-5 { background-color: #a855f7; }
.bar-hsk-6 { background-color: #db2777; }
.bar-hsk-7 { background-color: #eab308; }
.bar-hsk-8 { background-color: #4f46e5; }
.bar-hsk-9 { background-color: #ef4444; }
.bar-hsk-un { background-color: #9ca3af; }

/* Interactive Segmented Text */
.analyzer-output-text {
    font-size: 1.35rem;
    line-height: 2.1;
    font-family: var(--font-zh);
    padding: 0.5rem;
    color: var(--foreground);
}

.az-word {
    display: inline-block;
    padding: 0 0.1rem;
    border-bottom: 2px solid transparent;
    cursor: help;
    transition: all 0.15s ease;
    border-radius: 3px;
}

.az-word:hover {
    background: var(--border);
    transform: scale(1.05);
}

/* Color coding for words based on levels */
.az-word[data-level="1"] { border-color: #22c55e; color: #16a34a; }
.az-word[data-level="2"] { border-color: #3b82f6; color: #2563eb; }
.az-word[data-level="3"] { border-color: #14b8a6; color: #0d9488; }
.az-word[data-level="4"] { border-color: #f97316; color: #ea580c; }
.az-word[data-level="5"] { border-color: #a855f7; color: #9333ea; }
.az-word[data-level="6"] { border-color: #db2777; color: #db2777; }
.az-word[data-level="7"] { border-color: #eab308; color: #ca8a04; }
.az-word[data-level="8"] { border-color: #4f46e5; color: #4f46e5; }
.az-word[data-level="9"] { border-color: #ef4444; color: #dc2626; }
.az-word[data-level="un"] { border-color: #9ca3af; color: var(--muted-foreground); }

/* Global Tooltip for Analyzer */
.analyzer-tooltip {
    position: absolute;
    background-color: #1f2937;
    color: #ffffff;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.18);
    z-index: 1000;
    pointer-events: none;
    max-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-family: inherit;
    animation: fadeIn 0.12s ease-out;
}

.analyzer-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: #1f2937 transparent;
    display: block;
    width: 0;
}

.tooltip-zh {
    font-family: var(--font-zh);
    font-size: 1.5rem;
    font-weight: 700;
}

.tooltip-pinyin {
    font-size: 0.9rem;
    color: #9ca3af;
    font-weight: 600;
}

.tooltip-level {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    align-self: flex-start;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background-color: rgba(255,255,255,0.15);
}

.tooltip-definition {
    font-size: 0.85rem;
    line-height: 1.4;
    border-top: 1px solid #374151;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    color: #e5e7eb;
}

/* --- HSK Word Diff styling --- */
.diff-level-selector, .practice-level-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.diff-level-selector label, .practice-level-selector label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.diff-level-selector select, .practice-level-selector select {
    padding: 0.65rem 1rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--foreground);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.diff-level-selector select:focus, .practice-level-selector select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.diff-summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.92rem;
}

.diff-summary-table th, .diff-summary-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.diff-summary-table th {
    font-weight: 700;
    color: var(--muted-foreground);
}

.diff-summary-table td {
    font-weight: 550;
}

.diff-change-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-added { background: rgba(34,197,94,0.15); color: #16a34a; }
.badge-removed { background: rgba(239,68,68,0.15); color: #dc2626; }
.badge-shifted { background: rgba(249,115,22,0.15); color: #ea580c; }

.diff-words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.diff-word-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: help;
}

.diff-word-tag .word-cn {
    font-family: var(--font-zh);
    font-weight: 700;
}

.diff-word-tag .word-note {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* --- Practice Test Styles --- */
.practice-passage {
    font-family: var(--font-zh);
    font-size: 1.65rem;
    line-height: 2;
    color: var(--foreground);
    text-align: center;
    margin-bottom: 1.5rem;
}

.practice-hint-container {
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.hint-toggle-btn {
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.hint-toggle-btn:hover {
    background: var(--primary-light);
}

.practice-translation {
    font-size: 0.95rem;
    color: var(--muted-foreground);
    font-style: italic;
    background: var(--bg-card);
    padding: 0.65rem 1rem;
    border-radius: 6px;
    border: 1px dashed var(--border);
    animation: fadeIn 0.25s ease-out;
}

/* Keyframes for micro-animations */
@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Dictionary Star Button */
.dict-star-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-foreground);
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 0.75rem;
}

.dict-star-btn:hover {
    color: #eab308;
    background: rgba(234, 179, 8, 0.1);
}

.dict-star-btn.active {
    color: #eab308;
    fill: #eab308;
}

/* Vocabulary & Explore Grids */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

.vocab-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.vocab-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.04);
}

.vocab-card .card-zh {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--foreground);
}

.vocab-card .card-pinyin {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 0.35rem;
    font-weight: 500;
}

.vocab-card .card-vi {
    font-size: 0.88rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.vocab-card .card-level {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: rgba(244, 63, 94, 0.1); /* RGBA equivalent to primary tint */
    color: var(--primary);
    margin-top: 0.75rem;
}

/* Flashcard Container and Flip Animation */
.flashcard-container {
    max-width: 420px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: scaleIn 0.3s ease-out;
}

.flashcard-card {
    width: 100%;
    height: 280px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
    border-radius: 16px;
}

.flashcard-card.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: var(--bg-card) || var(--card);
}

.fc-zh {
    font-size: 5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    color: var(--foreground);
}

.fc-pinyin {
    font-size: 1.6rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.fc-vi {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--foreground);
    margin-top: 0.5rem;
}

.fc-level {
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(244, 63, 94, 0.1);
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.fc-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Explore expanded detail view styles */
.explore-detail-view {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    animation: fadeIn 0.3s ease-out;
}

.evolution-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1.25rem;
    text-align: center;
    margin-bottom: 2rem;
}

.evolution-item {
    background: var(--bg-card) || var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.evolution-item svg, .evolution-item img {
    width: 64px;
    height: 64px;
    margin-bottom: 0.75rem;
}

.evolution-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--foreground);
    margin-bottom: 0.2rem;
}

.evolution-period {
    font-size: 0.72rem;
    color: var(--muted-foreground);
}

.vocab-saved-empty {
    padding: 3rem 1.5rem;
    background: var(--card);
    border: 1.5px dashed var(--border);
    border-radius: 12px;
}

/* Hide mobile toggle by default on desktop */
.hamburger-btn {
    display: none;
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 768px) {
    /* Header Layout & Sandwich Menu Drawer */
    header {
        padding: 0.5rem 1rem;
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        width: 100% !important;
        background-color: var(--background) !important;
    }
    
    header nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--background) !important;
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 0.75rem;
        gap: 0.35rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.06);
        z-index: 1000;
    }
    
    header nav.nav-open {
        display: flex;
    }
    
    header nav .nav-link {
        width: 100%;
        padding: 0.75rem 1rem;
        border-radius: 8px;
        justify-content: flex-start;
        box-sizing: border-box;
    }
    
    /* Hamburger button style */
    .hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 20px;
        height: 14px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        margin-left: auto;
        margin-right: 1.25rem;
        outline: none;
    }
    
    .hamburger-btn .bar {
        width: 100%;
        height: 2px;
        background-color: var(--foreground);
        border-radius: 2px;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }
    
    /* Morph to X */
    .hamburger-btn.active .bar:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }
    .hamburger-btn.active .bar:nth-child(2) {
        opacity: 0;
    }
    .hamburger-btn.active .bar:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }
    
    /* Main Layout & Page Elements */
    .main-container {
        border-left: none;
        border-right: none;
        padding-top: 64px !important;
    }
    
    .desktop-wm {
        display: none;
    }
    
    /* Library Header & Level Tabs */
    .library-header h1 {
        font-size: 1.75rem !important;
    }
    
    .level-tabs {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.35rem;
    }
    
    .tab-btn {
        padding: 0.4rem 0.7rem;
        font-size: 0.8rem;
    }
    
    /* Grids & Cards spacing */
    .stories-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1rem;
        padding: 0.25rem 0;
    }
    
    .story-card-body {
        padding: 1.25rem;
    }
    
    /* Reader Header & Navigation controls */
    .reader-header-strip {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }
    
    #reader-story-title {
        font-size: 1.1rem;
    }
    
    .page-controls-docked {
        padding: 0.75rem 1rem;
    }
    
    /* Bottom stacked player dock on mobile */
    .audio-player-bar {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 0.75rem;
        height: auto;
        bottom: 0;
    }
    
    .audio-player-bar .player-controls {
        width: 100%;
        justify-content: center;
        gap: 2rem;
    }
    
    .audio-player-bar .player-progress-container {
        width: 100%;
    }
    
    .audio-player-bar .speed-select-container {
        width: 100%;
        display: flex;
        justify-content: center;
        margin-top: 0.25rem;
    }
    
    .speed-select {
        width: 120px;
        text-align: center;
    }
    
    /* Dictionary Floating Card position offset on mobile */
    .dict-card-container {
        width: calc(100% - 2rem);
        left: 1rem;
        right: 1rem;
        transform: none;
        bottom: calc(130px + 1rem) !important;
    }
    
    /* Explore and Flashcards details view spacing */
    .explore-detail-view {
        padding: 1.5rem;
    }
    
    .evolution-grid {
        grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
        gap: 0.75rem;
    }
    
    /* Search box styling */
    .search-box {
        padding: 0.5rem 1rem;
    }
}


