/* ========================================
   AI Godot Academy — 基础样式与布局
   ======================================== */

:root {
  /* 颜色 */
  --bg: #0f1419;
  --bg-elevated: #151b23;
  --card: #1a2332;
  --card-hover: #1f2a3d;
  --border: #2a3544;
  --border-subtle: #243041;

  --text: #e8edf4;
  --text-secondary: #9aa8b8;
  --text-muted: #6b7a8d;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.35);

  /* 尺寸 */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;

  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --topbar-height: 64px;
  --content-max: 860px;

  /* 字体 */
  --font-sans: "Inter", "HarmonyOS Sans", "Source Han Sans SC", "Noto Sans SC",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", "Consolas", monospace;

  --transition: 0.22s ease;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: #60a5fa;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

ul,
ol {
  list-style: none;
}

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
}

.sidebar.is-collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-height);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
}

.sidebar-brand {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 1;
  transition: opacity var(--transition);
}

.sidebar.is-collapsed .sidebar-brand,
.sidebar.is-collapsed .nav-label,
.sidebar.is-collapsed .nav-section-title {
  opacity: 0;
  width: 0;
  overflow: hidden;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-3);
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: var(--space-3) var(--space-3) var(--space-2);
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--card);
  color: var(--text);
}

.nav-link.is-active {
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

.nav-link.is-done .nav-dot {
  background: var(--success);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.nav-link.is-active .nav-icon {
  color: #93c5fd;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar.is-collapsed .nav-dot {
  display: none;
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition);
}

.sidebar-toggle:hover {
  background: var(--card);
  color: var(--text);
}

/* ---------- Main Column ---------- */
.main-column {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

.sidebar.is-collapsed ~ .main-column,
body.sidebar-collapsed .main-column {
  margin-left: var(--sidebar-collapsed);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.topbar-menu-btn:hover {
  background: var(--card);
  color: var(--text);
}

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.topbar-search {
  flex: 1;
  max-width: 360px;
  margin-left: auto;
  position: relative;
}

.topbar-search input {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.topbar-search input::placeholder {
  color: var(--text-muted);
}

.topbar-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.topbar-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 110;
}

.search-results.is-open {
  display: block;
}

.search-result-item {
  display: block;
  padding: 12px 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--card-hover);
}

.search-result-title {
  font-size: 14px;
  font-weight: 550;
}

.search-result-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-progress {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.progress-bar {
  width: 72px;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 999px;
  transition: width 0.35s ease;
  width: 0%;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--card);
  color: var(--text);
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  padding: var(--space-7) var(--space-6) var(--space-8);
  animation: fadeIn 0.35s ease;
}

.content-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.content--wide .content-inner {
  max-width: 1100px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Typography ---------- */
.page-eyebrow {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-3);
}

h1,
.h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-4);
}

h2,
.h2 {
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.3;
  margin: var(--space-7) 0 var(--space-4);
  letter-spacing: -0.015em;
}

h3,
.h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: var(--space-6) 0 var(--space-3);
}

.lead {
  font-size: 1.125rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 36em;
}

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

p strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 22px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition),
    background var(--transition), opacity var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  color: #fff;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--card-hover);
  color: var(--text);
  border-color: #3a4a5c;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition),
    transform var(--transition), background var(--transition);
}

.card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
}

.card-link {
  display: block;
  color: inherit;
}

.card-link:hover {
  color: inherit;
  transform: translateY(-2px);
}

/* ---------- Hero ---------- */
.hero {
  padding: var(--space-6) 0 var(--space-7);
  text-align: center;
}

.hero h1 {
  max-width: 16em;
  margin-left: auto;
  margin-right: auto;
}

.hero .lead {
  margin: 0 auto var(--space-6);
}

.hero .btn-group {
  justify-content: center;
  margin-bottom: var(--space-7);
}

.hero-visual {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  max-width: 800px;
  margin: 0 auto;
}

.hero-visual img {
  width: 100%;
  height: auto;
}

