/* Frame Finder — an optician's mirror with a velvet frame tray */
:root {
  --velvet: #2b1650;
  --velvet-2: #3d2070;
  --velvet-3: #5a2f8f;
  --brass: #f08a8f;
  --brass-soft: #fbcdab;
  --paper: #fbf5f6;
  --paper-2: #f1e6ee;
  --ink: #1c0f33;
  --muted: #7b6a90;
  --mist: #cbbbe0;
  --coat: linear-gradient(115deg, #944894 0%, #db697f 55%, #fbcdab 100%);
  --sans: "Instrument Sans", "Manjari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", "Manjari", Georgia, serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tray-h: 238px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #170b2e; color: var(--paper); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
html[lang="ml"] body { font-family: "Manjari", var(--sans); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
[hidden] { display: none !important; }
.spacer { flex: 1; }

/* ---------- stage ---------- */
.app { position: fixed; inset: 0; overflow: hidden; max-width: 560px; margin: 0 auto; background: radial-gradient(120% 70% at 50% 30%, #3a1d6b 0%, #170b2e 70%); }
.stage { position: absolute; left: 0; right: 0; top: 0; bottom: calc(var(--tray-h) + var(--safe-b) - 22px); width: 100%; height: calc(100% - var(--tray-h) - var(--safe-b) + 22px); object-fit: cover; display: block; }
.stage.mirror { transform: scaleX(-1); }
.stage.contain { object-fit: contain; }

.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 12px) 14px 12px; z-index: 3; background: linear-gradient(rgba(23,11,46,.55), rgba(23,11,46,0)); }
.face-chip { display: flex; flex-direction: column; align-items: flex-start; padding: 7px 14px 6px; border-radius: 14px; background: rgba(251,245,246,.94); color: var(--ink); line-height: 1.15; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.face-chip-label { font-size: 11px; color: var(--muted); }
.face-chip-value { font-family: var(--serif); font-size: 21px; }
html[lang="ml"] .face-chip-value { font-family: "Manjari", serif; font-size: 17px; font-weight: 700; }
.pill-btn { padding: 8px 14px; border-radius: 999px; background: rgba(23,11,46,.55); border: 1px solid rgba(203,187,224,.35); font-size: 14px; backdrop-filter: blur(8px); }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: rgba(23,11,46,.55); border: 1px solid rgba(203,187,224,.35); backdrop-filter: blur(8px); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.is-on { border-color: var(--brass); color: var(--brass-soft); }

.status { position: absolute; left: 50%; top: calc(var(--safe-t) + 84px); transform: translateX(-50%); z-index: 3; max-width: calc(100% - 40px); padding: 10px 16px; border-radius: 14px; background: rgba(23,11,46,.78); border: 1px solid rgba(203,187,224,.25); font-size: 15px; text-align: center; backdrop-filter: blur(10px); }
.status .btn { margin-top: 10px; }
.status.scan::before { content: ""; display: block; height: 3px; margin: -4px -6px 8px; border-radius: 3px; background: var(--coat); background-size: 200% 100%; animation: sheen 1.6s linear infinite; }
@keyframes sheen { to { background-position: -200% 0; } }

.controls { position: absolute; left: 0; right: 0; bottom: calc(var(--tray-h) + var(--safe-b) + 6px); display: flex; justify-content: center; align-items: center; gap: 38px; z-index: 3; }
.shutter { width: 70px; height: 70px; border-radius: 50%; border: 3px solid var(--paper); display: grid; place-items: center; background: rgba(23,11,46,.25); }
.shutter span { width: 54px; height: 54px; border-radius: 50%; background: var(--paper); transition: transform .12s; }
.shutter:active span { transform: scale(.88); }
.icon-btn.round { width: 48px; height: 48px; }

/* ---------- tray ---------- */
.tray { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--tray-h) + var(--safe-b)); padding-bottom: var(--safe-b); z-index: 4; border-radius: 26px 26px 0 0; background:
  radial-gradient(140% 90% at 50% 0%, rgba(255,255,255,.05), rgba(0,0,0,0) 60%),
  repeating-linear-gradient(115deg, rgba(255,255,255,.012) 0 2px, rgba(0,0,0,.02) 2px 4px),
  var(--velvet); box-shadow: 0 -10px 30px rgba(0,0,0,.35); display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 12px 14px 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 7px 13px; border-radius: 999px; font-size: 14px; color: var(--mist); white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); background: var(--paper); font-weight: 600; }
.tray-extra { padding: 0 16px; }
.tray-extra:empty { display: none; }
.strip { flex: 1; display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden; padding: 10px 16px 14px; scroll-snap-type: x proximity; scrollbar-width: none; align-items: stretch; }
.strip::-webkit-scrollbar { display: none; }
.strip-empty { color: var(--mist); font-size: 15px; line-height: 1.5; padding: 14px 4px; max-width: 34ch; }
.group-label { flex: none; writing-mode: vertical-rl; transform: rotate(180deg); font-size: 12px; color: var(--mist); padding: 4px 0; border-right: 1px solid rgba(203,187,224,.25); padding-right: 6px; text-align: center; }

.card { position: relative; flex: none; width: 138px; scroll-snap-align: start; border-radius: 16px; padding: 8px 10px 10px; text-align: left; background: var(--velvet-2); border: 1.5px solid transparent; display: flex; flex-direction: column; gap: 2px; transition: border-color .15s, background .15s; }
.card.is-on { border-color: var(--brass); background: var(--velvet-3); }
.card .thumb { width: 100%; height: 64px; display: block; border-radius: 10px; background: radial-gradient(90% 90% at 50% 40%, #fdf9fa, #f0e4ec); }
.card .thumb.dark { background: transparent; }
.card-name { font-weight: 600; font-size: 15px; margin-top: 6px; }
.card-sub { font-size: 12.5px; color: var(--mist); }
.card-score { margin-top: auto; padding-top: 4px; font-size: 12.5px; color: var(--brass-soft); }
.card-score b { font-size: 16px; font-weight: 700; color: var(--brass); }
.card-more { margin-top: auto; padding-top: 4px; font-size: 12.5px; color: var(--paper); text-decoration: underline; text-underline-offset: 3px; }
.badge { position: absolute; top: -7px; left: 10px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--ink); background: var(--coat); }
.card.lens-card .thumb { height: 64px; background: none; }
.card.saved-card img { width: 100%; height: 92px; object-fit: cover; border-radius: 10px; display: block; background: var(--velvet-3); }
.card.saved-card .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; background: rgba(23,11,46,.75); font-size: 16px; line-height: 26px; text-align: center; }

.swatch-row { display: flex; gap: 14px; align-items: flex-start; }
.swatch { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 64px; font-size: 12px; color: var(--mist); text-align: center; }
.swatch i { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(203,187,224,.3); box-shadow: inset 0 2px 6px rgba(255,255,255,.25); }
.swatch.is-on i { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(240,138,143,.25), inset 0 2px 6px rgba(255,255,255,.25); }
.swatch.is-on { color: var(--paper); }
.size-block { flex: none; display: flex; flex-direction: column; gap: 8px; padding-left: 16px; margin-left: 4px; border-left: 1px solid rgba(203,187,224,.2); }
.size-block p { margin: 0; font-size: 12.5px; color: var(--mist); }
.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(23,11,46,.5); gap: 2px; }
.seg button { padding: 6px 12px; border-radius: 9px; font-size: 14px; color: var(--mist); }
.seg button.is-on { background: var(--paper); color: var(--ink); font-weight: 600; }
.chip-row { display: flex; gap: 8px; align-items: center; padding: 2px 0 0; font-size: 13px; color: var(--mist); }

