:root{
  --green:#234d35;
  --green-dark:#14351d;
  --cream:#f3ead8;
  --panel:rgba(243,234,216,.92);
  --ink:#173522;
}

*{box-sizing:border-box}

html,body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  background:#000;
  font-family:Arial,Helvetica,sans-serif;
  user-select:none;
  touch-action:none;
}

#camera{
  position:fixed;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  background:#000;
  z-index:0;
}

#oldPhoto{
  position:fixed;
  top:50%;
  left:50%;
  width:92vw;
  max-width:none;
  opacity:.55;
  transform-origin:center center;
  z-index:2;
  touch-action:none;
  user-select:none;
  -webkit-user-drag:none;
}

/* PAGE D'ACCUEIL */
.welcome{
  position:fixed;
  inset:0;
  z-index:100;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  gap:34px;
  padding:24px 20px calc(30px + env(safe-area-inset-bottom));
  color:var(--ink);
  background:
    linear-gradient(180deg,rgba(243,234,216,.10),rgba(243,234,216,.22)),
    url("accueil-fond.jpg") center center/cover no-repeat;
  transition:opacity .45s ease,visibility .45s ease;
}

.welcome.hidden{
  opacity:0;
  visibility:hidden;
  pointer-events:none;
}

.welcome-logo-wrap,
.welcome-header,
.welcome-brand{
  width:100%;
  display:flex;
  justify-content:center;
  align-items:center;
}

.welcome-logo,
.welcome-header img,
.welcome-brand img{
  width:185px;
  max-width:58vw;
  height:auto;
  display:block;
  object-fit:contain;
  margin-top:-110px;
  filter:drop-shadow(0 8px 18px rgba(0,0,0,.18));
  border-radius:0;
  box-shadow:none;
}

/* carte crème */
.welcome-card{
  width:min(92vw,460px);
  padding:34px 30px;
  border-radius:34px;
  background:var(--panel);
  color:var(--ink);
  text-align:center;
  box-shadow:0 25px 70px rgba(0,0,0,.22);
  backdrop-filter:blur(7px);
}

.welcome-card h1,
.welcome-card p,
.welcome-dot,
.ornament{
  display:none!important;
}

.welcome-text,
.welcome-card small{
  display:block;
  margin:0 auto 30px;
  color:#111;
  font-size:18px;
  line-height:1.65;
  font-weight:500;
}

.welcome-card button,
#startBtn{
  width:100%;
  border:0;
  border-radius:18px;
  padding:20px 24px;
  background:linear-gradient(180deg,#356348,#1d4d33);
  color:#fff;
  font-size:21px;
  font-weight:800;
  box-shadow:0 13px 30px rgba(0,0,0,.20);
  transition:.25s;
  cursor:pointer;
}

.welcome-card button span,
.welcome-card button b{
  float:right;
  font-size:26px;
  line-height:18px;
  font-weight:400;
}

/* INTERFACE CAMERA */
#topBar{
  position:fixed;
  z-index:30;
  top:calc(16px + env(safe-area-inset-top));
  left:16px;
  display:flex;
  align-items:center;
  gap:12px;
  max-width:calc(100vw - 32px);
  min-height:72px;
  padding:10px 16px 10px 12px;
  color:var(--ink);
  background:var(--panel);
  border-radius:18px;
  box-shadow:0 10px 30px rgba(0,0,0,.22);
  backdrop-filter:blur(8px);
  pointer-events:none;
}

.top-logo{
  width:72px;
  height:72px;
  object-fit:contain;
  flex:0 0 auto;
  transform:translateY(-4px);
}

