:root {
  --bg: #0e0d0c;
  --panel: #1a1816;
  --line: #34302b;
  --text: #f3eee8;
  --muted: #a69d92;
  --accent: #d7263d;
  --accent-2: #f4b942;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(14, 13, 12, 0.92); backdrop-filter: blur(8px); z-index: 5;
}
.brand { font-weight: 800; letter-spacing: 0.04em; font-size: 20px; }
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 1px 8px; vertical-align: 3px;
}
.lang button { background: none; border: 1px solid var(--line); padding: 4px 10px; cursor: pointer; }
.lang button:first-child { border-radius: 8px 0 0 8px; }
.lang button:last-child { border-radius: 0 8px 8px 0; border-left: 0; }
.lang button.on { background: var(--text); color: var(--bg); }

main { max-width: 720px; margin: 0 auto; padding: 16px; }
.hero h1 { font-size: clamp(28px, 7vw, 40px); line-height: 1.15; margin: 12px 0; }
.hero p { color: var(--muted); margin: 0 0 8px; }
h2 { font-size: 18px; margin: 28px 0 12px; }
.privacy { color: #8fd3a8; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
.error { color: #ff8a8a; }
.notice { background: #3a2a12; border: 1px solid #6b4b1a; color: #ffd89a; padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.design-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .design-grid { grid-template-columns: repeat(4, 1fr); } }
.design {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: #efe6da; color: #1d1a17; border: 2px solid transparent; border-radius: 14px; padding: 10px; cursor: pointer;
}
.design svg { width: 100%; aspect-ratio: 1; height: auto; }
.design span { font-size: 13px; font-weight: 600; }
.design:hover, .design:focus-visible { border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; font-weight: 600; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.wide { width: 100%; margin-top: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.row .btn { flex: 1 1 140px; }
.link { background: none; border: 0; color: var(--muted); padding: 4px 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.selected { display: flex; align-items: center; gap: 14px; margin-top: 8px; padding: 12px; background: var(--panel); border-radius: 14px; }
.selected-art { width: 76px; height: 76px; background: #efe6da; border-radius: 10px; display: grid; place-items: center; padding: 6px; }
.selected-art canvas { max-width: 100%; max-height: 100%; }
.selected-name { font-weight: 700; }
.tips { display: flex; gap: 14px; align-items: center; color: var(--muted); }
.tips svg { flex: 0 0 110px; color: var(--line); }
.tips p { margin: 0; font-size: 14px; }

.edit { padding-top: 0; }
.stage { position: relative; margin: 0 -16px; background: #000; }
#canvas { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chips { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.chip {
  pointer-events: auto; background: rgba(14, 13, 12, 0.72); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.chip.static { cursor: default; }
.compare {
  position: absolute; right: 10px; bottom: 10px; background: rgba(14, 13, 12, 0.72); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px; padding: 8px 14px; font-size: 13px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: pointer;
}
.gestures { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0; }
.controls { display: grid; gap: 14px; margin-top: 8px; }
@media (min-width: 560px) { .controls { grid-template-columns: 1fr 1fr; } }
.controls label { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; font-size: 14px; color: var(--muted); }
.controls output { color: var(--text); font-variant-numeric: tabular-nums; }
.controls input[type=range] { grid-column: 1 / -1; width: 100%; accent-color: var(--accent); }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); display: grid; place-items: center; z-index: 20; padding: 24px; }
.overlay-box { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px; width: min(360px, 100%); text-align: center; }
.spinner { width: 36px; height: 36px; margin: 0 auto 12px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.2s; }

.sheet-wrap { place-items: end center; padding: 0; }
.sheet { background: var(--panel); width: min(520px, 100%); border-radius: 18px 18px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 4px 0 12px; }
#part-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-item { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; text-align: left; }
.sheet-item:first-child { grid-column: 1 / -1; }
.sheet-item.on { border-color: var(--accent); background: #2a1215; }
