:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #17212b;
  --muted: #637083;
  --line: #dce2e8;
  --primary: #15966a;
  --primary-dark: #0f6f50;
  --accent: #f06b45;
  --warning: #b45309;
  --shadow: 0 18px 50px rgba(23, 33, 43, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(21, 150, 106, 0.08), transparent 34%),
    linear-gradient(300deg, rgba(240, 107, 69, 0.1), transparent 30%),
    var(--bg);
  color: var(--ink);
}

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

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    opacity 0.18s ease;
}

button:hover {
  background: var(--primary-dark);
}

button:active {
  transform: translateY(1px);
}

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

.ghost {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

.ghost:hover {
  background: #f1f5f4;
}

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

.hidden {
  display: none !important;
}

.login-panel {
  width: min(460px, calc(100vw - 32px));
  margin: 10vh auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: fit-content;
  margin-bottom: 16px;
  padding: 6px 10px;
  border: 1px solid rgba(21, 150, 106, 0.24);
  border-radius: 999px;
  color: var(--primary-dark);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark.compact {
  margin-bottom: 8px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 18px;
  letter-spacing: 0;
}

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

p,
span,
label,
pre {
  line-height: 1.65;
}

.login-panel p,
.result-head p,
.empty-state span,
.product-card,
.section-head span,
.message {
  color: var(--muted);
}

.login-form,
.control-panel,
.control-section {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

label span {
  font-size: 14px;
}

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

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 126px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 150, 106, 0.13);
}

.message {
  min-height: 24px;
  font-size: 14px;
}

.message.error {
  color: #b42318;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin-bottom: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(240, 107, 69, 0.28);
  border-radius: 999px;
  background: rgba(240, 107, 69, 0.09);
  color: #8a341d;
  font-size: 14px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 18px;
  align-items: start;
}

.control-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 38px rgba(23, 33, 43, 0.08);
}

.control-panel {
  padding: 18px;
}

.control-section {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.control-section:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.section-head,
.result-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.product-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  font-size: 14px;
}

.product-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

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

.template-option {
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #f8faf9;
  cursor: pointer;
}

.template-option.selected {
  border-color: var(--primary);
  background: #eef9f4;
}

.template-option img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: white;
}

.template-option span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.result-panel {
  min-height: 70vh;
  padding: 18px;
}

.result-head {
  margin-bottom: 16px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 360px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.54);
  text-align: center;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.image-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.image-frame {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: var(--image-ratio, 1 / 1);
  overflow: hidden;
  border-radius: 6px;
  background: #eef2f4;
}

.image-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card h3 {
  margin: 0;
  min-height: 44px;
}

.image-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.image-actions button,
.image-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}

.image-actions a {
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
}

.copy-card {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.copy-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #2f3b46;
  font-family: inherit;
}

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

  .control-panel {
    position: static;
  }
}

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

  .login-panel {
    margin-top: 4vh;
    padding: 22px;
  }

  .topbar,
  .section-head,
  .result-head {
    display: grid;
  }

  .top-actions {
    justify-content: space-between;
  }

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

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