:root {
  --bg: #151214;
  --panel: rgba(21, 18, 20, 0.82);
  --ink: #f6efef;
  --muted: #b9adb0;
  --accent: #e0607e;
  --line: rgba(255, 255, 255, 0.14);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

/* start */
#start { display: flex; align-items: center; justify-content: center; padding: 24px; overflow-y: auto; background: radial-gradient(120% 80% at 50% 0%, #3a2128 0%, var(--bg) 60%); }
.start-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.kicker { margin: 0; color: var(--accent); text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 600; }
h1 { margin: 0 0 4px; font-size: 30px; line-height: 1.1; font-weight: 700; }
h2 { margin: 0 0 12px; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input { font-size: 17px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: var(--ink); outline: none; }
.field input:focus { border-color: var(--accent); }
.steps { margin: 4px 0; padding-left: 20px; color: var(--ink); font-size: 15px; display: flex; flex-direction: column; gap: 6px; }
.note { margin: 0; font-size: 12.5px; color: var(--muted); }
.primary { background: var(--accent); color: #fff; font-weight: 600; padding: 12px 18px; border-radius: 14px; }
.primary.big { padding: 16px; font-size: 18px; }
.ghost { padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line); color: var(--ink); }
.small { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 14px; }

/* przymiarka */
#stage { position: absolute; inset: 0; background: #000; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.topbar { position: absolute; top: 0; left: 0; right: 0; padding: calc(10px + var(--safe-t)) 14px 10px; display: flex; align-items: center; justify-content: space-between; background: linear-gradient(rgba(0,0,0,.55), rgba(0,0,0,0)); }
.salon { font-weight: 600; font-size: 16px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.top-actions { display: flex; gap: 8px; }
.icon { width: 44px; height: 44px; border-radius: 50%; background: rgba(0,0,0,.4); display: grid; place-items: center; }
.icon svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.sheet { position: absolute; top: calc(64px + var(--safe-t)); left: 12px; right: 12px; background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 12px; }
.row > span { width: 78px; font-size: 14px; color: var(--muted); flex: none; }
.row input[type=range] { flex: 1; accent-color: var(--accent); }
.seg { display: flex; flex: 1; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { flex: 1; padding: 7px 2px; font-size: 13px; }
.seg button.active { background: var(--accent); color: #fff; }

.bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 0 calc(10px + var(--safe-b)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.7) 30%); }
.pattern-name { text-align: center; font-size: 14px; font-weight: 600; min-height: 20px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.strip { display: flex; gap: 10px; overflow-x: auto; padding: 8px 14px; scroll-snap-type: x proximity; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.sw { flex: none; width: 58px; height: 58px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background-size: cover; background-position: center; scroll-snap-align: center; position: relative; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.sw.active { border-color: #fff; box-shadow: 0 0 0 3px var(--accent); }
.sw.add { display: grid; place-items: center; background: rgba(255,255,255,.12); font-size: 11px; line-height: 1.1; text-align: center; font-weight: 600; }
.sw.add b { display: block; font-size: 22px; font-weight: 400; }
.sw.custom::after { content: ""; position: absolute; right: -2px; top: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #000; }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 16px 0; }
.modes { display: flex; background: rgba(0,0,0,.45); border-radius: 12px; padding: 3px; justify-self: start; }
.mode { padding: 7px 10px; border-radius: 9px; font-size: 13px; color: var(--muted); }
.mode.active { background: rgba(255,255,255,.16); color: #fff; }
.shutter { width: 68px; height: 68px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.shutter span { width: 52px; height: 52px; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(.9); }
.shutter.save span { background: var(--accent); }
#btnGallery { justify-self: end; background: rgba(0,0,0,.45); }

.hint { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); background: rgba(0,0,0,.6); padding: 10px 16px; border-radius: 12px; text-align: center; font-size: 15px; max-width: 80%; }
.loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: rgba(0,0,0,.5); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgba(255,255,255,.25); border-top-color: #fff; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal-box { width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; background: #211b1e; border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.pick { display: flex; flex-direction: column; gap: 10px; }
#cropArea { position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; overflow: hidden; touch-action: none; background: #000; }
#cropCanvas { width: 100%; height: 100%; display: block; }
.crop-guide { position: absolute; top: 4%; bottom: 4%; left: 50%; width: 52%; transform: translateX(-50%); border: 2px dashed rgba(255,255,255,.8); border-radius: 45% 45% 30% 30% / 22% 22% 12% 12%; pointer-events: none; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.crop-guide span { position: absolute; top: -2px; left: 50%; transform: translate(-50%, -100%); font-size: 11px; background: rgba(0,0,0,.6); padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast { position: fixed; left: 50%; bottom: calc(180px + var(--safe-b)); transform: translateX(-50%); background: rgba(20,16,18,.92); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 88%; text-align: center; z-index: 20; }
