:root {
  --page: oklch(0.985 0.005 255);
  --ink: oklch(0.32 0.1 262);
  --ink-soft: oklch(0.46 0.07 262);
  --tile: oklch(0.34 0.11 262);
  --tile-deep: oklch(0.28 0.1 262);
  --tile-line: oklch(0.44 0.1 262);
  --on-tile: oklch(0.97 0.01 255);
  --on-tile-soft: oklch(0.86 0.04 255);
  --field: oklch(0.99 0.004 255);
  --ring: oklch(0.62 0.15 262);
  --sun: oklch(0.87 0.13 85);
  --moon: oklch(0.82 0.06 262);
  --err: oklch(0.88 0.08 25);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }

summary, button { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.5 Manrope, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

h1, h2, h3, p { margin: 0; }

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* Time conversion panel */
.conv {
  background: var(--tile);
  color: var(--on-tile);
  border-radius: 14px;
}

.conv summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 18px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 14px;
  touch-action: manipulation;
}

.conv summary::-webkit-details-marker { display: none; }

.conv summary:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 3px;
}

.chev { transition: transform 0.3s var(--ease-out); }
.conv[open] .chev { transform: rotate(180deg); }

.conv-body { padding: 0 18px 14px; }

.fields {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--on-tile-soft);
}

.fbtn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--field);
  border-radius: 9px;
  background: var(--field);
  color: var(--ink);
  font: 500 15px Manrope, system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
}

.dp .fbtn { min-width: 190px; }
.sel-region .fbtn { min-width: 200px; }
.fbtn .chev-s { width: 16px; height: 16px; color: var(--ink-soft); }

.fields button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.time-group { display: flex; gap: 6px; }
.time-group .fbtn { min-width: 72px; padding: 0 10px; }

/* Dropdown menus */
.sel { position: relative; }

.menu {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  max-height: min(400px, 60vh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  box-shadow: 0 14px 34px oklch(0.25 0.08 262 / 0.28), 0 2px 6px oklch(0.25 0.08 262 / 0.16);
  transform-origin: top left;
  animation: pop 0.2s var(--ease-out);
}

.menu:focus { outline: none; }

.menu li {
  padding: 8px 12px;
  border-radius: 8px;
  font: 500 15px Manrope, system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
}

.menu li.is-active { background: oklch(0.94 0.025 262); }
.menu li[aria-selected="true"] { background: var(--tile); color: var(--on-tile); }
.menu:focus-visible li.is-active { outline: 2px solid var(--ring); outline-offset: -2px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.reset {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--tile-line);
  border-radius: 9px;
  background: transparent;
  color: var(--on-tile);
  font: 500 15px Manrope, system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s var(--ease-out), transform 0.15s var(--ease-out);
}

.reset:hover { background: oklch(0.4 0.11 262); }
.reset:active { transform: scale(0.97); }

/* Date picker */
.dp { position: relative; }

.cal {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  width: 300px;
  max-width: calc(100vw - 32px);
  padding: 12px;
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  box-shadow: 0 14px 34px oklch(0.25 0.08 262 / 0.28), 0 2px 6px oklch(0.25 0.08 262 / 0.16);
  transform-origin: top left;
  animation: pop 0.2s var(--ease-out);
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.cal-head p { font-size: 15px; font-weight: 600; }

.cal button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 500 14px Manrope, system-ui, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.cal button:hover { background: oklch(0.94 0.025 262); }
.cal button:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

.cal-nav {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
}

.cal table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { padding: 4px 0; font-size: 12px; font-weight: 500; color: var(--ink-soft); }
.cal td { padding: 2px; text-align: center; }
.cal td button { width: 100%; height: 36px; }
.cal td button[aria-current="date"] { box-shadow: inset 0 0 0 1.5px var(--tile); font-weight: 600; }
.cal td button[aria-pressed="true"],
.cal td button[aria-pressed="true"]:hover { background: var(--tile); color: var(--on-tile); font-weight: 600; }

.cal-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.cal-foot button { padding: 7px 10px; font-weight: 600; color: var(--tile); }

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
}

.err {
  min-height: 20px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--err);
}

.status {
  margin: 14px 0 12px;
  font-size: 14px;
  color: var(--ink-soft);
}

/* Tiles */
.grp {
  margin: 28px 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--tile);
  color: var(--on-tile);
  animation: rise 0.5s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}

.tile[hidden] { display: none; }

.tile-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.tile-top :is(h2, h3) {
  font-size: 14px;
  font-weight: 500;
  color: var(--on-tile-soft);
  overflow-wrap: anywhere;
}

.dn.is-day { color: var(--sun); }
.dn.is-night { color: var(--moon); }

.t {
  margin-top: 8px;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.meta {
  margin-top: 4px;
  font-size: 14px;
  color: var(--on-tile-soft);
}

.wx {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 39px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--tile-line);
  font-size: 14px;
  color: var(--on-tile-soft);
}

.meta + .wx { margin-top: 14px; }
.wx .temp { font-size: 16px; font-weight: 600; color: var(--on-tile); }
.wx .hl { margin-left: auto; }
.is-converting .wx { visibility: hidden; }

.home .tile {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 24px;
  padding: 22px 24px;
  background: var(--tile-deep);
}

.home .tile-top { grid-column: 1 / -1; }
.home .t { font-size: clamp(44px, 10vw, 68px); letter-spacing: -0.025em; }
.home .meta { grid-column: 1; font-size: 15px; }

.home .wx {
  grid-column: 2;
  grid-row: 2 / span 2;
  align-self: end;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 0;
  border: 0;
}

.home .wx .temp { font-size: 24px; }
.home .wx .hl { margin-left: 0; }
.home .wx-icon svg { width: 26px; height: 26px; }

@media (max-width: 520px) {
  .home .tile { grid-template-columns: 1fr; }
  .home .wx {
    grid-column: 1;
    grid-row: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--tile-line);
  }
  .home .wx .hl { margin-left: auto; }
  .field { flex: 1 1 100%; }
  .time-group .sel { flex: 1; }
  .sel-region .fbtn, .dp .fbtn { min-width: 0; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid .tile { padding: 14px; }
  .grid .t { font-size: 24px; }
  .grid .meta { font-size: 13px; }
  .grid .wx { flex-wrap: wrap; row-gap: 2px; }
  .grid .wx .hl { flex-basis: 100%; margin-left: 0; font-size: 13px; }
}

.foot {
  margin-top: 36px;
  font-size: 13px;
  color: var(--ink-soft);
  display: grid;
  gap: 4px;
}

.foot a { color: var(--ink); text-underline-offset: 2px; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

@media (prefers-reduced-motion: reduce) {
  .tile, .cal, .menu { animation: none; }
  .chev, .reset { transition: none; }
}
