:root {
  color-scheme: light dark;
  --bg: #f2f4f1;
  --surface: #ffffff;
  --surface-muted: #e8ece8;
  --text: #26352b;
  --muted: #68736b;
  --border: rgba(53, 76, 60, 0.16);
  --accent: #48644f;
  --accent-hover: #354a3b;
  --danger: #a33d3d;
  --success: #37714a;
  --shadow: 0 18px 50px rgba(33, 47, 38, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171c18;
    --surface: #232a25;
    --surface-muted: #2c352f;
    --text: #edf2ee;
    --muted: #aab5ac;
    --border: rgba(213, 226, 216, 0.13);
    --accent: #9fb7a4;
    --accent-hover: #b5c9b9;
    --danger: #e08a8a;
    --success: #88c99a;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei UI", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.back-link:hover {
  color: var(--text);
}

.tool-heading {
  margin: 42px 0 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.lead {
  max-width: 60ch;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.privacy-badge {
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
}

.panel h2 {
  margin: 0 0 20px;
  font-size: 17px;
  letter-spacing: -0.015em;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

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

label,
.label {
  font-size: 13px;
  font-weight: 650;
}

input[type="text"],
input[type="url"],
input[type="number"],
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 150ms ease, background-color 150ms ease, opacity 150ms ease;
}

.button:hover {
  background: var(--accent-hover);
}

.button:active {
  transform: scale(0.98);
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.button.secondary {
  color: var(--text);
  background: var(--surface-muted);
  border-color: var(--border);
}

.button.secondary:hover {
  background: var(--bg);
}

.preview {
  min-height: 320px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border);
  border-radius: 18px;
  background: var(--bg);
  color: var(--muted);
  text-align: center;
}

.preview img,
.preview video,
.preview canvas,
.preview object {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
}

.preview canvas {
  width: auto;
  max-width: 100%;
  cursor: crosshair;
}

.status {
  min-height: 44px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface-muted);
  line-height: 1.5;
}

.status[data-kind="loading"] {
  color: var(--text);
}

.status[data-kind="success"] {
  color: var(--success);
}

.status[data-kind="error"] {
  color: var(--danger);
}

.status:empty {
  display: none;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.color-chip {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgb(255 255 255);
}

.advanced {
  margin: 18px 0;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 650;
}

.viewer-stage {
  min-height: 620px;
}

#model-viewer {
  width: 100%;
  height: 620px;
}

#model-viewer canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: none;
  cursor: grab;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 24px, 1120px);
    padding-top: 18px;
  }

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

  .tool-heading {
    margin-top: 28px;
    gap: 16px;
  }

  .privacy-badge {
    width: fit-content;
  }

  .panel {
    padding: 18px;
    border-radius: 18px;
  }

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

  .preview,
  .viewer-stage,
  #model-viewer {
    min-height: 360px;
    height: 360px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
