@font-face {
  font-family: "Source Serif 4";
  src: url("fonts/source-serif-4-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/ibm-plex-mono-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #e8dcc4;
  --paper-light: #d7e7da;
  --paper-deep: #bfd6c5;
  --ink: #202a38;
  --ink-soft: #55606c;
  --pen-red: #b0342b;
  --moss: #3e6b4f;
  --ochre: #a97a20;
  --rule: rgba(62, 107, 79, 0.12);
  --line: rgba(32, 42, 56, 0.28);
  --shadow: rgba(32, 42, 56, 0.14);
  --serif: "Source Serif 4", "Noto Serif CJK SC", "Songti SC", serif;
  --ui: "Inter", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "Noto Sans Mono CJK SC", monospace;
}

* {
  border-radius: 0 !important;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: var(--serif);
  background: var(--paper);
}

h1,
h2,
h3,
h4,
p,
dl,
dd {
  font-family: var(--serif);
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 680;
}

a {
  color: var(--ink);
  text-decoration-color: var(--pen-red);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--pen-red);
}

button,
.button,
input,
select,
textarea,
label,
.topbar,
.workspace-top,
.review-workspace-bar,
.state-pill,
.badge,
.project-meta,
.meta,
.status-key,
.status-value,
.filter-count,
.slot-content,
.doctor-admin-table,
.admin-row,
.case-item {
  font-family: var(--ui);
}

button,
.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(32, 42, 56, 0.46);
  background: var(--paper-light);
  color: var(--ink);
  padding: 7px 12px;
  box-shadow: none;
  font-weight: 650;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

button:hover,
.button:hover {
  color: var(--ink);
  border-color: var(--moss);
  background: var(--paper-deep);
}

button:active,
.button:active {
  background: #d2e5d6;
}

button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--ochre);
  outline-offset: 3px;
}

.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-light);
}

.primary:hover {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffdf4;
}

.danger-button,
.danger-text,
.link-danger {
  color: var(--pen-red);
  border-color: var(--pen-red);
  background: #f8eeee;
}

