/* ============================================
   OpenClaw Course - Skilljar-inspired Style
   ============================================ */

/* --- CSS Variables --- */
:root {
  --bg-primary: #FAF8F5;
  --bg-sidebar: #F0EDE8;
  --bg-white: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-secondary: #555555;
  --text-muted: #888888;
  --accent: #E8590C;
  --accent-hover: #D14800;
  --border: #E0DCD5;
  --border-light: #EBE8E2;
  --link: #2563EB;
  --link-hover: #1D4ED8;
  --success: #16A34A;
  --sidebar-width: 320px;
  --header-height: 60px;
  --font-serif: 'Georgia', 'Noto Serif SC', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 8px;
  --transition: 0.25s ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

/* --- Header --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.95);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.header-logo {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.02em;
  max-width: 100%;
  word-break: keep-all;
}

.header-logo span {
  color: var(--accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header-nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color var(--transition);
}

.header-nav-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.site-shot {
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-white);
  box-shadow: var(--shadow-md);
}

.site-shot img {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}

.site-shot-caption {
  padding: 12px 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: linear-gradient(180deg, rgba(250,248,245,0.75), rgba(240,237,232,0.95));
  border-top: 1px solid var(--border-light);
}

.step-shot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-top: 18px;
}

.step-shot-grid .site-shot {
  margin-top: 0;
  max-width: 960px;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 16, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
  z-index: 1200;
}

.image-lightbox.open {
  display: flex;
}

.image-lightbox img {
  max-width: min(1200px, 94vw);
  max-height: 88vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.35);
  background: #fff;
}

.image-lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
}

.feature-grid-simple {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.feature-card-simple {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.feature-card-simple h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.feature-card-simple p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-sidebar);
  border-radius: 20px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.lang-btn {
  padding: 5px 14px;
  border: none;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all var(--transition);
}

.lang-btn.active {
  background: var(--bg-white);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.lang-btn:hover:not(.active) {
  color: var(--text-primary);
}

/* Mobile Menu Button */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-primary);
}

.menu-toggle svg {
  width: 24px;
  height: 24px;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 900;
  transition: transform 0.3s ease;
}

.sidebar-desktop-toggle {
  position: fixed;
  top: calc(var(--header-height) + 16px);
  left: calc(var(--sidebar-width) - 16px);
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-white);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 950;
  transition: left 0.3s ease, transform 0.25s ease, color var(--transition), background var(--transition);
}

.sidebar-desktop-toggle:hover {
  color: var(--accent);
  transform: translateY(-1px);
}

.sidebar-desktop-toggle svg {
  width: 16px;
  height: 16px;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.sidebar-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 0 24px 8px;
  color: var(--text-primary);
  line-height: 1.4;
}

.sidebar-subtitle {
  font-size: 0.8rem;
  color: var(--link);
  text-decoration: underline;
  padding: 0 24px 20px;
  display: block;
  cursor: pointer;
}

.sidebar-subtitle:hover {
  color: var(--link-hover);
}

/* Nav Modules */
.nav-module {
  margin-bottom: 8px;
}

.nav-module-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  padding: 12px 24px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: rgba(0,0,0,0.04);
  color: var(--text-primary);
}

.nav-item.active {
  color: var(--text-primary);
  font-weight: 600;
  background: rgba(232, 89, 12, 0.12);
  border-left-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(232, 89, 12, 0.14);
}

.nav-item.completed .nav-icon {
  color: var(--success);
}

/* Nav Icons */
.nav-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.65rem;
  transition: all var(--transition);
}

.nav-item.completed .nav-icon {
  border-color: var(--success);
  background: var(--success);
  color: white;
}

.nav-item.active .nav-icon {
  border-color: var(--accent);
  transform: scale(1.08);
  box-shadow: 0 0 0 3px rgba(232, 89, 12, 0.12);
}

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  transition: margin-left 0.3s ease;
}

body.sidebar-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sidebar-width)));
}

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

