:root {
  --paper: #f7f3ea;
  --paper-deep: #eee8dd;
  --ink: #292927;
  --muted: #77736c;
  --line: rgba(45, 43, 39, 0.16);
  --accent: #a72d22;
  --accent-soft: rgba(167, 45, 34, 0.09);
  --poem-user-size: 31px;
  --poem-size: var(--poem-user-size);
  --sans: 'Microsoft YaHei UI', 'PingFang SC', sans-serif;
  --serif: 'Songti SC', 'STSong', SimSun, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--serif);
  transition: color .25s ease, background .25s ease;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .21;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
  z-index: 20;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; }

.page-shell {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  --scene: url('./assets/ink-landscape.png');
}

.page-shell::after {
  content: '';
  position: absolute;
  top: 78px;
  right: -90px;
  width: min(68vw, 1080px);
  height: auto;
  aspect-ratio: 4 / 3;
  background: var(--scene) right top / cover no-repeat;
  opacity: .45;
  pointer-events: none;
  z-index: -1;
  mask-image: linear-gradient(to left, #000 0 58%, transparent 94%);
}
.page-shell[data-visual="moon"] { --scene: url('./assets/ink-moon-mountains.png'); }
.page-shell[data-visual="river"] { --scene: url('./assets/ink-river-farewell.png'); }
.page-shell[data-visual="garden"] { --scene: url('./assets/ink-garden-flowers.png'); }

.site-header {
  height: 78px;
  padding: 0 clamp(24px, 4vw, 64px);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  color: inherit;
  text-decoration: none;
}

.brand-text { font-size: 27px; letter-spacing: .08em; font-weight: 600; }
.brand-seal {
  width: 25px;
  height: 25px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--accent);
  display: grid;
  place-content: center;
  font-family: var(--serif);
  font-size: 9px;
  line-height: 1.05;
  text-align: center;
}

.desktop-nav { display: flex; align-items: stretch; gap: 42px; }
.nav-link {
  position: relative;
  border: 0;
  background: transparent;
  padding: 0 2px;
  font-size: 16px;
  cursor: pointer;
}
.nav-link::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .2s ease;
}
.nav-link:hover, .nav-link.active { color: var(--accent); }
.nav-link.active::after { transform: scaleX(1); }

.header-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.script-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font: 15px var(--serif); }
.script-button:hover { color: var(--accent); border-color: var(--accent); }
.icon-button, .menu-button {
  border: 0;
  background: transparent;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.icon-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.icon-button:hover, .icon-button.selected { color: var(--accent); }
.menu-button { display: none; gap: 5px; align-content: center; }
.menu-button span { width: 23px; height: 1.5px; background: currentColor; transition: transform .2s ease; }
.mobile-nav { display: none; }

main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }

.date-rail {
  width: min(720px, 100%);
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.round-button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(247, 243, 234, .48);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .2s, color .2s, transform .2s;
}
.round-button:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.round-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.date-display {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 19px;
  cursor: default;
}
.date-display i, .author-line i { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }

