:root {
  --desk: #b7aa94;
  --desk-line: rgba(77, 59, 38, 0.08);
  --paper: #fffdf5;
  --paper-shade: #f5f0df;
  --paper-line: #d9ccb0;
  --ink: #202427;
  --ink-soft: #626566;
  --red: #b51f2a;
  --red-dark: #7d151d;
  --teal: #176972;
  --gold: #9b7442;
  --danger: #9e2025;
  --shadow: 0 22px 64px rgba(62, 44, 25, 0.24);
}

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

html {
  color-scheme: light;
}

body {
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background-color: var(--desk);
  background-image:
    repeating-linear-gradient(90deg, transparent 0 10px, var(--desk-line) 10px 11px),
    linear-gradient(125deg, rgba(255, 255, 255, 0.2), transparent 42%);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  letter-spacing: 0;
}

button,
input,
select {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

button:not(:disabled),
a,
select:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(23, 105, 114, 0.34);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.site-shell {
  width: min(1780px, 100%);
  margin: 0 auto;
  padding: 18px 20px 10px;
}

.book {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto minmax(0, 1fr);
  column-gap: 56px;
  min-height: 650px;
  height: calc(100vh - 66px);
  overflow: hidden;
  border: 1px solid rgba(109, 80, 43, 0.36);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.82);
}

.book::before {
  position: absolute;
  z-index: 2;
  top: 18px;
  bottom: 18px;
  left: 50%;
  width: 1px;
  content: "";
  background: rgba(117, 91, 57, 0.22);
  box-shadow:
    -8px 0 14px rgba(80, 56, 28, 0.06),
    8px 0 14px rgba(80, 56, 28, 0.06);
  pointer-events: none;
}

.book-tabs {
  position: relative;
  z-index: 3;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(5, minmax(72px, 126px));
  justify-content: center;
  height: 52px;
  border-bottom: 1px solid var(--paper-line);
  background: rgba(251, 247, 235, 0.9);
}

.book-tab {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  color: #625d54;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
}

.book-tab::after {
  position: absolute;
  right: 24px;
  bottom: -1px;
  left: 24px;
  height: 3px;
  content: "";
  background: transparent;
}

.book-tab[aria-selected="true"] {
  color: var(--red-dark);
}

.book-tab[aria-selected="true"]::after {
  background: var(--red);
}

.left-page,
.right-page {
  min-width: 0;
  min-height: 0;
  padding: 30px 52px 36px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(155, 116, 66, 0.36) transparent;
}

.left-page {
  padding-right: 28px;
  background: linear-gradient(90deg, rgba(247, 242, 226, 0.66), transparent 84%);
}

.right-page {
  position: relative;
  padding-left: 28px;
  background: linear-gradient(90deg, transparent, rgba(245, 239, 220, 0.42));
}

.page-mark {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-bottom: 30px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--paper-line);
  color: #76664f;
  font-size: 15px;
}

.book-intro {
  max-width: 580px;
}

