:root {
    --bg-desk: #efeee5;
    --paper: #fffdfa;
    --red-ink: #d63031;
    --black-ink: #2d3436;
    --green-marker: #00b894;
    --blue-marker: #0984e3;
    --line-color: #b2bec3;
    --tape-color: rgba(255, 255, 255, 0.6);
    --gold: #f1c40f;
    --folder-tab: #dfe6e9;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    background-color: var(--bg-desk);
    background-image: radial-gradient(#d1d1d1 0.8px, transparent 0.8px);
    background-size: 20px 20px;
    font-family: 'Indie Flower', 'Noto Sans JP', cursive;
    margin: 0; padding: 0 0 100px 0;
    color: var(--black-ink);
}

/* --- HEADER & STATS --- */
.sticky-header {
    position: sticky; top: 0; z-index: 100;
    background: rgba(239, 238, 229, 0.95);
    backdrop-filter: blur(5px);
    padding: 10px 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-bottom: 1px dashed var(--line-color);
}
.stats-bar { display: flex; justify-content: center; gap: 20px; font-family: 'Permanent Marker'; font-size: 1rem; margin-bottom: 8px; }
.stat-item span { color: var(--gold); text-shadow: 1px 1px 0 rgba(0,0,0,0.2); }

/* --- CUSTOM SELECT (MODERN) --- */
.filter-area { display: flex; justify-content: center; gap: 10px; align-items: center; position: relative; }

.custom-select-wrapper {
    position: relative;
    width: 220px;
    font-family: 'Sawarabi Mincho', serif;
}

.custom-select {
    background: white; border: 2px solid var(--black-ink);
    border-radius: 8px; padding: 8px 12px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; transition: 0.2s;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}
.custom-select:active { transform: translateY(1px); box-shadow: none; }
.select-value { font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Dropdown Menu */
.custom-options {
    position: absolute; top: 110%; left: 0; right: 0;
    background: white; border: 2px solid var(--black-ink);
    border-radius: 8px; overflow: hidden;
    display: none; z-index: 200;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.1);
    animation: slideDown 0.2s ease;
}
.custom-options.open { display: block; }

.option { padding: 10px 12px; cursor: pointer; border-bottom: 1px dashed #eee; transition: 0.2s; }
.option:last-child { border-bottom: none; }
.option:hover { background: #f0f0f0; padding-left: 18px; }
.opt-tag {
    background: var(--black-ink); color: white; padding: 2px 6px;
    border-radius: 4px; font-size: 0.8rem; margin-right: 5px;
}

@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Filter Button */
.btn-icon { background: white; border: 2px solid var(--black-ink); border-radius: 8px; cursor: pointer; padding: 8px 12px; font-size: 1.2rem; box-shadow: 2px 2px 0 rgba(0,0,0,0.1); }
.btn-icon:active { transform: translateY(1px); box-shadow: none; }
.btn-icon.active { background: var(--red-ink); color: white; border-color: var(--red-ink); }


/* --- TREE LAYOUT --- */
.tree-container { max-width: 600px; margin: 0 auto; padding: 20px; position: relative; }
.tree-line {
    position: absolute; left: 30px; top: 0; bottom: 0;
    width: 4px; background: var(--line-color); z-index: 0; border-radius: 2px;
}

/* --- LESSON GROUP (ACCORDION STYLE) --- */
.lesson-group {
    position: relative; z-index: 2;
    margin-bottom: 25px;
}

/* Header Bab (Folder Tab Style) */
.lesson-header {
    background: var(--black-ink); color: white;
    padding: 10px 20px; border-radius: 8px;
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.2);
    font-family: 'Permanent Marker'; font-size: 1.1rem;
    position: relative; transition: 0.2s;
    margin-left: 10px; /* Space from line */
}
/* Connector Line to Tree */
.lesson-header::before {
    content: ''; position: absolute; left: -14px; top: 50%;
    width: 14px; height: 3px; background: var(--black-ink);
}

.lesson-header:hover { transform: translateX(5px); }
.lesson-header i { transition: transform 0.3s; }
.lesson-group.open .lesson-header i { transform: rotate(180deg); }

/* Lesson Content (Hidden by default) */
.lesson-content-wrapper {
    max-height: 0; overflow: hidden;
    transition: max-height 0.4s ease-out, opacity 0.3s;
    opacity: 0; padding-left: 15px; /* Indent grammar items */
}
.lesson-group.open .lesson-content-wrapper {
    max-height: 3000px; opacity: 1; margin-top: 15px;
}


/* --- GRAMMAR ITEM (NESTED) --- */
.tree-item { position: relative; margin-bottom: 15px; padding-left: 20px; }

/* Tree Node (Small Circle) */
.tree-node {
    position: absolute; left: -11px; top: 18px; width: 16px; height: 16px;
    background: white; border: 3px solid var(--line-color); border-radius: 50%; z-index: 2; transition: all 0.3s;
}
.tree-item.active .tree-node { border-color: var(--green-marker); background: var(--green-marker); transform: scale(1.2); }
.tree-item.done .tree-node { border-color: var(--red-ink); background: var(--red-ink); }

/* Grammar Accordion Header */
.accordion-header {
    background: white; padding: 12px 15px; border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.1); box-shadow: 2px 2px 0 rgba(0,0,0,0.05);
    cursor: pointer; position: relative; display: flex; justify-content: space-between; align-items: center;
    transition: transform 0.2s;
}
.accordion-header:hover { transform: translateX(3px); border-color: var(--green-marker); }
.pattern-title { font-family: 'Sawarabi Mincho'; font-size: 1rem; margin: 0; font-weight: bold; }

/* Grammar Content */
.accordion-content { 
    max-height: 0; opacity: 0; overflow: hidden; 
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s;
}
.tree-item.active .accordion-content { max-height: 2000px; opacity: 1; margin-top: 10px; }

.content-body {
    background: var(--paper); padding: 20px; border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.05); position: relative;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.02);
}

