﻿:root {
  color-scheme: light;
  --ink: oklch(22% 0.018 260);
  --muted: oklch(46% 0.022 260);
  --soft: oklch(60% 0.018 260);
  --line: oklch(86% 0.012 260);
  --line-strong: oklch(76% 0.018 260);
  --paper: oklch(98.8% 0.005 260);
  --panel: oklch(96% 0.01 260);
  --field: oklch(99.3% 0.004 260);
  --accent: oklch(52% 0.15 15);
  --accent-hover: oklch(40% 0.12 15);
  --accent-weak: oklch(93% 0.035 15);
  --accent-line: oklch(76% 0.06 15);
  --danger: oklch(54% 0.18 28);
  --success: oklch(55% 0.13 166);
  --shadow: 0 18px 48px oklch(34% 0.025 260 / 0.10);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100vh; color: var(--ink);
  background:
    radial-gradient(circle at 20% -6%, oklch(93% 0.06 15 / 0.6), transparent 30%),
    linear-gradient(180deg, oklch(97% 0.012 260), oklch(93% 0.01 260));
}

main { width: min(1280px, calc(100vw - 32px)); margin: 0 auto; padding: 24px 0 40px; }

.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 2px 2px 20px; }

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

.eyebrow { margin-bottom: 8px; color: var(--accent-hover); font-size: 12px; font-weight: 780; letter-spacing: 0.08em; text-transform: uppercase; }

h1 { margin-bottom: 8px; font-size: 32px; line-height: 1.15; }

.page-head p:not(.eyebrow) { max-width: 72ch; margin-bottom: 0; color: var(--muted); line-height: 1.65; font-size: 14px; }

.badge { border: 1px solid var(--accent-line); border-radius: 7px; padding: 9px 13px; color: var(--accent-hover); background: var(--accent-weak); font-size: 13px; font-weight: 720; white-space: nowrap; }

.workspace { display: grid; grid-template-columns: minmax(340px, 430px) minmax(0, 1fr); gap: 16px; align-items: start; }

.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--paper); box-shadow: var(--shadow); }

form { padding: 0 18px 18px; }

.panel-head, .result-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--line); padding: 15px 0; margin-bottom: 15px; }

.panel-head h2, .result-head h2 { margin-bottom: 3px; font-size: 16px; }
.panel-head p, .result-head p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }

.result-head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.field { display: grid; gap: 7px; margin-bottom: 14px; }

label { font-size: 13px; font-weight: 740; }

input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 7px;
  min-height: 42px; padding: 10px 11px; color: var(--ink);
  background: var(--field); font: inherit; font-size: 14px;
  outline: none; transition: border-color 160ms ease, box-shadow 160ms ease;
}

input::placeholder, textarea::placeholder { color: var(--soft); }

input:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 4px oklch(52% 0.15 15 / 0.12);
}

input[readonly] { color: var(--muted); background: var(--panel); cursor: not-allowed; user-select: all; }
textarea { min-height: 140px; resize: vertical; line-height: 1.55; }
.field p { margin-bottom: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.secret-field input { letter-spacing: 0.02em; }

/* Ecommerce hidden state — hides the checkbox field by default */
.ecom-hidden { display: none !important; }

.checkbox-group {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; background: var(--field);
}

.checkbox-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 520; cursor: pointer;
  padding: 3px 2px; border-radius: 4px;
  transition: background 120ms ease; white-space: nowrap;
}

.checkbox-item:hover { background: oklch(97% 0.008 260); }

.checkbox-item input[type="checkbox"] {
  width: 15px; height: 15px; min-height: auto; padding: 0;
  accent-color: var(--accent-hover); cursor: pointer; flex-shrink: 0;
}

.file-shell {
  display: grid; gap: 8px; border: 1px dashed var(--line-strong);
  border-radius: 8px; padding: 10px; background: var(--panel);
}

.file-shell input { border-style: solid; background: var(--field); }

.local-preview {
  display: grid; place-items: center; min-height: 140px;
  margin: 2px 0 16px; border: 1px dashed var(--line);
  border-radius: 8px; color: var(--muted); background: var(--panel);
  overflow: hidden; font-size: 13px;
}

.local-preview img { display: block; max-width: 100%; max-height: 240px; border-radius: 6px; }

.actions { display: flex; gap: 10px; padding-top: 2px; }

