:root {
  color-scheme: light;
  --paper: #f7f3ea;
  --panel: #fffdf7;
  --ink: #1f2520;
  --muted: #68716d;
  --line: #d8d0c1;
  --line-strong: #b7aa96;
  --accent: #0d7f68;
  --accent-deep: #075a4b;
  --accent-soft: #d9eee6;
  --warn: #b65a2b;
  --blue: #356e9d;
  --shadow: 0 18px 42px rgba(45, 37, 22, 0.12);
  --radius: 8px;
  font-family: "Aptos", "Segoe UI Variable", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(90deg, rgba(31, 37, 32, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(31, 37, 32, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px clamp(14px, 2vw, 28px) 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-deep);
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 3vw, 3.25rem);
  line-height: 0.98;
  font-weight: 850;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  gap: 8px;
  width: min(520px, 100%);
}

.status-strip span {
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.76);
  padding: 10px 12px;
  min-height: 54px;
  display: grid;
  align-content: center;
  color: var(--muted);
  font-size: 0.8rem;
}

.status-strip strong {
  display: block;
  color: var(--ink);
  font-size: 1.2rem;
  line-height: 1.1;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 16px;
  align-items: start;
}

.control-panel,
.results-panel {
  border: 1px solid var(--line-strong);
  background: rgba(255, 253, 247, 0.92);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 16px;
  padding: 14px;
}

.drop-zone {
  display: grid;
  gap: 10px;
  min-height: 190px;
  place-items: center;
  padding: 22px 16px;
  border: 1px dashed var(--line-strong);
  background:
    linear-gradient(135deg, rgba(13, 127, 104, 0.08), rgba(53, 110, 157, 0.06)),
    var(--panel);
  text-align: center;
}

.drop-zone.is-dragover {
  border-color: var(--accent);
  outline: 3px solid rgba(13, 127, 104, 0.16);
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
}

.drop-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: var(--accent-deep);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.drop-title {
  font-weight: 800;
  font-size: 1.05rem;
}

.drop-copy {
  max-width: 28ch;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.button-row,
.action-panel,
.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button-row {
  margin-top: 10px;
}

.button {
  min-height: 40px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 750;
  transition:
    transform 0.16s ease,
    background-color 0.16s ease,
    border-color 0.16s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-deep);
}

.button.secondary {
  border-color: var(--line-strong);
  background: #fff7e7;
  color: var(--ink);
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.settings {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
}

legend {
  padding: 0 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.segmented label {
  min-width: 0;
}

.segmented input,
.radio-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-weight: 750;
  font-size: 0.88rem;
}

.segmented input:checked + span,
.radio-row input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.option-grid {
  display: grid;
  gap: 7px;
}

.radio-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.radio-row span {
  display: block;
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 7px 10px;
  color: var(--muted);
  font-weight: 700;
}

.custom-color {
  grid-template-columns: 1fr auto;
}

input[type="color"] {
  width: 42px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.range-stack {
  display: grid;
  gap: 8px;
}

.range-row,
.select-row {
  display: grid;
  grid-template-columns: minmax(86px, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.range-row input {
  grid-column: 1 / -1;
}

output {
  min-width: 54px;
  text-align: right;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  min-width: 150px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

.action-panel {
  margin-top: 14px;
}

.hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.results-panel {
  min-height: calc(100vh - 118px);
  padding: 16px;
}

.results-toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(160px, 260px);
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.results-toolbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
}

progress {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--panel);
}

progress::-webkit-progress-bar {
  background: var(--panel);
}

progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent), var(--blue));
}

.empty-state {
  display: grid;
  min-height: 460px;
  place-items: center;
  align-content: center;
  gap: 18px;
  border: 1px dashed var(--line);
  color: var(--muted);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-state p {
  width: min(420px, 90%);
  line-height: 1.55;
}

.empty-board {
  width: min(320px, 72vw);
  aspect-ratio: 5 / 3;
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(90deg, transparent 32%, rgba(13, 127, 104, 0.2) 32% 34%, transparent 34%),
    linear-gradient(transparent 58%, rgba(182, 90, 43, 0.22) 58% 60%, transparent 60%),
    conic-gradient(from 90deg, #e5ded1 25%, #faf6ed 0 50%, #e5ded1 0 75%, #faf6ed 0);
  background-size: auto, auto, 28px 28px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.result-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
}

.result-card[data-status="error"] {
  border-color: rgba(182, 90, 43, 0.6);
}

.preview-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

figure {
  min-width: 0;
}

figcaption {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.image-frame {
  display: grid;
  width: 100%;
  aspect-ratio: 1 / 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
}

.checker {
  background:
    conic-gradient(from 90deg, #d9d2c7 25%, #fbf8f0 0 50%, #d9d2c7 0 75%, #fbf8f0 0)
    0 0 / 18px 18px;
}

.image-frame img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.item-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.file-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dimensions {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-grid;
  min-width: 62px;
  min-height: 26px;
  place-items: center;
  border: 1px solid var(--line);
  background: #fff7e7;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.result-card[data-status="done"] .badge {
  border-color: rgba(13, 127, 104, 0.32);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.result-card[data-status="error"] .badge {
  border-color: rgba(182, 90, 43, 0.42);
  background: #f8dfcf;
  color: var(--warn);
}

.metric-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.metric-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saving {
  color: var(--accent-deep);
  font-weight: 850;
}

.size-out {
  color: var(--blue);
  font-weight: 800;
}

@media (max-width: 920px) {
  .topbar,
  .workbench,
  .results-toolbar {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
    align-items: start;
  }

  .status-strip {
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .control-panel {
    position: static;
  }

  .results-panel {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 10px;
  }

  .status-strip,
  .preview-pair,
  .button-row,
  .action-panel,
  .card-actions,
  .metric-row {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: 1fr;
  }
}