body.sidebar-collapsed .footer {
  width: 100%;
  margin-left: 0;
}

body.sidebar-collapsed .sidebar-desktop-toggle {
  left: 12px;
}

body.sidebar-collapsed .sidebar-desktop-toggle svg {
  transform: rotate(180deg);
}

.lesson-content {
  display: block;
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 40px 72px;
  scroll-margin-top: calc(var(--header-height) + 24px);
  content-visibility: auto;
  contain-intrinsic-size: 1px 1600px;
}

.lesson-content.active {
  display: block;
}

.lesson-content + .lesson-content {
  border-top: 1px solid var(--border-light);
}

.content-section p,
.content-section li,
.site-shot-caption,
.qr-sublabel,
.floating-contact-label,
.floating-contact-title {
  overflow-wrap: anywhere;
}

/* --- Typography --- */
.lesson-title {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.lesson-divider {
  border: none;
  border-top: 2px solid var(--border);
  margin: 16px 0 28px;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.lesson-meta strong {
  color: var(--text-primary);
}

/* Learning Objectives */
.objectives {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 32px;
}

.objectives h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.objectives p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.objectives ul {
  list-style: disc;
  padding-left: 20px;
}

.objectives li {
  margin-bottom: 6px;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Content Sections */
.content-section {
  margin-bottom: 36px;
}

.content-section h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-top: 8px;
  color: var(--text-primary);
}

.content-section h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.content-section h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.content-section p {
  margin-bottom: 14px;
  font-size: 0.95rem;
  line-height: 1.8;
}

.content-section ul, .content-section ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.content-section li {
  margin-bottom: 8px;
  font-size: 0.95rem;
  line-height: 1.7;
}

/* Highlight Box / Callout */
.callout {
  background: #FFF7ED;
  border-left: 4px solid var(--accent);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.7;
}

.callout.info {
  background: #EFF6FF;
  border-left-color: #3B82F6;
}

.callout.success {
  background: #F0FDF4;
  border-left-color: var(--success);
}

.callout.warning {
  background: #FFFBEB;
  border-left-color: #F59E0B;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

.content-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  background: var(--bg-white);
}

.content-table th {
  background: var(--bg-sidebar);
  font-weight: 700;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.content-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

.content-table tr:last-child td {
  border-bottom: none;
}

.content-table tr:hover td {
  background: rgba(0,0,0,0.015);
}

/* Code Blocks */
.code-block {
  background: #1E1E2E;
  color: #CDD6F4;
  padding: 20px 24px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  margin-bottom: 24px;
  position: relative;
}

.code-block.has-copy {
  padding-top: 20px;
  padding-right: 60px;
}

.code-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #E5E7EB;
  font-family: var(--font-sans);
  font-size: 0;
  cursor: pointer;
  transition: all var(--transition);
}

.code-copy-btn:hover {
  background: rgba(255,255,255,0.14);
  color: #FFFFFF;
}

.code-copy-btn::before {
  content: "⧉";
  font-size: 0.82rem;
  line-height: 1;
}

.code-copy-btn[data-state="copied"]::before {
  content: "✓";
  font-size: 0.8rem;
}

.code-copy-btn[data-state="failed"]::before {
  content: "!";
  font-size: 0.8rem;
}

.code-block .prompt {
  color: #A6E3A1;
}

.code-block .comment {
  color: #6C7086;
}

.code-block .output {
  color: #89B4FA;
}

code {
  font-family: var(--font-mono);
  background: rgba(0,0,0,0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}

/* Video Embed */
.video-section {
  margin: 36px 0 32px;
}

.video-section h3 {
  font-family: var(--font-serif);
  font-size: 1.95rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 20px;
}

.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 14px;
  background: #1f2340;
  margin-bottom: 8px;
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.12);
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1f2340;
  color: white;
  cursor: default;
  transition: all var(--transition);
}

.video-placeholder:hover {
  background: #1f2340;
}

.video-placeholder .play-icon {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  backdrop-filter: blur(4px);
}

.video-placeholder .play-icon svg {
  width: 36px;
  height: 36px;
  fill: white;
  margin-left: 6px;
}

.video-placeholder span {
  font-size: 1rem;
  opacity: 0.86;
}

/* Flowchart / Diagram */
.diagram-box {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-secondary);
}

