:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #737779;
  --line: #d9dddc;
  --paper: #ffffff;
  --canvas: #f4f6f4;
  --accent: #167c6b;
  --accent-dark: #0f5f52;
  --coral: #e76f51;
  --shadow: 0 18px 55px rgba(21, 31, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #f7f7f5 0%, #edf4f1 52%, #fff7f3 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
a {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: flex;
  align-items: center;
}

.workbench {
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(32, 33, 36, 0.08);
  box-shadow: var(--shadow);
  border-radius: 8px;
  overflow: hidden;
}

.topbar,
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 26px;
}

.topbar {
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  letter-spacing: 0;
}

.ghost-link,
.download-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-link {
  min-width: 58px;
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.05fr);
  gap: 18px;
  padding: 22px 26px 8px;
}

.drop-zone {
  min-height: 154px;
  border: 1px dashed #a7b2af;
  border-radius: 8px;
  background: #fafcfb;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #f0faf6;
}

.drop-zone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.upload-title {
  font-weight: 800;
}

.upload-meta {
  max-width: calc(100% - 28px);
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls {
  min-height: 154px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 14px;
}

.mode-group {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mode-group legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mode-group label {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.mode-group input {
  position: absolute;
  opacity: 0;
}

.mode-group label:has(input:checked) {
  border-color: var(--accent);
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: #f2fbf8;
}

.primary-button {
  width: 100%;
  border: 0;
  color: #fff;
  background: var(--ink);
  font-weight: 900;
}

.primary-button:disabled {
  cursor: not-allowed;
  background: #b6bcbb;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 18px 26px 24px;
}

.preview-pane {
  min-width: 0;
}

.pane-head {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.pane-head h2 {
  color: var(--ink);
}

.pane-head span {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
  overflow: hidden;
  display: grid;
  place-items: center;
}

.checker {
  background-color: #f7f7f5;
  background-image:
    linear-gradient(45deg, rgba(0, 0, 0, 0.035) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.035) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.035) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.035) 75%);
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.image-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
}

.image-stage.has-image img {
  display: block;
}

.empty-state {
  color: #9ca3a1;
  font-weight: 900;
}

.image-stage.has-image .empty-state {
  display: none;
}

.loading {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: #fff;
  background: rgba(32, 33, 36, 0.72);
  font-weight: 900;
}

.image-stage.is-loading .loading {
  display: grid;
}

.batch-panel,
.gallery-panel {
  padding: 0 26px 24px;
}

.gallery-panel {
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.tool-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 0 12px;
}

.thumb-grid {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 12px;
  padding: 12px;
  align-items: stretch;
}

.thumb-grid > .empty-state {
  grid-column: 1 / -1;
  place-self: center;
}

.thumb-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto auto auto;
  gap: 7px;
  padding: 8px;
}

.thumb-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  background: var(--canvas);
}

.thumb-card strong,
.thumb-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thumb-card strong {
  font-size: 12px;
}

.thumb-card span {
  color: var(--muted);
  font-size: 12px;
}

.mini-link {
  min-height: 30px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
}

.statusbar {
  min-height: 74px;
  border-top: 1px solid var(--line);
  background: #fbfcfb;
}

.statusbar p {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-button {
  min-width: 118px;
  color: #fff;
  background: var(--accent);
  font-weight: 900;
}

.download-button.disabled {
  pointer-events: none;
  background: #b6bcbb;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 18px, 640px);
    padding: 9px 0;
    align-items: flex-start;
  }

  .topbar,
  .statusbar,
  .upload-panel,
  .preview-grid,
  .batch-panel,
  .gallery-panel {
    padding-left: 14px;
    padding-right: 14px;
  }

  .upload-panel,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .mode-group {
    grid-template-columns: 1fr;
  }

  .mode-group label {
    min-height: 48px;
  }

  h1 {
    font-size: 32px;
  }

  .thumb-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
