@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&subset=cyrillic&display=swap');

/* ─── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary:       #1a56db;
    --primary-dark:  #1240a8;
    --primary-light: #e8f0fe;
    --accent:        #d97706;
    --success:       #16a34a;
    --danger:        #dc2626;
    --warning:       #f59e0b;
    --text:          #1e293b;
    --text-muted:    #64748b;
    --border:        #e2e8f0;
    --bg:            #f8fafc;
    --bg-card:       #ffffff;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:     0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:     0 10px 30px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.04);
    --radius:        10px;
    --radius-sm:     6px;
    --radius-lg:     16px;
    --font-body:     'Source Serif 4', Georgia, serif;
    --font-ui:       'DM Sans', system-ui, sans-serif;
    --nav-h:         64px;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}


/* ─── Navbar ────────────────────────────────────────────── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-h);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 8px;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 16px;
    white-space: nowrap;
}

.nav-brand .flag { font-size: 1.3rem; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color .2s, background .2s;
}

.nav-link:hover { color: var(--text); background: var(--bg); }
.nav-link.active { color: var(--primary); background: var(--primary-light); }

.nav-spacer { flex: 1; }

.nav-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: opacity .2s;
}
.nav-avatar:hover { opacity: .8; }

.nav-btn {
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.nav-btn-login {
    background: var(--primary);
    color: white;
}
.nav-btn-login:hover { background: var(--primary-dark); }

.nav-btn-logout {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.nav-btn-logout:hover { background: #fee2e2; color: var(--danger); border-color: #fca5a5; }

/* Language picker */
.nav-lang-picker {
    position: relative;
}
.nav-lang-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 4px 8px;
    line-height: 1;
    display: flex;
    align-items: center;
    transition: background .15s, border-color .15s;
}
.nav-lang-btn:hover { background: var(--bg); border-color: var(--primary); }
.nav-lang-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    list-style: none;
    margin: 0;
    padding: 4px 0;
    min-width: 160px;
    z-index: 200;
}
.nav-lang-dropdown.open { display: block; }
.nav-lang-option {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    color: var(--text);
    transition: background .12s;
}
.nav-lang-option:hover { background: var(--bg); }
.nav-lang-option.active { color: var(--primary); font-weight: 600; }

/* Mobile nav */
.nav-mobile-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    font-size: 1.4rem;
    color: var(--text);
}

@media (max-width: 640px) {
    .nav-mobile-toggle { display: block; }
    .nav-links { display: none; position: absolute; top: var(--nav-h); left: 0; right: 0;
        background: white; border-bottom: 1px solid var(--border);
        flex-direction: column; padding: 12px; gap: 4px; align-items: stretch; }
    .nav-links.open { display: flex; }
    .nav-link { padding: 10px 16px; }
}

/* ─── Page container ────────────────────────────────────── */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 20px 64px; }
.page-narrow { max-width: 780px; margin: 0 auto; padding: 32px 20px 64px; }

/* ─── Buttons ───────────────────────────────────────────── */
button, .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background .18s, color .18s, box-shadow .18s, transform .1s;
    white-space: nowrap;
}
button:active, .btn:active { transform: scale(0.97); }
button:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary, button.primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled), button.primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary, button.secondary { background: #e0e7ff; color: var(--primary); }
.btn-secondary:hover:not(:disabled), button.secondary:hover:not(:disabled) { background: #c7d2fe; }

.btn-danger, button.danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover:not(:disabled), button.danger:hover:not(:disabled) { background: #fca5a5; }

.btn-ghost, button.ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled), button.ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

button.btn-large { padding: 13px 28px; font-size: 1rem; }
button.btn-small, .btn-sm { padding: 5px 12px; font-size: 0.8rem; }

.btn-highlight {
    animation: pulse-btn 2s ease-in-out infinite;
}
@keyframes pulse-btn {
    0%,100% { box-shadow: 0 0 0 0 rgba(26,86,219,.4); }
    50% { box-shadow: 0 0 0 10px rgba(26,86,219,0); }
}

/* ─── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow-md); }

.card-clickable { cursor: pointer; }
.card-clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card-clickable:active { transform: translateY(0); }

/* ─── Forms ─────────────────────────────────────────────── */
input[type=text], input[type=email], input[type=password], select, textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--text);
    background: white;
    transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}

