:root {
  color-scheme: light;
  --ink: #20231e;
  --muted: #646a60;
  --paper: #f3f1e8;
  --panel: #fbfaf5;
  --line: #cbc9bd;
  --accent: #d84f2a;
  --accent-dark: #a93216;
  --green: #175b4a;
  --border-box: #3b73c6;
  --table-box: #9d5cc2;
  --notes-box: #dc8c1c;
  --iso-box: #d94141;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC",
    system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(32, 35, 30, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(32, 35, 30, 0.045) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  min-height: 68px;
  padding: 0 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 241, 232, 0.92);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.wordmark,
.quiet-link {
  color: var(--ink);
  text-decoration: none;
}

.wordmark {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.wordmark-mark {
  width: 25px;
  height: 25px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  position: relative;
}

.wordmark-mark::before,
.wordmark-mark::after {
  content: "";
  position: absolute;
  background: var(--accent);
}

.wordmark-mark::before {
  width: 33px;
  height: 2px;
  left: -6px;
  top: 10px;
}

.wordmark-mark::after {
  width: 2px;
  height: 33px;
  left: 10px;
  top: -6px;
}

.quiet-link,
.text-button {
  font-size: 0.88rem;
  color: var(--muted);
}

.shell {
  width: min(1460px, 94vw);
  margin: 0 auto;
  padding: 70px 0 100px;
}

.hero {
  max-width: 980px;
  padding: 2vw 0 74px;
}

.eyebrow,
.kicker {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1 {
  max-width: 850px;
  margin: 0;
  font-size: clamp(3rem, 7.5vw, 7rem);
  line-height: 0.96;
  letter-spacing: -0.055em;
}

.hero-copy {
  max-width: 680px;
  margin: 28px 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  line-height: 1.8;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.facts span {
  padding: 8px 13px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--panel);
}

.panel {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(35, 38, 31, 0.07);
}

.section-number {
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  color: var(--accent);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-weight: 800;
  font-size: 1.15rem;
}

.section-body {
  min-width: 0;
  padding: clamp(24px, 4vw, 54px);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  align-items: end;
  margin-bottom: 34px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3.2vw, 3rem);
  letter-spacing: -0.035em;
}

.section-heading > p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.92rem;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 130px auto;
  gap: 14px;
  align-items: stretch;
}

.file-drop {
  min-height: 104px;
  padding: 18px 22px;
  display: flex;
  gap: 16px;
  align-items: center;
  border: 1.5px dashed #94978c;
  border-radius: 14px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.file-drop:hover,
.file-drop.is-dragging {
  border-color: var(--accent);
  background: #fff6ef;
}

.file-drop input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-icon {
  width: 50px;
  height: 58px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 4px 10px 4px 4px;
  font-size: 0.68rem;
  font-weight: 900;
  color: var(--accent);
}

.file-drop strong,
.file-drop small {
  display: block;
}

.file-drop small {
  margin-top: 7px;
  color: var(--muted);
}

.page-field {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.page-field span,
.manual-box label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.page-field input,
.manual-box select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
}

.primary-button,
.secondary-button {
  border-radius: 11px;
  padding: 13px 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 780;
  cursor: pointer;
}

.primary-button {
  color: white;
  background: var(--accent);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.primary-button:hover {
  background: var(--accent-dark);
}

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

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.text-button {
  padding: 3px;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  cursor: pointer;
}

.status-box {
  margin-top: 16px;
  padding: 13px 16px;
  border-left: 4px solid var(--green);
  background: #e8f2ed;
  line-height: 1.55;
}

.status-box.is-error {
  border-left-color: var(--accent);
  background: #fbe9e4;
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, 0.75fr);
  gap: 26px;
}

.preview-column,
.candidate-column {
  min-width: 0;
}

.preview-toolbar,
.candidate-summary {
  min-height: 40px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 15px;
  font-size: 0.74rem;
  color: var(--muted);
}

.legend span::before {
  content: "";
  width: 9px;
  height: 9px;
  margin-right: 6px;
  display: inline-block;
  border-radius: 2px;
  background: currentColor;
}

.legend-border {
  color: var(--border-box);
}

.legend-table {
  color: var(--table-box);
}

.legend-notes {
  color: var(--notes-box);
}

.legend-isometric {
  color: var(--iso-box);
}

.preview-viewport {
  min-height: 420px;
  max-height: 74vh;
  padding: 18px;
  overflow: auto;
  display: grid;
  place-items: start center;
  border: 1px solid #b9b8af;
  background: #d7d6cf;
  background-image:
    linear-gradient(45deg, #cccbc4 25%, transparent 25%),
    linear-gradient(-45deg, #cccbc4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #cccbc4 75%),
    linear-gradient(-45deg, transparent 75%, #cccbc4 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.preview-stage {
  width: max-content;
  max-width: 100%;
  position: relative;
  line-height: 0;
  background: white;
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.16);
}

.preview-stage img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: calc(74vh - 38px);
}

#region-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: none;
}

#region-overlay.is-drawing {
  cursor: crosshair;
}

#region-overlay rect {
  vector-effect: non-scaling-stroke;
  stroke-width: 2;
  cursor: pointer;
}

