@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Cormorant+Garamond:ital,wght@1,500&family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --bg: #0B0F2B;
  --surface: #141A3D;
  --surface-high: #1E2652;
  --accent: #E9EDF8;
  --accent-soft: #FFFFFF;
  --periwinkle: #8FA3E6;
  --text: #F7F8FC;
  --text-muted: #9AA3C7;
  --gradient: linear-gradient(135deg, #FFFFFF 0%, #E9EDF8 50%, #B9C4E8 100%);
  --glow: radial-gradient(ellipse at 50% -10%, #1B2352 0%, #0B0F2B 60%);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #05060f;
  overscroll-behavior: none;
}

body {
  font-family: 'Poppins', sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  touch-action: pan-y;
}

.serif {
  font-family: 'Playfair Display', serif;
}

.italic-serif {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  min-height: 100vh;
  background: var(--glow);
  background-color: var(--bg);
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 80px rgba(0,0,0,0.6);
}

@media (min-width: 481px) {
  html, body { background: #05060f; }
  #app {
    margin-top: 24px;
    margin-bottom: 24px;
    min-height: calc(100vh - 48px);
    max-height: calc(100vh - 48px);
    border-radius: 32px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid rgba(233, 237, 248, 0.12);
  }
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
  animation: screenIn 380ms cubic-bezier(.22,.68,0,1.01);
}
@media (min-width: 481px) { .screen { min-height: calc(100vh - 48px); } }

.screen.active { display: flex; }

@keyframes screenIn {
  from { opacity: 0; transform: scale(0.97) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ---------- Typography helpers ---------- */
h1, h2, h3, p { margin: 0; }

.gold-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  color: var(--accent);
  letter-spacing: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.muted { color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn-gold {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 60px;
  border: none;
  border-radius: 30px;
  background: var(--gradient);
  color: var(--bg);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.4px;
  box-shadow: 0 10px 30px rgba(233, 237, 248, 0.18);
  cursor: pointer;
  transition: transform 120ms ease;
  font-family: 'Poppins', sans-serif;
}
.btn-gold:active { transform: scale(0.97); }
.btn-gold:disabled { opacity: 0.35; }

.btn-outline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  border-radius: 27px;
  background: rgba(20, 26, 61, 0.65);
  border: 1.5px solid rgba(233, 237, 248, 0.5);
  color: var(--accent-soft);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease;
}
.btn-outline:active { transform: scale(0.97); }

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  font-family: 'Poppins', sans-serif;
  padding: 10px;
  cursor: pointer;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

/* ---------- Cards on welcome ---------- */
.card-offer {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--surface-high), var(--surface));
  border: 1.5px solid rgba(233, 237, 248, 0.35);
  box-shadow: 0 10px 26px rgba(0,0,0,0.28);
  cursor: pointer;
  text-align: left;
  transition: transform 120ms ease;
  font-family: 'Poppins', sans-serif;
}
.card-offer:active { transform: scale(0.97); }

.card-offer .icon-wrap {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(233, 237, 248, 0.14);
  border: 1px solid rgba(233, 237, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.card-offer .icon-wrap img { width: 30px; height: 30px; object-fit: contain; }

.card-offer .offer-title { font-family: 'Playfair Display', serif; font-size: 19px; font-weight: 600; color: var(--text); }
.card-offer .offer-sub { font-size: 13px; color: var(--text-muted); margin-top: 3px; line-height: 1.3; }

.pill-btn {
  width: 100%;
  height: 56px;
  border-radius: 28px;
  background: rgba(20, 26, 61, 0.6);
  border: 1.5px solid rgba(233, 237, 248, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--accent-soft);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.pill-btn:active { transform: scale(0.97); }

/* ---------- Welcome ---------- */
.welcome-header {
  display: flex;
  justify-content: flex-end;
}

.welcome-logo {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0 4px;
}
.welcome-logo img { width: 78%; max-width: 300px; }

.slogan {
  text-align: center;
  font-size: 19px;
  line-height: 1.5;
  color: rgba(247,248,252,0.92);
  padding: 0 6px;
  margin: 18px 0 6px;
}

.welcome-actions { display: flex; flex-direction: column; gap: 14px; margin-top: auto; padding-top: 20px; }

.dev-credit {
  text-align: center;
  font-size: 11px;
  color: rgba(154,163,199,0.6);
  margin-top: 18px;
  letter-spacing: 0.5px;
}

/* ---------- Progress / quiz ---------- */
.quiz-header { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.progress-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--gradient);
  border-radius: 2px;
  transition: width 320ms ease;
}
.step-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

.quiz-title {
  font-family: 'Playfair Display', serif;
  font-size: 27px;
  font-weight: 600;
  line-height: 1.2;
  white-space: pre-line;
  margin-bottom: 8px;
}
.quiz-hint { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  overflow-y: auto;
  padding-bottom: 12px;
  flex: 1;
}

.option-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 10px;
  border-radius: 20px;
  background: var(--surface);
  border: 1.5px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: transform 120ms ease, border-color 150ms ease, background 150ms ease;
  text-align: center;
}
.option-card:active { transform: scale(0.96); }
.option-card.selected {
  border-color: var(--accent);
  background: var(--surface-high);
  box-shadow: 0 0 0 1px var(--accent), 0 8px 20px rgba(233,237,248,0.12);
}
.option-medallion {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.option-medallion img { width: 30px; height: 30px; object-fit: contain; }
.option-label { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.25; }

.quiz-footer { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.quiz-multi-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }

/* ---------- Name / inputs ---------- */
.name-field {
  width: 100%;
  height: 60px;
  border-radius: 30px;
  background: var(--surface);
  border: 1.5px solid rgba(255,255,255,0.12);
  color: var(--text);
  font-size: 18px;
  padding: 0 24px;
  font-family: 'Poppins', sans-serif;
  margin: 24px 0 8px;
}
.name-field:focus { outline: none; border-color: var(--accent); }
.name-field::placeholder { color: var(--text-muted); }

/* ---------- Loading ---------- */
.loading-screen { align-items: center; justify-content: center; text-align: center; gap: 20px; }
.bottle-wrap { width: 120px; height: 160px; position: relative; margin-bottom: 8px; }
.bottle {
  width: 100%; height: 100%;
  border: 2px solid rgba(233,237,248,0.5);
  border-radius: 18px 18px 30px 30px;
  position: relative;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
}
.bottle::before {
  content: '';
  position: absolute;
  top: -14px; left: 50%;
  transform: translateX(-50%);
  width: 34px; height: 20px;
  border: 2px solid rgba(233,237,248,0.5);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}
.bottle-fill {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 0%;
  background: var(--gradient);
  animation: fillBottle 1.8s cubic-bezier(.3,.1,.2,1) forwards;
}
@keyframes fillBottle { to { height: 82%; } }
.loading-title { font-family: 'Playfair Display', serif; font-size: 23px; white-space: pre-line; }
.loading-sub { color: var(--text-muted); font-size: 14px; }

/* ---------- Result ---------- */
.result-hero {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 24px;
  overflow: hidden;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.result-hero img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.result-hero.fallback { background: var(--glow); }
.result-hero.fallback img { display: none; }
.result-hero .fallback-diamond { width: 70px; height: 70px; opacity: 0.55; }

.tag-row { display: flex; justify-content: center; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.tag {
  padding: 7px 14px;
  border-radius: 20px;
  background: rgba(233,237,248,0.1);
  border: 1px solid rgba(233,237,248,0.35);
  color: var(--accent-soft);
  font-size: 12px;
  font-weight: 600;
}

.perfume-name { font-family: 'Playfair Display', serif; font-size: 27px; text-align: center; margin-top: 6px; }
.perfume-brand { text-align: center; color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.perfume-note { text-align: center; font-size: 14.5px; line-height: 1.6; margin: 16px 0; color: rgba(247,248,252,0.92); }

.pyramid {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid rgba(233,237,248,0.18);
  padding: 18px;
  margin: 8px 0 18px;
}
.pyramid-title { text-align: center; font-family: 'Playfair Display', serif; font-size: 17px; margin-bottom: 16px; }
.pyramid-tier { margin: 0 auto 10px; padding: 11px 12px; border-radius: 14px; text-align: center;
  background: linear-gradient(180deg, rgba(233,237,248,0.18), rgba(233,237,248,0.05));
  border: 1px solid rgba(233,237,248,0.3);
}
.pyramid-tier:nth-child(2) { width: 62%; }
.pyramid-tier:nth-child(3) { width: 82%; }
.pyramid-tier:nth-child(4) { width: 100%; }
.pyramid-tier-label { font-size: 10.5px; font-weight: 700; letter-spacing: 1.5px; color: var(--accent-soft); text-transform: uppercase; }
.pyramid-notes { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 7px; }
.note-chip { padding: 5px 11px; border-radius: 16px; background: var(--surface-high); border: 1px solid rgba(255,255,255,0.14); font-size: 12px; }

.refine-title { text-align: center; font-size: 13px; color: var(--text-muted); margin: 4px 0 10px; }
.refine-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 18px; scrollbar-width: none; }
.refine-row::-webkit-scrollbar { display: none; }
.refine-chip {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid rgba(233,237,248,0.3);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.refine-chip:active { transform: scale(0.96); }

.also-like-title { font-family: 'Playfair Display', serif; font-size: 17px; margin: 6px 0 12px; }
.also-like-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 20px; scrollbar-width: none; }
.also-like-row::-webkit-scrollbar { display: none; }
.suggestion-card { flex-shrink: 0; width: 118px; cursor: pointer; }
.suggestion-card .thumb {
  width: 118px; height: 118px; border-radius: 16px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.suggestion-card .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.suggestion-card .s-name { font-size: 12.5px; font-weight: 600; margin-top: 6px; line-height: 1.25; }
.suggestion-card .s-brand { font-size: 11px; color: var(--text-muted); }

.result-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.validated-banner {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px; border-radius: 20px; background: rgba(143,163,230,0.15);
  border: 1px solid rgba(143,163,230,0.5); color: var(--accent-soft); font-weight: 600;
}

/* ---------- Detail page ---------- */
.detail-topbar { display: flex; align-items: center; margin-bottom: 6px; }

/* ---------- Catalogue ---------- */
.cat-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.cat-title { font-family: 'Playfair Display', serif; font-size: 24px; flex: 1; }
.search-field {
  width: 100%;
  height: 48px;
  border-radius: 24px;
  background: var(--surface);
  border: 1.5px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 0 18px;
  font-size: 14px;
  font-family: 'Poppins', sans-serif;
  margin-bottom: 12px;
}
.search-field::placeholder { color: var(--text-muted); }
.filter-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 6px; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 9px 16px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.filter-chip.active { background: var(--gradient); color: var(--bg); border-color: transparent; }

.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  overflow-y: auto;
  padding-bottom: 20px;
}
.cat-card { cursor: pointer; }
.cat-card .thumb {
  width: 100%; aspect-ratio: 1/1; border-radius: 18px; background: var(--surface);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08); position: relative;
}
.cat-card .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.cat-card .c-name { font-size: 13px; font-weight: 600; margin-top: 8px; line-height: 1.25; }
.cat-card .c-brand { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px 0; font-size: 14px; grid-column: 1 / -1; }

/* ---------- Misc ---------- */
.spacer { flex: 1; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.diamond-loader { width: 46px; height: 46px; opacity: 0.85; animation: spin 2.2s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.badge-diamond { width: 22px; height: 22px; }

::selection { background: rgba(233,237,248,0.3); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  max-width: 86%;
  background: var(--surface-high);
  border: 1px solid rgba(233,237,248,0.35);
  color: var(--text);
  padding: 14px 20px;
  border-radius: 18px;
  font-size: 13.5px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
