:root {
  color-scheme: light;
  --ink: #142130;
  --muted: #68717c;
  --paper: #f7f3ea;
  --paper-cool: #f7f8f5;
  --canvas: #e8e5de;
  --line: #c8c5bd;
  --line-strong: #95958f;
  --accent: #a4472d;
  --accent-soft: #efe0d9;
  --navy: #183a55;
  --success: #2f6d53;
  --warning: #9a6425;
  --shadow: 0 8px 24px rgba(30, 39, 46, 0.08);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --sans: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 1280px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.42)),
    repeating-linear-gradient(90deg, rgba(20, 33, 48, 0.018) 0 1px, transparent 1px 5px),
    var(--canvas);
  font-family: var(--sans);
  font-size: 15px;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: 74px 70px minmax(0, 1fr) 34px;
  width: 100%;
  height: 100vh;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto auto;
  align-items: center;
  gap: 28px;
  padding: 10px 22px 10px 26px;
  color: #f8f6f0;
  background: var(--ink);
  border-bottom: 3px solid var(--accent);
}

.brand-block {
  display: flex;
  align-items: baseline;
  gap: 18px;
  min-width: 0;
}

.brand-block h1,
.brand-block p {
  margin: 0;
}

.brand-block h1 {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.eyebrow,
.column-kicker {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  color: #d7c7bc;
  white-space: nowrap;
}

.masthead-note {
  display: flex;
  align-items: center;
  color: #d8dde1;
  font-size: 12px;
  white-space: nowrap;
}

.masthead-note span + span::before {
  margin: 0 10px;
  color: #7b8790;
  content: "·";
}

.reading-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-button,
.sync-control {
  min-height: 34px;
  border: 1px solid #4a5863;
  border-radius: 4px;
  background: #202f3d;
}

.tool-button {
  padding: 0 12px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.tool-button:hover,
.tool-button:focus-visible {
  border-color: #b7c2ca;
  background: #2a3d4e;
  outline: none;
}

.tool-button:active {
  transform: translateY(1px);
}

.sync-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  cursor: pointer;
  user-select: none;
}

.sync-control input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

.sample-strip {
  position: relative;
  overflow: hidden;
  background: #efede7;
  border-bottom: 1px solid var(--line-strong);
}

.sample-strip-track {
  display: grid;
  grid-template-columns: repeat(10, minmax(122px, 1fr));
  height: 100%;
}

.sample-button {
  position: relative;
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  padding: 8px 12px;
  text-align: left;
  border: 0;
  border-right: 1px solid #d3d0c9;
  background: transparent;
  cursor: pointer;
  transition: background-color 170ms ease, color 170ms ease;
}

.sample-button:hover,
.sample-button:focus-visible {
  z-index: 1;
  background: #e4e1d9;
  outline: 2px solid var(--navy);
  outline-offset: -2px;
}

.sample-button.is-active {
  color: #fff;
  background: var(--navy);
}

.sample-button.is-active::after {
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 3px;
  background: #d98a68;
  content: "";
}

.sample-part {
  overflow: hidden;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sample-page {
  color: #777f86;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
}

.sample-button.is-active .sample-page {
  color: #c8d6df;
}

.workspace {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  padding: 10px;
}

.reading-column {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}

.generic-column {
  background: #fbfaf6;
}

.targeted-column {
  background: var(--paper-cool);
}

.column-header {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 13px 18px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.78);
}

.column-header h2,
.column-header p {
  margin: 0;
}

.column-header h2 {
  margin-top: 3px;
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.1;
}

.column-kicker {
  color: var(--accent);
}

.column-meta {
  display: grid;
  gap: 3px;
  justify-items: end;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  white-space: nowrap;
}

.targeted-header {
  display: grid;
  align-items: stretch;
  gap: 11px;
  min-height: 122px;
}

.targeted-heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.variant-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.variant-tab {
  position: relative;
  min-width: 0;
  height: 30px;
  padding: 0 7px;
  overflow: hidden;
  color: #5f6871;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
  border: 1px solid #c3c7c5;
  border-radius: 3px;
  background: #f0f1ee;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.variant-tab:hover,
.variant-tab:focus-visible {
  color: var(--ink);
  border-color: #89928e;
  outline: none;
}

.variant-tab.is-active {
  color: #fff;
  border-color: var(--navy);
  background: var(--navy);
}

.variant-tab.is-missing::after {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-left: 5px;
  vertical-align: 1px;
  border-radius: 50%;
  background: var(--warning);
  content: "";
}

.scroll-meter {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  overflow: hidden;
  background: transparent;
}

.scroll-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 80ms linear;
}

.reader {
  min-height: 0;
  padding: 24px 30px 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: #a7a59e transparent;
  scrollbar-width: thin;
  transition: opacity 140ms ease, transform 140ms ease;
}

.reader.is-changing {
  opacity: 0;
  transform: translateY(5px);
}

.reader:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: -4px;
}

.reader h3 {
  margin: 0 0 22px;
  padding-bottom: 15px;
  font-family: var(--serif);
  font-size: clamp(22px, 1.45vw, 28px);
  font-weight: 750;
  line-height: 1.42;
  letter-spacing: 0.015em;
  border-bottom: 2px solid var(--ink);
}

.reader p {
  margin: 0 0 1.18em;
  font-family: var(--serif);
  font-size: clamp(16px, 0.93vw, 18px);
  line-height: 1.88;
  text-align: justify;
  text-justify: inter-ideograph;
}

.reader p:first-of-type::first-letter {
  float: left;
  margin: 0.08em 0.1em 0 0;
  color: var(--accent);
  font-size: 2.35em;
  font-weight: 700;
  line-height: 0.86;
}

.source-notes {
  margin-top: 28px;
  padding-top: 16px;
  color: #555e66;
  border-top: 1px solid var(--line);
}

.quality-warning {
  display: grid;
  gap: 7px;
  margin: 0 0 22px;
  padding: 14px 16px;
  color: #6f2d1f;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.65;
  border: 2px solid #b85a3c;
  border-left-width: 7px;
  background: #f8e7df;
  box-shadow: 0 0 0 1px rgba(184, 90, 60, 0.14);
}

.quality-warning strong {
  font-size: 14px;
  letter-spacing: 0.04em;
}

.source-notes h4 {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.source-notes p,
.source-notes li {
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.65;
  text-align: left;
}

.source-notes ol {
  margin: 0;
  padding-left: 22px;
}

.missing-state {
  display: grid;
  align-content: center;
  min-height: 100%;
  padding: 42px;
  text-align: center;
}

.missing-state::before {
  display: block;
  width: 42px;
  height: 1px;
  margin: 0 auto 20px;
  background: var(--accent);
  content: "";
}

.missing-state h3 {
  margin: 0 0 12px;
  padding: 0;
  font-size: 24px;
  border: 0;
}

.missing-state p {
  max-width: 360px;
  margin: 0 auto;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.7;
  text-align: center;
}

.statusbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  color: #d7dce0;
  background: #24313d;
  font-size: 11px;
}

.statusbar p {
  margin: 0;
}

.statusbar p:nth-child(2) {
  overflow: hidden;
  text-align: center;
  white-space: nowrap;
  text-overflow: ellipsis;
}

kbd {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  margin: 0 2px;
  place-items: center;
  color: #eef1f3;
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid #68737c;
  border-radius: 3px;
  background: #34434f;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
