:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #5e6b80;
  --primary: #1e5eff;
  --primary-dark: #133f9f;
  --blue-soft: #eaf0ff;
  --green-soft: #e9f8ef;
  --yellow-soft: #fff7dc;
  --red-soft: #fff1f0;
  --border: #dce3f0;
  --success: #0f6b3f;
  --danger: #b42318;
  --shadow: 0 10px 28px rgba(23, 32, 51, 0.06);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: Arial, Helvetica, "Noto Sans Bengali", "Nirmala UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}

a { color: var(--primary-dark); }

.page {
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  background: linear-gradient(135deg, #112f72, #1e5eff);
  color: white;
  border-radius: 28px;
  padding: 42px;
  box-shadow: 0 20px 50px rgba(30, 94, 255, 0.24);
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: rgba(255,255,255,0.11);
  right: -90px;
  top: -90px;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2.05rem, 5vw, 4rem);
  line-height: 1.08;
  max-width: 980px;
  position: relative;
  z-index: 1;
}

.hero p {
  max-width: 900px;
  margin: 0;
  font-size: 1.08rem;
  opacity: 0.96;
  position: relative;
  z-index: 1;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

.btn {
  display: inline-block;
  text-decoration: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.55);
  color: white;
  background: rgba(255,255,255,0.12);
}

.btn.light {
  background: white;
  color: var(--primary-dark);
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.toolbar input {
  flex: 1;
  min-width: 240px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 1rem;
}

.toolbar button {
  border: 0;
  background: var(--primary);
  color: white;
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
}

.search-status {
  flex-basis: 100%;
  margin: 0;
  padding: 0 4px;
  color: var(--success);
  font-size: 0.94rem;
  font-weight: 700;
}

.search-status:empty {
  display: none;
}

.search-status.no-results {
  color: var(--danger);
}

.notice {
  background: var(--yellow-soft);
  border: 1px solid #f0d36a;
  border-radius: 18px;
  padding: 18px 20px;
  margin: 20px 0;
}

.grid, .three-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 24px 0;
}

.two-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.summary-card, section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.summary-card { padding: 20px; }
.summary-card h2 { font-size: 1.12rem; margin: 0 0 8px; }
.summary-card p { margin: 0; color: var(--muted); }

section {
  padding: 26px;
  margin: 24px 0;
}

section h2 {
  margin-top: 0;
  font-size: 1.65rem;
  line-height: 1.2;
}

section h3 { margin-top: 22px; }