/* ─── Badges / Tags ─────────────────────────────────────── */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--primary-light);
    color: var(--primary);
}
.tag-accent { background: #fef3c7; color: #92400e; }
.tag-success { background: #dcfce7; color: #15803d; }
.tag-neutral { background: #f1f5f9; color: var(--text-muted); }

/* ─── Toast ─────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transition: all .3s ease;
    font-size: 0.9rem;
    max-width: 90vw;
    text-align: center;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #7f1d1d; }

/* ─── Section headers ───────────────────────────────────── */
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}
.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.section-link {
    font-size: 0.85rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}
.section-link:hover { text-decoration: underline; }

/* ─── Post card ─────────────────────────────────────────── */
.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
}
.post-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.post-card:active { transform: translateY(0); }

.post-card-cover {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--primary);
    min-height: 140px;
}
.post-card-cover img { width: 100%; height: 100%; object-fit: cover; }

.post-card-body { padding: 18px; flex: 1; display: flex; flex-direction: column; gap: 8px; }

.post-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.post-card-date { font-size: 0.78rem; color: var(--text-muted); }

.post-card-title {
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text);
}

.post-card-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.55;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── Test / folder cards ───────────────────────────────── */
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

.folder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 20px;
    cursor: pointer;
    text-align: center;
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.folder-card:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); border-color: var(--primary); }
.folder-card:active { transform: translateY(0); }

.folder-card-icon { font-size: 2.5rem; margin-bottom: 12px; }
.folder-card-name { font-weight: 700; font-size: 1rem; color: var(--text); }
.folder-card-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

.folder-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

/* Test item list */
.test-list { display: flex; flex-direction: column; gap: 10px; }
.test-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: background .15s, border-color .15s;
}
.test-item:hover { background: var(--primary-light); border-color: var(--primary); }
.test-item-name { font-weight: 600; font-size: 0.95rem; }
.test-item-code { font-size: 0.78rem; color: var(--text-muted); font-family: monospace; }

/* ─── Hero ──────────────────────────────────────────────── */
.hero {
    background: linear-gradient(135deg, #1a237e 0%, #1a56db 60%, #1565c0 100%);
    color: white;
    padding: 72px 24px 60px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero-content { position: relative; max-width: 680px; margin: 0 auto; }
.hero-flag { font-size: 3.5rem; margin-bottom: 20px; display: block; }
.hero-title { font-size: clamp(1.8rem, 5vw, 2.8rem); font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.hero-sub { font-size: 1.1rem; opacity: 0.85; margin-bottom: 36px; line-height: 1.6; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.hero-cta {
    background: white;
    color: var(--primary-dark);
    padding: 13px 28px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform .15s, box-shadow .15s;
}
.hero-cta:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }

.hero-secondary {
    background: rgba(255,255,255,.15);
    color: white;
    padding: 13px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,.3);
    transition: background .2s;
}
.hero-secondary:hover { background: rgba(255,255,255,.25); }

/* ─── Modal ─────────────────────────────────────────────── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}
.modal.open { display: flex; }
.modal-box {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 820px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.close-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); padding: 4px 8px; }
.close-btn:hover { color: var(--text); }

/* ─── Test screens (preserved from app.js) ──────────────── */
.screen { margin-top: 0; }
.screen h2 { color: var(--text); margin-bottom: 20px; }
.screen h3 { color: var(--text-muted); margin: 20px 0 10px; }

.back-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.back-button:hover { background: var(--bg); color: var(--text); }

.overview-content { text-align: center; padding: 40px 20px; }
.overview-content h2 { margin-bottom: 32px; font-size: 1.8em; }
.overview-actions { display: flex; gap: 16px; justify-content: center; margin: 32px 0; flex-wrap: wrap; }

/* Section selector */
.section-selector {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}
.section-selector h3 { margin-bottom: 14px; font-size: 0.95rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.section-checkboxes { display: flex; flex-wrap: wrap; gap: 10px; }
.section-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    font-size: 0.9rem;
    font-weight: 500;
}
.section-checkbox-item input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; }
.section-checkbox-item:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }

