:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --ink: #12312d;
  --muted: #5b6f6b;
  --line: #e2e9e7;
  --brand: #0f766e;
  --brand-dark: #0b4f4a;
  --accent: #0f766e;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(15, 60, 55, 0.08);
  --font: "Inter", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body[data-lang="si"] { --font: "Noto Sans Sinhala", "Inter", system-ui, sans-serif; }
body[data-lang="ta"] { --font: "Noto Sans Tamil", "Inter", system-ui, sans-serif; }
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(244, 247, 246, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 20px;
}
.topbar .title { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-switch { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; }
.lang-switch a {
  padding: 5px 9px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted);
  font-family: "Inter", "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
}
.lang-switch a.active { background: var(--brand); color: #fff; }

/* ---------- Home ---------- */
.home {
  min-height: calc(100vh - 80px);
  display: flex; flex-direction: column; justify-content: center;
  padding: 40px 20px;
  text-align: center;
}
.home .logo {
  width: 96px; height: 96px; margin: 0 auto 20px; border-radius: 28px;
  display: grid; place-items: center; font-size: 52px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  box-shadow: 0 12px 30px rgba(15, 118, 110, 0.35);
}
.home h1 { margin: 0 0 6px; font-size: clamp(26px, 7vw, 36px); line-height: 1.2; letter-spacing: -0.02em; }
.home .alt-names { margin: 0 0 6px; color: var(--brand-dark); font-weight: 600; font-family: "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif; }
.home .choose { margin: 26px 0 14px; color: var(--muted); font-size: 14px; font-family: "Inter", "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif; }
.lang-buttons { display: grid; gap: 12px; max-width: 420px; width: 100%; margin: 0 auto; }
.lang-btn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-radius: var(--radius);
  background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.lang-btn:hover, .lang-btn:focus-visible { border-color: var(--brand); transform: translateY(-2px); outline: none; }
.lang-btn .big { font-size: 22px; font-weight: 700; }
.lang-btn .small { font-size: 13px; color: var(--muted); }
.lang-btn[lang="si"] .big { font-family: "Noto Sans Sinhala", sans-serif; }
.lang-btn[lang="ta"] .big { font-family: "Noto Sans Tamil", sans-serif; }
.lang-btn .arrow { font-size: 22px; color: var(--brand); }

/* ---------- Disease list ---------- */
.page { padding: 18px 16px 28px; }
.intro {
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.intro h1 { margin: 0 0 8px; font-size: 22px; line-height: 1.3; }
.intro p { margin: 0; font-size: 14.5px; opacity: .92; }
.section-label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 22px 4px 10px; }
.disease-grid { display: grid; gap: 12px; }
@media (min-width: 620px) { .disease-grid { grid-template-columns: 1fr 1fr; } }
.disease-card {
  display: flex; gap: 14px; align-items: center;
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  transition: transform .15s;
}
.disease-card:hover { transform: translateY(-2px); }
.disease-card .icon {
  flex: none; width: 56px; height: 56px; border-radius: 16px;
  display: grid; place-items: center; font-size: 30px;
  background: color-mix(in srgb, var(--accent) 14%, white);
}
.disease-card .name { font-weight: 700; font-size: 16px; line-height: 1.3; }
.disease-card .cat { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.disease-card .sum { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.disease-card .go { margin-left: auto; color: var(--muted); font-size: 20px; }

/* ---------- Disease page ---------- */
.disease-hero { display: flex; align-items: center; gap: 14px; margin: 4px 2px 16px; }
.disease-hero .icon {
  flex: none; width: 60px; height: 60px; border-radius: 18px; font-size: 32px;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, white);
}
.disease-hero .cat { font-size: 12.5px; font-weight: 700; color: var(--accent); }
.disease-hero h1 { margin: 0; font-size: 22px; line-height: 1.25; }

.carousel { position: relative; }
.track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scroll-behavior: smooth; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; gap: 0; border-radius: var(--radius);
}
.track::-webkit-scrollbar { display: none; }
.track:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.slide {
  flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
}
.media {
  position: relative; aspect-ratio: 16 / 9;
  background:
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.35), transparent 45%),
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 85%, white), var(--accent));
  display: grid; place-items: center;
}
.media .emoji { font-size: clamp(64px, 18vw, 96px); filter: drop-shadow(0 8px 16px rgba(0,0,0,.18)); }
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.media .badge {
  position: absolute; left: 12px; top: 12px; z-index: 1;
  background: rgba(0,0,0,.45); color: #fff; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; font-family: "Inter", sans-serif;
}
.media img { background: #fff; }
.media img.contain { object-fit: contain; }
.media .credit {
  position: absolute; right: 0; bottom: 0; z-index: 1; max-width: 85%;
  background: rgba(0,0,0,.55); color: #fff; font: 10.5px/1.3 "Inter", sans-serif;
  padding: 3px 8px; border-top-left-radius: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.slide .body { padding: 18px 18px 22px; }
.slide h2 { margin: 0 0 10px; font-size: 19px; line-height: 1.3; color: var(--accent); }
.slide ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.slide li { position: relative; padding-left: 22px; font-size: 15.5px; }
.slide li::before {
  content: ""; position: absolute; left: 4px; top: .62em;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}

.controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.nav-btn {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 22px; line-height: 1;
  box-shadow: var(--shadow); display: grid; place-items: center;
}
.nav-btn:disabled { opacity: .3; cursor: default; }
.dots { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.dots button {
  width: 9px; height: 9px; padding: 0; border-radius: 999px; border: none;
  background: color-mix(in srgb, var(--accent) 25%, white); transition: width .2s, background .2s;
}
.dots button.active { width: 24px; background: var(--accent); }
.hint { text-align: center; color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

.topics { margin-top: 26px; }
.topics ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.topics button {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 11px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14.5px;
}
.topics button .n {
  flex: none; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; font-family: "Inter", sans-serif;
  background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent);
}
.topics button.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 760px; width: 100%; margin: 0 auto;
  padding: 18px 16px calc(22px + env(safe-area-inset-bottom));
  text-align: center; font-size: 12.5px; color: var(--muted);
}
.site-footer .sos {
  display: inline-block; margin-bottom: 8px; padding: 6px 14px; border-radius: 999px;
  background: #fee2e2; color: #b91c1c; font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .track { scroll-behavior: auto; }
  * { transition: none !important; }
}
