:root {
  --ink: #12263a;
  --ink-soft: #4a6074;
  --mist: #eef4f8;
  --panel: #ffffff;
  --teal: #0f7a7a;
  --teal-deep: #0a5555;
  --gold: #c9922a;
  --line: rgba(18, 38, 58, 0.12);
  --shadow: 0 16px 48px rgba(18, 50, 72, 0.14);
  --radius: 16px;
  --font: "Montserrat", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--mist);
  line-height: 1.45;
  overflow-x: hidden;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 55% at 0% 0%, rgba(15, 122, 122, 0.22), transparent 55%),
    radial-gradient(ellipse 55% 40% at 100% 10%, rgba(201, 146, 42, 0.16), transparent 50%),
    linear-gradient(180deg, #e7f0f5 0%, #eef4f8 45%, #e4ece8 100%);
  animation: sky-shift 20s ease-in-out infinite alternate;
}

.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(90deg, rgba(18, 38, 58, 0.04) 1px, transparent 1px);
  background-size: 12.5% 100%;
  pointer-events: none;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 70%);
}

@keyframes sky-shift {
  from { filter: saturate(1) brightness(1); }
  to { filter: saturate(1.08) brightness(1.02); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 0.75rem;
  animation: rise 0.7s ease-out both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  background:
    conic-gradient(from 200deg, var(--teal), var(--gold), var(--teal-deep), var(--teal));
  box-shadow: inset 0 0 0 5px #eef4f8, 0 6px 16px rgba(10, 85, 85, 0.22);
  position: relative;
  flex-shrink: 0;
  animation: spin-slow 42s linear infinite;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 38% 46% 18% 46%;
  background: var(--ink);
  border-radius: 2px;
  transform-origin: top center;
  transform: rotate(25deg);
}

@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

.brand-name {
  margin: 0;
  font-family: var(--font);
  font-weight: 700;
  font-size: clamp(1.85rem, 5vw, 2.7rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--ink);
}

.tagline {
  margin: 0.65rem 0 0;
  max-width: 34rem;
  color: var(--ink-soft);
  font-size: clamp(0.98rem, 2.4vw, 1.08rem);
  font-weight: 500;
  animation: rise 0.7s ease-out 0.12s both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: stretch;
  margin-bottom: 1rem;
  animation: rise 0.7s ease-out 0.2s both;
}

.search-wrap {
  position: relative;
  flex: 1 1 16rem;
}

#city-search {
  width: 100%;
  padding: 0.9rem 1.1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font: 600 1rem/1.2 var(--font);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#city-search:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 122, 122, 0.14);
}

