:root {
    /* Light Mode Variables (Default) */
    --bg-color: #f0fdfa; /* Light teal gradient background base */
    --bg-gradient: linear-gradient(135deg, #e0f2fe 0%, #f0fdfa 100%);
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(255, 255, 255, 0.3);
    --text-main: #0f172a;
    --text-muted: #475569;
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --secondary: #10b981;
    --accent: #8b5cf6;
    --shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    /* Dark Mode Variables */
    --bg-color: #0f172a;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(30, 41, 59, 0.85);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #38bdf8;
    --primary-hover: #7dd3fc;
    --secondary: #34d399;
    --accent: #a78bfa;
    --shadow: 0 10px 25px -5px rgba(0,0,0,0.5), 0 8px 10px -6px rgba(0,0,0,0.5);
}

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

body {
    font-family: 'Inter', 'Tajawal', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    overflow: hidden;
}

.chinese-text {
    font-family: 'Noto Sans SC', sans-serif;
}

/* Glassmorphism utility */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

/* Header */
.logo {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header {
    display: none; /* Removed the old floating header setup */
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Container */
.container {
    max-width: 100%; /* Changed from 1400px to allow full width */
    margin: 0 auto;
    padding: 2rem 4rem; /* Increased side padding slightly */
    box-sizing: border-box;
}

/* Home Page */
.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); /* Auto-fit expands cards cleanly in wide layouts */
    gap: 2rem;
    margin-top: 2rem;
}

.level-card {
    padding: 2.5rem 2rem;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.level-card:hover:not(.disabled) {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.level-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(1);
}

.level-card h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary);
}

.level-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

