:root {
  --bg: #f4f0e8;
  --surface: #fffaf2;
  --surface-strong: #fffdf8;
  --ink: #1d1c19;
  --muted: #6e6a62;
  --line: rgba(29, 28, 25, 0.14);
  --accent: #176b5d;
  --accent-ink: #ffffff;
  --danger: #b13d2e;
  --danger-ink: #ffffff;
  --shadow: 0 24px 80px rgba(45, 36, 22, 0.16);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background:
    linear-gradient(120deg, rgba(23, 107, 93, 0.12), transparent 34%),
    linear-gradient(250deg, rgba(177, 61, 46, 0.10), transparent 38%),
    var(--bg);
  color: var(--ink);
}

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

.shell {
  width: min(1440px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 4px 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.status-pill {
  min-width: 92px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.72);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.status-pill.ready {
  border-color: rgba(23, 107, 93, 0.32);
  background: rgba(23, 107, 93, 0.1);
  color: var(--accent);
}

.status-pill.rejected {
  border-color: rgba(177, 61, 46, 0.3);
  background: rgba(177, 61, 46, 0.1);
  color: var(--danger);
}

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

.preview-panel,
.info-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 242, 0.78);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.preview-panel {
  min-height: calc(100svh - 112px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}

.image-stage {
  position: relative;
  min-height: 520px;
  background:
    linear-gradient(45deg, rgba(29, 28, 25, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(29, 28, 25, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(29, 28, 25, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(29, 28, 25, 0.05) 75%);
  background-color: #eee7dc;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  background-size: 24px 24px;
}

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

.image-stage.fill img {
  object-fit: cover;
}

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

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 20px;
}

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

.preview-tools {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.86);
}

.ghost-button,
.secondary-button,
.primary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  text-decoration: none;
}

.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.ghost-button:disabled,
.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.info-panel {
  min-height: calc(100svh - 112px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.summary > div {
  min-width: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.label,
.section-title,
dt {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
  line-height: 1.25;
}

.prompt-box,
.endpoint-box {
  min-width: 0;
}

.prompt-box p {
  margin: 0;
  max-height: 240px;
  overflow: auto;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
}

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

dd {
  margin: 0;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.message {
  min-height: 44px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--muted);
  line-height: 1.45;
}

.message.error {
  border-color: rgba(177, 61, 46, 0.3);
  background: rgba(177, 61, 46, 0.08);
  color: var(--danger);
}

.message.success {
  border-color: rgba(23, 107, 93, 0.32);
  background: rgba(23, 107, 93, 0.08);
  color: var(--accent);
}

.actions,
.mobile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-button {
  grid-column: 1 / -1;
  background: var(--surface-strong);
  color: var(--ink);
  border: 1px solid var(--line);
}

.primary-button {
  color: var(--accent-ink);
  padding: 0 16px;
}

.approve {
  background: var(--accent);
}

.reject {
  background: var(--danger);
}

.mobile-actions {
  display: none;
}

@media (max-width: 920px) {
  .shell {
    padding: 14px 12px 96px;
  }

  .topbar {
    align-items: flex-start;
  }

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

  .preview-panel,
  .info-panel {
    min-height: auto;
  }

  .image-stage {
    min-height: min(72svh, 620px);
  }

  .info-panel {
    padding: 14px;
  }

  .actions {
    display: none;
  }

  .mobile-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: grid;
    padding: 10px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255, 250, 242, 0.94);
    backdrop-filter: blur(14px);
  }
}

@media (max-width: 540px) {
  .topbar {
    gap: 10px;
  }

  .status-pill {
    min-width: 78px;
    font-size: 13px;
  }

  .summary {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .preview-tools {
    grid-template-columns: 1fr;
  }

  .ghost-button {
    flex: 1 1 100%;
  }

  .prompt-box p {
    max-height: none;
  }
}