.part-header {
  border-radius: 26px;
  padding: 30px;
  margin: 34px 0 20px;
  color: white;
  background: linear-gradient(135deg, #101828, #344054);
  box-shadow: var(--shadow);
}

.part-header.permit { background: linear-gradient(135deg, #0f5132, #198754); }
.part-header.road { background: linear-gradient(135deg, #143f9f, #1e5eff); }

.part-header h2 {
  margin: 0 0 8px;
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.part-header p { margin: 0; max-width: 900px; }

section[id],
.part-header[id],
.callout[id] {
  scroll-margin-top: 92px;
}

.nav-intro {
  margin: -4px 0 18px;
  color: var(--muted);
}

.nav-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.nav-group {
  border: 1px solid var(--border);
  border-top: 4px solid var(--success);
  border-radius: 18px;
  padding: 18px;
  background: #fbfcff;
}

.nav-group.road {
  border-top-color: var(--primary);
}

.nav-group h3 {
  margin: 0 0 12px;
  font-size: 1.16rem;
}

.nav-group h3 a {
  display: block;
  color: var(--text);
  text-decoration: none;
}

.nav-group h3 a:hover {
  color: var(--primary-dark);
}

.nav-card ul {
  display: grid;
  gap: 5px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-card li a {
  display: block;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.nav-card li a:hover,
.nav-card li a:focus-visible {
  background: var(--blue-soft);
  color: var(--primary-dark);
}

.nav-card li a:active {
  transform: translateX(2px);
}

.term-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 16px;
}

.term-table th,
.term-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.term-table th {
  background: var(--blue-soft);
  color: #0f2d6d;
  font-size: 0.94rem;
}

.term-table tbody tr {
  transition: background 0.15s ease;
}

.term-table tbody tr:nth-child(even) {
  background: #fbfcff;
}

.term-table tbody tr:hover {
  background: #f1f5ff;
}

.term-table tr:last-child td { border-bottom: none; }

.term {
  font-weight: 800;
  color: var(--primary-dark);
  white-space: nowrap;
}

.bengali {
  font-family: "Noto Sans Bengali", "Nirmala UI", "Vrinda", sans-serif;
  font-weight: 800;
  font-size: 1.08em;
  color: var(--success);
  line-height: 1.8;
}

.muted { color: var(--muted); }
.analogy { color: var(--muted); }

.tag {
  display: inline-block;
  background: var(--green-soft);
  color: var(--success);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 6px;
}

.tag.blue { background: var(--blue-soft); color: var(--primary-dark); }
.tag.red { background: var(--red-soft); color: var(--danger); }
.tag.yellow { background: var(--yellow-soft); color: #7a5600; }

.command-box, .step-grid, .sign-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.command, .step-card, .sign-card, .quiz-card, .phase-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 17px;
  background: #fbfcff;
}

.command { border-left: 6px solid var(--primary); }
.warning { border-left-color: var(--danger); background: #fff8f7; }
.step-card h3, .sign-card h3, .phase-card h3 { margin-top: 0; }

.checklist {
  list-style: none;
  padding-left: 0;
}

.checklist li {
  margin-bottom: 10px;
  padding-left: 30px;
  position: relative;
}

.checklist li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--success);
  font-weight: 900;
}

.mistake li, .practice-list li { margin-bottom: 10px; }

.callout {
  border-radius: 18px;
  padding: 18px;
  background: var(--blue-soft);
  border: 1px solid #b8c9ff;
  margin-top: 16px;
}

.callout.danger {
  background: var(--red-soft);
  border-color: #ffc7c2;
}

.callout.green {
  background: var(--green-soft);
  border-color: #b9e8ca;
}

.quiz-card button {
  display: block;
  width: 100%;
  margin: 8px 0;
  text-align: left;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: white;
  color: var(--text);
  cursor: pointer;
  font-size: 0.98rem;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease, transform 0.08s ease;
}

.quiz-card button:hover {
  border-color: #a9bce9;
  background: #f5f8ff;
}

.quiz-card button:focus-visible {
  outline: 3px solid rgba(30, 94, 255, 0.22);
  outline-offset: 1px;
}

.quiz-card button:active,
.quiz-card button.selected {
  transform: translateY(1px);
}

.quiz-card button.selected {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary), 0 3px 9px rgba(30, 94, 255, 0.13);
  background: var(--blue-soft);
}

.quiz-card button.selected.correct {
  border-color: var(--success);
  box-shadow: inset 0 0 0 1px var(--success), 0 3px 9px rgba(15, 107, 63, 0.14);
  background: var(--green-soft);
  color: var(--success);
}

.quiz-card button.selected.incorrect {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger), 0 3px 9px rgba(180, 35, 24, 0.12);
  background: var(--red-soft);
  color: var(--danger);
}

.quiz-card.answered-correct {
  border-color: #b9e8ca;
}

.quiz-card.answered-incorrect {
  border-color: #ffc7c2;
}

.quiz-result {
  margin-top: 10px;
  font-weight: 800;
  min-height: 1.65em;
}

.quiz-result.correct {
  color: var(--success);
}

.quiz-result.incorrect {
  color: var(--danger);
}

.official-links a {
  display: block;
  margin-bottom: 10px;
  padding: 12px 14px;
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  font-weight: 700;
}

.footer {
  background: #101828;
  color: #d0d5dd;
  border-radius: 22px;
  padding: 22px;
  margin: 26px 0 10px;
  font-size: 0.94rem;
  text-align: center;
}

.footer a { color: white; font-weight: 700; }
.hidden-by-search { display: none !important; }

.back-to-top {
  position: fixed;
  right: max(18px, calc((100vw - 1220px) / 2 + 18px));
  bottom: 22px;
  z-index: 8;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 10px 15px;
  border-radius: 999px;
  color: white;
  background: var(--primary-dark);
  box-shadow: 0 10px 24px rgba(19, 63, 159, 0.25);
  font-weight: 700;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease, background 0.15s ease;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover,
.back-to-top:focus-visible {
  background: var(--primary);
}

@media (min-width: 1460px) {
  .back-to-top {
    right: auto;
    left: calc(50% + 628px);
  }
}

@media print {
  body { background: white; }
  .toolbar, .hero-actions, .quiz-card button, .back-to-top { display: none; }
  .page { max-width: none; padding: 0; }
  .hero, section, .summary-card, .footer, .part-header { box-shadow: none; }
  a::after { content: " (" attr(href) ")"; font-size: 0.85em; }
}

@media (max-width: 900px) {
  .grid, .three-grid, .two-grid, .command-box, .step-grid, .sign-grid {
    grid-template-columns: 1fr;
  }

  .nav-columns { grid-template-columns: 1fr; }
  section[id],
  .part-header[id],
  .callout[id] { scroll-margin-top: 14px; }
  .page { padding: 14px; }
  .hero, section, .part-header { padding: 22px; }
  .toolbar { position: static; }

  .term-table,
  .term-table thead,
  .term-table tbody,
  .term-table th,
  .term-table td,
  .term-table tr { display: block; }

  .term-table thead { display: none; }

  .term-table tr {
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 14px;
    overflow: hidden;
  }

  .term-table td { border-bottom: 1px solid var(--border); }

  .term-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    margin-bottom: 4px;
  }
}

.callout h3 {
  margin-top: 0;
  margin-bottom: 8px;
}