#region-overlay rect.is-unselected {
  fill-opacity: 0.04;
  stroke-dasharray: 6 4;
  opacity: 0.55;
}

#region-overlay rect.category-border {
  fill: var(--border-box);
  stroke: var(--border-box);
  fill-opacity: 0.18;
}

#region-overlay rect.category-table {
  fill: var(--table-box);
  stroke: var(--table-box);
  fill-opacity: 0.18;
}

#region-overlay rect.category-technical_requirements {
  fill: var(--notes-box);
  stroke: var(--notes-box);
  fill-opacity: 0.2;
}

#region-overlay rect.category-isometric,
#region-overlay rect.category-manual {
  fill: var(--iso-box);
  stroke: var(--iso-box);
  fill-opacity: 0.18;
}

#region-overlay rect.draft-region {
  fill: var(--accent);
  stroke: var(--accent);
  fill-opacity: 0.16;
  stroke-dasharray: 4 3;
}

.preview-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.candidate-summary {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-weight: 750;
}

.candidate-list {
  max-height: 470px;
  overflow: auto;
  padding-right: 5px;
}

.candidate-item {
  padding: 12px 4px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
  border-bottom: 1px solid #deddd5;
}

.candidate-item input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

.candidate-item strong,
.candidate-item small {
  display: block;
}

.candidate-item strong {
  font-size: 0.9rem;
}

.candidate-item small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.candidate-item .remove-button {
  padding: 0;
  border: 0;
  color: var(--accent-dark);
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
}

.manual-box {
  margin-top: 20px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #f2f0e7;
}

.manual-box label {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.manual-actions {
  margin-top: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.secondary-button[aria-pressed="true"] {
  border-color: var(--accent);
  color: white;
  background: var(--accent);
}

.source-proof {
  margin: 18px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: ui-monospace, "Cascadia Mono", monospace;
  font-size: 0.7rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.full-button {
  width: 100%;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
  gap: 30px;
  align-items: start;
}

.result-preview {
  min-height: 280px;
  padding: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #deddd5;
}

.result-preview img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.result-checks {
  padding: 18px;
  border-left: 4px solid var(--green);
  background: #e8f2ed;
  line-height: 1.8;
}

.batch-results {
  display: grid;
  gap: 9px;
  margin-bottom: 18px;
}

.batch-result-item {
  display: grid;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  font-size: 0.82rem;
}

.batch-result-item.is-error {
  border-left: 4px solid #a8362d;
  color: #7c2923;
}

.batch-result-links {
  display: flex;
  gap: 14px;
}

.batch-result-links a {
  color: var(--accent);
  font-weight: 700;
}

.result-checks strong {
  display: block;
  font-size: 1.2rem;
}

.download-actions {
  margin: 22px 0;
  display: grid;
  gap: 10px;
}

.result-copy > p {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.7;
}

.result-stage-heading {
  margin: 0 0 22px;
}

.result-stage-heading h3 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  letter-spacing: -0.025em;
}

.result-stage-heading > p:last-child {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.view-segmentation {
  margin-top: 54px;
  padding-top: 42px;
  border-top: 1px solid var(--line);
}

.views-overview {
  min-height: 280px;
  padding: 16px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #deddd5;
}

.views-overview img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  background: white;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.views-summary {
  margin: 16px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--green);
  background: #e8f2ed;
  color: #23463d;
  line-height: 1.7;
}

.view-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.view-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.view-card img {
  width: 100%;
  height: 210px;
  display: block;
  object-fit: contain;
  border: 1px solid #deddd5;
  background: white;
}

.view-card > div {
  padding: 12px 4px 2px;
}

.view-card strong,
.view-card span,
.view-card a {
  display: block;
}

.view-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.view-card a {
  margin-top: 10px;
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

.view-downloads {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

footer {
  min-height: 86px;
  padding: 24px 4vw;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  background: var(--paper);
}

[hidden] {
  display: none !important;
}

@media (max-width: 1000px) {
  .review-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .candidate-list {
    max-height: none;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(94vw, 680px);
    padding-top: 42px;
  }

  .hero {
    padding-bottom: 48px;
  }

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

  .section-number {
    padding: 14px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .section-heading {
    display: block;
  }

  .section-heading > p {
    margin-top: 12px;
  }

  .upload-form {
    grid-template-columns: 1fr;
  }

  .page-field {
    min-height: 84px;
  }

  .preview-viewport {
    min-height: 260px;
    padding: 9px;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
  }
}
