:root {
  --bg: #f6f7f5; --surface: #fff; --text: #17201c; --muted: #5b6862; --line: #dde3df;
  --brand: #0f5c4d; --brand-ink: #fff; --brand-soft: #e3f1ed;
  --ok: #17703a; --ok-bg: #e2f4e8; --warn: #8a5300; --warn-bg: #fdf0d5; --mute-bg: #eceeed;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --r: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0e1512; --surface: #17201c; --text: #e8eeea; --muted: #9aa8a1; --line: #2a3631;
    --brand: #4cc2a5; --brand-ink: #06231c; --brand-soft: #173a31;
    --ok: #6fd596; --ok-bg: #153a24; --warn: #f0be63; --warn-bg: #3a2c10; --mute-bg: #25302b;
    --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #0e1512; --surface: #17201c; --text: #e8eeea; --muted: #9aa8a1; --line: #2a3631;
    --brand: #4cc2a5; --brand-ink: #06231c; --brand-soft: #173a31;
    --ok: #6fd596; --ok-bg: #153a24; --warn: #f0be63; --warn-bg: #3a2c10; --mute-bg: #25302b;
    --shadow: 0 1px 2px rgba(0,0,0,.4); }
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Tamil", "Nirmala UI", "Latha", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: calc(8px + env(safe-area-inset-top)) 16px 6px; border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1200px; margin: 0 auto 8px; }
.brand h1 { margin: 0; font-size: 1.15rem; line-height: 1.2; }
.brand p { margin: 0; font-size: .8rem; color: var(--muted); }
.langs { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); flex: none; }
.langs button { border: 0; background: none; min-width: 44px; min-height: 36px; padding: 0 10px; font-weight: 600; }
.langs button.on { background: var(--brand); color: var(--brand-ink); }
.search, .chips { max-width: 1200px; margin: 0 auto; }
.field { position: relative; }
.field input {
  width: 100%; height: 52px; padding: 0 48px 0 46px; font-size: 1rem; /* 16px: no iOS zoom */
  color: var(--text); background: var(--surface); border: 2px solid var(--line); border-radius: 14px;
  -webkit-appearance: none; appearance: none;
}
.field input:focus { border-color: var(--brand); outline: none; }
.field input::-webkit-search-cancel-button { display: none; }
.ico { position: absolute; left: 14px; top: 15px; width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.clear { position: absolute; right: 4px; top: 4px; width: 44px; height: 44px; border: 0; background: none; font-size: 1.6rem; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: .92rem; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"], .chip.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
.chip .n { background: var(--brand); color: var(--brand-ink); border-radius: 999px; min-width: 20px; height: 20px; font-size: .75rem; display: inline-grid; place-items: center; padding: 0 5px; }

/* ---------- layout ---------- */
.layout { max-width: 1200px; margin: 0 auto; padding: 12px 16px 24px; display: block; }
.banner { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; font-size: .88rem; margin-bottom: 12px; }
.head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 4px 2px 10px; color: var(--muted); font-size: .92rem; }
.head strong { color: var(--text); font-size: 1.05rem; }
.list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.list > li { min-width: 0; }

/* ---------- result card ---------- */
.card { display: flex; gap: 12px; width: 100%; min-width: 0; text-align: left; padding: 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-height: 112px; }
.card:active { transform: scale(.995); }
.card[aria-current="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.cover { flex: none; width: 64px; height: 92px; border-radius: 6px; overflow: hidden; background: var(--mute-bg);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.6rem; position: relative; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.title { font-weight: 650; font-size: 1.02rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.author { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.pill { font-size: .8rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--mute-bg); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.floor { background: var(--brand-soft); color: var(--brand); }

.more { text-align: center; padding: 14px 0; }
.more button, .primary { min-height: 48px; padding: 0 22px; border-radius: 12px; border: 1px solid var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 650; }
.primary { background: var(--brand); color: var(--brand-ink); width: 100%; margin-top: 14px; }
.empty { text-align: center; color: var(--muted); padding: 36px 8px; }
.empty h2 { color: var(--text); font-size: 1.1rem; margin: 0 0 6px; }
.suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.skel { height: 112px; border-radius: var(--r); background: linear-gradient(90deg, var(--mute-bg), var(--surface), var(--mute-bg)); background-size: 200% 100%; animation: sh 1.2s infinite linear; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } * { scroll-behavior: auto !important; transition: none !important; } }

/* ---------- detail: bottom sheet on phones/tablets ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.detail {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(0,0,0,.25); transform: translateY(105%); visibility: hidden;
  transition: transform .25s ease, visibility 0s linear .25s; margin: 0 auto; max-width: 640px; overscroll-behavior: contain;
}
.detail.open { transform: none; visibility: visible; transition: transform .25s ease; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.dclose { position: absolute; right: 8px; top: 8px; width: 44px; height: 44px; border: 0; background: none; font-size: 1.8rem; color: var(--muted); }
.d-top { display: flex; gap: 14px; padding-right: 36px; }
.d-top .cover { width: 84px; height: 120px; font-size: 2rem; }
.d-top h2 { margin: 0 0 4px; font-size: 1.2rem; line-height: 1.3; overflow-wrap: anywhere; }
.d-facts { margin: 14px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.d-facts dt { color: var(--muted); } .d-facts dd { margin: 0; overflow-wrap: anywhere; }
.d-find { margin: 14px 0; padding: 12px 14px; background: var(--brand-soft); border-radius: 12px; font-size: .95rem; }
.d-find b { font-size: 1.05rem; }
.d-find-k { display: block; font-size: .8rem; color: var(--muted); text-transform: none; }
.d-floor { display: block; font-size: 1.15rem !important; line-height: 1.4; }
.d-call { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; margin-top: 4px; line-height: 1.5; }
.nw { white-space: nowrap; }
.copies { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.copy { display: grid; gap: 4px; align-items: start; line-height: 1.5; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; font-size: .9rem; }
.copy-loc { font-weight: 600; overflow-wrap: anywhere; }
.copy-st { display: flex; }
.copy .pill { white-space: normal; }
.copy small { color: var(--muted); }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--text); display: inline-flex; align-items: center; font-weight: 600; font-size: .92rem; }
h3.sec { margin: 18px 0 0; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---------- filter sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(0,0,0,.45); }
.sheet[hidden] { display: none; }
.sheet-card { width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 18px calc(18px + env(safe-area-inset-bottom)); }
.sheet h2 { margin: 6px 0 10px; font-size: 1.15rem; }
.fgroup { margin: 14px 0; } .fgroup > b { display: block; margin-bottom: 8px; font-size: .9rem; color: var(--muted); }
.fopts { display: flex; flex-wrap: wrap; gap: 8px; }

.foot { max-width: 1200px; margin: 0 auto; padding: 8px 16px 32px; color: var(--muted); font-size: .8rem; }
.foot p { margin: 2px 0; }
.foot a { color: inherit; }

/* ---------- tablet / desktop: two-pane, detail docked on the right ---------- */
@media (min-width: 900px) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
  .list { grid-template-columns: 1fr; }
  .detail { position: sticky; top: 168px; bottom: auto; transform: none; visibility: visible; max-height: calc(100vh - 190px);
    border-radius: var(--r); border: 1px solid var(--line); box-shadow: var(--shadow); max-width: none; margin: 0; padding-top: 18px; z-index: 1; }
  .detail:not(.open) #dbody { color: var(--muted); }
  .d-empty { padding: 28px 8px; text-align: center; color: var(--muted); line-height: 1.6; }
  .grab, .dclose, .scrim { display: none !important; }
}
@media (min-width: 640px) and (max-width: 899px) {
  .list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- suggestions ---------- */
.sugg { position: absolute; left: 0; right: 0; top: 58px; z-index: 30; margin: 0; padding: 6px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  max-height: min(60vh, 380px); overflow-y: auto; overscroll-behavior: contain; }
.sugg[hidden] { display: none; }
.sg { padding: 11px 16px; min-height: 44px; display: flex; align-items: center; cursor: pointer; overflow-wrap: anywhere; }
.sg.on, .sg:hover { background: var(--brand-soft); }
.sg-head { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; padding: 10px 16px 4px; border-top: 1px solid var(--line); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }
.sg-clear { border: 0; background: none; color: var(--brand); font-weight: 600; min-height: 32px; padding: 0 4px; }

/* ---------- filters & results polish ---------- */
.chip.link { border-color: transparent; background: none; color: var(--brand); font-weight: 600; text-decoration: underline; }
.chip.dead { opacity: .45; }
.chip .ct { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .ct { color: inherit; opacity: .8; }
.btn.wide { width: 100%; justify-content: center; margin-top: 14px; }
.relaxed { flex-basis: 100%; background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 8px 12px; font-size: .88rem; margin-top: 6px; }
.head { flex-wrap: wrap; }
button.alink { border: 0; background: none; padding: 0; text-align: left; white-space: normal; text-decoration: underline dotted; text-underline-offset: 3px; color: var(--muted); }
button.alink:hover { color: var(--brand); }
.sheet-card .primary { position: sticky; bottom: 0; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet-head .chip { min-height: 36px; }

/* ---------- voice, browse, highlight ---------- */
.mic { position: absolute; right: 48px; top: 4px; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 50%; }
.mic[hidden] { display: none; }
.mic.on { color: #fff; background: #c0392b; animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(192,57,43,.25); } }
.field.has-mic input { padding-right: 92px; }
mark { background: color-mix(in srgb, var(--brand) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.browse h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 2px 10px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.tile { min-height: 56px; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); font-weight: 650; text-align: left; }
.tiles:not(.floors) .tile:first-child { grid-column: 1 / -1; background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.tile.floor { background: var(--brand-soft); color: var(--brand); box-shadow: none; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.copy-btn { margin-left: 2px; width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--brand); background: none; color: var(--brand); font-weight: 700; }
.tiles { margin-bottom: 10px; }
.tiles.floors { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.tile.floor { min-height: 44px; text-align: center; padding: 6px; font-size: .9rem; }
@media (min-width: 640px) { .tiles.floors { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.sortsel select { min-height: 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; padding: 0 10px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.totop { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 15; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 1.4rem; box-shadow: var(--shadow); }
.totop[hidden] { display: none; }
.langs button { white-space: nowrap; }

/* ---------- header FAQ icon ---------- */
.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.infobtn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--brand); display: grid; place-items: center; text-decoration: none; }

/* ---------- FAQ pages (plain HTML, no JavaScript needed) ---------- */
.docpage { background: var(--bg); }
.doc-top { max-width: 760px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px 0; display: flex; justify-content: space-between; gap: 12px; }
.doc-top a { color: var(--brand); font-weight: 600; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.doc { max-width: 760px; margin: 0 auto; padding: 8px 16px 48px; line-height: 1.6; }
.doc h1 { font-size: 1.5rem; line-height: 1.25; margin: 8px 0 10px; }
.doc h2 { font-size: 1.15rem; line-height: 1.35; margin: 0 0 6px; }
.doc section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin: 12px 0; scroll-margin-top: 12px; }
.doc section p, .doc section ul { margin: 6px 0; }
.doc a { color: var(--brand); }
.doc table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .88rem; table-layout: auto; }
.doc th, .doc td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.doc th { color: var(--muted); font-weight: 600; }
.doc th, .doc td { overflow-wrap: break-word; word-break: normal; }
.doc-intro { color: var(--muted); }
.doc-toc { padding-left: 22px; display: grid; gap: 4px; margin: 14px 0; }
.doc-meta { color: var(--muted); font-size: .85rem; }

/* ---------- book pages and card links ---------- */
a.card { text-decoration: none; color: inherit; }
.bk-head { display: flex; gap: 14px; align-items: flex-start; }
.bk-cover { border-radius: 6px; flex: none; height: auto; }
.bk-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 6px 0; }
.bk-facts dt { color: var(--muted); } .bk-facts dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- shelf strip ---------- */
.shelf { list-style: none; margin: 6px 0 0; padding: 0 0 0 14px; border-left: 3px solid var(--line); display: grid; gap: 2px; }
.shelf li > a, .shelf li.here { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: inherit; line-height: 1.5; min-height: 44px; box-sizing: border-box; }
.shelf li > a:hover { background: var(--brand-soft); }
.shelf .sh-t { overflow-wrap: anywhere; }
.shelf small { color: var(--muted); white-space: nowrap; flex: none; }
.shelf li.here { background: var(--brand-soft); border-radius: 10px; font-weight: 700; margin-left: -17px; padding-left: 24px; border-left: 3px solid var(--brand); }
.doc li small { color: var(--muted); margin-left: 6px; }

/* ---------- year range ---------- */
.yrs { display: flex; gap: 10px; }
.yrs label { flex: 1; display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
.yrs input { width: 100%; box-sizing: border-box; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text, inherit); font: inherit; font-size: 1rem; }

.sugg .sg.scope { font-weight: 600; }
.sugg .sg-scope { color: var(--brand); font-weight: 600; margin-right: 4px; }

.themebtn { cursor: pointer; font: inherit; }
.themebtn .moon { display: none; }
:root[data-eff="light"] .themebtn .moon { display: block; }
:root[data-eff="light"] .themebtn .sun { display: none; }

.d-live { margin: 4px 0 10px; font-size: .85rem; color: var(--muted); }
.d-live.fresh { color: var(--ok); }
.d-live.off { color: var(--warn); }
.fnote { display: block; margin-top: 6px; color: var(--muted); font-size: .8rem; }
.pill.pend { background: var(--mute-bg); color: var(--muted); font-weight: 500; animation: pend 1.2s ease-in-out infinite; }
@keyframes pend { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .pill.pend { animation: none; } }
.badge { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px; font-size: .7rem; font-weight: 600; letter-spacing: .02em; color: var(--brand); background: var(--brand-soft); text-decoration: none; vertical-align: 1px; }
.badge:hover, .badge:focus-visible { text-decoration: underline; }
/* narrow phones: keep the title on one line by slimming the header controls */
.brand { min-width: 0; flex: 1 1 auto; }
@media (max-width: 600px) {
  .top-inner { gap: 8px; }
  .brand h1 { font-size: 1.05rem; }
  .brand p { font-size: .75rem; line-height: 1.35; }
  .top-actions { gap: 6px; }
  .infobtn { width: 34px; height: 34px; }
  .infobtn svg { width: 19px; height: 19px; }
  .langs button { min-width: 36px; min-height: 34px; padding: 0 8px; font-size: .9rem; }
  .badge { margin-left: 0; margin-top: 2px; }
}
@media (max-width: 360px) { .brand h1 { font-size: 1rem; } .infobtn { width: 32px; height: 32px; } }
