:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1c1c1e;
  --secondary: #6b6f76;
  --border: rgba(0, 0, 0, 0.10);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.10);
  --row-hover: rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 6px 20px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1b1e;
    --panel: #242529;
    --text: #f2f2f7;
    --secondary: #9a9ea6;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #4a9dff;
    --accent-soft: rgba(74, 157, 255, 0.16);
    --row-hover: rgba(255, 255, 255, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;    /* map-first: no page scroll */
}

.app-header {                /* positioning wrapper for the floating Help / About buttons */
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 450;
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.help-btn {                  /* the Help button is itself a floating chip */
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
}
.help-btn:hover { border-color: var(--accent); }

.layout {
  position: relative;      /* map fills; panel floats over it */
  flex: 1 1 auto;
  min-height: 0;
}

.panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 340px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 12px;               /* gap between the floating cards */
  transition: opacity 0.6s ease-in-out;   /* slow, smooth fade both ways */
}
.panel.faded {             /* fade out while the map is being dragged/zoomed */
  opacity: 0.12;
  pointer-events: none;
}
.panel > * {               /* keep full card heights; the panel scrolls instead of squishing */
  flex-shrink: 0;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
/* The add-city card must let its search-results dropdown overflow the card. */
.card.search-card { overflow: visible; }

/* ---- location list ---- */
.location-list {
  /* grows with content; the whole left column scrolls as one (the map is sticky) */
}
/* UTC + your location sit at the top of the locations card; a thicker divider
   separates them from the added locations (shown only when there are any). */
.card.has-added .location-list.primary { border-bottom: 3px solid var(--border); }
.loc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  position: relative;
}
.loc-row:last-child { border-bottom: none; }
.loc-row:hover { background: var(--row-hover); }
.loc-row.selected { background: var(--accent-soft); }
.loc-row.static { cursor: default; }
.loc-row.static:hover { background: transparent; }