.today-switch { width: min(720px, 100%); min-height: 72px; margin-bottom: 12px; display: grid; grid-template-columns: 1fr 1px 1fr; align-items: stretch; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.today-switch > i { align-self: center; height: 32px; background: var(--line); }
.today-switch button { padding: 12px 22px; border: 0; background: transparent; text-align: left; cursor: pointer; position: relative; }
.today-switch button::after { content: ''; position: absolute; left: 22px; right: 22px; bottom: -1px; height: 2px; background: transparent; }
.today-switch button.selected::after { background: var(--accent); }
.today-switch span { display: block; margin-bottom: 5px; color: var(--accent); font: 13px var(--sans); letter-spacing: .1em; }
.today-switch strong { display: block; overflow: hidden; color: var(--ink); font-size: 17px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.page-shell.history-mode .date-rail, .page-shell.history-mode .today-switch, .page-shell.history-mode .reading-layout, .page-shell.history-mode .author-section, .page-shell.history-mode .reading-footer { display: none; }
.page-shell.single-mode .today-switch, .page-shell.single-mode .date-rail { display: none; }
.page-shell.archive-mode .today-switch { display: none; }

.history-view { padding: clamp(42px, 6vw, 76px) 0 90px; }
.history-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; padding-bottom: 30px; border-bottom: 1px solid var(--ink); }
.history-heading h1 { margin: 0 0 8px; font-size: clamp(42px, 5vw, 64px); }
.history-heading p { margin: 0; color: var(--muted); font: 14px var(--sans); }
.history-heading button, .load-more { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: 14px var(--sans); }
.history-list { border-bottom: 1px solid var(--line); }
.history-row { display: grid; grid-template-columns: 150px 1fr 1fr; gap: 0; border-bottom: 1px solid var(--line); }
.history-date { padding: 26px 24px 26px 0; }
.history-date strong { display: block; font-size: 24px; font-weight: 500; }
.history-date span { color: var(--muted); font: 12px var(--sans); }
.history-entry { min-width: 0; padding: 23px 28px; border: 0; border-left: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; transition: background .2s ease; }
.history-entry:hover { background: var(--accent-soft); }
.history-entry small { display: block; margin-bottom: 7px; color: var(--accent); font: 11px var(--sans); letter-spacing: .08em; }
.history-entry strong { display: block; margin-bottom: 7px; overflow: hidden; font-size: 20px; font-weight: 500; white-space: nowrap; text-overflow: ellipsis; }
.history-entry span { color: var(--muted); font: 12px var(--sans); }
.load-more { display: block; margin: 30px auto 0; padding: 10px 24px; border: 1px solid var(--line); }
.archive-return { display: block; width: max-content; margin: 18px 0 -4px; border: 0; background: transparent; color: var(--accent); cursor: pointer; font: 13px var(--sans); }

.reading-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, .8fr);
  gap: clamp(54px, 7vw, 112px);
  align-items: start;
}

.reading-main { min-width: 0; }
.title-block { text-align: center; margin: 12px 0 26px; }
.genre {
  min-height: 18px;
  margin: 0 0 6px;
  color: var(--muted);
  font: 12px/1.4 var(--sans);
  letter-spacing: .16em;
}
h1 { margin: 0; font-size: clamp(42px, 4.4vw, 65px); font-weight: 500; letter-spacing: .09em; }
.author-line { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 13px 0 0; color: #4c4944; font-size: 18px; }

.work-text {
  width: fit-content;
  max-width: 100%;
  min-height: 292px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: var(--poem-size);
  line-height: 2.08;
  letter-spacing: .09em;
  text-align: left;
  transition: opacity .18s ease;
}
.work-text.prose { font-size: calc(var(--poem-size) * .67); line-height: 2; letter-spacing: .04em; max-width: 680px; }
.work-text p { margin: 0; }
.work-text.prose p + p { margin-top: 1em; }

.work-actions {
  margin: 10px auto 26px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}
.work-actions button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #595650;
  font: 14px var(--sans);
  cursor: pointer;
}
.work-actions button:hover, .work-actions button.selected { color: var(--accent); }
.work-actions svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.type-control { font: 17px var(--serif); }

.tabs { height: 58px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); }
.tabs button {
  border: 0;
  background: transparent;
  position: relative;
  font-size: 18px;
  cursor: pointer;
}
.tabs button::after { content: ''; position: absolute; bottom: -1px; left: 35%; right: 35%; height: 2px; background: var(--accent); transform: scaleX(0); transition: transform .2s; }
.tabs button[aria-selected="true"] { color: var(--accent); }
.tabs button[aria-selected="true"]::after { transform: scaleX(1); }

