/* ==================== CSS Variables ==================== */
:root {
    --bg-base: #EBEBE6;
    --bg-card: #F5F5F2;
    --bg-hover: #E8E8E3;
    --text-primary: #2C2C2B;
    --text-secondary: #6B6B68;
    --text-muted: #9A9A95;
    --border-soft: #D1D1CB;
    --accent-green: #5E6D62;
    --accent-warm: #A67B7B;
    --accent-gold: #C9A961;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: 'Literata', 'Noto Serif SC', serif;
    line-height: 1.75;
    min-height: 100vh;
}

.container { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* ==================== Header ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 30px;
}

.logo { font-size: 24px; font-weight: 700; font-family: 'Crimson Pro', serif; }

.lang-switch {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid var(--border-soft);
}

.lang-option {
    padding: 8px 16px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    border: none;
    background: transparent;
}

.lang-option.active { background: var(--text-primary); color: var(--bg-base); }

/* ==================== Buttons ==================== */
.btn {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: system-ui, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary { background: var(--text-primary); color: var(--bg-base); }
.btn-primary:hover { background: var(--accent-green); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.15); }
.btn-secondary { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-soft); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-sm { padding: 7px 16px; font-size: 11px; border-radius: 7px; }

/* ==================== Mode Cards ==================== */
.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.mode-card {
    background: var(--bg-card);
    border: 2px solid var(--border-soft);
    border-radius: 16px;
    padding: 40px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.mode-card:hover { border-color: var(--accent-green); transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.08); }
.mode-icon { font-size: 56px; margin-bottom: 20px; }
.mode-title { font-size: 22px; font-weight: 700; margin-bottom: 12px; font-family: 'Crimson Pro', serif; }
.mode-desc { font-size: 15px; color: var(--text-secondary); line-height: 1.6; }

/* ==================== Learning Header ==================== */
.learning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: rgba(255,255,255,0.5);
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.level-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: var(--accent-green);
    color: white;
}

.time-estimate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(94,109,98,0.1);
    border-radius: 8px;
    font-size: 13px;
    color: var(--accent-green);
    font-weight: 600;
}

/* ==================== Stage Progress (Style D) ==================== */
.stage-progress {
    padding: 20px 32px 0;
    background: rgba(255,255,255,0.5);
    border-bottom: 1px solid var(--border-soft);
}

.stage-nodes {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    position: relative;
}

.stage-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    cursor: default;
}

.stage-node.clickable { cursor: pointer; }
.stage-node.clickable:hover .stage-circle { opacity: 0.8; }

.stage-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.3s;
    position: relative;
    z-index: 2;
}

.stage-circle.done { background: var(--accent-green); color: white; }
.stage-circle.active { background: var(--text-primary); color: white; box-shadow: 0 0 0 5px rgba(94,109,98,0.2); }
.stage-circle.locked { background: var(--border-soft); color: var(--text-muted); }

.stage-label {
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
    max-width: 52px;
    line-height: 1.2;
}

.stage-label.locked { color: var(--border-soft); }
.stage-label.active { color: var(--text-primary); font-weight: 600; }

.stage-bar-wrap {
    display: flex;
    align-items: center;
    margin: 0 14px 16px;
    gap: 0;
}

.stage-seg {
    flex: 1;
    height: 3px;
    background: var(--border-soft);
    transition: background 0.4s;
}

.stage-seg.done { background: var(--accent-green); }
.stage-seg.active { background: linear-gradient(to right, var(--accent-green) 50%, var(--border-soft)); }

.stage-current-card {
    background: var(--bg-card);
    border: 1.5px solid var(--text-primary);
    border-radius: 12px;
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 20px;
}

.stage-current-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0 0 3px; }
.stage-current-sub { font-size: 12px; color: var(--text-secondary); }

/* ==================== Content ==================== */
.learning-content { max-width: 1200px; margin: 0 auto; padding: 40px 20px; }

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 16px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

.section-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
    font-family: 'Crimson Pro', serif;
    color: var(--accent-green);
}

/* ==================== Stage Map (session overview) ==================== */
.stage-map { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

.stage-map-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    transition: all 0.2s;
}

.stage-map-item.completed { border-color: rgba(94,109,98,0.3); background: rgba(94,109,98,0.03); }
.stage-map-item.active { border: 1.5px solid var(--text-primary); cursor: pointer; }
.stage-map-item.active:hover { background: var(--bg-hover); }
.stage-map-item.locked { opacity: 0.4; }

.stage-map-num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

.stage-map-num.done { background: var(--accent-green); color: white; }
.stage-map-num.now { background: var(--text-primary); color: white; }
.stage-map-num.wait { background: var(--border-soft); color: var(--text-muted); }