button {
  border: 0; border-radius: 7px; min-height: 44px; padding: 12px 16px;
  color: #fff; background: var(--accent-hover); font: inherit;
  font-size: 14px; font-weight: 760; cursor: pointer;
  transition: background-color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

button:hover:not(:disabled) { background: oklch(36% 0.11 15); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: 0.6; }

.secondary { border: 1px solid var(--line); color: var(--ink); background: var(--field); }
.secondary:hover:not(:disabled) { background: var(--panel); }

.small { min-height: 34px; padding: 6px 12px; font-size: 12px; }

.result { overflow: hidden; }
.result-head { margin-bottom: 0; padding: 14px 18px; background: oklch(97% 0.008 250); }

#stateText {
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px;
  color: var(--muted); background: var(--field); font-size: 13px; white-space: nowrap;
}
#stateText.error { color: var(--danger); }
#stateText.success { color: var(--success); }

.preview {
  padding: 18px;
  background:
    linear-gradient(45deg, oklch(92% 0.006 260) 25%, transparent 25%),
    linear-gradient(-45deg, oklch(92% 0.006 260) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, oklch(92% 0.006 260) 75%),
    linear-gradient(-45deg, transparent 75%, oklch(92% 0.006 260) 75%);
  background-color: oklch(96.5% 0.007 260);
  background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0;
  min-height: 400px;
}

.preview p { display: grid; place-items: center; min-height: 360px; max-width: 430px; margin: 0 auto; color: var(--muted); text-align: center; line-height: 1.7; }

.preview img.single-output { display: block; max-width: 100%; max-height: 70vh; margin: 0 auto; border-radius: 10px; box-shadow: 0 22px 62px oklch(34% 0.025 260 / 0.20); }

.preview .image-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: 100%; }

.preview .image-grid img {
  display: block; width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 8px; box-shadow: 0 8px 28px oklch(34% 0.025 260 / 0.14);
  cursor: pointer; transition: transform 160ms ease, box-shadow 160ms ease;
}

.preview .image-grid img:hover { transform: scale(1.03); box-shadow: 0 14px 40px oklch(34% 0.025 260 / 0.22); }

.preview .image-grid .image-card { display: flex; flex-direction: column; gap: 6px; }
.preview .image-grid .image-label { font-size: 11px; color: var(--muted); text-align: center; font-weight: 620; }

.image-grid .image-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: min(148px, 100%);
  margin: 0 auto;
}

.image-grid .download-single, .image-grid .modify-single {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; font-size: 11px; font-weight: 640;
  cursor: pointer; text-decoration: none; min-height: 30px;
}

.image-grid .download-single { color: var(--accent-hover); background: var(--field); }
.image-grid .download-single:hover { background: var(--accent-weak); border-color: var(--accent-line); }

.image-grid .modify-single { color: oklch(52% 0.14 250); background: oklch(97% 0.02 250); border-color: oklch(80% 0.04 250); }
.image-grid .modify-single:hover { background: oklch(92% 0.04 250); border-color: oklch(65% 0.08 250); }

details { border-top: 1px solid var(--line); padding: 14px 18px 16px; background: oklch(97% 0.008 250); }
summary { cursor: pointer; color: var(--accent-hover); font-weight: 760; font-size: 14px; }

pre {
  overflow: auto; max-height: 280px; margin: 12px 0 0;
  border: 1px solid var(--line); border-radius: 7px; padding: 12px;
  background: oklch(20% 0.018 260); color: oklch(92% 0.01 260);
  font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}

.mode-hint { display: none; margin: -8px 0 12px; padding: 8px 12px; border-radius: 7px; background: var(--accent-weak); color: var(--accent-hover); font-size: 12px; font-weight: 620; line-height: 1.55; }
.mode-hint.visible { display: block; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.loading-text { animation: pulse 1.4s ease-in-out infinite; }

@media (max-width: 880px) {
  .page-head, .workspace { grid-template-columns: 1fr; }
  .page-head { align-items: start; gap: 12px; }
  .badge { width: fit-content; }
  .workspace { gap: 14px; }
  .preview { min-height: 320px; }
  .preview .image-grid { grid-template-columns: repeat(2, 1fr); }
  .checkbox-group { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  main { width: min(100vw - 14px, 1180px); padding: 12px 0 20px; }
  h1 { font-size: 24px; }
  .preview { min-height: 260px; padding: 14px; }
  .preview .image-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .checkbox-group { grid-template-columns: 1fr 1fr; }
  .actions { position: sticky; bottom: 0; z-index: 2; display: grid; grid-template-columns: minmax(0, 1fr) auto; margin: 0 -18px -18px; border-top: 1px solid var(--line); padding: 10px 18px; background: oklch(98.5% 0.006 260 / 0.96); }
  input, textarea, select { min-height: 46px; font-size: 16px; }
}

@media (max-width: 380px) {
  .preview .image-grid { grid-template-columns: 1fr; }
  .checkbox-group { grid-template-columns: 1fr; }
}
