:root {
  color-scheme: dark;
  --app-height: 100vh; /* JS tarafından window.visualViewport ile güncellenir */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --bg: #0b0d12;
  --card-bg: rgba(20, 22, 28, 0.92);
  --accent: #6ee7f2;
  --accent-strong: #34c9d8;
  --text: #f2f5f7;
  --text-dim: #a7b0bb;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
  /* 100vh yerine JS ile hesaplanan gerçek görünür yükseklik. dvh destekleniyorsa o da yedek. */
  height: var(--app-height);
}

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none; /* tarayıcı pinch-zoom / scroll ile AR gesture çakışmasın */
  -webkit-user-select: none;
  user-select: none;
}

@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

.hidden { display: none !important; }

/* ============ Genel ekran / kart ============ */
.screen {
  position: absolute;
  inset: 0;
  height: var(--app-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px)
           calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  background: radial-gradient(circle at 50% 20%, #182028 0%, #0b0d12 70%);
  z-index: 10;
}

.screen-card {
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
}

.brand-title {
  font-size: 26px;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}

.brand-subtitle {
  color: var(--text-dim);
  margin: 0 0 24px;
  font-size: 14px;
}

.model-status { margin: 20px 0; }

.progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 0.2s ease;
}

#model-progress-text {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.primary-btn, .secondary-btn {
  border: none;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #06181b;
}
.primary-btn.small { padding: 12px 16px; font-size: 14px; margin-top: 18px; }

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary-btn {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  margin-top: 10px;
}

.hint-text {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 14px;
}

/* ============ AR ekranı ============ */
#ar-screen { padding: 0; background: black; display: block; }

.camera-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.scan-hint {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  pointer-events: none;
  z-index: 5;
}

.scan-frame {
  width: min(64vw, 280px);
  aspect-ratio: 1;
  border: 2.5px dashed rgba(255,255,255,0.75);
  border-radius: 18px;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

#scan-hint-text {
  background: rgba(0,0,0,0.55);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
}

.icon-btn {
  position: absolute;
  border: none;
  background: rgba(20,22,28,0.7);
  color: var(--text);
  border-radius: 999px;
  width: 48px;
  height: 48px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
}

.lock-btn {
  top: calc(var(--safe-top) + 14px);
  left: calc(var(--safe-left) + 14px);
}

.help-btn {
  top: calc(var(--safe-top) + 14px);
  right: calc(var(--safe-right) + 14px);
  font-weight: 700;
}

.bottom-controls {
  position: absolute;
  bottom: calc(var(--safe-bottom) + 22px);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  z-index: 20;
}

.round-btn {
  position: static;
  width: 52px;
  height: 52px;
  font-size: 22px;
}

.camera-btn {
  width: 66px;
  height: 66px;
  font-size: 26px;
  background: rgba(255,255,255,0.92);
  color: #111;
}

.relocalize-hint {
  position: absolute;
  top: calc(var(--safe-top) + 74px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 20;
}

/* ============ Tutorial ============ */
.tutorial-overlay {
  background: rgba(6,8,12,0.88);
  z-index: 40;
}

.tutorial-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  padding: 20px;
}

.tutorial-step { display: none; }
.tutorial-step.active { display: block; }

.tutorial-emoji { font-size: 48px; margin-bottom: 16px; }
.tutorial-step p { font-size: 16px; line-height: 1.5; }

.tutorial-dots {
  margin-top: 22px;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
}
.dot.active { background: var(--accent); }

/* ============ Screenshot preview ============ */
#screenshot-preview {
  background: #000;
  flex-direction: column;
  padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 16px);
  z-index: 50;
}

.preview-close {
  position: absolute;
  top: calc(var(--safe-top) + 14px);
  right: calc(var(--safe-right) + 14px);
}

.preview-image-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#preview-image {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  object-fit: contain;
}

.preview-actions {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  gap: 12px;
  padding-top: 16px;
}

.preview-actions .secondary-btn,
.preview-actions .primary-btn { margin-top: 0; }
