:root {
  --bg: #f5f8f6;
  --surface: #ffffff;
  --surface-soft: #f7faf8;
  --ink: #18211d;
  --ink-strong: #101713;
  --muted: #5d6962;
  --border: #d9e1dc;
  --border-strong: #c8d2cc;
  --green: #178447;
  --green-dark: #0f6938;
  --green-soft: #eaf7ef;
  --coral: #dc665f;
  --coral-soft: #fff1f0;
  --shadow: 0 16px 42px rgba(31, 48, 39, 0.08);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
button, select, input[type="range"], input[type="checkbox"], input[type="color"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(23, 132, 71, .22); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .48; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; stroke-width: 2; }

.site-header { position: sticky; top: 0; z-index: 30; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.header-inner, .footer-inner { width: calc(100% - 40px); max-width: 1240px; min-height: 64px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { min-width: 0; display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand img { display: block; width: 102px; height: auto; }
.brand-divider { width: 1px; height: 24px; background: var(--border-strong); }
.brand-product { font-weight: 800; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 14px; }
.privacy-chip { display: inline-flex; align-items: center; gap: 7px; color: var(--green-dark); font-size: .83rem; font-weight: 700; }
.privacy-chip svg { width: 17px; }
.lang-switch { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: #f1f5f2; }
.lang-btn { min-width: 44px; min-height: 33px; padding: 5px 9px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 800; }
.lang-btn.active { background: var(--surface); color: var(--ink-strong); box-shadow: 0 1px 5px rgba(24, 33, 29, .12); }

main { width: calc(100% - 40px); max-width: 1240px; margin: 0 auto; padding: 34px 0 54px; }
.intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(270px, 340px); align-items: end; gap: 32px; margin-bottom: 22px; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; color: var(--green-dark); font-size: .77rem; font-weight: 800; }
.eyebrow > span:first-child { width: 20px; height: 2px; background: var(--green); }
h1 { margin: 0; color: var(--ink-strong); font-size: 3.35rem; line-height: 1.06; font-weight: 800; letter-spacing: 0; }
.intro p { max-width: 720px; margin: 12px 0 0; color: var(--muted); font-size: 1.02rem; }
.trust-note { min-height: 70px; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid #c5e0d0; border-radius: var(--radius); background: var(--green-soft); }
.trust-note > svg { flex: 0 0 auto; width: 24px; height: 24px; color: var(--green); }
.trust-note div { min-width: 0; display: flex; flex-direction: column; }
.trust-note strong { font-size: .9rem; }
.trust-note span { color: #45705a; font-size: .76rem; }

.tool-shell { overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.status-strip { min-height: 43px; padding: 8px 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); background: #fbfcfb; color: var(--muted); font-size: .77rem; font-weight: 700; }
.status-main, .status-meta { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #97a29b; box-shadow: 0 0 0 3px #edf0ee; }
.status-dot.ready { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot.busy { background: #d28a1f; box-shadow: 0 0 0 3px #fff3df; animation: pulse 1.2s infinite; }
.status-dot.error { background: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.status-separator { width: 1px; height: 12px; background: var(--border-strong); }
@keyframes pulse { 50% { opacity: .45; } }

.license-notice { min-height: 220px; padding: 36px; display: flex; align-items: center; justify-content: center; gap: 14px; color: #8c332e; background: var(--coral-soft); text-align: left; }
.license-notice > svg { flex: 0 0 auto; width: 30px; height: 30px; }
.license-notice div { display: flex; flex-direction: column; }
.license-notice strong { color: #6f2723; font-size: 1rem; }
.license-notice span { margin-top: 3px; font-size: .8rem; }

.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: 610px; }
.control-panel { padding: 22px; border-right: 1px solid var(--border); background: #fbfcfb; }
.stage-panel { min-width: 0; padding: 22px; display: flex; flex-direction: column; }
.panel-heading { display: flex; align-items: flex-start; gap: 11px; margin-bottom: 24px; }
.panel-heading.compact { align-items: center; margin: 0; }
.step-index { min-width: 32px; min-height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; background: var(--green-soft); color: var(--green-dark); font-size: .72rem; font-weight: 800; }
.panel-heading h2 { margin: 0; color: var(--ink-strong); font-size: 1.05rem; line-height: 1.25; }
.panel-heading p { margin: 2px 0 0; color: var(--muted); font-size: .76rem; }
.control-group { margin-bottom: 21px; }
.control-label { display: block; margin-bottom: 8px; color: #344139; font-size: .78rem; font-weight: 800; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.value-label { color: var(--green-dark); font-size: .75rem; font-weight: 800; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: #f0f4f1; }
.engine-grid { grid-template-columns: 1fr 1fr; }
.segment { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: .8rem; font-weight: 800; }
.segment svg { width: 16px; }
.segment.active { background: var(--surface); color: var(--ink-strong); box-shadow: 0 1px 6px rgba(24, 33, 29, .12); }
.segment.active svg { color: var(--green); }
input[type="range"] { width: 100%; height: 5px; margin: 8px 0; appearance: none; border-radius: 6px; background: linear-gradient(90deg, var(--green) var(--range-progress, 50%), #dce4df var(--range-progress, 50%)); }
input[type="range"]::-webkit-slider-thumb { width: 17px; height: 17px; appearance: none; border: 3px solid var(--surface); border-radius: 50%; background: var(--green); box-shadow: 0 1px 5px rgba(17, 25, 21, .3); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border: 3px solid var(--surface); border-radius: 50%; background: var(--green); box-shadow: 0 1px 5px rgba(17, 25, 21, .3); }
.range-labels { display: flex; justify-content: space-between; color: #849087; font-size: .68rem; }
.split-controls { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(104px, .8fr); gap: 10px; }
select, .color-control { width: 100%; min-height: 41px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--ink); }
select { padding: 0 30px 0 10px; font-size: .77rem; font-weight: 700; }
.color-control { padding: 5px 7px; display: flex; align-items: center; gap: 7px; font-size: .7rem; font-weight: 800; }
input[type="color"] { flex: 0 0 auto; width: 28px; height: 28px; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 4px; background: none; }
.toggle-row { min-height: 56px; margin: 0 0 20px; padding: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); cursor: pointer; }
.toggle-row > span:first-child { display: flex; flex-direction: column; }
.toggle-row strong { font-size: .79rem; }
.toggle-row small { color: var(--muted); font-size: .69rem; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-ui { position: relative; flex: 0 0 auto; width: 38px; height: 22px; border-radius: 12px; background: #cfd7d2; transition: .2s; }
.toggle-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .18); transition: .2s; }
.toggle-row input:checked + .toggle-ui { background: var(--green); }
.toggle-row input:checked + .toggle-ui::after { transform: translateX(16px); }
.toggle-row input:focus-visible + .toggle-ui { outline: 3px solid rgba(23, 132, 71, .22); outline-offset: 2px; }
.primary-button, .secondary-button, .upload-button { min-height: 43px; padding: 10px 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 6px; font-size: .81rem; font-weight: 800; transition: background .18s, transform .18s, border-color .18s; }
.primary-button { width: 100%; border: 1px solid var(--green); background: var(--green); color: #fff; box-shadow: 0 6px 14px rgba(23, 132, 71, .18); }
.primary-button:hover:not(:disabled) { background: var(--green-dark); transform: translateY(-1px); }
.primary-button.small { width: auto; }
.secondary-button { border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); }
.secondary-button:hover:not(:disabled) { border-color: #9aaaa0; background: var(--surface-soft); }
.model-hint { margin: 9px 0 0; display: flex; align-items: flex-start; gap: 6px; color: #7b877f; font-size: .66rem; }
.model-hint svg { flex: 0 0 auto; width: 13px; height: 13px; margin-top: 1px; }

.stage-toolbar { min-height: 47px; margin-bottom: 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.view-tabs { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: #f1f5f2; }
.view-tabs button { min-width: 56px; min-height: 31px; padding: 5px 9px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 800; }
.view-tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(24, 33, 29, .1); }
.drop-zone { flex: 1; min-height: 490px; padding: 36px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed #afbeb4; border-radius: var(--radius); background: var(--surface-soft); text-align: center; transition: border-color .2s, background .2s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--green); background: #f3fbf6; }
.drop-visual { position: relative; width: 100px; height: 90px; margin-bottom: 15px; }
.image-mark { position: absolute; left: 9px; top: 0; width: 69px; height: 61px; display: flex; align-items: center; justify-content: center; border: 1px solid #bfd0c5; border-radius: 7px; background: #fff; color: var(--green); box-shadow: 7px 8px 0 var(--green-soft); transform: rotate(-3deg); }
.image-mark svg { width: 28px; height: 28px; }
.pencil-stroke { position: absolute; right: 4px; bottom: 9px; width: 55px; height: 3px; border-radius: 3px; background: var(--coral); transform: rotate(-42deg); box-shadow: 0 8px 0 -1px rgba(220, 102, 95, .35); }
.drop-zone h3 { margin: 0; color: var(--ink-strong); font-size: 1.12rem; }
.drop-zone > p { margin: 7px 0 18px; color: var(--muted); font-size: .79rem; }
.upload-button { border: 1px solid var(--green); background: var(--green); color: #fff; }
.upload-button:hover { background: var(--green-dark); }
.paste-tip { margin-top: 15px; color: #869189; font-size: .69rem; }
kbd { min-width: 22px; padding: 2px 5px; display: inline-block; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; background: #fff; color: #657169; font: 600 .65rem/1.4 inherit; }

.preview-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.canvas-frame { position: relative; flex: 1; min-height: 450px; overflow: hidden; display: grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius); background-color: #eef2ef; background-image: linear-gradient(45deg, #e2e8e4 25%, transparent 25%), linear-gradient(-45deg, #e2e8e4 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e2e8e4 75%), linear-gradient(-45deg, transparent 75%, #e2e8e4 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0; }
.canvas-frame:not(.view-original):not(.view-result) { cursor: col-resize; touch-action: pan-y; }
.canvas-frame canvas { position: absolute; display: block; max-width: calc(100% - 28px); max-height: calc(100% - 28px); width: auto; height: auto; box-shadow: 0 6px 22px rgba(20, 32, 25, .15); }
.result-mask { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.result-mask canvas { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.compare-line { position: absolute; top: 14px; bottom: 14px; left: 50%; z-index: 3; width: 2px; background: rgba(255, 255, 255, .95); box-shadow: 0 0 0 1px rgba(24, 33, 29, .22); pointer-events: none; }
.compare-line span { position: absolute; top: 50%; left: 50%; width: 33px; height: 33px; display: grid; place-items: center; border: 1px solid var(--border-strong); border-radius: 50%; background: #fff; color: var(--green); box-shadow: 0 4px 13px rgba(24, 33, 29, .18); transform: translate(-50%, -50%); }
.compare-line svg { width: 17px; }
.compare-range { position: absolute; width: 1px !important; height: 1px !important; opacity: 0; }
.processing-overlay { position: absolute; inset: 0; z-index: 6; padding: 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(249, 251, 250, .92); backdrop-filter: blur(5px); text-align: center; }
.loader-ring { width: 38px; height: 38px; margin-bottom: 14px; border: 3px solid #d7e8dd; border-top-color: var(--green); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.processing-overlay strong { color: var(--ink-strong); font-size: .94rem; }
.processing-overlay > span { margin-top: 3px; color: var(--muted); font-size: .75rem; }
.progress-track { width: min(280px, 74%); height: 5px; margin-top: 15px; overflow: hidden; border-radius: 5px; background: #dbe5df; }
.progress-track span { display: block; width: 8%; height: 100%; border-radius: inherit; background: var(--green); transition: width .2s ease; }
.result-actions { min-height: 56px; padding-top: 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.download-actions { display: flex; gap: 8px; }
.view-original .result-mask, .view-original .compare-line { display: none; }
.view-result #originalCanvas, .view-result .compare-line { display: none; }
.view-result .result-mask { width: 100% !important; }

.feature-band { margin-top: 20px; padding: 20px 4px; display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.feature-band > div { min-width: 0; padding: 0 20px; display: grid; grid-template-columns: 30px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; border-right: 1px solid var(--border); }
.feature-band > div:last-child { border-right: 0; }
.feature-band svg { grid-row: 1 / 3; align-self: center; width: 24px; height: 24px; color: var(--green); }
.feature-band strong { font-size: .79rem; }
.feature-band span { overflow-wrap: anywhere; color: var(--muted); font-size: .68rem; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; max-width: min(520px, calc(100% - 32px)); padding: 11px 15px; display: flex; align-items: center; gap: 9px; border: 1px solid #e8bbb8; border-radius: 7px; background: var(--coral-soft); color: #8c332e; box-shadow: 0 12px 30px rgba(58, 24, 21, .15); font-size: .8rem; font-weight: 700; transform: translateX(-50%); }
.toast svg { flex: 0 0 auto; }
footer { background: #fff; border-top: 1px solid var(--border); }
.footer-inner { min-height: 68px; color: var(--muted); font-size: .72rem; }
.footer-inner p { margin: 0; }
.footer-inner strong { color: var(--ink); }
.copyright a { color: var(--green-dark); font-weight: 800; text-decoration: none; }
.copyright a:hover { text-decoration: underline; }

@media (max-width: 960px) {
  h1 { font-size: 2.7rem; }
  .workspace { grid-template-columns: 290px minmax(0, 1fr); }
  .control-panel, .stage-panel { padding: 18px; }
  .feature-band { grid-template-columns: repeat(2, 1fr); row-gap: 20px; }
  .feature-band > div:nth-child(2) { border-right: 0; }
  .canvas-frame { min-height: 400px; }
}

@media (max-width: 760px) {
  .header-inner, .footer-inner, main { width: calc(100% - 24px); }
  .privacy-chip { display: none; }
  .brand img { width: 88px; }
  .brand-divider { height: 20px; }
  .brand-product { font-size: .82rem; }
  main { padding-top: 24px; }
  .intro { grid-template-columns: 1fr; gap: 16px; }
  h1 { font-size: 2.15rem; }
  .intro p { font-size: .9rem; }
  .trust-note { min-height: 60px; }
  .status-strip { align-items: flex-start; flex-direction: column; gap: 2px; padding: 9px 13px; }
  .status-meta { padding-left: 16px; }
  .workspace { display: flex; flex-direction: column; }
  .control-panel { order: 2; border-top: 1px solid var(--border); border-right: 0; }
  .stage-panel { order: 1; min-height: 540px; }
  .stage-toolbar { align-items: center; }
  .panel-heading.compact p { display: none; }
  .drop-zone { min-height: 420px; padding: 26px 18px; }
  .canvas-frame { min-height: 410px; }
  .feature-band { grid-template-columns: 1fr 1fr; }
  .feature-band > div { padding: 0 10px; }
  .footer-inner { padding: 14px 0; align-items: flex-start; flex-direction: column; justify-content: center; gap: 3px; }
}

@media (max-width: 480px) {
  .header-inner { width: calc(100% - 18px); gap: 8px; }
  .brand { gap: 8px; }
  .brand img { width: 78px; }
  .brand-product { max-width: 74px; white-space: normal; line-height: 1.1; }
  .lang-btn { min-width: 39px; padding-inline: 7px; }
  main { width: calc(100% - 16px); }
  h1 { font-size: 1.85rem; }
  .tool-shell { border-radius: 6px; }
  .stage-panel, .control-panel { padding: 14px; }
  .stage-toolbar { align-items: flex-start; }
  .stage-toolbar .step-index { display: none; }
  .view-tabs button { min-width: 44px; padding-inline: 6px; }
  .drop-zone { min-height: 360px; }
  .canvas-frame { min-height: 360px; }
  .result-actions { align-items: stretch; flex-direction: column; }
  .result-actions > button { width: 100%; }
  .download-actions { display: grid; grid-template-columns: 1fr 1.4fr; }
  .download-actions button { width: 100%; padding-inline: 8px; }
  .feature-band { grid-template-columns: 1fr; row-gap: 0; }
  .feature-band > div { padding: 13px 6px; border-right: 0; border-bottom: 1px solid var(--border); }
  .feature-band > div:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
