:root {
  color-scheme: light;
  --paper: #eeeee5;
  --card: #f5f4e9;
  --ink: #202d26;
  --muted: #526056;
  --green: #244b40;
  --pale: #e6ebe1;
  --line: #cdd4c8;
  --gold: #957641;
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", SimSun, serif;
  --sans: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --sticky-height: 103px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-width: 0; color: var(--ink); font: 1rem/1.62 var(--sans);
  background: radial-gradient(ellipse at 5% 0, #dce3d7 0, transparent 32rem),
    repeating-linear-gradient(144deg, #64796103 0 1px, transparent 1px 9px), var(--paper);
}
button, a { -webkit-tap-highlight-color: rgba(45, 83, 71, .12); }
button { font: inherit; cursor: pointer; }
img { display: block; width: 100%; height: 100%; object-fit: cover; }
h1, h2, h3, h4, h5, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #92703b; outline-offset: 4px; }
.shell { width: min(100% - 4rem, 1056px); margin-inline: auto; }

.masthead { position: relative; isolation: isolate; padding: 28px 0 25px; border-block-end: 1px solid var(--line); }
.masthead .shell { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; flex: 0 0 39px; width: 39px; height: 39px;
  border-radius: 5px; border: 1px solid #4c665b; color: #f2f1e8; background: var(--green);
  font: 1.25rem/1 var(--serif); box-shadow: inset 0 0 0 3px #244b40, inset 0 0 0 4px #688478;
}
.brand h1 { font: 700 clamp(1.5rem, 3vw, 1.83rem)/1.22 var(--serif); letter-spacing: .115em; white-space: nowrap; }
.father-greeting { margin-top: 3px; color: var(--muted); font-size: .94rem; font-weight: 650; line-height: 1.35; white-space: nowrap; }

.work-art img { opacity: 0; }
.work-art img.cover-loaded { opacity: 1; }

.timeline-title { margin: clamp(15px, 3vw, 28px) auto 13px; }
.timeline-title h2 { font: 700 clamp(1.49rem, 4vw, 2rem)/1.35 var(--serif); letter-spacing: .09em; }

.era-bar {
  position: -webkit-sticky; position: sticky; top: 0; z-index: 5; width: 100%;
  padding: 10px 0 9px; border-block: 1px solid #becbbf; background: #eeefe5;
  box-shadow: 0 8px 21px -19px #264436a6;
}
.era-bar::after {
  position: absolute; content: ""; height: 2px; inset: auto auto -1px 0;
  width: var(--era-progress, 0%); background: #6d8978; transition: width 220ms ease-out;
  pointer-events: none;
}
.era-status { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 9px; padding-bottom: 3px; color: var(--green); font-size: .875rem; }
.era-status::before { content: ""; flex: 0 0 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.era-status-title { display: inline-flex; gap: .5em; align-items: baseline; }
.era-status strong { font-weight: 750; }
.era-years, .period-years { color: #405b4c; font-variant-numeric: tabular-nums; font-weight: 650; }
.era-years { min-width: 0; }
.era-links { display: flex; align-items: center; gap: 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: #a1ad9f transparent; padding: 3px 2px 6px; }
.era-link {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 6px 15px; border: 1px solid #c9d2c5; border-radius: 5px; font-size: .95rem;
  color: #354a3e; text-decoration: none; background: #f5f5ed;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.era-link:hover { background: #e3e9de; }
.era-link:focus-visible { outline-offset: -3px; }
.era-link[aria-current="location"] { color: #fffcef; background: var(--green); border-color: var(--green); font-weight: 700; }

.timeline { padding-top: 28px; padding-bottom: 40px; }
.period, .catalog-extra { scroll-margin-top: calc(var(--sticky-height) + 17px); }
.period { position: relative; padding: 2px 0 34px 27px; border-left: 1px solid #b6c3b5; }
.period::before { content: ""; position: absolute; z-index: 1; top: 13px; left: -6px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #718b79; background: var(--paper); box-shadow: 0 0 0 4px var(--paper); }
.period-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.period-head h3 { font: 700 1.54rem/1.35 var(--serif); letter-spacing: .09em; }
.period-range { color: var(--muted); font-size: .88rem; }
.period-years { font-size: .92rem; }
.catalog-extra { padding: 20px 0 0; border-top: 1px solid #b6c3b5; }
.catalog-part + .catalog-part { margin-top: 20px; }
.catalog-part .period-head { margin-bottom: 9px; }
.catalog-part h4 { color: var(--green); font-size: 1.02rem; }
.work-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.work-card { display: grid; grid-template-columns: 96px minmax(0, 1fr); min-height: 134px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--card); }
.work-card:only-child { grid-column: 1 / -1; }
.work-art { position: relative; overflow: hidden; min-height: 100%; min-width: 0; color: #344d3e; background: #e1e7da; }
.work-art::before, .work-art::after { pointer-events: none; content: ""; position: absolute; }
.work-art::before { inset: 0; background: radial-gradient(ellipse at 14% 118%, #526b5865 0%, transparent 69%), repeating-linear-gradient(145deg, transparent, transparent 16px, #5f7c6722 17px, transparent 18px); }
.work-art::after { inset: 11px; border: 1px solid currentColor; opacity: .22; }
.work-art img { position: absolute; inset: 0; z-index: 1; }
.work-art[data-tone="ochre"] { color: #644b35; background: #e8deca; }
.work-art[data-tone="slate"] { color: #4c575b; background: #dfe4e3; }
.work-art-fallback { position: absolute; inset: 0; display: grid; place-items: center; font: 2.1rem/1 var(--serif); }
.work-copy { min-width: 0; padding: 13px 15px 12px; }
.work-title { color: var(--ink); font: 700 1.21rem/1.35 var(--serif); letter-spacing: .045em; }
.work-meta { margin-top: 2px; color: #3e5b48; font-size: .86rem; font-weight: 600; }
.work-desc { margin-top: 5px; color: var(--muted); font-size: .92rem; line-height: 1.55; }
.work-note { margin-top: 5px; color: var(--muted); font-size: .85rem; line-height: 1.5; }

footer { border-top: 1px solid var(--line); padding: 15px 0 23px; color: var(--muted); font-size: .87rem; }

@media (max-width: 760px) {
  .shell { width: calc(100% - 2.5rem); }
  .masthead { padding-block: 18px; }
  .timeline { padding-top: 23px; }
  .work-card { grid-template-columns: 72px minmax(0, 1fr); }
  .work-copy { padding-inline: 11px; }
}

@media (max-width: 540px) {
  .shell { width: calc(100% - 2rem); }
  .masthead { padding-block: 15px; }
  .brand { gap: 9px; }
  .brand-mark { width: 32px; height: 32px; flex-basis: 32px; font-size: 1.1rem; }
  .brand h1 { letter-spacing: .075em; }
  .era-links { gap: 6px; }
  .era-link { padding-inline: 12px; }
  .period { padding-left: 18px; padding-bottom: 26px; }
  .period-head { flex-wrap: wrap; gap: 3px 9px; margin-bottom: 10px; }
  .period-head h3 { font-size: 1.44rem; }
  .work-grid { grid-template-columns: 1fr; gap: 8px; }
  .work-card { min-height: 115px; grid-template-columns: 78px minmax(0, 1fr); }
  .work-copy { padding: 10px 11px; }
  .work-title { font-size: 1.15rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .era-bar::after, .era-link { transition: none; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

button:disabled { cursor: default; opacity: .55; }
.account-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.account-actions button { white-space: nowrap; }
.plain-button, .solid-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 7px 14px;
  border: 1px solid #a8b7a8;
  border-radius: 6px;
  color: var(--green);
  background: var(--card);
  font-weight: 650;
  line-height: 1.4;
}
.solid-button { border-color: var(--green); background: var(--green); color: #fbfaee; }
.plain-button:hover:not(:disabled) { background: var(--pale); }
.solid-button:hover:not(:disabled) { background: #356254; }
.auth, .admin, .state-panel { padding-block: 28px 44px; }
.auth-panel { width: min(100%, 440px); margin: 28px auto 0; }
.auth-panel .login-entry { margin-bottom: 11px; }
.auth-panel #password {
  min-height: 55px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.45rem, 5vw, 1.9rem);
  letter-spacing: .13em;
  text-align: center;
}
.auth-panel #password::placeholder { font-size: 1rem; letter-spacing: .04em; }
.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  min-width: 0;
  gap: 7px;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}
.keypad button {
  min-height: 52px;
  padding: 3px 4px;
  border: 1px solid #aebcad;
  border-radius: 7px;
  background: #faf9ef;
  color: var(--green);
  font-size: 1.45rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  touch-action: manipulation;
}
.keypad button:active { background: var(--pale); }
.keypad .key-command { font-size: .95rem; }
.keypad .key-backspace { font-size: 1.3rem; }
#login-submit { width: 100%; min-height: 48px; }
.panel { padding: clamp(18px, 4vw, 30px); border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.panel h2, .admin h2 { font: 700 1.7rem/1.35 var(--serif); letter-spacing: .075em; }
.panel h2, .panel h3 { margin-bottom: 15px; }
.admin-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; align-items: start; }
.field { display: grid; gap: 4px; margin-bottom: 13px; color: var(--green); font-weight: 640; }
.field :is(input, select, textarea) {
  width: 100%;
  min-height: 45px;
  padding: 8px 10px;
  border: 1px solid #a8b7a8;
  border-radius: 6px;
  background: #fbfaee;
  color: var(--ink);
  font: 400 1rem/1.5 var(--sans);
}
.field textarea { resize: vertical; }
.message { margin-top: 8px; color: var(--muted); font-size: .93rem; }
.message[data-error="true"] { color: #86473b; }
#retry { margin-top: 10px; }

.work-open {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 1px;
  padding: 0 6px 0 0;
  border: none;
  background: transparent;
  color: var(--green);
  font-weight: 650;
  font-size: .91rem;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.work-availability { display: block; margin-top: 4px; color: var(--muted); font-size: .84rem; }
button.work-art { display: block; width: 100%; align-self: stretch; padding: 0; border: 0; appearance: none; }
button.work-art:focus-visible { outline-offset: -5px; z-index: 1; }
button.work-art:hover img { filter: brightness(.92); }
.work-card[data-availability="available"] .work-art-fallback { pointer-events: none; }
.work-card[data-availability="unavailable"] {
  background: #ebebe5;
  border-color: #d1d3ca;
}
.work-card[data-availability="unavailable"] .work-art {
  filter: grayscale(1);
  opacity: .52;
}
.work-card[data-availability="unavailable"] .work-meta { color: #545a54; }
.episode-list { margin: 2px 0 4px; padding: 0; max-height: 20rem; overflow-y: auto; list-style: none; }
.episode-list li + li { border-top: 1px solid var(--line); }
.episode-list button {
  display: block;
  min-height: 44px;
  width: 100%;
  padding: 8px 4px;
  border: none;
  color: var(--green);
  background: transparent;
  font-size: .9rem;
  text-align: left;
}
.episode-list button:hover { background: var(--pale); }
.episode-list button:focus-visible { outline-offset: -3px; }
.work-card { scroll-margin-top: calc(var(--sticky-height) + 20px); }
.work-detail {
  width: min(100% - 2rem, 650px);
  max-height: min(88vh, 760px);
  max-height: min(88dvh, 760px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0;
  border: 1px solid #aebcaf;
  border-radius: 13px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 16px 55px #172b2473;
}
.work-detail::backdrop { background: #1d2b24a6; }
.work-detail-body { padding: clamp(15px, 4vw, 25px); }
#work-detail[open] { display: flex; flex-direction: column; overflow: hidden; }
#work-detail-scroll { flex: 1 1 auto; min-height: 0; padding-top: 7px; overflow: auto; overscroll-behavior: contain; }
.work-detail-head { display: flex; flex: none; justify-content: space-between; align-items: flex-start; gap: 8px; padding: clamp(12px, 4vw, 20px) clamp(15px, 4vw, 25px); border-bottom: 1px solid var(--line); background: var(--card); }
.work-detail-head h2 { font: 700 1.62rem/1.35 var(--serif); letter-spacing: .05em; }
.work-detail-head button { flex: 0 0 auto; }
.work-detail-body > .work-desc { margin-top: 10px; }
.work-progress { margin: 16px 0; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: #eeefe5; }
.work-progress h3 { margin-bottom: 4px; font-size: 1rem; }
#work-resume { margin-top: 8px; }
.detail-episodes { max-height: none; overflow: visible; }
.detail-episodes [data-current] { border: 2px solid #376955; border-inline-start-width: 5px; border-radius: 6px; background: #bfd9ca; }
.detail-episodes [data-last-heard] { border-inline-start: 3px solid #829e90; background: #e8ebe1; }
.episode-row-head { display: flex; align-items: center; gap: 6px; padding-inline: 5px; }
.detail-episodes .episode-synopsis-toggle { flex: 1 1 auto; width: auto; min-width: 0; padding-inline: 6px; font-size: 1rem; }
.detail-episodes [data-current] .episode-synopsis-toggle { font-weight: 700; }
.detail-episodes .episode-play { flex: 0 0 auto; width: auto; padding-inline: 9px; border: 1px solid var(--green); border-radius: 5px; color: #fbfaee; background: var(--green); white-space: nowrap; text-align: center; }
.detail-episodes .episode-play:hover { background: #356254; }
.episode-current-state { display: inline-block; margin-inline: .5rem; padding: 2px 6px; border-radius: 4px; color: #fbfaee; background: #244b40; font-size: .82rem; font-weight: 700; }
.episode-synopsis { padding: 2px 11px 11px; color: var(--ink); font-size: .9rem; line-height: 1.55; }
.episode-unavailable { flex: 0 0 auto; padding-inline: 4px; color: var(--muted); font-size: .85rem; }
.logout-dialog { max-width: 27rem; }
.episode-switch h2, .logout-dialog h2 { margin-bottom: 6px; font: 700 1.45rem/1.35 var(--serif); }
.episode-switch-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.backup-panel { grid-column: 1 / -1; }
.backup-panel > .work-desc { margin-bottom: 11px; }
.backup-panel .field { max-width: 32rem; }
.backup-panel > button + button { margin-inline-start: 6px; }
.player {
  position: fixed;
  z-index: 9;
  inset: auto 0 0;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #9cab9d;
  background: #eeefe5;
}
body.has-player { padding-bottom: 128px; }
body.has-resume { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
.player-resume { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.player-resume > button { margin: 0; }
.player-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 1.4fr) auto auto; gap: 8px; align-items: center; }
.player-title { min-width: 0; min-height: 44px; padding: 5px 4px; overflow: hidden; border: 0; border-radius: 5px; background: transparent; color: var(--green); text-align: left; font-weight: 660; }
.player-title:hover { background: var(--pale); }
.player-title span:not(.sr-only) { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-title #playing-title, .player-title #resume-title { text-decoration: underline; text-underline-offset: 3px; }
.player-title #playing-episode { color: var(--muted); font-size: .84rem; font-weight: 650; }
.player-title span.player-resume-meta { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: .82rem; }
.player-resume-meta #resume-place { flex: 0 0 auto; }
.player-resume-meta time { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.player-playback { display: flex; min-width: 0; align-items: center; gap: 8px; }
.player audio { display: block; flex: 1 1 auto; width: 100%; min-width: 0; height: 44px; }
.sleep-trigger { flex: 0 0 auto; white-space: nowrap; }
.sleep-trigger[data-active="true"] { background: #d8e5d9; }
.player-message { grid-column: 1 / -1; margin-top: 0; }
.sleep-dialog { max-width: 28rem; }
.sleep-dialog h2 { font: 700 1.45rem/1.35 var(--serif); margin-bottom: 8px; }
.sleep-dialog h2:focus { outline: none; }
.sleep-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.sleep-options label { cursor: pointer; }
.sleep-options span { display: flex; min-height: 44px; }
.sleep-options input:checked + .plain-button { color: #fbfaee; border-color: var(--green); background: var(--green); }
.sleep-options input:focus-visible + span { outline: 3px solid #92703b; outline-offset: 2px; }
#sleep-continuous { grid-column: 1 / -1; }

@media (max-width: 620px) {
  .admin-panels { grid-template-columns: 1fr; }
  .masthead .shell { gap: 8px; }
  .account-actions { gap: 3px; }
  .account-actions .plain-button { padding-inline: 7px; font-size: .83rem; }
  .player-wrap { grid-template-columns: minmax(0, 1fr) auto auto; }
  .player-title { grid-area: 1 / 1; }
  .player #previous-episode { grid-area: 1 / 2; }
  .player #next-episode { grid-area: 1 / 3; }
  .player-playback { grid-row: 2; grid-column: 1 / -1; }
  .player .plain-button { padding-inline: 8px; font-size: .84rem; }
  body.has-player { padding-bottom: calc(158px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 360px) {
  .brand h1 { font-size: 1.21rem; }
  .brand-mark { width: 28px; height: 28px; flex-basis: 28px; }
}

.wechat-leave-dialog { max-width: 27rem; }
.wechat-leave-dialog h2, .wechat-exited h2 { font: 700 1.45rem/1.35 var(--serif); }
.wechat-leave-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.wechat-leave-dismiss { margin-top: 8px; }
.wechat-exited { max-width: 29rem; padding-block: clamp(24px, 8vw, 64px); }
.wechat-exited .panel { padding: clamp(16px, 5vw, 24px); }
.wechat-exited p { margin: 8px 0 16px; color: var(--muted); }
