/* ==========================================================================
   Vibe Engineering SMIT - Single-Page Course Application Stylesheet
   Complete unified styles for layout, themes, lessons, components, and search
   ========================================================================== */

/* ---------- Color Variables & Theme Tokens ---------- */
:root {
  --violet-50: #f5f3ff;
  --violet-100: #ede9fe;
  --violet-200: #ddd6fe;
  --violet-300: #c4b5fd;
  --violet-400: #a78bfa;
  --violet-500: #8b5cf6;
  --violet-600: #7c3aed;
  --violet-700: #6d28d9;
  --violet-800: #5b21b6;
  --violet-900: #4c1d95;

  --amber-300: #fcd34d;
  --amber-400: #fbbf24;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  --em: #10b981;
  --em-d: #047857;
  --rose: #e11d48;
  --rose-d: #9f1239;

  --bg: #faf9fc;
  --plane: #f2eff8;
  --surface: #ffffff;
  --surface-2: #faf8fe;
  --ink: #17141f;
  --ink-2: #4a4658;
  --muted: #716b88;
  --hair: #e7e2f0;
  --hair-2: #efeaf7;
  --brand: var(--violet-700);
  --brand-soft: var(--violet-100);
  --brand-ink: var(--violet-800);
  --accent: var(--amber-500);

  --shadow-sm: 0 1px 2px rgba(24, 16, 44, 0.06), 0 1px 3px rgba(24, 16, 44, 0.05);
  --shadow-md: 0 6px 24px -8px rgba(60, 30, 110, 0.22), 0 2px 8px -3px rgba(60, 30, 110, 0.12);
  --shadow-lg: 0 24px 60px -18px rgba(60, 20, 120, 0.34);

  --r: 14px;
  --r-lg: 20px;
  --maxw: 1200px;
  --code-bg: #1c162b;
  --code-ink: #e9e3fb;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0c0a12;
  --plane: #0a0810;
  --surface: #151122;
  --surface-2: #191428;
  --ink: #f4f1fb;
  --ink-2: #c3bcd6;
  --muted: #918aa8;
  --hair: #2a2340;
  --hair-2: #231d36;
  --brand: var(--violet-400);
  --brand-soft: #241a3d;
  --brand-ink: var(--violet-200);
  --accent: var(--amber-400);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.7);

  --code-bg: #0f0b1a;
  --code-ink: #e9e3fb;

  color-scheme: dark;
}

/* ---------- Base & Reset ---------- */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

/* ---------- Top Reading Progress Bar ---------- */
#reading-prog-container {
  height: 3px;
  background: var(--hair);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

#reading-prog {
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--violet-600), var(--amber-400));
  transition: width 0.1s linear;
}

/* ---------- Sticky Site Header ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--hair);
}

.site-head .bar {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand .glyph {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--violet-600), var(--violet-800));
  color: #fff;
  font-size: 15px;
  box-shadow: 0 4px 12px -3px rgba(109, 40, 217, 0.6);
}

.brand small {
  display: block;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Search Trigger Button ---------- */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--hair);
  color: var(--muted);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  height: 38px;
}

.search-trigger:hover,
.search-trigger:focus-visible {
  border-color: var(--brand);
  color: var(--ink);
  outline: none;
  box-shadow: 0 0 0 2px var(--brand-soft);
}

.search-trigger svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-trigger kbd {
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: inherit;
  font-weight: 700;
  color: var(--ink-2);
}

/* ---------- Language Switcher Pill ---------- */
.lang-pill {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  height: 38px;
}

.lang-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.lang-opt:hover {
  color: var(--ink);
}

.lang-opt.active {
  background: var(--brand);
  color: #ffffff !important;
  box-shadow: 0 1px 3px rgba(109, 40, 217, 0.35);
}

:root[data-theme="dark"] .lang-opt.active {
  background: var(--brand);
  color: #0c0a12 !important;
  font-weight: 800;
}

/* ---------- Icon Buttons ---------- */
.icon-btn {
  border: 1px solid var(--hair);
  background: var(--surface);
  color: var(--ink-2);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 17px;
  transition: all 0.15s;
}

