:root {
  color-scheme: light;
  --ink: #201912;
  --muted: #7b705f;
  --paper: #f7f2e7;
  --panel: rgba(255, 252, 245, 0.88);
  --line: rgba(90, 68, 28, 0.16);
  --gold: #b98a38;
  --gold-2: #e8c673;
  --deep: #2b2116;
  --red: #e71919;
  --shadow: 0 24px 80px rgba(72, 52, 22, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Microsoft YaHei", "Noto Sans SC", "PingFang SC", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 10%, rgba(230, 198, 115, 0.25), transparent 34%),
    radial-gradient(circle at 86% 14%, rgba(85, 67, 38, 0.18), transparent 32%),
    linear-gradient(135deg, #f7f0df 0%, #f3ead7 48%, #ebe1cf 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 14px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(185, 138, 56, 0.5);
}

button.primary {
  color: #fffaf0;
  border-color: transparent;
  background: linear-gradient(135deg, #2b2116, #927038);
  box-shadow: 0 14px 34px rgba(77, 54, 21, 0.22);
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 20px;
  min-height: 100vh;
  padding: 18px;
}

.left-panel,
.template-panel,
.topbar {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}

.left-panel {
  border-radius: 18px;
  padding: 18px;
  overflow: auto;
  max-height: calc(100vh - 36px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 22px;
  border-bottom: 1px solid var(--line);
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(185, 138, 56, 0.6);
  border-radius: 50%;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 700;
}

.brand-lockup p {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

.brand-lockup span,
.eyebrow,
.section-head span,
.upload-zone small {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-block {
  padding: 20px 0 4px;
  border-bottom: 1px solid var(--line);
}

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

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 16px;
}

label {
  display: grid;
  gap: 7px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input[type="text"],
input:not([type]) {
  width: 100%;
}

input[type="file"] {
  display: none;
}

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

input:not([type="range"]):not([type="checkbox"]) {
  height: 42px;
  border: 1px solid rgba(87, 65, 27, 0.18);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

input:focus {
  border-color: rgba(185, 138, 56, 0.72);
  box-shadow: 0 0 0 3px rgba(185, 138, 56, 0.12);
}

.upload-zone {
  min-height: 112px;
  place-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px dashed rgba(185, 138, 56, 0.48);
  border-radius: 14px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(244, 229, 188, 0.42)),
    repeating-linear-gradient(-45deg, rgba(185, 138, 56, 0.08) 0 1px, transparent 1px 9px);
}

.upload-zone.is-dragging {
  border-color: var(--gold);
  background: rgba(255, 248, 225, 0.95);
}

.upload-zone strong {
  font-size: 15px;
}

.mini-actions,
.export-actions {
  display: flex;
  gap: 10px;
}

.toggle-line {
  display: flex;
  grid-template-columns: unset;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.stage {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 18px;
  padding: 18px 20px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 38px);
  letter-spacing: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 320px;
  gap: 18px;
  min-height: 0;
}

.preview-wrap {
  display: grid;
  place-items: center;
  min-height: 0;
  border: 1px solid rgba(61, 45, 21, 0.12);
  border-radius: 18px;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.18)),
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, 0.75), transparent 44%);
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: min(100%, calc((100vh - 150px) * 0.5625));
  max-height: calc(100vh - 150px);
  aspect-ratio: 9 / 16;
  border-radius: 14px;
  box-shadow: 0 26px 80px rgba(50, 37, 19, 0.28);
  background: #fff;
}

.template-panel {
  border-radius: 18px;
  padding: 18px;
  overflow: auto;
  max-height: calc(100vh - 128px);
}

.template-grid {
  display: grid;
  gap: 12px;
}

.template-card {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 92px;
  padding: 10px;
  text-align: left;
  background: rgba(255, 255, 255, 0.58);
}

.template-card.active {
  border-color: rgba(185, 138, 56, 0.85);
  background: rgba(255, 248, 229, 0.82);
}

.template-thumb {
  width: 74px;
  height: 74px;
  border-radius: 10px;
  border: 1px solid rgba(78, 56, 20, 0.14);
  overflow: hidden;
}

.template-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 5px;
}

.template-card small {
  color: var(--muted);
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  padding: 10px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(32, 25, 18, 0.88);
  transition: 0.24s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .left-panel {
    max-height: none;
  }

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

  .template-panel {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .export-actions,
  .mini-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-wrap {
    padding: 12px;
  }
}
