/* ============================================================
   Global Styles — editorial design system
   ------------------------------------------------------------
   Serif display (Cormorant Garamond) + light Inter body,
   gentle rounded corners, hairline borders, no shadows.
   All brand decisions live in the :root tokens below.
   ============================================================ */

:root {
    /* Brand */
    --accent:         #294f6c;
    --accent-hover:   #224159;
    --accent-soft:    #e9eff4;
    --accent-fill:    #294f6c;
    --accent-on-dark: #97bbd8;

    /* Neutrals */
    --bg:             #ffffff;
    --band:           #f5f4f0;
    --surface:        #ffffff;
    --heading:        #1c1c1c;
    --text:           #3a3a3a;
    --text-muted:     #6a6a6a;
    --text-faint:     #6b6b6b;
    --border:         #e8e8e8;
    --border-strong:  #d9d9d9;
    --input-border:   #8a8a8a;

    /* Ink = high-contrast fill (near-black on light, near-white on dark) */
    --ink:            #1c1c1c;
    --ink-contrast:   #ffffff;

    /* Fixed dark bands (hero, CTA, footer — dark in both themes) */
    --dark-band:      #1c1c1c;
    --on-dark-muted:  #909090;

    /* Status */
    --success:        #3e7a52;
    --success-light:  #eef5f0;
    --error:          #b04a38;
    --error-light:    #faf0ee;
    --warning:        #8a5f1c;
    --warning-light:  #faf5ec;
    --info:           #4a6a8a;

    /* Status colours for text on the fixed dark bands (the same in every theme) */
    --success-on-dark: #6fae85;
    --error-on-dark:   #d98a7c;
    --warning-on-dark: #c9a05e;

    /* Focus */
    --focus-ring:     0 0 0 3px rgba(41, 79, 108, 0.18);

    /* Type */
    --font-serif:     'Cormorant Garamond', Georgia, serif;
    --font-sans:      'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
    --font-mono:      'JetBrains Mono', 'Courier New', monospace;

    /* Layout */
    --inner-max:      1200px;
    --nav-height:     64px;
    --section-pad:    5.5rem 2rem;

    /* Corner radius */
    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      16px;
}

[data-theme="dark"] {
    --accent:         #97bbd8;
    --accent-hover:   #bcd3e6;
    --accent-soft:    rgba(151, 187, 216, 0.14);
    --accent-fill:    #294f6c;
    --accent-on-dark: #97bbd8;

    --bg:             #191919;
    --band:           #1f1e1c;
    --surface:        #1f1e1c;
    --heading:        #f0ede6;
    --text:           #d6d3cd;
    --text-muted:     #9a9a9a;
    --text-faint:     #8c8c8c;
    --border:         #2d2d2b;
    --border-strong:  #3c3c3a;
    --input-border:   #7a7a78;

    --ink:            #f0ede6;
    --ink-contrast:   #191919;

    --dark-band:      #101010;
    --on-dark-muted:  #909090;

    --success:        #6fae85;
    --success-light:  rgba(111, 174, 133, 0.12);
    --error:          #d98a7c;
    --error-light:    rgba(217, 138, 124, 0.10);
    --warning:        #c9a05e;
    --warning-light:  rgba(201, 160, 94, 0.10);
    --info:           #7c9cb8;

    --focus-ring:     0 0 0 3px rgba(151, 187, 216, 0.25);
}

/* ── Purple palette — matches the Irish EMT MCQ Study Bank PDF cover ──
   (deep aubergine + violet/lavender accents). Toggled via the navbar
   palette button, independent of the light/dark switch above; status
   colours (success/error/warning/info) are intentionally left to fall
   through from the sage palette above — they're semantic, not brand. */
[data-palette="purple"][data-theme="light"] {
    --accent:         #7c3aed;
    --accent-hover:   #6d28d9;
    --accent-soft:    #f3ebfd;
    --accent-on-dark: #c586fa;
    --accent-fill:    #7c3aed;

    --band:           #f8f5fc;
    --heading:        #2e1a47;
    --text:           #3a3542;
    --text-muted:     #756e80;
    --text-faint:     #70697b;
    --border:         #e9e1f5;
    --border-strong:  #d5c5ec;
    --input-border:   #8f84a3;

    --ink:            #2e1a47;
    --ink-contrast:   #ffffff;

    --dark-band:      #2e1a47;
    --on-dark-muted:  #b9a9cc;

    --focus-ring:     0 0 0 3px rgba(124, 58, 237, 0.18);
}

[data-palette="purple"][data-theme="dark"] {
    --accent:         #b088f5;
    --accent-hover:   #c8a8fa;
    --accent-soft:    rgba(176, 136, 245, 0.14);
    --accent-on-dark: #c8a8fa;
    --accent-fill:    #b088f5;

    --bg:             #18131f;
    --band:           #1e1826;
    --surface:        #1e1826;
    --heading:        #ede7f6;
    --text:           #d6cfe0;
    --text-muted:     #a89bb8;
    --text-faint:     #9a8eab;
    --border:         #2e2638;
    --border-strong:  #3d3348;
    --input-border:   #7d6f92;

    --ink:            #ede7f6;
    --ink-contrast:   #18131f;

    --dark-band:      #120e17;
    --on-dark-muted:  #9c8fae;

    --focus-ring:     0 0 0 3px rgba(176, 136, 245, 0.25);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

/* Visitors who ask their system for less motion get none: no page fade, banner slide, confetti or toast fade */
@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;
    }
}