.top-brand{
  min-width:150px;
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.brand{
  font-family:Georgia,"Times New Roman",serif;
  font-size:25px;
  font-weight:900;
  letter-spacing:1px;
  color:var(--green);
  line-height:1;
}

.baseline{
  margin-top:4px;
  font-size:12px;
  font-weight:700;
  color:var(--green);
}

.top-separator{
  width:1px;
  height:42px;
  background:rgba(23,53,34,.22);
}

.top-place{min-width:110px}

.place-title{
  color:#111;
  font-size:17px;
  font-weight:800;
  line-height:1.2;
}

.place-precision{
  margin-top:2px;
  font-size:12px;
  color:#333;
}

.place-date{
  margin-top:3px;
  font-size:14px;
  color:#333;
}

#bottomBar{
  position:fixed;
  z-index:30;
  left:50%;
  bottom:calc(16px + env(safe-area-inset-bottom));
  transform:translateX(-50%);
  width:min(92vw,900px);
  padding:13px 16px;
  color:#111;
  background:var(--panel);
  border-radius:18px;
  box-shadow:0 12px 35px rgba(0,0,0,.24);
  backdrop-filter:blur(8px);
}

.slider-wrap,
.time-labels{
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:center;
  gap:14px;
  font-size:15px;
  font-weight:700;
}

#opacitySlider{
  width:100%;
  accent-color:var(--green);
}

.action-row{
  display:flex;
  gap:12px;
  margin-top:11px;
}

.action-row button{
  flex:1;
  border:0;
  border-radius:14px;
  padding:12px 8px;
  background:rgba(255,255,255,.42);
  color:#111;
  font-weight:800;
  font-size:15px;
}

.gesture-hint{display:none!important}
.hidden-photo{display:none!important}

#errorBox{
  position:fixed;
  z-index:120;
  left:14px;
  right:14px;
  bottom:132px;
  display:none;
  padding:12px;
  border-radius:14px;
  color:#fff;
  background:rgba(120,0,0,.92);
  line-height:1.35;
}

/* TELEPHONES */
@media(max-width:430px){
  .welcome{
    gap:32px;
    padding:22px 20px calc(28px + env(safe-area-inset-bottom));
  }

  .welcome-logo,
  .welcome-header img,
  .welcome-brand img{
    width:190px;
    max-width:56vw;
    margin-top:-90px;
  }

  .welcome-card{
    width:min(92vw,430px);
    padding:32px 24px;
    border-radius:32px;
  }

  .welcome-text,
  .welcome-card small{
    font-size:17px;
    line-height:1.6;
  }

  .welcome-card button,
  #startBtn{
    padding:19px 22px;
    font-size:20px;
  }

  #topBar{
    top:calc(10px + env(safe-area-inset-top));
    left:10px;
    right:10px;
    max-width:none;
    padding:9px 11px;
    gap:9px;
  }

  .top-logo{
    width:58px;
    height:58px;
    transform:translateY(-4px);
  }

  .top-brand{min-width:120px}
  .brand{font-size:21px}
  .baseline{font-size:11px}
  .place-title{font-size:15px}
  .place-date{font-size:12px}

  #bottomBar{
    width:calc(100vw - 20px);
    padding:12px;
  }

  .slider-wrap,
  .time-labels{
    font-size:13px;
    gap:9px;
  }

  .action-row button{
    padding:11px 6px;
    font-size:13px;
  }
}

/* PAYSAGE */
@media(orientation:landscape) and (max-height:520px){
  .welcome{
    flex-direction:row;
    justify-content:center;
    gap:32px;
    padding:18px 32px;
  }

  .welcome-logo,
  .welcome-header img,
  .welcome-brand img{
    width:180px;
    max-width:28vw;
    margin-top:0;
  }

  .welcome-logo-wrap,
  .welcome-header,
  .welcome-brand{
    width:auto;
  }

  .welcome-card{
    width:min(44vw,430px);
    padding:26px;
    border-radius:30px;
  }

  .welcome-text,
  .welcome-card small{
    display:none;
  }

  .welcome-card button,
  #startBtn{
    padding:16px 20px;
    font-size:18px;
  }

  #topBar{
    top:calc(10px + env(safe-area-inset-top));
    left:calc(14px + env(safe-area-inset-left));
    min-height:54px;
    padding:7px 12px 7px 9px;
    gap:10px;
    border-radius:14px;
  }

  .top-logo{
    width:48px;
    height:48px;
    transform:translateY(-2px);
  }

  .top-brand{min-width:130px}
  .brand{font-size:22px}
  .baseline{font-size:11px;margin-top:2px}
  .top-separator{height:34px}
  .place-title{font-size:15px}
  .place-date,.place-precision{font-size:12px}

  #bottomBar{
    width:min(70vw,760px);
    bottom:calc(10px + env(safe-area-inset-bottom));
    padding:9px 12px;
    display:grid;
    grid-template-columns:1fr auto;
    align-items:center;
    gap:12px;
    border-radius:14px;
  }

  .slider-wrap,
  .time-labels{
    font-size:13px;
    gap:10px;
  }

  .action-row{
    margin:0;
    gap:8px;
  }

  .action-row button{
    min-width:112px;
    padding:10px 12px;
    font-size:13px;
  }
}

