:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --paper: #fffdf7;
  --paper-strong: #ffffff;
  --text: #1d2526;
  --muted: #66706e;
  --faint: #8a938f;
  --border: #e4ded1;
  --accent: #2f766d;
  --accent-strong: #195c55;
  --highlight: #b77622;
  --shadow: 0 18px 48px rgba(37, 47, 43, 0.12);
  --reader-size: 18px;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="sepia"] {
  --bg: #f3ecd9;
  --paper: #fff8e6;
  --paper-strong: #fffaf0;
  --text: #2d251c;
  --muted: #756a5c;
  --faint: #948674;
  --border: #dfd2b8;
  --accent: #7b6140;
  --accent-strong: #5b472f;
  --highlight: #9f6224;
  --shadow: 0 18px 42px rgba(77, 57, 33, 0.14);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101414;
  --paper: #171d1d;
  --paper-strong: #1d2525;
  --text: #ecf1ed;
  --muted: #acb8b4;
  --faint: #83908c;
  --border: #2a3836;
  --accent: #7fd0c2;
  --accent-strong: #a7eadf;
  --highlight: #f0b35f;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

[data-size="16"] { --reader-size: 16px; }
[data-size="17"] { --reader-size: 17px; }
[data-size="18"] { --reader-size: 18px; }
[data-size="19"] { --reader-size: 19px; }
[data-size="20"] { --reader-size: 20px; }
[data-size="21"] { --reader-size: 21px; }
[data-size="22"] { --reader-size: 22px; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(47, 118, 109, 0.07), transparent 240px),
    var(--bg);
  color: var(--text);
  font-family: inherit;
}
button, input { font: inherit; }
button {
  -webkit-tap-highlight-color: transparent;
  border: 1px solid var(--border);
  background: var(--paper-strong);
  color: var(--text);
}
button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 30;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  width: 100%;
  height: 3px;
  color: var(--accent);
  background: color-mix(in srgb, var(--border) 60%, transparent);
}
.progress::-webkit-progress-bar {
  background: color-mix(in srgb, var(--border) 60%, transparent);
}
.progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), var(--highlight));
}
.progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent), var(--highlight));
}
.reader-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 28px);
}
.topbar {
  position: sticky;
  top: 3px;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  margin: 0 -10px;
  padding: 8px 10px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
}
.icon-button, .text-button, .theme-button, .bottom-action {
  min-width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 22px rgba(22, 31, 30, 0.08);
}
.icon-button {
  flex-direction: column;
  gap: 4px;
}
.icon-button span {
  width: 17px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}
.topbar-title {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.topbar-title strong {
  font-size: 14px;
  line-height: 1.1;
}
.topbar-title span {
  color: var(--muted);
  font-size: 12px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.text-button {
  width: 42px;
  font-size: 13px;
  font-weight: 700;
}
.theme-button span {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--paper), var(--accent));
  border: 1px solid var(--border);
}
.hero {
  padding: 36px 0 24px;
}
.path {
  margin: 0 0 16px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}
.hero h1 {
  margin: 0;
  max-width: 10em;
  font-size: clamp(32px, 10vw, 58px);
  line-height: 1.04;
  letter-spacing: 0;
}
.dek {
  margin: 18px 0 0;
  max-width: 34em;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.78;
}
.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 0;
}
.hero-facts span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 18px;
  color: var(--faint);
  font-size: 12px;
}
.bottom-toolbar {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  z-index: 24;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: min(calc(100% - 20px), 720px);
  margin: 0 auto;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--paper-strong) 91%, transparent);
  box-shadow: 0 12px 38px rgba(19, 27, 26, 0.18);
  backdrop-filter: blur(18px);
}
.bottom-action {
  min-width: 48px;
  height: 36px;
  padding: 0 11px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}
.font-cluster {
  display: grid;
  grid-template-columns: 38px 56px 38px;
  gap: 4px;
}
.font-cluster button {
  min-width: 0;
  height: 36px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}
