/* ============================================
   ENGLISH QUIZ GLOBAL — GLOBAL STYLESHEET
   Light / Dark theme via CSS variables
   ============================================ */

/* ── THEME VARIABLES ── */
:root {
    /* Surfaces — warm-tinted greys, not pure white */
    --bg:           #f0f0f0;
    --surface:      #fafafa;
    --surface-2:    #f2f2f2;
    --surface-3:    #e8e8e8;

    /* Borders */
    --border:       #dcdcdc;
    --border-soft:  #ebebeb;

    /* Text — not pure black, easier on the eyes */
    --text:         #1a1a1a;
    --text-2:       #555555;
    --text-3:       #999999;

    /* Accent — near-black with hover */
    --accent:       #1a1a1a;
    --accent-hover: #333333;
    --accent-text:  #ffffff;

    /* Semantic */
    --danger:       #c0392b;
    --success:      #27ae60;
    --warning:      #e67e22;
    --info:         #2980b9;

    /* Chart colors — visible on light bg */
    --chart-1:      #1a1a1a;
    --chart-2:      #555555;
    --chart-3:      #999999;
    --chart-4:      #cccccc;
    --chart-accent: #2980b9;

    /* Shadows — more dimensional */
    --shadow-sm:    0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
    --shadow:       0 2px 8px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
    --shadow-md:    0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);

    /* Shape */
    --radius-sm:    6px;
    --radius:       10px;
    --radius-lg:    14px;

    /* Layout */
    --nav-h:        58px;
    --sidebar-w:    240px;
}

[data-theme="dark"] {
    --bg:           #111111;
    --surface:      #1c1c1c;
    --surface-2:    #242424;
    --surface-3:    #2e2e2e;

    --border:       #333333;
    --border-soft:  #2a2a2a;

    --text:         #f0f0f0;
    --text-2:       #aaaaaa;
    --text-3:       #666666;

    --accent:       #f0f0f0;
    --accent-hover: #d8d8d8;
    --accent-text:  #111111;

    /* Chart colors — visible on dark bg */
    --chart-1:      #f0f0f0;
    --chart-2:      #aaaaaa;
    --chart-3:      #666666;
    --chart-4:      #444444;
    --chart-accent: #5dade2;

    --shadow-sm:    0 1px 3px rgba(0,0,0,.4);
    --shadow:       0 2px 8px rgba(0,0,0,.5);
    --shadow-md:    0 4px 16px rgba(0,0,0,.55);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.6);
}

/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background .2s, color .2s;
    min-height: 100vh;
}

img { max-width: 100%; display: block; }
a   { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }

/* ── TOP NAV ── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 200;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 24px;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}

.nav-brand img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid var(--border);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.nav-links a {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: background .15s, color .15s;
    white-space: nowrap;
}

.nav-links a:hover  { background: var(--surface-2); color: var(--text); }
.nav-links a.active { background: var(--accent); color: var(--accent-text); }

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--danger);
    color: #fff;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    margin-left: 4px;
    vertical-align: middle;
}

/* THEME TOGGLE */
.theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--accent); color: var(--accent-text); }

/* NAV MOBILE MENU TOGGLE */
.nav-menu-btn {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

/* ── FOOTER ── */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    padding: 32px 24px;
    margin-top: 60px;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-brand { font-size: 14px; font-weight: 700; color: var(--text); }
.footer-copy  { font-size: 13px; color: var(--text-3); }

.footer-links { display: flex; gap: 20px; flex-wrap: wrap; }
.footer-links a { font-size: 13px; color: var(--text-3); transition: color .15s; }
.footer-links a:hover { color: var(--text); }

/* ── ADMIN LAYOUT ── */
.admin-layout {
    display: flex;
    min-height: calc(100vh - var(--nav-h));
}

.admin-sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    padding: 16px 0;
    box-shadow: var(--shadow-sm);
}

.sidebar-section-label {
    padding: 16px 16px 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-3);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: background .15s, color .15s;
    border-left: 2px solid transparent;
}

.sidebar-link:hover  { background: var(--surface-2); color: var(--text); }
.sidebar-link.active { background: var(--surface-3); color: var(--text); border-left-color: var(--text); font-weight: 600; }

.sidebar-icon { width: 16px; text-align: center; font-size: 13px; flex-shrink: 0; }

.admin-main {
    flex: 1;
    padding: 32px;
    overflow-x: hidden;
    min-width: 0;
}

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 28px; }
.page-title  { font-size: 22px; font-weight: 700; color: var(--text); }
.page-sub    { font-size: 13px; color: var(--text-3); margin-top: 4px; }

/* ── CONTAINER ── */
.container    { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 780px;  margin: 0 auto; padding: 0 24px; }

