:root {
  --bg: #f6f1e7;
  --bg2: #efe7d6;
  --paper: #fffdf8;
  --ink: #2a241c;
  --muted: #7b6f5f;
  --faint: #b9ac97;
  --line: rgba(80, 60, 30, 0.13);
  --shadow: 0 1px 2px rgba(60, 40, 10, 0.05), 0 12px 32px -12px rgba(60, 40, 10, 0.18);
  --ot: #a5782f;
  --ot-soft: rgba(165, 120, 47, 0.10);
  --nt: #3f5f86;
  --nt-soft: rgba(63, 95, 134, 0.09);
  --serif: "Cormorant Garamond", "EB Garamond", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --bg2: #1d1914;
    --paper: #211c16;
    --ink: #efe6d6;
    --muted: #a59985;
    --faint: #6b604f;
    --line: rgba(239, 230, 214, 0.10);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -16px rgba(0, 0, 0, 0.6);
    --ot: #d6aa5f;
    --ot-soft: rgba(214, 170, 95, 0.10);
    --nt: #8fb0d8;
    --nt-soft: rgba(143, 176, 216, 0.09);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light dark;
}

body {
  font-family: var(--sans);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--paper) 0%, var(--bg) 55%, var(--bg2) 100%) fixed;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.wrap {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 24px 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.stage {
  margin: auto 0;
  padding: 24px 0;
}

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

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: 0.18em;
}

.brand-sub {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.soon {
  font-size: 12px;
  color: var(--faint);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: not-allowed;
  border: 1px dashed var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  white-space: nowrap;
  user-select: none;
}

.soon em {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}

header.date {
  text-align: center;
  margin: 0 0 24px;
}

.weekday {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
}

.day {
  font-variant-numeric: lining-nums;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(46px, 9vw, 72px);
  line-height: 1.02;
  margin: 10px 0 6px;
  letter-spacing: -0.005em;
}

.year {
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--muted);
  font-variant-numeric: lining-nums;
}

.rel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  color: var(--muted);
  height: 22px;
}

.rel::before,
.rel::after {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--faint);
  opacity: 0.6;
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 6px 0 30px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font: 500 14px var(--sans);
  height: 46px;
  min-width: 46px;
  padding: 0 18px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(60, 40, 10, 0.05);
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: var(--faint);
}

.btn:active {
  transform: scale(0.96);
}

.btn:focus-visible {
  outline: 2px solid var(--nt);
  outline-offset: 2px;
}

.btn.icon {
  padding: 0;
  width: 46px;
}

.btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn.today[aria-pressed="true"] {
  background: transparent;
  color: var(--muted);
}

.btn.today .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ot);
}

.btn.today[aria-pressed="true"] .dot {
  background: var(--faint);
}

.picker {
  position: relative;
}

.picker input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  border: 0;
}

.picker input::-webkit-calendar-picker-indicator {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.readings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.card {
  position: relative;
  background:
    linear-gradient(160deg, var(--soft) 0%, transparent 55%),
    var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22px;
  bottom: 22px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  opacity: 0.75;
}

.card.ot {
  --accent: var(--ot);
  --soft: var(--ot-soft);
}

.card.nt {
  --accent: var(--nt);
  --soft: var(--nt-soft);
}

.label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

.ref {
  font-variant-numeric: lining-nums;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(34px, 5.2vw, 44px);
  line-height: 1.1;
  margin-top: 18px;
  color: var(--ink);
  word-break: break-word;
}

.ref.missing {
  font-size: 22px;
  font-style: italic;
  color: var(--muted);
}

.fade .card {
  opacity: 0;
  transform: translateX(var(--dx, 0));
}

.progress {
  margin: 30px auto 0;
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.bar {
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--ot), var(--nt));
  border-radius: inherit;
  transition: width 0.5s ease;
}

.pmeta {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

footer {
  padding-top: 12px;
  text-align: center;
  font-size: 11.5px;
  color: var(--faint);
  letter-spacing: 0.02em;
}

.kbd {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 5px;
  font-size: 10.5px;
  margin: 0 1px;
}

.touch-only {
  display: none;
}

@media (hover: none) {
  .touch-only {
    display: inline;
  }

  .desk-only {
    display: none;
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 18px 18px 18px;
  }

  .brand-sub {
    display: none;
  }

  header.date {
    margin: 0 0 20px;
  }

  .stage {
    padding: 20px 0 8px;
  }

  .readings {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .card {
    padding: 24px 22px 22px;
    border-radius: 18px;
  }

  .ref {
    font-size: 38px;
    margin-top: 12px;
  }

  .controls {
    margin-bottom: 24px;
  }

  .btn.today {
    padding: 0 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
