/* === Base Reset & Typography === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
    overflow-x: clip;  /* clip (not hidden) so position:sticky descendants still work */
}

/* === Layout === */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

/* === Navbar === */
.navbar {
    background: #1a1a2e;
    color: white;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}
.nav-brand {
    color: white;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 1px;
}
.nav-links a {
    color: #ccc;
    text-decoration: none;
    margin-left: 24px;
    font-size: .95rem;
    transition: color .2s;
}
.nav-links a:hover { color: white; }

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
    text-align: center;
}
.btn-primary { background: #2196F3; color: white; }
.btn-primary:hover { background: #1976D2; }
.btn-secondary { background: #607D8B; color: white; }
.btn-secondary:hover { background: #455A64; }
.btn-danger { background: #F44336; color: white; }
.btn-danger:hover { background: #D32F2F; }
.btn-large { padding: 14px 40px; font-size: 1.15rem; }
.btn-small { padding: 4px 12px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* === Home Hero === */
.home-hero {
    position: relative;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: white;
    padding: 60px 20px;
    text-align: center;
    overflow: hidden;
    margin: -20px -20px 0;
}
.hero-bg {
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Ctext x='10' y='40' font-size='30' opacity='.04' fill='white'%3E%E6%97%A5%3C/text%3E%3C/svg%3E");
    pointer-events: none;
}
.hero-content { position: relative; max-width: 700px; margin: 0 auto; }
.hero-badge {
    display: inline-block;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    padding: 4px 18px;
    border-radius: 20px;
    font-size: .85rem;
    letter-spacing: 2px;
    margin-bottom: 16px;
}
.home-hero h1 {
    font-size: 2.2rem;
    line-height: 1.3;
    margin-bottom: 16px;
}
.hero-mn { color: #93c5fd; font-size: 1.6rem; }
.hero-sub { color: rgba(255,255,255,.7); font-size: 1rem; line-height: 1.6; max-width: 500px; margin: 0 auto 24px; }
.hero-sub strong { color: #fbbf24; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-hero-primary {
    background: #3b82f6;
    color: white;
    padding: 14px 36px;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 700;
    text-decoration: none;
    transition: background .2s, transform .1s;
}
.btn-hero-primary:hover { background: #2563eb; transform: translateY(-1px); }
.btn-hero-outline {
    background: transparent;
    color: white;
    padding: 14px 36px;
    border: 2px solid rgba(255,255,255,.3);
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    text-decoration: none;
    transition: all .2s;
}
.btn-hero-outline:hover { border-color: white; background: rgba(255,255,255,.1); }

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    margin: -30px auto 30px;
    max-width: 700px;
    position: relative;
    z-index: 10;
    overflow: hidden;
}
.stat-item {
    flex: 1;
    text-align: center;
    padding: 20px 10px;
    border-right: 1px solid #f0f0f0;
}
.stat-item:last-child { border-right: none; }
.stat-num { font-size: 1.6rem; font-weight: 900; color: #1a1a2e; }
.stat-label { font-size: .75rem; color: #999; margin-top: 2px; }

/* Features */
.features-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 30px 0;
}
.feature-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
    transition: transform .2s;
}
.feature-card:hover { transform: translateY(-3px); }
.feature-icon { font-size: 2rem; margin-bottom: 10px; }
.feature-card h3 { font-size: 1rem; color: #1a1a2e; margin-bottom: 6px; }
.feature-card p { font-size: .85rem; color: #666; line-height: 1.5; }

/* Section Title */
.section-title { text-align: center; margin: 40px 0 20px; }
.section-title h2 { font-size: 1.5rem; color: #1a1a2e; }
.section-title p { color: #999; font-size: .95rem; }

/* === New Level Cards === */
.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    padding: 0 0 30px;
}
.level-card-new {
    background: white;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.level-card-new:hover { transform: translateY(-5px); box-shadow: 0 8px 30px rgba(0,0,0,.14); }
.lc-top {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
}
.lc-kanji { font-size: 2.5rem; opacity: .5; font-weight: 900; }
.lc-name { font-size: 2rem; font-weight: 900; letter-spacing: 2px; }
.lc-body { padding: 18px; }
.lc-body h3 { font-size: 1.05rem; color: #333; margin-bottom: 10px; }
.lc-meta {
    display: flex;
    justify-content: space-between;
    font-size: .85rem;
    color: #888;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}
.lc-sections { margin-bottom: 12px; }
.lc-sec {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: .85rem;
    color: #555;
}
.lc-sec span { color: #999; }
.lc-best {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: .85rem;
}
.lc-best-score { font-weight: 700; font-size: 1rem; }
.lc-best-score.good { color: #22c55e; }
.lc-best-score.low { color: #f59e0b; }
.lc-new { color: #3b82f6; font-size: .8rem; justify-content: center; background: #eff6ff; }
.lc-btn {
    text-align: center;
    padding: 12px;
    color: white;
    border-radius: 8px;
    font-weight: 700;
    font-size: .95rem;
    letter-spacing: .5px;
}

/* Recent Activity */
.recent-section { margin-bottom: 30px; }
.recent-tests { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: white;
    border-radius: 10px;
    padding: 12px 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
    cursor: pointer;
    transition: background .15s;
}
.recent-item:hover { background: #f8fafc; }
.ri-level {
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}
.ri-info { flex: 1; }
.ri-section { font-weight: 600; font-size: .95rem; }
.ri-date { font-size: .8rem; color: #999; }
.ri-score { font-size: 1.2rem; font-weight: 900; }
.ri-score.passed { color: #22c55e; }
.ri-score.failed { color: #ef4444; }
.ri-result { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 10px; }
.ri-result.passed { background: #dcfce7; color: #166534; }
.ri-result.failed { background: #fee2e2; color: #991b1b; }

/* === Test Selection === */
.page-header { text-align: center; padding: 30px 0; }
.page-header h1 { font-size: 2rem; }
.test-options { max-width: 900px; margin: 0 auto; }
.test-option-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    text-align: center;
}
.test-option-card.full-test { border: 2px solid #2196F3; }
.test-option-card.mock-test { border: 2px solid #e74c3c; background: #fef2f2; }
.mock-badge {
    display: inline-block;
    background: #e74c3c;
    color: white;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 1px;
}
.sections-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.q-count { color: #999; font-size: .9rem; }
.practice-btns { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* Section Headers */
.section-header-bar { margin-bottom: 16px; }
.section-header-bar h2 { font-size: 1.4rem; color: #1a1a2e; margin-bottom: 4px; }
.section-header-bar p { color: #888; font-size: .9rem; }
.section-practice-section { margin-top: 40px; }
.empty-text { text-align: center; color: #999; padding: 30px; }
.loading-text { text-align: center; color: #999; padding: 20px; }

/* Mock Exam Cards */
.mock-exams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.mock-exam-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    border: 2px solid transparent;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.mock-exam-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.mock-exam-card.completed { border-color: #d1d5db; }

.me-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.me-number { font-size: 1.1rem; font-weight: 800; color: #1a1a2e; }
.me-total {
    background: #1a1a2e;
    color: white;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 700;
}

.me-sections { margin-bottom: 14px; }
.me-sec {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: .85rem;
}
.me-sec-name { color: #555; }
.me-sec-count { color: #888; font-weight: 600; }

.me-score {
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.me-score.passed { background: #dcfce7; }
.me-score.failed { background: #fee2e2; }
.me-score-num { font-size: 1.4rem; font-weight: 900; display: block; }
.me-score.passed .me-score-num { color: #16a34a; }
.me-score.failed .me-score-num { color: #dc2626; }
.me-score-label { font-size: .75rem; font-weight: 700; letter-spacing: 1px; }
.me-score.passed .me-score-label { color: #166534; }
.me-score.failed .me-score-label { color: #991b1b; }

.me-btn { width: 100%; font-weight: 700; }

/* Exam Structure Preview */
.exam-structure { text-align: left; margin: 20px 0; }
.structure-section { margin-bottom: 16px; }
.structure-section-title {
    background: #34495e;
    color: white;
    padding: 8px 14px;
    border-radius: 6px 6px 0 0;
    font-size: .9rem;
    font-weight: 600;
}
.structure-table { border: 1px solid #e0e0e0; border-top: none; border-radius: 0 0 6px 6px; overflow: hidden; }
.structure-row {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid #f0f0f0;
    font-size: .9rem;
}
.structure-row:last-child { border-bottom: none; }
.structure-row.incomplete { background: #fff7ed; }
.s-mondai {
    font-weight: 700;
    color: #2c3e50;
    min-width: 55px;
}
.s-type { flex: 1; color: #555; }
.s-count {
    font-weight: 600;
    color: #16a34a;
    min-width: 60px;
    text-align: right;
}
.structure-row.incomplete .s-count { color: #ea580c; }

/* === Exam Page (dethitiengnhat-inspired modern) === */
.exam-page { max-width: 900px; margin: 0 auto; }

/* Submit / score button (in the sticky exam bar) */
.exam-score-btn {
    background: #22c55e;
    color: white;
    border: none;
    padding: 9px 22px;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, transform .08s;
}
.exam-score-btn:hover { background: #16a34a; }
.exam-score-btn:active { transform: translateY(1px); }

/* Sticky exam bar (title · timer · progress + submit) */
.exam-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 10px 16px;
    position: sticky;
    top: 64px;            /* below the 56px sticky navbar + a little gap */
    z-index: 90;
    border-radius: 14px;
    margin: 8px 0 18px;
    box-shadow: 0 4px 18px rgba(17,24,39,.08);
}
[data-theme="dark"] .exam-bar { background: var(--surface); border-color: var(--border); }
.exam-title { font-weight: 700; font-size: .95rem; color: var(--text-dim); white-space: nowrap; }
/* Beautiful timer pill */
.exam-timer-box {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, #111827, #1f2937);
    color: #34d399;
    padding: 8px 18px; border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 2px 8px rgba(0,0,0,.15);
}
.timer-icon { color: currentColor; opacity: .85; flex-shrink: 0; }
.timer-display {
    font-size: 1.35rem; font-weight: 700; letter-spacing: 1px;
    font-family: 'SF Mono','Roboto Mono','Courier New',monospace;
    font-variant-numeric: tabular-nums; color: currentColor;
}
.exam-timer-box.warn { color: #fbbf24; }
.exam-timer-box.danger { color: #f87171; animation: pulse-timer 1s infinite; }
.timer-display.timer-warning { color: #fbbf24; }   /* legacy hook (JS adds to span) */
.timer-display.timer-danger { color: #f87171; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .5; } }
@keyframes pulse-timer { 50% { box-shadow: 0 0 0 4px rgba(248,113,113,.25); } }
.exam-bar-right { display: flex; align-items: center; gap: 12px; }
.exam-progress-text { font-weight: 700; color: var(--text); font-size: .95rem; white-space: nowrap; }
.exam-progress-text { font-size: .85rem; color: #94a3b8; }

/* 問題 header (dethitiengnhat big_item style) */
.dttn { background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.big_item {
    background: #f3f4f6;
    color: #6b7280;
    padding: 10px 16px;
    font-size: .95rem;
    line-height: 1.6;
    border-bottom: 1px solid #e5e7eb;
}
.big_item strong { color: #4b5563; }
[data-theme="dark"] .big_item { background: #232734; color: #9ca3af; border-bottom-color: #2c313d; }
[data-theme="dark"] .big_item strong { color: #cbd5e1; }

/* Question text row (alternating colors like dethitiengnhat) */
.question_list {
    background: #f1f5f9;
    padding: 10px 16px;
    font-size: 1rem;
    line-height: 1.8;
    border-left: 3px solid #6366f1;
}
.question_list:nth-child(odd) { background: #f8fafc; }
.q-num-inline { font-weight: 700; color: #4338ca; }

/* Reading context */
.question_context {
    background: #fefce8;
    padding: 12px 16px;
    border-left: 3px solid #eab308;
    line-height: 1.8;
    font-size: .95rem;
}

/* Answer rows (2x2 grid radio buttons) */
.answer_2row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    padding: 8px 16px;
}
.answer_1row {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 8px 16px;
}
.answer_2row .container, .answer_1row .container {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    cursor: pointer;
    border-radius: 6px;
    transition: background .15s;
    position: relative;
}
.answer_2row .container:hover, .answer_1row .container:hover { background: #eff6ff; }
.answer_2row .container.selected, .answer_1row .container.selected {
    background: #dbeafe;
    outline: 2px solid #3b82f6;
}
.answer_2row .container.answer-correct, .answer_1row .container.answer-correct {
    background: #dcfce7;
    outline: 2px solid #22c55e;
}
.answer_2row .container.answer-wrong, .answer_1row .container.answer-wrong {
    background: #fee2e2;
    outline: 2px solid #ef4444;
}
.answers { font-size: .95rem; line-height: 1.5; }

/* Custom radio */
.container input[type="radio"] { position: absolute; opacity: 0; cursor: pointer; }
.checkmark {
    width: 18px; height: 18px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.container.selected .checkmark {
    border-color: #3b82f6;
    background: #3b82f6;
}
.container.selected .checkmark::after {
    content: '';
    width: 6px; height: 6px;
    background: white;
    border-radius: 50%;
}
.container.answer-correct .checkmark { border-color: #22c55e; background: #22c55e; }
.container.answer-correct .checkmark::after { content: ''; width: 6px; height: 6px; background: white; border-radius: 50%; }
.container.answer-wrong .checkmark { border-color: #ef4444; background: #ef4444; }
.container.answer-wrong .checkmark::after { content: ''; width: 6px; height: 6px; background: white; border-radius: 50%; }

.question_sep { height: 1px; background: #e2e8f0; }

/* Audio Player */
.q-audio-player {
    background: #1e293b;
    padding: 10px 16px;
}
.audio-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.audio-btn { padding: 6px 14px; border: none; border-radius: 5px; cursor: pointer; font-size: .85rem; font-weight: 600; }
.audio-play { background: #22c55e; color: white; }
.audio-play:hover { background: #16a34a; }
.audio-pause { background: #f59e0b; color: white; }
.audio-replay { background: #3b82f6; color: white; }
.audio-replay:disabled { cursor: not-allowed; }
.audio-progress-bar { flex: 1; min-width: 80px; height: 5px; background: #475569; border-radius: 3px; overflow: hidden; }
.audio-progress { height: 100%; width: 0%; background: #22c55e; border-radius: 3px; transition: width .2s; }

/* Result Modal (Kết Quả style) */
.result-modal-bg {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}
.result-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.result-modal-header {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    padding: 14px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.result-close {
    background: none; border: none; color: white;
    font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.result-modal-body { padding: 20px; }
.rm-row {
    display: flex; justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: .95rem;
}
.rm-row.rm-correct { background: #f0fdf4; margin: 0 -20px; padding: 10px 20px; }
.rm-row.rm-wrong { background: #fef2f2; margin: 0 -20px; padding: 10px 20px; }
.rm-row.rm-total { font-size: 1.1rem; font-weight: 700; border-bottom: none; }
.rm-pass { color: #16a34a; }
.rm-fail { color: #dc2626; }
.rm-divider { height: 2px; background: #e5e7eb; margin: 8px 0; }
.rm-result {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 3px;
    padding: 14px;
    margin: 0 -20px;
}
.rm-result.rm-pass { background: #dcfce7; color: #166534; }
.rm-result.rm-fail { background: #fee2e2; color: #991b1b; }
.result-modal-footer {
    padding: 16px 20px;
    display: flex; gap: 10px; justify-content: center;
    border-top: 1px solid #f0f0f0;
}

/* === Mondai Breakdown === */
.mondai-breakdown { max-width: 700px; margin: 30px auto; }
.mondai-breakdown h2 { text-align: center; margin-bottom: 20px; font-size: 1.2rem; }
.breakdown-section { margin-bottom: 20px; }
.breakdown-section-title {
    background: #34495e;
    color: white;
    padding: 8px 14px;
    border-radius: 6px 6px 0 0;
    font-size: .9rem;
    font-weight: 600;
}
.breakdown-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: white;
    border: 1px solid #eee;
    border-top: none;
}
.breakdown-row:last-child { border-radius: 0 0 6px 6px; }
.bd-label { min-width: 160px; display: flex; gap: 8px; align-items: center; }
.bd-mondai { font-weight: 700; color: #2c3e50; font-size: .85rem; min-width: 45px; }
.bd-type { font-size: .85rem; color: #666; }
.bd-bar-wrap {
    flex: 1;
    height: 10px;
    background: #e5e7eb;
    border-radius: 5px;
    overflow: hidden;
}
.bd-bar { height: 100%; border-radius: 5px; transition: width .5s; }
.bd-bar.bar-good { background: #22c55e; }
.bd-bar.bar-ok { background: #f59e0b; }
.bd-bar.bar-bad { background: #ef4444; }
.bd-score { min-width: 80px; text-align: right; font-weight: 600; font-size: .9rem; }
.bd-pct { color: #999; font-weight: normal; font-size: .8rem; }

/* === Results === */
.results-header { text-align: center; padding: 30px 0; }
.score-circle {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    border: 6px solid;
}
.score-circle.passed { border-color: #4CAF50; color: #4CAF50; }
.score-circle.failed { border-color: #F44336; color: #F44336; }
.score-number { font-size: 2.5rem; font-weight: bold; }
.score-label { font-size: 1rem; text-transform: uppercase; letter-spacing: 2px; }

.results-stats { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin: 20px 0; }
.stat-card {
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    min-width: 150px;
}
.stat-card h3 { font-size: .85rem; color: #999; margin-bottom: 6px; }
.stat-card p { font-size: 1.3rem; font-weight: bold; }

.results-actions { text-align: center; margin-top: 30px; display: flex; gap: 12px; justify-content: center; }

/* === Review === */
.review-container { max-width: 900px; margin: 0 auto; }
.review-item {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border-left: 5px solid;
}
.review-item.correct { border-left-color: #4CAF50; }
.review-item.incorrect { border-left-color: #F44336; }
.review-header { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.review-num { font-weight: bold; }
.review-type { font-size: .85rem; color: #666; background: #f0f0f0; padding: 2px 10px; border-radius: 10px; }
.review-result { margin-left: auto; font-weight: bold; }
.review-item.correct .review-result { color: #4CAF50; }
.review-item.incorrect .review-result { color: #F44336; }
.review-context { background: #FFF8E1; padding: 12px; border-radius: 6px; margin-bottom: 10px; font-size: .95rem; }
.review-question { font-size: 1.05rem; margin-bottom: 12px; line-height: 1.6; }
.review-option { padding: 8px 12px; margin: 4px 0; border-radius: 6px; }
.review-option.correct-answer { background: #E8F5E9; }
.review-option.wrong-answer { background: #FFEBEE; }
.review-explanation { background: #E3F2FD; padding: 12px; border-radius: 6px; margin-top: 10px; font-size: .9rem; }

/* === History Table === */
.data-table { width: 100%; border-collapse: collapse; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.data-table th { background: #f8f8f8; padding: 12px; text-align: left; font-size: .85rem; color: #666; border-bottom: 2px solid #eee; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; font-size: .95rem; }
.level-tag { padding: 2px 10px; border-radius: 10px; color: white; font-size: .8rem; font-weight: bold; }
.level-tag.n5 { background: #4CAF50; } .level-tag.n4 { background: #2196F3; }
.level-tag.n3 { background: #FF9800; } .level-tag.n2 { background: #9C27B0; }
.level-tag.n1 { background: #F44336; }
.result-tag { padding: 2px 12px; border-radius: 10px; font-size: .8rem; font-weight: bold; }
.result-tag.passed { background: #E8F5E9; color: #2E7D32; }
.result-tag.failed { background: #FFEBEE; color: #C62828; }

/* === Admin === */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 30px; }
.stat-total { font-size: 1.5rem; font-weight: bold; color: #2196F3; }
.admin-section { background: white; padding: 24px; border-radius: 10px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.admin-section h2 { margin-bottom: 16px; }
.admin-form .form-row { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.admin-form .form-group { margin-bottom: 12px; }
.admin-form label { display: block; margin-bottom: 4px; font-size: .9rem; color: #666; }
.admin-form input, .admin-form select, .admin-form textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: .95rem;
    flex: 1;
    min-width: 150px;
}
.admin-form textarea { width: 100%; }
.pagination { text-align: center; padding: 16px; }

/* ======================================================
   RESPONSIVE - Tablet (768px - 1024px)
   ====================================================== */
@media (max-width: 1024px) {
    .container { padding: 16px; }
    .levels-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
    .level-card { padding: 24px; }
    .exam-page { max-width: 100%; padding: 0 8px; }
    .exam-top-bar { padding: 10px 16px; }
    .review-container { max-width: 100%; padding: 0 8px; }

    /* Admin form */
    .admin-form .form-row { flex-direction: column; }
    .admin-form input, .admin-form select { min-width: 100%; }
}

/* ======================================================
   RESPONSIVE - Mobile (max 640px)
   ====================================================== */
@media (max-width: 640px) {
    /* --- Navbar --- */
    .nav-container { height: 48px; }
    .nav-brand { font-size: 1.1rem; }
    .nav-links a { margin-left: 14px; font-size: .85rem; }

    /* --- Home Hero --- */
    .home-hero { padding: 40px 16px; margin: -16px -16px 0; }
    .home-hero h1 { font-size: 1.5rem; }
    .hero-mn { font-size: 1.15rem; }
    .hero-sub { font-size: .9rem; }
    .btn-hero-primary, .btn-hero-outline { padding: 12px 24px; font-size: .95rem; }
    .stats-bar { margin: -24px 8px 20px; }
    .stat-num { font-size: 1.2rem; }
    .stat-label { font-size: .65rem; }
    .features-section { grid-template-columns: 1fr 1fr; gap: 10px; }
    .feature-card { padding: 16px; }
    .feature-icon { font-size: 1.5rem; }
    .feature-card h3 { font-size: .9rem; }
    .feature-card p { font-size: .8rem; }

    /* --- Level Cards --- */
    .levels-grid { grid-template-columns: 1fr; gap: 14px; padding: 10px 0; }
    .lc-top { padding: 14px; }
    .lc-kanji { font-size: 1.8rem; }
    .lc-name { font-size: 1.5rem; }
    .lc-body { padding: 14px; }
    .recent-item { padding: 10px 12px; gap: 10px; }
    .ri-score { font-size: 1rem; }

    /* --- Test Selection --- */
    .page-header { padding: 20px 0; }
    .page-header h1 { font-size: 1.4rem; }
    .test-option-card { padding: 20px; }
    .sections-grid { grid-template-columns: 1fr; }

    /* --- Exam --- */
    .exam-bar { top: 56px; padding: 8px 10px; border-radius: 0; gap: 8px; flex-wrap: wrap; margin: 0 -8px 14px; }
    .exam-title { display: none; }   /* save space on mobile */
    .exam-timer-box { padding: 6px 14px; }
    .exam-score-btn { padding: 8px 16px; font-size: .85rem; }
    .timer-display { font-size: 1.15rem; }
    .big_item { font-size: .85rem; padding: 8px 12px; }
    .question_list { font-size: .9rem; padding: 8px 12px; }
    .question_context { font-size: .85rem; padding: 8px 12px; }
    .answer_2row { grid-template-columns: 1fr; padding: 6px 10px; }
    .answer_2row .container, .answer_1row .container { padding: 8px 10px; }
    .answers { font-size: .85rem; }
    }
    .audio-btn { padding: 5px 10px; font-size: .75rem; }
    .result-modal { max-width: 95%; }
    .result-modal-footer { flex-direction: column; }
    .result-modal-footer .btn { width: 100%; }

    /* --- Results --- */
    .score-circle { width: 140px; height: 140px; }
    .score-number { font-size: 2rem; }
    .results-stats { flex-direction: column; align-items: center; }
    .stat-card { min-width: 100%; }
    .results-actions { flex-direction: column; align-items: center; }
    .results-actions .btn { width: 100%; }

    /* --- Review --- */
    .review-item { padding: 14px; }
    .review-header { flex-wrap: wrap; gap: 6px; }
    .review-result { margin-left: 0; }
    .review-options .review-option { font-size: .9rem; }

    /* --- History Table --- */
    .data-table { font-size: .8rem; }
    .data-table th, .data-table td { padding: 8px 6px; }
    /* Hide less important columns on mobile */
    .data-table th:nth-child(5),
    .data-table td:nth-child(5) { display: none; }

    /* --- Admin --- */
    .admin-stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
    .admin-section { padding: 16px; }
    .admin-form .form-row { flex-direction: column; gap: 8px; }
    .admin-form input, .admin-form select, .admin-form textarea {
        min-width: 100%;
        font-size: .9rem;
    }
    /* Admin table scroll */
    #questions-table { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ======================================================
   RESPONSIVE - Small Mobile (max 480px)
   ====================================================== */
@media (max-width: 480px) {
    .nav-container { padding: 0 8px; }
    .nav-brand { font-size: .95rem; }
    .nav-links a { margin-left: 10px; font-size: .8rem; }

    .hero h1 { font-size: 1.3rem; }
    .hero p { font-size: .9rem; }

    .level-card { padding: 16px; }
    .level-badge { font-size: 1rem; padding: 4px 14px; }
    .level-card h2 { font-size: 1rem; }
    .level-info li { font-size: .8rem; }

    .exam-top-bar { padding: 8px 10px; }
    .timer-display { font-size: 1.1rem; }
    .btn-submit-exam { font-size: .8rem; padding: 6px 10px; }

    .mondai-header { font-size: .85rem; }
    .q-text { font-size: .9rem; }
    .q-option { padding: 8px 10px; font-size: .85rem; }
    .opt-num { width: 20px; height: 20px; font-size: .75rem; }

    .audio-btn { padding: 5px 8px; font-size: .75rem; }

    .score-modal { padding: 18px; border-radius: 12px; }
    .score-big { font-size: 2.5rem; }

    .test-option-card { padding: 14px; }
    .btn-large { padding: 12px 24px; font-size: 1rem; }
}

/* ======================================================
   RESPONSIVE - Large Desktop (1400px+)
   ====================================================== */
@media (min-width: 1400px) {
    .container { max-width: 1400px; }
    .levels-grid { grid-template-columns: repeat(5, 1fr); }
    .exam-page { max-width: 1000px; }
}

/* ======================================================
   v2: THEME TOKENS + DARK MODE + AUTH/SRS COMPONENTS
   ====================================================== */
:root {
    --bg: #ffffff;
    --surface: #f7f8fa;
    --surface-2: #f0f1f4;
    --text: #111827;
    --text-dim: #6b7280;
    --border: #ececf1;
    --primary: #4f46e5;
    --primary-d: #4338ca;
    --nav-bg: #ffffff;
    --shadow: 0 1px 3px rgba(17,24,39,.06), 0 8px 24px rgba(17,24,39,.05);
    --radius: 16px;
}
[data-theme="dark"] {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #232734;
    --text: #e5e7eb;
    --text-dim: #9ca3af;
    --border: #2c313d;
    --nav-bg: #141621;
    --shadow: 0 2px 14px rgba(0,0,0,.4);
}
[data-theme="dark"] body { background: var(--bg); color: var(--text); }
[data-theme="dark"] .navbar { background: var(--nav-bg); }
/* Card / surface remap for dark */
[data-theme="dark"] .dttn,
[data-theme="dark"] .feature-card,
[data-theme="dark"] .stat-card,
[data-theme="dark"] .stats-bar,
[data-theme="dark"] .level-card-new,
[data-theme="dark"] .mock-exam-card,
[data-theme="dark"] .test-option-card,
[data-theme="dark"] .recent-item,
[data-theme="dark"] .review-item,
[data-theme="dark"] .result-modal,
[data-theme="dark"] .admin-section,
[data-theme="dark"] .data-table,
[data-theme="dark"] .me-sections,
[data-theme="dark"] .me-header,
[data-theme="dark"] .page-header,
[data-theme="dark"] .results-header,
[data-theme="dark"] .section-practice-section,
[data-theme="dark"] .section-header-bar {
    background: var(--surface) !important;
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] .answers {
    background: var(--surface-2) !important;
    color: var(--text);
    border-color: var(--border) !important;
}
[data-theme="dark"] .answers:hover { background: #2b3142 !important; }
/* Mock-exam + exam text contrast fixes for dark */
[data-theme="dark"] .me-number { color: var(--text); }
[data-theme="dark"] .me-sec-name { color: var(--text-dim); }
[data-theme="dark"] .me-sec { border-color: var(--border); }
[data-theme="dark"] .me-total { background: var(--primary); }
[data-theme="dark"] .q-num-inline { color: var(--text-dim); }
[data-theme="dark"] #questions-container { color: var(--text); }
[data-theme="dark"] .dttn .answers { color: var(--text) !important; }
[data-theme="dark"] .data-table th { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .data-table td { border-color: var(--border); color: var(--text); }
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}
[data-theme="dark"] h1,[data-theme="dark"] h2,[data-theme="dark"] h3 { color: var(--text); }

/* ---- Navbar additions ---- */
.nav-right { display: flex; align-items: center; gap: 14px; }
.nav-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: 999px; font-size: .85rem;
    font-weight: 600; text-decoration: none; transition: all .2s;
}
.nav-chip-streak { background: rgba(245,158,11,.18); color: #fbbf24; }
.nav-chip-due { background: rgba(59,130,246,.2); color: #93c5fd; }
.nav-chip-due:hover { background: rgba(59,130,246,.35); }
.nav-chip .dot {
    background: #ef4444; color: #fff; border-radius: 999px;
    min-width: 18px; height: 18px; padding: 0 5px; font-size: .72rem;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.theme-toggle {
    background: rgba(255,255,255,.12); border: none; color: #fff;
    width: 34px; height: 34px; border-radius: 999px; cursor: pointer;
    font-size: 1rem; display: inline-flex; align-items: center; justify-content: center;
    transition: background .2s;
}
.theme-toggle:hover { background: rgba(255,255,255,.25); }
.nav-user {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    color: #fff; text-decoration: none; font-size: .92rem;
}
.nav-avatar {
    width: 30px; height: 30px; border-radius: 999px;
    background: linear-gradient(135deg,#3b82f6,#8b5cf6);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; color: #fff;
}
.nav-login-btn {
    background: var(--primary); color: #fff !important; padding: 7px 18px;
    border-radius: 8px; font-weight: 600; margin-left: 8px;
}
.nav-login-btn:hover { background: var(--primary-d); }

/* ---- Auth pages ---- */
.auth-wrap {
    min-height: calc(100vh - 56px); display: flex; align-items: center;
    justify-content: center; padding: 40px 16px;
}
.auth-card {
    background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
    padding: 36px 32px; width: 100%; max-width: 420px; border: 1px solid var(--border);
}
.auth-card h1 { font-size: 1.6rem; margin-bottom: 6px; color: var(--text); }
.auth-card .auth-sub { color: var(--text-dim); margin-bottom: 26px; font-size: .95rem; }
.auth-logo {
    width: 56px; height: 56px; border-radius: 16px; margin-bottom: 18px;
    background: linear-gradient(135deg,#3b82f6,#8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; color: #fff; font-weight: 700;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: .85rem; font-weight: 600;
    color: var(--text-dim); margin-bottom: 6px;
}
.form-input {
    width: 100%; padding: 12px 14px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 1rem; background: var(--surface-2);
    color: var(--text); transition: border .2s, box-shadow .2s;
}
.form-input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.level-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.level-pill {
    flex: 1; min-width: 56px; text-align: center; padding: 10px 0;
    border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer;
    font-weight: 700; color: var(--text-dim); background: var(--surface-2);
    transition: all .15s; user-select: none;
}
.level-pill.active {
    border-color: var(--primary); color: #fff; background: var(--primary);
}
.btn-block { width: 100%; padding: 13px; font-size: 1.05rem; font-weight: 600; }
.auth-foot { text-align: center; margin-top: 20px; color: var(--text-dim); font-size: .9rem; }
.auth-foot a { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-error {
    background: #fef2f2; color: #dc2626; border: 1px solid #fecaca;
    padding: 10px 14px; border-radius: 10px; font-size: .9rem; margin-bottom: 16px;
}
[data-theme="dark"] .auth-error { background: rgba(220,38,38,.12); border-color: rgba(220,38,38,.4); }

/* ---- Study / SRS page ---- */
.study-wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.study-head { text-align: center; margin-bottom: 24px; }
.study-head h1 { font-size: 1.5rem; color: var(--text); }
.study-progress {
    height: 8px; background: var(--border); border-radius: 999px;
    overflow: hidden; margin: 16px 0 4px;
}
.study-progress-bar {
    height: 100%; background: linear-gradient(90deg,#3b82f6,#8b5cf6);
    width: 0; transition: width .3s;
}
.study-meta { display: flex; justify-content: space-between; color: var(--text-dim); font-size: .85rem; }
.srs-card {
    background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
    border: 1px solid var(--border); padding: 28px 26px; margin-top: 20px;
}
.srs-badge {
    display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 10px;
    border-radius: 999px; background: rgba(59,130,246,.15); color: var(--primary);
    margin-bottom: 14px;
}
.srs-context {
    background: var(--surface-2); border-left: 3px solid var(--primary);
    padding: 12px 14px; border-radius: 8px; margin-bottom: 16px;
    color: var(--text); white-space: pre-wrap; font-size: .95rem;
}
.srs-question { font-size: 1.25rem; color: var(--text); margin-bottom: 20px; line-height: 1.7; }
.srs-opt {
    display: block; width: 100%; text-align: left; padding: 14px 16px;
    margin-bottom: 10px; border: 1.5px solid var(--border); border-radius: 12px;
    background: var(--surface-2); color: var(--text); font-size: 1rem; cursor: pointer;
    transition: all .15s;
}
.srs-opt:hover { border-color: var(--primary); }
.srs-opt.correct { border-color: #22c55e; background: rgba(34,197,94,.12); }
.srs-opt.wrong { border-color: #ef4444; background: rgba(239,68,68,.12); }
.srs-opt:disabled { cursor: default; }
.srs-explain {
    margin-top: 14px; padding: 14px; border-radius: 12px;
    background: var(--surface-2); color: var(--text); font-size: .92rem; line-height: 1.6;
}
.srs-grade { display: flex; gap: 10px; margin-top: 18px; }
.grade-btn {
    flex: 1; padding: 14px 0; border: none; border-radius: 12px; cursor: pointer;
    font-weight: 700; font-size: .95rem; color: #fff; transition: transform .1s, filter .15s;
}
.grade-btn:hover { filter: brightness(1.08); }
.grade-btn:active { transform: scale(.97); }
.grade-again { background: #ef4444; }
.grade-hard { background: #f59e0b; }
.grade-good { background: #22c55e; }
.grade-easy { background: #3b82f6; }
.grade-sub { display: block; font-size: .72rem; opacity: .85; font-weight: 500; margin-top: 2px; }
.study-empty { text-align: center; padding: 70px 20px; }
.study-empty .big { font-size: 4rem; margin-bottom: 12px; }
.study-empty h2 { color: var(--text); margin-bottom: 8px; }
.study-empty p { color: var(--text-dim); margin-bottom: 22px; }

/* ---- Profile page ---- */
.profile-wrap { max-width: 860px; margin: 0 auto; padding: 24px 16px 60px; }
.profile-hero {
    background: linear-gradient(135deg,#1a1a2e,#0f3460); color: #fff;
    border-radius: 18px; padding: 28px; display: flex; align-items: center;
    gap: 20px; margin-bottom: 24px;
}
.profile-avatar {
    width: 72px; height: 72px; border-radius: 999px; flex-shrink: 0;
    background: linear-gradient(135deg,#3b82f6,#8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; font-weight: 700;
}
.profile-hero h1 { font-size: 1.5rem; margin-bottom: 4px; }
.profile-hero .pmeta { opacity: .85; font-size: .9rem; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px; margin-bottom: 24px; }
.pstat {
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    padding: 18px; text-align: center; box-shadow: var(--shadow);
}
.pstat .num { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.pstat .lbl { color: var(--text-dim); font-size: .82rem; margin-top: 2px; }
.profile-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 24px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.profile-card h2 { font-size: 1.1rem; color: var(--text); margin-bottom: 16px; }

@media (max-width: 640px) {
    .nav-chip-streak { display: none; }
    .srs-grade { flex-wrap: wrap; }
    .grade-btn { min-width: calc(50% - 5px); }
    .profile-hero { flex-direction: column; text-align: center; }
}

/* ======================================================
   v3: CLEAN MINIMAL (Apple/Notion) — light-first refresh
   ====================================================== */
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans',
                 'Yu Gothic', Roboto, sans-serif;
}

/* ---- Navbar: white, bordered, dark text ---- */
.navbar {
    background: rgba(255,255,255,.8);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}
[data-theme="dark"] .navbar {
    background: rgba(20,22,33,.8);
    border-bottom-color: var(--border);
}
.nav-brand { color: var(--text); letter-spacing: -.3px; }
.nav-links a { color: var(--text-dim); font-weight: 500; }
.nav-links a:hover { color: var(--text); }
.theme-toggle {
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
}
.theme-toggle:hover { background: var(--surface-2); }
.nav-user { color: var(--text); }
[data-theme="dark"] .nav-brand,
[data-theme="dark"] .nav-links a:hover,
[data-theme="dark"] .nav-user { color: var(--text); }

/* ---- Buttons: indigo, rounded, soft ---- */
.btn { border-radius: 12px; font-weight: 600; letter-spacing: -.1px;
       transition: transform .08s ease, filter .15s ease, background .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-d); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e6e8ec; }
[data-theme="dark"] .btn-secondary { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .btn-secondary:hover { background: #2b3142; }
.btn-hero-primary { background: var(--primary); color: #fff; }
.btn-hero-primary:hover { background: var(--primary-d); }
.nav-login-btn { background: var(--primary); border-radius: 10px; }
.nav-login-btn:hover { background: var(--primary-d); }

/* ---- Card surfaces → #F7F8FA, 16px, soft shadow, thin border ---- */
.feature-card, .stat-card, .stats-bar, .level-card-new, .mock-exam-card,
.test-option-card, .recent-item, .review-item, .admin-section, .data-table,
.dttn, .me-sections, .auth-card, .srs-card, .profile-card, .pstat,
.section-practice-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.feature-card:hover, .level-card-new:hover, .mock-exam-card:hover,
.test-option-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(17,24,39,.08), 0 16px 40px rgba(17,24,39,.06);
    border-color: #dcdce4;
}

/* ---- Hero: light, calm, indigo accent (replaces dark navy) ---- */
.home-hero {
    background: linear-gradient(180deg, #f7f8fc 0%, #ffffff 100%);
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
[data-theme="dark"] .home-hero {
    background: linear-gradient(180deg, #171a24 0%, var(--bg) 100%);
    color: var(--text);
}
.home-hero .hero-mn { color: var(--primary); }
.home-hero .hero-sub { color: var(--text-dim); }
.home-hero strong { color: var(--primary); }
.hero-badge {
    background: rgba(79,70,229,.1); color: var(--primary);
    border: 1px solid rgba(79,70,229,.2);
}
.hero-bg { opacity: .5; }
[data-theme="dark"] .hero-bg { opacity: 1; }
.btn-hero-outline { color: var(--text); border: 1px solid var(--border); background: var(--surface); }
.btn-hero-outline:hover { background: var(--surface-2); }

/* ---- Section headers / page headers in clean style ---- */
.page-header, .section-header-bar, .results-header, .me-header { color: var(--text); }
.stat-num, .pstat .num, .me-number { color: var(--primary); }

/* ---- Premium badge ---- */
.premium-badge {
    display: inline-flex; align-items: center; gap: 5px;
    background: linear-gradient(135deg,#f59e0b,#d97706); color: #fff;
    padding: 3px 11px; border-radius: 999px; font-size: .78rem; font-weight: 700;
}
.locked-overlay {
    position: relative;
}
.locked-overlay::after {
    content: '🔒 Premium'; position: absolute; inset: 0;
    background: rgba(255,255,255,.78); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: var(--primary); border-radius: var(--radius);
}
[data-theme="dark"] .locked-overlay::after { background: rgba(20,22,33,.78); }

/* ---- Google sign-in button ---- */
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 12px;
    background: #fff; color: #3c4043; font-weight: 600; font-size: 1rem;
    cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s;
}
.btn-google:hover { background: #f7f8fa; box-shadow: var(--shadow); }
[data-theme="dark"] .btn-google { background: var(--surface-2); color: var(--text); }
.btn-google svg { width: 18px; height: 18px; }
.auth-divider {
    display: flex; align-items: center; gap: 12px; margin: 18px 0;
    color: var(--text-dim); font-size: .82rem;
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ---- Pricing / upgrade ---- */
.pricing-wrap { max-width: 760px; margin: 0 auto; padding: 36px 16px 60px; }
.pricing-head { text-align: center; margin-bottom: 34px; }
.pricing-head h1 { font-size: 2rem; letter-spacing: -.5px; margin-bottom: 8px; }
.pricing-head p { color: var(--text-dim); }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.plan {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; padding: 28px; box-shadow: var(--shadow);
}
.plan.featured { border: 2px solid var(--primary); position: relative; }
.plan.featured::before {
    content: 'Хамгийн их сонгогддог'; position: absolute; top: -12px; left: 50%;
    transform: translateX(-50%); background: var(--primary); color: #fff;
    font-size: .72rem; font-weight: 700; padding: 4px 14px; border-radius: 999px;
}
.plan h3 { font-size: 1.2rem; margin-bottom: 6px; }
.plan .price { font-size: 2.4rem; font-weight: 800; letter-spacing: -1px; margin: 8px 0; }
.plan .price small { font-size: .9rem; font-weight: 500; color: var(--text-dim); }
.plan ul { list-style: none; margin: 18px 0; padding: 0; }
.plan li { padding: 7px 0; color: var(--text); display: flex; gap: 9px; align-items: flex-start; }
.plan li .ok { color: #22c55e; font-weight: 800; }
.plan li .no { color: var(--text-dim); }
.plan li.dim { color: var(--text-dim); }
@media (max-width: 640px){ .plan-grid { grid-template-columns: 1fr; } }

/* ---- Admin dashboard ---- */
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.admin-head h1 { font-size: 1.6rem; letter-spacing: -.5px; margin-bottom: 16px; }
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px;
    border-bottom: 1px solid var(--border); padding-bottom: 0; }
.atab {
    background: none; border: none; border-bottom: 2px solid transparent;
    padding: 10px 14px; font-size: .95rem; font-weight: 600; color: var(--text-dim);
    cursor: pointer; transition: all .15s; margin-bottom: -1px;
}
.atab:hover { color: var(--text); }
.atab.active { color: var(--primary); border-bottom-color: var(--primary); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr));
    gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-ic { font-size: 1.4rem; margin-bottom: 6px; }
.kpi-num { font-size: 1.8rem; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.kpi-lbl { color: var(--text-dim); font-size: .85rem; font-weight: 600; margin-top: 2px; }
.kpi-sub { color: var(--text-dim); font-size: .76rem; margin-top: 6px; }

.spark { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-fill { width: 70%; min-height: 3px; background: linear-gradient(180deg,#6366f1,#4f46e5);
    border-radius: 6px 6px 0 0; transition: height .4s; }
.bar-n { font-size: .8rem; font-weight: 700; color: var(--text); margin-top: 4px; }
.bar-d { font-size: .72rem; color: var(--text-dim); }

.arow { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 14px; flex-wrap: wrap; }
.amuted { color: var(--text-dim); font-size: .85rem; }
.apage { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem;
    font-weight: 700; background: var(--surface-2); color: var(--text-dim); }
.tag-p { background: rgba(245,158,11,.15); color: #d97706; }
.tag-a { background: rgba(79,70,229,.12); color: var(--primary); }
.tag-stu { background: rgba(34,197,94,.13); color: #16a34a; }

/* ---- History empty state ---- */
.hist-empty { max-width: 520px; margin: 24px auto; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
    padding: 40px 28px; box-shadow: var(--shadow); }
.hist-empty .big { font-size: 3.4rem; margin-bottom: 10px; }
.hist-empty h2 { font-size: 1.3rem; margin-bottom: 10px; color: var(--text); }
.hist-empty p { color: var(--text-dim); line-height: 1.7; margin-bottom: 16px; }
.hist-hint { background: var(--surface-2); border-radius: 12px; padding: 12px 16px;
    font-size: .88rem; color: var(--text); line-height: 1.6; margin-bottom: 22px; text-align: left; }
.tag-ok { background: rgba(34,197,94,.15); color: #16a34a; }
.tag-fail { background: rgba(239,68,68,.15); color: #dc2626; }
.tag-pend { background: rgba(245,158,11,.15); color: #d97706; }

.data-table td, .data-table th { padding: 10px 12px; text-align: left; font-size: .9rem;
    border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
.admin-wrap .form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.admin-wrap select { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text); font-size: .92rem; }

/* ---- Public SEO pages ---- */
.seo-wrap { max-width: 1000px; margin: 0 auto; padding: 16px 16px 64px; }
.seo-hero { text-align: center; padding: 40px 16px 28px; }
.seo-hero h1 { font-size: 2.2rem; letter-spacing: -.8px; line-height: 1.2; margin-bottom: 14px; }
.seo-lead { color: var(--text-dim); font-size: 1.05rem; max-width: 640px; margin: 0 auto 22px; line-height: 1.7; }
.seo-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.seo-h2 { font-size: 1.5rem; letter-spacing: -.4px; margin: 36px 0 16px; text-align: center; }
.seo-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.seo-level-card {
    display: block; text-decoration: none; color: var(--text);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .15s, border-color .15s;
}
.seo-level-card:hover { transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(17,24,39,.08), 0 18px 44px rgba(17,24,39,.07); border-color: var(--primary); }
.slc-badge { display: inline-block; font-size: 1.3rem; font-weight: 800; color: var(--primary);
    background: rgba(79,70,229,.1); border-radius: 10px; padding: 4px 14px; margin-bottom: 10px; }
.slc-jp { font-size: .82rem; color: var(--text-dim); font-weight: 600; margin-bottom: 8px; }
.seo-level-card p { font-size: .92rem; color: var(--text-dim); line-height: 1.6; margin-bottom: 12px; }
.slc-stats { display: flex; gap: 12px; font-size: .82rem; color: var(--text); font-weight: 600; flex-wrap: wrap; }
.seo-why { margin-top: 40px; }
.seo-feats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 14px; }
.seo-feat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.seo-feat b { display: block; margin-bottom: 6px; font-size: 1rem; }
.seo-feat span { color: var(--text-dim); font-size: .9rem; line-height: 1.6; }
.seo-bottom-cta { text-align: center; margin: 48px auto 0; max-width: 560px;
    background: linear-gradient(180deg, #f7f8fc, var(--surface)); border: 1px solid var(--border);
    border-radius: 20px; padding: 36px 24px; }
[data-theme="dark"] .seo-bottom-cta { background: linear-gradient(180deg, #171a24, var(--surface)); }
.seo-bottom-cta h2 { font-size: 1.4rem; margin-bottom: 8px; }
.seo-crumb { font-size: .88rem; color: var(--text-dim); margin: 8px 0 4px; }
.seo-crumb a { color: var(--primary); text-decoration: none; }
.seo-vocab-table { width: 100%; border-collapse: collapse; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.seo-vocab-table th { background: var(--surface-2); text-align: left; padding: 12px 14px;
    font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
.seo-vocab-table td { padding: 11px 14px; border-top: 1px solid var(--border); font-size: .95rem; }
.vt-word { font-weight: 700; font-size: 1.1rem; }
.vt-read { color: var(--primary); font-weight: 600; }
.seo-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 20px; }
.seo-other { text-align: center; margin-top: 32px; color: var(--text-dim); font-size: .9rem; }
.seo-other a { color: var(--primary); text-decoration: none; font-weight: 700; margin: 0 8px;
    padding: 4px 12px; border: 1px solid var(--border); border-radius: 8px; }
@media (max-width: 640px) { .seo-hero h1 { font-size: 1.6rem; } }

/* ---- Kanji lessons ---- */
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 12px; margin-top: 18px; }
.kanji-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px; box-shadow: var(--shadow); text-align: center; transition: transform .12s, box-shadow .15s;
}
.kanji-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(17,24,39,.08); }
.kc-char { font-size: 3rem; font-weight: 800; line-height: 1.1; color: var(--text);
    font-family: 'Hiragino Sans', 'Yu Gothic', serif; }
.kc-mean { font-weight: 700; color: var(--text); margin: 4px 0 6px; font-size: .95rem; }
.kc-read { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; }
.kc-on { color: var(--primary); }
.kc-kun { color: #16a34a; }
.kc-foot { margin-top: 8px; font-size: .76rem; color: var(--text-dim); }
.kc-ex-toggle { color: var(--primary); cursor: pointer; font-weight: 600; }
.kc-examples { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
    text-align: left; font-size: .82rem; }
.kanji-card.open .kc-examples { display: block; }
.kc-ex { padding: 3px 0; color: var(--text-dim); }
.kc-ex b { color: var(--text); }
.kc-ex-r { color: var(--primary); }
.kc-sub-label { font-size: .72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .04em; color: var(--text-dim); margin-bottom: 4px; }
.kc-similar { display: flex; flex-wrap: wrap; gap: 6px; }
.kc-sim { display: inline-flex; flex-direction: column; align-items: center;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
    padding: 4px 8px; min-width: 40px; }
.kc-sim { font-size: 1.3rem; font-weight: 700; color: var(--text);
    font-family: 'Hiragino Sans','Yu Gothic',sans-serif; line-height: 1.1; }
.kc-sim small { font-size: .6rem; color: var(--text-dim); font-weight: 500; margin-top: 2px;
    max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 640px){ .kanji-grid { grid-template-columns: repeat(auto-fill, minmax(110px,1fr)); } .kc-char { font-size: 2.4rem; } }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--border); margin-top: 40px; background: var(--surface); }
.footer-inner { max-width: 1100px; margin: 0 auto; padding: 28px 20px; text-align: center; }
.footer-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.footer-links a { color: var(--text-dim); text-decoration: none; font-size: .9rem; font-weight: 600; }
.footer-links a:hover { color: var(--primary); }
.footer-note { color: var(--text-dim); font-size: .78rem; line-height: 1.7; max-width: 640px; margin: 0 auto; }

/* ---- Welcome / level pick ---- */
.welcome-levels { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.welcome-lvl { display: flex; align-items: center; gap: 16px; text-align: left;
    background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
    padding: 18px 22px; cursor: pointer; transition: all .15s; box-shadow: var(--shadow); width: 100%; }
.welcome-lvl:hover { border-color: var(--primary); transform: translateY(-2px); }
.welcome-lvl.active { border-color: var(--primary); background: rgba(79,70,229,.06); }
.welcome-lvl b { font-size: 1.5rem; font-weight: 800; color: var(--primary); min-width: 48px; }
.welcome-lvl span { color: var(--text-dim); font-size: .95rem; }

/* ---- Exam encouragement toast ---- */
.cheer-toast {
    position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
    background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff;
    padding: 13px 24px; border-radius: 999px; font-weight: 700; font-size: 1rem;
    box-shadow: 0 8px 30px rgba(79,70,229,.4); z-index: 2000;
    opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s;
    max-width: 90vw; text-align: center;
}
.cheer-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- Grammar lessons ---- */
.gram-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.gram-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden; }
.gram-head { display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 16px 18px; cursor: pointer; flex-wrap: wrap; }
.gram-head:hover { background: var(--surface-2); }
.gram-pattern { font-size: 1.25rem; font-weight: 800; color: var(--text);
    font-family: 'Hiragino Sans', 'Yu Gothic', sans-serif; }
.gram-reading { color: var(--text-dim); font-size: .85rem; margin-left: 8px; }
.gram-mean { color: var(--primary); font-weight: 600; font-size: .95rem; text-align: right; }
.gram-body { display: none; padding: 0 18px 18px; }
.gram-card.open .gram-body { display: block; }
.gram-exp { color: var(--text); line-height: 1.8; margin-bottom: 12px; }
.gram-form { background: var(--surface-2); border-radius: 10px; padding: 10px 14px;
    font-size: .9rem; color: var(--text); margin-bottom: 12px; }
.gram-examples { display: flex; flex-direction: column; gap: 8px; }
.gram-ex { border-left: 3px solid var(--primary); padding: 6px 0 6px 12px; }
.gram-ex-jp { font-size: 1.05rem; color: var(--text); font-family: 'Hiragino Sans','Yu Gothic',sans-serif; }
.gram-ex-mn { font-size: .88rem; color: var(--text-dim); margin-top: 2px; }

/* ===================== COMMUNITY / SOCIAL LAYER ===================== */
.muted { color: var(--text-dim); }

/* Profile: avatar picker */
.avatar-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.av-opt { aspect-ratio: 1; border-radius: 14px; overflow: hidden; cursor: pointer;
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); transition: transform .12s, border-color .12s; }
.av-opt:hover { transform: translateY(-2px); }
.av-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.av-opt.sel { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.18); }
.av-none { font-size: .78rem; font-weight: 600; color: var(--text-dim); }

/* Profile: toggles + bio */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 0; border-top: 1px solid var(--border); }
.toggle-row .muted { font-size: 12px; }
.toggle-cb { width: 44px; height: 26px; appearance: none; -webkit-appearance: none; background: var(--surface-2);
  border-radius: 99px; position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; }
.toggle-cb:checked { background: var(--primary); }
.toggle-cb::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.toggle-cb:checked::after { left: 21px; }
.profile-public-link { display: inline-block; margin-top: 6px; font-size: 13px; color: var(--primary);
  text-decoration: none; font-weight: 600; }
.profile-public-link:hover { text-decoration: underline; }
textarea.form-input { resize: vertical; font-family: inherit; }

/* Badges */
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; }
.badge { display: flex; align-items: center; gap: 7px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 99px; padding: 6px 13px 6px 10px; }
.badge .b-emoji { font-size: 1.15rem; }
.badge .b-name { font-size: .82rem; font-weight: 600; color: var(--text); }

/* Public profile */
.pubprof-wrap { max-width: 720px; margin: 0 auto; }
.pub-private { text-align: center; padding: 44px 20px; }
.pub-private .big { font-size: 46px; margin-bottom: 8px; }
.pub-hero { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.pub-avatar { width: 84px; height: 84px; border-radius: 22px; background-size: cover;
  background-position: center; flex-shrink: 0; box-shadow: var(--shadow); }
.pub-avatar.letter { display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: 700; color: #fff; background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.pub-id { flex: 1; min-width: 180px; }
.pub-id h1 { margin: 0 0 2px; }
.pub-bio { margin: 10px 0; color: var(--text); line-height: 1.5; }
.pub-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-dim); padding: 8px 12px; }
.btn-ghost:hover { background: var(--surface-2); }
.more-menu { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; max-width: 240px; }
.more-item { text-align: left; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; color: var(--text); font-size: .9rem; }
.more-item:hover { background: var(--surface); }

/* Leaderboard */
.lb-wrap { max-width: 720px; margin: 0 auto; }
.lb-head { text-align: center; margin-bottom: 18px; }
.lb-controls { display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; margin-bottom: 16px; }
.lb-tabs { display: inline-flex; background: var(--surface-2); border-radius: 99px; padding: 4px; }
.lb-tab { border: none; background: transparent; padding: 8px 16px; border-radius: 99px;
  cursor: pointer; color: var(--text-dim); font-weight: 600; font-size: .88rem; }
.lb-tab.active { background: var(--bg); color: var(--text); box-shadow: var(--shadow); }
.lb-select { max-width: 150px; padding: 8px 12px; }
.lb-list { display: flex; flex-direction: column; gap: 8px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; text-decoration: none; color: var(--text);
  transition: transform .1s; }
.lb-row:hover { transform: translateX(3px); }
.lb-row.me { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79,70,229,.15); }
.lb-rank { width: 32px; text-align: center; font-weight: 800; font-size: 1.05rem; color: var(--text-dim); }
.lb-av { width: 42px; height: 42px; border-radius: 50%; background-size: cover; background-position: center; flex-shrink: 0; }
.lb-av.letter { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.lb-name { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.lb-name .muted { font-size: .78rem; }
.lb-streak { font-size: .85rem; color: var(--text-dim); white-space: nowrap; }
.lb-pts { font-weight: 800; color: var(--primary); white-space: nowrap; }
.lb-pts .muted { font-weight: 400; font-size: .72rem; }

/* Direct messages */
.dm-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 16px; max-width: 920px; margin: 0 auto;
  height: calc(100vh - 160px); min-height: 460px; }
.dm-threads { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  overflow-y: auto; }
.dm-threads-head { padding: 14px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--surface); }
.dm-threads-head h2 { margin: 0; font-size: 1.05rem; }
.thread { display: flex; gap: 10px; align-items: center; padding: 11px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--surface-2); }
.dm-av { width: 40px; height: 40px; border-radius: 50%; background-size: cover; background-position: center; flex-shrink: 0; }
.dm-av.letter { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.thread-info { flex: 1; min-width: 0; }
.thread-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.thread-last { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dm-badge { background: var(--primary); color: #fff; border-radius: 99px; font-size: .7rem;
  padding: 1px 7px; font-weight: 700; }
.dm-chat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden; }
.dm-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px; padding: 30px; }
.dm-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dm-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
  border-bottom: 1px solid var(--border); }
.dm-head-user { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.dm-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 75%; padding: 9px 13px; border-radius: 16px; font-size: .92rem; line-height: 1.4;
  position: relative; word-wrap: break-word; }
.bubble.mine { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.bubble.theirs { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 5px; }
.bubble .b-time { display: block; font-size: .65rem; opacity: .7; margin-top: 3px; text-align: right; }
.dm-composer { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.dm-composer input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 99px;
  background: var(--bg); color: var(--text); font-size: .92rem; }
.dm-note { padding: 0 16px 10px; font-size: .8rem; }
.nav-chip-dm { background: var(--surface-2); color: var(--text); position: relative; }

@media (max-width: 700px) {
  .dm-wrap { grid-template-columns: 1fr; height: auto; }
  .dm-chat { min-height: 420px; }
  .pub-hero { flex-direction: column; align-items: center; text-align: center; }
  .pub-actions { justify-content: center; }
}

/* ===================== PHASE 1: people + floating chat ===================== */
/* People directory */
.people-wrap { max-width: 880px; margin: 0 auto; }
.people-head { text-align: center; margin-bottom: 16px; }
.people-reqs { background: var(--surface); border: 1px solid var(--primary); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; }
.people-reqs h2 { margin: 0 0 10px; font-size: 1rem; }
.req-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.req-row:first-of-type { border-top: none; }
.req-name { flex: 1; display: flex; flex-direction: column; text-decoration: none; color: var(--text); min-width: 0; }
.req-name .muted { font-size: .78rem; }
.req-acts { display: flex; gap: 6px; }
.people-search { margin-bottom: 16px; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pp-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.pp-link { display: flex; flex-direction: column; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.pp-av { width: 64px; height: 64px; border-radius: 50%; background-size: cover; background-position: center; }
.pp-av.letter { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 1.6rem; background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.pp-name { display: flex; flex-direction: column; }
.pp-name .muted { font-size: .76rem; }
.pp-meta { font-size: .82rem; }
.pp-act { margin-top: 4px; }
.people-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0; }

/* Floating Messenger-style chat widget */
.chat-widget { position: fixed; bottom: 18px; right: 18px; z-index: 950; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.cw-launcher { width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary); color: #fff; box-shadow: 0 6px 20px rgba(79,70,229,.45); position: relative;
  display: flex; align-items: center; justify-content: center; transition: transform .12s; }
.cw-launcher:hover { transform: scale(1.06); }
.cw-ico { font-size: 1.5rem; line-height: 1; }
.cw-badge { position: absolute; top: -2px; right: -2px; background: #ef4444; color: #fff; font-size: .68rem;
  font-weight: 700; border-radius: 99px; padding: 1px 6px; border: 2px solid var(--bg); }
.cw-panel { width: 300px; max-height: 60vh; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.cw-panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cw-panel-head strong { flex: 1; }
.cw-add { text-decoration: none; color: var(--primary); font-size: 1.3rem; font-weight: 700; line-height: 1; }
.cw-x { background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 1rem; padding: 2px 4px; }
.cw-friends { overflow-y: auto; }
.cw-friend { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; }
.cw-friend:hover { background: var(--surface-2); }
.cw-av { width: 34px; height: 34px; border-radius: 50%; background-size: cover; background-position: center; flex-shrink: 0; display: inline-block; }
.cw-av.letter { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .9rem; background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.cw-fn { flex: 1; font-size: .9rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cw-fbadge { background: var(--primary); color: #fff; border-radius: 99px; font-size: .68rem; padding: 1px 7px; font-weight: 700; }
.cw-chat { width: 320px; height: 430px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow); flex-direction: column; overflow: hidden; }
.cw-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.cw-chat-name { font-weight: 700; color: var(--text); text-decoration: none; }
.cw-chat-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.cw-b { max-width: 78%; padding: 7px 11px; border-radius: 14px; font-size: .88rem; line-height: 1.35; word-wrap: break-word; }
.cw-b.me { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.cw-b.th { align-self: flex-start; background: var(--surface-2); color: var(--text); border-bottom-left-radius: 4px; }
.cw-chat-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--border); }
.cw-chat-input input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--bg); color: var(--text); font-size: .88rem; }
.cw-send { border: none; background: var(--primary); color: #fff; width: 36px; border-radius: 50%; cursor: pointer; font-size: 1rem; }
.cw-note { padding: 8px 14px; font-size: .8rem; }

@media (max-width: 700px) {
  .cw-panel, .cw-chat { width: calc(100vw - 28px); }
  .cw-chat { height: 70vh; }
}

/* ===================== PHASE 2: feed / posts ===================== */
.feed-wrap { max-width: 600px; margin: 0 auto; }
.composer { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; margin-bottom: 18px; }
.comp-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.comp-tab { flex: 1; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px;
  padding: 8px; cursor: pointer; color: var(--text-dim); font-weight: 600; font-size: .85rem; }
.comp-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.comp-extra { margin-top: 10px; }
.comp-preview { max-width: 100%; max-height: 220px; border-radius: 12px; margin-top: 10px; display: block; }
#poll-opts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.comp-foot { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.comp-vis { max-width: 150px; padding: 8px 10px; }
.comp-foot .btn { margin-left: auto; }

.feed-list { display: flex; flex-direction: column; gap: 14px; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px; }
.post-head { display: flex; align-items: center; gap: 10px; position: relative; }
.post-author { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: 1; }
.post-author span { display: flex; flex-direction: column; }
.post-author .muted { font-size: .76rem; }
.fc-av { width: 40px; height: 40px; border-radius: 50%; background-size: cover; background-position: center; flex-shrink: 0; display: inline-block; }
.fc-av.letter { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.post-menu-btn { background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: 1.2rem; padding: 0 6px; }
.post-menu { position: absolute; top: 30px; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); z-index: 5; display: flex; flex-direction: column; min-width: 160px; }
.post-body { margin: 10px 0; color: var(--text); line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.post-img { width: 100%; border-radius: 12px; margin: 6px 0; display: block; }
.post-actions { display: flex; gap: 8px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.post-like, .post-cbtn { background: var(--surface-2); border: none; border-radius: 10px; padding: 7px 14px;
  cursor: pointer; color: var(--text-dim); font-size: .88rem; font-weight: 600; }
.post-like.liked { color: #ef4444; }
.post-like:hover, .post-cbtn:hover { background: var(--border); }

/* Poll */
.poll { display: flex; flex-direction: column; gap: 7px; margin: 8px 0; }
.poll-row { position: relative; border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px;
  cursor: pointer; overflow: hidden; display: flex; align-items: center; }
.poll-fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(79,70,229,.16); transition: width .4s; z-index: 0; }
.poll-row.voted { border-color: var(--primary); }
.poll-row.voted .poll-fill { background: rgba(79,70,229,.28); }
.poll-txt { position: relative; z-index: 1; flex: 1; color: var(--text); font-size: .9rem; }
.poll-pct { position: relative; z-index: 1; font-weight: 700; color: var(--primary); font-size: .85rem; }
.poll-total { font-size: .78rem; margin-top: 2px; }

/* Comments */
.comments { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.comment { display: flex; gap: 8px; }
.comment.reply { margin-left: 36px; }
.c-author { flex-shrink: 0; }
.c-body { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; font-size: .88rem; color: var(--text); flex: 1; line-height: 1.4; }
.c-body strong { margin-right: 4px; }
.c-meta { margin-top: 4px; font-size: .74rem; color: var(--text-dim); }
.c-reply, .c-x { background: none; border: none; cursor: pointer; color: var(--text-dim); font-size: .74rem; padding: 0; }
.c-reply:hover, .c-x:hover { color: var(--primary); }
.comment-add { display: flex; gap: 6px; margin-top: 4px; }
.comment-add input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--bg); color: var(--text); font-size: .85rem; }

/* ===================== PHASE 3: groups + notifications ===================== */
.groups-wrap { max-width: 760px; margin: 0 auto; }
.groups-head { text-align: center; margin-bottom: 18px; }
.group-create { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 18px; display: flex; flex-direction: column; gap: 10px; }
.group-create h2 { margin: 0; font-size: 1.05rem; }
.gc-row { display: flex; gap: 12px; flex-wrap: wrap; }
.gc-row label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--text-dim); flex: 1; }
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.group-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; }
.gc-title { text-decoration: none; color: var(--text); }
.gc-title h3 { margin: 0 0 6px; }
.gc-desc { font-size: .85rem; flex: 1; margin: 0 0 12px; line-height: 1.45; }
.gc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gc-foot .muted { font-size: .78rem; }

.group-wrap { max-width: 600px; margin: 0 auto; }
.group-header { display: flex; align-items: flex-start; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px; margin-bottom: 16px; }
.gh-main { flex: 1; }
.gh-main h1 { margin: 0 0 4px; font-size: 1.4rem; }
.gh-meta { font-size: .8rem; margin-top: 8px; }
.g-pending { background: var(--surface); border: 1px solid var(--primary); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px; }
.g-pending h3 { margin: 0 0 10px; font-size: 1rem; }

/* Notification bell */
.nav-bell-wrap { position: relative; display: inline-block; }
.nav-bell { background: var(--surface-2); color: var(--text); cursor: pointer; border: none; }
.notif-dropdown { position: absolute; top: 42px; right: 0; width: 320px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); z-index: 1000; }
.notif-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; text-decoration: none;
  color: var(--text); border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: rgba(79,70,229,.08); }
.nd-av { width: 34px; height: 34px; border-radius: 50%; background-size: cover; background-position: center; flex-shrink: 0; display: inline-block; }
.nd-av.letter { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .85rem; background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.ni-txt { font-size: .85rem; line-height: 1.35; }

@media (max-width: 700px) {
  .notif-dropdown { width: calc(100vw - 28px); right: -60px; }
}

/* ===================== HOMEPAGE side box (community / people) ===================== */
.home-layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; margin-top: 24px; }
.home-side { position: sticky; top: 80px; }
.side-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 13px 14px; box-shadow: var(--shadow); }
.cb-count { font-size: 2rem; font-weight: 800; color: var(--primary); line-height: 1; }
.cb-count-label { color: var(--text-dim); font-size: .85rem; margin-bottom: 14px; }
.cb-invite { font-size: .92rem; line-height: 1.55; color: var(--text); margin: 14px 0; }
.cb-login { display: block; text-align: center; margin-top: 12px; font-size: .82rem; color: var(--text-dim); text-decoration: none; }
.cb-login:hover { color: var(--primary); }
.cb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.cb-head strong { font-size: .92rem; }
.cb-all { font-size: .76rem; color: var(--primary); text-decoration: none; font-weight: 600; }
.sp-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.sp-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); flex: 1; min-width: 0; }
.sp-av { width: 28px; height: 28px; border-radius: 50%; background-size: cover; background-position: center; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.sp-av.letter { color: #fff; font-weight: 700; font-size: .72rem; background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.sp-nm { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sp-act { flex-shrink: 0; }
.btn-xs { padding: 4px 8px; font-size: .74rem; line-height: 1; min-width: 26px; }

@media (max-width: 900px) {
  .home-layout { grid-template-columns: 1fr; }
  .home-side { position: static; }
}

/* ===================== VOICE CALL bar ===================== */
.call-bar { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 960;
  display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 99px; padding: 10px 18px; box-shadow: 0 8px 28px rgba(0,0,0,.28); max-width: calc(100vw - 24px); }
.cl-info { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--text); white-space: nowrap; }
.cl-dot { width: 9px; height: 9px; border-radius: 50%; background: #22c55e; animation: cl-pulse 1.5s infinite; flex-shrink: 0; }
@keyframes cl-pulse { 0%,100%{ opacity: 1; } 50%{ opacity: .35; } }
.cl-avatars { display: flex; }
.cl-avatars .fc-av { width: 30px; height: 30px; border-radius: 50%; margin-left: -8px; border: 2px solid var(--surface);
  background-size: cover; background-position: center; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .72rem; }
.cl-avatars .fc-av.letter { background: linear-gradient(135deg, var(--primary), #8b5cf6); }
.cl-actions { display: flex; gap: 8px; flex-shrink: 0; }
.cl-leave { background: #ef4444; color: #fff; border: none; }
.cl-leave:hover { background: #dc2626; }

@media (max-width: 600px) {
  .call-bar { flex-wrap: wrap; justify-content: center; border-radius: 18px; }
}
