:root {
  --bg: #f7eef2;
  --bg-card: #ffffff;
  --ink: #2a2230;
  --muted: #7a6b76;
  --line: #eadfe6;
  --pink: #e8b4c4;
  --pink-deep: #c97b93;
  --gold: #c9a86c;
  --gold-soft: #f3e6c8;
  --teal: #2bb8c4;
  --magenta: #d94f9a;
  --amber: #e3a023;
  --purple: #8b5cf6;
  --whatsapp: #25d366;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(74, 40, 58, 0.08);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: "Noto Sans TC", system-ui, sans-serif;
  --display: "Cormorant Garamond", "Noto Sans TC", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(120% 80% at 50% -10%, #fff7fb 0%, transparent 55%),
    linear-gradient(180deg, #faf4f7 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
button, label.btn { font-family: inherit; }
a { color: var(--pink-deep); }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 16px calc(24px + var(--safe-b));
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}
.brand-mark {
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.brand-sub {
  margin-left: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}
.brand-link {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--gold);
}

.view { display: none; flex: 1; }
.view.active { display: flex; flex-direction: column; }

.hero-card, .loading-card, .insight-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px 22px 24px;
  margin-top: 8px;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}
.hero-card h1 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: 2rem;
  line-height: 1.25;
  font-weight: 600;
}
.lead {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.98rem;
}
.feature-list {
  margin: 0 0 24px;
  padding: 0 0 0 1.1rem;
  color: var(--ink);
  line-height: 1.7;
  font-size: 0.92rem;
}
.feature-list li { margin-bottom: 6px; }

.cta-row {
  display: grid;
  gap: 10px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  border: none;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--pink-deep), #a85f78);
  color: #fff;
  box-shadow: 0 8px 20px rgba(169, 80, 110, 0.28);
}
.btn-secondary {
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--pink);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  min-height: 44px;
  font-weight: 500;
  font-size: 0.95rem;
}
.btn-whatsapp {
  background: var(--whatsapp);
  color: #fff;
  width: 100%;
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.28);
}

.disclaimer {
  margin: 18px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  text-align: center;
}
.disclaimer.small { margin-top: 12px; }

.loading-card {
  margin: auto 0;
  padding: 40px 24px;
  text-align: center;
}
.loading-card h2 {
  margin: 18px 0 8px;
  font-size: 1.35rem;
}
.loading-card p {
  margin: 0;
  color: var(--muted);
}
.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid var(--gold-soft);
  border-top-color: var(--pink-deep);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}
.photo-stage {
  position: relative;
  background: #1a1218;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  aspect-ratio: 3 / 4;
}
#result-canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.issue-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.92);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}
.issue-badge[data-issue="pores"] { color: #0e7a84; }
.issue-badge[data-issue="spots"] { color: #b01d6e; }
.issue-badge[data-issue="wrinkles"] { color: #9a6808; }
.issue-badge[data-issue="sagging"] { color: #5b35c5; }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: rgba(255,255,255,0.7);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.tab {
  border: none;
  background: transparent;
  min-height: 44px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.tab.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(74, 40, 58, 0.08);
}
.tab[data-issue="pores"].active { color: #0e7a84; }
.tab[data-issue="spots"].active { color: #b01d6e; }
.tab[data-issue="wrinkles"].active { color: #9a6808; }
.tab[data-issue="sagging"].active { color: #5b35c5; }

.insight-card { padding: 18px 16px; }
.insight-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.insight-card h2 {
  margin: 0;
  font-size: 1.2rem;
}
.severity { min-width: 110px; text-align: right; }
.severity-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--pink-deep);
  margin-bottom: 4px;
}
.severity-track {
  height: 6px;
  border-radius: 999px;
  background: #f0e4ea;
  overflow: hidden;
}
.severity-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--pink-deep));
  transition: width 0.35s ease;
}
#insight-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.95rem;
}

.cta-block { margin-top: 4px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  background: #2a2230;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

@media (min-width: 768px) {
  .app { max-width: 560px; padding-top: 28px; }
  .hero-card h1 { font-size: 2.35rem; }
  .photo-stage { max-height: 70vh; }
}
