:root {
  color-scheme: light;
  --ink: #163235;
  --muted: #5c7476;
  --line: #cbd9d8;
  --soft: #f3f8f7;
  --panel: #fff;
  --brand: #19665d;
  --brand-dark: #104a44;
  --warn: #b7612d;
  --page: #eaf0ef;
  --gold: #a96f21;
  --blue: #28617c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans TC", "Segoe UI", sans-serif;
  line-height: 1.55;
}

a { color: var(--blue); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: #143f3c;
  color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}

.brand {
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
}

.brand span { color: #bed9d3; font-weight: 520; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions > span { color: #c6dfda; font-size: 13px; }
.top-actions .top-status { color: #fff; }

.primary, .secondary, .editor-tools button, .new-document, .upload-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 7px 12px;
  font-weight: 750;
}

.primary { background: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-dark); }
.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.top-link { text-decoration: none; }
button:disabled { cursor: not-allowed; opacity: .48; }

.shell {
  min-height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  padding: 20px 16px;
  background: #f7fbfa;
  border-right: 1px solid var(--line);
}

.search { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 750; }
.search input, .metadata input, .review-note {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 9px;
  background: #fff;
  color: var(--ink);
}

.metadata input[readonly] { background: #fbfdfc; }
.filters { margin: 16px 0; display: grid; gap: 5px; }
.filters button, .filters a {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  padding: 7px 8px;
  text-align: left;
  text-decoration: none;
}

.filters button.active, .filters button:hover, .filters a.active, .filters a:hover {
  background: #dcece9;
  color: #124e48;
  font-weight: 750;
}

.new-document {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  border-color: #a9cbc5;
  background: #e6f2ef;
  color: #135a52;
  text-decoration: none;
}

.sidebar-note { margin: 18px 2px; color: var(--muted); font-size: 13px; }
.workspace { min-width: 0; padding: 28px clamp(18px, 4vw, 52px) 70px; }
.dashboard { max-width: 1180px; margin: 0 auto; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; }
.eyebrow { margin: 0 0 3px; color: #49706d; font-size: 13px; font-weight: 780; }
.page-heading h1 { margin: 0; font-size: 28px; }
.count { color: var(--muted); }

.reading-progress {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.reading-progress > div {
  padding: 11px 13px;
  border: 1px solid #cfe0dd;
  border-radius: 6px;
  background: #f6fbfa;
}

.reading-progress strong { display: block; color: #1a5f57; }
.reading-progress span { color: var(--muted); font-size: 13px; }
.progress { height: 8px; margin: 0 0 20px; border-radius: 99px; background: #d8e5e2; overflow: hidden; }
.progress > span { display: block; width: 0; height: 100%; background: var(--brand); transition: width .25s ease; }

.course-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 12px;
}

.course-card {
  display: grid;
  gap: 10px;
  min-height: 148px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(20, 50, 53, .04);
}

.course-card:hover { border-color: #83aca6; box-shadow: 0 4px 12px rgba(20, 50, 53, .08); }
.course-card.is-confirmed { border-left: 4px solid #4b9c73; }
.course-card.is-draft { border-left: 4px solid #c38b3b; }
.course-card h2 { margin: 0; font-size: 17px; line-height: 1.35; }
.course-card p { margin: 0; color: var(--muted); font-size: 13px; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: auto; }
.card-flags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { border-radius: 99px; padding: 3px 7px; background: #edf4f3; color: #315d5a; font-size: 12px; font-weight: 750; }
.tag.major { background: #fff0e6; color: #965024; }
.tag.na { background: #edf0f2; color: #59676d; }
.tag.minor { background: #e8f4f7; color: #236c7f; }
.tag.draft { background: #fff3df; color: #8a5a17; }
.tag.confirmed { background: #e9f6ed; color: #347151; }
.open-link { color: #1a5f57; font-size: 13px; font-weight: 750; text-decoration: none; }

.notice { border-left: 4px solid var(--warn); background: #fff5ed; padding: 11px 13px; }
.hidden { display: none !important; }

.editor { max-width: 1040px; margin: 0 auto; }
.editor-header { display: flex; align-items: center; gap: 12px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.icon-button {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-size: 21px;
  text-decoration: none;
}

.editor-title { min-width: 0; flex: 1; }
.editor-title h1 { margin: 0; color: var(--ink); font-size: 22px; font-weight: 800; line-height: 1.3; }
.metadata { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.metadata label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 750; }
.editor-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.editor-tools button, .upload-button { border-color: #a9cbc5; background: #e6f2ef; color: #135a52; cursor: pointer; }
.source-notice { margin: 12px 0; padding: 11px 13px; border-left: 4px solid #698b87; background: #f4f7f7; color: #415f5e; font-size: 14px; }
.progress-notice { display: flex; gap: 10px; margin: 12px 0; padding: 10px 12px; border: 1px solid #c9dce8; background: #f2f8fc; color: #3d5e71; font-size: 14px; }
.progress-notice span { color: #577582; }

.document-body {
  min-height: 55vh;
  padding: clamp(18px, 3vw, 38px);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  outline: 2px solid transparent;
  outline-offset: 3px;
}

.document-body:focus { outline-color: #78aaa3; }
.document-body h2 { margin: 0 0 12px; font-size: 20px; }
.document-body h3 { margin: 15px 0 6px; color: #1b5e58; font-size: 15px; }
.document-body p, .document-body li { line-height: 1.75; }
.document-body img { max-width: 100%; height: auto; border-radius: 4px; }
.document-body figure { margin: 18px 0; }

.official-content { box-shadow: 0 1px 2px rgba(20, 50, 53, .04); }
.zixin-standard { margin: 0 0 18px; padding: 18px; border: 1px solid #b9d7d0; border-radius: 5px; background: #f2faf7; }
.zixin-standard h2 { color: var(--brand-dark); }
.source-reference { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
details.reference { padding: 12px 14px; border: 1px solid var(--line); border-radius: 5px; background: #fafcfb; }
details.reference summary { cursor: pointer; font-weight: 800; }
.sop-card { margin: 0 0 18px; padding: 18px; border: 1px solid #d7e4e2; border-radius: 5px; }
.section-heading { display: flex; gap: 10px; align-items: baseline; }
.section-heading h2 { margin: 0; }
.section-heading span { color: var(--brand); font-weight: 800; }
.content-block { margin-top: 12px; }
.content-block h3 { color: var(--brand-dark); }
.section-source { margin-top: 10px; color: var(--muted); font-size: 12px; }

.attachment-gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.attachment-gallery figure { margin: 0; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: #fff; overflow: hidden; }
.attachment-gallery img, .sop-visuals img { display: block; width: 100%; height: auto; object-fit: contain; }
.attachment-gallery figcaption { padding-top: 6px; color: var(--muted); font-size: 12px; }
.file-links, .external-links { display: flex; flex-direction: column; gap: 8px; }
.file-links a { padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; }
.external-links a { word-break: break-all; }
.table-wrap { overflow-x: auto; }
.official-content table { width: 100%; min-width: 760px; border-collapse: collapse; }
.official-content th, .official-content td { padding: 8px 10px; border: 1px solid var(--line); vertical-align: top; }
.official-content th { background: #e7f1ec; color: var(--brand-dark); }
.official-content .sheet-title { background: var(--brand); color: #fff; text-align: center; }
.official-content .abbr { font-weight: 800; text-align: center; }

.review-panel { margin-top: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: #f7fbfa; }
.review-panel h2 { margin: 0 0 10px; font-size: 18px; }
.review-note { min-height: 92px; resize: vertical; }
.review-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

@media (max-width: 760px) {
  .topbar { height: auto; min-height: 58px; padding: 9px 12px; }
  .brand span { display: none; }
  .top-actions > span:not(.top-status) { display: none; }
  .shell { display: block; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace { padding: 20px 14px 60px; }
  .course-list, .reading-progress, .metadata, .attachment-gallery { grid-template-columns: 1fr; }
  .editor-header { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: start; gap: 10px; }
  .editor-header .icon-button { grid-column: 1; grid-row: 1; }
  .editor-title { grid-column: 2 / 4; grid-row: 1; width: 100%; }
  .editor-header .secondary { grid-column: 1 / 3; grid-row: 2; }
  .editor-header .primary { grid-column: 3; grid-row: 2; }
  .document-body { padding: 18px; }
  .progress-notice { display: grid; }
}

@media print {
  body { background: #fff; }
  .topbar, .sidebar, .editor-header, .metadata, .editor-tools, .source-notice, .progress-notice, .review-panel { display: none !important; }
  .shell, .workspace { display: block; min-height: 0; padding: 0; }
  .editor { max-width: none; }
  .document-body { min-height: 0; padding: 0; border: 0; box-shadow: none; outline: 0; }
  details.reference { display: block; }
  details.reference > summary { display: none; }
}