.tab-panel { min-height: 185px; padding: 28px 4px; font-size: 16px; line-height: 2; color: #484640; }
.tab-panel h2 { margin: 0 0 12px; color: var(--ink); font-size: 23px; font-weight: 500; }
.tab-panel p { margin: 0; }
.meta-list { display: flex; flex-wrap: wrap; gap: 10px 24px; font: 13px/1.8 var(--sans); color: var(--muted); }
.meta-list span::before { content: '—'; margin-right: 7px; color: var(--accent); }

.editorial-notes { border-left: 1px solid var(--line); padding-left: 34px; margin-top: 14px; }
.editorial-notes section { margin-bottom: 38px; }
.editorial-notes h2, .section-heading h2 {
  position: relative;
  margin: 0 0 14px;
  padding-left: 16px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: .06em;
}
.editorial-notes h2::before, .section-heading h2::before { content: ''; position: absolute; left: 0; top: .15em; width: 3px; height: 1.15em; background: var(--accent); }
.editorial-notes p, .editorial-notes blockquote { margin: 0; font-size: 14px; line-height: 1.9; color: #55514b; }
.editorial-notes blockquote { padding: 0; }
.editorial-notes blockquote::before { content: '“'; color: var(--accent); font-size: 28px; margin-right: 3px; vertical-align: -.25em; }

.author-section {
  border-top: 1px solid var(--line);
  padding: 34px 0 54px;
  display: grid;
  grid-template-columns: minmax(170px, .6fr) minmax(0, 1.7fr);
  gap: 32px;
  align-items: start;
}
.section-heading { display: flex; flex-direction: column; gap: 7px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading span { padding-left: 16px; color: var(--muted); font: 12px var(--sans); }
.author-profile { display: grid; grid-template-columns: 78px 1fr; gap: 20px; }
.author-monogram { width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-deep); color: var(--accent); font-size: 30px; border: 1px solid var(--line); }
.author-profile h3 { margin: 1px 0 7px; font-size: 21px; font-weight: 500; }
.author-profile p { margin: 0; font-size: 14px; line-height: 1.8; color: #57534d; }
.author-profile .author-life { margin-top: 8px; color: var(--muted); }

.reading-footer {
  min-height: 58px;
  padding: 0 clamp(24px, 4vw, 64px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr minmax(280px, 420px) 1fr;
  align-items: center;
  gap: 20px;
  font-size: 13px;
}
.reading-footer p { margin: 0; }
.reading-footer p a { color: var(--muted); text-decoration: none; }
.reading-footer p a:hover { color: var(--accent); }
.reading-footer > button { justify-self: end; border: 0; background: none; color: var(--accent); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.reading-footer > button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.progress-wrap { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px; font: 12px var(--sans); color: var(--muted); }
.progress-wrap strong { color: var(--ink); font-weight: 500; }
.progress-track { height: 4px; background: rgba(80,76,70,.14); overflow: hidden; }
.progress-track i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 10px 18px; border-radius: 2px; background: #292927; color: #fff; font: 13px var(--sans); transition: .22s ease; z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.status-banner { position: fixed; z-index: 31; top: 86px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); padding: 12px 14px; background: #fff4e6; color: #6e3e23; border: 1px solid rgba(110,62,35,.24); box-shadow: 0 12px 35px rgba(40,34,26,.12); font: 14px var(--sans); }
.status-banner:not([hidden]) { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.status-banner button { border: 0; color: var(--accent); background: transparent; cursor: pointer; font-weight: 600; }
.page-shell.loading .reading-main, .page-shell.loading .editorial-notes, .page-shell.loading .author-section { opacity: .38; }
.page-shell.loading { cursor: progress; }
.drawer-backdrop { position: fixed; inset: 0; z-index: 38; background: rgba(24,22,19,.36); backdrop-filter: blur(2px); }
.utility-drawer { position: fixed; z-index: 39; top: 0; right: 0; bottom: 0; width: min(460px, 100%); padding: 34px clamp(24px, 5vw, 42px); overflow-y: auto; background: var(--paper); border-left: 1px solid var(--line); box-shadow: -18px 0 50px rgba(34,30,24,.14); transform: translateX(105%); transition: transform .25s ease; }
.utility-drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.drawer-head p { margin: 0 0 7px; color: var(--accent); font: 12px var(--sans); letter-spacing: .14em; }
.drawer-head h2 { margin: 0; font-size: 28px; font-weight: 500; }
.drawer-close { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; background: transparent; cursor: pointer; font: 27px/1 var(--sans); }
.search-form, .history-form { padding: 24px 0 15px; }
.search-form label, .history-form label { display: block; margin-bottom: 9px; color: var(--muted); font: 13px var(--sans); }
.search-form div, .history-form div { display: grid; grid-template-columns: 1fr auto; }
.search-form input, .history-form input { min-width: 0; height: 45px; padding: 0 13px; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-right: 0; outline: none; font: 15px var(--sans); }
.search-form input:focus, .history-form input:focus { border-color: var(--accent); }
.search-form button, .history-form button { height: 45px; padding: 0 18px; color: #fff; background: var(--accent); border: 1px solid var(--accent); cursor: pointer; font: 14px var(--sans); }
.result-status { min-height: 21px; margin: 5px 0 12px; color: var(--muted); font: 13px var(--sans); }
.search-results { border-top: 1px solid var(--line); }
.result-item { display: grid; grid-template-columns: 1fr auto; width: 100%; gap: 16px; padding: 17px 2px; text-align: left; color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.result-item strong { display: block; margin-bottom: 6px; font-size: 18px; font-weight: 500; }
.result-item span { color: var(--muted); font: 12px var(--sans); }
.result-item i { align-self: center; color: var(--accent); font: normal 20px var(--sans); }
body.drawer-open { overflow: hidden; }
body.dark .status-banner { background: #342921; color: #ebcdb9; }

body.dark {
  --paper: #1d1c1a;
  --paper-deep: #2a2824;
  --ink: #e9e4da;
  --muted: #aaa49a;
  --line: rgba(235, 228, 215, .14);
  --accent: #d46b5d;
  --accent-soft: rgba(212, 107, 93, .1);
}
body.dark .page-shell::after { opacity: .12; filter: invert(.82); }
body.dark .round-button { background: rgba(29,28,26,.46); }
body.dark .author-line, body.dark .work-actions button, body.dark .tab-panel, body.dark .editorial-notes p, body.dark .editorial-notes blockquote, body.dark .author-profile p { color: #c5beb3; }

/* 4:3 平板横屏：保留双栏，但收紧导航、留白和字号。 */
@media (min-width: 821px) and (max-width: 1100px) {
  :root { --poem-size: clamp(25px, calc(var(--poem-user-size) * .88), 32px); }
  .site-header {
    height: 72px;
    padding-inline: 28px;
    grid-template-columns: minmax(190px, 1fr) auto minmax(100px, 1fr);
  }
  .brand-text { font-size: 23px; }
  .desktop-nav { gap: 22px; }
  .nav-link { font-size: 15px; }
  .header-actions { gap: 2px; }
  main { width: min(960px, calc(100% - 40px)); }
  .date-rail { width: 63%; min-height: 84px; }
  .reading-layout {
    grid-template-columns: minmax(0, 1.48fr) minmax(246px, .72fr);
    gap: 34px;
  }
  .title-block { margin: 6px 0 20px; }
  h1 { font-size: clamp(44px, 5.2vw, 56px); }
  .work-text { min-height: 270px; line-height: 2; }
  .editorial-notes { padding-left: 24px; }
  .editorial-notes section { margin-bottom: 28px; }
  .editorial-notes h2 { font-size: 18px; }
  .editorial-notes p, .editorial-notes blockquote { font-size: 13px; }
  .tab-panel { min-height: 165px; padding-block: 24px; }
  .author-section {
    grid-template-columns: 145px minmax(0, 1fr) auto;
    gap: 22px;
    padding-block: 28px 42px;
  }
  .reading-footer { padding-inline: 28px; grid-template-columns: .8fr minmax(260px, 360px) .8fr; }
  .page-shell::after { right: -170px; width: 78vw; opacity: .38; }
}

@media (max-width: 820px) {
  :root { --poem-size: clamp(21px, calc(var(--poem-user-size) * .76), 27px); }
  .site-header { position: relative; height: 68px; padding: 0 20px; grid-template-columns: 1fr; }
  .brand-text { font-size: 23px; }
  .brand-seal { order: -1; width: 25px; height: 25px; }
  .desktop-nav, .header-actions .icon-button { display: none; }
  .header-actions { position: absolute; top: 13px; right: 12px; }
  .menu-button { display: grid; }
  .mobile-nav { position: fixed; z-index: 18; top: 68px; left: 0; right: 0; padding: 12px 20px 18px; background: var(--paper); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; transform: translateY(-130%); transition: transform .25s ease; }
  .mobile-nav.open { transform: translateY(0); }
  .mobile-nav button { height: 42px; border: 0; background: transparent; font-size: 15px; }
  .page-shell::after { top: auto; bottom: 40px; right: -230px; width: 760px; height: auto; aspect-ratio: 4 / 3; opacity: .23; }
  main { width: min(100% - 38px, 680px); }
  .date-rail { min-height: 91px; }
  .round-button { width: 38px; height: 38px; }
  .date-display { font-size: 17px; gap: 10px; }
  .today-switch { margin-bottom: 22px; }
  .today-switch button { padding-inline: 14px; }
  .today-switch button::after { left: 14px; right: 14px; }
  .today-switch strong { font-size: 15px; }
  .history-view { padding-top: 35px; }
  .history-heading { align-items: start; }
  .history-heading h1 { font-size: 42px; }
  .history-row { grid-template-columns: 1fr; }
  .history-date { padding: 22px 4px 13px; }
  .history-entry { padding: 17px 4px; border-left: 0; border-top: 1px solid var(--line); }
  .reading-layout { display: block; }
  .title-block { margin-top: 13px; }
  .genre { margin-bottom: 3px; }
  h1 { font-size: clamp(39px, 12vw, 55px); }
  .work-text { min-height: 300px; font-size: var(--poem-size); line-height: 2.15; letter-spacing: .045em; }
  .work-text.prose { width: 100%; font-size: 17px; line-height: 2; }
  .work-actions { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 9px 0; margin: 10px 0 0; justify-content: space-around; }
  .work-actions button:nth-last-child(-n + 2) { padding-inline: 6px; }
  .tabs { height: 63px; }
  .tabs button { font-size: 17px; }
  .tab-panel { min-height: 155px; padding: 27px 3px 34px; }
  .editorial-notes { border-left: 0; border-top: 1px solid var(--line); padding: 34px 3px 0; margin: 0; }
  .editorial-notes section { margin-bottom: 32px; }
  .editorial-notes h2 { font-size: 22px; }
  .editorial-notes p, .editorial-notes blockquote { font-size: 15px; line-height: 2; }
  .author-section { grid-template-columns: 1fr; gap: 20px; padding-bottom: 72px; }
  .section-heading { flex-direction: row; align-items: baseline; justify-content: space-between; }
  .reading-footer { min-height: 52px; padding: 0 20px; grid-template-columns: 1fr auto; position: sticky; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--paper) 94%, transparent); backdrop-filter: blur(8px); }
  .reading-footer p { display: none; }
  .reading-footer > button { font-size: 13px; }
  .progress-wrap { grid-template-columns: auto 1fr; }
  .progress-wrap span { display: none; }
  .progress-track { width: 120px; }
  .status-banner { top: 76px; }
  .utility-drawer { padding-top: 24px; }
}

@media (max-width: 430px) {
  :root { --poem-size: clamp(20px, calc(var(--poem-user-size) * .72), 25px); }
  .brand-seal { display: none; }
  .date-rail { min-height: 82px; }
  .date-display { font-size: 16px; }
  h1 { font-size: 42px; }
  .author-line { font-size: 16px; }
  .work-text { min-height: 280px; line-height: 2.2; }
  .work-actions button { padding: 0 7px; }
  .work-actions button span:not(.type-control) { display: none; }
  .tab-panel { font-size: 15px; }
  .author-profile { grid-template-columns: 64px 1fr; }
  .author-monogram { width: 64px; height: 64px; font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
