:root {
  --viewer: #2b2b2b;
  --toolbar: #1f1f1f;
  --toolbar-line: #494949;
  --paper: #ffffff;
  --ink: #111111;
  --muted: #666666;
  --rule: #202020;
  --focus: #76b900;
  --font: Arial, "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--viewer); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--viewer);
  font-family: var(--font);
}

button, select { font: inherit; }

button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.viewer-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: 44px minmax(180px, 520px) 74px 44px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 7px 16px;
  color: #ffffff;
  background: var(--toolbar);
  border-bottom: 1px solid var(--toolbar-line);
}

.page-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: #ffffff;
  background: transparent;
  border: 1px solid #676767;
  border-radius: 2px;
  font-size: 20px;
  cursor: pointer;
}

.page-button:disabled {
  color: #666666;
  border-color: #3d3d3d;
  cursor: default;
}

.module-picker select {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 14px;
  color: #ffffff;
  background: #303030;
  border: 1px solid #676767;
  border-radius: 2px;
  font-weight: 700;
}

.page-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 44px;
  color: #d4d4d4;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.viewer-stage {
  display: flex;
  justify-content: center;
  padding: 30px 18px 56px;
}

.catalog-page {
  width: min(100%, 920px);
  min-height: 1301px;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .38);
}

.diagram-frame {
  position: relative;
  margin: 0 14px;
  overflow: hidden;
  background: var(--paper);
  border: 2px solid var(--rule);
}

.diagram-frame img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1761 / 834;
  object-fit: contain;
  background: var(--paper);
}

.parts-table-wrap {
  margin: 0 14px;
}

.parts-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  border: 2px solid var(--rule);
  border-top: 0;
  font-size: 14px;
  line-height: 1.25;
}

.parts-table th,
.parts-table td {
  padding: 5px 7px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid #b9b9b9;
  vertical-align: middle;
}

.parts-table th:last-child,
.parts-table td:last-child { border-right: 0; }

.parts-table tbody tr:last-child td { border-bottom: 0; }

.parts-table th {
  height: 38px;
  padding-block: 7px;
  background: #ffffff;
  border-bottom: 2px solid var(--rule);
  font-size: 14px;
  font-weight: 400;
  text-align: center;
}

.parts-table td:nth-child(1),
.parts-table td:nth-child(2),
.parts-table td:nth-child(5) {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.parts-table td:nth-child(2),
.parts-table td:nth-child(3),
.parts-table td:nth-child(4),
.parts-table td:nth-child(5) { font-weight: 700; }

.col-ref { width: 7%; }
.col-code { width: 15%; }
.col-zh { width: 25%; }
.col-en { width: 45%; }
.col-qty { width: 8%; }

.page-footer {
  display: flex;
  justify-content: space-between;
  padding: 16px 18px 24px;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 680px) {
  .viewer-bar {
    grid-template-columns: 40px minmax(0, 1fr) 56px 40px;
    gap: 6px;
    min-height: 52px;
    padding: 6px 8px;
  }

  .page-button { width: 40px; height: 40px; }
  .module-picker select { height: 40px; padding-inline: 10px 26px; font-size: 12px; }
  .page-indicator { height: 40px; gap: 3px; font-size: 11px; }
  .viewer-stage { padding: 8px 5px 24px; }
  .catalog-page { min-height: calc((100vw - 10px) * 1.414); box-shadow: none; }
  .diagram-frame, .parts-table-wrap { margin-inline: 5px; }
  .diagram-frame { border-width: 1px; }
  .parts-table { border-width: 1px; font-size: 9px; }
  .parts-table th { height: 30px; padding: 4px 2px; border-bottom-width: 1px; font-size: 9px; }
  .parts-table td { padding: 4px 3px; overflow-wrap: anywhere; }
  .col-ref { width: 9%; }
  .col-code { width: 17%; }
  .col-zh { width: 25%; }
  .col-en { width: 41%; }
  .col-qty { width: 8%; }
  .page-footer { padding: 10px 7px 14px; font-size: 9px; }
}

@media print {
  html, body { background: #ffffff; }
  .viewer-bar { display: none; }
  .viewer-stage { padding: 0; }
  .catalog-page { width: 100%; min-height: 100vh; box-shadow: none; }
}
