:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #14202e;
  --muted: #5d6b7c;
  --line: #e1e6ee;
  --hero: #0f1b2d;
  --hero-text: #f5f7fb;
  --accent: #f5b301;
  --accent-ink: #1b1400;
  --warn-bg: #fff4d6;
  --warn-line: #f0c75e;
  --ok-bg: #e5f6ec;
  --ok-line: #8fd1a8;
  --hit: #ffe08a;
  --today: #d93a3a;
  --tmrw: #e07b00;
  --wa: #1f9e55;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b131f;
    --surface: #131e2d;
    --text: #e8edf4;
    --muted: #93a1b3;
    --line: #233247;
    --hero: #070d16;
    --warn-bg: #3a2d08;
    --warn-line: #7a5d12;
    --ok-bg: #0f2e1d;
    --ok-line: #2c6b45;
    --hit: #6b5310;
  }
}
:root[data-theme="dark"] {
  --bg: #0b131f; --surface: #131e2d; --text: #e8edf4; --muted: #93a1b3; --line: #233247;
  --hero: #070d16; --warn-bg: #3a2d08; --warn-line: #7a5d12; --ok-bg: #0f2e1d; --ok-line: #2c6b45; --hit: #6b5310;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Tamil", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
}
a { color: inherit; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* hero */
.hero { background: var(--hero); color: var(--hero-text); padding: 28px 0 18px; }
.hero h1 { margin: 0; font-size: clamp(1.7rem, 6vw, 2.3rem); font-weight: 800; letter-spacing: -.01em; }
.bolt { color: var(--accent); }
.tag { margin: 4px 0 16px; opacity: .85; }

/* app bar (public page) */
.appbar { padding: 20px 0 16px; }
.appbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; text-decoration: none; }
.appbar .brand-name { margin: 0; font-size: clamp(1.4rem, 5vw, 2rem); line-height: 1.15; font-weight: 800; }

