/* Cure lounge loyalty app.
   Layout: one phone-width column. Logo banner, glowing membership card (QR inside),
   stamp drops, appointment journal. The owner gets tabs above the same column. */
:root {
  --bg: #eef0f5;          /* pale dusty blue */
  --surface: #ffffff;
  --ink: #2f3546;
  --muted: #6f7890;
  --line: #dde1ea;
  --brand: #8391aa;       /* Cure lounge blue */
  --accent: #a85d67;      /* polish drop mauve */
  --accent-ink: #ffffff;
  --accent-soft: #f4e6e8;
  --ok: #3f7a5f;
  --warn: #a4572a;
  --display: "Quicksand", "Varela Round", system-ui, sans-serif;
  --body: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --script: "Allura", "Segoe Script", cursive;
  --r: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181b23; --surface: #22262f; --ink: #eef0f5; --muted: #a3abbf; --line: #343a48;
    --accent: #d9939b; --accent-ink: #22161a; --accent-soft: #3a2a30; --ok: #7cc6a1; --warn: #e4a173;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.55; -webkit-text-size-adjust: 100%; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.wrap { max-width: 520px; margin: 0 auto; padding-top: calc(18px + env(safe-area-inset-top, 0px)); padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px)); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 22px; }
.stack { display: flex; flex-direction: column; gap: 22px; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.label { font-size: .7rem; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }

/* Brand */
.banner { display: block; width: 100%; aspect-ratio: 2000 / 1143; object-fit: cover; border-radius: var(--r); background: var(--brand); }
.ownerbar { display: flex; align-items: center; gap: 14px; }
.ownerbar img { width: 96px; aspect-ratio: 2000 / 1143; object-fit: cover; border-radius: 10px; flex: 0 0 auto; background: var(--brand); }
.ownerbar h1 { font-size: 1.35rem; }
.greet { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.greet .hello { font-family: var(--script); font-size: 2.1rem; line-height: 1; color: var(--accent); }

/* Controls */
button, .btn { font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 10px 18px; font-weight: 700; position: relative; }
button:focus-visible, input:focus-visible, textarea:focus-visible, .btn:focus-within, .picks label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ghost-accent { border-color: var(--accent); color: var(--accent); }
.linkbtn { background: none; border: none; padding: 4px; color: var(--muted); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, textarea { font: inherit; font-size: 16px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; width: 100%; }
textarea { min-height: 72px; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > * { min-width: 0; }
.grow { flex: 1 1 160px; }

/* Membership card */
.glow { position: relative; padding: 6px 0; }
.glow::before { content: ""; position: absolute; inset: 8% 4% -2%; border-radius: 40px; background: radial-gradient(60% 70% at 70% 40%, rgba(168,93,103,.45), transparent 70%), radial-gradient(60% 70% at 25% 60%, rgba(131,145,170,.6), transparent 70%); filter: blur(28px); z-index: 0; }
.mcard { position: relative; z-index: 1; border-radius: 24px; overflow: hidden; color: #fff;
  background: linear-gradient(140deg, rgba(255,255,255,.28), rgba(255,255,255,0) 45%), linear-gradient(135deg, #9aa6bf 0%, #8391aa 45%, #a58792 100%);
  border: 1px solid rgba(255,255,255,.45); box-shadow: 0 18px 40px -16px rgba(47,53,70,.55); }
.mcard::after { content: ""; position: absolute; width: 180px; height: 180px; right: -40px; top: -70px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.35), transparent 70%); pointer-events: none; }
.mtop { display: flex; gap: 16px; align-items: center; padding: 22px 22px 18px; flex-wrap: wrap; }
.minfo { flex: 1 1 170px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.tier { align-self: flex-start; font-size: .68rem; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; padding: 4px 12px; border-radius: 999px; background: rgba(255,255,255,.28); border: 1px solid rgba(255,255,255,.5); }
.tier.unlocked { background: #fff; color: #a85d67; border-color: #fff; }
.mname { font-family: var(--display); font-weight: 700; font-size: 1.75rem; line-height: 1.1; overflow-wrap: anywhere; text-shadow: 0 1px 12px rgba(47,53,70,.25); }
.meter { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; }
.meter b { font-variant-numeric: tabular-nums; font-weight: 700; }
.bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,.4); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: #fff; box-shadow: 0 0 10px rgba(255,255,255,.8); }
.mqr { flex: 0 0 auto; background: #fff; padding: 8px; border-radius: 16px; box-shadow: 0 6px 18px rgba(47,53,70,.25); }
.mqr img { display: block; width: 116px; height: 116px; }
.mfoot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 13px 22px; background: rgba(255,255,255,.2); border-top: 1px solid rgba(255,255,255,.35); font-size: .9rem; }
.mcode { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .22em; font-weight: 700; }

/* Panels and stamp drops */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.drops { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.drop { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; border: 1.5px dashed var(--line); }
.drop svg { width: 46%; height: 60%; }
.drop.on { border: none; background: var(--accent-soft); }
.drop.gift { border: 1.5px solid var(--accent); color: var(--accent); }
.drop.gift svg { width: 52%; height: 52%; }

/* Appointment journal */
.visits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.visit { display: grid; grid-template-columns: 52px 1fr; gap: 16px; padding: 16px 0; border-top: 1px solid var(--line); }
.visit:first-child { border-top: none; padding-top: 0; }
.visit:last-child { padding-bottom: 0; }
.date { text-align: center; font-variant-numeric: tabular-nums; }
.date .d { font-family: var(--display); font-weight: 600; font-size: 1.6rem; line-height: 1; }
.date .m { font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 700; }
.date .y { font-size: .7rem; color: var(--muted); }
.svc { display: flex; flex-wrap: wrap; gap: 6px; }
.svc span { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 11px; font-size: .82rem; font-weight: 700; }
.vnote { margin-top: 7px; font-size: .92rem; overflow-wrap: anywhere; }
.vtag { margin-top: 6px; font-size: .8rem; font-weight: 700; }
.vtag.earned { color: var(--ok); }
.vtag.reward { color: var(--accent); }
.empty { text-align: center; padding: 18px 8px; color: var(--muted); }
.sign { text-align: center; font-family: var(--script); font-size: 1.7rem; color: var(--muted); }

/* Owner desk */
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px; }
.panel .tabs { background: var(--bg); }
.tabs button { flex: 1; border: none; background: transparent; padding: 9px 6px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--brand); color: #fff; }
.scanbtn { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 16px; border: 1.5px dashed var(--brand); border-radius: var(--r); background: var(--surface); color: var(--ink); text-align: center; font-weight: 400; width: 100%; }
.scanbtn svg { width: 42px; height: 42px; color: var(--accent); }
.scanbtn strong { font-family: var(--display); font-size: 1.15rem; }
.picks { display: flex; flex-wrap: wrap; gap: 8px; }
.picks label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px; cursor: pointer; font-size: .9rem; user-select: none; }
.picks input { width: auto; accent-color: var(--accent); }
.picks label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.clients { list-style: none; margin: 0; padding: 0; }
.clients li { border-top: 1px solid var(--line); }
.clients li:first-child { border-top: none; }
.clients button { width: 100%; text-align: left; border: none; border-radius: 12px; background: transparent; padding: 12px 6px; display: flex; justify-content: space-between; gap: 12px; align-items: center; font-weight: 400; }
.clients button:hover { background: var(--accent-soft); }
.pill { font-variant-numeric: tabular-nums; font-size: .82rem; padding: 2px 11px; border-radius: 999px; background: var(--bg); color: var(--ink); font-weight: 700; white-space: nowrap; }
.pill.ready { background: var(--accent); color: var(--accent-ink); }
.notice { border-radius: 14px; padding: 12px 14px; background: var(--accent-soft); font-size: .92rem; }
.notice.err { background: transparent; border: 1px solid var(--warn); color: var(--warn); }

/* Flip card: front = member card with QR, back = stamps */
/* 3D half-turn. iPhone Safari can ignore backface-visibility and draw the
   front mirrored, so the app also swaps which side is visible (show-back)
   at the halfway point, when the card is edge-on. */
.flip { -webkit-perspective: 1400px; perspective: 1400px; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.flip-inner { display: grid; transition: transform .75s cubic-bezier(.3,.7,.2,1); -webkit-transform-style: preserve-3d; transform-style: preserve-3d; }
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.face { grid-area: 1 / 1; -webkit-backface-visibility: hidden; backface-visibility: hidden; transform: rotateY(0deg); }
.face.back { transform: rotateY(180deg); visibility: hidden; }
.flip.show-back .face.front { visibility: hidden; }
.flip.show-back .face.back { visibility: visible; }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
.face .mcard, .ocard .mcard { height: 100%; display: flex; flex-direction: column; }
.face .mtop { flex: 1; flex-wrap: nowrap; }
.face .minfo { flex: 1 1 auto; }
.mbody { padding: 18px 20px 18px; display: flex; flex-direction: column; gap: 12px; flex: 1; position: relative; z-index: 1; }
.mhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.mhead .title { font-family: var(--display); font-weight: 700; font-size: 1.25rem; overflow-wrap: anywhere; }
.face .mfoot, .ocard .mfoot { flex-wrap: nowrap; }
.face .mfoot > span:first-child, .ocard .mfoot > span:first-child { flex: 1; min-width: 0; }
.tapnote { font-size: .78rem; opacity: .9; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tapnote svg { width: 14px; height: 14px; }
@media (max-width: 420px) { .mqr img { width: 100px; height: 100px; } .face .mtop { gap: 12px; padding: 20px 18px 16px; } }

/* Stamps with the brush picture */
.cstamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; row-gap: 14px; }
.cs { position: relative; aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; border: 1px dashed rgba(255,255,255,.6); background: rgba(255,255,255,.12); }
.cs.on { border: 1px solid rgba(255,255,255,.95); background: radial-gradient(circle at 35% 30%, #fff, #f3eef2 70%); box-shadow: 0 3px 10px rgba(47,53,70,.25); }
.cs img { width: 40%; height: auto; transform: translate(6%, -2%); filter: drop-shadow(0 2px 2px rgba(47,53,70,.25)); }
.cs.milestone { border: 1.5px solid #fff; }
.cs.milestone.on::after { content: ""; position: absolute; inset: 2px; border-radius: 50%; border: 1.5px solid #a85d67; }
.cs .tag { font-family: var(--display); font-weight: 700; font-size: .95rem; color: #fff; line-height: 1; text-align: center; }
.cs .gift { width: 50%; height: 50%; color: #fff; }
.cs .badge { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); background: #a85d67; color: #fff; font-family: var(--display); font-weight: 700; font-size: .8rem; line-height: 1; padding: 3px 8px; border: 1.5px solid #fff; border-radius: 999px; box-shadow: 0 2px 6px rgba(47,53,70,.3); white-space: nowrap; z-index: 1; }

/* Rewards list */
.rewards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rw { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; flex-wrap: wrap; }
.rw .at { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 700; background: var(--accent-soft); color: var(--accent); }
.rw .what { flex: 1 1 140px; min-width: 0; }
.rw .what b { display: block; overflow-wrap: anywhere; }
.rw.is-ready { border-color: var(--accent); }
.status { font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.status.ready { background: var(--accent); color: var(--accent-ink); }
.status.used { background: var(--bg); color: var(--ok); }
.status.todo { background: var(--bg); color: var(--muted); }

/* Owner: stamp stepper, appointment actions, reward editor */
.stepper { display: flex; align-items: center; gap: 16px; justify-content: center; }
.stepper button { width: 52px; height: 52px; padding: 0; font-size: 1.6rem; line-height: 1; display: grid; place-items: center; }
.stepper .num { font-family: var(--display); font-size: 2.4rem; font-weight: 700; min-width: 90px; text-align: center; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stepper .num small { display: block; font-size: .8rem; font-family: var(--body); color: var(--muted); font-weight: 600; }
.sm { padding: 6px 13px; font-size: .85rem; }
.danger { border-color: var(--warn); color: var(--warn); }
.vactions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.confirm { margin-top: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--warn); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.vform { padding: 14px; border: 1px solid var(--accent); border-radius: 14px; display: flex; flex-direction: column; gap: 12px; }
.rrow { display: grid; grid-template-columns: 70px 1fr 40px; gap: 8px; align-items: center; }
.rrow input { padding: 9px 10px; }
.iconbtn { width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }

/* Reminder: time for a new set */
.remind { display: flex; gap: 14px; align-items: center; padding: 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); flex-wrap: wrap; }
.remind.due { border: 1.5px solid var(--accent); background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.remind .ricon { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; background: #fff; display: grid; place-items: center; box-shadow: 0 3px 10px rgba(47,53,70,.18); }
.remind .ricon img { width: 34%; height: auto; transform: translateX(6%); }
.remind .rtext { flex: 1 1 150px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.remind .rtext b { font-family: var(--display); font-size: 1.05rem; }
.remind .btn { flex: 0 0 auto; text-decoration: none; }
@media (max-width: 420px) { .remind .btn { width: 100%; text-align: center; } }
.srow { display: grid; grid-template-columns: 1fr 64px auto 40px; gap: 8px; align-items: center; }
.srow input { padding: 9px 10px; }
.srow .wk { font-size: .82rem; color: var(--muted); }

/* Camera scanner */
.scanner { position: fixed; inset: 0; z-index: 30; background: rgba(20,22,30,.94); display: grid; place-items: center; padding: 16px; }
.scanner-inner { position: relative; width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.scanner video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 20px; background: #000; }
.scanframe { position: absolute; top: 0; left: 0; width: 100%; aspect-ratio: 1; border-radius: 20px; box-shadow: inset 0 0 0 40px rgba(20,22,30,.45); border: 2px solid rgba(255,255,255,.8); pointer-events: none; }
.scanhint { color: #fff; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--bg); padding: 10px 20px; border-radius: 999px; font-weight: 700; z-index: 40; max-width: calc(100% - 32px); text-align: center; }
#qrScratch { position: absolute; left: -9999px; top: 0; }
@media (prefers-reduced-motion: no-preference) {
  .drop.on svg { animation: fall .45s cubic-bezier(.3,1.4,.6,1) both; }
  @keyframes fall { from { transform: translateY(-8px) scale(.7); opacity: .3; } to { transform: none; opacity: 1; } }
}
