:root {
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.4);
    --bg-dark: #0b0b0b;
    --bg-panel: #141419;
    --bg-item: rgba(255, 255, 255, 0.03);
    --bg-item-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.2);
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --error: #ef4444;
    --success: #10b981;
    --font-serif: 'Playfair Display', serif;
    --font-sans: 'Inter', sans-serif;
    --sidebar-width: 300px;
    --header-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    /* Firefox scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Webkit Scrollbars (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2.5rem;
    flex-shrink: 0;
    backdrop-filter: blur(12px);
    z-index: 100;
    overflow-y: auto;
}

.main-content {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
}

/* Mobile Nav */
.mobile-header {
    display: none;
    height: var(--header-height);
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(12px);
}

.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    display: none;
    backdrop-filter: blur(4px);
}

.mobile-menu-overlay.active { display: block; }

.mobile-drawer {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100%;
    background: var(--bg-panel);
    z-index: 2001;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-drawer.active { left: 0; }

/* Sidebar Elements */
.logo-container { margin-bottom: 4rem; }
.logo-text { font-family: var(--font-serif); font-size: 2.5rem; font-weight: 700; font-style: italic; color: white; }

.nav-links { display: flex; flex-direction: column; gap: 0.75rem; }
.nav-item {
    padding: 1.25rem;
    border-radius: 16px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.nav-item:hover { background: var(--bg-item); color: white; }
.nav-item.active { background: var(--bg-item); border-color: var(--accent); color: white; box-shadow: 0 0 20px var(--accent-glow); }

/* XP Visuals */
.xp-container { padding: 1.25rem; background: rgba(255, 255, 255, 0.03); border-radius: 20px; margin-bottom: 3rem; }
.xp-bar-bg { height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: linear-gradient(90deg, #f59e0b, #fbbf24); width: 0%; transition: width 0.5s ease; }
.xp-text { font-size: 11px; font-weight: 800; color: #f59e0b; text-transform: uppercase; letter-spacing: 0.12em; }

/* Premium Animations */
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@keyframes pulse-success { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); } 70% { transform: scale(1.02); box-shadow: 0 0 0 15px rgba(16, 185, 129, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
@keyframes float-up { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes shimmer { 0% { background-position: -1000px 0; } 100% { background-position: 1000px 0; } }
@keyframes sparkle { 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(0); opacity: 0; } }

.shake { animation: shake 0.2s ease-in-out 0s 2; }
.pulse-success { animation: pulse-success 0.5s ease-out; }
.fade-in-up { animation: float-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

.shimmer {
    background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0) 100%);
    background-size: 1000px 100%;
    animation: shimmer 3s infinite linear;
}

.correct-glow { box-shadow: 0 0 40px rgba(16, 185, 129, 0.3) !important; border-color: #10b981 !important; }
.correct { background: #10b981 !important; border-color: #10b981 !important; color: black !important; box-shadow: 0 0 20px rgba(16, 185, 129, 0.4); }
.wrong { background: #ef4444 !important; border-color: #ef4444 !important; color: white !important; box-shadow: 0 0 20px rgba(239, 68, 68, 0.4); }

/* Empty State Styling */
.empty-library-state {
    padding: 3rem 2rem;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 24px;
    background: rgba(255,255,255,0.01);
}
.empty-library-icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-library-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }

/* Components */
.glass-panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 32px; padding: 3rem; backdrop-filter: blur(8px); }
.hero-card { 
    background: var(--bg-item); 
    border: 1px solid var(--border); 
    border-radius: 32px; 
    padding: 3rem; 
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    cursor: pointer; 
    text-align: center; 
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.hero-card:hover { border-color: var(--accent); background: var(--bg-item-hover); transform: translateY(-10px); box-shadow: 0 20px 40px rgba(0,0,0,0.6); }
.hero-card.selected { border-color: var(--accent); background: rgba(255, 255, 255, 0.1); box-shadow: 0 0 30px var(--accent-glow); transform: scale(1.02); }
.hero-card.selected::after { content: '✓'; position: absolute; top: 1rem; right: 1rem; width: 30px; height: 30px; background: var(--accent); color: black; border-radius: 50%; display: flex; items-center: center; justify-content: center; font-weight: 900; font-size: 0.8rem; }

.btn-primary { background: transparent; border: 2px solid var(--accent); color: var(--accent); padding: 1.25rem 3rem; border-radius: 18px; font-weight: 800; font-size: 1rem; letter-spacing: 0.15em; text-transform: uppercase; cursor: pointer; transition: all 0.3s; }
.btn-primary:hover:not(:disabled) { background: var(--accent); color: black; box-shadow: 0 0 30px var(--accent-glow); transform: translateY(-3px); }
.btn-outline { background: var(--bg-item); border: 1px solid var(--border); color: var(--text-muted); padding: 1.25rem 2rem; border-radius: 18px; font-weight: 700; cursor: pointer; transition: all 0.2s; position: relative; }
.btn-outline:hover { border-color: var(--border-hover); color: white; background: var(--bg-item-hover); }
.btn-outline.selected { border-color: var(--accent); background: var(--accent); color: black; box-shadow: 0 0 20px var(--accent-glow); }
.btn-outline.selected::after { content: '●'; position: absolute; top: 0.5rem; right: 0.75rem; font-size: 0.6rem; color: black; opacity: 0.5; }

.step-container { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }

.lang-font { font-family: 'Noto Sans JP', 'Noto Sans KR', sans-serif; display: block; }

/* Study Screens */
.screen-header { padding: 2rem 5rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); width: 100%; background: var(--bg-panel); }
.content-body { flex-grow: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; width: 100%; max-width: 1400px; margin: 0 auto; }
.quiz-container { width: 100%; max-width: 1100px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 2rem; }
.question-display { font-size: clamp(4rem, 15vh, 8rem); font-weight: 800; color: white; line-height: 1; margin: 0; }
.options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; width: 100%; }
.btn-option { 
    background: var(--bg-item); border: 1px solid var(--border); padding: clamp(1rem, 4vh, 2.5rem); border-radius: 24px; 
    font-size: clamp(1rem, 3vh, 1.75rem); font-weight: 800; color: white; cursor: pointer; transition: all 0.2s;
}
.btn-option:hover { border-color: var(--accent); background: var(--bg-item-hover); transform: translateY(-5px); }

/* Path Selection Layout */
.mode-cards-container {
    display: flex;
    flex-direction: row;
    gap: 2rem;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}

.mode-cards-container .hero-card {
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .mode-cards-container {
        flex-direction: column;
        gap: 1.5rem;
    }
}

/* Mode Cards */
.mode-card { background: var(--bg-item); border: 1px solid var(--border); padding: 2rem; border-radius: 24px; display: flex; align-items: center; gap: 1.5rem; cursor: pointer; transition: all 0.3s; width: 100%; }
.mode-card.selected { border-color: var(--accent); background: rgba(255,255,255,0.08); box-shadow: 0 0 25px var(--accent-glow); }
.mode-card-icon { width: 60px; height: 60px; background: rgba(255,255,255,0.05); border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 2rem; flex-shrink: 0; }
.mode-card-content { display: flex; flex-direction: column; text-align: left; }
.mode-card-title { font-weight: 800; font-size: 1.1rem; color: white; }
.mode-card-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.25rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); margin-left: auto; flex-shrink: 0; }
.mode-card.selected .status-dot { background: var(--accent); box-shadow: 0 0 10px var(--accent); }

/* Utilities */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.w-full { width: 100%; }
.h-auto { height: auto; }
.h-32 { height: 8rem; }
.hidden { display: none !important; }

/* Spacing Utilities */
.gap-10 { gap: 10px; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-6 > * + * { margin-top: 1.5rem; }
.space-y-8 > * + * { margin-top: 2rem; }
.space-y-10 > * + * { margin-top: 2.5rem; }
.space-y-12 > * + * { margin-top: 3rem; }
.space-y-16 > * + * { margin-top: 4rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-12 { margin-bottom: 3rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.pt-8 { padding-top: 2rem; }
.pt-12 { padding-top: 3rem; }

/* Text Utilities */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }
.text-4xl { font-size: 2.25rem; }
.text-5xl { font-size: 3rem; }
.text-6xl { font-size: 3.75rem; }
.text-7xl { font-size: 4.5rem; }
.text-8xl { font-size: 6rem; }
.text-9xl { font-size: 8rem; }

.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.font-medium { font-weight: 500; }
.italic { font-style: italic; }
.uppercase { text-transform: uppercase; }
.tracking-widest { letter-spacing: 0.2em; }
.tracking-tight { letter-spacing: -0.025em; }
.opacity-30 { opacity: 0.3; }
.opacity-40 { opacity: 0.4; }
.opacity-50 { opacity: 0.5; }
.opacity-60 { opacity: 0.6; }
.opacity-80 { opacity: 0.8; }

.serif-font { font-family: var(--font-serif); }

/* Grid Utilities */
.grid { display: grid; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-8 { gap: 2rem; }
.gap-12 { gap: 3rem; }
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (min-width: 768px) {
    .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
    .md\:flex-row { flex-direction: row; }
    .md\:gap-8 { gap: 2rem; }
    .md\:gap-6 { gap: 1.5rem; }
}

/* SRS Dots */
.mastery-dots { display: flex; gap: 5px; justify-content: center; margin-top: 1.5rem; }
.mastery-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.1); }
.mastery-dot.filled { background: var(--success); box-shadow: 0 0 8px var(--success); }

@media (max-width: 1024px) {
    .sidebar { display: none; }
    .mobile-header { display: flex; }
    .app-container { height: auto; min-height: 100vh; flex-direction: column; }
    .main-content { height: auto; min-height: calc(100vh - var(--header-height)); }
    .screen-header { padding: 1.5rem 1rem; flex-direction: column; gap: 1.5rem; }
    .content-body { padding: 2rem 1.5rem; }
    .question-display { font-size: clamp(4rem, 20vw, 7rem); }
}

@media (max-width: 640px) {
    .options-grid { grid-template-columns: 1fr; }
    .hero-card { padding: 1.5rem; border-radius: 24px; }
    .hero-card .text-6xl { font-size: 2.5rem; margin-bottom: 1rem; }
    .hero-card h3 { font-size: 1.25rem; }
    .logo-text { font-size: 1.75rem; }
    .btn-primary, .btn-outline { width: 100%; padding: 1.25rem 1.5rem; font-size: 0.9rem; }
    .text-6xl { font-size: 2.25rem; }
    .text-5xl { font-size: 1.75rem; }
    .text-8xl { font-size: 3rem; }
    .gap-8 { gap: 1rem; }
}

/* Ambient Orbs */
.ambient-light { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.2; animation: float 20s infinite ease-in-out; }
.orb-1 { top: -15%; left: -15%; width: 70vw; height: 70vw; background: radial-gradient(circle, var(--accent), transparent); }
.orb-2 { bottom: -15%; right: -15%; width: 80vw; height: 80vw; background: radial-gradient(circle, #2d3748, transparent); animation-delay: -10s; }

/* Particle */
.particle { position: absolute; pointer-events: none; width: 8px; height: 8px; border-radius: 50%; z-index: 100; }
