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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #fff;
  color: #111;
  line-height: 1.6;
}

/* ── Nav ── */
nav {
  padding: 14px 40px;
  border-bottom: 1px solid #e5e5e5;
  font-size: 0.9rem;
}
nav a { color: #444; text-decoration: none; }
nav a:hover { color: #111; text-decoration: underline; }

/* ── Page Header ── */
.page-header {
  background: white;
  border-bottom: 1px solid #e5e5e5;
  padding: 40px 0 32px;
}
.page-header h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 6px; }
.subtitle { color: #444; font-size: 1rem; }

/* ── Container ── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 40px;
}

.main-content {
  padding-top: 40px;
  padding-bottom: 60px;
  display: flex;
  flex-direction: column;
  gap: 56px;
}

/* ── Section ── */
.section-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.section-desc {
  font-size: 0.88rem;
  color: #888;
  margin-bottom: 24px;
}

/* ── Flow Layout ── */
.flow-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  align-items: start;
}

/* ── Flow Diagram ── */
.flow-diagram {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.flow-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Top row: 3 nodes */
.flow-row-top {
  justify-content: flex-start;
}

/* Side row: left ↑ and right ↓ */
.flow-row-side {
  display: flex;
  justify-content: space-between;
  padding: 0 0;
  align-items: center;
  min-height: 32px;
}

/* Bottom row: 4 nodes reversed */
.flow-row-bottom {
  justify-content: flex-start;
  flex-direction: row-reverse;
  /* nodes go right-to-left visually matching the loop */
}

/* ── Flow Node (pill button) ── */
.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 14px;
  min-width: 100px;
  border: 2px solid #e5e5e5;
  border-radius: 999px;
  background: white;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  text-align: center;
  font-family: system-ui, -apple-system, sans-serif;
}
.flow-node:hover {
  border-color: #2563eb;
  background: #eff6ff;
}
.flow-node.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.18);
}

.flow-icon { font-size: 1.1rem; line-height: 1; }
.flow-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #111;
  line-height: 1.35;
}
.flow-label small {
  font-size: 0.72rem;
  color: #888;
  font-weight: 400;
}
.flow-node.active .flow-label { color: #2563eb; }

/* ── Arrows ── */
.flow-arrow {
  font-size: 1.1rem;
  color: #aaa;
  flex-shrink: 0;
  user-select: none;
}
.flow-arrow-down {
  font-size: 1.1rem;
  color: #aaa;
  user-select: none;
}
.flow-arrow-up-left {
  margin-left: 46px; /* align with first node center */
}
.flow-arrow-right-down {
  margin-right: 8px;
}

/* ── Detail panel ── */
.flow-detail {
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 20px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s;
}
.flow-detail.has-content {
  border-color: #2563eb;
  animation: fadeSlideIn 0.2s ease;
}

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

.flow-detail-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 10px;
  color: #888;
  font-size: 0.88rem;
  text-align: center;
}
.placeholder-icon { font-size: 1.6rem; }

.detail-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111;
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-title .detail-icon { font-size: 1.1rem; }

.detail-desc {
  font-size: 0.85rem;
  color: #444;
  line-height: 1.6;
}

.detail-cmd-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 7px;
  padding: 8px 12px;
}
.detail-cmd {
  font-family: 'Menlo','Monaco',monospace;
  font-size: 0.82rem;
  color: #111;
  flex: 1;
}
.copy-btn {
  font-size: 0.72rem;
  font-family: system-ui, -apple-system, sans-serif;
  padding: 3px 10px;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  background: #fff;
  color: #444;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.copy-btn:hover { background: #f0f0f0; }
.copy-btn.copied {
  background: #dcfce7;
  border-color: #16a34a;
  color: #16a34a;
}

/* ── Checklist Section ── */
.checklist-section { }

.checklist-progress-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  margin-top: 16px;
}
.checklist-progress-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #444;
  white-space: nowrap;
  min-width: 80px;
}
.checklist-track {
  flex: 1;
  height: 6px;
  background: #e5e5e5;
  border-radius: 99px;
  overflow: hidden;
}
.checklist-fill {
  height: 100%;
  background: #16a34a;
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ── Checklist ── */
.checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  color: #444;
  padding: 11px 16px;
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
  line-height: 1.5;
}
.check-label:hover { background: #f0f0f0; }
.check-label input[type="checkbox"] { display: none; }

.check-box {
  width: 22px;
  height: 22px;
  border: 2px solid #d1d5db;
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.check-label input:checked ~ .check-box {
  background: #16a34a;
  border-color: #16a34a;
}
.check-label input:checked ~ .check-box::after {
  content: '✓';
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}
.check-label input:checked ~ span:last-child {
  color: #888;
}

.check-label code {
  font-family: 'Menlo','Monaco',monospace;
  font-size: 0.8rem;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 3px;
  padding: 1px 5px;
  color: #111;
}
.check-label input:checked ~ span:last-child code {
  color: #888;
}

/* ── Completion Banner ── */
.completion-banner {
  margin-top: 20px;
  background: #dcfce7;
  border: 1px solid #16a34a;
  border-radius: 10px;
  padding: 20px 24px;
  font-size: 1rem;
  font-weight: 600;
  color: #14532d;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  animation: fadeSlideIn 0.4s ease;
}

.btn-next-course {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  background: #16a34a;
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-next-course:hover { background: #15803d; }

/* ── Mobile ── */
@media (max-width: 640px) {
  nav { padding: 14px 20px; }
  .container { padding: 0 20px; }

  .flow-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .flow-row-top,
  .flow-row-bottom {
    flex-wrap: wrap;
    gap: 8px;
  }
  .flow-row-bottom {
    flex-direction: row;
  }
  .flow-arrow { display: none; }
  .flow-row-side { display: none; }
  .flow-node { min-width: 80px; padding: 8px 10px; }
}
