/* Hast Rekha scan flow — page-specific styles (extends css/tokens.css) */

.pane-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  margin: 6px 0 8px;
  text-align: center;
}
.lede { color: var(--ink-dim); text-align: center; max-width: 560px; margin: 0 auto 26px; }
.sub-h {
  font-family: var(--font-display); font-weight: 400; font-size: 1.25rem;
  margin: 30px 0 12px;
}
.pane-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }
.center { text-align: center; }
.hint { color: var(--ink-faint); font-size: 0.88rem; text-align: center; }
.form-err { color: var(--bad); text-align: center; font-weight: 600; }
.notice {
  border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 20px 22px; margin: 22px 0; background: var(--card);
}
.notice h3 { margin: 0 0 6px; }
.notice p { margin: 6px 0; color: var(--ink-dim); }
.notice.warn { border-color: rgba(240, 195, 107, 0.45); }
.notice.bad { border-color: rgba(239, 154, 154, 0.45); }
.advice { margin: 10px 0 0; padding-left: 20px; color: var(--warn); font-size: 0.92rem; }

/* ---- step 1 · animated hand coach ---- */
.guide-art { display: flex; justify-content: center; margin: 8px 0 24px; }
.hand-coach { width: min(240px, 62vw); height: auto; }
.coach-frame {
  fill: none; stroke: var(--gold); stroke-width: 2; stroke-dasharray: 10 8;
  opacity: 0.7; animation: framepulse 2.6s ease-in-out infinite;
  transform-origin: center; transform-box: fill-box;
}
@keyframes framepulse { 0%, 100% { transform: scale(1); opacity: 0.55; } 50% { transform: scale(1.025); opacity: 0.9; } }
.coach-palm .hand-silhouette {
  fill: rgba(232, 180, 160, 0.06); stroke: var(--rose); stroke-width: 2.5;
}
.coach-palm { transform-box: fill-box; transform-origin: 50% 92%; animation: handsway 4.2s ease-in-out infinite; }
@keyframes handsway { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(1.6deg); } }
.coach-line { stroke: var(--gold); stroke-width: 2; stroke-linecap: round; fill: none;
  stroke-dasharray: 90; stroke-dashoffset: 90; animation: linedraw 2.4s ease forwards; }
.coach-line.l2 { animation-delay: 0.5s; }
.coach-line.l3 { animation-delay: 1s; }
@keyframes linedraw { to { stroke-dashoffset: 0; } }

