/* =========================================================================
   SysPotter — site stylesheet (no framework)
   1. Tokens   2. Base   3. Layout   4. Components   5. Header & footer
   6. Home     7. Course page        8. Article page  9. Pricing & checkout
   10. Forms, auth, contact          11. Legal, profile, error   12. Utilities
   ========================================================================= */

/* 1. Tokens -------------------------------------------------------------- */
:root {
    --paper: #fbfaf7;
    --surface: #ffffff;
    --surface-2: #f4f3ef;
    --ink: #0b1120;
    --ink-2: #1f2a3d;
    --body: #3d4658;
    --muted: #667085;
    --line: #e5e4df;
    --line-strong: #d3d2cc;

    /* Brand palette, taken from the logo */
    --accent: #ffb830;        /* amber: fills only (buttons, bars, highlights) */
    --accent-hover: #f5a50f;
    --accent-soft: #fff4dc;
    --accent-ink: #8a5300;    /* deep amber: text & links on light backgrounds (6:1) */
    --sd: #0a6f96;            /* System Design track (logo cyan) */
    --sd-fill: #47c8ff;
    --sd-soft: #e5f6fe;
    --dsa: #6d45d6;           /* DSA track (logo purple) */
    --dsa-fill: #a884ff;
    --dsa-soft: #f1ebff;
    --warn: #b54708;
    --warn-soft: #fff4e5;
    --ok: #067647;
    --ok-soft: #e7f6ee;
    --danger: #b42318;
    --danger-soft: #fdecea;

    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-head: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    --r-sm: 6px;
    --r: 10px;
    --r-lg: 16px;
    --r-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(11, 18, 32, .05);
    --shadow: 0 1px 2px rgba(11, 18, 32, .04), 0 8px 24px -12px rgba(11, 18, 32, .12);
    --shadow-lg: 0 24px 60px -24px rgba(11, 18, 32, .28);
    --focus: 0 0 0 3px rgba(138, 83, 0, .45);

    --container: 1180px;
    --gutter: clamp(16px, 4vw, 32px);
    --header-h: 64px;
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-padding-top: calc(var(--header-h) + 16px);
}

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--paper);
    color: var(--body);
    font: 400 16px/1.6 var(--font-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4 {
    margin: 0 0 .5em;
    color: var(--ink);
    font-family: var(--font-head);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -.02em;
}

h1 { font-size: clamp(2.1rem, 4.6vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); }
h3 { font-size: 1.2rem; letter-spacing: -.01em; }

p { margin: 0 0 1em; }

a {
    color: var(--accent-ink);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover { color: var(--ink); }

img, svg { max-width: 100%; }

:focus-visible {
    outline: none;
    box-shadow: var(--focus);
    border-radius: var(--r-sm);
}

::selection { background: #ffe3a6; }

code, kbd, pre { font-family: var(--font-mono); }

[hidden] { display: none !important; }

/* 3. Layout --------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: calc(var(--container) + 2 * var(--gutter));
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.container-narrow { max-width: calc(760px + 2 * var(--gutter)); }

.section { padding-block: clamp(56px, 8vw, 96px); }

.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px 32px;
    margin-bottom: 32px;
}

.section-head p { max-width: 560px; margin: 0; color: var(--muted); }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    color: var(--accent-ink);
    font: 600 .75rem/1 var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.eyebrow::before {
    content: "";
    width: 18px;
    height: 1px;
    background: currentColor;
}

.lead {
    font-size: clamp(1.05rem, 1.6vw, 1.2rem);
    color: var(--body);
    max-width: 640px;
}

.grid-bg {
    background-image: radial-gradient(rgba(11, 18, 32, .09) 1px, transparent 1px);
    background-size: 22px 22px;
}

/* 4. Components ----------------------------------------------------------- */
.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--ink);
    --btn-border: var(--line-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--btn-border);
    border-radius: var(--r);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font: 600 .95rem/1.2 var(--font-body);
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, transform .15s, box-shadow .15s;
}

.btn:hover { --btn-border: var(--ink-2); color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { --btn-bg: var(--ink); --btn-fg: #fff; --btn-border: var(--ink); }
.btn-primary:hover { --btn-bg: var(--ink-2); --btn-border: var(--ink-2); }

.btn-accent { --btn-bg: var(--accent); --btn-fg: var(--ink); --btn-border: var(--accent); }
.btn-accent:hover { --btn-bg: var(--accent-hover); --btn-border: var(--accent-hover); }

.btn-ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn-ghost:hover { --btn-bg: var(--surface-2); --btn-border: transparent; }

.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-border: #f3c4bf; }
.btn-danger:hover { --btn-bg: var(--danger-soft); --btn-border: var(--danger); }

.btn-sm { min-height: 36px; padding: 6px 14px; font-size: .875rem; }
.btn-lg { min-height: 52px; padding: 14px 26px; font-size: 1rem; }
.btn-block { width: 100%; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--body);
    font: 500 .75rem/1.5 var(--font-body);
    white-space: nowrap;
}

.badge-free { border-color: #b7e4cf; background: var(--ok-soft); color: var(--ok); }
.badge-locked { border-color: var(--line); background: var(--surface-2); color: var(--muted); }
.badge-ok { border-color: #b7e4cf; background: var(--ok-soft); color: var(--ok); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-danger { border-color: #f3c4bf; background: var(--danger-soft); color: var(--danger); }
.badge-dsa { border-color: #d9c9ff; background: var(--dsa-soft); color: var(--dsa); }
.badge-sd { border-color: #b3e6fb; background: var(--sd-soft); color: var(--sd); }

.card {
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.card-pad { padding: clamp(20px, 3vw, 32px); }

.alert {
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: var(--r);
    font-size: .95rem;
}

.alert-success { border-color: #b7e4cf; background: var(--ok-soft); color: var(--ok); }
.alert-error { border-color: #f3c4bf; background: var(--danger-soft); color: var(--danger); }
.alert-info { border-color: #f6d58f; background: var(--accent-soft); color: var(--accent-ink); }

.stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 32px;
    margin: 28px 0 0;
    padding: 0;
    list-style: none;
}

.stat-row li { display: flex; flex-direction: column; }

.stat-value {
    color: var(--ink);
    font: 600 1.4rem/1.2 var(--font-head);
}

.stat-label {
    color: var(--muted);
    font: 500 .72rem/1.4 var(--font-mono);
    letter-spacing: .06em;
    text-transform: uppercase;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
    color: var(--muted);
    font-size: .875rem;
}

.breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 6px; color: var(--line-strong); }
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--ink); text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--ink-2); }

.search-field { position: relative; }

.search-field svg {
    position: absolute;
    top: 50%;
    left: 12px;
    width: 16px;
    height: 16px;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.search-field input { padding-left: 36px; }

.empty-state {
    padding: 48px 24px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-lg);
    text-align: center;
    color: var(--muted);
}

.empty-state h3 { margin-bottom: 6px; }

/* Dialog (native <dialog>) */
dialog.modal {
    width: min(640px, calc(100vw - 32px));
    max-height: min(86vh, 860px);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--body);
    box-shadow: var(--shadow-lg);
}

dialog.modal::backdrop { background: rgba(11, 18, 32, .55); backdrop-filter: blur(2px); }

dialog.modal-wide { width: calc(100vw - 32px); max-width: 1400px; height: calc(100vh - 48px); max-height: none; }

.modal-inner { display: flex; flex-direction: column; max-height: inherit; height: 100%; }

.modal-header,
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 22px;
}

.modal-header { border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 1.25rem; }
.modal-footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.modal-body { flex: 1; overflow: auto; padding: 20px 22px; }
.modal-body h3 { margin: 18px 0 4px; font-size: 1rem; }
.modal-body h3:first-child { margin-top: 0; }
.modal-body p { font-size: .95rem; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* 5. Header & footer ------------------------------------------------------ */
.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--r);
    background: var(--ink);
    color: #fff;
}

.skip-link:focus { top: 12px; color: #fff; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid transparent;
    background: rgba(251, 250, 247, .82);
    backdrop-filter: saturate(180%) blur(12px);
    transition: border-color .2s;
}

.site-header.is-scrolled { border-bottom-color: var(--line); }

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    height: var(--header-h);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font: 500 1.2rem/1 var(--font-head);
    letter-spacing: -.02em;
    text-decoration: none;
}

.brand:hover { color: var(--ink); }
.brand strong { font-weight: 700; }

.brand-mark { width: 32px; height: 32px; flex: none; }

.primary-nav { display: flex; align-items: center; gap: 4px; }

.primary-nav > a:not(.btn):not(.nav-user) {
    padding: 8px 12px;
    border-radius: var(--r-sm);
    color: var(--body);
    font-size: .95rem;
    font-weight: 500;
    text-decoration: none;
}

.primary-nav > a:not(.btn):not(.nav-user):hover { background: var(--surface-2); color: var(--ink); }
.nav-cta { margin-left: 8px; }

.nav-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding: 4px 12px 4px 4px;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--ink);
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
}

