/*
  Pocket TrialRoom — Lightweight UI
  Philosophy: No web fonts, no backdrop-filter, no heavy animations.
  System fonts only. Works on old Android 6+ / iOS 10+ phones.
*/

/* ── RESET ──────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f7f7f5;
  color: #1c1c1c;
  line-height: 1.55;
  min-height: 100vh;
}

/* ── UTILITY ─────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── HEADER ──────────────────────────────── */
.header {
  background: #fff;
  border-bottom: 1.5px solid #e8e8e4;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  max-width: 680px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1c1c1c;
  flex-shrink: 0;
}

.logo-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: #1c1c1c;
}

/* ── GHOST BUTTON (header) ──────────────── */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #1c1c1c;
  cursor: pointer;
  min-height: 40px;
  position: relative;
}

.count-badge {
  background: #1c1c1c;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ── TABS ────────────────────────────────── */
.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1.5px solid #e8e8e4;
  max-width: 680px;
  margin: 0 auto;
}

/* stretch tabs full width */
.tabs {
  max-width: none;
  background: #fff;
  border-bottom: 1.5px solid #e8e8e4;
}

.tabs .inner {
  display: flex;
  align-items: center;
  padding: 0 18px;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 13px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #999;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
  white-space: nowrap;
}

.tab.active {
  color: #1c1c1c;
  border-bottom-color: #1c1c1c;
}

.tab-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e8e8e4;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #555;
}

.tab.active .tab-num {
  background: #1c1c1c;
  color: #fff;
}

.tab-arrow {
  color: #ccc;
  font-size: 0.9rem;
  padding: 0 4px;
  pointer-events: none;
}

/* ── MAIN ────────────────────────────────── */
.main {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}

/* ── STEP SECTIONS ───────────────────────── */
.step { }
.step.hidden { display: none !important; }

/* ── SECTION TITLE ───────────────────────── */
.section-title {
  margin-bottom: 20px;
}

.section-title h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #1c1c1c;
  margin-bottom: 4px;
}

.section-title p {
  font-size: 0.9rem;
  color: #666;
}

/* ── UPLOAD BOX ──────────────────────────── */
.upload-box {
  background: #fff;
  border: 2px dashed #d4d4d0;
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
}

.upload-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #f0f0ed;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.upload-label {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 20px;
}

.upload-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 280px;
  margin: 0 auto;
}

/* ── CARD ────────────────────────────────── */
.card {
  background: #fff;
  border: 1.5px solid #e8e8e4;
  border-radius: 14px;
  padding: 18px;
  margin-top: 16px;
}

.card-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 5px;
}

.card-sub {
  font-size: 0.88rem;
  color: #666;
  margin-bottom: 14px;
}

.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ── CANVAS BOX ──────────────────────────── */
.canvas-box {
  position: relative;
  width: 100%;
  background: #f0f0ed;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
  margin-bottom: 14px;
}

#cutout-canvas {
  max-width: 100%;
  max-height: 420px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* ── TOOL ROWS ───────────────────────────── */
.tool-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.tool-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
}

.tool-row input[type="range"] {
  width: 100%;
  accent-color: #1c1c1c;
  height: 4px;
  cursor: pointer;
}

.tool-btns {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

/* tool button */
.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f0f0ed;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.83rem;
  font-weight: 600;
  color: #444;
  cursor: pointer;
  min-height: 38px;
}

.tbtn.active {
  background: #1c1c1c;
  color: #fff;
  border-color: #1c1c1c;
}

.tbtn-plain {
  background: none;
  border: none;
  font-size: 0.83rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  padding: 8px 6px;
  min-height: 38px;
}

/* ── BUTTONS ─────────────────────────────── */
.btn-fill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #1c1c1c;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px 22px;
  font-size: 0.93rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
  width: 100%;
  text-align: center;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  color: #1c1c1c;
  border: 1.5px solid #d4d4d0;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  width: 100%;
  text-align: center;
}

.btn-plain-sm {
  background: none;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  padding: 8px 12px;
  text-decoration: underline;
}

.btn-sm {
  min-height: 40px;
  padding: 9px 16px;
  font-size: 0.85rem;
  width: auto;
  flex: 1;
}

/* ── CAMERA VIEWPORT ─────────────────────── */
.viewport {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  /* Tall mobile-first aspect ratio */
  aspect-ratio: 9 / 14;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

/* fallback for old browsers without aspect-ratio */
@supports not (aspect-ratio: 9 / 14) {
  .viewport { padding-top: 155%; }
}

#webcam-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#webcam-video.mirror {
  transform: scaleX(-1);
}