/* =========================================================
   V5 — ÉCRAN DE COMPARAISON
   Bandeau + commandes harmonisés avec l'accueil
   ========================================================= */

#topBar{
  top:calc(14px + env(safe-area-inset-top)) !important;
  left:14px !important;
  right:auto !important;
  max-width:calc(100vw - 28px) !important;
  min-height:auto !important;
  padding:12px 16px 12px 12px !important;
  border-radius:22px !important;
  background:rgba(243,234,216,.93) !important;
  box-shadow:0 18px 48px rgba(0,0,0,.25) !important;
  backdrop-filter:blur(10px) !important;
  align-items:center !important;
  gap:14px !important;
}

.top-logo{
  width:78px !important;
  height:78px !important;
  object-fit:contain !important;
  transform:translateY(-2px) !important;
}

.top-brand{
  min-width:138px !important;
}

.brand{
  font-size:27px !important;
  letter-spacing:1.1px !important;
}

.baseline{
  font-size:13px !important;
  margin-top:4px !important;
}

.top-separator{
  height:56px !important;
  background:rgba(23,53,34,.20) !important;
}

.top-place{
  min-width:120px !important;
  padding-left:2px !important;
}

.place-title{
  font-size:19px !important;
  font-weight:900 !important;
  color:#111 !important;
}

.place-precision{
  font-size:12px !important;
  color:#333 !important;
}

.place-date{
  font-size:15px !important;
  color:#234d35 !important;
  font-weight:800 !important;
}

/* panneau inférieur premium */
#bottomBar{
  width:min(92vw,760px) !important;
  padding:15px 16px 16px !important;
  border-radius:24px !important;
  background:rgba(243,234,216,.93) !important;
  box-shadow:0 20px 56px rgba(0,0,0,.25) !important;
  backdrop-filter:blur(10px) !important;
}

.slider-wrap,
.time-labels{
  display:grid !important;
  grid-template-columns:auto 1fr auto !important;
  align-items:center !important;
  gap:14px !important;
  font-size:15px !important;
  font-weight:900 !important;
  color:#111 !important;
}

#opacitySlider{
  height:28px !important;
  accent-color:#234d35 !important;
}

.action-row{
  display:flex !important;
  gap:12px !important;
  margin-top:13px !important;
}

.action-row button{
  flex:1 !important;
  border:0 !important;
  border-radius:18px !important;
  padding:14px 10px !important;
  background:linear-gradient(180deg,#356348,#1d4d33) !important;
  color:#fff !important;
  font-weight:900 !important;
  font-size:15px !important;
  box-shadow:0 10px 24px rgba(0,0,0,.18) !important;
}

/* si l'ancien HTML contient .tools, on les masque en V5 */
.tools{
  display:none !important;
}

/* Portrait étroit */
@media(max-width:430px){
  #topBar{
    top:calc(10px + env(safe-area-inset-top)) !important;
    left:10px !important;
    right:10px !important;
    max-width:none !important;
    padding:10px 12px !important;
    gap:10px !important;
    border-radius:20px !important;
  }

  .top-logo{
    width:66px !important;
    height:66px !important;
  }

  .top-brand{
    min-width:112px !important;
  }

  .brand{
    font-size:22px !important;
  }

  .baseline{
    font-size:11px !important;
  }

  .top-separator{
    height:50px !important;
  }

  .place-title{
    font-size:16px !important;
  }

  .place-date{
    font-size:13px !important;
  }

  #bottomBar{
    width:calc(100vw - 20px) !important;
    padding:13px !important;
    border-radius:22px !important;
  }

  .slider-wrap,
  .time-labels{
    font-size:13px !important;
    gap:10px !important;
  }

  .action-row button{
    padding:13px 8px !important;
    font-size:13px !important;
  }
}