.nav-user:hover { border-color: var(--line-strong); color: var(--ink); }
.nav-user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    font: 600 .85rem/1 var(--font-head);
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    cursor: pointer;
}

.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
    display: block;
    width: 18px;
    height: 2px;
    margin-inline: auto;
    border-radius: 2px;
    background: var(--ink);
    transition: transform .2s, opacity .2s;
}

.nav-toggle-bar { position: relative; }
.nav-toggle-bar::before, .nav-toggle-bar::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bar::before { top: -6px; }
.nav-toggle-bar::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after { transform: translateY(-6px) rotate(-45deg); }

.site-footer {
    margin-top: auto;
    padding: 56px 0 28px;
    border-top: 1px solid var(--line);
    background: var(--surface);
    font-size: .925rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 32px;
}

.footer-brand p { max-width: 360px; margin-top: 14px; color: var(--muted); }

.footer-col { display: flex; flex-direction: column; gap: 8px; }

.footer-col h2 {
    margin: 0 0 4px;
    color: var(--ink);
    font: 600 .75rem/1.4 var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.footer-col a { color: var(--body); text-decoration: none; }
.footer-col a:hover { color: var(--ink); text-decoration: underline; }

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: .85rem;
}

/* 6. Home ----------------------------------------------------------------- */
.hero {
    position: relative;
    overflow: hidden;
    padding: clamp(48px, 8vw, 104px) 0 clamp(48px, 7vw, 88px);
    border-bottom: 1px solid var(--line);
}

.hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, var(--paper));
    pointer-events: none;
}

.hero-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
    align-items: center;
    gap: clamp(32px, 6vw, 72px);
}

.hero h1 { max-width: 14ch; }
.hero h1 em {
    font-style: normal;
    background: linear-gradient(transparent 62%, var(--accent) 62%, var(--accent) 92%, transparent 92%);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.hero-tracks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }

.blueprint {
    position: relative;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.blueprint-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    color: var(--muted);
    font: 500 .75rem/1 var(--font-mono);
}

.blueprint-bar i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--line-strong);
}

.blueprint-bar span { margin-left: 8px; }
.blueprint svg { display: block; width: 100%; height: auto; }
.blueprint .bp-box { fill: var(--surface); stroke: var(--ink-2); stroke-width: 1.5; }
.blueprint .bp-accent { fill: var(--accent-soft); stroke: #e6a11f; }
.blueprint .bp-dsa { fill: var(--dsa-soft); stroke: var(--dsa-fill); }
.blueprint .bp-line { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 4 4; }
.blueprint text { fill: var(--ink); font: 500 11px var(--font-mono); }

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.course-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color .2s, box-shadow .2s, transform .2s;
}

.course-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }

.course-card::before {
    content: "";
    position: absolute;
    top: -1px;
    left: 26px;
    right: 26px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--sd-fill);
}

