:root {
  --bg: #f5f6f8;
  --paper: #fff;
  --ink: #242a33;
  --muted: #626b77;
  --line: #dfe3e8;
  --accent: #245cbd;
  --accent-hover: #1c4999;
  --accent-soft: #eef3fc;
  --canvas: #eef0f3;
  --stage-height: clamp(300px, calc(100dvh - 360px), 440px);
  color-scheme: light;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button { border: 0; background: none; min-height: 44px; min-width: 44px; padding: 0 14px; border-radius: 6px; color: inherit; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; transition: background .18s, border-color .18s; }
button:disabled { opacity: .4; cursor: not-allowed; }
button:hover:not(:disabled) { background: var(--canvas); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
button svg, .import-icon { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.primary { background: var(--accent); color: #fff; border: 1px solid transparent; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary { background: var(--paper); border: 1px solid var(--line); }
.secondary:hover:not(:disabled) { background: #f8f9fb; border-color: #b8c0cb; }
.text-button { color: var(--muted); padding: 0 10px; }
.icon-button { width: 44px; padding: 0; }
.mirror { transform: scaleX(-1); }
[hidden] { display: none !important; }
.svg-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.site-header { height: 72px; padding: 0 max(32px, calc((100vw - 1240px) / 2)); display: flex; align-items: center; justify-content: space-between; background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 18px; font-weight: 600; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 6px; color: #fff; background: var(--accent); font-size: 18px; font-weight: 500; }
main { max-width: 1304px; margin: auto; padding: 0 32px; }
.workbench { padding-top: 32px; }
.workspace-heading { display: flex; justify-content: space-between; align-items: center; min-height: 44px; margin-bottom: 24px; gap: 16px; }
.workspace-heading h1 { font-size: 28px; font-weight: 600; line-height: 1.4; margin: 0; }
.workspace-grid { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(0,1fr); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.image-panel, .text-panel { min-width: 0; }
.image-panel { border-right: 1px solid var(--line); }
.text-panel { display: flex; flex-direction: column; }
.panel-heading { height: 64px; padding: 10px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 16px; font-weight: 600; margin: 0; }
.panel-heading #resultInfo { color: var(--muted); font-size: 14px; }
.history-actions { display: flex; align-items: center; gap: 4px; }
.history-actions .text-button { font-size: 14px; }
.import-card { height: calc(var(--stage-height) + 100px); padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #fafbfc; }
.import-target { width: 100%; flex: 1; border: 1px dashed #c6ccd5; border-radius: 6px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 32px 16px; }
.import-icon { width: 36px; height: 36px; stroke-width: 1.2; color: var(--muted); margin-bottom: 24px; }
.import-target .primary { min-width: 136px; height: 48px; font-size: 16px; }
.import-methods, .import-formats { color: var(--muted); font-size: 14px; text-align: center; line-height: 1.7; }
.import-methods { margin: 20px 0 8px; }
.import-formats { margin: 0; }
.import-card.drag-over { background: var(--accent-soft); }
.import-card.drag-over .import-target { border-color: var(--accent); }
.canvas-stage { background: var(--canvas); height: var(--stage-height); padding: 24px; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.canvas-wrap { position: relative; max-width: 100%; max-height: 100%; line-height: 0; user-select: none; touch-action: auto; box-shadow: 0 1px 6px #24303e18; flex-shrink: 0; }
.canvas-wrap.selecting { touch-action: none; cursor: crosshair; }
.canvas-wrap canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.selection { position: absolute; border: 1px solid #fff; background: #245cbd26; pointer-events: none; box-shadow: 0 0 0 1px var(--accent); }
.selection span { display: block; background: #fff; position: absolute; right: -3px; bottom: -3px; width: 6px; height: 6px; }
.image-toolbar { min-height: 60px; padding: 8px 10px; display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tool-button { font-size: 14px; padding: 0 8px; gap: 6px; }
.tool-button[aria-expanded=true] { color: var(--accent); background: var(--accent-soft); }
.tool-button svg { width: 16px; height: 16px; }
.export-image { margin-left: auto; }
.image-info { height: 40px; margin: 0; padding: 0 20px; display: flex; align-items: center; color: var(--muted); font-size: 14px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tool-drawer { border-bottom: 1px solid var(--line); padding: 20px; background: #fafbfc; }
.tool-drawer p { margin: 0 0 16px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.selection-fields { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.selection-fields label { font-size: 14px; }
.selection-fields input { width: 100%; height: 44px; margin-top: 8px; border: 1px solid #bcc4cf; border-radius: 5px; padding: 0 10px; background: var(--paper); color: var(--ink); }
.drawer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 16px; }
.adjust-fields { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 20px; }
.adjust-fields label { font-size: 14px; }
.adjust-fields span { float: right; color: var(--muted); }
input[type=range] { width: 100%; margin: 16px 0 0; accent-color: var(--accent); height: 24px; }
.adjust-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 44px; }
.check-label input { accent-color: var(--accent); width: 18px; height: 18px; }
.recognize-controls { display: flex; gap: 12px; padding: 16px 20px; }
.recognize-controls select { min-width: 0; flex: 1; height: 44px; border: 1px solid #bcc4cf; border-radius: 5px; background: var(--paper); padding: 0 10px; font-size: 14px; color: var(--ink); }
.recognize-controls .primary { padding: 0 18px; }
.progress-area { padding: 12px 20px; background: var(--accent-soft); border-top: 1px solid var(--line); font-size: 14px; }
.progress-area > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.progress-area .text-button { padding: 0 8px; }
.progress-area progress { width: 100%; height: 5px; border: 0; display: block; margin: 8px 0 12px; accent-color: var(--accent); }
progress::-webkit-progress-bar { background: #d6e0f2; border-radius: 4px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.progress-area p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.7; }
.stale-note { padding: 12px 20px; color: #73501d; background: #fff8e9; font-size: 14px; line-height: 1.7; }
.result-body { flex: 1; min-height: 260px; position: relative; display: flex; border-top: 1px solid var(--line); }
.result-empty { width: 100%; align-self: center; text-align: center; padding: 24px 32px; }
.result-empty p { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.8; }
.result-body textarea { display: block; width: 100%; height: 100%; min-height: 260px; position: absolute; inset: 0; resize: none; border: 0; padding: 20px; font-size: 16px; line-height: 1.9; color: var(--ink); background: var(--paper); }
.result-body textarea:focus-visible { outline-offset: -3px; }
.text-actions { padding: 12px 20px 16px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); }
.text-actions > .text-button { padding: 0; }
.text-actions > span { font-size: 14px; color: var(--muted); margin-left: auto; }
.text-actions > div { display: flex; gap: 12px; width: 100%; }
.text-actions .secondary { flex: 1; }
.text-actions svg { width: 16px; height: 16px; }
.notice { margin: 16px 0 0; border: 1px solid #b7caed; border-radius: 6px; background: var(--accent-soft); padding: 12px 16px; font-size: 14px; line-height: 1.8; color: #214a88; overflow-wrap: anywhere; white-space: pre-line; }
.notice.error { color: #923c25; border-color: #dfb8ac; background: #fff5f1; }
footer { padding: 20px 0 28px; color: var(--muted); font-size: 14px; line-height: 1.8; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 24px; box-shadow: 0 12px 48px #0002; color: var(--ink); max-height: 85dvh; overflow-y: auto; }
dialog::backdrop { background: #242a3370; }
.info-dialog { max-width: 600px; width: calc(100% - 32px); }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.dialog-heading h2, dialog h2 { font-size: 20px; margin: 0; }
.info-dialog h3 { font-size: 16px; margin: 24px 0 12px; }
.info-dialog li, .confirm-dialog p { font-size: 14px; line-height: 1.8; color: var(--muted); }
.info-dialog ol, .info-dialog ul { padding-left: 22px; }
.info-dialog li { margin: 8px 0; }
.dialog-end { width: 100%; margin-top: 16px; }
.confirm-dialog { max-width: 440px; width: calc(100% - 32px); }
.confirm-dialog p { margin: 16px 0 24px; }
@media (max-width: 1100px) {
  .site-header { padding: 0 24px; }
  main { padding: 0 24px; }
  .workspace-grid { grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); }
  .image-toolbar { padding: 8px; gap: 0; }
  .export-image { margin-left: 0; }
  .tool-button { font-size: 13px; }
  .recognize-controls { gap: 8px; }
}
@media (max-width: 820px) {
  .workspace-grid { grid-template-columns: minmax(0,1fr); }
  .image-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .import-card { height: 360px; }
  .result-body { min-height: 280px; }
  .export-image { margin-left: auto; }
}
@media (max-width: 480px) {
  .site-header { height: 64px; padding: 0 16px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; font-size: 17px; }
  .site-header .text-button { font-size: 14px; padding: 0 4px; }
  main { padding: 0 12px; }
  .workbench { padding-top: 24px; }
  .workspace-heading { margin-bottom: 20px; gap: 8px; }
  .workspace-heading h1 { font-size: 24px; }
  .workspace-heading .secondary { padding: 0 10px; font-size: 14px; }
  .panel-heading { height: 60px; padding: 8px 14px; gap: 4px; }
  .history-actions { gap: 0; }
  .history-actions .text-button { padding: 0 6px; }
  .import-card { height: 330px; padding: 16px; gap: 4px; }
  .import-target { padding: 24px 12px; }
  .import-icon { margin-bottom: 20px; }
  .import-methods { margin-top: 16px; }
  .import-formats { font-size: 13px; }
  .desktop-paste { display: none; }
  .canvas-stage { padding: 16px; }
  .image-toolbar { justify-content: flex-start; padding: 8px; gap: 4px; }
  .tool-button { padding: 0 8px; font-size: 14px; }
  .export-image { margin-left: 0; }
  .image-info { padding: 0 14px; font-size: 13px; }
  .tool-drawer { padding: 16px 14px; }
  .selection-fields { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .selection-fields input, .recognize-controls select { font-size: 16px; }
  .adjust-fields { grid-template-columns: minmax(0,1fr); gap: 16px; }
  .adjust-fields input { margin-top: 8px; }
  .adjust-bottom { align-items: flex-start; flex-direction: column; gap: 0; }
  .adjust-bottom .drawer-actions { width: 100%; margin-top: 4px; }
  .recognize-controls { padding: 14px; gap: 8px; }
  .recognize-controls .primary { padding: 0 12px; }
  .result-empty { padding: 24px; }
  .result-body textarea { padding: 16px; }
  .text-actions { padding: 12px 14px 16px; }
  .text-actions > div { gap: 8px; }
  .progress-area, .stale-note { padding-left: 14px; padding-right: 14px; }
  footer { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.site-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 24px; }
.site-footer p { margin: 0; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 0 20px; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); text-decoration: none; }
.site-footer a:hover, .site-footer a[aria-current] { color: var(--accent); }
.help-links { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.help-links a, .document-content a { color: var(--accent); text-underline-offset: 4px; }
.help-links a { display: inline-flex; align-items: center; min-height: 44px; }
.header-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; color: var(--muted); text-decoration: none; }
.header-link:hover { color: var(--accent); }
.document-main { max-width: 940px; padding: 0 32px; }
.document-content { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; margin-top: 40px; padding: 40px 56px; font-size: 16px; line-height: 1.85; }
.document-content h1 { font-size: 28px; line-height: 1.4; font-weight: 600; margin: 0 0 16px; }
.document-content h2 { font-size: 20px; line-height: 1.5; font-weight: 600; margin: 0 0 16px; }
.document-content h3 { font-size: 16px; line-height: 1.6; font-weight: 600; margin: 0 0 6px; }
.document-content p { margin: 8px 0 12px; }
.document-content .document-lead { color: var(--muted); margin: 0 0 32px; }
.document-content section + section { margin-top: 36px; padding-top: 32px; border-top: 1px solid var(--line); }
.guide-steps { padding-left: 28px; margin: 0; }
.guide-steps li { padding-left: 8px; margin-bottom: 24px; }
.guide-steps li::marker { color: var(--accent); font-weight: 600; }
.guide-steps li:last-child { margin-bottom: 0; }
.fact-list { margin: 0 0 20px; }
.fact-list > div { display: grid; grid-template-columns: 112px minmax(0,1fr); gap: 20px; border-bottom: 1px solid var(--line); padding: 12px 0; }
.fact-list dt { color: var(--muted); }
.fact-list dd { margin: 0; overflow-wrap: anywhere; }
.document-content details { border-bottom: 1px solid var(--line); }
.document-content summary { min-height: 56px; padding: 14px 0; cursor: pointer; font-weight: 500; }
.document-content summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.document-content details p { padding-left: 20px; }
.email-link { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
.document-main .site-footer { justify-content: center; }
@media (max-width: 600px) {
  .site-footer { justify-content: center; text-align: center; }
  .site-footer nav { justify-content: center; gap: 0 16px; }
  .document-main { padding: 0 12px; }
  .document-content { margin-top: 24px; padding: 28px 20px; }
  .document-content h1 { font-size: 24px; }
  .document-content h2 { font-size: 18px; }
  .document-content section + section { margin-top: 28px; padding-top: 24px; }
  .fact-list > div { grid-template-columns: 80px minmax(0,1fr); gap: 12px; }
  .guide-steps { padding-left: 20px; }
}