/* Step-by-5 compact cards */
.level-card.step5-card {
    padding: 1.75rem 1.5rem;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.level-card.step5-card h2 {
    font-size: 2rem;
    margin-bottom: 0.35rem;
}
.level-card.step5-card p {
    margin-bottom: 1rem;
    font-size: 1rem;
}

.btn-group {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
    border: 1px solid var(--secondary);
}

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

/* Vocab Page */
.vocab-container {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
    width: 100%;
}

.vocab-card {
    padding: 3rem 2rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}
@media (min-width: 768px) {
    .vocab-card {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
    }
    .vocab-card > div:first-child {
        flex: 1;
        border-right: 1px solid var(--card-border);
        padding-right: 2rem;
    }
    .vocab-card > div:last-child {
        flex: 1;
        padding-left: 2rem;
    }
    .vocab-card .audio-row {
        justify-content: flex-start;
    }
}

.word-display {
    font-size: 6rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    line-height: 1.2;
}

.pinyin {
    font-size: 1.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.meaning {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.audio-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.btn-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.btn-icon:hover {
    transform: scale(1.1);
    background: var(--primary-hover);
}

.btn-icon.secondary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}
.btn-icon.secondary:hover {
    background: var(--primary);
    color: white;
}

.sentence-section {
    background: rgba(0,0,0,0.03);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: left;
    margin-bottom: 2rem;
}
[data-theme="dark"] .sentence-section {
    background: rgba(255,255,255,0.05);
}

.sentence-ch {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.sentence-en {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Navigation between words */
.nav-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Practice Area (Drawing Canvas) */
.practice-area {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}
.canvas-container {
    position: relative;
    width: 100%;
    max-width: 300px;
    height: 150px;
    border: 2px dashed var(--card-border);
    border-radius: 12px;
    margin: 0.5rem 0;
}
.stroke-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    color: rgba(0,0,0,0.05);
    pointer-events: none;
    font-family: 'Noto Sans SC', sans-serif;
}

.practice-input {
    width: 100%;
    max-width: 300px;
    padding: 0.75rem;
    font-size: 1.1rem;
    border: 2px solid var(--card-border);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
    text-align: center;
    transition: all 0.3s;
}
.practice-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}
[data-theme="dark"] .stroke-bg {
    color: rgba(255,255,255,0.05);
}
canvas {
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/* Quiz Page */
.quiz-card {
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.quiz-question {
    font-size: 4rem;
    margin-bottom: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}
.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.quiz-option {
    padding: 1.25rem 1rem;
    background: rgba(14, 165, 233, 0.1);
    border: 2px solid rgba(14, 165, 233, 0.3);
    border-radius: 14px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
}
.quiz-option:hover {
    background: rgba(14, 165, 233, 0.2);
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px -4px rgba(14, 165, 233, 0.25);
}
.quiz-option:active {
    transform: translateY(0);
}
.quiz-option.correct {
    background: #6ee7b7;
    color: #065f46;
    border-color: #6ee7b7;
    transform: scale(1.03);
    box-shadow: 0 6px 20px -4px rgba(110, 231, 183, 0.4);
}
.quiz-option.wrong {
    background: #fca5a5;
    color: #991b1b;
    border-color: #fca5a5;
    animation: wrongShake 0.5s ease;
}

.score-display {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #0ea5e9, #8b5cf6);
    padding: 4px 14px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

/* Confetti wrapper */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Responsive */
@media (max-width: 768px) {
    .word-display { font-size: 4rem; }
    .quiz-options { grid-template-columns: 1fr; }
    .container { padding: 1rem; }
}

/* Sidebar App Layout */
#app {
    height: 100vh;
    height: 100dvh;
}
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
}
.sidebar {
    width: 250px;
    background: var(--card-bg);
    border-right: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    z-index: 1000;
    transition: transform 0.3s;
}
.sidebar .logo {
    margin-bottom: 1rem;
}
.nav-links {
    list-style: none;
    flex: 1;
}
.nav-links li {
    padding: 0.65rem 1rem;
    margin-bottom: 0.3rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}
.nav-links li:hover:not(.disabled) {
    background: rgba(14, 165, 233, 0.1);
    color: var(--primary);
}
.nav-links li.active {
    background: var(--primary);
    color: white;
}
.nav-links li.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.sidebar-theme-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 0.6rem;
    justify-content: center;
    border-radius: 8px;
    background: rgba(0,0,0,0.05);
}
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}
.mobile-topbar {
    display: none;
    padding: 1rem 1.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    justify-content: space-between;
    align-items: center;
    z-index: 999;
}
.menu-btn {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}
.scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 2rem;
}
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .nav-links {
        overflow-y: auto;
    }
    .nav-links li {
        padding: 0.55rem 0.85rem;
        margin-bottom: 0.15rem;
        font-size: 0.88rem;
    }
    .mobile-topbar {
        display: flex;
    }
    .scroll-area {
        padding: 1rem;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    }
    .nav-controls {
        gap: 4px;
    }
    .nav-controls .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    .nav-controls .hsk-level-badge {
        font-size: 0.65rem !important;
        padding: 2px 7px !important;
    }
    .smart-dashboard-grid {
        grid-template-columns: 1fr !important;
    }
    .smart-cat-grid {
        grid-template-columns: 1fr !important;
    }
    .smart-quiz-btn {
        font-size: 0.95rem !important;
        padding: 0.8rem 1.5rem !important;
    }
    .quiz-tf-btn {
        font-size: 1.1rem !important;
        padding: 0.8rem 2rem !important;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

/* Flip Card Styles */
.radical-card-container {
    perspective: 1000px;
    height: 300px;
    cursor: pointer;
}

.radical-card {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    transform-style: preserve-3d;
}

.radical-card.is-flipped {
    transform: rotateY(180deg);
}

.radical-front, .radical-back {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.radical-back {
    transform: rotateY(180deg);
}

/* ===== Interactive Pinyin Chart ===== */
.pinyin-chart-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: var(--card-bg);
    -webkit-overflow-scrolling: touch;
}
.pinyin-chart-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 900px;
    font-size: 0.85rem;
}
.pinyin-chart-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}
.pinyin-chart-table th.pinyin-header {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: white;
    padding: 8px 6px;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    min-width: 52px;
    border: 1px solid rgba(255,255,255,0.15);
    letter-spacing: 0.5px;
}
.pinyin-chart-table th.pinyin-corner {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    min-width: 60px;
    border: 1px solid rgba(255,255,255,0.15);
}
.pinyin-final-header {
    background: linear-gradient(135deg, #fbbf2420, #f59e0b20);
    color: #b45309;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 10px;
    text-align: center;
    border: 1px solid rgba(0,0,0,0.06);
    min-width: 60px;
    position: sticky;
    left: 0;
    z-index: 5;
}
[data-theme="dark"] .pinyin-final-header {
    background: linear-gradient(135deg, #78350f40, #92400e30);
    color: #fbbf24;
}
.pinyin-cell {
    text-align: center;
    padding: 6px 4px;
    border: 1px solid rgba(0,0,0,0.05);
    font-size: 0.82rem;
    color: var(--text-muted);
    transition: all 0.15s ease;
    min-height: 32px;
}
[data-theme="dark"] .pinyin-cell {
    border-color: rgba(255,255,255,0.05);
}
.pinyin-cell.has-sound {
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
}
.pinyin-cell.has-sound:hover {
    background: linear-gradient(135deg, #0ea5e910, #0ea5e920);
    color: var(--primary);
    font-weight: 700;
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.2);
    border-radius: 4px;
    position: relative;
    z-index: 2;
}
/* Zebra striping for readability */
.pinyin-chart-table tbody tr:nth-child(even) {
    background: rgba(0,0,0,0.015);
}
[data-theme="dark"] .pinyin-chart-table tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}

/* ===== Tone Popup Overlay ===== */
.tone-popup-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.15s ease;
}
.tone-popup {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    min-width: 300px;
    max-width: 400px;
    animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ===== New Radical Cards ===== */
.radical-new-card {
    padding: 1rem 1.2rem;
    border-radius: 14px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.radical-new-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}
.radical-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

/* ===== Classifier Wizard ===== */
.wizard-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 1.5rem;
}
.wizard-cat-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 1.2rem 1rem;
    border-radius: 16px;
    border: 2px solid rgba(0,0,0,0.08);
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.25s ease;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-main);
}
.wizard-cat-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.wizard-cat-btn .wizard-cat-emoji {
    font-size: 2.2rem;
    line-height: 1;
}
.wizard-question-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    animation: wizardSlideIn 0.35s ease;
}
.wizard-result-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.1);
    border: 2px solid var(--primary);
    animation: wizardPop 0.4s ease;
}
.wizard-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.wizard-breadcrumb span {
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(0,0,0,0.05);
    font-weight: 500;
}
.wizard-breadcrumb .wizard-bc-active {
    background: var(--primary);
    color: white;
}
.wizard-breadcrumb .wizard-bc-arrow {
    background: none;
    padding: 0;
    font-size: 0.9rem;
}
@keyframes wizardSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes wizardPop {
    0% { opacity: 0; transform: scale(0.9); }
    60% { transform: scale(1.03); }
    100% { opacity: 1; transform: scale(1); }
}

