/* ==========================================================================
   MarkStudio Pro — codenimbuslabs.com
   Modern design system: light/dark themes, glass nav, aurora hero, bento
   grids, window-framed screenshots, docs layout with sticky TOC.
   No external fonts, no frameworks. KaTeX is self-hosted (math page only).
   ========================================================================== */

/* ---------- Design tokens ---------- */

:root {
  color-scheme: light;

  --bg: #f5f7fc;
  --bg-soft: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f2f5fb;
  --surface-3: #e9eef8;

  --ink: #0b1326;
  --soft: #3d4a64;
  --muted: #5f6f8e;
  --faint: #93a1bd;

  --border: rgba(15, 33, 70, 0.1);
  --border-strong: rgba(15, 33, 70, 0.17);

  --accent: #0a8be0;
  --accent-2: #5b5bf0;
  --accent-ink: #ffffff;
  --accent-soft: rgba(10, 139, 224, 0.1);
  --accent-soft-2: rgba(91, 91, 240, 0.1);
  --gradient: linear-gradient(120deg, #0a8be0, #5b5bf0);
  --gradient-soft: linear-gradient(120deg, rgba(10, 139, 224, 0.12), rgba(91, 91, 240, 0.12));

  --ok: #1a9e6c;
  --warn: #c2613f;

  --code-bg: #0d1428;
  --code-ink: #d9e3f8;
  --code-border: rgba(120, 150, 220, 0.22);

  --glass: rgba(255, 255, 255, 0.72);
  --shadow-sm: 0 1px 2px rgba(11, 19, 38, 0.05), 0 2px 8px rgba(11, 19, 38, 0.05);
  --shadow-md: 0 6px 24px rgba(11, 19, 38, 0.09);
  --shadow-lg: 0 24px 70px -18px rgba(11, 19, 38, 0.25);
  --glow: 0 10px 32px -8px rgba(10, 139, 224, 0.5);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --max: 1180px;

  --font-sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "SF Pro Display", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;

  --bg: #060a15;
  --bg-soft: #090f1d;
  --surface: #0c1325;
  --surface-2: #101a31;
  --surface-3: #16213c;

  --ink: #e9eefb;
  --soft: #b9c5dd;
  --muted: #8294b3;
  --faint: #56668a;

  --border: rgba(148, 175, 230, 0.13);
  --border-strong: rgba(148, 175, 230, 0.22);

  --accent: #41b3ff;
  --accent-2: #8a8dff;
  --accent-ink: #051120;
  --accent-soft: rgba(65, 179, 255, 0.12);
  --accent-soft-2: rgba(138, 141, 255, 0.12);
  --gradient: linear-gradient(120deg, #41b3ff, #8a8dff);
  --gradient-soft: linear-gradient(120deg, rgba(65, 179, 255, 0.14), rgba(138, 141, 255, 0.14));

  --ok: #4cd49b;
  --warn: #e69a77;

  --code-bg: #0a101f;
  --code-ink: #d9e3f8;
  --code-border: rgba(120, 150, 220, 0.2);

  --glass: rgba(7, 11, 22, 0.66);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 70px -18px rgba(0, 0, 0, 0.6);
  --glow: 0 10px 36px -8px rgba(65, 179, 255, 0.4);
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.menu-open { overflow: hidden; }

::selection { background: var(--accent); color: var(--accent-ink); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img { display: block; max-width: 100%; height: auto; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.022em;
  margin: 0 0 0.6em;
  font-weight: 700;
  text-wrap: balance;
}

p { margin: 0 0 1em; }

.grad {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: -100px; left: 16px;
  z-index: 200;
  padding: 0.7rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transition: top 0.2s ease;
}
.skip-link:focus { top: 14px; }

:is(a, button, input, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Inline code, pre, kbd ---------- */

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

code {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.12rem 0.4rem;
  font-size: 0.88em;
}

pre {
  position: relative;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 2.7rem 1.3rem 1.25rem;
  margin: 1.2rem 0 1.6rem;
  font-size: 0.92rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}

pre::before {
  content: "";
  position: absolute;
  top: 15px; left: 17px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: rgba(160, 180, 230, 0.4);
  box-shadow: 19px 0 0 rgba(160, 180, 230, 0.26), 38px 0 0 rgba(160, 180, 230, 0.16);
}

pre code { background: transparent; border: 0; padding: 0; font-size: inherit; color: inherit; }

.copy-btn {
  position: absolute;
  top: 9px; right: 9px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.7rem;
  font: 600 0.74rem var(--font-sans);
  letter-spacing: 0.02em;
  color: #c0cdec;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(160, 180, 230, 0.25);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, background 0.2s ease;
}
pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, 0.14); }
.copy-btn.copied { color: #7fe7b6; border-color: rgba(127, 231, 182, 0.4); opacity: 1; }

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0.18em 0.55em;
  font-size: 0.82em;
  font-weight: 600;
  text-align: center;
  color: var(--soft);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 3px;
  border-radius: 7px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.78rem 1.55rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 600 0.95rem var(--font-sans);
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1.2), box-shadow 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn svg { flex: none; }

.btn.primary {
  background: var(--gradient);
  color: #ffffff;
  box-shadow: var(--glow);
}
.btn.primary:hover { box-shadow: 0 14px 40px -8px rgba(10, 139, 224, 0.55); filter: brightness(1.06); }

.btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.btn.secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn.ghost { color: var(--accent); padding-inline: 1rem; }
.btn.ghost:hover { background: var(--accent-soft); }

.btn.small { padding: 0.5rem 1.05rem; font-size: 0.85rem; }

/* ---------- Header / nav ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  backdrop-filter: blur(16px) saturate(1.6);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.site-header.scrolled { border-bottom-color: var(--border); box-shadow: var(--shadow-sm); }

.nav {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.7rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1.6rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font: 700 1.06rem var(--font-display);
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  list-style: none;
  margin: 0 0 0 auto;
  padding: 0;
}

.nav-links a {
  display: block;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  color: var(--soft);
  font-size: 0.93rem;
  font-weight: 500;
  transition: color 0.2s ease, background 0.2s ease;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-3); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.nav-actions { display: flex; align-items: center; gap: 0.7rem; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  padding: 0;
  background: var(--surface);
  color: var(--soft);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.3s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); transform: rotate(15deg); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.menu-toggle {
  display: none;
  position: relative;
  width: 40px; height: 40px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 120;
}
.menu-toggle span {
  position: absolute;
  left: 9px;
  width: 22px; height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transition: transform 0.3s ease, opacity 0.3s ease, top 0.3s ease;
}
.menu-toggle span:nth-child(1) { top: 13px; }
.menu-toggle span:nth-child(2) { top: 19px; }
.menu-toggle span:nth-child(3) { top: 25px; }
body.menu-open .menu-toggle span:nth-child(1) { top: 19px; transform: rotate(45deg); }
body.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
body.menu-open .menu-toggle span:nth-child(3) { top: 19px; transform: rotate(-45deg); }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  overflow: clip;
  padding: 4.5rem 1.4rem 5rem;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(var(--border-strong) 1px, transparent 1.4px);
  background-size: 26px 26px;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent 78%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent 78%);
}

.hero-bg::before,
.hero-bg::after {
  content: "";
  position: absolute;
  width: 560px; height: 560px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.45;
}
.hero-bg::before {
  top: -220px; left: -130px;
  background: radial-gradient(circle, var(--accent), transparent 65%);
  animation: drift 16s ease-in-out infinite alternate;
}
.hero-bg::after {
  top: -160px; right: -180px;
  background: radial-gradient(circle, var(--accent-2), transparent 65%);
  animation: drift 19s ease-in-out infinite alternate-reverse;
}
html[data-theme="dark"] .hero-bg::before,
html[data-theme="dark"] .hero-bg::after { opacity: 0.3; }

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(70px, 50px) scale(1.12); }
}

.hero-grid {
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 10fr) minmax(0, 11fr);
  gap: 3.4rem;
  align-items: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 0.95rem 0.38rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--soft);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.4rem;
}
.hero-badge .pulse-dot {
  width: 8px; height: 8px;
  margin-left: 0.35rem;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(26, 158, 108, 0.5);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(26, 158, 108, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(26, 158, 108, 0); }
  100% { box-shadow: 0 0 0 0 rgba(26, 158, 108, 0); }
}

.hero h1 {
  font-size: clamp(2.4rem, 1.2rem + 3.4vw, 3.9rem);
  font-weight: 800;
  letter-spacing: -0.034em;
  margin-bottom: 1rem;
}

.lead {
  font-size: clamp(1.02rem, 0.95rem + 0.35vw, 1.18rem);
  color: var(--muted);
  max-width: 56ch;
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.9rem;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.3rem;
  margin-top: 1.7rem;
  padding: 0;
  list-style: none;
  font-size: 0.86rem;
  color: var(--muted);
}
.hero-meta li { display: inline-flex; align-items: center; gap: 0.45rem; }
.hero-meta svg { color: var(--ok); flex: none; }

/* App window frame for screenshots */

.hero-shot {
  position: relative;
}

.hero-shot::before {
  content: "";
  position: absolute;
  inset: 8% -4% -6% -4%;
  background: var(--gradient);
  filter: blur(70px);
  opacity: 0.22;
  border-radius: 50%;
  z-index: -1;
}

.app-window {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: 0;
}

.app-window-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0.35rem 0.4rem 0.35rem 0.95rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
/* Windows-style window controls: title on the left, minimize / maximize /
   close glyphs on the right (close hovers red). The app is Windows-only, so
   the frame must not imply macOS. */
.app-window-bar i {
  order: 2;
  width: 30px; height: 22px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.app-window-bar i::before { content: ""; color: currentColor; }
.app-window-bar i:nth-child(1)::before { width: 9px; height: 1px; background: currentColor; }
.app-window-bar i:nth-child(2)::before { width: 8px; height: 8px; border: 1px solid currentColor; border-radius: 1px; }
.app-window-bar i:nth-child(3)::before { content: "\00d7"; font: 600 14px/1 var(--font-sans); }
.app-window-bar i:hover { background: var(--surface-3); color: var(--ink); }
.app-window-bar i:nth-child(3):hover { background: #e23b3b; color: #fff; }
.app-window-bar span {
  order: 1;
  margin-right: auto;
  font: 500 0.76rem var(--font-mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-window img { width: 100%; }

.hero-window {
  border-radius: 18px;
}
.hero-window .app-window-bar {
  display: none;
}
.hero-window img {
  display: block;
  border-radius: 18px;
}

.float-chip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.95rem;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  box-shadow: var(--shadow-md);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--soft);
  white-space: nowrap;
}
.float-chip .icon-tile { width: 30px; height: 30px; border-radius: 9px; }
.float-chip.c1 { top: 3.6%; left: 8.2%; }
.float-chip.c2 { top: 72%; right: 13.5%; }
.float-chip.c3 { top: 24%; right: 25%; }

/* ---------- Sections ---------- */

.section { padding: 4.4rem 1.4rem; }
.section.alt { background: var(--bg-soft); border-block: 1px solid var(--border); }
.section-inner { max-width: var(--max); margin: 0 auto; }

.section-head { max-width: 640px; margin-bottom: 2.6rem; }
.section-head.center { margin-inline: auto; text-align: center; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.85rem;
  margin-bottom: 1rem;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.section-head h2, .section-head .h2 {
  font-size: clamp(1.65rem, 1.25rem + 1.4vw, 2.35rem);
  font-weight: 750;
}
.section-head p { color: var(--muted); font-size: 1.04rem; margin: 0; }

/* ---------- Stats strip ---------- */

.stats-strip {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.4rem;
  transform: translateY(-2.4rem);
}
.stats-strip .inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.stat {
  background: var(--surface);
  padding: 1.4rem 1.2rem;
  text-align: center;
}
.stat b {
  display: block;
  font: 800 1.85rem var(--font-display);
  letter-spacing: -0.03em;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat span { font-size: 0.84rem; color: var(--muted); font-weight: 500; }

/* ---------- Cards / grids / bento ---------- */

.grid { display: grid; gap: 1.3rem; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3rem; align-items: center; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.7rem 1.6rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.3, 1), box-shadow 0.35s ease, border-color 0.35s ease;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at 18% -10%, var(--accent-soft), transparent 55%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.card:hover {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  box-shadow: var(--shadow-md);
}
.card:hover::before { opacity: 1; }

.card h3 { font-size: 1.13rem; margin: 0 0 0.5rem; }
.card p { color: var(--muted); font-size: 0.95rem; margin: 0; }
.card > a { position: relative; display: inline-flex; align-items: center; gap: 0.4rem; margin-top: 1.1rem; font-weight: 600; font-size: 0.92rem; }
.card > a::after { content: "→"; transition: transform 0.25s ease; }
.card > a:hover { text-decoration: none; }
.card > a:hover::after { transform: translateX(4px); }

.icon-tile {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  margin-bottom: 1.1rem;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.icon-tile.alt2 { background: var(--accent-soft-2); color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 22%, transparent); }

.bento {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.3rem;
}
.bento .card.span-3 { grid-column: span 3; }
.bento .card.span-2 { grid-column: span 2; }

/* Letter tiles for export formats */
.format-tile {
  display: grid;
  place-items: center;
  width: 46px; height: 46px;
  margin-bottom: 1.1rem;
  border-radius: 13px;
  font: 800 0.82rem var(--font-display);
  letter-spacing: 0.02em;
}
.format-tile.word { background: rgba(41, 98, 198, 0.13); color: #3b76d6; border: 1px solid rgba(41, 98, 198, 0.3); }
.format-tile.pdf { background: rgba(216, 70, 70, 0.12); color: #e06060; border: 1px solid rgba(216, 70, 70, 0.3); }
.format-tile.html { background: rgba(232, 122, 36, 0.13); color: #ec8d44; border: 1px solid rgba(232, 122, 36, 0.3); }

.mini-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.mini-list li {
  position: relative;
  padding: 0.3rem 0 0.3rem 1.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.mini-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.72rem;
  width: 14px; height: 7px;
  border-left: 2px solid var(--ok);
  border-bottom: 2px solid var(--ok);
  transform: rotate(-45deg) scale(0.78);
}

/* ---------- Feature rows ---------- */

.feature-list, .check-list { list-style: none; margin: 1.4rem 0 0; padding: 0; }
.feature-list li, .check-list li {
  position: relative;
  padding: 0.42rem 0 0.42rem 2rem;
  color: var(--soft);
}
.feature-list li::before, .check-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.62rem;
  width: 19px; height: 19px;
  border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a8be0' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center/11px no-repeat;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
html[data-theme="dark"] .feature-list li::before,
html[data-theme="dark"] .check-list li::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2341b3ff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
}

.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.4rem; }
.tag {
  padding: 0.32rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font: 500 0.81rem var(--font-mono);
  color: var(--soft);
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.tag:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); }

/* ---------- Steps ---------- */

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; counter-reset: step; }
.step {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.7rem 1.6rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.step::after {
  counter-increment: step;
  content: "0" counter(step);
  position: absolute;
  top: 0.4rem; right: 1rem;
  font: 800 3.4rem var(--font-display);
  letter-spacing: -0.04em;
  background: var(--gradient-soft);
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  opacity: 0.16;
}
.step h3 { font-size: 1.1rem; margin-bottom: 0.45rem; }
.step p { color: var(--muted); font-size: 0.94rem; margin: 0; }

/* ---------- Theme showcase ---------- */

.theme-tabs { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-bottom: 1.4rem; }
.theme-tabs button {
  padding: 0.5rem 1.15rem;
  background: var(--surface);
  color: var(--soft);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font: 600 0.86rem var(--font-sans);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.theme-tabs button[aria-selected="true"] {
  background: var(--gradient);
  color: #ffffff;
  border-color: transparent;
  box-shadow: var(--glow);
}

.tab-panel[hidden] { display: none; }

.palette-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.7rem;
  margin-top: 1.6rem;
}
.swatch {
  padding: 1rem 0.9rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  font-size: 0.8rem;
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}
.swatch::before {
  content: "Aa";
  display: block;
  font: 700 1.25rem var(--font-display);
  margin-bottom: 0.45rem;
}
.swatch.normal-light { background: #fdfdfc; color: #20262e; }
.swatch.normal-light::before { color: #2471ad; }
.swatch.normal-dark { background: #131e2c; color: #dfe9f5; }
.swatch.normal-dark::before { color: #5dd9e8; }
.swatch.paper-light { background: #f4ecdd; color: #43352a; font-family: Georgia, "Times New Roman", serif; }
.swatch.paper-light::before { color: #8a3a2a; font-family: Georgia, "Times New Roman", serif; }
.swatch.paper-dark { background: #221d15; color: #e2d8c4; font-family: Georgia, "Times New Roman", serif; }
.swatch.paper-dark::before { color: #e8b86d; font-family: Georgia, "Times New Roman", serif; }

/* ---------- Split feature ---------- */

.split-feature {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 3rem;
  align-items: center;
}

/* ---------- FAQ ---------- */

.faq { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }

details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.3s ease;
}
details[open] { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }

summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  padding: 1.1rem 3rem 1.1rem 1.3rem;
  font-weight: 650;
  font-size: 0.98rem;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "";
  position: absolute;
  right: 1.15rem; top: 50%;
  width: 11px; height: 11px;
  translate: 0 -50%;
  background:
    linear-gradient(var(--accent), var(--accent)) center/11px 2px no-repeat,
    linear-gradient(var(--accent), var(--accent)) center/2px 11px no-repeat;
  transition: transform 0.3s ease;
}
details[open] summary::after { transform: rotate(135deg); }
details > p, details > pre { margin: 0 1.3rem 1.2rem; color: var(--muted); font-size: 0.94rem; }
details > pre { margin-top: 0.6rem; }

/* ---------- CTA band ---------- */

.cta-band { padding: 1.4rem; }
.cta-band .inner {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  padding: 4rem 2rem;
  text-align: center;
  border-radius: var(--radius-lg);
  background: linear-gradient(120deg, #0a66c2, #5b5bf0 55%, #7a3ff2);
  color: #ffffff;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}
.cta-band .inner::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.18), transparent 42%),
    radial-gradient(circle at 85% 80%, rgba(255, 255, 255, 0.13), transparent 45%),
    radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1.4px);
  background-size: auto, auto, 24px 24px;
  pointer-events: none;
}
.cta-band h2 {
  position: relative;
  font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.7rem;
}
.cta-band p { position: relative; color: rgba(255, 255, 255, 0.85); max-width: 52ch; margin: 0 auto 1.8rem; }
.cta-band .actions { position: relative; justify-content: center; margin-top: 0; }
.cta-band .btn.primary { background: #ffffff; color: #1d2c6b; box-shadow: 0 14px 38px -10px rgba(0, 0, 0, 0.45); }
.cta-band .btn.secondary { background: transparent; color: #ffffff; border-color: rgba(255, 255, 255, 0.45); }
.cta-band .btn.secondary:hover { border-color: #ffffff; color: #ffffff; }

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 4rem;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 3.4rem 1.4rem 1.4rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2.2fr 1fr 1fr 1fr;
  gap: 2.5rem;
  padding-bottom: 2.6rem;
}

.footer-brand p { color: var(--muted); font-size: 0.92rem; max-width: 34ch; margin: 0.9rem 0 0; }

.footer-col h4 {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.9rem;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: 0.55rem; }
.footer-col a { color: var(--soft); font-size: 0.92rem; }
.footer-col a:hover { color: var(--accent); }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-bottom .footer-links { display: flex; gap: 1.3rem; }
.footer-bottom a { color: var(--muted); }
.footer-bottom a:hover { color: var(--accent); }

/* ---------- Page hero (inner pages) ---------- */

.page-hero {
  position: relative;
  overflow: clip;
  padding: 3.6rem 1.4rem 2.8rem;
}
.page-hero .inner { max-width: var(--max); margin: 0 auto; }
.page-hero h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.9rem);
  font-weight: 780;
  letter-spacing: -0.03em;
  max-width: 22ch;
}
.page-hero .lead { max-width: 64ch; }

/* ---------- Docs layout ---------- */

.page-shell { max-width: var(--max); margin: 0 auto; padding: 0 1.4rem 3rem; }

.content-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 3.2rem;
  align-items: start;
}

.toc {
  position: sticky;
  top: 86px;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 1.1rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.toc::before {
  content: "On this page";
  padding: 0 0.75rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--faint);
}
.toc a {
  position: relative;
  padding: 0.42rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.89rem;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.toc a:hover { color: var(--ink); background: var(--surface-3); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.content { min-width: 0; max-width: 760px; }

.content h2 {
  font-size: 1.5rem;
  font-weight: 720;
  margin: 2.8rem 0 0.9rem;
  padding-top: 0.4rem;
  scroll-margin-top: 92px;
}
.content h2:first-child { margin-top: 0; }
.content h2::before {
  content: "";
  display: block;
  width: 38px; height: 4px;
  border-radius: 4px;
  background: var(--gradient);
  margin-bottom: 0.85rem;
}
.content h3 { font-size: 1.12rem; margin: 1.9rem 0 0.6rem; scroll-margin-top: 92px; }
.content p, .content li { color: var(--soft); }
.content ul { padding-left: 1.3rem; }
.content li { margin-bottom: 0.4rem; }
.content li::marker { color: var(--accent); }

.callout {
  display: flow-root;
  margin: 1.3rem 0 1.6rem;
  padding: 1rem 1.25rem 1rem 3.1rem;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  border-radius: var(--radius-sm);
  color: var(--soft);
  font-size: 0.95rem;
  position: relative;
}
.callout::before {
  content: "";
  position: absolute;
  left: 1.05rem; top: 1.05rem;
  width: 21px; height: 21px;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-5M12 8h.01'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-5M12 8h.01'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* ---------- Tables ---------- */

.table-wrap {
  margin: 1.2rem 0 1.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.table-wrap table, .shortcut-table table, .symbol-table table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
.table-wrap th, .shortcut-table th, .symbol-table th {
  text-align: left;
  padding: 0.8rem 1.15rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-wrap td, .shortcut-table td, .symbol-table td {
  padding: 0.8rem 1.15rem;
  border-bottom: 1px solid var(--border);
  color: var(--soft);
  vertical-align: top;
}
.table-wrap tr:last-child td, .shortcut-table tr:last-child td, .symbol-table tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr, .shortcut-table tbody tr, .symbol-table tbody tr { transition: background 0.15s ease; }
.table-wrap tbody tr:hover, .shortcut-table tbody tr:hover, .symbol-table tbody tr:hover { background: var(--surface-2); }

.shortcut-table, .symbol-table {
  margin: 1.2rem 0 1.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.shortcut-table td:first-child { white-space: nowrap; }

/* ---------- Symbol grid (math page) ---------- */

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 0.7rem;
  margin: 1.1rem 0 1.7rem;
}
.sym {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}
.sym:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}
.sym code { font-size: 0.78rem; background: transparent; border: 0; padding: 0; color: var(--muted); word-break: break-all; }
.sym span { font-size: 1.18rem; color: var(--ink); min-height: 1.5em; }

/* ---------- Search bar ---------- */

.search-bar { position: relative; margin-bottom: 2rem; }
.search-bar input {
  width: 100%;
  padding: 0.95rem 1.2rem 0.95rem 3rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--ink);
  font: 500 0.98rem var(--font-sans);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-sm);
}
.search-bar input::placeholder { color: var(--faint); }
.search-bar::before {
  content: "";
  position: absolute;
  left: 1.15rem; top: 50%;
  translate: 0 -50%;
  width: 18px; height: 18px;
  background: var(--faint);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.8-3.8'/%3E%3C/svg%3E") center/contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.8-3.8'/%3E%3C/svg%3E") center/contain no-repeat;
  pointer-events: none;
}
.search-hint {
  position: absolute;
  right: 1.3rem; top: 50%;
  translate: 0 -50%;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
}

/* ---------- Flow diagram (CSS-only mermaid echo) ---------- */

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  margin: 1.2rem 0 1.7rem;
  padding: 1.5rem 1.3rem;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.flow-node {
  padding: 0.6rem 1.1rem;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent);
  border-radius: 10px;
  font: 600 0.86rem var(--font-mono);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.flow-node.last { background: var(--accent-soft-2); border-color: color-mix(in srgb, var(--accent-2) 36%, transparent); }
.flow-arrow { color: var(--faint); display: inline-flex; }

/* ---------- KaTeX sizing guard ---------- */

.katex { font-size: 1.05em; }
.content .katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.35rem 0; }

/* ---------- Reveal animations ---------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.2, 0.7, 0.3, 1), transform 0.7s cubic-bezier(0.2, 0.7, 0.3, 1);
  transition-delay: var(--reveal-delay, 0s);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

html.no-js [data-reveal] { opacity: 1; transform: none; }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1024px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2.6rem; }
  .hero { padding-top: 3.2rem; }
  .hero-shot { max-width: 720px; }
  .bento .card.span-2, .bento .card.span-3 { grid-column: span 3; }
  .bento { grid-template-columns: repeat(6, 1fr); }
  .grid.two, .split-feature { grid-template-columns: 1fr; gap: 2.2rem; }
  .stats-strip .inner { grid-template-columns: repeat(2, 1fr); }
  .content-layout { grid-template-columns: 1fr; gap: 1.6rem; }
  .toc {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.8rem;
  }
  .toc::before { width: 100%; padding-bottom: 0.4rem; }
  .toc a { border-left: 0; border-radius: 999px; padding: 0.32rem 0.8rem; background: var(--surface-2); }
  .toc a.active { background: var(--accent-soft); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .menu-toggle { display: block; margin-left: auto; }
  .nav { gap: 0.8rem; }
  .nav-links {
    position: fixed;
    inset: 0;
    z-index: 110;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    background: var(--glass);
    -webkit-backdrop-filter: blur(24px) saturate(1.5);
    backdrop-filter: blur(24px) saturate(1.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .nav-links.open { opacity: 1; visibility: visible; }
  .nav-links a { font-size: 1.25rem; padding: 0.7rem 1.6rem; }
  .nav-actions { margin-left: 0; }
  .nav .btn.nav-cta { display: none; }

  .grid.three, .faq, .steps { grid-template-columns: 1fr; }
  .bento .card.span-2, .bento .card.span-3 { grid-column: span 6; }
  .palette-strip { grid-template-columns: repeat(2, 1fr); }
  .section { padding: 3.2rem 1.2rem; }
  .float-chip { display: none; }
  .stats-strip .inner { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr; gap: 1.8rem; }
  .actions .btn { flex: 1 1 auto; }
}

@media (max-width: 430px) {
  .stats-strip .inner { grid-template-columns: 1fr 1fr; }
  .stat b { font-size: 1.5rem; }
  .hero h1 { font-size: 2.15rem; }
}