input,
select,
textarea {
  border: 1px solid rgba(32, 42, 56, 0.46);
  border-bottom: 2px solid var(--ink);
  background: #ffffff;
  color: var(--ink);
  padding: 9px 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

input::placeholder,
textarea::placeholder {
  color: #7b786d;
}

.paper-select {
  min-height: 48px;
  border: 1px solid rgba(32, 42, 56, 0.62);
  border-left: 5px solid var(--moss);
  border-bottom: 2px solid var(--ink);
  background-color: rgba(223, 236, 226, 0.92);
  color: var(--ink);
  font-weight: 650;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.paper-select:hover {
  border-color: var(--moss);
  background-color: #d2e5d6;
}

.paper-select:invalid {
  color: var(--ink-soft);
  font-weight: 500;
}

.paper-select option {
  background: var(--paper-light);
  color: var(--ink);
  font-weight: 500;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--pen-red);
  box-shadow: none;
}

.topbar,
.workspace-top {
  min-height: 58px;
  height: auto;
  position: relative;
  z-index: 20;
  background: rgba(232, 220, 196, 0.98);
  border: 0;
  border-bottom: 1px solid rgba(32, 42, 56, 0.24);
  box-shadow: none;
  padding: 10px clamp(16px, 3vw, 42px);
}

.topbar strong,
.workspace-top strong {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 720;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: var(--ink);
  font-family: var(--ui);
  line-height: 1;
  white-space: nowrap;
}

.site-brand-logo {
  width: 46px;
  height: 36px;
  flex: 0 0 46px;
  overflow: hidden;
}

.site-brand-logo img {
  display: block;
  width: 54px;
  height: 54px;
  margin: -9px 0 0 -4px;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.site-brand-name {
  font-size: 18px;
  font-weight: 720;
}

.topbar-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-identity > span:last-child {
  padding-left: 12px;
  border-left: 1px solid rgba(32, 42, 56, 0.22);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar span,
.workspace-top span {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
}

.page {
  width: min(1440px, calc(100% - 36px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

.page h1 {
  font-size: 27px;
  line-height: 1.15;
}

.page-intro,
.section-heading,
.section-title-row {
  border-bottom: 1px solid var(--ink);
  padding-bottom: 13px;
}

.page-intro p,
.section-heading p,
.section-title-row .meta,
.project-main > p,
.instruction-summary > p {
  text-decoration: none;
}

.meta,
.subtle {
  color: var(--ink-soft);
}

.notification-section {
  margin: 0 0 28px;
}

.admin-notification-menu {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.notification-trigger {
  position: relative;
  width: 40px;
  min-width: 40px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(32, 42, 56, 0.48);
  background: var(--paper-light);
  color: var(--ink);
  cursor: pointer;
  list-style: none;
}

.notification-trigger::-webkit-details-marker {
  display: none;
}

.notification-trigger:hover,
.admin-notification-menu[open] > .notification-trigger {
  border-color: var(--moss);
  background: #d2e5d6;
}

.notification-trigger svg {
  display: block;
}

.notification-badge,
.topbar .notification-badge {
  position: absolute;
  top: -6px;
  right: -7px;
  min-width: 19px;
  height: 19px;
  margin: 0;
  padding: 1px 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--paper-light);
  border-radius: 10px;
  background: var(--pen-red);
  color: #ffffff;
  font: 10px/1 var(--mono);
}

.notification-popover {
  position: absolute;
  z-index: 100;
  top: calc(100% + 10px);
  right: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: min(70vh, 620px);
  overflow: auto;
  padding: 16px;
  border: 1px solid rgba(32, 42, 56, 0.55);
  background: var(--paper-light);
  box-shadow: 4px 5px 0 rgba(32, 42, 56, 0.14);
}

.notification-popover .notification-heading {
  position: sticky;
  top: -16px;
  z-index: 1;
  padding: 12px 0;
  background: var(--paper-light);
}

.notification-popover .notification-heading h1 {
  font-size: 19px;
}

.notification-popover .notification-card {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.notification-popover .notification-content strong {
  font-size: 14px;
}

.notification-popover .notification-actions {
  width: 100%;
  flex-wrap: wrap;
}

.notification-popover .notification-actions .button,
.notification-popover .notification-actions form,
.notification-popover .notification-actions button {
  flex: 1 1 120px;
}

.notification-popover .notification-actions button {
  width: 100%;
}

.notification-heading,
.tab-panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.notification-heading h1,
.tab-panel-heading h1 {
  margin: 0;
  font-size: 22px;
}

.notification-heading > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.notification-heading form,
.notification-actions form {
  margin: 0;
}

.notification-heading button,
.notification-actions button,
.notification-actions .button {
  min-height: 44px;
}

.notification-heading span,
.tab-panel-heading p {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--ui);
  font-size: 12px;
}

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

.notification-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 16px;
  border: 1px solid rgba(32, 42, 56, 0.32);
  border-left: 4px solid var(--ochre);
  background: var(--paper-light);
}

.notification-card.review-submitted {
  border-left-color: var(--moss);
}

.notification-card.site_alert {
  border-left-color: var(--pen-red);
}

.notification-card.site_alert p {
  white-space: pre-line;
}

.notification-card.is-read {
  border-left-color: rgba(32, 42, 56, 0.32);
  background: rgba(248, 246, 238, 0.7);
}

.notification-content {
  min-width: 0;
}

.notification-content strong {
  display: block;
  font-family: var(--serif);
  font-size: 16px;
}

.notification-content p {
  margin: 4px 0;
  color: var(--ink-soft);
}

.notification-content time {
  color: var(--ink-soft);
  font: 11px/1.4 var(--mono);
}

.notification-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.notification-empty {
  margin: 0;
  padding: 12px 0;
  color: var(--ink-soft);
}

.read-notifications {
  margin-top: 12px;
  border-top: 1px solid rgba(32, 42, 56, 0.24);
  padding-top: 10px;
}

.read-notifications > summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
  font-family: var(--ui);
  font-weight: 700;
}

.read-notifications[open] > summary {
  margin-bottom: 10px;
}

.task-tabs {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 20px;
}

.task-tab {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  border: 1px solid rgba(32, 42, 56, 0.34);
  background: rgba(232, 220, 196, 0.72);
  color: var(--ink);
  font-family: var(--ui);
  font-weight: 700;
  text-decoration: none;
}

.task-tab:hover,
.task-tab.active {
  border-color: var(--moss);
  background: var(--paper-light);
  color: var(--ink);
}

.task-tab span {
  min-width: 22px;
  padding: 2px 5px;
  border: 1px solid rgba(32, 42, 56, 0.25);
  text-align: center;
  font: 11px/1.2 var(--mono);
}

.task-tab-panel {
  min-width: 0;
}

button:disabled,
.button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.alert,
.status-banner,
.workspace-alert {
  border: 1px solid currentColor;
  border-left-width: 3px;
  box-shadow: none;
}

.alert,
.status-banner.fail,
.workspace-alert {
  color: var(--pen-red);
  background: #f3d8c9;
}

.status-banner.pass,
.workspace-alert.success {
  color: var(--moss);
  background: #dbe5cf;
  border-color: var(--moss);
}

.status-banner.warn {
  color: #775313;
  background: #ebd59d;
  border-color: var(--ochre);
}

.admin-section {
  position: relative;
  background: transparent;
  border: 0;
  padding: 0 0 30px;
  margin: 0 0 28px;
}

.review-admin-table,
.review-project-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  border: 0;
}

.older-review-projects {
  border: 1px solid rgba(32, 42, 56, 0.32);
  background: rgba(232, 220, 196, 0.5);
}

.older-review-projects > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  font-family: var(--ui);
  font-weight: 700;
}

.older-review-projects[open] > summary {
  border-bottom: 1px solid rgba(32, 42, 56, 0.28);
}

.older-review-project-list {
  padding: 16px;
}

.review-admin-project,
.review-project-row {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(32, 42, 56, 0.32);
  background: var(--paper-light);
  padding: 20px;
}

.review-project-row.claimed {
  border-left: 6px solid var(--moss);
  background: #dce9d7;
}

.review-project-row.unapplied {
  border-left: 6px solid #55717b;
  background: #e3ecec;
}

.review-admin-project:nth-child(even),
.review-project-row:nth-child(even),
.review-project-row.available {
  background: var(--paper-light);
}

.review-project-row.claimed:nth-child(even) {
  background: #dce9d7;
}

.review-project-row.unapplied:nth-child(even) {
  background: #e3ecec;
}

.task-status-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--ui);
  font-size: 12px;
}