/* ===== Dashboard Progress Bars ===== */
.hsk-progress-bar {
    margin-top: 0.75rem;
    width: 100%;
}
.hsk-progress-track {
    height: 6px;
    background: rgba(0,0,0,0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}
[data-theme="dark"] .hsk-progress-track {
    background: rgba(255,255,255,0.08);
}
.hsk-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}
/* RTL progress: fill starts from right side */
.rtl-progress {
    direction: rtl;
}
.rtl-progress .hsk-progress-fill {
    background: linear-gradient(270deg, #0ea5e9, #38bdf8);
}

/* ─── Practice Feedback Animations ─── */
@keyframes correctPulse {
    0% { box-shadow: 0 0 0 0 rgba(16,185,129,0.6); }
    50% { box-shadow: 0 0 0 20px rgba(16,185,129,0); transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(16,185,129,0); transform: scale(1); }
}
@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-12px); }
    30% { transform: translateX(10px); }
    45% { transform: translateX(-8px); }
    60% { transform: translateX(6px); }
    75% { transform: translateX(-3px); }
}
.feedback-correct {
    animation: correctPulse 0.6s ease;
    border: 2px solid #10b981 !important;
    background: rgba(16,185,129,0.08) !important;
}
.feedback-wrong {
    animation: wrongShake 0.5s ease;
    border: 2px solid #ef4444 !important;
    background: rgba(244,63,94,0.08) !important;
}
.feedback-banner {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
    font-size: 3rem; font-weight: 800; z-index: 10; pointer-events: none;
    text-shadow: 0 2px 10px rgba(0,0,0,0.15);
    animation: feedbackPop 0.8s ease forwards;
}
@keyframes feedbackPop {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(0.3); }
    30% { opacity: 1; transform: translate(-50%,-50%) scale(1.2); }
    60% { transform: translate(-50%,-50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%,-60%) scale(0.9); }
}
/* Progress bar inside quiz — removed per user preference */
/* Hub score badge */
.hub-score-badge {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.8rem; font-weight: 700; padding: 3px 10px;
    border-radius: 20px; margin-top: 0.5rem;
}
.hub-score-badge.gold { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #78350f; }
.hub-score-badge.silver { background: linear-gradient(135deg, #94a3b8, #64748b); color: white; }
.hub-score-badge.bronze { background: linear-gradient(135deg, #fb923c, #ea580c); color: white; }

/* === ANALYZE BUTTON === */
.btn-analyze {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    margin-top: 1rem;
    border: 2px solid var(--accent);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08), rgba(139, 92, 246, 0.15));
    color: var(--accent);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.3px;
}
.btn-analyze:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(139, 92, 246, 0.25));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.25);
}
.btn-analyze:active {
    transform: translateY(0);
}

/* === DECOMPOSITION MODAL OVERLAY === */
.decomp-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.25s ease;
    padding: 1.5rem;
}
.decomp-modal-overlay.active {
    opacity: 1;
}
.decomp-modal-overlay.closing {
    opacity: 0;
}

/* === MODAL CONTENT === */
.decomp-modal {
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.decomp-modal-overlay.active .decomp-modal {
    transform: scale(1) translateY(0);
}
.decomp-modal-overlay.closing .decomp-modal {
    transform: scale(0.9) translateY(20px);
}

/* Modal Header */
.decomp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--card-border);
}
.decomp-modal-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.decomp-modal-word {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.decomp-modal-word .chinese-text {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}
.decomp-modal-pinyin {
    font-size: 1.1rem;
    color: var(--accent);
    font-weight: 600;
}
.decomp-modal-meaning {
    font-size: 1rem;
    color: var(--text-muted);
}
.decomp-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--card-border);
    background: rgba(0,0,0,0.04);
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.decomp-modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

/* Modal Body */
.decomp-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Character Sections */
.decomp-char-section {
    border-radius: 14px;
    padding: 1.25rem;
    background: rgba(0,0,0,0.025);
    border: 1px solid var(--card-border);
    animation: decompSlideIn 0.4s ease backwards;
}
[data-theme="dark"] .decomp-char-section {
    background: rgba(255,255,255,0.04);
}
@keyframes decompSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.decomp-char-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}
.decomp-main-char {
    font-size: 3rem;
    color: var(--primary);
    line-height: 1;
    font-weight: 700;
}
.decomp-equals {
    font-size: 1.5rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* Components List */
.decomp-components-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
}
.decomp-plus {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.4;
    line-height: 1;
    padding: 2px 0;
}