/* --- COMMON CONTENT STYLES --- */
.meaning { font-weight: bold; color: var(--red-ink); margin-bottom: 10px; font-size: 1.1rem; }
.usage-box { background: rgba(0, 184, 148, 0.1); padding: 10px; border-left: 3px solid var(--green-marker); font-size: 0.9rem; margin-bottom: 15px; }
.sticky-note {
    background: #fff385; padding: 10px; margin: 10px 0; transform: rotate(1deg);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.1); cursor: pointer; position: relative;
}
.sticky-note .jp { font-size: 1.1rem; font-weight: bold; margin: 0; }
.sticky-note .romaji { font-size: 0.8rem; color: #666; display: none; margin-top: 5px;}

/* Buttons & Inputs */
.footer-action { margin-top: 20px; border-top: 2px dashed #eee; padding-top: 15px; display: flex; flex-direction: column; gap: 8px; }
.btn { border: none; padding: 12px; font-family: 'Permanent Marker'; cursor: pointer; border-radius: 6px; box-shadow: 2px 3px 0 rgba(0,0,0,0.2); font-size: 1rem; width: 100%; }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn-action { background: var(--green-marker); color: white; }
.btn-secondary { background: var(--blue-marker); color: white; }
.btn-neutral { background: #636e72; color: white; }

.card-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 10px; }
.action-btn { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #b2bec3; padding: 0;}
.action-btn.active { color: var(--red-ink); }

/* Builder & Quiz */
.drop-zone { min-height: 60px; border: 2px dashed var(--black-ink); margin: 15px 0; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; padding: 10px; align-items: center; border-radius: 8px; background: rgba(255,255,255,0.5); }
.word-pill { background: white; border: 1px solid var(--black-ink); padding: 6px 10px; border-radius: 15px; cursor: pointer; font-family: 'Sawarabi Mincho'; font-size: 1rem; box-shadow: 1px 2px 0 rgba(0,0,0,0.1); }
.ai-input { width: 100%; height: 80px; padding: 10px; border: 2px solid var(--black-ink); border-radius: 5px; font-family: 'Sawarabi Mincho'; font-size: 1rem; resize: none; margin-bottom: 10px; }
.ai-result { background: white; border: 2px solid var(--blue-marker); padding: 15px; border-radius: 8px; margin-top: 15px; position: relative; }
.ai-score-badge { position: absolute; top: -12px; right: 10px; background: var(--blue-marker); color: white; padding: 4px 8px; border-radius: 12px; font-weight: bold; font-family: 'Permanent Marker'; font-size: 0.9rem;}

/* STAMP */
.hanko-stamp {
    width: 70px; height: 70px; border: 3px solid var(--red-ink); color: var(--red-ink);
    font-family: 'Sawarabi Mincho'; display: flex; align-items: center; justify-content: center;
    font-weight: bold; position: absolute; bottom: 15px; right: 15px; font-size: 1.1rem;
    transform: scale(2) rotate(-15deg); opacity: 0; pointer-events: none;
    transition: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); border-radius: 6px;
    background: rgba(255,255,255,0.9); z-index: 10;
}
.tree-item.passed .hanko-stamp { opacity: 1; transform: scale(1) rotate(-15deg); }

.floating-controls { position: fixed; bottom: 20px; right: 20px; z-index: 99; }
.btn-float { width: 50px; height: 50px; border-radius: 50%; border: none; background: #fdcb6e; font-weight: bold; box-shadow: 2px 5px 10px rgba(0,0,0,0.2); cursor: pointer; }

/* MOBILE OPTIMIZATION */
@media (max-width: 480px) {
    .custom-select-wrapper { width: 180px; }
    .lesson-header { font-size: 1rem; padding: 8px 15px; }
    .tree-line { left: 20px; }
}


/* ... css sebelumnya tetap sama ... */

/* --- WELCOME SCREEN --- */
.welcome-screen {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    border: 2px dashed var(--line-color);
    margin-top: 20px;
    position: relative; z-index: 5;
    animation: fadeIn 0.5s ease;
}

.welcome-icon { font-size: 4rem; margin-bottom: 10px; }
.welcome-content h2 {
    font-family: 'Permanent Marker'; font-size: 2.2rem;
    color: var(--red-ink); margin: 0 0 15px 0;
}
.welcome-content p {
    font-family: 'Sawarabi Mincho'; font-size: 1.1rem;
    margin: 5px 0; color: #555;
}

.arrow-hint {
    font-size: 3rem; margin-top: 30px;
    animation: bounce 1.5s infinite;
    opacity: 0.7;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

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

/* ... css lainnya tetap sama ... */
/* ... style sebelumnya ... */

/* --- SYNTAX HIGHLIGHTING (Kuromoji) --- */

/* 1. Grammar Pattern (Merah & Bold) - Prioritas Tertinggi */
.hl-grammar {
    color: #d63031;
    font-weight: bold;
    border-bottom: 2px solid rgba(214, 48, 49, 0.3);
    background: rgba(214, 48, 49, 0.05);
    padding: 0 2px;
    border-radius: 3px;
}

/* 2. Partikel (Biru) - は, が, を, に... */
.hl-particle {
    color: #0984e3; 
    font-weight: bold;
}

/* 3. Verba / Kata Kerja (Hijau) - 食べます, 行く... */
.hl-verb {
    color: #00b894;
    font-weight: bold;
}

/* 4. Adjektiva / Kata Sifat (Oranye) - 美しい, 高い... */
.hl-adj {
    color: #e67e22;
    font-weight: bold;
}

/* 5. Kata Benda / Lainnya (Hitam Standar) */
.hl-noun {
    color: #2d3436;
}

/* Sticky Note Typography Update */
.sticky-note .jp {
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 1.8; /* Jarak baris dilonggarkan agar highlight jelas */
    margin: 0;
}

/* ... style welcome screen sebelumnya ... */
/* ... CSS Lainnya Tetap Sama ... */

/* HAPUS BAGIAN LOADER KUROMOJI LAMA JIKA ADA */

/* --- Syntax Highlighting (Regex Version) --- */
.hl-grammar {
    color: #d63031;
    font-weight: bold;
    border-bottom: 2px solid rgba(214, 48, 49, 0.3);
    background: rgba(214, 48, 49, 0.05);
    padding: 0 2px;
    border-radius: 3px;
}

.hl-particle {
    color: #0984e3; 
    font-weight: bold;
}

/* --- Sticky Note Translation Style --- */
.sticky-note .jp {
    font-size: 1.3rem;
    font-weight: 500;
    line-height: 1.6;
    margin: 0;
}

.sticky-note .romaji {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}

/* Style Baru untuk Terjemahan */
.sticky-note .trans {
    font-size: 0.95rem;
    color: var(--black-ink);
    font-style: italic;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed rgba(0,0,0,0.1); /* Garis pemisah tipis */
    display: block; /* Selalu muncul */
}

/* ... CSS Lainnya Tetap Sama ... */

/* --- KUROMOJI LOADER --- */
.loader-area {
    margin-top: 20px;
    width: 100%;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.loader-text {
    font-family: 'Sawarabi Mincho';
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--black-ink);
    font-weight: bold;
}

.progress-track {
    width: 100%;
    height: 10px;
    background: #dfe6e9;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--black-ink);
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: var(--green-marker); /* Warna hijau marker */
    width: 0%;
    transition: width 0.3s ease-out;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255,255,255,0.3) 10px,
        rgba(255,255,255,0.3) 20px
    );
}

/* --- LOCKED STATE UNTUK DROPDOWN --- */
.custom-select-wrapper.locked {
    opacity: 0.6;
    pointer-events: none; /* Gak bisa diklik */
    filter: grayscale(100%);
}

.custom-select-wrapper.locked .custom-select {
    background: #eee;
    cursor: not-allowed;
}

/* ... (CSS sebelumnya tetap sama) ... */

/* --- NEW: PARTICLE QUIZ STYLES --- */
.blank-slot {
    display: inline-block;
    width: 60px;
    height: 40px;
    border-bottom: 3px solid var(--black-ink);
    margin: 0 5px;
    vertical-align: middle;
    text-align: center;
    font-weight: bold;
    color: var(--blue-marker);
    font-size: 1.2rem;
    cursor: pointer;
    background: rgba(0,0,0,0.05);
    border-radius: 4px;
    transition: 0.2s;
}

.blank-slot.filled {
    background: var(--paper);
    border: 2px solid var(--green-marker);
    color: var(--green-marker);
}

.blank-slot.active {
    background: #ffeaa7;
    border-color: #fdcb6e;
    transform: scale(1.1);
}

/* --- NEW: CONFETTI ANIMATION --- */
.confetti-piece {
    position: absolute;
    width: 10px; height: 10px;
    background: #ffd300;
    top: 0;
    opacity: 0;
}
@keyframes confettiDrop {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100px) rotate(720deg); opacity: 0; }
}

/* --- NEW: XP & LEVEL BAR --- */
.xp-container {
    display: flex; align-items: center; gap: 5px;
    background: rgba(0,0,0,0.1); padding: 5px 10px; border-radius: 15px;
}
.xp-bar-bg {
    width: 100px; height: 8px; background: #555; border-radius: 4px; overflow: hidden;
}
.xp-bar-fill {
    height: 100%; background: var(--gold); width: 0%; transition: width 0.5s ease;
}
