/* ============================================================
   Encelis — Global Design System
   Dark academic palette · Instrument Serif + Inter
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg-base:      #0D1117;
    --bg-surface:   #161B22;
    --bg-elevated:  #21262D;
    --bg-hover:     #2A3140;

    /* Borders */
    --border:       rgba(255, 255, 255, 0.08);
    --border-focus: rgba(232, 168, 56, 0.6);

    /* Text */
    --text-primary:   #F0EDE6;
    --text-secondary: #8B949E;
    --text-muted:     #4B535D;
    --text-inverse:   #0D1117;

    /* Accents */
    --amber:        #E8A838;
    --amber-dim:    rgba(232, 168, 56, 0.15);
    --amber-glow:   rgba(232, 168, 56, 0.30);
    --teal:         #3DBFA0;
    --teal-dim:     rgba(61, 191, 160, 0.15);
    --teal-glow:    rgba(61, 191, 160, 0.25);
    --coral:        #E05A5A;
    --coral-dim:    rgba(224, 90, 90, 0.15);
    --orange:       #F07832;
    --orange-dim:   rgba(240, 120, 50, 0.15);
    --purple:       #9B7BE8;
    --purple-dim:   rgba(155, 123, 232, 0.15);

    /* Typography */
    --font-serif: var(--font-sans);
    --font-sans:  'Inter', system-ui, sans-serif;

    /* Sizing */
    --nav-h:        64px;
    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    16px;
    --radius-xl:    24px;
    --radius-pill:  999px;

    /* Transitions */
    --t-fast:   0.12s ease;
    --t-mid:    0.22s ease;
    --t-slow:   0.4s ease;

    /* Shadows */
    --shadow-card:  0 4px 24px rgba(0, 0, 0, 0.4), inset 0 0 0 1px var(--border);
    --shadow-glow-amber: 0 0 20px rgba(232, 168, 56, 0.2);
    --shadow-glow-teal:  0 0 20px rgba(61, 191, 160, 0.2);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

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

/* Hide number input spinners in Chrome/Safari/Edge */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

img { display: block; max-width: 100%; }
a  { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
ul, ol { list-style: none; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-hover); }

/* ══════════════════════════════════════════════════════════════
   NAVIGATION
   ══════════════════════════════════════════════════════════════ */
.site-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: var(--nav-h);
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}

/* Logo */
.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    transition: opacity var(--t-fast);
}
.nav-logo:hover { opacity: 0.85; }
.nav-logo__img {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
    filter: invert(1); /* make it white on dark bg */
}
.nav-logo__wordmark {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

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

.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--t-fast), background var(--t-fast);
    white-space: nowrap;
}
.nav-link:hover { color: var(--text-primary); background: var(--bg-elevated); }
.nav-link--active { color: var(--text-primary); background: var(--bg-elevated); }
.nav-link--admin  { color: var(--amber); }
.nav-link--admin:hover { color: var(--amber); background: var(--amber-dim); }
.nav-link--danger { color: var(--coral); }

/* Widgets row */
.nav-widgets {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

/* Streak */
.nav-streak {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--amber);
    cursor: default;
}
.nav-streak__icon {
    width: 18px; height: 18px;
    filter: drop-shadow(0 0 6px rgba(232, 168, 56, 0.5));
    animation: flame-pulse 2s ease-in-out infinite;
}
@keyframes flame-pulse {
    0%, 100% { transform: scaleY(1); filter: drop-shadow(0 0 6px rgba(232,168,56,0.5)); }
    50%       { transform: scaleY(1.08); filter: drop-shadow(0 0 10px rgba(232,168,56,0.8)); }
}
.nav-streak__count {
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    min-width: 18px;
}

/* Level Pill */
.nav-level {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}
.level-pill {
    display: flex;
    gap: 2px;
    padding: 3px 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}