.task-status-filters a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid rgba(32, 42, 56, 0.35);
  color: var(--ink);
  text-decoration: none;
}

.task-status-filters .claimed,
.state-pill.claimed {
  color: #244f36;
  background: #c6dac5;
}

.task-status-filters .unapplied,
.state-pill.unapplied {
  color: #294952;
  background: #cadadd;
}

.task-status-filters a:hover,
.task-status-filters a.active {
  border-color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--ink);
}

.project-reviewer-progress {
  grid-column: 1 / -1;
  margin-top: 16px;
  border-top: 1px solid rgba(32, 42, 56, 0.3);
  padding-top: 12px;
}

.project-reviewer-progress h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.reviewer-progress-list {
  display: grid;
}

.reviewer-progress-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 220px) auto;
  align-items: center;
  gap: 16px;
  border-top: 1px solid rgba(32, 42, 56, 0.2);
  padding: 8px 0;
}

.reviewer-progress-identity strong,
.reviewer-progress-identity span {
  display: block;
}

.reviewer-progress-identity span,
.reviewer-progress-empty {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font: 11px/1.4 var(--ui);
}

.reviewer-progress-value {
  min-width: 0;
  font: 11px/1.4 var(--mono);
}

.percent-progress {
  width: 100%;
  display: grid;
  grid-template-columns: 42px minmax(90px, 1fr);
  align-items: center;
  gap: 8px;
  font: 11px/1.4 var(--mono);
  font-variant-numeric: tabular-nums;
}

.percent-progress-number {
  text-align: right;
  color: var(--ink);
  font-weight: 700;
}

.project-meta-progress {
  min-width: 190px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-meta-progress > span {
  white-space: nowrap;
}

.percent-progress.meta-progress {
  width: 125px;
}

.application-trial-progress {
  min-width: min(220px, 100%);
  display: grid;
  grid-template-columns: auto minmax(130px, 1fr);
  align-items: center;
  gap: 8px;
}

.application-trial-progress > span {
  white-space: nowrap;
}

.percent-progress.slot-progress {
  margin-top: 2px;
}

.workspace-progress-meter {
  width: 180px;
  display: grid;
  grid-template-columns: 42px minmax(90px, 1fr);
  align-items: center;
  gap: 8px;
}

.workspace-progress-meter strong {
  text-align: right;
}

.reviewer-progress-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.review-admin-project > header {
  align-items: center;
}

.project-title-line h2 {
  font-family: var(--serif);
  font-size: 20px;
}

.project-number,
.slot-letter,
.workspace-progress strong,
.status-count-grid strong,
.project-facts dd,
.progress-row,
.case-id {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.project-number {
  background: var(--ink);
  color: var(--paper-light);
  border: 0;
  padding: 4px 8px;
}

.state-pill,
.badge {
  min-height: 24px;
  border: 1px solid rgba(32, 42, 56, 0.5);
  box-shadow: none;
  transform: none;
  font-size: 11px;
}

.state-pill.open,
.state-pill.active,
.badge.done {
  color: #173f2a;
  background: #cbd9be;
}

.state-pill.locked,
.badge.partial {
  color: #69490f;
  background: #e7cf8d;
}

.state-pill.expired,
.state-pill.withdrawn,
.state-pill.submitted,
.state-pill.completed {
  color: #76251f;
  background: #e9beb2;
}

.state-pill.submitted,
.state-pill.completed {
  color: #244f36;
  background: #c6dac5;
}

.project-meta {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11px;
}

.progress,
.progress.compact,
.progress.small {
  height: 7px;
  border: 1px solid rgba(32, 42, 56, 0.45);
  background: var(--paper-deep);
}

.progress > div,
.progress.compact > div,
.progress.small > div {
  height: 100%;
  background: var(--moss);
}

.review-project-filters {
  margin: 18px 0 16px;
  padding: 14px;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-light);
  box-shadow: none;
}

.review-slot-grid {
  gap: 0;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: rgba(232, 220, 196, 0.48);
}

.review-application-panel {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-light);
}