/* Navigation Buttons */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  margin-top: 40px;
  border-top: 1px solid var(--border);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.nav-btn-next {
  background: var(--accent);
  color: white;
  margin-left: auto;
}

.nav-btn-next:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.nav-btn-prev {
  background: var(--bg-white);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.nav-btn-prev:hover {
  background: var(--bg-sidebar);
  color: var(--text-primary);
}

/* --- Mind Map Section --- */
.mindmap-section {
  padding: 0;
  margin: 0 -20px 32px;
}

.mindmap-container {
  position: relative;
  width: 100%;
  min-height: 550px;
  background: var(--bg-white);
  border-radius: 16px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

#mindmap-canvas {
  width: 100%;
  height: 100%;
  min-height: 550px;
}

/* --- QR Code Section --- */
.qr-section {
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  padding: 60px 40px;
  text-align: center;
}

.qr-section h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.qr-section p {
  color: var(--text-secondary);
  margin-bottom: 36px;
  font-size: 0.95rem;
}

.qr-grid {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
}

.qr-item {
  text-align: center;
}

.qr-placeholder {
  width: 180px;
  height: 180px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all var(--transition);
}

.qr-placeholder:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.qr-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  border-radius: 6px;
}

.qr-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.qr-sublabel {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.floating-contact {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 850;
}

.floating-contact-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 156px;
  padding: 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: 0 16px 36px rgba(26, 26, 26, 0.10);
}

.floating-contact-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.floating-contact-item {
  text-align: center;
}

.floating-contact-qr {
  width: 128px;
  height: 128px;
  margin: 0 auto 8px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-primary);
}

.floating-contact-qr img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.floating-contact-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* --- Footer --- */
.footer {
  background: var(--text-primary);
  color: rgba(255,255,255,0.6);
  width: calc(100% - var(--sidebar-width));
  margin-left: var(--sidebar-width);
  padding: 32px 40px;
  text-align: center;
  font-size: 0.82rem;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

.footer p + p {
  margin-top: 8px;
}

.footer a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
}

.footer a:hover {
  color: white;
  text-decoration: underline;
}

.footer-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  text-align: center;
}

/* --- Mobile Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 899;
}

/* --- Course Overview (Welcome) --- */
.welcome-hero {
  text-align: center;
  padding: 40px 0 32px;
}

.welcome-hero h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.welcome-hero p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 24px;
  line-height: 1.7;
}

.welcome-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.stat-item {
  text-align: center;
}

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

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Module Card Grid */
.module-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 32px 0;
}

.module-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all var(--transition);
}

.module-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--accent);
}

