:root {
  color-scheme: light;
  --paper: #fbfbf7;
  --page-bg:
    radial-gradient(circle at 14% 18%, rgba(255, 198, 225, .10), transparent 30%),
    radial-gradient(circle at 82% 12%, rgba(192, 229, 255, .09), transparent 32%),
    radial-gradient(circle at 88% 78%, rgba(205, 244, 215, .08), transparent 34%),
    radial-gradient(circle at 18% 84%, rgba(255, 239, 190, .08), transparent 30%),
    linear-gradient(135deg, #fffefe 0%, #fdfefe 42%, #fffefb 100%);
  --ink: #1f2321;
  --muted: #8b8f8b;
  --line: #dcded8;
  --button-bg: rgba(251, 251, 247, .86);
  --panel-bg: rgba(251, 251, 247, .98);
}

:root[data-theme="night"] {
  color-scheme: dark;
  --paper: #111312;
  --page-bg: var(--paper);
  --ink: #e4e0d4;
  --muted: #8d938f;
  --line: #343936;
  --button-bg: rgba(17, 19, 18, .82);
  --panel-bg: rgba(17, 19, 18, .98);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--ink);
  font-family: ui-serif, "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", Georgia, serif;
  letter-spacing: 0;
}

body, .pillBtn, .pagerBtn, .archivePanel, .archiveHeader, .archiveTools, .archivePager, .archiveItem, .closeBtn, select {
  transition: background 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              color 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

button {
  font: inherit;
  letter-spacing: 0;
}

.page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 72px 24px;
}

.today {
  width: min(100%, 760px);
  display: grid;
  justify-items: center;
  gap: 22px;
}

.poem {
  width: 100%;
  text-align: center;
  white-space: pre-wrap;
  font-size: clamp(20px, 3.8vw, 36px);
  line-height: 2.05;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.poemLine {
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  filter: blur(2px);
  animation: poemFadeIn 1.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.poemMeta {
  min-height: 22px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.65;
  text-align: center;
  opacity: 0;
  animation: metaFadeIn 1.2s ease forwards;
  animation-delay: 1.2s;
}

.poem[data-status="missing"] {
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

@keyframes poemFadeIn {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes metaFadeIn {
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    scroll-behavior: auto !important;
  }
  .poemLine, .poemMeta {
    opacity: 1 !important;
    transform: none !important;
  }
}

.actions {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  gap: 10px;
}

.pillBtn,
.pagerBtn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--button-bg);
  color: var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

a.pillBtn {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.pillBtn:hover,
.pagerBtn:hover,
.closeBtn:hover {
  border-color: var(--muted);
}

.pagerBtn:disabled {
  cursor: default;
  opacity: .45;
}

.archivePanel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--panel-bg);
}

.archivePanel.open {
  display: grid;
}

.archiveHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.archiveHeader h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 400;
}

.archiveStats {
  min-height: 18px;
  margin: 6px 0 0;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

.closeBtn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.archiveTools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.archiveTools label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.archiveTools select {
  min-width: 138px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--button-bg);
  color: var(--ink);
  padding: 0 30px 0 10px;
  font: inherit;
  font-size: 14px;
}

.archiveList {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(var(--archive-columns, 3), minmax(0, 1fr));
  grid-auto-rows: auto;
  gap: 18px;
}

.archiveItem {
  min-width: 0;
  min-height: 168px;
  padding: 12px 12px 14px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: pre-wrap;
  font-size: clamp(14px, 1.8vw, 20px);
  line-height: 1.85;
  overflow: hidden;
  display: grid;
  align-content: center;
}

.archiveTime {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.4;
}

.archiveTone {
  margin-top: 8px;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 12px;
  line-height: 1.4;
}

.archiveText {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: center;
}

.archiveEmpty {
  grid-column: 1 / -1;
  place-self: center;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 14px;
}