.level-seg {
    width: 8px; height: 8px;
    border-radius: 50%;
    transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.level-seg--empty   { background: var(--bg-hover); }
.level-seg--orange  { background: var(--orange); box-shadow: 0 0 6px rgba(240,120,50,0.6); }
.level-seg--green   { background: var(--teal);   box-shadow: 0 0 6px rgba(61,191,160,0.6); }
.level-seg--current { transform: scale(1.35); }
.level-seg--current.level-seg--orange { animation: seg-pulse-orange 1.8s ease-in-out infinite; }
.level-seg--current.level-seg--green  { animation: seg-pulse-green  1.8s ease-in-out infinite; }

@keyframes seg-pulse-orange {
    0%, 100% { box-shadow: 0 0 6px rgba(240,120,50,0.6); }
    50%       { box-shadow: 0 0 14px rgba(240,120,50,1); }
}
@keyframes seg-pulse-green {
    0%, 100% { box-shadow: 0 0 6px rgba(61,191,160,0.6); }
    50%       { box-shadow: 0 0 14px rgba(61,191,160,1); }
}
.level-pill__label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    min-width: 22px;
}

/* User button */
.nav-user { position: relative; }
.nav-user__btn {
    display: flex; align-items: center;
    padding: 2px;
    border-radius: 50%;
    transition: opacity var(--t-fast);
}
.nav-user__btn:hover { opacity: 0.8; }
.nav-user__avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--amber), var(--orange));
    color: var(--text-inverse);
    font-size: 0.875rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.nav-user__dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 180px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 16px 40px rgba(0,0,0,0.5);
    padding: 6px;
    z-index: 200;
    animation: dropdown-in var(--t-mid) ease;
}
@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.nav-user__name {
    padding: 8px 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.dropdown-item {
    display: block;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color var(--t-fast), background var(--t-fast);
}
.dropdown-item:hover { color: var(--text-primary); background: var(--bg-hover); }
.dropdown-item--danger { color: var(--coral); }
.dropdown-item--danger:hover { background: var(--coral-dim); }

/* Hamburger */
.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
    margin-left: auto;
}
.nav-hamburger span {
    display: block;
    width: 22px; height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform var(--t-mid), opacity var(--t-mid);
}

/* Mobile drawer */
.nav-mobile-drawer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: none;
    flex-direction: column;
    gap: 2px;
}
.nav-mobile-drawer:not([hidden]) {
    display: flex;
}
.nav-mobile-drawer .nav-link {
    display: block;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
}

/* ══════════════════════════════════════════════════════════════
   PAGE LAYOUT
   ══════════════════════════════════════════════════════════════ */
.page-wrapper {
    padding-top: var(--nav-h);
    min-height: 100vh;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

.container--narrow {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 24px;
}

.page-header {
    padding: 48px 0 32px;
}
.page-title {
    font-family: var(--font-serif);
    font-size: clamp(1.65rem, 3.6vw, 2.25rem);
    line-height: 1.15;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.page-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ══════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: border-color var(--t-mid), box-shadow var(--t-mid);
}
.card > :last-child { margin-bottom: 0 !important; }
.card:hover { border-color: rgba(255,255,255,0.12); }

.card--glow-amber:hover { box-shadow: var(--shadow-card), var(--shadow-glow-amber); border-color: rgba(232,168,56,0.2); }
.card--glow-teal:hover  { box-shadow: var(--shadow-card), var(--shadow-glow-teal);  border-color: rgba(61,191,160,0.2); }

.card--locked {
    opacity: 0.5;
    pointer-events: none;
}
.card--completed {
    border-color: rgba(61,191,160,0.2);
}
.card--active {
    border-color: rgba(232,168,56,0.3);
    box-shadow: var(--shadow-card), 0 0 30px rgba(232,168,56,0.08);
}

/* ── Module Card ─ */
.module-card {
    position: relative;
    overflow: hidden;
}
.module-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.module-card__title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.3;
}
.module-card__badge {
    flex-shrink: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
}
.badge--locked    { background: var(--bg-hover); color: var(--text-muted); }
.badge--open      { background: var(--amber-dim); color: var(--amber); }
.badge--completed { background: var(--teal-dim);  color: var(--teal); }