a { text-decoration: none; color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Links inside running text are underlined so they are not told apart by colour alone */
p a:not(.btn-action),
li a:not(.btn-action):not(.dropdown-item),
.form-helptext a,
.text-meta a,
.legal-body-text a,
.auth-consent a,
.result-header a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Inline code: Bootstrap's pink fails contrast on the dark themes */
code { color: var(--accent); }

body {
    font-family: var(--font-sans);
    font-weight: 300;
    font-size: 15px;
    line-height: 1.7;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* While the fixed cookie banner shows, the page reserves its height (set by cookie-consent.js) so a
   focused control is never scrolled underneath it */
html { scroll-padding-bottom: var(--cookie-banner-h, 0px); }

/* The navbar is sticky, so a focused control is scrolled clear of it. The quiz also has a sticky
   progress bar under the navbar, which its focusable parts allow for as well. */
html { scroll-padding-top: var(--nav-height); }
.quiz-question-card,
.quiz-option input,
.quiz-info-btn { scroll-margin-top: 64px; }
body { padding-bottom: var(--cookie-banner-h, 0px); }

strong { font-weight: 600; }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 400;
    letter-spacing: 0.02em;
    color: var(--heading);
    line-height: 1.15;
}

/* ── Eyebrow label (uppercase micro-label with hairline dash) */
.mk-label {
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 400;
    margin: 0 0 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mk-label::before {
    content: '';
    display: block;
    width: 24px;
    height: 1px;
    background: currentColor;
    flex-shrink: 0;
}

.mk-label-center { justify-content: center; }

.mk-label-on-dark { color: rgba(255, 255, 255, 0.72); }

.mk-italic {
    font-style: italic;
    color: var(--accent-on-dark);
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-sans);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 400;
    line-height: 1.4;
    padding: 12px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn-action:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
}

.btn-action:disabled,
.btn-action:disabled:hover {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-lg { padding: 15px 36px; }

.btn-validate {
    background: var(--accent-fill);
    border-color: var(--accent-fill);
    color: #ffffff;
}

.btn-validate:hover { opacity: 0.85; color: #ffffff; }

/* The dark-purple fill is light, so its filled controls take dark text */
[data-palette="purple"][data-theme="dark"] .btn-validate,
[data-palette="purple"][data-theme="dark"] .btn-validate:hover,
[data-palette="purple"][data-theme="dark"] .plan-tag,
[data-palette="purple"][data-theme="dark"] .cookie-btn-accept { color: var(--ink-contrast); }

.btn-export {
    background: transparent;
    border-color: var(--ink);
    color: var(--ink);
}

.btn-export:hover {
    background: var(--ink);
    color: var(--ink-contrast);
}

/* Light outline button for dark bands (hero) */
.btn-ghost-light {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.8);
    color: #ffffff;
}

.btn-ghost-light:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

/* Inline text-link button (e.g. "Forgot password?") */
.auth-link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.auth-link-btn:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ============================================================
   Marketing shell — navbar
   ============================================================ */
/* Skip link: off-screen until a keyboard user tabs to it */
.skip-link {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10001;
    padding: 10px 16px;
    background: var(--ink);
    color: var(--ink-contrast);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: translateY(0);
    color: var(--ink-contrast);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* The page container takes focus when the skip link is used; it is not a control, so no ring */
.mk-main:focus { outline: none; }

.mk-navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--nav-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.mk-nav-inner {
    max-width: var(--inner-max);
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 2rem;
    position: relative;
}

.mk-brand {
    font-family: var(--font-serif);
    font-size: 21px;
    letter-spacing: 2px;
    color: var(--heading);
    text-decoration: none;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.mk-brand:hover { color: var(--heading); }

.mk-brand-logo {
    display: block;
    height: 40px;
    width: auto;
}

/* Show the logo variant that suits the theme (logo-dark-blue.png has lightened blues) */
[data-theme="light"] .mk-brand-logo--dark  { display: none; }
[data-theme="dark"]  .mk-brand-logo--light { display: none; }

.mk-nav-links {
    display: flex;
    gap: 1.9rem;
    align-items: center;
    margin-left: auto;
}

.mk-nav-link {
    font-size: 11.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.15s ease;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.mk-nav-link:hover { color: var(--accent); }

.mk-nav-actions {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    flex-shrink: 0;
}

.mk-nav-cta {
    background: var(--ink);
    color: var(--ink-contrast);
    font-size: 11.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 400;
    padding: 10px 22px;
    text-decoration: none;
    transition: opacity 0.15s ease;
    white-space: nowrap;
}

.mk-nav-cta:hover { opacity: 0.85; color: var(--ink-contrast); }

.mk-icon-btn {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    cursor: pointer;
    transition: color 0.15s ease;
    padding: 0;
}

.mk-icon-btn:hover { color: var(--heading); }

[data-theme="light"] .dm-to-light { display: none; }
[data-theme="dark"]  .dm-to-dark  { display: none; }

[data-palette="sage"]   .palette-to-sage   { display: none; }
[data-palette="purple"] .palette-to-purple { display: none; }

.mk-nav-auth {
    display: flex;
    align-items: center;
    gap: 1.1rem;
}

.mk-user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.mk-user-chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.mk-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
}

.mk-user-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--heading);
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mk-signin-link-mobile {
    display: none;
}

.mk-menu-btn {
    display: none;
    width: 36px;
    height: 34px;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--ink);
    color: var(--ink);
    font-size: 17px;
    cursor: pointer;
    padding: 0;
}

/* ============================================================
   Page content
   ============================================================ */
.mk-main {
    /* "backwards", not "both": "both" keeps transform: translateY(0) after the fade, which makes
       .mk-main the containing block for fixed elements such as the import overlay. */
    animation: pageIn 0.18s ease backwards;
}

/* Close buttons: Bootstrap draws the cross in black, so it is inverted on the dark themes, and the focus ring
   is a solid outline like the other controls */
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

.btn-close:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    box-shadow: none;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Marketing shell — sections & bands
   ============================================================ */
.mk-inner {
    max-width: var(--inner-max);
    margin: 0 auto;
}

.mk-section { padding: var(--section-pad); }

.mk-section--band { background: var(--band); }

.mk-section-head {
    text-align: center;
    margin-bottom: 3.5rem;
}

.mk-section-title {
    font-size: clamp(30px, 4vw, 44px);
    margin: 0 0 12px;
}

.mk-section-sub {
    font-size: 15px;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1.8;
    max-width: 560px;
    margin: 0 auto;
}

/* ── Hero (dark band in both themes) ────────────────────── */
.mk-hero {
    background: var(--dark-band);
    text-align: center;
    padding: 7.5rem 2rem 6.5rem;
}

.mk-hero-title {
    font-size: clamp(40px, 5.5vw, 64px);
    color: #ffffff;
    line-height: 1.12;
    max-width: 760px;
    margin: 0 auto 1.5rem;
}

.mk-hero-sub {
    font-size: 16px;
    font-weight: 300;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.85);
    max-width: 520px;
    margin: 0 auto 2.5rem;
}

.mk-hero-actions {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
}

/* ── Accent band ────────────────────────────────────────── */
.mk-band {
    background: var(--accent);
    padding: 1.1rem 2rem;
}

[data-theme="dark"] .mk-band { background: #294f6c; }

.mk-band-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.mk-band-item {
    font-size: 10px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #ffffff;
    font-weight: 300;
}

.mk-band-sep { color: #ffffff; opacity: 0.35; }

/* ── Value propositions ─────────────────────────────────── */
.mk-value-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
}

.mk-value-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2.25rem 2rem;
}

.mk-value-icon {
    font-size: 26px;
    color: var(--accent);
    display: block;
    margin-bottom: 1.1rem;
    line-height: 1;
}

.mk-value-title {
    font-size: 22px;
    margin: 0 0 8px;
}

.mk-value-desc {
    font-size: 14px;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1.75;
    margin: 0;
}

/* ── Feature tiles ──────────────────────────────────────── */
.mk-feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

.mk-feature-tile {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1.75rem;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.mk-feature-tile:hover { border-color: var(--ink); }

.mk-feature-icon {
    font-size: 20px;
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 3px;
    line-height: 1;
}

.mk-feature-name {
    font-family: var(--font-serif);
    font-size: 19px;
    color: var(--heading);
    margin: 0 0 4px;
    line-height: 1.25;
}

.mk-feature-desc {
    font-size: 13.5px;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1.7;
    margin: 0;
}

/* ── Closing CTA (dark band) ────────────────────────────── */
.mk-cta {
    background: var(--dark-band);
    text-align: center;
    padding: 5.5rem 2rem;
}

.mk-cta-title {
    font-size: clamp(30px, 4vw, 44px);
    color: #ffffff;
    margin: 0 0 12px;
}

.mk-cta-sub {
    font-size: 15px;
    font-weight: 300;
    color: var(--on-dark-muted);
    margin: 0 0 2.25rem;
}

/* ============================================================
   Marketing shell — footer (dark in both themes)
   ============================================================ */
.mk-footer {
    background: var(--dark-band);
    padding: 3.5rem 2rem 0;
    margin-top: 0;
}

.mk-footer-inner {
    max-width: var(--inner-max);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 3rem;
    align-items: start;
}

.mk-footer-logo-img {
    display: block;
    height: 56px;
    width: auto;
    margin-bottom: 12px;
}

.mk-footer-logo {
    font-family: var(--font-serif);
    font-size: 20px;
    letter-spacing: 2px;
    color: #ffffff;
    margin: 0 0 8px;
}

.mk-footer-tagline {
    font-size: 13px;
    font-weight: 300;
    color: var(--on-dark-muted);
    margin: 0;
}

.mk-footer-col-title {
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    margin: 0 0 14px;
}

.mk-footer-link {
    font-size: 13px;
    color: var(--on-dark-muted);
    text-decoration: none;
    font-weight: 300;
    display: block;
    margin-bottom: 10px;
    transition: color 0.15s ease;
}

.mk-footer-link:hover { color: #ffffff; }

.mk-footer-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: var(--font-sans);
    text-align: left;
}

.mk-footer-bottom {
    max-width: var(--inner-max);
    margin: 3rem auto 0;
    padding: 1.4rem 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 12px;
    color: var(--on-dark-muted);
}

/* ============================================================
   Marketing shell — page scaffolding (pricing, etc.)
   ============================================================ */
.mk-page {
    max-width: var(--inner-max);
    margin: 0 auto;
    padding: 0 2rem;
}

.mk-page-head {
    text-align: center;
    padding: 4.5rem 0 3rem;
}

.mk-page-title {
    font-size: clamp(32px, 4.5vw, 48px);
    margin: 0 0 12px;
}

.mk-page-sub {
    font-size: 15px;
    font-weight: 300;
    color: var(--text-muted);
    margin: 0 auto;
    max-width: 520px;
}

.mk-page-body {
    padding-bottom: 5rem;
}

/* A button or two under the page subtitle */
.mk-page-head-actions {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}

/* Narrow reading column for text-led pages (About) */
.mk-prose {
    max-width: 720px;
    margin: 0 auto;
}

.mk-prose-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 2.5rem;
}

/* ============================================================
   About page (single-column story)
   ============================================================ */
.about-body { padding-bottom: 5rem; }

/* Each chapter: small serif heading above the prose, hairline between chapters */
.about-section {
    padding: 2.5rem 0;
    border-top: 1px solid var(--border);
}

.about-section:first-child {
    padding-top: 0;
    border-top: 0;
}

.about-title {
    font-size: clamp(24px, 3vw, 30px);
    line-height: 1.2;
    margin: 0 0 1rem;
}

/* Disclaimer: quiet banded notice with an accent rule */
.about-notice {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    background: var(--band);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    padding: 1.75rem 2rem;
    margin-top: 3.5rem;
}

.about-notice-icon {
    font-size: 20px;
    line-height: 1;
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 3px;
}

.about-notice-title {
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0 0 8px;
}

.about-notice-text { margin: 0; }

/* Contact CTA sub-line */
.about-cta-sub { max-width: 520px; margin-left: auto; margin-right: auto; }

/* ============================================================
   Contact Us (page and popup share the form)
   ============================================================ */
.contact-message {
    resize: vertical;
    min-height: 140px;
}

/* Doubled with .form-helptext, which is defined later and sets margin: 0 */
.form-helptext.contact-fallback {
    margin-top: 2.5rem;
    text-align: center;
}

.contact-fallback a { color: var(--accent); }

/* ============================================================
   Pricing
   ============================================================ */
.mk-plans {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 1.5rem;
    flex-wrap: wrap;
    padding-bottom: 6rem;
}

.plan-card {
    position: relative;
    width: 100%;
    max-width: 340px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 2.25rem 2rem;
}

.plan-card--featured {
    border: 2px solid var(--accent);
}

.plan-tag {
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-fill);
    color: #ffffff;
    font-size: 10px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 400;
    padding: 4px 12px;
    white-space: nowrap;
}