.course-card.is-dsa::before { background: var(--dsa-fill); }

.course-card h3 { margin: 14px 0 8px; font-size: 1.45rem; }

.course-card h3 a { color: inherit; text-decoration: none; }

/* Whole card is clickable while keeping a single, meaningful link for SEO and screen readers. */
.course-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }

.course-card p { color: var(--muted); }

.course-card .thumb {
    margin: -26px -26px 18px;
    border-bottom: 1px solid var(--line);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    overflow: hidden;
    aspect-ratio: 16 / 7;
}

.course-card .thumb img { width: 100%; height: 100%; object-fit: cover; }

.course-meta {
    display: flex;
    gap: 22px;
    margin: 8px 0 18px;
    padding: 14px 0;
    border-block: 1px solid var(--line);
}

.course-meta div { display: flex; flex-direction: column; }
.course-meta strong { color: var(--ink); font: 600 1.15rem/1.2 var(--font-head); }
.course-meta span { color: var(--muted); font-size: .8rem; }

.topic-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; padding: 0; list-style: none; }

.topic-list li {
    padding: 3px 10px;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: .8rem;
}

.card-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    color: var(--ink);
    font-weight: 600;
}

.course-card:hover .card-cta span { transform: translateX(3px); }
.card-cta span { transition: transform .2s; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.feature {
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
}

.feature-num {
    display: inline-block;
    margin-bottom: 18px;
    color: var(--accent-ink);
    font: 600 .8rem/1 var(--font-mono);
}

.feature h3 { margin-bottom: 8px; }
.feature p { margin: 0; color: var(--muted); font-size: .95rem; }

.cta-band {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 24px;
    padding: clamp(28px, 5vw, 48px);
    border-radius: var(--r-lg);
    background: var(--ink);
    color: #c9cfdb;
}

.cta-band h2 { color: #fff; margin-bottom: 8px; }
.cta-band p { margin: 0; }
.cta-band .btn { --btn-bg: var(--accent); --btn-fg: var(--ink); --btn-border: var(--accent); }
.cta-band .btn:hover { --btn-bg: var(--accent-hover); --btn-border: var(--accent-hover); }

/* 7. Course page ---------------------------------------------------------- */
.page-hero {
    padding: clamp(36px, 6vw, 72px) 0 clamp(32px, 5vw, 56px);
    border-bottom: 1px solid var(--line);
}

.page-hero h1 { max-width: 20ch; }

.course-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
    gap: 48px;
}

.enroll-card { position: sticky; top: calc(var(--header-h) + 20px); }

.enroll-card .price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin: 6px 0 2px;
    color: var(--ink);
    font: 600 2.2rem/1 var(--font-head);
}

.enroll-card .price small { color: var(--muted); font: 500 .9rem var(--font-body); }
.enroll-card ul { margin: 18px 0; padding: 0; list-style: none; font-size: .925rem; }

.enroll-card li {
    position: relative;
    padding: 5px 0 5px 24px;
}

.enroll-card li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 12px;
    width: 10px;
    height: 6px;
    border-left: 2px solid var(--ok);
    border-bottom: 2px solid var(--ok);
    transform: rotate(-45deg);
}

.enroll-card .btn + .btn { margin-top: 10px; }

.curriculum-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.curriculum-head .search-field { width: min(100%, 340px); }

.module {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    overflow: hidden;
}

.module > summary {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 22px;
    cursor: pointer;
    list-style: none;
}

.module > summary::-webkit-details-marker { display: none; }
.module > summary:hover { background: #fcfcfa; }

.module-num {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--ink);
    font: 600 .85rem/1 var(--font-mono);
}

