@layer base, components;
@layer base {
  :root {
    color-scheme: light;
    --paper: #f7f4f1; --surface: #fffdfb; --ink: #2c2322; --muted: #695856;
    --line: #e3d8d4; --soft: #f6e8e5; --accent: #9b3935; --on-accent: #fffdfb;
    --mark: #f5d5ce; --hero-edge: #e8c9c1; --shadow: #6828200e;
    /* 背景.jpg: upper-left #e84849, upper-center #bf3d3c, right #65241e.
       The left stop is darkened for white text; the warm halftone echoes the source. */
    --banner-start: #a83b39; --banner-middle: #8f302c; --banner-end: #65241e;
    --banner-copy: #ffebe8; --banner-line: #ffd9ce68; --banner-dot: #f7a08731;
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --paper: #201b1b; --surface: #282222; --ink: #f4ece9; --muted: #c8b5b1;
    --line: #4d3d3b; --soft: #44302e; --accent: #ffa69c; --on-accent: #361c1a;
    --mark: #704039; --hero-edge: #60413e; --shadow: #14080730;
    --banner-start: #802f2d; --banner-middle: #682622; --banner-end: #451a17;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
      color-scheme: dark;
      --paper: #201b1b; --surface: #282222; --ink: #f4ece9; --muted: #c8b5b1;
      --line: #4d3d3b; --soft: #44302e; --accent: #ffa69c; --on-accent: #361c1a;
      --mark: #704039; --hero-edge: #60413e; --shadow: #14080730;
      --banner-start: #802f2d; --banner-middle: #682622; --banner-end: #451a17;
    }
  }
  *, *::before, *::after { box-sizing: border-box; }
  [hidden] { display: none !important; }
  body { margin: 0; background: var(--paper); color: var(--ink); font-family: system-ui,"PingFang SC","Microsoft YaHei",sans-serif; line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }
  main { flex: 1; }
  h1,h2,h3,p { margin: 0; }
  h1,h2,h3 { line-height: 1.32; }
  a { color: var(--accent); text-underline-offset: 4px; }
  button,input,select { font: inherit; color: inherit; }
  button,summary { cursor: pointer; }
  button { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; min-height: 40px; padding: 6px 13px; }
  button:hover:not(:disabled) { border-color: var(--accent); }
  button:disabled { opacity: .47; cursor: default; }
  input,select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; width: 100%; min-width: 0; }
  :focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
  mark { background: var(--mark); color: var(--ink); border-radius: 2px; }
  time { font-variant-numeric: tabular-nums; }
}
@layer components {
  .site-width { width: min(1080px, calc(100% - 64px)); margin-inline: auto; }
  .skip { position: absolute; top: 0; left: 1rem; z-index: 3; transform: translateY(-150%); background: var(--surface); padding: 8px; }
  .skip:focus { transform: none; }
  .site-header { border-bottom: 1px solid var(--line); background: var(--surface); }
  .topbar { display: flex; align-items: center; min-height: 69px; gap: 26px; }
  .brand { text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 11px; margin-right: auto; line-height: 1.2; white-space: nowrap; }
  .brand strong { font-size: 15px; }
  .brand small { display: block; font-size: 9px; color: var(--muted); letter-spacing: .11em; margin-top: 4px; }
  .brand-icon { display: block; flex: none; width: 40px; height: 40px; object-fit: cover; border-radius: 10px; outline: 1px solid var(--hero-edge); outline-offset: 2px; }
  .topbar nav { display: flex; gap: 24px; align-items: stretch; align-self: stretch; }
  .topbar nav a { display: grid; place-items: center; padding-top: 2px; color: var(--muted); text-decoration: none; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
  .topbar nav a[aria-current] { border-color: var(--accent); color: var(--accent); font-weight: 700; }
  .theme { border-radius: 50%; width: 36px; min-height: 36px; padding: 0; }
  .hero {
    margin-top: 32px;
    position: relative;
    isolation: isolate;
    min-height: 306px;
    border-radius: 20px;
    padding: 41px 42px 29px;
    overflow: hidden;
    color: #fffaf8;
    background: linear-gradient(112deg, var(--banner-start), var(--banner-middle) 51%, var(--banner-end));
  }
  .hero-copy,.hero-stats { position: relative; z-index: 1; }
  .eyebrow { width: fit-content; padding: 4px 9px; border: 1px solid var(--banner-line); border-radius: 5px; font-size: .78rem; color: var(--banner-copy); font-weight: 700; letter-spacing: .05em; display: flex; align-items: center; gap: 7px; }
  .eyebrow span { width: 6px; height: 6px; background: #ffbaae; border-radius: 50%; }
  .hero h1 { font-size: clamp(2.15rem, 5.2vw, 4rem); letter-spacing: -.06em; margin-block: 13px 10px; }
  .hero-description { color: var(--banner-copy); max-width: min(31rem, 59%); font-size: 1rem; }
  .hero-stats { display: flex; align-items: center; flex-wrap: wrap; font-size: .82rem; color: var(--banner-copy); margin-top: 28px; gap: 8px 17px; }
  .hero-stats span + span { border-left: 1px solid var(--banner-line); padding-left: 17px; }
  .hero-stats strong { color: #fffaf8; font-size: 1rem; font-variant-numeric: tabular-nums; }
  .hero-art { position: absolute; right: 0; top: 0; bottom: 0; width: 44%; pointer-events: none; }
  .hero-art::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, var(--banner-dot) 2px, transparent 2.6px) 0 0 / 14px 14px;
    mask-image: linear-gradient(90deg, transparent, #000 44%);
  }
  .hero-art img { position: absolute; bottom: 0; right: 10%; width: min(79%, 320px); height: auto; display: block; }
  .search-panel { margin-block: 18px 34px; border: 1px solid var(--line); border-radius: 16px; padding: 22px 26px; background: var(--surface); box-shadow: 0 4px 18px var(--shadow); }
  .search-panel h2,.section-title h2 { font-size: 1.26rem; }
  .searchbar { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); min-height: 55px; border-radius: 11px; margin-top: 13px; padding: 5px 5px 5px 15px; background: var(--paper); }
  .searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--soft); }
  .searchbar input { border: 0; padding: 0; background: transparent; outline: 0; }
  .primary { background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); border-radius: 8px; min-height: 40px; font-weight: 650; padding: 8px 16px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
  .primary:hover { filter: brightness(.93); }
  .magnifier { width: 14px; height: 14px; border: 1.6px solid var(--muted); border-radius: 50%; display: inline-block; flex: 0 0 14px; position: relative; }
  .magnifier::after { content: ''; position: absolute; width: 6px; height: 1.6px; top: 10px; left: 9px; transform: rotate(45deg); background: var(--muted); transform-origin: left; }
  .filters { margin-top: 9px; color: var(--muted); font-size: .85rem; }
  .filters summary { width: fit-content; }
  .filter-grid,.archive-filters { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 10px; }
  .filter-grid label,.archive-filters label { display: grid; gap: 4px; color: var(--muted); }
  .archive-filters { border: 1px solid var(--line); border-radius: 13px; background: var(--surface); padding: 15px; }
  #search-status:not(:empty),#archive-status { color: var(--muted); margin: 13px 0; font-size: .9rem; }
  .suggestions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
  .suggestions button,.tags span { min-height: initial; padding: 3px 10px; border-radius: 99px; background: var(--soft); color: var(--accent); font-size: .8rem; }
  .section-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
  .section-title a,.record-aside a { font-size: .85rem; }
  .record-card { display: grid; grid-template-columns: 82px minmax(0,1fr) auto; gap: 18px; padding: 17px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); margin-bottom: 12px; }
  .record-symbol { min-height: 75px; align-self: stretch; display: grid; place-items: center; background: var(--soft); border-radius: 9px; color: var(--accent); }
  .record-symbol span { border: 1px solid var(--hero-edge); border-radius: 50%; display: grid; place-items: center; width: 33px; height: 33px; font-size: .8rem; }
  .record-meta { color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 3px 13px; align-items: center; font-variant-numeric: tabular-nums; }
  .record-card h3 { font-size: 1.16rem; margin: 6px 0 7px; }
  .record-card h3 a { text-decoration: none; color: var(--ink); }
  .record-card h3 a:hover { color: var(--accent); text-decoration: underline; }
  .tags { display: flex; gap: 5px; flex-wrap: wrap; }
  .record-aside { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; min-width: 85px; gap: 6px; }
  .review,.badge { border-radius: 5px; padding: 2px 7px; background: var(--soft); color: var(--accent); font-size: .75rem; white-space: nowrap; }
  .rank-1,.rank-2 { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
  .site-footer { margin-top: 50px; border-top: 1px solid var(--line); }
  .site-footer div { min-height: 65px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; padding-block: 12px; font-size: .76rem; color: var(--muted); }
  .page-heading { margin-block: 35px 20px; padding: 7px 0 8px 16px; border-left: 3px solid var(--accent); }
  .page-heading h1,.episode-header h1 { font-size: clamp(1.6rem,4vw,2.8rem); letter-spacing: -.035em; }
  .page-heading p { color: var(--muted); margin-top: 9px; }
  .result { border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 14px 16px; margin-bottom: 9px; }
  .result:focus-within { border-color: var(--hero-edge); }
  .result-quote mark { padding-inline: 2px; }
  .result-top,.result-actions,.player-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: .84rem; }
  .result-top { color: var(--muted); }
  .result-quote { color: var(--ink); display: block; text-decoration: none; margin: 8px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .result-quote:hover { color: var(--accent); }
  .result-context { margin-top: 7px; color: var(--muted); font-size: .84rem; }
  .result-context p { border-left: 2px solid var(--line); padding-left: 9px; margin-top: 5px; }
  #pages,#pages form { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; font-size: .86rem; }
  #pages input { width: 76px; }
  .back { display: block; width: fit-content; font-size: .86rem; margin-top: 27px; }
  .episode-header { border: 1px solid var(--line); border-top: 3px solid var(--accent); background: var(--surface); border-radius: 14px; padding: 22px 24px; margin-top: 12px; }
  .episode-header h1 { margin-block: 10px; }
  .episode-actions,.downloads div { display: flex; flex-wrap: wrap; gap: 7px 15px; align-items: center; }
  .episode-actions,.downloads { margin-top: 14px; }
  .downloads { font-size: .9rem; }
  .downloads div { margin-top: 7px; }
  .episode-search { margin-block: 24px; }
  .episode-search h2 { font-size: 1.17rem; }
  .reading { display: grid; grid-template-columns: minmax(150px, 218px) minmax(0, 1fr); gap: 23px; align-items: start; }
  .transcript { min-width: 0; background: var(--surface); padding: 18px 22px; border: 1px solid var(--line); border-radius: 13px; }
  .reading aside { position: sticky; top: 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); padding: 14px; font-size: .84rem; }
  .reading ol { padding-left: 24px; margin: 7px 0 0; }
  .reading ol li { padding: 2px 0; }
  .chapter { margin-bottom: 23px; }
  .chapter h2 { margin-bottom: 8px; font-size: 1.27rem; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
  .speech { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px; padding: 5px; align-items: start; scroll-margin: 20px; }
  .speech:hover,.is-active,.speech:target { background: var(--soft); border-radius: 7px; }
  .speech.is-active { border-left: 3px solid var(--accent); padding-left: 2px; }
  .stamp,.speech-text { padding: 2px 3px; border: 0; background: transparent; text-align: left; min-height: 30px; }
  .stamp { color: var(--accent); font-size: .83rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .stamp:hover { text-decoration: underline; }
  .speech-text { white-space: pre-wrap; word-break: break-word; line-height: 1.85; }
  .speech-text small { display: block; color: var(--muted); }
  dialog { width: min(690px, calc(100% - 24px)); max-height: 92dvh; overflow: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 15px; padding: 17px; overscroll-behavior: contain; }
  dialog::backdrop { background: #201313a8; }
  .player-top { display: flex; align-items: start; justify-content: space-between; gap: 9px; margin-bottom: 9px; }
  .player-top h2 { font-size: 1.23rem; }
  .player-top p,.muted { color: var(--muted); font-size: .83rem; }
  #player-frame iframe { display: block; aspect-ratio: 16 / 9; width: 100%; max-height: 45dvh; border: 0; background: #231c1c; border-radius: 8px; }
  .player-actions { margin-block: 9px; }
  .player-context p { margin-top: 7px; white-space: pre-wrap; padding: 6px 8px; border-radius: 5px; font-size: .89rem; }
  .player-context .stamp { margin-right: 7px; }
  .current-quote { background: var(--soft); border-left: 3px solid var(--accent); }
  @media (max-width: 700px) {
    .site-width { width: calc(100% - 28px); }
    .topbar { gap: 10px; min-height: 57px; }
    .topbar nav { gap: 10px; }
    .topbar nav a { font-size: .78rem; }
    .brand { gap: 5px; }
    .brand strong { font-size: .76rem; }
    .brand small { display: none; }
    .brand-icon,.theme { width: 29px; min-height: 29px; height: 29px; }
    .hero { margin-top: 17px; min-height: 220px; padding: 21px 15px 16px; border-radius: 16px; }
    .hero h1 { font-size: clamp(1.55rem, 6vw, 2.45rem); letter-spacing: -.04em; }
    .hero-copy { max-width: 61%; }
    .hero-description { max-width: 100%; font-size: .85rem; }
    .hero-art { width: 39%; }
    .hero-art::before { inset: 0 0 29px; }
    .hero-art img { right: 0; bottom: 54px; width: 100%; max-width: 170px; }
    .hero-stats { margin-top: 15px; gap: 7px 9px; font-size: .72rem; }
    .hero-stats strong { font-size: .83rem; }
    .hero-stats span + span { padding-left: 9px; }
    .search-panel { padding: 15px 12px; margin-bottom: 25px; }
    .filter-grid,.archive-filters { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
    .archive-filters label:first-child { grid-column: 1/-1; }
    .record-card { grid-template-columns: 39px minmax(0,1fr); padding: 10px; gap: 8px; }
    .record-symbol { min-height: 40px; align-self: start; }
    .record-symbol span { width: 27px; height: 27px; }
    .record-aside { grid-column: 2; flex-direction: row; align-items: center; }
    .episode-header { padding: 15px; }
    .reading { grid-template-columns: minmax(0,1fr); }
    .reading aside { position: static; }
    .reading ol { columns: 2; }
    .transcript { padding: 12px 10px; }
    .result { padding: 11px 9px; }
    .result-actions { row-gap: 6px; }
    .speech { grid-template-columns: minmax(0,1fr); gap: 1px; padding-block: 7px; }
    .speech p,.speech-text { font-size: .96rem; }
    .site-footer { margin-top: 32px; }
  }
}
