* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#camera {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
}

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

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom) 16px;
}

#hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

#hour-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 2px;
  pointer-events: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#hour-bar::-webkit-scrollbar { display: none; }

.hour-btn {
  flex: 0 0 auto;
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.hour-btn.active {
  background: #ffb347;
  color: #1a1200;
  border-color: #ffb347;
}

#hud-bottom {
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0));
  padding: 24px 4px 16px;
  border-radius: 12px;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  padding: 2px 4px;
}

.hud-label {
  opacity: 0.75;
  margin-right: 12px;
}

#recenter-btn {
  position: absolute;
  right: 16px;
  bottom: 130px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 20px;
  pointer-events: auto;
}

/* Start screen */
#start-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 20%, #1c2a3a, #05070a 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 10;
}

.start-card {
  max-width: 420px;
  color: #fff;
  text-align: center;
}

.start-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
  background: linear-gradient(90deg, #ffd76a, #ff9b4a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.start-card p {
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.85;
  margin: 12px 0 20px;
}

.start-card .disclaimer {
  font-size: 12px;
  opacity: 0.55;
  margin-top: 24px;
}

#start-btn, #manual-submit {
  background: #ffb347;
  color: #1a1200;
  border: none;
  border-radius: 999px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.mode-btn {
  background: #ffb347;
  color: #1a1200;
  border: none;
  border-radius: 999px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.mode-btn.secondary {
  background: transparent;
  color: #ffb347;
  border: 1px solid #ffb347;
}

#manual-location {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

#manual-location label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  opacity: 0.8;
  gap: 4px;
  text-align: left;
}

#manual-location input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #444;
  background: #111;
  color: #fff;
  font-size: 15px;
}

#error-msg {
  color: #ff8a80;
  font-size: 13px;
  margin-top: 12px;
}

/* ---- Mode carte ---- */
#map-screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #05070a;
}

#map {
  position: absolute;
  inset: 0;
}

#map-topbar {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 12px;
  z-index: 1000;
}

#map-back-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #111;
  font-size: 18px;
}

#map-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 12px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  background: #fff;
}

#map-date {
  flex: 0 0 auto;
  border-radius: 999px;
  border: none;
  padding: 0 10px;
  font-size: 14px;
  background: #fff;
  max-width: 140px;
}

#map-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #101820;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
  color: #fff;
  max-height: 70vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

#map-sheet-handle {
  width: 40px;
  height: 4px;
  background: #444;
  border-radius: 2px;
  margin: 10px auto;
}

#map-sheet-content {
  padding: 0 20px 20px;
}

#map-hint {
  text-align: center;
  opacity: 0.7;
  font-size: 14px;
}

#map-sun-info .hud-row {
  padding: 4px 0;
  font-size: 14px;
}

#sunpath-canvas {
  display: block;
  margin: 12px auto;
  max-width: 100%;
  height: auto;
}

#time-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}

#time-slider-label {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  width: 44px;
  flex: 0 0 auto;
}

#time-slider {
  flex: 1 1 auto;
}

#map-loc-label {
  text-align: right;
  font-size: 12px;
  opacity: 0.85;
}

/* ---- Mode photo ---- */
#photo-screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #05070a;
  display: flex;
  flex-direction: column;
}

#photo-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 12px 12px;
  color: #fff;
  flex: 0 0 auto;
}

#photo-back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 16px;
  flex: 0 0 auto;
}

#photo-title {
  flex: 1 1 auto;
  font-size: 15px;
  font-weight: 600;
}

.topbar-btn {
  background: #ffb347;
  color: #1a1200;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}

.topbar-btn.secondary {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

#photo-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px;
  text-align: center;
  color: #fff;
  opacity: 0.9;
}

#photo-empty p {
  max-width: 340px;
  font-size: 14px;
  opacity: 0.75;
}

#photo-viewport {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  background: #000;
  min-height: 0;
}

#photo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #000;
}

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

#horizon-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 28px;
  margin-top: -14px;
  cursor: ns-resize;
  touch-action: none;
}

#photo-sheet {
  flex: 0 0 auto;
  background: #101820;
  color: #fff;
  border-radius: 18px 18px 0 0;
  max-height: 46vh;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

#photo-sheet-content {
  padding: 0 20px 20px;
}

.inline-fields {
  display: flex;
  gap: 12px;
  margin: 8px 0;
}

.inline-fields label {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  opacity: 0.8;
}

.inline-fields input {
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #0b1015;
  color: #fff;
  font-size: 14px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.slider-row .hud-label {
  flex: 0 0 110px;
  font-size: 13px;
}

.slider-row input[type="range"] {
  flex: 1 1 auto;
}

.slider-row span:last-child {
  flex: 0 0 56px;
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hint.small {
  font-size: 12px;
  opacity: 0.6;
  margin: 6px 0;
}

#map-pick-btn-ar {
  position: absolute;
  right: 16px;
  bottom: 80px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 20px;
  pointer-events: auto;
}

/* ---- Sélecteur de position (façon Google Maps) ---- */
#location-picker-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #05070a;
}

#lp-topbar {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 12px;
  z-index: 1000;
}

#lp-cancel-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #111;
  font-size: 16px;
}

#lp-search {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0 12px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  background: #fff;
}

#lp-map {
  position: absolute;
  inset: 0;
}

#lp-center-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -100%);
  font-size: 36px;
  z-index: 1000;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

#lp-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  background: #101820;
  color: #fff;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 14px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  border-radius: 18px 18px 0 0;
}

#lp-coords {
  text-align: center;
  font-size: 13px;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}

#lp-confirm-btn {
  background: #ffb347;
  color: #1a1200;
  border: none;
  border-radius: 999px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