.font-cluster button[data-font-reset] {
  font-weight: 700;
}
.theme-swatches {
  display: flex;
  gap: 6px;
}
.theme-swatches button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
}
.theme-swatches button:nth-child(1) { background: #fffdf7; }
.theme-swatches button:nth-child(2) { background: #f3ecd9; }
.theme-swatches button:nth-child(3) { background: #171d1d; }
.progress-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 36px;
  color: var(--accent-strong);
  font-size: 16px;
}
.article {
  padding: 4px 0 136px;
  font-size: var(--reader-size);
  line-height: 1.92;
}
.article p, .article ol, .article ul {
  margin: 0 0 1.16em;
}
.article h2, .article h3, .article h4 {
  scroll-margin-top: 84px;
  letter-spacing: 0;
}
.article h2 {
  margin: 2.25em 0 0.76em;
  padding-top: 0.2em;
  font-size: 1.34em;
  line-height: 1.36;
}
.article h2::before {
  content: "";
  display: block;
  width: 44px;
  height: 4px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--highlight));
}
.article h3 {
  margin: 1.7em 0 0.55em;
  font-size: 1.12em;
  line-height: 1.42;
}
.article strong {
  color: color-mix(in srgb, var(--accent-strong) 72%, var(--text));
  font-weight: 800;
}
.article a {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
.article a.file-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 700;
}
.article ol, .article ul {
  padding-left: 1.35em;
}
.article li {
  margin: 0.34em 0;
  padding-left: 0.15em;
}
.article hr {
  height: 1px;
  border: 0;
  margin: 2.1em 0;
  background: var(--border);
}
.article code {
  padding: 0.1em 0.32em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
  margin: 1.25em 0 1.6em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 12px 28px rgba(22, 31, 30, 0.08);
}
.table-scroll table {
  min-width: 720px;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84em;
  line-height: 1.58;
}
.table-scroll th, .table-scroll td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.align-left { text-align: left; }
.align-center { text-align: center; }
.align-right { text-align: right; }
.table-scroll th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper-strong);
  color: var(--accent-strong);
  font-size: 0.88em;
}
.table-scroll tr:last-child td {
  border-bottom: 0;
}
.attachment-section {
  margin-top: 2.6em;
  padding-top: 0.7em;
  border-top: 1px solid var(--border);
}
.attachment-section h2 {
  margin-top: 1.1em;
}
.attachment-intro, .attachment-head p, .attachment-empty {
  color: var(--muted);
}
.attachment-block {
  margin: 1.25em 0 1.8em;
}
.attachment-head, .sheet-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.attachment-head h3, .sheet-head h3 {
  margin: 0;
}
.attachment-head p {
  margin: 0.25em 0 0;
  word-break: break-all;
  font-size: 0.82em;
  line-height: 1.45;
}
.download-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-radius: var(--radius);
  background: var(--paper-strong);
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 0.82em;
  font-weight: 800;
}
.excel-sheet {
  margin-top: 1em;
}
.sheet-head {
  margin-bottom: 0.55em;
}
.sheet-head span {
  color: var(--faint);
  font-size: 0.78em;
  white-space: nowrap;
}
.sheet-notes {
  display: grid;
  gap: 0.45em;
  margin: 0.55em 0 0.85em;
  color: var(--muted);
  font-size: 0.86em;
  line-height: 1.62;
}
.sheet-notes p {
  margin: 0;
}
.table-scroll--excel table {
  min-width: 980px;
  font-size: 0.78em;
}
.toc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(8, 13, 12, 0.38);
}
.toc-drawer {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  max-height: min(76vh, 680px);
  transform: translateY(110%);
  transition: transform 180ms ease;
  border-top: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  background: var(--paper-strong);
  box-shadow: 0 -20px 54px rgba(0, 0, 0, 0.22);
}
.toc-drawer[data-open="true"] {
  transform: translateY(0);
}
.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
}
.toc-head button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
}
.toc-body {
  display: grid;
  gap: 2px;
  max-height: calc(min(76vh, 680px) - 58px);
  overflow: auto;
  padding: 10px 10px max(24px, env(safe-area-inset-bottom));
}
.toc-link {
  display: block;
  padding: 11px 12px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.35;
}
.toc-link--sub {
  padding-left: 24px;
  color: var(--muted);
  font-size: 13px;
}
.toc-link:active, .toc-link:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.float-toc {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 18;
  min-width: 54px;
  padding: 0 12px;
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}
html[data-toc-open="true"], html[data-toc-open="true"] body {
  overflow: hidden;
}
@media (max-width: 560px) {
  .reader-shell { padding-inline: 17px; }
  .topbar { margin-inline: -7px; padding-inline: 7px; grid-template-columns: 42px 1fr auto; }
  .topbar-actions { gap: 5px; }
  .text-button { display: none; }
  .hero { padding-top: 28px; }
  .hero h1 { max-width: 9em; }
  .bottom-toolbar { gap: 5px; padding: 7px; }
  .font-cluster { grid-template-columns: 34px 50px 34px; }
  .font-cluster button, .theme-swatches button, .bottom-action, .progress-chip { height: 34px; }
  .theme-swatches button { width: 34px; }
  .attachment-head { align-items: flex-start; flex-direction: column; }
  .download-link { align-self: flex-start; }
  .table-scroll--excel table { min-width: 860px; }
  .article { font-size: var(--reader-size); }
}
@media (min-width: 900px) {
  body {
    background:
      linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 5%, transparent), transparent),
      var(--bg);
  }
  .article {
    padding-bottom: 140px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .toc-drawer { transition: none; }
}
