@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css');

/* Font Awesome icon base styles */
i[class*="fa-"] { font-style: normal; }

/* Contextual icon sizing */
.sec-title i[class*="fa-"]        { font-size: 17px; opacity: 0.85; vertical-align: middle; }
.feat-icon i[class*="fa-"]        { font-size: 34px; color: var(--primary); display: block; }
.topic-header i[class*="fa-"]     { font-size: 18px; opacity: 0.9; }
.subtopic-tag i[class*="fa-"]     { font-size: 10px; }
.tip-title i[class*="fa-"]        { font-size: 13px; color: #e65100; }
.sb-label i[class*="fa-"]         { font-size: 11px; opacity: 0.7; }
.btn-nav i[class*="fa-"]          { font-size: 13px; }
.hero-badge i[class*="fa-"]       { font-size: 12px; }
.toc-grid i[class*="fa-"]         { font-size: 11px; }
.chapter-toc-title i[class*="fa-"]{ font-size: 12px; }
.cmp-col-title i[class*="fa-"]    { font-size: 15px; }
.site-logo i[class*="fa-"]        { font-size: 18px; }
footer .footer-logo i[class*="fa-"]{ font-size: 20px; margin-right: 6px; }

/* Inline card icons (those in style="font-size:32px" divs) */
div[style*="font-size:32px"] i[class*="fa-"],
div[style*="font-size:26px"] i[class*="fa-"],
div[style*="font-size:28px"] i[class*="fa-"] {
  font-size: inherit;
  color: var(--primary);
}

/* OS icon brand colors */
.fa-windows  { color: #0078d4 !important; }
.fa-apple    { color: #555 !important; }
.fa-linux    { color: #333 !important; }
.fa-android  { color: #3ddc84 !important; }
.fa-google-drive { color: #f9ab00; }

/* White icons inside colored banners */
.chapter-banner i[class*="fa-"],
.topic-header i[class*="fa-"],
.cc-header i[class*="fa-"] {
  color: rgba(255,255,255,0.85) !important;
}

/* Section title icon color matches chapter */
.content-card .sec-title i[class*="fa-"] { color: var(--primary-dark); }

:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --primary-light: #e3f2fd;
  --accent: #f57c00;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #607080;
  --border: #dde3ea;
  --tip-bg: #fffde7;
  --tip-border: #f9a825;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --radius: 12px;
  --radius-sm: 7px;

  /* Chapter colors */
  --c1: #e91e63; --c1-bg: #fce4ec;
  --c2: #9c27b0; --c2-bg: #f3e5f5;
  --c3: #00897b; --c3-bg: #e0f2f1;
  --c4: #e53935; --c4-bg: #ffebee;
  --c5: #f57c00; --c5-bg: #fff3e0;
  --c6: #388e3c; --c6-bg: #e8f5e9;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans Devanagari', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
}

/* ============================
   HEADER — REDESIGNED
   ============================ */
.site-header {
  background: linear-gradient(135deg, #071e3d 0%, #0d3572 45%, var(--primary-dark) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 24px rgba(0,0,0,0.45);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  height: 66px;
  gap: 0;
}

/* ── Logo ── */
.site-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
  padding-right: 20px;
  border-right: 1px solid rgba(255,255,255,0.12);
  margin-right: 16px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.08) 100%);
  border: 1.5px solid rgba(255,255,255,0.28);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
  transition: all 0.2s;
}
.site-logo:hover .logo-icon {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.4);
  transform: scale(1.06);
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.logo-name {
  color: white;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.2px;
  line-height: 1;
}
.logo-tagline {
  color: rgba(255,255,255,0.45);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

/* ── Navigation ── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.header-nav::-webkit-scrollbar { display: none; }

.hnav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.18s;
  border: 1px solid transparent;
  position: relative;
}
.hnav-link:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.95);
  border-color: rgba(255,255,255,0.12);
}
.hnav-link.active {
  background: rgba(255,255,255,0.16);
  color: white;
  font-weight: 700;
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 1px 0 rgba(255,255,255,0.1) inset;
}

.hnav-num {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: rgba(255,255,255,0.8);
  flex-shrink: 0;
  transition: all 0.18s;
}
.hnav-link.active .hnav-num {
  background: white;
  color: var(--primary-dark);
  border-color: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.hnav-link:hover .hnav-num {
  background: rgba(255,255,255,0.2);
  color: white;
}

.hnav-text { font-size: 12px; }

/* Home link (on chapter pages — right side) */
.hnav-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: 8px;
  text-decoration: none;
  color: rgba(255,255,255,0.6);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.18s;
  border: 1px solid rgba(255,255,255,0.1);
  margin-left: auto;
  flex-shrink: 0;
}
.hnav-home:hover {
  background: rgba(255,255,255,0.12);
  color: white;
  border-color: rgba(255,255,255,0.2);
}

/* Legacy class — kept */
.header-nav a:not(.hnav-link):not(.hnav-home) {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.18s;
}

@media (max-width: 768px) {
  .logo-tagline { display: none; }
  .hnav-text { display: none; }
  .hnav-link { padding: 6px 9px; }
  .header-inner { height: 58px; }
  .logo-icon { width: 34px; height: 34px; font-size: 16px; }
}

/* HERO */
.hero {
  background: linear-gradient(135deg, #0d47a1 0%, #1565c0 50%, #1976d2 100%);
  color: white;
  text-align: center;
  padding: 70px 24px 60px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
.hero > * { position: relative; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 50px;
  padding: 5px 16px;
  font-size: 13px;
  margin-bottom: 22px;
}

.hero-title-hi {
  font-size: clamp(30px, 6vw, 52px);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 6px;
}
.hero-title-en {
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 400;
  opacity: 0.85;
  margin-bottom: 20px;
}
.hero-desc {
  font-size: 16px;
  opacity: 0.8;
  max-width: 480px;
  margin: 0 auto 36px;
  line-height: 1.7;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  flex-wrap: wrap;
}
.hero-stat-num { font-size: 36px; font-weight: 800; }
.hero-stat-label { font-size: 13px; opacity: 0.75; }

/* SECTION LABEL */
.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin-bottom: 8px;
}

/* FEATURES */
.features-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.feat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: var(--shadow);
  text-align: center;
}
.feat-icon { font-size: 36px; margin-bottom: 10px; }
.feat-title { font-weight: 700; font-size: 15px; margin-bottom: 5px; }
.feat-desc { color: var(--text-muted); font-size: 13px; }

/* CHAPTER CARDS */
.section-heading {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.chapter-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chapter-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }

.cc-header {
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.cc-num {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: white; flex-shrink: 0;
}
.cc-title { color: white; font-weight: 700; font-size: 16px; line-height: 1.3; }
.cc-subtitle { color: rgba(255,255,255,0.8); font-size: 13px; margin-top: 2px; }

.cc-body {
  padding: 16px 22px;
  flex: 1;
}
.cc-topics {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cc-topics li {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 7px;
  align-items: flex-start;
}
.cc-topics li::before { content: '›'; color: var(--primary); font-weight: 700; flex-shrink: 0; }

.cc-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.btn-go {
  background: var(--primary);
  color: white;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* CHAPTER PAGE LAYOUT */
.chapter-layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 24px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  align-items: start;
}

/* ============================
   SIDEBAR — REDESIGNED
   ============================ */
.c-sidebar {
  position: sticky;
  top: 78px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: calc(100vh - 98px);
  display: flex;
  flex-direction: column;
}

/* Section wrapper */
.sb-sec {
  padding: 14px 12px;
  flex-shrink: 0;
}
.sb-sec + .sb-sec {
  border-top: 1px solid var(--border);
}
.sb-topics-sec {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sb-topics-sec::-webkit-scrollbar { width: 3px; }
.sb-topics-sec::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Section label */
.sb-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 0 4px;
}

/* ── Chapter List ── */
.sb-chapters {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sb-ch {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.18s;
  border: 1px solid transparent;
}
.sb-ch:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}
.sb-ch.active {
  background: var(--primary);
  color: white;
  font-weight: 700;
  border-color: var(--primary);
}

.sb-ch-num {
  min-width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
  transition: all 0.18s;
}
.sb-ch:hover .sb-ch-num {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.sb-ch.active .sb-ch-num {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.35);
  color: white;
}

/* ── Topic Tree ── */
.sb-topic-tree {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 6px;
}

/* Topic group = topic link + sub-list */
.sb-tg { display: flex; flex-direction: column; }

/* Topic link (bold numbered) */
.sb-topic {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s;
}
.sb-topic:hover { background: var(--bg); }

.sb-t-badge {
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

/* Sub-topic list with vertical connecting line */
.sb-sub-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 1px 0 3px 19px;
  padding-left: 13px;
  border-left: 2px solid var(--border);
}

.sb-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 12px;
  transition: all 0.15s;
  position: relative;
}
.sb-sub::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: all 0.15s;
}
.sb-sub:hover {
  background: var(--bg);
  color: var(--primary);
}
.sb-sub:hover::before { background: var(--primary); }

/* Legacy classes — kept for compatibility */
.sidebar-h { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); margin-bottom: 8px; padding: 0 4px; }
.sidebar-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.sidebar-list a { display:flex; align-items:center; gap:9px; padding:7px 8px; border-radius:7px; text-decoration:none; color:var(--text-muted); font-size:13px; transition:all 0.18s; }
.sidebar-list a:hover { background:var(--bg); color:var(--text); }
.sidebar-list a.active { background:var(--primary); color:white; font-weight:600; }
.s-num { min-width:22px; height:22px; background:var(--border); border-radius:50%; text-align:center; font-size:11px; line-height:22px; font-weight:700; }
.sidebar-list a.active .s-num { background:rgba(255,255,255,0.3); }

/* CHAPTER BANNER */
.chapter-banner {
  border-radius: var(--radius);
  padding: 30px 32px;
  color: white;
  margin-bottom: 22px;
}
.ch-label { font-size: 13px; opacity: 0.8; font-weight: 500; margin-bottom: 6px; }
.ch-title-hi { font-size: clamp(24px, 4vw, 34px); font-weight: 800; margin-bottom: 4px; }
.ch-title-en { font-size: clamp(15px, 2.5vw, 20px); opacity: 0.85; margin-bottom: 14px; }
.ch-intro { font-size: 14px; opacity: 0.88; line-height: 1.7; max-width: 560px; }

/* CONTENT CARDS */
.content-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  min-width: 0;        /* CSS grid overflow fix — allows cell to shrink */
}

.sec-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sec-intro {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.7;
}

/* BULLET LIST */
.b-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.b-list li {
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 14px; line-height: 1.6;
}
.b-list li::before { content: '▸'; color: var(--primary); flex-shrink: 0; margin-top: 2px; font-size: 13px; }

/* NUMBERED LIST */
.n-list { list-style: none; counter-reset: nl; display: flex; flex-direction: column; gap: 8px; }
.n-list li {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 14px; line-height: 1.6;
  counter-increment: nl;
}
.n-list li::before {
  content: counter(nl);
  background: var(--primary);
  color: white;
  min-width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* TABLES */
.tbl-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 14px 0;
  min-width: 0;        /* grid overflow fix */
  max-width: 100%;     /* prevent expanding parent */
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead tr { background: var(--primary); color: white; }
thead th { padding: 11px 15px; text-align: left; font-weight: 600; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: #fafbfc; }
tbody tr:hover { background: #f0f4ff; }
tbody td { padding: 10px 15px; vertical-align: top; line-height: 1.5; }

/* TIP BOX */
.tip-box {
  background: var(--tip-bg);
  border-left: 4px solid var(--tip-border);
  border-radius: 0 8px 8px 0;
  padding: 16px 18px;
  margin: 18px 0;
}
.tip-title {
  font-weight: 700;
  color: #e65100;
  margin-bottom: 10px;
  font-size: 14px;
  display: flex; align-items: center; gap: 6px;
}
.tip-box .b-list li { font-size: 13px; }
.tip-box .b-list li::before { content: '★'; color: var(--tip-border); }

/* IPO CYCLE */
.ipo-row {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 16px 0;
  flex-wrap: wrap;
  gap: 8px;
}
.ipo-box {
  background: var(--primary);
  color: white;
  border-radius: 10px;
  padding: 18px 22px;
  text-align: center;
  flex: 1;
  min-width: 130px;
}
.ipo-main { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.ipo-hi { font-size: 12px; opacity: 0.8; margin-bottom: 8px; }
.ipo-ex { font-size: 12px; opacity: 0.7; background: rgba(255,255,255,0.15); border-radius: 5px; padding: 4px 8px; }
.ipo-arr { font-size: 28px; color: var(--primary); display: flex; align-items: center; flex-shrink: 0; }

/* COMPARE GRID */
.cmp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
}
.cmp-col {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 18px;
}
.cmp-col-title {
  font-size: 15px; font-weight: 700;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}

/* KEYBOARD */
.keyboard-wrap {
  overflow-x: auto;
  padding: 4px 0;
}
.keyboard {
  background: #2b2b2b;
  border-radius: 10px;
  padding: 16px;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
}
.kb-row { display: flex; gap: 5px; }
.key {
  background: #4c4c4c;
  color: #fff;
  border-radius: 5px;
  min-width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border-bottom: 3px solid #1a1a1a;
  user-select: none; white-space: nowrap; padding: 0 5px;
  letter-spacing: 0;
}
.key-w2 { min-width: 52px; }
.key-w3 { min-width: 72px; }
.key-w4 { min-width: 92px; }
.key-sp { min-width: 200px; }
.key-hi { background: #1565c0; }

/* SHORTCUT PILLS */
.sc-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  align-items: center;
  font-size: 14px;
}
.sc-key {
  background: #f0f0f0;
  border: 1px solid #bbb;
  border-bottom: 2px solid #999;
  border-radius: 5px;
  padding: 2px 9px;
  font-family: 'Courier New', monospace;
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}

/* CHAPTER NAVIGATION */
.ch-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
  gap: 12px;
  flex-wrap: wrap;
}
.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow);
  transition: all 0.18s;
}
.btn-nav:hover { border-color: var(--primary); color: var(--primary); }
.btn-next { background: var(--primary); color: white; border-color: var(--primary); }
.btn-next:hover { background: var(--primary-dark); color: white; }

/* BADGE */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 50px;
  font-size: 12px; font-weight: 600;
}
.b-blue { background: #e3f2fd; color: #1565c0; }
.b-green { background: #e8f5e9; color: #2e7d32; }
.b-orange { background: #fff3e0; color: #e65100; }
.b-red { background: #ffebee; color: #c62828; }
.b-purple { background: #f3e5f5; color: #6a1b9a; }
.b-teal { background: #e0f2f1; color: #00695c; }

/* RUN COMMAND */
.cmd {
  font-family: 'Courier New', monospace;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 13px;
  font-weight: 700;
  color: #c62828;
}

/* FOOTER */
footer {
  background: var(--primary-dark);
  color: rgba(255,255,255,0.8);
  text-align: center;
  padding: 36px 24px;
}
.footer-logo { font-size: 20px; font-weight: 800; color: white; margin-bottom: 6px; }
.footer-sub { font-size: 13px; margin-bottom: 3px; }
.footer-copy { font-size: 12px; opacity: 0.5; margin-top: 18px; }

/* CONTAINER */
.page-wrap { max-width: 1240px; margin: 0 auto; padding: 32px 20px; }

/* ============================
   RESPONSIVE — MOBILE FIRST
   ============================ */

/* Tablet (≤ 900px) */
@media (max-width: 900px) {
  .chapter-layout { grid-template-columns: 1fr; padding: 16px 12px 40px; }
  .c-sidebar { display: none; }
  .chapters-grid { grid-template-columns: 1fr 1fr; }
}

/* Mobile (≤ 640px) */
@media (max-width: 640px) {

  /* CRITICAL: Prevent horizontal page overflow */
  html { overflow-x: hidden; }
  body { overflow-x: hidden; max-width: 100vw; }
  main { overflow-x: hidden; }
  .chapter-layout { overflow-x: hidden; }

  /* Header */
  .header-inner { height: 52px; gap: 10px; padding: 0 12px; }
  .logo-name { font-size: 13px; }
  .logo-tagline { display: none; }
  .logo-icon { width: 30px; height: 30px; font-size: 14px; border-radius: 8px; }
  .site-logo { padding-right: 10px; margin-right: 8px; }
  .hnav-link { padding: 5px 7px; gap: 4px; }
  .hnav-text { display: none; }
  .hnav-num { width: 18px; height: 18px; font-size: 10px; }
  .hnav-home { padding: 5px 10px; font-size: 11px; }
  .hnav-home span { display: none; }

  /* Hero */
  .hero { padding: 32px 16px 28px; }
  .hero-title-hi { font-size: 24px; }
  .hero-title-en { font-size: 16px; }
  .hero-desc { font-size: 14px; }
  .hero-stats { gap: 16px; flex-wrap: wrap; justify-content: center; }
  .hero-stat-num { font-size: 28px; }

  /* Chapter cards on home page */
  .chapters-grid { grid-template-columns: 1fr; gap: 14px; }
  .features-row { grid-template-columns: 1fr 1fr; }

  /* Chapter pages */
  .chapter-layout { padding: 12px 10px 40px; gap: 14px; }
  .chapter-banner { padding: 18px 16px; border-radius: 10px; }
  .ch-title-hi { font-size: 20px; }
  .ch-title-en { font-size: 14px; }
  .ch-intro { font-size: 13px; }

  /* Topic headers */
  .topic-header { padding: 10px 14px; margin: 20px 0 10px; }
  .topic-name { font-size: 14px; }
  .topic-en { font-size: 11px; }
  .topic-badge { font-size: 11px; padding: 4px 10px; }

  /* Content cards */
  .content-card { padding: 14px 12px; margin-bottom: 12px; }
  .sec-title { font-size: 15px; }

  /* Chapter TOC — single column on mobile to prevent overflow */
  .chapter-toc { padding: 14px 12px; overflow: hidden; }
  .toc-grid { grid-template-columns: 1fr; gap: 6px; }
  .toc-item { padding: 8px 12px; font-size: 13px; }
  .toc-num  { min-width: 24px; height: 24px; font-size: 12px; }

  /* Comparison grids */
  .cmp-grid { grid-template-columns: 1fr; gap: 10px; }
  .ipo-row { flex-direction: column; align-items: stretch; }
  .ipo-arr { transform: rotate(90deg); align-self: center; }

  /* Tables — horizontal scroll */
  .tbl-wrap { font-size: 12px; }
  .tbl-wrap table { font-size: 12px; }
  .tbl-wrap thead th { padding: 8px 10px; font-size: 11px; }
  .tbl-wrap tbody td { padding: 8px 10px; }

  /* Keyboard */
  .keyboard-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Subtopic tags */
  .subtopic-tag { font-size: 10px; padding: 3px 8px; }

  /* Bullet lists */
  .b-list li { font-size: 13px; }
  .n-list li { font-size: 13px; }

  /* Tip box */
  .tip-box { padding: 12px 14px; }

  /* Navigation buttons */
  .ch-nav { flex-direction: column; gap: 8px; }
  .btn-nav { text-align: center; justify-content: center; }
  .btn-next { margin-left: 0; }

  /* Diagram images */
  .diagram-wrap { padding: 12px 10px 8px; }

  /* Shortcut grid */
  .sc-grid { font-size: 12px; gap: 4px 10px; }

  /* Sidebar bottom margin */
  .c-sidebar { display: none; }
}

/* Very small phones (≤ 380px) */
@media (max-width: 380px) {
  .header-inner { padding: 0 8px; }
  .logo-name { font-size: 12px; }
  .hnav-link { padding: 4px 6px; }
  .toc-grid { grid-template-columns: 1fr !important; }
  .features-row { grid-template-columns: 1fr; }
  .hero-stats { gap: 12px; }
}

/* ============================
   CHAPTER 2 & 4 MOBILE FIXES
   ============================ */

/* Keyboard scroll hint — only on mobile */
.scroll-hint {
  display: none;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 6px;
  padding: 5px 10px;
  margin-bottom: 8px;
  text-align: center;
  border: 1px solid var(--border);
}

/* Evolution arrow in Ch2 — hide on mobile (cards stack vertically) */
.evo-arrow { transition: none; }

/* 6-column dual tables — hide right 3 cols on mobile */
/* Shows: Key | अक्षर | Key (3 cols only) */

@media (max-width: 640px) {
  /* Show keyboard scroll hint */
  .scroll-hint { display: block; }

  /* Keyboard wrap — ensure it scrolls, not overflow page */
  .keyboard-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: 8px;
  }

  /* Evolution arrows — hide on mobile */
  .evo-arrow { display: none !important; }

  /* 6-column dual tables: hide last 3 columns (Alt codes + KrutiDev) */
  .tbl-dual-head th:nth-child(4),
  .tbl-dual-head th:nth-child(5),
  .tbl-dual-head th:nth-child(6) { display: none; }
  .tbl-dual-head ~ tbody tr td:nth-child(4),
  .tbl-dual-head ~ tbody tr td:nth-child(5),
  .tbl-dual-head ~ tbody tr td:nth-child(6) { display: none; }

  /* Shortcut boxes — stack to 1 column */
  [style*="minmax(260px"] { grid-template-columns: 1fr !important; }
  [style*="minmax(280px"] { grid-template-columns: 1fr !important; }

  /* sc-grid shortcut pairs — slightly smaller */
  .sc-grid { font-size: 12px; gap: 5px 10px; }
  .sc-key { font-size: 11px; padding: 1px 6px; }

  /* Inventor cards in Ch2 — 1 column for very narrow */
  [style*="minmax(230px"] { grid-template-columns: 1fr !important; }

  /* Chapter 4 — various inline grids */
  [style*="minmax(200px"] { grid-template-columns: 1fr 1fr !important; }
  [style*="minmax(180px"] { grid-template-columns: 1fr 1fr !important; }
  [style*="minmax(160px"] { grid-template-columns: 1fr 1fr !important; }

  /* Chapter 4 — toc with 6 items */
  .chapter-toc .toc-grid { grid-template-columns: 1fr; }
}

/* HOME CONTAINER */
.home-container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* Intro text */
p.intro-text { font-size: 15px; color: var(--text-muted); margin-bottom: 24px; line-height: 1.7; }

/* ── Computer Introduction wrapper box ── */
.course-intro-box {
  background: var(--card);
  border-radius: 16px;
  padding: 0 0 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  margin-bottom: 32px;
  overflow: hidden;
}

.course-intro-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #071e3d 0%, #0d47a1 60%, #1565c0 100%);
  margin-bottom: 20px;
}

.course-intro-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.course-intro-icon i { font-size: 20px; color: white; }

.course-intro-title {
  font-size: 20px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.course-intro-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.75);
  margin-top: 4px;
}

/* chapters-grid gets horizontal padding inside the box */
.course-intro-box .chapters-grid {
  padding: 0 20px;
}

@media (max-width: 640px) {
  .course-intro-header { padding: 16px 16px; gap: 12px; }
  .course-intro-title { font-size: 17px; }
  .course-intro-sub { font-size: 11px; }
  .course-intro-icon { width: 40px; height: 40px; border-radius: 10px; }
  .course-intro-icon i { font-size: 17px; }
  .course-intro-box .chapters-grid { padding: 0 12px; }
  .course-intro-box { margin-bottom: 20px; }
}

/* Info strip */
.info-strip {
  background: var(--primary-light);
  border: 1px solid #bbdefb;
  border-radius: 9px;
  padding: 16px 20px;
  font-size: 14px;
  color: var(--primary-dark);
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================
   DIAGRAM / IMAGE STYLES
   ============================ */
.diagram-wrap {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 20px 14px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}
.diagram-wrap img, .diagram-wrap svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  background: #f8fafc;
}
.diagram-caption {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
  font-style: italic;
}

/* Spec item */
.spec-item { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.spec-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.spec-val { font-size: 15px; font-weight: 600; }

/* =============================================
   TOPIC / SUB-TOPIC STRUCTURE
   ============================================= */

/* Chapter TOC — overview at top of each chapter */
.chapter-toc {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
  border-top: 4px solid var(--primary);
  min-width: 0;
}
.chapter-toc-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 9px;
}
.toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.18s;
  background: var(--bg);
}
.toc-item:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-1px);
}
.toc-num {
  min-width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  flex-shrink: 0;
}