.module-card-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.module-card h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.module-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Comparison / Feature Tag */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tag-green { background: #DCFCE7; color: #166534; }
.tag-red { background: #FEE2E2; color: #991B1B; }
.tag-yellow { background: #FEF9C3; color: #854D0E; }
.tag-blue { background: #DBEAFE; color: #1E40AF; }
.tag-gray { background: #F3F4F6; color: #374151; }

/* Step List */
.step-list {
  counter-reset: step;
  list-style: none;
  padding: 0;
}

.step-list li {
  counter-increment: step;
  position: relative;
  padding-left: 48px;
  margin-bottom: 20px;
  min-height: 36px;
}

.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
}

/* Analogy Box */
.analogy {
  background: linear-gradient(135deg, #FFF7ED 0%, #FFFBEB 100%);
  border: 1px solid #FED7AA;
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 20px;
  font-size: 0.92rem;
}

.analogy::before {
  content: '💡';
  margin-right: 8px;
}

/* Accordion */
.accordion-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.accordion-header {
  padding: 14px 20px;
  background: var(--bg-white);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background var(--transition);
}

.accordion-header:hover {
  background: var(--bg-sidebar);
}

.accordion-header::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: transform var(--transition);
}

.accordion-item.open .accordion-header::after {
  content: '−';
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.accordion-body-inner {
  padding: 0 20px 18px;
  font-size: 0.9rem;
  line-height: 1.7;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.lesson-content.active {
  animation: fadeInUp 0.4s ease;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* --- Per-lesson Mind Map (HTML/CSS animated) --- */
.lesson-mindmap {
  margin: 40px 0 24px;
  padding: 32px 24px;
  background: linear-gradient(135deg, #FAF8F5 0%, #F0EDE8 100%);
  border-radius: 16px;
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.lesson-mindmap h3 {
  text-align: center;
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.mindmap-tree {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  position: relative;
  min-height: 200px;
}

.mm-center {
  background: var(--accent);
  color: white;
  padding: 14px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  box-shadow: 0 4px 20px rgba(232, 89, 12, 0.25);
  z-index: 2;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.mm-branches {
  display: contents;
}

.mm-branch {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.mm-branch.mm-left {
  align-items: flex-end;
  padding-right: 40px;
  order: -1;
}

.mm-branch.mm-right {
  align-items: flex-start;
  padding-left: 40px;
  order: 1;
}

/* Connection lines via pseudo-elements */
.mm-branch.mm-left::after,
.mm-branch.mm-right::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40px;
  height: 2px;
  background: var(--border);
}

.mm-branch.mm-left::after {
  right: 0;
}

.mm-branch.mm-right::after {
  left: 0;
}

.mm-node {
  position: relative;
  opacity: 0;
  transform: translateX(var(--tx, 20px));
  animation: mmNodeIn 0.5s ease forwards;
  animation-delay: var(--delay, 0s);
}

.mm-branch.mm-left .mm-node {
  --tx: 20px;
}

.mm-branch.mm-right .mm-node {
  --tx: -20px;
}

/* Node appearance controlled by visibility observer in JS */
.lesson-mindmap:not(.visible) .mm-node {
  animation: none;
  opacity: 0;
}

.mm-node span {
  display: inline-block;
  background: var(--bg-white);
  border: 2px solid var(--color, var(--border));
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: all 0.25s ease;
}

.mm-node span:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-color: var(--accent);
}

/* Sub-nodes (smaller, indented) */
.mm-node.mm-l2 span {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 12px;
  border-width: 1px;
  color: var(--text-secondary);
}

/* Branch vertical connector dots */
.mm-branch .mm-node::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color, var(--border));
  top: 50%;
  transform: translateY(-50%);
}

.mm-branch.mm-left .mm-node::before {
  right: -24px;
}

.mm-branch.mm-right .mm-node::before {
  left: -24px;
}

@keyframes mmNodeIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: min(82vw, 340px);
  }

  .sidebar-desktop-toggle {
    display: none;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

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

  .main {
    margin-left: 0;
  }

  .footer {
    width: 100%;
    margin-left: 0;
  }

  .menu-toggle {
    display: flex;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .lesson-content {
    padding: 32px 20px 80px;
    max-width: 100%;
  }

  .mindmap-section {
    padding: 40px 20px;
  }

  .qr-section {
    padding: 40px 20px;
  }

  .table-wrapper {
    margin-left: -4px;
    margin-right: -4px;
  }

  .content-table {
    min-width: 560px;
    font-size: 0.84rem;
  }

  .content-table th,
  .content-table td {
    padding: 10px 12px;
  }

  .code-block {
    padding: 16px 18px;
    font-size: 0.8rem;
    border-radius: 10px;
  }

  .code-block.has-copy {
    padding-top: 16px;
    padding-right: 48px;
  }

  .code-copy-btn {
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
  }

  .lesson-nav {
    gap: 12px;
    flex-wrap: wrap;
  }

  .nav-btn {
    min-height: 44px;
  }

  .floating-contact {
    right: 14px;
    bottom: 14px;
  }

  .floating-contact-card {
    width: 128px;
    padding: 10px;
    gap: 10px;
    border-radius: 14px;
  }

  .floating-contact-qr {
    width: 106px;
    height: 106px;
    margin-bottom: 6px;
  }

  .floating-contact-title,
  .floating-contact-label {
    font-size: 0.72rem;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 56px;
  }

  .header {
    padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  }

  .header-logo {
    font-size: clamp(1.1rem, 4.8vw, 1.28rem);
    line-height: 1.2;
    max-width: calc(100vw - 140px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-nav-link {
    display: none;
  }

  .sidebar {
    padding-top: 18px;
  }

  .sidebar-title {
    font-size: 1rem;
    padding: 0 18px 8px;
  }

  .sidebar-subtitle {
    padding: 0 18px 18px;
  }

  .nav-module-title {
    padding: 12px 18px 6px;
    font-size: 0.76rem;
  }

  .nav-item {
    padding: 9px 18px;
    font-size: 0.88rem;
  }

  .lesson-title {
    font-size: 1.5rem;
    line-height: 1.25;
  }

  .content-section h2 {
    font-size: 1.25rem;
  }

  .content-section {
    margin-bottom: 28px;
  }

  .content-section p,
  .content-section li {
    font-size: 0.96rem;
  }

  .objectives {
    padding: 20px;
  }

  .objectives h3 {
    font-size: 1.28rem;
  }

  .welcome-hero h1 {
    font-size: 1.6rem;
  }

  .welcome-stats {
    gap: 20px;
  }

  .stat-number {
    font-size: 1.5rem;
  }

  .qr-grid {
    gap: 24px;
  }

  .qr-placeholder {
    width: 150px;
    height: 150px;
  }

  .floating-contact {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .floating-contact-card {
    width: 108px;
    padding: 8px;
    gap: 8px;
    border-radius: 12px;
  }

  .floating-contact-qr {
    width: 90px;
    height: 90px;
    border-radius: 10px;
  }

  .floating-contact-title,
  .floating-contact-label {
    font-size: 0.68rem;
  }

  .step-shot-grid {
    gap: 18px;
  }

  .step-shot-grid .site-shot {
    max-width: 100%;
  }

  .image-lightbox {
    padding: 16px;
  }

  .image-lightbox-close {
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
  }

  .callout {
    padding: 14px 14px 14px 16px;
  }

  .nav-btn {
    width: 100%;
    justify-content: center;
  }

  .nav-btn-next {
    margin-left: 0;
  }

  .mindmap-container {
    min-height: 400px;
  }

  #mindmap-canvas {
    min-height: 400px;
  }

  .mindmap-tree {
    flex-direction: column;
    gap: 16px;
  }

  .mm-branch {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .mm-branch.mm-left {
    padding-right: 0;
    align-items: center;
    order: 0;
  }

  .mm-branch.mm-right {
    padding-left: 0;
    align-items: center;
    order: 0;
  }

  .mm-branch.mm-left::after,
  .mm-branch.mm-right::after {
    display: none;
  }

  .mm-branch .mm-node::before {
    display: none;
  }

  .mm-node span {
    font-size: 0.78rem;
    padding: 6px 10px;
  }

  .mm-center {
    font-size: 0.85rem;
    padding: 10px 18px;
  }

  .footer {
    padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
    line-height: 1.8;
  }
}

@media (max-width: 480px) {
  :root {
    --header-height: 54px;
    --sidebar-width: min(90vw, 320px);
  }

  .header {
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }

  .header-left {
    gap: 10px;
    flex: 1;
  }

  .header-right {
    gap: 8px;
  }

  .lang-switcher {
    transform: scale(0.94);
    transform-origin: right center;
  }

  .header-logo {
    font-size: 1.08rem;
    max-width: calc(100vw - 118px);
  }

  .sidebar-title {
    font-size: 0.95rem;
    padding: 0 16px 8px;
  }

  .sidebar-subtitle,
  .nav-module-title,
  .nav-item {
    padding-left: 16px;
    padding-right: 16px;
  }

  .nav-item {
    font-size: 0.84rem;
  }

  .lesson-content {
    padding: 26px 14px 150px;
  }

  .lesson-title {
    font-size: 1.32rem;
  }

  .content-section h2 {
    font-size: 1.12rem;
  }

  .content-section p,
  .content-section li {
    font-size: 0.92rem;
    line-height: 1.75;
  }

  .content-table {
    min-width: 480px;
    font-size: 0.78rem;
  }

  .content-table th,
  .content-table td {
    padding: 8px 10px;
  }

  .code-block {
    padding: 14px 14px;
    font-size: 0.74rem;
    border-radius: 9px;
  }

  .code-block.has-copy {
    padding-top: 14px;
    padding-right: 40px;
  }

  .code-copy-btn {
    width: 20px;
    height: 20px;
  }

  .callout {
    padding: 12px 12px 12px 14px;
  }

  .qr-placeholder {
    width: 130px;
    height: 130px;
  }

  .nav-btn {
    font-size: 0.84rem;
    padding: 10px 16px;
  }

  .floating-contact {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .floating-contact-card {
    width: 92px;
    padding: 6px;
    gap: 6px;
    border-radius: 10px;
  }

  .floating-contact-qr {
    width: 78px;
    height: 78px;
    margin-bottom: 4px;
    border-radius: 8px;
  }

  .floating-contact-title,
  .floating-contact-label {
    font-size: 0.62rem;
    line-height: 1.2;
  }

  .footer {
    padding: 20px 14px calc(20px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 390px) {
  .header-logo {
    font-size: 0.98rem;
    max-width: calc(100vw - 110px);
  }

  .lesson-content {
    padding: 24px 12px 160px;
  }

  .lesson-title {
    font-size: 1.24rem;
  }

  .content-section h2 {
    font-size: 1.04rem;
  }

  .floating-contact-card {
    width: 84px;
    padding: 5px;
    gap: 5px;
  }

  .floating-contact-qr {
    width: 70px;
    height: 70px;
  }

  .floating-contact-title,
  .floating-contact-label {
    font-size: 0.58rem;
  }

  .content-table {
    min-width: 420px;
    font-size: 0.74rem;
  }

  .content-table th,
  .content-table td {
    padding: 7px 9px;
  }
}

@media (max-width: 900px) and (max-height: 820px) {
  .lesson-content {
    padding-bottom: 112px;
  }

  .floating-contact {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
  }

  .floating-contact-card {
    flex-direction: row;
    align-items: flex-start;
    gap: 6px;
    width: auto;
    padding: 6px;
    border-radius: 10px;
  }

  .floating-contact-title {
    display: none;
  }

  .floating-contact-item {
    width: 76px;
  }

  .floating-contact-qr {
    width: 76px;
    height: 76px;
    margin-bottom: 4px;
    border-radius: 8px;
  }

  .floating-contact-label {
    font-size: 0.58rem;
    line-height: 1.2;
  }
}

@media (max-width: 900px) and (max-height: 560px) {
  .header {
    padding-top: env(safe-area-inset-top);
  }

  .lesson-content {
    padding-top: 20px;
    padding-bottom: 92px;
  }

  .lesson-title {
    font-size: 1.16rem;
  }

  .content-section h2 {
    font-size: 1rem;
  }

  .floating-contact-card {
    padding: 5px;
  }

  .floating-contact-item {
    width: 68px;
  }

  .floating-contact-qr {
    width: 68px;
    height: 68px;
  }

  .floating-contact-label {
    font-size: 0.54rem;
  }
}

/* --- Print Styles --- */
@media print {
  .sidebar, .header, .menu-toggle, .lesson-nav, .sidebar-overlay {
    display: none !important;
  }
  .main {
    margin-left: 0 !important;
  }
  .lesson-content {
    display: block !important;
    page-break-after: always;
  }
}