.archivePager {
  min-height: 64px;
  padding: 12px 24px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border-top: 1px solid var(--line);
  font-family: ui-sans-serif, system-ui, sans-serif;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 620px) {
  .page {
    padding: 56px 18px;
  }

  .poem {
    font-size: clamp(20px, 8vw, 32px);
    line-height: 2;
  }

  .actions {
    right: 16px;
    bottom: 16px;
  }

  .archiveHeader {
    padding: 18px;
  }

  .archiveTools {
    padding: 12px 18px;
  }

  .archiveTools label {
    flex: 1 1 128px;
  }

  .archiveTools select {
    width: 100%;
    min-width: 0;
  }

  .archiveList {
    padding: 18px;
    gap: 12px;
  }

  .archiveItem {
    min-height: 142px;
  }

  .archivePager {
    min-height: 54px;
    gap: 10px;
  }
}

/* Anime ink-wash art direction: the supplied artwork stays behind the poem. */
:root {
  --paper: #f7f1e5;
  --page-bg: linear-gradient(135deg, #e8e5db 0%, #f8f3e9 40%, #dfe5df 100%);
  --ink: #152725;
  --muted: #66736a;
  --line: rgba(32, 59, 53, .21);
  --button-bg: rgba(248, 244, 234, .78);
  --panel-bg: rgba(247, 242, 232, .95);
  --jade: #287d76;
  --vermilion: #ad433b;
}

:root[data-theme="night"] {
  --paper: #101a1b;
  --page-bg: linear-gradient(135deg, #0d1719 0%, #162325 52%, #10191c 100%);
  --ink: #f2ecde;
  --muted: #a9afa1;
  --line: rgba(201, 223, 208, .24);
  --button-bg: rgba(17, 31, 32, .79);
  --panel-bg: rgba(15, 27, 29, .96);
  --jade: #76c8b8;
  --vermilion: #e57869;
}

body {
  isolation: isolate;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 72% 8%, rgba(255, 255, 255, .54), transparent 42%),
    linear-gradient(165deg, #b8bec0 0%, #d6dadb 48%, #f0f1f0 100%);
}

body::before,
body::after {
  z-index: 0;
}

body::before {
  display: none;
}

body::after {
  display: none;
}

:root[data-theme="night"] body::before {
  opacity: .35;
  filter: invert(.9) grayscale(.25);
}

:root[data-theme="night"] body::after {
  display: none;
}

.page,
.actions,
.archivePanel {
  position: relative;
  z-index: 1;
}

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 3vw, 28px);
  padding: clamp(34px, 6vw, 66px) max(24px, 8vw);
}

.masthead {
  width: min(100%, 590px);
  display: block;
  color: var(--ink);
}

.masthead::after {
  content: "";
  display: block;
  width: min(100%, 430px);
  height: 1px;
  margin-top: 16px;
  background: linear-gradient(90deg, var(--ink), rgba(38, 82, 74, .16), transparent);
}

.masthead h1 {
  margin: 0;
  font-size: clamp(27px, 4vw, 43px);
  font-weight: 500;
  letter-spacing: .18em;
  line-height: 1;
}

.mastheadEyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--jade);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
}

.today {
  position: relative;
  width: min(100%, 590px);
  min-height: min(36vh, 318px);
  padding: clamp(28px, 5.5vw, 46px) clamp(22px, 5vw, 48px);
  border: 1px solid rgba(244, 250, 250, .20);
  border-radius: 24px;
  background: rgba(244, 250, 250, .055);
  box-shadow: 0 14px 34px rgba(20, 37, 42, .08);
  overflow: hidden;
}

:root[data-theme="night"] .today {
  border-color: rgba(218, 239, 239, .18);
  background: rgba(12, 24, 27, .06);
  box-shadow: 0 14px 34px rgba(0, 0, 0, .12);
}

.today::before,
.today::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.today::before {
  display: none;
}

.today::after {
  display: none;
}

.poem,
.poemMeta {
  position: relative;
  z-index: 1;
}

.poem {
  color: var(--ink);
  font-size: clamp(21px, 3.2vw, 32px);
  font-weight: 500;
  letter-spacing: .16em;
  line-height: 2.12;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .48);
}

.poemMeta {
  margin-top: 8px;
  color: var(--jade);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  letter-spacing: .1em;
}

