:root {
  --paper: #f3eddf;
  --paper-deep: #e5dcc8;
  --line: #b9ae98;
  --ink: #18221f;
  --ink-soft: #4f504a;
  --vermilion: #a53224;
  --vermilion-deep: #782217;
  --green: #176a57;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.6;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--paper); padding: 6px 12px; }

.masthead {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: var(--ink);
  color: var(--paper);
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--vermilion); color: #fff;
  display: grid; place-items: center; font-size: 20px;
}
.masthead-title { flex: 1; }
.eyebrow { margin: 0; font-size: 12px; letter-spacing: .08em; opacity: .75; }
.masthead h1 { margin: 0; font-size: 20px; }
.session-box { text-align: right; }
.session-name { margin: 0; font-size: 15px; font-weight: 600; }
.session-role { margin: 0; font-size: 12px; opacity: .75; }
.logout-button { margin-top: 6px; padding: 0; color: inherit; background: none; border: 0; text-decoration: underline; cursor: pointer; }
.login-panel { max-width: 1080px; min-height: 72vh; margin: 0 auto; padding: 64px 32px; display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: 72px; }
.login-intro h2 { font-family: "Songti SC", "STSong", serif; font-size: clamp(32px, 4vw, 52px); line-height: 1.35; font-weight: 600; margin: 24px 0; }
.login-intro > p:last-child { color: var(--ink-soft); font-size: 15px; line-height: 2; }
.login-card { padding: 36px; background: #fffdf7; border: 1px solid var(--line); border-top: 4px solid var(--vermilion); box-shadow: 0 10px 28px #18221f0a; }
.login-mark { display: inline-block; color: var(--vermilion); border: 1px solid currentColor; padding: 3px 7px; font-family: "Songti SC", serif; letter-spacing: .15em; font-size: 13px; }
.login-card h3 { margin: 24px 0 4px; font-size: 24px; }
.login-card > p { color: var(--ink-soft); font-size: 14px; }
.login-card .login-button { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-top: 28px; padding: 14px 18px; background: #1768db; border: 1px solid #1768db; color: white; text-decoration: none; font-size: 16px; }
.login-card .login-button:hover { background: #1054b4; }
.login-button:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }
.login-card .login-status { min-height: 22px; margin: 16px 0; }
.login-card .login-footnote { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--paper-deep); font-size: 12px; }
@media (max-width: 700px) {
  .login-panel { grid-template-columns: 1fr; gap: 24px; padding: 32px 20px; min-height: auto; }
  .login-intro h2 { margin: 12px 0; }
  .login-card { padding: 24px; }
}

.dev-switcher {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 24px; background: var(--paper-deep);
  font-size: 13px; border-bottom: 1px solid var(--line);
}
.dev-switcher button {
  border: 1px solid var(--line); background: var(--paper);
  padding: 4px 10px; border-radius: 999px; cursor: pointer; color: var(--ink);
}
.dev-switcher button:hover { border-color: var(--vermilion); color: var(--vermilion); }
.dev-switcher button.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.tabs { display: flex; gap: 4px; padding: 10px 24px 0; }
.tabs button {
  border: 1px solid var(--line); border-bottom: none;
  background: var(--paper-deep); padding: 8px 20px; cursor: pointer;
  border-radius: 8px 8px 0 0; font-size: 14px; color: var(--ink-soft);
}
.tabs button.active { background: var(--paper); color: var(--ink); font-weight: 600; }

main { padding: 16px 24px 40px; }
.view { max-width: 1280px; margin: 0 auto; }
[hidden] { display: none !important; }

.desk-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.folio { margin: 0; font-size: 12px; letter-spacing: .08em; color: var(--ink-soft); }
.desk-head h2 { margin: 0; font-size: 22px; }
.state-chip {
  margin: 0; padding: 4px 12px; border-radius: 999px;
  background: var(--paper-deep); border: 1px solid var(--line); font-size: 13px;
}

.doc-table { width: 100%; border-collapse: collapse; background: #fffdf6; }
.doc-table th, .doc-table td { border: 1px solid var(--line); padding: 8px 12px; text-align: left; font-size: 14px; }
.doc-table th { background: var(--paper-deep); }
.doc-table button {
  border: 1px solid var(--vermilion); color: var(--vermilion); background: transparent;
  padding: 4px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.doc-table button:hover { background: var(--vermilion); color: #fff; }

.empty-note { color: var(--ink-soft); font-size: 14px; }

.doc-tools { display: flex; align-items: center; gap: 12px; }
.doc-tools label { font-size: 13px; color: var(--ink-soft); }
.current-version-label {
  margin: 0; color: var(--green); font-size: 13px; font-weight: 700;
  letter-spacing: .02em;
}
.doc-tools select {
  border: 1px solid var(--line); background: #fffdf6; padding: 4px 8px;
  border-radius: 6px; margin-left: 6px;
}

.button-outline { border: 1px solid var(--ink); background: transparent; color: var(--ink); }
.button-outline:hover { background: var(--ink); color: var(--paper); }

.upload-form {
  background: #fffdf6; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px; display: grid; gap: 12px;
}
.drop-zone {
  border: 1.5px dashed var(--line); border-radius: 8px; padding: 14px;
  display: grid; gap: 4px; text-align: center; cursor: pointer; background: var(--paper);
}
.drop-zone:hover { border-color: var(--vermilion); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { font-size: 15px; }
.drop-zone small { color: var(--ink-soft); }
.upload-fields { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.upload-fields label { font-size: 13px; color: var(--ink-soft); display: grid; gap: 4px; flex: 1; min-width: 220px; }
.upload-fields input {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
  font-family: inherit; font-size: 14px; background: #fff;
}

.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }

.preview-guidance {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin-bottom: 14px; padding: 14px 16px 14px 18px;
  background: #fff7df; border: 1px solid #c9ad68; border-left: 5px solid var(--vermilion);
  border-radius: 4px;
}
.preview-guidance strong { font-family: "Songti SC", "STSong", serif; font-size: 17px; }
.preview-guidance p { margin: 2px 0 0; color: var(--ink-soft); font-size: 13px; }
.download-word {
  flex: none; padding: 9px 15px; border-radius: 4px; background: var(--vermilion);
  color: #fff; text-decoration: none; font-size: 14px; font-weight: 650;
}
.download-word:hover { background: var(--vermilion-deep); }
.review-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; flex: none; min-width: 310px; }
.review-actions .download-word { grid-column: 1 / -1; text-align: center; }
.layout-feedback, .share-review {
  border: 1px solid var(--vermilion); border-radius: 4px; background: transparent;
  color: var(--vermilion-deep); padding: 7px 9px; font: inherit; font-size: 13px; cursor: pointer;
}
.layout-feedback:hover, .share-review:hover { background: #f4e2d6; }

.review-content-host {
  background: #ddd5c4; border: 1px solid var(--line); border-radius: 6px;
  padding: 22px; max-height: 76vh; overflow: auto; min-width: 0;
}
.review-doc {
  width: min(100%, 820px); min-height: 70vh; margin: 0 auto; padding: 54px 64px 72px;
  background: #fffef9; color: #22251f; border: 1px solid #c9c0ad;
  box-shadow: 0 10px 28px rgba(41, 35, 23, .12);
  font-family: "Songti SC", "STSong", "SimSun", serif; font-size: 15px; line-height: 1.85;
}
.review-doc p { position: relative; margin: 0 0 10px; white-space: pre-wrap; }
.review-doc .review-paragraph { text-indent: 2em; }
.review-doc .review-spacer { min-height: 1em; margin: 0; }
.review-doc .review-heading { text-indent: 0; font-weight: 700; color: #17231f; }
.review-doc .review-heading-1 { margin: 24px 0 10px; font-size: 18px; border-bottom: 1px solid #d9d1c0; padding-bottom: 4px; }
.review-doc .review-heading-2 { margin: 18px 0 8px; font-size: 16px; }
.review-doc .review-heading-3 { margin: 14px 0 6px; font-size: 15px; }
.review-doc table {
  position: relative; width: 100%; margin: 16px 0 22px; border-collapse: collapse;
  table-layout: fixed; font-family: "Songti SC", "STSong", "SimSun", serif; font-size: 14px;
}
.review-doc td { border: 1px solid #777168; padding: 7px 9px; vertical-align: top; word-break: break-word; }
.review-doc td p { text-indent: 0; margin: 0 0 4px; }
.review-doc ::selection { background: rgba(165, 50, 36, .24); color: inherit; }
.review-doc [data-node-id].has-feedback { outline: 2px solid rgba(23, 106, 87, .45); outline-offset: 3px; }

.content-marker {
  position: absolute; top: -7px; right: -7px; z-index: 5;
  min-width: 22px; height: 22px; border-radius: 999px;
  border: none; color: #fff; font-size: 12px; font-weight: 700;
  cursor: pointer; box-shadow: 0 2px 7px rgba(0, 0, 0, .28);
  display: grid; place-items: center; padding: 0 6px;
}
.content-marker:hover { transform: scale(1.12); }

.role-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  flex: none;
}

.annotation-panel {
  background: #fffdf6; border: 1px solid var(--line); border-radius: 10px;
  padding: 0; max-height: 78vh; overflow: auto; min-width: 0;
  display: flex; flex-direction: column;
}
.annotation-panel .panel-head {
  padding: 12px 16px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--paper-deep); border-radius: 10px 10px 0 0;
}
.annotation-panel .panel-head strong { font-size: 14px; }
.annotation-panel .panel-head > div { display: grid; gap: 1px; }
.collaboration-state { color: var(--green); font-size: 11px; font-weight: 500; }
.panel-count {
  font-size: 12px; color: var(--ink-soft); background: var(--paper);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px;
}
.panel-body { padding: 12px 16px 16px; }
.annotation-panel .thread { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
.thread .thread-meta { font-size: 12px; color: var(--ink-soft); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.thread .thread-opinion { font-size: 14px; margin: 6px 0; white-space: pre-wrap; }
.thread .thread-anchor { font-size: 12px; color: var(--ink-soft); background: var(--paper-deep); padding: 6px 8px; border-radius: 6px; margin: 4px 0; white-space: pre-wrap; }
.thread .thread-suggestion { font-size: 13px; color: var(--green); margin: 4px 0; }
.thread .status-chip { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--paper-deep); }
.classification-note { display: inline-block; margin: 5px 6px 0 0; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: #e8e3d7; color: var(--ink-soft); }
.classification-classified { background: #e3efe9; color: var(--green); }
.classification-failed { background: #f6e3d0; color: var(--vermilion-deep); }
.promotion-note { display: inline-block; margin-top: 5px; padding: 3px 9px; border-radius: 999px; background: #e3efe9; color: var(--green); font-size: 12px; }
.promote-button { margin-top: 6px; border: 1px solid var(--green); color: var(--green); background: transparent; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.promote-button:disabled { opacity: .5; cursor: not-allowed; }
.delete-feedback-button { margin: 6px 0 0 8px; border: 1px solid #a53224; color: #8f291f; background: transparent; border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.delete-feedback-button:disabled { opacity: .5; cursor: not-allowed; }

.cred-badge { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 4px; }
.cred-A { background: #7a1f1f; color: #fff; }
.cred-B { background: #b35900; color: #fff; }
.cred-C { background: #176a57; color: #fff; }
.cred-D { background: #68685f; color: #fff; }

.reply-box { margin-top: 8px; display: flex; gap: 8px; }
.reply-box textarea { flex: 1; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-family: inherit; font-size: 13px; }
.reply-box button { border: 1px solid var(--vermilion); color: var(--vermilion); background: transparent; border-radius: 6px; padding: 0 14px; cursor: pointer; }

.popover {
  position: fixed; z-index: 50; width: 340px;
  background: #fffdf6; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(24, 34, 31, .25); padding: 14px 16px;
}
.popover-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.popover-head button { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--ink-soft); }
.popover-help { margin: 0 0 8px; padding: 8px 10px; border-left: 3px solid var(--green); background: #e8efe9; color: #31574c; font-size: 12px; }
.popover label { display: block; font-size: 12px; color: var(--ink-soft); margin: 8px 0 2px; }
.popover textarea, .popover input, .popover select {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 8px; font-family: inherit; font-size: 13px; margin-top: 2px;
}
.anchor-box { background: var(--paper-deep); color: var(--ink-soft); }

.button { border: none; border-radius: 8px; padding: 8px 18px; font-size: 14px; cursor: pointer; }
.button-vermilion { background: var(--vermilion); color: #fff; }
.button-vermilion:hover { background: var(--vermilion-deep); }
.button:disabled { opacity: .5; cursor: not-allowed; }

.message { margin-top: 12px; padding: 10px 14px; border-radius: 8px; background: #f6e3d0; color: var(--vermilion-deep); font-size: 14px; }
.message.error { background: #f6e3d0; color: var(--vermilion-deep); }

.dashboard-body { display: grid; gap: 18px; }
.dash-card { background: #fffdf6; border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.dash-card h3 { margin: 0 0 10px; font-size: 15px; }
.dash-bars { display: flex; align-items: flex-end; gap: 10px; height: 90px; padding-top: 6px; }
.dash-bar { flex: 1; max-width: 60px; background: var(--vermilion); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.dash-bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 12px; }
.dash-axis { display: flex; gap: 10px; font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.dash-axis div { flex: 1; max-width: 60px; text-align: center; }
.dash-cats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.dash-cat { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: #fff; }
.dash-cat b { display: block; font-size: 20px; color: var(--vermilion); }

footer { padding: 12px 24px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 12px; display: flex; justify-content: space-between; }

@media (max-width: 900px) {
  main { padding-inline: 12px; }
  .masthead { padding-inline: 14px; }
  .session-box { display: none; }
  .preview-guidance { align-items: stretch; flex-direction: column; gap: 12px; }
  .download-word { text-align: center; }
  .review-actions { min-width: 0; width: 100%; }
  .doc-layout { grid-template-columns: 1fr; }
  .review-content-host { padding: 10px; max-height: none; }
  .review-doc { padding: 36px 24px 48px; }
  .annotation-panel { max-height: none; }
}
.candidate-history {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid #d8c9b8;
  background: #fffaf3;
}

.candidate-history > p {
  margin: 6px 0 10px;
  color: #685b4c;
}

.candidate-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #eadfce;
}

.candidate-history-row button,
.candidate-history-row a {
  flex: 0 0 auto;
}
/* Problem-based processing stays beside the reviewed version, above the document. */
.problem-processing { margin: 18px 0; border: 1px solid #b8b2a5; border-left: 4px solid #a53224; background: #faf8f2; }
.problem-processing summary { padding: 16px 20px; cursor: pointer; font-weight: 700; }
.problem-processing summary span { margin-left: 16px; font-size: .85rem; font-weight: 400; color: #665e51; }
.processing-body { padding: 0 20px 20px; max-width: 960px; }
.processing-body label { display: block; margin: 12px 0; }
.processing-body textarea, .processing-body select { display: block; width: 100%; padding: 9px; margin-top: 6px; border: 1px solid #b8b2a5; background: white; color: #27251f; font: inherit; }
.processing-body button { margin: 6px 8px 6px 0; }
.processing-body .button-outline { border: 1px solid #746b5c; background: #fff; }
.processing-body .button-outline:hover { background: #e9e4d6; color: #27251f; }
.processing-recommendation { font-weight: 700; color: #176a57; }
.processing-scope { padding: 12px; background: #eeeee5; line-height: 1.8; }
.processing-blocker { color: #9c3024; overflow-wrap: anywhere; }
.processing-record { border-top: 1px solid #d8d2c5; padding: 16px 0; }
.processing-record p { line-height: 1.65; overflow-wrap: anywhere; }
@media (max-width: 640px) { .problem-processing summary span { display: block; margin: 6px 0 0; } .processing-body { padding: 0 12px 12px; } }
