:root {
  color-scheme: light;
  --ink: #22252a;
  --muted: #6d727a;
  --line: #d8dde3;
  --surface: #ffffff;
  --surface-soft: #f5f7f8;
  --accent: #146c6c;
  --accent-strong: #0f5050;
  --accent-soft: #d9eeee;
  --warm: #d9664f;
  --gold: #c89b3c;
  --shadow: 0 18px 50px rgba(29, 37, 45, 0.11);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(20, 108, 108, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(217, 102, 79, 0.08), transparent 40%),
    #eef2f3;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
label {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: flex;
  height: 100vh;
  width: min(1480px, 100%);
  margin: 0 auto;
  flex-direction: column;
  padding: 14px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 12px;
}

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

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.05;
  font-weight: 850;
}

.model-pill {
  min-width: 138px;
  border: 1px solid rgba(20, 108, 108, 0.28);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
  text-align: center;
}

.workspace {
  display: grid;
  min-height: 0;
  flex: 1;
  grid-template-columns: minmax(288px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.control-panel,
.image-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.control-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
  padding: 14px;
}

.upload-zone {
  display: grid;
  min-height: 112px;
  cursor: pointer;
  place-items: center;
  border: 1px dashed #aeb7be;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 108, 108, 0.09), rgba(217, 102, 79, 0.05)),
    var(--surface-soft);
  text-align: center;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    background 160ms ease;
}

.upload-zone:hover,
.upload-zone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(20, 108, 108, 0.25);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-size: 28px;
  line-height: 1;
}

.upload-title {
  margin-top: -8px;
  font-weight: 780;
}

.upload-meta {
  margin-top: -14px;
  color: var(--muted);
  font-size: 12px;
}

.section {
  display: grid;
  gap: 10px;
}

.section-title,
.field-label {
  color: #3b4148;
  font-size: 13px;
  font-weight: 780;
}

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

.preset {
  min-height: 44px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 720;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.preset:hover {
  border-color: rgba(20, 108, 108, 0.45);
}

.preset.is-active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 76px;
  resize: vertical;
  padding: 11px 12px;
  line-height: 1.5;
}

select {
  min-height: 40px;
  padding: 0 10px;
}

textarea:focus,
select:focus,
.primary-action:focus-visible,
.secondary-action:focus-visible,
.preset:focus-visible,
.ghost-action:focus-visible {
  outline: 3px solid rgba(20, 108, 108, 0.24);
  outline-offset: 2px;
}

.compact-grid {
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: center;
}

.primary-action {
  min-height: 48px;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 820;
  transition:
    background 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.primary-action:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-action {
  min-height: 42px;
  cursor: pointer;
  border: 1px solid rgba(20, 108, 108, 0.28);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 820;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    transform 140ms ease,
    opacity 140ms ease;
}

.secondary-action:hover:not(:disabled) {
  border-color: rgba(20, 108, 108, 0.48);
  background: #c9e7e7;
  transform: translateY(-1px);
}

.secondary-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.status {
  min-height: 42px;
  margin: auto 0 0;
  border-left: 3px solid var(--gold);
  padding: 5px 0 5px 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status.is-error {
  border-left-color: var(--warm);
  color: #9d3d2d;
}

.preview-area {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.image-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.pane-head {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 0 16px;
  color: #3b4148;
  font-size: 13px;
  font-weight: 780;
}

.pane-head span:last-child {
  color: var(--muted);
  font-weight: 650;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost-action {
  display: inline-grid;
  min-width: 76px;
  min-height: 34px;
  cursor: pointer;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
}

.ghost-action:hover:not(:disabled):not([aria-disabled="true"]) {
  border-color: rgba(20, 108, 108, 0.5);
  color: var(--accent);
}

.ghost-action:disabled,
.ghost-action[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.45;
  pointer-events: none;
}

.image-frame {
  position: relative;
  display: grid;
  min-height: 0;
  place-items: center;
  background:
    linear-gradient(45deg, #f3f5f6 25%, transparent 25%),
    linear-gradient(-45deg, #f3f5f6 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f3f5f6 75%),
    linear-gradient(-45deg, transparent 75%, #f3f5f6 75%),
    #fff;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
  background-size: 20px 20px;
}

.image-frame img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 16px;
}

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

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

.empty-state {
  display: grid;
  width: min(280px, 70%);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(109, 114, 122, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 780;
}

.loading-cover {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent-strong);
  font-weight: 820;
}

.loading-cover.is-visible {
  display: grid;
}

.loading-cover span {
  display: block;
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  border: 4px solid rgba(20, 108, 108, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 780ms linear infinite;
}

.loading-cover p {
  margin: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 38vh) minmax(0, 1fr);
  }

  .preview-area {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
    overflow-x: auto;
  }

  .control-panel,
  .image-pane {
    min-height: 0;
  }

  .image-frame {
    min-height: 0;
  }
}

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

  .topbar {
    align-items: center;
    flex-direction: row;
    padding-bottom: 10px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    font-size: 24px;
  }

  .model-pill {
    min-width: auto;
    padding: 8px 10px;
  }

  .control-panel {
    padding: 12px;
  }

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

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

  .pane-head {
    min-height: 56px;
    justify-content: center;
    padding: 8px 10px;
  }

  .result-actions {
    width: 100%;
  }

  .ghost-action {
    flex: 1;
  }

  .image-frame {
    min-height: 0;
  }
}