.module-title { flex: 1; margin: 0; font-size: 1.1rem; }
.module-count { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.chevron {
    flex: none;
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .2s;
}

details[open] > summary .chevron { transform: rotate(-135deg) translate(-2px, -2px); }

.module-body { padding: 4px 22px 18px; border-top: 1px solid var(--line); }

.part { padding-top: 14px; }

.part-title {
    margin: 0 0 6px;
    color: var(--muted);
    font: 600 .75rem/1.4 var(--font-mono);
    letter-spacing: .06em;
    text-transform: uppercase;
}

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

.lesson {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-inline: -12px;
    border-radius: var(--r);
    color: var(--ink-2);
    text-decoration: none;
}

.lesson:hover { background: var(--surface-2); color: var(--ink); }
.lesson-idx { color: var(--muted); font: 500 .8rem var(--font-mono); }
.lesson-title { font-weight: 500; }
.lesson-time { color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* 8. Article page --------------------------------------------------------- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    width: 100%;
    height: 3px;
    background: transparent;
    pointer-events: none;
}

.reading-progress span {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: 0 50%;
}

.article-hero {
    padding: clamp(28px, 5vw, 56px) 0 28px;
    border-bottom: 1px solid var(--line);
}

.article-hero h1 { max-width: 28ch; font-size: clamp(1.9rem, 4vw, 3rem); }

.article-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.reading-layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr) 220px;
    align-items: start;
    gap: 40px;
    padding-block: 32px 72px;
}

.sidebar {
    position: sticky;
    top: calc(var(--header-h) + 20px);
    max-height: calc(100vh - var(--header-h) - 40px);
    overflow: auto;
    padding-right: 6px;
    scrollbar-width: thin;
}

.sidebar-title {
    margin: 0 0 10px;
    color: var(--muted);
    font: 600 .72rem/1.4 var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sidebar .search-field { margin-bottom: 12px; }
.sidebar .search-field input { min-height: 38px; font-size: .875rem; }

.toc-module { border-bottom: 1px solid var(--line); }

.toc-module > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    color: var(--ink);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
}

.toc-module > summary::-webkit-details-marker { display: none; }
.toc-part { margin: 6px 0 4px; color: var(--muted); font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.toc-list { margin: 0 0 10px; padding: 0; list-style: none; }

.toc-link {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    border-left: 2px solid var(--line);
    color: var(--body);
    font-size: .875rem;
    line-height: 1.4;
    text-decoration: none;
}

.toc-link:hover { border-left-color: var(--line-strong); background: var(--surface-2); color: var(--ink); }

.toc-link[aria-current="page"] {
    border-left-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
}

.toc-link .lock { flex: none; margin-left: auto; color: var(--muted); font-size: .75rem; }

.sidebar-toggle {
    display: none;
    width: 100%;
    justify-content: space-between;
}

.on-this-page { position: sticky; top: calc(var(--header-h) + 20px); font-size: .875rem; }
.on-this-page ol { margin: 0 0 20px; padding: 0; list-style: none; border-left: 1px solid var(--line); }
.on-this-page a { display: block; padding: 4px 0 4px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); text-decoration: none; }
.on-this-page a:hover { color: var(--ink); }
.on-this-page a.is-active { border-left-color: var(--accent); color: var(--ink); font-weight: 500; }
.on-this-page .toc-h3 a { padding-left: 26px; font-size: .825rem; }

/* Article typography */
.prose {
    min-width: 0;
    color: #2b3445;
    font-size: 1.0625rem;
    line-height: 1.75;
}