/* Individual Component */
.decomp-component {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(0,0,0,0.06);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    animation: decompSlideIn 0.4s ease backwards;
}
[data-theme="dark"] .decomp-component {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.08);
}
.decomp-component:hover {
    transform: translateX(6px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    border-color: var(--primary);
}
[data-theme="dark"] .decomp-component:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.decomp-component .comp-char {
    font-size: 2.5rem;
    line-height: 1;
    min-width: 50px;
    text-align: center;
    color: var(--primary);
    font-weight: 700;
}
.decomp-component .comp-info {
    flex: 1;
    min-width: 0;
}
.decomp-component .comp-pinyin {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
}
.decomp-component .comp-meaning {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1px;
}
.decomp-component .comp-role {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
}
.comp-role.radical {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.comp-role.phonetic {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}
.comp-role.semantic {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.comp-role.component {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Explanation Callout */
.decomp-explanation {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-top: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.08), rgba(245, 158, 11, 0.12));
    border: 1px solid rgba(245, 158, 11, 0.2);
    animation: decompSlideIn 0.5s ease backwards;
}
.decomp-explanation i {
    color: #f59e0b;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-top: 1px;
}
.decomp-explanation span {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-main);
    font-weight: 500;
}
[data-theme="dark"] .decomp-explanation {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.06), rgba(245, 158, 11, 0.1));
    border-color: rgba(245, 158, 11, 0.15);
}

/* Modal Legend */
.decomp-modal-legend {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--card-border);
    flex-wrap: wrap;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ====== HYBRID RTL for Character Analysis Modal ====== */
.decomp-rtl {
    direction: rtl;
}

/* Header: label flows RTL */
.decomp-rtl .decomp-modal-label {
    direction: rtl;
    text-align: right;
}

/* Word row: natural RTL — Arabic meaning first (right), then pinyin, then Chinese */
.decomp-rtl .decomp-modal-word {
    direction: rtl;
}
.decomp-rtl .decomp-modal-word .chinese-text {
    direction: ltr;
    unicode-bidi: isolate;
}
.decomp-rtl .decomp-modal-pinyin {
    direction: ltr;
    unicode-bidi: isolate;
}
.decomp-rtl .decomp-modal-meaning {
    direction: rtl;
    unicode-bidi: isolate;
}

/* Close button: in RTL direction, flex already places it on the left (visual end) */
.decomp-rtl .decomp-modal-header {
    direction: rtl;
}

/* Character header: 怎 = (char on right, = after it to the left)
   direction:rtl makes flex flow right-to-left, so HTML order [char][=] → char on right, = on left */
.decomp-rtl .decomp-char-header {
    direction: rtl;
    justify-content: flex-start; /* flex-start in RTL = right side */
}
.decomp-rtl .decomp-main-char {
    direction: ltr;
    unicode-bidi: isolate;
}
.decomp-rtl .decomp-equals {
    direction: ltr;
    unicode-bidi: isolate;
}

/* Component cards: RTL layout — badge(left) | info(middle) | char(right) */
.decomp-rtl .decomp-component {
    direction: rtl;
}
.decomp-rtl .decomp-component:hover {
    transform: translateX(-6px);
}
.decomp-rtl .decomp-component .comp-char {
    direction: ltr;
    unicode-bidi: isolate;
}
.decomp-rtl .decomp-component .comp-info {
    text-align: right;
    direction: rtl;
}
.decomp-rtl .decomp-component .comp-pinyin {
    direction: ltr;
    unicode-bidi: isolate;
    text-align: right;
}
.decomp-rtl .decomp-component .comp-meaning {
    direction: rtl;
    text-align: right;
}
.decomp-rtl .decomp-component .comp-role {
    direction: rtl;
}

/* Explanation callout: RTL — bulb icon on right, text flows right-to-left */
.decomp-rtl .decomp-explanation {
    direction: rtl;
    text-align: right;
    /* No row-reverse: direction:rtl already puts first child (icon) on the right */
}
.decomp-rtl .decomp-explanation span {
    direction: rtl;
    unicode-bidi: plaintext;
    text-align: right;
}

/* Legend: natural RTL flow */
.decomp-rtl .decomp-modal-legend {
    direction: rtl;
}
.decomp-rtl .legend-item {
    direction: rtl;
}
.decomp-rtl .legend-item .comp-role {
    direction: rtl;
}


