:root {
  --bg: #f7f4ef;
  --card: #ffffff;
  --accent: #2d6a4f;
  --accent-light: #40916c;
  --text: #1b4332;
  --muted: #52796f;
  --border: #d8e2dc;
  --success: #52b788;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(27, 67, 50, 0.08);
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  padding: 20px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 2rem;
  color: var(--accent);
  margin-bottom: 0.3rem;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--muted);
}

.tagline {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  color: var(--accent-light);
}

.progress-section {
  background: var(--card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.progress-section h2 {
  margin-bottom: 0.8rem;
  font-size: 1.2rem;
}

.progress-bar {
  height: 14px;
  background: var(--border);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  width: 0%;
  transition: width 0.4s ease;
}

#progressText {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.intro {
  background: var(--card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.intro h2 {
  margin-bottom: 0.8rem;
  color: var(--accent);
}

.intro p {
  margin-bottom: 0.8rem;
}

.modules h2 {
  margin-bottom: 1rem;
  color: var(--accent);
}

.module-grid {
  display: grid;
  gap: 1rem;
}

.module-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
  border: 2px solid transparent;
}

.module-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(27, 67, 50, 0.12);
}

.module-card.completed {
  border-color: var(--success);
  background: #f0faf5;
}

.module-number {
  width: 42px;
  height: 42px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.module-card.completed .module-number {
  background: var(--success);
}

.module-info {
  flex: 1;
}

.module-info h3 {
  font-size: 1.1rem;
  margin-bottom: 0.2rem;
}

.module-info p {
  font-size: 0.9rem;
  color: var(--muted);
}

.module-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

.btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.btn:hover {
  background: var(--accent-light);
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-secondary:hover {
  background: var(--border);
}

/* Module page styles */
.module-page {
  background: var(--card);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.module-page h1 {
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.module-meta {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.step {
  margin-bottom: 1.8rem;
  padding-left: 1rem;
  border-left: 4px solid var(--accent-light);
}

.step h3 {
  margin-bottom: 0.5rem;
  color: var(--text);
}

.step ul, .step ol {
  margin: 0.6rem 0 0.6rem 1.4rem;
}

.step li {
  margin-bottom: 0.35rem;
}

.video-box {
  background: #eef7f0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
}

.video-box h4 {
  margin-bottom: 0.4rem;
  color: var(--accent);
}

.video-box a {
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}

.tip {
  background: #fff8e6;
  border-left: 4px solid #f4a261;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
}

.tip strong {
  color: #e76f51;
}

.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.complete-btn {
  background: var(--success);
}

.complete-btn:hover {
  background: #40916c;
}

footer {
  text-align: center;
  margin-top: 2rem;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 600px) {
  body {
    padding: 12px;
  }
  header h1 {
    font-size: 1.6rem;
  }
  .module-card {
    flex-direction: column;
    text-align: center;
  }
}

/* ===== AI Chat styles ===== */
.chat-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 2rem 0;
  overflow: hidden;
}

.chat-header {
  padding: 1.2rem 1.5rem;
  background: #eef7f0;
  border-bottom: 1px solid var(--border);
}

.chat-header h2 {
  color: var(--accent);
  margin-bottom: 0.3rem;
  font-size: 1.25rem;
}

.chat-header p {
  font-size: 0.9rem;
  color: var(--muted);
}

.chat-messages {
  height: 380px;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  background: #fafcfb;
}

.message {
  display: flex;
  max-width: 85%;
}

.message.user {
  align-self: flex-end;
}

.message.bot {
  align-self: flex-start;
}

.bubble {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.message.user .bubble {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.bot .bubble {
  background: white;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

.chat-input-area {
  display: flex;
  gap: 0.6rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: white;
}

.chat-input-area textarea {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
}

.chat-input-area textarea:focus {
  border-color: var(--accent-light);
}

.chat-input-area .btn {
  align-self: flex-end;
  padding: 0.7rem 1.2rem;
}

.chat-note {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 1rem 1rem;
  margin: 0;
}

@media (max-width: 600px) {
  .chat-messages {
    height: 320px;
  }
  .message {
    max-width: 92%;
  }
}