.stage-map-body { flex: 1; }
.stage-map-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin: 0 0 2px; }
.stage-map-sub { font-size: 12px; color: var(--text-secondary); }

.stage-map-badge {
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 600;
    flex-shrink: 0;
}

.badge-done { background: rgba(94,109,98,0.12); color: var(--accent-green); }
.badge-active { background: var(--text-primary); color: var(--bg-base); }
.badge-locked { background: var(--border-soft); color: var(--text-muted); }

/* ==================== Forms ==================== */
textarea, input[type="text"], input[type="password"] {
    width: 100%;
    padding: 20px;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    font-family: inherit;
    font-size: 16px;
    line-height: 1.8;
    background: white;
    color: var(--text-primary);
    transition: all 0.3s;
    resize: vertical;
}

textarea:focus, input:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 4px rgba(94,109,98,0.08);
}

.input-label { display: block; font-size: 14px; font-weight: 600; color: var(--text-secondary); margin-bottom: 8px; }

/* ==================== Markdown ==================== */
.markdown-content { line-height: 1.9; color: var(--text-primary); }
.markdown-content h1 { font-size: 2rem; margin: 1.5rem 0 1rem; font-weight: 700; color: var(--accent-green); }
.markdown-content h2 { font-size: 1.75rem; margin: 1.5rem 0 1rem; font-weight: 700; color: var(--accent-green); }
.markdown-content h3 { font-size: 1.5rem; margin: 1.25rem 0 0.75rem; font-weight: 600; }
.markdown-content p { margin: 1rem 0; }
.markdown-content ul, .markdown-content ol { margin: 1rem 0; padding-left: 2rem; }
.markdown-content li { margin: 0.5rem 0; }
.markdown-content strong { font-weight: 600; color: var(--accent-green); }
.markdown-content em { font-style: italic; color: var(--text-secondary); }
.markdown-content code { background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; font-family: 'Courier New', monospace; font-size: 0.9em; }
.markdown-content hr { border: none; border-top: 2px solid var(--border-soft); margin: 2rem 0; }

/* ==================== Thematic Vocab Cards ==================== */
.thematic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-top: 8px; }

.thematic-card {
    background: white;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 18px 20px;
    border-left: 3px solid var(--accent-gold);
}

