:root {
  --bg: #f6f3ed;
  --card: #fffefa;
  --ink: #292521;
  --muted: #786e65;
  --line: #e5dfd7;
  --accent: #302924;
  --soft: #f2eee7;
  --peach: #f5e5dc;
  --rose: #9c6154;
  --gold: #a48059;
  font: 15px -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 0; scroll-padding-top: 88px; }
body { min-width: 0; margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .48; cursor: not-allowed; }
a { color: inherit; text-decoration: none; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4, p { overflow-wrap: anywhere; }
button, select { max-width: 100%; }
input, textarea, select {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffefa;
  padding: 10px 12px;
  line-height: 1.6;
}
input, textarea { width: 100%; }
input[type='checkbox'], input[type='radio'] { width: auto; accent-color: var(--accent); }
textarea { display: block; resize: vertical; }
textarea::placeholder, input::placeholder { color: #81756c; }
:focus-visible { outline: 3px solid #bc8c76; outline-offset: 3px; }
::selection { background: #efcfc0; color: #30251f; }
[hidden] { display: none !important; }
dialog:not([open]) { display: none; }

/* A quiet, compact header keeps the manuscript in the foreground. */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  min-height: 84px;
  padding: 15px max(32px, calc((100vw - 1108px) / 2));
  border-bottom: 1px solid var(--line);
  background: #fbf9f4;
}
.brand { display: inline-flex; align-items: center; gap: 11px; justify-self: start; }
.brand-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 39px;
  width: 39px;
  height: 41px;
  border-radius: 11px;
  color: #fff9ed;
  background: var(--ink);
  font-family: 'Songti SC', 'STSong', Georgia, serif;
  font-size: 23px;
  line-height: 1;
}
.brand-icon sup { align-self: flex-start; margin: 7px 0 0 1px; font: 11px Georgia, serif; }
.brand-name { font-size: 18px; font-weight: 650; letter-spacing: .5px; line-height: 1; }
.brand-name small { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; font-weight: 400; letter-spacing: 1.4px; }
.topbar nav { display: flex; gap: 8px; align-items: center; }
.nav { min-height: 40px; padding: 9px 20px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.nav:hover { background: var(--soft); color: var(--ink); }
.nav.active { color: var(--ink); font-weight: 600; background: #eee8df; }
.header-tools { display: flex; justify-self: end; align-items: center; gap: 14px; min-width: 0; }
.connection { color: var(--muted); font-size: 11px; line-height: 1.5; }
.connection.error { color: #a04937; }
.more-menu { position: relative; }
.more-menu > summary {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  list-style: none;
  cursor: pointer;
}
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu[open] > summary, .more-menu > summary:hover { background: #eee7dd; border-color: var(--line); }
.menu-items {
  position: absolute;
  z-index: 12;
  right: 0;
  top: calc(100% + 9px);
  display: grid;
  gap: 3px;
  width: 184px;
  max-width: calc(100vw - 32px);
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 12px 35px #46372b16;
}
.menu-items button { padding: 10px 12px; border-radius: 6px; text-align: left; font-size: 13px; line-height: 1.5; }
.menu-items button:hover { background: var(--soft); }

main { width: min(1180px, 100%); margin: 0 auto; padding: 27px 36px 0; }
.quick-guide { display: flex; align-items: center; flex-wrap: wrap; gap: 9px 23px; margin: 0 0 21px; padding-bottom: 16px; border-bottom: 1px solid var(--line); color: #81705f; font-size: 10px; line-height: 1.8; }
.quick-guide span { white-space: nowrap; }
.quick-guide small { margin-left: auto; color: #7c6b58; font-size: 9px; }
.view, .paper-layout > *, .paper-heading > *, .library-heading > * { min-width: 0; }
.eyebrow { color: #8a6959; font-size: 10px; font-weight: 550; letter-spacing: 1.6px; line-height: 1.6; }
h1 { margin: 11px 0 13px; font-size: 28px; font-weight: 620; line-height: 1.55; letter-spacing: -.3px; }
.paper-tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 23px; }
.paper-tabs button { min-height: 35px; padding: 7px 15px; border: 1px solid transparent; border-radius: 20px; color: #746a60; font-size: 12px; line-height: 1.5; }
.paper-tabs button:hover { color: var(--ink); background: #eee7dd; }
.paper-tabs button.active { border-color: #dfd6cb; color: var(--ink); background: #fffaf2; font-weight: 550; }
.paper-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 360px); gap: 28px; align-items: start; }
.paper-surface {
  min-width: 0;
  padding: 39px 40px 0;
  border: 1px solid #e4ded5;
  border-radius: 15px;
  background: var(--card);
  box-shadow: 0 5px 20px #5b423304;
}
.paper-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.paper-heading h1 { font-family: 'Noto Serif SC', 'Songti SC', 'STSong', Georgia, serif; font-size: 28px; font-weight: 600; }
.paper-meta { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.8; }
.journal-chip { flex-shrink: 0; max-width: 115px; margin-top: 4px; padding: 5px 9px; border: 1px solid #e4d5c9; border-radius: 5px; color: #7d5e4a; background: #faf2e9; font-size: 10px; line-height: 1.7; overflow-wrap: anywhere; }
.paper-toolbar { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 12px; min-height: 45px; margin: 15px 0 21px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.paper-toolbar label { min-width: 0; margin-right: auto; max-width: 75%; }
.paper-toolbar select { width: 100%; max-width: 330px; padding: 5px 27px 5px 9px; border-color: #e7e1d8; background: #faf7f1; color: #72665b; font-size: 11px; text-overflow: ellipsis; }
.paper-toolbar .text-button { font-size: 11px; }
.language-picker { display: inline-flex; flex: 0 0 auto; align-items: center; gap: 2px; padding: 3px; border: 1px solid #e6dacb; border-radius: 7px; background: #f5efe6; }
.language-picker button { min-height: 28px; padding: 4px 9px; border-radius: 4px; color: #85715f; font-size: 10px; line-height: 1.5; }
.language-picker button.active { color: #5a4030; background: #fffdf7; box-shadow: 0 1px 4px #5d3f2910; }
.paper-toolbar .language-picker { margin-right: auto; }
.paper-toolbar .language-picker + label { max-width: 42%; margin-right: 0; }
.paper-preview {
  min-width: 0;
  min-height: min(420px, 55svh);
  max-height: 70vh;
  max-height: 70svh;
  padding: 0 10px 20px 0;
  overflow: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #d5cabf transparent;
  font-size: 16px;
  line-height: 1.9;
  color: #39332d;
}
.paper-preview > :first-child { margin-top: 0; }
.paper-preview iframe { display: block; width: 100%; height: 65vh; border: 0; border-radius: 4px; }
.paper-preview iframe.paper-pdf { height: 65vh; height: 65svh; background: #f4f0e8; }
.paper-preview .pdf-fallback { display: block; width: fit-content; max-width: 100%; margin: 11px 0 0; font-size: 11px; text-align: left; }
.paper-preview .empty { min-height: 260px; display: flex; flex-direction: column; justify-content: center; }
.paper-footnote { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 18px; padding: 18px 0 20px; border-top: 1px solid var(--line); color: #827568; font-size: 10px; line-height: 1.7; }
.paper-footnote span:last-child { font-size: 8px; letter-spacing: 1.6px; }

/* Discussion is a small notebook next to the page. */
.discussion-column { min-width: 0; }
.companion-note { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 9px; min-height: 140px; margin-bottom: 27px; padding: 12px 0 14px 3px; border-bottom: 1px solid #e2d8ce; }
.companion-note > div { min-width: 0; }
.companion-note .eyebrow { font-size: 8px; letter-spacing: 1.1px; }
.companion-note h2 { margin: 11px 0 8px; font-family: 'Noto Serif SC', 'Songti SC', 'STSong', Georgia, serif; font-size: 23px; font-weight: 600; line-height: 1.4; letter-spacing: -.4px; }
.companion-note p { margin: 0; color: #827063; font-size: 11px; line-height: 1.9; }
.companion-note img { flex: 0 0 118px; width: 118px; height: 118px; object-fit: contain; }
.discussion-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.discussion-heading h2 { margin: 0; font-size: 16px; font-weight: 600; }
.round-number { color: #887566; font-size: 10px; letter-spacing: 1px; }
.guest-note { margin: 0 0 13px; padding: 12px 14px; border: 1px solid #e5d6c9; border-radius: 9px; background: #faf0e7; color: #77604f; font-size: 12px; line-height: 1.9; }
.guest-note .text-button { display: block; margin-top: 7px; }
.current-todos { margin: 0 0 16px; padding: 13px 14px 4px; border: 1px solid #e7d9c7; border-radius: 10px; background: #f9efe2; }
.todo-heading { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 3px; }
.todo-heading h3 { margin: 0; color: #785537; font-size: 11px; font-weight: 600; line-height: 1.7; }
.todo-heading > span { color: #79634e; font-size: 9px; line-height: 1.7; }
#todo-list { min-width: 0; }
.todo-item { display: flex; align-items: center; justify-content: space-between; gap: 13px; width: 100%; min-height: 43px; padding: 10px 0; border-top: 1px solid #e9ddcd; text-align: left; }
.todo-item:first-child { border-top-color: transparent; }
.todo-item > span:first-child { display: -webkit-box; min-width: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: #6e543e; font-size: 11px; line-height: 1.8; overflow-wrap: anywhere; }
.todo-item > span:last-child { flex-shrink: 0; color: #9a6a45; font-size: 10px; white-space: nowrap; }
.todo-item:hover > span:first-child { color: #34281e; }
.todo-item:hover > span:last-child { color: #6e4021; }
.composer { padding: 18px; border: 1px solid #e2d4c8; border-radius: 13px; background: #fffaf3; }
.composer-header { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.avatar { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; border-radius: 10px; background: #ecd9ce; color: #765444; font-size: 11px; font-weight: 550; }
.avatar.owner { background: #e9e0ce; color: #79613d; }
.avatar.agent { color: #625c53; background: #e8e3d8; }
.composer-header strong { color: #68594c; font-size: 12px; font-weight: 550; }
.composer-header small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.composer textarea { width: 100%; min-height: 106px; padding: 11px 12px; border-color: #e9e1d7; border-radius: 8px; background: #fffefa; color: #40362e; font-size: 13px; line-height: 1.9; }
.composer-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-top: 13px; }
.composer-footer select { max-width: 140px; padding: 4px 0; border: 0; background: transparent; font-size: 11px; }
#draft-status { color: #817366; font-size: 10px; }
.composer-footer .button { margin-left: auto; min-height: 35px; padding: 8px 12px; font-size: 11px; }
.reply-context { margin-bottom: 12px; padding: 10px 11px; border-left: 2px solid #c18b75; border-radius: 0 5px 5px 0; background: #f2e5da; color: #77604f; font-size: 12px; line-height: 1.8; overflow-wrap: anywhere; }
.reply-context button { float: right; margin-left: 5px; font-size: 17px; }
#return-current { width: 100%; margin-top: 12px; }
.feed-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 13px; }
.feed-filters { display: flex; flex-wrap: wrap; gap: 20px; }
.feed-filters button { padding: 5px 0 8px; border-bottom: 2px solid transparent; color: #827365; font-size: 12px; }
.feed-filters button.active { border-color: #a8755e; color: var(--ink); font-weight: 550; }
#message-count { color: #817366; font-size: 10px; }
.discussion-feed { min-width: 0; }
.message-card { min-width: 0; margin: 0 0 13px; padding: 17px; border: 1px solid #e4ddd3; border-radius: 11px; background: #fffdf8; overflow-wrap: anywhere; }
.message-top { display: flex; align-items: center; gap: 9px; min-width: 0; }
.message-top > div { min-width: 0; }
.message-author { color: #534639; font-size: 12px; font-weight: 550; }
.message-date { margin-top: 5px; color: #83796e; font-size: 10px; line-height: 1.5; }
.message-top .badge { margin-left: auto; }
.badge, .soft-tag { display: inline-block; padding: 3px 6px; border-radius: 5px; background: #f0e8db; color: #806345; font-size: 10px; font-weight: 400; line-height: 1.6; }
.badge { flex-shrink: 0; }
.badge.done { background: #e9ece1; color: #606c4e; }
.badge.adopted { background: #e6ebe3; color: #58694f; }
.badge.needs-owner { background: #f5e4d6; color: #916047; }
.message-text { margin: 13px 0; color: #50483f; font-size: 13px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-text a, .message-quote a { text-decoration: underline; text-underline-offset: 3px; }
.message-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 14px; }
.message-actions button, .message-actions select { padding: 4px 0; border: 0; color: #836653; background: transparent; font-size: 10px; line-height: 1.6; }
.message-actions select { margin-left: auto; max-width: 135px; }
.message-actions button:hover { color: #492e20; text-decoration: underline; text-underline-offset: 3px; }
.message-quote { margin: 12px 0; padding: 9px 11px; border-left: 2px solid #cdb5a3; border-radius: 0 5px 5px 0; background: #f4eee4; color: #786452; font-size: 11px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-card { margin: 14px 0 0 5px; padding: 13px 12px; border-left: 2px solid #d5bca9; border-radius: 0 8px 8px 0; background: #f5f0e8; overflow-wrap: anywhere; }
.reply-card .avatar { flex-basis: 25px; width: 25px; height: 25px; border-radius: 8px; font-size: 9px; }
.reply-card .message-text { margin: 10px 0; font-size: 12px; }
.reply-card .message-author { font-size: 11px; }
.reply-card .message-actions { gap: 6px 11px; }
.message-question { margin: 12px 0; padding: 11px 12px; border: 1px solid #e4d3c2; border-radius: 8px; color: #7a5c45; background: #faf0e3; font-size: 12px; line-height: 1.85; overflow-wrap: anywhere; }
.message-question summary { cursor: pointer; font-weight: 550; }
.message-question[open] > summary { margin-bottom: 9px; }
.message-question p { margin: 9px 0; white-space: pre-wrap; }
.message-question button { color: #80583f; font-size: 11px; }
.empty { padding: 27px 18px; border: 1px dashed #dfd4c7; border-radius: 10px; background: #faf6ef; text-align: center; color: #89715e; }
.empty > span { color: #a98467; font-size: 22px; }
.empty h3 { margin: 10px 0; color: #78624f; font-size: 14px; font-weight: 500; }
.empty p { margin: 0; color: #89715e; font-size: 12px; line-height: 1.9; }
#more-messages { display: block; margin: 18px auto; }
.carryover-card { margin: 14px 0; padding: 14px; border: 1px dashed #ddc9b5; border-radius: 9px; background: #f8eddf; }
.carryover-card summary { color: #806246; font-size: 12px; line-height: 1.8; cursor: pointer; }
.carryover-card p { margin: 10px 0; color: #7c6754; font-size: 12px; line-height: 1.9; white-space: pre-wrap; }
.round-info { margin-top: 27px; padding-top: 15px; border-top: 1px solid #ded4c7; }
.round-info > summary { color: #7e6b59; font-size: 11px; cursor: pointer; line-height: 1.7; }
.round-info[open] > summary { margin-bottom: 17px; }
.round-info h3 { margin: 12px 0 7px; font-size: 13px; line-height: 1.6; font-weight: 550; }
.round-info p { color: #7b6c5f; font-size: 12px; line-height: 1.9; white-space: pre-wrap; }
.round-info small { color: #837569; font-size: 10px; line-height: 1.8; }
#historical-conclusion { padding-top: 13px; border-top: 1px solid var(--line); }
.supplemental-upload { margin-top: 14px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 10px 15px; border: 1px solid #dcd2c5; border-radius: 8px; color: #6f5744; background: #fffaf2; font-size: 12px; line-height: 1.5; }
.button:hover { border-color: #bfa18b; background: #f4e9dc; }
.button.primary { color: #fff8eb; border-color: var(--accent); background: var(--accent); }
.button.primary:hover { border-color: #554134; background: #554134; }
.button.secondary { color: #77563f; border-color: #e2cbb8; background: #f5e9dc; }
.button.secondary:hover { background: #eddac7; }
.button.quiet { color: #7b6b5b; border-color: var(--line); background: #faf6ef; }
.button.danger { color: #fff9f1; border-color: #a55743; background: #a55743; }
.button.danger:hover { background: #8b4132; }
.text-button { padding: 5px 0; color: #8a6248; font-size: 12px; line-height: 1.7; }
.text-button:hover { color: #4d3120; text-decoration: underline; text-underline-offset: 4px; }

/* Manuscript formatting is shared by inline and expanded reading. */
.reader-paragraph { position: relative; min-width: 0; margin: 0; padding: 0; }
.reader-paragraph p { margin: 0 0 1.2em; white-space: pre-wrap; overflow-wrap: anywhere; }
.reader-paragraph h1, .reader-paragraph h2 { margin: 1.65em 0 .8em; color: #332b24; font-family: 'Noto Serif SC', 'Songti SC', 'STSong', Georgia, serif; font-size: 23px; font-weight: 600; line-height: 1.65; }
.reader-paragraph h3 { margin: 1.6em 0 .7em; color: #45382c; font-size: 18px; font-weight: 600; line-height: 1.65; }
.reader-paragraph h4 { margin: 1.4em 0 .65em; color: #544234; font-size: 16px; font-weight: 600; line-height: 1.7; }
.reader-paragraph:first-child > :first-child { margin-top: 0; }
.reader-paragraph ul, .reader-paragraph ol { margin: .8em 0 1.3em; padding-left: 1.5em; }
.reader-paragraph li { margin-bottom: .65em; }
.reader-paragraph a { color: #8b5338; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.reader-paragraph blockquote { margin: 1.3em 0; padding: 12px 18px; border-left: 3px solid #cfa88e; background: #f8f1e8; color: #796552; }
.reader-paragraph code { padding: 2px 4px; border-radius: 3px; background: #f0e7db; font-size: .87em; overflow-wrap: anywhere; }
.reader-paragraph pre { max-width: 100%; padding: 15px; border-radius: 7px; background: #f5f0e7; overflow: auto; font-size: 12px; line-height: 1.75; }
.reader-paragraph > button { display: none; }
#reader-content.annotating .reader-paragraph { padding-right: 39px; }
#reader-content.annotating .reader-paragraph > button { position: absolute; top: 2px; right: 0; display: inline-flex; align-items: center; justify-content: center; width: 28px; min-height: 28px; padding: 0; border: 1px solid #e2c6b1; border-radius: 7px; color: #99664a; background: #f7eadb; font-size: 16px; }
#reader-content.annotating .reader-paragraph > button:hover { background: #efd7bf; }
.reader-table { width: 100%; min-width: 0; max-width: 100%; margin: 22px 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
.reader-table table { width: 100%; min-width: 560px; border-collapse: collapse; color: #544335; font-size: 12px; }
.reader-table th, .reader-table td { padding: 11px 13px; border: 1px solid #e0d6c9; text-align: left; vertical-align: top; line-height: 1.8; }
.reader-table th { color: #66503c; background: #f1e8db; font-weight: 550; }
.reader-table tbody tr:nth-child(even) { background: #fcf8f1; }

.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 13px 0 27px; }
.library-heading h1 { margin-bottom: 0; font-family: 'Noto Serif SC', 'Songti SC', 'STSong', Georgia, serif; }
.document-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.document-card { position: relative; min-width: 0; padding: 25px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.doc-symbol { display: grid; place-items: center; width: 39px; height: 46px; margin-bottom: 18px; border: 1px solid #e9dbca; border-radius: 6px; color: #977253; background: #f6ebdb; font: 12px Georgia, serif; }
.document-card h3 { margin: 14px 0 10px; font-size: 16px; font-weight: 550; line-height: 1.7; }
.document-card p { margin: 0 0 14px; color: #867565; font-size: 11px; line-height: 1.9; white-space: pre-wrap; overflow-wrap: anywhere; }
.document-card .button { margin-top: 7px; }
.delete-doc { position: absolute; top: 21px; right: 17px; padding: 5px; color: #93745f; font-size: 10px; }
.timeline-card { margin: 15px 0; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; }
.timeline-card h3 { font-size: 16px; font-weight: 550; line-height: 1.7; }
.timeline-card p { color: #796858; font-size: 13px; line-height: 1.9; white-space: pre-wrap; }
.footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; margin-top: 43px; padding: 23px 0 25px; border-top: 1px solid var(--line); color: #796b5f; font-size: 10px; line-height: 1.8; }
.footer > span:first-child { color: #6d5846; font-weight: 600; }
.footer i { margin-left: 11px; color: #796b5f; font-size: 10px; font-weight: 400; font-style: normal; }

/* Dialogs keep the normal closed state and never become page sections. */
dialog { width: min(560px, calc(100% - 32px)); max-width: calc(100% - 32px); max-height: calc(100vh - 40px); max-height: calc(100svh - 40px); margin: auto; padding: 29px; overflow: auto; border: 1px solid #ded0be; border-radius: 16px; color: var(--ink); background: #fffaf2; box-shadow: 0 24px 90px #31251d30; }
dialog::backdrop { background: #30251e70; backdrop-filter: blur(5px); }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 21px; }
.dialog-header > div { min-width: 0; }
.dialog-header h2 { margin: 0; font-size: 21px; font-weight: 550; line-height: 1.55; }
.close-dialog { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; margin: -4px -5px 0 0; border-radius: 50%; color: #6e5744; font-size: 25px; line-height: 1; }
.close-dialog:hover { background: #efdfce; }
dialog label { display: block; margin: 18px 0 8px; color: #75614f; font-size: 12px; line-height: 1.7; }
dialog form > .button { margin-top: 22px; }
dialog textarea { font-size: 14px; line-height: 1.85; }
.field-hint { color: #887563; font-size: 12px; line-height: 1.9; }
.form-error { color: #a54832; font-size: 12px; line-height: 1.8; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-row > div { min-width: 0; }
.form-row select { width: 100%; }
.access-dialog { width: min(440px, calc(100% - 32px)); }
.access-dialog .button { width: 100%; }
#document-file { padding: 10px; font-size: 12px; }
.instructions-text { color: #6d5946; font-size: 14px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: anywhere; }
.help-list { margin: 0; padding-left: 22px; font-size: 14px; line-height: 2; }
.help-list li { margin-bottom: 13px; }
.history-dialog { width: min(650px, calc(100% - 32px)); }
.reader-dialog { width: min(1020px, calc(100% - 40px)); padding: 28px 32px; background: #faf6ee; }
.reader-dialog .dialog-header { margin-bottom: 17px; }
.reader-dialog h2 { margin-top: 7px; font-size: 20px; line-height: 1.6; }
.reader-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 21px; }
.reader-actions > span { margin-left: auto; }
.reader-actions .button { min-height: 36px; padding: 8px 12px; font-size: 11px; }
.reader-actions .annotation-switch { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: #796858; font-size: 11px; white-space: nowrap; }
.annotation-switch input { margin: 0; }
#reader-content { min-height: 240px; max-height: 65vh; max-height: 65svh; padding: 31px 36px; overflow: auto; overscroll-behavior: contain; border: 1px solid #e7ddcd; border-radius: 10px; color: #39332d; background: #fffefa; font-size: 16px; line-height: 1.9; scrollbar-width: thin; scrollbar-color: #cfbdaa transparent; }
#reader-content iframe { display: block; width: 100%; height: 60vh; border: 0; }

.welcome-dialog { position: fixed; display: none; grid-template-columns: minmax(0, 1fr) 340px; align-items: center; gap: 20px; width: min(790px, calc(100% - 32px)); padding: 46px 35px 41px 47px; overflow: auto; border-color: #ecd7c6; background: linear-gradient(120deg, #fffaf0 14%, #faeadf 100%); }
.welcome-dialog[open] { display: grid; }
.welcome-close { position: absolute; z-index: 1; top: 13px; right: 13px; display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid #e2cbbb; border-radius: 50%; color: #634a38; background: #fff9ef; font-size: 27px; line-height: 1; }
.welcome-close:hover { border-color: #c2a08a; background: #f1ddcb; }
.welcome-copy { min-width: 0; }
.welcome-logo { display: block; width: fit-content; margin-bottom: 29px; color: #302720; font: 40px/1.05 'Songti SC', 'STSong', Georgia, serif; }
.welcome-logo sup { font: 19px Georgia, serif; vertical-align: top; margin-left: 1px; }
.welcome-copy > .eyebrow { display: block; color: #806149; font-size: 8px; letter-spacing: 1.5px; }
.welcome-copy h2 { margin: 14px 0 17px; color: #483323; font-family: 'Noto Serif SC', 'Songti SC', 'STSong', Georgia, serif; font-size: 38px; font-weight: 600; letter-spacing: -1px; line-height: 1.5; }
.welcome-copy p { margin: 0 0 23px; color: #80614c; font-size: 12px; line-height: 2; }
.welcome-copy .button { min-height: 43px; padding-inline: 22px; }
.welcome-copy > small { display: block; margin-top: 11px; color: #826b57; font-size: 10px; }
.welcome-dialog > img { justify-self: center; width: 340px; height: 340px; object-fit: contain; }
.toast { position: fixed; z-index: 100; bottom: max(23px, env(safe-area-inset-bottom)); left: 50%; width: max-content; max-width: min(520px, calc(100% - 32px)); padding: 13px 19px; transform: translateX(-50%); border: 1px solid #675141; border-radius: 11px; color: #fff7e9; background: #3d3026; box-shadow: 0 8px 30px #34251c25; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip:focus { position: fixed; z-index: 110; top: 10px; left: 10px; padding: 12px; border-radius: 6px; background: #fff; color: var(--ink); }
noscript { display: block; margin: 20px; padding: 15px; color: #874c35; background: #f4e4d0; }

@media (max-width: 1100px) {
  .topbar { padding-inline: 28px; }
  main { padding-inline: 28px; }
  .paper-layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 23px; }
  .paper-surface { padding: 30px 29px 0; }
  .paper-heading h1 { font-size: 25px; }
  .companion-note h2 { font-size: 21px; }
  .companion-note .eyebrow { letter-spacing: .7px; font-size: 7px; }
  .companion-note img { flex-basis: 118px; }
}

@media (max-width: 940px) {
  .paper-layout { grid-template-columns: minmax(0, 1fr); gap: 29px; }
  .paper-surface { padding: 34px 40px 0; }
  .discussion-column { width: 100%; }
  .companion-note { min-height: 138px; margin-bottom: 22px; padding: 8px 18px 15px; border: 1px solid #e4d5c8; border-radius: 12px; background: #f4e8dd; }
  .companion-note h2 { font-size: 25px; }
  .companion-note .eyebrow { font-size: 8px; letter-spacing: 1.3px; }
  .companion-note p { font-size: 12px; }
  .document-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .composer textarea { min-height: 100px; }
  .paper-preview { min-height: min(340px, 55svh); }
  .message-card { padding: 20px; }
}

@media (max-width: 680px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: 12px; min-height: 74px; padding: 13px 17px; }
  .brand { gap: 7px; }
  .brand-icon { flex-basis: 33px; width: 33px; height: 35px; border-radius: 9px; font-size: 20px; }
  .brand-icon sup { margin-top: 5px; font-size: 10px; }
  .brand-name { font-size: 15px; }
  .brand-name small { display: none; }
  .topbar nav { justify-self: center; gap: 3px; }
  .nav { min-height: 36px; padding: 8px 12px; font-size: 13px; white-space: nowrap; }
  .header-tools { gap: 6px; }
  .connection { max-width: 52px; font-size: 9px; }
  .more-menu > summary { width: 30px; height: 33px; font-size: 21px; }
  main { padding: 20px 17px 0; }
  .quick-guide { gap: 5px 14px; margin-bottom: 15px; padding-bottom: 11px; font-size: 9px; }
  .quick-guide small { width: 100%; margin-left: 0; font-size: 8px; }
  .paper-tabs { gap: 4px; margin-bottom: 17px; }
  .paper-tabs button { min-height: 33px; padding: 7px 12px; font-size: 11px; }
  .paper-layout { gap: 25px; }
  .paper-surface { padding: 25px 23px 0; border-radius: 12px; }
  .paper-heading { flex-wrap: wrap; gap: 4px; }
  .paper-heading h1 { font-size: 25px; line-height: 1.6; }
  .paper-heading .eyebrow { font-size: 9px; }
  .paper-meta { font-size: 11px; }
  .journal-chip { margin-top: 7px; max-width: 100%; }
  .paper-toolbar { min-height: 40px; gap: 10px; margin: 12px 0 20px; padding-bottom: 12px; }
  .paper-toolbar label { max-width: 70%; }
  .paper-toolbar select { font-size: 11px; }
  .paper-toolbar .language-picker + label { max-width: calc(100% - 116px); }
  .paper-toolbar .language-picker { margin-right: auto; }
  .language-picker button { min-height: 27px; padding-inline: 8px; }
  .paper-preview { min-height: min(300px, 55svh); max-height: 70vh; max-height: 70svh; padding: 0 5px 14px 0; font-size: 15px; line-height: 1.95; }
  .paper-footnote { margin-top: 15px; padding: 15px 0 17px; font-size: 9px; gap: 8px; }
  .paper-footnote span:last-child { font-size: 7px; letter-spacing: 1.1px; }
  .companion-note { min-height: 137px; gap: 3px; padding: 11px 14px; }
  .companion-note h2 { font-size: 23px; }
  .companion-note p { font-size: 11px; }
  .companion-note .eyebrow { font-size: 7px; letter-spacing: .8px; }
  .companion-note img { flex-basis: 118px; width: 118px; height: 118px; }
  .discussion-heading h2 { font-size: 16px; }
  .composer { padding: 17px; }
  .composer textarea { min-height: 115px; font-size: 16px; }
  .composer-footer .button { min-height: 38px; font-size: 12px; }
  #draft-status { font-size: 9px; }
  .message-card { padding: 17px; }
  .message-text { font-size: 14px; }
  .message-actions button, .message-actions select { font-size: 11px; }
  .reply-card { margin-left: 3px; padding: 12px; }
  .reply-card .message-text { font-size: 13px; }
  .badge { max-width: 78px; white-space: normal; text-align: center; font-size: 9px; }
  .reader-paragraph h1, .reader-paragraph h2 { font-size: 21px; }
  .reader-paragraph h3 { font-size: 17px; }
  .reader-paragraph h4 { font-size: 15px; }
  .reader-table table { font-size: 12px; }
  .library-heading { align-items: flex-start; gap: 15px; flex-wrap: wrap; margin: 10px 0 23px; }
  .library-heading h1 { font-size: 25px; }
  .library-heading .button { min-height: 35px; padding: 8px 12px; font-size: 11px; }
  .document-grid { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .document-card { padding: 22px; }
  .footer { margin-top: 30px; padding-top: 20px; font-size: 9px; }
  .footer i { margin-left: 8px; font-size: 9px; }
  dialog { width: calc(100% - 26px); max-width: calc(100% - 26px); max-height: calc(100vh - 28px); max-height: calc(100svh - 28px); padding: 24px 21px; border-radius: 13px; }
  dialog input, dialog select, dialog textarea { font-size: 16px; }
  .dialog-header h2 { font-size: 20px; }
  .field-hint { font-size: 11px; }
  .form-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .reader-dialog { width: calc(100% - 18px); max-width: calc(100% - 18px); padding: 20px 15px 16px; }
  .reader-dialog .dialog-header { margin-bottom: 12px; gap: 8px; }
  .reader-dialog h2 { font-size: 17px; }
  .reader-actions { gap: 7px; margin-bottom: 15px; }
  .reader-actions .button { padding: 7px 10px; font-size: 10px; }
  .reader-actions > span { margin-left: 0; }
  .reader-actions .annotation-switch { font-size: 10px; }
  #reader-content { min-height: 200px; max-height: 64vh; max-height: 64svh; padding: 22px 15px; font-size: 15px; line-height: 1.95; }
  #reader-content.annotating .reader-paragraph { padding-right: 32px; }
  #reader-content.annotating .reader-paragraph > button { width: 25px; min-height: 27px; }
  .welcome-dialog { grid-template-columns: minmax(0, 1fr); gap: 18px; width: min(420px, calc(100% - 28px)); padding: 29px 29px 21px; }
  .welcome-close { top: 12px; right: 12px; width: 40px; height: 40px; }
  .welcome-logo { margin-bottom: 21px; font-size: 32px; }
  .welcome-logo sup { font-size: 16px; }
  .welcome-copy > .eyebrow { font-size: 7px; letter-spacing: 1.3px; }
  .welcome-copy h2 { margin: 11px 0 12px; font-size: 33px; line-height: 1.42; }
  .welcome-copy p { margin-bottom: 19px; font-size: 12px; line-height: 1.9; }
  .welcome-copy .button { min-height: 41px; }
  .welcome-copy > small { margin-top: 8px; font-size: 9px; }
  .welcome-dialog > img { width: 230px; height: 230px; }
  .toast { bottom: max(17px, env(safe-area-inset-bottom)); padding: 11px 15px; font-size: 12px; }
}

@media (max-width: 380px) {
  .topbar { gap: 8px; padding-inline: 13px; }
  .brand-name { display: none; }
  main { padding-inline: 13px; }
  .paper-surface { padding-inline: 19px; }
  .companion-note h2 { font-size: 21px; }
  .companion-note .eyebrow { letter-spacing: .3px; }
}

@media (prefers-reduced-motion: no-preference) {
  button, a, summary { transition: color .16s, background-color .16s, border-color .16s; }
}

/* A consistent PDF reader, including browsers without a native PDF plug-in. */
.pdf-viewer{width:100%;min-width:0}.pdf-controls{display:flex;align-items:center;gap:12px;padding:7px 4px 12px;font-size:12px;color:#72665b}.pdf-controls button{border:1px solid var(--line);background:#fffdfa;border-radius:6px;min-width:32px;min-height:30px;font-size:18px}.pdf-controls .pdf-zoom{font-size:11px;padding:4px 11px;margin-left:auto}.pdf-page-scroll{width:100%;max-height:61svh;overflow:auto;background:#ebe7e1;padding:8px;border-radius:5px;text-align:center}.pdf-page-canvas{display:block;max-width:none;margin:auto;box-shadow:0 1px 6px #24212416;background:white}.paper-preview:has(.pdf-viewer){padding-right:0;max-height:none;overflow:visible;min-height:0}#reader-content:has(.pdf-viewer){max-height:none;overflow:visible;padding:10px}#reader-content .pdf-page-scroll{max-height:58svh}.quick-guide a{white-space:nowrap}.quick-guide a:hover{text-decoration:underline}#composer,#current-todos,#paper-preview{scroll-margin-top:20px}
@media(max-width:640px){.paper-surface{padding:23px 16px}.paper-toolbar{margin-bottom:8px}.pdf-controls{padding-bottom:8px}.pdf-page-scroll{padding:6px}.quick-guide a{font-size:10px}}

/* Keep the first screen about the manuscript, with a short route to feedback. */
.topbar{min-height:68px;padding-top:10px;padding-bottom:10px}main{padding-top:18px}.quick-guide{margin-bottom:12px;padding-bottom:9px}.paper-tabs{margin-bottom:15px}.paper-surface{padding:23px 27px 0}.paper-heading h1{font-size:23px;line-height:1.45;margin:7px 0 7px}.paper-heading .eyebrow{font-size:9px}.paper-meta{font-size:11px}.paper-toolbar{margin:10px 0 9px;padding-bottom:9px;min-height:38px}.companion-note{min-height:126px;margin-bottom:18px;padding-top:0;padding-bottom:8px}.common-todos{margin-top:9px;font-size:10px}.todo-progress{font-size:10px;color:#70675f;line-height:1.7;margin:9px 0 0}.mobile-feedback{display:none}
@media(max-width:940px){.mobile-feedback{display:block;position:fixed;bottom:18px;right:18px;border-radius:24px;background:var(--ink);color:white;padding:11px 18px;font-size:12px;box-shadow:0 4px 18px #29272922;z-index:8}.footer{padding-bottom:75px}}
@media(max-width:680px){.topbar{min-height:64px}.quick-guide small{display:none}main{padding-top:13px}.paper-tabs{margin-bottom:12px}.paper-surface{padding:19px 16px 0}.paper-heading h1{font-size:21px}.paper-heading{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:5px}.paper-meta{font-size:10px}.journal-chip{font-size:9px;padding:3px 6px;margin:0}.paper-toolbar{gap:8px;margin-bottom:5px}.paper-toolbar .language-picker+label{max-width:calc(100% - 112px)}.paper-toolbar #full-reader-button{margin-left:auto}.paper-footnote{padding-bottom:13px;margin-top:10px}.pdf-controls{padding-top:4px}}

.reply-question{margin-top:10px;border-top:1px solid var(--line);padding-top:8px}.reply-question summary{cursor:pointer;font-size:11px}.reply-question p{white-space:pre-wrap;max-height:220px;overflow:auto;font-size:12px;line-height:1.8;color:var(--ink)}
