:root {
  --paper: #f7f4ed;
  --paper-2: #efe9de;
  --ink: #17212b;
  --muted: #6c7278;
  --line: rgba(23, 33, 43, 0.14);
  --navy: #17324d;
  --red: #a73535;
  --card: rgba(255, 255, 255, 0.72);
  --shadow: 0 18px 55px rgba(36, 38, 41, 0.08);
  --radius: 22px;
  --content: 1120px;
  --reading: 760px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at 85% 0%, rgba(167, 53, 53, 0.06), transparent 28rem),
    linear-gradient(180deg, #fbfaf7 0%, var(--paper) 30%, #f2eee6 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang HK", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.7;
  min-height: 100vh;
}

a { color: inherit; }
button, input { font: inherit; }
img { max-width: 100%; height: auto; }

.progress {
  position: fixed;
  z-index: 100;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--red);
  transition: width 80ms linear;
}

.site-header {
  width: min(calc(100% - 40px), var(--content));
  margin: 0 auto;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.brand {
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.brand-mark {
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", serif;
  font-weight: 800;
  letter-spacing: .06em;
  font-size: 1.38rem;
}
.brand-sub {
  font-size: .68rem;
  letter-spacing: .15em;
  color: var(--muted);
}

.top-nav { display: flex; gap: 22px; font-size: .93rem; }
.top-nav a { color: var(--muted); text-decoration: none; }
.top-nav a:hover { color: var(--ink); }

#app { width: min(calc(100% - 40px), var(--content)); margin: 0 auto; }

.loading-shell {
  min-height: 65vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}
.loader {
  width: 34px;
  height: 34px;
  border: 2px solid var(--line);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hero {
  padding: 72px 0 42px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 44px;
  align-items: end;
}
.kicker {
  margin: 0 0 12px;
  font-size: .78rem;
  letter-spacing: .22em;
  color: var(--red);
  font-weight: 800;
}
.hero h1 {
  margin: 0;
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", serif;
  font-size: clamp(3.6rem, 9vw, 7.5rem);
  line-height: .95;
  letter-spacing: -.055em;
  font-weight: 900;
}
.hero-copy {
  border-left: 1px solid var(--line);
  padding-left: 30px;
  padding-bottom: 8px;
}
.hero-copy p { margin: 0 0 18px; color: var(--muted); font-size: 1.04rem; }
.hero-copy strong { color: var(--ink); }
.hero-copy .school-spirit {
  margin: 0;
  max-width: 31rem;
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", serif;
  font-size: clamp(1.08rem, 1.8vw, 1.32rem);
  line-height: 1.8;
  letter-spacing: .02em;
}


.latest-wrap { padding: 28px 0 60px; }
.section-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.section-label h2 {
  margin: 0;
  font-size: .82rem;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.section-label span { color: var(--muted); font-size: .84rem; }

.latest-card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, .85fr);
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.latest-image {
  min-height: 340px;
  background: linear-gradient(140deg, #d9d3c9, #f2ede4);
  overflow: hidden;
}
.latest-image img { width: 100%; height: 100%; object-fit: cover; display: block; image-rendering: auto; }
.latest-image.placeholder {
  display: grid;
  place-items: center;
  font-family: "Songti TC", serif;
  font-size: clamp(2.6rem, 6vw, 5.8rem);
  font-weight: 900;
  color: rgba(23, 50, 77, .14);
}
.latest-body { padding: clamp(28px, 4vw, 52px); display: flex; flex-direction: column; justify-content: center; }
.badge {
  align-self: flex-start;
  background: var(--red);
  color: white;
  border-radius: 999px;
  padding: 5px 11px;
  font-size: .72rem;
  letter-spacing: .08em;
  font-weight: 800;
  margin-bottom: 24px;
}
.latest-title {
  margin: 0 0 16px;
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.13;
  letter-spacing: -.03em;
}
.meta { color: var(--muted); font-size: .86rem; }
.excerpt { color: #454d54; margin: 20px 0 28px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.primary-btn, .secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  text-decoration: none;
  font-weight: 750;
  font-size: .92rem;
  transition: transform .15s ease, background .15s ease, color .15s ease;
}
.primary-btn { background: var(--ink); color: #fff; align-self: flex-start; }
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-1px); }
.secondary-btn { background: transparent; color: var(--ink); }

.catalog { padding: 42px 0 88px; border-top: 1px solid var(--line); }
.catalog-head {
  display: grid;
  grid-template-columns: 1fr minmax(250px, 380px);
  gap: 30px;
  align-items: end;
  margin-bottom: 30px;
}
.catalog-head h2 {
  margin: 4px 0 0;
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: clamp(2.25rem, 5vw, 4.4rem);
  line-height: 1;
  letter-spacing: -.035em;
}
.search-box { position: relative; }
.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.64);
  border-radius: 999px;
  padding: 13px 18px;
  outline: none;
  color: var(--ink);
}
.search-box input:focus { border-color: rgba(23, 50, 77, .45); box-shadow: 0 0 0 4px rgba(23, 50, 77, .06); }

.chapter-list { border-top: 1px solid var(--line); }
.chapter-row {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: padding .18s ease, background .18s ease;
}
.chapter-row:hover { padding-left: 10px; background: rgba(255,255,255,.35); }
.chapter-no {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--red);
  font-weight: 800;
  letter-spacing: .06em;
  font-size: .82rem;
}
.chapter-main { min-width: 0; }
.chapter-title { margin: 0; font-size: 1.08rem; font-weight: 760; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-date { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.chapter-arrow { color: var(--muted); font-size: 1.3rem; }
.empty { padding: 42px 0; color: var(--muted); }

.reader-shell { width: min(100%, var(--reading)); margin: 0 auto; padding: 46px 0 84px; }
.reader-top { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 54px; }
.back-link { color: var(--muted); text-decoration: none; font-size: .9rem; }
.back-link:hover { color: var(--ink); }
.reader-label { font-size: .75rem; letter-spacing: .16em; color: var(--red); font-weight: 800; }
.reader-title {
  margin: 10px 0 14px;
  font-family: "Songti TC", "Noto Serif TC", serif;
  font-size: clamp(2.5rem, 7vw, 4.8rem);
  line-height: 1.08;
  letter-spacing: -.045em;
}
.reader-meta { color: var(--muted); font-size: .86rem; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.article-body {
  padding-top: 36px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang HK", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: clamp(1.08rem, 2vw, 1.23rem);
  line-height: 2.02;
  letter-spacing: normal;
  word-spacing: normal;
  word-break: normal;
  overflow-wrap: break-word;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
.article-body p {
  margin: 0 0 1.45em;
  text-align: left !important;
  letter-spacing: normal !important;
  word-spacing: normal !important;
}
.article-body div,
.article-body li,
.article-body span {
  letter-spacing: normal !important;
  word-spacing: normal !important;
}
.article-body h2, .article-body h3 { line-height: 1.35; margin-top: 2.2em; }
.article-body img { border-radius: 14px; margin: 1.1em auto; display: block; }
.article-body a { text-decoration-thickness: 1px; text-underline-offset: 3px; }
.article-body blockquote { margin: 2em 0; padding: 0 0 0 20px; border-left: 3px solid var(--red); color: #444; }
.article-body iframe { width: 100%; max-width: 100%; border: 0; border-radius: 12px; }

.reader-nav {
  margin-top: 58px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}
.nav-chapter {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  text-decoration: none;
  background: rgba(255,255,255,.42);
  min-width: 0;
}
.nav-chapter.right { text-align: right; }
.nav-chapter.disabled { opacity: .35; pointer-events: none; }
.nav-cap { color: var(--muted); font-size: .72rem; display: block; margin-bottom: 3px; }
.nav-title { font-weight: 750; font-size: .9rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.catalog-btn { align-self: center; white-space: nowrap; }

.error-card {
  margin: 80px auto;
  max-width: 650px;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.error-card h1 { margin-top: 0; font-family: "Songti TC", serif; }

.site-footer {
  width: min(calc(100% - 40px), var(--content));
  margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 28px 0 44px;
  display: flex;
  justify-content: space-between;
  gap: 22px;
  color: var(--muted);
  font-size: .8rem;
}
.site-footer p { margin: 0; }
.noscript { padding: 24px; background: #fff3cd; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 26px; padding-top: 48px; }
  .hero-copy { border-left: 0; border-top: 1px solid var(--line); padding: 22px 0 0; }
  .latest-card { grid-template-columns: 1fr; }
  .latest-image { max-height: 330px; }
  .catalog-head { grid-template-columns: 1fr; align-items: stretch; }
}

@media (max-width: 620px) {
  .site-header { width: min(calc(100% - 28px), var(--content)); min-height: 72px; }
  #app, .site-footer { width: min(calc(100% - 28px), var(--content)); }
  .brand-sub { display: none; }
  .top-nav { gap: 14px; font-size: .86rem; }
  .top-nav a:nth-child(3) { display: none; }
  .hero h1 { font-size: clamp(3.35rem, 20vw, 5rem); }
  .latest-wrap { padding-bottom: 46px; }
  .latest-body { padding: 26px 22px 30px; }
  .chapter-row { grid-template-columns: 60px minmax(0, 1fr) auto; gap: 12px; min-height: 82px; }
  .reader-shell { padding-top: 30px; }
  .reader-top { margin-bottom: 38px; }
  .reader-nav { grid-template-columns: 1fr 1fr; }
  .catalog-btn { grid-column: 1 / -1; grid-row: 1; text-align: center; }
  .site-footer { flex-direction: column; }
}

.article-body br + br { display: block; content: ""; margin-top: .8em; }

/* ─────────────────────────────────────────────
   Novel reader mode
   ───────────────────────────────────────────── */
body.reader-page {
  --reader-surface: rgba(251, 250, 247, .88);
  --reader-body-ink: #222a31;
  --reader-soft: rgba(23, 33, 43, .055);
  background:
    radial-gradient(circle at 50% -20%, rgba(167, 53, 53, .045), transparent 32rem),
    #f7f4ed;
}

body.reader-page .site-header {
  min-height: 72px;
}

body[data-reader-width="narrow"] .reader-shell { width: min(100%, 640px); }
body[data-reader-width="medium"] .reader-shell { width: min(100%, 720px); }
body[data-reader-width="wide"] .reader-shell { width: min(100%, 860px); }

.reader-page .reader-shell {
  padding-top: 34px;
}

.reader-tools {
  position: sticky;
  z-index: 30;
  top: 10px;
  margin: 0 0 52px;
  min-height: 52px;
  padding: 7px 8px 7px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--reader-surface);
  box-shadow: 0 8px 28px rgba(28, 31, 34, .07);
  -webkit-backdrop-filter: blur(18px) saturate(135%);
  backdrop-filter: blur(18px) saturate(135%);
}

.reader-tools-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 750;
  letter-spacing: .08em;
}

.reader-tools-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 0;
}

.reader-tool-btn,
.resume-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  background: var(--reader-soft);
  border-radius: 11px;
  min-height: 36px;
  padding: 0 11px;
  font-size: .78rem;
  line-height: 1;
  white-space: nowrap;
  transition: background .15s ease, transform .15s ease;
}

.reader-tool-btn:hover,
.resume-btn:hover {
  background: rgba(23, 33, 43, .1);
}

.reader-tool-btn:active,
.resume-btn:active { transform: translateY(1px); }
.reader-tool-btn.text-btn { min-width: 39px; padding: 0 8px; font-weight: 800; }

.reader-header {
  margin-bottom: 0;
}

.reader-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.reader-meta > span + span::before {
  content: "·";
  margin-right: 16px;
  color: color-mix(in srgb, var(--muted) 50%, transparent);
}

.resume-btn {
  min-height: 30px;
  padding: 0 10px;
  color: var(--red);
  background: rgba(167, 53, 53, .08);
}

.article-body {
  padding-top: 42px;
  color: var(--reader-body-ink);
  font-size: var(--reader-font-size, 1.18rem);
  line-height: 1.95;
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
  font-kerning: normal;
  hanging-punctuation: first last;
}

.article-body > p,
.article-body > div {
  margin-top: 0;
  margin-bottom: 1.32em;
}

.article-body p,
.article-body div,
.article-body li,
.article-body span {
  font-size: inherit !important;
  line-height: inherit !important;
  letter-spacing: 0 !important;
  word-spacing: 0 !important;
}

.article-body strong,
.article-body b { font-weight: 700; }
.article-body em,
.article-body i { font-style: italic; }

.article-body h2,
.article-body h3 {
  color: var(--ink);
  line-height: 1.4;
  margin: 2.4em 0 1em;
  letter-spacing: 0;
}

.article-body img {
  width: auto;
  max-width: min(100%, 1000px);
  height: auto;
  border-radius: 16px;
  margin: 1.65em auto;
  box-shadow: 0 10px 30px rgba(25, 28, 30, .06);
}

.article-body blockquote {
  margin: 2em 0;
  padding: .15em 0 .15em 1.15em;
  border-left: 3px solid var(--red);
  color: color-mix(in srgb, var(--reader-body-ink) 78%, var(--muted));
}

.article-body hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 3em auto;
  width: 38%;
}

body.reader-serif .article-body {
  font-family: "Songti TC", "Noto Serif TC", "PMingLiU", "Times New Roman", serif;
}

/* Night mode only affects the reader page and is remembered locally. */
body.reader-page.reader-night {
  --paper: #17191c;
  --paper-2: #202328;
  --ink: #ece8e0;
  --muted: #a4a8ad;
  --line: rgba(236, 232, 224, .13);
  --navy: #9ab5d0;
  --red: #d77575;
  --card: rgba(32, 35, 40, .78);
  --reader-surface: rgba(30, 33, 37, .9);
  --reader-body-ink: #ddd9d2;
  --reader-soft: rgba(255, 255, 255, .07);
  background: #17191c;
  color-scheme: dark;
}

body.reader-page.reader-night .reader-tool-btn:hover,
body.reader-page.reader-night .resume-btn:hover {
  background: rgba(255, 255, 255, .12);
}

body.reader-page.reader-night .article-body img {
  box-shadow: none;
}

body.reader-page.reader-night .nav-chapter {
  background: rgba(255, 255, 255, .035);
}

body.reader-page.reader-night .secondary-btn {
  border-color: rgba(236, 232, 224, .45);
}

@media (max-width: 820px) {
  body[data-reader-width="narrow"] .reader-shell,
  body[data-reader-width="medium"] .reader-shell,
  body[data-reader-width="wide"] .reader-shell { width: 100%; }

  .reader-tools {
    margin-bottom: 42px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .reader-tools::-webkit-scrollbar { display: none; }
  .reader-tools-label { display: none; }
  .reader-tools-actions { justify-content: flex-start; width: max-content; }
}

@media (max-width: 620px) {
  .reader-page .reader-shell { padding-top: 20px; }
  .reader-page .reader-top { margin-bottom: 24px; }
  .reader-tools {
    top: 7px;
    min-height: 48px;
    margin-left: -4px;
    margin-right: -4px;
    margin-bottom: 36px;
    padding: 5px;
    border-radius: 15px;
  }
  .reader-tool-btn { min-height: 36px; }
  .reader-title { margin-top: 8px; }
  .reader-meta { padding-bottom: 24px; }
  .article-body {
    padding-top: 30px;
    font-size: var(--reader-font-size, 1.18rem);
    line-height: 1.92;
  }
  .article-body > p,
  .article-body > div { margin-bottom: 1.22em; }
  .article-body img { border-radius: 12px; margin: 1.35em auto; }
}