/* server-rendered lists, town pages */
.ssr-day { font-size: 1.05rem; margin: 18px 0 8px; }
.ssr-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ssr-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.ssr-list a { text-decoration: none; }
.town-index { margin-top: 26px; }
.chip-links { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-links a { text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: .9rem; }
.chip-links a:hover { border-color: var(--accent); }
.chip-links b { background: var(--tmrw); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .78rem; margin-left: 2px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; margin-bottom: 12px; }
.sec-head .view-title, .sec-head p { margin: 0; }
.num, .dist-links b { display: inline-block; min-width: 26px; background: var(--tmrw); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: .78rem; font-weight: 700; text-align: center; }
.dist-links { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 8px; }
.dist-links a { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-decoration: none; font-weight: 700; line-height: 1.35; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.dist-links a:hover { border-color: var(--accent); }
.dist-links span { min-width: 0; overflow-wrap: anywhere; }
.dist-links small { display: block; font-size: .8rem; font-weight: 400; }
.town-group, .en-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.town-group h3, .en-day h3 { margin: 0 0 10px; font-size: 1rem; }
.town-group h3 .muted, .en-day h3 .muted { font-weight: 400; font-size: .85rem; }
.town-groups { display: grid; gap: 12px; }
.town-group .chip-links, .en-day .chip-links { gap: 6px; }
.town-group .chip-links a, .en-day .chip-links a { background: var(--bg); padding: 3px 10px; font-size: .84rem; }
.town-group .chip-links b, .num.soft { background: var(--warn-bg); color: var(--text); }
.town-group .chip-links b { padding: 0 6px; }
.en-days { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; margin-bottom: 12px; }
.en-day { flex: 1 1 280px; border-top: 4px solid var(--today); }
.en-day.tomorrow { border-top-color: var(--tmrw); }
.en-day.many { flex-grow: 2.2; }
.en-day p { margin: 0 0 10px; }
.en-day .more { align-self: center; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 2px 0 6px; }
.crumbs a { color: var(--muted); }
.page-title { font-size: clamp(1.4rem, 5vw, 1.9rem); margin: 0 0 14px; line-height: 1.25; }
.page-title .muted { display: block; font-weight: 400; font-size: .6em; }
.day-status { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.day-status > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.day-status > .has { border-color: var(--tmrw); }
a.btn-app { display: inline-block; text-decoration: none; margin: 6px 0 14px; }
.brand-icon { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.appbar h1 { font-size: clamp(1.4rem, 5vw, 2rem); line-height: 1.15; }
.appbar .tag { margin: 2px 0 0; font-size: .92rem; }
.by { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--hero-text); opacity: .9; flex: 0 0 auto; }
.by span { font-size: .72rem; line-height: 1.1; text-align: right; max-width: 70px; opacity: .8; }
.by img, .presented img { background: #fff; border-radius: 50%; padding: 3px; }
.by img { width: 40px; height: 40px; }
.by:hover { opacity: 1; }

.search { position: relative; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 1rem; opacity: .55; pointer-events: none; }
.search input {
  width: 100%; font: inherit; font-size: 1.05rem;
  padding: 14px 44px 14px 42px; border-radius: var(--radius);
  border: 2px solid transparent; background: #fff; color: #14202e; outline: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.18);
}
.search input::-webkit-search-cancel-button { display: none; }
.search input:focus { border-color: var(--accent); }
.search .ghost {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; font-size: 1.1rem; padding: 8px 10px; cursor: pointer; color: #5d6b7c;
}

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-flex; align-items: center; border-radius: 999px; background: rgba(255,255,255,.12); color: var(--hero-text); font-size: .9rem; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 6px 4px 6px 12px; }
.chip .chip-x { padding: 6px 12px 6px 6px; opacity: .7; }
.chip.save { padding: 6px 12px; border: 1px dashed rgba(255,255,255,.45); background: transparent; }

main.wrap { padding-top: 18px; padding-bottom: 8px; min-height: 40vh; }

/* banners */
.banner { border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; border: 1px solid; }
.banner p { margin: 4px 0 0; }
.banner.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.banner.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.banner.info { background: var(--surface); border-color: var(--line); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.when { font-weight: 800; font-size: .85rem; padding: 2px 10px; border-radius: 999px; background: var(--line); }
.when.today { background: var(--today); color: #fff; }
.when.tmrw { background: var(--tmrw); color: #fff; }
.date { color: var(--muted); font-size: .9rem; }
.time { font-size: 1.15rem; font-weight: 700; margin: 8px 0 2px; }
.town { margin: 0 0 8px; }
.areas { display: flex; flex-wrap: wrap; gap: 6px; }
.area { font-size: .88rem; padding: 2px 9px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); }
.area.hit { background: var(--hit); border-color: var(--warn-line); font-weight: 700; }
.cut-note { font-size: .88rem; line-height: 1.6; margin: 10px 0 0; padding: 9px 12px; border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-line); }
.cut-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cut-chip { font: inherit; color: inherit; min-height: 40px; padding: 6px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.work { font-size: .85rem; margin: 10px 0 0; overflow-wrap: anywhere; }
.actions { margin-top: 10px; }
.btn { display: inline-block; text-decoration: none; font-weight: 600; font-size: .9rem; padding: 8px 14px; border-radius: 10px; }
.btn.wa { background: var(--wa); color: #fff; }

/* browse */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
.tab { font: inherit; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 14px; padding: 6px 14px; cursor: pointer; white-space: nowrap; display: flex; flex-direction: column; align-items: center; line-height: 1.25; flex: 0 0 auto; }
.tab-count { font-weight: 400; opacity: .75; }
.tab-date { font-size: .78rem; font-weight: 400; opacity: .8; }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* views: on desktop "home" + "about" (as footer); on phone one at a time */
.view-saved { display: none; }
.view-about { font-size: .9rem; margin-top: 28px; padding-bottom: 28px; }
.about-grid { display: grid; gap: 12px; }
.about-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.about-box h3 { margin: 0 0 8px; font-size: 1.05rem; }
.about-box p { margin: 0 0 12px; }
.about-box > :last-child { margin-bottom: 0; }
.view-title { font-size: 1.2rem; margin: 4px 0 14px; }
.mobile-only { display: none; }
.small { font-size: .85rem; }
.presented { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.presented img { width: 64px; height: 64px; flex: 0 0 auto; box-shadow: 0 0 0 1px var(--line); }
.presented strong { font-size: 1.15rem; display: block; }
.presented a { text-decoration: none; }
.about-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.btn-app { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer; background: var(--accent); color: var(--accent-ink); }
.btn-app.ghost-btn { background: var(--surface); color: var(--text); border: 1px solid var(--line); }

/* saved areas list */
.saved-card { font: inherit; width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; }
.saved-card.has-cut { border-left: 5px solid var(--tmrw); }
.saved-card.no-cut { border-left: 5px solid var(--line); }
.saved-ico { font-size: 1.4rem; }
.saved-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.saved-body strong { font-size: 1.05rem; }
.saved-body .muted { font-size: .88rem; }
.saved-go { font-size: 1.6rem; color: var(--muted); }
.empty { text-align: center; padding: 28px 12px; }
.empty-ico { font-size: 2.4rem; margin: 0; }

/* map */
body.searching .view-map { display: none !important; }
:root { --m-now: #d92d20; --m-later: #e07b00; --m-done: #7c8796; --m-cut: #ffe3b8; --m-clear: #ffffff; --m-none: #eceff4; --m-none-line: #d3d9e3; --m-edge: #b4bfce; --m-sea: #e2edf8; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --m-now: #ff5c4d; --m-later: #f59a23; --m-done: #8794a6; --m-cut: #4a3510; --m-clear: #1b2940; --m-none: #0f1826; --m-none-line: #1e2b3e; --m-edge: #3b4d67; --m-sea: #0a1322; }
}
.day-bar { display: flex; align-items: stretch; gap: 8px; margin-bottom: 6px; }
.day-bar .tabs { flex: 1; min-width: 0; margin: 0; padding: 0 0 4px; scrollbar-width: none; }
.day-bar .tabs::-webkit-scrollbar { display: none; }
.cal-btn { font: inherit; font-size: .74rem; font-weight: 700; line-height: 1.1; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 52px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); cursor: pointer; }
.cal-btn:hover { border-color: var(--accent); }
/* arrows for the mouse; a finger just swipes the row */
.day-go { display: none; }
@media (hover: hover) and (pointer: fine), (min-width: 960px) {
  .day-go:not([hidden]) { font: inherit; font-size: 1.6rem; line-height: 1; flex: 0 0 auto; display: block; width: 40px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); cursor: pointer; }
  .day-go:hover:not(:disabled) { border-color: var(--accent); }
  .day-go:disabled { opacity: .35; cursor: default; }
}
.saved-strip { font: inherit; font-size: .9rem; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn-line); border-radius: 12px; padding: 7px 12px; margin-bottom: 8px; cursor: pointer; }
.saved-strip[hidden] { display: none; }
.saved-strip .saved-go { font-size: 1.3rem; line-height: 1; }
.cal { border: 0; border-radius: 18px; padding: 16px; width: min(380px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.cal::backdrop { background: rgba(7,13,22,.55); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 1.1rem; }
.cal-head button { font: inherit; font-size: 1.5rem; line-height: 1; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; }
.cal-head button:disabled { opacity: .3; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-w { text-align: center; font-size: .78rem; color: var(--muted); padding-bottom: 2px; }
.cal-d { font: inherit; min-height: 50px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; gap: 1px; line-height: 1.3; border: 1px solid transparent; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.cal-d.has { background: var(--m-cut); color: var(--text); font-weight: 700; }
.cal-d.today { border-color: var(--text); }
.cal-d.on { outline: 3px solid var(--m-later); outline-offset: -1px; color: var(--text); }
.cal-d:disabled { opacity: .35; cursor: default; }
.cal-n { display: inline-block; min-width: 20px; padding: 0 5px; border-radius: 999px; background: var(--today); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; }
.cal p { margin: 10px 0; }
.cal-close { font: inherit; font-weight: 700; width: 100%; padding: 11px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); cursor: pointer; }
.map-none { font-size: 1rem !important; }
.map-panel, .map-box svg { scroll-margin: 170px 0 90px; }
@media (max-width: 720px) { .view-map { scroll-margin-top: 170px; } }
.map-count, .map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 10px; }
.map-count b { font-size: 1.2rem; }
.map-legend { font-size: .82rem; color: var(--muted); }
.map-key { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; }
.sw.now { background: var(--m-now); box-shadow: 0 0 0 3px color-mix(in srgb, var(--m-now) 30%, transparent); }
.sw.later { background: var(--m-later); }
.sw.done { background: var(--m-done); }
.sw.area-cut, .sw.area-clear, .sw.area-none { border-radius: 3px; border: 1px solid var(--m-edge); }
.sw.area-cut { background: var(--m-cut); }
.sw.area-clear { background: var(--m-clear); }
.sw.area-none { background: repeating-linear-gradient(45deg, var(--m-none) 0 3px, var(--m-none-line) 3px 4px); }
.map-box { position: relative; max-width: 560px; margin: 0 auto; }
.map-box svg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-tap-highlight-color: transparent; }
.dist { stroke: var(--m-edge); stroke-width: 1px; vector-effect: non-scaling-stroke; }
.dist.cut { fill: var(--m-cut); }
.dist.clear { fill: var(--m-clear); }
.dist.none { fill: url(#noinfo); }
.dist.on { stroke: var(--text); stroke-width: 1.5px; }
.map-noinfo-bg { fill: var(--m-none); }
.map-noinfo-line { fill: var(--m-none-line); }
.map-label { fill: var(--text); stroke: var(--bg); paint-order: stroke; stroke-linejoin: round; font-weight: 600; pointer-events: none; }
.map-lead { stroke: var(--muted); stroke-width: 1px; vector-effect: non-scaling-stroke; pointer-events: none; }
.spot { pointer-events: none; }
.dot-c { stroke: var(--surface); }
.spot.now .dot-c, .pulse { fill: var(--m-now); }
.spot.later .dot-c { fill: var(--m-later); }
.spot.done .dot-c { fill: var(--m-done); }
.spot.on .dot-c { stroke: var(--text); }
.dot-n { fill: #fff; font-weight: 800; }
.pulse { opacity: .5; transform-box: fill-box; transform-origin: center; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { to { transform: scale(2.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; transform: scale(1.7); opacity: .3; } }
.map-back { position: absolute; left: 0; top: 0; font: inherit; font-size: .88rem; font-weight: 700; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.map-box svg.zoomed { touch-action: none; cursor: grab; border-radius: 12px; box-shadow: 0 0 0 1px var(--line); }
.map-zoom { position: absolute; right: 0; bottom: 8px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,.14); }
.map-zoom[hidden] { display: none; }
.map-zoom button { font: inherit; font-size: 1.6rem; font-weight: 700; line-height: 1; width: 46px; height: 46px; border: 0; background: none; color: var(--text); cursor: pointer; touch-action: manipulation; }
.map-zoom button + button { border-top: 1px solid var(--line); }
.map-zoom button:disabled { color: var(--muted); opacity: .4; cursor: default; }
.map-tip { position: absolute; z-index: 5; max-width: 240px; white-space: pre-line; pointer-events: none; background: var(--hero); color: var(--hero-text); font-size: .82rem; line-height: 1.4; border-radius: 10px; padding: 7px 10px; }
.map-list-title { font-size: 1rem; margin: 14px 0 8px; }
.map-row { font: inherit; width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; margin-bottom: 6px; cursor: pointer; }
.map-row:hover { border-color: var(--accent); }
.map-row-t { min-width: 0; font-size: .92rem; }
.map-row-time, .map-row-areas { display: block; font-size: .84rem; }
.map-row-areas { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-row-t { flex: 1; }
@media (min-width: 721px) {
  main.wrap { display: flex; flex-direction: column; }
  .view-map { margin-bottom: 26px; }
  .map-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .map-list > h3, .map-list > p { grid-column: 1 / -1; margin-bottom: 2px; }
  .map-row { margin: 0; }
}

/* computer: "about" is a dark footer over the full width of the window */
@media (min-width: 721px) {
  main.wrap { padding-bottom: 0; }
  .town-index { margin-top: 40px; }
  .sec-head .view-title { font-size: 1.35rem; }
  .dist-links { grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 10px; }
  .dist-links a { padding: 12px 14px; }
  .view-about { --muted: #a9b6c7; background: var(--hero); color: var(--hero-text); margin-top: 48px; padding: 36px 0 40px; box-shadow: 0 0 0 100vmax var(--hero); clip-path: inset(0 -100vmax); }
  .about-grid { grid-template-columns: 1fr 1.5fr; gap: 26px 40px; }
  .about-box:last-child { grid-column: 1 / -1; }
  .about-box { background: none; border: 0; border-radius: 0; padding: 0; }
  .about-box h3 { color: var(--accent); }
  .about-box p { opacity: .92; }
  .about-box .chip-links a, .view-about .ghost-btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: inherit; }
  .about-box .chip-links a:hover, .view-about .ghost-btn:hover { border-color: var(--accent); }
  .presented img { box-shadow: none; }
}
/* home: three footer columns; town cards of different height fill their columns */
@media (min-width: 960px) {
  body:not(.town-page) .about-grid { grid-template-columns: 1fr 1.5fr 1.2fr; gap: 48px; }
  body:not(.town-page) .about-box:last-child { grid-column: auto; }
  body:not(.town-page) .town-groups { display: block; columns: 300px; column-gap: 12px; }
  body:not(.town-page) .town-group { break-inside: avoid; margin-bottom: 12px; }
}

/* wide screens: map on the left, the day's details on the right */
@media (min-width: 960px) {
  body:not(.town-page):not(.admin) .wrap { max-width: 2200px; padding: 0 28px; }
  .view-map { --mh: min(clamp(620px, calc(100vh - 120px), 1000px), 70vw); display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); column-gap: 24px; }
  .view-map > * { grid-column: 1 / -1; min-width: 0; }
  .view-map > .map-box { grid-column: 1; grid-row: 5; width: 100%; max-width: none; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--m-sea); }
  .map-box svg, .map-box svg.zoomed { height: var(--mh); border-radius: 0; box-shadow: none; }
  .map-back { left: 12px; top: 12px; }
  .map-zoom { right: 12px; bottom: 12px; }
  /* the legend sits on the sea, next to the zoom buttons */
  .view-map > .map-legend { grid-column: 1; grid-row: 5; align-self: end; justify-self: end; flex-direction: column; margin: 0 72px 13px 0; padding: 9px 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; pointer-events: none; position: relative; z-index: 1; }
  .view-map > .map-side { grid-column: 2; grid-row: 5; max-height: calc(var(--mh) + 2px); overflow-y: auto; padding-right: 6px; scrollbar-width: thin; }
  .view-map > .map-note { grid-row: 6; margin: 10px 0 0; }
  .view-map > .view-title { margin-top: 18px; }
  .map-list { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
  .map-list-title { margin-top: 0; }
  #results { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 12px; align-items: start; }
  #results .card { margin: 0; }
}
/* both sides stay free for a 160px wide ad (300px on very wide screens) */
@media (min-width: 1280px) {
  body:not(.town-page):not(.admin) .wrap { max-width: min(1720px, calc(100% - 2 * 192px)); padding: 0; }
}

/* bottom navigation (phone only) */
.bottomnav { display: none; }

@media (max-width: 720px) {
  body { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .appbar { position: sticky; top: 0; z-index: 20; padding: calc(10px + env(safe-area-inset-top)) 0 12px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
  .appbar-row { margin-bottom: 10px; }
  .brand { gap: 10px; }
  .brand-icon { width: 40px; height: 40px; }
  .brand > div { min-width: 0; }
  .appbar h1 { font-size: 1.15rem; white-space: nowrap; }
  .appbar .tag { font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .by span { font-size: .62rem; max-width: 52px; }
  .by img { width: 34px; height: 34px; }
  .search input { padding-top: 12px; padding-bottom: 12px; font-size: 1rem; box-shadow: none; }
  .chips { margin-top: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }

  main.wrap { padding-top: 12px; min-height: 60vh; }
  .view { display: none; }
  body[data-view="home"] .view-home,
  body[data-view="home"] .view-map,
  body[data-view="saved"] .view-saved,
  body[data-view="about"] .view-about { display: block; }
  /* the number sits next to the English name, so the Tamil name keeps the full width */
  .dist-links a { position: relative; padding: 9px 10px; font-size: .88rem; }
  .dist-links b { position: absolute; right: 10px; bottom: 9px; }
  .view-about { margin-top: 0; font-size: .95rem; }
  .mobile-only { display: block; }
  /* keep the first screen for the map */
  body:not([data-view="home"]) #stale { display: none; }
  body:not(.searching):not(.town-page) .chips { display: none; }
  .view-map > .view-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .view-map .map-count { margin: 2px 0 4px; gap: 2px 12px; font-size: .85rem; }
  .view-map .map-count b { font-size: 1.05rem; }
  .view-map .map-legend { gap: 4px 14px; font-size: .8rem; white-space: nowrap; margin: 4px 0 10px; }
  .view-map .map-legend .map-key { gap: 4px; }
  .cal { margin-bottom: 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

  .tabs { margin: 0 -16px 10px; padding: 2px 16px 6px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .card { border-radius: 18px; box-shadow: 0 2px 10px rgba(15,27,45,.06); }
  .btn.wa { display: block; text-align: center; padding: 11px 14px; border-radius: 12px; }

  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  }
  .bottomnav button, .bottomnav a {
    text-decoration: none;
    flex: 1; font: inherit; font-size: .78rem; background: none; border: 0; color: var(--muted);
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 10px; cursor: pointer;
  }
  .bottomnav .nav-ico { position: relative; font-size: 1.3rem; line-height: 1; filter: grayscale(1); opacity: .7; }
  .bottomnav button.on { color: var(--text); font-weight: 700; }
  .town-page .view-about { display: block; margin-top: 24px; }
  .appbar .brand-name { font-size: 1.15rem; white-space: nowrap; }
  .bottomnav button.on .nav-ico { filter: none; opacity: 1; }
  .dot { position: absolute; top: -2px; right: -6px; width: 9px; height: 9px; border-radius: 50%; background: var(--today); border: 2px solid var(--surface); }
}

.foot { padding-top: 16px; padding-bottom: 32px; font-size: .85rem; border-top: 1px solid var(--line); margin-top: 16px; }
.foot p { margin: 6px 0; }

/* admin */
.admin input[type=password], .admin input[type=text] { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); width: 100%; background: var(--surface); color: var(--text); }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: .92rem; }
.admin-nav a { color: var(--hero-text); }
.muted-light { opacity: .75; }
.admin form.inline { display: inline; margin: 0; }
.admin button.link-btn { background: none; border: 0; padding: 0; color: var(--hero-text); text-decoration: underline; font-weight: 400; }
.form-card { max-width: 420px; margin: 24px auto; display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.form-card label { font-weight: 600; margin-top: 8px; }
.form-card button { margin-top: 14px; }
.admin code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.stat b { font-size: 1.25rem; }
.stat span { color: var(--muted); font-size: .85rem; }
.banner.stale { background: var(--warn-bg); border-color: var(--warn-line); }
.admin .row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.admin button { font: inherit; font-weight: 600; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.admin button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tbl-wrap { overflow-x: auto; }
table.preview { border-collapse: collapse; font-size: .82rem; width: 100%; }
table.preview th, table.preview td { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; vertical-align: top; }
.msg { padding: 10px 12px; border-radius: 10px; margin: 8px 0; }
.msg.err { background: #fde2e2; color: #7a1010; }
.msg.ok { background: var(--ok-bg); }
.msg.big { font-size: 1.1rem; font-weight: 700; padding: 16px; }
.admin button.big-btn { font-size: 1.1rem; padding: 14px 22px; }
.admin .steps { padding-left: 22px; margin: 20px 0; }
.admin .steps li { margin-bottom: 12px; }
.admin .steps li::marker { font-weight: 800; color: var(--muted); }
.drop { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 34px 16px; border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop:focus { border-color: var(--accent); outline: none; }
.drop.over { border-color: var(--accent); background: var(--warn-bg); }
.drop-icon { font-size: 2rem; }
.drop strong { font-size: 1.05rem; }
.auto { background: var(--surface); border: 2px solid var(--accent); border-radius: var(--radius); padding: 16px 18px; margin-top: 18px; }
.auto h2 { margin: 0 0 4px; font-size: 1.15rem; }
.auto p { margin: 0 0 12px; }
.auto-row { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.cap-box { display: flex; align-items: center; justify-content: center; min-width: 180px; min-height: 84px; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cap-box img { display: block; height: 82px; width: auto; }
.cap-box img[hidden], .cap-box [hidden] { display: none; }
.cap-box .muted { color: #5d6b7c; font-size: .85rem; padding: 0 10px; }
.admin .auto-row input[type=text] { flex: 1 1 150px; width: auto; min-width: 0; font-size: 1.4rem; font-weight: 700; letter-spacing: .12em; }
.admin .auto-row button { min-width: 52px; }
.admin .auto-row .primary { flex: 0 1 130px; font-size: 1.1rem; }
.admin button:disabled { opacity: .5; cursor: default; }
.manual { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.manual summary { cursor: pointer; font-weight: 600; }
#out { margin-top: 14px; }
.msg button { margin-top: 8px; }
.msg.warn { background: var(--warn-bg); }