.tips { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tip {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.tip h3 { margin: 0 0 4px; font-size: 0.95rem; color: var(--rose); }
.tip p { margin: 0; font-size: 0.88rem; color: var(--ink-dim); }

/* ---- step 2 · capture ---- */
.cam-wrap { margin-bottom: 18px; }
.cam-wrap video {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: var(--radius);
  border: 1px solid var(--card-border); background: #000; display: block;
}
.cam-actions { display: flex; gap: 12px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.drop strong { display: block; margin: 10px 0 2px; font-size: 1.02rem; }
.drop { display: block; margin-top: 18px; }
.thumbs-head { margin-top: 16px; }
.thumb { position: relative; }
.thumb img { display: block; }
.thumb-rm {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px;
  border-radius: 50%; border: 1px solid var(--card-border);
  background: var(--bg-3); color: var(--ink); font-size: 16px; line-height: 1;
  cursor: pointer;
}

/* ---- step 3 · quality ---- */
.quality-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.qcard {
  position: relative; background: var(--card); border: 2px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px; cursor: pointer; color: var(--ink);
  font-family: inherit; text-align: left; transition: border-color 0.2s;
}
.qcard.best { border-color: var(--gold); }
.qcard img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; display: block; }
.qring { position: absolute; top: 16px; right: 16px; width: 52px; height: 52px; }
.qring svg { width: 100%; height: 100%; }
.qring .qbg { fill: rgba(26,16,51,0.75); stroke: rgba(255,255,255,0.15); stroke-width: 6; }
.qring .qfg { fill: none; stroke-width: 6; stroke-linecap: round; }
.qring .qfg.ok { stroke: var(--ok); }
.qring .qfg.mid { stroke: var(--warn); }
.qring .qfg.low { stroke: var(--bad); }
.qring b {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 0.8rem; color: var(--ink);
}
.qcard .badge { margin: 8px 0 0; }
.qbars { display: block; margin-top: 8px; }
.qbars span { display: block; margin-top: 4px; }
.qbars i { font-style: normal; font-size: 0.72rem; color: var(--ink-faint); display: block; }
.qbars em {
  display: block; height: 4px; border-radius: 4px; font-style: normal;
  background: linear-gradient(90deg, var(--rose-deep), var(--gold));
}

/* ---- step 4 · enhance ---- */
.cmp-labels { display: flex; justify-content: space-between; margin: 8px 2px 0; font-size: 0.85rem; color: var(--ink-dim); }
.steps-row {
  display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 12px;
  scroll-snap-type: x mandatory;
}
.step-chip { flex: 0 0 118px; scroll-snap-align: start; margin: 0; }
.step-chip img {
  width: 118px; height: 118px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--card-border); display: block;
}
.step-chip figcaption { font-size: 0.72rem; color: var(--ink-dim); margin-top: 6px; line-height: 1.35; }

/* ---- step 5 · detect ---- */
.detect-art { width: min(200px, 54vw); height: auto; margin: 10px auto; display: block; }
.detect-art .d-palm { fill: rgba(232,180,160,0.05); stroke: var(--rose); stroke-width: 2.5; }
.detect-art .d-line {
  fill: none; stroke: var(--gold); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 220; stroke-dashoffset: 220;
  animation: ddraw 2.2s ease-in-out infinite;
}
.detect-art .dl2 { animation-delay: 0.4s; }
.detect-art .dl3 { animation-delay: 0.8s; }
@keyframes ddraw { 0% { stroke-dashoffset: 220; } 55% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -220; } }
.stage-text { color: var(--ink-dim); margin: 6px 0 14px; min-height: 1.6em; }
.pbar { height: 6px; border-radius: 6px; background: rgba(255,255,255,0.1); overflow: hidden; max-width: 380px; margin: 0 auto; }
.pbar i { display: block; height: 100%; width: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--rose-deep), var(--gold)); transition: width 0.5s ease; }

