:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #66727d;
  --line: #dbe3e7;
  --paper: #f7f9fa;
  --panel: #ffffff;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --action: #ff7a1a;
  --action-strong: #ea580c;
  --warm: #f97316;
  --blue: #2563eb;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(24, 39, 49, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  min-height: 100vh;
  padding: 24px;
}

.workspace,
.settings {
  min-width: 0;
}

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

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: 0;
}

.dropzone {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 18px;
  min-height: 150px;
  padding: 26px;
  border: 2px dashed #9bb6bc;
  border-radius: 8px;
  background: #eef7f6;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background: #e1f3ee;
  transform: translateY(-1px);
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 30px;
  font-weight: 800;
}

.dropzone h2 {
  font-size: 21px;
  line-height: 1.25;
  margin-bottom: 8px;
}

.dropzone p,
.results-head span,
.panel-title span,
.empty-state p {
  color: var(--muted);
  line-height: 1.55;
}

.results-shell {
  margin-top: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.results-head div {
  display: grid;
  gap: 4px;
}

.primary-button,
.secondary-button,
.ghost-button,
.preset-grid button,
.quick-sizes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 13px;
  font-weight: 700;
}

.primary-button {
  background: var(--action);
  color: #fff;
  box-shadow: 0 10px 22px rgba(249, 115, 22, 0.28);
}

.primary-button:hover {
  background: var(--action-strong);
}

.primary-button:disabled {
  cursor: progress;
  background: #94a3b8;
  color: #fff;
  box-shadow: none;
}

.secondary-button {
  background: #fff;
  border-color: #b7c5cb;
  color: var(--ink);
}

.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  min-height: 220px;
  padding: 18px;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.empty-state span {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: #ecf0f3;
  color: var(--blue);
  font-size: 28px;
}

.settings {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(24, 39, 49, 0.08);
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2 {
  font-size: 18px;
}

.preset-grid,
.quick-sizes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.preset-grid button,
.quick-sizes button {
  min-width: 0;
  background: #f4f7f8;
  border-color: #d7e1e5;
  color: #24313a;
  white-space: nowrap;
}

.preset-grid button:hover,
.quick-sizes button:hover {
  border-color: var(--warm);
  background: #fff7ed;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: #34434d;
  font-size: 14px;
  font-weight: 700;
}

input[type="number"],
input[type="color"],
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c9d5db;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

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

input[type="color"] {
  padding: 4px;
}

output {
  justify-self: end;
  color: var(--accent);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.image-card {
  display: grid;
  grid-template-rows: 180px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.thumb-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  border: 0;
  padding: 0;
  overflow: hidden;
  background:
    linear-gradient(45deg, #f0f3f4 25%, transparent 25%),
    linear-gradient(-45deg, #f0f3f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f3f4 75%),
    linear-gradient(-45deg, transparent 75%, #f0f3f4 75%);
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

.thumb-wrap:not(:disabled)::after {
  content: "点击预览";
  position: absolute;
  left: 10px;
  bottom: 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.92);
  color: #fff;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.thumb-wrap:not(:disabled):hover::after,
.thumb-wrap:not(:disabled):focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.thumb-wrap:not(:disabled):focus-visible {
  outline: 3px solid rgba(255, 122, 26, 0.58);
  outline-offset: -3px;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status {
  position: absolute;
  top: 10px;
  right: 10px;
  max-width: calc(100% - 20px);
  border-radius: 999px;
  background: rgba(23, 32, 38, 0.82);
  color: #fff;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.done {
  background: var(--accent);
}

.status.error {
  background: var(--danger);
}

.card-body {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.card-body h3 {
  overflow: hidden;
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  min-width: 0;
  color: #26333c;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
}

.preview-modal[hidden] {
  display: none;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 24, 0.72);
}

.preview-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1180px, 100%);
  max-height: min(92vh, 900px);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.preview-head,
.preview-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.preview-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.preview-head h2 {
  max-width: min(720px, 70vw);
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-head p,
#previewHint {
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  font-size: 24px;
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 320px;
  overflow: auto;
  padding: 18px;
  background:
    linear-gradient(45deg, #eef2f3 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f3 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f3 75%);
  background-color: #fbfcfd;
  background-position:
    0 0,
    0 12px,
    12px -12px,
    -12px 0;
  background-size: 24px 24px;
}

.preview-stage img {
  max-width: 100%;
  max-height: 68vh;
  object-fit: contain;
  box-shadow: 0 8px 28px rgba(24, 39, 49, 0.2);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .settings {
    order: -1;
  }
}

@media (max-width: 620px) {
  .topbar,
  .results-head {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 26px;
  }

  .dropzone {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .drop-icon {
    width: 50px;
    height: 50px;
  }

  .two-col,
  .preset-grid,
  .quick-sizes {
    grid-template-columns: 1fr;
  }

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

  .preview-modal {
    padding: 10px;
  }

  .preview-head,
  .preview-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .preview-head {
    padding-right: 58px;
  }

  .preview-head .icon-button {
    position: absolute;
    top: 12px;
    right: 12px;
  }

  .preview-head h2 {
    max-width: 100%;
  }
}
