:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #1f2a22;
  background: #eef1ec;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #eef1ec; }
button, input, select { font: inherit; }

.app-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 28px auto;
  background: #fff;
  border: 1px solid #dce2da;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(29, 47, 34, .09);
}

.topbar {
  height: 76px;
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e3e7e1;
}
.topbar h1 { margin: 0; font-size: 21px; line-height: 1.2; letter-spacing: 0; }
.topbar p { margin: 4px 0 0; color: #7a857c; font-size: 13px; }
.local-mark { padding: 6px 9px; border: 1px solid #c9d4c8; border-radius: 5px; color: #59705e; font-size: 12px; }

.workspace { min-height: 690px; display: grid; grid-template-columns: 390px minmax(0, 1fr); }
.controls { padding: 26px; border-right: 1px solid #e3e7e1; background: #fbfcfa; }
.field { margin: 0 0 20px; padding: 0; border: 0; }
.field > label, .field legend, .two-columns label { display: block; margin-bottom: 8px; color: #4f5d52; font-size: 13px; font-weight: 700; }

input[type="text"], input[type="url"], select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #cfd7cd;
  border-radius: 5px;
  color: #1f2a22;
  background: #fff;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
}
input[type="text"]:focus, input[type="url"]:focus, select:focus { border-color: #367444; box-shadow: 0 0 0 3px rgba(54, 116, 68, .12); }
input[type="file"] { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }

.upload-box {
  min-height: 96px;
  padding: 15px;
  display: grid !important;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 12px;
  border: 1px dashed #abb9a9;
  border-radius: 6px;
  background: #f6f8f4;
  cursor: pointer;
}
.upload-box:hover { border-color: #367444; }
.upload-icon { grid-row: 1 / 3; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; color: #fff; background: #326b3e; font-size: 24px; font-weight: 400; }
.upload-box strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-box > span:last-child { color: #819084; font-size: 12px; font-weight: 400; }

.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segment { height: 42px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border: 1px solid #cfd7cd; border-radius: 6px; background: #eef2ec; }
.segment label { margin: 0; cursor: pointer; }
.segment input { position: absolute; opacity: 0; }
.segment span { height: 34px; display: grid; place-items: center; border-radius: 4px; color: #68746a; font-size: 13px; }
.segment input:checked + span { color: #1f5f31; background: #fff; box-shadow: 0 1px 4px rgba(31, 55, 37, .13); font-weight: 700; }

.switch-row { align-self: end; height: 42px; margin: 0 !important; padding: 0 10px; display: flex !important; align-items: center; justify-content: space-between; border: 1px solid #cfd7cd; border-radius: 5px; background: #fff; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { position: relative; width: 34px; height: 20px; border-radius: 10px; background: #b7c0b7; transition: background .15s; }
.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch-row input:checked + i { background: #367444; }
.switch-row input:checked + i::after { transform: translateX(14px); }

.primary-button, .download-button { height: 44px; display: grid; place-items: center; border: 0; border-radius: 5px; color: #fff; background: #2f6d3d; font-weight: 700; text-decoration: none; cursor: pointer; }
.primary-button { width: 100%; }
.primary-button:hover, .download-button:hover { background: #255c32; }
.primary-button:disabled { opacity: .55; cursor: wait; }
.error-message { min-height: 18px; margin: 10px 0 0; color: #b33a32; font-size: 12px; line-height: 1.5; }

.preview-panel { min-width: 0; padding: 26px; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 18px; background: #f1f3ef; }
.preview-stage { position: relative; min-height: 540px; display: grid; place-items: center; overflow: hidden; border: 1px solid #d9dfd7; border-radius: 6px; background-color: #e7ebe5; background-image: linear-gradient(45deg, #dfe4dd 25%, transparent 25%), linear-gradient(-45deg, #dfe4dd 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #dfe4dd 75%), linear-gradient(-45deg, transparent 75%, #dfe4dd 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; }
.preview-stage canvas { display: none; width: min(560px, calc(100% - 40px)); aspect-ratio: 1; background: #fff; box-shadow: 0 12px 34px rgba(28, 42, 31, .16); }
.preview-stage canvas.visible { display: block; }
.preview-stage canvas.source-preview { opacity: .72; }
.empty-state { text-align: center; color: #758078; }
.empty-state strong { display: block; margin-top: 8px; font-size: 14px; }
.empty-symbol { font-size: 45px; color: #9ba69d; }

.loading-state { position: absolute; inset: 0; display: none; place-items: center; align-content: center; gap: 14px; color: #324638; background: rgba(244, 247, 242, .88); backdrop-filter: blur(3px); }
.loading-state.visible { display: grid; }
.loading-state strong { font-size: 14px; }
.spinner { width: 34px; height: 34px; border: 3px solid #c7d2c6; border-top-color: #2f6d3d; border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-bar { min-height: 66px; padding: 12px 14px; display: none; grid-template-columns: minmax(150px, 1fr) auto 120px; align-items: center; gap: 14px; border: 1px solid #d4ddd2; border-radius: 6px; background: #fff; }
.result-bar.visible { display: grid; }
.result-copy strong { display: block; font-size: 14px; color: #235d32; }
.result-copy span { display: block; margin-top: 4px; color: #7b877d; font-size: 12px; }
.result-bar.warning .result-copy strong { color: #a45a18; }
.scan-list { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.scan-chip { padding: 5px 7px; border-radius: 4px; color: #637066; background: #edf2eb; font-size: 11px; }
.scan-chip b { color: #23703a; }
.scan-chip.failed { background: #fff1e4; }
.scan-chip.failed b { color: #b14f16; }
.download-button { height: 38px; font-size: 13px; }

@media (max-width: 900px) {
  .app-shell { width: 100%; margin: 0; border: 0; border-radius: 0; }
  .workspace { grid-template-columns: 1fr; }
  .controls { border-right: 0; border-bottom: 1px solid #e3e7e1; }
  .preview-stage { min-height: 400px; }
  .result-bar { grid-template-columns: 1fr auto; }
  .scan-list { grid-column: 1 / 3; justify-content: flex-start; }
}

@media (max-width: 520px) {
  .app-shell { min-height: 100vh; }
  .topbar, .controls, .preview-panel { padding-left: 18px; padding-right: 18px; }
  .two-columns { grid-template-columns: 1fr; }
  .preview-stage { min-height: 330px; }
  .preview-stage canvas { width: calc(100% - 20px); }
  .result-bar { grid-template-columns: 1fr; }
  .scan-list { grid-column: auto; justify-content: flex-start; }
}