.suggestions {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: min(16rem, 45vh);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.suggestions li {
  padding: 0.85rem 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.95rem;
  font-weight: 500;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(15, 122, 122, 0.2);
}

.suggestions li:hover,
.suggestions li[aria-selected="true"] {
  background: rgba(15, 122, 122, 0.1);
}

.suggestions .meta {
  color: var(--ink-soft);
  font-size: 0.85rem;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
}

.btn {
  border: none;
  cursor: pointer;
  font: 700 0.92rem/1 var(--font);
  border-radius: 999px;
  padding: 0.85rem 1.1rem;
  transition: transform 0.15s, background 0.2s, color 0.2s;
}

.btn:active {
  transform: scale(0.97);
}

.btn.ghost {
  background: #fff;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}

.btn.ghost:hover,
.btn.ghost[aria-pressed="true"] {
  color: var(--teal-deep);
  border-color: rgba(15, 122, 122, 0.35);
  background: #fff;
}

.converter {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: rise 0.75s ease-out 0.28s both;
}

.converter-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.tz-row {
  display: grid;
  grid-template-columns: minmax(11rem, 13rem) repeat(24, minmax(2.85rem, 1fr));
  min-width: 56rem;
  border-bottom: 1px solid var(--line);
}

.tz-row:last-child {
  border-bottom: none;
}

.tz-row.is-home .city-panel {
  background: #e8f4f3;
}

.city-panel {
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.55rem 0.55rem 0.55rem 0.3rem;
  background-color: #ffffff;
  background: #ffffff;
  border-right: 1px solid var(--line);
  box-shadow: 6px 0 12px rgba(18, 38, 58, 0.08);
  min-height: 6.4rem;
  isolation: isolate;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

.city-reorder {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.15rem;
  flex-shrink: 0;
  width: 1.15rem;
}

.reorder-btn {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 1px solid rgba(18, 38, 58, 0.16);
  border-radius: 4px;
  background: #f3f7f9;
  color: var(--teal-deep);
  font-size: 0.55rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.reorder-btn:hover {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.reorder-spacer {
  width: 1.15rem;
  height: 1.15rem;
}

.city-info {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
}

.city-line {
  margin: 0;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.2;
}

.city-line-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.city-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  font-size: 0.97rem;
  color: var(--ink);
}

.city-offset {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.city-region {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.city-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.city-time {
  font-family: var(--font);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--teal-deep);
  font-variant-numeric: tabular-nums;
}

.city-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.1rem;
}

.icon-btn {
  width: 1.45rem;
  height: 1.45rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  padding: 0;
}

.icon-btn.is-home-star {
  color: var(--gold);
}

.icon-btn:hover {
  background: rgba(18, 38, 58, 0.06);
  color: var(--ink);
}

.icon-btn.danger:hover {
  background: rgba(180, 50, 40, 0.1);
  color: #a12d24;
}

.hour-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  min-height: 6.6rem;
  padding: 0.28rem 0.15rem 0.4rem;
  border: none;
  border-right: 1px solid rgba(18, 38, 58, 0.08);
  cursor: pointer;
  user-select: none;
  transition: filter 0.15s, transform 0.15s, box-shadow 0.15s;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  color: #000;
  font-variant-numeric: tabular-nums;
}

.hour-cal {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  margin-top: 0.1rem;
  margin-bottom: 0.55rem;
  width: 100%;
  min-width: 0;
}

.hour-date,
.hour-weekday {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0 0.1rem;
  box-sizing: border-box;
  font-size: 0.52rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  /* Fit longest labels (e.g. AUG 31) — do not wrap or ellipsis-truncate */
  text-overflow: clip;
}

.hour-date {
  color: #36454f;
  font-variant-numeric: tabular-nums;
}

.hour-weekday {
  color: #962525;
  letter-spacing: 0.05em;
}

.hour-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  line-height: 1.1;
  margin-top: auto;
  margin-bottom: auto;
}

.hour-cell .ampm {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #000;
  opacity: 0.78;
}

/* Time-of-day — two simple bands */
.hour-cell.tod-night {
  background: #c0c4ff;
  color: #000;
}

.hour-cell.tod-day {
  background: #ffcbad;
  color: #000;
}

.hour-cell.is-now {
  box-shadow: inset 0 0 0 2px var(--teal);
  z-index: 1;
  filter: brightness(0.97);
}

.hour-cell.is-hover,
.hour-cell.is-selected {
  background: #ffe566 !important;
  color: #000;
  transform: scale(1.04);
  z-index: 1;
  filter: none;
}

.hour-cell.is-selected {
  box-shadow: inset 0 0 0 2px #12263a;
}

.hint {
  margin: 0;
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  background: #f4f8fa;
}

.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.25rem 2.5rem;
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 500;
}

.site-footer p {
  margin: 0;
}

.empty-state {
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 500;
}

@media (max-width: 640px) {
  .site-header {
    padding: 1.15rem 1rem 0.5rem;
  }

  .brand-name {
    font-size: 1.55rem;
  }

  .tagline {
    font-size: 0.92rem;
  }

  .app-shell {
    padding: 0.85rem 0.75rem 1.75rem;
  }

  .toolbar {
    gap: 0.5rem;
  }

  .btn {
    padding: 0.75rem 0.9rem;
  }

  .tz-row {
    grid-template-columns: minmax(9.6rem, 10.8rem) repeat(24, minmax(2.7rem, 1fr));
    min-width: 52rem;
  }

  .city-panel {
    padding: 0.5rem 0.4rem 0.5rem 0.2rem;
    min-height: 6.4rem;
    background: #ffffff !important;
  }

  .tz-row.is-home .city-panel {
    background: #e8f4f3 !important;
  }

  .city-time {
    font-size: 1.02rem;
  }

  .hour-cell {
    min-height: 6.6rem;
    font-size: 0.78rem;
  }

  .hint {
    font-size: 0.8rem;
  }

  .site-footer {
    padding: 0 0.75rem 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