/* ── CARDS ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-3);
    margin-bottom: 16px;
}

/* ── STAT CARDS ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ── GRID LAYOUTS ── */
.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.four-col  { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

@media (max-width: 900px) {
    .two-col, .three-col { grid-template-columns: 1fr; }
}

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: var(--shadow); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); box-shadow: var(--shadow); }

.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); box-shadow: var(--shadow-sm); }
.btn-danger:hover { opacity: .9; box-shadow: var(--shadow); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); box-shadow: var(--shadow-sm); }
.btn-success:hover { opacity: .9; box-shadow: var(--shadow); }

.btn-sm   { padding: 5px 12px; font-size: 12px; }
.btn-lg   { padding: 12px 28px; font-size: 15px; font-weight: 700; }
.btn-full { width: 100%; justify-content: center; }

/* ── FORMS ── */
.form-group   { margin-bottom: 18px; }
.form-label   { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

@media (max-width: 640px) {
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

.input, .select, .textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
    box-shadow: var(--shadow-sm);
}

.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}

[data-theme="dark"] .input:focus,
[data-theme="dark"] .select:focus,
[data-theme="dark"] .textarea:focus {
    box-shadow: 0 0 0 3px rgba(255,255,255,.08);
}

.textarea { resize: vertical; min-height: 90px; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }

.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input[type="checkbox"] { accent-color: var(--text); width: 15px; height: 15px; }
.check-row label { font-size: 13px; color: var(--text-2); cursor: pointer; }

/* ── ALERTS ── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

[data-theme="dark"] .alert-success { background: #052e16; color: #86efac; border-color: #166534; }
[data-theme="dark"] .alert-error   { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .alert-info    { background: #0c1a3a; color: #93c5fd; border-color: #1e3a8a; }
[data-theme="dark"] .alert-warning { background: #271900; color: #fcd34d; border-color: #78350f; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); box-shadow: var(--shadow); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    white-space: nowrap;
}

td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-2);
    vertical-align: middle;
    background: var(--surface);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.td-name { font-weight: 600; color: var(--text); }
.td-sub  { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ── BADGES ── */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text-2);
    background: var(--surface-2);
}

.badge-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.badge-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.badge-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.badge-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

[data-theme="dark"] .badge-success { background: #052e16; color: #86efac; border-color: #166534; }
[data-theme="dark"] .badge-danger  { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .badge-info    { background: #0c1a3a; color: #93c5fd; border-color: #1e3a8a; }
[data-theme="dark"] .badge-warning { background: #271900; color: #fcd34d; border-color: #78350f; }

/* ── TABS ── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab-btn {
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--text); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── MODALS ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(2px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-3); line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ── PROGRESS BARS ── */
.progress-track { background: var(--surface-3); border-radius: 10px; height: 6px; overflow: hidden; }
.progress-fill  { height: 6px; background: var(--text); border-radius: 10px; transition: width .4s ease; }

/* ── CHARTS — ensure visibility ── */
/* recharts / chart.js default text */
.recharts-cartesian-axis-tick text,
.recharts-legend-item-text {
    fill: var(--text-2) !important;
    font-size: 12px;
}
.recharts-cartesian-grid line { stroke: var(--border) !important; }
.recharts-tooltip-wrapper .recharts-default-tooltip {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-md) !important;
    color: var(--text) !important;
}
/* Generic canvas chart labels */
canvas { max-width: 100%; }

/* ── SECTION DIVIDERS (test page) ── */
.section-divider {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin: 28px 0 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
}

.section-divider-icon { font-size: 18px; color: var(--text-3); }
.section-divider h3   { font-size: 15px; font-weight: 700; color: var(--text); }
.section-divider p    { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ── QUESTION CARDS ── */
.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: 24px 28px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
    transition: box-shadow .2s;
}
.question-card:hover { box-shadow: var(--shadow-md); }

.question-card.listening { border-left-color: var(--text-2); }
.question-card.writing   { border-left-color: var(--text-3); }

.q-number { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); margin-bottom: 10px; }
.q-text   { font-size: 16px; line-height: 1.7; color: var(--text); margin-bottom: 18px; }

.options { display: flex; flex-direction: column; gap: 8px; }
.option-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.option-label:hover { border-color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.option-label input[type="radio"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--text); }

/* ── DIFF TAGS ── */
.diff-tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid var(--border);
    color: var(--text-3);
    background: var(--surface-2);
    margin-left: 6px;
    vertical-align: middle;
}

/* ── PASSAGE BLOCK ── */
.passage-block {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: 22px 26px;
    margin-bottom: 4px;
    margin-top: 24px;
    box-shadow: var(--shadow-sm);
}
.passage-block h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); margin-bottom: 12px; }
.passage-block p  { font-size: 15px; line-height: 1.85; color: var(--text-2); margin-bottom: 10px; }
.toggle-passage   { font-size: 12px; color: var(--text-3); background: none; border: none; cursor: pointer; font-weight: 600; margin-top: 8px; display: block; }
.toggle-passage:hover { color: var(--text); }