/* Mode paysage : commandes compactes, image dégagée */
@media(orientation:landscape) and (max-height:520px){
  #topBar{
    top:calc(8px + env(safe-area-inset-top)) !important;
    left:calc(10px + env(safe-area-inset-left)) !important;
    right:auto !important;
    max-width:52vw !important;
    padding:8px 12px 8px 9px !important;
    border-radius:16px !important;
    gap:10px !important;
  }

  .top-logo{
    width:50px !important;
    height:50px !important;
    transform:translateY(-1px) !important;
  }

  .top-brand{
    min-width:120px !important;
  }

  .brand{
    font-size:22px !important;
  }

  .baseline{
    font-size:11px !important;
    margin-top:2px !important;
  }

  .top-separator{
    height:38px !important;
  }

  .place-title{
    font-size:15px !important;
  }

  .place-precision,
  .place-date{
    font-size:12px !important;
  }

  #bottomBar{
    width:min(68vw,760px) !important;
    bottom:calc(8px + env(safe-area-inset-bottom)) !important;
    padding:9px 12px !important;
    display:grid !important;
    grid-template-columns:1fr auto !important;
    align-items:center !important;
    gap:12px !important;
    border-radius:16px !important;
  }

  .slider-wrap,
  .time-labels{
    font-size:13px !important;
    gap:10px !important;
  }

  .action-row{
    margin:0 !important;
    gap:8px !important;
  }

  .action-row button{
    min-width:112px !important;
    padding:10px 12px !important;
    font-size:13px !important;
    border-radius:14px !important;
  }
}

/* =========================================================
   V7 — MODE CALIBRATION
   Accès : ?calibration=1&photo=1
   ========================================================= */

#calibrationPanel{
  position:fixed;
  z-index:200;
  left:50%;
  bottom:calc(18px + env(safe-area-inset-bottom));
  transform:translateX(-50%);
  width:min(92vw,520px);
  padding:18px;
  border-radius:26px;
  background:rgba(243,234,216,.95);
  color:#173522;
  box-shadow:0 24px 70px rgba(0,0,0,.30);
  backdrop-filter:blur(12px);
  font-family:Arial,Helvetica,sans-serif;
}

#calibrationPanel h2{
  margin:0 0 4px;
  font-family:Georgia,"Times New Roman",serif;
  font-size:24px;
  color:#234d35;
}

#calibrationPanel .cal-subtitle{
  margin:0 0 14px;
  font-size:13px;
  color:#333;
  line-height:1.35;
}

.cal-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom:14px;
}

.cal-item{
  padding:11px 12px;
  border-radius:16px;
  background:rgba(255,255,255,.45);
}

.cal-label{
  display:block;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.5px;
  font-weight:900;
  color:#234d35;
  margin-bottom:3px;
}

.cal-value{
  display:block;
  font-size:17px;
  font-weight:900;
  color:#111;
}

.cal-actions{
  display:flex;
  gap:10px;
}

.cal-actions button{
  flex:1;
  border:0;
  border-radius:16px;
  padding:13px 10px;
  background:linear-gradient(180deg,#356348,#1d4d33);
  color:#fff;
  font-weight:900;
  font-size:14px;
}

.cal-actions button.secondary{
  background:rgba(255,255,255,.55);
  color:#173522;
}

#calibrationOutput{
  width:100%;
  min-height:110px;
  margin-top:12px;
  padding:12px;
  border:0;
  border-radius:16px;
  background:rgba(255,255,255,.65);
  color:#111;
  font-family:Consolas,monospace;
  font-size:12px;
  display:none;
}

