/* ============================================================
   SHAI — design system (teal · mint · achievement orange)
   Style: bento + soft shadows, shadcn/21st.dev inspired.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* --- Reset & base ------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
    /* Brand scale — teal */
    --brand-50:  #F0FDFA;
    --brand-100: #CCFBF1;
    --brand-200: #99F6E4;
    --brand-300: #5EEAD4;
    --brand-400: #2DD4BF;
    --brand-500: #14B8A6;
    --brand-600: #0D9488;   /* primary */
    --brand-700: #0F766E;
    --brand-800: #115E59;
    --brand-900: #134E4A;

    /* Accents */
    --orange-50:  #FFF7ED;
    --orange-100: #FFEDD5;
    --orange-400: #FB923C;
    --orange-500: #F97316;  /* achievement CTA */
    --orange-600: #EA580C;

    --yellow-100: #FEF9C3;
    --yellow-500: #EAB308;
    --rose-500:   #F43F5E;
    --indigo-500: #6366F1;
    --emerald-500: #10B981;

    /* Surfaces */
    --bg:        #F0FDFA;
    --bg-2:      #ECFEFF;
    --panel:     #FFFFFF;
    --panel-2:   #F8FFFE;

    /* Text */
    --text:      #0F172A;
    --text-soft: #134E4A;
    --muted:     #64748B;
    --soon:      #94A3B8;

    /* Strokes */
    --border:        #E2E8F0;
    --border-strong: #CBD5E1;
    --border-brand:  #CCFBF1;

    /* Legacy aliases — keep existing classes mapped */
    --accent:      var(--brand-600);
    --accent-2:    var(--brand-400);
    --accent-warm: var(--orange-500);

    /* Shadows — teal-tinted, soft */
    --shadow:        0 1px 2px rgba(13, 148, 136, 0.05), 0 1px 3px rgba(13, 148, 136, 0.07);
    --shadow-hover:  0 6px 20px rgba(13, 148, 136, 0.14), 0 2px 6px rgba(13, 148, 136, 0.07);
    --shadow-lg:     0 16px 40px rgba(13, 148, 136, 0.16), 0 4px 12px rgba(13, 148, 136, 0.08);

    /* Radii */
    --r-sm:   8px;
    --r-md:   12px;
    --r-lg:   16px;
    --r-xl:   20px;
    --r-2xl:  24px;
    --r-full: 9999px;

    /* Type */
    --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
    --font-mono:    'JetBrains Mono', 'SFMono-Regular', Consolas, Menlo, monospace;

    /* Motion */
    --t-fast: 150ms;
    --t-base: 200ms;
    --t-slow: 320ms;
    --ease:   cubic-bezier(0.2, 0.8, 0.2, 1);
}

body {
    font-family: var(--font-sans);
    background:
        radial-gradient(900px 600px at -10% -10%, rgba(45, 212, 191, 0.18), transparent 60%),
        radial-gradient(700px 500px at 110% 0%, rgba(249, 115, 22, 0.12), transparent 60%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv11', 'ss01';
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
    color: var(--text);
}

a { color: var(--brand-700); }

::selection {
    background: var(--brand-200);
    color: var(--brand-900);
}

/* --- Layout ------------------------------------------------------------ */
.container {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 72px;
    flex: 1;
}

/* --- Header / footer --------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid rgba(13, 148, 136, 0.08);
    padding: 14px 24px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.site-header__user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--muted);
}

.site-header__user .user-name {
    font-weight: 600;
    color: var(--text);
}

.brand {
    text-decoration: none;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--orange-500) 100%);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
    flex-shrink: 0;
}

.brand-mark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 22px;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--orange-500) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    position: relative;
}

.brand-tag {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.site-footer {
    text-align: center;
    padding: 24px;
    color: var(--muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.4);
}

/* --- Hero -------------------------------------------------------------- */
.hero {
    text-align: center;
    padding: 64px 0 40px;
    position: relative;
}

.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--brand-700);
    background: var(--brand-100);
    padding: 6px 14px;
    border-radius: var(--r-full);
    margin-bottom: 20px;
}

.hero-eyebrow::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-600);
    box-shadow: 0 0 8px var(--brand-400);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(40px, 6vw, 60px);
    margin: 0 0 14px;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

.shai-name {
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-400) 45%, var(--orange-500) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-sub {
    color: var(--muted);
    font-size: 18px;
    margin: 0;
    max-width: 580px;
    margin: 0 auto;
}

/* --- Subject grid (homepage bento) ------------------------------------ */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
    margin-top: 40px;
}

.subject-card {
    position: relative;
    display: block;
    padding: 28px 26px;
    border-radius: var(--r-xl);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text);
    overflow: hidden;
    transition: transform var(--t-base) var(--ease),
                border-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.subject-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--brand-100), transparent 60%);
    opacity: 0;
    transition: opacity var(--t-base) var(--ease);
    pointer-events: none;
}

.subject-card > * { position: relative; z-index: 1; }

.subject-card h2 {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 700;
}

.subject-status {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

.subject-card--available {
    cursor: pointer;
}

.subject-card--available:hover {
    transform: translateY(-3px);
    border-color: var(--brand-300);
    box-shadow: var(--shadow-hover);
}

.subject-card--available:hover::before { opacity: 1; }

/* Subject accent dot (per-subject color tag) */
.subject-card .subject-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    background: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.15);
    vertical-align: middle;
}