.icon-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.menu-btn {
  display: none;
}

/* ---------- SPA Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 44px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 22px;
  min-height: calc(100vh - 120px);
}

/* ---------- Sidebar Navigation ---------- */
.side {
  position: sticky;
  top: 60px;
  align-self: start;
  height: calc(100vh - 72px);
  overflow-y: auto;
  padding: 24px 0 40px;
  font-size: 13.5px;
}

.side::-webkit-scrollbar {
  width: 6px;
}
.side::-webkit-scrollbar-thumb {
  background: var(--hair);
  border-radius: 6px;
}

.side .grp {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 18px 0 6px;
  padding: 0 8px;
}

.side .side-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  font-weight: 600;
  border-left: 2px solid transparent;
  transition: background 0.12s;
}

.side .side-link:hover {
  background: var(--brand-soft);
  text-decoration: none;
  color: var(--brand-ink);
}

.side .side-link.active {
  color: var(--brand);
  background: var(--brand-soft);
  border-left-color: var(--brand);
  font-weight: 700;
}

.side .vibe-check {
  font-size: 11px;
  color: var(--em);
  font-weight: 800;
  display: none;
}

.side .side-link.visited .vibe-check {
  display: inline-block;
}

/* Sidebar On-This-Page TOC */
.side-toc-container {
  margin-top: 26px;
  border-top: 1px solid var(--hair);
  padding-top: 14px;
}

.side-toc-container .toc-item {
  display: block;
  font-weight: 550;
  font-size: 12.5px;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 6px;
  border-left: 2px solid transparent;
}

.side-toc-container .toc-item:hover {
  color: var(--brand);
  background: var(--surface-2);
  text-decoration: none;
}

.side-toc-container .toc-item.here {
  color: var(--brand);
  font-weight: 700;
  border-left-color: var(--brand);
}

/* ---------- Main Lesson Area ---------- */
main#lesson-content {
  padding: 24px 0 90px;
  min-width: 0;
}

.content {
  max-width: 780px;
}