/* Topic Header — main section divider */
.topic-header {
  border-radius: var(--radius);
  padding: 14px 22px;
  margin: 32px 0 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  color: white;
  position: relative;
  overflow: hidden;
}
.topic-header::after {
  content: '';
  position: absolute; right: -20px; top: -20px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,0.07);
  border-radius: 50%;
}
.topic-header:first-of-type { margin-top: 0; }

.topic-badge {
  background: rgba(255,255,255,0.22);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 7px;
  padding: 5px 13px;
  font-weight: 800;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.03em;
}
.topic-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}
.topic-en {
  font-size: 12px;
  opacity: 0.8;
  margin-top: 2px;
}

/* Sub-topic tag — on each content-card */
.subtopic-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid #bbdefb;
}
/* Chapter-colored sub-topic tags */
.st-c1 { background: #fce4ec; color: #880e4f; border-color: #f48fb1; }
.st-c2 { background: #f3e5f5; color: #4a148c; border-color: #ce93d8; }
.st-c3 { background: #e0f2f1; color: #004d40; border-color: #80cbc4; }
.st-c4 { background: #ffebee; color: #b71c1c; border-color: #ef9a9a; }
.st-c5 { background: #fff3e0; color: #bf360c; border-color: #ffcc80; }
.st-c6 { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }

/* Topic colors (for inline use) */
.bg-c1 { background: linear-gradient(135deg, #ad1457, #e91e63); }
.bg-c2 { background: linear-gradient(135deg, #6a1b9a, #9c27b0); }
.bg-c3 { background: linear-gradient(135deg, #00695c, #00897b); }
.bg-c4 { background: linear-gradient(135deg, #b71c1c, #e53935); }
.bg-c5 { background: linear-gradient(135deg, #bf360c, #f57c00); }
.bg-c6 { background: linear-gradient(135deg, #1b5e20, #388e3c); }

/* legacy sidebar-subtopic — unused, kept for safety */
.sidebar-subtopic a { font-size: 12px; color: var(--text-muted); }

@media (max-width: 640px) {
  .toc-grid { grid-template-columns: 1fr 1fr; }
  .topic-header { padding: 12px 16px; }
  .topic-name { font-size: 15px; }
}
