/* ============================================================
   Scratch 教程中心 — Anthropic-inspired warm minimal theme
   Palette: ivory canvas, slate ink, terracotta/coral accent
   ============================================================ */

:root {
  /* Surfaces */
  --ivory: #faf9f5;        /* page background */
  --ivory-2: #f0eee6;      /* deeper cream: sections, hover */
  --ivory-3: #e9e6db;      /* subtle fills */
  --card: #ffffff;         /* card surface */

  /* Ink & text */
  --ink: #141413;          /* primary text / headings */
  --ink-soft: #3a3a37;
  --muted: #6f6e67;        /* secondary text */
  --faint: #97958c;        /* tertiary text */

  /* Borders */
  --border: #e6e3d9;
  --border-strong: #d8d4c7;

  /* Accents */
  --coral: #d97757;        /* primary accent (terracotta) */
  --coral-dark: #c15f3c;   /* hover */
  --coral-soft: #f4e6de;   /* tint background */
  --blue: #6a9bcc;
  --green: #788c5d;

  /* Code surface (dark on cream) */
  --code-bg: #1f1e1b;
  --code-bg-2: #2a2925;
  --code-text: #ecebe3;
  --code-border: #34322d;

  /* Typography */
  --font-serif: 'Fraunces', Georgia, 'Noto Sans SC', serif;
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Shape & motion */
  --header-height: 68px;
  --r-xl: 20px;
  --r-lg: 16px;
  --r-md: 10px;
  --r-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 19, 0.04);
  --shadow: 0 6px 24px rgba(20, 20, 19, 0.07);
  --shadow-lg: 0 18px 48px rgba(20, 20, 19, 0.10);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--ivory);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--ivory-2); }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
  border: 2px solid var(--ivory-2);
}
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

a { text-decoration: none; color: inherit; }
button { font-family: var(--font-sans); }

/* ==================== Utilities ==================== */

.gradient-text {
  color: var(--coral);
}

.glass {
  background: var(--card);
  border: 1px solid var(--border);
}

.fade-in {
  animation: fadeInUp 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
  transform: translateY(14px);
}

