:root {
  --spark-yellow: #F5C518;
  --spark-dark: #1A1A2E;
  --spark-accent: #E94560;
  --spark-soft: #F8F8F8;
  --spark-muted: #6B7280;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  background: var(--spark-soft);
  color: var(--spark-dark);
  -webkit-text-size-adjust: 100%;
}

section[id^="step-"] { scroll-margin-top: 72px; }

/* ---------- Language system ---------- */
.lang-zh { display: block; }
.lang-en { display: none; }
html[lang="en"] .lang-zh { display: none; }
html[lang="en"] .lang-en { display: block; }
.hidden { display: none !important; }
.inline-lang .lang-zh, .inline-lang.lang-zh, .inline-lang .lang-en { display: inline; }
html[lang="en"] .inline-lang .lang-zh { display: none; }
html:not([lang="en"]) .inline-lang .lang-en { display: none; }

/* ---------- Layout blocks ---------- */
.card {
  background: #fff;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  border: 1px solid #F3F4F6;
  margin-bottom: 1.5rem;
}

.step-header {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.step-num {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  background: var(--spark-yellow);
  color: var(--spark-dark);
  font-weight: 700;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.field-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--spark-dark);
  display: block;
  margin-bottom: 0.25rem;
}

.input-field {
  width: 100%;
  border: 2px solid #E5E7EB;
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 16px; /* 16px prevents iOS Safari zoom-on-focus */
  background: #fff;
  color: var(--spark-dark);
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.input-field:focus { border-color: var(--spark-yellow); outline: none; }
.input-field.invalid { border-color: var(--spark-accent); }

/* ---------- Selectable cards ---------- */
.count-card,
.style-card,
.char-card {
  border: 2px solid #E5E7EB;
  background: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
  display: block;
  position: relative;
}
.count-card:hover, .style-card:hover, .char-card:hover {
  border-color: #FDE68A;
}
.count-card:focus-within, .style-card:focus-within, .char-card:focus-within {
  outline: 2px solid var(--spark-dark);
  outline-offset: 2px;
}

.count-card { border-radius: 0.75rem; padding: 1rem; text-align: center; height: 100%; }
.style-card { border-radius: 0.75rem; padding: 0.5rem 0.5rem 0.75rem; text-align: center; height: 100%; }
.char-card  { border-radius: 0.75rem; padding: 0.75rem 0.5rem; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.5rem; }

.count-card.selected,
.style-card.selected,
.char-card.selected {
  border-color: var(--spark-yellow);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
}

/* Avatar circle (A-Ke head image with emoji fallback) */
.avatar {
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  background: var(--spark-yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-card .avatar { width: 4.5rem; height: 4.5rem; font-size: 2.25rem; }
.avatar.has-img { width: auto; background: transparent; border-radius: 0.5rem; }
.char-card .avatar.has-img { width: auto; }
.avatar.has-img img { width: auto; height: 100%; object-fit: contain; }

/* Style preview: flip card (front = icon, back = A-Ke sample) */
.style-card { position: relative; }
.style-preview {
  position: relative;
  aspect-ratio: 1 / 1;
  margin-bottom: 0.5rem;
  perspective: 800px;
}
.flip-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 0.5rem;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 0.5s ease;
}
.flip-front { background: #FAFAFB; transform: rotateY(0deg); }
.flip-back { background: transparent; transform: rotateY(180deg); }
.style-preview.flipped .flip-front { transform: rotateY(-180deg); }
.style-preview.flipped .flip-back { transform: rotateY(0deg); }
.flip-back img { width: 100%; height: 100%; object-fit: contain; }
.style-emoji-big { font-size: 2.25rem; line-height: 1; }
.flip-back .back-emoji { display: none; }
.flip-back.no-img .back-emoji { display: block; }
.flip-hint { font-size: 0.6875rem; color: var(--spark-muted); margin-top: 0.375rem; }
.flip-btn {
  position: absolute; top: 0.5rem; right: 0.5rem; z-index: 3;
  width: 1.75rem; height: 1.75rem; border-radius: 9999px;
  border: 1px solid #E5E7EB; background: #fff; color: var(--spark-dark);
  font-size: 1rem; line-height: 1; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
}
.flip-btn:hover { background: var(--spark-yellow); border-color: var(--spark-yellow); }

/* ---------- Pick chips (theme / tone) ---------- */
.chip-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.pick-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 2px solid #E5E7EB;
  background: #fff;
  color: var(--spark-dark);
  border-radius: 9999px;
  padding: 0.375rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}
.pick-chip:hover { border-color: #FDE68A; }
.pick-chip:focus-visible { outline: 2px solid var(--spark-dark); outline-offset: 2px; }
.pick-chip[aria-pressed="true"] {
  background: rgba(245, 197, 24, 0.18);
  border-color: var(--spark-yellow);
  font-weight: 700;
}
.pick-chip.at-limit:not([aria-pressed="true"]) { opacity: 0.45; cursor: not-allowed; }
.pick-chip.custom { border-style: dashed; }
.pick-chip .x { font-size: 1rem; line-height: 1; opacity: 0.6; }

.counter { font-size: 0.75rem; font-weight: 700; color: var(--spark-muted); }
.counter.over { color: #B91C1C; }
.limit-msg { font-size: 0.75rem; font-weight: 600; color: #B45309; min-height: 1rem; margin-top: 0.5rem; }

.add-row { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.btn-secondary {
  flex-shrink: 0;
  border: 2px solid var(--spark-dark);
  background: #fff;
  color: var(--spark-dark);
  border-radius: 0.75rem;
  padding: 0 1rem;
  font-weight: 700;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-secondary:hover { background: var(--spark-dark); color: #fff; }

/* ---------- Warning boxes ---------- */
.warning-amber {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.warning-red {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.warning-dark {
  background: var(--spark-dark);
  color: #fff;
  border-radius: 0.75rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.rule-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.rule-list li { margin-bottom: 0.5rem; line-height: 1.4; }
.rule-list li:last-child { margin-bottom: 0; }

/* ---------- Header / hero ---------- */
.step-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.step-pill:hover { border-color: var(--spark-yellow); color: #fff; }
.step-pill.current { border-color: var(--spark-yellow); color: #fff; }
.step-pill.done {
  background: var(--spark-yellow);
  border-color: var(--spark-yellow);
  color: var(--spark-dark);
}
.step-pill > span { display: inline; }
html[lang="en"] .step-pill > .lang-zh { display: none; }
html:not([lang="en"]) .step-pill > .lang-en { display: none; }

/* ---------- Buttons / feedback ---------- */
.price-strike { text-decoration: line-through; opacity: 0.55; }

.btn-primary {
  width: 100%;
  background: var(--spark-yellow);
  color: var(--spark-dark);
  font-weight: 700;
  font-size: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  font-family: inherit;
}
.btn-primary:hover:not(:disabled) { filter: brightness(0.95); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.error-box {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.error-box ul { margin: 0.5rem 0 0 1.1rem; padding: 0; list-style: disc; }
.error-box .lang-zh, .error-box .lang-en { display: inline; }
html[lang="en"] .error-box .lang-zh { display: none; }
html:not([lang="en"]) .error-box .lang-en { display: none; }

/* ---------- Order summary (dark) ---------- */
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.875rem;
}
.summary-row > span:first-child { color: rgba(255, 255, 255, 0.65); flex-shrink: 0; }
.summary-row > span:last-child { text-align: right; word-break: break-word; }
.summary-row .lang-zh, .summary-row .lang-en { display: inline; }
html[lang="en"] .summary-row .lang-zh { display: none; }
html:not([lang="en"]) .summary-row .lang-en { display: none; }
.summary-total { font-size: 1.25rem; font-weight: 700; color: var(--spark-yellow); border-bottom: 0; padding-top: 0.75rem; }

/* ---------- Order details (success view, light) ---------- */
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #F3F4F6;
  font-size: 0.875rem;
  text-align: left;
}
.detail-row > span:first-child { color: var(--spark-muted); flex-shrink: 0; }
.detail-row > span:last-child { text-align: right; word-break: break-word; font-weight: 600; }
.detail-row .lang-zh, .detail-row .lang-en { display: inline; }
html[lang="en"] .detail-row .lang-zh { display: none; }
html:not([lang="en"]) .detail-row .lang-en { display: none; }
.detail-total { font-size: 1.125rem; border-bottom: 0; }

.next-steps { text-align: left; list-style: none; margin: 0; padding: 0; counter-reset: s; }
.next-steps li { position: relative; padding-left: 2rem; margin-bottom: 0.75rem; font-size: 0.875rem; line-height: 1.5; counter-increment: s; }
.next-steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: 0;
  width: 1.375rem; height: 1.375rem; border-radius: 9999px;
  background: var(--spark-yellow); color: var(--spark-dark);
  font-weight: 700; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
}

.action-link {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.375rem;
  border: 2px solid var(--spark-dark);
  border-radius: 0.75rem;
  padding: 0.625rem 1rem;
  font-weight: 700; font-size: 0.875rem;
  background: #fff; color: var(--spark-dark);
  text-decoration: none; cursor: pointer; font-family: inherit;
  transition: all 0.15s ease;
}
.action-link:hover { background: var(--spark-dark); color: #fff; }
.action-link.primary { background: var(--spark-yellow); border-color: var(--spark-yellow); }
.action-link.primary:hover { filter: brightness(0.95); background: var(--spark-yellow); color: var(--spark-dark); }

/* ---------- Panel layout ---------- */
.app-main { max-width: 42rem; margin: 0 auto; padding: 2rem 1rem; }
.panels { display: block; }
.panel-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--spark-muted);
  margin: 0 0 1rem;
}

/* ---------- Sticky CTA (page 1) ---------- */
.panel-cta {
  position: sticky; bottom: 0; z-index: 6;
  background: rgba(248, 248, 248, 0.96);
  border-top: 1px solid #E5E7EB;
  padding: 0.75rem 0;
  margin-top: 1rem;
}
.cta-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.cta-price { font-size: 0.8125rem; color: var(--spark-muted); line-height: 1.4; flex: 1 1 12rem; }
.cta-price strong { color: var(--spark-dark); font-size: 1.125rem; }
.cta-price .cta-was { text-decoration: line-through; margin-right: 0.25rem; }
.cta-btn { width: auto; padding: 0.875rem 1.5rem; }
.panel-cta .error-box { margin-bottom: 0.5rem; }

/* ---------- Page 2: confirm order ---------- */
.order-view { max-width: 64rem; margin: 0 auto; }
.order-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.back-link {
  background: none; border: 0; padding: 0.25rem 0; margin-bottom: 0.5rem;
  font-weight: 700; font-size: 0.875rem; color: var(--spark-muted);
  cursor: pointer; font-family: inherit;
}
.back-link:hover { color: var(--spark-dark); }

@media (min-width: 1024px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .app-main { flex: 1; min-height: 0; max-width: 1400px; width: 100%; padding: 1rem; overflow-y: auto; }
  .panels {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 1rem;
    height: 100%;
  }
  .panel {
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-top: 3.5rem;
    scroll-padding-bottom: 5rem;
    background: #EFEFF3;
    border: 1px solid #E5E7EB;
    border-radius: 1rem;
    padding: 0 1rem 0.5rem;
  }
  .panel-label {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #EFEFF3;
    padding: 1rem 0 0.75rem;
    margin: 0 0 0.5rem;
  }
  section[id^="step-"] { scroll-margin-top: 48px; }
  footer { display: none; }

  /* Page 1 fills the viewport; page 2 / done scroll normally */
  body[data-view="build"] #order-form,
  body[data-view="build"] #view-build { height: 100%; }
  .panel-cta { background: #EFEFF3; margin: 0 -1rem; padding: 0.75rem 1rem 0.75rem; }
  .order-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; }
  .order-left { position: sticky; top: 0; }
  .order-view .panel-label { position: static; background: none; padding: 0; margin: 0 0 0.75rem; }
  .order-view { padding-bottom: 1.5rem; }
}


/* SparkSticker UX: locked second step and pre-order FAQ */
.spark-locked { opacity: .45; }
#step1-next:disabled, #next-btn:disabled { opacity:.5; cursor:not-allowed; }
.spark-faq details { border-bottom:1px solid #ddd5c7; padding:12px 0; }
.spark-faq summary { cursor:pointer; font-weight:700; }
.spark-faq p { margin-top:8px; line-height:1.8; font-size:14px; }
.step-pill[aria-disabled="true"] { opacity:.45; }

/* Hide all price figures until a plan is selected (JS reveals them). */
.plan-card-price, .plan-card-discount { visibility:hidden; }

/* Single active step layout: remove empty desktop grid column. */
@media (min-width: 1024px) {
  body[data-view="build"] .panels { grid-template-columns: minmax(0, 1fr); max-width: 920px; margin: 0 auto; }
  body[data-view="build"] .panel { width: 100%; }
}
/* Keep the navigation below the content instead of covering fields. */
body[data-view="build"] .panel-cta { position: static; bottom: auto; }

/* Dual-column restoration: the original Step 1/2 panels remain side by side. */
@media (min-width:1024px) {
  body[data-view="build"] .panels {display:grid!important;grid-template-columns:minmax(0,2fr) minmax(0,3fr)!important;align-items:stretch;}
  body[data-view="build"] #panel-1, body[data-view="build"] #panel-2 {display:block!important;min-width:0;}
}
.spark-amend-action {margin:1rem 0;}

/* 2026-10-16 release: full-width desktop two-column workflow, normal page scroll */
@media (min-width:1024px) {
 html,body {height:auto!important;min-height:100%;overflow-x:hidden!important;overflow-y:auto!important;}
 body {display:block!important;overflow-y:auto!important;}
 .app-main {width:100%!important;max-width:none!important;margin:0!important;padding:20px 24px!important;overflow:visible!important;height:auto!important;min-height:0!important;}
 body[data-view="build"] #order-form,body[data-view="build"] #view-build {height:auto!important;}
 body[data-view="build"] .panels {display:grid!important;width:100%!important;max-width:none!important;margin:0!important;grid-template-columns:minmax(0,45fr) minmax(0,55fr)!important;gap:20px!important;height:auto!important;align-items:start!important;}
 body[data-view="build"] .panel {height:auto!important;max-height:none!important;overflow:visible!important;min-width:0!important;}
 .order-view {max-width:none!important;width:100%!important;}
 .order-grid {grid-template-columns:minmax(0,45fr) minmax(0,55fr)!important;gap:20px!important;}
 .order-left {position:static!important;}
}