.module-card__desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Progress bar */
.progress-bar {
    height: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-bar__fill {
    height: 100%;
    border-radius: var(--radius-pill);
    background: linear-gradient(90deg, var(--amber), var(--orange));
    transition: width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.progress-bar__fill--complete {
    background: linear-gradient(90deg, var(--teal), #2B9E86);
}
.progress-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.module-card__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.atom-page-grid {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
    padding: 24px 0 48px;
    align-items: start;
}

/* Lock icon */
.module-card__lock {
    position: absolute;
    top: 16px; right: 16px;
    width: 20px; height: 20px;
    color: var(--text-muted);
    opacity: 0.4;
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.5;
    transition: all var(--t-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background var(--t-fast);
}
.btn:hover::after { background: rgba(255,255,255,0.05); }
.btn:active { transform: translateY(1px); }

.btn--sm   { padding: 6px 14px; font-size: 0.8125rem; }
.btn--lg   { padding: 14px 28px; font-size: 1rem; }
.btn--full { width: 100%; }

.btn--primary {
    background: linear-gradient(135deg, var(--amber), var(--orange));
    color: var(--text-inverse);
    box-shadow: 0 4px 14px rgba(232,168,56,0.3);
}
.btn--primary:hover { box-shadow: 0 6px 20px rgba(232,168,56,0.45); }

.btn--teal {
    background: linear-gradient(135deg, var(--teal), #2B9E86);
    color: var(--text-inverse);
    box-shadow: 0 4px 14px rgba(61,191,160,0.25);
}
.btn--teal:hover { box-shadow: 0 6px 20px rgba(61,191,160,0.4); }

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn--ghost:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.2); background: var(--bg-elevated); }

.btn--danger {
    background: var(--coral-dim);
    color: var(--coral);
    border: 1px solid rgba(224,90,90,0.25);
}
.btn--danger:hover { background: rgba(224,90,90,0.25); }

.btn--disabled,
.btn[disabled] {
    opacity: 0.4;
    pointer-events: none;
}

/* ══════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 20px;
}
.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}
.form-input,
.form-textarea,
.form-select {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 10px 14px;
    font-size: 0.9375rem;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    width: 100%;
}
.form-select {
    appearance: none;
    cursor: pointer;
    padding-right: 42px;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}
.form-select option {
    background: var(--bg-surface);
    color: var(--text-primary);
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(232,168,56,0.12);
}
.form-textarea { resize: vertical; min-height: 120px; }
.form-hint { font-size: 0.8125rem; color: var(--text-muted); }
.form-error { font-size: 0.8125rem; color: var(--coral); }
.form-static {
    display: flex;
    align-items: center;
    min-height: 43px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-secondary);
}
.form-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    user-select: none;
}
.form-toggle__input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.form-toggle__track {
    display: inline-flex;
    align-items: center;
    width: 38px;
    height: 22px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-elevated);
    transition: background var(--t-fast), border-color var(--t-fast);
}
.form-toggle__thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--t-fast), background var(--t-fast);
}
.form-toggle__input:checked + .form-toggle__track {
    border-color: rgba(61,191,160,0.55);
    background: var(--teal-dim);
}
.form-toggle__input:checked + .form-toggle__track .form-toggle__thumb {
    background: var(--teal);
    transform: translateX(16px);
}
.form-toggle__input:focus-visible + .form-toggle__track {
    outline: 3px solid rgba(232,168,56,0.2);
    outline-offset: 2px;
}
.admin-select {
    position: relative;
    width: 100%;
}
.admin-select__native {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
.atom-picker.admin-select__native { display: none; }
.admin-select__button {
    position: relative;
    width: 100%;
    min-height: 43px;
    padding: 10px 42px 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.admin-select__button::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 15px;
    width: 7px;
    height: 7px;
    border-right: 1px solid var(--text-muted);
    border-bottom: 1px solid var(--text-muted);
    transform: translateY(-65%) rotate(45deg);
}
.admin-select__button[aria-expanded='true'] {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(232,168,56,0.12);
}
.admin-select__button[aria-expanded='true']::after {
    transform: translateY(-25%) rotate(225deg);
}
.admin-select__menu {
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    padding: 5px;
    max-height: min(360px, 55vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--border-focus);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    box-shadow: 0 14px 30px rgba(0,0,0,0.35);
}
.admin-select__menu::-webkit-scrollbar { width: 8px; }
.admin-select__menu::-webkit-scrollbar-track { background: transparent; }
.admin-select__menu::-webkit-scrollbar-thumb {
    border: 2px solid var(--bg-surface);
    border-radius: var(--radius-pill);
    background: var(--border-focus);
}
.admin-select__menu { scrollbar-color: var(--border-focus) transparent; scrollbar-width: thin; }
.admin-select__option {
    display: block;
    width: 100%;
    padding: 10px 11px;
    border: 0;
    border-radius: calc(var(--radius-md) - 2px);
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.admin-select__option:hover,
.admin-select__option:focus-visible,
.admin-select__option[aria-selected='true'] {
    background: var(--amber-dim);
    color: var(--text-primary);
    outline: none;
}
.admin-select__option:disabled,
.admin-select__option[aria-disabled='true'] {
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.55;
}

/* ══════════════════════════════════════════════════════════════
   AUTH PAGES
   ══════════════════════════════════════════════════════════════ */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: radial-gradient(ellipse at 50% -10%, rgba(232,168,56,0.08) 0%, transparent 60%);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 0 0 1px var(--border);
}
.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 32px;
}
.auth-logo img {
    width: 40px; height: 40px;
    border-radius: 50%;
    filter: invert(1);
}
.auth-logo__name {
    font-family: var(--font-sans);
    font-weight: 600;
    letter-spacing: -0.02em;
    font-size: 1.5rem;
    color: var(--text-primary);
}
.auth-title {
    font-family: var(--font-sans);
    font-weight: 600;
    letter-spacing: -0.02em;
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 6px;
}
.auth-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
}
.auth-footer {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 24px;
}
.auth-footer a { color: var(--amber); text-decoration: underline; text-underline-offset: 3px; }