#ar-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── CAMERA OVERLAY BUTTONS ──────────────── */
.cam-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  z-index: 10;
}

.cam-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 38px;
}

.cam-btn.active {
  background: rgba(255, 255, 255, 0.9);
  color: #1c1c1c;
  border-color: transparent;
}

/* ── POSE STATUS INDICATOR ───────────────── */
.pose-indicator {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  z-index: 10;
  white-space: nowrap;
  pointer-events: none;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffb703;
  display: inline-block;
}

.indicator-dot.active {
  background: #38b000;
  box-shadow: 0 0 8px #38b000;
}

/* ── LOADING OVERLAY ─────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(247, 247, 245, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 20;
  font-size: 0.88rem;
  font-weight: 500;
  color: #444;
}

/* ── SPINNER (pure CSS, no library) ─────── */
.spin {
  width: 28px;
  height: 28px;
  border: 3px solid #ddd;
  border-top-color: #1c1c1c;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── SLIDERS ─────────────────────────────── */
.sliders {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: #1c1c1c;
  cursor: pointer;
}

/* ── ACTION BAR ──────────────────────────── */
.action-bar {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.action-bar .btn-outline {
  flex: 0 0 auto;
  width: auto;
  padding: 12px 16px;
  font-size: 0.85rem;
}

.btn-snap {
  flex: 1;
}

/* ── MODAL ───────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  padding: 0;
}

.modal.hidden { display: none !important; }

.modal-box {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-wide {
  max-width: 720px;
  margin: 0 auto;
  border-radius: 18px;
  max-height: 80vh;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 14px;
  border-bottom: 1.5px solid #e8e8e4;
}

.modal-head h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1c1c1c;
}

.close-btn {
  background: #f0f0ed;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 1rem;
  cursor: pointer;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

.modal-foot {
  padding: 14px 18px;
  border-top: 1.5px solid #e8e8e4;
  display: flex;
  gap: 10px;
}

/* ── EMPTY STATE ─────────────────────────── */
.empty-msg {
  text-align: center;
  padding: 36px 20px;
  color: #999;
}

.empty-msg svg {
  display: block;
  margin: 0 auto 12px;
  color: #ccc;
}

.empty-msg p {
  font-size: 0.9rem;
  color: #888;
}

/* ── WARDROBE GRID ───────────────────────── */
.wardrobe-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.wardrobe-card {
  border: 1.5px solid #e8e8e4;
  border-radius: 10px;
  overflow: hidden;
  background: #f7f7f5;
}

.wardrobe-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
}

.wardrobe-card-info {
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #666;
}

.btn-del {
  background: none;
  border: none;
  font-size: 0.75rem;
  color: #c00;
  font-weight: 600;
  cursor: pointer;
  padding: 2px;
}

/* ── COMPARE ─────────────────────────────── */
.compare-body {
  display: grid;
  grid-template-columns: 1fr 28px 1fr;
  gap: 10px;
  padding: 18px;
  align-items: center;
}

.compare-col { text-align: center; }

.compare-tag {
  display: inline-block;
  background: #1c1c1c;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  line-height: 22px;
  margin-bottom: 6px;
}

.compare-slot {
  border: 2px dashed #d4d4d0;
  border-radius: 10px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #f7f7f5;
  font-size: 0.82rem;
  color: #aaa;
}

.compare-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compare-divider {
  font-size: 0.8rem;
  font-weight: 700;
  color: #aaa;
  text-align: center;
}

/* ── TOASTS ──────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: #1c1c1c;
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.83rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ── RESPONSIVE — wider screens ──────────── */
@media (min-width: 520px) {
  .upload-btns {
    flex-direction: row;
  }
  .upload-btns .btn-fill,
  .upload-btns .btn-outline {
    width: auto;
    flex: 1;
  }
  .card-actions .btn-fill,
  .card-actions .btn-outline {
    width: auto;
    flex: 1;
  }
  .wardrobe-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── SITE FOOTER ─────────────────────────── */
.site-footer {
  border-top: 1.5px solid #e8e8e4;
  background: #fff;
  padding: 28px 18px 36px;
  margin-top: 40px;
}

.site-footer-inner {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.footer-tagline {
  font-size: 0.82rem;
  color: #888;
  margin-bottom: 16px;
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 14px;
}

.footer-links a {
  font-size: 0.82rem;
  color: #555;
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  color: #1c1c1c;
  text-decoration: underline;
}

.footer-sep {
  color: #ccc;
  font-size: 0.75rem;
}

.footer-copy {
  font-size: 0.78rem;
  color: #aaa;
}

.footer-copy a {
  color: #888;
  text-decoration: none;
  font-weight: 600;
}
