:root {
  --bg: #000;
  --text: #fff;
  --muted: #8e8e93;
  --line: rgba(255,255,255,.12);
  --surface: rgba(28,28,30,.92);
  --surface-2: rgba(255,255,255,.08);
  --accent: #ff9f0a;
  --dot-day: #d6d6d6;
  --dot-night: #4a4a4c;
  --terminator: rgba(255,255,255,.35);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased; overflow: hidden;
  display: flex; flex-direction: column; height: 100dvh;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Top bar */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 16px; position: relative; z-index: 5; }
.logo { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 600; font-size: .95rem; letter-spacing: -.01em; white-space: nowrap; }
.logo .dim { color: var(--muted); font-weight: 500; }
.controls { display: flex; gap: 6px; margin-left: auto; }
.btn {
  font: inherit; font-size: .85rem; font-weight: 600; background: var(--surface-2); color: var(--text);
  border: 0; border-radius: 999px; padding: 7px 12px; cursor: pointer; transition: background .15s; white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.14); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.icon { padding: 7px 8px; display: inline-flex; }
.btn.small { padding: 4px 10px; font-size: .78rem; }
.btn[aria-pressed="true"] { background: var(--accent); color: #000; }

.search-wrap { position: relative; flex: 1; max-width: 360px; margin-left: 8px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 999px; padding: 0 12px; }
.search svg { color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; font: inherit; font-size: .9rem; background: none; border: 0; color: var(--text); padding: 8px 0; }
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.results {
  list-style: none; margin: 6px 0 0; padding: 6px; position: absolute; left: 0; right: 0; z-index: 10; min-width: 280px;
  background: var(--surface); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,.8); max-height: 320px; overflow: auto;
}
.results li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 9px; cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: var(--surface-2); }
.results .name { font-weight: 600; font-size: .92rem; }
.results .sub { color: var(--muted); font-size: .78rem; }
.results .now { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88rem; flex: none; }
.results .none { color: var(--muted); cursor: default; }

.travel-bar[hidden] { display: none; }
.travel-bar { display: flex; align-items: center; gap: 12px; padding: 4px 16px 10px; font-size: .85rem; color: var(--muted); position: relative; z-index: 5; }
.travel-bar label { color: var(--text); font-weight: 600; }
.offset-label { font-variant-numeric: tabular-nums; min-width: 4ch; }
.travel-bar input[type="range"] { flex: 1; accent-color: var(--accent); }

/* Compare panel */
.compare[hidden] { display: none; }
.compare { position: relative; z-index: 5; padding: 2px 16px 12px; max-width: 980px; margin: 0 auto; width: 100%; }
.compare-row { display: flex; align-items: center; gap: 8px; }
.compare-row .search-wrap { flex: 1; max-width: none; margin: 0; }
.compare-row .search input { padding: 10px 0; }
.compare-row .search input.has-city::placeholder { color: var(--text); font-weight: 600; opacity: 1; }
.compare-out { margin-top: 10px; display: none; }
.compare-out.show { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; font-size: .95rem; color: var(--muted); }
.compare-out .headline { color: var(--text); font-weight: 600; font-size: 1.05rem; }
.compare-out .times { font-variant-numeric: tabular-nums; }
.compare-out .times b { color: var(--text); font-weight: 650; }
.compare-out .window strong { color: var(--accent); font-weight: 650; }
.compare-out a { color: var(--accent); text-decoration: none; font-weight: 600; }
.compare-out a:hover { text-decoration: underline; }

/* Region pages: map, clock and city strip only */
body.region .top, body.region .travel-bar, body.region .compare { display: none; }

/* Map and overlays */
main { position: relative; flex: 1; min-height: 0; }
.map-wrap { position: absolute; inset: 0; }
#map, #fx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#fx { pointer-events: none; z-index: 1; }