/* ── TTS BUTTON ── */
.tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    box-shadow: var(--shadow-sm);
}
.tts-btn:hover  { background: var(--accent); color: var(--accent-text); border-color: var(--accent); box-shadow: var(--shadow); }
.tts-btn.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ── HERO (landing) ── */
.hero {
    background: var(--text);
    color: var(--surface);
    padding: 100px 24px 80px;
    text-align: center;
}
.hero-logo { width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 20px; border: 1px solid rgba(255,255,255,.2); box-shadow: 0 4px 20px rgba(0,0,0,.3); }
.hero h1   { font-size: 2.6rem; font-weight: 800; margin-bottom: 14px; line-height: 1.2; }
.hero p    { font-size: 1.05rem; opacity: .75; max-width: 600px; margin: 0 auto 28px; }
.hero .btn-primary   { background: #fff; color: #000; border-color: #fff; box-shadow: 0 2px 12px rgba(255,255,255,.2); }
.hero .btn-secondary { border-color: rgba(255,255,255,.4); color: #fff; background: transparent; }
.hero .btn-secondary:hover { background: rgba(255,255,255,.1); }

/* ── FEATURE CARDS ── */
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 24px;
    border-radius: var(--radius-lg);
    transition: box-shadow .2s, transform .2s;
    box-shadow: var(--shadow-sm);
}
.feature-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.feature-card h3 { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.feature-card p  { font-size: 13px; color: var(--text-3); line-height: 1.6; }

/* ── NEWS CARDS ── */
.news-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.news-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: box-shadow .2s, transform .2s;
    box-shadow: var(--shadow-sm);
}
.news-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.news-card h3 { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.4; }
.news-card p  { font-size: 13px; color: var(--text-3); line-height: 1.6; }

/* ── MESSAGES ── */
.msg-layout  { display: flex; height: calc(100vh - var(--nav-h)); overflow: hidden; }
.msg-sidebar { width: 300px; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.msg-main    { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.msg-bubble       { max-width: 72%; padding: 10px 14px; border-radius: var(--radius); font-size: 14px; line-height: 1.6; }
.msg-bubble.mine  { background: var(--text); color: var(--surface); align-self: flex-end; border-radius: var(--radius) var(--radius) 2px var(--radius); box-shadow: var(--shadow-sm); }
.msg-bubble.other { background: var(--surface); color: var(--text); align-self: flex-start; border: 1px solid var(--border); border-radius: var(--radius) var(--radius) var(--radius) 2px; box-shadow: var(--shadow-sm); }

/* ── LEADERBOARD ── */
.rank-medal { font-size: 15px; font-weight: 800; color: var(--text); }

/* ── STICKY PROGRESS (test) ── */
.sticky-progress {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-3);
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
}

.progress-bar-top  { height: 3px; background: var(--surface-3); position: fixed; top: var(--nav-h); left: 0; right: 0; z-index: 199; }
.progress-bar-fill { height: 3px; background: var(--text); transition: width .3s; }

/* ── CERTIFICATE ── */
.certificate-wrap {
    background: var(--surface);
    border: 10px solid var(--text);
    max-width: 1000px;
    margin: 0 auto;
    padding: 56px 68px;
    position: relative;
    box-shadow: var(--shadow-lg);
}
.certificate-wrap::before {
    content: '';
    position: absolute;
    inset: 18px;
    border: 1px solid var(--border);
    pointer-events: none;
}

/* ── UTILITY ── */
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.mb-4  { margin-bottom: 16px; }
.mb-6  { margin-bottom: 24px; }
.mb-8  { margin-bottom: 32px; }
.flex  { display: flex; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-sm    { font-size: 13px; }
.text-xs    { font-size: 11px; }
.text-muted { color: var(--text-3); }
.font-bold  { font-weight: 700; }
.w-full     { width: 100%; }
.text-center { text-align: center; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .admin-sidebar.open { display: block; position: fixed; z-index: 300; top: var(--nav-h); left: 0; height: calc(100vh - var(--nav-h)); }
    .admin-main    { padding: 20px 16px; }
    .nav-links     { display: none; }
    .nav-links.open { display: flex; flex-direction: column; position: fixed; top: var(--nav-h); left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px; z-index: 300; gap: 4px; box-shadow: var(--shadow-md); }
    .nav-menu-btn  { display: flex; }
    .hero h1       { font-size: 1.8rem; }
    .msg-sidebar   { width: 260px; }
    .container, .container-sm { padding: 0 16px; }
    .stats-grid    { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .stats-grid  { grid-template-columns: 1fr; }
    .msg-sidebar { width: 100%; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ── THEME TRANSITION ── */
*, *::before, *::after { transition: background-color .2s, border-color .2s, color .15s; }
button, a { transition: background-color .15s, border-color .15s, color .15s, opacity .15s, transform .15s, box-shadow .15s; }