:root {
  /* paper / ink */
  --paper: #f6f3ec;
  --paper-2: #efeae0;
  --paper-3: #e6e0d2;
  --surface: #fdfbf7;
  --surface-2: #ffffff;

  --ink: #1a1814;
  --ink-2: #3a3630;
  --ink-3: #706957;
  --ink-4: #a39c8a;
  --ink-5: #d6cfbd;

  --stroke: rgba(26, 24, 20, 0.10);
  --stroke-2: rgba(26, 24, 20, 0.16);
  --stroke-soft: rgba(26, 24, 20, 0.06);

  /* accents (blue = primary accent role) */
  --blue: #2563eb;
  --blue-2: #1d4fd7;
  --blue-soft: #e3ecff;
  --blue-softer: #eef3ff;

  --coral: #f08c6a;
  --coral-2: #e3744e;
  --coral-soft: #fde5d9;

  --mint: #42a883;
  --mint-soft: #d8eee3;

  --amber: #d9a33a;
  --amber-soft: #f7ead0;

  --on-accent: #ffffff;

  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(26, 24, 20, 0.04), 0 1px 0 rgba(26, 24, 20, 0.03);
  --shadow: 0 1px 3px rgba(26, 24, 20, 0.04), 0 4px 14px rgba(26, 24, 20, 0.06);
  --shadow-lg: 0 12px 34px -10px rgba(26, 24, 20, 0.18), 0 4px 12px rgba(26, 24, 20, 0.06);
}

