:root {
  color-scheme: dark;
  --bg: #0f1112;
  --panel: #181b1e;
  --panel-2: #20252a;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6f3ee;
  --muted: #b9b2a8;
  --accent: #bfa46b;
  --accent-2: #d8c18b;
  --danger: #ef6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at top left, rgba(191, 164, 107, 0.12), transparent 34%),
    linear-gradient(135deg, #0f1112 0%, #171a1d 52%, #0d0f10 100%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow: hidden;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 16px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
}

.stage {
  display: grid;
  min-width: 0;
}

.camera-frame {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 32px);
  min-height: calc(100dvh - 32px);
  border: 1px solid rgba(191, 164, 107, 0.22);
  border-radius: 8px;
  background: #080a0b;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.32);
  touch-action: none;
}

#camera,
#overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#camera.is-mirrored {
  transform: scaleX(-1);
}

#overlay {
  z-index: 2;
}

#overlay {
  pointer-events: none;
}

.wrist-guide {
  position: absolute;
  inset: 0;
  z-index: 3;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.camera-frame.is-searching .wrist-guide {
  opacity: 1;
}

.wrist-guide.is-hidden {
  opacity: 0;
}

.guide-arm-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
  background:
    linear-gradient(rgba(10, 12, 13, 0.5), rgba(10, 12, 13, 0.72)),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.035) 0 1px, transparent 1px 80px);
}

.empty-state.is-hidden {
  display: none;
}

.empty-state h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 84px);
  line-height: 0.92;
  letter-spacing: 0;
}

.empty-state p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
}

.mark {
  width: 86px;
  height: 86px;
  border: 10px solid var(--accent);
  border-radius: 50%;
  box-shadow: inset 0 0 0 10px #101315, 0 18px 46px rgba(47, 191, 159, 0.25);
}

.status-pill {
  position: absolute;
  left: 18px;
  top: 18px;
  z-index: 4;
  min-width: 118px;
  border: 1px solid rgba(191, 164, 107, 0.34);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(17, 19, 21, 0.78);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  backdrop-filter: blur(12px);
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: calc(100vh - 32px);
  min-height: calc(100dvh - 32px);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(191, 164, 107, 0.22);
  border-radius: 8px;
  padding: 18px;
  background: rgba(24, 27, 30, 0.94);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

.brand-block span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-block h2 {
  margin: 6px 0 0;
  font-size: 27px;
  line-height: 1.05;
  letter-spacing: 0;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #11100d;
  cursor: pointer;
  font-weight: 850;
}

.primary-button:hover {
  filter: brightness(1.06);
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-group label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel-2);
  color: var(--text);
}

.auto-calibration {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid rgba(191, 164, 107, 0.42);
  border-radius: 8px;
  padding: 13px 14px;
  background: rgba(191, 164, 107, 0.08);
}

.auto-calibration strong,
.auto-calibration span {
  display: block;
}

.auto-calibration strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.auto-calibration span:last-child {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auto-dot {
  flex: 0 0 auto;
  width: 11px;
  height: 11px;
  margin-top: 4px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(191, 164, 107, 0.14);
}

.watch-list {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.watch-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.watch-card.is-active,
.watch-card:hover {
  border-color: rgba(191, 164, 107, 0.78);
  background: rgba(191, 164, 107, 0.1);
}

.watch-preview {
  display: block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #c9c8c4;
  box-shadow: inset 0 0 0 8px #202326, inset 0 0 0 12px #f2f0ea;
}

.watch-preview.product {
  border-radius: 10px;
  background-color: #f3f4f4;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 8px 18px rgba(0, 0, 0, 0.24);
}

.watch-preview.edifice {
  background-image: url("assets/ersa-edifice-eqb-1100d.jpg");
}

.watch-preview.gshock-steel {
  background-image: url("assets/ersa-gshock-gmc-b2100ads.jpg");
}

.watch-preview.full-metal {
  background-image: url("assets/ersa-gshock-gmw-bz5000rc.jpg");
}

.watch-preview.bulova {
  background-image: url("assets/ersa-bulova-96b419.jpg");
}

.watch-preview.women-casio {
  background-image: url("assets/ersa-casio-women-ltp1303.jpg");
}

.watch-preview.roamer {
  background-image: url("assets/ersa-roamer-850837.jpg");
}

.watch-preview.sport {
  background: #0c0d0f;
  box-shadow: inset 0 0 0 8px #1d2228, inset 0 0 0 12px #111315;
}

.watch-preview.digital {
  border-radius: 12px;
  background: linear-gradient(90deg, #12171b 0 28%, #1f2a31 28% 72%, #12171b 72%);
  box-shadow: inset 0 0 0 6px #07090a, inset 0 0 0 12px #2f3b44;
}

.watch-preview.casio {
  border-radius: 10px;
  background-color: #f3f4f4;
  background-image: url("assets/casio-red.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.watch-preview.gshock {
  border-radius: 12px;
  background-color: #f3f4f4;
  background-image: url("assets/gshock-orange.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.watch-preview.swiss {
  background-color: #f3f4f4;
  background-image: url("assets/swiss-military-silver.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.watch-preview.rose {
  background: #e8b7a4;
  box-shadow: inset 0 0 0 8px #552f2f, inset 0 0 0 12px #f2ddd5;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
    min-height: 100dvh;
  }

  .camera-frame {
    min-height: 58dvh;
    max-height: 64dvh;
  }

  .control-panel {
    min-height: auto;
    max-height: none;
    padding: 14px;
  }

  .brand-block h2 {
    font-size: 22px;
  }

  .primary-button {
    min-height: 48px;
  }

  .watch-list {
    display: flex;
    gap: 8px;
    margin-top: 0;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .watch-card {
    flex: 0 0 178px;
    grid-template-columns: 42px minmax(0, 1fr);
    min-height: 56px;
    scroll-snap-align: start;
  }

  .watch-preview {
    width: 42px;
    height: 42px;
  }

  .empty-state {
    padding: 22px;
  }

  .empty-state h1 {
    font-size: 44px;
  }

  .empty-state p {
    font-size: 15px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  .camera-frame {
    min-height: 54dvh;
  }

  .status-pill {
    left: 10px;
    top: 10px;
    min-width: 98px;
    padding: 8px 10px;
    font-size: 13px;
  }
}
