/* Grow & Glow — Hair Design Studio. Brand: deep green #386055, sage #83998B, mist #CFD9D7, font Kanit. */
:root {
  --green: #386055; --deep: #1F4A3A; --sage: #83998B; --mist: #CFD9D7; --tint: #E8EFEC;
  --bg: #F6F8F7; --card: #FFFFFF; --ink: #1E2B27; --soft: #4F5F59; --line: #DDE5E2;
  --err: #B4443A; --r: 18px; --shadow: 0 14px 40px -24px rgba(20, 50, 40, .45);
  --font: 'Kanit', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-weight: 300; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
b, h1, h2, h3 { font-weight: 500; }
h1 { font-size: 34px; margin: 0; color: var(--deep); }
h2 { font-size: 24px; margin: 0; color: var(--deep); }
h3 { font-size: 15px; margin: 0; text-transform: uppercase; letter-spacing: .08em; color: var(--green); font-weight: 500; }

/* ---------- header ---------- */
.top { flex: 0 0 auto; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); }
.top .logo { height: 46px; width: auto; }
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.brand b { font-size: 18px; color: var(--deep); }
.brand span { font-size: 13px; color: var(--sage); letter-spacing: .06em; text-transform: uppercase; }
.spacer { flex: 1; }
.seg { display: inline-flex; padding: 3px; border-radius: 99px; background: var(--tint); }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 99px; cursor: pointer; font-size: 14px; color: var(--soft); }
.seg button.on { background: var(--card); color: var(--deep); font-weight: 500; box-shadow: 0 2px 8px -4px rgba(0,0,0,.3); }

