/* ==========================================================
   Calm, mobile-first stylesheet. Light + dark via [data-theme].
   ========================================================== */
:root {
  --bg: #f6f5f0;
  --surface: #ffffff;
  --surface-2: #edf1ee;
  --text: #1c2625;
  --muted: #4f5d5a;
  --primary: #1b6a64;
  --primary-hover: #15554f;
  --on-primary: #ffffff;
  --accent: #9a4a1c;
  --border: #d6ddd9;
  --focus: #c77700;
  --danger: #a8231b;
  --ok: #1d6b35;
  --shadow: 0 1px 2px rgba(20, 30, 28, .05), 0 6px 20px rgba(20, 30, 28, .06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Noto Sans Bengali", "Hind Siliguri", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Hind Siliguri", "Noto Sans Bengali", system-ui, sans-serif;
  --maxw: 1120px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #111614;
  --surface: #19201e;
  --surface-2: #222b28;
  --text: #e4ebe8;
  --muted: #a4b2ae;
  --primary: #70c4bb;
  --primary-hover: #8fd3cb;
  --on-primary: #0b1715;
  --accent: #f0a56f;
  --border: #303b38;
  --focus: #ffc266;
  --danger: #ff8f86;
  --ok: #7fd49a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 1.0625rem; line-height: 1.75;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
h1, h2, h3 { font-family: var(--font-head); line-height: 1.35; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.65rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: .5rem; background: var(--primary); color: var(--on-primary); padding: .5rem 1rem; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: .5rem; }
.section { padding: 2rem 0; }
.page-head { padding-top: 2rem; padding-bottom: 1rem; }
.page-head p { color: var(--muted); max-width: 60ch; }

/* ── Header ─────────────────────────────── */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; min-height: 60px; }
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; margin-right: auto; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: var(--on-primary); font-size: 1.2rem; }
.header-actions { display: flex; align-items: center; gap: .35rem; }
.icon-btn, .lang-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; cursor: pointer; font: inherit; }
.lang-btn { padding: 0 .9rem; font-size: .95rem; }
.icon-btn:hover, .lang-btn:hover { border-color: var(--primary); }
.site-nav { width: 100%; display: none; }
.site-nav.open { display: block; }
.site-nav ul { list-style: none; margin: 0; padding: .25rem 0 .75rem; display: grid; gap: .15rem; }
.site-nav a { display: block; padding: .6rem .75rem; border-radius: var(--radius-sm); text-decoration: none; color: var(--text); }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] { background: var(--surface-2); color: var(--primary); font-weight: 600; }
@media (min-width: 960px) {
  .menu-btn { display: none; }
  .site-nav { display: block; width: auto; order: 2; }
  .header-actions { order: 3; }
  .site-nav ul { display: flex; padding: 0; gap: .1rem; }
  .site-nav a { padding: .45rem .65rem; font-size: .97rem; }
}
.offline-bar { background: var(--accent); color: #fff; text-align: center; padding: .5rem 1rem; font-size: .95rem; }
[data-theme="dark"] .offline-bar { color: #1a0f07; }

/* ── Buttons & forms ────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1.15rem; border-radius: 999px; border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-outline { background: transparent; color: var(--primary); }
.btn-outline:hover { background: var(--surface-2); color: var(--primary); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
[data-theme="dark"] .btn-danger { color: #210403; }
.btn-small { min-height: 38px; padding: .3rem .85rem; font-size: .93rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
legend { font-weight: 600; padding: 0; margin-bottom: .35rem; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; }
.check input { width: 20px; height: 20px; margin-top: .3rem; flex: 0 0 auto; accent-color: var(--primary); }
label { display: block; font-weight: 600; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { font-size: .88rem; color: var(--muted); margin-top: .25rem; }
input[type="text"], input[type="search"], input[type="email"], input[type="number"], input[type="password"], input[type="url"], select, textarea {
  width: 100%; min-height: 46px; padding: .55rem .8rem; font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
}
input[type="file"] { font: inherit; max-width: 100%; }
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.row { display: grid; gap: 1rem; }
@media (min-width: 640px) { .row-2 { grid-template-columns: 1fr 1fr; } .row-3 { grid-template-columns: repeat(3, 1fr); } }

.segmented { display: inline-flex; border: 1.5px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { margin: 0; padding: .3rem .85rem; border-radius: 999px; font-weight: 500; cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; }
.segmented input:checked + label { background: var(--primary); color: var(--on-primary); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); }

/* ── Cards & grids ──────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
@media (min-width: 600px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.chip { display: inline-flex; align-items: center; min-height: 38px; padding: .25rem .9rem; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.badge { display: inline-block; font-size: .8rem; padding: .1rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.notice { border-left: 4px solid var(--primary); background: var(--surface-2); padding: .9rem 1rem; border-radius: var(--radius-sm); }
.notice p:last-child { margin-bottom: 0; }
.notice-error { border-color: var(--danger); }
.notice-warn { border-color: var(--accent); }

/* ── Hero ───────────────────────────────── */
.hero { padding: 3rem 0 2rem; background:
  radial-gradient(1200px 400px at 10% -10%, color-mix(in srgb, var(--primary) 16%, transparent), transparent),
  radial-gradient(800px 300px at 100% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent); }
.hero h1 { font-size: clamp(2rem, 7vw, 3.3rem); margin-bottom: .3em; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 46ch; }
.tool-card { display: flex; flex-direction: column; gap: .4rem; text-decoration: none; color: var(--text); }
.tool-card:hover { border-color: var(--primary); color: var(--text); }
.tool-icon { font-size: 1.8rem; line-height: 1; }
.feature { display: grid; gap: 1rem; }
@media (min-width: 560px) { .feature { grid-template-columns: 140px 1fr; } }

/* ── Books ──────────────────────────────── */
.toolbar { display: grid; gap: .75rem; margin-bottom: 1.25rem; }
@media (min-width: 700px) { .toolbar { grid-template-columns: 2fr 1fr; align-items: end; } }
.book-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
@media (min-width: 700px) { .book-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }
.book { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.book-body { padding: .85rem; display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.book h3 { font-size: 1.05rem; margin: 0; }
.book .author { color: var(--muted); font-size: .93rem; margin: 0; }
.book .btn-row { margin-top: auto; padding-top: .4rem; gap: .4rem; }
.book .btn { flex: 1 1 auto; }
.cover { aspect-ratio: 3 / 4; width: 100%; object-fit: cover; background: var(--surface-2); }
.cover-fallback { aspect-ratio: 3 / 4; display: flex; flex-direction: column; justify-content: flex-end; padding: 1rem; color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; line-height: 1.3; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.cover-fallback small { font-weight: 500; font-size: .85rem; opacity: .95; }

/* ── Reader ─────────────────────────────── */
.reader-bar { position: sticky; top: 60px; z-index: 20; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.reader-bar .title { font-weight: 700; margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-stage { margin: 1rem auto 2rem; }
.epub-view { height: calc(100vh - 200px); min-height: 420px; background: #fffdf8; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.reader-night .epub-view { background: #141414; }
.pdf-pages { display: grid; gap: 1rem; justify-items: center; }
.pdf-pages canvas { max-width: 100%; height: auto !important; box-shadow: var(--shadow); background: #fff; }
.reader-night .pdf-pages canvas { filter: invert(.92) hue-rotate(180deg); }
.size-label { min-width: 3.5em; text-align: center; font-variant-numeric: tabular-nums; }

/* ── Health ─────────────────────────────── */
.tip { scroll-margin-top: 80px; }
.tip h3 { margin-top: .4rem; }
.tip-body p { margin-bottom: .7em; }
.tip.highlight { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent); }
.tod { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 14%, var(--surface)), var(--surface)); }

/* ── BMI ────────────────────────────────── */
.bmi-value { font-size: clamp(2.6rem, 10vw, 3.6rem); font-weight: 700; font-family: var(--font-head); line-height: 1.1; }
.scale { position: relative; margin: 1.75rem 0 .5rem; }
.scale-bar { display: flex; height: 16px; border-radius: 999px; overflow: hidden; }
.scale-bar span { display: block; height: 100%; }
.scale-marker { position: absolute; top: -10px; width: 4px; height: 36px; margin-left: -2px; background: var(--text); border-radius: 2px; transition: left .4s ease; }
.scale-labels { display: grid; grid-template-columns: 21.67fr 21.67fr 16.66fr 40fr; gap: .25rem; font-size: .78rem; line-height: 1.35; color: var(--muted); margin-top: .5rem; }
.cat-pill { display: inline-block; padding: .2rem .8rem; border-radius: 999px; font-weight: 700; }

/* ── Search / autocomplete ──────────────── */
.search-wrap { position: relative; }
.search-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.search-row .search-wrap { flex: 1 1 260px; }
.suggestions { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; margin: 0; padding: .3rem; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 320px; overflow-y: auto; }
.suggestions li { padding: .55rem .7rem; border-radius: 7px; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--surface-2); }
.suggestions .sub { display: block; font-size: .85rem; color: var(--muted); }

/* ── Weather ────────────────────────────── */
.wx-now { display: grid; gap: 1rem; }
@media (min-width: 760px) { .wx-now { grid-template-columns: 1.1fr 1fr; } }
.wx-temp { font-size: clamp(3rem, 12vw, 4.5rem); font-weight: 700; line-height: 1; font-family: var(--font-head); }
.wx-icon { font-size: 3rem; line-height: 1; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 480px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: .6rem .75rem; }
.stat .k { font-size: .85rem; color: var(--muted); display: block; }
.stat .v { font-weight: 700; font-size: 1.1rem; }
.forecast { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.forecast li { display: grid; grid-template-columns: 4.5em 2em 1fr auto; gap: .6rem; align-items: center; padding: .5rem .25rem; border-bottom: 1px solid var(--border); }
.forecast li:last-child { border-bottom: 0; }
.forecast .range { display: flex; align-items: center; gap: .5rem; font-variant-numeric: tabular-nums; }
.forecast .bar { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); position: relative; min-width: 40px; }
.forecast .bar i { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, #5aa9e6, #f2a541); }
.forecast .rain { font-size: .85rem; color: var(--muted); }
.chart-wrap { overflow-x: auto; }
.chart-wrap svg { display: block; min-width: 640px; width: 100%; height: auto; }
.chart-wrap text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.unit-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* ── AQI ────────────────────────────────── */
.aqi-hero { display: grid; gap: 1rem; align-items: center; }
@media (min-width: 700px) { .aqi-hero { grid-template-columns: auto 1fr; } }
.aqi-badge { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; text-align: center; font-family: var(--font-head); margin-inline: auto; }
.aqi-badge b { display: block; font-size: 2.6rem; line-height: 1; }
.aqi-badge span { font-size: .85rem; font-weight: 600; }
.pollutants { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
@media (min-width: 700px) { .pollutants { grid-template-columns: repeat(3, 1fr); } }
.aqi-legend { display: grid; gap: .35rem; list-style: none; padding: 0; margin: 0; }
.aqi-legend li { display: flex; gap: .6rem; align-items: flex-start; font-size: .93rem; }
.swatch { flex: 0 0 auto; display: inline-block; min-width: 4.2rem; text-align: center; border-radius: 6px; padding: 0 .3rem; font-weight: 700; font-size: .85rem; }
.rank-list { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rank-list li { display: flex; align-items: center; gap: .6rem; padding: .45rem 0; border-bottom: 1px solid var(--border); counter-increment: r; }
.rank-list li::before { content: counter(r); width: 1.6em; color: var(--muted); font-variant-numeric: tabular-nums; }
.rank-list .name { flex: 1; }

/* ── Footer ─────────────────────────────── */
.site-footer { margin-top: 3rem; border-top: 1px solid var(--border); background: var(--surface); padding: 2rem 0 1rem; }
.footer-grid { display: grid; gap: 1.5rem; }
@media (min-width: 760px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }
.footer-brand { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; margin: 0 0 .3rem; }
.footer-h { font-size: 1rem; margin-bottom: .5rem; }
.footer-links { list-style: none; padding: 0; margin: 0; display: grid; gap: .2rem; }
.footer-links a { color: var(--text); text-decoration: none; display: inline-block; padding: .15rem 0; }
.footer-links a:hover { color: var(--primary); text-decoration: underline; }
.footer-disclaimer { padding: .6rem .8rem; background: var(--surface-2); border-radius: var(--radius-sm); font-size: .95rem; }
.footer-bottom { border-top: 1px solid var(--border); margin-top: 1.5rem; padding-top: 1rem; }

/* ── Cookie, toast, dialogs ─────────────── */
.cookie { position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 60; max-width: 560px; margin-inline: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.cookie p { margin-bottom: .6rem; font-size: .95rem; }
.cookie-actions { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; }
.toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translate(-50%, 150%); background: var(--text); color: var(--bg); padding: .6rem 1.1rem; border-radius: 999px; z-index: 70; transition: transform .25s ease; max-width: 90vw; }
.toast.show { transform: translate(-50%, 0); }
dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 0; width: min(720px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dialog-body { padding: 1.25rem; }

/* ── Admin ──────────────────────────────── */
.admin-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.admin-table th, .admin-table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table th { font-size: .85rem; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.tabs { display: flex; gap: .4rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs button { border: 0; background: none; font: inherit; padding: .6rem 1rem; cursor: pointer; color: var(--muted); border-bottom: 3px solid transparent; min-height: 44px; }
.tabs button[aria-selected="true"] { color: var(--primary); border-color: var(--primary); font-weight: 700; }

/* ── Prose pages (privacy, terms) ───────── */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 1.6em; }
html[lang="bn"] [data-lang-block="en"], html[lang="en"] [data-lang-block="bn"] { display: none; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--radius-sm); min-height: 1.2em; }
@keyframes sk { to { background-position: -200% 0; } }