.prose > :first-child { margin-top: 0; }
.prose h2 { margin: 2.2em 0 .6em; font-size: 1.65rem; }
.prose h3 { margin: 1.8em 0 .5em; font-size: 1.3rem; }
.prose h4 { margin: 1.6em 0 .4em; font-size: 1.1rem; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre, .prose figure { margin: 0 0 1.25em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { color: var(--ink); }
.prose a { font-weight: 500; }
.prose hr { margin: 2.5em 0; border: 0; border-top: 1px solid var(--line); }
.prose img { height: auto; border: 1px solid var(--line); border-radius: var(--r); }
.prose figcaption { margin-top: 8px; color: var(--muted); font-size: .875rem; text-align: center; }

.prose blockquote {
    padding: 14px 18px;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--r) var(--r) 0;
    background: var(--accent-soft);
    color: var(--ink-2);
}

.prose blockquote > :last-child { margin-bottom: 0; }

.prose :not(pre) > code {
    padding: .15em .4em;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface-2);
    color: #a3215a;
    font-size: .86em;
}

.prose pre {
    position: relative;
    overflow: auto;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: #f7f7f4;
    font-size: .875rem;
    line-height: 1.6;
}

.prose pre code { padding: 0; background: none; }
.prose pre code.hljs { padding: 0; background: transparent; }

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--muted);
    font: 500 .75rem var(--font-body);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}

.prose pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }

.prose table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: .95rem;
}

.prose th, .prose td { padding: 10px 14px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); color: var(--ink); font-weight: 600; }

.mermaid-diagram {
    margin: 0 0 1.25em;
    padding: 16px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    text-align: center;
    cursor: zoom-in;
}

.mermaid-diagram:not([data-processed]) { color: transparent; min-height: 120px; }

#diagramModalContent svg { max-width: none; height: auto; }

.paywall {
    position: relative;
    margin-top: 8px;
    padding: clamp(24px, 4vw, 40px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
}

.paywall-teaser {
    position: relative;
    max-height: 9em;
    overflow: hidden;
    color: var(--body);
}

.paywall-teaser::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent, var(--paper) 90%);
}

.paywall-icon {
    display: inline-grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-ink);
}

.paywall h2 { font-size: 1.5rem; }
.paywall p { max-width: 460px; margin-inline: auto; color: var(--muted); }
.paywall .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }

.pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 48px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.pager a {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
}

.pager a:hover { border-color: var(--ink-2); }
.pager small { color: var(--muted); font: 500 .75rem var(--font-mono); letter-spacing: .05em; text-transform: uppercase; }
.pager .next { grid-column: 2; text-align: right; }

.admin-edit { margin-top: 24px; }

/* 9. Pricing & checkout -------------------------------------------------- */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.plan {
    display: flex;
    flex-direction: column;
    padding: 28px;
}

.plan h2, .plan h3 { margin: 10px 0 6px; font-size: 1.4rem; }
.plan p { color: var(--muted); }

.plan-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 8px 0 4px;
    color: var(--ink);
    font: 600 2.4rem/1 var(--font-head);
}

.plan-price small { color: var(--muted); font: 500 .95rem var(--font-body); }
.plan-sub { margin-bottom: 18px; font-size: .875rem; }
.plan ul { flex: 1; margin: 6px 0 22px; padding: 18px 0 0; border-top: 1px solid var(--line); list-style: none; }
.plan li { position: relative; padding: 5px 0 5px 24px; font-size: .95rem; }

.plan li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 12px;
    width: 10px;
    height: 6px;
    border-left: 2px solid var(--ok);
    border-bottom: 2px solid var(--ok);
    transform: rotate(-45deg);
}

.checkout-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    align-items: start;
    gap: 40px;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 18px 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface-2);
    font-size: .9rem;
    line-height: 1.5;
}

.checkbox input { flex: none; width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent-ink); }

.fine-print { margin: 14px 0 0; color: var(--muted); font-size: .8rem; text-align: center; }

.trust-list { display: grid; gap: 14px; margin: 24px 0 0; padding: 0; list-style: none; }

.trust-list li {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 14px;
    align-items: start;
}

.trust-list .num {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: var(--r);
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--accent-ink);
    font: 600 .8rem var(--font-mono);
}

