/* WAN Web Development — design system.
   Tokens → base → layout → components → pages. Light and dark themes share the same tokens. */

:root {
  --navy-950: #0b1033;
  --navy-900: #111845;
  --navy-800: #1a2260;
  --indigo-700: #3b2fc9;
  --indigo-600: #4f46e5;
  --indigo-500: #6366f1;
  --purple-600: #7c3aed;
  --purple-500: #8b5cf6;
  --cyan-400: #22d3ee;
  --cyan-500: #06b6d4;
  --green-600: #16a34a;
  --amber-500: #f59e0b;
  --red-600: #dc2626;

  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2fa;
  --border: #e3e6f3;
  --text: #141838;
  --text-2: #4b5172;
  --text-3: #7a809f;
  --link: #4338ca;
  --code-bg: #0f1535;
  --code-text: #e5e9ff;

  --brand-gradient: linear-gradient(135deg, var(--indigo-600) 0%, var(--purple-600) 100%);
  --hero-gradient: radial-gradient(1200px 500px at 85% 0%, rgba(124, 58, 237, .35), transparent 60%),
                   linear-gradient(120deg, #0d1240 0%, #1b1d6b 55%, #3a1d7a 100%);
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(17, 24, 69, .06);
  --shadow: 0 4px 16px rgba(17, 24, 69, .08);
  --shadow-lg: 0 18px 40px rgba(17, 24, 69, .16);
  --font: "Hind Siliguri", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-en: "Inter", "Hind Siliguri", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --container: 1240px;
  --reading-size: 1.0625rem;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0a0e2a;
  --surface: #121839;
  --surface-2: #1a2149;
  --border: #283163;
  --text: #e8eaff;
  --text-2: #b3b8dc;
  --text-3: #8389b5;
  --link: #a5b4fc;
  --code-bg: #070b22;
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e2a;
    --surface: #121839;
    --surface-2: #1a2149;
    --border: #283163;
    --text: #e8eaff;
    --text-2: #b3b8dc;
    --text-3: #8389b5;
    --link: #a5b4fc;
    --code-bg: #070b22;
    --shadow: 0 4px 16px rgba(0, 0, 0, .35);
    --shadow-lg: 0 18px 40px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.65;
  color: var(--text); background: var(--bg); overflow-x: hidden;
}
html[lang="en"] body { font-family: var(--font-en); }
img, svg { max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; color: var(--text); }
h1 { font-size: clamp(1.75rem, 3.6vw, 2.6rem); }
h2 { font-size: clamp(1.35rem, 2.4vw, 1.75rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
code, pre, kbd { font-family: var(--mono); font-size: .92em; }
:not(pre) > code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; border: 1px solid var(--border); }
pre { background: var(--code-bg); color: var(--code-text); padding: 1rem 1.1rem; border-radius: var(--radius); overflow-x: auto; line-height: 1.55; position: relative; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--text-2); background: var(--surface-2); }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
:focus-visible { outline: 3px solid var(--cyan-400); outline-offset: 2px; border-radius: 4px; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--indigo-600); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { left: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--text-3); }
.small { font-size: .875rem; }
.center { text-align: center; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
.section { padding: 2.2rem 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.section-title h2 { margin: 0; display: flex; align-items: center; gap: .7rem; }
.section-title h2::after { content: ""; width: 56px; height: 3px; border-radius: 3px; background: var(--brand-gradient); }

/* ---------------------------------------------------------------- top bar & header */
.topbar { background: var(--navy-950); color: #c9cdf5; font-size: .85rem; }
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 38px; flex-wrap: wrap; }
.topbar a, .topbar button { color: #c9cdf5; }
.stack-strip { display: flex; gap: 1.1rem; flex-wrap: wrap; align-items: center; }
.stack-strip span { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.stack-strip .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.topbar-links { display: flex; gap: 1rem; align-items: center; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.header-main { display: flex; align-items: center; gap: 1.2rem; min-height: 72px; }
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); text-decoration: none !important; flex-shrink: 0; }
.brand img { width: 48px; height: 36px; }
.brand-name { font-family: var(--font-en); font-weight: 800; font-size: 1.28rem; line-height: 1.05; letter-spacing: -.01em; }
.brand-name small { display: block; font-weight: 600; font-size: .95rem; color: var(--text-2); }
.brand-tagline { font-size: .82rem; color: var(--text-2); max-width: 260px; line-height: 1.4; border-left: 1px solid var(--border); padding-left: 1rem; }
.header-search { flex: 1; position: relative; max-width: 460px; }
.header-search input { width: 100%; padding: .65rem 1rem .65rem 2.6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; }
.header-search svg { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); width: 18px; color: var(--text-3); }
.suggestions { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); list-style: none; margin: 0; padding: .35rem; z-index: 50; }
.suggestions a { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .7rem; border-radius: 8px; color: var(--text); }
.suggestions a:hover, .suggestions a[aria-selected="true"] { background: var(--surface-2); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; position: relative; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .badge-dot { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; border-radius: 8px; background: var(--red-600); color: #fff; font-size: .65rem; display: grid; place-items: center; padding: 0 4px; }
.lang-select { border: 1px solid var(--border); border-radius: 999px; padding: .45rem .8rem; background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; }
.menu-toggle { display: none; }

.main-nav { background: var(--brand-gradient); }
.main-nav > .container { display: flex; align-items: stretch; gap: .1rem; overflow-x: auto; scrollbar-width: none; }
.main-nav > .container::-webkit-scrollbar { display: none; }
.nav-item { position: relative; }
.nav-link { display: flex; align-items: center; gap: .3rem; color: #eef0ff; padding: .85rem .95rem; font-weight: 500; white-space: nowrap; background: none; border: 0; font: inherit; cursor: pointer; }
.nav-link:hover, .nav-link.active { background: rgba(255, 255, 255, .14); color: #fff; text-decoration: none; }
.nav-link svg { width: 14px; height: 14px; opacity: .8; }
.mega { position: fixed; left: 50%; transform: translateX(-50%); width: min(960px, calc(100vw - 32px)); background: var(--surface); color: var(--text); border-radius: 0 0 var(--radius-lg) var(--radius-lg); box-shadow: var(--shadow-lg); padding: 1.3rem; display: none; z-index: 60; border: 1px solid var(--border); }
.nav-item.open .mega { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .4rem 1.4rem; }
.mega h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: .2rem 0 .3rem; }
.mega a { display: block; padding: .3rem 0; color: var(--text); }

/* ---------------------------------------------------------------- buttons, badges, forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .62rem 1.2rem; border-radius: 10px; font: inherit; font-weight: 600; border: 1px solid transparent; cursor: pointer; text-decoration: none !important; line-height: 1.2; transition: transform .08s ease, box-shadow .15s ease, background .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-gradient); color: #fff; box-shadow: 0 6px 18px rgba(79, 70, 229, .35); }
.btn-primary:hover { box-shadow: 0 10px 24px rgba(79, 70, 229, .45); }
.btn-outline { border-color: var(--indigo-500); color: var(--link); background: transparent; }
.btn-outline:hover { background: rgba(99, 102, 241, .08); }
.btn-light { background: #fff; color: var(--navy-900); }
.btn-ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-sm { padding: .38rem .75rem; font-size: .86rem; border-radius: 8px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge-free { background: rgba(22, 163, 74, .12); color: var(--green-600); border-color: transparent; }
.badge-premium { background: rgba(124, 58, 237, .14); color: var(--purple-600); border-color: transparent; }
.badge-planned { background: rgba(245, 158, 11, .14); color: #b45309; border-color: transparent; }
.badge-status { text-transform: uppercase; letter-spacing: .03em; }
.badge-PUBLISHED, .badge-PAID, .badge-ACTIVE, .badge-OPEN { background: rgba(22, 163, 74, .12); color: var(--green-600); }
.badge-DRAFT, .badge-PENDING_VERIFICATION { background: rgba(245, 158, 11, .14); color: #b45309; }
.badge-REVIEW, .badge-APPROVED, .badge-SCHEDULED { background: rgba(99, 102, 241, .14); color: var(--indigo-600); }
.badge-ARCHIVED, .badge-REJECTED, .badge-SUSPENDED, .badge-HIDDEN, .badge-EXPIRED { background: rgba(220, 38, 38, .1); color: var(--red-600); }

label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-size: .82rem; color: var(--text-3); margin-top: .25rem; }
.field-error { color: var(--red-600); font-size: .85rem; margin-top: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], input[type=url], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: .62rem .8rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
textarea.code { font-family: var(--mono); font-size: .9rem; min-height: 320px; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .35rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 0 1rem; }

.alert { padding: .8rem 1rem; border-radius: var(--radius); margin: 1rem 0; border: 1px solid; }
.alert-ok { background: rgba(22, 163, 74, .08); border-color: rgba(22, 163, 74, .3); color: var(--green-600); }
.alert-error { background: rgba(220, 38, 38, .07); border-color: rgba(220, 38, 38, .3); color: var(--red-600); }
.alert-info { background: rgba(99, 102, 241, .08); border-color: rgba(99, 102, 241, .3); color: var(--text-2); }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1.2rem; }
.card-link { display: block; color: var(--text); text-decoration: none !important; transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--indigo-500); }
.card h3 { margin-bottom: .35rem; }
.card-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .82rem; color: var(--text-3); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.panel-head { background: var(--brand-gradient); color: #fff; padding: .75rem 1.1rem; font-weight: 700; }
.panel-body { padding: 1rem 1.1rem; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-lines li { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.list-lines li:last-child { border-bottom: 0; }
.list-check li { padding: .3rem 0 .3rem 1.8rem; position: relative; }
.list-check li::before { content: ""; position: absolute; left: 0; top: .62rem; width: 18px; height: 18px; border-radius: 50%; background: var(--green-600) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center/12px no-repeat; }

.tech-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .45rem; padding: 1rem .5rem; text-align: center; min-height: 112px; }
.tech-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-family: var(--font-en); font-weight: 800; color: #fff; font-size: 1rem; letter-spacing: -.02em; }
.tech-tile .name { font-weight: 600; font-size: .92rem; color: var(--text); }
.feature { display: flex; gap: 1rem; align-items: flex-start; }
.feature .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.feature .ico svg { width: 26px; height: 26px; }
.ico-indigo { background: rgba(99, 102, 241, .14); color: var(--indigo-600); }
.ico-purple { background: rgba(139, 92, 246, .14); color: var(--purple-600); }
.ico-amber { background: rgba(245, 158, 11, .16); color: #b45309; }
.ico-cyan { background: rgba(6, 182, 212, .14); color: #0e7490; }
.ico-green { background: rgba(22, 163, 74, .12); color: var(--green-600); }

.course-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.course-cover { height: 96px; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-en); font-weight: 800; font-size: 1.3rem; }
.cover-green { background: linear-gradient(135deg, #16a34a, #65a30d); }
.cover-orange { background: linear-gradient(135deg, #ea580c, #dc2626); }
.cover-indigo { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.cover-blue { background: linear-gradient(135deg, #2563eb, #06b6d4); }
.cover-purple { background: linear-gradient(135deg, #7c3aed, #c026d3); }
.course-body { padding: 1rem; display: flex; flex-direction: column; gap: .4rem; flex: 1; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-gradient); border-radius: 99px; }

.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.stat { display: flex; gap: .8rem; align-items: center; padding: 1rem 1.1rem; border-right: 1px solid var(--border); }
.stat:last-child { border-right: 0; }
.stat svg { width: 34px; height: 34px; color: var(--indigo-600); flex-shrink: 0; }
.stat b { display: block; font-size: 1.35rem; font-family: var(--font-en); line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--text-2); }

.roadmap { list-style: none; margin: 0; padding: 0; position: relative; }
.roadmap li { display: flex; gap: .9rem; padding: .55rem 0; position: relative; }
.roadmap li::before { content: ""; position: absolute; left: 15px; top: 2.3rem; bottom: -.5rem; width: 2px; background: var(--border); }
.roadmap li:last-child::before { display: none; }
.roadmap .num { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-gradient); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; position: relative; z-index: 1; font-family: var(--font-en); }

/* ---------------------------------------------------------------- hero */
.hero { background: var(--hero-gradient); color: #fff; position: relative; overflow: hidden; }
.hero .container { display: grid; grid-template-columns: 1.1fr .9fr; gap: 2rem; align-items: center; padding-top: 2.6rem; padding-bottom: 3.4rem; }
.hero h1 { color: #fff; font-size: clamp(2rem, 4.6vw, 3.2rem); line-height: 1.15; }
.hero h1 .accent { background: linear-gradient(90deg, #67e8f9, #a5b4fc); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { color: #d6d9ff; font-size: 1.08rem; max-width: 640px; }
.hero-pill { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .85rem; border-radius: 999px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22); font-weight: 600; margin-bottom: 1rem; }
.hero-checks { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-top: 1.2rem; font-size: .9rem; color: #d6d9ff; }
.hero-checks span::before { content: "✓"; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--green-600); color: #fff; font-size: .7rem; margin-right: .35rem; }
.hero-code { background: rgba(7, 11, 34, .85); border: 1px solid rgba(165, 180, 252, .25); border-radius: var(--radius-lg); box-shadow: 0 30px 60px rgba(0, 0, 0, .45); overflow: hidden; }
.hero-code .bar { display: flex; gap: 6px; padding: .7rem .9rem; background: rgba(255, 255, 255, .05); }
.hero-code .bar i { width: 11px; height: 11px; border-radius: 50%; display: block; }
.hero-code pre { background: transparent; margin: 0; font-size: .86rem; color: #c7d2fe; }
.tok-a { color: #f9a8d4; } .tok-k { color: #93c5fd; } .tok-s { color: #86efac; } .tok-c { color: #64748b; }
.hero-search { display: flex; gap: .5rem; max-width: 600px; margin: 1.2rem 0 0; }
.hero-search input { flex: 1; padding: .8rem 1.1rem; border-radius: 12px; border: 0; font: inherit; }

/* ---------------------------------------------------------------- page layouts */
.page-head { background: var(--hero-gradient); color: #fff; padding: 2rem 0 2.2rem; }
.page-head h1 { color: #fff; margin-bottom: .3rem; }
.page-head p { color: #d6d9ff; margin: 0; max-width: 760px; }
.breadcrumbs { font-size: .85rem; margin-bottom: .6rem; color: #c3c8f5; }
.breadcrumbs a { color: #e0e4ff; }
.breadcrumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.breadcrumbs li + li::before { content: "›"; margin-right: .35rem; opacity: .7; }
.with-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.6rem; align-items: start; }
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: end; margin-bottom: 1.2rem; }
.filters > * { flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: .86rem; }
.chip.active, .chip:hover { background: var(--indigo-600); color: #fff; border-color: var(--indigo-600); text-decoration: none; }
.pagination { display: flex; gap: .4rem; justify-content: center; margin: 1.6rem 0; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--text-3); border: 2px dashed var(--border); border-radius: var(--radius-lg); }

/* tutorial reader: chapters | content | toc */
.reader { display: grid; grid-template-columns: 250px minmax(0, 1fr) 240px; gap: 1.6rem; align-items: start; padding-top: 1.4rem; }
.reader-nav, .reader-aside { position: sticky; top: 88px; max-height: calc(100vh - 100px); overflow: auto; font-size: .92rem; }
.reader-nav ol { list-style: none; padding: 0; margin: 0; }
.reader-nav a { display: flex; gap: .5rem; align-items: center; padding: .42rem .6rem; border-radius: 8px; color: var(--text-2); }
.reader-nav a.current { background: rgba(99, 102, 241, .12); color: var(--link); font-weight: 600; }
.reader-nav a .tick { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.reader-nav a .tick.done { background: var(--green-600); border-color: var(--green-600); }
.article { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: clamp(1rem, 3vw, 2.2rem); min-width: 0; }
.prose { font-size: var(--reading-size); }
.prose h2 { margin-top: 2rem; padding-top: .5rem; border-top: 1px solid var(--border); scroll-margin-top: 96px; }
.prose h3 { margin-top: 1.4rem; scroll-margin-top: 96px; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .25rem 0; }
.prose blockquote { margin: 1rem 0; padding: .6rem 1rem; border-left: 4px solid var(--indigo-500); background: var(--surface-2); border-radius: 0 var(--radius) var(--radius) 0; }
.prose table { display: block; overflow-x: auto; margin: 1rem 0; }
.prose img { border-radius: var(--radius); }
.code-tools { position: absolute; top: .45rem; right: .45rem; display: flex; gap: .3rem; opacity: .85; }
.code-tools button { font: inherit; font-size: .75rem; padding: .2rem .55rem; border-radius: 6px; background: rgba(255, 255, 255, .1); color: #e0e7ff; border: 1px solid rgba(255, 255, 255, .2); cursor: pointer; }
.toc a { display: block; padding: .25rem 0 .25rem .7rem; color: var(--text-2); border-left: 2px solid var(--border); }
.toc a.lvl-3 { padding-left: 1.4rem; font-size: .86rem; }
.toc a.active { color: var(--link); border-left-color: var(--indigo-600); font-weight: 600; }
.reader-tools { display: flex; gap: .4rem; flex-wrap: wrap; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2rem; }
.prevnext a { padding: .9rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); display: block; }
.prevnext .next { text-align: right; }
body.reading-mode .reader-nav, body.reading-mode .reader-aside, body.reading-mode .site-header, body.reading-mode .topbar, body.reading-mode .main-nav, body.reading-mode .site-footer { display: none; }
body.reading-mode .reader { grid-template-columns: minmax(0, 820px); justify-content: center; }

/* learning (lesson) layout */
.learn { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 1.4rem; align-items: start; padding-top: 1.2rem; }
.video { position: relative; padding-top: 56.25%; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 1rem; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* quiz */
.quiz-q { margin-bottom: 1.2rem; }
.quiz-opt { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: 10px; margin: .45rem 0; cursor: pointer; font-weight: 400; }
.quiz-opt:hover { border-color: var(--indigo-500); }
.quiz-opt input { margin-top: .3rem; }
.quiz-opt.correct { border-color: var(--green-600); background: rgba(22, 163, 74, .08); }
.quiz-opt.wrong { border-color: var(--red-600); background: rgba(220, 38, 38, .06); }
.timer { font-family: var(--font-en); font-weight: 700; font-variant-numeric: tabular-nums; }
.score-ring { width: 120px; height: 120px; border-radius: 50%; display: grid; place-items: center; font-size: 1.8rem; font-weight: 800; font-family: var(--font-en); margin: 0 auto 1rem; }

/* playground */
.playground { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.playground textarea { min-height: 420px; background: var(--code-bg); color: var(--code-text); border-color: transparent; tab-size: 4; }
.playground iframe, .output { width: 100%; min-height: 420px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.output { background: var(--code-bg); color: var(--code-text); font-family: var(--mono); font-size: .88rem; padding: 1rem; white-space: pre-wrap; overflow: auto; margin: 0; }
.output .err { color: #fca5a5; }
.playground.fullscreen { position: fixed; inset: 0; z-index: 90; background: var(--bg); padding: 1rem; }

/* dashboard & admin */
.app-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.4rem; padding: 1.4rem 0 2rem; align-items: start; }
.side-menu { position: sticky; top: 88px; }
.side-menu a { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; border-radius: 10px; color: var(--text-2); font-weight: 500; }
.side-menu a:hover { background: var(--surface-2); text-decoration: none; }
.side-menu a.active { background: var(--brand-gradient); color: #fff; }
.side-menu h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin: 1rem .8rem .3rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.kpi b { display: block; font-size: 1.6rem; font-family: var(--font-en); }
.kpi span { color: var(--text-3); font-size: .85rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap table { min-width: 640px; }
.inline-form { display: inline-flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.inline-form select, .inline-form input { width: auto; padding: .3rem .5rem; }
details.box { border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem 1rem; background: var(--surface); margin-bottom: .8rem; }
details.box summary { cursor: pointer; font-weight: 600; }

/* community */
.discussion-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 1rem; padding: 1rem; border-bottom: 1px solid var(--border); }
.discussion-row:last-child { border-bottom: 0; }
.votes { text-align: center; font-size: .78rem; color: var(--text-3); }
.votes b { display: block; font-size: 1.1rem; color: var(--text); font-family: var(--font-en); }
.answer.accepted { border-color: var(--green-600); box-shadow: 0 0 0 1px var(--green-600); }

/* certificate */
.certificate { max-width: 820px; margin: 0 auto; padding: 2.4rem; border: 10px solid transparent; border-radius: 18px; background: linear-gradient(var(--surface), var(--surface)) padding-box, var(--brand-gradient) border-box; text-align: center; }

/* ---------------------------------------------------------------- footer */
.site-footer { background: var(--navy-950); color: #b9bee8; margin-top: 3rem; font-size: .92rem; }
.site-footer a { color: #d9dcff; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 2rem; padding: 2.6rem 0 1.6rem; }
.site-footer h4 { color: #fff; font-size: .98rem; margin-bottom: .7rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { padding: .2rem 0; }
.newsletter { display: flex; gap: .4rem; margin-top: .6rem; }
.newsletter input { flex: 1; min-width: 0; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .1); padding: 1rem 0; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .85rem; }
.offline-banner { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--navy-900); color: #fff; padding: .6rem 1.1rem; border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 99; }
.toast { position: fixed; right: 1rem; bottom: 1rem; background: var(--navy-900); color: #fff; padding: .75rem 1.1rem; border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 99; max-width: 360px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .reader { grid-template-columns: 220px minmax(0, 1fr); }
  .reader-aside { display: none; }
  .brand-tagline { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 900px) {
  .hero .container, .with-sidebar, .learn, .app-shell, .playground { grid-template-columns: minmax(0, 1fr); }
  .hero-code { display: none; }
  .reader { grid-template-columns: minmax(0, 1fr); }
  .reader-nav { position: static; max-height: none; }
  .reader-nav details:not([open]) ol { display: none; }
  .side-menu { position: static; display: flex; gap: .3rem; overflow-x: auto; }
  .side-menu h4 { display: none; }
  .side-menu a { white-space: nowrap; }
  .stat { border-right: 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 720px) {
  .header-main { flex-wrap: wrap; padding: .6rem 0; gap: .6rem; }
  .header-search { order: 3; flex-basis: 100%; max-width: none; }
  .header-actions .btn-label { display: none; }
  .stack-strip { display: none; }
  .menu-toggle { display: inline-grid; }
  .main-nav { display: none; }
  .main-nav.open { display: block; }
  .main-nav > .container { flex-direction: column; overflow: visible; }
  .mega { position: static; transform: none; width: 100%; border-radius: var(--radius); box-shadow: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .prevnext { grid-template-columns: 1fr; }
  .discussion-row { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .site-header, .main-nav, .site-footer, .reader-nav, .reader-aside, .reader-tools, .code-tools, .no-print, #comments { display: none !important; }
  .reader { display: block; }
  .article { border: 0; padding: 0; }
  body { background: #fff; color: #000; }
  pre { white-space: pre-wrap; border: 1px solid #ccc; background: #f6f6f6; color: #000; }
  a { color: #000; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