.actions {
  position: static;
  right: auto;
  bottom: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(247, 242, 232, .45);
  box-shadow: 0 8px 26px rgba(22, 44, 38, .12);
  backdrop-filter: blur(10px);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.pillBtn,
.pagerBtn {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  padding: 8px 13px;
  font-family: ui-serif, "Songti SC", serif;
}

.pillBtn:hover,
.pagerBtn:hover,
.pillBtn:focus-visible,
.pagerBtn:focus-visible,
.closeBtn:focus-visible {
  border-color: var(--jade);
  background: rgba(40, 125, 118, .1);
  outline: 2px solid rgba(40, 125, 118, .28);
  outline-offset: 2px;
}

.archivePanel {
  background:
    radial-gradient(ellipse at 78% 6%, rgba(255, 255, 255, .34), transparent 42%),
    linear-gradient(165deg, rgba(176, 185, 187, .88) 0%, rgba(211, 217, 218, .88) 48%, rgba(238, 240, 240, .84) 100%);
}

.archiveHeader,
.archiveTools,
.archivePager {
  background: rgba(247, 242, 232, .72);
  backdrop-filter: blur(10px);
}

.archiveHeader h1 {
  font-family: ui-serif, "Songti SC", serif;
  font-weight: 500;
  letter-spacing: .12em;
}

.archiveItem {
  background: rgba(255, 254, 247, .48);
  border: 1px solid rgba(32, 59, 53, .15);
  box-shadow: 0 10px 22px rgba(23, 43, 38, .06);
}

:root[data-theme="night"] .today,
:root[data-theme="night"] .archiveHeader,
:root[data-theme="night"] .archiveTools,
:root[data-theme="night"] .archivePager {
  background: rgba(15, 27, 29, .78);
}

:root[data-theme="night"] .today {
  background: rgba(15, 27, 29, .06);
  box-shadow: 0 18px 42px rgba(0, 0, 0, .3), inset 0 0 0 5px rgba(190, 225, 214, .04);
}

@media (max-width: 620px) {
  body::after {
    width: 66vw;
    height: 54vh;
    right: -19vw;
    bottom: 4vh;
    opacity: .19;
  }

  .page {
    gap: 15px;
    padding: 34px 18px 28px;
  }

  .masthead h1 {
    font-size: 29px;
  }

  .today {
    min-height: 38vh;
    padding: 30px 20px;
    border-radius: 20px;
  }

  .poem {
    font-size: clamp(22px, 7.3vw, 31px);
    line-height: 2.05;
  }

  .actions {
    gap: 0;
    width: 100%;
  }

  .pillBtn {
    flex: 1 1 auto;
    padding: 9px 8px;
    font-size: 13px;
  }
}

.weatherCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.weatherHaze {
  position: fixed;
  inset: -18vmax;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: .58;
  background:
    radial-gradient(ellipse at 18% 36%, rgba(255, 255, 255, .30), transparent 26%),
    radial-gradient(ellipse at 72% 62%, rgba(248, 252, 253, .25), transparent 31%),
    linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, .08) 44%, transparent 68%);
  filter: blur(.45px);
  mix-blend-mode: screen;
  animation: weatherHazeDrift 30s ease-in-out infinite alternate;
}

.weatherHaze::before,
.weatherHaze::after {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, .21), rgba(246, 251, 252, .05) 46%, transparent 70%);
  filter: blur(20px);
  animation: weatherHazePuff 23s ease-in-out infinite alternate;
}

.weatherHaze::after {
  inset: 28% 4% 6% 35%;
  opacity: .72;
  animation-delay: -9s;
  animation-duration: 29s;
}

@keyframes weatherHazeDrift {
  from { transform: translate3d(-2.5%, -1%, 0) scale(1.02); }
  to { transform: translate3d(2.8%, 1.8%, 0) scale(1.08); }
}

@keyframes weatherHazePuff {
  from { transform: translate3d(-5%, 1%, 0) scale(.94); opacity: .52; }
  to { transform: translate3d(8%, -3%, 0) scale(1.09); opacity: .84; }
}

@media print, (prefers-reduced-motion: reduce) {
  .weatherCanvas,
  .weatherHaze {
    display: none;
  }
}
