/* ROYA — Gen Z AR try-on. Light, clean, high-contrast neon accents, no horizontal scrolling. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --bg: #f7f7fb;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1f1f8;
  --border: #e6e6f0;
  --text: #17172a;
  --text-dim: #5c5c78;
  --text-faint: #9292ac;

  --pink: #ff3ea5;
  --violet: #8b5cf6;
  --cyan: #0891b2;
  --lime: #4d7c0f;

  --grad-hero: linear-gradient(120deg, #ff3ea5 0%, #8b5cf6 45%, #22d3ee 100%);
  --grad-btn: linear-gradient(120deg, #ff3ea5, #8b5cf6);
  --grad-card: linear-gradient(160deg, rgba(139,92,246,.10), rgba(34,211,238,.05));

  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --font-display: "Cairo", "Space Grotesk", sans-serif;
  --font-body: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  color-scheme: light;
}

html, body { background: var(--bg); overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  font-family: var(--font-body);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 12px 16px 100px;
  position: relative;
  min-height: 100vh;
  overflow-x: hidden;
}

img { max-width: 100%; }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 18px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--bg) 78%, transparent);
}
.brand-logo {
  height: 30px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  cursor: pointer;
  border-radius: 6px;
}
.iconbtn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 1px 3px rgba(23,23,42,.06);
  flex: none;
}
.favcount {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  background: var(--pink);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 999px;
  min-width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  padding: 0 3px;
}

/* ---------- screens ---------- */
.screen { display: none; animation: fadein .25s ease; max-width: 100%; }
.screen.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.screen-title { margin: 6px 2px 16px; }
.screen-title h2 { margin: 0 0 4px; font-family: var(--font-display); font-size: 22px; font-weight: 800; }
.screen-title p { margin: 0; color: var(--text-dim); font-size: 13px; }

/* ---------- landing ---------- */
.hero-visual {
  position: relative;
  height: 190px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.hero-visual img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.hero-visual::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(0deg, rgba(23,23,42,.35) 0%, rgba(23,23,42,0) 55%);
}

.home-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 12px 6px 0;
  gap: 4px;
}
.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--violet);
  margin-bottom: 8px;
}
.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(26px, 7.5vw, 34px);
  line-height: 1.15;
  margin: 0 0 10px;
  font-weight: 900;
  color: var(--text);
}
.home-hero p { color: var(--text-dim); margin: 0 0 26px; line-height: 1.6; font-size: 14px; }
.home-hero .btn-lg { min-height: 60px; font-size: 16px; margin-bottom: 10px; }

/* ---------- buttons ---------- */
.btn {
  min-height: 52px;
  border-radius: var(--radius-md);
  border: 0;
  font-weight: 800;
  font-size: 15px;
  font-family: var(--font-display);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  padding: 0 18px;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.97); }
.btn-block { width: 100%; }
.btn-primary { background: var(--grad-btn); color: #fff; box-shadow: 0 10px 30px rgba(255,62,165,.22); }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn:disabled { opacity: .5; cursor: default; }

.lens-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.lens-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(23,23,42,.05);
}
.lens-media {
  aspect-ratio: 1 / 1;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--surface-2);
}
.lens-media img { width: 100%; height: 100%; object-fit: cover; }
.lens-media .lens-orb {
  width: 62%;
  height: 62%;
  border-radius: 50%;
  box-shadow: inset 0 0 0 6px rgba(255,255,255,.5), 0 8px 24px rgba(23,23,42,.15);
}
.lens-badge {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  color: var(--lime);
  font-size: 10px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 999px;
}
.lens-fav {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.85);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
}
.lens-fav.active { color: var(--pink); }
.lens-info { padding: 10px 12px 12px; }
.lens-info .li-name { font-weight: 800; font-size: 14px; margin-bottom: 1px; color: var(--text); }
.lens-info .li-color { font-size: 11px; color: var(--text-faint); margin-bottom: 6px; }
.lens-info .li-price { font-size: 12px; color: var(--cyan); font-weight: 700; margin-bottom: 8px; }
.li-tryon {
  width: 100%;
  min-height: 36px;
  border-radius: 10px;
  border: 0;
  background: var(--grad-btn);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}