/* Part of Speech Badges */
.pos-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 0.35rem;
}
.pos-n { background: rgba(99, 102, 241, 0.1); color: #6366f1; border: 1px solid rgba(99, 102, 241, 0.2); }
.pos-v { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }
.pos-adj { background: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); }
.pos-adv { background: rgba(245, 158, 11, 0.1); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.2); }
.pos-prep { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; border: 1px solid rgba(139, 92, 246, 0.2); }
.pos-conj { background: rgba(236, 72, 153, 0.1); color: #ec4899; border: 1px solid rgba(236, 72, 153, 0.2); }
.pos-mw { background: rgba(6, 182, 212, 0.1); color: #06b6d4; border: 1px solid rgba(6, 182, 212, 0.2); }
.pos-part { background: rgba(107, 114, 128, 0.1); color: #6b7280; border: 1px solid rgba(107, 114, 128, 0.2); }
.pos-pron { background: rgba(59, 130, 246, 0.1); color: #3b82f6; border: 1px solid rgba(59, 130, 246, 0.2); }
.pos-num { background: rgba(14, 165, 233, 0.1); color: #0ea5e9; border: 1px solid rgba(14, 165, 233, 0.2); }

/* ========== Step by 5 — Roadmap Grid ========== */
.step5-roadmap-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.75rem;
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1rem;
}
@media (max-width: 640px) {
    .step5-roadmap-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
.step5-dot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: default;
    transition: transform 0.2s;
}
.step5-dot.completed, .step5-dot.current {
    cursor: pointer;
}
.step5-dot.completed:hover, .step5-dot.current:hover {
    transform: translateY(-3px);
}
.step5-dot-inner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}
.step5-dot.completed .step5-dot-inner {
    background: linear-gradient(135deg, #6ee7b7, #10b981);
    color: white;
    border-color: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12), 0 4px 12px rgba(16, 185, 129, 0.25);
}
.step5-dot.current .step5-dot-inner {
    background: linear-gradient(135deg, #38bdf8, #0ea5e9);
    color: white;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 6px rgba(14, 165, 233, 0.15), 0 4px 12px rgba(14, 165, 233, 0.3);
    animation: step5Pulse 2s ease-in-out infinite;
}
.step5-dot.locked .step5-dot-inner {
    background: #e2e8f0;
    color: #94a3b8;
    border-color: #cbd5e1;
    font-size: 0.8rem;
}
.step5-dot-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}
.step5-dot.completed .step5-dot-label {
    color: #10b981;
}
.step5-dot.current .step5-dot-label {
    color: #0ea5e9;
    font-weight: 700;
}
@keyframes step5Pulse {
    0%, 100% { box-shadow: 0 0 0 6px rgba(14,165,233,0.15), 0 4px 12px rgba(14,165,233,0.3); }
    50% { box-shadow: 0 0 0 12px rgba(14,165,233,0.08), 0 4px 16px rgba(14,165,233,0.4); }
}

/* In-Progress Session — pulsing orange-to-blue to draw attention */
.step5-dot.in-progress .step5-dot-inner {
    background: linear-gradient(135deg, #f59e0b, #0ea5e9);
    color: white;
    border-color: #f59e0b;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.2), 0 4px 12px rgba(245, 158, 11, 0.3);
    animation: step5InProgress 1.5s ease-in-out infinite;
}
.step5-dot.in-progress .step5-dot-label {
    color: #f59e0b;
    font-weight: 700;
    font-size: 0.65rem;
}
@keyframes step5InProgress {
    0%, 100% { box-shadow: 0 0 0 6px rgba(245,158,11,0.2), 0 4px 12px rgba(245,158,11,0.3); }
    50% { box-shadow: 0 0 0 14px rgba(245,158,11,0.08), 0 4px 18px rgba(14,165,233,0.35); }
}

/* Reading Challenge Dots */
.step5-dot.reading .step5-dot-inner {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    border-color: #f59e0b !important;
    font-size: 1rem;
    box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.15), 0 4px 14px rgba(245, 158, 11, 0.3) !important;
}
.step5-dot.reading.current .step5-dot-inner {
    animation: readingPulse 2s infinite;
}
.step5-dot.reading.completed .step5-dot-inner {
    background: linear-gradient(135deg, #fbbf24, #f59e0b) !important;
    border-color: #f59e0b !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15), 0 4px 12px rgba(245, 158, 11, 0.25) !important;
}
.step5-dot.reading.locked .step5-dot-inner {
    background: var(--card-bg) !important;
    border-color: var(--card-border) !important;
    opacity: 0.5;
}
.step5-dot.reading .step5-dot-label {
    color: #f59e0b;
    font-weight: 700;
}
.step5-dot.reading.completed .step5-dot-label {
    color: #f59e0b;
}
@keyframes readingPulse {
    0%, 100% { box-shadow: 0 0 0 6px rgba(245,158,11,0.15), 0 4px 12px rgba(245,158,11,0.3); }
    50% { box-shadow: 0 0 0 12px rgba(245,158,11,0.08), 0 4px 16px rgba(245,158,11,0.4); }
}

/* =============================================
   READING CHALLENGE — Premium Redesign
   ============================================= */

/* Tighter centered container */
.reading-container {
    max-width: 640px;
    margin: 0 auto;
}

/* Header */
.rc-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.rc-header-info h1 {
    font-size: 1.75rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.rc-header-info p {
    color: var(--text-muted);
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
}
.rc-passage-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(14, 165, 233, 0.12);
    color: var(--primary);
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-left: 0.5rem;
}

/* Progress pills */
.rc-progress-pills {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 0.5rem;
}
.rc-pill {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--card-border);
    transition: all 0.3s ease;
}
.rc-pill.done {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}
.rc-pill.active {
    background: var(--primary);
    box-shadow: 0 0 6px rgba(14, 165, 233, 0.4);
    transform: scale(1.2);
}

/* Reading Passage Card */
.rc-passage-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.75rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
.rc-passage-card .rc-card-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Passage lines */
.rc-passage-line {
    font-size: 1.4rem;
    line-height: 2.4;
    transition: opacity 0.4s ease, background 0.3s ease;
    padding: 2px 8px;
    border-radius: 8px;
    margin: 0;
    direction: ltr;
    text-align: left;
}
.rc-passage-line.dimmed {
    opacity: 0.4;
}
.rc-passage-line.highlighted {
    opacity: 1;
    background: rgba(245, 158, 11, 0.06);
    border-radius: 8px;
}

/* Capsule-style blanks */
.reading-gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.5rem;
    padding: 0.15rem 0.75rem;
    margin: 0 0.2rem;
    background: rgba(148, 163, 184, 0.1);
    border: 2px dashed rgba(148, 163, 184, 0.35);
    border-radius: 20px;
    color: var(--text-muted);
    font-weight: 700;
    text-align: center;
    transition: all 0.3s ease;
    font-size: 1rem;
    vertical-align: middle;
    line-height: 1.6;
}
.reading-gap.active {
    border-color: #f59e0b;
    border-style: solid;
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
    animation: gapPulse 1.5s ease-in-out infinite;
}
.reading-gap.correct {
    border-color: #10b981;
    border-style: solid;
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
    animation: gapCorrectPop 0.4s ease-out;
}
.reading-gap.wrong {
    border-color: #ef4444;
    border-style: solid;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    animation: gapShake 0.4s ease-out;
}

@keyframes gapPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1); }
    50% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.15); }
}
@keyframes gapCorrectPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
@keyframes gapShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(2px); }
}

