:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-alt: #eef3f9;
  --ink: #162235;
  --ink-muted: #516075;
  --navy: #14365d;
  --navy-dark: #0d2440;
  --accent: #1d5fa7;
  --accent-soft: #e6effa;
  --gold: #b45309;
  --gold-soft: #fef3c7;
  --green: #166534;
  --green-soft: #dcfce7;
  --red: #991b1b;
  --red-soft: #fee2e2;
  --border: #d5dfec;
  --shadow: 0 4px 18px rgba(15, 35, 65, 0.06);
  --radius: 10px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", "Noto Sans Devanagari", "Nirmala UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header & Navigation */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--navy-dark);
  color: #fff;
  border-bottom: 3px solid #2b6cb0;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}
.brand:hover { text-decoration: none; }

.brand-badge {
  background: #2b6cb0;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.brand-title { font-size: 1.05rem; font-weight: 700; display: block; line-height: 1.2; }
.brand-sub { font-size: 0.78rem; color: #b9cde6; display: block; }

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lang-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.lang-btn {
  border: none;
  background: transparent;
  color: #dbe7f5;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.lang-btn.active {
  background: #ffffff;
  color: var(--navy-dark);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn:hover { background: var(--surface-alt); text-decoration: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--navy); border-color: var(--navy); }
.btn-outline-light {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.2); }
.btn-recall.active {
  background: #f59e0b;
  color: #111827;
  border-color: #f59e0b;
}

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 65%, #1e4e85 100%);
  color: #fff;
  padding: 34px 0 30px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 2.8vw, 2.15rem);
  line-height: 1.25;
}

.hero p {
  margin: 0 0 18px;
  color: #d6e4f5;
  max-width: 780px;
  font-size: 0.98rem;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Main & Cards */
main { padding: 28px 0 56px; }

.section-title {
  font-size: 1.3rem;
  color: var(--navy-dark);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr));
  gap: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card h3 {
  margin: 0 0 8px;
  color: var(--navy-dark);
  font-size: 1.1rem;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tag-ready { background: var(--green-soft); color: var(--green); }
.tag-soon { background: var(--surface-alt); color: var(--ink-muted); }
.tag-high { background: var(--red-soft); color: var(--red); }
.tag-med { background: var(--gold-soft); color: var(--gold); }
.tag-backup { background: var(--accent-soft); color: var(--navy); }

/* Tabs for Subject Page */
.study-toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 63px;
  z-index: 30;
}

.tab-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 0;
  scrollbar-width: thin;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 0.86rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.tab-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 12px 0; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 0.92rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
}

tr:nth-child(even) td { background: #f9fbfe; }

/* Accordions / Chapter Cards */
.chapter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chapter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.chapter-header h3 {
  margin: 0;
  font-size: 1.06rem;
  color: var(--navy-dark);
}

.chapter-body { padding: 16px 18px; }
.chapter-card.collapsed .chapter-body { display: none; }

.topic-block {
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.topic-block:last-child { border-bottom: none; padding-bottom: 0; }

.topic-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.topic-title {
  font-weight: 700;
  color: var(--navy);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.callout {
  background: var(--gold-soft);
  border-left: 4px solid #d97706;
  padding: 10px 14px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 0.92rem;
}

.callout-info {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

/* Active Recall Blur */
body.recall-mode .recall-answer {
  filter: blur(6px);
  user-select: none;
  cursor: pointer;
  transition: filter 0.18s ease;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 4px 6px;
}
body.recall-mode .recall-answer.revealed {
  filter: none;
  user-select: text;
  background: transparent;
  padding: 0;
}

.recall-hint {
  display: none;
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 8px;
}
body.recall-mode .recall-hint { display: block; }

/* Search & Filter Bar */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
}

.search-input {
  flex: 1;
  min-width: 220px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.92rem;
}

.progress-box {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.progress-bar-track {
  flex: 1;
  height: 10px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: #16a34a;
  width: 0%;
  transition: width 0.25s ease;
}

/* Guided Study Flow */
.stepper-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.stepper-bar > div { min-width: 0; max-width: 100%; }

.step-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}

.step-pill {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink-muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}
.step-pill.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.step-pill.done {
  background: var(--green-soft);
  color: var(--green);
  border-color: #86efac;
}

.qa-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.qa-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.marks-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  background: var(--navy);
  color: #fff;
}

.answer-textarea {
  width: 100%;
  min-height: 78px;
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  background: #fbfdff;
}

.model-answer-box {
  margin-top: 10px;
  padding: 14px 16px;
  border-radius: 8px;
  background: #f4f9f5;
  border-left: 4px solid #16a34a;
  line-height: 1.62;
}
.model-answer-box p { margin: 6px 0; }
.model-answer-box ul { margin: 6px 0 8px; padding-left: 20px; }
.model-answer-box li { margin-bottom: 4px; }
.model-ans-heading {
  margin: 10px 0 4px !important;
  color: var(--navy-dark);
  font-weight: 700;
}

.rating-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 10px;
}

.rate-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.rate-btn.active-weak { background: var(--red-soft); color: var(--red); border-color: #fca5a5; }
.rate-btn.active-mid { background: var(--gold-soft); color: var(--gold); border-color: #fcd34d; }
.rate-btn.active-good { background: var(--green-soft); color: var(--green); border-color: #86efac; }

.guided-nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
}

@media (max-width: 680px) {
  .container { padding: 0 14px; }
  .study-toolbar { top: 0; position: relative; }
  .header-inner { padding: 10px 0; gap: 10px; }
  .brand { gap: 8px; min-width: 0; }
  .brand-badge { padding: 5px 8px; font-size: 0.76rem; white-space: nowrap; }
  .brand-title { font-size: 0.96rem; }
  .brand-sub { font-size: 0.72rem; }
  .hero { padding: 22px 0 20px; }
  .card, .qa-card { padding: 14px; }
  .chapter-header, .chapter-body { padding: 12px 14px; }
  .btn, .tab-btn, .step-pill { min-height: 40px; }
  .rate-btn { min-height: 38px; padding: 6px 12px; }
  .answer-textarea, .search-input { font-size: 16px; }
  #guidedSelect { width: 100%; max-width: 100% !important; }
  .stepper-bar > div:last-child { width: 100%; }
  #prevTopicTopBtn, #nextTopicTopBtn { flex: 1 1 0; justify-content: center; }
  .guided-nav-footer .btn { width: 100%; justify-content: center; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  th, td { padding: 7px 9px; font-size: 0.85rem; }
}

@media print {
  .site-header, .study-toolbar, .filter-bar, .btn, .recall-hint { display: none !important; }
  .tab-panel { display: block !important; }
  .chapter-card.collapsed .chapter-body { display: block !important; }
  body { background: #fff; }
  .card, .chapter-card { box-shadow: none; break-inside: avoid; }
}