.hero { position: absolute; left: 24px; bottom: calc(20px + var(--safe-b)); z-index: 2; pointer-events: none; }
body.satellite .hero, body.satellite .list { text-shadow: 0 1px 2px rgba(0,0,0,.8), 0 4px 18px rgba(0,0,0,.6); }
.hero-name { color: var(--accent); font-weight: 700; font-size: clamp(1.3rem, 2.6vw, 2.2rem); letter-spacing: -.01em; line-height: 1.1; }
.hero-time { font-weight: 700; font-size: clamp(4.2rem, 11vw, 9rem); line-height: .95; letter-spacing: -.04em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.hero-ampm { font-size: .32em; margin-left: .15em; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.hero-meta { color: var(--muted); font-size: clamp(.85rem, 1.3vw, 1rem); margin-top: 6px; font-variant-numeric: tabular-nums; }
.hero-meta .diff { color: var(--text); }
.consent-link[hidden] { display: none !important; }
.hero-links { display: flex; gap: 14px; }
.hero-link { display: inline-block; margin-top: 8px; color: var(--muted); font-size: .8rem; text-decoration: none; pointer-events: auto; border-bottom: 1px solid var(--line); }
.hero-link:hover { color: var(--text); }

/* Cities wrap into rows that stack upward from the bottom right: the first row stays at the bottom, extra cities go above. */
.list { list-style: none; margin: 0; padding: 0 24px 0 0; position: absolute; right: 0; bottom: calc(22px + var(--safe-b)); z-index: 2;
  max-width: min(62%, calc(100% - 460px)); display: flex; flex-direction: row; flex-wrap: wrap-reverse; justify-content: flex-end; align-items: flex-end; gap: 2px 4px; }
.row { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 6px 12px 4px; border-radius: 12px; cursor: pointer; color: var(--muted); position: relative; flex: none; transition: background .15s, color .15s; }
.row:hover, .row:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.row.selected { color: var(--text); }
.row.selected .row-name { color: var(--accent); }
.row-name { font-weight: 600; font-size: clamp(.85rem, 1.2vw, 1rem); white-space: nowrap; line-height: 1.2; }
.row-name .local-mark { font-size: .75em; margin-right: 4px; opacity: .9; }
.row-time { font-weight: 700; font-size: clamp(1.25rem, 2vw, 1.7rem); font-variant-numeric: tabular-nums; letter-spacing: -.02em; white-space: nowrap; line-height: 1.15; }
.row-time .ampm { font-size: .55em; margin-left: 3px; font-weight: 600; opacity: .7; }
.row-time .dayoff { font-size: .5em; margin-left: 5px; color: var(--accent); font-weight: 600; vertical-align: .35em; }
.remove { position: absolute; right: 2px; top: 2px; background: none; border: 0; color: var(--muted); padding: 3px; border-radius: 6px; cursor: pointer; opacity: 0; display: inline-flex; }
.row:hover .remove, .row:focus-within .remove { opacity: 1; }
.remove:hover { color: var(--text); background: var(--surface-2); }
.row.local .remove { display: none; }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%) translateY(-8px); background: var(--surface); border: 1px solid var(--line); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: .88rem; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Server-rendered content pages */
body.page { overflow: auto; height: auto; min-height: 100dvh; }
body.page main { flex: none; height: calc(100dvh - 56px); min-height: 520px; }
.content { max-width: 860px; margin: 0 auto; padding: 40px 24px calc(48px + var(--safe-b)); line-height: 1.55; font-size: 1rem; }
.content a { color: var(--accent); text-decoration: none; }
.content a:hover { text-decoration: underline; }
.content h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); letter-spacing: -.02em; line-height: 1.15; margin: 8px 0 12px; }
.content h2 { font-size: 1.2rem; margin: 36px 0 10px; letter-spacing: -.01em; }
.content p { margin: 0 0 14px; color: #d1d1d6; }
.content ul:not(.cols) { color: #d1d1d6; padding-left: 20px; margin: 0 0 14px; }
.content ul:not(.cols) li { margin-bottom: 8px; }
.content .lede { font-size: 1.1rem; color: var(--text); }
.content strong { font-weight: 650; }
.crumbs { font-size: .85rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs .sep { opacity: .5; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 20px 0; padding: 0; }
.facts div { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.facts dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.facts dd { margin: 4px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.content table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .95rem; }
.content th, .content td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.content th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.content tr.both td { background: rgba(255,159,10,.12); }
.content tr.both td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.content tr.one td { color: #d1d1d6; }
.content td .dayoff { font-size: .7em; margin-left: 5px; color: var(--accent); font-weight: 600; vertical-align: .3em; }
.cols { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 32px; }
.cols li { break-inside: avoid; margin: 0 0 8px; color: #d1d1d6; }
.cols .more { color: var(--muted); font-size: .85em; }
.cols .t { color: var(--muted); font-size: .85em; font-variant-numeric: tabular-nums; }
.offsets { display: flex; flex-wrap: wrap; gap: 6px 12px; }
.back { margin-top: 32px; color: var(--muted); }
.site-footer { margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }
.site-footer a { color: var(--muted); }
/* Ad slots take no space until Google reports a filled ad (data-ad-status is set by the AdSense script). */
.ad { margin: 0; }
.ad ins.adsbygoogle { background: transparent; }
.ad ins.adsbygoogle:not([data-ad-status="filled"]) { max-height: 0 !important; overflow: hidden; display: block; }
.ad ins.adsbygoogle[data-ad-status="filled"] { margin: 28px 0; }

@media (max-width: 720px) {
  body.page main { height: auto; min-height: 0; }
  .cols { columns: 1; }
  .content { padding: 24px 16px calc(40px + var(--safe-b)); }
  body { overflow: auto; height: auto; min-height: 100dvh; }
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; margin: 4px 0 0; }
  .compare-row { flex-wrap: wrap; }
  .compare-row .search-wrap { flex-basis: calc(50% - 25px); order: 0; }
  .compare-out.show { gap: 4px 14px; font-size: .9rem; }
  main { flex: none; display: flex; flex-direction: column; }
  .map-wrap { position: relative; height: auto; aspect-ratio: 360 / 150; }
  body.region .map-wrap { aspect-ratio: 3 / 2; }
  .hero { position: static; padding: 8px 16px 0; }
  .hero-time { font-size: clamp(4rem, 20vw, 6rem); }
  .list { position: static; max-width: none; flex-wrap: wrap; justify-content: flex-start; gap: 6px; padding: 16px 16px calc(24px + var(--safe-b)); }
  .row { padding: 8px 28px 6px 12px; background: var(--surface-2); color: var(--text); }
  .row .remove { opacity: .7; right: 4px; top: 4px; }
  .row.selected { box-shadow: inset 0 0 0 1.5px var(--accent); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