/* Per-subject accents — applied by subject_id class on the card */
.subject-card--physics   .subject-dot { background: var(--brand-500);  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.18); }
.subject-card--chemistry .subject-dot { background: var(--orange-500); box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.18); }
.subject-card--biology   .subject-dot { background: var(--emerald-500); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18); }
.subject-card--maths     .subject-dot { background: var(--indigo-500); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18); }

.subject-card--chemistry:hover::before { background: linear-gradient(135deg, var(--orange-100), transparent 60%); }
.subject-card--chemistry:hover         { border-color: var(--orange-400); }
.subject-card--biology:hover::before   { background: linear-gradient(135deg, #D1FAE5, transparent 60%); }
.subject-card--biology:hover           { border-color: var(--emerald-500); }
.subject-card--maths:hover::before     { background: linear-gradient(135deg, #E0E7FF, transparent 60%); }
.subject-card--maths:hover             { border-color: var(--indigo-500); }

.subject-card--soon {
    opacity: 0.66;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.6);
}

.subject-arrow {
    position: absolute;
    bottom: 22px;
    right: 24px;
    width: 36px;
    height: 36px;
    border-radius: var(--r-full);
    background: var(--brand-50);
    color: var(--brand-700);
    display: grid;
    place-items: center;
    font-size: 16px;
    transition: background var(--t-base) var(--ease),
                color var(--t-base) var(--ease),
                transform var(--t-base) var(--ease);
}

.subject-card--available:hover .subject-arrow {
    background: var(--brand-600);
    color: #fff;
    transform: translateX(3px);
}

.subject-card--chemistry:hover .subject-arrow { background: var(--orange-500); color: #fff; }
.subject-card--biology:hover   .subject-arrow { background: var(--emerald-500); color: #fff; }
.subject-card--maths:hover     .subject-arrow { background: var(--indigo-500); color: #fff; }

/* --- Breadcrumbs ------------------------------------------------------- */
.breadcrumbs {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 20px;
    font-weight: 500;
}

.breadcrumbs a {
    color: var(--muted);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}

.breadcrumbs a:hover { color: var(--brand-700); }

.breadcrumbs .sep {
    margin: 0 8px;
    opacity: 0.5;
}

/* --- Section list ----------------------------------------------------- */
.lede {
    color: var(--muted);
    margin: 0 0 28px;
    font-size: 16px;
}

.section-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.section-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    margin-bottom: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    transition: border-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.section-item:hover {
    border-color: var(--brand-300);
    box-shadow: var(--shadow-hover);
}

.section-num {
    font-weight: 700;
    color: var(--brand-600);
    min-width: 28px;
    font-variant-numeric: tabular-nums;
}

.section-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    flex: 1;
    transition: color var(--t-fast) var(--ease);
}

.section-link:hover { color: var(--brand-700); }

.section-name--soon {
    color: var(--muted);
    flex: 1;
}

.badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: var(--r-full);
    font-weight: 600;
    display: inline-block;
}

.badge--ready {
    background: var(--brand-100);
    color: var(--brand-800);
}

.badge--soon {
    background: #F1F5F9;
    color: var(--muted);
}

/* --- Feature grid (subject hub bento) --------------------------------- */
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    margin-top: 32px;
}

.feature-card {
    position: relative;
    padding: 28px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.feature-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--brand-100), transparent 60%);
    opacity: 0;
    transition: opacity var(--t-base) var(--ease);
    pointer-events: none;
}

.feature-card > * { position: relative; z-index: 1; }

.feature-card h2 {
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: 700;
}

.feature-card p {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 15px;
}

.feature-card .placeholder {
    font-size: 13px;
    color: var(--orange-600);
    margin-top: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.feature-card--later {
    opacity: 0.66;
}

.feature-card--later .placeholder { color: var(--muted); }

.feature-card--link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: transform var(--t-base) var(--ease),
                border-color var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
}

.feature-card--link:hover {
    transform: translateY(-3px);
    border-color: var(--brand-300);
    box-shadow: var(--shadow-hover);
}

.feature-card--link:hover::before { opacity: 1; }

.feature-cta {
    margin-top: 14px !important;
    color: var(--brand-700) !important;
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.feature-card--link:hover .feature-cta { color: var(--orange-600) !important; }

/* Optional icon container per feature */
.feature-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--r-md);
    background: var(--brand-100);
    color: var(--brand-700);
    display: grid;
    place-items: center;
    margin-bottom: 14px;
    font-size: 22px;
    font-weight: 700;
}

