:root {
  color-scheme: light;
  --ink: #1f2620;
  --muted: #6d756c;
  --paper: #f7f5ef;
  --panel: #fffffb;
  --line: #d8d2c4;
  --accent: #2f6f5e;
  --accent-dark: #17493d;
  --warm: #d7a948;
  --shadow: 0 22px 60px rgba(43, 45, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-serif, Georgia, "Times New Roman", "Noto Serif TC", serif;
  background:
    linear-gradient(135deg, rgba(47, 111, 94, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(215, 169, 72, 0.18), transparent 40%),
    var(--paper);
  color: var(--ink);
}

button,
input,
a {
  font: inherit;
}

.shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.workspace {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}

.panel,
.preview {
  background: rgba(255, 255, 251, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  position: sticky;
  top: 28px;
  padding: 22px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.mark {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background:
    radial-gradient(circle at 64% 36%, var(--warm) 0 18%, transparent 19%),
    linear-gradient(135deg, transparent 0 45%, var(--accent) 46% 100%);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.inline-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 168px;
  padding: 18px;
  border: 1.5px dashed #9a927e;
  border-radius: 8px;
  background: #f2eee3;
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.dropzone:hover {
  border-color: var(--accent);
  background: #eee8d9;
  transform: translateY(-1px);
}

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

.drop-title {
  display: block;
  font-size: 22px;
  font-weight: 700;
}

.drop-subtitle {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.settings {
  display: grid;
  gap: 18px;
  margin: 22px 0;
}

.settings label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}

.settings input {
  grid-column: 1 / -1;
  accent-color: var(--accent);
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.primary {
  position: relative;
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fffdf6;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.primary:disabled {
  cursor: progress;
  opacity: 0.76;
  transform: none;
}

.spinner {
  display: none;
  width: 18px;
  height: 18px;
  margin-left: 10px;
  vertical-align: -4px;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.primary.is-loading .spinner {
  display: inline-block;
}

.status {
  min-height: 22px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.hero-preview {
  grid-row: span 2;
}

.preview {
  overflow: hidden;
}

.preview-head {
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.preview-head a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 330px;
  padding: 16px;
  overflow: hidden;
}

.hero-preview .stage {
  min-height: 718px;
}

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

.bg-stage {
  background: #eee8dc;
}

.stage img {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.bg-stage .background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  opacity: 0.24;
  z-index: 0;
}

.empty {
  position: absolute;
  inset: auto;
  color: var(--muted);
  font-size: 14px;
  z-index: 2;
}

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

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

@media (max-width: 980px) {
  .workspace,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .hero-preview {
    grid-row: auto;
  }

  .hero-preview .stage,
  .stage {
    min-height: 420px;
  }
}

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

  .controls {
    padding: 18px;
  }

  h1 {
    font-size: 24px;
  }

  .stage,
  .hero-preview .stage {
    min-height: 320px;
  }
}