/* Answer Area Card */
.rc-answer-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    margin-bottom: 1rem;
}
.rc-answer-card .rc-card-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Gap progress indicator inside answer card */
.rc-gap-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1rem;
}
.rc-gap-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--card-border);
    transition: all 0.3s ease;
}
.rc-gap-dot.done {
    background: #10b981;
}
.rc-gap-dot.active {
    background: #f59e0b;
    transform: scale(1.3);
    box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}
.rc-gap-dot.wrong {
    background: #ef4444;
}

/* Answer option buttons */
.rc-option-grid {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.rc-option-btn {
    font-size: 1.4rem;
    padding: 0.85rem 1.75rem;
    border-radius: 14px;
    border: 2px solid var(--card-border);
    background: rgba(14, 165, 233, 0.04);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    text-align: center;
    font-family: 'Noto Sans SC', 'LXGW WenKai', sans-serif;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}
.rc-option-btn:hover:not(:disabled) {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.06);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.12);
}
.rc-option-btn:active:not(:disabled) {
    transform: translateY(0);
}
.rc-option-btn.correct-opt {
    background: rgba(16, 185, 129, 0.12) !important;
    border-color: #10b981 !important;
    color: #065f46 !important;
}
.rc-option-btn.wrong-opt {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: #ef4444 !important;
    color: #991b1b !important;
}

/* Feedback area */
.rc-feedback {
    text-align: center;
    min-height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    margin-top: 0.75rem;
}

/* Complete button area */
.rc-complete-area {
    text-align: center;
    margin-top: 1rem;
}
.rc-complete-btn {
    display: none;
    animation: completeBtnPop 0.5s ease-out;
}
.rc-complete-btn.visible {
    display: inline-flex;
}
@keyframes completeBtnPop {
    0% { transform: scale(0.8); opacity: 0; }
    60% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== Step-by-5 Exercise Container ===== */
.exercise-container {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
}
.exercise-container .exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.exercise-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    text-align: center;
}
.exercise-card h3 {
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    font-size: 1rem;
}
.exercise-card .exercise-chinese {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
    direction: ltr;
}
.exercise-card .exercise-meaning {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}
.exercise-card .exercise-next-btn {
    margin-top: 0.75rem;
}
@media (max-width: 600px) {
    .exercise-container {
        padding: 0.75rem;
    }
    .exercise-card {
        padding: 1rem;
    }
}

/* Passage completion glow */
.rc-passage-card.all-done {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1), 0 4px 16px rgba(16, 185, 129, 0.12);
    animation: passageGlow 1s ease-out;
}
@keyframes passageGlow {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
    50% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.15), 0 4px 20px rgba(16, 185, 129, 0.2); }
    100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1), 0 4px 16px rgba(16, 185, 129, 0.12); }
}

/* Mobile: sticky answer bar */
@media (max-width: 640px) {
    .reading-container {
        max-width: 100%;
        padding: 0 0.75rem;
    }
    .rc-passage-card {
        padding: 1.25rem;
    }
    .rc-passage-line {
        font-size: 1.2rem;
        line-height: 2.2;
    }
    .rc-answer-card {
        position: sticky;
        bottom: 0;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
        z-index: 10;
        padding: 0.75rem 1rem;
    }
    .rc-option-btn {
        font-size: 1.25rem;
        padding: 0.7rem 1.25rem;
        min-width: 70px;
    }
}

