:root {
  --paper: #f2efe7;
  --paper-raised: #faf8f2;
  --ink: #181c1b;
  --muted: #69706c;
  --muted-accessible: #5f6662;
  --line: #cfd0c8;
  --vermilion: #b93f2d;
  --deep-green: #21342c;
  --font-body: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-number: Bahnschrift, "DIN Alternate", sans-serif;
  --canvas: 1320px;
  --shadow: 0 12px 32px rgb(24 28 27 / 7%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 0;
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    repeating-linear-gradient(0deg, rgb(24 28 27 / 1.4%) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 17% 24%, rgb(255 255 255 / 38%) 0 1px, transparent 1.5px),
    radial-gradient(circle at 78% 67%, rgb(33 52 44 / 3.5%) 0 0.7px, transparent 1.2px);
  background-size: auto, 11px 13px, 17px 19px;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.has-dialog {
  overflow: hidden;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

a {
  color: inherit;
  text-decoration-color: rgb(185 63 45 / 55%);
  text-underline-offset: 0.2em;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

.number,
#result-summary,
.sync-status {
  font-variant-numeric: tabular-nums lining-nums;
}

.number {
  font-family: var(--font-number);
}

:focus-visible {
  outline: 3px solid var(--vermilion);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  color: var(--paper-raised);
  background: var(--deep-green);
  border: 1px solid var(--paper-raised);
  border-radius: 2px;
  transform: translateY(-160%);
  transition: transform 150ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

.masthead {
  width: min(calc(100% - 56px), var(--canvas));
  margin: 30px auto 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.masthead::after {
  display: block;
  height: 5px;
  border-top: 1px solid var(--ink);
  content: "";
  transform-origin: left;
  animation: draw-rule 700ms 80ms both cubic-bezier(0.22, 1, 0.36, 1);
}

.masthead__inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px 36px;
  padding: 25px 2px 23px;
}

.eyebrow {
  grid-column: 1 / -1;
  margin: 0 0 5px;
  color: var(--vermilion);
  font-family: var(--font-number);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1.2;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(3.2rem, 6.3vw, 6.5rem);
  font-weight: 900;
  letter-spacing: -0.075em;
  line-height: 0.94;
}

.masthead__subtitle {
  align-self: end;
  max-width: 20rem;
  margin: 0;
  padding: 3px 0 3px 13px;
  color: var(--deep-green);
  border-left: 3px solid var(--vermilion);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  line-height: 1.65;
}

.sync-status {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: var(--muted-accessible);
  font-family: var(--font-number), var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.07em;
}

main {
  width: min(calc(100% - 56px), var(--canvas));
  margin: 0 auto;
  padding: 32px 0 96px;
}

.archive-switcher {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: stretch;
  gap: 28px;
  margin-bottom: 28px;
  animation: rise-in 500ms 120ms both ease-out;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabs button {
  min-height: 44px;
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--deep-green);
  background: var(--paper-raised);
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.tabs button:hover {
  border-color: var(--deep-green);
}

.tabs button[aria-selected="true"] {
  color: #fffaf3;
  background: var(--vermilion);
  border-color: var(--vermilion);
  box-shadow: inset 0 0 0 2px rgb(255 250 243 / 28%);
}

.tabs button[aria-selected="true"]::before {
  display: inline-block;
  width: 0.42em;
  height: 0.42em;
  margin-right: 0.55em;
  background: currentColor;
  border-radius: 50%;
  content: "";
  vertical-align: 0.12em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-left: 1px solid var(--line);
}

.stat {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 7px 24px;
  border-right: 1px solid var(--line);
}

.stat__label {
  color: var(--muted-accessible);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.stat strong {
  margin-top: 2px;
  font-size: clamp(1.7rem, 2.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.filters {
  position: relative;
  margin-bottom: 22px;
  padding: 21px 24px 24px;
  color: #eff1eb;
  background: var(--deep-green);
  border-top: 4px double rgb(250 248 242 / 42%);
  border-bottom: 4px double rgb(250 248 242 / 42%);
  box-shadow: var(--shadow);
  animation: rise-in 500ms 190ms both ease-out;
}

.filters h2 {
  margin: 0 0 15px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.filters h2::before {
  display: inline-block;
  width: 24px;
  height: 1px;
  margin-right: 9px;
  background: var(--vermilion);
  content: "";
  vertical-align: 0.3em;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(250px, 2fr) repeat(4, minmax(126px, 1fr)) auto;
  align-items: end;
  gap: 14px;
}

.filter-field {
  min-width: 0;
}

.filter-field label {
  display: block;
  margin-bottom: 6px;
  color: #ced3cf;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.045em;
}

.filter-field input,
.filter-field select {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid #707c76;
  border-radius: 2px;
  color: var(--ink);
  background-color: var(--paper-raised);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.filter-field select {
  min-height: 44px;
  padding-right: 30px;
  appearance: auto;
}

.filter-field input:hover,
.filter-field select:hover {
  border-color: #b9c1bc;
}

.filter-field input::placeholder {
  color: var(--muted-accessible);
  opacity: 1;
}

.filter-field input:invalid,
.filter-field select:invalid {
  border-color: var(--vermilion);
  box-shadow: inset 3px 0 var(--vermilion);
}

.filter-actions button {
  min-width: 112px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid #f0eee5;
  border-radius: 2px;
  color: var(--paper-raised);
  background: var(--deep-green);
  font-weight: 800;
  letter-spacing: 0.06em;
  transition: color 150ms ease, background-color 150ms ease;
}

.filter-actions button:hover {
  color: var(--deep-green);
  background: var(--paper-raised);
}

#archive-panel {
  min-width: 0;
  animation: rise-in 500ms 260ms both ease-out;
}

.result-summary {
  margin: 0;
  padding: 0 2px 12px;
  color: var(--muted-accessible);
  border-bottom: 1px solid var(--line);
  font-family: var(--font-number), var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.result-summary:not(:empty)::before {
  display: inline-block;
  width: 0.52em;
  height: 0.52em;
  margin-right: 0.65em;
  color: var(--vermilion);
  background: currentColor;
  content: "";
  transform: rotate(45deg);
  vertical-align: 0.08em;
}

.archive-results[aria-busy="true"] {
  min-height: 240px;
  background:
    repeating-linear-gradient(0deg, transparent 0 49px, rgb(105 112 108 / 12%) 49px 50px),
    repeating-linear-gradient(90deg, transparent 0 31%, rgb(250 248 242 / 48%) 31% 33%);
}

.year-group {
  margin-top: 40px;
}

.year-group__heading {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 0 18px;
  padding-bottom: 9px;
  border-bottom: 3px double var(--ink);
  line-height: 1;
}

.year-group__year {
  font-size: clamp(2.35rem, 4vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.05em;
}

.year-group__unit {
  font-size: 0.82rem;
  font-weight: 800;
}

.year-group__records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: 16px;
}

.record-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 17px;
  min-width: 0;
  min-height: 184px;
  height: 100%;
  padding: 14px;
  overflow: hidden;
  background: rgb(250 248 242 / 80%);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 rgb(24 28 27 / 4%);
  transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.record-card::after {
  position: absolute;
  right: -18px;
  bottom: -18px;
  width: 38px;
  height: 38px;
  border: 1px solid rgb(185 63 45 / 24%);
  border-radius: 50%;
  content: "";
}

.record-card:hover {
  background: var(--paper-raised);
  border-color: #aaada7;
  box-shadow: 0 8px 22px rgb(24 28 27 / 8%);
}

.record-card__cover {
  position: relative;
  align-self: start;
  width: 100%;
  min-height: 0;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: #dedbcf;
  border: 1px solid #c4c2b9;
  box-shadow: 3px 4px 0 rgb(33 52 44 / 11%);
}

.record-card__cover a {
  display: block;
}

.record-card__image {
  width: 100%;
  height: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  color: var(--muted-accessible);
  background: #e7e3d8;
  font-size: 0.72rem;
}

.record-card--book .record-card__cover {
  width: 92%;
  aspect-ratio: 3 / 4;
  background: #e7e3d8;
}

.record-card--book .record-card__image {
  aspect-ratio: 3 / 4;
  object-fit: contain;
}

.record-card__detail {
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: flex-start;
}

.record-card__title {
  display: -webkit-box;
  width: 100%;
  margin: 0 0 8px;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 1.06rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.42;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.record-card__title a {
  text-decoration: none;
}

.record-card__title a:hover {
  color: var(--vermilion);
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.record-card__meta {
  width: 100%;
  margin: 0 0 3px;
  overflow-wrap: anywhere;
  color: var(--muted-accessible);
  font-size: 0.74rem;
  line-height: 1.5;
}

.record-card__meta--subtitle {
  display: -webkit-box;
  max-height: 3em;
  overflow: hidden;
  color: #444a47;
  font-weight: 700;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.record-card__badges {
  display: flex;
  width: 100%;
  max-height: 6.75rem;
  flex-wrap: wrap;
  align-items: center;
  align-content: flex-start;
  gap: 5px 6px;
  margin: 5px 0 8px;
  padding-right: 3px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #9aa59e transparent;
  scrollbar-width: thin;
}

.record-card__badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 4px 8px;
  color: var(--muted-accessible);
  background: #ebe9e1;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
}

.record-card__badge--score {
  color: #8a3023;
  background: #f4e5da;
}

.record-card__badge--genre {
  min-height: 44px;
  padding: 6px 11px;
  color: var(--deep-green);
  background: #e1e8e1;
  border-color: #bac9be;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.record-card__badge--genre:hover {
  color: #fffaf3;
  background: var(--deep-green);
  border-color: var(--deep-green);
}

.record-card__facts {
  width: 100%;
  max-height: 4.5em;
  overflow: hidden;
}

.record-card__fact {
  display: -webkit-box;
  width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--muted-accessible);
  font-size: 0.74rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
}

.record-card__actions {
  display: flex;
  width: 100%;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.record-card__summary-button {
  min-height: 44px;
  padding: 7px 18px;
  color: var(--ink);
  background: var(--paper-raised);
  border: 1px solid #aeb5af;
  border-radius: 3px;
  font-weight: 800;
  letter-spacing: 0.08em;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.record-card__summary-button:hover {
  color: #fffaf3;
  background: var(--vermilion);
  border-color: var(--vermilion);
}

.record-card__meta--tags {
  width: auto;
  margin-top: 6px;
  padding: 2px 7px;
  color: var(--deep-green);
  background: #e2e6df;
  border: 1px solid #cdd3cb;
  border-radius: 999px;
  font-size: 0.68rem;
}

.record-card__meta--score {
  width: auto;
  margin-top: auto;
  padding-top: 9px;
  color: var(--vermilion);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.summary-dialog {
  width: min(780px, calc(100vw - 3rem));
  max-width: none;
  max-height: calc(100vh - 3rem);
  max-height: calc(100dvh - 3rem);
  padding: 0;
  overflow: visible;
  color: var(--ink);
  background: transparent;
  border: 0;
}

.summary-dialog::backdrop {
  background: rgb(12 25 20 / 66%);
  backdrop-filter: blur(3px);
}

.summary-dialog__surface {
  display: flex;
  max-height: calc(100vh - 3rem);
  max-height: calc(100dvh - 3rem);
  flex-direction: column;
  overflow: hidden;
  background: #fbfaf5;
  border: 1px solid rgb(33 52 44 / 28%);
  border-radius: 9px;
  box-shadow: 0 26px 80px rgb(8 18 14 / 34%), 0 2px 0 rgb(255 255 255 / 60%) inset;
}

.summary-dialog__header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 25px 28px 21px;
  border-bottom: 1px solid var(--line);
}

.summary-dialog__header > div {
  min-width: 0;
}

.summary-dialog__kicker {
  margin: 0 0 5px;
  color: var(--deep-green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.summary-dialog__header h2 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  font-size: clamp(1.45rem, 3vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.3;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.summary-dialog__meta {
  display: -webkit-box;
  margin: 7px 0 0;
  overflow: hidden;
  color: var(--muted-accessible);
  font-size: 0.78rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

#summary-dialog-close {
  display: inline-grid;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 48px;
  place-items: center;
  padding: 0;
  color: var(--deep-green);
  background: transparent;
  border: 1px solid #b9c2bb;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

#summary-dialog-close:hover {
  color: #fffaf3;
  background: var(--deep-green);
  border-color: var(--deep-green);
}

.summary-dialog__body {
  width: 100%;
  min-height: 0;
  flex: 1 1 auto;
  margin: 0;
  padding: 27px 30px 34px;
  overflow-x: hidden;
  overflow-y: auto;
  color: #303633;
  font-size: clamp(1rem, 1.5vw, 1.08rem);
  line-height: 1.95;
  text-align: justify;
  overflow-wrap: anywhere;
  white-space: pre-line;
  scrollbar-color: #8c9891 transparent;
  scrollbar-width: thin;
}

.empty-state,
.load-state {
  margin: 28px 0 0;
  padding: 45px 24px;
  color: var(--muted-accessible);
  background: rgb(250 248 242 / 62%);
  border: 1px dashed #aeb1aa;
  text-align: center;
}

.empty-state::before,
.load-state::before {
  display: block;
  width: 24px;
  height: 2px;
  margin: 0 auto 16px;
  color: var(--deep-green);
  background: currentColor;
  content: "";
}

.load-state {
  color: #7e291f;
  border-color: rgb(185 63 45 / 45%);
}

.load-state::before {
  width: 28px;
  height: 28px;
  color: var(--vermilion);
  background:
    linear-gradient(currentColor, currentColor) center 6px / 2px 9px no-repeat,
    linear-gradient(currentColor, currentColor) center 18px / 2px 2px no-repeat;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
}

@keyframes draw-rule {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1100px) {
  .filter-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .filter-field--keyword {
    grid-column: 1 / -1;
  }

  .filter-actions {
    grid-column: 4;
  }

  .year-group__records {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    font-size: 15px;
  }

  .masthead,
  main {
    width: min(calc(100% - 28px), var(--canvas));
  }

  .masthead {
    margin-top: 14px;
  }

  .masthead__inner {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 14px;
    padding: 19px 0 17px;
  }

  .masthead h1 {
    font-size: clamp(2.6rem, 14.5vw, 4.25rem);
    letter-spacing: -0.08em;
  }

  .masthead__subtitle {
    grid-column: 1 / -1;
    max-width: none;
    padding: 2px 0 2px 10px;
    font-size: 0.72rem;
    letter-spacing: 0.035em;
  }

  .sync-status {
    margin-top: 6px;
    font-size: 0.68rem;
  }

  main {
    padding-top: 24px;
    padding-bottom: 58px;
  }

  .archive-switcher {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }

  .tabs {
    width: 100%;
  }

  .tabs button {
    flex: 1;
    padding-inline: 12px;
  }

  .stats {
    border-top: 1px solid var(--line);
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat {
    padding: 13px 10px;
  }

  .stat:first-child {
    border-left: 1px solid var(--line);
  }

  .stat__label {
    font-size: 0.64rem;
    letter-spacing: 0.02em;
  }

  .stat strong {
    font-size: 1.55rem;
  }

  .filters {
    padding: 18px 16px 20px;
  }

  .filter-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .filter-field--keyword,
  .filter-actions {
    grid-column: auto;
  }

  .filter-actions button {
    width: 100%;
  }

  .year-group {
    margin-top: 32px;
  }

  .year-group__records {
    grid-template-columns: minmax(0, 1fr);
  }

  .year-group__year {
    font-size: 2.6rem;
  }

  .record-card {
    grid-template-columns: 96px minmax(0, 1fr);
    gap: 14px;
    min-height: 160px;
    padding: 12px;
  }

  .record-card__cover {
    min-height: 0;
  }

  .record-card__title {
    font-size: 1rem;
  }

  .summary-dialog {
    width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
  }

  .summary-dialog__surface {
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
  }

  .summary-dialog__header {
    gap: 14px;
    padding: 20px 18px 17px;
  }

  .summary-dialog__body {
    padding: 21px 19px 27px;
    font-size: 1rem;
    line-height: 1.85;
    text-align: start;
  }
}

@media (max-width: 360px) {
  .record-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .stat {
    padding-inline: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