/* Alert flash messages */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 20px;
    border: 1px solid transparent;
}
.alert--error   { background: var(--coral-dim); color: var(--coral); border-color: rgba(224,90,90,0.2); }
.alert--success { background: var(--teal-dim);  color: var(--teal);  border-color: rgba(61,191,160,0.2); }
.alert--info    { background: var(--amber-dim); color: var(--amber); border-color: rgba(232,168,56,0.2); }
.alert--warning { background: var(--amber-dim); color: var(--amber);  border-color: rgba(232,168,56,0.35); }

/* ══════════════════════════════════════════════════════════════
   QUIZ / PRACTICE UI
   ══════════════════════════════════════════════════════════════ */
.quiz-wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 24px;
}

/* Quiz header */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
}
.quiz-progress-track {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--amber), var(--orange));
    border-radius: var(--radius-pill);
    transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.quiz-counter {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Question card */
.question-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 32px;
    margin-bottom: 24px;
    animation: card-in var(--t-slow) ease;
    box-shadow: var(--shadow-card);
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.question-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.question-diff-badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 700;
    margin-left: 8px;
}
.diff-1 { background: var(--teal-dim);   color: var(--teal); }
.diff-2 { background: var(--teal-dim);   color: var(--teal); }
.diff-3 { background: var(--amber-dim);  color: var(--amber); }
.diff-4 { background: var(--amber-dim);  color: var(--amber); }
.diff-5 { background: var(--orange-dim); color: var(--orange); }
.diff-6 { background: var(--coral-dim);  color: var(--coral); }