/* =============================================
   TONE PAIR DRILL
   ============================================= */
.td-mode-tabs {
    display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap;
}
.td-tab {
    padding: 0.6rem 1.2rem; border-radius: 10px; border: 2px solid var(--card-border);
    background: var(--card-bg); color: var(--text-muted); font-weight: 600; cursor: pointer;
    display: flex; align-items: center; gap: 6px; transition: all 0.2s; font-size: 0.9rem;
}
.td-tab:hover { border-color: var(--primary); color: var(--primary); }
.td-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.td-mode-desc {
    padding: 0.8rem 1.2rem; margin-bottom: 1.5rem; font-size: 0.9rem; color: var(--text-muted);
}

.td-grid-wrapper {
    display: flex; flex-direction: column; gap: 2px; margin-bottom: 2rem;
}
.td-grid-header, .td-grid-row {
    display: grid; grid-template-columns: 50px repeat(4, 1fr); gap: 2px;
}
.td-corner { min-height: 30px; }
.td-col-label, .td-row-label {
    font-weight: 800; font-size: 0.9rem; display: flex; align-items: center; justify-content: center;
}
.td-cell {
    position: relative; padding: 0.8rem 0.5rem; border-radius: 12px; text-align: center;
    cursor: pointer; transition: all 0.2s; border: 2px solid transparent;
    background: var(--card-bg); min-height: 70px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.td-cell:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }

/* Heatmap levels */
.td-cell.heat-0 { background: rgba(0,0,0,0.03); }
.td-cell.heat-1 { background: rgba(14,165,233,0.08); border-color: rgba(14,165,233,0.15); }
.td-cell.heat-2 { background: rgba(14,165,233,0.18); border-color: rgba(14,165,233,0.3); }
.td-cell.heat-3 { background: linear-gradient(135deg, rgba(14,165,233,0.2), rgba(139,92,246,0.15)); border-color: rgba(14,165,233,0.4); }
[data-theme="dark"] .td-cell.heat-0 { background: rgba(255,255,255,0.03); }
[data-theme="dark"] .td-cell.heat-1 { background: rgba(56,189,248,0.08); }
[data-theme="dark"] .td-cell.heat-2 { background: rgba(56,189,248,0.18); }
[data-theme="dark"] .td-cell.heat-3 { background: linear-gradient(135deg, rgba(56,189,248,0.2), rgba(167,139,250,0.15)); }

.td-cell-pair { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.td-cell-reps { font-size: 0.7rem; color: var(--text-muted); }
.td-check { position: absolute; top: 4px; right: 6px; font-size: 0.7rem; color: #10b981; font-weight: 800; }
.td-sandhi-badge { font-size: 0.7rem; }

/* Drill card */
.td-drill-card { padding: 2rem; text-align: center; }
.td-drill-pinyin { font-size: 3rem; font-weight: 800; margin-bottom: 1rem; letter-spacing: 4px; }
.td-drill-btns { display: flex; gap: 0.75rem; justify-content: center; margin-bottom: 1.5rem; }
.td-sandhi-note {
    background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
    border-radius: 10px; padding: 0.6rem 1rem; font-size: 0.85rem; color: var(--text-main); margin-bottom: 1rem;
}

/* Real word section — Glass Mini Card */
.td-example-card {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(13,148,136,0.07) 0%, rgba(59,130,246,0.05) 50%, rgba(139,92,246,0.04) 100%);
    border: 1.5px solid rgba(13,148,136,0.25);
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(13,148,136,0.1), inset 0 1px 0 rgba(255,255,255,0.6);
}
.td-rw-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 0.5rem; }
.td-rw-word { font-size: 2.5rem; font-weight: 700; color: var(--primary); }
.td-rw-pinyin { font-size: 1.1rem; color: var(--accent); }
.td-rw-meaning { font-size: 0.95rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Record section */
.td-record-section {
    margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--card-border);
}
.td-record-btns { display: flex; gap: 0.75rem; justify-content: center; }

/* Tone rule hint */
.td-rule-hint {
    margin-top: 1.5rem; padding: 0.6rem 1rem; border-radius: 10px;
    background: rgba(59,130,246,0.08); border: 1px solid rgba(59,130,246,0.2);
    font-size: 0.85rem; color: var(--text-main);
}

/* Tone rules panel */
.td-section { margin-top: 2rem; }
.td-section h3 { margin-bottom: 0.75rem; font-size: 1.1rem; }
.td-rules { display: flex; flex-direction: column; gap: 0.75rem; transition: all 0.3s; }
.td-rules.collapsed { display: none; }
.td-rule { padding: 1rem; }
.td-rule-name { font-weight: 700; color: var(--primary); font-size: 0.95rem; }
.td-rule-formula { font-weight: 700; font-size: 1.1rem; margin: 0.25rem 0 0.15rem; }
.td-rule-example { font-size: 0.85rem; color: var(--accent); margin-bottom: 0.35rem; }
.td-rule-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }

/* Tone concept accent highlighting */
.tone-hl {
    color: #0d9488;
    font-weight: 500;
}

