:root {
  --bg: #fffaf0;
  --surface: #ffffff;
  --ink: #1f2933;
  --muted: #52606d;
  --line: #eadfca;
  --brand: #ffb703;
  --brand-ink: #7a4a00;
  --accent: #e85d04;
  --radius: 16px;
  --shadow: 0 2px 0 rgba(31, 41, 51, .06), 0 6px 18px rgba(31, 41, 51, .06);
  --font: "Noto Sans Sinhala", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Baloo 2", "Noto Sans Sinhala", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.65 var(--font); }
img { max-width: 100%; height: auto; }
a { color: #0b63b6; }
a:hover { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); line-height: 1.2; margin: 1.4em 0 .5em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin-top: .4em; }
h2 { font-size: clamp(1.35rem, 3.5vw, 1.75rem); }
h3 { font-size: 1.15rem; }
.lang-si h1, .lang-si h2, .lang-si h3 { font-family: "Noto Sans Sinhala", var(--font); font-weight: 700; }
.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 780px; }
.small { font-size: .88rem; color: var(--muted); }
.lead { font-size: 1.12rem; color: #334e68; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: #fff; padding: 8px 12px; z-index: 10; }

/* header */
/* Mobile first: logo on top, menu as a swipeable row of big buttons below it */
.site-header { background: var(--surface); border-bottom: 3px solid var(--brand); }
.bar { display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding-top: 10px; padding-bottom: 8px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font: 700 1.15rem var(--display); }
.logo-mark { width: 36px; height: 36px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .lang { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; background: var(--brand); color: #3d2600; font-weight: 700; text-decoration: none; }
.site-header nav a[aria-current] { background: var(--brand); font-weight: 700; }
.site-header nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; -webkit-overflow-scrolling: touch; }
.site-header nav::-webkit-scrollbar { display: none; }
.site-header nav a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; text-decoration: none; color: var(--ink); padding: 0 14px; border-radius: 999px; font-size: .95rem; background: #fff8e6; white-space: nowrap; }
.site-header nav a:hover { background: #fff1d0; }

/* buttons */
.btn { display: inline-block; background: var(--accent); color: #fff; text-decoration: none; padding: 12px 22px; border-radius: 999px; font-weight: 700; margin: 4px 6px 4px 0; border: 2px solid var(--accent); }
.btn:hover { color: #fff; background: #c84d00; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.big { font-size: 1.1rem; padding: 14px 28px; }
.btn.disabled { background: #d9e2ec; border-color: #d9e2ec; color: #52606d; cursor: default; margin: 0; }

/* hero */
.hero { background: linear-gradient(135deg, #fff1c1 0%, #ffe3d1 60%, #e3f2ff 100%); padding: 24px 0 20px; border-bottom: 1px solid var(--line); }
.hero h1 { max-width: 760px; }
.hero .lead { max-width: 700px; }

/* category tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 2px solid color-mix(in srgb, var(--c) 30%, white); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); position: relative; }
.tile:hover { border-color: var(--c); }
.tile-icon { display: inline-grid; place-items: center; min-width: 48px; height: 48px; padding: 0 8px; border-radius: 12px; background: color-mix(in srgb, var(--c) 14%, white); color: var(--c); font: 700 1.3rem var(--display); }
.tile-name { font-weight: 700; line-height: 1.3; }
.tile-count { position: absolute; top: 12px; right: 12px; font-size: .8rem; color: var(--muted); }
.tiles.small .tile { padding: 12px; }

/* material cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--surface); border-radius: var(--radius); border-top: 6px solid var(--c); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.card:hover { transform: translateY(-2px); }
.card-icon { font: 700 1.1rem var(--display); color: var(--c); }
.card-cat { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card-title { font-weight: 700; font-size: 1.05rem; line-height: 1.35; }
.card-meta { font-size: .88rem; color: var(--muted); }
.badge { align-self: flex-start; font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-top: auto; }
.badge.free { background: #d3f9d8; color: #1b5e20; }
.badge.soon { background: #edf2f7; color: #52606d; }
.cat-block h2 a { color: var(--ink); text-decoration: none; }
.cat-head { display: flex; align-items: flex-start; margin: 8px 0 20px; }
.cat-head h1 { margin-top: 0; }

/* material page */
.crumbs { font-size: .88rem; color: var(--muted); margin: 18px 0 6px; }
.crumbs a { color: var(--muted); }
.kicker { color: var(--c); font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: .05em; font-size: .85rem; }
.material h1 { margin-top: .2em; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0 0 12px; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.download { background: var(--surface); border: 2px dashed color-mix(in srgb, var(--c) 45%, white); border-radius: var(--radius); padding: 18px; margin: 18px 0 8px; }
.download p { margin: 8px 0 0; }
.material ul, .prose ul, .prose ol { padding-left: 1.3em; }
.material li, .prose li { margin: .3em 0; }
.table-wrap { overflow-x: auto; }
table.words { border-collapse: collapse; width: 100%; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.words th, .words td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.words th { background: #fff1d0; font-size: .9rem; }
.words .big-letter { font-size: 1.6rem; font-weight: 700; color: var(--accent); width: 70px; }

/* sections */
.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.three > div { background: var(--surface); border-radius: var(--radius); padding: 4px 18px 10px; box-shadow: var(--shadow); }
.guide-list { padding-left: 1.2em; }
.guide-list li { margin: .6em 0; }
.contact-box { background: var(--surface); padding: 16px; border-radius: var(--radius); font-size: 1.1rem; box-shadow: var(--shadow); }
.prose { padding-bottom: 20px; }

/* ads: clearly labelled, kept apart from buttons */
.ad { margin: 32px auto; max-width: 1100px; padding: 0 16px; min-height: 120px; }
.ad-label { display: block; font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.ad-preview div { display: grid; place-items: center; height: 120px; background: repeating-linear-gradient(45deg, #f0f4f8, #f0f4f8 10px, #e4e9ef 10px, #e4e9ef 20px); border-radius: 8px; color: var(--muted); font-size: .9rem; }
.narrow .ad, article .ad { padding: 0; }

/* footer */
.site-footer { margin-top: 48px; background: #243b53; color: #d9e2ec; padding: 32px 0 16px; }
.site-footer a { color: #fff; }
.site-footer .small { color: #9fb3c8; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.foot-title { font-weight: 700; color: #fff; margin-bottom: 6px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 4px 0; }
.copy { margin-top: 20px; }

.btn { min-height: 48px; }
.crumbs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-head { flex-direction: column; gap: 8px; }
form.filters { grid-template-columns: 1fr 1fr; }
.filters label:first-child { grid-column: 1 / -1; }
.download .btn.big { display: block; text-align: center; }
.tiles { grid-template-columns: repeat(2, 1fr); }
.cards { grid-template-columns: 1fr; }
.words td, .words th { padding: 8px; }

/* Bottom tab bar for phones: one thumb reaches everything */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(31, 41, 51, .08); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 600; }
.tabbar a[aria-current] { color: var(--accent); }
.tabbar a[aria-current] svg { stroke-width: 2.6; }
body { padding-bottom: 64px; }
[id] { scroll-margin-top: 12px; }

/* Larger screens */
@media (min-width: 560px) {
  .cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  form.filters { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
  .filters label:first-child { grid-column: auto; }
  .download .btn.big { display: inline-block; }
}
@media (min-width: 860px) {
  .tabbar { display: none; }
  body { padding-bottom: 0; }
  [id] { scroll-margin-top: 80px; }
  .site-header { position: sticky; top: 0; z-index: 5; }
  .top { display: contents; }
  .logo { order: 0; }
  .main-nav { order: 1; margin-left: auto !important; }
  .top .lang { order: 2; }
  .bar { flex-direction: row; align-items: center; gap: 12px; }
  .site-header nav { margin: 0; padding: 0; overflow: visible; }
  .site-header nav a { background: transparent; min-height: 40px; }
  .cat-head { flex-direction: row; gap: 16px; }
  .crumbs { white-space: normal; }
}
@media print {
  .site-header, .site-footer, .ad { display: none; }
}

/* chips, filters, cover */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem; }
.chip:hover { border-color: var(--brand); color: var(--ink); }
.chip.small { padding: 2px 10px; font-size: .82rem; font-weight: 500; }
.filters { display: grid; gap: 10px; background: var(--surface); padding: 14px; border-radius: var(--radius); box-shadow: var(--shadow); margin: 18px 0; }
.filters label { display: flex; flex-direction: column; font-size: .85rem; font-weight: 600; gap: 4px; }
.filters input, .filters select { font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; background: #fff; min-height: 44px; }
.card[hidden], .filters[hidden] { display: none; }
.no-match { font-weight: 600; }
.cover { display: block; max-width: 320px; border-radius: 12px; box-shadow: var(--shadow); margin: 12px 0; }