.question-text {
    font-family: var(--font-serif);
    font-size: clamp(1.1rem, 2.5vw, 1.375rem);
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-line;
    margin-bottom: 28px;
}
.question-blank {
    display: inline-block;
    border-bottom: 2px solid var(--amber);
    min-width: 80px;
    margin: 0 4px;
    color: transparent;
}

/* Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}
.option-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9375rem;
    text-align: left;
    cursor: pointer;
    transition: all var(--t-fast);
    width: 100%;
}
.option-btn:hover:not(.option-btn--selected):not(.option-btn--correct):not(.option-btn--wrong) {
    border-color: rgba(255,255,255,0.2);
    background: var(--bg-hover);
}
.option-letter {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all var(--t-fast);
}
.option-btn--selected .option-letter {
    background: var(--amber);
    color: var(--text-inverse);
    border-color: var(--amber);
}
.option-btn--selected {
    border-color: var(--amber);
    background: var(--amber-dim);
}
.option-btn--correct {
    border-color: var(--teal);
    background: var(--teal-dim);
}
.option-btn--correct .option-letter {
    background: var(--teal);
    color: var(--text-inverse);
    border-color: var(--teal);
}
.option-btn--wrong {
    border-color: var(--coral);
    background: var(--coral-dim);
}
.option-btn--wrong .option-letter {
    background: var(--coral);
    color: var(--text-inverse);
    border-color: var(--coral);
}

/* Fill blank input */
.fill-input-wrap { margin-bottom: 24px; }
.fill-input {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 14px 18px;
    font-size: 1rem;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.fill-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(232,168,56,0.12);
}
.fill-input--correct { border-color: var(--teal); background: var(--teal-dim); }
.fill-input--wrong   { border-color: var(--coral); background: var(--coral-dim); }

/* Explanation box */
.explanation-box {
    padding: 14px 18px;
    background: var(--bg-base);
    border-left: 3px solid var(--amber);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 16px;
    margin-bottom: 16px;
    animation: card-in var(--t-mid) ease;
}
.explanation-box strong { color: var(--text-primary); }

/* Quiz actions row */
.quiz-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Results screen */
.results-card {
    text-align: center;
    padding: 48px 32px;
}
.results-score {
    font-family: var(--font-serif);
    font-size: clamp(3rem, 8vw, 5rem);
    line-height: 1;
    margin-bottom: 8px;
}
.results-score--pass { color: var(--teal); }
.results-score--fail { color: var(--coral); }
.results-label {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}
.results-breakdown {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}
.results-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.results-stat__value {
    font-size: 1.5rem;
    font-weight: 700;
}
.results-stat__label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat--correct { color: var(--teal); }
.stat--wrong   { color: var(--coral); }

/* ══════════════════════════════════════════════════════════════
   THEORY PAGE
   ══════════════════════════════════════════════════════════════ */
.theory-body {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
}
.theory-body h2 { font-family: var(--font-serif); font-size: 1.5rem; margin: 32px 0 12px; color: var(--text-primary); }
.theory-body h3 { font-family: var(--font-serif); font-size: 1.2rem; margin: 24px 0 10px; color: var(--amber); }
.theory-body p  { margin-bottom: 16px; }
.theory-body ul, .theory-body ol { padding-left: 20px; margin-bottom: 16px; }
.theory-body li { margin-bottom: 6px; list-style: disc; }
.theory-body ol li { list-style: decimal; }
.theory-body strong { color: var(--amber); font-weight: 600; }
.theory-body em     { color: var(--teal); font-style: italic; }
.theory-body code {
    font-family: 'Courier New', monospace;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.875em;
    color: var(--amber);
}
.theory-body table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.theory-body th, .theory-body td {
    padding: 10px 14px;
    border: 1px solid var(--border);
    font-size: 0.9rem;
    text-align: left;
}
.theory-body th {
    background: var(--bg-elevated);
    font-weight: 600;
    color: var(--text-secondary);
}
.theory-body tr:nth-child(even) { background: rgba(255,255,255,0.02); }