/* ---- step 6 · verify overlay ---- */
.ovl-root { margin-bottom: 6px; }
.ovl-toolbar { display: grid; gap: 8px; margin-top: 14px; }
.ovl-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.ovl-row.active { border-color: rgba(212,162,78,0.55); }
.ovl-rowhead {
  display: flex; align-items: center; gap: 10px; background: none; border: 0;
  color: var(--ink); font-family: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; padding: 4px; flex: 1 1 auto; text-align: left;
}
.ovl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rose); flex: none; }
.ovl-dot.fate { background: var(--gold); }
.ovl-conf { font-size: 0.78rem; color: var(--ink-faint); font-weight: 400; }
.ovl-seg { display: inline-flex; border: 1px solid var(--card-border); border-radius: 999px; overflow: hidden; }
.ovl-segbtn {
  background: transparent; border: 0; color: var(--ink-dim); font-family: inherit;
  font-size: 0.78rem; padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
.ovl-segbtn.on { background: linear-gradient(120deg, var(--rose-deep), var(--gold)); color: #241303; font-weight: 700; }
.ovl-reset {
  background: none; border: 1px solid var(--card-border); border-radius: 50%;
  width: 30px; height: 30px; display: grid; place-items: center;
  color: var(--ink-dim); cursor: pointer; flex: none;
}
.ovl-reset:hover { color: var(--rose); border-color: var(--rose); }
.ov-line.active { stroke-width: 4.5; }
.ov-pt.h-end { fill: var(--gold); r: 9; }
.ov-pt.h-mid { fill: var(--rose); }
.ov-pt.h-curv { fill: transparent; stroke-dasharray: 4 3; }
.ov-arms { fill: none; stroke: rgba(212,162,78,0.5); stroke-width: 1.5; stroke-dasharray: 5 5; }
.ovl-g text.ov-label { pointer-events: none; }
.ovl-g text.ov-label {
  pointer-events: none;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  fill: rgba(255, 255, 255, 0.95);
  paint-order: stroke;
  stroke: rgba(20, 8, 20, 0.9);
  stroke-width: 3px;
  dominant-baseline: middle;
}
.ovl-g circle.ov-label-dot {
  fill: #d4a24e;
  stroke: rgba(255,255,255,0.6);
  stroke-width: 1px;
  pointer-events: none;
}

/* ---- step 7 · results ---- */
.result-card.summary { border-color: rgba(212,162,78,0.4); }
.result-card.summary h2 { font-family: var(--font-display); font-weight: 400; margin: 0 0 8px; font-size: 1.3rem; }
.share-wrap { margin-bottom: 8px; }
#share-canvas { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--card-border); display: block; }
.history { display: grid; gap: 10px; }
.hist-item {
  display: flex; gap: 12px; align-items: center; background: var(--card);
  border: 1px solid var(--card-border); border-radius: var(--radius-sm); padding: 10px;
}
.hist-item img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex: none; }
.hist-item strong { display: block; font-size: 0.9rem; }
.hist-item span { font-size: 0.82rem; color: var(--ink-dim); display: block; }

@media (max-width: 560px) {
  .ovl-row { gap: 8px; }
  .ovl-segbtn { padding: 7px 9px; font-size: 0.72rem; }
  .pane-actions .btn { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .coach-frame, .coach-palm,
  .coach-line, .detect-art .d-line { animation: none !important; }
  .coach-line, .detect-art .d-line { stroke-dashoffset: 0 !important; }
}

/* ---- Hast Rekha Engine transparency panel ---- */
.engine-panel {
  margin: 26px 0 6px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.engine-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--ink); font-family: inherit; font-size: 1.02rem; font-weight: 700;
  padding: 18px 20px; text-align: left;
}
.engine-head .eng-chev { margin-left: auto; transition: transform .25s ease; color: var(--ink-dim); flex: none; }
.engine-head.open .eng-chev { transform: rotate(180deg); }
.engine-body { padding: 0 16px 16px; }
.eng-chips { display: grid; gap: 10px; }
.eng-chip {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--card-border);
  border-radius: 14px; overflow: hidden;
}
.eng-chip-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--ink); font-family: inherit; padding: 13px 14px; text-align: left;
}
.eng-chip-label { font-weight: 700; font-size: .92rem; }
.eng-chip-val {
  margin-left: auto; font-size: .85rem; color: var(--gold-soft);
  background: rgba(212,162,78,0.12); border: 1px solid rgba(212,162,78,0.3);
  border-radius: 999px; padding: 3px 12px; white-space: nowrap;
}
.eng-chip-head .eng-chev { color: var(--ink-faint); transition: transform .25s ease; flex: none; }
.eng-chip-head.open .eng-chev { transform: rotate(180deg); }
.eng-chip-x { padding: 0 14px 14px; }
.eng-chip-x p { margin: 0 0 10px; color: var(--ink-dim); font-size: .9rem; }
.eng-steps {
  font-size: .8rem; color: var(--ink-faint);
  background: rgba(255,255,255,0.04); border-radius: 10px; padding: 10px 12px;
  margin: 0; line-height: 1.7; word-break: break-word;
}
.eng-bars { display: grid; gap: 8px; }
.eng-bar-row { display: grid; grid-template-columns: 92px 1fr 52px; align-items: center; gap: 10px; font-size: .82rem; }
.eng-bar-row i { font-style: normal; color: var(--ink-dim); }
.eng-bar-row s { text-decoration: none; color: var(--ink-faint); text-align: right; font-variant-numeric: tabular-nums; }
.eng-bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,0.10); overflow: hidden; display: block; }
.eng-bar b { display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--rose-deep), var(--gold)); }