.plan-name {
    font-family: var(--font-serif);
    font-size: 24px;
    color: var(--heading);
    margin: 0 0 2px;
}

.plan-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 10px 0 6px;
}

.plan-price {
    font-family: var(--font-serif);
    font-size: 46px;
    color: var(--heading);
    line-height: 1;
}

.plan-period {
    font-size: 13px;
    font-weight: 300;
    color: var(--text-muted);
}

.plan-desc {
    font-size: 14px;
    font-weight: 300;
    color: var(--text-muted);
    margin: 0 0 1.5rem;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
}

.plan-features li {
    font-size: 14px;
    font-weight: 300;
    color: var(--text);
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.plan-features i {
    color: var(--accent);
    margin-right: 10px;
    font-size: 13px;
}

/* ============================================================
   Legal pages (typographic document)
   ============================================================ */
.legal-doc {
    max-width: 720px;
    margin: 0 auto;
    padding: 4rem 2rem 6rem;
}

.legal-title {
    font-size: clamp(34px, 5vw, 48px);
    margin: 0 0 10px;
}

.legal-doc .text-meta {
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.legal-h2 {
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1.4;
    color: var(--heading);
    margin: 32px 0 10px;
}

.legal-body-text {
    font-size: 15px;
    font-weight: 300;
    color: var(--text);
    line-height: 1.85;
    margin: 0 0 8px;
}

.legal-body-text a { color: var(--accent); }

.legal-body-text a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ── Payment page ───────────────────────────────────────── */
.payment-card {
    max-width: 460px;
    margin: 0 auto;
    padding: 2.25rem 2rem;
}

/* ── Setup Guide page ───────────────────────────────────── */
.guide-intro { max-width: 760px; margin: 0 auto 2rem; }

.guide-lede {
    font-size: 15px;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1.8;
    margin: 0;
}

.guide-card {
    max-width: 760px;
    padding: 2rem 2.25rem;
    margin: 0 auto 1.25rem;
}

.guide-step-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.guide-step-num {
    font-family: var(--font-serif);
    font-size: 26px;
    color: var(--accent);
    line-height: 1;
    flex-shrink: 0;
    min-width: 38px;
}

.guide-step-title {
    font-size: 19px;
    margin: 0;
}

.guide-body p,
.guide-body li {
    font-size: 14.5px;
    font-weight: 300;
    color: var(--text);
    line-height: 1.8;
}

.guide-body p { margin: 0 0 12px; }
.guide-body p:last-child { margin-bottom: 0; }

.guide-body ul,
.guide-body ol {
    margin: 0;
    padding-left: 20px;
}

.guide-body ul + p,
.guide-body ol + p {
    margin-top: 12px;
}

.guide-body li { margin-bottom: 8px; }
.guide-body li:last-child { margin-bottom: 0; }

.guide-body code {
    font-family: var(--font-mono);
    font-size: 12.5px;
    background: var(--band);
    border: 1px solid var(--border);
    padding: 1px 6px;
    color: var(--heading);
}

.guide-body a { text-decoration: underline; text-underline-offset: 2px; }

.guide-note-label {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--text-muted);
    margin: 20px 0 10px !important;
}

.guide-code-block {
    background: var(--band);
    border: 1px solid var(--border);
    padding: 16px 18px;
    margin: 10px 0 0;
    overflow-x: auto;
}

.guide-code-block code {
    background: none;
    border: none;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre;
}

.guide-table-wrap {
    overflow-x: auto;
    margin-top: 10px;
}

/* Areas that scroll sideways take focus, so a keyboard user can scroll them */
.guide-table-wrap:focus-visible,
.guide-code-block:focus-visible,
.chart-table-wrap:focus-visible,
.progress-heat-wrap:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.guide-table {
    width: 100%;
    border-collapse: collapse;
}

.guide-table th {
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

.guide-table td {
    font-size: 13px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.guide-table td:first-child { white-space: nowrap; }

.guide-table tr:last-child td { border-bottom: none; }

/* ============================================================
   Auth pages (centered editorial forms)
   ============================================================ */
.auth-shell {
    max-width: 400px;
    margin: 0 auto;
    padding: 4.5rem 1.5rem 6rem;
}

.auth-shell--center {
    max-width: 460px;
    text-align: center;
}

/* ------------------------------------------------------------
   Password strength meter — "vital signs" monitor
   (Pages/Shared/_PasswordMeter.cshtml + js/password-meter.js)
   ------------------------------------------------------------ */
.pw-meter {
    margin-top: 10px;
    color: var(--error);
}

.pw-meter[data-level="2"] { color: var(--warning); }
.pw-meter[data-level="3"],
.pw-meter[data-level="4"] { color: var(--success); }

.pw-meter-monitor {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: var(--dark-band);
    border: 1px solid var(--border-strong);
    color: var(--error-on-dark);
}

/* The monitor is dark in every theme, so its trace and BPM number take the light status colours */
.pw-meter[data-level="2"] .pw-meter-monitor { color: var(--warning-on-dark); }
.pw-meter[data-level="3"] .pw-meter-monitor,
.pw-meter[data-level="4"] .pw-meter-monitor { color: var(--success-on-dark); }

.pw-meter-ecg {
    flex: 1;
    height: 34px;
    min-width: 0;
}

.pw-meter-trace {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linejoin: round;
    stroke-linecap: round;
    stroke-dasharray: 100;   /* paths use pathLength="100" */
    /* Two sweeps, then it holds still: it is decorative, and moving content must stop within 5 seconds */
    animation: pw-meter-sweep 2s linear 2 forwards;
}

.pw-meter-trace--flat { display: none; }
.pw-meter[data-level="0"] .pw-meter-trace--beat { display: none; }
.pw-meter[data-level="0"] .pw-meter-trace--flat { display: inline; animation-duration: 3s; animation-iteration-count: 1; }
/* Sweep speed matches the BPM shown (two beats per sweep): 100 → 1.2s, 70 → 1.7s, 60 → 2s, 55 → 2.2s */
.pw-meter[data-level="1"] .pw-meter-trace { animation-duration: 1.2s; }
.pw-meter[data-level="2"] .pw-meter-trace { animation-duration: 1.7s; }
.pw-meter[data-level="4"] .pw-meter-trace { animation-duration: 2.2s; }

@keyframes pw-meter-sweep {
    from { stroke-dashoffset: 100; }
    to   { stroke-dashoffset: 0; }
}

.pw-meter-bpm {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 20px;
    line-height: 1;
    min-width: 3.2em;
    text-align: right;
}

.pw-meter-bpm-unit {
    display: block;
    margin-top: 3px;
    font-size: 9px;
    letter-spacing: 0.14em;
    color: var(--on-dark-muted);
}

.pw-meter-bars {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    margin-top: 8px;
}

.pw-meter-bars span {
    height: 4px;
    background: var(--border-strong);
    transition: background 0.2s ease;
}

.pw-meter-bars span:first-child,
.pw-meter[data-level="1"] .pw-meter-bars span:nth-child(-n+2),
.pw-meter[data-level="2"] .pw-meter-bars span:nth-child(-n+3),
.pw-meter[data-level="3"] .pw-meter-bars span:nth-child(-n+4),
.pw-meter[data-level="4"] .pw-meter-bars span { background: currentColor; }

.pw-meter-status {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.5;
}

.pw-meter-label { font-weight: 600; }   /* inherits the level colour */
.pw-meter-detail { color: var(--text-muted); }

.pw-meter-tip {
    margin: 2px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text-faint);
}

.pw-meter-tip:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
    .pw-meter-trace { animation: none; stroke-dashoffset: 0; }
}

/* Terms & privacy acceptance checkbox on sign-up */
.auth-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-muted);
    cursor: pointer;
}

