/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #22263a;
  --border:    #2d3148;
  --accent:    #7c6ef7;
  --accent-lo: #3d3878;
  --text:      #e8eaf6;
  --muted:     #7a7f9a;
  --fav:       #f5c542;
  --radius:    14px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15,17,23,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -.5px;
  white-space: nowrap;
  background: linear-gradient(135deg, #a89af7 0%, #7c6ef7 60%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── 12h/24h toggle ──────────────────────────────────────── */
.fmt-toggle {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  cursor: pointer;
  gap: 2px;
  flex-shrink: 0;
}
.fmt-opt {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 6px;
  transition: background .15s, color .15s;
  user-select: none;
}
.fmt-opt.active {
  background: var(--accent);
  color: #fff;
}

/* ── Search ───────────────────────────────────────────────── */
.search-wrap { flex: 1; max-width: 400px; position: relative; }
.search-wrap::before {
  content: '';
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%237a7f9a' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") center/contain no-repeat;
}
#search {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
#search::placeholder { color: var(--muted); }
#search:focus { border-color: var(--accent); }

/* ── Main layout ──────────────────────────────────────────── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

.hidden { display: none !important; }

/* ── Clock grid ───────────────────────────────────────────── */
.clock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

/* ── Clock card ───────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  cursor: default;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card.is-fav {
  border-color: var(--accent-lo);
  background: linear-gradient(145deg, var(--surface) 70%, #221f46);
}

.card-city {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 28px;
}
.card-region {
  font-size: .75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-time {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -.5px;
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.card-date {
  font-size: .75rem;
  color: var(--muted);
}
.card-offset {
  font-size: .7rem;
  color: var(--muted);
  margin-top: 2px;
}
.card-local-offset {
  font-size: .7rem;
  color: var(--muted);
  font-weight: 500;
}
.card-local-offset.is-local {
  color: var(--accent);
  font-weight: 600;
}

/* day period dot */
.card-time-wrap { display: flex; align-items: baseline; gap: 6px; }
.period {
  font-size: .75rem;
  font-weight: 600;
  color: var(--muted);
  align-self: flex-end;
  margin-bottom: 2px;
}

/* ── Fav button ───────────────────────────────────────────── */
.fav-btn {
  position: absolute;
  top: 14px; right: 14px;
  width: 26px; height: 26px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--muted);
  transition: color .2s, transform .15s;
  display: flex; align-items: center; justify-content: center;
}
.fav-btn:hover { color: var(--fav); transform: scale(1.2); }
.fav-btn.active { color: var(--fav); }
.fav-btn svg { width: 18px; height: 18px; }

/* ── Day/Night band on card ───────────────────────────────── */
.card-band {
  height: 3px;
  border-radius: 2px;
  margin-top: 10px;
  background: var(--border);
  overflow: hidden;
  position: relative;
}
.card-band-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 2px;
  transition: width .5s;
}
.day-fill   { background: linear-gradient(90deg, #f5c542, #ff9800); }
.night-fill { background: linear-gradient(90deg, #3d3878, #7c6ef7); }

/* ── No results ───────────────────────────────────────────── */
.empty-msg {
  grid-column: 1/-1;
  color: var(--muted);
  font-size: .9rem;
  padding: 12px 0;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 520px) {
  .header-inner { flex-direction: column; align-items: stretch; }
  .search-wrap { max-width: 100%; }
  main { padding: 20px 16px 48px; }
}
