@font-face {
  font-family: "CaliwayWeb";
  src:
    local("Caliway"),
    local("Caliway Regular"),
    url("fonts/Caliway.woff2") format("woff2"),
    url("fonts/Caliway.ttf") format("truetype"),
    url("fonts/Caliway.otf") format("opentype");
  font-display: swap;
}

:root {
  --bg: #f3f3f5;
  --panel: #ffffff;
  --text: #202024;
  --muted: #8b8b91;
  --line: #e3e3e6;
  --black: #1c1c1f;
  --brand-blue: #0000c8;
  --soft: #eeeeF0;
  --ok: #277a49;
  --warn: #9d6722;
  --radius: 16px;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", Arial, sans-serif;
  overscroll-behavior-y: none;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button, select {
  touch-action: manipulation;
}

/* -------------------------
   MOBILE FIRST
   ------------------------- */

.app-shell {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding:
    max(14px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 16px;
}

.brand {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
}

h1 {
  margin: 5px 0 0;
  font-size: clamp(22px, 6vw, 28px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.local-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--black);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "selection"
    "preview"
    "signature";
  gap: 12px;
}

.panel,
.preview-column {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: 0 6px 22px rgba(0,0,0,.045);
}

.selection-panel {
  grid-area: selection;
  padding: 16px;
}

.preview-column {
  grid-area: preview;
  padding: 12px;
}

.signature-panel {
  grid-area: signature;
  padding: 16px;
}

.section-title {
  margin: 0 0 9px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
}

.inline-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

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

.version-segmented {
  margin-bottom: 18px;
}

.color-segmented {
  margin-bottom: 0;
}

.save-image-btn {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border: 0;
  border-radius: 10px;
  background: var(--brand-blue);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}

.save-image-btn:active {
  transform: translateY(1px);
}

.save-image-btn:disabled {
  opacity: .55;
  cursor: default;
}


.model-btn,
.choice,
.version-btn {
  width: 100%;
  min-height: 48px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: var(--soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 750;
  font-size: 14px;
}

.model-btn.active,
.choice.active,
.version-btn.active {
  background: var(--brand-blue);
  color: #fff;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.field-block + .field-block {
  margin-top: 0;
}

.select-input,
.text-input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  padding: 0 13px;
  background: #fff;
  color: var(--text);
  margin: 0 0 18px;
  font-size: 16px; /* iOS: 避免聚焦时自动放大页面 */
}

.select-input:focus,
.text-input:focus {
  border-color: #b7b7bd;
  box-shadow: 0 0 0 3px rgba(0,0,0,.035);
}

.signature-input {
  height: 54px;
  margin-bottom: 18px;
  font-size: 18px;
}

.preview-toolbar {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 0 2px;
}

.preview-heading {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.preview-heading strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.preview-heading span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}



.preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 12px;
  background:
    linear-gradient(45deg, #f3f3f3 25%, transparent 25%),
    linear-gradient(-45deg, #f3f3f3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f3f3f3 75%),
    linear-gradient(-45deg, transparent 75%, #f3f3f3 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  contain: layout paint;
}

#productImage {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  user-select: none;
  -webkit-user-drag: none;
}

.signature-text {
  position: absolute;
  z-index: 3;
  transform: translate(-50%, -50%);
  transform-origin: center;
  color: #fff;
  font-family: "CaliwayWeb", "Caliway", "Brush Script MT", cursive;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  display: none;
}

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

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

.empty-state span {
  max-width: 280px;
  font-size: 11px;
  line-height: 1.6;
}

.current-info {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 10px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  word-break: break-word;
}

footer {
  color: var(--muted);
  font-size: 10px;
  text-align: center;
  padding: 18px 0 0;
  letter-spacing: .08em;
}

/* 极窄手机 */
@media (max-width: 359px) {
  .app-shell {
    padding-left: 8px;
    padding-right: 8px;
  }

  .selection-panel,
  .signature-panel {
    padding: 13px;
  }

  .preview-column {
    padding: 9px;
  }

  .model-btn,
  .choice,
  .version-btn {
    min-height: 46px;
    font-size: 13px;
  }
}

/* 大手机 / 横屏手机：系列和编号并排 */
@media (min-width: 560px) {
  .field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

/* -------------------------
   TABLET / DESKTOP
   左侧两张卡片 + 右侧大预览
   ------------------------- */
@media (min-width: 900px) {
  .app-shell {
    width: min(1480px, calc(100% - 36px));
    padding: 22px 0 40px;
  }

  .topbar {
    padding: 8px 4px 20px;
  }

  .brand {
    font-size: 13px;
  }

  h1 {
    font-size: 28px;
  }

  .local-badge {
    padding: 8px 12px;
    font-size: 12px;
  }

  .workspace {
    grid-template-columns: 400px minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
      "selection preview"
      "signature preview";
    gap: 18px;
    align-items: start;
  }

  .selection-panel,
  .signature-panel {
    padding: 24px;
  }

  .preview-column {
    padding: 20px;
    grid-row: 1 / span 2;
  }

  .model-btn,
  .choice,
  .version-btn {
    min-height: 44px;
  }

  .preview-toolbar {
    min-height: 46px;
  }

  .preview-heading strong {
    font-size: 15px;
  }

  .preview-heading span,
  .status {
    font-size: 12px;
  }

  .current-info {
    font-size: 12px;
    padding-top: 14px;
  }

  footer {
    font-size: 11px;
    padding-top: 22px;
  }
}


/* =========================
   BLUEMONT V0.5 RC BRANDING
   ========================= */
.brand-header {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 18px;
}

.brand-wordmark {
  color: var(--brand-blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(31px, 9vw, 46px);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1;
  text-align: center;
}

.model-btn.active,
.choice.active,
.version-btn.active {
  background: var(--brand-blue);
  color: #fff;
}

.save-image-btn {
  background: var(--brand-blue);
  color: #fff;
}

footer {
  color: var(--brand-blue);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  padding-top: 26px;
  padding-bottom: 10px;
}

@media (min-width: 900px) {
  .brand-header {
    min-height: 112px;
    padding-top: 14px;
    padding-bottom: 24px;
  }

  .brand-wordmark {
    font-size: 46px;
  }
}


/* =========================
   V0.5.1 VI IMAGE BRANDING
   Use provided VI image assets for header and footer.
   ========================= */
.brand-header {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 18px;
}

.brand-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.brand-image-header {
  width: min(82vw, 460px);
}

footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 26px;
  padding-bottom: 10px;
}

.brand-image-footer {
  width: min(72vw, 420px);
}

@media (min-width: 900px) {
  .brand-header {
    min-height: 112px;
    padding-top: 14px;
    padding-bottom: 24px;
  }

  .brand-image-header {
    width: 460px;
  }

  .brand-image-footer {
    width: 420px;
  }
}


/* =========================
   V0.5.3 LOGO SIZE OVERRIDE
   Header logo -30%
   Footer official -40%
   ========================= */
.brand-image-header {
  width: min(57.4vw, 322px) !important;
}

.brand-image-footer {
  width: min(43.2vw, 252px) !important;
}

@media (min-width: 900px) {
  .brand-image-header {
    width: 322px !important;
  }

  .brand-image-footer {
    width: 252px !important;
  }
}


/* =========================
   V0.5.4 EXTRA SIZE REDUCTION
   Based on V0.5.3, shrink both brand images another 30%
   ========================= */
.brand-image-header {
  width: min(40.18vw, 225.4px) !important;
}

.brand-image-footer {
  width: min(30.24vw, 176.4px) !important;
}

@media (min-width: 900px) {
  .brand-image-header {
    width: 225.4px !important;
  }

  .brand-image-footer {
    width: 176.4px !important;
  }
}

/* =========================
   V1.1 NATIVE SAVE TARGET
   Keep the live HTML preview untouched for instant editing, while an almost
   transparent real composite image sits above it for long-press/right-click.
   Saving that image therefore includes the current signature.
   ========================= */
.composite-image {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  opacity: 0.001;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: auto;
  touch-action: pan-y pinch-zoom;
}


/* =========================
   V1.1.6
   Normal UI stays rounded.
   Only while a real native long-press is being prepared do we temporarily
   remove the visual clipping, so the browser captures/saves the square image.
   ========================= */
.preview-stage.native-save-square {
  overflow: visible !important;
  border-radius: 0 !important;
  contain: none !important;
  background: transparent !important;
}

.preview-stage.native-save-square #productImage,
.preview-stage.native-save-square .composite-image {
  border-radius: 0 !important;
  clip-path: none !important;
  mask: none !important;
  -webkit-mask-image: none !important;
}

.preview-stage.native-save-square .composite-image {
  opacity: 1 !important;
  z-index: 20 !important;
}


/* V1.1.8: remove duplicate product info line below preview */
.current-info {
  display: none !important;
}
