:root {
  color-scheme: light;
  --paper: #f6f7f8;
  --ink: #24313b;
  --muted: #707b83;
  --red: #b8322b;
  --line: #e2e6e9;
  --blue: #365e76;
  --blue-soft: #edf3f6;
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button, a, summary, label[for="file"] { -webkit-tap-highlight-color: transparent; }
button, select, summary { cursor: pointer; }
:is(button, a, select, input, summary):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
button { border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); padding: 8px 12px; }
button:disabled, select:disabled { cursor: default; }
button:disabled { opacity: .45; }
button svg, a svg, summary svg, .dropzone svg { flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
a { color: var(--blue); }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 13px; font-weight: 600; }
p { line-height: 1.65; }
.header { height: 64px; padding: 0 36px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: #fff; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand h1 { font-size: 18px; font-weight: 650; letter-spacing: .3px; }
.brand svg { width: 29px; height: 29px; stroke: var(--red); fill: none; stroke-width: 1.7; }
.header-actions { display: flex; align-items: center; gap: 20px; }
.local-note { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.local-note i { width: 5px; height: 5px; background: #508071; border-radius: 50%; }
.quiet-button { padding: 8px 10px; background: transparent; border-color: transparent; color: var(--blue); font-size: 12px; }
main { max-width: 1440px; padding: 28px 36px 0; margin: auto; }
.workbench { display: grid; grid-template-columns: minmax(280px, 320px) minmax(0, 1fr); align-items: start; gap: 28px; }
.input-column, .output-column, .workspace { min-width: 0; }
.dropzone { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px; background: #fff; border: 1px dashed #a9b5bf; border-radius: 9px; cursor: pointer; }
.dropzone svg { width: 18px; height: 18px; color: var(--red); }
.dropzone strong { font-size: 13px; font-weight: 600; white-space: nowrap; }
.dropzone span { color: var(--muted); font-size: 11px; margin-left: auto; white-space: nowrap; }
.dropzone.dragover { border-color: var(--red); background: #fff4f2; }
.dropzone:focus-within { outline: 2px solid var(--blue); outline-offset: 3px; }
#file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.upload-toolbar { display: flex; align-items: center; min-height: 44px; gap: 10px; position: relative; }
.primary { min-width: 116px; min-height: 40px; margin-left: auto; border-color: var(--red); background: var(--red); color: #fff; font-size: 13px; font-weight: 600; }
.status { margin-top: 10px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.status:empty { display: none; }
.status.error { color: #a02620; padding: 10px 12px; border-left: 2px solid var(--red); background: #fff1ef; }
.settings-panel { flex-shrink: 0; }
.settings-panel > summary { list-style: none; display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 12px; color: var(--muted); font-size: 12px; border-radius: 7px; }
.settings-panel > summary::-webkit-details-marker { display: none; }
.settings-panel > summary svg { width: 17px; height: 17px; }
.settings-panel[open] > summary { color: var(--blue); background: var(--blue-soft); }
.settings-content { position: absolute; z-index: 5; top: 52px; left: 0; width: min(540px, 100%); max-height: min(580px, 70vh); overflow-y: auto; overscroll-behavior: contain; background: #fff; border: 1px solid transparent; border-radius: 12px; box-shadow: 0 0 0 1px rgb(0 0 0 / .08), 0 8px 24px rgb(0 0 0 / .09), 0 2px 6px rgb(0 0 0 / .04); padding: 20px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 24px; }
.field label { display: block; margin-bottom: 9px; font-size: 12px; font-weight: 600; }
.field p { font-size: 11px; color: var(--muted); margin-top: 7px; }
#preset-note, #rotate-note { display: none; }
.field output { float: right; color: var(--blue); font-variant-numeric: tabular-nums; font-weight: 400; }
select { width: 100%; min-height: 36px; padding: 7px 9px; border: 1px solid #8796a1; border-radius: 7px; background: #fff; color: var(--ink); font-size: 12px; }
select:disabled { background: #f1f4f6; color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--red); margin: 5px 0 0; }
.range-field { padding-top: 3px; }
.comparison { margin-top: 16px; border: 1px solid var(--line); border-radius: 11px; background: #fff; overflow: hidden; }
.image-panel { min-width: 0; }
.panel-heading { min-height: 50px; padding: 10px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.panel-heading > span, .result-heading > span { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.result-heading { min-width: 0; display: flex; align-items: center; gap: 10px; }
.result-heading h2 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.download { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-shrink: 0; border: 1px solid #bdc9d1; border-radius: 7px; padding: 8px 11px 8px 9px; background: #fff; color: var(--blue); font-size: 12px; font-weight: 600; white-space: nowrap; text-decoration: none; }
.download svg { width: 16px; height: 16px; stroke-width: 1.9; }
.download.disabled { opacity: .4; cursor: default; pointer-events: none; }
.stage { display: flex; align-items: center; justify-content: center; overflow: hidden; }
.result-panel .stage { height: clamp(320px, 43vh, 440px); padding: 28px; }
.stage img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.placeholder { color: #84909a; font-size: 12px; text-align: center; line-height: 1.7; padding: 0 12px; }
.checker { background-color: #fff; background-image: conic-gradient(#f0f2f4 25%, transparent 0 50%, #f0f2f4 0 75%, transparent 0); background-size: 16px 16px; }
.white { background: #fff; }
.gray { background: #a4b0ba; }
.dark { background: #253442; }
.result-image-frame { position: relative; width: 100%; height: 100%; max-width: 420px; max-height: 420px; border: 0; padding: 0; background: transparent; cursor: zoom-in; }
.stage .result-image-frame #result, .stage .result-image-frame #repair-overlay { position: absolute; inset: 0; width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; }
.stage #repair-overlay { pointer-events: none; }
.result-toolbar { min-height: 48px; border-top: 1px solid var(--line); padding: 7px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.preview-modes { display: flex; align-items: center; gap: 3px; min-width: 0; }
.preview-modes button { border-color: transparent; background: transparent; padding: 6px 9px; font-size: 11px; white-space: nowrap; border-radius: 5px; }
.preview-modes button[aria-pressed="true"] { color: var(--blue); background: var(--blue-soft); border-color: #d7e2ea; }
.backgrounds { display: flex; flex-shrink: 0; align-items: center; gap: 7px; }
.swatch { width: 25px; height: 25px; padding: 0; border: 4px solid #fff; border-radius: 50%; outline: 1px solid #ccd5dd; outline-offset: -3px; background-clip: padding-box; }
.swatch.active { outline: 2px solid var(--blue); outline-offset: 0; }
.swatch:focus-visible { outline-offset: 3px; }
.selection { margin-top: 18px; }
.selection-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.selection-heading > span { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.selection-heading > button { border-color: transparent; background: transparent; color: var(--muted); font-size: 11px; padding: 5px 8px; }
.input-list { display: grid; gap: 8px; list-style: none; padding: 3px; margin: -3px; }
.source-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 6px 10px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.source-card.is-reference { border-color: #91a7b8; }
.source-preview { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 0; border-radius: 4px; overflow: hidden; background: #fff; border-color: transparent; cursor: zoom-in; }
.source-preview img { width: 100%; height: 100%; object-fit: contain; outline: 1px solid oklch(0 0 0 / .1); outline-offset: -1px; }
.source-info { min-width: 0; align-self: center; }
.source-name { display: block; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 1.6; }
.source-meta, .source-size { display: block; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.source-actions { display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.source-actions button { min-height: 24px; font-size: 10px; padding: 3px 5px; border-color: transparent; background: transparent; border-radius: 4px; white-space: nowrap; }
.reference-button { color: var(--blue); }
.reference-button:disabled { opacity: 1; background: var(--blue-soft); color: var(--blue); }
.remove-image { color: var(--muted); }
.source-details { grid-column: 1 / -1; min-width: 0; border-top: 1px solid var(--line); }
.source-details summary { font-size: 10px; color: var(--muted); padding-top: 5px; }
.source-details p { font-size: 10px; color: var(--muted); padding-top: 5px; overflow-wrap: anywhere; }
.source-details .status-rejected, .source-details .status-duplicate { color: #8c652f; }
.source-details .status-aligned { color: #3c7563; }
.scheme-comparison { margin-top: 22px; }
.scheme-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.scheme-heading-label { display: flex; align-items: center; gap: 8px; }
#scheme-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scheme-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 9px; align-items: stretch; }
.scheme-card { min-width: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; position: relative; }
.scheme-card.is-selected { border-color: var(--blue); outline: 1px solid var(--blue); outline-offset: 0; }
.choose-scheme { display: flex; flex-direction: column; width: 100%; min-width: 0; border: 0; border-radius: 0; padding: 0; text-align: left; }
.choose-scheme:focus-visible { outline-offset: -3px; }
.scheme-preview { display: flex; align-items: center; justify-content: center; width: 100%; height: 132px; padding: 14px; overflow: hidden; border: 0; border-radius: 0; border-bottom: 1px solid var(--line); cursor: zoom-in; }
.scheme-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.scheme-preview > span { font-size: 11px; color: var(--muted); text-align: center; }
.scheme-card-heading { display: flex; align-items: center; width: 100%; flex: 1; gap: 5px; min-height: 39px; padding: 8px 10px; }
.scheme-card-heading h3 { margin: 0; font-size: 11px; font-weight: 500; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scheme-card.is-selected .scheme-card-heading { background: var(--blue-soft); color: var(--blue); }
.scheme-selected-mark { margin-left: auto; flex-shrink: 0; color: var(--blue); font-size: 12px; line-height: 1; }
.recommendation-badge, .estimate-badge { flex-shrink: 0; padding: 2px 5px; border-radius: 4px; color: #3d6c57; background: #edf5ef; font-size: 10px; line-height: 1.5; white-space: nowrap; }
.recommendation-badge { position: absolute; top: 8px; left: 8px; pointer-events: none; }
.estimate-badge { color: #8b6633; background: #faf4e8; position: absolute; top: 8px; right: 8px; }
.scheme-card.is-failed { border-style: dashed; }
.scheme-card.is-failed .choose-scheme { opacity: .65; height: auto; }
.scheme-error { font-size: 11px; color: #966342; padding: 8px 10px; overflow-wrap: anywhere; }
.scheme-diagnostic { padding: 0 10px 10px; color: var(--muted); font-size: 10px; }
.scheme-diagnostic pre { max-height: 200px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; overscroll-behavior: contain; }
#experiment-report { font-size: 11px; }
.result-details { margin-top: 14px; color: var(--muted); }
.result-details > summary { display: inline-block; padding: 8px 0; font-size: 11px; }
.result-details > summary::before { content: "+"; display: inline-block; width: 17px; }
.result-details[open] > summary::before { content: "−"; }
.result-details > summary::-webkit-details-marker { display: none; }
.details-content { padding: 16px; margin-top: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 11px; line-height: 1.7; overflow-wrap: anywhere; }
.details-content p + p, .details-content > div + div, .details-content > p { margin-top: 7px; }
.details-content ul { margin: 6px 0; padding-left: 19px; }
.details-content strong, #selected-score { color: var(--ink); font-weight: 500; }
#selected-cautions { color: #8b6633; }
.recommendation-details, .notice, .fusion-report { padding-top: 9px; border-top: 1px solid var(--line); margin-top: 9px; }
.details-content :is(p, ul):empty { display: none; }
.recommendation strong { color: #3e6b58; font-weight: 500; }
.recommendation.is-tentative strong { color: #87744f; }
footer { display: flex; justify-content: space-between; max-width: 1440px; margin: 0 auto; padding: 22px 36px; font-size: 10px; color: #84909a; }
footer a { color: inherit; text-decoration: none; }
#extract.is-pointer-pressed:not(:disabled) { background: #95261f; border-color: #95261f; }
#sample.is-pointer-pressed:not(:disabled), #download.is-pointer-pressed:not(.disabled) { background: #e6eef4; border-color: #91a7b8; }
@media (hover: hover) {
  .quiet-button:hover, .settings-panel > summary:hover { background: #eaf0f4; color: var(--blue); }
  .dropzone:hover { border-color: #7c8e9b; background: #fcfdfe; }
  .primary:not(:disabled):hover { background: #a72b25; border-color: #a72b25; }
  .download:not(.disabled):hover { border-color: var(--blue); background: #f5f9fc; }
  .selection-heading > button:hover, .remove-image:hover { color: var(--red); background: #fff0ee; }
  .reference-button:not(:disabled):hover, .preview-modes button:not(:disabled):hover { background: var(--blue-soft); }
  .scheme-card:not(.is-selected):not(.is-failed):hover { border-color: #8ca1b2; }
  .result-details > summary:hover, footer a:hover { color: var(--blue); }
}
@media (prefers-reduced-motion: no-preference) {
  #extract, #sample, #download { transition: transform 150ms ease-out; }
  #extract.is-pointer-pressed:not(:disabled), #sample.is-pointer-pressed:not(:disabled), #download.is-pointer-pressed:not(.disabled) { transform: scale(.96); }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  #extract, #sample, #download { transition: opacity 100ms ease-out; }
  #extract.is-pointer-pressed:not(:disabled), #sample.is-pointer-pressed:not(:disabled), #download.is-pointer-pressed:not(.disabled) { opacity: .85; }
}
@media (max-width: 1100px) {
  .header { padding-inline: 24px; }
  main { padding: 24px 24px 0; }
  .workbench { grid-template-columns: 260px minmax(0, 1fr); gap: 20px; }
  .scheme-list { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  .scheme-preview { height: 116px; padding: 12px; }
  footer { padding-inline: 24px; }
}
@media (max-width: 760px) {
  .header { height: 56px; padding-inline: 16px; }
  .header-actions { gap: 10px; }
  .brand h1 { font-size: 17px; }
  .brand svg { width: 26px; height: 26px; }
  main { padding: 16px 16px 0; }
  .workbench { grid-template-columns: minmax(0, 1fr); gap: 22px; }
  .dropzone { min-height: 44px; }
  .panel-heading { min-height: 44px; padding: 8px 12px; }
  .selection { margin-top: 10px; }
  .selection-heading { margin-bottom: 5px; }
  .input-list { display: flex; overflow-x: auto; overscroll-behavior-x: contain; align-items: flex-start; }
  .source-card { flex: 0 0 232px; }
  .comparison { margin-top: 12px; }
  .result-panel .stage { height: 330px; padding: 22px; }
  .scheme-list { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
  .scheme-preview { height: 132px; }
  .scheme-comparison { margin-top: 18px; }
  footer { padding-inline: 16px; }
}
@media (max-width: 420px) {
  .header-actions { gap: 4px; }
  .local-note { font-size: 10px; }
  .quiet-button { padding-inline: 6px; }
  .upload-toolbar { gap: 5px; flex-wrap: wrap; }
  .settings-panel > summary { padding-inline: 7px; gap: 4px; }
  .primary { min-width: 96px; padding-inline: 9px; }
  .settings-content { padding: 16px; top: 100%; margin-top: 6px; }
  .settings-grid { gap: 16px; }
  .result-heading { gap: 7px; }
  .result-heading > span { display: none; }
  .download { font-size: 11px; padding: 7px 9px 7px 7px; }
  .result-toolbar { padding-inline: 9px; gap: 6px; }
  .preview-modes { gap: 0; }
  .preview-modes button { padding: 6px; font-size: 10px; }
  .backgrounds { gap: 3px; }
  .swatch { width: 23px; height: 23px; }
  .scheme-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scheme-card-heading h3 { font-size: 12px; }
}
@media (forced-colors: active) {
  .settings-content { border-color: CanvasText; }
  .primary, .download, button, select, .dropzone, .scheme-card, .source-card, .comparison { border-color: ButtonText; }
  .scheme-card.is-selected, .swatch.active { outline: 2px solid Highlight; }
  .preview-modes button[aria-pressed="true"], .reference-button:disabled { border: 1px solid Highlight; }
  .primary:disabled, button:disabled, .download.disabled { color: GrayText; border-color: GrayText; opacity: 1; }
}