.auth-consent input[type="checkbox"] {
    margin: 3px 0 0;
    flex-shrink: 0;
    accent-color: var(--accent);
}

.auth-consent a { color: var(--accent); }
.auth-consent a:hover { color: var(--accent-hover); }

.auth-extra {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.auth-head {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-title {
    font-size: clamp(30px, 4vw, 38px);
    margin: 0 0 6px;
}

.auth-sub {
    font-size: 14px;
    font-weight: 300;
    color: var(--text-muted);
    margin: 0;
}

.auth-logged-in {
    text-align: center;
    padding: 2rem 0;
}

.auth-status-text {
    font-size: 15px;
    font-weight: 300;
    color: var(--text-muted);
}

.auth-status-text strong { color: var(--heading); }

.auth-logged-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.verify-icon {
    font-size: 40px;
    color: var(--accent);
    display: block;
    margin-bottom: 1.25rem;
    line-height: 1;
}

/* Tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    font-family: var(--font-sans);
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 400;
    color: var(--text-muted);
    padding: 10px 16px;
    cursor: pointer;
    border: none;
    background: transparent;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.tab-btn:hover { color: var(--heading); }

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ============================================================
   Forms
   ============================================================ */
.form-input {
    padding: 11px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 300;
    color: var(--text);
    background: var(--surface);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input::placeholder { color: var(--text-faint); }

.form-input:focus {
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

.field-label {
    display: block;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 7px;
}

/* A field label with a small button beside it (for example an info icon). */
.field-label-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
}

.field-label-row .field-label { margin-bottom: 0; }

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ── Pro-tier badge + locked-control styling ────────────── */
.pro-badge {
    display: inline-block;
    font-size: 9.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 7px;
    margin-left: 6px;
    vertical-align: middle;
}

.pro-locked {
    opacity: 0.55;
    cursor: not-allowed;
}

.pro-locked-link {
    color: var(--accent);
    text-decoration: underline;
}

.field-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.form-helptext {
    font-size: 14px;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1.75;
    margin: 0;
}

/* ── Tooltips (Bootstrap): rounded, hairline border, no arrow ── */
.tooltip {
    --bs-tooltip-bg: var(--surface);
    --bs-tooltip-color: var(--text);
    --bs-tooltip-border-radius: var(--radius-sm);
    --bs-tooltip-font-size: 12px;
    --bs-tooltip-padding-x: 10px;
    --bs-tooltip-padding-y: 6px;
    --bs-tooltip-opacity: 1;
    font-family: var(--font-sans);
}

.tooltip .tooltip-inner { border: 1px solid var(--border-strong); }

.tooltip .tooltip-arrow { display: none; }

/* ── Alerts (result headers) ────────────────────────────── */
.result-header {
    padding: 12px 14px;
    border-left: 2px solid transparent;
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.5;
    margin-bottom: 20px;
}

.result-header.error {
    background: var(--error-light);
    border-left-color: var(--error);
    color: var(--error);
}

.result-header.success {
    background: var(--success-light);
    border-left-color: var(--success);
    color: var(--success);
}

.result-header.upsell {
    background: var(--accent-soft);
    border-left-color: var(--accent);
    color: var(--heading);
}

.result-header.upsell a { color: var(--accent); }

.result-header.error a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

/* ============================================================
   Cards
   ============================================================ */
.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.card-head-title {
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 400;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-head-title i { color: var(--accent); }

.output-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

/* ── Accordion (Quiz History) ───────────────────────────── */
.output-body[hidden] { display: none; }

.mk-accordion {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mk-accordion .tool-card { height: auto; }

.card-head-toggle {
    width: 100%;
    padding: 20px 24px;
    background: var(--band);
    border: 0;
    border-bottom: 1px solid var(--border);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.card-head-toggle:hover { background: var(--accent-soft); }

.card-head-toggle[aria-expanded="false"] {
    background: var(--surface);
    border-bottom-color: transparent;
}

.card-head-toggle[aria-expanded="false"]:hover { background: var(--accent-soft); }

.card-head-toggle .card-head-title {
    font-family: var(--font-serif);
    font-size: 21px;
    letter-spacing: 0;
    text-transform: none;
    color: var(--heading);
    gap: 12px;
}

.card-head-toggle .card-head-title i { font-size: 18px; }

.card-head-chevron {
    flex-shrink: 0;
    margin-left: 16px;
    color: var(--accent);
    transition: transform 0.2s ease;
}

.card-head-toggle[aria-expanded="false"] .card-head-chevron { transform: rotate(-90deg); }

/* ── Account page ───────────────────────────────────────── */
.account-card {
    margin: 0 auto 20px;
    padding: 26px 28px;
    max-width: 640px;
}

.account-section-title {
    font-family: var(--font-sans);
    font-size: 11.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.account-section-title i {
    color: var(--accent);
    font-size: 14px;
}

.account-card .btn-action { align-self: flex-start; }

.account-field-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.account-field-row:last-of-type { border-bottom: none; }

.account-field-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 400;
    color: var(--text-faint);
    min-width: 90px;
}

.account-field-value {
    font-size: 14.5px;
    font-weight: 400;
    color: var(--heading);
    min-width: 0;
    overflow-wrap: anywhere;
}

.account-billing-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.account-billing-hint { margin-top: 14px; }

/* ── System Administration pages ────────────────────────── */
.admin-card {
    margin: 0 auto 20px;
    padding: 26px 28px;
    max-width: 1100px;
}

.admin-back {
    max-width: 1100px;
    margin: 0 auto 14px;
    font-size: 13px;
}

.admin-back a { color: var(--text-muted); text-decoration: none; }
.admin-back a:hover { color: var(--accent); }

.admin-table td { vertical-align: middle; }

/* Full-page "Please wait" cover shown while an import request is running (sysadmin-question-import.js). */
.busy-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.busy-overlay-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 26px 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
}

/* ── Question images (quiz, demo, results, shared results) ── */
/* The picture in a question is shown smaller than its real size; a click opens it at full size. */
.question-image-button {
    display: block;
    max-width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
    text-align: left;
}

.question-image-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.question-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 320px;
    margin: 0 0 16px;
    border: 1px solid var(--border);
}

.question-option-image {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 180px;
    margin-top: 8px;
    border: 1px solid var(--border);
}

.question-image-fallback {
    display: block;
    padding: 12px;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    font-size: 14px;
}

/* Full-size viewer: the image keeps its real size and the dialog scrolls when it's taller than the window. */
.question-image-viewer-body {
    max-height: calc(100vh - 160px);
    overflow: auto;
}

.question-image-viewer-img {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
}

/* Question builder: one answer per row. Wraps to a column on narrow screens. */
.qn-answer-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.qn-answer-text {
    flex: 1 1 260px;
    min-width: 0;
}

.qn-answer-image-wrap {
    flex: 0 1 220px;
    min-width: 0;
}

.qn-answer-image-wrap .form-input,
.qn-answer-image-wrap .qn-answer-image {
    width: 100%;
}

.qn-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

/* Library thumbnail button: the thumbnail opens the full image in a preview. */
.admin-image-open {
    display: block;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.admin-image-open:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Library preview: the image scales down to the panel width, and tall images scroll inside the dialog. */
.image-preview-body {
    max-height: 80vh;
    overflow: auto;
}

.image-preview-img {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
}

/* Library thumbnails: shown smaller than the file's natural size; click to see it in the preview. */
.admin-image-thumb {
    display: block;
    width: 120px;
    height: auto;
    max-width: 100%;
    border: 1px solid var(--border);
}

.admin-code {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--heading);
    margin-right: 10px;
}

.admin-copy-btn { padding: 5px 10px; }

.admin-status--active   { color: var(--success); }
.admin-status--used-up  { color: var(--text-muted); }
.admin-status--expired  { color: var(--warning); }
.admin-status--disabled { color: var(--error); }

/* Warning icon in a confirmation popup, next to the sentence it applies to. */
.modal-warning-icon { color: var(--warning); margin-right: 4px; }

/* Answer Sets page: the level accordion takes the same width as the panels above it. */
.as-levels { max-width: 1100px; margin: 0 auto 20px; }

/* Accordion panels on this page slide for 500 ms (Bootstrap's collapse defaults to 350 ms). */
.as-collapse.collapsing { transition-duration: 500ms; }

/* A level's accordion panel, padded like the panels above it. */
.as-panel { padding: 20px 28px 26px; }

/* Search results: a stacked list that wraps to the panel width, so it never scrolls sideways. */
.as-result {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.as-result:last-child { border-bottom: none; }
.as-result-main { flex: 1 1 260px; min-width: 0; }
.as-result-main .mk-label { margin-bottom: 6px; }
.as-result-text { margin: 0; font-size: 13.5px; overflow-wrap: anywhere; }

/* Level header on the Answer Sets page: a tick when the level has a set, a cross when it doesn't. */
.as-set-icon { flex-shrink: 0; margin-left: auto; margin-right: 12px; font-size: 16px; }
.as-set-icon--yes { color: var(--success); }
.as-set-icon--no  { color: var(--error); }

/* Bootstrap modal, restyled to the editorial look: rounded corners, hairline borders, no shadow */
.mk-modal .modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: none;
    color: var(--text);
}

.mk-modal .modal-header,
.mk-modal .modal-footer {
    border-color: var(--border);
    padding: 16px 24px;
}

.mk-modal .modal-body { padding: 20px 24px; }

.mk-modal .modal-title {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 400;
    color: var(--heading);
}

.mk-modal .btn-close { border-radius: var(--radius-sm); }

/* Announcements: scrollable checkbox lists */
.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.admin-toolbar .form-helptext { margin: 0 0 0 auto; }

.admin-check-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.admin-check-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.admin-check-row:last-child { border-bottom: none; }
.admin-check-row:hover { background: var(--accent-soft); }
.admin-check-row input[type="checkbox"] { margin: 0; flex-shrink: 0; accent-color: var(--accent); }

.admin-check-name {
    font-size: 14.5px;
    color: var(--heading);
}

.admin-check-meta {
    font-size: 13px;
    font-weight: 300;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.admin-check-tag {
    margin-left: auto;
    font-size: 11px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-faint);
    white-space: nowrap;
}

.admin-check-row--disabled { cursor: default; }
.admin-check-row--disabled:hover { background: none; }
.admin-check-row--disabled .admin-check-name { color: var(--text-muted); }

.admin-check-empty { padding: 16px; margin: 0; }

/* ── Example page ───────────────────────────────────────── */
.example-note {
    padding: 18px 20px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 300;
    line-height: 1.7;
    margin: 0;
}

.example-actions { padding: 0 20px 20px; }

.example-output-text {
    padding: 18px 20px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ── Shared text utilities ──────────────────────────────── */
.text-meta {
    font-size: 13px;
    font-weight: 300;
    color: var(--text-muted);
}

/* ============================================================
   Toasts
   ============================================================ */
.toast-container { z-index: 9999; }

.app-toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: none;
    min-width: 220px;
}

.app-toast .toast-body {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
}

.app-toast .toast-body i { font-size: 15px; }

/* Dismiss button on error and warning toasts */
.app-toast .btn-close {
    margin-left: auto;
    flex-shrink: 0;
    padding: 4px;
    font-size: 10px;
}

.app-toast--success i { color: var(--success); }
.app-toast--error   i { color: var(--error); }
.app-toast--info    i { color: var(--info); }
.app-toast--warning i { color: var(--warning); }

/* ============================================================
   Cookie consent banner
   ============================================================ */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    animation: cookieBannerSlideUp 0.3s ease;
}

@keyframes cookieBannerSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.cookie-banner-inner {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.cookie-banner-text {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 240px;
}

.cookie-banner-icon {
    font-size: 17px;
    color: var(--accent);
    flex-shrink: 0;
    line-height: 1.5;
}

.cookie-banner-text strong {
    display: block;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--heading);
    margin-bottom: 3px;
}

.cookie-banner-text p {
    margin: 0;
    font-size: 13px;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1.6;
}

.cookie-banner-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.cookie-btn {
    font-family: var(--font-sans);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 400;
    padding: 10px 20px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cookie-btn-accept {
    background: var(--accent-fill);
    border-color: var(--accent);
    color: #ffffff;
}

.cookie-btn-accept:hover { opacity: 0.85; }

.cookie-btn-decline {
    background: transparent;
    border-color: var(--ink);
    color: var(--ink);
}

.cookie-btn-decline:hover {
    background: var(--ink);
    color: var(--ink-contrast);
}

.cookie-policy-link {
    color: var(--accent);
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cookie-policy-link:hover { color: var(--accent-hover); }

/* ── Scrollbars ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============================================================
   Quiz
   ============================================================ */
.quiz-continue-card {
    margin: 0 auto 20px;
    max-width: 560px;
}

.quiz-setup-card {
    margin: 0 auto;
    padding: 26px 28px;
    max-width: 480px;
}

.quiz-setup-card .btn-action { width: 100%; }

.quiz-timed-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}

.quiz-timed-toggle input[type="checkbox"] { margin: 0; }

/* A mode toggle with its info icon beside it. */
.quiz-toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quiz-error {
    color: var(--error);
}

.quiz-taking {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.quiz-progress-bar {
    position: sticky;
    top: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 10px 16px;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    z-index: 10;
}

.quiz-timer {
    font-family: var(--font-mono);
    font-weight: 500;
    color: var(--heading);
}

.quiz-timer.quiz-timer-low { color: var(--error); }

.quiz-question-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.quiz-question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 22px 24px;
}

.quiz-question-num {
    font-family: var(--font-sans);
    line-height: 1.7;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.quiz-question-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.quiz-question-head .quiz-question-num { margin: 0; }

/* The small buttons at the right of a question's header */
.quiz-question-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.quiz-info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border: 1px solid var(--input-border);
    background: none;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.quiz-info-btn:hover,
.quiz-info-btn[aria-expanded="true"] {
    color: var(--accent);
    border-color: var(--accent);
}

.quiz-question-text {
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 700;
    color: var(--heading);
    margin: 0 0 16px;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 14.5px;
    font-weight: 300;
    color: var(--text);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-option:hover { border-color: var(--accent); }

.quiz-option input[type="radio"] { accent-color: var(--accent); }

.quiz-option:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.quiz-submit-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

/* ── Review (results page) ─────────────────────────────── */
.quiz-review-card { border-left: 3px solid var(--border-strong); }
.quiz-review-card--correct { border-left-color: var(--success); }
.quiz-review-card--incorrect { border-left-color: var(--error); }

.quiz-option--review {
    cursor: default;
    justify-content: space-between;
}

.quiz-option--review:hover { border-color: var(--border); }

.quiz-option--correct {
    border-color: var(--success);
    background: var(--success-light);
    color: var(--success);
}

.quiz-option--wrong {
    border-color: var(--error);
    background: var(--error-light);
    color: var(--error);
}

.quiz-option-tag {
    font-size: 10.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
    white-space: nowrap;
}

.quiz-rationale {
    background: var(--band);
    border: 1px solid var(--border);
    padding: 14px 16px;
    margin: 16px 0 0;
}

.quiz-rationale-category,
.quiz-question-category {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
    color: var(--accent);
    margin: 0 0 6px;
}

.quiz-rationale-text {
    font-size: 14px;
    font-weight: 300;
    line-height: 1.7;
    color: var(--text);
    margin: 0;
}

.quiz-score-summary {
    text-align: center;
    padding: 2.25rem 2rem;
    margin-bottom: 1.25rem;
}

.quiz-score-value {
    font-family: var(--font-serif);
    font-size: 56px;
    color: var(--heading);
    margin: 0;
    line-height: 1.1;
}

.quiz-score-label {
    font-size: 15px;
    color: var(--text-muted);
    margin: 8px 0 20px;
}

.quiz-score-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ── History page ───────────────────────────────────────── */
.quiz-history-empty {
    font-size: 14.5px;
    font-weight: 300;
    color: var(--text-muted);
    padding: 20px;
    margin: 0;
}

.quiz-history-empty a { color: var(--accent); }

.quiz-section-stats {
    display: flex;
    flex-direction: column;
}

.quiz-stat-row {
    display: grid;
    grid-template-columns: 220px 1fr 130px;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
}

.quiz-stat-row:last-child { border-bottom: none; }

.quiz-stat-name {
    font-size: 13.5px;
    color: var(--text);
}

.quiz-stat-bar-wrap {
    height: 8px;
    background: var(--band);
    border: 1px solid var(--border);
}

.quiz-stat-bar {
    height: 100%;
    background: var(--accent);
}

.quiz-stat-pct {
    font-size: 12.5px;
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
}

.quiz-attempt-list {
    display: flex;
    flex-direction: column;
}

.quiz-attempt-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.quiz-attempt-row:last-child { border-bottom: none; }

.quiz-attempt-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.quiz-attempt-link:hover { opacity: 0.65; }

.quiz-attempt-retake {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 10.5px;
}

.quiz-attempt-section {
    font-size: 14px;
    color: var(--heading);
    margin: 0;
}

.quiz-attempt-date {
    font-size: 12px;
    color: var(--text-faint);
    margin: 2px 0 0;
}

.quiz-attempt-score {
    font-size: 14px;
    font-weight: 500;
    color: var(--accent);
    white-space: nowrap;
}

@media (max-width: 600px) {
    .quiz-stat-row { grid-template-columns: 1fr; gap: 6px; }
    .quiz-stat-pct { text-align: left; }
}

/* ── Friends & Messages pages ───────────────────────────── */
.btn-compact {
    padding: 8px 16px;
    font-size: 10.5px;
    flex-shrink: 0;
}

.result-header.notice {
    background: var(--band);
    border-left-color: var(--info);
    color: var(--text);
}

.result-header.warning {
    background: var(--warning-light);
    border-left-color: var(--warning);
    color: var(--warning);
}

.friends-code-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 18px;
    padding: 18px 20px;
    background: var(--band);
    border: 1px solid var(--border);
}

.friends-code {
    font-family: var(--font-mono);
    font-size: 26px;
    letter-spacing: 0.12em;
    color: var(--heading);
    margin: 0 0 4px;
}

.friends-code-box .text-meta { margin: 0; }

.friends-subhead { margin: 24px 0 0; }

.friends-redeem-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.friends-code-input {
    flex: 1;
    min-width: 200px;
    font-family: var(--font-mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.friends-code-input::placeholder { text-transform: none; }

.friends-result { margin: 16px 0 0; }

.friends-list {
    display: flex;
    flex-direction: column;
}

.friends-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.friends-row:last-child { border-bottom: none; }

.friends-row-title {
    font-size: 14px;
    color: var(--heading);
    margin: 0;
}

.friends-row-meta {
    font-size: 12px;
    color: var(--text-faint);
    margin: 2px 0 0;
}

.message-row--unread {
    border-left: 2px solid var(--accent);
    padding-left: 12px;
}

.message-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.message-outcome {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
    max-width: 45%;
}

.mk-nav-badge {
    display: inline-block;
    min-width: 17px;
    margin-left: 6px;
    padding: 1px 5px;
    font-size: 10px;
    letter-spacing: 0;
    line-height: 1.4;
    text-align: center;
    background: var(--accent);
    color: var(--ink-contrast);
}

/* ── Sharing results ────────────────────────────────────── */
.quiz-share-card { margin-bottom: 1.25rem; }

.quiz-share-friends {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0 4px;
}

.quiz-share-friend {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--heading);
    cursor: pointer;
}

.quiz-share-friend input,
.quiz-share-review-toggle input { accent-color: var(--accent); margin: 0; }

.quiz-share-review-toggle { margin-top: 14px; }

.shared-result-meta { margin: 6px 0 16px; }

.shared-result-note {
    text-align: center;
    margin: 0 0 1.25rem;
}

/* ── Challenges ─────────────────────────────────────────── */
.quiz-challenge-banner { margin-bottom: 0; }

.quiz-challenge-deadline { margin-top: 16px; }
.quiz-challenge-deadline .form-input { width: 220px; max-width: 100%; }

.quiz-challenge-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.quiz-challenge-custom .form-input { width: 90px; }

.challenge-status {
    text-align: center;
    padding: 2rem;
    max-width: 760px;
    margin: 0 auto 1.25rem;
}

.challenge-headline {
    font-family: var(--font-serif);
    font-size: 30px;
    color: var(--heading);
    margin: 0 0 8px;
}

.challenge-subline {
    max-width: 560px;
    margin: 0 auto 18px;
}

/* Podium: 2nd | 1st | 3rd, with the winner standing tallest */
.challenge-podium {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: end;
    gap: 1rem;
    max-width: 760px;
    margin: 0 auto 1.25rem;
}

.challenge-podium-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--border-strong);
    text-align: center;
    padding: 20px 16px;
}

.challenge-podium-card--1 { order: 2; padding-top: 36px; border-top-color: var(--accent); }
.challenge-podium-card--2 { order: 1; }
.challenge-podium-card--3 { order: 3; }
.challenge-podium-card--me { background: var(--accent-soft); }

.challenge-medal {
    font-size: 40px;
    line-height: 1;
    margin: 0 0 8px;
}

.challenge-podium-name {
    font-size: 15px;
    color: var(--heading);
    margin: 0 0 6px;
}

.challenge-podium-score {
    font-family: var(--font-serif);
    font-size: 36px;
    color: var(--heading);
    margin: 0;
}

.challenge-podium-card .text-meta { margin: 2px 0 0; }

.challenge-tag {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 8px 0 0;
}

.challenge-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
}

.friends-row .challenge-badges { justify-content: flex-start; margin-top: 6px; }

.challenge-badge {
    font-size: 11px;
    padding: 3px 8px;
    color: var(--heading);
    background: var(--accent-soft);
    border: 1px solid var(--border);
}

.challenge-row--me .friends-row-title { font-weight: 600; }

/* Confetti for the winner (skipped when reduced motion is preferred) */
.challenge-confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 2000;
}

.challenge-confetti-piece {
    position: absolute;
    top: -16px;
    width: 8px;
    height: 14px;
    animation-name: confetti-fall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.challenge-confetti-piece--0 { background: var(--accent); }
.challenge-confetti-piece--1 { background: var(--error); }
.challenge-confetti-piece--2 { background: var(--warning); }
.challenge-confetti-piece--3 { background: var(--info); }
.challenge-confetti-piece--4 { background: var(--success); }

@keyframes confetti-fall {
    to { transform: translateY(105vh) rotate(720deg); }
}

/* ── Chat ───────────────────────────────────────────────── */
.chat-app {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: min(70vh, 680px);
    min-height: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.chat-list-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
}

.chat-pane-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-list { flex: 1; overflow-y: auto; }
.chat-list-empty { padding: 18px; margin: 0; }

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 18px;
    text-align: left;
    color: inherit;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    border-left: 2px solid transparent;
    cursor: pointer;
}

.chat-list-item:hover { background: var(--band); }

.chat-list-item--active {
    background: var(--accent-soft);
    border-left-color: var(--accent);
}

.chat-list-text { flex: 1; min-width: 0; }

.chat-list-name {
    font-size: 14px;
    color: var(--heading);
    margin: 0;
}

.chat-list-preview {
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 2px 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-badge { margin-left: 0; flex-shrink: 0; }

.chat-convo-pane {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.chat-convo-name {
    flex: 1;
    font-size: 14px;
    color: var(--heading);
}

.chat-connection { font-size: 12px; color: var(--warning); }

.chat-back { display: none; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    background: var(--band);
}

.chat-empty { text-align: center; margin: 40px 0; }

.chat-load-earlier { display: block; margin: 0 auto 12px; }

.chat-day {
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin: 14px 0;
}

.chat-row {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    margin-bottom: 10px;
}

.chat-row--me   { margin-left: auto; align-items: flex-end; }
.chat-row--them { align-items: flex-start; }

.chat-bubble {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    border: 1px solid var(--border);
}

.chat-bubble--me {
    background: var(--accent-fill);
    border-color: var(--accent);
    color: var(--ink-contrast);
}

/* Dark sage keeps the dark blue fill, so its text goes light (dark text was 2.03:1) */
[data-theme="dark"]:not([data-palette="purple"]) .chat-bubble--me:not(.chat-card) { color: #ffffff; }

.chat-bubble--them {
    background: var(--surface);
    color: var(--text);
}

/* Cards (shared results, challenges) stay light so their links read clearly */
.chat-card { white-space: normal; }

.chat-bubble--me.chat-card {
    background: var(--accent-soft);
    color: var(--heading);
}

.chat-card-title {
    font-weight: 500;
    color: var(--heading);
    margin: 0 0 4px;
}

.chat-card-detail {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.chat-card-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 11.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    text-decoration: none;
}

.chat-card-link:hover { text-decoration: underline; }

.chat-meta {
    font-size: 11px;
    color: var(--text-faint);
    margin: 4px 2px 0;
}

.chat-seen {
    font-size: 11px;
    color: var(--accent);
    margin: 2px 2px 0;
}

.chat-typing {
    font-size: 12.5px;
    font-style: italic;
    color: var(--text-muted);
    margin: 0;
    padding: 6px 18px;
    border-top: 1px solid var(--border);
}

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}

.chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 160px;
    resize: none;
    line-height: 1.5;
}

.chat-send { padding: 12px 18px; }

.chat-counter { padding: 0 18px 10px; margin: 0; }

.chat-privacy-note { text-align: center; margin: 14px 0 0; }

/* Phones: one pane at a time — the list, then the open conversation */
@media (max-width: 768px) {
    .chat-app { grid-template-columns: 1fr; height: 75vh; }
    .chat-convo-pane { display: none; }
    .chat-app--open .chat-list-pane { display: none; }
    .chat-app--open .chat-convo-pane { display: flex; }
    .chat-back { display: inline-flex; }
    .chat-row { max-width: 88%; }
}

@media (max-width: 600px) {
    .challenge-podium { grid-template-columns: 1fr; }
    .challenge-podium-card--1 { order: 1; }
    .challenge-podium-card--2 { order: 2; }
    .challenge-podium-card--3 { order: 3; }
}

@media (max-width: 600px) {
    .friends-row { flex-direction: column; align-items: flex-start; }
    .message-outcome { text-align: left; max-width: none; }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 992px) {
    .mk-value-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Signed-in users have seven nav links plus the theme buttons and account chip:
   tighten the spacing on mid-size screens, then collapse to the menu. */
@media (max-width: 1240px) {
    .mk-nav-inner { gap: 1.25rem; }
    .mk-nav-links { gap: 1.25rem; }
}

@media (max-width: 1100px) {
    .mk-nav-links {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 1.25rem 2rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1.1rem;
        margin-left: 0;
        z-index: 999;
    }

    .mk-navbar.mk-nav-open .mk-nav-links { display: flex; }

    .mk-menu-btn { display: inline-flex; }

    .mk-nav-actions { margin-left: auto; }

    .mk-signin-link-desktop { display: none; }

    .mk-signin-link-mobile { display: block; }
}

@media (max-width: 768px) {
    :root {
        --section-pad: 4rem 1.25rem;
    }

    .mk-hero { padding: 5rem 1.25rem 4.5rem; }

    .mk-value-grid { grid-template-columns: 1fr; }

    .about-notice { padding: 1.5rem 1.25rem; }

    .mk-footer-inner {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 480px) {
    /* Logo + icon buttons must fit a 320px phone; the account chip shows just its avatar */
    .mk-nav-inner   { padding: 0 1rem; gap: 1rem; }
    .mk-nav-actions { gap: 0.5rem; }
    .mk-user-name   { display: none; }

    .field-grid-2 { grid-template-columns: 1fr; }

    .cookie-banner-actions { width: 100%; }
    .cookie-banner-actions .cookie-btn { flex: 1; }
}

/* ============================================================
   Results charts (Results page, built by js/charts.js)
   Cards, stat column, section list, heatmap, calendar, tables.
   Everything uses the :root variables, so every theme and
   palette works. Corners stay square (decision 9).
   ============================================================ */

/* Card: a .tool-card with a coloured header band, a body, and a footer link */
.chart-card-head {
    align-items: flex-start;
    gap: 16px;
    padding: 20px 24px;
    background: var(--accent-fill);
    border-bottom: 0;
    color: #ffffff;
}

/* The purple palette's dark fill is light, so its band takes dark text */
[data-palette="purple"][data-theme="dark"] .chart-card-head { color: var(--ink-contrast); }

.chart-card-title {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 500;
    line-height: 1.2;
    margin: 0;
    color: inherit;
}

.chart-card-sub {
    font-size: 13px;
    font-weight: 400;
    margin: 4px 0 0;
    opacity: 0.78;
}

.chart-card-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.chart-icon-btn {
    background: transparent;
    border: 0;
    color: inherit;
    padding: 6px 8px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

.chart-icon-btn:hover,
.chart-icon-btn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.16); }

.chart-icon-btn:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.chart-card-body {
    display: flex;
    flex: 1;
    gap: 24px;
    min-width: 0;
    padding: 24px;
}

/* Stat column to the left of the chart: a small mono label over a large figure */
.chart-stats {
    flex: 0 0 140px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.chart-stat-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 4px;
}

.chart-stat-value {
    font-family: var(--font-serif);
    font-size: 30px;
    font-weight: 500;
    line-height: 1.1;
    color: var(--heading);
    margin: 0;
}

.chart-stat-value.is-up   { color: var(--success); }
.chart-stat-value.is-down { color: var(--error); }

/* Chart.js needs a box with a height to fill */
.chart-box {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 300px;
}

.chart-box.is-short { height: 200px; }
.chart-box canvas   { display: block; }

/* Scrolls sideways when a table is wider than the card. Never vertically: the card grows with the table, and a
   vertical scrollbar there only appears from a rounding error and then covers the last row. */
.chart-table-wrap {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Fills the card body (the heatmap and the calendar, which are plain HTML) */
.chart-fill { flex: 1; min-width: 0; }

.chart-fallback {
    padding: 24px;
    font-size: 14px;
    color: var(--text-muted);
}

.chart-card-foot {
    display: flex;
    justify-content: flex-end;
    padding: 14px 24px;
    border-top: 1px solid var(--border);
}

.chart-card-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent);
}

/* A wide card with a narrow one beside it (or two equal cards) */
.chart-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.chart-row.is-even { grid-template-columns: 1fr 1fr; }
.chart-row > .tool-card { min-width: 0; }

/* Results page: the filter bar, sticky under the navbar on wide screens */
.progress-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px 20px;
    margin-bottom: 20px;
    padding: 16px 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

@media (min-width: 901px) {
    .progress-filters {
        position: sticky;
        top: var(--nav-height);
        z-index: 5;
    }
}

.progress-filter { min-width: 0; }
.progress-filter select.form-input { min-width: 150px; }

/* Period: one button per choice, the chosen one filled */
.progress-seg {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--input-border);
}

.progress-seg-btn {
    padding: 11px 14px;
    background: var(--surface);
    border: 0;
    border-left: 1px solid var(--border-strong);
    font: inherit;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
}

.progress-seg-btn:first-child { border-left: 0; }
.progress-seg-btn:hover { background: var(--accent-soft); }
.progress-seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.progress-seg-btn.is-active {
    background: var(--ink);
    color: var(--ink-contrast);
}

.progress-seg-btn.is-locked { color: var(--text-muted); }

/* Section: a Bootstrap dropdown holding a list of checkboxes, restyled square */
.progress-dd-btn {
    display: block;
    min-width: 190px;
    max-width: 260px;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.progress-dd-menu {
    --bs-dropdown-bg: var(--surface);
    --bs-dropdown-color: var(--text);
    --bs-dropdown-border-color: var(--border-strong);
    --bs-dropdown-border-radius: var(--radius-md);
    --bs-dropdown-padding-y: 0;
    min-width: 300px;
    max-height: 340px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    box-shadow: none;
}

.progress-dd-clear {
    display: block;
    width: 100%;
    padding: 9px 16px;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--border);
    font: inherit;
    font-size: 13px;
    text-align: left;
    color: var(--accent);
    cursor: pointer;
}

.progress-dd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 7px 16px;
    font-size: 13.5px;
    color: var(--text);
    cursor: pointer;
}

.progress-dd-item:hover { background: var(--accent-soft); }
.progress-dd-item input { margin: 0; flex-shrink: 0; }
.progress-dd-name { flex: 1; min-width: 0; }

.progress-dd-item .text-meta {
    margin-left: auto;
    white-space: nowrap;
}

/* Admin only: find a user by name */
.progress-user-picker {
    position: relative;
    min-width: 240px;
}

.progress-user-list {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    min-width: 300px;
    max-height: 320px;
    margin: 4px 0 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border-strong);
}