/* ---------- lens detail ---------- */
.detail-content { padding-top: 4px; }
.detail-media {
  aspect-ratio: 1/1;
  max-width: 220px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 10px 30px rgba(23,23,42,.12);
}
.detail-media img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.detail-media .lens-orb { width: 100%; height: 100%; }
.detail-body { text-align: center; }
.detail-collection { font-size: 12px; color: var(--text-faint); margin-bottom: 6px; }
.detail-name { font-family: var(--font-display); font-size: 26px; font-weight: 900; margin: 0 0 4px; }
.detail-color { color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }
.detail-price { font-size: 18px; font-weight: 800; color: var(--pink); margin-bottom: 14px; }
.detail-desc { color: var(--text-dim); font-size: 14px; line-height: 1.7; margin: 0 auto 18px; max-width: 340px; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- size selector (used in detail / entry / sheet) ---------- */
.size-block { margin: 0 auto 18px; max-width: 340px; text-align: start; }
.size-block .size-label { font-size: 12px; font-weight: 800; color: var(--text-dim); margin-bottom: 8px; }
.size-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.size-chip {
  flex: 1 1 auto;
  min-width: 88px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  line-height: 1.5;
}
.size-chip .sc-price { display: block; font-size: 11px; color: var(--text-faint); font-weight: 700; }
.size-chip.active { border-color: var(--pink); background: rgba(255,62,165,.06); color: var(--pink); }
.size-chip.active .sc-price { color: var(--pink); }

/* compact variant: try-on screen, always-visible (not tucked in a sheet) */
.size-row-compact { gap: 6px; }
.size-row-compact .size-chip { min-width: 66px; padding: 7px 8px; font-size: 11px; }
.size-row-compact .size-chip .sc-price { font-size: 9.5px; }

/* ---------- selection summary ---------- */
.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 0 0 18px;
  box-shadow: 0 1px 3px rgba(23,23,42,.05);
}
.summary-card .sum-title { font-size: 11px; font-weight: 800; color: var(--text-faint); letter-spacing: .04em; margin-bottom: 8px; }
.summary-grid { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 4px; }
.summary-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.summary-item .si-swatch { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 3px rgba(255,255,255,.6); }
.summary-item .si-label { color: var(--text-faint); }
.summary-item .si-value { font-weight: 800; color: var(--text); }
.summary-card .sum-size-block { margin: 12px 0 0; max-width: none; padding-top: 12px; border-top: 1px solid var(--border); }
.summary-card .sum-size-block .size-label { margin-bottom: 8px; }

/* ---------- lens size adjust (distinct from stage view-zoom) ---------- */
.lens-size-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 12px 0;
}
.lens-size-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.lens-size-label { font-size: 12px; font-weight: 800; color: var(--text-dim); }
.lens-size-value { font-size: 12px; font-weight: 800; color: var(--pink); }
.lens-size-controls { display: flex; align-items: center; gap: 10px; }
.lens-size-btn {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--grad-btn);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(255,62,165,.3);
}
.lens-size-btn:active { transform: scale(.92); }
.lens-size-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.lens-size-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad-btn);
  transition: width .15s ease;
}

/* ---------- try-on size row (always visible) ---------- */
.tryon-size-block { margin: 0 0 12px; }
.tryon-size-block .size-label { font-size: 11px; font-weight: 800; color: var(--text-faint); margin-bottom: 6px; }

/* ---------- try-on entry ---------- */
.entry-head { text-align: center; margin-bottom: 18px; }
.entry-swatch {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 12px;
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.6), 0 8px 24px rgba(23,23,42,.15);
}
.entry-head h2 { font-family: var(--font-display); font-size: 20px; margin: 0 0 4px; }
.entry-head p { color: var(--text-dim); font-size: 13px; margin: 0; }

.entry-options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.entry-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  text-align: start;
  position: relative;
  box-shadow: 0 1px 3px rgba(23,23,42,.05);
}
.entry-card--highlight { border-image: var(--grad-hero) 1; border-width: 2px; border-style: solid; }
.entry-emoji { font-size: 26px; flex: none; }
.entry-label { font-weight: 800; font-size: 15px; display: block; color: var(--text); }
.entry-sub { font-size: 12px; color: var(--text-faint); display: block; }
.entry-card > span { pointer-events: none; }
.entry-tag {
  position: absolute;
  top: 12px;
  inset-inline-end: 14px;
  font-size: 10px;
  font-weight: 800;
  color: var(--pink);
  background: rgba(255,62,165,.1);
  padding: 3px 8px;
  border-radius: 999px;
}
.no-photo-note { text-align: center; color: var(--text-faint); font-size: 12px; }

