:root {
    color-scheme: light;
    --page: #f4f7f5;
    --surface: #fff;
    --text: #182b24;
    --muted: #52655b;
    --line: #dbe6df;
    --green: #14745c;
    --green-dark: #0c563f;
    --mint: #e8f5ed;
    --soft: #f5faf7;
    --shadow: 0 1px 2px #143a2410, 0 10px 30px #143a2406;
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
    font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--text); background: var(--page); line-height: 1.5; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible + span { outline: 3px solid #43a98a; outline-offset: 2px; }
h1, h2, p, figure { margin: 0; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.shell { width: min(1160px, calc(100% - 72px)); margin-inline: auto; }
.topbar { background: var(--surface); border-bottom: 1px solid #e1e9e4; }
.topbar-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.125rem; font-weight: 800; letter-spacing: -.025em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: #174c3a; color: white; }
.brand-mark .icon { width: 21px; height: 21px; }
.local-status { display: flex; align-items: center; gap: 5px; color: #325849; font-size: .875rem; }
.local-status .icon { width: 16px; height: 16px; }

main { padding-block: 28px 64px; }
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    min-height: 226px;
    padding: 24px clamp(24px, 4.2vw, 56px);
    overflow: hidden;
    border: 1px solid #c8dfd3;
    border-radius: 24px;
    background-color: #e5f1e9;
    background-image: radial-gradient(ellipse at 78% -15%, #f8fdf9, #f8fdf900 64%),
        linear-gradient(90deg, #f1f8f2 32%, #eef8f100 80%),
        repeating-linear-gradient(0deg, transparent 0 23px, #2a775f16 23px 24px),
        repeating-linear-gradient(90deg, transparent 0 23px, #2a775f16 23px 24px);
}
.hero-category { color: #17644d; font-weight: 750; font-size: .875rem; letter-spacing: .055em; }
.hero h1 { margin-block: 9px 10px; font-size: clamp(2.1rem, 4.25vw, 3.42rem); line-height: 1.13; letter-spacing: -.045em; text-wrap: balance; }
.hero-description { color: #3d594d; line-height: 1.65; }
.comparison { display: flex; gap: 10px; }
.comparison figure {
    width: clamp(94px, 13vw, 152px);
    min-width: 0;
    padding: 5px;
    border-radius: 13px;
    background: white;
    border: 1px solid #d6e5dc;
    box-shadow: 0 4px 16px #1b573315;
}
.comparison img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: white; }
.comparison figcaption { padding: 4px 0 0; text-align: center; color: #53665b; font-size: .8125rem; }
.example-after figcaption { color: var(--green-dark); font-weight: 750; }

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(290px, 335px);
    grid-template-areas: "upload settings" "queue settings";
    align-items: start;
    gap: 16px 20px;
    margin-top: 20px;
}
.panel { min-width: 0; padding: 21px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); }
.upload-panel { grid-area: upload; }
.settings-panel { grid-area: settings; align-self: start; position: sticky; top: 16px; }
.queue-panel { grid-area: queue; }
.panel-heading, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; min-height: 38px; }
.panel-heading h2, .dialog-head h2 { font-size: 1.125rem; line-height: 1.35; font-weight: 780; letter-spacing: -.02em; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 42px;
    padding: 8px 15px;
    border: 1px solid transparent;
    border-radius: 10px;
    font-weight: 750;
    font-size: .9375rem;
    line-height: 1.25;
    transition: color .16s, background .16s, border-color .16s;
}
.button-primary { color: white; background: var(--green); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-primary:disabled { color: #52675e; background: #e7eeea; }
.button-quiet { min-height: 38px; padding: 5px 9px; background: transparent; color: #285d4b; font-size: .875rem; }
.button-quiet:hover:not(:disabled) { background: var(--mint); }
.button-quiet:disabled { color: #687c71; }
.button-quiet .icon { width: 16px; height: 16px; }

.dropzone {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 11px;
    padding: 20px 14px 22px;
    background: var(--soft);
    border: 2px dashed #a8c8b7;
    border-radius: 15px;
    transition: background .16s, border-color .16s;
}
.dropzone:has(.drop-target:hover:not(:disabled)),
.dropzone:has(.drop-target:focus-visible),
.dropzone.is-dragging { background: #e9f6ee; border-color: var(--green); }
.drop-target { position: absolute; inset: 0; width: 100%; border: 0; border-radius: inherit; background: transparent; }
.drop-target:focus-visible { outline-offset: 3px; }
.upload-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; color: var(--green-dark); background: #deefe5; }
.upload-mark .icon { width: 22px; height: 22px; }
.drop-copy { text-align: center; }
.drop-title { font-size: 1rem; font-weight: 750; }
.drop-hint { margin-top: 3px; color: var(--muted); font-size: .875rem; line-height: 1.45; }
.drop-cta { margin-top: 1px; }
.dropzone:has(.drop-target:hover:not(:disabled)) .drop-cta { background: var(--green-dark); }
.dropzone:has(.drop-target:disabled) .drop-cta { color: #52675e; background: #e3ebe6; }
.dropzone.has-files { grid-template-columns: auto minmax(0, 1fr) auto; justify-items: start; align-items: center; padding: 12px; gap: 10px; }
.dropzone.has-files .drop-copy { text-align: left; }
.dropzone.has-files .drop-cta { margin-top: 0; }
.upload-note { margin-top: 11px; padding: 9px 11px; border-radius: 8px; background: #fff4e6; color: #824717; font-size: .875rem; line-height: 1.5; }

.size-options { margin: 0; padding: 0; border: 0; }
.size-options legend { padding: 0; margin-bottom: 8px; color: var(--muted); font-size: .875rem; }
.size-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.size-option { position: relative; display: block; cursor: pointer; }
.size-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.size-option span {
    display: grid;
    place-items: center;
    min-height: 43px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: #344f42;
    background: white;
    font-size: .875rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.size-option:hover span { border-color: #8db3a0; }
.size-option input:checked + span { border-color: #198265; color: var(--green-dark); background: var(--mint); font-weight: 750; }
.size-option:has(input:disabled) { cursor: default; opacity: .66; }
.mode-options { margin-top: 14px; }
.mode-hint { margin-top: 7px; color: var(--muted); font-size: .8125rem; }
.output-format { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 14px 0 16px; color: var(--muted); font-size: .875rem; }
.swatch { width: 13px; height: 13px; border-radius: 4px; border: 1px solid #9eb8a9; background: white; }
.divider { height: 12px; border-left: 1px solid #c3d5cc; margin-inline: 3px; }

.action-dock { padding-top: 13px; border-top: 1px solid var(--line); }
.action-status { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; min-height: 21px; margin-bottom: 8px; }
.run-note { color: #4c6357; font-size: .875rem; line-height: 1.45; }
.progress-count { white-space: nowrap; color: var(--green-dark); font-size: .875rem; font-weight: 750; font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 6px; margin-bottom: 11px; overflow: hidden; border: 0; border-radius: 20px; appearance: none; accent-color: var(--green); }
progress::-webkit-progress-bar { border-radius: 20px; background: #e5ede8; }
progress::-webkit-progress-value { border-radius: 20px; background: var(--green); transition: width .2s ease; }
progress::-moz-progress-bar { border-radius: 20px; background: var(--green); }
.batch-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.batch-actions .button { flex: 1 0 auto; min-height: 44px; }
.action-dock.has-output .process-button { color: #215a46; border-color: #c6dcd0; background: #edf6f0; }
.action-dock.has-output .process-button:hover:not(:disabled) { background: #dceee3; }
.action-dock.has-output .process-button:disabled { color: #65776c; }
.download-button .icon { width: 17px; height: 17px; }
.batch-actions.has-two-downloads .process-button { flex-basis: 100%; }

.queue-panel.is-clearing, .dropzone.is-clearing { overflow: hidden; pointer-events: none; }

.queue-title { display: flex; align-items: center; gap: 8px; }
.counter { padding: 2px 8px; border-radius: 20px; background: #edf4f0; color: #3b6252; font-size: .8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(156px, 100%), 1fr)); gap: 11px; list-style: none; margin: 0; padding: 0; }
.queue-row { min-width: 0; border-radius: 13px; border: 1px solid var(--line); overflow: hidden; background: white; }
.queue-row[data-state="processing"] { border-color: #60a990; box-shadow: 0 0 0 1px #60a99045; }
.tile-picture { position: relative; aspect-ratio: 1.35; background: #edf3ef; }
.thumb-button { position: absolute; inset: 0; display: grid; place-items: center; width: 100%; padding: 0; border: 0; color: #1b523f; background: transparent; }
.thumb-button:focus-visible { outline-offset: -3px; }
.thumb-button img { display: block; grid-area: 1 / 1; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.thumb-button .tile-placeholder { grid-area: 1 / 1; width: 28px; height: 28px; color: #769689; }
.thumb-button:has(img:not([hidden])) .tile-placeholder { visibility: hidden; }
.thumb-button .expand-icon { position: absolute; bottom: 6px; right: 6px; width: 27px; height: 27px; padding: 5px; border-radius: 7px; background: #fffffff0; border: 1px solid #d6e3db; }
.queue-row[data-state="success"] .tile-picture { background: white; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; color: #285d4b; background: white; border: 1px solid #d7e4dc; border-radius: 9px; }
.icon-button:hover:not(:disabled) { background: var(--mint); }
.icon-button:disabled { color: #7a8b81; }
.remove-button { position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; background: #fffffff0; }
.remove-button .icon { width: 15px; height: 15px; }
.file-info { display: grid; justify-items: start; align-content: start; gap: 4px; padding: 9px 9px 10px; border-top: 1px solid #edf2ee; }
.file-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; font-weight: 700; }
.file-state { display: inline-flex; align-items: center; gap: 5px; padding: 2px 6px; border-radius: 6px; color: #52655b; background: #f0f4f1; font-size: .8125rem; }
.file-state::before { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: currentColor; content: ""; }
.queue-row[data-state="processing"] .file-state { color: #115d46; background: #e0f4e8; }
.queue-row[data-state="success"] .file-state { color: #176343; background: #e7f6eb; }
.queue-row[data-state="error"] .file-state { color: #953b30; background: #fbebe8; }
.file-detail { font-size: .8125rem; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
.queue-row[data-state="error"] .file-detail { color: #8c3d32; }

dialog { width: min(770px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 18px; border: 1px solid var(--line); border-radius: 18px; color: var(--text); background: white; box-shadow: 0 24px 80px #092c1d55; }
dialog::backdrop { background: #102e24bf; }
.dialog-head { align-items: flex-start; }
.dialog-head h2 { align-self: center; min-width: 0; overflow-wrap: anywhere; }
.dialog-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dialog-images:has(#preview-result[hidden]) { grid-template-columns: minmax(0, 1fr); max-width: min(430px, 100%); margin-inline: auto; }
.dialog-images img { display: block; width: 100%; aspect-ratio: 1; max-height: min(53vh, 410px); object-fit: contain; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.dialog-images figcaption { margin-top: 7px; text-align: center; color: var(--muted); font-size: .875rem; }
.dialog-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 15px; }
.dialog-nav span { min-width: 66px; text-align: center; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
.previous-button .icon { transform: rotate(180deg); }

@media (max-width: 780px) {
    .shell { width: calc(100% - 32px); }
    .topbar-inner { min-height: 56px; }
    main { padding-block: 16px 36px; }
    body:has(.action-dock.is-active) main { padding-bottom: calc(136px + env(safe-area-inset-bottom)); }
    body:has(.action-dock .has-two-downloads .process-button:not([hidden])) main { padding-bottom: calc(176px + env(safe-area-inset-bottom)); }
    .hero { min-height: 154px; padding: 17px 19px; border-radius: 18px; }
    .hero h1 { font-size: clamp(1.64rem, 5vw, 2.5rem); }
    .hero-description { font-size: .875rem; }
    .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "upload" "settings" "queue"; gap: 12px; margin-top: 14px; }
    .settings-panel { position: static; }
    .panel { padding: 15px; border-radius: 15px; }
    .size-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .mode-options .size-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .output-format { margin-bottom: 0; }
    .action-dock:not(.is-active) { display: none; }
    .action-dock.is-active {
        position: fixed;
        z-index: 2;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 9px 16px calc(10px + env(safe-area-inset-bottom));
        background: var(--surface);
        box-shadow: 0 -8px 24px #21412e14;
    }
    .batch-actions .button { min-height: 44px; padding-inline: 9px; }
    .dialog-images figcaption { font-size: .8125rem; }
    .remove-button { width: 40px; height: 40px; }
}

@media (max-width: 490px) {
    .hero { gap: 9px; padding-inline: 14px; }
    .comparison { gap: 4px; }
    .comparison figure { width: clamp(48px, 13.6vw, 66px); padding: 3px; border-radius: 8px; }
    .comparison img { border-radius: 5px; }
    .comparison figcaption { font-size: .75rem; }
    .dropzone.has-files { grid-template-columns: auto minmax(0, 1fr); }
    .dropzone.has-files .drop-cta { grid-column: 2; justify-self: start; min-height: 35px; padding-block: 5px; }
    .drop-hint { font-size: .8125rem; }
    .size-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .queue { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