.progress-user-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 9px 14px;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--border);
    font: inherit;
    text-align: left;
    color: var(--text);
    cursor: pointer;
}

.progress-user-item:hover,
.progress-user-item:focus-visible,
.progress-user-item[aria-selected="true"] { background: var(--accent-soft); }

.progress-user-name {
    font-size: 14px;
    color: var(--heading);
}

.progress-user-none {
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--text-muted);
}

.progress-block { margin-bottom: 20px; }

.progress-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
}

.progress-tile {
    padding: 18px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.progress-empty {
    height: auto;
    align-items: center;
    padding: 28px 20px;
    text-align: center;
}

.progress-empty-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

/* While new numbers load, the old ones stay, dimmed, so the page doesn't jump */
.progress-content { transition: opacity 0.15s ease; }

.progress-content.is-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* "Show all sections" under the section list */
.progress-more {
    width: 100%;
    padding: 12px 20px;
    background: none;
    border: 0;
    border-top: 1px solid var(--border);
    font: inherit;
    font-size: 12.5px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    cursor: pointer;
}

.progress-more:hover { background: var(--accent-soft); }

/* Section rows beyond the first few are collapsed until "Show all" */
.progress-sec-row.is-collapsed { display: none; }

.progress-verdict {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-verdict i {
    flex-shrink: 0;
    font-size: 18px;
}

/* Section list: the weakest few in the accent colour, the rest quieter */
.progress-sec-row { grid-template-columns: minmax(0, 240px) 1fr minmax(0, 240px); }

.progress-sec-row .quiz-stat-bar         { background: var(--text-faint); }
.progress-sec-row .quiz-stat-bar.is-focus { background: var(--accent); }
.progress-sec-row .quiz-stat-bar.is-faded { opacity: 0.45; }

.progress-sec-row .quiz-stat-pct strong {
    font-weight: 500;
    color: var(--heading);
}

.progress-sec-row.is-button {
    width: 100%;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--border);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.progress-sec-row.is-button:hover { background: var(--accent-soft); }

.progress-tag {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 7px;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    vertical-align: middle;
    color: var(--accent);
    background: var(--accent-soft);
}

.progress-change {
    display: inline-block;
    margin-left: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.progress-change.is-up   { color: var(--success); }
.progress-change.is-down { color: var(--error); }

/* Shades, pale to deep, for the heatmap and the calendar. Mixed from the accent, so every palette works. */
.heat-0 { background: var(--band); }
.heat-1 { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--heading); }
.heat-2 { background: color-mix(in srgb, var(--accent) 28%, var(--surface)); color: var(--heading); }
.heat-3 { background: color-mix(in srgb, var(--accent) 46%, var(--surface)); color: var(--heading); }
.heat-4 { background: color-mix(in srgb, var(--accent) 80%, var(--surface)); color: var(--ink-contrast); }
.heat-5 { background: var(--accent); color: var(--ink-contrast); }
/* No questions: no fill, just a hairline, so it can't be mistaken for a low score */
.heat-empty {
    background: transparent;
    outline: 1px solid var(--border);
    outline-offset: -1px;
}
.heat-small { outline: 1px dashed var(--text-muted); outline-offset: -2px; }

.progress-heat-wrap {
    max-width: 100%;
    overflow-x: auto;
}

.progress-heat {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 12.5px;
}

.progress-heat th,
.progress-heat td {
    padding: 0;
    text-align: center;
    font-weight: 400;
}

.progress-heat thead th {
    padding: 0 4px 6px;
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.progress-heat tbody th {
    position: sticky;
    left: 0;
    min-width: 170px;
    max-width: 240px;
    padding-right: 12px;
    background: var(--surface);
    color: var(--text);
    text-align: left;
}

.progress-heat td {
    min-width: 44px;
    height: 30px;
    font-variant-numeric: tabular-nums;
}

.progress-heat.is-dense td { min-width: 30px; font-size: 11px; }

.progress-heat-name {
    padding: 0;
    background: none;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.progress-heat-name:hover { color: var(--accent); text-decoration: underline; }

.progress-heat-key {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.progress-heat-key-title {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.progress-heat-key-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.progress-heat-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
}

/* Activity calendar: a column a week, Monday at the top */
.progress-cal {
    display: flex;
    align-items: flex-start;
    gap: 3px;
    min-width: min-content;
}

.progress-cal-days {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-right: 6px;
    font-size: 10.5px;
    color: var(--text-muted);
}

.progress-cal-days span         { height: 13px; line-height: 13px; }
.progress-cal-days span:first-child { height: 14px; }

.progress-cal-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.progress-cal-month {
    width: 13px;
    height: 14px;
    font-size: 10.5px;
    line-height: 14px;
    color: var(--text-muted);
    white-space: nowrap;
}

.progress-cal-cell {
    display: block;
    width: 13px;
    height: 13px;
}

.progress-cal-cell.is-pad { background: transparent; }

.progress-cal-streak {
    margin: 14px 0 0;
    font-size: 14px;
    color: var(--text-muted);
}

.progress-cal-streak strong {
    font-weight: 500;
    color: var(--heading);
}

/* Table view of a chart */
.progress-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.progress-table th,
.progress-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 400;
    text-align: left;
    color: var(--text);
}

.progress-table thead th {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.progress-table .is-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* The first column (the date or quiz name) never wraps; with many columns the cells are a little tighter, and
   the card scrolls sideways only if the table still doesn't fit */
.progress-table th:first-child { white-space: nowrap; }

.progress-table.is-wide th,
.progress-table.is-wide td { padding-left: 8px; padding-right: 8px; }

@media (max-width: 900px) {
    .chart-row,
    .chart-row.is-even { grid-template-columns: 1fr; }

    .chart-card-body { flex-direction: column; padding: 20px; }
    .chart-stats     { flex: none; flex-direction: row; flex-wrap: wrap; gap: 20px 28px; }

    /* Stacked: the chart keeps its own height instead of sharing what is left */
    .chart-box,
    .chart-table-wrap { flex: none; }
}

@media (max-width: 600px) {
    .progress-sec-row { grid-template-columns: 1fr; }
    .chart-card-head  { padding: 16px 20px; }
}

/* ============================================================
   Corner radius
   ------------------------------------------------------------
   One place that gives each bordered component its size, so
   similar elements always match. Buttons, inputs, tooltips,
   the modal, toast and dropdown are set where they are defined.
   ============================================================ */

/* Small: buttons, badges, tags, thumbnails */
.mk-menu-btn,
.mk-icon-btn,
.cookie-btn,
.quiz-info-btn,
.quiz-stat-bar-wrap,
.guide-body code,
.pw-meter-monitor,
.pro-badge,
.plan-tag,
.mk-nav-badge,
.progress-tag,
.challenge-badge,
.question-image,
.question-option-image,
.question-image-fallback,
.image-preview-img,
.admin-image-thumb { border-radius: var(--radius-sm); }

/* The period control: the buttons inside fill its corners, so clip them */
.progress-seg {
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* Medium: tiles, notices, options, code blocks, bubbles */
.mk-feature-tile,
.about-notice,
.guide-code-block,
.admin-check-list,
.quiz-progress-bar,
.quiz-option,
.quiz-rationale,
.quiz-review-card,
.friends-code-box,
.chat-bubble,
.progress-tile,
.progress-user-list { border-radius: var(--radius-md); }

/* Large: cards and panels */
.mk-value-card,
.plan-card,
.tool-card,
.quiz-question-card,
.busy-overlay-panel,
.challenge-podium-card { border-radius: var(--radius-lg); }

.chat-app {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* A card's header band and footer sit flush with its corners, so they take the card's top and bottom curves */
.card-head-toggle { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.card-head-toggle[aria-expanded="false"] { border-radius: var(--radius-lg); }
.chart-card-foot { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ============================================================
   Print (Pro results export)
   ============================================================ */
@media print {
    .mk-navbar, .mk-footer, #toastContainer, .cookie-banner,
    .quiz-score-actions, .quiz-info-btn {
        display: none !important;
    }

    .mk-main { animation: none; }

    .quiz-score-summary, .quiz-question-card {
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .quiz-rationale { display: block !important; }
}

/* Results page: print the charts without the controls */
@media print {
    .progress-filters,
    .chart-card-actions,
    .chart-card-foot,
    .progress-more,
    .mk-page-head-actions,
    #results-limit,
    #results-error { display: none !important; }

    /* Browsers drop backgrounds when printing unless told not to: the header bands (white text on a colour) and
       the heatmap shades would vanish. */
    .chart-card-head,
    .heat-0, .heat-1, .heat-2, .heat-3, .heat-4, .heat-5, .heat-empty,
    .quiz-stat-bar,
    .progress-tag,
    .result-header {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .mk-page { max-width: none; padding: 0; }
    .mk-page-head { padding: 1.5rem 0 1rem; }

    /* Every section, not just the weakest few */
    .progress-sec-row.is-collapsed { display: grid; }

    /* The heatmap shrinks to the page instead of scrolling, so no days are cut off */
    .progress-heat-wrap { overflow: visible; }
    .progress-heat td { min-width: 0; height: 22px; font-size: 9px; }
    .progress-heat thead th { padding: 0 1px 4px; font-size: 8px; white-space: normal; }

    /* Over 40 columns: sideways dates and no numbers (too small to read), so every column fits the page */
    .progress-heat.is-dense { border-spacing: 1px; }
    .progress-heat.is-dense td { min-width: 0; font-size: 0; }

    .progress-heat.is-dense thead th {
        height: 40px;
        padding: 0;
        font-size: 5.5px;
        line-height: 1;
        white-space: nowrap;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
    }

    .progress-heat tbody th {
        position: static;
        min-width: 110px;
        max-width: 150px;
        font-size: 10px;
    }

    .tool-card,
    .progress-tile { break-inside: avoid; }
}
