* {
  box-sizing: border-box;
}
html {
  --paper: #f4f8f8;
  --ink: #1a3338;
  --muted: #49616a;
  --line: #bdcece;
  --accent: #136463;
  --soft: #e2eeeb;
  --panel: #ffffffea;
  --warn: #92441f;
  color-scheme: light;
}
html.dark {
  --paper: #13272b;
  --ink: #e5f0ed;
  --muted: #abc5c3;
  --line: #446063;
  --accent: #8ed7c6;
  --soft: #264143;
  --panel: #162c30f2;
  --warn: #ffba85;
  color-scheme: dark;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Geist, "PingFang SC", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
#ocean {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  z-index: -1;
  pointer-events: none;
}
body.read #ocean {
  display: none;
}
header {
  padding: 15px max(4vw, 20px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}
nav,
.actions,
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
button,
.btn {
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 6px 13px;
  cursor: pointer;
  text-decoration: none;
}
button:hover,
.btn:hover,
button.active {
  background: var(--soft);
  border-color: var(--accent);
}
button.primary {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--accent);
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
main {
  max-width: 1250px;
  margin: auto;
  padding: 34px max(3vw, 16px) 90px;
}
.hero {
  padding: 8vh 0 6vh;
}
.hero h1 {
  font-family: Georgia, "Songti SC", serif;
  font-size: 52px;
  margin: 0 0 24px;
}
.hero form {
  display: grid;
  gap: 12px;
  max-width: 320px;
}
.pair,
.cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.course {
  display: block;
  padding: 23px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.course b {
  font:
    38px Georgia,
    serif;
}
.course small {
  display: block;
  color: var(--muted);
}
h1,
h2,
h3,
p {
  margin: 0 0 0.7em;
}
h1 {
  font-size: 30px;
}
h2 {
  font-size: 21px;
}
h3 {
  font-size: 17px;
}
.back,
.textlink,
a {
  color: var(--accent);
}
.back {
  display: inline-block;
  margin-bottom: 18px;
}
.tabs {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin: 12px 0 18px;
}
.tabs button {
  border: 0;
  background: transparent;
}
.tabs .active {
  background: var(--soft);
}
.list {
  padding: 0;
  margin: 0;
  list-style: none;
}
.list li,
.entry {
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.list a {
  color: var(--ink);
  text-decoration: none;
  display: block;
}
.list a:hover {
  text-decoration: underline;
}
.lesson-group > h2 {
  margin: 28px 0 8px;
  font-size: 20px;
}
small,
.meta {
  color: var(--muted);
}
.meta {
  font-size: 14px;
}
.body {
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.part {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.cols > article {
  min-width: 0;
}
.cols > article + article {
  padding-left: 22px;
  border-left: 1px solid var(--line);
}
input,
textarea,
select {
  font: inherit;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 9px;
  max-width: 100%;
}
textarea {
  width: 100%;
}
label {
  display: block;
}
.options label {
  padding: 6px 2px;
}
.options input {
  margin-right: 7px;
}
details {
  margin: 14px 0;
}
summary {
  cursor: pointer;
  color: var(--accent);
}
.sources {
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.sources div {
  margin: 5px 0;
}
blockquote {
  border-left: 3px solid var(--accent);
  margin: 8px 0 15px;
  padding-left: 12px;
  white-space: pre-wrap;
}
.clock {
  font-variant-numeric: tabular-nums;
  position: sticky;
  top: 0;
  background: var(--paper);
  padding: 6px 0;
  font-weight: 700;
}
.msg {
  padding: 10px;
  background: var(--soft);
}
#selection {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 20px #1232;
}
dialog {
  width: min(450px, 90%);
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
}
dialog::backdrop {
  background: #1237;
}
#notice {
  position: fixed;
  bottom: 10px;
  right: 16px;
  max-width: 85%;
  background: var(--ink);
  color: var(--paper);
  padding: 5px 12px;
  border-radius: 5px;
}
#notice:empty {
  display: none;
}
.actions {
  margin: 13px 0;
}
.empty {
  padding: 20px 0;
  color: var(--muted);
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
mark {
  color: #2b2415;
  background: #f1d688;
}
.mark-ids {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mark-reply { margin-block: 6px; max-width: 64ch; }
.mark-reply p { white-space: pre-wrap; overflow-wrap: anywhere; }
.mark-reply blockquote { margin: 8px 0; color: var(--muted); }
.recordings { margin-block: 18px; }
.recordings audio { width: min(100%, 480px); }
.diagram-guide { margin-block: 14px; }
.diagram-guide figure { margin: 10px 0; }
.diagram-guide img { display: block; width: 100%; height: auto; }
.diagram-guide figcaption { color: var(--muted); font-size: 0.92em; }
.diagram-guide li { margin-block: 6px; }
.answer-diagram { margin: 16px 0; }
.answer-diagram img { display: block; max-width: 100%; max-height: 780px; width: auto; height: auto; margin-inline: auto; }
.part[data-part] { scroll-margin-top: 68px; }
.return-target { outline: 2px solid var(--accent); outline-offset: 3px; }
.recordings li { padding-block: 10px; }
.recordings li p { margin-block: 4px; color: var(--muted); }
.recording-pages { display: grid; gap: 5px; padding-block: 6px; }
.table-scroll { max-width: 100%; overflow-x: auto; }
.cols > article { min-width: 0; }
.code-guide { border-top: 1px solid var(--line); padding-block: 10px; margin-block: 8px; }
.code-guide h4 { margin: 22px 0 8px; }
.code-guide pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: 10px 12px;
  border-left: 2px solid var(--line);
  font-size: 0.92em;
}
.code-guide pre .selectable { white-space: pre-wrap; }
.guide-lines { padding-inline-start: 30px; }
.guide-lines pre, .guide-lines p { margin-block: 4px; }
.guide-lines li { margin-block: 12px; }
.code-guide dd { margin-inline-start: 16px; }
.table-scroll table { width: 100%; border-collapse: collapse; }
.lesson-reader > .table-scroll { margin-bottom: 0.7em; }
.lesson-reader > .table-scroll table { min-width: 600px; }
.lesson-reader > .table-scroll .selectable { overflow-wrap: normal; }
.worked .selectable, .answer-template .selectable { white-space: pre-wrap; }
.answer-template dt { font-weight: 600; }
.answer-template dd { margin: 0 0 .6em; }
.answer-tree { overflow-x: auto; padding: .75rem; }
.answer-tree .selectable { white-space: pre; }
.worked li { margin-block: 6px; }
.table-scroll th, .table-scroll td {
  text-align: start;
  vertical-align: top;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
button[disabled] {
  opacity: 0.55;
  cursor: default;
}
.selectable {
  white-space: pre-line;
  overflow-wrap: anywhere;
}
@media (max-width: 700px) {
  .cols {
    grid-template-columns: 1fr;
  }
  .cols > article + article {
    border-left: none;
    border-top: 1px dotted var(--line);
    padding: 10px 0;
  }
  .pair {
    gap: 8px;
  }
  .course {
    padding: 12px;
  }
  .course b {
    font-size: 26px;
  }
  .hero h1 {
    font-size: 40px;
  }
  main {
    padding-top: 20px;
  }
  header {
    padding: 10px 14px;
  }
  header nav {
    gap: 4px;
  }
  button {
    padding: 5px 9px;
  }
}

.reading-return { position: sticky; top: 8px; z-index: 4; width: fit-content; margin-bottom: 14px; }
.reading-return button { background: var(--paper); }
.topic-links { margin-block: 14px 22px; display: grid; gap: 6px; }
.word-tools { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; margin-block: 16px 24px; }
.word-tools label { display: grid; gap: 4px; }
.word-tools select { min-height: 40px; }
.word-type { display: flex; align-items: center; gap: 12px; margin-block: 12px; }
.word-type select { width: auto; }
.vocabulary-group { margin-block: 24px; }
.vocabulary-group td:first-child { width: 30%; }
.vocabulary-group td small { display: block; margin-top: 8px; color: var(--muted); }
.vocabulary-group td p:first-child { margin-top: 0; }
.vocabulary-tabs { margin-block: 24px; }
.vocabulary-tabs a { color: var(--ink); text-decoration: none; padding: 8px 12px; border-radius: 6px; }
.vocabulary-tabs a:hover { text-decoration: underline; }
.personal-vocabulary table { table-layout: fixed; }
.personal-vocabulary th:first-child { width: 30%; }
.personal-vocabulary td { padding-block: 20px; overflow-wrap: anywhere; }
.personal-vocabulary td > p:first-child { margin-top: 0; }
.personal-vocabulary .word-type { flex-wrap: wrap; gap: 4px; font-size: 14px; }
.personal-vocabulary .word-type select { max-width: 100%; }
.word-quote { font-weight: 600; }
.word-label, .word-origin { color: var(--muted); font-size: 14px; }
.word-label { margin: 16px 0 4px; }
.source-sentence { margin-top: 0; }
.word-actions { flex-wrap: wrap; gap: 8px; font-size: 14px; }
.word-actions button { max-width: 100%; overflow-wrap: anywhere; text-align: start; }
.scan-list { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 16px; }
#topic-graph[data-mode="all"] { display: block; }
.map-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.map-controls label { display: flex; gap: 8px; align-items: center; }
.map-controls input { width: 160px; padding: 0; }
.graph-viewport { width: 100%; height: 580px; overflow: auto; border: 1px solid var(--line); padding: 10px; }
.graph-size { position: relative; }
.graph-stage { position: relative; display: flex; gap: 52px; width: max-content; padding: 16px; transform-origin: top left; }
.graph-column { display: flex; flex-direction: column; justify-content: center; gap: 24px; width: 260px; flex: 0 0 260px; }
.graph-node { border: 1px solid var(--line); padding: 14px; border-radius: 6px; background: var(--paper); position: relative; z-index: 1; font-size: 16px; }
#topic-graph .graph-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#topic-graph .graph-stage path { stroke: var(--muted); fill: none; stroke-width: 1.2; }
@media (max-width: 640px) {
  .graph-viewport { height: 440px; }
  .word-tools { align-items: stretch; }
  .word-tools label { flex: 1; }
}

.paper-note-layout {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: 3rem;
  margin-top: 2rem;
  align-items: start;
}
.paper-note-index {
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.paper-note-index button {
  text-align: left;
}
main:has(.reading-return) .paper-note-index {
  top: 4.5rem;
}
.paper-note-body {
  max-width: 75ch;
  min-width: 0;
}
.note-group {
  scroll-margin-top: 1.5rem;
  margin-bottom: 3rem;
}
.paper-note {
  border-bottom: 1px solid var(--line);
  padding: 0 0 2rem;
  margin-bottom: 2rem;
  overflow-wrap: anywhere;
}
.note-topics {
  display: flex;
  flex-direction: column;
  align-items: start;
  margin-top: 1rem;
}
@media (max-width: 760px) {
  .paper-note-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .paper-note-index {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.paper-downloads { margin-block: 1rem; }
.export-language { display: flex; align-items: center; gap: .5rem; margin-bottom: .65rem; }
.export-language input { width: auto; }
.question-translation { margin-block: .75rem 1rem; }
.question-translation > div { padding-block: .25rem; }