.feature-card--notes       .feature-icon { background: #E0F2FE; color: #0369A1; }
.feature-card--chat        .feature-icon { background: var(--brand-100); color: var(--brand-700); }
.feature-card--papers      .feature-icon,
.feature-card--past-papers .feature-icon { background: var(--orange-100); color: var(--orange-600); }
.feature-card--flashcards  .feature-icon { background: #FCE7F3; color: #BE185D; }
.feature-card--video       .feature-icon { background: #EDE9FE; color: #6D28D9; }

/* --- Notes page ------------------------------------------------------- */
.notes-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    margin-top: 8px;
}

@media (max-width: 880px) {
    .notes-layout { grid-template-columns: 1fr; }
    .notes-toc { position: static !important; max-height: none !important; }
}

.notes-toc {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 20px 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    font-size: 14px;
    box-shadow: var(--shadow);
}

.notes-toc > h2 {
    margin: 0 6px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-weight: 700;
    font-family: var(--font-sans);
}

.toc-sections,
.toc-subs {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-section { margin: 4px 0; }
.toc-sub { margin: 2px 0; }

.notes-toc details > summary {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    cursor: pointer;
    padding: 7px 10px;
    border-radius: var(--r-sm);
    transition: background var(--t-fast) var(--ease);
}

.notes-toc details > summary::-webkit-details-marker { display: none; }
.notes-toc details > summary::marker { content: ''; }

.notes-toc details > summary:hover {
    background: var(--brand-50);
}

.toc-chevron {
    flex: 0 0 auto;
    width: 0;
    height: 0;
    border-left: 4px solid var(--muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform var(--t-fast) var(--ease);
    margin-left: 2px;
}

.notes-toc details[open] > summary .toc-chevron {
    transform: rotate(90deg);
    border-left-color: var(--brand-600);
}

.toc-section-link {
    flex: 1;
    text-decoration: none;
    color: var(--text);
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
}
.toc-section-link:hover { color: var(--brand-700); }
.toc-section-num {
    color: var(--brand-600);
    font-weight: 700;
    min-width: 16px;
    font-variant-numeric: tabular-nums;
}
.toc-section-title { flex: 1; }
.toc-section--active > details > summary {
    background: var(--brand-100);
}
.toc-section--active > details > summary .toc-section-link {
    color: var(--brand-800);
}

.toc-subs {
    padding: 2px 0 6px 18px;
    margin: 0;
    border-left: 2px solid var(--border);
    margin-left: 8px;
}

.toc-link {
    color: var(--text);
    text-decoration: none;
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 8px;
    line-height: 1.35;
    font-weight: 500;
}

.toc-num {
    color: var(--brand-600);
    font-weight: 700;
    font-size: 13px;
    min-width: 24px;
    font-variant-numeric: tabular-nums;
}

.toc-title { flex: 1; }

.toc-link:hover .toc-title,
.toc-link:hover .toc-num { color: var(--brand-700); }

.toc-badge {
    font-size: 10px;
    font-weight: 700;
    background: var(--orange-100);
    color: var(--orange-600);
    padding: 2px 7px;
    border-radius: var(--r-full);
    letter-spacing: 0.05em;
}

.toc-sub--active > details > summary {
    background: var(--brand-100);
}

.toc-sub--active .toc-title,
.toc-sub--active .toc-num { color: var(--brand-800); }

.toc-headings {
    list-style: none;
    padding: 4px 0 8px 24px;
    margin: 0;
    border-left: 2px solid var(--border);
    margin-left: 14px;
}

.toc-headings li { margin: 0; }

.toc-headings a {
    color: var(--muted);
    text-decoration: none;
    display: block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.4;
    transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.toc-headings a:hover {
    color: var(--brand-700);
    background: var(--brand-50);
}

/* The pager at the bottom of the notes body. */
.notes-pager {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.pager-link {
    flex: 0 1 auto;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    padding: 14px 18px;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--panel);
    transition: border-color var(--t-base) var(--ease),
                transform var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease);
    min-width: 0;
}

.pager-link:hover {
    border-color: var(--brand-300);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.pager-link--prev { text-align: left; }
.pager-link--next { text-align: right; margin-left: auto; }

.pager-arrow {
    color: var(--brand-600);
    font-size: 20px;
    font-weight: 700;
}

.pager-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    font-weight: 600;
}

.pager-title {
    display: block;
    font-weight: 600;
    color: var(--text);
    margin-top: 2px;
}

.notes-h1-num {
    color: var(--brand-600);
    font-weight: 800;
    margin-right: 10px;
    font-variant-numeric: tabular-nums;
}

.notes-badge {
    margin-left: 10px;
    font-size: 11px;
    font-weight: 700;
    background: var(--orange-100);
    color: var(--orange-600);
    padding: 4px 10px;
    border-radius: var(--r-full);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    vertical-align: middle;
}

/* --- Subject hero --------------------------------------------------- */
.subject-hero {
    margin-top: 4px;
    margin-bottom: 28px;
}
.subject-hero h1 {
    margin: 0 0 6px;
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --- Past papers page ----------------------------------------------- */
.papers-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    margin-top: 8px;
}

@media (max-width: 880px) {
    .papers-layout { grid-template-columns: 1fr; }
    .papers-sidebar { position: static !important; max-height: none !important; }
}

.papers-sidebar {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 20px 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    font-size: 14px;
}

.papers-sidebar h2 {
    margin: 0 6px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-weight: 700;
    font-family: var(--font-sans);
}

.papers-sidebar-h2 { margin-top: 22px !important; }

.papers-filters,
.papers-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.papers-filter {
    display: flex;
    gap: 8px;
    align-items: baseline;
    text-decoration: none;
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--r-sm);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.papers-filter:hover {
    background: var(--brand-50);
    color: var(--brand-700);
}
.papers-filter--active {
    background: var(--brand-100);
    color: var(--brand-800);
    font-weight: 600;
}
.papers-filter-num {
    color: var(--brand-600);
    font-weight: 700;
    font-size: 13px;
    min-width: 18px;
    font-variant-numeric: tabular-nums;
}
.papers-filter-label { flex: 1; }
.papers-filter-count {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--muted);
    background: #F1F5F9;
    padding: 2px 8px;
    border-radius: var(--r-full);
    font-weight: 600;
}
.papers-filter--active .papers-filter-count {
    background: var(--brand-200);
    color: var(--brand-800);
}

/* Question-type tabs */
.type-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 0 0 24px;
}

.type-tab {
    text-decoration: none;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    transition: border-color var(--t-base) var(--ease),
                transform var(--t-base) var(--ease),
                box-shadow var(--t-base) var(--ease),
                background var(--t-base) var(--ease);
    position: relative;
    cursor: pointer;
}
.type-tab:hover:not(.type-tab--empty) {
    border-color: var(--brand-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.type-tab-label {
    font-weight: 700;
    font-size: 16px;
}
.type-tab-hint {
    font-size: 12px;
    color: var(--muted);
}
.type-tab-count {
    position: absolute;
    top: 14px;
    right: 16px;
    font-size: 12px;
    font-weight: 700;
    background: #F1F5F9;
    color: var(--muted);
    padding: 2px 8px;
    border-radius: var(--r-full);
}

.type-tab--recall.type-tab--active {
    background: linear-gradient(135deg, var(--brand-50), #FFFFFF);
    border-color: var(--brand-400);
}
.type-tab--recall.type-tab--active .type-tab-label { color: var(--brand-700); }
.type-tab--recall.type-tab--active .type-tab-count {
    background: var(--brand-200);
    color: var(--brand-800);
}

.type-tab--application.type-tab--active {
    background: linear-gradient(135deg, #E0E7FF, #FFFFFF);
    border-color: var(--indigo-500);
}
.type-tab--application.type-tab--active .type-tab-label { color: var(--indigo-500); }
.type-tab--application.type-tab--active .type-tab-count {
    background: #C7D2FE;
    color: #3730A3;
}

.type-tab--evaluation.type-tab--active {
    background: linear-gradient(135deg, var(--orange-100), #FFFFFF);
    border-color: var(--orange-400);
}
.type-tab--evaluation.type-tab--active .type-tab-label { color: var(--orange-600); }
.type-tab--evaluation.type-tab--active .type-tab-count {
    background: #FED7AA;
    color: var(--orange-600);
}

.type-tab--empty {
    opacity: 0.5;
    cursor: default;
}

/* Per-question chips */
.question-type {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--r-full);
    text-transform: capitalize;
}
.question-type--recall      { background: var(--brand-100);  color: var(--brand-800); }
.question-type--application { background: #E0E7FF;            color: #3730A3; }
.question-type--evaluation  { background: var(--orange-100);  color: var(--orange-600); }

.papers-list li {
    padding: 6px 10px;
    border-radius: var(--r-sm);
}
.papers-list-label { display: block; font-weight: 500; }
.papers-list-meta {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.papers-body {
    min-width: 0;
}

.papers-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.papers-eyebrow {
    margin: 0;
    color: var(--brand-700);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.papers-header h1 {
    margin: 6px 0 6px;
    font-size: 32px;
    font-weight: 800;
}
.papers-summary { margin: 0; color: var(--muted); font-size: 15px; }
.papers-empty { color: var(--muted); padding: 32px 0; text-align: center; }

.ms-caveat {
    background: var(--orange-50);
    border: 1px solid #FED7AA;
    border-left: 3px solid var(--orange-500);
    border-radius: var(--r-md);
    padding: 14px 18px;
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
}
.ms-caveat strong { color: var(--orange-600); display: block; margin-bottom: 4px; }

.papers-paper-heading {
    margin: 28px 0 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: var(--font-sans);
}
.papers-paper-heading:first-of-type { margin-top: 8px; }

.question-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 24px 26px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
    transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}

.question-card:hover {
    border-color: var(--brand-200);
    box-shadow: var(--shadow-hover);
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.question-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}
.question-id {
    font-weight: 800;
    color: var(--brand-600);
    font-size: 18px;
    font-variant-numeric: tabular-nums;
}
.question-title {
    font-weight: 600;
    font-size: 16px;
}

.question-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.question-marks {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--r-full);
    background: var(--brand-100);
    color: var(--brand-800);
}
.question-topic {
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: var(--r-full);
    background: #F1F5F9;
    color: var(--muted);
    text-decoration: none;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.question-topic:hover { background: var(--brand-100); color: var(--brand-800); }

.question-body {
    line-height: 1.65;
    font-size: 15px;
}
.question-body p { margin: 0 0 10px; }
.question-body ul, .question-body ol { margin: 4px 0 10px; padding-left: 22px; }
.question-body li { margin: 4px 0; }
.question-body strong { color: var(--text); }
.question-body code {
    background: var(--brand-50);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.92em;
    font-family: var(--font-mono);
    color: var(--brand-800);
}
.question-body em { color: var(--muted); }

.mark-scheme {
    margin-top: 20px;
}

.mark-scheme > summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--orange-100);
    border: 1px solid #FED7AA;
    color: var(--orange-600);
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: 14px;
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.mark-scheme > summary::-webkit-details-marker { display: none; }
.mark-scheme > summary::marker { content: ''; }
.mark-scheme > summary:hover { background: #FED7AA; }

.ms-toggle-arrow {
    transition: transform var(--t-fast) var(--ease);
}
.mark-scheme[open] .ms-toggle-arrow { transform: rotate(180deg); }
.mark-scheme .ms-toggle-label-open { display: none; }
.mark-scheme[open] .ms-toggle-label-closed { display: none; }
.mark-scheme[open] .ms-toggle-label-open { display: inline; }

.mark-scheme-body {
    margin-top: 14px;
    padding: 18px 20px;
    background: var(--orange-50);
    border: 1px solid #FED7AA;
    border-radius: var(--r-md);
    line-height: 1.65;
    font-size: 14px;
}
.mark-scheme-body p { margin: 0 0 8px; }
.mark-scheme-body ul { margin: 4px 0 8px; padding-left: 22px; }
.mark-scheme-body li { margin: 4px 0; }
.mark-scheme-body strong { color: var(--text); }

/* --- Chat page (Ask SHAI) -------------------------------------------- */
.chat-shell {
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-top: 4px;
    height: calc(100vh - 160px);
    min-height: 600px;
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.chat-header h1 {
    margin: 4px 0 6px;
    font-size: 28px;
    font-weight: 800;
}

.chat-eyebrow {
    margin: 0;
    color: var(--brand-700);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.chat-sub {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
    max-width: 620px;
}

.chat-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.chat-reset,
.chat-fullscreen {
    flex: 0 0 auto;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--muted);
    padding: 7px 14px;
    border-radius: var(--r-full);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: border-color var(--t-base) var(--ease),
                color var(--t-base) var(--ease),
                background var(--t-base) var(--ease);
}
.chat-reset:hover,
.chat-fullscreen:hover { border-color: var(--brand-400); color: var(--brand-700); }

.chat-fs-label--exit { display: none; }
.chat-shell--fullscreen .chat-fs-label--enter { display: none; }
.chat-shell--fullscreen .chat-fs-label--exit { display: inline; }
.chat-shell--fullscreen .chat-fullscreen {
    background: var(--brand-600);
    border-color: var(--brand-600);
    color: #ffffff;
}
.chat-shell--fullscreen .chat-fullscreen:hover {
    background: var(--brand-700);
    border-color: var(--brand-700);
    color: #ffffff;
}

.chat-shell--fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    max-width: none;
    height: 100vh;
    min-height: 0;
    margin: 0;
    padding: 24px;
    background:
        radial-gradient(900px 600px at -10% -10%, rgba(45, 212, 191, 0.18), transparent 60%),
        radial-gradient(700px 500px at 110% 0%, rgba(249, 115, 22, 0.12), transparent 60%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
    overflow: hidden;
}

.chat-shell--fullscreen .chat-header,
.chat-shell--fullscreen .chat-warning,
.chat-shell--fullscreen .chat-messages,
.chat-shell--fullscreen .chat-composer {
    max-width: 1100px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
}

body.chat-fullscreen-active { overflow: hidden; }

.chat-warning {
    background: var(--orange-50);
    border: 1px solid #FED7AA;
    border-left: 3px solid var(--orange-500);
    color: var(--text);
    padding: 12px 16px;
    border-radius: var(--r-md);
    font-size: 14px;
}
.chat-warning a { color: var(--brand-700); }

.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-empty {
    margin: auto 0;
    text-align: center;
    color: var(--muted);
    padding: 28px 12px;
}

.chat-empty-title {
    margin: 0 0 16px;
    font-size: 14px;
    font-weight: 500;
}

.chat-starters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
    max-width: 640px;
    margin: 0 auto;
}

.chat-starter {
    background: var(--brand-50);
    border: 1px solid var(--brand-100);
    border-radius: var(--r-md);
    padding: 13px 15px;
    text-align: left;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    font-family: inherit;
    transition: border-color var(--t-base) var(--ease),
                background var(--t-base) var(--ease),
                transform var(--t-base) var(--ease);
}
.chat-starter:hover {
    border-color: var(--brand-400);
    background: var(--brand-100);
    transform: translateY(-1px);
}

.chat-message {
    display: flex;
    width: 100%;
}

.chat-message--user { justify-content: flex-end; }
.chat-message--assistant { justify-content: flex-start; }

.chat-bubble {
    max-width: 82%;
    padding: 13px 17px;
    border-radius: var(--r-lg);
    line-height: 1.6;
    font-size: 15px;
    box-shadow: var(--shadow);
}

.chat-message--user .chat-bubble {
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-500) 100%);
    color: #ffffff;
    border-bottom-right-radius: 6px;
}
.chat-message--user .chat-role { color: rgba(255, 255, 255, 0.8); }
.chat-message--user .chat-body { color: #ffffff; }
.chat-message--user .chat-body a { color: #ffffff; text-decoration: underline; }

.chat-message--assistant .chat-bubble {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}

.chat-role {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 4px;
}

.chat-body {
    word-wrap: break-word;
}
.chat-body p { margin: 0 0 8px; }
.chat-body p:last-child { margin-bottom: 0; }
.chat-body ul, .chat-body ol { margin: 4px 0 8px; padding-left: 20px; }
.chat-body li { margin: 3px 0; }
.chat-body code {
    background: rgba(15, 23, 42, 0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.92em;
    font-family: var(--font-mono);
}
.chat-message--user .chat-body code {
    background: rgba(255, 255, 255, 0.2);
}
.chat-body pre {
    background: #0F172A;
    color: #E2E8F0;
    padding: 14px 16px;
    border-radius: var(--r-md);
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
    font-family: var(--font-mono);
}
.chat-body pre code { background: none; padding: 0; color: inherit; }
.chat-body table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 14px;
}
.chat-body th, .chat-body td {
    border: 1px solid var(--border);
    padding: 6px 10px;
}
.chat-body blockquote {
    border-left: 3px solid var(--orange-500);
    margin: 8px 0;
    padding: 6px 14px;
    color: var(--muted);
    background: var(--orange-50);
    border-radius: 4px;
}

.chat-body--error {
    color: #B91C1C;
    background: #FEF2F2;
    padding: 10px 12px;
    border-radius: var(--r-sm);
    border-left: 3px solid #DC2626;
}

.chat-cursor {
    display: inline-block;
    color: var(--brand-600);
    animation: chatBlink 1s steps(2, start) infinite;
    margin-left: 1px;
}

@keyframes chatBlink {
    to { visibility: hidden; }
}

.chat-composer {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 10px;
    box-shadow: var(--shadow);
    transition: border-color var(--t-base) var(--ease), box-shadow var(--t-base) var(--ease);
}
.chat-composer:focus-within {
    border-color: var(--brand-400);
    box-shadow: var(--shadow-hover);
}

.chat-input {
    flex: 1;
    resize: vertical;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    padding: 8px 10px;
    max-height: 60vh;
    min-height: 44px;
}

.chat-send {
    flex: 0 0 auto;
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-500) 100%);
    color: #ffffff;
    border: none;
    border-radius: var(--r-md);
    padding: 10px 22px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
    align-self: stretch;
    font-size: 14px;
}
.chat-send:hover:not(:disabled) {
    filter: brightness(1.05);
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.32);
}
.chat-send:active:not(:disabled) { transform: scale(0.98); }
.chat-send:disabled {
    background: var(--soon);
    cursor: not-allowed;
    box-shadow: none;
}

/* --- Notes body ----------------------------------------------------- */
.notes-header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.notes-header h1 {
    margin: 6px 0 0;
    font-size: 36px;
    font-weight: 800;
}
.notes-eyebrow {
    margin: 0;
    color: var(--brand-700);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.notes-body {
    max-width: 780px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 36px 40px;
    box-shadow: var(--shadow);
    line-height: 1.7;
}

.notes-body h2 {
    margin: 36px 0 14px;
    font-size: 26px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}
.notes-body h3 {
    margin: 26px 0 10px;
    font-size: 20px;
    color: var(--brand-700);
    font-weight: 700;
}
.notes-body h4 {
    margin: 20px 0 8px;
    font-size: 17px;
    color: var(--orange-600);
    font-weight: 600;
}

.notes-body p { margin: 0 0 14px; }
.notes-body ul, .notes-body ol { margin: 0 0 16px; padding-left: 24px; }
.notes-body li { margin: 5px 0; }

.notes-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 36px 0;
}

.notes-body code {
    background: var(--brand-50);
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 0.92em;
    font-family: var(--font-mono);
    color: var(--brand-800);
}

.notes-body pre {
    background: #0F172A;
    color: #E2E8F0;
    padding: 16px 18px;
    border-radius: var(--r-md);
    overflow-x: auto;
    font-size: 14px;
    font-family: var(--font-mono);
}
.notes-body pre code { background: none; padding: 0; color: inherit; }

.notes-body blockquote {
    margin: 18px 0;
    padding: 14px 18px;
    background: var(--brand-50);
    border-left: 4px solid var(--brand-500);
    border-radius: var(--r-sm);
    color: var(--text);
}
.notes-body blockquote p { margin: 0; }
.notes-body blockquote p + p { margin-top: 8px; }

.notes-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 22px;
    font-size: 15px;
}
.notes-body th, .notes-body td {
    border: 1px solid var(--border);
    padding: 9px 13px;
    text-align: left;
    vertical-align: top;
}
.notes-body th {
    background: var(--brand-50);
    color: var(--brand-900);
    font-weight: 600;
}
.notes-body tr:nth-child(even) td { background: #F8FAFC; }

.notes-body a {
    color: var(--brand-700);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: var(--brand-300);
    transition: text-decoration-color var(--t-fast) var(--ease);
}
.notes-body a:hover { text-decoration-color: var(--brand-700); }

.diagram {
    margin: 22px 0;
    padding: 18px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    text-align: center;
    box-shadow: var(--shadow);
}
.diagram img {
    max-width: 100%;
    height: auto;
}
.diagram figcaption {
    margin-top: 10px;
    font-size: 13px;
    color: var(--muted);
    font-style: italic;
    text-transform: capitalize;
}

.notes-body mjx-container[display="true"] {
    margin: 16px 0 !important;
}

/* --- Auth (login pages) ------------------------------------------------ */
.auth-card {
    max-width: 440px;
    margin: 72px auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--brand-600), var(--brand-400), var(--orange-500));
}

.auth-card h1 {
    margin: 0 0 8px;
    font-size: 30px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.auth-sub { color: var(--muted); margin: 0 0 28px; font-size: 15px; }

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.auth-form input {
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    background: var(--panel);
    font-size: 15px;
    color: var(--text);
    font-family: inherit;
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.auth-form input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

.flash {
    padding: 12px 16px;
    border-radius: var(--r-md);
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 500;
}

.flash--error {
    background: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FECACA;
    border-left: 3px solid #DC2626;
}

.flash--success {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
    border-left: 3px solid var(--emerald-500);
}

/* --- Buttons (shared) -------------------------------------------------- */
.btn-primary {
    background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-500) 100%);
    color: #fff;
    border: none;
    padding: 11px 22px;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(13, 148, 136, 0.2);
    transition: filter var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3);
}
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: 9px 16px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.btn-secondary:hover {
    background: var(--brand-50);
    border-color: var(--brand-300);
    color: var(--brand-700);
}

.btn-small {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border-strong);
    padding: 7px 12px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.btn-small:hover {
    background: var(--brand-50);
    border-color: var(--brand-300);
    color: var(--brand-700);
}

.btn-danger {
    color: #B91C1C;
    border-color: #FECACA;
}

.btn-danger:hover {
    background: #FEF2F2;
    color: #991B1B;
    border-color: #FCA5A5;
}

.inline-form {
    display: inline;
    margin: 0;
}

/* --- Admin page -------------------------------------------------------- */
.admin-page {
    max-width: 1180px;
    margin: 0 auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 28px;
}

.admin-header h1 {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand-500) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.admin-sub { color: var(--muted); margin: 0; font-size: 15px; }

.admin-block {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 22px 26px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.admin-block h2 { margin: 0 0 18px; font-size: 19px; font-weight: 700; }

.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
}

.admin-form input {
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.admin-form input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.18);
}

.admin-form--row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.admin-form--row label { flex: 1 1 140px; }

.admin-empty { color: var(--muted); }

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th, .admin-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.admin-table th {
    background: var(--brand-50);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-800);
}