/* Weekly suggestion */
.td-weekly { padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; font-size: 0.9rem; color: var(--text-muted); }

@media (max-width: 768px) {
    .td-grid-header, .td-grid-row { grid-template-columns: 35px repeat(4, 1fr); gap: 1px; }
    .td-cell { padding: 0.5rem 0.25rem; min-height: 55px; }
    .td-cell-pair { font-size: 0.75rem; }
    .td-drill-pinyin { font-size: 2.2rem; }
}

/* ═══════════════════════════════════════════════════ */
/* SENTENCE X-RAY STYLES                             */
/* ═══════════════════════════════════════════════════ */

.xray-card {
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    position: relative;
    margin-bottom: 1.5rem;
}

.xray-counter {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

.xray-target-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.2rem;
    background: var(--primary-bg);
    border: 2px solid var(--primary);
    border-radius: 30px;
    margin-bottom: 0.75rem;
    margin-left: auto;
    margin-right: auto;
}

.xray-english {
    font-size: 1.4rem;
    color: #1e5a8a;
    margin-bottom: 2rem;
    font-style: italic;
    background: #dbeafe;
    padding: 0.7rem 1.4rem;
    border-radius: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
}

.xray-words-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 1.5rem 1rem;
}

.xray-word {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    min-width: 60px;
    flex-shrink: 0;
    flex-grow: 0;
    transition: transform 0.15s;
}

.xray-word:hover {
    transform: scale(1.08);
}

.xray-word:active {
    transform: scale(0.95);
}

.xray-pinyin {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 500;
}

.xray-hanzi {
    font-size: 3.5rem;
    line-height: 1.2;
    color: var(--text-main);
    font-weight: 400;
    white-space: nowrap;
    width: max-content;
}

.xray-target .xray-hanzi {
    color: #F97316;
    font-weight: 700;
}

.xray-target .xray-pinyin {
    color: #F97316;
    font-weight: 700;
}

.xray-label {
    font-size: 0.85rem;
    color: white;
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
    line-height: 1.35;
}

.xray-note {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: linear-gradient(135deg, #0d948815, #0d948808);
    border: 1px solid #0d948830;
    border-radius: 14px;
    padding: 1rem 1.2rem;
    margin: 0.75rem 0;
    text-align: left;
}

.xray-note-rtl {
    direction: rtl;
    text-align: right;
}

.xray-note-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.xray-note-text {
    font-size: 0.88rem;
    color: var(--text-main);
    line-height: 1.6;
}

.xray-listen-row {
    margin-top: 1rem;
}

.xray-nav {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.xray-legend {
    padding: 1rem 1.5rem;
    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}

.xray-legend-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.xray-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.xray-legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .xray-hanzi { font-size: 2rem; }
    .xray-words-row { gap: 0.35rem; }
    .xray-word { min-width: 50px; gap: 0.6rem; }
    .xray-card { padding: 1.2rem; }
    .xray-label { font-size: 0.65rem; padding: 0.2rem 0.4rem; }
    .xray-search-bar { flex-direction: column; }
    .xray-search-btn { width: 100%; justify-content: center; }
    .xray-nav {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .xray-nav .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* ═══════════════════════════════════════════════════ */
/* BREAK IT DOWN PRO — AI SEARCH BAR                  */
/* ═══════════════════════════════════════════════════ */

.xray-search-container {
    margin-bottom: 1.5rem;
}

.xray-search-bar {
    display: flex;
    gap: 0.5rem;
    padding: 4px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(14,165,233,0.12));
    border: 2px solid rgba(139,92,246,0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.xray-search-bar:focus-within {
    border-color: rgba(139,92,246,0.5);
    box-shadow: 0 0 0 4px rgba(139,92,246,0.1), 0 8px 32px rgba(139,92,246,0.15);
    background: linear-gradient(135deg, rgba(139,92,246,0.15), rgba(14,165,233,0.15));
}

.xray-search-input {
    flex: 1;
    padding: 0.85rem 1.2rem;
    border: none;
    border-radius: 12px;
    background: var(--card-bg);
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 500;
    outline: none;
    font-family: inherit;
}

.xray-search-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.xray-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.xray-search-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(139,92,246,0.4);
}

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

.xray-key-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    border: 1px solid rgba(139,92,246,0.3);
    border-radius: 8px;
    background: rgba(139,92,246,0.08);
    color: #8b5cf6;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.xray-key-btn:hover {
    background: rgba(139,92,246,0.15);
    border-color: rgba(139,92,246,0.5);
}

/* Loading Spinner */
.xray-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(139,92,246,0.15);
    border-top: 4px solid #8b5cf6;
    border-radius: 50%;
    animation: xraySpinnerRotate 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes xraySpinnerRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* API Key Modal */
.xray-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 1.5rem;
    animation: modalFadeIn 0.2s ease;
}

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

.xray-modal {
    width: 100%;
    max-width: 440px;
    padding: 1.5rem;
    border-radius: 20px;
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

[data-theme="dark"] .xray-search-bar {
    background: linear-gradient(135deg, rgba(139,92,246,0.08), rgba(14,165,233,0.08));
    border-color: rgba(139,92,246,0.25);
}
