/* === Theme variables (overridden by JS from JSON config) === */
:root {
  --primary: #FF85A1;
  --secondary: #FFF5F7;
  --accent: #FFB7C5;
  --text: #1F2937;
  --text-light: #9CA3AF;
  --text-faint: #D1D5DB;
  --bg: #FFFFFF;
  --border: #F3F4F6;
  --radius: 24px;
  --font: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
}

/* === Reset === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* === App container === */
.app {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* === Page system === */
.page { display: none; flex: 1; flex-direction: column; }
.page.active { display: flex; }

/* === Common components === */
.brand-tag {
  display: inline-block;
  padding: 4px 12px;
  background: var(--secondary);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border-radius: 20px;
}

.btn {
  width: 100%;
  height: 56px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-family: var(--font);
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.btn-primary:active { transform: scale(0.95); }

.btn-secondary {
  background: var(--bg);
  color: var(--text-light);
  border: 1.5px solid var(--border);
}

.btn-secondary:active { background: #F9FAFB; }

.input-field {
  width: 100%;
  height: 56px;
  background: #F9FAFB;
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 0 24px;
  font-size: 18px;
  font-family: var(--font);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.15em;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.input-field:focus {
  border-color: var(--accent);
  background: var(--secondary);
}

.input-field::placeholder {
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0;
}

.error-msg {
  color: #EF4444;
  font-size: 14px;
  font-weight: 500;
  min-height: 20px;
  text-align: center;
}

/* === Loading === */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  font-size: 14px;
  color: var(--text-light);
}

/* === Error page === */
.error-page {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 32px;
}

.error-title { font-size: 18px; font-weight: 700; }
.error-text { font-size: 14px; color: var(--text-light); }

/* === Calculating transition === */
.calc-page {
  justify-content: center;
  align-items: center;
  text-align: center;
}

.calc-content { opacity: 0; animation: calcFadeIn 0.4s ease forwards; }

.calc-text {
  font-size: 15px;
  color: var(--text-light);
  font-weight: 600;
  margin-top: 20px;
  letter-spacing: 0.05em;
}

.calc-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.calc-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.3;
  animation: calcPulse 1.2s ease-in-out infinite;
}

.calc-dots span:nth-child(2) { animation-delay: 0.2s; }
.calc-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes calcPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

@keyframes calcFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Unlock page === */
.unlock-page {
  padding: 0 32px;
  padding-top: max(96px, 18vh);
}

.unlock-content {
  text-align: center;
  margin-bottom: 48px;
}

.unlock-content .brand-tag { margin-bottom: 16px; }

.unlock-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
}

.unlock-subtitle {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.6;
}

.unlock-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-footer-text {
  margin-top: auto;
  padding: 24px 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.6;
}

/* === Start page === */
.start-page {
  padding: 0 32px;
  padding-top: max(96px, 18vh);
}

.start-content { margin-bottom: 32px; }
.start-content .brand-tag { margin-bottom: 16px; }

.start-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.start-description {
  font-size: 16px;
  color: var(--text-light);
  line-height: 1.8;
  font-weight: 500;
}

.social-proof {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}

.social-avatars {
  display: flex;
  margin-left: 4px;
}

.social-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  margin-left: -6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.social-dot:first-child { margin-left: 0; }

.social-text {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 600;
}

.start-duration {
  text-align: center;
  margin-top: 16px;
  font-size: 11px;
  color: var(--text-faint);
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

/* === Quiz page === */
.quiz-page { padding: 48px 24px 24px; }

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.quiz-back {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 0.2s;
}

.quiz-back:active { color: var(--primary); }
.quiz-back:disabled { opacity: 0.2; pointer-events: none; }

.quiz-counter {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.quiz-progress {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 36px;
}

.quiz-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 1px;
  transition: width 0.3s ease;
}

.quiz-title {
  font-size: 11px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0 4px;
  margin-bottom: 8px;
  opacity: 0.7;
}

.quiz-question {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 8px;
  padding: 0 4px;
}

.quiz-separator {
  width: 40px;
  height: 3px;
  background: var(--primary);
  opacity: 0.2;
  border-radius: 2px;
  margin-bottom: 28px;
  margin-left: 4px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-option {
  padding: 18px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  color: #4B5563;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background-color 0.15s;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.quiz-option:active {
  transform: scale(0.98);
}

.quiz-option.selected {
  border-color: var(--accent);
  background: var(--secondary);
}

/* === Result page === */
.result-page {
  padding: 48px 0 32px;
  background: #FAFAFA;
}

.result-header {
  text-align: center;
  padding: 0 32px;
  margin-bottom: 24px;
}

.result-intro {
  display: block;
  font-size: 14px;
  color: var(--text-light);
  font-weight: 500;
  margin-bottom: 6px;
}

.result-label {
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -0.02em;
}

/* === Share card (visible on result page, captured for export) === */
.share-card {
  margin: 0 20px 24px;
  background: #FFFFFF;
  border-radius: 32px;
  padding: 32px 24px 40px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.share-test-name {
  text-align: center;
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.5em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 24px;
}

.share-label {
  text-align: center;
  font-size: 36px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.share-tags {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
}

.share-tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  border-radius: 20px;
  border: 1px solid;
}

.share-radar {
  display: flex;
  justify-content: center;
  margin-bottom: 32px;
}

.share-radar svg { overflow: visible; }

.radar-label {
  font-size: 11px;
  font-weight: 800;
  fill: var(--text);
}

.radar-value {
  font-size: 10px;
  font-weight: 800;
}

.share-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 24px;
}

.share-section-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: -0.02em;
  padding-left: 12px;
  margin-bottom: 8px;
}

.share-section-content {
  font-size: 14px;
  color: #6B7280;
  line-height: 1.8;
  font-weight: 500;
}

.share-quote-box {
  padding: 20px;
  border-radius: 24px;
  text-align: center;
  margin-bottom: 32px;
}

.share-quote-text {
  font-size: 15px;
  font-weight: 700;
  font-style: italic;
  line-height: 1.8;
}

/* === Secondary result (dual display for normalize_highest) === */
.share-secondary {
  text-align: center;
  padding: 20px;
  margin-bottom: 24px;
  border-radius: 20px;
  border: 1.5px dashed;
  border-color: var(--accent);
}

.share-secondary-intro {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.share-secondary-label {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.share-secondary-desc {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  margin-left: 6px;
  letter-spacing: 0.1em;
}

.share-brand {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.share-brand-name {
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.share-brand-sub {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  font-weight: 800;
  margin-top: 2px;
}

/* === Result actions === */
.result-actions {
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* === Image Preview Overlay === */
.image-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.image-preview-hint {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  margin-bottom: 16px;
}

.image-preview-img {
  max-width: 100%;
  max-height: 70vh;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  -webkit-touch-callout: default;
}

/* === Image-based result card (NBTI style) === */
.share-label-code {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.share-slogan {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 20px;
  opacity: 0.85;
}

.share-image-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.share-image {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 16px;
}

.share-percentage {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  font-weight: 600;
  margin-bottom: 24px;
}

.share-percentage strong {
  font-weight: 800;
}

.image-preview-close {
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  right: 16px;
  margin-top: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 18px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