.thematic-word { font-family: 'Crimson Pro', serif; font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.thematic-pos { font-size: 11px; color: var(--text-muted); font-style: italic; margin-left: 4px; }
.thematic-meaning { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.thematic-example { font-size: 13px; color: var(--text-primary); font-style: italic; margin-bottom: 6px; padding: 8px 10px; background: var(--bg-base); border-radius: 6px; }
.thematic-other { font-size: 12px; color: var(--accent-green); font-style: italic; }
.thematic-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }

/* ==================== Cloze Interactive ==================== */
.cloze-exercise { margin: 20px 0; }

.cloze-question {
    margin: 12px 0;
    padding: 14px 18px;
    background: white;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    line-height: 2.4;
    font-size: 15px;
}

.cloze-input {
    display: inline-block;
    border: none;
    border-bottom: 2px solid var(--accent-gold);
    background: transparent;
    font-family: 'Crimson Pro', serif;
    font-size: 15px;
    color: var(--text-primary);
    padding: 0 4px;
    min-width: 80px;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    vertical-align: middle;
}

.cloze-input:focus { border-bottom-color: var(--accent-green); }
.cloze-input.correct { border-bottom-color: #10B981; color: #10B981; font-weight: 600; }
.cloze-input.wrong { border-bottom-color: var(--accent-warm); color: var(--accent-warm); }
.cloze-input.revealed { border-bottom-color: #6366f1; color: #6366f1; font-style: italic; }

.cloze-hint { font-size: 11px; color: var(--text-muted); margin-left: 6px; }
.cloze-att { font-size: 11px; color: var(--text-muted); display: inline-block; margin-left: 3px; vertical-align: middle; }

.exercise-section { margin: 28px 0; }
.exercise-section-title { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border-soft); }

.score-banner { padding: 14px 18px; border-radius: 12px; margin: 16px 0; font-weight: 600; text-align: center; font-size: 15px; }
.score-banner.good { background: rgba(16,185,129,0.1); color: #10B981; border: 1px solid rgba(16,185,129,0.3); }
.score-banner.ok { background: rgba(245,158,11,0.1); color: #F59E0B; border: 1px solid rgba(245,158,11,0.3); }
.score-banner.poor { background: rgba(166,123,123,0.1); color: var(--accent-warm); border: 1px solid rgba(166,123,123,0.3); }

/* ==================== Writing Guide ==================== */
.writing-guide { margin: 16px 0; border: 1px solid var(--accent-gold); border-radius: 12px; overflow: hidden; }

.writing-guide-header {
    padding: 12px 16px;
    background: rgba(201,169,97,0.1);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-gold);
    user-select: none;
}

.writing-guide-header:hover { background: rgba(201,169,97,0.15); }
.writing-guide-body { padding: 16px 20px; background: rgba(201,169,97,0.04); display: none; font-size: 14px; line-height: 1.8; color: var(--text-secondary); white-space: pre-wrap; }
.writing-guide-body.open { display: block; }
.writing-guide-arrow { transition: transform 0.2s; }
.writing-guide-arrow.open { transform: rotate(180deg); }

/* ==================== Report ==================== */
.report-card { margin-top: 20px; border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; }
.report-item { padding: 14px 18px; border-bottom: 1px solid var(--border-soft); display: flex; gap: 12px; align-items: flex-start; }
.report-item:last-child { border-bottom: none; }
.report-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.report-content { flex: 1; }
.report-word { font-weight: 700; font-family: 'Crimson Pro', serif; font-size: 15px; }
.report-reason { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }

/* ==================== Mindmap Placeholder ==================== */
.mindmap-placeholder {
    text-align: center;
    padding: 60px 20px;
    border: 2px dashed var(--border-soft);
    border-radius: 16px;
    margin: 20px 0;
}

.mindmap-placeholder .mp-icon { font-size: 48px; margin-bottom: 16px; }
.mindmap-placeholder .mp-title { font-size: 20px; font-weight: 700; font-family: 'Crimson Pro', serif; color: var(--text-secondary); margin-bottom: 8px; }
.mindmap-placeholder .mp-sub { font-size: 14px; color: var(--text-muted); }

/* ==================== Flashcard ==================== */
.flashcard-container { max-width: 600px; margin: 60px auto; }

.flashcard {
    background: white;
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    padding: 48px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.08);
    text-align: center;
}

.flashcard-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }

.flashcard-type {
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-hover);
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.flashcard-audio {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-soft);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.flashcard-audio:hover { border-color: var(--accent-green); background: rgba(94,109,98,0.1); }
.flashcard-meaning { font-size: 24px; color: var(--text-secondary); margin-bottom: 32px; font-style: italic; line-height: 1.6; }

.flashcard-input {
    width: 100%;
    padding: 20px;
    font-size: 20px;
    text-align: center;
    border: 2px solid var(--border-soft);
    border-radius: 12px;
    margin-bottom: 24px;
    font-family: 'Crimson Pro', serif;
}

.memory-buttons { display: flex; gap: 12px; justify-content: center; opacity: 0; transition: opacity 0.3s; margin-top: 24px; }
.memory-buttons.show { opacity: 1; }

.memory-btn { flex: 1; padding: 14px 20px; border-radius: 10px; border: 2px solid; background: white; cursor: pointer; transition: all 0.2s; font-weight: 600; font-size: 13px; }
.memory-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
.memory-btn.proficient { border-color: #10B981; color: #10B981; }
.memory-btn.proficient:hover { background: #10B981; color: white; }
.memory-btn.hesitant { border-color: #F59E0B; color: #F59E0B; }
.memory-btn.hesitant:hover { background: #F59E0B; color: white; }
.memory-btn.forgotten { border-color: var(--accent-warm); color: var(--accent-warm); }
.memory-btn.forgotten:hover { background: var(--accent-warm); color: white; }

/* ==================== Misc ==================== */
.spinner { width: 48px; height: 48px; border: 4px solid var(--border-soft); border-top-color: var(--text-primary); border-radius: 50%; animation: spin 1s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeInUp 0.5s cubic-bezier(0.4,0,0.2,1); }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.toast { position: fixed; bottom: 32px; right: 32px; background: var(--text-primary); color: var(--bg-base); padding: 14px 22px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 32px rgba(0,0,0,0.2); z-index: 1000; animation: slideIn 0.3s; }
@keyframes slideIn { from { transform: translateX(400px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.chunk-added-banner { margin-top: 16px; padding: 12px 16px; background: rgba(94,109,98,0.08); border-radius: 8px; font-size: 13px; color: var(--accent-green); }

.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-12 { gap: 12px; }

/* ==================== Invite Gate ==================== */
.invite-gate {
    max-width: 400px;
    margin: 100px auto;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 20px;
    padding: 48px 40px;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .mode-grid { grid-template-columns: 1fr; }
    .learning-header { flex-direction: column; gap: 16px; padding: 16px; }
    .content-card { padding: 24px; }
    .flashcard { padding: 32px 24px; }
    .stage-label { font-size: 8px; max-width: 40px; }
    .thematic-grid { grid-template-columns: 1fr; }
}
