:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "Segoe UI", sans-serif;
  --shell: #080a0c; --chrome: #0d1013; --surface: #111417; --raised: #171a1d;
  --control: #1d2023; --line: #34322a; --gold-line: #6f5c2c; --accent: #e7c46a;
  --accent-hover: #f0d47e; --accent-ink: #17130a; --ink: #f3f1ea; --muted: #999b9d;
  --subtle: #676b6f; --error: #ef7676; --preview: #11161c; --radius: 7px;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-width: 0; margin: 0; overflow: hidden; }
body { background: var(--shell); color: var(--ink); font-size: 13px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled, input:disabled, select:disabled { opacity: .42; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.app-shell { width: 100%; height: 100%; display: grid; grid-template-rows: minmax(0, 1fr); background: var(--shell); }
.workspace { min-height: 0; display: grid; grid-template-columns: minmax(620px, 1fr) 336px; }
.preview-area { min-width: 0; min-height: 0; display: grid; grid-template-rows: 46px minmax(0, 1fr) auto; margin: 12px; margin-right: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.preview-heading strong { font-size: 14px; }
.preview-options { display: flex; align-items: center; gap: 9px; }
select, input[type="number"] { min-width: 0; height: 32px; padding: 5px 8px; border: 1px solid #45484a; border-radius: 4px; color: var(--ink); background: var(--control); }
.preview-options select { width: 112px; }
.inline-check { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.preview-viewport { position: relative; min-height: 0; overflow: hidden; background: var(--preview); touch-action: none; }
.preview-stage { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-origin: 0 0; box-shadow: 0 0 0 1px rgb(0 0 0 / .35); --crop-edge-size: 9px; --crop-handle-size: 18px; --crop-handle-offset: -6px; --crop-handle-inset: 12px; --crop-handle-border: 1px; }
.preview-layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; user-select: none; pointer-events: none; }
.preview-layer:not([src]), .preview-layer[src=""] { display: none; }
#vector-layer { opacity: 1; }
.preview-stage.mode-source #binary-layer, .preview-stage.mode-source #vector-layer { display: none; }
.preview-stage.mode-binary #source-layer, .preview-stage.mode-binary #vector-layer { display: none; }
.preview-stage.mode-vector #source-layer, .preview-stage.mode-vector #binary-layer { display: none; }
.preview-stage.mode-overlay #binary-layer { display: none; }
.preview-stage.mode-overlay #source-layer { opacity: .58; }
.preview-stage.mode-overlay #vector-layer { opacity: 1; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; color: var(--ink); pointer-events: none; }
.empty-state button { pointer-events: auto; }
.empty-state strong { font-size: 20px; font-weight: 400; }
.empty-state span { color: var(--muted); }
.loading-state { position: absolute; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center; gap: 12px; background: rgb(8 10 12 / .58); }
.loading-state strong { color: var(--ink); font-size: 14px; font-weight: 600; }
.loading-spinner { width: 30px; height: 30px; border: 3px solid rgb(231 196 106 / .28); border-top-color: var(--accent); border-radius: 50%; animation: loading-spin .8s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.crop-bar { min-height: 44px; display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-top: 1px solid var(--line); background: var(--surface); }
.crop-bar span { margin-right: auto; color: var(--muted); }
.inspector { min-height: 0; overflow-y: auto; padding: 12px; background: var(--chrome); scrollbar-color: #494b4d transparent; }
.panel { margin-bottom: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--raised); }
.panel h2 { margin: 0 0 11px; color: var(--accent); font-size: 13px; font-weight: 600; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.mode-switch button, .button, .accent-button { min-height: 32px; padding: 7px 12px; border: 1px solid #494b4d; border-radius: 5px; color: var(--ink); background: var(--control); text-align: center; }
.mode-switch button { font-weight: 600; }
.mode-switch button.active, .accent-button { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.mode-switch button:hover:not(:disabled), .button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.mode-switch button.active:hover:not(:disabled) { border-color: var(--accent-hover); background: var(--accent-hover); color: var(--accent-ink); }
.accent-button:hover:not(:disabled) { background: var(--accent-hover); color: var(--accent-ink); }
.manual-threshold { display: grid; grid-template-columns: 1fr auto; gap: 5px 8px; margin-top: 12px; color: var(--muted); }
.manual-threshold output { color: var(--accent); font-variant-numeric: tabular-nums; }
.manual-threshold input { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }
.switch-line { display: flex; align-items: center; justify-content: space-between; min-height: 29px; margin-top: 12px; color: var(--ink); }
.switch-line input { position: absolute; opacity: 0; pointer-events: none; }
.switch-line i { position: relative; width: 38px; height: 21px; border: 1px solid #55585a; border-radius: 11px; background: #3b3e40; }
.switch-line i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 15px; height: 15px; border-radius: 50%; background: #b7b8b8; }
.switch-line input:checked + i { border-color: var(--accent); background: var(--gold-line); }
.switch-line input:checked + i::after { left: 19px; background: var(--accent); }
.size-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 30px; align-items: center; gap: 0; margin: 2px 0; color: var(--muted); }
.size-row input { width: 100%; text-align: right; font-family: Consolas, monospace; }
.size-row em { margin-left: 6px; color: var(--muted); font-style: normal; }
.size-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 9px; }
.format-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.format-checks label { display: flex; align-items: center; gap: 8px; min-height: 28px; }
.validation-message { min-height: 24px; margin-top: 7px; color: var(--error); }
.wide-button { width: 100%; margin-top: 6px; }
.diagnostic-panel { position: fixed; left: 12px; right: 360px; bottom: 12px; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; min-height: 48px; padding: 8px 10px 8px 12px; border: 1px solid #8e4d4d; border-left: 3px solid var(--error); border-radius: 5px; background: #352326; }
.diagnostic-panel div { min-width: 0; }.diagnostic-panel strong, .diagnostic-panel span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.diagnostic-panel span { color: #d9a6a6; font-size: 11px; }
.icon-button { width: 32px; height: 32px; border: 1px solid #494b4d; border-radius: 5px; color: var(--ink); background: var(--control); font-size: 18px; }
.toast-region { position: fixed; right: 14px; bottom: 12px; z-index: 40; display: grid; gap: 7px; }.toast { max-width: 390px; padding: 10px 12px; border: 1px solid #494b4d; border-left: 3px solid #84bf76; border-radius: 5px; background: #252b31; }.toast.error { border-left-color: var(--error); }
dialog { width: min(500px, calc(100vw - 30px)); padding: 0; border: 1px solid #494b4d; border-radius: 7px; color: var(--ink); background: var(--chrome); box-shadow: 0 24px 60px rgb(0 0 0 / .5); } dialog::backdrop { background: rgb(8 10 12 / .7); }
.dialog-body { padding: 16px; }.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }.dialog-heading h2 { margin: 0; font-size: 15px; }.dialog-file { display: grid; place-items: center; min-height: 70px; margin-top: 14px; border: 1px dashed #6f5c2c; border-radius: 5px; color: var(--accent); cursor: pointer; }.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 16px; }.details-body pre { max-height: 58vh; overflow: auto; padding: 12px; border: 1px solid var(--line); background: var(--shell); white-space: pre-wrap; word-break: break-word; }
.crop-selection { position: absolute; border: 4px solid var(--accent); background: rgb(184 3 4 / .03); cursor: move; touch-action: none; }
.crop-selection::before { content: ""; position: fixed; inset: -10000px; box-shadow: 0 0 0 10000px rgb(8 10 12 / .45); pointer-events: none; }
.crop-selection .handle { position: absolute; box-sizing: border-box; z-index: 1; }
.crop-selection .n, .crop-selection .s { left: var(--crop-handle-inset); right: var(--crop-handle-inset); height: var(--crop-edge-size); background: rgb(231 196 106 / .18); cursor: ns-resize; }
.crop-selection .e, .crop-selection .w { top: var(--crop-handle-inset); bottom: var(--crop-handle-inset); width: var(--crop-edge-size); background: rgb(231 196 106 / .18); cursor: ew-resize; }
.crop-selection .nw, .crop-selection .ne, .crop-selection .sw, .crop-selection .se { width: var(--crop-handle-size); height: var(--crop-handle-size); background: transparent; }
.crop-selection .nw::before, .crop-selection .ne::before, .crop-selection .sw::before, .crop-selection .se::before,
.crop-selection .nw::after, .crop-selection .ne::after, .crop-selection .sw::after, .crop-selection .se::after { content: ""; position: absolute; background: var(--accent); box-shadow: 0 0 0 var(--crop-handle-border) rgb(8 10 12 / .38); }
.crop-selection .nw::before, .crop-selection .ne::before, .crop-selection .sw::before, .crop-selection .se::before { width: 100%; height: calc(var(--crop-handle-border) * 3); }
.crop-selection .nw::after, .crop-selection .ne::after, .crop-selection .sw::after, .crop-selection .se::after { width: calc(var(--crop-handle-border) * 3); height: 100%; }
.crop-selection .n { left: var(--crop-handle-inset); top: var(--crop-handle-offset); }
.crop-selection .s { left: var(--crop-handle-inset); bottom: var(--crop-handle-offset); }
.crop-selection .e { right: var(--crop-handle-offset); }
.crop-selection .w { left: var(--crop-handle-offset); }
.crop-selection .nw { left: var(--crop-handle-offset); top: var(--crop-handle-offset); cursor: nwse-resize; }
.crop-selection .ne { right: var(--crop-handle-offset); top: var(--crop-handle-offset); cursor: nesw-resize; }
.crop-selection .sw { left: var(--crop-handle-offset); bottom: var(--crop-handle-offset); cursor: nesw-resize; }
.crop-selection .se { right: var(--crop-handle-offset); bottom: var(--crop-handle-offset); cursor: nwse-resize; }
.crop-selection .nw::before, .crop-selection .ne::before { top: 0; }
.crop-selection .sw::before, .crop-selection .se::before { bottom: 0; }
.crop-selection .nw::before, .crop-selection .sw::before { left: 0; }
.crop-selection .ne::before, .crop-selection .se::before { right: 0; }
.crop-selection .nw::after, .crop-selection .ne::after { top: 0; }
.crop-selection .sw::after, .crop-selection .se::after { bottom: 0; }
.crop-selection .nw::after, .crop-selection .sw::after { left: 0; }
.crop-selection .ne::after, .crop-selection .se::after { right: 0; }
[hidden] { display: none !important; }
@media (max-width: 1000px) { html, body { height: auto; overflow: auto; }.app-shell { height: auto; min-height: 100%; }.workspace { grid-template-columns: 1fr; grid-template-rows: minmax(520px, 68vh) auto; }.inspector { border-top: 1px solid var(--line); }.diagnostic-panel { right: 12px; } }
@media (max-width: 640px) { .workspace { grid-template-rows: minmax(470px, 67vh) auto; }.preview-area { margin: 8px; }.preview-heading { padding-inline: 10px; }.preview-options { gap: 5px; }.preview-options select { width: 82px; }.inline-check { font-size: 11px; }.panel { padding: 12px; } }
