:root {
  --green: #7DC932;
  --green-light: #E8F7D4;
  --green-mid: #B8E07A;
  --green-dark: #5AA020;
  --bg: #F5F7F2;
  --white: #FFFFFF;
  --card: #FFFFFF;
  --text: #1A2310;
  --text-muted: #7A8C70;
  --text-light: #B0BCA8;
  --border: #E8EDE4;
  --shadow: 0 2px 12px rgba(80,120,40,0.08);
  --shadow-md: 0 4px 20px rgba(80,120,40,0.12);
  --radius: 18px;
  --radius-sm: 12px;
  --ch1: #4A9FD4;
  --ch1-light: #D6EDFA;
  --ch2: #7DC932;
  --ch2-light: #E8F7D4;
  --ch3: #F2844B;
  --ch3-light: #FDE8DB;
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

html, body {
  height: 100%;
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ===== SCREENS ===== */
.screen { 
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1), opacity 0.35s;
  will-change: transform;
}
.screen.hidden { transform: translateX(100%); opacity: 0; pointer-events: none; }
.screen.slide-left { transform: translateX(-30%); opacity: 0; pointer-events: none; }

/* ===== SCROLL AREA ===== */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll-area::-webkit-scrollbar { display: none; }

/* ===== WELCOME SCREEN ===== */
#welcome-screen { background: var(--bg); }

.welcome-hero {
  margin: 18px auto 0;
  width: min(100% - 32px, 1120px);
  padding: 30px 22px;
  background: linear-gradient(135deg, #ffffff 0%, #f6fbef 58%, #e8f7d4 100%);
  border: 1.5px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.welcome-copy p {
  font-size: 13px;
  font-weight: 900;
  color: var(--green-dark);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.welcome-copy h1 {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1.05;
  color: var(--text);
  max-width: 620px;
}

.welcome-copy span {
  display: block;
  max-width: 620px;
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  font-weight: 700;
}

.welcome-mark {
  width: 92px;
  height: 92px;
  border-radius: 26px;
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  font-size: 42px;
  flex-shrink: 0;
}

.welcome-content {
  width: min(100% - 32px, 1120px);
  margin: 18px auto 110px;
}

.welcome-subject-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.welcome-subject-card {
  border: 1.5px solid var(--border);
  background: var(--white);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--subject-accent);
}

.welcome-subject-card.active {
  background: var(--subject-light);
  border-color: var(--subject-accent);
}

.welcome-subject-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--subject-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.welcome-subject-card h3 {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 4px;
}

.welcome-subject-card p {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.welcome-subject-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.welcome-subject-meta span {
  font-size: 11px;
  font-weight: 900;
  color: var(--subject-dark);
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--subject-accent);
  border-radius: 999px;
  padding: 4px 8px;
}

.welcome-subject-arrow {
  font-size: 30px;
  line-height: 1;
  color: var(--subject-accent);
  font-weight: 900;
}

/* ===== HOME SCREEN ===== */
#home-screen { background: var(--bg); }

.home-header {
  padding: 54px 22px 20px;
  background: var(--white);
  border-radius: 0 0 28px 28px;
  box-shadow: var(--shadow);
}

.home-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.greeting-block h1 {
  font-family: 'Fredoka One', cursive;
  font-size: 26px;
  color: var(--text);
  line-height: 1.1;
}

.greeting-block p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.avatar-wrap {
  width: 46px; height: 46px;
  background: var(--green-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  border: 2px solid var(--green-mid);
}

.progress-banner {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.progress-banner-text { color: white; }
.progress-banner-text small { font-size: 12px; opacity: 0.85; display: block; margin-bottom: 4px; }
.progress-banner-text h2 { font-size: 20px; font-weight: 800; line-height: 1.2; }

.progress-ring {
  width: 58px; height: 58px;
  position: relative;
  flex-shrink: 0;
}

.progress-ring svg { transform: rotate(-90deg); }
.progress-ring circle {
  fill: none; stroke-width: 5;
  stroke-linecap: round;
}
.progress-ring .bg-circle { stroke: rgba(255,255,255,0.25); }
.progress-ring .fg-circle { stroke: white; transition: stroke-dashoffset 0.6s ease; }
.progress-ring .ring-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: white;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.stat-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.stat-card .stat-text small { font-size: 11px; color: var(--text-muted); display: block; }
.stat-card .stat-text strong { font-size: 16px; font-weight: 800; }

.home-content { padding: 20px 16px 100px; }

.section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-left: 4px;
}

/* Chapter Cards */
.chapter-list { display: flex; flex-direction: column; gap: 14px; }

.chapter-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
  border: 1.5px solid var(--border);
}

.chapter-card:active { transform: scale(0.98); }

.chapter-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}

.chapter-icon-wrap {
  width: 58px; height: 58px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
  background: var(--accent-light);
}

.chapter-card-text { flex: 1; min-width: 0; }
.chapter-card-text .ch-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 4px;
}

.chapter-card-text h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 5px;
}

