:root {
  --bg: #f4efe7;
  --paper: rgba(255, 250, 244, 0.86);
  --paper-strong: #fff8ef;
  --ink: #1d1a16;
  --muted: #6d665d;
  --accent: #cf4c31;
  --accent-deep: #a43620;
  --line: rgba(33, 27, 22, 0.08);
  --shadow: 0 22px 60px rgba(77, 45, 18, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(207, 76, 49, 0.12), transparent 30%),
    radial-gradient(circle at bottom right, rgba(146, 117, 78, 0.12), transparent 28%),
    linear-gradient(135deg, #f8f3ec 0%, #efe5d7 100%);
}

.shell {
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero h1 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.04;
  max-width: 640px;
}

.hero-text {
  margin: 8px 0 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.hero-badge {
  border: 1px solid rgba(207, 76, 49, 0.22);
  background: rgba(255, 249, 243, 0.72);
  color: var(--accent-deep);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
}

.panel {
  background: var(--paper);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 18px;
}

.panel-header h2 {
  margin: 0;
  font-size: 19px;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.source-details {
  margin-top: 4px;
}

.source-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 248, 239, 0.75);
  border: 1px solid var(--line);
  font-weight: 700;
}

.source-summary::-webkit-details-marker {
  display: none;
}

.source-summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.source-header {
  margin-top: 14px;
}

.panel-header-gap {
  margin-top: 14px;
}

.upload-card,
.control-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.upload-card span,
.control-group label,
.hint-list p {
  font-size: 14px;
  font-weight: 700;
}

.upload-card input,
.control-group input,
.control-group select {
  width: 100%;
}

.upload-card input[type="file"] {
  padding: 14px;
  background: var(--paper-strong);
  border: 1px dashed rgba(29, 26, 22, 0.18);
  border-radius: 16px;
  cursor: pointer;
}

.control-group select {
  appearance: none;
  padding: 14px 16px;
  background: var(--paper-strong);
  border: 1px solid rgba(29, 26, 22, 0.12);
  border-radius: 16px;
  color: var(--ink);
  font: inherit;
}

.control-group input[type="range"] {
  accent-color: var(--accent);
}

.hint-list {
  margin-top: 24px;
  padding: 16px 18px;
  background: rgba(255, 248, 239, 0.85);
  border: 1px solid var(--line);
  border-radius: 20px;
}

.hint-list ul {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.mobile-dock {
  display: none;
}

.status-text {
  min-height: 22px;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

.export-result {
  margin-top: 14px;
  padding: 14px;
  background: rgba(255, 248, 239, 0.85);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.export-result a {
  color: var(--accent-deep);
  font-weight: 700;
  text-decoration: none;
}

.export-result img {
  display: block;
  width: 100%;
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button.primary {
  flex: 1;
  color: white;
  background: linear-gradient(135deg, var(--accent) 0%, #e47a2b 100%);
}

.stage-panel {
  padding: 18px;
}

.stage-wrap {
  position: relative;
  margin-top: 10px;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(45deg, rgba(0, 0, 0, 0.02) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 0, 0, 0.02) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 0, 0, 0.02) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 0, 0, 0.02) 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}

.source-stage {
  min-height: 220px;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  border-radius: 22px;
  background: white;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

#sourceCanvas {
  max-height: 24vh;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

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

@media (max-width: 980px) {
  .hero {
    flex-direction: column;
  }

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

  .actions {
    flex-direction: column;
  }

  .shell {
    width: min(100vw - 20px, 680px);
    padding: 10px 0 18px;
  }

  .controls,
  .stage-panel {
    padding: 12px;
  }

  .panel {
    border-radius: 18px;
  }

  .hero {
    gap: 8px;
    margin-bottom: 10px;
  }

  .hero-title-row {
    align-items: flex-start;
    gap: 8px;
  }

  .hero-text {
    font-size: 12px;
    line-height: 1.35;
  }

  .hero-badge {
    padding: 6px 10px;
    font-size: 11px;
  }

  .stage-wrap {
    min-height: 250px;
  }

  .source-stage {
    min-height: 150px;
  }

  canvas {
    max-height: 36vh;
  }

  #sourceCanvas {
    max-height: 16vh;
  }

  .source-details:not([open]) + .panel-header,
  .panel-header.panel-header-gap {
    margin-top: 8px;
  }

  .hint-list {
    display: none;
  }

  .actions {
    display: none;
  }

  .mobile-dock {
    position: sticky;
    bottom: 0;
    display: block;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(248, 243, 236, 0) 0%, rgba(248, 243, 236, 0.94) 28%);
    backdrop-filter: blur(10px);
  }

  .mobile-dock-button {
    width: 100%;
    box-shadow: 0 16px 34px rgba(207, 76, 49, 0.24);
  }

  body {
    padding-bottom: 84px;
  }

  .source-summary {
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
  }

  .source-summary small {
    font-size: 11px;
  }

  .source-header,
  .result-header p {
    display: none;
  }
}