.review-application-panel > strong {
  font-family: var(--serif);
}

.review-application-list {
  display: grid;
  gap: 8px;
  margin-top: 9px;
}

.review-application-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid rgba(32, 42, 56, 0.2);
  font: 12px/1.5 var(--ui);
}

.application-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.review-slot {
  position: relative;
  min-height: 112px;
  border: 0;
  border-right: 1px solid rgba(32, 42, 56, 0.28);
  background: transparent;
  box-shadow: none;
  transform: none;
}

.review-slot:last-child {
  border-right: 0;
}

.review-slot:nth-child(2) {
  transform: none;
}

.review-slot:nth-child(3) {
  transform: none;
}

.slot-letter {
  background: var(--ink);
  color: var(--paper-light);
  font-size: 18px;
}

.slot-export-actions {
  border-color: rgba(32, 42, 56, 0.25);
}

.export-control {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
}

.export-details > summary {
  list-style: none;
  cursor: pointer;
}

.export-details > summary::-webkit-details-marker {
  display: none;
}

.export-details[open] > summary,
.export-control > button[aria-expanded="true"] {
  border-color: var(--moss);
  background: #d2e5d6;
}

.export-menu-options {
  position: absolute;
  z-index: 40;
  top: calc(100% + 5px);
  right: 0;
  display: grid;
  min-width: 174px;
  padding: 4px;
  border: 1px solid rgba(32, 42, 56, 0.58);
  background: var(--paper-light);
  box-shadow: 3px 4px 0 rgba(32, 42, 56, 0.12);
}

.export-menu-options[hidden] {
  display: none;
}

.export-menu-options a {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 7px 9px;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 12px;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.export-menu-options a:hover {
  color: var(--ink);
  background: #d2e5d6;
}

.slot-export-actions .export-menu-options {
  right: auto;
  left: 0;
}

.auto-project-number {
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-light);
  box-shadow: none;
}

.auto-project-number strong {
  font-family: var(--mono);
  color: var(--ink);
}

.review-upload-form {
  padding: 20px;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-light);
}

.draft-file-status {
  display: block;
  margin-top: 6px;
  color: var(--moss);
  font: 11px/1.4 var(--mono);
}

#projectDraftStatus {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
}

.registration-code-form {
  padding: 16px;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-light);
}

.doctor-admin-table,
.admin-table,
.progress-table {
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: rgba(223, 236, 226, 0.76);
}

.doctor-admin-row,
.admin-row,
.progress-row {
  border-color: rgba(32, 42, 56, 0.24);
}

.doctor-admin-row.head,
.admin-row.head,
.progress-row.head {
  background: var(--ink);
  color: var(--paper-light);
}

.status-grid {
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.status-item {
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-light);
  box-shadow: none;
  transform: none;
}

.status-item:nth-child(even) {
  transform: none;
}

.status-item.pass {
  border-left: 6px solid var(--moss);
}

.status-item.warn {
  border-left: 6px solid var(--ochre);
  background: #f3e4bd;
}

.status-item.fail {
  border-left: 6px solid var(--pen-red);
}

.status-count-grid {
  border-color: var(--ink);
  background: var(--paper-light);
}

.status-count-grid > div {
  border-color: rgba(32, 42, 56, 0.38);
}

.status-count-grid strong {
  color: var(--pen-red);
}

.empty-state {
  border: 1px dashed var(--ink);
  background: var(--paper-light);
  color: var(--ink-soft);
  font-family: var(--ui);
}

.auth {
  position: relative;
  align-items: flex-start;
  padding-top: clamp(64px, 12vh, 130px);
}

.auth-panel {
  position: relative;
  background: var(--paper-light);
  border: 1px solid rgba(32, 42, 56, 0.28);
  padding: 34px;
  box-shadow: none;
  transform: none;
}

.auth-panel h1 {
  font-size: 30px;
  margin-top: 0;
}

.instruction-layout {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 26px;
  padding: 34px;
  background: transparent;
}

.instruction-viewer {
  grid-column: 1;
  grid-row: 1;
  padding: 0;
  filter: none;
}

.instruction-viewer iframe {
  border: 1px solid var(--ink);
  background: #ffffff;
}

.instruction-summary {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  position: relative;
  overflow: auto;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-light);
  padding: 28px;
  box-shadow: none;
  transform: none;
}

.project-facts {
  border-color: var(--ink);
}

.project-facts > div {
  border-color: rgba(32, 42, 56, 0.3);
}

.claim-form {
  border-top: 2px solid var(--pen-red);
  padding-top: 14px;
}