.th-hint {
    font-size: 12px;
    color: var(--muted);
    font-weight: 400;
}

.admin-edit-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(110px, 1fr));
    gap: 8px 10px;
    align-items: end;
}

.admin-edit-form label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.admin-edit-form input {
    padding: 7px 9px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--panel);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    width: 100%;
}

.admin-edit-form input:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.admin-edit-form button {
    grid-column: 1 / -1;
    justify-self: end;
}

.admin-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 110px;
}

.badge--on  { background: #D1FAE5; color: #065F46; }
.badge--off { background: #FEE2E2; color: #991B1B; }

.row-disabled td { opacity: 0.55; }

/* --- Flashcards page -------------------------------------------------- */
.cards-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    margin-top: 8px;
}

@media (max-width: 880px) {
    .cards-layout { grid-template-columns: 1fr; }
    .cards-sidebar { position: static !important; max-height: none !important; }
}

.cards-sidebar {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 20px 16px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    font-size: 14px;
}

.cards-sidebar h2 {
    margin: 0 6px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-weight: 700;
    font-family: var(--font-sans);
}

.cards-decks {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cards-deck-link {
    display: flex;
    align-items: baseline;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    padding: 10px 12px;
    border-radius: var(--r-sm);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.cards-deck-link:hover {
    background: var(--brand-50);
    color: var(--brand-700);
}

.cards-deck-link--active {
    background: var(--brand-100);
    color: var(--brand-800);
    font-weight: 600;
}

.cards-deck-num {
    color: var(--brand-600);
    font-weight: 700;
    font-size: 13px;
    min-width: 22px;
    font-variant-numeric: tabular-nums;
}

.cards-deck-name { flex: 1; }

.cards-deck-count {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--muted);
    background: #F1F5F9;
    padding: 2px 8px;
    border-radius: var(--r-full);
    font-weight: 600;
}

.cards-deck-link--active .cards-deck-count {
    background: var(--brand-200);
    color: var(--brand-800);
}

.cards-body { min-width: 0; }

.cards-header {
    margin-bottom: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.cards-eyebrow {
    margin: 0;
    color: var(--brand-700);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.cards-header h1 {
    margin: 6px 0 6px;
    font-size: 32px;
    font-weight: 800;
}
.cards-sub { margin: 0; color: var(--muted); font-size: 15px; }

.cards-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cards-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cards-filter {
    background: var(--panel);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 7px 14px;
    border-radius: var(--r-full);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.cards-filter:hover {
    border-color: var(--brand-400);
    color: var(--brand-700);
}

.cards-filter--active {
    background: var(--brand-600);
    color: #fff;
    border-color: var(--brand-600);
}

.cards-filter--unknown.cards-filter--active {
    background: var(--orange-500);
    border-color: var(--orange-500);
}

.cards-filter--know.cards-filter--active {
    background: var(--emerald-500);
    border-color: var(--emerald-500);
}

.cards-filter-count {
    font-size: 11px;
    font-weight: 700;
    background: rgba(15, 23, 42, 0.08);
    padding: 2px 8px;
    border-radius: var(--r-full);
    min-width: 18px;
    text-align: center;
}

.cards-filter--active .cards-filter-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.cards-reset {
    background: var(--panel);
    border: 1px solid var(--border-strong);
    color: var(--muted);
    padding: 7px 14px;
    border-radius: var(--r-full);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.cards-reset:hover {
    border-color: var(--orange-500);
    color: var(--orange-600);
}

.cards-stage {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
}

.cards-progress {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
}

.cards-deck-row {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) 56px;
    gap: 16px;
    align-items: center;
}

@media (max-width: 720px) {
    .cards-deck-row {
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        gap: 8px;
    }
}

.cards-arrow {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    color: var(--brand-700);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    font-family: inherit;
    transition: background var(--t-base) var(--ease),
                color var(--t-base) var(--ease),
                border-color var(--t-base) var(--ease),
                transform var(--t-base) var(--ease);
}

.cards-arrow:hover {
    background: var(--brand-600);
    color: #fff;
    border-color: var(--brand-600);
    transform: scale(1.06);
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.32);
}

.cards-arrow:active { transform: scale(0.95); }

.cards-deck {
    position: relative;
    width: 100%;
    min-height: 380px;
}

@media (max-width: 720px) {
    .cards-deck { min-height: 340px; }
}

.card-peek {
    position: absolute;
    inset: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    pointer-events: none;
    transition: transform var(--t-slow) var(--ease), opacity var(--t-slow) var(--ease);
}

.card-peek--1 {
    transform: translate(6px, 8px) scale(0.985);
    z-index: 1;
    opacity: 0.85;
}

.card-peek--2 {
    transform: translate(12px, 16px) scale(0.97);
    z-index: 0;
    opacity: 0.6;
}

.cards-deck[data-peek="0"] .card-peek--1,
.cards-deck[data-peek="0"] .card-peek--2 { display: none; }
.cards-deck[data-peek="1"] .card-peek--2 { display: none; }

.card-wrap {
    position: absolute;
    inset: 0;
    z-index: 2;
}

.card-flipper {
    position: relative;
    width: 100%;
    height: 100%;
    perspective: 1400px;
    cursor: pointer;
    outline: none;
}

.card-flipper:focus-visible .card-face {
    outline: 2px solid var(--brand-500);
    outline-offset: 4px;
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow);
    padding: 38px 42px 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1), box-shadow var(--t-base) var(--ease);
    overflow: auto;
}

.card-flipper:hover .card-face {
    box-shadow: var(--shadow-hover);
}

.card-face--front {
    background: linear-gradient(160deg, #FFFFFF 0%, var(--brand-50) 100%);
}

.card-face--back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, #FFFFFF 0%, var(--orange-50) 100%);
    text-align: left;
    align-items: stretch;
    justify-content: flex-start;
}

.card-flipper--flipped .card-face--front {
    transform: rotateY(180deg);
}
.card-flipper--flipped .card-face--back {
    transform: rotateY(360deg);
}

.card-side-label {
    position: absolute;
    top: 16px;
    left: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--brand-700);
    background: var(--brand-100);
    padding: 4px 12px;
    border-radius: var(--r-full);
}

.card-face--back .card-side-label {
    color: var(--orange-600);
    background: var(--orange-100);
}

.card-number {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    background: #F1F5F9;
    padding: 4px 12px;
    border-radius: var(--r-full);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.card-content {
    font-size: 22px;
    line-height: 1.5;
    color: var(--text);
    max-width: 640px;
    margin: 0 auto;
    font-weight: 500;
}

.card-content--answer {
    font-size: 17px;
    line-height: 1.7;
    text-align: left;
    width: 100%;
    max-width: 100%;
    font-weight: 400;
}

.card-content--answer p { margin: 0 0 10px; }
.card-content--answer p:last-child { margin-bottom: 0; }
.card-content--answer ul, .card-content--answer ol { margin: 4px 0 10px; padding-left: 22px; }
.card-content--answer li { margin: 4px 0; }
.card-content--answer strong { color: var(--text); }
.card-content--answer code {
    background: var(--brand-50);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.95em;
    font-family: var(--font-mono);
    color: var(--brand-800);
}
.card-content--answer table {
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 14px;
    width: 100%;
}
.card-content--answer th, .card-content--answer td {
    border: 1px solid var(--border);
    padding: 7px 11px;
    text-align: left;
    vertical-align: top;
}
.card-content--answer th {
    background: var(--brand-50);
    font-weight: 600;
}
.card-content--answer blockquote {
    border-left: 3px solid var(--orange-500);
    margin: 8px 0;
    padding: 6px 14px;
    background: var(--orange-50);
    border-radius: 4px;
    color: var(--text);
}
.card-content--answer mjx-container[display="true"] { margin: 8px 0 !important; }

.card-pill {
    margin-top: 16px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: var(--r-full);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.card-pill--p2 {
    background: var(--orange-100);
    color: var(--orange-600);
}

.card-hint {
    position: absolute;
    bottom: 16px;
    right: 20px;
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}

.card-status-line {
    text-align: center;
    min-height: 24px;
}

.card-status-pill {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: var(--r-full);
}

.card-status-pill--know {
    background: #D1FAE5;
    color: #065F46;
}

.card-status-pill--unknown {
    background: var(--orange-100);
    color: var(--orange-600);
}

.card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: center;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.card-actions--know-only {
    grid-template-columns: minmax(0, 360px);
    justify-content: center;
}

.card-actions[hidden] { display: none; }
.cards-deck-row[hidden] { display: none; }
.card-status-pill[hidden] { display: none; }

.card-btn {
    padding: 13px 22px;
    border-radius: var(--r-md);
    font-size: 15px;
    font-weight: 600;
    border: 1px solid var(--border-strong);
    background: var(--panel);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    transition: background var(--t-fast) var(--ease),
                border-color var(--t-fast) var(--ease),
                color var(--t-fast) var(--ease),
                transform var(--t-fast) var(--ease),
                box-shadow var(--t-fast) var(--ease);
}

.card-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); }

.card-btn--know {
    background: #ECFDF5;
    border-color: #A7F3D0;
    color: #065F46;
}
.card-btn--know:hover {
    background: var(--emerald-500);
    border-color: var(--emerald-500);
    color: #fff;
}

.card-btn--unknown {
    background: var(--orange-50);
    border-color: #FED7AA;
    color: var(--orange-600);
}
.card-btn--unknown:hover {
    background: var(--orange-500);
    border-color: var(--orange-500);
    color: #fff;
}

.cards-empty {
    background: var(--panel);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-xl);
    padding: 44px 24px;
    text-align: center;
    color: var(--muted);
}

.cards-empty p { margin: 0 0 16px; font-size: 15px; line-height: 1.55; }

.cards-empty-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* --- Focus visibility (global a11y) ----------------------------------- */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 2px;
    border-radius: 4px;
}
