* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #f3f1ec;
  --card: #ffffff;
  --ink: #2f2b26;
  --muted: #8a8378;
  --line: #e6e1d8;
  --accent: #c98a7d;
}

html, body { height: 100%; }

html { touch-action: manipulation; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  -webkit-touch-callout: none;
}

.view {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: 76px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 48px);
  padding-left: 20px;
  padding-right: 20px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}
.view.hidden { display: none; }

.header { text-align: center; margin-bottom: 22px; }
.logo { font-size: 24px; font-weight: 700; letter-spacing: 2px; }
.logo.small { font-size: 18px; letter-spacing: 1px; }
.subtitle { font-size: 13px; color: var(--muted); margin-top: 8px; }

.card {
  background: var(--card);
  border-radius: 18px;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 24px rgba(80, 65, 45, .06);
}
.card > * + * { margin-top: 20px; }

.field { display: flex; flex-direction: column; }
.field > * + * { margin-top: 9px; }
.field > label { font-size: 14px; font-weight: 600; color: #5a544b; }

.field input[type="text"],
.field input[type="date"] {
  width: 100%;
  padding: 14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  background: #faf9f6;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus { border-color: var(--accent); }

.upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 150px;
  border: 1.5px dashed #cfc8bc;
  border-radius: 14px;
  background: #faf9f6;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload .upload-icon { font-size: 34px; line-height: 1; color: #c4bcad; font-weight: 300; margin-bottom: 8px; }
.upload:active, .upload.drag { border-color: var(--accent); background: #f7efec; }
.upload.has-img { border-style: solid; border-color: #9ecbb3; color: #4a8f6b; }
.upload.has-img .upload-icon { color: #4a8f6b; }

.swatches { display: flex; flex-wrap: wrap; margin: 7px -7px -7px; }
.swatch {
  width: 40px; height: 40px;
  margin: 7px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  position: relative;
  transition: transform .12s;
}
.swatch:active { transform: scale(.92); }
.swatch.active { border-color: var(--ink); }
.swatch.active::after {
  content: "";
  position: absolute;
  top: -6px; right: -6px; bottom: -6px; left: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
}

.field-row { flex-direction: row; flex-wrap: wrap; }
.field-row > * + * { margin-left: 22px; margin-top: 0; }
.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 400 !important;
  color: #5a544b; cursor: pointer;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.btn {
  padding: 15px;
  border-radius: 14px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.primary { background: var(--ink); color: #fff; margin-top: 20px; }
.btn.primary:active { opacity: .88; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--muted); margin-top: 0; }
.btn.ghost:active { border-color: var(--accent); color: var(--accent); }

/* 结果视图 */
.result-header {
  justify-content: center;
  margin-bottom: 16px;
}
.link {
  background: none; border: none;
  font-size: 15px; color: var(--accent);
  cursor: pointer; padding: 4px;
  min-width: 72px;
  text-align: left;
}
.link.placeholder { visibility: hidden; }

.result-canvas {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(60, 50, 40, .18);
}
.result-canvas canvas { width: 100%; height: auto; display: block; }

.tip { text-align: center; font-size: 12.5px; color: var(--muted); margin: 14px 0 4px; }

.result-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 14px;
}
.result-actions .btn.primary { margin-top: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 40px);
  transform: translate(-50%, 16px);
  background: rgba(47, 43, 38, .92);
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 22px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 99;
  max-width: 80%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
