:root {
  --bg: #f7f5f0;
  --surface: #fffcf5;
  --surface-2: #f2eee5;
  --ink: #171716;
  --muted: #6d6860;
  --line: #d8d2c6;
  --line-strong: #bfb6a8;
  --accent: #d84a3a;
  --accent-dark: #ad3428;
  --good: #247a57;
  --focus: #2f5fbb;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

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

button,
input {
  font: inherit;
}

.asset-warning {
  display: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.tool-panel {
  width: min(1040px, 100%);
  min-height: min(720px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.1;
  letter-spacing: 0;
  font-weight: 760;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 64px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  background: var(--surface-2);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  white-space: nowrap;
}

.status-pill.ready {
  color: var(--good);
  border-color: rgba(36, 122, 87, 0.35);
  background: rgba(36, 122, 87, 0.08);
}

.status-pill.busy {
  color: var(--accent-dark);
  border-color: rgba(216, 74, 58, 0.35);
  background: rgba(216, 74, 58, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  min-height: 0;
}

.upload-zone {
  position: relative;
  padding: 24px;
  border-right: 1px solid var(--line);
}

#imageInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-target {
  position: relative;
  height: clamp(230px, 34vh, 340px);
  min-height: 230px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #fbf8f1;
  overflow: hidden;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.drop-target:hover,
.drop-target.dragging {
  border-color: var(--accent);
  background: #fffaf1;
}

.drop-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.drop-icon svg,
.primary-button svg,
.download-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-copy {
  min-width: 0;
  display: grid;
  gap: 8px;
  text-align: center;
}

.drop-title {
  display: block;
  font-size: 20px;
  font-weight: 740;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-subtitle {
  display: block;
  color: var(--muted);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-wrap {
  display: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-2);
}

.preview-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.drop-target.has-file {
  grid-template-columns: minmax(86px, 32%) minmax(0, 1fr);
  place-items: stretch;
  align-items: center;
  align-content: center;
  gap: 14px;
  border-style: solid;
}

.drop-target.has-file .preview-wrap {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.drop-target.has-file .drop-icon {
  display: none;
}

.drop-target.has-file .drop-copy {
  align-self: center;
  text-align: left;
}

.result-panel {
  padding: 24px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  background: #fbf8f1;
}

.result-head {
  display: flex;
  align-items: center;
  min-height: 32px;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.step-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #aaa196;
}

.step-dot.ready {
  background: var(--good);
}

.step-dot.busy {
  background: var(--accent);
  animation: pulse 1s infinite ease-in-out;
}

.prep-guide {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  padding: 15px 16px;
}

.prep-guide h2 {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 760;
  letter-spacing: 0;
}

.prep-guide ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.prep-guide li + li {
  margin-top: 4px;
}

.server-warning {
  border: 1px solid rgba(216, 74, 58, 0.35);
  border-radius: 6px;
  background: rgba(216, 74, 58, 0.08);
  color: var(--accent-dark);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
}

.download-list {
  display: grid;
  align-content: start;
  gap: 10px;
}

.download-button {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  transition:
    border-color 140ms ease,
    background 140ms ease;
}

.download-button:hover {
  border-color: var(--focus);
  background: #fff;
}

.download-meta {
  min-width: 0;
}

.download-format {
  display: block;
  font-size: 15px;
  font-weight: 760;
  line-height: 1.2;
}

.download-name {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--accent-dark);
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
  font-weight: 740;
  transition:
    background 140ms ease,
    opacity 140ms ease;
}

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

.primary-button:focus-visible,
.download-button:focus-visible,
.drop-target:focus-visible {
  outline: 3px solid rgba(47, 95, 187, 0.24);
  outline-offset: 2px;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 12px;
    place-items: start center;
  }

  .tool-panel {
    min-height: auto;
  }

  .topbar {
    align-items: flex-start;
    padding: 16px;
  }

  h1 {
    font-size: clamp(28px, 8vw, 34px);
  }

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

  .upload-zone {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 14px 16px;
    min-height: 0;
  }

  .drop-target {
    height: 178px;
    min-height: 178px;
    padding: 14px;
  }

  .result-panel {
    grid-template-rows: auto auto auto auto;
    padding: 14px 16px 16px;
    gap: 12px;
  }

  .prep-guide {
    padding: 12px 13px;
  }

  .prep-guide h2 {
    margin-bottom: 7px;
    font-size: 14px;
  }

  .prep-guide ol {
    font-size: 13px;
    line-height: 1.48;
  }

  .drop-target.has-file {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .drop-target.has-file .drop-title {
    font-size: 18px;
  }

  .primary-button {
    min-height: 48px;
  }
}