/* ---------- try-on screen ---------- */
.status { font-size: 12px; color: var(--text-dim); margin: 4px 2px 10px; min-height: 16px; }
.status.error { color: #d1435b; }
.status.ok { color: #2b7a3d; }

.stage {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #05050a;
  min-height: 340px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
}
canvas { display: block; max-width: 100%; max-height: 62vh; width: auto; height: auto; }
#liveVideo { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.stage-topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px;
  z-index: 3;
  background: linear-gradient(180deg, rgba(5,5,10,.55) 0%, rgba(5,5,10,0) 75%);
}
.stage-lens-info { display: flex; flex-direction: column; gap: 1px; color: #fff; }
.stage-lens-name { font-family: var(--font-display); font-weight: 800; font-size: 15px; }
.stage-lens-color { font-size: 11px; opacity: .85; }
.stage-icon-btn {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(23,23,42,.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  display: grid; place-items: center;
  font-size: 15px;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.stage-icon-btn:active { transform: scale(.92); }
.stage-icon-btn.heart.active { color: var(--pink); background: rgba(255,255,255,.92); border-color: transparent; }

.stage-rail {
  position: absolute;
  top: 54px;
  inset-inline-end: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 3;
}
.zoom-pill {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: rgba(23,23,42,.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(5,5,10,.25);
  overflow: hidden;
}
.zoom-pill-btn {
  flex: none;
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .12s ease;
}
.zoom-pill-btn:active { background: rgba(255,255,255,.18); }
.zoom-pill-divider { height: 1px; margin: 0 8px; background: rgba(255,255,255,.28); }

.rail-btn {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3);
  background: rgba(23,23,42,.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(5,5,10,.2);
  transition: transform .12s ease, background .12s ease;
}
.rail-btn:active { transform: scale(.92); background: rgba(23,23,42,.6); }
.rail-btn.active { background: var(--grad-btn); border-color: transparent; }
.empty-state {
  position: absolute; inset: 0;
  display: grid; place-items: center; align-content: center; gap: 8px;
  color: #fff;
  background: linear-gradient(150deg, #1a1a2e, #05050a);
  text-align: center;
}
.eye { font-size: 46px; }
.live-badge {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  background: rgba(255,62,165,.9);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

.split-label {
  position: absolute;
  top: 12px;
  background: rgba(23,23,42,.75);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  z-index: 2;
}
.split-label-after { left: 12px; }
.split-label-before { right: 12px; }
.split-divider {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 2px;
  margin-inline-start: -1px;
  background: rgba(255,255,255,.85);
  box-shadow: 0 0 6px rgba(0,0,0,.35);
  z-index: 2;
}

.hidden { display: none !important; }

.lens-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 2px 6px;
  margin: 0 -2px 4px;
  scrollbar-width: none;
}
.lens-strip::-webkit-scrollbar { display: none; }

.tryon-actions { margin-top: 10px; }
.tryon-actions .btn { min-height: 50px; }

/* ---------- AI mode ---------- */
.ai-action-bar { margin-top: 12px; }
.ai-action-bar .ai-hint { margin: 8px 2px 0; font-size: 12px; color: var(--text-faint); text-align: center; }
#aiGenerateBtn.is-loading { animation: pulse 1.1s ease-in-out infinite; cursor: progress; }
#aiGenerateBtn:disabled { opacity: .85; }
/* Overlay-only controls that don't apply to AI generation */
body.ai-mode #lensSizeBlock { display: none !important; }

/* ---------- favorites ---------- */
.empty-favs { text-align: center; padding: 60px 20px; color: var(--text-faint); }
.empty-favs strong { display: block; color: var(--text); margin: 10px 0 4px; font-size: 15px; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(23,23,42,.5);
  backdrop-filter: blur(2px); z-index: 40;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: 26px 26px 0 0;
  padding: 10px 16px 24px;
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
  animation: sheetup .22s ease;
  box-shadow: 0 -10px 40px rgba(23,23,42,.15);
}
@keyframes sheetup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 999px; margin: 0 auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-family: var(--font-display); font-size: 17px; }
.sheet-lens-item {
  flex: 0 0 76px;
  text-align: center;
  cursor: pointer;
  padding: 4px;
}
.sheet-lens-item .orb {
  width: 60px; height: 60px; border-radius: 50%; margin: 0 auto 6px;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.6);
  border: 2px solid transparent;
}
.sheet-lens-item.active .orb { border-color: var(--pink); }
.sheet-lens-item .name { font-size: 11px; font-weight: 700; color: var(--text-dim); }

/* ---------- order preview sheet ---------- */
.order-row-media { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.order-orb { width: 52px; height: 52px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 4px rgba(255,255,255,.6); }
.order-name { font-weight: 800; font-size: 15px; color: var(--text); }
.order-sub { font-size: 12px; color: var(--text-faint); }
.order-line {
  display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim);
  padding: 10px 0; border-top: 1px solid var(--border);
}
.order-total { font-weight: 800; color: var(--text); font-size: 15px; }
.order-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  z-index: 60;
  box-shadow: 0 12px 30px rgba(23,23,42,.3);
  animation: toastin .2s ease;
  max-width: calc(100vw - 40px);
  text-align: center;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

.footer { text-align: center; color: var(--text-faint); padding: 20px 16px 10px; font-size: 11px; }

@media (min-width: 720px) {
  .app { width: min(520px, 100%); }
}
