/* =========================================================
   Softromeda Edu - public site styles
   ========================================================= */

:root {
    --brand:        #2563eb;
    --brand-dark:   #1d4ed8;
    --brand-light:  #dbeafe;
    --accent:       #f59e0b;
    --success:      #16a34a;
    --danger:       #dc2626;
    --warning:      #d97706;

    --ink:          #0f172a;
    --ink-soft:     #334155;
    --muted:        #64748b;
    --line:         #e2e8f0;
    --line-soft:    #f1f5f9;
    --bg:           #ffffff;
    --bg-soft:      #f8fafc;
    --bg-code:      #0f172a;

    /* surfaces that sit on top of --bg (cards, inputs, dropdowns) */
    --surface:      #ffffff;
    --surface-2:    #f8fafc;
    --on-brand:     #ffffff;
    --success-dark: #15803d;
    --brand-line:   #bfdbfe;
    --header-bg:    rgba(255, 255, 255, .92);
    --hero-bg:      linear-gradient(160deg, #f8fafc 0%, #eef2ff 100%);
    --code-inline:  #be185d;
    --support:      #e11d48;
    --support-dark: #be123c;
    --footer-bg:    #0f172a;
    --footer-line:  #1e293b;
    --footer-ink:   #cbd5e1;
    --footer-muted: #94a3b8;

    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
    --shadow-sm:    0 1px 3px rgba(15, 23, 42, .08);

    --font: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --mono: 'Cascadia Mono', 'Consolas', 'SF Mono', 'Fira Code', monospace;

    --header-h: 64px;

    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.015em; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }

.container { width: min(1240px, 100% - 40px); margin-inline: auto; }

/* ---------------- buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .6rem 1.15rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit; font-weight: 600; font-size: .95rem;
    cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-dark); color: var(--on-brand); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--bg-soft); }
.btn--outline { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn--outline:hover { background: var(--brand-light); }
/* support: warm rather than brand blue, so it reads as an ask, not a nav item */
.btn--support { background: var(--support); color: #fff; border-color: var(--support); }
.btn--support:hover { background: var(--support-dark); border-color: var(--support-dark); color: #fff; }
.btn--support span { font-size: 1.05em; line-height: 1; }

.btn--lg { padding: .85rem 1.6rem; font-size: 1rem; }
.btn--block { width: 100%; }

/* ---------------- header ---------------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.site-header__inner { display: flex; align-items: center; gap: 1.5rem; height: var(--header-h); }

.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__mark {
    display: grid; place-items: center;
    width: 32px; height: 32px;
    background: var(--brand); color: var(--on-brand);
    border-radius: 8px; font-family: var(--mono); font-size: .8rem;
}
.brand__text strong { color: var(--brand); }
.brand--light, .brand--light .brand__text strong { color: #fff; }
.brand--light .brand__mark { background: rgba(255, 255, 255, .2); }
.brand--footer { color: var(--ink); margin-bottom: .75rem; }

.site-nav { display: flex; align-items: center; gap: 1.1rem; margin-left: auto; }
.site-nav__link { color: var(--ink-soft); font-weight: 500; font-size: .95rem; padding: .4rem 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.site-nav__link:hover { color: var(--brand); text-decoration: none; }
.site-nav__link.is-active { color: var(--brand); border-bottom-color: var(--brand); }

.search-box { display: flex; align-items: center; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .15rem .15rem .85rem; }
.search-box input { border: 0; background: transparent; outline: none; font: inherit; font-size: .9rem; width: 150px; padding: .3rem 0; }
.search-box button { border: 0; background: transparent; cursor: pointer; font-size: .95rem; padding: .3rem .6rem; }

.nav-toggle { display: none; margin-left: auto; flex-direction: column; gap: 4px; background: none; border: 0; cursor: pointer; padding: .5rem; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px; }

.avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: .9rem; text-transform: uppercase; flex-shrink: 0; }
.avatar--lg { width: 64px; height: 64px; font-size: 1.6rem; }
.avatar--sm { width: 26px; height: 26px; font-size: .75rem; }

.user-menu { position: relative; }
.user-menu__button { display: flex; align-items: center; gap: .5rem; background: none; border: 1px solid var(--line); border-radius: 999px; padding: .25rem .8rem .25rem .25rem; cursor: pointer; font: inherit; font-size: .9rem; }
.user-menu__name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu__dropdown {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 200px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .4rem; display: none; z-index: 60;
}
.user-menu.is-open .user-menu__dropdown { display: block; }
.user-menu__dropdown a, .user-menu__dropdown button {
    display: block; width: 100%; text-align: left; padding: .55rem .75rem;
    border: 0; background: none; font: inherit; font-size: .92rem; color: var(--ink);
    border-radius: var(--radius-sm); cursor: pointer;
}
.user-menu__dropdown a:hover, .user-menu__dropdown button:hover { background: var(--bg-soft); text-decoration: none; }

/* ---------------- flash ---------------- */
.flash-stack { margin: 1rem 0 0; display: grid; gap: .6rem; }
.flash { display: flex; align-items: center; gap: .7rem; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid; font-size: .95rem; }
.flash--success { background: #f0fdf4; border-color: #bbf7d0; color: #14532d; }
.flash--error   { background: #fef2f2; border-color: #fecaca; color: #7f1d1d; }
.flash--warning { background: #fffbeb; border-color: #fde68a; color: #78350f; }
.flash--info    { background: #eff6ff; border-color: #bfdbfe; color: #1e3a8a; }
.flash__text { flex: 1; }
.flash__close { border: 0; background: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }

/* ---------------- hero ---------------- */
.hero { background: var(--hero-bg); border-bottom: 1px solid var(--line); padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.hero__inner { display: grid; grid-template-columns: 1.05fr .95fr; gap: 3rem; align-items: center; }
.hero__eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; font-weight: 700; color: var(--brand); margin-bottom: .5rem; }
.hero h1 { margin-bottom: .6rem; }
.hero h1 span { color: var(--brand); }
.hero__lead { font-size: 1.08rem; color: var(--ink-soft); max-width: 46ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.6rem 0; }
.hero__stats { display: flex; gap: 2.2rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.hero__stats div { display: flex; flex-direction: column; }
.hero__stats strong { font-size: 1.6rem; color: var(--ink); }
.hero__stats span { font-size: .85rem; color: var(--muted); }

.code-window { background: var(--bg-code); border-radius: var(--radius); overflow: hidden; box-shadow: 0 20px 45px rgba(15, 23, 42, .25); }
.code-window__bar { display: flex; align-items: center; gap: .4rem; padding: .7rem .9rem; background: #1e293b; }
.code-window__bar span { width: 11px; height: 11px; border-radius: 50%; background: #475569; }
.code-window__bar span:first-child { background: #ef4444; }
.code-window__bar span:nth-child(2) { background: #f59e0b; }
.code-window__bar span:nth-child(3) { background: #22c55e; }
.code-window__bar em { margin-left: auto; font-style: normal; font-size: .8rem; color: #94a3b8; font-family: var(--mono); }
.code-window pre { margin: 0; padding: 1.2rem; overflow-x: auto; }
.code-window code { font-family: var(--mono); font-size: .88rem; line-height: 1.75; color: #e2e8f0; }
.code-window .k { color: #c084fc; }
.code-window .f { color: #60a5fa; }
.code-window .s { color: #86efac; }
.code-window .v { color: #fbbf24; }
.code-window .c { color: #64748b; font-style: italic; }

/* ---------------- sections ---------------- */
.section { padding: clamp(2.5rem, 5vw, 4rem) 0; }
.section--muted { background: var(--bg-soft); border-block: 1px solid var(--line); }
.section__head { max-width: 60ch; margin-bottom: 2rem; }
.section__head p { color: var(--muted); margin: 0; }

.page-head { padding: 2.5rem 0 2rem; background: var(--bg-soft); border-bottom: 1px solid var(--line); }
.page-head h1 { margin-bottom: .3rem; }
.page-head p { color: var(--muted); margin: 0; }
.page-head--colored { background: linear-gradient(135deg, var(--card-color, #2563eb), color-mix(in srgb, var(--card-color, #2563eb) 65%, #0f172a)); color: #fff; border: 0; padding: 2.8rem 0 2.4rem; }
.page-head--colored h1, .page-head--colored p { color: #fff; }
.page-head--colored p { opacity: .9; }
.page-head__icon { font-size: .9em; }

/* ---------------- cards ---------------- */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.1rem; }
.category-card {
    display: block; padding: 1.4rem; background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius);
    border-top: 3px solid var(--card-color, var(--brand));
    transition: transform .15s, box-shadow .15s;
}
.category-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); text-decoration: none; }
.category-card__icon { font-size: 1.8rem; display: block; margin-bottom: .6rem; }
.category-card h3 { font-size: 1.08rem; margin-bottom: .35rem; }
.category-card p { font-size: .9rem; color: var(--muted); margin-bottom: .8rem; }
.category-card__count { font-size: .82rem; font-weight: 600; color: var(--card-color, var(--brand)); }

.tutorial-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.1rem; }
.tutorial-card {
    display: flex; flex-direction: column; padding: 1.3rem; background: var(--surface); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius);
    transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tutorial-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); text-decoration: none; }
.tutorial-card__top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }
.tutorial-card__icon { font-size: 1.7rem; }
.tutorial-card__badge { font-size: .72rem; font-weight: 600; padding: .2rem .55rem; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.tutorial-card h3 { font-size: 1.05rem; margin-bottom: .35rem; }
.tutorial-card p { font-size: .88rem; color: var(--muted); flex: 1; margin-bottom: .9rem; }
.tutorial-card__meta { display: flex; gap: .8rem; font-size: .8rem; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: .7rem; }

.catalog-group { margin-bottom: 2.8rem; }
.catalog-group__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; padding-bottom: .6rem; border-bottom: 2px solid var(--card-color, var(--brand)); }
.catalog-group__head h2 { margin: 0; font-size: 1.35rem; }
.catalog-group__icon { margin-right: .3rem; }
.catalog-group__head a { font-size: .88rem; font-weight: 600; white-space: nowrap; }

/* 300px rather than 220px keeps the row count low enough that the last row is
   never a single stranded card: at 220px a 1280px screen fits five columns and
   a 1024px one fits four, which orphans the final card at most card counts */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.feature__icon { font-size: 1.9rem; display: block; margin-bottom: .5rem; }
.feature h3 { font-size: 1.05rem; margin-bottom: .3rem; }
.feature p { font-size: .92rem; color: var(--muted); margin: 0; }

.empty-state { text-align: center; padding: 3rem 1rem; background: var(--bg-soft); border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }
.empty-state .btn { margin-top: .8rem; }

/* ---------------- tutorial landing ---------------- */
.tutorial-hero__subtitle { font-size: 1.08rem; max-width: 60ch; }
.tutorial-hero__meta { display: flex; flex-wrap: wrap; gap: 1.2rem; font-size: .9rem; opacity: .92; margin-bottom: 1.4rem; }
.tutorial-hero__actions { display: flex; gap: .75rem; flex-wrap: wrap; }
.tutorial-hero__progress { display: flex; align-items: center; gap: .8rem; margin-top: 1.3rem; font-size: .88rem; }
.tutorial-hero__progress .progress-bar { flex: 1; max-width: 320px; }

.progress-bar { height: 8px; border-radius: 999px; background: rgba(148, 163, 184, .35); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--success); border-radius: 999px; transition: width .3s; }

.tutorial-body { display: grid; grid-template-columns: 1fr 300px; gap: 2.5rem; align-items: start; }
.tutorial-body__title { margin-top: 2rem; }

.chapter-index { list-style: none; margin: 0; padding: 0; counter-reset: chapter; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chapter-index__item + .chapter-index__item { border-top: 1px solid var(--line); }
.chapter-index__item a { display: flex; align-items: center; gap: 1rem; padding: .95rem 1.1rem; color: var(--ink); transition: background .15s; }
.chapter-index__item a:hover { background: var(--bg-soft); text-decoration: none; }
.chapter-index__num { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; background: var(--bg-soft); border: 1px solid var(--line); font-size: .85rem; font-weight: 700; color: var(--muted); }
.chapter-index__item.is-done .chapter-index__num { background: var(--success); border-color: var(--success); color: var(--on-brand); }
.chapter-index__text { flex: 1; display: flex; flex-direction: column; }
.chapter-index__text em { font-style: normal; font-size: .85rem; color: var(--muted); }
.chapter-index__time { font-size: .8rem; color: var(--muted); white-space: nowrap; }

.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.2rem; }
.side-card h3 { font-size: 1rem; margin-bottom: .8rem; }
.side-card--accent { background: var(--brand-light); border-color: var(--brand-line); }
.side-card--accent p { font-size: .9rem; color: var(--ink-soft); }
.side-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .5rem; }
.side-list a { font-size: .92rem; color: var(--ink-soft); }
.side-list a:hover { color: var(--brand); }
.side-list__empty { font-size: .9rem; color: var(--muted); }
.side-card__link { font-size: .88rem; font-weight: 600; }

.prose { max-width: 72ch; }
.prose--narrow { max-width: 65ch; }

/* reference documents: scanned more than read, and they carry a two-column
   index plus tables, so they get a wider measure than running prose */
.prose--legal { max-width: 880px; }

/* legal pages (terms / privacy) */
.legal-meta { font-size: .88rem; color: var(--muted); }
.legal-toc { margin: 1.6rem 0 2.2rem; padding: 1.1rem 1.3rem; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); }
.legal-toc strong { display: block; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .6rem; }
.legal-toc ol { margin: 0; padding-left: 1.3rem; columns: 3; column-gap: 2.2rem; }
.legal-toc li { margin: .2rem 0; font-size: .92rem; break-inside: avoid; }
.prose h3 { font-size: 1.02rem; margin: 1.4rem 0 .5rem; }
.prose h2 { margin-top: 1.8rem; }

/* tables written straight into a page (not through the Markdown parser) */
.prose table { width: 100%; border-collapse: collapse; margin: 1.2rem 0; font-size: .93rem; }
.prose th { text-align: left; font-weight: 700; background: var(--bg-soft); padding: .65rem .9rem; border-bottom: 2px solid var(--line); }
.prose td { padding: .6rem .9rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.prose tbody tr:last-child td { border-bottom: 0; }

/* =========================================================
   Reading page
   ========================================================= */
.reading-progress { position: sticky; top: var(--header-h); z-index: 40; height: 3px; background: var(--line-soft); }
.reading-progress__bar { display: block; height: 100%; width: 0; background: var(--brand); transition: width .1s linear; }

.reading-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 220px; gap: 2.5rem; padding: 2rem 0 3rem; align-items: start; }

.reading-sidebar { position: sticky; top: calc(var(--header-h) + 24px); max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto; padding-right: .5rem; }
.reading-sidebar__head { padding-bottom: .9rem; border-bottom: 1px solid var(--line); margin-bottom: .9rem; }
.reading-sidebar__back { display: block; font-weight: 700; font-size: .98rem; color: var(--ink); margin-bottom: .7rem; }
.reading-sidebar__back:hover { color: var(--brand); text-decoration: none; }

.progress-mini__bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: .35rem; }
.progress-mini__bar span { display: block; height: 100%; background: var(--success); transition: width .3s; }
.progress-mini__label { font-size: .8rem; color: var(--muted); }

.chapter-list ol { list-style: none; margin: 0; padding: 0; counter-reset: item; }
.chapter-list__item a { display: flex; gap: .65rem; padding: .45rem .6rem; border-radius: var(--radius-sm); color: var(--ink-soft); font-size: .9rem; line-height: 1.4; }
.chapter-list__item a:hover { background: var(--bg-soft); text-decoration: none; }
.chapter-list__num { display: grid; place-items: center; width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; background: var(--line-soft); font-size: .72rem; font-weight: 700; color: var(--muted); }
.chapter-list__item.is-done .chapter-list__num { background: var(--success); color: var(--on-brand); }
.chapter-list__item.is-current a { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.chapter-list__item.is-current .chapter-list__num { background: var(--brand); color: var(--on-brand); }

.reading-content { min-width: 0; }

.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 1.2rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs--light { color: rgba(255, 255, 255, .8); margin-bottom: .8rem; }
.breadcrumbs--light a { color: rgba(255, 255, 255, .85); }
.breadcrumbs--light a:hover { color: #fff; }

.chapter-header { padding-bottom: 1.4rem; border-bottom: 1px solid var(--line); margin-bottom: 1.8rem; }
.chapter-header__eyebrow { text-transform: uppercase; letter-spacing: .07em; font-size: .78rem; font-weight: 700; color: var(--brand); margin-bottom: .3rem; }
.chapter-header h1 { margin-bottom: .5rem; }
.chapter-header__summary { font-size: 1.05rem; color: var(--ink-soft); max-width: 70ch; }
.chapter-header__meta { display: flex; flex-wrap: wrap; gap: 1.1rem; font-size: .85rem; color: var(--muted); }

.toc-mobile { display: none; margin-bottom: 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.toc-mobile summary { font-weight: 600; cursor: pointer; }
.toc-mobile ol { margin: .7rem 0 0; padding-left: 1.2rem; font-size: .92rem; }

.reading-toc { position: sticky; top: calc(var(--header-h) + 24px); font-size: .88rem; }
.reading-toc__inner { border-left: 2px solid var(--line); padding-left: 1rem; max-height: calc(100vh - var(--header-h) - 60px); overflow-y: auto; }
.reading-toc h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .7rem; }
.reading-toc ul { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .45rem; }
.reading-toc a { color: var(--muted); line-height: 1.4; display: block; }
.reading-toc a:hover, .reading-toc a.is-active { color: var(--brand); text-decoration: none; }
.reading-toc a.is-active { font-weight: 600; }
.toc-level-3 { padding-left: .85rem; font-size: .85rem; }
.reading-toc__top { font-size: .82rem; font-weight: 600; }

/* ---------------- chapter actions ---------------- */
.chapter-actions { margin: 2.5rem 0 1.5rem; padding: 1.5rem; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; }
.btn--complete { background: var(--success); color: var(--on-brand); padding: .8rem 1.8rem; font-size: 1rem; }
.btn--complete:hover { background: var(--success-dark); color: var(--on-brand); }
.btn--complete.is-completed { background: var(--surface); color: var(--success); border-color: var(--success); }
.btn__icon { font-size: 1.05rem; }
.chapter-actions__hint { font-size: .88rem; color: var(--muted); margin: .8rem 0 0; }

.login-nudge p { margin: 0 0 .4rem; }
.login-nudge p:nth-child(2) { font-size: .92rem; color: var(--muted); }
.login-nudge__actions { display: flex; gap: .6rem; justify-content: center; margin-top: 1rem; }

.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.5rem 0 2.5rem; }
.chapter-nav__link { display: flex; flex-direction: column; gap: .2rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); transition: border-color .15s, background .15s; }
.chapter-nav__link:hover { border-color: var(--brand); background: var(--bg-soft); text-decoration: none; }
.chapter-nav__link--next { text-align: right; }
.chapter-nav__dir { font-size: .8rem; font-weight: 600; color: var(--brand); }
.chapter-nav__title { font-weight: 600; font-size: .95rem; }

/* ---------------- report form ---------------- */
.report-section { margin-top: 2rem; padding: 1.4rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.report-section__prompt { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.report-section__prompt h3 { font-size: 1.05rem; margin-bottom: .25rem; }
.report-section__prompt p { font-size: .9rem; color: var(--muted); margin: 0; max-width: 62ch; }
.report-form { margin-top: 1.4rem; padding-top: 1.4rem; border-top: 1px solid var(--line); display: grid; gap: 1rem; }
.report-form__row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.report-form__actions { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.report-form__status { font-size: .9rem; font-weight: 600; }
.report-form__status.is-ok { color: var(--success); }
.report-form__status.is-error { color: var(--danger); }

/* ---------------- forms ---------------- */
.field { display: block; }
.field__label { display: block; font-size: .88rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .35rem; }
.field__label em { color: var(--danger); font-style: normal; }
.field__hint { display: block; font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.field__error { display: block; font-size: .82rem; color: var(--danger); font-style: normal; margin-top: .3rem; }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="search"], .field input[type="number"], .field select, .field textarea {
    width: 100%; padding: .6rem .8rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    font: inherit; font-size: .95rem; background: var(--surface); color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light);
}
.field textarea { resize: vertical; min-height: 90px; font-family: inherit; }
.field--check { display: flex; align-items: center; gap: .55rem; }
.field--check input { width: 16px; height: 16px; accent-color: var(--brand); }
.field--check span { font-size: .92rem; }
.stacked-form { display: grid; gap: 1rem; }

/* ---------------- auth ---------------- */
.auth-page { background: var(--bg-soft); }
.auth-wrap { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-aside { background: linear-gradient(160deg, var(--brand), #1e3a8a); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: center; }
.auth-aside h2 { font-size: 1.9rem; margin: 2rem 0 .8rem; }
.auth-aside p { opacity: .9; max-width: 42ch; }
.auth-aside__list { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .6rem; opacity: .95; }
.auth-main { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2.2rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.6rem; margin-bottom: .3rem; }
.auth-card__lead { color: var(--muted); font-size: .95rem; margin-bottom: 1.6rem; }
.auth-card__foot { text-align: center; font-size: .9rem; color: var(--muted); margin: 1rem 0 0; }

/* ---------------- profile ---------------- */
.profile-head { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.profile-head h1 { font-size: 1.7rem; margin-bottom: .2rem; }
.profile-head__stat { margin-left: auto; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.5rem; }
.profile-head__stat strong { display: block; font-size: 1.8rem; color: var(--brand); line-height: 1.1; }
.profile-head__stat span { font-size: .82rem; color: var(--muted); }
.profile-grid { display: grid; grid-template-columns: 1fr 340px; gap: 2.5rem; align-items: start; }
.progress-list { display: grid; gap: 1rem; }
.progress-card { padding: 1.2rem; border: 1px solid var(--line); border-left: 4px solid var(--card-color, var(--brand)); border-radius: var(--radius); background: var(--surface); }
.progress-card__head { display: flex; align-items: center; gap: .9rem; margin-bottom: .8rem; }
.progress-card__icon { font-size: 1.6rem; }
.progress-card h3 { font-size: 1.05rem; margin: 0; }
.progress-card__head p { font-size: .82rem; color: var(--muted); margin: 0; }
.progress-card__percent { margin-left: auto; font-weight: 700; font-size: 1.1rem; color: var(--success); }
.progress-card__foot { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); margin-top: .6rem; }

/* ---------------- search ---------------- */
.search-page-form { display: flex; gap: .6rem; margin-top: 1rem; max-width: 560px; }
.search-page-form input { flex: 1; padding: .7rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; background: var(--surface); color: var(--ink); }
.search-heading { margin: 2rem 0 1rem; font-size: 1.2rem; }
.search-results { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.search-results a { display: block; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.search-results a:hover { border-color: var(--brand); background: var(--bg-soft); text-decoration: none; }
.search-results strong { display: block; }
.search-results__source { font-size: .82rem; color: var(--brand); }
.search-results em { display: block; font-style: normal; font-size: .88rem; color: var(--muted); margin-top: .25rem; line-height: 1.55; }
.search-summary { margin: .9rem 0 0; font-size: .95rem; color: var(--muted); }
.search-summary strong { color: var(--ink); }
.empty-state__hint { font-size: .92rem; }

/* search-term highlighting inside titles and snippets */
mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; padding: 0 .12em; }

/* ---------------- errors ---------------- */
.error-page { text-align: center; padding: 5rem 0; }
.error-page__code { font-size: 5rem; font-weight: 800; color: var(--brand-light); margin: 0; line-height: 1; }
.error-page__actions { display: flex; gap: .7rem; justify-content: center; margin-top: 1.5rem; }

/* ---------------- footer ---------------- */
.site-footer { background: var(--footer-bg); color: var(--footer-ink); margin-top: 3rem; padding: 3rem 0 1.5rem; }
.site-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2.5rem; }
.site-footer h4 { color: #fff; font-size: .95rem; margin-bottom: .8rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.site-footer a { color: var(--footer-ink); font-size: .92rem; }
.site-footer a:hover { color: #fff; }
.site-footer .brand__text, .site-footer .brand { color: #fff; }
.site-footer__about { font-size: .92rem; max-width: 46ch; color: var(--footer-muted); }
.site-footer__bottom { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-top: 2.5rem; padding-top: 1.3rem; border-top: 1px solid var(--footer-line); font-size: .85rem; color: var(--footer-muted); }
.site-footer__bottom p { margin: 0; }

/* =========================================================
   Markdown body
   ========================================================= */
.markdown-body { font-size: 1.02rem; line-height: 1.75; color: var(--ink); }
.markdown-body > *:first-child { margin-top: 0; }
.markdown-body h2 { margin: 2.2rem 0 .8rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); font-size: 1.55rem; }
.markdown-body h3 { margin: 1.8rem 0 .6rem; font-size: 1.22rem; }
.markdown-body h4 { margin: 1.4rem 0 .5rem; font-size: 1.05rem; }
.markdown-body p { margin: 0 0 1.1em; }
.markdown-body strong { font-weight: 700; }

.md-anchor { opacity: 0; margin-left: .4rem; font-weight: 400; color: var(--muted); text-decoration: none; font-size: .85em; }
.md-heading:hover .md-anchor { opacity: 1; }

.md-list { margin: 0 0 1.2em; padding-left: 1.5rem; }
.md-list li { margin-bottom: .45em; }
.md-list .md-list { margin: .45em 0 0; }

.md-quote { margin: 1.4rem 0; padding: .9rem 1.2rem; border-left: 4px solid var(--brand); background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-soft); }
.md-quote p:last-child { margin-bottom: 0; }

.md-rule { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

.md-code { background: var(--line-soft); border: 1px solid var(--line); border-radius: 5px; padding: .12em .4em; font-family: var(--mono); font-size: .89em; color: var(--code-inline); }

kbd { display: inline-block; padding: .15em .5em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); font-family: var(--mono); font-size: .82em; color: var(--ink); }

.md-image { display: block; margin: 1.5rem auto; border-radius: var(--radius); border: 1px solid var(--line); }
.md-figure { margin: 1.8rem 0; text-align: center; }
.md-figure figcaption { font-size: .87rem; color: var(--muted); margin-top: .6rem; font-style: italic; }
.md-figure svg { max-width: 100%; height: auto; }

/* code blocks */
.code-block { margin: 1.5rem 0; background: var(--bg-code); border-radius: var(--radius); overflow: hidden; border: 1px solid #1e293b; }
.code-block__bar { display: flex; align-items: center; justify-content: space-between; padding: .5rem .9rem; background: #1e293b; }
.code-block__lang { font-size: .76rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #94a3b8; }
.code-block__copy { border: 1px solid #334155; background: transparent; color: #94a3b8; border-radius: 6px; padding: .18rem .6rem; font: inherit; font-size: .76rem; cursor: pointer; transition: background .15s, color .15s; }
.code-block__copy:hover { background: #334155; color: #e2e8f0; }
.code-block__copy.is-copied { background: var(--success); border-color: var(--success); color: var(--on-brand); }
.code-block pre { margin: 0; padding: 1.1rem 1.2rem; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: .875rem; line-height: 1.7; color: #e2e8f0; white-space: pre; }
.code-block--output { background: var(--surface-2); border-color: var(--line); }
.code-block--output .code-block__bar { background: var(--line-soft); }
.code-block--output .code-block__lang { color: var(--muted); }
.code-block--output .code-block__copy { border-color: var(--line); color: var(--muted); }
.code-block--output code { color: var(--ink); }

/* syntax highlighting - baked in at publish time by app/Support/Highlighter.php */
.code-block .hl-comment  { color: #64748b; font-style: italic; }
.code-block .hl-string   { color: #86efac; }
.code-block .hl-keyword  { color: #f0abfc; font-weight: 600; }
.code-block .hl-builtin  { color: #7dd3fc; }
.code-block .hl-function { color: #93c5fd; }
.code-block .hl-class    { color: #fcd34d; }
.code-block .hl-variable { color: #fdba74; }
.code-block .hl-number   { color: #fca5a5; }
.code-block .hl-operator { color: #94a3b8; }
.code-block .hl-punct    { color: #94a3b8; }
.code-block .hl-tag      { color: #f0abfc; }
.code-block .hl-property { color: #7dd3fc; }
.code-block .hl-selector { color: #fcd34d; }
.code-block .hl-atrule   { color: #f0abfc; font-weight: 600; }
.code-block .hl-decorator{ color: #fcd34d; }
.code-block .hl-flag     { color: #fdba74; }

/* the light "Natija" panel keeps its plain look */
.code-block--output code span { color: inherit; font-style: normal; font-weight: inherit; }


/* tables */
.table-wrap { overflow-x: auto; margin: 1.5rem 0; border: 1px solid var(--line); border-radius: var(--radius); }
.md-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.md-table th { background: var(--bg-soft); font-weight: 700; text-align: left; padding: .7rem .9rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.md-table td { padding: .65rem .9rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.md-table tbody tr:last-child td { border-bottom: 0; }
.md-table tbody tr:hover { background: var(--bg-soft); }

/* callouts */
.callout { margin: 1.6rem 0; padding: 1rem 1.2rem; border-radius: var(--radius); border: 1px solid; border-left-width: 4px; }
.callout__title { font-weight: 700; margin-bottom: .35rem; font-size: .96rem; }
.callout__body > *:last-child { margin-bottom: 0; }
.callout__body { font-size: .96rem; }
.callout--note    { background: #eff6ff; border-color: #bfdbfe; border-left-color: var(--brand); }
.callout--note .callout__title { color: #1e40af; }
.callout--tip     { background: #f0fdf4; border-color: #bbf7d0; border-left-color: var(--success); }
.callout--tip .callout__title { color: #166534; }
.callout--warning { background: #fffbeb; border-color: #fde68a; border-left-color: var(--warning); }
.callout--warning .callout__title { color: #92400e; }
.callout--danger  { background: #fef2f2; border-color: #fecaca; border-left-color: var(--danger); }
.callout--danger .callout__title { color: #991b1b; }
.callout--success { background: #f0fdfa; border-color: #99f6e4; border-left-color: #0d9488; }
.callout--success .callout__title { color: #115e59; }
.callout--task    { background: #faf5ff; border-color: #e9d5ff; border-left-color: #9333ea; }
.callout--task .callout__title { color: #6b21a8; }

/* figures authored as raw HTML inside chapters */
.chart-figure { margin: 1.8rem 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.chart-figure figcaption { text-align: center; font-size: .87rem; color: var(--muted); margin-top: .8rem; font-style: italic; }
.person-card { display: flex; gap: 1.2rem; align-items: center; margin: 1.8rem 0; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.person-card img, .person-card svg { width: 96px; height: 96px; border-radius: 50%; flex-shrink: 0; border: 3px solid var(--surface); box-shadow: var(--shadow-sm); }
.person-card__body h4 { margin: 0 0 .25rem; }
.person-card__body p { margin: 0; font-size: .92rem; color: var(--ink-soft); }

/* ---------------- contact page ---------------- */
.contact-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 2.5rem; align-items: start; }
.contact-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.8rem; box-shadow: var(--shadow-sm); }
.contact-card h2 { margin-bottom: .4rem; }
.contact-card__lead { color: var(--muted); font-size: .95rem; margin-bottom: 1.6rem; }
.contact-form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.contact-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.contact-aside .side-card h3 { font-size: 1rem; margin-bottom: .9rem; }
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.contact-list li { display: flex; gap: .8rem; align-items: flex-start; font-size: .92rem; }
.contact-list__icon { font-size: 1.15rem; line-height: 1.3; flex-shrink: 0; }
.contact-list strong { display: block; font-size: .82rem; color: var(--muted); font-weight: 600; }

.faq { border-bottom: 1px solid var(--line-soft); padding: .7rem 0; }
.faq:last-child { border-bottom: 0; padding-bottom: 0; }
.faq summary { cursor: pointer; font-weight: 600; font-size: .92rem; color: var(--ink-soft); list-style: none; display: flex; justify-content: space-between; gap: .6rem; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '+'; color: var(--brand); font-weight: 700; flex-shrink: 0; }
.faq[open] summary::after { content: '\2212'; }
.faq[open] summary { margin-bottom: .5rem; }
.faq p { margin: 0; font-size: .88rem; color: var(--muted); }

/* ---------------- email confirmation ---------------- */
.code-input { display: flex; gap: .55rem; justify-content: center; margin: .4rem 0 .2rem; }
.code-input input {
    width: 52px; height: 62px; padding: 0;
    text-align: center; font-size: 1.6rem; font-weight: 700; font-family: var(--mono);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.code-input input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.code-input input.is-filled { border-color: var(--brand); }

.field__error--center { text-align: center; }
.field__label--row { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; }
.field__link { font-size: .82rem; font-weight: 600; }

.resend-form { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.resend-form .btn[disabled] { opacity: .55; cursor: not-allowed; }

.link-button { border: 0; background: none; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }

/* =========================================================
   Support / donation page
   ========================================================= */
.support-head { background: linear-gradient(160deg, var(--bg-soft), color-mix(in srgb, var(--support) 8%, var(--bg-soft))); }
.support-head__eyebrow { text-transform: uppercase; letter-spacing: .09em; font-size: .78rem; font-weight: 700; color: var(--support); margin-bottom: .5rem; }
.support-head h1 { max-width: 22ch; }
.support-head__lead { font-size: 1.06rem; color: var(--ink-soft); max-width: 58ch; margin-bottom: 1.5rem; }
.support-head__actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.support-head__note { font-size: .88rem; color: var(--muted); }

.support-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1rem; margin-bottom: 2.5rem; }
.support-stats__item { text-align: center; padding: 1.2rem .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.support-stats__item strong { display: block; font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--ink); }
.support-stats__item span { font-size: .85rem; color: var(--muted); }
.support-stats__item--accent { border-color: color-mix(in srgb, var(--support) 40%, transparent); background: color-mix(in srgb, var(--support) 8%, transparent); }
.support-stats__item--accent strong { color: var(--support); }

.support-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 2.5rem; align-items: start; }
.support-main h2 { margin-top: 2.2rem; }
.support-main h2:first-child { margin-top: 0; }

.support-list { list-style: none; margin: 1.2rem 0 0; padding: 0; display: grid; gap: .9rem; }
.support-list li { padding: .9rem 1.1rem; background: var(--bg-soft); border-left: 3px solid var(--line); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: .95rem; }
.support-list li strong { color: var(--ink); }
.support-list--next li { border-left-color: var(--support); }

.support-promise { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .9rem; margin-top: 1.2rem; }
.support-promise__item { display: flex; gap: .7rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.support-promise__item span { color: var(--success); font-weight: 700; flex-shrink: 0; }
.support-promise__item p { margin: 0; font-size: .92rem; color: var(--ink-soft); }

.support-cta { margin-top: 2.5rem; padding: 2rem; text-align: center; border: 1px solid color-mix(in srgb, var(--support) 35%, transparent); border-radius: var(--radius); background: color-mix(in srgb, var(--support) 6%, transparent); }
.support-cta h2 { margin-top: 0; }
.support-cta p { max-width: 52ch; margin-inline: auto; color: var(--ink-soft); }
.support-cta__url { font-size: .85rem; color: var(--muted); margin: 1rem 0 0; word-break: break-all; }

.support-side .side-list li { font-size: .92rem; }

@media (max-width: 960px) {
    .support-grid { grid-template-columns: 1fr; }
}



/* =========================================================
   Exam, certificates
   ========================================================= */
.quiz-brief { display: flex; flex-wrap: wrap; gap: 2.2rem; padding: 1.2rem 1.4rem; background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.4rem; }
.quiz-brief__item { display: flex; flex-direction: column; }
.quiz-brief__item strong { font-size: 1.5rem; color: var(--ink); line-height: 1.2; }
.quiz-brief__item span { font-size: .82rem; color: var(--muted); }
.quiz-note { margin-top: 0; }

.quiz-form { margin-top: 1.8rem; display: grid; gap: 1.1rem; }
.quiz-question { margin: 0; padding: 1.3rem 1.4rem; border: 1px solid var(--line); border-left: 3px solid var(--line); border-radius: var(--radius); background: var(--surface); transition: border-color .15s; }
.quiz-question.is-answered { border-left-color: var(--success); }
.quiz-question__legend { display: flex; gap: .8rem; align-items: baseline; font-weight: 600; font-size: 1.02rem; padding: 0; margin-bottom: 1rem; }
.quiz-question__number { display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; background: var(--bg-soft); border: 1px solid var(--line); font-size: .8rem; color: var(--muted); }
.quiz-question.is-answered .quiz-question__number { background: var(--success); border-color: var(--success); color: var(--on-brand); }

.quiz-options { display: grid; gap: .5rem; }
.quiz-option { display: flex; align-items: center; gap: .7rem; padding: .65rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; transition: border-color .15s, background .15s; }
.quiz-option:hover { border-color: var(--brand); background: var(--bg-soft); }
.quiz-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.quiz-option__marker { display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); }
.quiz-option__text { flex: 1; font-size: .95rem; }
.quiz-option:has(input:checked) { border-color: var(--brand); background: var(--brand-light); }
.quiz-option:has(input:checked) .quiz-option__marker { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.quiz-option:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }

.quiz-actions { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; padding: 1.2rem 0 0; border-top: 1px solid var(--line); }
.quiz-actions__progress { margin: 0 auto 0 0; font-size: .9rem; color: var(--muted); }
.quiz-actions__progress strong { color: var(--ink); }

.quiz-result { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; padding: 1.8rem; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 2.5rem; }
.quiz-result--pass { background: color-mix(in srgb, var(--success) 8%, transparent); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.quiz-result--fail { background: color-mix(in srgb, var(--warning) 8%, transparent); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.quiz-result__score { display: grid; place-items: center; width: 132px; height: 132px; flex-shrink: 0; border-radius: 50%; background: var(--surface); border: 3px solid currentColor; }
.quiz-result--pass .quiz-result__score { color: var(--success); }
.quiz-result--fail .quiz-result__score { color: var(--warning); }
.quiz-result__score strong { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.quiz-result__score small { font-size: 1.1rem; }
.quiz-result__score span { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.quiz-result__body { flex: 1; min-width: 260px; }
.quiz-result__body h1 { font-size: 1.8rem; margin-bottom: .4rem; }
.quiz-result__body p { color: var(--ink-soft); margin-bottom: .6rem; }
.quiz-result__number { font-size: .95rem; }
.quiz-result__actions { display: flex; gap: .7rem; flex-wrap: wrap; margin-top: 1rem; }

.quiz-review { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; counter-reset: review; }
.quiz-review__item { padding: 1.2rem 1.4rem; border: 1px solid var(--line); border-left: 3px solid var(--danger); border-radius: var(--radius); background: var(--surface); }
.quiz-review__item.is-correct { border-left-color: var(--success); }
.quiz-review__question { display: flex; gap: .7rem; font-weight: 600; margin-bottom: .8rem; }
.quiz-review__badge { flex-shrink: 0; color: var(--danger); }
.is-correct .quiz-review__badge { color: var(--success); }
.quiz-review__options { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.quiz-review__options li { display: flex; align-items: center; gap: .6rem; padding: .45rem .7rem; border-radius: var(--radius-sm); font-size: .92rem; color: var(--ink-soft); }
.quiz-review__options li.is-expected { background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--ink); font-weight: 600; }
.quiz-review__options li.is-given { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--ink); }
.quiz-review__options em { margin-left: auto; font-style: normal; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.quiz-review__marker { display: grid; place-items: center; width: 22px; height: 22px; flex-shrink: 0; border-radius: 50%; border: 1px solid var(--line); font-size: .72rem; font-weight: 700; }
.quiz-review__explanation { margin: .8rem 0 0; font-size: .9rem; color: var(--muted); }

.quiz-locked { text-align: center; padding: 3rem 1.5rem; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg-soft); }
.quiz-locked__icon { font-size: 2.6rem; display: block; margin-bottom: .8rem; }
.quiz-locked h1 { font-size: 1.5rem; margin-bottom: .5rem; }
.quiz-locked p { color: var(--muted); max-width: 52ch; margin-inline: auto; }
.quiz-locked__progress { max-width: 340px; margin: 1.5rem auto 0; }
.quiz-locked__progress p { font-size: .9rem; margin-top: .5rem; }
.quiz-locked__timer { margin-top: 1rem; }
.quiz-locked__actions { display: flex; gap: .7rem; justify-content: center; margin-top: 1.6rem; flex-wrap: wrap; }

.exam-card__hint { font-size: .85rem; color: var(--muted); margin: .5rem 0 0; }
.exam-card .progress-bar { margin-top: .8rem; }
.exam-card--earned strong { font-family: var(--mono); font-size: .95rem; }

/* ---- the certificate itself ---- */
.certificate-page { padding-top: 2.5rem; }
.verify-banner { display: flex; align-items: center; gap: 1rem; max-width: 900px; margin: 0 auto 1.4rem; padding: .9rem 1.2rem; border: 1px solid; border-radius: var(--radius); }
.verify-banner--valid { background: color-mix(in srgb, var(--success) 10%, transparent); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.verify-banner--void { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.verify-banner__icon { font-size: 1.5rem; }
.verify-banner strong { display: block; font-size: 1rem; }
.verify-banner span { font-size: .9rem; color: var(--ink-soft); }

.certificate { position: relative; max-width: 900px; margin-inline: auto; padding: 3rem clamp(1.4rem, 5vw, 4rem); background: var(--surface); border: 2px solid var(--brand); border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.certificate::after { content: ''; position: absolute; inset: 10px; border: 1px solid var(--accent); border-radius: calc(var(--radius) - 4px); pointer-events: none; }
.certificate.is-void { opacity: .72; border-color: var(--danger); }
.certificate__brand { text-transform: uppercase; letter-spacing: .22em; font-size: .78rem; font-weight: 700; color: var(--brand); margin-bottom: 1.2rem; }
.certificate__title { font-size: clamp(1.9rem, 5vw, 2.8rem); letter-spacing: .2em; margin-bottom: .4rem; }
.certificate__lead { font-size: .92rem; color: var(--muted); margin-bottom: 1.6rem; }
.certificate__holder { font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 800; color: var(--ink); padding-bottom: .7rem; border-bottom: 2px solid var(--accent); display: inline-block; margin: 0 0 1.4rem; }
.certificate__reason { font-size: .92rem; color: var(--muted); max-width: 46ch; margin: 0 auto .7rem; }
.certificate__tutorial { font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 700; margin-bottom: 2rem; }
.certificate__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1.2rem; padding: 1.4rem 0; border-block: 1px solid var(--line); margin: 0 0 1.8rem; }
.certificate__facts dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .25rem; }
.certificate__facts dd { margin: 0; font-size: 1.1rem; font-weight: 700; }
.certificate__foot { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; text-align: left; }
.certificate__number span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.certificate__number strong { font-family: var(--mono); font-size: 1.25rem; letter-spacing: .04em; }
.certificate__qr { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.certificate__qr svg { width: 104px; height: 104px; border-radius: 6px; }
.certificate__qr span { font-size: .7rem; color: var(--muted); }

.certificate-tools { display: flex; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; justify-content: center; max-width: 900px; margin: 1.8rem auto 0; }
.certificate-hint { max-width: 900px; margin: 1.2rem auto 0; font-size: .9rem; color: var(--muted); text-align: center; }

.share-link { flex: 1; min-width: 300px; }
.share-link__label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; }
.share-link__row { display: flex; gap: .5rem; }
.share-link__row input { flex: 1; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); font: inherit; font-size: .88rem; font-family: var(--mono); background: var(--surface-2); color: var(--ink-soft); }
.share-link__targets { display: flex; gap: .5rem; margin-top: .6rem; flex-wrap: wrap; }
.share-link__target { font-size: .85rem; padding: .3rem .8rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); }
.share-link__target:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }

.certificate-list { display: grid; gap: .8rem; margin-bottom: 2.2rem; }
.certificate-card { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-left: 4px solid var(--card-color, var(--brand)); border-radius: var(--radius); background: var(--surface); flex-wrap: wrap; }
.certificate-card.is-void { opacity: .6; }
.certificate-card__icon { font-size: 1.7rem; }
.certificate-card__body { flex: 1; min-width: 200px; }
.certificate-card__body h3 { font-size: 1.02rem; margin: 0 0 .2rem; }
.certificate-card__body p { margin: 0; font-size: .85rem; color: var(--muted); }
.certificate-card__void { color: var(--danger); }
.certificate-card__actions { display: flex; gap: .5rem; }

@media (max-width: 560px) {
    .quiz-result { justify-content: center; text-align: center; }
    .quiz-result__body { text-align: center; }
    .quiz-result__actions, .certificate__foot { justify-content: center; }
    .certificate-card__actions { width: 100%; }
    .certificate-card__actions .btn { flex: 1; }
}

@media print {
    .verify-banner, .certificate-tools, .certificate-hint { display: none !important; }
    .certificate { border-color: #1e293b !important; box-shadow: none !important; }
}

/* =========================================================
   Theme toggle (light / dark / auto)
   =========================================================
   The preference lives in localStorage and is applied by the inline
   script in partials/theme-head.php before the first paint:
     <html data-theme="light|dark" data-theme-pref="light|dark|auto">
   `data-theme` drives the palette, `data-theme-pref` drives which
   icon and which menu row are marked as chosen.
   ========================================================= */
.theme-toggle { position: relative; flex-shrink: 0; }

.theme-toggle__button {
    display: grid; place-items: center;
    width: 34px; height: 34px; padding: 0;
    background: none; border: 1px solid var(--line); border-radius: 50%;
    color: var(--ink-soft); font: inherit; font-size: 1rem; line-height: 1;
    cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.theme-toggle__button:hover { background: var(--bg-soft); border-color: var(--brand); color: var(--brand); }
.theme-toggle__button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* only the icon matching the current preference is shown */
.theme-toggle__icon { display: none; }
[data-theme-pref="light"] .theme-toggle__icon--light,
[data-theme-pref="dark"]  .theme-toggle__icon--dark,
[data-theme-pref="auto"]  .theme-toggle__icon--auto { display: block; }

.theme-toggle__menu {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: .4rem; display: none; z-index: 60;
}
.theme-toggle.is-open .theme-toggle__menu { display: block; }
.theme-toggle__menu button {
    display: flex; align-items: center; gap: .65rem;
    width: 100%; text-align: left; padding: .5rem .7rem;
    border: 0; background: none; font: inherit; font-size: .92rem; color: var(--ink);
    border-radius: var(--radius-sm); cursor: pointer;
}
.theme-toggle__menu button:hover { background: var(--bg-soft); }
.theme-toggle__menu button::after { content: ''; margin-left: auto; color: var(--brand); font-weight: 700; }
.theme-toggle__label { flex: 1; }

[data-theme-pref="light"] .theme-toggle__menu [data-theme-set="light"],
[data-theme-pref="dark"]  .theme-toggle__menu [data-theme-set="dark"],
[data-theme-pref="auto"]  .theme-toggle__menu [data-theme-set="auto"] { color: var(--brand); font-weight: 600; }

/* auth pages have no header, so the control floats in the corner */
.theme-toggle--floating { position: fixed; top: 1rem; right: 1rem; z-index: 30; }
.theme-toggle--floating .theme-toggle__button { background: var(--surface); box-shadow: var(--shadow-sm); }

/* =========================================================
   Dark palette
   =========================================================
   Everything above paints from the tokens declared on :root, so the
   dark theme is a token swap plus the handful of components below
   that bake in light-only pastels.
   ========================================================= */
[data-theme="dark"] {
    color-scheme: dark;

    --brand:        #60a5fa;
    --brand-dark:   #93c5fd;
    --brand-light:  rgba(96, 165, 250, .16);
    --brand-line:   rgba(96, 165, 250, .38);
    --accent:       #fbbf24;
    --success:      #4ade80;
    --success-dark: #86efac;
    --danger:       #f87171;
    --warning:      #fbbf24;

    --ink:          #e6edf7;
    --ink-soft:     #b7c3d6;
    --muted:        #8b9ab2;
    --line:         #23304a;
    --line-soft:    #1a2438;
    --bg:           #0b1220;
    --bg-soft:      #0f1829;
    --bg-code:      #0a1020;

    --surface:      #111b2e;
    --surface-2:    #0d1524;
    --on-brand:     #08111f;
    --header-bg:    rgba(11, 18, 32, .9);
    --hero-bg:      linear-gradient(160deg, #0f1829 0%, #16224a 100%);
    --code-inline:  #f9a8d4;
    --support:      #fb7185;
    --support-dark: #f43f5e;
    --footer-bg:    #070d19;
    --footer-line:  #1b2740;
    --footer-ink:   #b7c3d6;
    --footer-muted: #8b9ab2;

    --shadow:       0 1px 2px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .45);
    --shadow-sm:    0 1px 3px rgba(0, 0, 0, .5);
}

[data-theme="dark"] .btn--support { color: var(--on-brand); }
[data-theme="dark"] .btn--support:hover { color: var(--on-brand); }

/* flash messages */
[data-theme="dark"] .flash--success { background: rgba(74, 222, 128, .12); border-color: rgba(74, 222, 128, .35); color: #bbf7d0; }
[data-theme="dark"] .flash--error   { background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .35); color: #fecaca; }
[data-theme="dark"] .flash--warning { background: rgba(251, 191, 36, .12);  border-color: rgba(251, 191, 36, .35);  color: #fde68a; }
[data-theme="dark"] .flash--info    { background: rgba(96, 165, 250, .12);  border-color: rgba(96, 165, 250, .35);  color: #bfdbfe; }

/* callouts */
[data-theme="dark"] .callout--note    { background: rgba(96, 165, 250, .1);  border-color: rgba(96, 165, 250, .3);  border-left-color: var(--brand); }
[data-theme="dark"] .callout--note .callout__title { color: #93c5fd; }
[data-theme="dark"] .callout--tip     { background: rgba(74, 222, 128, .1);  border-color: rgba(74, 222, 128, .3);  border-left-color: var(--success); }
[data-theme="dark"] .callout--tip .callout__title { color: #86efac; }
[data-theme="dark"] .callout--warning { background: rgba(251, 191, 36, .1);  border-color: rgba(251, 191, 36, .3);  border-left-color: var(--warning); }
[data-theme="dark"] .callout--warning .callout__title { color: #fcd34d; }
[data-theme="dark"] .callout--danger  { background: rgba(248, 113, 113, .1); border-color: rgba(248, 113, 113, .3); border-left-color: var(--danger); }
[data-theme="dark"] .callout--danger .callout__title { color: #fca5a5; }
[data-theme="dark"] .callout--success { background: rgba(45, 212, 191, .1);  border-color: rgba(45, 212, 191, .3); border-left-color: #2dd4bf; }
[data-theme="dark"] .callout--success .callout__title { color: #5eead4; }
[data-theme="dark"] .callout--task    { background: rgba(192, 132, 252, .1); border-color: rgba(192, 132, 252, .3); border-left-color: #c084fc; }
[data-theme="dark"] .callout--task .callout__title { color: #d8b4fe; }

/* the login split screen keeps white text, so its gradient has to stay deep */
[data-theme="dark"] .auth-aside { background: linear-gradient(160deg, #16305c, #0a1730); }

/* a translucent --brand-light would make this vanish */
[data-theme="dark"] .error-page__code { color: #1f3a63; }

/* chapter diagrams are authored as light-mode SVG (dark ink, pale fills),
   so they keep a light plate instead of dissolving into the page */
[data-theme="dark"] .markdown-body svg { background: #f8fafc; border-radius: var(--radius-sm); }
[data-theme="dark"] .md-image { background: #f8fafc; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1100px) {
    .reading-layout { grid-template-columns: 250px minmax(0, 1fr); }
    .reading-toc { display: none; }
    .toc-mobile { display: block; }
}

@media (max-width: 960px) {
    .hero__inner { grid-template-columns: 1fr; }
    .hero__visual { order: -1; }
    .tutorial-body, .profile-grid, .contact-layout { grid-template-columns: 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .site-footer__grid { grid-template-columns: 1fr 1fr; }
    .legal-toc ol { columns: 2; }
}

@media (max-width: 820px) {
    /* the nav collapses, so the theme control takes over the right edge */
    .site-header__inner .theme-toggle { margin-left: auto; }
    .nav-toggle { display: flex; margin-left: .35rem; }
    .site-nav {
        display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: .3rem;
        background: var(--surface); border-bottom: 1px solid var(--line); padding: 1rem 20px 1.4rem;
        box-shadow: var(--shadow);
    }
    .site-nav.is-open { display: flex; }
    .search-box { order: -1; margin-bottom: .5rem; }
    .search-box input { width: 100%; }
    .reading-layout { grid-template-columns: 1fr; }
    .reading-sidebar { position: static; max-height: none; order: 2; margin-top: 2rem; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); }
    .reading-content { order: 1; }
    .chapter-nav { grid-template-columns: 1fr; }
    .profile-head__stat { margin-left: 0; }
}

@media (max-width: 560px) {
    .container { width: calc(100% - 32px); }
    .hero__stats { gap: 1.4rem; }
    .code-input { gap: .35rem; }
    .code-input input { width: 44px; height: 54px; font-size: 1.35rem; }
    .site-footer__grid { grid-template-columns: 1fr; }
    .legal-toc ol { columns: 1; }
    .report-section__prompt { flex-direction: column; align-items: stretch; }
    .contact-form__row { grid-template-columns: 1fr; }
    .code-block code { font-size: .8rem; }
}

@media print {
    .site-header, .site-footer, .reading-sidebar, .reading-toc,
    .chapter-actions, .report-section, .chapter-nav, .reading-progress { display: none !important; }
    .reading-layout { grid-template-columns: 1fr; }
    body { font-size: 12pt; }

    /* printers do not render dark backgrounds well - flatten the code blocks */
    .code-block { background: #fff !important; border: 1px solid #cbd5e1 !important; }
    .code-block__bar { background: #f1f5f9 !important; }
    .code-block__lang { color: #475569 !important; }
    .code-block code { color: #0f172a !important; }
    .code-block code span { color: #0f172a !important; }
    .code-block .hl-comment { color: #64748b !important; }
    .code-block .hl-string  { color: #166534 !important; }
    .code-block .hl-keyword { color: #6b21a8 !important; }
    .code-block .hl-number  { color: #b91c1c !important; }
}