/* Test header */
.test-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.test-header h2 { font-size: 1.2rem; margin: 0; flex: 1; }
.test-header-buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* History */
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.history-header h2 { margin: 0; }
.history-item {
    padding: 14px 18px;
    margin: 8px 0;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    border-left: 4px solid var(--primary);
}
.history-date { font-size: 0.85rem; color: var(--text-muted); margin: 4px 0; }
.history-score { font-weight: 700; color: var(--success); margin: 4px 0; }
.history-user { font-size: 0.85rem; color: var(--text-muted); margin: 4px 0; }

/* Floating progress */
.floating-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success), #15803d);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(22,163,74,.4);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: transform .2s, box-shadow .2s;
    padding: 8px;
}
.floating-btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(22,163,74,.5); }
.floating-btn:active { transform: scale(0.95); }
.progress-icon { font-size: 18px; line-height: 1; }
.progress-count { font-size: 9px; font-weight: 700; margin-top: 2px; }

.floating-panel {
    position: fixed;
    bottom: 90px;
    left: 24px;
    width: 340px;
    max-height: 480px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 199;
    overflow: hidden;
    animation: slideUp .25s ease;
}
@keyframes slideUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.floating-panel-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.floating-panel-header h3 { margin: 0; font-size: 1rem; }

