:root {
  --bg: #f2eefa;
  --bg-2: #fdf1e6;
  --surface: #ffffff;
  --ink: #10192b;
  --muted: #5c6c85;
  --line: #dde4ef;
  --night: #120e22;
  --nautical: #4b3f72;
  --dawn: #ff8c61;
  --dusk: #ff8c61;
  --day: #ffd84d;
  --marker: #fff8ec;
  --moon: #8b98bd;
  --moon-dim: #e6e9f1;
  --band-border: rgba(16, 25, 43, 0.16);
  --on-accent: #1a1408;
  /* Selected calendar day-number: --nautical reads as near-black (great
     contrast) against the light surface, but is only medium-purple against
     the dark one — too low-contrast there — so dark mode uses --day
     instead, which is high-contrast in both directions. */
  --cal-selected: var(--nautical);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0a1a;
    --bg-2: #1f150f;
    --surface: #141f36;
    --ink: #eef1f6;
    --muted: #90a3c2;
    --line: #263252;
    --night: #251f3f;
    --nautical: #5c4f8a;
    --dawn: #ff9a72;
    --dusk: #ff9a72;
    --day: #ffde6a;
    --marker: #fff8ec;
    --moon: #a3aed0;
    --moon-dim: #2a3860;
    --band-border: rgba(255, 255, 255, 0.22);
    --cal-selected: var(--day);
  }
}
:root[data-theme="dark"] {
  --bg: #0d0a1a;
  --bg-2: #1f150f;
  --surface: #141f36;
  --ink: #eef1f6;
  --muted: #90a3c2;
  --line: #263252;
  --night: #251f3f;
  --nautical: #5c4f8a;
  --dawn: #ff9a72;
  --dusk: #ff9a72;
  --day: #ffde6a;
  --marker: #fff8ec;
  --moon: #a3aed0;
  --moon-dim: #2a3860;
  --band-border: rgba(255, 255, 255, 0.22);
  --cal-selected: var(--day);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg) 60%, var(--bg-2) 100%);
  color: var(--ink);
  font-family: "Inter", sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 36px 16px 56px;
}

.page {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.masthead {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

h1 {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 2.1rem;
  margin: 0;
  text-wrap: balance;
  letter-spacing: -0.01em;
}

.subline {
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.toggle-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

.theme-toggle,
.view-toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--line);
  border-radius: 999px;
}

.theme-btn,
.view-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: transparent;
  border-radius: 999px;
}
.theme-btn { font-size: 0.62rem; padding: 5px 11px; }
.view-btn { font-size: 0.7rem; padding: 6px 16px; font-weight: 600; }

.theme-btn.active,
.view-btn.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}

.theme-btn:focus-visible,
.view-btn:focus-visible {
  outline: 2px solid var(--day);
  outline-offset: 1px;
}

.panel[hidden] { display: none; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 1px 2px rgba(16, 25, 43, 0.04);
}

.cap {
  font-family: "Inter", sans-serif;
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

.dial-wrap {
  position: relative;
  width: clamp(230px, 80vw, 300px);
  aspect-ratio: 1;
  flex: 0 0 auto;
  margin: 4px 0;
}

.dial-gradient {
  position: absolute;
  top: 8.26%;
  left: 8.26%;
  width: 83.48%;
  height: 83.48%;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--band-border);
}

svg#dial { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }

.tick { stroke: var(--line); stroke-width: 2; }
.tick-major { stroke: var(--muted); stroke-width: 2.5; }
.sun-event-mark { stroke: var(--on-accent); stroke-width: 2; stroke-linecap: round; }
.hour-label {
  fill: var(--muted);
  font-family: "Inter", sans-serif;
  font-size: 18px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  font-variant-numeric: tabular-nums;
}
#now-marker-halo, #moon-marker-halo { pointer-events: none; }

.dial-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 53.9%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  text-align: center;
}

.center-time {
  font-family: "Inter", sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 1.9rem;
  line-height: 1;
}

.center-caption {
  font-family: "Inter", sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.center-next {
  font-family: "Inter", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.66rem;
  color: var(--muted);
  margin-top: 4px;
}

.time-slider-label {
  align-self: flex-start;
  font-family: "Inter", sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-top: 2px;
  margin-bottom: -4px;
}

.time-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 2px 0 0;
  cursor: pointer;
}
.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--band-border);
}
.time-slider::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--band-border);
}
.time-slider:focus-visible { outline: 2px solid var(--day); outline-offset: 2px; }

.astro-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 22px;
  width: 100%;
  margin-top: 6px;
}

.astro-col-header {
  font-family: "Inter", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.astro-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}
.astro-row:first-of-type { border-top: none; }

