:root {
  --ink: #183449;
  --navy: #164a6b;
  --orange: #e97825;
  --orange-dark: #bb5715;
  --paper: #fbfaf7;
  --white: #ffffff;
  --line: #dfe7eb;
  --muted: #748592;
  --reader: #202a33;
  --reader-panel: #172129;
  --shadow: 0 12px 36px rgba(24, 52, 73, .09);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
  text-rendering: optimizeLegibility;
}
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(233, 120, 37, .45); outline-offset: 3px; }
img { max-width: 100%; }

.site-shell { min-height: 100vh; background: var(--paper); }
.site-loading, .noscript-message {
  width: min(600px, calc(100% - 40px));
  margin: 18vh auto 0;
  padding: 36px;
  border: 1px solid var(--line);
  background: var(--white);
  text-align: center;
  box-shadow: var(--shadow);
}
.noscript-message h1 { margin: 0 0 12px; color: var(--navy); font-size: 26px; }
.noscript-message p { margin: 0; color: var(--muted); }

.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 max(5vw, 24px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
}
.brand { display: inline-flex; align-items: center; gap: 14px; min-height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; font-weight: 700; }
.brand-logo { display: block; width: 132px; height: auto; }
.brand-divider { width: 1px; height: 26px; background: #d3dde3; }
.header-note { color: var(--muted); font-size: 13px; }

.hero { overflow: hidden; background: #eee4d7; }
.hero-image { display: block; width: 100%; height: auto; }
.series-anchor-nav {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 15px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 8px 24px rgba(24, 52, 73, .06);
}
.series-anchor-inner { display: flex; align-items: center; gap: 18px; width: min(1180px, 100%); margin: 0 auto; }
.series-anchor-inner > span { flex: none; color: var(--orange-dark); font-size: 12px; font-weight: 800; }
.series-anchor-links { display: flex; gap: 10px; min-width: 0; overflow-x: auto; padding: 2px 2px 7px; scrollbar-width: thin; }
.series-anchor-links button {
  flex: none;
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid #d6e1e7;
  border-radius: 999px;
  background: var(--white);
  color: var(--navy);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}
.series-anchor-links button:hover { border-color: var(--orange); color: var(--orange-dark); background: #fff7ef; }

.content-section, .volumes-page { width: min(1180px, 100%); margin: 0 auto; padding: 64px 30px 90px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading p, .volume-intro > p { margin: 0; color: var(--orange-dark); font-size: 12px; font-weight: 800; }
.section-heading h1, .volume-intro h1 { margin: 7px 0 0; color: var(--navy); font-size: 30px; line-height: 1.25; }
.section-heading > span { flex: none; color: var(--muted); font-size: 13px; }
.series-list { display: grid; gap: 24px; }
.series-card {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
  scroll-margin-top: 100px;
}
.series-card:hover { transform: translateY(-4px); box-shadow: 0 18px 44px rgba(24, 52, 73, .14); }
.series-image { aspect-ratio: 1400 / 600; min-height: 0; overflow: hidden; background: #f0f1ef; }
.series-image img { display: block; width: 100%; height: 100%; object-fit: contain; }
.series-placeholder, .cover-placeholder { display: flex; align-items: center; justify-content: center; min-height: 300px; padding: 30px; background: var(--navy); color: var(--white); font-size: 30px; font-weight: 800; text-align: center; }
.series-info { position: relative; display: flex; min-width: 0; flex-direction: column; justify-content: center; min-height: 0; padding: 54px 42px 42px; }
.level-badge { position: absolute; top: 18px; right: 18px; padding: 6px 11px; border: 1px solid #d9e3e8; border-radius: 999px; background: #f5f8f9; color: var(--navy); font-size: 12px; font-weight: 800; }
.series-info p { margin: 0; color: var(--orange-dark); font-size: 13px; font-weight: 800; }
.series-info h3 { margin: 7px 0 8px; color: var(--ink); font-size: 32px; line-height: 1.2; }
.series-info > span:not(.level-badge) { color: var(--muted); font-size: 14px; }
.series-info b, .volume-card b { margin-top: 26px; color: var(--orange-dark); font-size: 14px; }
.series-info i, .volume-card i { margin-left: 9px; font-style: normal; }
.data-message { display: flex; flex-direction: column; gap: 8px; padding: 40px; border: 1px dashed #bdccd4; border-radius: 8px; background: var(--white); color: var(--muted); text-align: center; }
.data-message strong { color: var(--navy); }

.breadcrumb { display: flex; align-items: center; gap: 12px; margin-bottom: 48px; color: var(--muted); font-size: 13px; }
.breadcrumb button { padding: 0; border: 0; background: transparent; cursor: pointer; }
.breadcrumb strong { color: var(--navy); }
.volume-intro { margin-bottom: 42px; text-align: center; }
.volume-intro > span { color: var(--muted); }
.volume-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 220px)); align-items: start; justify-content: center; gap: 20px; }
.volume-card { padding: 12px; border: 0; border-radius: 8px; background: var(--white); box-shadow: 0 7px 28px rgba(32, 58, 78, .08); text-align: left; }
button.volume-card { cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
button.volume-card:hover { transform: translateY(-5px); box-shadow: 0 15px 34px rgba(32, 58, 78, .14); }
.volume-card.locked { cursor: default; }
.cover-wrap { position: relative; aspect-ratio: 1240 / 1754; overflow: hidden; border-radius: 5px; background: #f3f1ed; }
.cover-wrap img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cover-placeholder { min-height: 280px; font-size: 22px; }
.available, .coming-soon { position: absolute; top: 10px; left: 10px; padding: 5px 10px; border-radius: 999px; background: var(--white); color: var(--orange-dark); font-size: 11px; font-weight: 800; }
.coming-soon { color: var(--muted); background: rgba(255, 255, 255, .94); }
.volume-card > div:last-child { padding: 13px 4px 7px; }
.volume-card p { margin: 0 0 6px; color: var(--orange-dark); font-size: 10px; font-weight: 800; }
.volume-card h2 { margin: 0 0 6px; color: var(--ink); font-size: 16px; line-height: 1.35; }
.volume-card div > span { color: var(--muted); font-size: 11px; }
.volume-card b { display: block; margin-top: 14px; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 30px max(5vw, 25px); border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.site-footer span { color: #2f6592; font-size: 18px; font-weight: 900; }
.site-footer p { margin: 0; }

.reader-shell { display: flex; flex-direction: column; height: 100dvh; min-height: 0; overflow: hidden; background: #202a33; color: var(--white); }
.reader-shell.is-expanded { position: fixed; inset: 0; z-index: 20; width: 100vw; height: 100dvh; }
.reader-header { position: relative; z-index: 10; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; flex: 0 0 66px; min-height: 66px; padding: 0 20px; border-bottom: 1px solid var(--line); background: var(--white); color: var(--ink); }
.back-button { justify-self: start; min-height: 38px; padding: 8px 13px; border: 0; border-radius: 6px; background: #f1f5f6; cursor: pointer; font-size: 13px; }
.back-button span { margin-right: 4px; font-size: 22px; vertical-align: -2px; }
.reader-title { display: flex; min-width: 0; max-width: min(52vw, 360px); flex-direction: column; text-align: center; }
.reader-title strong, .reader-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-title strong { font-size: 14px; }
.reader-title span { margin-top: 2px; color: #8593a0; font-size: 11px; }
.reader-actions { position: relative; z-index: 11; display: flex; justify-self: end; gap: 8px; }
.icon-button, .zoom-controls button { display: inline-grid; place-items: center; width: 38px; height: 36px; padding: 0; border: 1px solid #d8e1e5; border-radius: 6px; background: var(--white); cursor: pointer; font-size: 18px; line-height: 1; touch-action: manipulation; }
.icon-button[aria-pressed="true"] { border-color: var(--orange); color: var(--orange-dark); }
.reader-body { position: relative; display: flex; flex: 1 1 auto; height: 0; min-height: 0; }
.thumbnail-panel { flex: none; width: 124px; padding: 16px 12px; overflow-y: auto; background: #172129; }
.thumbnail-panel > p { margin: 0 0 12px; color: #9cabb7; font-size: 11px; }
.thumbnail-panel button { display: block; width: 100%; margin-bottom: 10px; padding: 6px; border: 2px solid transparent; border-radius: 5px; background: #26323b; color: #aeb9c2; cursor: pointer; }
.thumbnail-panel button.active { border-color: var(--orange); color: var(--white); }
.thumbnail-panel img { display: block; width: 100%; aspect-ratio: 3 / 4; border-radius: 3px; object-fit: cover; }
.thumbnail-panel button > span:last-child { display: block; margin-top: 4px; font-size: 10px; }
.video-thumb { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 70px; border-radius: 4px; background: #111923; font-size: 22px; }
.video-thumb small { margin-top: 4px; font-size: 9px; }
.book-stage { position: relative; display: flex; flex: 1; align-items: center; justify-content: center; min-width: 0; min-height: 0; background: #2d3943; }
.page-viewport { display: block; width: calc(100% - 120px); height: 100%; min-height: 0; padding: 22px; overflow: auto; overscroll-behavior: contain; }
.page-frame { display: flex; align-items: center; justify-content: center; width: 100%; min-width: 100%; height: 100%; margin: 0 auto; transform-origin: center; transition: opacity .22s ease, transform .22s ease; }
.page-frame img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; background: var(--white); box-shadow: 0 15px 50px rgba(0, 0, 0, .42); user-select: none; }
.page-frame video { display: block; width: min(1100px, 100%); max-height: 100%; background: #000; box-shadow: 0 15px 50px rgba(0, 0, 0, .42); }
.page-frame.turn-next { opacity: 0; transform: translateX(-40px) rotateY(-7deg); }
.page-frame.turn-prev { opacity: 0; transform: translateX(40px) rotateY(7deg); }
.page-arrow { position: absolute; z-index: 2; display: grid; place-items: center; width: 48px; height: 62px; padding: 0; border: 0; border-radius: 7px; background: rgba(255, 255, 255, .12); color: var(--white); cursor: pointer; font-size: 38px; line-height: 1; }
.page-arrow:hover:not(:disabled) { background: var(--orange); }
.page-arrow:disabled, .zoom-controls button:disabled { opacity: .3; cursor: default; }
.page-arrow.left { left: 18px; }
.page-arrow.right { right: 18px; }
.empty-reader { padding: 40px; color: #c9d3dc; text-align: center; }
.reader-toolbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; flex: 0 0 64px; min-height: 64px; padding: 0 22px; background: var(--white); color: var(--ink); }
.page-count { color: #687987; font-size: 12px; }
.zoom-controls { display: flex; align-items: center; gap: 7px; }
.zoom-controls .zoom-value { width: 66px; color: var(--ink); font-size: 12px; }
.keyboard-hint { justify-self: end; color: #8997a2; font-size: 11px; }
.thumbnail-backdrop { display: none; }

@media (max-width: 850px) {
  .series-card { grid-template-columns: 1fr; }
  .volume-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .header-note, .keyboard-hint { display: none; }
  .thumbnail-backdrop { position: absolute; inset: 0; z-index: 7; display: block; border: 0; background: rgba(0, 0, 0, .28); cursor: pointer; }
  .thumbnail-panel { position: absolute; top: 0; bottom: 0; left: 0; z-index: 8; width: min(42vw, 180px); box-shadow: 12px 0 30px rgba(0, 0, 0, .35); }
  .page-viewport { width: calc(100% - 80px); padding: 12px; }
  .page-arrow { width: 36px; }
  .page-arrow.left { left: 5px; }
  .page-arrow.right { right: 5px; }
}
@media (max-width: 520px) {
  .topbar { min-height: 62px; padding: 0 16px; }
  .brand { gap: 8px; }
  .brand-logo { width: 104px; }
  .brand > span:last-child { font-size: 13px; }
  .series-anchor-nav { padding: 12px 18px; }
  .series-anchor-inner { display: block; }
  .series-anchor-inner > span { display: block; margin-bottom: 8px; }
  .content-section, .volumes-page { padding: 45px 18px 70px; }
  .section-heading > span { display: none; }
  .series-info { min-height: 0; padding: 28px 26px 30px; }
  .series-info h3 { font-size: 28px; }
  .volume-grid { gap: 12px; }
  .reader-header { grid-template-columns: auto minmax(0, 1fr) auto; padding: 0 8px; }
  .reader-title { max-width: none; }
  .reader-title strong { font-size: 11px; }
  .reader-title span { display: none; }
  .back-button { width: 42px; padding: 7px 10px; font-size: 0; }
  .back-button span { margin: 0; font-size: 25px; }
  .icon-button { width: 34px; }
  .page-viewport { width: 100%; padding: 10px 42px; }
  .reader-toolbar { grid-template-columns: 1fr auto; padding: 0 12px; }
  .site-footer { align-items: flex-start; flex-direction: column; gap: 5px; }
}

@supports not (height: 100dvh) {
  .reader-shell { height: 100vh; }
}