.chapter-card-text p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.ch-arrow {
  font-size: 18px;
  color: var(--text-light);
  flex-shrink: 0;
}

.topic-count {
  font-size: 11px;
  color: var(--accent);
  font-weight: 700;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Mini progress bar */
.mini-progress { 
  height: 4px;
  background: var(--accent-light);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}
.mini-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  width: 0%;
  transition: width 0.6s ease;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 72px;
  background: var(--white);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  z-index: 200;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  cursor: pointer;
  border-radius: 16px;
  transition: all 0.2s;
}

.nav-item.active .nav-icon-wrap {
  background: var(--green);
  color: white;
}

.nav-icon-wrap {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  background: transparent;
  transition: all 0.2s;
}

.nav-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.nav-item.active .nav-label { color: var(--green-dark); }

/* FAB Center */
.nav-fab {
  flex: 0 0 70px;
  display: flex;
  justify-content: center;
}

.fab-btn {
  width: 52px; height: 52px;
  background: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 14px rgba(125,201,50,0.4);
  cursor: pointer;
  transition: transform 0.2s;
}
.fab-btn:active { transform: scale(0.92); }

.subject-sheet {
  position: fixed;
  left: 50%;
  bottom: 88px;
  width: min(100% - 32px, 430px);
  transform: translateX(-50%);
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.18);
  z-index: 420;
}

.subject-sheet.hidden { display: none; }

.subject-sheet h3 {
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 10px;
}

.subject-option {
  width: 100%;
  border: 1.5px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Nunito', sans-serif;
  text-align: left;
  cursor: pointer;
  margin-bottom: 8px;
}

.subject-option.active {
  background: var(--green-light);
  border-color: var(--green);
}

.subject-option .subject-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  font-size: 20px;
  flex-shrink: 0;
}

.subject-option strong { display:block; font-size: 14px; }
.subject-option span { display:block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ===== CHAPTER SCREEN ===== */
#chapter-screen { background: var(--bg); }

.chapter-header {
  padding: 54px 20px 24px;
  position: relative;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: none;
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  font-family: 'Nunito', sans-serif;
}

.chapter-hero {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--ch-accent);
}

.chapter-hero .ch-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--ch-accent);
  background: var(--ch-accent-light);
  padding: 4px 12px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 10px;
}

.chapter-hero h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 22px;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 10px;
}

.chapter-hero p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.chapter-content { padding: 16px 16px 100px; }

/* Topics Grid */
.topics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.topic-tile {
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.topic-tile:active { transform: scale(0.96); }

.topic-tile::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--ch-accent);
  border-radius: 0 0 12px 12px;
  transform: scaleX(0);
  transition: transform 0.2s;
}

.topic-tile:hover::after { transform: scaleX(1); }

.topic-tile .tile-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--ch-accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.topic-tile h4 {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.topic-tile p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.topic-tile .tile-arrow {
  position: absolute;
  right: 12px; top: 12px;
  font-size: 12px;
  color: var(--text-light);
}

/* Summary Card */
.summary-card {
  background: var(--ch-accent-light);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  border: 1.5px solid var(--ch-accent);
  cursor: pointer;
  transition: transform 0.15s;
}

.summary-card:active { transform: scale(0.98); }

.summary-card h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--ch-accent);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-card p {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

/* ===== DETAIL SCREEN ===== */
#detail-screen { background: var(--bg); }

.detail-header {
  padding: 54px 20px 20px;
  background: var(--white);
  border-radius: 0 0 24px 24px;
  box-shadow: var(--shadow);
}

.detail-header .detail-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--ch-accent);
  background: var(--ch-accent-light);
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 8px;
}