.lefthand-banner {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(212, 162, 78, 0.12);
  border: 1px solid rgba(212, 162, 78, 0.45);
  border-radius: 14px; padding: 14px 16px; margin: 16px 0;
}
.lefthand-banner svg { flex: none; color: #d4a24e; margin-top: 2px; }
.lefthand-banner strong { display: block; font-size: 1.05em; margin-bottom: 4px; color: #f0d9a8; }
.lefthand-banner span { font-size: 0.92em; opacity: 0.9; }

/* ---------- Manual Draw UI ---------- */
.draw-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
  margin: 0 auto;
}

.draw-instructions {
  text-align: center;
  padding: 12px;
  background: rgba(212, 162, 78, 0.08);
  border: 1px solid rgba(212, 162, 78, 0.25);
  border-radius: 12px;
}

.draw-title {
  font-size: 20px;
  font-weight: 700;
  color: #f0e2d0;
  margin: 0 0 8px 0;
}

.draw-guidance {
  font-size: 14px;
  line-height: 1.5;
  color: #d8c8b8;
  margin: 0;
  max-width: 600px;
  margin: 0 auto;
}

.draw-main {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

@media (max-width: 700px) {
  .draw-main {
    flex-direction: column;
  }
}

.draw-ref {
  flex: 0 0 280px;
  text-align: center;
}

.draw-ref-img {
  width: 100%;
  max-width: 280px;
  border-radius: 0;
  border: none;
  background: transparent;
  filter: drop-shadow(0 8px 32px rgba(0, 0, 0, 0.5));
}

.draw-ref-caption {
  font-size: 11px;
  color: #a89078;
  margin: 6px 0 0 0;
}

.draw-canvas-wrap {
  flex: 1;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(212, 162, 78, 0.4);
  touch-action: none;
  min-height: 300px;
  background: #0f0a12;
}

.draw-photo {
  width: 100%;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

.draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  touch-action: none;
}

.draw-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 20px;
  pointer-events: none;
}

.draw-lines {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}

.draw-line-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: #e8d8c8;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.draw-line-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(212, 162, 78, 0.4);
}

.draw-line-btn.active {
  background: rgba(212, 162, 78, 0.15);
  border-color: #d4a24e;
  box-shadow: 0 0 0 1px #d4a24e;
}

.draw-line-btn.done {
  border-color: rgba(76, 175, 80, 0.5);
}

.draw-line-btn.done .draw-line-status {
  color: #4caf50;
}

.draw-line-btn.skipped {
  opacity: 0.5;
}

.draw-line-btn.skipped .draw-line-status {
  color: #888;
}

.draw-line-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d4a24e;
  flex-shrink: 0;
}

.draw-line-name {
  flex: 1;
}

.draw-line-status {
  font-weight: 700;
  font-size: 14px;
  min-width: 16px;
  text-align: center;
}

.draw-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.draw-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #e8d8c8;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.draw-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.draw-progress {
  font-size: 14px;
  color: #a89078;
}

/* ---------- measurement transparency panel ---------- */
.measure-panel {
  margin-top: 16px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 12px;
  background: rgba(212, 175, 55, 0.06);
  overflow: hidden;
}
.measure-panel summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: #d4af37;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.measure-panel summary::-webkit-details-marker { display: none; }
.measure-panel summary::before {
  content: '▸';
  font-size: 12px;
  transition: transform 0.2s;
}
.measure-panel[open] summary::before { transform: rotate(90deg); }
.measure-body { padding: 0 16px 16px; }

.m-widget {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.m-widget:last-child { border-bottom: none; }
.m-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
}
.m-icon svg { width: 32px; height: 32px; }
.m-info { flex: 1; min-width: 0; }
.m-name {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #a89078;
  margin-bottom: 4px;
}
.m-value {
  font-size: 15px;
  font-weight: 600;
  color: #f0e6d8;
}
.m-bar-track {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  margin-top: 6px;
  position: relative;
  overflow: visible;
}
.m-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #d4af37, #f4d03f);
  border-radius: 4px;
  transition: width 0.3s;
}
.m-bar-ticks {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: rgba(255,255,255,0.3);
}
.m-drove {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(212, 175, 55, 0.1);
  border-radius: 8px;
  font-size: 13px;
  color: #d4af37;
}
.m-drove strong { color: #f4d03f; }
.m-note {
  margin-top: 8px;
  font-size: 12px;
  color: #a89078;
  font-style: italic;
}
