:root,
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --border: #e2e8f0;
  --accent: #0284c7;
  --accent-fg: #ffffff;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgb(15 23 42 / 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1e293b;
    --text: #f8fafc;
    --muted: #94a3b8;
    --border: #1e293b;
    --accent: #38bdf8;
    --accent-fg: #0b1120;
    --danger: #f87171;
    --shadow: 0 10px 28px rgb(0 0 0 / 0.45);
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: #1e293b;
  --accent: #38bdf8;
  --accent-fg: #0b1120;
  --danger: #f87171;
  --shadow: 0 10px 28px rgb(0 0 0 / 0.45);
}

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header, main, footer {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 3vw, 1.75rem);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { margin: 0 0 0.75rem; font-size: 0.8rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
main { flex: 1; display: grid; gap: 2rem; padding-block: 1.5rem 2.5rem; }
footer { padding-block: 1.25rem; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
footer p { margin: 0; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.header-controls, .add-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

button, input, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.48rem 0.75rem;
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

button { cursor: pointer; font-weight: 550; }
button:hover { background: var(--surface-2); border-color: var(--muted); }
button#addBtn { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button#addBtn:hover { filter: brightness(1.06); }

:is(button, input, select, a, [tabindex], #suggestions li):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#hero {
  text-align: center;
  padding: clamp(1.5rem, 4vw, 2.75rem) 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#heroTime {
  font-size: clamp(3rem, 11vw, 6.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

#heroDate { margin-top: 0.6rem; font-size: clamp(0.95rem, 2.2vw, 1.15rem); font-weight: 500; }
#heroZone { margin-top: 0.25rem; color: var(--muted); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
#heroSync { margin-top: 0.5rem; color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
#heroSync:empty, #copyMsg:empty, #suggestions:empty { display: none; }

#add { display: flex; flex-wrap: wrap; gap: 0.65rem; align-items: center; }
.add-input-wrap { position: relative; flex: 1 1 260px; }
#placeInput { width: 100%; }
#copyMsg { font-size: 0.85rem; color: var(--accent); font-weight: 500; }

#suggestions {
  position: absolute;
  inset: calc(100% + 4px) 0 auto 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 0.25rem;
  max-height: 260px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

#suggestions li { padding: 0.5rem 0.65rem; border-radius: 6px; cursor: pointer; font-size: 0.92rem; }
#suggestions li:hover, #suggestions li.active, #suggestions li[aria-selected="true"] { background: var(--surface-2); color: var(--accent); }

#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 0.85rem; }

article.card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 0.35rem 0.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.card > div:not(.coffset):not(.cdiff) { flex: 1 0 100%; }
.card > div:has(.city), .card > div:has(button) { display: flex; align-items: center; gap: 0.4rem; }
.card .city { margin: 0 auto 0 0; font-size: 1rem; font-weight: 650; }
.card .cicon { display: inline-flex; align-items: center; line-height: 1; }
.card .ctime { font-size: 1.75rem; font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card .cdate, .card .coffset, .card .cdiff { font-size: 0.84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.card > .coffset { margin-right: 0.25rem; }
.card > button:first-of-type { margin-left: auto; }
.card button { padding: 0.25rem 0.5rem; font-size: 0.8rem; line-height: 1.2; }
.card button.remove:hover { color: var(--danger); border-color: var(--danger); }

.plan-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.65rem; margin-bottom: 0.9rem; }
.plan-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--muted); }
.plan-field select, .plan-field input { font-variant-numeric: tabular-nums; }

#planGrid { display: flex; flex-direction: column; gap: 0.45rem; }
#planGrid > * {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(3rem, 5rem);
  align-items: center;
  gap: 0.4rem 1rem;
  padding: 0.65rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}
#planGrid > * > :nth-child(2) { text-align: center; }
#planGrid > * > :nth-child(3) { text-align: right; }

#planGrid .off { background: var(--surface-2); color: var(--muted); border-style: dashed; opacity: 0.72; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