.review-workspace-shell {
  background: var(--paper);
}

.review-workspace-bar {
  background: rgba(232, 220, 196, 0.98);
  border-bottom: 1px solid rgba(32, 42, 56, 0.24);
  box-shadow: none;
}

.save-status-banner {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 14px;
  border-bottom: 1px solid rgba(62, 107, 79, 0.36);
  background: var(--paper-light);
  color: var(--moss);
  font-family: var(--ui);
  font-size: 12px;
}

.save-status-banner strong {
  font-family: var(--ui);
  font-size: 13px;
}

.workspace-project-name strong {
  font-family: var(--serif);
  font-size: 17px;
}

.workspace-project-name .site-brand {
  margin-bottom: 2px;
}

.review-workspace-bar .site-brand-logo,
.workspace-top .site-brand-logo {
  width: 35px;
  height: 28px;
  flex-basis: 35px;
}

.review-workspace-bar .site-brand-logo img,
.workspace-top .site-brand-logo img {
  width: 42px;
  height: 42px;
  margin: -7px 0 0 -3px;
}

.review-workspace-bar .site-brand-name,
.workspace-top .site-brand-name {
  font-size: 15px;
}

.review-task-frame {
  margin: 12px;
  width: calc(100% - 24px);
  border: 1px solid var(--ink);
  background: #ffffff;
  box-shadow: none;
}

.workspace {
  background: transparent;
}

.case-pane,
.annotation-pane {
  background: var(--paper-light);
  border-color: var(--ink);
}

.evidence-pane {
  background: #ffffff;
}

.case-item,
.card,
.doctor-answer,
.thumb,
.pdf-link {
  border: 1px solid rgba(32, 42, 56, 0.48);
  background: var(--paper-light);
  box-shadow: none;
}

.case-item.active,
.visit.current {
  border-left: 3px solid var(--pen-red);
  box-shadow: none;
}

.datebar {
  background: var(--paper-light);
  border-color: var(--ink);
}

.datebtn {
  border-color: var(--ink);
  background: transparent;
}

.datebtn.current {
  background: var(--ink);
  color: var(--paper-light);
}

code,
.fname,
.case-meta,
.system-status-meta {
  font-family: var(--mono);
}

.task-state-section {
  margin-top: 26px;
}

.task-state-section > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--ink);
}

.task-state-section > header h2 {
  margin: 0;
  font-size: 19px;
}

.task-state-section > header span,
.directory-count {
  min-width: 30px;
  padding: 3px 8px;
  border: 1px solid currentColor;
  text-align: center;
  font: 12px/1.4 var(--mono);
}

.review-project-row.ongoing {
  border-left: 6px solid #2f6674;
  background: #e3ecec;
}

.review-project-row.completed {
  border-left: 6px solid var(--moss);
  background: #dce9d7;
}

.state-pill.ongoing,
.state-pill.pending {
  color: #294952;
  background: #cadadd;
}

.state-pill.test {
  color: #5f2a12;
  background: #efcfb6;
  border-color: #9c5b37;
}

.application-reply-card {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #b68727;
  border-left-width: 5px;
  background: #f3e4bd;
  color: #63470f;
  font: 13px/1.5 var(--ui);
}

.application-reply-card strong {
  font-family: var(--serif);
}

.application-reply-card.test,
.workspace-alert.test {
  color: #294952;
  background: #dbe8e8;
  border-color: #477582;
}

.doctor-directory-section {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 3px double var(--ink);
}

.doctor-directory-table {
  border: 1px solid rgba(32, 42, 56, 0.3);
  background: var(--paper-light);
}

.doctor-directory-row {
  display: grid;
  grid-template-columns: 64px minmax(110px, 0.7fr) minmax(180px, 1.5fr) minmax(110px, 0.6fr);
  gap: 16px;
  padding: 11px 14px;
  border-top: 1px solid rgba(32, 42, 56, 0.2);
  font: 13px/1.5 var(--ui);
}

.doctor-directory-row:first-child {
  border-top: 0;
}

.doctor-directory-row.head {
  background: var(--ink);
  color: var(--paper-light);
  font-weight: 700;
}

.review-application-row > div:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.review-application-row time,
.review-application-row span {
  color: var(--ink-soft);
}

.review-application-row .application-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-deep);
  color: var(--ink);
  font-weight: 700;
}

.review-application-row .application-status-approved {
  border-color: #6d8b69;
  background: #dce9d7;
  color: #244f36;
}

.review-application-row .application-status-rejected,
.review-application-row .application-status-cancelled,
.review-application-row .application-status-withdrawn {
  color: #75504b;
  background: #eee0dc;
}

.review-approved-heading span {
  margin-left: 8px;
  color: var(--ink-soft);
  font: 12px/1.5 var(--ui);
}