/* ---------- Roadmap ---------- */
.section {
  margin-top: var(--space-8);
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.section-header h2 {
  margin-top: 0;
}

.section-header p {
  max-width: 32em;
  margin: 0 auto;
}

.roadmap {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 560px;
  margin: 0 auto;
}

.roadmap-item {
  display: flex;
  gap: var(--space-4);
  position: relative;
}

.roadmap-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 40px;
  flex-shrink: 0;
}

.roadmap-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  z-index: 1;
  transition: border-color var(--transition), background var(--transition),
    color var(--transition);
}

.roadmap-item:hover .roadmap-dot,
.roadmap-item.is-done .roadmap-dot {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.roadmap-item.is-done .roadmap-dot {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.roadmap-line {
  flex: 1;
  width: 2px;
  background: var(--border);
  min-height: 24px;
}

.roadmap-item:last-child .roadmap-line {
  display: none;
}

.roadmap-body {
  flex: 1;
  padding-bottom: var(--space-5);
  min-width: 0;
}

.roadmap-body a {
  display: block;
  padding: var(--space-4);
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: inherit;
  transition: border-color var(--transition), transform var(--transition),
    box-shadow var(--transition);
}

.roadmap-body a:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.roadmap-day {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
}

.roadmap-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.roadmap-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ---------- Course Sections ---------- */
.lesson-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-5) 0;
}

.lesson-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: border-color var(--transition), background var(--transition),
    color var(--transition);
}

.lesson-nav a:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--card-hover);
}

.lesson-num {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.goals-list {
  display: grid;
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-6);
}

.goal-item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-4);
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 15px;
}

.goal-item::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.knowledge-box {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-4) var(--space-5);
  margin: var(--space-5) 0;
}

.knowledge-box .label {
  font-size: 12px;
  font-weight: 700;
  color: #93c5fd;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.knowledge-box p:last-child {
  margin-bottom: 0;
}

.figure {
  margin: var(--space-5) 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: var(--card);
}

.figure img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0b1220;
}

.figure figcaption {
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border-subtle);
}

.flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: var(--space-5) 0;
  padding: var(--space-4);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.flow-step {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.flow-arrow {
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Prompt / Code Cards ---------- */
.prompt-card,
.code-card {
  margin: var(--space-5) 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.card-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border-subtle);
}

.card-toolbar .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-toolbar .spacer {
  flex: 1;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  transition: background var(--transition), color var(--transition),
    border-color var(--transition);
}

.btn-icon:hover {
  background: var(--card-hover);
  color: var(--text);
  border-color: #3a4a5c;
}

.btn-icon.is-copied {
  color: var(--success);
  border-color: var(--success);
  background: var(--success-soft);
}

.prompt-body,
.code-body {
  padding: var(--space-4) var(--space-5);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

.code-body {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  margin: 0;
}

.code-card.is-collapsed .code-body {
  max-height: 120px;
  overflow: hidden;
  position: relative;
}

.code-card.is-collapsed .code-body::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48px;
  background: linear-gradient(transparent, var(--bg-elevated));
  pointer-events: none;
}

/* ---------- FAQ ---------- */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.faq-item {
  background: var(--card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: background var(--transition);
}

.faq-question:hover {
  background: var(--card-hover);
}

.faq-chevron {
  color: var(--text-muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.faq-item.is-open .faq-chevron {
  transform: rotate(180deg);
}

.faq-answer {
  display: none;
  padding: 0 var(--space-5) var(--space-5);
  color: var(--text-secondary);
  font-size: 14px;
}

.faq-item.is-open .faq-answer {
  display: block;
  animation: fadeIn 0.25s ease;
}

/* ---------- Lesson Footer ---------- */
.lesson-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.mark-done-btn.is-done {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success);
}

.mark-done-btn.is-done:hover {
  transform: none;
}

/* ---------- Placeholder Page ---------- */
.coming-soon {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

.coming-soon h1 {
  margin-bottom: var(--space-3);
}

.coming-soon .lead {
  margin: 0 auto var(--space-6);
}

/* ---------- Overlay (mobile) ---------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 95;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.is-visible {
  display: block;
}

body.sidebar-open-mobile {
  overflow: hidden;
}

/* 触控优化 */
@media (hover: none) and (pointer: coarse) {
  .btn:hover,
  .card:hover,
  .card-link:hover,
  .roadmap-body a:hover {
    transform: none;
  }

  .nav-link:active,
  .btn:active,
  .lesson-nav a:active {
    opacity: 0.92;
  }
}

/* ---------- Reveal on scroll ---------- */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(86vw, 300px) !important;
    max-width: 300px;
    box-shadow: var(--shadow-lg);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .sidebar.is-mobile-open {
    transform: translateX(0);
  }

  .main-column,
  body.sidebar-collapsed .main-column {
    margin-left: 0;
  }

  .topbar-menu-btn {
    display: flex;
    min-width: 44px;
    min-height: 44px;
  }

  .topbar-title {
    display: none;
  }

  .sidebar.is-collapsed .sidebar-brand,
  .sidebar.is-collapsed .nav-label,
  .sidebar.is-collapsed .nav-section-title {
    opacity: 1;
    width: auto;
    overflow: visible;
    pointer-events: auto;
  }

  .sidebar.is-collapsed .nav-dot {
    display: block;
  }

  .nav-link {
    min-height: 44px;
    padding: 12px 14px;
  }

  .content {
    padding: var(--space-6) var(--space-5) var(--space-7);
  }

  .topbar {
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }

  .hero-visual {
    border-radius: 12px;
  }

  .code-body,
  .prompt-body {
    font-size: 13px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .card-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
}

@media (max-width: 640px) {
  :root {
    --content-max: 100%;
  }

  body {
    font-size: 15px;
  }

  .content {
    padding: var(--space-5) max(14px, env(safe-area-inset-left))
      calc(var(--space-7) + env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-right));
  }

  .topbar {
    gap: 8px;
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .topbar-search {
    max-width: none;
    min-width: 0;
    flex: 1;
  }

  .topbar-search input {
    height: 40px;
    font-size: 16px; /* 避免 iOS 聚焦自动放大 */
    padding-left: 36px;
  }

  .topbar-progress {
    gap: 6px;
  }

  .topbar-progress .progress-label,
  .topbar-progress #progress-text {
    display: none;
  }

  .progress-bar {
    width: 40px;
  }

  .theme-toggle {
    min-width: 40px;
    min-height: 40px;
  }

  .search-results {
    position: fixed;
    left: 10px;
    right: 10px;
    top: calc(var(--topbar-height) + env(safe-area-inset-top) + 4px);
    max-height: min(60vh, 360px);
  }

  .hero {
    padding: var(--space-4) 0 var(--space-5);
    text-align: left;
  }

  .hero h1 {
    font-size: clamp(1.55rem, 7vw, 2rem);
    margin-left: 0;
    margin-right: 0;
  }

  .hero .lead {
    font-size: 1rem;
  }

  .hero .btn-group {
    justify-content: stretch;
  }

  .section-header {
    text-align: left;
  }

  .section-header p {
    margin-left: 0;
    margin-right: 0;
  }

  .btn {
    width: 100%;
    min-height: 44px;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-icon {
    min-height: 36px;
    padding: 0 12px;
  }

  .lesson-nav a {
    min-height: 48px;
    padding: 12px 14px;
  }

  .lesson-footer {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .roadmap {
    max-width: none;
  }

  .roadmap-body a {
    padding: 14px;
  }

  .flow {
    flex-direction: column;
    align-items: stretch;
  }

  .flow-arrow {
    text-align: center;
    transform: rotate(90deg);
  }

  .flow-step {
    text-align: center;
  }

  .figure {
    margin: var(--space-4) 0;
    border-radius: 12px;
  }

  .figure figcaption {
    font-size: 12px;
    padding: 10px 12px;
  }

  .faq-question {
    min-height: 48px;
    padding: 14px 16px;
  }

  .goals-list {
    gap: 10px;
  }

  .goal-item {
    padding: 12px 14px;
  }

  h2,
  .h2 {
    font-size: 1.28rem;
    margin-top: var(--space-6);
  }

  .page-eyebrow {
    font-size: 12px;
  }

  /* 防止代码块撑破屏幕 */
  pre,
  code,
  .code-body,
  .prompt-body {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .code-body {
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
  }
}

@media (max-width: 380px) {
  .topbar-progress {
    display: none;
  }

  .hero h1 br {
    display: none;
  }
}