.section-kicker,
.state-kicker,
.chain-eyebrow {
  color: var(--gold);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.book-intro h1 {
  margin-top: 12px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 58px;
  font-weight: 700;
  line-height: 1.08;
  white-space: pre-line;
}

.title-rule {
  display: block;
  width: 74px;
  height: 5px;
  margin: 22px 0 18px;
  border-radius: 2px;
  background: var(--red);
}

.subtitle {
  color: var(--red-dark);
  font-size: 18px;
  font-weight: 700;
}

.description {
  max-width: 540px;
  margin-top: 15px;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.8;
}

.search-box,
.chain-setup {
  width: min(100%, 580px);
  margin-top: 30px;
  padding-top: 23px;
  border-top: 1px solid var(--paper-line);
}

.input-label,
.select-label,
.control-group legend,
.chain-form label {
  display: block;
  margin-bottom: 8px;
  color: #4e4b46;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  font-weight: 700;
}

.input-frame {
  position: relative;
  padding: 5px;
  border: 1px solid #b9aa8c;
  background: rgba(255, 254, 248, 0.8);
  box-shadow: inset 0 0 0 1px rgba(181, 31, 42, 0.08);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input-frame:focus-within {
  border-color: var(--red);
  box-shadow: inset 0 0 0 1px rgba(181, 31, 42, 0.24), 0 6px 20px rgba(94, 60, 30, 0.09);
}

.input-frame::before,
.input-frame::after,
.input-corner::before,
.input-corner::after {
  position: absolute;
  width: 10px;
  height: 10px;
  content: "";
  pointer-events: none;
}

.input-frame::before {
  top: 2px;
  left: 2px;
  border-top: 1px solid rgba(181, 31, 42, 0.38);
  border-left: 1px solid rgba(181, 31, 42, 0.38);
}

.input-frame::after {
  top: 2px;
  right: 2px;
  border-top: 1px solid rgba(181, 31, 42, 0.38);
  border-right: 1px solid rgba(181, 31, 42, 0.38);
}

.input-corner::before {
  bottom: 2px;
  left: 2px;
  border-bottom: 1px solid rgba(181, 31, 42, 0.38);
  border-left: 1px solid rgba(181, 31, 42, 0.38);
}

.input-corner::after {
  right: 2px;
  bottom: 2px;
  border-right: 1px solid rgba(181, 31, 42, 0.38);
  border-bottom: 1px solid rgba(181, 31, 42, 0.38);
}

.search-input {
  width: 100%;
  height: 70px;
  padding: 8px 18px;
  border: 0;
  outline: 0;
  background:
    linear-gradient(transparent calc(50% - 1px), rgba(181, 31, 42, 0.14) 50%, transparent calc(50% + 1px));
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 34px;
  text-align: center;
}

.search-input::placeholder {
  color: #a59c8c;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", sans-serif;
  font-size: 17px;
}

.search-input:disabled {
  color: #8e877b;
  cursor: wait;
}

.data-status {
  min-height: 24px;
  margin: 8px 2px 12px;
  color: var(--ink-soft);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
}

.poetry-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(128px, 0.8fr);
  gap: 14px;
  align-items: end;
  margin-top: 14px;
}

.poetry-controls .control-group {
  min-width: 0;
  margin: 0;
}

.poetry-corpus-control {
  min-width: 0;
}

.poetry-controls .select-control {
  min-width: 0;
}

.data-status.is-ready {
  color: var(--teal);
}

.data-status.is-error {
  color: var(--danger);
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 46px;
  border-radius: 4px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.primary-button {
  width: 100%;
  padding: 10px 18px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 8px 18px rgba(181, 31, 42, 0.16);
}

.primary-button:not(:disabled):hover {
  background: var(--red-dark);
  transform: translateY(-1px);
}

.primary-button:disabled {
  color: rgba(255, 255, 255, 0.72);
  background: #9f9688;
  box-shadow: none;
  cursor: wait;
}

.secondary-button {
  padding: 9px 20px;
  border: 1px solid #a89779;
  color: var(--red-dark);
  background: transparent;
}

.secondary-button:hover {
  border-color: var(--red);
  background: rgba(181, 31, 42, 0.05);
}

.control-group {
  margin-bottom: 18px;
  border: 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  padding: 3px;
  border: 1px solid #b9aa8c;
  border-radius: 4px;
  background: rgba(226, 217, 197, 0.42);
}

.segmented-control label {
  position: relative;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border-radius: 2px;
  color: #6b655b;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.segmented-control input:checked + span {
  color: var(--red-dark);
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(69, 49, 27, 0.12);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(23, 105, 114, 0.34);
  outline-offset: 2px;
}

.select-control {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #b9aa8c;
  border-radius: 4px;
  outline: 0;
  background: var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.state-panel {
  display: flex;
  min-height: calc(100% - 68px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 42px 30px;
  text-align: center;
}

.state-seal,
.empty-watermark {
  display: grid;
  width: 74px;
  height: 74px;
  margin-bottom: 20px;
  place-items: center;
  border: 2px solid var(--red);
  color: var(--red);
  font-family: "Songti SC", "STSong", serif;
  font-size: 38px;
  transform: rotate(-2deg);
}

.loader-panel h2,
.empty-panel h2,
.error-panel h2 {
  margin-top: 8px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 28px;
}

.state-detail,
.empty-panel p,
.error-panel p {
  max-width: 480px;
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 15px;
}

.load-progress {
  position: relative;
  width: min(430px, 100%);
  height: 7px;
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid rgba(155, 116, 66, 0.42);
  border-radius: 3px;
  background: rgba(219, 208, 184, 0.4);
}

.load-progress span {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: linear-gradient(90deg, var(--red), #d15545, var(--teal));
  transition: transform 0.18s ease;
}

.load-progress.is-indeterminate span {
  width: 42%;
  transform: translateX(-110%);
  animation: progress-slide 1.35s ease-in-out infinite;
}

.load-progress-meta {
  display: flex;
  width: min(430px, 100%);
  justify-content: space-between;
  margin: 8px 0 22px;
  color: #837968;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
}

.empty-watermark {
  border-color: rgba(23, 105, 114, 0.42);
  color: var(--teal);
  opacity: 0.72;
}

.error-mark {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 14px;
  place-items: center;
  border: 1px solid var(--danger);
  border-radius: 50%;
  color: var(--danger);
  font-family: Georgia, serif;
  font-size: 27px;
  font-weight: 700;
}

.results-panel {
  min-height: calc(100% - 68px);
}

.result-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.result-heading h2 {
  flex: 0 0 auto;
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
}

.result-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--red);
}

.heading-rule {
  height: 1px;
  flex: 1;
  background: var(--paper-line);
}

.result-content {
  border-top: 3px solid var(--ink);
}

.hanzi-result {
  padding: 26px 8px 24px;
  border-bottom: 1px solid var(--paper-line);
}

.hanzi-head {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.hanzi-character {
  min-width: 92px;
  color: var(--red);
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 72px;
  line-height: 1;
  text-align: center;
}

.hanzi-info {
  min-width: 0;
  padding-top: 4px;
}

.entry-name {
  margin-bottom: 8px;
  font-size: 21px;
  font-weight: 700;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 16px;
  align-items: baseline;
  font-size: 16px;
}

.result-meta .page {
  font-weight: 700;
}

.result-meta .position {
  color: #625b51;
}

.result-meta .pinyin,
.idiom-pinyin {
  color: var(--teal);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

.definition {
  margin-top: 18px;
  padding: 17px 18px;
  border-left: 3px solid rgba(181, 31, 42, 0.38);
  background: rgba(238, 230, 209, 0.35);
  font-size: 17px;
  line-height: 1.85;
  white-space: pre-wrap;
}

.search-results-list {
  list-style: none;
}

.search-result-row {
  border-bottom: 1px dotted #cdbf9f;
}

.idiom-result-button {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(160px, 1.2fr) auto auto;
  gap: 18px;
  width: 100%;
  min-height: 64px;
  align-items: center;
  padding: 12px 8px;
  text-align: left;
  background: transparent;
}

.idiom-result-button:hover,
.idiom-result-button[aria-expanded="true"] {
  background: rgba(222, 211, 185, 0.28);
}

.idiom-word {
  color: var(--red-dark);
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
  font-weight: 700;
}

.idiom-abbr {
  color: #8d806b;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  text-transform: uppercase;
}

.row-action {
  color: var(--teal);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
}

.idiom-detail,
.chain-detail {
  padding: 2px 18px 20px;
  border-left: 2px solid var(--teal);
  color: #434644;
}

.poetry-result-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  width: 100%;
  min-height: 76px;
  align-items: center;
  padding: 13px 8px;
  background: transparent;
  text-align: left;
}

.poetry-result-button:hover,
.poetry-result-button[aria-expanded="true"] {
  background: rgba(222, 211, 185, 0.28);
}

.poetry-result-heading {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.poetry-title {
  overflow-wrap: anywhere;
  color: var(--red-dark);
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
}

.poetry-meta {
  color: #6e675d;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
}

.poetry-labels {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.poetry-corpus,
.poetry-featured {
  padding: 2px 7px;
  border: 1px solid rgba(155, 116, 66, 0.42);
  color: var(--gold);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  line-height: 1.5;
}

.poetry-featured {
  border-color: rgba(181, 31, 42, 0.34);
  color: var(--red-dark);
}

.poetry-detail {
  margin: 0 8px 22px;
  padding: 18px 22px 20px;
  border-top: 1px solid var(--paper-line);
  border-left: 2px solid var(--teal);
  background: rgba(247, 243, 229, 0.45);
}

.poetry-note {
  margin-bottom: 13px;
  color: var(--gold);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  text-align: center;
}

.poetry-text {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 18px;
  line-height: 1.75;
  text-align: center;
}

.poetry-text p {
  overflow-wrap: anywhere;
}

.detail-loading,
.detail-error {
  padding: 12px 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.detail-explanation {
  line-height: 1.8;
  white-space: pre-wrap;
}

.idiom-detail details {
  margin-top: 10px;
  border-top: 1px solid rgba(217, 204, 176, 0.72);
  padding-top: 8px;
}

.idiom-detail summary {
  color: var(--teal);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  cursor: pointer;
}

.idiom-detail details p {
  margin-top: 8px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.xiehouyu-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 22px minmax(0, 0.9fr);
  gap: 12px;
  align-items: baseline;
  padding: 17px 8px;
  border-bottom: 1px dotted #cdbf9f;
}

.xiehouyu-riddle {
  font-size: 17px;
}

.xiehouyu-dash {
  color: var(--gold);
  text-align: center;
}

.xiehouyu-answer {
  color: var(--red-dark);
  font-size: 17px;
  font-weight: 700;
}

.chain-panel {
  min-height: calc(100% - 68px);
}

.chain-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 17px;
  border-bottom: 3px solid var(--ink);
}

.chain-heading h2 {
  margin-top: 3px;
  font-family: "Songti SC", "STSong", serif;
  font-size: 23px;
}

.chain-badge {
  flex: 0 0 auto;
  padding: 4px 9px;
  border: 1px solid var(--paper-line);
  color: var(--teal);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  font-weight: 700;
}

.chain-history {
  display: flex;
  min-height: 138px;
  max-height: 255px;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  overflow: auto;
  scrollbar-width: thin;
}

.chain-turn {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.chain-turn-label {
  padding-top: 8px;
  color: #827967;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  text-align: right;
}

.chain-word-wrap {
  min-width: 0;
}

.chain-word-button {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: baseline;
  gap: 14px;
  padding: 7px 12px;
  border-left: 3px solid var(--teal);
  background: rgba(223, 232, 226, 0.42);
  text-align: left;
}

.chain-turn.player .chain-word-button {
  border-left-color: var(--red);
  background: rgba(238, 220, 211, 0.36);
}

.chain-word-button strong {
  color: var(--ink);
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
}

.chain-word-button span {
  min-width: 0;
  overflow: hidden;
  color: #6b706f;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chain-detail {
  margin-top: 4px;
  padding: 8px 12px 10px;
  font-size: 14px;
}

.chain-form {
  padding-top: 15px;
  border-top: 1px solid var(--paper-line);
}

.chain-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 9px;
}

.chain-input-row input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #b9aa8c;
  border-radius: 3px;
  outline: 0;
  background: rgba(255, 254, 248, 0.92);
  font-family: "Songti SC", "STSong", serif;
  font-size: 20px;
}

.chain-input-row input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(181, 31, 42, 0.12);
}

.chain-input-row .primary-button {
  min-width: 0;
}

.chain-message {
  min-height: 24px;
  margin: 7px 2px 0;
  color: var(--ink-soft);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
}

.chain-message.is-error {
  color: var(--danger);
}

.chain-message.is-success {
  color: var(--teal);
  font-weight: 700;
}

.hint-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0 2px;
}

.hint-option {
  min-height: 32px;
  padding: 4px 10px;
  border: 1px solid rgba(23, 105, 114, 0.42);
  border-radius: 3px;
  color: var(--teal);
  background: transparent;
  font-size: 13px;
}

.chain-actions {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}

.text-button {
  min-height: 36px;
  padding: 5px 11px;
  color: var(--teal);
  background: transparent;
  font-size: 12px;
}

.text-button:hover:not(:disabled) {
  background: rgba(23, 105, 114, 0.06);
}

.text-button.danger {
  color: var(--danger);
}

.text-button:disabled {
  color: #aaa398;
  cursor: not-allowed;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(42px, 1fr)) auto;
  gap: 6px;
  align-items: center;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--paper-line);
}

.stats-strip div {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-direction: column;
}

.stats-strip strong {
  color: var(--red-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
}

.stats-strip span {
  color: #7c7569;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 10px;
}

.clear-stats {
  min-height: 30px;
  padding: 3px 8px;
  color: #887e70;
  background: transparent;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

footer {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: rgba(60, 50, 39, 0.76);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  text-align: center;
}

footer a {
  color: #5a3134;
  text-underline-offset: 3px;
}

.shake {
  animation: shake 0.36s ease both;
}

@keyframes progress-slide {
  0% { transform: translateX(-110%); }
  55% { transform: translateX(130%); }
  100% { transform: translateX(260%); }
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

@media (max-width: 1280px) {
  .book {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 42px;
  }

  .left-page,
  .right-page {
    padding: 24px 38px 28px;
  }

  .left-page {
    padding-right: 22px;
  }

  .right-page {
    padding-left: 22px;
  }

  .page-mark {
    margin-bottom: 22px;
  }

  .book-intro h1 {
    font-size: 50px;
  }

  .title-rule {
    margin: 17px 0 14px;
  }

  .description {
    font-size: 15px;
  }

  .search-box,
  .chain-setup {
    margin-top: 22px;
    padding-top: 18px;
  }

  .search-input {
    height: 62px;
    font-size: 30px;
  }

  .state-panel {
    padding: 24px;
  }

  .chain-history {
    min-height: 112px;
    max-height: 205px;
  }
}

@media (min-width: 861px) and (max-width: 1280px) {
  body[data-mode="chain"] .page-mark {
    margin-bottom: 14px;
  }

  body[data-mode="chain"] .book-intro h1 {
    margin-top: 7px;
    font-size: 44px;
  }

  body[data-mode="chain"] .title-rule {
    margin: 12px 0 10px;
  }

  body[data-mode="chain"] .subtitle {
    font-size: 16px;
  }

  body[data-mode="chain"] .description {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.6;
  }

  body[data-mode="chain"] .chain-setup {
    margin-top: 13px;
    padding-top: 12px;
  }

  body[data-mode="chain"] .control-group {
    margin-bottom: 11px;
  }

  body[data-mode="chain"] .select-control {
    height: 42px;
  }

  body[data-mode="chain"] .data-status {
    margin-top: 4px;
    margin-bottom: 7px;
  }
}

@media (min-width: 861px) and (max-height: 780px) {
  body[data-mode="poetry"] .left-page {
    padding-top: 20px;
    padding-bottom: 22px;
  }

  body[data-mode="poetry"] .page-mark {
    margin-bottom: 12px;
  }

  body[data-mode="poetry"] .book-intro h1 {
    margin-top: 7px;
    font-size: 44px;
    line-height: 1.04;
  }

  body[data-mode="poetry"] .title-rule {
    margin: 12px 0 10px;
  }

  body[data-mode="poetry"] .subtitle {
    font-size: 16px;
  }

  body[data-mode="poetry"] .description {
    margin-top: 8px;
    font-size: 14px;
    line-height: 1.55;
  }

  body[data-mode="poetry"] .search-box {
    margin-top: 12px;
    padding-top: 11px;
  }

  body[data-mode="poetry"] .search-input {
    height: 58px;
  }

  body[data-mode="poetry"] .poetry-controls {
    gap: 10px;
    margin-top: 10px;
  }

  body[data-mode="poetry"] .poetry-controls .select-control {
    height: 42px;
  }

  body[data-mode="poetry"] .data-status {
    margin-top: 5px;
    margin-bottom: 7px;
  }
}

@media (max-width: 860px) {
  .site-shell {
    padding: 10px 10px 6px;
  }

  .book {
    display: block;
    height: auto;
    min-height: calc(100vh - 48px);
    overflow: visible;
  }

  .book::before {
    display: none;
  }

  .book-tabs {
    position: sticky;
    z-index: 5;
    top: 0;
    grid-template-columns: repeat(5, 1fr);
    height: 48px;
    background: rgba(255, 253, 245, 0.97);
  }

  .book-tab {
    font-size: 13px;
  }

  .book-tab::after {
    right: 14px;
    left: 14px;
  }

  .left-page,
  .right-page {
    padding: 22px 22px 28px;
    overflow: visible;
    background: transparent;
  }

  .right-page {
    min-height: 420px;
    border-top: 1px solid var(--paper-line);
  }

  .page-mark {
    margin-bottom: 22px;
  }

  .book-intro h1 {
    font-size: 44px;
  }

  .description {
    max-width: 620px;
  }

  .search-box,
  .chain-setup {
    width: 100%;
    max-width: 620px;
  }

  .state-panel,
  .results-panel,
  .chain-panel {
    min-height: 360px;
  }

  footer {
    flex-direction: column;
    gap: 2px;
    padding: 8px 12px 3px;
  }
}

@media (max-width: 520px) {
  .site-shell {
    padding: 0;
  }

  .book {
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .left-page,
  .right-page {
    padding: 19px 16px 25px;
  }

  .right-page {
    min-height: 390px;
  }

  .page-mark {
    min-height: 28px;
    margin-bottom: 18px;
    padding-bottom: 9px;
    font-size: 13px;
  }

  .section-kicker {
    font-size: 11px;
  }

  .book-intro h1 {
    margin-top: 8px;
    font-size: 38px;
    line-height: 1.12;
  }

  .title-rule {
    width: 58px;
    height: 4px;
    margin: 15px 0 13px;
  }

  .subtitle {
    font-size: 16px;
  }

  .description {
    margin-top: 10px;
    font-size: 14px;
    line-height: 1.7;
  }

  .search-box,
  .chain-setup {
    margin-top: 19px;
    padding-top: 16px;
  }

  .search-input {
    height: 58px;
    font-size: 28px;
  }

  .primary-button {
    min-height: 44px;
  }

  .poetry-controls {
    gap: 9px;
  }

  .poetry-controls .segmented-control span {
    min-height: 36px;
    font-size: 12px;
  }

  .poetry-controls .select-control {
    height: 42px;
    padding: 0 9px;
    font-size: 13px;
  }

  .state-panel,
  .results-panel,
  .chain-panel {
    min-height: 330px;
  }

  .state-panel {
    padding: 30px 7px;
  }

  .state-seal,
  .empty-watermark {
    width: 62px;
    height: 62px;
    font-size: 32px;
  }

  .loader-panel h2,
  .empty-panel h2,
  .error-panel h2 {
    font-size: 24px;
  }

  .result-heading {
    margin-bottom: 16px;
  }

  .hanzi-result {
    padding: 20px 2px;
  }

  .hanzi-head {
    gap: 12px;
  }

  .hanzi-character {
    min-width: 68px;
    font-size: 58px;
  }

  .entry-name {
    font-size: 18px;
  }

  .result-meta {
    gap: 4px 10px;
    font-size: 14px;
  }

  .definition {
    padding: 13px 12px;
    font-size: 15px;
  }

  .idiom-result-button {
    grid-template-columns: 1fr auto;
    gap: 3px 10px;
    padding: 12px 4px;
  }

  .idiom-pinyin {
    grid-row: 2;
    font-size: 13px;
  }

  .idiom-abbr {
    display: none;
  }

  .row-action {
    grid-column: 2;
    grid-row: 1 / 3;
  }

  .idiom-detail,
  .chain-detail {
    padding-right: 8px;
    padding-left: 12px;
  }

  .poetry-result-button {
    gap: 10px;
    padding: 12px 4px;
  }

  .poetry-title {
    font-size: 19px;
  }

  .poetry-labels {
    align-items: flex-end;
    flex-direction: column;
    gap: 4px;
  }

  .poetry-featured {
    display: none;
  }

  .poetry-detail {
    margin-right: 2px;
    margin-left: 2px;
    padding: 15px 10px 17px;
  }

  .poetry-text {
    font-size: 16px;
    line-height: 1.8;
  }

  .xiehouyu-row {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 14px 4px;
  }

  .xiehouyu-dash {
    display: none;
  }

  .xiehouyu-riddle,
  .xiehouyu-answer {
    font-size: 16px;
  }

  .xiehouyu-answer::before {
    content: "答：";
    color: var(--gold);
    font-weight: 400;
  }

  .chain-heading h2 {
    font-size: 20px;
  }

  .chain-history {
    max-height: 300px;
  }

  .chain-turn {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 7px;
  }

  .chain-word-button {
    display: block;
  }

  .chain-word-button strong,
  .chain-word-button span {
    display: block;
  }

  .chain-word-button span {
    margin-top: 1px;
    font-size: 11px;
  }

  .chain-input-row {
    grid-template-columns: minmax(0, 1fr) 78px;
  }

  .chain-input-row input {
    padding: 0 10px;
    font-size: 18px;
  }

  .stats-strip {
    grid-template-columns: repeat(5, 1fr);
  }

  .clear-stats {
    grid-column: 1 / -1;
    justify-self: center;
  }

  footer {
    background: var(--paper-shade);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