.astro-label {
  color: var(--muted);
  font-size: 0.74rem;
  white-space: nowrap;
}

.astro-value {
  font-family: "Inter", sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.cal-month-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 6px;
}

.cal-month-label {
  font-family: "Inter", sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
}

.cal-nav-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--line);
  color: var(--ink);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-nav-btn:focus-visible { outline: 2px solid var(--day); outline-offset: 1px; }

.cal-header-row,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  width: 100%;
}

.cal-weekday {
  text-align: center;
  font-family: "Inter", sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding-bottom: 6px;
}

.cal-cell {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: "Inter", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 58px;
  padding: 6px 1px;
  border-top: 1px solid var(--line);
}
.cal-cell.is-blank { cursor: default; }
.cal-cell:focus-visible { outline: 2px solid var(--day); outline-offset: -2px; }

.cal-daynum {
  font-family: "Inter", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.cal-cell.is-today {
  box-shadow: inset 0 0 0 1.5px var(--day);
  border-radius: 10px;
}
.cal-cell.is-selected {
  background: color-mix(in srgb, var(--day) 16%, transparent);
  border-radius: 10px;
}
.cal-cell.is-selected .cal-daynum { color: var(--cal-selected); }

.cal-time {
  font-family: "Inter", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.56rem;
  color: var(--muted);
  white-space: nowrap;
}
.cal-time .cal-arrow-up { color: var(--day); }
.cal-time .cal-arrow-down { color: var(--moon); }

.date-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 12px;
}

.icon-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--line);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:focus-visible { outline: 2px solid var(--day); outline-offset: 1px; }

.today-link {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--day);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.today-link[hidden] { display: none; }

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 18, 0.45);
  z-index: 40;
}
.drawer-backdrop[hidden] { display: none; }

.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: min(340px, calc(100% - 32px));
  margin: 0 auto;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 12px 20px 28px;
  box-shadow: 0 -8px 30px rgba(8, 10, 18, 0.25);
}
.drawer[hidden] { display: none; }

.drawer-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 auto 14px;
}

.pick-header,
.pick-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.pick-header span {
  text-align: center;
  font-family: "Inter", sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
  padding-bottom: 6px;
}

.pick-grid {
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.pick-cell {
  appearance: none;
  border: none;
  cursor: pointer;
  background: var(--surface);
  color: var(--ink);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Inter", sans-serif;
  font-variant-numeric: tabular-nums;
  font-size: 0.85rem;
  font-weight: 500;
}
.pick-cell.is-blank { cursor: default; }
.pick-cell.is-today { box-shadow: inset 0 0 0 1.5px var(--day); }
.pick-cell.is-selected {
  background: var(--day);
  color: var(--on-accent);
  font-weight: 700;
  box-shadow: none;
}

.footnote {
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.5;
}

.footnote strong { color: var(--ink); font-weight: 500; }

/* Tablet and up: same single-widget layout, scaled up — not a different design. */
@media (min-width: 700px) {
  body { padding: 20px 16px 32px; }
  .page { max-width: 760px; gap: 18px; }
  h1 { font-size: 2.8rem; }
  .subline { font-size: 0.95rem; }
  .toggle-row { flex-direction: row; gap: 14px; margin-top: 10px; }
  .theme-btn { font-size: 0.72rem; padding: 7px 15px; }
  .panel { padding: 24px 28px 22px; gap: 10px; }
  .cap { font-size: 0.8rem; }
  .dial-wrap { width: 380px; }
  .center-time { font-size: 2.5rem; }
  .center-caption { font-size: 0.74rem; }
  .center-next { font-size: 0.8rem; }
  .astro-table { gap: 10px 32px; margin-top: 10px; }
  .astro-col-header { font-size: 0.78rem; }
  .astro-row { font-size: 0.95rem; padding: 7px 0; }
  .astro-label { font-size: 0.85rem; }
  .footnote { font-size: 0.88rem; }
  .view-btn { font-size: 0.8rem; padding: 8px 22px; }
  .cal-month-label { font-size: 1.75rem; }
  .cal-nav-btn { width: 46px; height: 46px; font-size: 1.65rem; }
  .cal-weekday { font-size: 0.95rem; padding-bottom: 4px; }
  .cal-cell { min-height: 92px; padding: 8px 4px; }
  .cal-daynum { font-size: 1.35rem; }
  .cal-time { font-size: 0.95rem; }
  .icon-btn { width: 46px; height: 46px; }
  .today-link { font-size: 0.9rem; }
  .drawer { padding: 18px 28px 34px; }
  .pick-cell { font-size: 1rem; }
  .pick-header span { font-size: 0.72rem; }
}