/* ══════════════════════════════════════════════════════════════
   WEEKLY STATS
   ══════════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.stat-card__value {
    font-family: var(--font-serif);
    font-size: 2rem;
    line-height: 1;
    color: var(--text-primary);
}
.stat-card--amber .stat-card__value { color: var(--amber); }
.stat-card--teal  .stat-card__value { color: var(--teal); }

.weak-atoms-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}
.weak-atom-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.weak-atom-row__name { flex: 1; font-size: 0.9rem; }
.weak-atom-row__bar  { flex: 0 0 120px; height: 4px; background: var(--bg-elevated); border-radius: var(--radius-pill); overflow: hidden; }
.weak-atom-row__fill { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--coral), var(--orange)); }
.weak-atom-row__pct  { font-size: 0.8125rem; font-weight: 600; color: var(--coral); min-width: 40px; text-align: right; }

/* Archive list */
.archive-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.archive-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    transition: border-color var(--t-fast);
}
.archive-row:hover { border-color: rgba(255,255,255,0.15); }
.archive-row__label { color: var(--text-secondary); }
.archive-row__score { font-weight: 700; color: var(--amber); }

/* ══════════════════════════════════════════════════════════════
   ADMIN PANEL
   ══════════════════════════════════════════════════════════════ */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: calc(100vh - var(--nav-h));
    gap: 0;
}
.admin-sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 24px 0;
}
.admin-sidebar__title {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 20px 12px;
}
.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all var(--t-fast);
    border-left: 2px solid transparent;
}
.admin-nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
}
.admin-nav-link--active {
    color: var(--amber);
    border-left-color: var(--amber);
    background: var(--amber-dim);
}
.admin-content {
    padding: 32px;
    overflow: auto;
}
.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-primary);
    vertical-align: middle;
}
.data-table tr:hover td { background: rgba(255,255,255,0.02); }
.data-table tr:last-child td { border-bottom: none; }

/* Tag badges */
.tag {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.tag--mc       { background: var(--purple-dim); color: var(--purple); }
.tag--fill     { background: var(--amber-dim);  color: var(--amber); }
.tag--correct  { background: var(--teal-dim);   color: var(--teal); }
.tag--para     { background: var(--orange-dim); color: var(--orange); }
.tag--draft    { background: var(--bg-elevated); color: var(--text-muted); }
.tag--published{ background: var(--teal-dim); color: var(--teal); }

/* Inline actions */
.actions-row { display: flex; gap: 6px; flex-wrap: wrap; }
.atom-order-actions { display: inline-flex; gap: 4px; }
.atom-order-actions .btn { min-width: 32px; padding: 6px 9px; }

/* ══════════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 32px;
    text-align: center;
    gap: 12px;
}
.empty-state__icon {
    font-size: 3rem;
    opacity: 0.3;
    margin-bottom: 8px;
}
.empty-state__title {
    font-family: var(--font-serif);
    font-size: 1.375rem;
    color: var(--text-primary);
}
.empty-state__desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 360px;
    line-height: 1.6;
}

/* Cooldown display */
.cooldown-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-surface);
    border: 1px solid rgba(155,123,232,0.2);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}
.cooldown-banner__icon { font-size: 2rem; }
.cooldown-banner__text h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.cooldown-banner__text p  { font-size: 0.875rem; color: var(--text-secondary); }
.cooldown-timer { font-weight: 700; color: var(--purple); font-size: 1.1rem; }