/* ---------- intro ---------- */
.intro { position: fixed; inset: 0; z-index: 20; overflow-y: auto; background:
  radial-gradient(90% 55% at 50% 22%, #4a2784 0%, rgba(43,22,80,0) 70%), var(--velvet); }
.intro-inner { max-width: 460px; margin: 0 auto; padding: calc(var(--safe-t) + 18px) 24px calc(var(--safe-b) + 28px); min-height: 100%; display: flex; flex-direction: column; }
.intro-brand { display: flex; align-items: center; gap: 12px; }
.intro-brand img { filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.brand-name { margin: 0; font-family: var(--serif); font-size: 26px; line-height: 1; }
html[lang="ml"] .brand-name { font-family: "Manjari", serif; font-weight: 700; font-size: 22px; }
.brand-tag { margin: 2px 0 0; font-size: 13px; color: var(--mist); }
.hero-canvas { width: 100%; height: 200px; margin: 28px 0 0; display: block; }
.hero-name { margin: 0; text-align: center; font-family: var(--serif); font-style: italic; font-size: 20px; color: var(--brass-soft); min-height: 1.4em; transition: opacity .35s; }
.intro-title { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 11.5vw, 54px); line-height: 1.0; letter-spacing: -0.01em; margin: 22px 0 14px; }
html[lang="ml"] .intro-title { font-family: "Manjari", serif; font-weight: 700; font-size: clamp(30px, 8.6vw, 40px); line-height: 1.3; }
.intro-body { margin: 0 0 26px; font-size: 17px; line-height: 1.5; color: #e4d8f2; max-width: 36ch; }
.intro-actions { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.btn { display: inline-flex; justify-content: center; align-items: center; min-height: 52px; padding: 0 22px; border-radius: 16px; font-size: 17px; font-weight: 600; }
.btn-primary { background: var(--brass); color: var(--ink); }
.btn-primary:active { background: var(--brass-soft); }
.btn-ghost { border: 1.5px solid rgba(203,187,224,.45); color: var(--paper); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-line { border: 1.5px solid rgba(28,15,51,.25); color: var(--ink); }
.btn-small { min-height: 40px; font-size: 15px; padding: 0 16px; border-radius: 12px; }
.btn-link { margin-top: 14px; color: var(--brass-soft); text-decoration: underline; text-underline-offset: 3px; font-size: 15px; align-self: center; }
.fine.by a { color: var(--mist); text-decoration: none; border-bottom: 1px solid rgba(203,187,224,.4); }
.fine { font-size: 13.5px; color: var(--mist); text-align: center; margin: 14px 0 0; line-height: 1.5; }

/* ---------- sheet (printed card) ---------- */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(14,6,28,.55); opacity: 0; transition: opacity .25s; }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 92%; overflow-y: auto; overscroll-behavior: contain; background: var(--paper); color: var(--ink); border-radius: 26px 26px 0 0; padding: 0 20px calc(var(--safe-b) + 22px); transform: translateY(100%); transition: transform .32s cubic-bezier(.2,.8,.2,1); outline: none; }
.sheet.open .sheet-scrim { opacity: 1; }
.sheet.open .sheet-panel { transform: none; }
.sheet-grab { display: block; width: 100%; padding: 10px 0 6px; position: sticky; top: 0; background: var(--paper); z-index: 2; }
.sheet-grab span { display: block; width: 44px; height: 5px; border-radius: 3px; background: #cdbfe0; margin: 0 auto; }
.sheet-body h2 { font-family: var(--serif); font-weight: 400; font-size: 38px; line-height: 1; margin: 0; }
html[lang="ml"] .sheet-body h2 { font-family: "Manjari", serif; font-weight: 700; font-size: 30px; line-height: 1.2; }
.sheet-body h3 { font-size: 15px; font-weight: 600; margin: 24px 0 8px; color: var(--velvet); }
.sheet-body p { margin: 0 0 8px; font-size: 16px; line-height: 1.55; }
.sheet-body .muted { color: var(--muted); }
.sheet-hero { height: 150px; margin: 4px -4px 14px; border-radius: 18px; background: radial-gradient(80% 90% at 50% 45%, #ffffff, var(--paper-2)); }
.sheet-hero canvas { width: 100%; height: 100%; display: block; }
.sheet-head { display: flex; align-items: flex-end; gap: 14px; }
.sheet-head > div:first-child { flex: 1; }
.sheet-head .sub { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.score-ring { flex: none; width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; text-align: center; line-height: 1; font-weight: 700; font-size: 22px;
  background: conic-gradient(var(--brass) calc(var(--p) * 1%), #e6dcee 0); position: relative; }
.score-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--paper); }
.score-ring span { position: relative; }
.score-ring small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.fit-line { display: inline-block; margin-top: 10px; padding: 5px 11px; border-radius: 999px; background: #efe4f1; font-size: 14px; color: var(--velvet); }
.fit-line.warn { background: #f4e9d2; color: #7a5a14; }
.boxing { display: flex; align-items: baseline; gap: 10px; font-size: 30px; font-weight: 600; letter-spacing: .01em; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.boxing .box { display: inline-block; width: .62em; height: .62em; border: 2px solid currentColor; transform: translateY(1px); }
.boxing .arm { font-weight: 400; color: var(--muted); margin-left: 8px; }
.spec-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: #e2d6e8; border: 1px solid #e2d6e8; border-radius: 14px; overflow: hidden; }
.spec-grid div { background: var(--paper); padding: 10px 12px; }
.spec-grid dt { font-size: 12.5px; color: var(--muted); }
.spec-grid dd { margin: 2px 0 0; font-size: 16px; font-weight: 600; }
.sheet .swatch { color: var(--muted); }
.sheet .swatch i { border-color: #ddd0e6; }
.sheet .swatch.is-on { color: var(--ink); }
.sheet .seg { background: #eee3f0; }
.sheet .seg button { color: var(--muted); }
.sheet .seg button.is-on { background: var(--ink); color: var(--paper); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 13px; border-radius: 999px; border: 1.5px solid #d9cce4; font-size: 14.5px; background: #fff; }
.chip.is-on { border-color: var(--velvet); background: var(--velvet); color: var(--paper); }
.tier { display: inline-flex; gap: 3px; align-items: center; font-size: 15px; }
.tier i { width: 9px; height: 9px; border-radius: 50%; background: #ddd0e6; }
.tier i.on { background: var(--brass); }
.tier span { margin-left: 8px; }
.store-list { list-style: none; margin: 10px 0 0; padding: 0; border-top: 1px solid #e2d6e8; }
.store-list li { border-bottom: 1px solid #e2d6e8; }
.store-list a { display: flex; align-items: center; justify-content: space-between; padding: 14px 2px; color: var(--ink); text-decoration: none; font-size: 16.5px; font-weight: 600; }
.store-list a small { font-weight: 400; color: var(--muted); font-size: 13.5px; }
.store-list a svg { width: 18px; height: 18px; color: var(--velvet-3); }
.note { font-size: 13.5px !important; color: var(--muted); margin-top: 10px !important; }
.sheet-actions { position: sticky; bottom: calc(-1 * var(--safe-b) - 22px); display: flex; gap: 10px; padding: 14px 0 calc(var(--safe-b) + 14px); margin: 20px 0 calc(-1 * var(--safe-b) - 22px); background: linear-gradient(rgba(251,245,246,0), var(--paper) 30%); }
.sheet-actions .btn { flex: 1; }

/* face card */
.rx { padding: 6px 0 0; }
.rx-label { font-size: 14px; color: var(--muted); margin: 0 0 6px !important; }
.rx h2 { font-size: 64px !important; }
html[lang="ml"] .rx h2 { font-size: 40px !important; }
.rx-conf { display: inline-block; margin: 8px 0 12px; font-size: 14px; color: var(--velvet); }
.ratio { display: grid; grid-template-columns: 112px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; margin: 8px 0; }
.ratio .bar { position: relative; height: 8px; border-radius: 4px; background: #ebe0ee; }
.ratio .bar::after { content: ""; position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1.5px; background: #a995c0; }
.ratio .bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--velvet-3); }
.ratio b { text-align: right; font-variant-numeric: tabular-nums; }
.measure { display: grid; grid-template-columns: 1fr auto; gap: 10px 12px; margin: 6px 0; font-size: 15.5px; }
.measure dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.capture-img { width: 100%; border-radius: 18px; display: block; margin: 4px 0 14px; }

/* toast */
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 78px); transform: translate(-50%, -12px); padding: 11px 18px; border-radius: 14px; background: var(--paper); color: var(--ink); font-size: 15px; font-weight: 500; box-shadow: 0 10px 30px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 40; max-width: calc(100% - 40px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 561px) {
  body { background: #110823; }
  .app { border-left: 1px solid rgba(203,187,224,.12); border-right: 1px solid rgba(203,187,224,.12); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}