#calibrationOutput.visible{
  display:block;
}

#calibrationHint{
  position:fixed;
  z-index:190;
  left:50%;
  top:calc(14px + env(safe-area-inset-top));
  transform:translateX(-50%);
  width:min(92vw,520px);
  padding:11px 14px;
  border-radius:999px;
  background:rgba(35,77,53,.94);
  color:white;
  text-align:center;
  font-size:14px;
  font-weight:900;
  box-shadow:0 12px 34px rgba(0,0,0,.24);
}

@media(orientation:landscape) and (max-height:520px){
  #calibrationPanel{
    left:auto;
    right:calc(12px + env(safe-area-inset-right));
    bottom:calc(10px + env(safe-area-inset-bottom));
    transform:none;
    width:min(42vw,430px);
    padding:14px;
    border-radius:20px;
  }

  #calibrationPanel h2{
    font-size:20px;
  }

  .cal-grid{
    grid-template-columns:1fr 1fr;
    gap:8px;
  }

  .cal-item{
    padding:8px 10px;
  }

  .cal-value{
    font-size:14px;
  }

  .cal-actions button{
    padding:10px 8px;
    font-size:12px;
  }

  #calibrationOutput{
    min-height:80px;
    font-size:11px;
  }

  #calibrationHint{
    top:calc(8px + env(safe-area-inset-top));
    font-size:12px;
    padding:8px 12px;
    width:auto;
    max-width:56vw;
  }
}

/* =========================================================
   V7.1 — CALIBRATION GUIDÉE + EXPORT JSON
   Accès : ?photo=1&calibration=1
   ========================================================= */

#calibrationPanel{
  position:fixed;
  z-index:220;
  left:50%;
  bottom:calc(16px + env(safe-area-inset-bottom));
  transform:translateX(-50%);
  width:min(92vw,560px);
  padding:18px;
  border-radius:28px;
  background:rgba(243,234,216,.96);
  color:#173522;
  box-shadow:0 25px 76px rgba(0,0,0,.32);
  backdrop-filter:blur(14px);
  font-family:Arial,Helvetica,sans-serif;
}

#calibrationPanel h2{
  margin:0;
  font-family:Georgia,"Times New Roman",serif;
  color:#234d35;
  font-size:25px;
  line-height:1;
}

.cal-step{
  margin:6px 0 14px;
  color:#333;
  font-size:13px;
  font-weight:800;
}

.cal-guide{
  padding:13px 14px;
  margin-bottom:14px;
  border-radius:18px;
  background:rgba(35,77,53,.10);
  color:#173522;
  font-weight:900;
  line-height:1.35;
}

.cal-guide.ok{
  background:rgba(35,77,53,.92);
  color:#fff;
}

.cal-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom:14px;
}

.cal-item{
  padding:11px 12px;
  border-radius:16px;
  background:rgba(255,255,255,.50);
}

.cal-label{
  display:block;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.5px;
  font-weight:900;
  color:#234d35;
  margin-bottom:3px;
}

.cal-value{
  display:block;
  font-size:17px;
  font-weight:900;
  color:#111;
}

.cal-actions{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.cal-actions button{
  border:0;
  border-radius:17px;
  padding:13px 10px;
  background:linear-gradient(180deg,#356348,#1d4d33);
  color:#fff;
  font-weight:900;
  font-size:14px;
  box-shadow:0 10px 24px rgba(0,0,0,.18);
}

.cal-actions button.secondary{
  background:rgba(255,255,255,.58);
  color:#173522;
  box-shadow:none;
}

#calibrationOutput{
  width:100%;
  min-height:116px;
  margin-top:12px;
  padding:12px;
  border:0;
  border-radius:17px;
  background:rgba(255,255,255,.70);
  color:#111;
  font-family:Consolas,monospace;
  font-size:12px;
  display:none;
}

#calibrationOutput.visible{
  display:block;
}