.loc-main { flex: 1 1 auto; min-width: 0; }
.loc-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.loc-sub {
  font-size: 10.5px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.loc-time {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.loc-badge {
  width: 18px;
  text-align: center;
  color: var(--secondary);
  font-size: 12px;
  flex: 0 0 auto;
}
.loc-badge.home { font-size: 24px; width: 26px; }   /* bigger house icon for your location */
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
}
.del-btn {
  border: none;
  background: transparent;
  color: var(--secondary);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.12s;
}
.loc-row:hover .del-btn { opacity: 1; }
@media (hover: none) { .del-btn { opacity: 1; } }
.del-btn:hover { color: #ff453a; }

/* ---- scrubber ---- */
.scrubber {
  padding: 8px 16px 8px;   /* now its own card, so no tint/borders of its own */
}
.scrubber-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  min-height: 20px;   /* fixed so the appearing/disappearing "Now" button doesn't reflow height */
}
.scrubber-time {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.scrubber-abbr { font-size: 11px; color: var(--secondary); }
.now-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.scrubber-track {
  position: relative;
  height: 16px;
  cursor: pointer;
  touch-action: none;
}
.scrubber-track::before {
  content: "";
  position: absolute;
  top: 6px; left: 0; right: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}
.scrubber-fill {
  position: absolute;
  top: 6px; left: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
}
.scrubber-knob {
  position: absolute;
  top: 0;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transform: translateX(-8px);
}
.scrubber-ends {
  display: flex;
  justify-content: space-between;
  color: var(--secondary);
  font-size: 10px;
  margin-top: 4px;
}
.copy-btn {
  display: none;                          /* shown only when there are added locations */
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);   /* footer bar attached under the list rows */
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 11px;
  cursor: pointer;
}
.card.has-added .copy-btn { display: block; }
.copy-btn:hover { background: var(--row-hover); }
.clear-btn { color: #ff453a; }   /* destructive action */

/* ---- add / search ---- */
.add-row { position: relative; padding: 12px 14px 6px; }
.city-search {
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.city-search:focus { border-color: var(--accent); }
.search-results {
  position: absolute;
  left: 14px; right: 14px;
  top: 52px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
  z-index: 500;
}
.result-row {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-row:hover, .result-row.active { background: var(--accent-soft); }
.result-country { color: var(--secondary); font-size: 11px; }
.hint {
  color: var(--secondary);
  font-size: 11px;
  padding: 0 14px 12px;
  margin: 4px 0 0;
}

/* ---- saved sets ---- */
.sets {
  padding: 12px 14px 14px;   /* now its own card, so no top border of its own */
}
.sets-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.sets-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.save-set-form {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.set-name-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}
.set-name-input:focus { border-color: var(--accent); }
.set-form-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 0 14px;
  border-radius: 7px;
  cursor: pointer;
}
.set-form-btn:disabled { opacity: 0.45; cursor: default; }

.sets-list { display: flex; flex-direction: column; gap: 4px; }
.set-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}
.set-row:hover { background: var(--row-hover); border-color: var(--accent); }
.set-row.active { background: var(--accent-soft); border-color: var(--accent); }
.set-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.set-count { color: var(--secondary); font-size: 11px; flex: 0 0 auto; }
.set-modified {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 400;
  font-style: italic;
  color: var(--accent);
}
.set-update {
  flex: 0 0 auto;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
}
.set-update:hover { filter: brightness(1.05); }
.set-update:disabled { opacity: 0.4; cursor: default; filter: none; }

/* the Location Groups card, inline under the pills */
.groups-block .sets-list { max-height: 40vh; overflow-y: auto; }
.set-del {
  border: none;
  background: transparent;
  color: var(--secondary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex: 0 0 auto;
}
.set-del:hover { color: #ff453a; }
.sets-empty {
  color: var(--secondary);
  font-size: 12px;
  font-style: italic;
}

/* ---- map ---- */
.map-panel {
  position: absolute;    /* fills the whole layout area */
  inset: 0;
  overflow: hidden;
  background: var(--panel);
}
#map {
  width: 100%;
  height: 100%;
}

.app-footer { display: none; }   /* map-first: hide the credit strip */

/* pin labels */
.pin-home {
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  width: 16px; height: 16px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}

/* ---- zone picker modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }   /* override the flex display when hidden */
.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 320px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-title {
  font-size: 15px;
  font-weight: 700;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-list { overflow-y: auto; }
.zone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.zone-row:hover { background: var(--row-hover); }
.zone-city { flex: 1 1 auto; font-size: 14px; font-weight: 600; }
.zone-time { font-size: 14px; font-variant-numeric: tabular-nums; }
.zone-abbr { color: var(--secondary); font-size: 11px; min-width: 42px; text-align: right; }
.modal-cancel {
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
}

/* help modal — wide and short: two columns of sections */
.help-modal { max-width: 620px; }
.help-body {
  overflow-y: auto;
  padding: 12px 18px 6px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  column-count: 2;
  column-gap: 26px;
}
.help-body > p { margin: 0 0 10px; column-span: all; }
.help-sec { break-inside: avoid; margin-bottom: 10px; }
.help-body h3 { margin: 0 0 4px; font-size: 13px; font-weight: 700; }
.help-body ul { margin: 0; padding-left: 18px; }
.help-body li { margin: 3px 0; }

/* about modal — narrow, single column */
.about-modal { max-width: 380px; }
.help-body.about-body { column-count: 1; padding-bottom: 10px; }
.about-body a { color: var(--accent); font-weight: 600; }

/* map tap feedback */
.toast {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 8px;
  z-index: 600;
  pointer-events: none;
  max-width: 90%;
  white-space: nowrap;
}
.toast[hidden] { display: none; }

/* ---- responsive: only go full-width on an actual phone ---- */
@media (max-width: 520px) {
  .panel { left: 8px; right: 8px; width: auto; max-height: 58%; }
}

/* ================= iOS look ================= */

/* top-right stack: location pills, with the time slider beneath them */
.right-stack {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  width: 280px;
  max-width: calc(100vw - 24px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pills {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  padding: 7px 14px 7px 8px;
  font-size: 14px;
  width: 100%;                      /* all pills the same width; longer names truncate */
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.22,0.61,0.36,1), opacity 0.35s ease;
}
.pill.static { cursor: default; padding-left: 14px; }
.pill.entering, .pill.leaving { transform: translateX(120%); opacity: 0; }
.pill-x {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border: none; border-radius: 50%;
  background: rgba(120, 120, 128, 0.2);
  color: var(--secondary); font-size: 13px; font-weight: 700; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pill-x:hover { background: #ff453a; color: #fff; }
.pill-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-time { margin-left: 8px; font-variant-numeric: tabular-nums; color: var(--secondary); white-space: nowrap; }
.pill.home .pill-name::before { content: "\2302  "; }   /* house glyph */

/* time slider block, directly under the pills */
.time-block { width: 100%; }
.time-block[hidden] { display: none; }

/* top icon toolbar */
.toolbar {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 500;
  display: flex;
  flex-direction: row;
  gap: 10px;
}
.tb-btn {
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--accent);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  text-decoration: none;
  font-weight: 700; font-size: 14px;
}
.tb-btn svg { width: 22px; height: 22px; }
.tb-btn:hover { border-color: var(--accent); }
.tb-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tb-classic { color: var(--secondary); }

/* toolbar panels drop below their toolbar icon (top/left set in JS) */
.float-panel {
  position: absolute;
  z-index: 510;
  width: 320px;
  max-width: calc(100vw - 24px);
}
.float-panel[hidden] { display: none; }
.float-panel .card { overflow: visible; }

/* fade controls out of the way while dragging/zooming the map */
.right-stack, .toolbar, .float-panel { transition: opacity 0.6s ease-in-out; }
body.dragging .right-stack,
body.dragging .toolbar,
body.dragging .float-panel { opacity: 0.12; pointer-events: none; }

/* on phones, stack the circle buttons vertically down the left edge */
@media (max-width: 640px) {
  .toolbar { flex-direction: column; }
}
