:root {
  --bg:           #f0f4f8;
  --surface:      #ffffff;
  --border:       #cbd5e0;
  --text:         #1a202c;
  --text-muted:   #718096;
  --accent:       #2b6cb0;
  --accent-dark:  #2c5282;

  --work-bg:      rgba(66, 153, 225, 0.18);
  --work-border:  rgba(66, 153, 225, 0.45);
  --overlap-bg:   rgba(72, 187, 120, 0.35);
  --overlap-line: rgba(47, 133, 90, 0.7);

  --radius: 8px;
  --label-w: 180px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────── */

header {
  background: var(--accent);
  color: #fff;
  padding: 1rem 1.5rem;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.dot { color: rgba(255,255,255,0.55); }

.tagline {
  font-size: 0.9rem;
  opacity: 0.75;
  font-weight: 400;
}

/* ── Main ─────────────────────────────────────────────────── */

main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Picker ───────────────────────────────────────────────── */

.picker {
  position: relative;
}

.picker__input-wrap {
  position: relative;
}

.picker__input {
  width: 100%;
  padding: 0.65rem 2.5rem 0.65rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.picker__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.picker__icon {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1;
}

.picker__suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  list-style: none;
  z-index: 100;
  max-height: 260px;
  overflow-y: auto;
}

.picker__suggestions li {
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.1s;
}

.picker__suggestions li:hover,
.picker__suggestions li[aria-selected="true"] {
  background: var(--bg);
  color: var(--accent);
}

.picker__suggestions li + li {
  border-top: 1px solid var(--border);
}

/* ── Grid ─────────────────────────────────────────────────── */

.grid-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.grid {
  display: grid;
  grid-template-columns: var(--label-w) 1fr;
  min-width: 0;
}

.grid__track {
  display: grid;
  grid-template-columns: repeat(48, 1fr);
  position: relative;
}

/* ── Grid header row ──────────────────────────────────────── */

.grid__header-label {
  padding: 0.4rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
}

.grid__header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: relative;
}

.grid__hour-label {
  grid-column: span 2;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0.4rem 0;
  border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

.grid__hour-label:first-child {
  border-left: none;
}

/* ── City rows ────────────────────────────────────────────── */

.grid__city-label {
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  min-width: 0;
}

.grid__city-label:first-child { border-top: none; }

.grid__city-name {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grid__city-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.grid__city-time {
  font-size: 0.75rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.grid__city-offset {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.grid__remove {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: 0.4;
  transition: opacity 0.15s, color 0.15s;
  margin-left: auto;
  flex-shrink: 0;
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
}

.grid__city-label { position: relative; }
.grid__remove:hover { opacity: 1; color: #e53e3e; }

/* ── Grid cells ───────────────────────────────────────────── */

.grid__track--city {
  border-top: 1px solid var(--border);
}

.grid__cell {
  height: 40px;
  border-left: 1px solid transparent;
  transition: background 0.1s;
}

.grid__cell:first-child { border-left: none; }

/* Every 2 cells = 1 hour — add a subtle tick every hour */
.grid__cell:nth-child(2n+1) {
  border-left-color: rgba(0,0,0,0.04);
}

.grid__cell--work {
  background: var(--work-bg);
}

.grid__cell--overlap {
  background: var(--overlap-bg);
}

/* ── Summary row ──────────────────────────────────────────── */

.grid__summary-label {
  padding: 0.45rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-top: 2px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
}

.grid__track--summary {
  border-top: 2px solid var(--border);
  background: var(--bg);
}

.grid__cell--summary {
  height: 20px;
  background: transparent;
}

.grid__cell--summary.grid__cell--overlap {
  background: var(--overlap-bg);
  border-bottom: 2px solid var(--overlap-line);
}

/* ── Now line ─────────────────────────────────────────────── */

.grid__now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(229, 62, 62, 0.6);
  pointer-events: none;
  z-index: 2;
}

.grid__now-label {
  position: absolute;
  top: 2px;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(229, 62, 62, 0.85);
  white-space: nowrap;
  transform: translateX(-50%);
}

/* ── Overlap message ──────────────────────────────────────── */

.overlap-message {
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-weight: 500;
}

.overlap-message--found {
  background: rgba(72, 187, 120, 0.12);
  color: #276749;
  border: 1px solid rgba(72, 187, 120, 0.35);
}

.overlap-message--none {
  background: rgba(237, 137, 54, 0.1);
  color: #744210;
  border: 1px solid rgba(237, 137, 54, 0.3);
}

/* ── Empty state ──────────────────────────────────────────── */

.grid-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Footer ───────────────────────────────────────────────── */

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

/* ── Mobile ───────────────────────────────────────────────── */

@media (max-width: 600px) {
  :root { --label-w: 120px; }

  h1 { font-size: 1.2rem; }

  .grid__city-name { font-size: 0.78rem; }
  .grid__city-time { font-size: 0.68rem; }
  .grid__city-offset { display: none; }
  .grid__cell { height: 32px; }

  .grid__hour-label { font-size: 0.55rem; }
}