.btn { border: 1px solid var(--line); background: var(--card); padding: 10px 18px; border-radius: 99px; cursor: pointer; font-size: 15px; font-weight: 400; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: transform .12s, background .2s, border-color .2s; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--sage); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 500; }
.btn.primary:hover:not(:disabled) { background: var(--deep); }
.btn.ghost { background: transparent; }
.btn.big { padding: 15px 34px; font-size: 18px; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; font-size: 16px; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--soft); stroke-width: 1.6; }
.input, select.input { width: 100%; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 16px; outline: none; }
.input:focus { border-color: var(--green); }
.error { color: var(--err); margin: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.muted { color: var(--soft); }

/* ---------- main ---------- */
main { flex: 1; min-height: 0; position: relative; }
.screen { position: absolute; inset: 0; display: none; }
body[data-step="capture"] #scr-capture { display: flex; }
body:not([data-step="capture"]) #scr-work { display: flex; }

/* capture */
#scr-capture { overflow: auto; justify-content: center; padding: 28px 20px; }
.capture { width: min(980px, 100%); display: flex; flex-direction: column; gap: 18px; align-items: stretch; }
.capture .lead { margin: 0; color: var(--soft); font-size: 17px; }
.capture .input { max-width: 420px; }
.shots { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; }
.shot { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.shot-head { display: flex; align-items: baseline; gap: 8px; }
.shot-head b { font-size: 19px; color: var(--deep); }
.shot-head small { color: var(--sage); }
.shot-hint { margin: 0; font-size: 14px; color: var(--soft); }
.shot-photo { position: relative; height: clamp(170px, 30vh, 340px); border-radius: 14px; overflow: hidden; background: var(--tint); display: grid; place-items: center; }
.shot-photo img { width: 100%; height: 100%; object-fit: contain; background: #e9eeec; }
.shot-photo .ph { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--sage); }
.shot-photo .ph svg { width: 54px; height: 54px; fill: none; stroke: var(--sage); stroke-width: 1.3; }
.shot-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.capture > .btn.big { align-self: flex-start; }

/* workspace */
#scr-work { gap: 0; }
.stage-col { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 14px; gap: 12px; }
.panel { flex: 0 0 400px; overflow: auto; background: var(--card); border-left: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.thumbs { display: flex; gap: 10px; overflow-x: auto; flex: 0 0 auto; }
.thumbs:empty { display: none; }
.thumb { flex: 0 0 auto; display: flex; gap: 10px; align-items: center; padding: 6px 14px 6px 6px; border-radius: 14px; background: var(--card); border: 2px solid transparent; cursor: pointer; box-shadow: var(--shadow); }
.thumb img, .thumb .ph { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--tint); }
.thumb b { display: block; font-size: 14px; color: var(--deep); }
.thumb span { font-size: 12px; color: var(--soft); }
.thumb.on { border-color: var(--green); }
.thumb .ph { display: grid; place-items: center; }
.thumb .ph .spinner { width: 22px; height: 22px; }

.stage { position: relative; flex: 1; min-height: 0; border-radius: var(--r); overflow: hidden; background: #E3EAE7; box-shadow: var(--shadow); }
#designCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: none; }
body[data-step="plan"] #designCanvas { display: block; }
body[data-step="plan"] .viewer { display: none; }
.viewer { position: absolute; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; }

/* compare viewer */
.layer { position: absolute; inset: 0; overflow: hidden; }
.layer img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; pointer-events: none; }
.layer.after { clip-path: inset(0 0 0 var(--pos, 50%)); }
.split { position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 12px rgba(0,0,0,.35); pointer-events: none; }
.split i { position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: var(--green); border: 3px solid #fff; display: grid; place-items: center; color: #fff; font-style: normal; font-size: 18px; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
.side { position: absolute; inset: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: #fff; }
.side .layer { position: relative; }
.vtag { position: absolute; top: 12px; padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 500; letter-spacing: .1em; pointer-events: none; z-index: 2; }
.vtag.l { left: 12px; background: rgba(255,255,255,.9); color: var(--soft); }
.vtag.r { right: 12px; background: var(--green); color: #fff; }
.vbar { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 8px; align-items: center; z-index: 3; }
.vbar .seg { background: rgba(255,255,255,.92); }
.zoom-hint { font-size: 12px; color: var(--soft); background: rgba(255,255,255,.85); padding: 4px 10px; border-radius: 99px; }
.vtools { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 8px; z-index: 3; }
.vtools .icon-btn { background: rgba(255,255,255,.92); }

.busy { position: absolute; inset: 0; background: rgba(246, 248, 247, .86); backdrop-filter: blur(4px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; z-index: 10; text-align: center; padding: 20px; }
.busy b { font-size: 22px; color: var(--deep); }
.busy span { color: var(--soft); }
.busy .elapsed { font-variant-numeric: tabular-nums; font-size: 14px; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--mist); border-top-color: var(--green); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* summary bar (results) */
.summary { flex: 0 0 auto; display: none; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px 18px; gap: 18px; align-items: center; flex-wrap: wrap; }
body[data-step="results"] .summary { display: flex; }
.sum-item { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.sum-item label { font-size: 12px; color: var(--sage); text-transform: uppercase; letter-spacing: .08em; }
.sum-item .val { font-size: 20px; font-weight: 500; color: var(--deep); display: flex; align-items: center; gap: 8px; }
.sum-item select, .sum-item input { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; background: var(--bg); font-size: 16px; }
.sum-item input.grafts { width: 92px; }
.sum-sep { width: 1px; align-self: stretch; background: var(--line); }

/* panel blocks */
.block { display: flex; flex-direction: column; gap: 10px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.facts dt { color: var(--soft); }
.facts dd { margin: 0; font-weight: 400; }
.stage-pill { display: inline-flex; align-items: center; gap: 8px; }
.stage-pill select { border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; background: var(--bg); }
.note { font-size: 14px; color: var(--soft); margin: 0; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode { border: 2px solid var(--line); border-radius: 14px; padding: 12px; background: var(--card); cursor: pointer; text-align: left; }
.mode b { display: block; color: var(--deep); font-size: 15px; }
.mode span { font-size: 12px; color: var(--soft); }
.mode.on { border-color: var(--green); background: var(--tint); }
.plan { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; }
.plan .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); flex: 0 0 auto; }
.plan .dot.c1 { background: var(--sage); } .plan .dot.c2 { background: var(--green); } .plan .dot.c3 { background: var(--deep); }
.plan .txt { flex: 1; min-width: 0; }
.plan .txt b { display: block; color: var(--deep); }
.plan .txt span { font-size: 13px; color: var(--soft); }
.plan input { width: 88px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; text-align: right; background: var(--bg); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--green); }
.estimate { background: var(--tint); border-radius: 14px; padding: 14px 16px; }
.estimate .big { font-size: 30px; font-weight: 500; color: var(--deep); line-height: 1.1; }
.estimate span { font-size: 14px; color: var(--soft); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions .btn.primary { grid-column: 1 / -1; }

/* footer */
.legal { flex: 0 0 auto; padding: 8px 20px; font-size: 12px; color: var(--soft); background: var(--card); border-top: 1px solid var(--line); line-height: 1.4; }

/* modals */
.modal { position: fixed; inset: 0; background: rgba(20, 35, 30, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.cam { width: min(920px, 100%); max-height: 100%; background: #111; border-radius: 22px; overflow: hidden; display: flex; flex-direction: column; color: #fff; }
.cam-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; }
.cam-head .icon-btn { background: transparent; border-color: #444; color: #fff; }
.cam-view { position: relative; flex: 1; min-height: 0; background: #000; aspect-ratio: 4 / 3; }
.cam-view video { width: 100%; height: 100%; object-fit: cover; }
.cam-view video.mirror { transform: scaleX(-1); }
.guide { position: absolute; left: 50%; top: 48%; width: 38%; aspect-ratio: 3 / 4; transform: translate(-50%, -50%); border: 3px dashed rgba(255,255,255,.85); border-radius: 50%; box-shadow: 0 0 0 9999px rgba(0,0,0,.35); pointer-events: none; }
.guide.top { width: 52%; aspect-ratio: 1; top: 50%; }
.cam-hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; margin: 0; font-size: 15px; text-shadow: 0 1px 6px rgba(0,0,0,.8); }
.cam-actions { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; }
.cam-actions .btn { color: #fff; border-color: #444; }
.shutter { width: 70px; height: 70px; border-radius: 50%; border: 5px solid #fff; background: var(--green); cursor: pointer; }
.sheet { width: min(560px, 100%); max-height: 100%; overflow: auto; background: var(--card); border-radius: 22px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.set-grid { display: grid; grid-template-columns: 1fr 130px; gap: 10px; align-items: center; }
.toast { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); background: var(--deep); color: #fff; padding: 12px 20px; border-radius: 99px; z-index: 60; max-width: 90%; text-align: center; }

/* ---------- portrait tablets / narrow screens ---------- */
@media (max-width: 1000px), (orientation: portrait) {
  body { overflow: auto; }
  main { flex: none; min-height: 0; }
  .screen { position: static; }
  #scr-work { flex-direction: column; }
  .stage-col { padding: 12px; }
  .stage { flex: none; height: 62vh; min-height: 360px; }
  .panel { flex: none; border-left: 0; border-top: 1px solid var(--line); }
  .shots { grid-template-columns: 1fr; }
}