.trust-list strong { display: block; color: var(--ink); }
.trust-list span { color: var(--muted); font-size: .925rem; }

/* 10. Forms, auth, contact ------------------------------------------------ */
.field { margin-bottom: 18px; }

.field label {
    display: block;
    margin-bottom: 6px;
    color: var(--ink);
    font-size: .9rem;
    font-weight: 600;
}

.input, .field input, .field textarea, .field select, .search-field input {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--surface);
    color: var(--ink);
    font: 400 1rem/1.4 var(--font-body);
    transition: border-color .15s, box-shadow .15s;
}

.field textarea { min-height: 150px; resize: vertical; }

.input:focus, .field input:focus, .field textarea:focus, .field select:focus, .search-field input:focus {
    border-color: var(--accent-ink);
    outline: none;
    box-shadow: var(--focus);
}

.field.has-error input, .field.has-error textarea { border-color: var(--danger); }
.field-error { margin-top: 6px; color: var(--danger); font-size: .85rem; }
.field-hint { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: .8rem; }

.hp-field { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.auth-wrap {
    display: grid;
    place-items: center;
    padding: clamp(40px, 8vw, 96px) var(--gutter);
}

.auth-card { width: min(100%, 460px); padding: clamp(28px, 5vw, 44px); text-align: center; }
.auth-card h1 { font-size: clamp(1.7rem, 3vw, 2.1rem); }
.auth-card p { color: var(--muted); }

.google-btn {
    width: 100%;
    margin-top: 12px;
    gap: 12px;
    --btn-border: var(--line-strong);
}

.google-btn svg { width: 20px; height: 20px; }

.contact-layout {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: clamp(28px, 6vw, 72px);
    align-items: start;
}

/* 11. Legal, profile, error ---------------------------------------------- */
.legal { padding-block: clamp(36px, 6vw, 72px); }
.legal-header { margin-bottom: 32px; }
.legal-header .updated { color: var(--muted); font: 500 .8rem var(--font-mono); }
.legal-body section { padding: 22px 0; border-top: 1px solid var(--line); }
.legal-body h2 { font-size: 1.3rem; }
.legal-body h3 { margin-top: 1.2em; font-size: 1.05rem; }
.legal-body ul { padding-left: 1.3em; }
.legal-body li { margin: .3em 0; }

.profile-grid { display: grid; gap: 20px; padding-block: 36px 72px; }

.profile-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
}

.profile-head .avatar { width: 56px; height: 56px; font-size: 1.4rem; }
.profile-head h1 { margin: 0; font-size: 1.8rem; }
.profile-head p { margin: 0; color: var(--muted); }
.profile-head form { margin-left: auto; }

.card-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.card-title h2 { margin: 0; font-size: 1.2rem; }

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

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .925rem;
}

.table th {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font: 600 .72rem var(--font-mono);
    letter-spacing: .06em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.table td { padding: 14px 12px; border-bottom: 1px solid var(--line); color: var(--ink-2); }
.table tr:last-child td { border-bottom: 0; }

.error-page { display: grid; place-items: center; padding: clamp(56px, 10vw, 120px) var(--gutter); text-align: center; }
.error-code { color: var(--line-strong); font: 700 clamp(5rem, 16vw, 9rem)/1 var(--font-head); letter-spacing: -.04em; }
.error-page p { max-width: 460px; color: var(--muted); }
.error-page .actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }

/* 12. Utilities & responsive --------------------------------------------- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }

@media (max-width: 1180px) {
    .reading-layout { grid-template-columns: 250px minmax(0, 1fr); }
    .on-this-page-col { display: none; }
}

@media (max-width: 960px) {
    .hero-grid, .course-hero-grid, .checkout-layout, .contact-layout { grid-template-columns: 1fr; }
    .hero h1 { max-width: 18ch; }
    .enroll-card { position: static; }
    .feature-grid { grid-template-columns: 1fr; }
    .reading-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 20px; }
    .sidebar { position: static; max-height: none; overflow: visible; padding: 0; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-panel { display: none; margin-top: 12px; }
    .sidebar.is-open .sidebar-panel { display: block; }
}

@media (max-width: 760px) {
    .nav-toggle { display: inline-grid; place-items: center; }

    .primary-nav {
        position: absolute;
        top: var(--header-h);
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: 12px var(--gutter) 20px;
        border-bottom: 1px solid var(--line);
        background: var(--paper);
        box-shadow: var(--shadow);
    }

    .primary-nav.is-open { display: flex; }
    .primary-nav > a:not(.btn):not(.nav-user) { padding: 12px; }
    .nav-cta, .nav-user { margin: 8px 0 0; }
    .nav-user { align-self: flex-start; }

    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
    .cta-band { grid-template-columns: 1fr; }
    .course-grid { grid-template-columns: 1fr; }
    .lesson { grid-template-columns: 40px minmax(0, 1fr) auto; }
    .lesson-time { display: none; }
    .pager { grid-template-columns: 1fr; }
    .pager .next { grid-column: 1; }
    .profile-head form { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
    .site-header, .site-footer, .sidebar, .on-this-page-col, .reading-progress, .pager, .copy-btn { display: none !important; }
    .reading-layout { display: block; }
    body { background: #fff; }
}

.pt-0 { padding-top: 0; }
.blueprint .bp-note { fill: var(--muted); }

/* Legal pages (terms, privacy, refunds) */
.legal-page { padding-block: clamp(36px, 6vw, 72px); }
.legal-container { max-width: calc(780px + 2 * var(--gutter)); margin-inline: auto; padding-inline: var(--gutter); }
.legal-hero { margin-bottom: 28px; }
.legal-hero h1 span { color: var(--accent-ink); }
.legal-hero p { color: var(--body); font-size: 1.05rem; }
.legal-eyebrow {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--accent-ink);
    font: 600 .75rem/1 var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
}
.legal-updated { color: var(--muted); font: 500 .8rem var(--font-mono); }
.legal-card { padding: clamp(20px, 4vw, 40px); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.legal-section { padding: 22px 0; border-top: 1px solid var(--line); }
.legal-section:first-child { padding-top: 0; border-top: 0; }
.legal-section h2 { font-size: 1.3rem; }
.legal-section h3 { margin-top: 1.2em; font-size: 1.05rem; }
.legal-section ul { padding-left: 1.3em; }
.legal-section li { margin: .3em 0; }
.legal-bottom { margin-top: 24px; }
.legal-home-link { font-weight: 600; text-decoration: none; }

/* Layout helpers used by course & checkout pages */
.course-title { margin-top: 14px; }
.container-mid { max-width: calc(900px + 2 * var(--gutter)); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 24px; }
.eyebrow-flush { margin: 0; }

/* Fixes: keep icon padding on search inputs (overrides generic input padding above) and
   stop track badges stretching inside flex-column cards. */
.search-field input { padding-left: 38px; }
.course-card > .badge, .plan > .badge { align-self: flex-start; }

/* Optional email/password sign-in (review account) */
.password-login { margin-top: 18px; text-align: left; }
.password-login summary { color: var(--muted); font-size: .9rem; text-align: center; cursor: pointer; }
.password-login summary:hover { color: var(--ink); }
.password-login form { margin-top: 16px; }

/* Course page: membership card for learners who already have access */
.member-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 0; color: var(--ink-2); }

/* Approximate USD price under INR prices (display only; payments are in INR) */
.price-usd { margin: 4px 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }

/* Inline SVG diagrams in lessons (their style attribute is stripped, so size them here).
   Mermaid diagrams sit inside .mermaid-diagram and are not affected. */
.prose > svg, .prose figure > svg { display: block; max-width: min(100%, 560px); height: auto; margin: 1.25em auto; font-family: inherit; }