.detail-header h2 {
  font-family: 'Fredoka One', cursive;
  font-size: 24px;
  color: var(--text);
  line-height: 1.25;
}

.detail-content { padding: 18px 16px 120px; }

.detail-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
}

.detail-card h3 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-card h3 .h3-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--ch-accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.translation-help {
  font-size: 12px;
  color: #6b7280;
  margin: -4px 0 12px;
}

.bilingual-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.translation-line {
  width: 100%;
  text-align: left;
  border: 1.5px solid var(--border);
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
}

.translation-line .hindi-text {
  display: block;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.55;
}

.translation-line .english-text {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--ch-accent-dark);
  font-size: 13px;
  line-height: 1.55;
  transition: all .2s ease;
}

.translation-line:hover,
.translation-line.show-translation {
  border-color: var(--ch-accent);
  background: var(--ch-accent-light);
}

.translation-line:hover .english-text,
.translation-line.show-translation .english-text {
  max-height: 110px;
  opacity: 1;
  margin-top: 6px;
}

.inline-translation {
  display: inline-block;
  position: relative;
  border-bottom: 1px dotted var(--ch-accent, #7C3AED);
  cursor: pointer;
  vertical-align: baseline;
}

.inline-translation .hindi-text {
  display: inline;
}

.inline-translation .english-text {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--ch-accent-dark, #5B21B6);
  font-size: .86em;
  line-height: 1.45;
  font-weight: 800;
  transition: all .18s ease;
}

.inline-translation:hover .english-text,
.inline-translation.show-translation .english-text,
.inline-translation:focus .english-text {
  max-height: 140px;
  opacity: 1;
  margin-top: 4px;
}

.word-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.word-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.word-card strong {
  display: block;
  color: var(--ch-accent-dark);
  font-size: 17px;
  margin-bottom: 2px;
}

.word-card span,
.word-card small {
  display: block;
  color: #6b7280;
  font-size: 12px;
  font-weight: 800;
}

.word-card p {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  margin: 6px 0 4px;
}

.note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.note-btn {
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.note-btn.primary {
  background: var(--ch-accent);
  border-color: var(--ch-accent);
  color: white;
}

.note-frame {
  border-radius: 12px;
  overflow: auto;
  border: 1.5px solid var(--border);
  background: #fafafa;
  max-height: min(72vh, 860px);
  overscroll-behavior: contain;
}

.note-img {
  width: 100%;
  min-width: 100%;
  display: block;
  border-radius: 12px;
  transition: width 0.18s ease;
}

.note-viewer {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(16, 24, 14, 0.92);
  display: flex;
  flex-direction: column;
  color: white;
}

.note-viewer.hidden { display: none; }

.note-viewer-toolbar {
  min-height: 68px;
  padding: 12px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.16);
}

.note-viewer-title {
  min-width: 0;
}

.note-viewer-title strong {
  display: block;
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-viewer-title span {
  display: block;
  font-size: 12px;
  opacity: 0.72;
  margin-top: 2px;
}

.note-viewer-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.viewer-btn {
  min-width: 42px;
  min-height: 38px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.12);
  color: white;
  border-radius: 10px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  cursor: pointer;
}

.viewer-btn.close {
  background: white;
  color: #111827;
}

.note-viewer-stage {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

.note-viewer-stage img {
  width: min(100%, 980px);
  max-width: none;
  margin: 0 auto;
  background: white;
  border-radius: 14px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.35);
  transition: width 0.18s ease;
}

.point-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.point-item:last-child { border-bottom: none; }

.point-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ch-accent);
  margin-top: 6px;
  flex-shrink: 0;
}

.point-item p { font-size: 14px; line-height: 1.6; color: var(--text); }

/* Chips row */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--ch-accent-light);
  border: 1.5px solid var(--ch-accent);
  border-radius: 12px;
  padding: 10px 14px;
  min-width: 70px;
}

.chip .chip-icon { font-size: 22px; }
.chip .chip-label { font-size: 11px; font-weight: 700; color: var(--ch-accent); text-align: center; }

/* Steps */
.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.step-item:last-child { border-bottom: none; }

