:root {
  color-scheme: light;
  --nav-width: 286px;
  --toolbar-height: 64px;
  --ink: #202528;
  --muted: #667177;
  --line: #d8dcde;
  --paper: #ffffff;
  --canvas: #f3f5f4;
  --nav: #172328;
  --nav-muted: #9eb0b5;
  --accent: #087f8c;
  --warm: #d35f43;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0;
}

.navigator {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--nav-width);
  display: grid;
  grid-template-rows: auto auto 1fr;
  color: #f5f8f8;
  background: var(--nav);
  border-right: 1px solid #34444a;
}

.nav-header { padding: 18px 18px 14px; border-bottom: 1px solid #34444a; }
.nav-header strong { display: block; font-family: Georgia, serif; font-size: 17px; line-height: 1.35; }
.nav-header span { display: block; margin-top: 5px; color: var(--nav-muted); font-size: 12px; text-transform: uppercase; }

.nav-search { display: block; padding: 12px; border-bottom: 1px solid #34444a; }
.nav-search input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  color: #f8fbfb;
  background: #223239;
  border: 1px solid #46585f;
  border-radius: 4px;
  outline: none;
}
.nav-search input:focus { border-color: #61c3cb; box-shadow: 0 0 0 2px rgba(97,195,203,.2); }
.nav-search input::placeholder { color: #aebdc1; }

#page-list { overflow: auto; padding: 8px 0 20px; }
.page-link {
  display: grid;
  grid-template-columns: 45px 1fr;
  gap: 7px;
  align-items: start;
  padding: 8px 13px;
  color: #dfe7e9;
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 12px;
  line-height: 1.35;
}
.page-link:hover { background: #223239; }
.page-link.active { color: #fff; background: #293d44; border-left-color: #61c3cb; }
.page-link .number { color: #87a0a7; font-variant-numeric: tabular-nums; }
.page-link.active .number { color: #a8e1e5; }
.page-link[hidden] { display: none; }

.workspace { margin-left: var(--nav-width); min-width: 0; }
.toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--toolbar-height);
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(255,255,255,.97);
  border-bottom: 1px solid var(--line);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  text-decoration: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-button:hover { color: var(--accent); border-color: var(--accent); }
.icon-button.disabled { opacity: .3; pointer-events: none; }
.menu-button { display: none; }

.page-identity { min-width: 0; line-height: 1.25; }
.page-identity span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.page-identity strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }

.view-switch { display: grid; grid-template-columns: repeat(3, auto); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.view-switch button { min-height: 36px; padding: 0 11px; color: var(--muted); background: #fff; border: 0; border-right: 1px solid var(--line); cursor: pointer; }
.view-switch button:last-child { border-right: 0; }
.view-switch button.active { color: #fff; background: var(--accent); }

.parallel-reader { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); max-width: 1680px; margin: 0 auto; background: var(--paper); }
.document { min-width: 0; padding: 28px clamp(24px, 3vw, 52px) 80px; overflow-wrap: anywhere; }
.document + .document { border-left: 1px solid var(--line); }
.language-label { margin-bottom: 28px; padding-bottom: 8px; color: var(--accent); border-bottom: 2px solid var(--accent); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.chinese-document .language-label { color: var(--warm); border-bottom-color: var(--warm); }

.document h1, .document h2, .document h3, .document h4 { margin: 1.4em 0 .55em; font-family: Georgia, "Noto Serif SC", "Songti SC", serif; line-height: 1.3; }
.document h1 { font-size: 28px; }
.document h2 { font-size: 23px; }
.document h3 { font-size: 19px; }
.document h4 { font-size: 17px; }
.document p { margin: .7em 0; }
.document img { display: block; max-width: 100%; height: auto; margin: 18px auto; }
.source-page-link { display: block; color: inherit; text-decoration: none; }
.document .source-page-image {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  border: 1px solid #c8ced0;
  box-shadow: 0 3px 14px rgba(24, 35, 40, .12);
}
.document table { width: 100%; margin: 18px 0; border-collapse: collapse; font-size: 14px; }
.document th, .document td { padding: 7px 9px; border: 1px solid #bcc4c7; text-align: left; vertical-align: top; }
.document th { background: #edf1f1; }
.document pre { max-width: 100%; padding: 14px; overflow: auto; color: #e8eeee; background: #202b30; border-left: 3px solid var(--accent); }
.document code { font-family: "Cascadia Mono", Consolas, monospace; font-size: .88em; }
.document :not(pre) > code { padding: 2px 4px; background: #edf1f1; border-radius: 3px; }
.document blockquote { margin: 16px 0; padding: 4px 16px; color: #505c61; border-left: 3px solid var(--warm); }
.document hr { margin: 28px 0; border: 0; border-top: 1px solid var(--line); }
.document mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; padding: 5px 0; }

body.view-english .parallel-reader, body.view-chinese .parallel-reader { grid-template-columns: minmax(0, 900px); justify-content: center; }
body.view-english .chinese-document, body.view-chinese .english-document { display: none; }
body.view-english .document, body.view-chinese .document { border-left: 0; }
.nav-scrim { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .navigator { transform: translateX(-100%); transition: transform .2s ease; }
  body.nav-open .navigator { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .menu-button { display: inline-grid; }
  body.nav-open .nav-scrim { position: fixed; inset: 0; z-index: 25; display: block; background: rgba(0,0,0,.35); }
  .parallel-reader { grid-template-columns: 1fr; }
  .document + .document { border-top: 8px solid var(--canvas); border-left: 0; }
}

@media (max-width: 640px) {
  .toolbar { grid-template-columns: auto auto minmax(0, 1fr) auto; padding: 7px 8px; }
  .view-switch { grid-column: 1 / -1; width: 100%; }
  .view-switch button { width: 100%; }
  .document { padding: 20px 16px 58px; }
  .document h1 { font-size: 24px; }
  .document h2 { font-size: 21px; }
}

@media print {
  .navigator, .toolbar, .nav-scrim { display: none !important; }
  .workspace { margin: 0; }
  .parallel-reader { display: grid; grid-template-columns: 1fr 1fr; max-width: none; }
  .document { padding: 12mm; font-size: 10pt; }
}