/* Question types — preserved */
.question-block { margin-bottom: 28px; background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.question-block.composite { border-left: 4px solid var(--primary); }
.question-number { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.question-text { font-size: 1rem; font-weight: 600; margin-bottom: 14px; line-height: 1.5; }
.option-label { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 6px 0; cursor: pointer; font-size: 0.92rem; transition: background .15s, border-color .15s; }
.option-label:hover { background: var(--primary-light); border-color: var(--primary); }
.option-label input { accent-color: var(--primary); margin-top: 2px; }
.option-label.correct { background: #dcfce7; border-color: var(--success); }
.option-label.incorrect { background: #fee2e2; border-color: var(--danger); }
.text-answer { width: 100%; min-height: 80px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.92rem; resize: vertical; }
.essay-answer { min-height: 160px; }
.word-count { font-size: 0.78rem; color: var(--text-muted); margin-top: 6px; text-align: right; }

/* Section nav tabs */
.section-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.section-tab { padding: 7px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600; cursor: pointer; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); transition: all .15s; }
.section-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.section-tab.answered { border-color: var(--success); color: var(--success); }
.section-tab.active.answered { background: var(--success); border-color: var(--success); color: white; }

/* Subsection */
.subsection-block { margin-bottom: 24px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.subsection-header { padding: 14px 18px; background: var(--bg); border-bottom: 1px solid var(--border); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.subsection-header h3 { margin: 0; font-size: 0.95rem; font-weight: 700; }
.subsection-body { padding: 20px 28px; }
.subsection-body > p { line-height: 1.8; color: var(--text); margin-bottom: 16px; white-space: pre-line; }

/* Audio transcript */
.audio-player-wrap { display: flex; flex-direction: column; gap: 0; margin-bottom: 12px; }
.audio-transcript-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    line-height: 1;
    color: var(--text-muted);
    transition: background .15s, border-color .15s, color .15s;
}
.audio-transcript-btn:hover, .audio-transcript-btn.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.audio-transcript-box {
    margin-top: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--text-muted);
    white-space: pre-wrap;
}

/* Results */
.score-summary { background: var(--primary-light); border: 1px solid #c7d2fe; border-radius: var(--radius); padding: 28px; text-align: center; margin-bottom: 24px; }
.score-big { font-size: 3.5rem; font-weight: 800; color: var(--primary); }
.score-label { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }
.section-scores-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin: 20px 0; }
.section-score-card { background: white; border: 2px solid var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; }
.section-score-card.enabled { border-color: var(--success); }
.section-score-card.disabled { opacity: .55; background: var(--bg); }
.section-score-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.section-score-percentage { font-size: 2rem; font-weight: 800; color: var(--success); margin: 8px 0; }
.section-score-details { font-size: 0.78rem; color: var(--text-muted); }
.section-disabled-badge { display: inline-block; background: var(--danger); color: white; padding: 2px 8px; border-radius: 99px; font-size: 0.7rem; margin-left: 4px; }
.section-result-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 0.75rem; font-weight: 700; margin-top: 6px; letter-spacing: .04em; }
.section-result-badge.pass { background: var(--success); color: #fff; }
.section-result-badge.fail { background: var(--danger); color: #fff; }
.section-result-badge.not-graded { background: var(--border); color: var(--text-muted); }
.section-result-badge.skipped { background: var(--border); color: var(--text-muted); }
.detail-explanation { margin-top: 8px; padding: 8px 12px; background: var(--bg); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 0.88rem; color: var(--text); line-height: 1.5; }
.explanation-label { font-weight: 600; color: var(--accent); }

/* Result details */
.detail-item { padding: 14px; background: var(--bg); border-radius: var(--radius-sm); margin: 8px 0; border-left: 4px solid var(--border); }
.detail-item.correct { border-left-color: var(--success); }
.detail-item.incorrect { border-left-color: var(--danger); }
.detail-question { font-weight: 600; margin-bottom: 8px; font-size: 0.92rem; }
.detail-answer { font-size: 0.88rem; padding: 6px 10px; background: white; border-radius: var(--radius-sm); }

/* Audio player */
.audio-player { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 0; }
.audio-btn { background: var(--primary); color: white; border: none; border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 0.9rem; flex-shrink: 0; }
.audio-progress-bar { flex: 1; height: 4px; background: #e2e8f0; border-radius: 2px; cursor: pointer; position: relative; }
.audio-progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width .1s; }
.audio-time { font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.audio-speed-btn { font-size: 0.78rem; background: var(--bg); border: 1px solid var(--border); color: var(--text-muted); padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer; }

/* Video */
.video-player { margin: 12px 0; }
.video-element { width: 100%; max-width: 720px; border-radius: var(--radius-sm); display: block; }
.video-controls-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

/* Speech */
.speech-controls { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; }
.speech-record-btn { padding: 8px 18px; border-radius: 20px; border: 2px solid #e53935; background: #fff; color: #e53935; font-weight: 600; cursor: pointer; transition: background .2s, color .2s; }
.speech-record-btn.recording { background: #e53935; color: #fff; animation: pulse-border 1.2s infinite; }
@keyframes pulse-border { 0%,100% { box-shadow: 0 0 0 0 rgba(229,57,53,.4); } 50% { box-shadow: 0 0 0 6px rgba(229,57,53,0); } }
.speech-status-dot { width: 10px; height: 10px; border-radius: 50%; background: #ccc; display: inline-block; transition: background .3s; }
.speech-status-dot.active { background: #e53935; animation: blink-dot 1s infinite; }
@keyframes blink-dot { 0%,100% { opacity:1; } 50% { opacity:.2; } }
.speech-clear-btn { margin-left: auto; color: var(--text-muted); border: 1px solid var(--border); background: transparent; cursor: pointer; border-radius: var(--radius-sm); padding: 4px 10px; font-size: 0.85rem; }
.speech-transcript { width: 100%; min-height: 100px; border-radius: var(--radius-sm); border: 1px solid var(--border); padding: 10px; font-size: 1rem; resize: vertical; background: var(--bg); box-sizing: border-box; }
.speech-transcript:not([readonly]) { background: white; border-color: #aaa; }
.speech-word-count { text-align: right; font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }
.speech-unsupported { margin: 12px 0; padding: 12px 16px; background: #fff8e1; border-left: 4px solid var(--warning); border-radius: var(--radius-sm); color: #555; line-height: 1.6; }

/* Custom HTML */
.custom-html-content { margin: 16px 0; padding: 14px; background: white; border-radius: var(--radius-sm); border: 1px solid var(--border); overflow-x: auto; }
.custom-html-content table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.custom-html-content th, .custom-html-content td { padding: 10px 14px; border: 1px solid var(--border); text-align: left; }
.custom-html-content th { background: var(--primary); color: white; font-weight: 700; font-size: 0.88em; text-transform: uppercase; }
.custom-html-content tr:nth-child(even) { background: var(--bg); }
.custom-html-content tr:hover { background: var(--primary-light); }
.custom-html-content p { margin: 8px 0; }
.custom-html-content blockquote { margin: 12px 0; padding: 10px 16px; border-left: 4px solid var(--primary); background: var(--bg); font-style: italic; }

/* Image in question */
.question-image { max-width: 100%; border-radius: var(--radius-sm); margin: 10px 0; display: block; }

/* Guest warning */
.guest-warning { background: #fff8e1; border-top: 1px solid #ffe082; border-right: 1px solid #ffe082; border-bottom: 1px solid #ffe082; border-left: 4px solid var(--warning); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; font-size: 0.9rem; color: #5d4037; }
.guest-warning a { color: var(--primary); font-weight: 700; }

/* ─── Post page ─────────────────────────────────────────── */
.post-cover { width: 100%; max-height: 400px; object-fit: cover; border-radius: var(--radius); margin-bottom: 28px; display: block; }
.post-cover-placeholder { width: 100%; height: 280px; background: linear-gradient(135deg, var(--primary-light), #c7d2fe); border-radius: var(--radius); margin-bottom: 28px; display: flex; align-items: center; justify-content: center; font-size: 4rem; color: var(--primary); }

.post-meta-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.post-date { font-size: 0.82rem; color: var(--text-muted); }

.post-title { font-family: var(--font-body); font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 600; line-height: 1.25; margin-bottom: 16px; }

.post-content {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.85;
    color: #2d3748;
}
.post-content h1,.post-content h2 { font-size: 1.5rem; font-weight: 700; margin: 2em 0 .75em; color: var(--text); }
.post-content h3 { font-size: 1.2rem; font-weight: 700; margin: 1.75em 0 .6em; color: var(--text); }
.post-content h4 { font-size: 1rem; font-weight: 700; margin: 1.5em 0 .5em; }
.post-content p { margin-bottom: 1.2em; }
.post-content blockquote { margin: 1.5em 0; padding: 14px 20px; border-left: 4px solid var(--primary); background: var(--primary-light); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-style: italic; }
.post-content blockquote p { margin: 0; }
.post-content strong { font-weight: 700; }
.post-content em { font-style: italic; }
.post-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: .9em; }
.post-content pre { background: #1e293b; color: #e2e8f0; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 1.5em 0; }
.post-content pre code { background: none; padding: 0; color: inherit; }
.post-content ul, .post-content ol { padding-left: 1.5em; margin-bottom: 1.2em; }
.post-content li { margin-bottom: .4em; }
.post-content a { color: var(--primary); text-decoration: underline; }
.post-content img { max-width: 100%; border-radius: var(--radius-sm); margin: 1em 0; }
.post-content hr { border: none; border-top: 1px solid var(--border); /* linter: border:none resets all sides, border-top re-adds just the top -- this is intentional */ margin: 2em 0; }
.post-content table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: .95rem; }
.post-content th { background: var(--primary); color: white; padding: 10px 14px; text-align: left; font-size: .85em; text-transform: uppercase; }
.post-content td { padding: 10px 14px; border: 1px solid var(--border); }
.post-content tr:nth-child(even) { background: var(--bg); }

/* Bookmark button */
.bookmark-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: white; cursor: pointer; font-size: 0.875rem; font-weight: 600; color: var(--text-muted); transition: all .2s; }
.bookmark-btn:hover { border-color: var(--accent); color: var(--accent); background: #fef3c7; }
.bookmark-btn.bookmarked { background: #fef3c7; border-color: var(--accent); color: var(--accent); }

/* Related posts */
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }

/* ─── Profile page ──────────────────────────────────────── */
.profile-hero { background: linear-gradient(135deg, #1a237e, #1a56db); color: white; padding: 40px 24px; border-radius: var(--radius-lg); margin-bottom: 32px; display: flex; align-items: center; gap: 20px; }
.profile-avatar-lg { width: 72px; height: 72px; border-radius: 50%; background: rgba(255,255,255,.2); font-size: 1.8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 3px solid rgba(255,255,255,.4); }
.profile-name { font-size: 1.5rem; font-weight: 700; }
.profile-email { opacity: .75; font-size: 0.9rem; }
.profile-section { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; }
.profile-section-title { font-size: 1rem; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.pref-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.pref-row:last-child { border-bottom: none; }
.pref-label { font-weight: 600; font-size: 0.92rem; }
.pref-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

.coming-soon-badge { display: inline-flex; align-items: center; gap: 6px; background: #f1f5f9; color: var(--text-muted); padding: 6px 14px; border-radius: 99px; font-size: 0.8rem; font-weight: 600; }

/* ─── About page ────────────────────────────────────────── */
.about-hero { text-align: center; padding: 48px 24px 32px; }
.about-hero-icon { font-size: 4rem; margin-bottom: 16px; }
.about-hero-title { font-size: 2rem; font-weight: 800; margin-bottom: 10px; }
.about-hero-sub { font-size: 1.05rem; color: var(--text-muted); max-width: 520px; margin: 0 auto; }
.about-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; margin: 32px 0; }
.about-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.about-card-icon { font-size: 2rem; margin-bottom: 12px; }
.about-card-title { font-weight: 700; margin-bottom: 8px; }
.about-card-text { font-size: 0.88rem; color: var(--text-muted); line-height: 1.6; }

/* ─── Posts list page ───────────────────────────────────── */
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.filter-btn { padding: 6px 16px; border: 1px solid var(--border); border-radius: 99px; font-size: 0.85rem; font-weight: 500; background: white; cursor: pointer; transition: all .15s; color: var(--text-muted); }
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ─── Login page ────────────────────────────────────────── */
body.login-body { background: linear-gradient(135deg, #1a237e 0%, #1565c0 100%); display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { background: white; border-radius: var(--radius-lg); padding: 48px 40px; max-width: 420px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center; }
.login-logo { font-size: 64px; margin-bottom: 16px; }
.login-title { font-size: 1.8em; color: #1a237e; margin-bottom: 8px; font-weight: 800; }
.login-subtitle { font-size: .95em; color: var(--text-muted); margin-bottom: 32px; line-height: 1.5; }
.login-divider { height: 1px; background: var(--border); margin: 0 0 32px; }
.google-btn-container { display: flex; justify-content: center; margin: 0 auto 20px; }
.login-error { color: var(--danger); font-size: .9em; margin-top: 12px; padding: 10px; background: #fff5f5; border-radius: var(--radius-sm); border: 1px solid #fca5a5; }
.login-note { font-size: .8em; color: #999; margin-top: 24px; line-height: 1.6; }

/* ─── Misc utilities ────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state-text { font-size: 1rem; }

.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-block { display: flex; align-items: center; justify-content: center; padding: 48px; gap: 12px; color: var(--text-muted); font-size: 0.9rem; }

/* Responsive tweaks */
@media (max-width: 640px) {
    .page, .page-narrow { padding: 20px 14px 48px; }
    .hero { padding: 48px 16px 40px; }
    .folder-grid { grid-template-columns: 1fr 1fr; }
    .posts-grid { grid-template-columns: 1fr; }
    .related-grid { grid-template-columns: 1fr; }
    .profile-hero { flex-direction: column; text-align: center; }
    .modal-box { border-radius: var(--radius); }
}

/* ─── Subsection toggle from original ──────────────────── */
.section-type-filter { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; }
.section-type-filter h3 { font-size: 0.9rem; margin-bottom: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.section-toggle-container { display: flex; flex-direction: column; gap: 8px; }
.section-toggle-item { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.9rem; font-weight: 500; }
.section-toggle-item input[type=checkbox] { accent-color: var(--primary); width: 15px; height: 15px; }
.individual-sections { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ─── Quiz / Poll Widget ──────────────────────────────────── */
.quiz-widget-host { margin: 32px 0; }

.quiz-widget {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 24px 20px;
    max-width: 560px;
}
.quiz-widget.loading,
.quiz-widget.error {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 32px 24px;
}

/* Badges (type only — level is inline on question) */
.quiz-badges { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.quiz-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--primary-muted, rgba(99,102,241,.12));
    color: var(--primary);
}

/* Inline level badge — sits at end of question text */
.quiz-level-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: .06em;
    padding: 1px 7px;
    border-radius: 99px;
    vertical-align: middle;
    margin-left: 6px;
    color: #fff;
}
.lvl-a1 { background: #4ade80; color: #14532d; }   /* light green */
.lvl-a2 { background: #16a34a; }                    /* dark green  */
.lvl-b1 { background: #3b82f6; }                    /* blue        */
.lvl-b2 { background: #f97316; }                    /* orange      */
.lvl-c1 { background: #ef4444; }                    /* red         */
.lvl-c2 { background: #9f1239; }                    /* crimson     */

/* Question */
.quiz-question {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 16px;
    color: var(--text);
}

/* Options — pre-vote */
.quiz-options { display: flex; flex-direction: column; gap: 8px; }

button.quiz-option {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border-radius: calc(var(--radius) - 2px);
    border: 1.5px solid var(--border);
    background: var(--bg-alt, var(--bg));
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
button.quiz-option:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--primary-muted, rgba(99,102,241,.07));
}
button.quiz-option:disabled { opacity: 0.65; cursor: not-allowed; }

/* Options — post-vote (div, not button) */
div.quiz-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: calc(var(--radius) - 2px);
    border: 1.5px solid var(--border);
    font-size: 0.9rem;
    flex-wrap: wrap;
}
div.quiz-option.correct {
    border-color: #10b981;
    background: rgba(16,185,129,.08);
}
div.quiz-option.wrong {
    border-color: #ef4444;
    background: rgba(239,68,68,.08);
}
div.quiz-option.chosen-correct {
    border-color: #10b981;
    background: rgba(16,185,129,.12);
}

.quiz-opt-text { flex: 1; }

.quiz-chosen-mark {
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}
div.quiz-option.correct    .quiz-chosen-mark { color: #10b981; }
div.quiz-option.wrong      .quiz-chosen-mark { color: #ef4444; }
div.quiz-option.chosen-correct .quiz-chosen-mark { color: #10b981; }

/* Vote bar */
.quiz-bar-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}
.quiz-bar {
    height: 6px;
    border-radius: 99px;
    background: var(--primary);
    transition: width .4s ease;
    min-width: 2px;
}
div.quiz-option.correct    .quiz-bar { background: #10b981; }
div.quiz-option.wrong      .quiz-bar { background: #ef4444; }
.quiz-pct {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 34px;
    text-align: right;
}

/* Result message */
.quiz-result {
    margin-top: 14px;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: calc(var(--radius) - 2px);
}
.quiz-result.correct-msg { color: #10b981; background: rgba(16,185,129,.1); }
.quiz-result.wrong-msg   { color: #ef4444; background: rgba(239,68,68,.1); }

/* Vote count */
.quiz-vote-count {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* Guest nudge */
.quiz-guest-note {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 640px) {
    .quiz-widget { padding: 16px 14px; }
}

/* ─── Hero split layout (CTA left, daily quiz right) ─────── */
.hero-split {
    display: flex;
    align-items: center;
    gap: 48px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.hero-left {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hero-right {
    flex: 0 0 360px;
    width: 360px;
}

.hero-quiz-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

/* Override quiz-widget inside hero to blend with hero bg */
.hero-right .quiz-widget {
    background: rgba(255,255,255,0.06);
    border-color: rgba(255,255,255,0.12);
}
.hero-right .quiz-question { color: inherit; }
.hero-right button.quiz-option {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.15);
    color: inherit;
}
.hero-right button.quiz-option:hover:not(:disabled) {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.35);
}

/* Mobile: stack vertically, CTA on top */
@media (max-width: 768px) {
    .hero-split {
        flex-direction: column;
        gap: 32px;
        align-items: stretch;
    }
    .hero-left { align-items: center; text-align: center; }
    .hero-right { flex: none; width: 100%; }
}

.hero-quiz-shell {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.hero-quiz-label {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,0.82);
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 99px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.14);
}
/* ─── Grammar Note Chip (inline {{note:id}} widget) ─────── */
.note-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(22, 163, 74, 0.08);
    border: 1.5px solid rgba(22, 163, 74, 0.25);
    border-radius: 99px;
    padding: 3px 6px 3px 8px;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 500;
    color: #15803d;
    vertical-align: middle;
    margin: 0 2px;
    white-space: nowrap;
}

.note-chip-phrase {
    font-weight: 600;
    color: #15803d;
}

.note-chip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid rgba(22, 163, 74, 0.5);
    background: transparent;
    color: #16a34a;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: background .15s, color .15s, border-color .15s;
    flex-shrink: 0;
    animation: note-pulse 1.8s ease-in-out infinite;
}

@keyframes note-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
    50%       { box-shadow: 0 0 0 5px rgba(22, 163, 74, 0); }
}

.note-chip-btn:hover:not(:disabled) {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}

.note-chip-btn.saved {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
    cursor: default;
    animation: none;
}

.note-chip-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    animation: none;
}

/* Profile saved notes list */
.saved-notes-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.saved-note-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    flex-wrap: wrap;
}

.saved-note-phrase {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.saved-note-meaning {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    flex: 1;
    min-width: 0;
}

.saved-note-remove {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 3px 8px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    flex-shrink: 0;
}

.saved-note-remove:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* Profile bookmark cards */
.bookmark-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bookmark-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.bookmark-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.bookmark-item-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 4px;
}

.bookmark-item-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.bookmark-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ─── Note Modal ─────────────────────────────────────────── */
.note-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    transition: opacity .2s ease;
}

.note-modal-overlay.open {
    opacity: 1;
}

.note-modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px 28px 24px;
    max-width: 440px;
    width: 100%;
    position: relative;
    transform: translateY(8px);
    transition: transform .2s ease;
}

.note-modal-overlay.open .note-modal {
    transform: translateY(0);
}

.note-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: background .15s, color .15s;
}

.note-modal-close:hover {
    background: var(--bg);
    color: var(--text);
}

.note-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.note-modal-phrase {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    font-family: var(--font-body);
}

.note-modal-meaning {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
    font-style: italic;
}

.note-modal-image {
    margin-bottom: 16px;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg);
}

.note-modal-image img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 280px;
    object-fit: contain;
}

.note-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

@media (max-width: 480px) {
    .note-modal { padding: 20px 18px 18px; }
    .note-modal-actions { justify-content: stretch; }
    .note-modal-actions .btn { flex: 1; justify-content: center; }
}

/* ── Section selector edit-mode ─────────────────────── */
.section-selector-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.section-selector-header h3 { margin: 0; flex: 1; }
.btn-edit-sections {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
    border: 1px solid var(--border, #d1d5db);
    background: transparent;
    color: var(--text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-edit-sections:hover {
    background: var(--surface-alt, #f3f4f6);
    color: var(--text, #111);
    border-color: var(--primary, #4f46e5);
}
.btn-done-sections {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 14px;
    font-size: 0.82rem;
    border-radius: 6px;
    border: none;
    background: var(--primary, #4f46e5);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.15s;
}
.btn-done-sections:hover { opacity: 0.88; }
.section-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.section-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.83rem;
    font-weight: 500;
    border: 1.5px solid transparent;
}
.pill-on {
    background: var(--primary-light, #ede9fe);
    color: var(--primary-dark, #3730a3);
    border-color: var(--primary-light, #c4b5fd);
}
.pill-off {
    background: var(--surface-alt, #f3f4f6);
    color: var(--text-muted, #9ca3af);
    border-color: var(--border, #e5e7eb);
    text-decoration: line-through;
    opacity: 0.65;
}
.section-selector.editing {
    border: 1.5px solid var(--primary, #4f46e5);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--primary-light, #f5f3ff);
}
#overview-actions button:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
}
/* ─── Image size cap (desktop only) ─────────────────────── */
@media (min-width: 768px) {
    .question-image {
        max-width: 62.8%;
        height: auto;
    }
}