/* AI เพื่อเยาวชน - ประถม 4-6  ( denser, more mature theme ) */
:root {
  --primary: #0f766e;
  --primary-dark: #0d5c56;
  --primary-light: #ccfbf1;
  --accent: #4f46e5;
  --accent-light: #e0e7ff;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --radius: 14px;
  --font: 'Sarabun', 'Segoe UI', system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --primary-light: #134e4a;
  --accent-light: #312e81;
  --shadow: 0 4px 20px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.45);
}

[data-theme="soft"] {
  --bg: #fef7ed;
  --bg-card: #fffbeb;
  --text: #1c1917;
  --text-muted: #78716c;
  --border: #fde68a;
  --primary: #b45309;
  --primary-dark: #92400e;
  --primary-light: #fef3c7;
  --accent: #a16207;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  font-size: 16px;
}

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }

/* Header - denser */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0;
  flex-wrap: wrap;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
}
.logo img { width: 44px; height: 44px; border-radius: 10px; }
.logo-text { display: flex; flex-direction: column; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--primary); line-height: 1.2; }
.level { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }

.nav {
  display: flex;
  gap: 0.35rem;
  margin-left: auto;
  flex-wrap: wrap;
}
.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  background: var(--primary);
  color: white;
}
.nav-link.external {
  background: var(--accent);
  color: white;
}
.nav-link.external:hover { background: #4338ca; }

.header-actions { display: flex; gap: 0.35rem; align-items: center; }
.icon-btn {
  appearance: none; -webkit-appearance: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: var(--text);
  line-height: 1; padding: 0; margin: 0; outline: none;
}
.icon-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.mobile-only { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1.35rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; box-shadow: 0 4px 14px rgba(15,118,110,0.3); }
.btn.primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(15,118,110,0.4); }
.btn.secondary { background: var(--bg-card); color: var(--primary); border: 2px solid var(--primary); }
.btn.secondary:hover { background: var(--primary-light); }
.btn.large { padding: 0.85rem 1.75rem; font-size: 1.05rem; }

/* Hero - more serious */
.hero {
  padding: 3rem 0 2.5rem;
  background: linear-gradient(145deg, #f0fdfa 0%, #e0e7ff 50%, #f8fafc 100%);
}
[data-theme="dark"] .hero { background: linear-gradient(145deg, #134e4a 0%, #1e1b4b 50%, #0f172a 100%); }
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 2.5rem;
  align-items: center;
}
.hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  font-weight: 800;
  line-height: 1.25;
  color: var(--text);
  margin-bottom: 0.85rem;
}
.hero h1 span { color: var(--primary); }
.hero-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  max-width: 520px;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.hero-card {
  background: linear-gradient(160deg, #0f766e, #4f46e5);
  border-radius: 18px;
  padding: 2rem 1.5rem;
  color: white;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.hero-card .icons { font-size: 2.8rem; margin-bottom: 0.75rem; letter-spacing: 0.3rem; }
.hero-card p { font-weight: 700; font-size: 1.1rem; opacity: 0.95; }

/* Features denser */
.section { padding: 2.5rem 0; }
.section-title {
  font-size: 1.45rem;
  font-weight: 800;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.section-sub { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.95rem; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.15rem;
}
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.feature-icon { font-size: 1.75rem; margin-bottom: 0.6rem; }
.feature-card h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.4rem; }
.feature-card p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.55; }

/* Lesson list denser */
.lesson-list { display: flex; flex-direction: column; gap: 0.85rem; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  box-shadow: var(--shadow);
}
.lesson-item:hover { border-color: var(--primary); transform: translateX(4px); }
.lesson-num {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem; flex-shrink: 0;
}
.lesson-info h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.15rem; }
.lesson-info p { font-size: 0.88rem; color: var(--text-muted); }

/* Lesson content - denser typography */
.lesson-header {
  background: linear-gradient(135deg, #0f766e 0%, #4f46e5 100%);
  color: white;
  padding: 2rem 0 1.75rem;
}
.lesson-header h1 { font-size: 1.65rem; font-weight: 800; margin-bottom: 0.3rem; }
.lesson-meta { font-size: 0.85rem; opacity: 0.9; margin-bottom: 0.25rem; }

.lesson-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  margin: 1.5rem 0 2.5rem;
  box-shadow: var(--shadow);
}
.lesson-content h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  margin: 1.5rem 0 0.65rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--primary-light);
}
.lesson-content h2:first-child { margin-top: 0; }
.lesson-content h3 { font-size: 1.05rem; font-weight: 700; margin: 1.1rem 0 0.45rem; color: var(--text); }
.lesson-content p { margin-bottom: 0.75rem; font-size: 0.98rem; }
.lesson-content ul, .lesson-content ol { margin: 0.5rem 0 1rem 1.4rem; }
.lesson-content li { margin-bottom: 0.4rem; font-size: 0.96rem; }

.example-box {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.15rem;
  border-radius: 0 10px 10px 0;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.activity-box {
  background: var(--accent-light);
  border-left: 4px solid var(--accent);
  padding: 1rem 1.15rem;
  border-radius: 0 10px 10px 0;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.key-box {
  background: #fef3c7;
  border-left: 4px solid #d97706;
  padding: 1rem 1.15rem;
  border-radius: 0 10px 10px 0;
  margin: 1rem 0;
  font-size: 0.95rem;
}
[data-theme="dark"] .key-box { background: #422006; }

/* Quiz */
.quiz-question {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin-bottom: 0.9rem;
}
.quiz-question p { margin-bottom: 0.6rem; font-weight: 600; }
.quiz-options label {
  display: block;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.3rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.95rem;
}
.quiz-options label:hover { background: var(--primary-light); }
.quiz-options input { margin-right: 0.5rem; }

/* Footer */
.footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: auto;
}
.footer-content { text-align: center; }
.footer-brand { font-weight: 800; color: var(--primary); margin-bottom: 0.3rem; }
.footer-note { font-size: 0.85rem; color: var(--text-muted); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.modal-content h2 { font-size: 1.2rem; margin-bottom: 0.75rem; }
.dhikr { font-size: 1.15rem; direction: rtl; margin: 0.75rem 0 0.25rem; color: var(--primary); font-weight: 600; }
.dhikr-trans { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1rem; }
.health-tips { text-align: left; background: var(--bg); padding: 0.85rem; border-radius: 10px; margin-bottom: 1rem; font-size: 0.9rem; }
.health-tips h3 { font-size: 0.95rem; margin-bottom: 0.4rem; }
.health-tips ul { margin-left: 1.2rem; }
.modal-actions { display: flex; flex-direction: column; gap: 0.75rem; align-items: center; }
.checkbox-label { font-size: 0.88rem; color: var(--text-muted); cursor: pointer; }

/* Mobile */
@media (max-width: 900px) {
  .mobile-only { display: inline-flex !important; }
  .nav {
    display: none !important;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg-card);
    flex-direction: column;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    gap: 0.2rem; z-index: 150;
  }
  .nav.open { display: flex !important; }
  .nav-link { width: 100%; text-align: center; padding: 0.8rem; }
  .header-inner { position: relative; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-card { order: -1; max-width: 280px; margin: 0 auto; }
}

/* Print */
@media print {
  .header, .footer, .no-print, .icon-btn, .header-actions, #reminder-modal, .quiz-question, .activity-box, .btn {
    display: none !important;
  }
  .lesson-content { box-shadow: none; border: none; }
  body { background: white; color: black; }
}