@keyframes fadeInUp {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes skeletonLoading {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes pageTransition {
  from { opacity: 0.4; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

/* ==================== Header ==================== */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  background: rgba(250, 249, 245, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  transition: var(--transition);
}

.logo:hover { opacity: 0.8; }

.logo-icon { font-size: 1.6rem; }

.logo-text {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ==================== Hero ==================== */

.hero {
  padding: calc(var(--header-height) + 90px) 32px 70px;
  text-align: center;
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

/* Anthropic look is clean — hide the floating particles */
.hero-particles { display: none; }

.hero-content { position: relative; z-index: 1; }

.hero-title {
  font-size: clamp(2.6rem, 6vw, 4rem);
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 560px;
  margin: 0 auto 44px;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 56px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-number {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  color: var(--coral);
}

.stat-label {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ==================== Main Content ==================== */

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 32px 90px;
}

.section-header { margin-bottom: 12px; }

.section-title {
  font-size: 1.9rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.section-desc {
  color: var(--muted);
  font-size: 1rem;
}

/* ==================== Scratch Project Directory ==================== */

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

.project-table-wrap {
  margin-top: 32px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.project-table-wrap[hidden] { display: none; }

.project-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.project-table th,
.project-table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.project-table thead th {
  padding-top: 13px;
  padding-bottom: 13px;
  background: var(--ivory-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.project-table tbody tr:last-child > * { border-bottom: 0; }

.project-row { transition: background-color 0.2s ease; }
.project-row:hover { background: #f8fbff; }

.project-name-cell {
  width: 34%;
  min-width: 260px;
  font-family: var(--font-sans);
}

.project-name-link {
  display: inline-block;
}

.project-list-title {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.project-name-link:hover .project-list-title { color: #3373cc; }

.project-name-link small {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 0.72rem;
  font-weight: 400;
}

.project-category-label {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 20px;
  background: rgba(76, 151, 255, 0.1);
  color: #3373cc;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.project-table .numeric-column {
  text-align: center;
  white-space: nowrap;
}

.project-table td.numeric-column strong {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1rem;
}

.project-size {
  color: var(--muted);
  white-space: nowrap;
}

.project-action-cell { text-align: right !important; }

.project-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #3373cc;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.project-open svg { transition: transform 0.2s ease; }
.project-open:hover svg { transform: translateX(3px); }

/* ==================== Loading / Empty / Error ==================== */

.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--border-strong);
  border-left-color: var(--coral);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.loading-text { margin-top: 18px; color: var(--muted); }

.empty-state {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.empty-icon { font-size: 3.5rem; margin-bottom: 14px; }
.empty-text { color: var(--muted); font-size: 1.05rem; }

.error-state { text-align: center; }
.error-icon { font-size: 2.6rem; }
.error-text { color: var(--muted); margin-top: 12px; }

/* ==================== Skeleton ==================== */

.skeleton {
  background: linear-gradient(90deg, var(--ivory-2) 25%, var(--ivory-3) 50%, var(--ivory-2) 75%);
  background-size: 200% 100%;
  animation: skeletonLoading 1.6s infinite linear;
  border-radius: var(--r-sm);
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-md);
}

.skeleton-line {
  height: 15px;
  margin-bottom: 16px;
  border-radius: 4px;
}

/* ==================== Footer ==================== */

.footer {
  text-align: center;
  padding: 36px 32px;
  color: var(--faint);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
}

/* ==================== Tutorial Page ==================== */

.tutorial-body { overflow: hidden; }

.tutorial-breadcrumb {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  padding: 11px 32px;
  font-size: 0.88rem;
  color: var(--muted);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(240, 238, 230, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.breadcrumb-link { color: var(--coral-dark); transition: var(--transition); }
.breadcrumb-link:hover { color: var(--coral); }
.breadcrumb-sep { color: var(--faint); }
.breadcrumb-current { color: var(--ink); font-weight: 500; }
.breadcrumb-chapter { color: var(--coral-dark); font-weight: 500; }

.tutorial-container {
  --sidebar-width: calc(50% - 8px);
  display: flex;
  height: calc(100vh - var(--header-height) - 44px);
  margin-top: calc(var(--header-height) + 44px);
  padding: 16px;
  gap: 0;
  width: 100%;
}

/* Sidebar (chapter images extracted from the PDF) */
.tutorial-sidebar {
  flex: 0 0 var(--sidebar-width);
  min-width: 0;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tutorial-resizer {
  position: relative;
  flex: 0 0 16px;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}

.tutorial-resizer::before {
  content: '';
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 50%;
  width: 3px;
  border-radius: 3px;
  background: var(--border-strong);
  transform: translateX(-50%);
  transition: width 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.tutorial-resizer:hover::before,
.tutorial-resizer:focus-visible::before,
.tutorial-resizer.dragging::before {
  width: 5px;
  background: var(--coral);
  box-shadow: 0 0 0 4px var(--coral-soft);
}

.tutorial-body.resizing-panels,
.tutorial-body.resizing-panels * {
  cursor: col-resize !important;
  user-select: none !important;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px;
}

.page-display {
  flex: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--r-md);
  min-height: 0;
  background: var(--ivory-2);
}

.chapter-gallery-empty {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 32px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

.chapter-gallery {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
}

.chapter-gallery-header {
  position: sticky;
  top: -16px;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: -16px -16px 14px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--ivory-2) 94%, transparent);
  backdrop-filter: blur(8px);
}

.chapter-gallery-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--coral);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.chapter-gallery-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.35;
}

.chapter-gallery-count {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.chapter-image-list {
  display: grid;
  gap: 16px;
}

.chapter-image-card {
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.chapter-image-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #fff;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
}

.chapter-image-viewport.zoomed { cursor: grab; }
.chapter-image-viewport.dragging { cursor: grabbing; }

.chapter-image-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  pointer-events: none;
  transform-origin: 0 0;
  will-change: transform;
}

.chapter-image-viewport.resetting canvas {
  transition: transform 0.2s ease;
}

.chapter-image-caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
}

/* Keep each desktop image viewport at the full available panel height.
   Width changes no longer feed back into the image card's height. */
@media (min-width: 1025px) {
  .chapter-gallery {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .chapter-gallery-header {
    position: static;
    flex: 0 0 auto;
  }

  .chapter-image-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .chapter-image-card {
    flex: 0 0 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .chapter-image-viewport {
    flex: 1 1 0;
    min-height: 0;
    height: 0;
  }

  .chapter-image-viewport canvas {
    object-fit: contain;
    object-position: center;
  }

  .chapter-image-caption {
    flex: 0 0 auto;
  }
}

.page-transition { animation: pageTransition 0.3s ease-out; }

/* Page nav */
.page-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px 0 8px;
}

.page-nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.page-nav-btn:hover:not(:disabled) {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
}

.page-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-indicator {
  font-family: var(--font-serif);
  font-size: 1rem;
  min-width: 78px;
  text-align: center;
  color: var(--muted);
}

.page-current { color: var(--ink); font-weight: 600; font-size: 1.15rem; }
.page-sep { margin: 0 4px; color: var(--faint); }

/* Thumbnails */
.thumbnail-strip {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.thumbnail {
  flex-shrink: 0;
  border: 2px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
  background: none;
  position: relative;
  overflow: hidden;
}

.thumbnail canvas {
  display: block;
  border-radius: 4px;
  width: 58px;
  height: auto;
}

.thumbnail.active {
  border-color: var(--coral);
}

.thumbnail:hover:not(.active) { border-color: var(--border-strong); }

.thumb-label {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 0.62rem;
  color: #fff;
  background: rgba(20, 20, 19, 0.6);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-serif);
}

/* Content (right) */
.tutorial-content {
  flex: 1 1 0;
  min-width: 0;
  border-radius: var(--r-lg);
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow-y: auto;
}

.content-inner { padding: 32px; }

.tutorial-header {
  margin-bottom: 30px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.tutorial-category {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--coral-soft);
  color: var(--coral-dark);
  margin-bottom: 12px;
}

.tutorial-title {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
}

/* Text content */
.tutorial-text { min-height: 200px; }

.page-text-header { margin-bottom: 20px; }

.page-badge {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--ivory-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.text-lines {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.text-heading {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--ink);
  margin-top: 10px;
  padding-left: 14px;
  border-left: 3px solid var(--coral);
}

.text-paragraph {
  color: var(--ink-soft);
  line-height: 1.85;
  font-size: 1rem;
}

.text-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: var(--ivory-2);
  border-left: 3px solid var(--coral);
}

.step-marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  flex-shrink: 0;
  margin-top: 9px;
}

.step-text { color: var(--ink); line-height: 1.7; font-weight: 500; }

/* Bullet list (CSS-drawn marker) */
.text-bullet {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-left: 4px;
}

.text-bullet-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
  flex-shrink: 0;
  margin-top: 11px;
}

.text-bullet-content {
  flex: 1;
  color: var(--ink-soft);
  line-height: 1.85;
  font-size: 1rem;
}

.text-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.text-empty-icon { font-size: 2.6rem; margin-bottom: 12px; }
.text-error { color: #c0392b; text-align: center; padding: 40px; }

/* Code blocks — dark surface on the cream page */
.code-block {
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  margin: 4px 0;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--code-bg-2);
  border-bottom: 1px solid var(--code-border);
}

.code-block-label {
  font-size: 0.78rem;
  color: #cbb6a6;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.code-copy-btn {
  padding: 4px 12px;
  border-radius: var(--r-sm);
  border: 1px solid rgba(217, 119, 87, 0.4);
  background: rgba(217, 119, 87, 0.12);
  color: #e69878;
  font-size: 0.74rem;
  cursor: pointer;
  transition: var(--transition);
}

.code-copy-btn:hover {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
}

.code-copy-btn.copied {
  background: rgba(120, 140, 93, 0.25);
  color: #a9c07f;
  border-color: rgba(120, 140, 93, 0.5);
}

.code-content {
  padding: 16px 18px;
  margin: 0;
  overflow-x: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--code-text);
  tab-size: 2;
}

.code-content code { font-family: inherit; color: inherit; }

/* Inline code */
.inline-code {
  display: inline;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--coral-soft);
  color: var(--coral-dark);
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.88em;
  border: 1px solid rgba(217, 119, 87, 0.25);
}

/* Step indicator (page dots) */
.step-indicator {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.step-label {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
  display: block;
}

.step-dots { display: flex; flex-wrap: wrap; gap: 8px; }

.step-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--card);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0;
}

.step-dot.active {
  border-color: var(--coral);
  background: var(--coral);
}

.step-dot:hover:not(.active) {
  border-color: var(--coral);
  background: var(--coral-soft);
}

/* ==================== Chapter Navigation / Progress ==================== */

.chapter-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -32px -32px 28px;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.chapter-nav-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--ink);
}

.chapter-nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--coral);
}

.chapter-nav-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.chapter-nav-eyebrow {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

#chapter-progress-text { color: var(--coral-dark); font-weight: 600; }

.chapter-nav-current {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chapter-nav-caret {
  flex-shrink: 0;
  color: var(--faint);
  transition: transform 0.3s ease;
}

.chapter-nav.expanded .chapter-nav-caret { transform: rotate(180deg); }

/* Stepper */
.chapter-stepper {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 16px;
}

.chapter-step {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
}

.chapter-step::before {
  content: '';
  position: absolute;
  top: 13px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border-strong);
  z-index: 0;
}

.chapter-step:first-child::before { display: none; }

.chapter-step-num {
  position: relative;
  z-index: 1;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--card);
  border: 2px solid var(--border-strong);
  color: var(--muted);
  transition: var(--transition);
}

.chapter-step-label { font-size: 0.72rem; white-space: nowrap; text-align: center; }

.chapter-step:hover .chapter-step-num { border-color: var(--coral); }

.chapter-step.done .chapter-step-num {
  background: var(--coral-soft);
  border-color: var(--coral);
  color: var(--coral-dark);
}

.chapter-step.done::before { background: var(--coral); }

.chapter-step.current .chapter-step-num {
  background: var(--coral);
  border-color: var(--coral);
  color: #fff;
}

.chapter-step.current .chapter-step-label { color: var(--ink); font-weight: 600; }

/* TOC */
.chapter-toc {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chapter-toc[hidden] { display: none; }

.toc-chapter { display: flex; flex-direction: column; }

.toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  color: var(--muted);
  transition: var(--transition);
  font-size: 0.9rem;
}

.toc-item:hover { background: var(--ivory-2); color: var(--ink); }

.toc-chapter-head { font-weight: 600; color: var(--ink); }

.toc-badge {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--coral-soft);
  color: var(--coral-dark);
}

.toc-chapter-title { flex: 1; min-width: 0; }

.toc-page { flex-shrink: 0; font-size: 0.72rem; color: var(--faint); font-family: var(--font-serif); }

.toc-subs {
  display: flex;
  flex-direction: column;
  padding-left: 12px;
  margin-left: 20px;
  border-left: 1px dashed var(--border-strong);
}

.toc-sub { font-size: 0.85rem; }

.toc-sub-num {
  flex-shrink: 0;
  min-width: 28px;
  color: var(--coral-dark);
  font-family: var(--font-serif);
  font-size: 0.76rem;
  font-weight: 600;
}

.toc-sub-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toc-chapter.current > .toc-chapter-head { background: var(--coral-soft); color: var(--ink); }
.toc-chapter.current > .toc-chapter-head .toc-badge { background: var(--coral); color: #fff; }

.toc-item.current {
  background: var(--coral-soft);
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--coral);
}

/* ==================== Tutorial Error State ==================== */

.tutorial-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  text-align: center;
  padding: 40px;
}

.tutorial-error .error-icon { font-size: 3.5rem; margin-bottom: 16px; }

.error-title { font-size: 1.4rem; margin-bottom: 24px; color: var(--muted); font-weight: 500; }

.error-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 26px;
  border-radius: 30px;
  background: var(--coral);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  transition: var(--transition);
}

.error-back-btn:hover { background: var(--coral-dark); }

/* ==================== Responsive ==================== */

@media (max-width: 1024px) {
  .tutorial-container {
    flex-direction: column;
    height: auto;
    min-height: calc(100vh - var(--header-height) - 44px);
    gap: 16px;
    overflow-y: auto;
  }
  .tutorial-resizer { display: none; }
  .tutorial-sidebar { width: 100%; min-height: 50vh; flex: none; }
  .tutorial-content { width: 100%; flex: none; min-height: 50vh; }
  .hero-stats { gap: 40px; }
}

@media (max-width: 768px) {
  .header-inner { padding: 0 20px; }
  .hero { padding: calc(var(--header-height) + 60px) 20px 50px; }
  .hero-subtitle { font-size: 1rem; }
  .hero-stats { gap: 28px; }
  .stat-number { font-size: 1.6rem; }
  .main-content { padding: 16px 20px 60px; }
  .project-table-wrap { margin-top: 24px; }
  .tutorial-container { padding: 12px; gap: 12px; }
  .content-inner { padding: 20px; }
  .chapter-nav { margin: -20px -20px 20px; padding: 14px 20px; }
  .chapter-step-label { display: none; }
  .breadcrumb-chapter { display: none; }
  .tutorial-title { font-size: 1.4rem; }
}
