:root {
  color-scheme: light;
  --ink: #172027;
  --muted: #66747d;
  --line: #dbe1e4;
  --surface: #ffffff;
  --canvas: #f3f5f4;
  --accent: #087f5b;
  --accent-dark: #056747;
  --soft-green: #e7f4ef;
  --danger: #b42318;
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: var(--canvas); }
button, input { font: inherit; }
.topbar { height: 72px; padding: 0 clamp(20px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; color: white; background: var(--ink); font-weight: 800; border-radius: 6px; }
.brand div { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 15px; }
.brand div span { margin-top: 4px; font-size: 9px; color: var(--muted); }
.local-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.local-status span { width: 8px; height: 8px; border-radius: 50%; background: #20a474; box-shadow: 0 0 0 3px var(--soft-green); }
.workspace { width: min(1120px, calc(100% - 40px)); min-height: calc(100vh - 126px); margin: 0 auto; display: grid; grid-template-columns: minmax(320px, 430px) 1fr; }
.control-panel { padding: 46px 46px 38px 0; border-right: 1px solid var(--line); }
.result-panel { min-width: 0; padding: 46px 0 38px 54px; display: flex; flex-direction: column; justify-content: center; }
.section-heading p { margin: 0 0 8px; color: var(--accent); text-transform: uppercase; font-size: 11px; font-weight: 800; }
.section-heading h1 { margin: 0 0 24px; font-size: 24px; line-height: 1.35; letter-spacing: 0; }
.dropzone { min-height: 172px; padding: 25px; border: 1.5px dashed #aab5ba; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fafbfb; cursor: pointer; transition: border-color .18s, background .18s; text-align: center; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: #f3faf7; }
.dropzone.has-file { border-style: solid; border-color: var(--accent); background: var(--soft-green); }
.dropzone input { position: absolute; opacity: 0; pointer-events: none; }
.upload-symbol { width: 34px; height: 34px; display: grid; place-items: center; margin-bottom: 12px; border: 1px solid #b9c2c6; border-radius: 50%; font-size: 20px; }
.dropzone strong { max-width: 100%; font-size: 15px; overflow-wrap: anywhere; }
.dropzone > span:last-child { margin-top: 7px; color: var(--muted); font-size: 11px; }
.setting-group { margin-top: 26px; }
.setting-label { margin-bottom: 9px; font-size: 12px; font-weight: 700; }
.segmented { height: 42px; padding: 3px; display: grid; grid-template-columns: 1fr 1fr; background: #e8ecec; border-radius: 6px; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { height: 36px; display: grid; place-items: center; border-radius: 4px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.segmented input:checked + span { color: var(--ink); background: white; box-shadow: 0 1px 3px rgba(23,32,39,.12); }
.setting-note { min-height: 18px; margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.toggle-row { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.toggle-row:first-of-type { margin-top: 14px; border-top: 1px solid var(--line); }
.toggle-row div { display: flex; flex-direction: column; gap: 3px; }
.toggle-row strong { font-size: 12px; }
.toggle-row div span { color: var(--muted); font-size: 10px; }
.custom-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.custom-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.custom-heading > div { display: flex; flex-direction: column; gap: 3px; }
.custom-heading strong { font-size: 12px; }
.custom-heading div span, .region-summary { color: var(--muted); font-size: 10px; }
.icon-button { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; border: 1px solid #bfc8cc; border-radius: 5px; color: var(--ink); background: white; cursor: pointer; font-size: 20px; }
.icon-button:disabled { opacity: .45; cursor: not-allowed; }
.replacement-list { display: flex; flex-direction: column; gap: 8px; }
.replacement-row { margin-top: 10px; display: grid; grid-template-columns: 1fr 26px 1fr 32px; gap: 6px; align-items: center; }
.replacement-row input { width: 100%; min-width: 0; height: 36px; padding: 0 9px; border: 1px solid #c7d0d4; border-radius: 5px; background: white; font-size: 11px; }
.replacement-row > span { color: var(--muted); text-align: center; }
.replacement-row .icon-button { font-size: 16px; color: var(--danger); }
.compact { min-height: 34px; padding: 0 12px; font-size: 11px; }
.region-summary { margin-top: 9px; }
.switch input { position: absolute; opacity: 0; }
.switch > span { width: 36px; height: 20px; display: block; padding: 2px; border-radius: 12px; background: #aeb8bd; cursor: pointer; transition: background .18s; }
.switch > span::after { content: ""; width: 16px; height: 16px; display: block; border-radius: 50%; background: white; transition: transform .18s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.primary, .secondary { min-height: 44px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; border: 0; font-weight: 800; font-size: 13px; text-decoration: none; cursor: pointer; }
button.primary { width: 100%; margin-top: 26px; color: white; background: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.primary:disabled { background: #aeb8bd; cursor: not-allowed; }
.empty-state { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.empty-state strong { margin-top: 19px; color: var(--ink); font-size: 15px; }
.empty-state > span { margin-top: 6px; font-size: 11px; }
.document-shape { width: 94px; height: 116px; padding: 35px 20px; border: 1px solid #cbd2d6; border-radius: 5px; background: white; box-shadow: 10px 10px 0 #e4e8e8; }
.document-shape span { display: block; height: 5px; margin-bottom: 10px; background: #dfe4e6; border-radius: 2px; }
.document-shape span:nth-child(2) { width: 75%; }
.hidden { display: none !important; }
.progress-state, .complete-state, .error-state { width: min(100%, 560px); margin: 0 auto; }
.result-heading { display: flex; align-items: center; gap: 14px; }
.result-heading > span { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 5px; color: var(--danger); background: #fcedeb; font-size: 10px; font-weight: 900; }
.result-heading div { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.result-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-heading small { color: var(--muted); }
.progress-track { height: 7px; margin: 30px 0 12px; overflow: hidden; background: #dfe4e4; border-radius: 4px; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .35s; }
.progress-number { display: flex; align-items: baseline; justify-content: space-between; }
.progress-number strong { font-size: 28px; }
.progress-number span { color: var(--muted); font-size: 11px; }
.success-line { display: flex; align-items: center; gap: 13px; }
.success-line > span { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--accent); font-weight: 900; }
.success-line div { display: flex; flex-direction: column; gap: 4px; }
.success-line strong { font-size: 19px; }
.success-line small { color: var(--muted); }
.summary-strip { margin-top: 27px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.summary-strip div { padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 5px; border-right: 1px solid var(--line); }
.summary-strip div:last-child { border-right: 0; }
.summary-strip span { color: var(--muted); font-size: 10px; }
.summary-strip strong { font-size: 22px; }
.entity-section { margin-top: 25px; }
.entity-title { display: flex; justify-content: space-between; align-items: center; }
.entity-title strong { font-size: 13px; }
.entity-title span { color: var(--muted); font-size: 10px; }
.entity-list { margin-top: 10px; max-height: 154px; overflow: auto; border-top: 1px solid var(--line); }
.entity-row { min-height: 42px; display: grid; grid-template-columns: 100px 1fr 42px; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); font-size: 11px; }
.entity-row span:first-child { color: var(--muted); }
.entity-row code { color: var(--ink); font-family: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entity-row b { text-align: right; font-weight: 700; }
.entity-empty { padding: 18px 0; color: var(--muted); font-size: 11px; }
.actions { margin-top: 26px; display: grid; grid-template-columns: 1fr 120px; gap: 10px; }
.download { color: white; background: var(--accent); }
.secondary { color: var(--ink); border: 1px solid #bfc8cc; background: white; }
.text-button { width: 100%; margin-top: 13px; padding: 8px; border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 11px; }
.error-state { text-align: center; }
.error-state > span { width: 42px; height: 42px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--danger); font-weight: 900; }
.error-state p { color: var(--muted); line-height: 1.6; font-size: 12px; }
.error-state .secondary { margin-top: 10px; padding: 0 24px; }
footer { min-height: 54px; padding: 0 20px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 24px; border-top: 1px solid var(--line); color: #89949a; background: #edf0ef; font-size: 9px; }
.modal { position: fixed; inset: 0; z-index: 20; padding: 24px; display: grid; place-items: center; background: rgba(23,32,39,.72); }
.modal-dialog { width: min(900px, 100%); max-height: calc(100vh - 48px); padding: 18px; display: flex; flex-direction: column; border-radius: 8px; background: var(--surface); }
.modal-header, .page-toolbar, .modal-actions { display: flex; align-items: center; }
.modal-header { justify-content: space-between; }
.modal-header > div { display: flex; flex-direction: column; gap: 4px; }
.modal-header span, .modal-actions span { color: var(--muted); font-size: 11px; }
.page-toolbar { min-height: 48px; gap: 8px; border-bottom: 1px solid var(--line); }
.page-toolbar > span { min-width: 84px; text-align: center; font-size: 11px; }
.page-toolbar .compact { margin-left: auto; }
.preview-loading { min-height: 380px; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.preview-stage { position: relative; align-self: center; min-height: 0; max-width: 100%; overflow: auto; background: #cfd5d6; touch-action: none; }
.preview-stage img { max-width: 100%; max-height: calc(100vh - 220px); display: block; user-select: none; pointer-events: none; }
.selection-layer { position: absolute; inset: 0; cursor: crosshair; }
.region-box { position: absolute; border: 2px solid #e03131; background: rgba(224,49,49,.22); }
.region-box button { position: absolute; top: -12px; right: -12px; width: 23px; height: 23px; padding: 0; border: 0; border-radius: 50%; color: white; background: #c92a2a; cursor: pointer; line-height: 1; }
.draft-region { position: absolute; border: 1px dashed #c92a2a; background: rgba(224,49,49,.14); pointer-events: none; }
.modal-actions { min-height: 54px; justify-content: space-between; padding-top: 10px; }
.modal-actions .primary { min-width: 110px; min-height: 38px; }
@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 18px; }
  .workspace { width: 100%; min-height: auto; display: block; }
  .control-panel { padding: 28px 20px 30px; border-right: 0; border-bottom: 1px solid var(--line); }
  .result-panel { min-height: 420px; padding: 34px 20px; }
  .section-heading h1 { font-size: 21px; }
  .dropzone { min-height: 150px; }
  .replacement-row { grid-template-columns: 1fr 22px 1fr 32px; }
  .modal { padding: 0; }
  .modal-dialog { width: 100%; height: 100vh; max-height: none; border-radius: 0; }
  footer { gap: 12px; }
}