#calibrationHint{
  position:fixed;
  z-index:210;
  left:50%;
  top:calc(12px + env(safe-area-inset-top));
  transform:translateX(-50%);
  width:min(92vw,560px);
  padding:11px 14px;
  border-radius:999px;
  background:rgba(35,77,53,.94);
  color:#fff;
  text-align:center;
  font-size:14px;
  font-weight:900;
  box-shadow:0 12px 34px rgba(0,0,0,.24);
}

@media(orientation:landscape) and (max-height:520px){
  #calibrationPanel{
    left:auto;
    right:calc(12px + env(safe-area-inset-right));
    bottom:calc(10px + env(safe-area-inset-bottom));
    transform:none;
    width:min(44vw,460px);
    padding:14px;
    border-radius:22px;
  }

  #calibrationPanel h2{font-size:20px}
  .cal-step{margin:4px 0 8px;font-size:12px}
  .cal-guide{padding:9px 11px;margin-bottom:9px;font-size:12px}
  .cal-grid{gap:8px;margin-bottom:10px}
  .cal-item{padding:8px 10px}
  .cal-label{font-size:10px}
  .cal-value{font-size:14px}
  .cal-actions button{padding:10px 8px;font-size:12px}
  #calibrationOutput{min-height:72px;font-size:10px}
  #calibrationHint{
    width:auto;
    max-width:56vw;
    top:calc(8px + env(safe-area-inset-top));
    font-size:12px;
    padding:8px 12px;
  }
}

/* =========================================================
   V8 — GUIDAGE VISITEUR GPS + ORIENTATION
   ========================================================= */

#guidanceBox{
  position:fixed;
  z-index:150;
  left:50%;
  top:calc(112px + env(safe-area-inset-top));
  transform:translateX(-50%);
  width:min(90vw,560px);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:12px 16px;
  border-radius:999px;
  background:rgba(243,234,216,.95);
  color:#173522;
  text-align:center;
  font-size:14px;
  font-weight:900;
  box-shadow:0 12px 34px rgba(0,0,0,.24);
  backdrop-filter:blur(10px);
  pointer-events:none;
}

#guidanceBox.warning{
  background:rgba(243,234,216,.96);
  color:#5a3b18;
}

#guidanceBox.ok{
  background:rgba(35,77,53,.94);
  color:#fff;
}

#guidanceBox.info{
  background:rgba(243,234,216,.95);
  color:#173522;
}

#guidanceIcon{
  flex:0 0 auto;
  font-size:19px;
}

#alignedMessage{
  position:fixed;
  z-index:160;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%) scale(.96);
  width:min(84vw,460px);
  padding:22px 26px;
  border-radius:24px;
  background:rgba(243,234,216,.96);
  color:#173522;
  text-align:center;
  font-size:21px;
  font-weight:900;
  box-shadow:0 24px 70px rgba(0,0,0,.30);
  backdrop-filter:blur(12px);
  opacity:0;
  visibility:hidden;
  transition:.35s ease;
  pointer-events:none;
}

#alignedMessage.visible{
  opacity:1;
  visibility:visible;
  transform:translate(-50%,-50%) scale(1);
}

@media(max-width:430px){
  #guidanceBox{
    top:calc(102px + env(safe-area-inset-top));
    width:calc(100vw - 24px);
    padding:10px 13px;
    font-size:12px;
    line-height:1.3;
  }

  #alignedMessage{
    font-size:18px;
    padding:19px 22px;
  }
}

@media(orientation:landscape) and (max-height:520px){
  #guidanceBox{
    top:calc(70px + env(safe-area-inset-top));
    width:auto;
    max-width:58vw;
    padding:8px 12px;
    font-size:12px;
  }

  #alignedMessage{
    width:min(58vw,430px);
    font-size:17px;
    padding:16px 20px;
  }
}

