:root {
  --bg: #f3f5f6;
  --paper: #ffffff;
  --ink: #252525;
  --muted: #667078;
  --line: #d9e0e4;
  --accent: #8b2f2a;
  --accent-dark: #5e201d;
  --blue: #24576b;
  --green: #5b6b3b;
  --shadow: 0 18px 50px rgba(28, 41, 51, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.65;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: rgba(243, 245, 246, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
}

h1 {
  font-size: clamp(22px, 2.2vw, 34px);
  letter-spacing: 0;
}

.subtitle,
.eyebrow {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.control {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
}

.control.subtle {
  background: transparent;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(620px, 1fr) minmax(260px, 330px);
  gap: 18px;
  max-width: 1640px;
  margin: 0 auto;
  padding: 24px;
}

.nav,
.notes {
  position: sticky;
  top: 112px;
  align-self: start;
  max-height: calc(100vh - 136px);
  overflow: auto;
}

.nav {
  padding: 14px;
}

.nav h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

.section-link {
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
}

.section-link.active,
.section-link:hover {
  border-color: var(--line);
  background: rgba(255, 253, 248, 0.85);
  color: var(--accent-dark);
}

.reader-intro,
.author-panel,
.references-section,
.note-panel,
.entry {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.reader-intro,
.author-panel,
.references-section {
  padding: 16px 18px;
  margin-bottom: 18px;
}

.reader-intro {
  color: var(--muted);
}

.author-panel h2,
.references-section h2 {
  margin: 6px 0 12px;
  font-size: 22px;
}

.author-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.author-card,
.reference-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  padding: 14px;
}

.author-card h3 {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 18px;
}

.author-original,
.reference-original {
  color: #353535;
}

.author-translation,
.reference-translation {
  margin-top: 8px;
  color: #4a4f42;
}

.reference-note {
  margin-top: 0;
  color: var(--muted);
}

.references-list {
  display: grid;
  gap: 10px;
}

.reference-item h3 {
  margin-bottom: 8px;
  color: var(--accent-dark);
  font-size: 15px;
}

.entry {
  margin-bottom: 18px;
  padding: 20px;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
  cursor: pointer;
}

.entry:hover,
.entry.active {
  border-color: rgba(139, 47, 42, 0.45);
  transform: translateY(-1px);
}

.entry.locked {
  background: #fff6f4;
  border-color: var(--accent);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  background: #f8fafb;
}

.entry h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

.original {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.75;
  color: #202020;
}

.translation {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: #332f2a;
}

.translation-label {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
}

.note-panel {
  padding: 20px;
}

.note-panel h2 {
  font-size: 22px;
  margin: 8px 0 6px;
}

.note-panel h3 {
  color: var(--accent-dark);
  font-size: 16px;
  margin: 18px 0 8px;
}

.note-panel ul {
  padding-left: 20px;
  margin: 8px 0;
}

.note-panel li {
  margin-bottom: 8px;
}

body.report-mode .critical-section {
  display: none;
}

body.report-mode .note-panel {
  border-color: var(--accent);
}

body.report-mode .control.report-active {
  background: var(--accent-dark);
}

.inline-note-slot {
  margin-top: 16px;
}

.inline-note {
  display: none;
  padding: 18px;
  border: 1px solid rgba(139, 47, 42, 0.34);
  border-radius: 8px;
  background: #fff9f7;
}

.inline-note h2 {
  font-size: 20px;
  margin: 8px 0 6px;
}

.inline-note h3 {
  color: var(--accent-dark);
  font-size: 15px;
  margin: 14px 0 6px;
}

.inline-note ul {
  padding-left: 20px;
  margin: 8px 0;
}

.inline-note li {
  margin-bottom: 6px;
}

.critical {
  border-left: 4px solid var(--green);
  padding: 10px 12px;
  background: #f3f5ec;
  border-radius: 6px;
}

.lock-state {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 1050px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .nav {
    position: static;
    max-height: none;
  }

  .notes {
    display: none;
  }

  .inline-note {
    display: block;
  }

  .section-nav {
    display: flex;
    overflow-x: auto;
    gap: 8px;
  }

  .section-link {
    min-width: 160px;
  }

  .author-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 640px) {
  .topbar {
    position: static;
    flex-direction: column;
    padding: 16px;
  }

  .layout {
    padding: 14px;
  }

  .entry {
    padding: 16px;
  }
}