.compact-empty {
  margin-top: 9px;
  padding: 10px;
}

.workspace-alert.trial {
  color: #63470f;
  background: #f3e4bd;
  border-color: #b68727;
}

.detail-reviewer-progress {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid rgba(32, 42, 56, 0.3);
}

.participant-progress {
  margin-top: 12px;
}

.people-status-panel > summary {
  display: flex;
  align-items: center;
  gap: 10px 18px;
  min-height: 34px;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  overflow-x: auto;
  font: 13px/1.4 var(--ui);
}

.people-status-panel > summary::-webkit-details-marker {
  display: none;
}

.people-status-panel > summary::before {
  content: "▸";
  flex: 0 0 auto;
  color: var(--ink-soft);
}

.people-status-panel[open] > summary::before {
  content: "▾";
}

.people-status-summary strong {
  font-size: 15px;
}

.people-status-summary span {
  color: var(--ink-soft);
}

.people-status-list {
  display: grid;
  min-width: 0;
  max-width: 100%;
  margin-top: 4px;
  overflow-x: auto;
}

.people-status-row {
  display: grid;
  grid-template-columns: minmax(100px, 150px) minmax(180px, 1fr) 130px auto minmax(170px, auto);
  align-items: center;
  gap: 12px;
  min-height: 38px;
  border-top: 1px solid rgba(32, 42, 56, 0.2);
  font: 12px/1.4 var(--ui);
  white-space: nowrap;
}

.people-status-profile {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
}

.people-status-years {
  overflow: visible;
}

.people-status-row > span:nth-child(5) {
  color: var(--ink-soft);
  text-align: right;
}

.task-timestamps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin-top: 8px;
  color: var(--ink-soft);
  font: 12px/1.6 var(--ui);
}

.task-timestamp time {
  font-variant-numeric: tabular-nums;
}

.timestamp-empty {
  opacity: 0.75;
}

.people-status-row .doctor-timestamps {
  grid-column: 1 / -1;
  margin: -5px 0 6px;
  white-space: normal;
}

.people-status-progress {
  grid-column: 1 / -1;
  width: min(100%, 360px);
  min-width: 0;
  margin-bottom: 4px;
}

.slot-content .doctor-timestamps {
  margin: 0;
}

.people-status-badge {
  min-width: 52px;
  padding: 2px 7px;
  border: 1px solid rgba(32, 42, 56, 0.28);
  background: var(--paper-deep);
  text-align: center;
  font-weight: 700;
}

.people-status-annotating {
  border-color: #aa7d25;
  background: #f3e4bd;
  color: #63470f;
}

.people-status-completed {
  border-color: #6d8b69;
  background: #dce9d7;
  color: #244f36;
}

.detail-reviewer-progress h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