.dark {
  --paper: #20201e;
  --paper-2: #2a2a27;
  --paper-3: #34342f;
  --surface: #262624;
  --surface-2: #2d2d2a;

  --ink: #f2ecd9;
  --ink-2: #d6cfbd;
  --ink-3: #9c937f;
  --ink-4: #6a6253;
  --ink-5: #3a352a;

  --stroke: rgba(242, 236, 217, 0.08);
  --stroke-2: rgba(242, 236, 217, 0.14);
  --stroke-soft: rgba(242, 236, 217, 0.05);

  --blue: #6b95ff;
  --blue-2: #87a8ff;
  --blue-soft: rgba(107, 149, 255, 0.14);
  --blue-softer: rgba(107, 149, 255, 0.08);

  --coral: #f29777;
  --coral-2: #f5a98d;
  --coral-soft: rgba(242, 151, 119, 0.18);

  --mint: #6ec6a1;
  --mint-soft: rgba(110, 198, 161, 0.18);

  --amber: #e8c063;
  --amber-soft: rgba(232, 192, 99, 0.18);

  --on-accent: #ffffff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, 0.55), 0 6px 14px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 400;
  font-size: 18px;
  line-height: 1.6;
  transition: background-color 0.15s, color 0.15s;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono {
  font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
code { background: var(--paper-2); padding: 0.1em 0.3em; border-radius: 3px; font-size: 0.9em; }
pre { background: var(--paper-2); padding: 1em; border-radius: 6px; overflow-x: auto; line-height: 1.45; }
pre code { background: transparent; padding: 0; }

/* ── theme toggle ── */
.theme-toggle {
  position: fixed; top: 1rem; right: 1rem; z-index: 100;
  width: 34px; height: 34px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--stroke-2);
  background: var(--surface-2);
  color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { background: var(--paper); border-color: var(--ink-4); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-block; }
html.dark .theme-toggle .icon-sun { display: inline-block; }
html.dark .theme-toggle .icon-moon { display: none; }

/* ── landing ── */
.page-landing { padding: 4rem 1.5rem; max-width: 1100px; margin: 0 auto; }
.site-header h1 {
  font-size: 2.5rem; margin: 0 0 0.4rem 0; letter-spacing: -0.01em;
}
.site-tagline { color: var(--ink-2); font-style: italic; margin: 0 0 3rem 0; }
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}
.module-card {
  display: block;
  padding: 1.4rem 1.5rem;
  border: 1px solid var(--stroke);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.module-card:hover {
  background: var(--surface-2);
  border-color: var(--blue);
  text-decoration: none;
}
.module-id {
  font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 0.4rem;
}
.module-title { font-size: 1.25rem; margin: 0 0 0.6rem 0; }
.module-blurb { color: var(--ink-2); font-size: 0.95rem; margin: 0 0 0.8rem 0; }
.module-meta { font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.75rem; color: var(--ink-3); }

/* ── module page ── */
.page-module { max-width: 820px; margin: 0 auto; padding: 3rem 1.5rem; }
.breadcrumbs { font-size: 0.85rem; color: var(--ink-3); margin-bottom: 1.5rem; }
.bc-sep { margin: 0 0.5rem; color: var(--ink-3); }
.module-header { margin-bottom: 2.5rem; }
.module-header h1 { font-size: 2rem; margin: 0.4rem 0 0.6rem 0; }

.lessons-list { display: flex; flex-direction: column; gap: 0.8rem; }
.lesson-row {
  display: block; padding: 1rem 1.2rem;
  border: 1px solid var(--stroke); background: var(--surface);
  color: var(--ink); text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.lesson-row:hover { background: var(--surface-2); border-color: var(--blue); text-decoration: none; }
.lesson-row-pending { opacity: 0.5; cursor: default; position: relative; }
.lesson-row-pending:hover { background: var(--surface); border-color: var(--stroke); }
.lesson-id { font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 0.3rem; }
.lesson-title { font-size: 1.1rem; margin: 0 0 0.3rem 0; }
.lesson-summary { color: var(--ink-2); font-size: 0.9rem; margin: 0; }
.lesson-pending-badge {
  position: absolute; top: 0.8rem; right: 1rem;
  font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.65rem; color: var(--ink-3);
  background: var(--paper-2); padding: 0.15rem 0.5rem; border-radius: 3px;
}

/* ── lesson page ── */
.page-lesson { max-width: 820px; margin: 0 auto; padding: 3rem 1.5rem 6rem; }
.lesson-article { margin-top: 1rem; font-size: 18px; line-height: 1.6; }
.lesson-article h1 {
  font-size: 2rem; line-height: 1.2; margin: 0 0 1.5rem 0;
  border-bottom: 1px solid var(--stroke); padding-bottom: 0.6rem;
}
.lesson-article h2 { font-size: 1.4rem; margin: 2.5rem 0 1rem 0; }
.lesson-article h3 { font-size: 1.15rem; margin: 2rem 0 0.8rem 0; }
.lesson-article p { margin: 0 0 1.1rem 0; }
.lesson-article ul, .lesson-article ol { margin: 0 0 1.1rem 0; padding-left: 1.6rem; }
.lesson-article li { margin-bottom: 0.4rem; }
.lesson-article blockquote {
  border-left: 3px solid var(--blue);
  padding: 0.4rem 0 0.4rem 1.2rem;
  margin: 1.2rem 0; color: var(--ink-2);
}
.lesson-article hr { border: 0; border-top: 1px solid var(--stroke); margin: 2.5rem 0; }

.embed-image {
  display: block; max-width: 100%; height: auto;
  margin: 1.5rem auto;
  border: 1px solid var(--stroke);
  cursor: zoom-in;
}
.embed-missing {
  display: inline-block; padding: 0.2em 0.5em;
  font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em; background: var(--paper-2); color: var(--ink-3);
  border: 1px dashed var(--ink-3);
}
.embed-link { font-family: 'JetBrains Mono', ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.9em; }

.wikilink { border-bottom: 1px dashed var(--blue); }
.wikilink:hover { text-decoration: none; border-bottom-style: solid; }
.wikilink-unresolved {
  color: var(--ink-3);
  border-bottom: 1px dotted var(--ink-3);
}

.lesson-nav {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 4rem; padding-top: 1.5rem;
  border-top: 1px solid var(--stroke);
  font-size: 0.95rem;
}
.lesson-nav-prev, .lesson-nav-next { max-width: 45%; }
.lesson-nav-spacer { flex: 1; }

/* ── lightbox ── */
.lightbox-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center; justify-content: center;
  cursor: zoom-out;
  overscroll-behavior: contain;
}
.lightbox-overlay.open { display: flex; }
.lightbox-img {
  max-width: 95vw; max-height: 95vh;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}
.lightbox-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 1.5rem; line-height: 1;
  font-family: 'Inter', -apple-system, sans-serif;
  cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.25); }
