:root {
  color-scheme: light;
  --paper: #fbfbf7;
  --page-bg:
    radial-gradient(circle at 14% 18%, rgba(255, 176, 210, .24), transparent 30%),
    radial-gradient(circle at 82% 12%, rgba(142, 205, 255, .22), transparent 32%),
    radial-gradient(circle at 88% 78%, rgba(173, 232, 185, .20), transparent 34%),
    radial-gradient(circle at 18% 84%, rgba(255, 224, 150, .20), transparent 30%),
    linear-gradient(135deg, #fffefe 0%, #fbfdff 42%, #fffdf8 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;
}

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

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

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

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

.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;
}

.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 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;
}

.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;
}

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

.archiveItem {
  min-width: 0;
  min-height: 0;
  padding: 14px 12px;
  border-top: 1px solid var(--line);
  text-align: center;
  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;
}

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

.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;
  }

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

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