@media (max-width: 760px) {
  .review-project-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 16px 14px;
  }

  .review-project-row > *,
  .project-main,
  .people-status-panel,
  .instruction-summary {
    min-width: 0;
    max-width: 100%;
  }

  .project-title-line h2,
  .project-card-title {
    min-width: 0;
    max-width: 100%;
    font-size: 18px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .project-main > p,
  .instruction-summary > p {
    font-size: 14px;
    line-height: 1.7;
    overflow-wrap: anywhere;
  }

  .project-meta {
    gap: 8px 12px;
    overflow-wrap: anywhere;
  }

  .project-main .task-timestamps,
  .instruction-summary > .task-timestamps {
    flex-direction: column;
    gap: 4px;
  }

  .task-timestamp {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .review-project-row > .project-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }

  .review-project-row > .project-actions > *,
  .review-project-row .export-details > summary {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    text-align: center;
    justify-content: center;
    white-space: normal;
  }

  .review-project-row .export-details {
    display: block;
  }

  .review-project-row .export-menu-options {
    position: static;
    min-width: 0;
    width: 100%;
    margin-top: 6px;
  }

  .people-status-panel > summary {
    flex-wrap: wrap;
    gap: 6px 10px;
    white-space: normal;
    overflow: visible;
  }

  .people-status-summary strong {
    flex: 1;
    min-width: 0;
    font-size: 14px;
  }

  .people-status-summary > span {
    flex-basis: 100%;
    font-size: 12px;
  }

  .people-status-list {
    overflow: visible;
  }

  .people-status-row {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 10px;
    padding: 12px 0;
    font-size: 13px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .people-status-row > strong {
    grid-column: 1;
    grid-row: 1;
  }

  .people-status-row > .people-status-badge {
    grid-column: 2;
    grid-row: 1;
  }

  .people-status-row > .people-status-profile,
  .people-status-row > span:nth-child(5) {
    grid-column: 1 / -1;
    overflow: visible;
    white-space: normal;
    text-align: left;
  }

  .people-status-row .doctor-timestamps {
    flex-direction: column;
    gap: 3px;
    margin: 0;
  }

  .instruction-summary {
    padding: 18px 14px;
    overflow: visible;
  }

  .project-facts > div {
    gap: 12px;
  }

  .project-facts dd {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 1100px) {
  .status-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .instruction-layout {
    grid-template-columns: minmax(0, 1fr) 320px;
  }
}

@media (max-width: 900px) {
  .page {
    width: min(100% - 24px, 760px);
    padding-top: 34px;
  }

  .instruction-layout {
    display: flex;
    flex-direction: column;
    padding: 22px 14px;
  }

  .instruction-summary {
    order: 1;
    transform: none;
  }

  .instruction-viewer {
    order: 2;
    height: 68vh;
  }

  .review-slot {
    border-right: 0;
    border-bottom: 1px solid rgba(32, 42, 56, 0.28);
    transform: none !important;
  }

  .review-slot:last-child {
    border-bottom: 0;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 600px) {
  .admin-notification-menu {
    width: 100%;
  }

  .notification-trigger {
    width: 100%;
    min-height: 44px;
  }

  .notification-popover {
    position: fixed;
    top: 112px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: calc(100dvh - 126px);
  }

  .review-application-row {
    align-items: stretch;
    flex-direction: column;
  }

  .application-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  }

  .topbar-identity {
    width: 100%;
    flex: 0 0 auto;
    gap: 6px;
  }

  .topbar-identity > span:last-child {
    display: none;
  }

  .topbar .site-brand-logo {
    width: 38px;
    height: 30px;
    flex-basis: 38px;
  }

  .topbar .site-brand-logo img {
    width: 45px;
    height: 45px;
    margin: -7px 0 0 -3px;
  }

  .topbar .site-brand-name {
    font-size: 14px;
    white-space: normal;
    line-height: 1.2;
  }

  .topbar > div:last-child {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    width: 100%;
    gap: 6px;
  }

  .topbar > div:last-child .button {
    width: 100%;
    min-width: 0;
  }

  .review-workspace-bar .workspace-actions {
    overflow-x: visible;
    flex-wrap: wrap;
  }

  .review-workspace-bar .export-menu-options {
    right: auto;
    left: 0;
  }

  .notification-card {
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .notification-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .notification-actions .button,
  .notification-actions form,
  .notification-actions button {
    flex: 1 1 132px;
  }

  .notification-actions button {
    width: 100%;
  }

  .task-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .task-tab {
    justify-content: center;
    padding-inline: 10px;
  }

  .tab-panel-heading {
    display: block;
  }

  .tab-panel-heading p {
    margin-top: 5px;
  }

  .task-status-filters {
    margin-top: 12px;
  }

  .reviewer-progress-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
  }

  .reviewer-progress-value {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .reviewer-progress-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .auth {
    min-height: 100dvh;
    padding: 40px max(14px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }

  .auth-panel,
  .auth-panel.wide {
    width: 100%;
    padding: 26px 20px;
    transform: none;
  }

  .auth-panel .site-brand {
    max-width: 100%;
    white-space: normal;
    line-height: 1.2;
  }

  .auth-panel .site-brand-name {
    font-size: 16px;
  }

  button,
  .button,
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    min-height: 20px;
    min-width: 20px;
  }

  .page {
    width: calc(100% - 24px);
    padding: 28px 0 max(48px, env(safe-area-inset-bottom));
  }

  .admin-section {
    padding: 14px;
  }

  .doctor-admin-table {
    border: 0;
    background: transparent;
  }

  .doctor-admin-row {
    background: rgba(223, 236, 226, 0.9);
  }

  .application-reply-card {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .doctor-directory-row.head {
    display: none;
  }

  .doctor-directory-row {
    grid-template-columns: 1fr;
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid rgba(32, 42, 56, 0.28);
  }

  .doctor-directory-row > div {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(32, 42, 56, 0.16);
    overflow-wrap: anywhere;
  }

  .doctor-directory-row > div:last-child {
    border-bottom: 0;
  }

  .doctor-directory-row > div::before {
    content: attr(data-label);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 700;
  }

  .save-status-banner {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

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

  .review-task-frame {
    margin: 6px;
    width: calc(100% - 12px);
  }
}

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

/* Workspace: secondary actions live in the "更多" menu. */
.workspace-more .export-menu-options button {
  min-height: 34px;
  justify-content: flex-start;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

.workspace-more .export-menu-options button:hover {
  background: #d2e5d6;
}

.workspace-more .export-menu-options .danger-text {
  color: var(--pen-red);
}

.save-status-banner.save-status-error {
  border-bottom-color: rgba(176, 52, 43, 0.5);
  background: #f6dcd6;
  color: var(--pen-red);
}

.save-status-banner a {
  color: inherit;
  font-weight: 700;
}

@media (max-width: 600px) {
  .review-workspace-bar .workspace-actions > *,
  .review-workspace-bar .workspace-actions > details > summary {
    flex: 1 1 auto;
    padding-left: 8px;
    padding-right: 8px;
    white-space: nowrap;
  }

  .review-workspace-bar .workspace-more .export-menu-options {
    right: 0;
    left: auto;
  }
}

/* Doctor dashboard on phones: shorter cards; full text stays on the task detail page. */
@media (max-width: 600px) {
  .review-dashboard .project-description {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
  }
}

/* Doctor dashboard tabs: 进行中 / 我的任务 / 已完成 */
.task-tabs {
  display: flex;
  gap: 2px;
  margin-top: 18px;
  border-bottom: 2px solid var(--ink);
}

.task-tabs [role="tab"] {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  border: 1px solid rgba(32, 42, 56, 0.32);
  border-bottom: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 700 15px/1.2 var(--ui);
  cursor: pointer;
}

.task-tabs [role="tab"] span {
  min-width: 24px;
  padding: 1px 6px;
  border: 1px solid currentColor;
  font: 12px/1.4 var(--mono);
  text-align: center;
}

.task-tabs [role="tab"][aria-selected="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.task-tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--ochre);
  outline-offset: 2px;
}

.task-tab-panel .task-state-section {
  margin-top: 14px;
}

/* "展开其余 N 个" fold used by the my-task groups */
.list-more > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 4px 0;
  color: var(--moss);
  font: 700 13px/1.4 var(--ui);
  cursor: pointer;
  list-style: none;
}

.list-more > summary::-webkit-details-marker {
  display: none;
}

.list-more > summary::before {
  content: "▸";
}

.list-more[open] > summary::before {
  content: "▾";
}

/* 我的任务 */
.my-task-group + .my-task-group {
  margin-top: 22px;
}

.my-task-group > header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(32, 42, 56, 0.4);
}

.my-task-group > header h3 {
  margin: 0;
  font-size: 17px;
}

.my-task-group > header span {
  min-width: 24px;
  padding: 1px 6px;
  border: 1px solid currentColor;
  font: 12px/1.4 var(--mono);
  text-align: center;
}

.my-task-list {
  display: grid;
  gap: 8px;
}

.my-task-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(32, 42, 56, 0.32);
  border-left: 6px solid #2f6674;
  background: #e3ecec;
}

.my-task-card.my-task-pending {
  border-left-color: var(--ochre);
  background: #efe6cf;
}

.my-task-card.my-task-completed {
  border-left-color: var(--moss);
  background: var(--paper-light);
}

.my-task-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.my-task-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.my-task-title a {
  overflow: hidden;
  color: var(--ink);
  font: 700 16px/1.35 var(--serif);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-task-title a:hover {
  text-decoration: underline;
}

.my-task-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  font: 12px/1.4 var(--ui);
}

.my-task-progress {
  width: 200px;
}

.my-task-progress .progress.compact {
  margin-top: 0;
}

.my-task-count,
.my-task-time {
  color: var(--ink-soft);
  font: 12px/1.4 var(--mono);
}

.my-task-actions {
  flex: 0 0 auto;
}

.my-task-empty {
  margin: 0;
  padding: 12px 0;
  color: var(--ink-soft);
  font: 13px/1.4 var(--ui);
}

@media (max-width: 600px) {
  .task-tabs [role="tab"] {
    flex: 1 1 0;
    justify-content: center;
    padding: 8px 6px;
    font-size: 14px;
  }

  .my-task-card {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .my-task-title a {
    white-space: normal;
  }

  .my-task-progress {
    width: min(200px, 55vw);
  }

  .my-task-actions .button {
    width: 100%;
    justify-content: center;
  }
}

.project-note {
  margin: 6px 0;
  padding: 6px 10px;
  border-left: 3px solid var(--ochre);
  background: rgba(246, 231, 196, 0.7);
  font: 13px/1.5 var(--ui);
}

details.doctor-directory-section > summary {
  cursor: pointer;
  list-style: none;
}

details.doctor-directory-section > summary::-webkit-details-marker {
  display: none;
}

details.doctor-directory-section > summary h1::after {
  content: " ▸";
  color: var(--ink-soft);
  font-size: 0.7em;
}

details.doctor-directory-section[open] > summary h1::after {
  content: " ▾";
}

.workspace-alert.peer {
  border-color: rgba(62, 107, 79, 0.36);
  background: var(--paper-light);
  color: var(--moss);
}

.people-status-row .people-results-link {
  margin-left: 10px;
  padding: 1px 8px;
  border: 1px solid var(--moss);
  color: var(--moss);
  font: 700 12px/1.6 var(--ui);
  text-decoration: none;
  white-space: nowrap;
}

.people-status-row .people-results-link:hover {
  background: #d2e5d6;
}