/* ══════════════════════════════════════════════════════════════
   DIVIDERS & SPACING UTILITIES
   ══════════════════════════════════════════════════════════════ */
.divider {
    height: 1px;
    background: var(--border);
    margin: 24px 0;
}
.section-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 16px;
}
.section-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }
.flex   { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-small { font-size: 0.875rem; }
.text-amber { color: var(--amber); }
.text-teal  { color: var(--teal); }
.text-coral { color: var(--coral); }

/* Atom list within module */
.atom-picker-label,
.atom-picker { display: none; }
.atom-list { display: flex; flex-direction: column; gap: 8px; }
.atom-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: border-color var(--t-fast), background var(--t-fast);
}
.atom-row:hover { border-color: rgba(255,255,255,0.12); background: var(--bg-hover); }
.atom-row--locked { opacity: 0.45; pointer-events: none; }
.atom-row--completed { border-color: rgba(61,191,160,0.2); }
.atom-row__num {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}
.atom-row--completed .atom-row__num { background: var(--teal-dim); border-color: var(--teal); color: var(--teal); }
.atom-row__info { flex: 1; }
.atom-row__title { font-size: 0.9rem; font-weight: 500; }
.atom-row__meta  { font-size: 0.75rem; color: var(--text-muted); }
.atom-row__status { font-size: 0.75rem; font-weight: 600; }

/* ══════════════════════════════════════════════════════════════
   RICH EDITOR (admin theory)
   ══════════════════════════════════════════════════════════════ */
.rich-editor-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 8px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
}
.toolbar-btn {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 600;
    transition: all var(--t-fast);
}
.toolbar-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.toolbar-btn--active { color: var(--amber); background: var(--amber-dim); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    .nav-links, .nav-widgets { display: none; }
    .nav-hamburger { display: flex; }
    .nav-inner { gap: 16px; }

    .admin-layout { grid-template-columns: 1fr; min-height: auto; }
    .admin-sidebar {
        align-self: start;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 12px 0;
    }
    .admin-content {
        min-width: 0;
        padding: 20px 16px;
    }
    .admin-content > * { max-width: 100%; }
    .admin-content .card { overflow-x: auto !important; }
    .admin-content .data-table { min-width: 640px; }
    .admin-form-grid { grid-template-columns: 1fr; gap: 0; }
    .admin-content .page-title { margin-bottom: 16px !important; }
    .admin-content .btn { max-width: 100%; }

    .module-card { padding: 18px; }
    .module-card__header { flex-direction: column; gap: 10px; }
    .module-card__badge { align-self: flex-start; }
    .module-card__actions { align-items: stretch; }
    .module-card__actions .btn { flex: 1 1 150px; text-align: center; }

    .atom-page-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        padding-top: 16px;
    }
    .atom-page-grid > aside .card { padding: 14px; }
    .atom-picker-label {
        display: block;
        margin: 0 0 6px;
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }
    .atom-picker {
        display: block;
        width: 100%;
        min-height: 44px;
        margin-bottom: 12px;
        padding: 10px 12px;
        border: 1px solid var(--border-focus);
        border-radius: var(--radius-md);
        background: var(--bg-elevated);
        color: var(--text-primary);
        font: inherit;
    }
    .atom-page-grid .atom-list {
        display: none;
    }
    .atom-page-grid .atom-row { min-width: 0; padding: 10px; }
    .atom-page-grid .atom-row__title { overflow-wrap: anywhere; }

    .quiz-wrap { padding: 24px 16px; }
    .question-card { padding: 20px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .container { padding: 0 16px; }
    .auth-card { padding: 28px 20px; }
    .results-card { padding: 32px 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { padding: 32px 0 24px; }
    .page-subtitle { font-size: 0.9rem; }
    .module-card__actions { flex-direction: column; }
    .module-card__actions .btn { flex-basis: auto; width: 100%; }
    .atom-page-grid .atom-list { grid-template-columns: 1fr; }
}