/* ---------- Hero & Badges ---------- */
.daybadge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 750;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.daybadge.d2 { background: #fde6c8; color: #8a5a00; }
:root[data-theme="dark"] .daybadge.d2 { background: #3a2c0d; color: var(--amber-300); }
.daybadge.d3 { background: #d3f5e6; color: #06603f; }
:root[data-theme="dark"] .daybadge.d3 { background: #0c3327; color: #54e0aa; }
.daybadge.d4 { background: #e4ecfb; color: #1e4fa3; }
:root[data-theme="dark"] .daybadge.d4 { background: #0e1a30; color: #7db0f4; }
.daybadge.d5 { background: #fbe0ea; color: #9f1239; }
:root[data-theme="dark"] .daybadge.d5 { background: #3a0f1e; color: #f7789f; }
.daybadge.d6 { background: #fde4c0; color: #8a5300; }
:root[data-theme="dark"] .daybadge.d6 { background: #3a2a0b; color: #fcc858; }
.daybadge.d7 { background: #ece7ff; color: #5b21b6; }
:root[data-theme="dark"] .daybadge.d7 { background: #241a3d; color: #c4b5fd; }
.daybadge.d8 { background: #fbe2f6; color: #9d1c8f; }
:root[data-theme="dark"] .daybadge.d8 { background: #33103a; color: #f3a6e6; }
.daybadge.d9 { background: #dbeafe; color: #1e478a; }
:root[data-theme="dark"] .daybadge.d9 { background: #0e1e3a; color: #93bdf7; }
.daybadge.d10 { background: #cdf3ee; color: #0b5f57; }
:root[data-theme="dark"] .daybadge.d10 { background: #07302c; color: #5ed9cd; }
.daybadge.d11 { background: #e2e0ff; color: #3f34b5; }
:root[data-theme="dark"] .daybadge.d11 { background: #191537; color: #b0a6f7; }
.daybadge.d12 { background: #ffe3d3; color: #9a3d12; }
:root[data-theme="dark"] .daybadge.d12 { background: #3a1c0c; color: #f6a172; }
.daybadge.d13 { background: #d3ecff; color: #0b5788; }
:root[data-theme="dark"] .daybadge.d13 { background: #07283e; color: #69bff2; }
.daybadge.lab { background: #111; color: #fff; }
:root[data-theme="dark"] .daybadge.lab { background: #2a2340; color: #fff; }

h1.page {
  font-size: clamp(30px, 4.4vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.03em;
  font-weight: 820;
  margin: 16px 0 12px;
}

.lede {
  font-size: 19px;
  color: var(--ink-2);
  max-width: 65ch;
  margin: 0 0 14px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 14px 0 4px;
  border-top: 1px solid var(--hair);
  margin-top: 22px;
}

.meta b {
  color: var(--ink-2);
}

/* ---------- Typography & Headings ---------- */
.content h2 {
  font-size: 26px;
  letter-spacing: -0.02em;
  font-weight: 780;
  margin: 50px 0 8px;
  scroll-margin-top: 84px;
}

.content h2 .num {
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  margin-right: 10px;
  font-weight: 800;
}

.content h3 {
  font-size: 19px;
  font-weight: 720;
  margin: 32px 0 6px;
  letter-spacing: -0.01em;
}

.content p {
  margin: 14px 0;
}

.content ul,
.content ol {
  margin: 14px 0;
  padding-left: 22px;
}

.content li {
  margin: 7px 0;
}

.content li::marker {
  color: var(--brand);
}

strong {
  font-weight: 720;
  color: var(--ink);
}

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

mark {
  background: linear-gradient(transparent 58%, var(--amber-300) 58%);
  color: inherit;
  padding: 0 1px;
}
:root[data-theme="dark"] mark {
  background: linear-gradient(transparent 58%, rgba(251, 191, 36, 0.45) 58%);
}

kbd {
  font-family: ui-monospace, monospace;
  font-size: 0.82em;
  background: var(--surface-2);
  border: 1px solid var(--hair);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 1px 7px;
  color: var(--ink);
}

code.inl {
  font-family: ui-monospace, monospace;
  font-size: 0.86em;
  background: var(--brand-soft);
  color: var(--brand-ink);
  padding: 1.5px 6px;
  border-radius: 6px;
}

/* ---------- Callouts ---------- */
.call {
  border-radius: var(--r);
  padding: 18px 20px 18px 52px;
  margin: 24px 0;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hair);
  box-shadow: var(--shadow-sm);
  font-size: 15.5px;
}

.call:before {
  position: absolute;
  left: 16px;
  top: 17px;
  font-size: 20px;
  line-height: 1;
}

.call .t {
  font-weight: 780;
  letter-spacing: -0.01em;
  margin: 0 0 3px;
  font-size: 15px;
}

.call p:first-of-type { margin-top: 0; }
.call p:last-child { margin-bottom: 0; }

.call.idea {
  background: var(--brand-soft);
  border-color: transparent;
}
.call.idea:before { content: "💡"; }
.call.idea .t { color: var(--brand-ink); }

.call.warn {
  background: #fff5e6;
  border-color: #f6e3bf;
}
.call.warn:before { content: "⚠️"; }
.call.warn .t { color: #9a6100; }

.call.tip {
  background: #e9f9f1;
  border-color: #c4ebd8;
}
.call.tip:before { content: "✅"; }
.call.tip .t { color: #06603f; }

.call.def {
  background: var(--surface-2);
}
.call.def:before { content: "📘"; }
.call.def .t { color: var(--brand); }

.call.quote {
  background: var(--surface);
  border-left: 4px solid var(--brand);
  padding-left: 22px;
}
.call.quote:before { content: ""; }

.call.money {
  background: #eef4ff;
  border-color: #cfe0fb;
}
.call.money:before { content: "💳"; }
.call.money .t { color: #1e4fa3; }

/* Dark mode callouts WCAG AA */
:root[data-theme="dark"] .call.idea { background: #1e1633; border-color: #38275c; }
:root[data-theme="dark"] .call.idea .t { color: #d8b4fe; }
:root[data-theme="dark"] .call.idea p { color: #ede9fe; }

:root[data-theme="dark"] .call.warn { background: #271a06; border-color: #4a340b; }
:root[data-theme="dark"] .call.warn .t { color: #fde047; }
:root[data-theme="dark"] .call.warn p { color: #fef08a; }

:root[data-theme="dark"] .call.tip { background: #09261c; border-color: #0f4835; }
:root[data-theme="dark"] .call.tip .t { color: #6ee7b7; }
:root[data-theme="dark"] .call.tip p { color: #a7f3d0; }

:root[data-theme="dark"] .call.money { background: #0b1d38; border-color: #143566; }
:root[data-theme="dark"] .call.money .t { color: #93c5fd; }
:root[data-theme="dark"] .call.money p { color: #bfdbfe; }

/* ---------- Code Blocks ---------- */
.code {
  background: var(--code-bg);
  border-radius: var(--r);
  margin: 22px 0;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.code .cbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.code .dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}
.code .dot.r { background: #ff5f57; }
.code .dot.y { background: #febc2e; }
.code .dot.g { background: #28c840; }

.code .fname {
  margin-left: 8px;
  color: #b9aee0;
  font-size: 12.5px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
}

.code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  color: var(--code-ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.6;
}

.code pre .c { color: #8a7fb0; }
.code pre .h { color: #c4b5fd; font-weight: 700; }
.code pre .s { color: #fcd34d; }
.code pre .k { color: #7dd3fc; }
.code pre .g { color: #6ee7b7; }
.term { background: #0d0a17; }
.term .fname { color: #7dd3fc; }

/* ---------- Steps ---------- */
.steps {
  counter-reset: s;
  margin: 26px 0;
  display: grid;
  gap: 14px;
}

.step {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r);
  padding: 18px 20px 18px 62px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.step:before {
  counter-increment: s;
  content: counter(s);
  position: absolute;
  left: 16px;
  top: 16px;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 15px;
  box-shadow: 0 4px 10px -3px rgba(109, 40, 217, 0.6);
}

.step h4 {
  margin: 0 0 4px;
  font-size: 16.5px;
  font-weight: 730;
}

.step .time {
  float: right;
  font-size: 12px;
  font-weight: 750;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 9px;
  border-radius: 999px;
}

.step p {
  margin: 8px 0 0;
  font-size: 14.5px;
  color: var(--ink-2);
}

/* ---------- Tables ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14.5px;
  border: 1px solid var(--hair);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.tbl th {
  background: var(--surface-2);
  text-align: left;
  font-weight: 750;
  padding: 12px 14px;
  border-bottom: 1px solid var(--hair);
  font-size: 13px;
}

.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hair-2);
  vertical-align: top;
}

.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }

/* ---------- Cards & Grids ---------- */
.grid {
  display: grid;
  gap: 16px;
  margin: 24px 0;
}
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
@media(max-width: 640px) {
  .grid.c2, .grid.c3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: var(--r);
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
}
.card h4 {
  margin: 0 0 5px;
  font-size: 16px;
  font-weight: 730;
  letter-spacing: -0.01em;
}
.card p {
  margin: 0;
  color: var(--ink-2);
  font-size: 14.5px;
}
.card .k {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
}
.card.hl {
  background: linear-gradient(160deg, var(--violet-700), var(--violet-900));
  color: #fff;
  border: 0;
}
.card.hl h4, .card.hl p, .card.hl .k { color: #fff; }
.card.hl .k { color: var(--amber-300); }

/* ---------- Key Takeaways ---------- */
.takeaways {
  background: linear-gradient(165deg, var(--surface), var(--surface-2));
  border: 1px solid var(--hair);
  border-radius: var(--r-lg);
  padding: 24px 26px;
  margin: 44px 0 10px;
  box-shadow: var(--shadow-md);
}

.takeaways h3 {
  margin: 0 0 10px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.takeaways h3 .p {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 14px;
}

.takeaways ul {
  margin: 0;
  padding-left: 4px;
  list-style: none;
}

.takeaways li {
  padding-left: 28px;
  position: relative;
  margin: 9px 0;
}

.takeaways li:before {
  content: "→";
  position: absolute;
  left: 2px;
  color: var(--brand);
  font-weight: 800;
}

/* ---------- Previous / Next Navigation Pager ---------- */
.pager {
  display: flex;
  gap: 14px;
  margin-top: 56px;
  border-top: 1px solid var(--hair);
  padding-top: 26px;
}

.pager a {
  flex: 1;
  border: 1px solid var(--hair);
  border-radius: var(--r);
  padding: 14px 18px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: 0.15s;
}

.pager a:hover {
  border-color: var(--brand);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.pager .l {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pager .t {
  font-weight: 730;
  color: var(--ink);
  margin-top: 3px;
}

.pager .nx {
  text-align: right;
}

/* ---------- Class 1 Note Box ---------- */
.class1-note-box {
  background: var(--surface-2);
  border: 1px dashed var(--hair);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 18px auto 26px;
  max-width: 640px;
  font-size: 13.5px;
  color: var(--ink-2);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
}
.class1-note-box .icon {
  font-size: 16px;
  line-height: 1.2;
}

/* ---------- Search Modal ---------- */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(12, 10, 18, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 60px 16px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
}

.search-dialog {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 16px;
  width: 100%;
  max-width: 660px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: searchSlideDown 0.16s ease-out;
}

@keyframes searchSlideDown {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--hair);
}

.search-head svg {
  width: 20px;
  height: 20px;
  stroke: var(--brand);
  stroke-width: 2.2;
  fill: none;
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  outline: none;
  font-family: inherit;
  padding: 0;
}

.search-close {
  background: var(--surface-2);
  border: 1px solid var(--hair);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.search-filters {
  display: flex;
  gap: 6px;
  padding: 8px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--hair);
}

.filter-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}

.filter-btn.active {
  background: var(--surface);
  border-color: var(--hair);
  color: var(--brand);
  font-weight: 700;
}

.search-body {
  max-height: 440px;
  overflow-y: auto;
  padding: 10px 12px;
}

.search-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.search-item {
  display: block;
  padding: 10px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.12s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.search-item:hover,
.search-item.selected {
  background: var(--brand-soft);
  border-color: var(--hair);
  text-decoration: none;
}

.search-item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.search-item-badge {
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--brand-ink);
  border: 1px solid var(--hair);
}

.search-item-lang {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}
.search-item-lang.en { background: rgba(14, 165, 233, 0.15); color: #0284c7; }
.search-item-lang.ur { background: rgba(16, 185, 129, 0.15); color: #059669; }

.search-item-title {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
}

.search-item-snippet {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.45;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

mark.match {
  background: var(--amber-300);
  color: #111111;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 2px;
}
:root[data-theme="dark"] mark.match {
  background: var(--amber-400);
  color: #0a0810;
}

.search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 18px;
  background: var(--surface-2);
  border-top: 1px solid var(--hair);
  font-size: 12px;
  color: var(--muted);
}

.kbd-hints {
  display: flex;
  gap: 12px;
}
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Footer ---------- */
.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 30px 22px 50px;
  color: var(--muted);
  font-size: 13.5px;
  border-top: 1px solid var(--hair);
}

.footlinks {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
}
.footlinks a {
  font-weight: 650;
}

/* ---------- Responsive Breakpoints ---------- */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .side {
    display: none;
    position: fixed;
    top: 58px;
    left: 0;
    right: 0;
    bottom: 0;
    height: auto;
    background: var(--bg);
    z-index: 45;
    padding: 16px 22px 40px;
    border-top: 1px solid var(--hair);
  }
  .side.open {
    display: block;
  }
  .menu-btn {
    display: grid;
  }
  .search-trigger .search-text,
  .search-trigger kbd {
    display: none;
  }
  .search-trigger {
    padding: 0;
    width: 38px;
    justify-content: center;
  }
}

@media (max-width: 500px) {
  .site-head .bar {
    gap: 8px;
    padding: 8px 14px;
  }
  .brand small {
    display: none;
  }
  .brand .glyph {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  .lang-opt {
    padding: 4px 8px;
    font-size: 11px;
  }
  .search-footer {
    display: none;
  }
}