.step-num {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--ch-accent);
  color: white;
  font-weight: 800;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.step-text { flex: 1; }
.step-text strong { font-size: 14px; display: block; margin-bottom: 2px; }
.step-text span { font-size: 12px; color: var(--text-muted); }

/* Table */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.detail-table th {
  background: var(--ch-accent);
  color: white;
  padding: 10px 8px;
  text-align: left;
  font-weight: 700;
}
.detail-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.5;
}
.detail-table tr:nth-child(even) td { background: var(--ch-accent-light); }
.detail-table th:first-child { border-radius: 8px 0 0 0; }
.detail-table th:last-child { border-radius: 0 8px 0 0; }

/* Highlight box */
.highlight-box {
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.6;
  margin-top: 8px;
}
.highlight-box.green { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.highlight-box.yellow { background: #fef3c7; color: #78350f; border-left: 4px solid #f59e0b; }
.highlight-box.red { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.highlight-box.blue { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* Two col */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.col-box { padding: 12px; border-radius: var(--radius-sm); font-size: 13px; }
.col-box h4 { font-size: 13px; font-weight: 800; margin-bottom: 6px; }
.col-box ul { padding-left: 14px; }
.col-box li { margin-bottom: 5px; line-height: 1.4; }
.col-box.green-box { background: #d1fae5; }
.col-box.red-box { background: #fee2e2; }

/* Remember banner */
.remember-banner {
  background: linear-gradient(135deg, var(--ch-accent) 0%, var(--ch-accent-dark, var(--green-dark)) 100%);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  color: white;
}
.remember-banner h4 { font-size: 14px; font-weight: 800; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.remember-banner p { font-size: 13px; opacity: 0.92; line-height: 1.6; }

/* Quiz in detail */
.quiz-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
}
.quiz-card h3 { font-size: 15px; font-weight: 800; color: var(--text); margin-bottom: 14px; }
.q-item { margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px dashed var(--border); }
.q-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.q-question { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.q-options { display: flex; flex-direction: column; gap: 6px; }
.q-opt {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  transition: all 0.2s;
  width: 100%;
}
.q-opt:hover { border-color: var(--ch-accent); background: var(--ch-accent-light); }
.q-opt.correct { background: #d1fae5; border-color: #10b981; color: #065f46; }
.q-opt.wrong { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.q-feedback { font-size: 12px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; display: none; }
.q-feedback.show { display: block; }
.q-feedback.c { background: #d1fae5; color: #065f46; }
.q-feedback.w { background: #fee2e2; color: #991b1b; }

.exercise-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
}

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: exercise;
}

.exercise-item {
  counter-increment: exercise;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 12px 12px 42px;
  position: relative;
  font-size: 14px;
  line-height: 1.55;
}

.exercise-item::before {
  content: counter(exercise);
  position: absolute;
  left: 12px;
  top: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--ch-accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
}

.answer-section {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}

.answer-section h4 {
  color: var(--ch-accent-dark);
  font-size: 14px;
  font-weight: 900;
  margin-bottom: 10px;
}

.answer-item {
  background: var(--white);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 4px solid var(--ch-accent);
}

.answer-item:last-child { margin-bottom: 0; }

.answer-item strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 4px;
}

.answer-item p {
  color: #374151;
  font-size: 14px;
  line-height: 1.6;
}

/* ===== PROGRESS SCREEN ===== */
#progress-screen { background: var(--bg); }

.progress-header {
  padding: 54px 20px 20px;
  background: var(--white);
  border-radius: 0 0 24px 24px;
  box-shadow: var(--shadow);
}

.progress-header h1 {
  font-family: 'Fredoka One', cursive;
  font-size: 26px;
  margin-bottom: 4px;
}
.progress-header p { font-size: 13px; color: var(--text-muted); }

.progress-content { padding: 18px 16px 100px; }

.big-circle-wrap {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.big-ring {
  width: 150px; height: 150px;
  position: relative;
}
.big-ring svg { transform: rotate(-90deg); }
.big-ring circle { fill: none; stroke-width: 10; stroke-linecap: round; }
.big-ring .bg-c { stroke: var(--border); }
.big-ring .fg-c { stroke: var(--green); transition: stroke-dashoffset 1s ease; }
.big-ring .ring-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.big-ring .ring-inner strong { font-size: 30px; font-weight: 900; color: var(--green-dark); }
.big-ring .ring-inner span { font-size: 12px; color: var(--text-muted); }

.ch-progress-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}
.ch-prog-icon { font-size: 28px; }
.ch-prog-text { flex: 1; }
.ch-prog-text h4 { font-size: 14px; font-weight: 800; margin-bottom: 4px; }
.ch-prog-text small { font-size: 12px; color: var(--text-muted); }
.ch-prog-bar { height: 6px; background: var(--border); border-radius: 6px; margin-top: 6px; overflow: hidden; }
.ch-prog-bar-fill { height: 100%; border-radius: 6px; transition: width 1s ease; }

/* ===== ANIMATION ===== */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.anim-in { animation: fadeSlideUp 0.4s ease both; }
.anim-in:nth-child(1) { animation-delay: 0.05s; }
.anim-in:nth-child(2) { animation-delay: 0.10s; }
.anim-in:nth-child(3) { animation-delay: 0.15s; }
.anim-in:nth-child(4) { animation-delay: 0.20s; }
.anim-in:nth-child(5) { animation-delay: 0.25s; }
.anim-in:nth-child(6) { animation-delay: 0.30s; }

/* Tablet and desktop layout */
@media (min-width: 700px) {
  body { background: #E5E8E0; }

  .home-header,
  .welcome-hero,
  .welcome-content,
  .home-content,
  .chapter-header,
  .chapter-content,
  .detail-header,
  .detail-content,
  .progress-header,
  .progress-content {
    width: min(100% - 48px, 1120px);
    margin-left: auto;
    margin-right: auto;
  }

  .home-header,
  .welcome-hero,
  .chapter-header,
  .detail-header,
  .progress-header {
    margin-top: 18px;
    border-radius: 28px;
  }

  .home-content,
  .chapter-content,
  .detail-content,
  .progress-content {
    padding-left: 0;
    padding-right: 0;
  }

  .chapter-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .welcome-subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .detail-content {
    max-width: 920px;
  }

  .bottom-nav {
    width: min(100% - 48px, 760px);
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 16px;
    border-radius: 24px;
  }
}

@media (min-width: 1024px) {
  body {
    background: var(--bg);
  }

  .home-header,
  .welcome-hero,
  .welcome-content,
  .home-content,
  .chapter-header,
  .chapter-content,
  .detail-header,
  .detail-content,
  .progress-header,
  .progress-content {
    width: calc(100% - 64px);
    max-width: none;
  }

  .screen {
    width: 100vw;
  }

  .home-header {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.2fr);
    gap: 18px;
    align-items: stretch;
  }

  .home-header-top {
    margin-bottom: 0;
    align-items: flex-start;
  }

  .progress-banner {
    margin-bottom: 0;
  }

  .stats-row {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 520px;
  }

  .chapter-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .welcome-subject-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .welcome-subject-card {
    min-height: 190px;
    align-items: start;
    grid-template-columns: 1fr auto;
  }

  .welcome-subject-icon {
    grid-column: 1 / -1;
  }

  .chapter-card {
    min-height: 178px;
    align-items: flex-start;
  }

  .chapter-card-text h3 {
    font-size: 17px;
  }

  .topics-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .ch-progress-item {
    width: calc(33.333% - 8px);
    display: inline-flex;
    vertical-align: top;
  }

  .bottom-nav {
    width: min(720px, calc(100% - 64px));
  }
}

@media (min-width: 1440px) {
  .home-header,
  .welcome-hero,
  .welcome-content,
  .home-content,
  .chapter-header,
  .chapter-content,
  .detail-header,
  .detail-content,
  .progress-header,
  .progress-content {
    width: calc(100% - 96px);
  }

  .chapter-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .topics-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .home-header {
    grid-template-columns: minmax(360px, 0.85fr) minmax(520px, 1.25fr);
  }

  .chapter-card {
    min-height: 190px;
  }
}

@media (max-width: 520px) {
  .note-viewer-toolbar {
    grid-template-columns: 1fr;
  }

  .note-viewer-controls {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .note-viewer-stage {
    padding: 10px;
  }
}
