:root{
  --brand:#4289c5;
  --brand-dark:#1c3f59;
  --bg:#0f1f2b;
  --card:#152938;
  --text:#eaf2fb;
  --muted:#a6c2d9;
  --accent:#8fd4ff;
}

*{box-sizing:border-box}
html,body{height:100%}

body.theme{
  margin:0;
  background:linear-gradient(180deg, var(--brand-dark), #0b1721);
  color:var(--text);
  font-family: "IBM Plex Sans","Tajawal",system-ui,Arial,sans-serif;
}

/* Topbar */
#topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #4289c5;
  padding: 20px 40px;
  height: 70px;
  color: white;
}

/* Left and right logo containers */
#header-logos,
#header-logos-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

#header-logos img,
#header-logos-right img {
  height: 50px;
  object-fit: contain;
}



/* Optional central title (if used) */
#app-title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'IBM Plex Sans', 'Tajawal', sans-serif;
  font-weight: 700;
  font-size: 42px;
  letter-spacing: 1px;
  pointer-events: none;
}

#logo1 {
  height: 60px;
  transform: scale(1.1);
}

#logo3 {
  background-color: #fff;
  border-radius: 18px;
  margin-top: 3px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  height: 62px !important;
  object-fit: contain;
}

.app-title{
  font-weight:700;
  letter-spacing:.5px;
  font-size:28px;
}

.container{
  height:calc(100dvh - 72px - 64px);
  padding:20px 24px;
}

/* Footer */
.footer{
  height:64px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 24px;
  background:#0b1821;
  color:var(--muted);
  border-top:1px solid rgba(255,255,255,.08);
  flex-wrap:wrap;
  row-gap:8px;
}

.footer .btn{
  font-size:16px;
  padding:10px 16px;
  min-width:auto;
}

.btn{
  font-size:22px;
  padding:16px 28px;
  border-radius:16px;
  border:none;
  cursor:pointer;
  min-width:160px;
}
.btn-primary{
  background:var(--brand);
  color:#fff;
  box-shadow:0 6px 16px rgba(66,137,197,.35);
}
.btn-primary:hover{filter:brightness(1.06)}
.btn-ghost{
  background:transparent;
  color:var(--accent);
  border:2px solid var(--accent);
}
.btn-ghost:hover{background:rgba(143,212,255,.08)}

.input{
  width:100%;
  padding:16px 18px;
  font-size:20px;
  border-radius:14px;
  border:2px solid #2a4a5f;
  background:#0e1a24;
  color:#fff;
}

.screen{
  display:none;
  height:100%;
  width:100%;
}
.screen.active{
  display:flex;
}

/* Welcome screen */
.hero{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:24px;
  width:100%;
}
.headline{
  font-size:56px;
  text-align:center;
  margin:0;
  font-weight:800;
}
.subhead{
  font-size:22px;
  color:var(--muted);
  margin:0 0 10px 0;
  text-align:center;
  max-width:900px;
}
.actions{
  display:flex;
  gap:16px;
  flex-wrap:wrap;
  justify-content:center;
}

/* Camera view – DESKTOP BASE (your old one) */
.camera-wrap{
  position:relative;
  width:100%;
  height:100%;
  border-radius:24px;
  background:var(--card);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  box-shadow:0 20px 60px rgba(0,0,0,.35);
}
video#video{
  max-width:100%;
  max-height:100%;
  border-radius:12px;
}
canvas.overlay{
  position:absolute;
  inset:0;
  pointer-events:none;
}

/* ---------- HUD + PROGRESS BAR (from the good mobile version) ---------- */
.hud{
  position:absolute;
  left:16px;
  right:16px;
  bottom:16px;
  display:flex;
  align-items:center;
  gap:12px;
  justify-content:space-between;
  z-index: 10; /* above video/canvas */
}

.progress{
  position: relative;
  flex: 1 1 auto;
  height: 18px;
  background:#0d1b25;
  border-radius:14px;
  overflow:hidden;
  border:1px solid #2a4a5f;
}

.bar{
  position:absolute;
  left:0;
  top:0;
  height:100%;
  width:0%;
  display:block;
  background:linear-gradient(90deg, #43d17c, #8ae85e);
  transition: width 0.18s linear;
  will-change: width;
}

.tips{
  color:var(--muted);
  font-size:18px;
}
/* ---------------------------------------------------------------------- */

/* Result view */
.result-wrap{
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:24px;
}
.result-wrap img{
  max-height:80%;
  max-width:92%;
  border-radius:18px;
  box-shadow:0 16px 50px rgba(0,0,0,.5);
}

/* Modal */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:60;
}
.modal.hidden{
  display:none;
}
.modal-card{
  width:min(820px, 92vw);
  background:#0c1620;
  border:1px solid #234258;
  border-radius:18px;
  padding:24px;
  box-shadow:0 20px 60px rgba(0,0,0,.6);
}
.modal-title{
  margin:0 0 10px 0;
  font-size:28px;
}
.modal-step.hidden{
  display:none;
}
.qr{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:12px;
  background:#0b1620;
  border-radius:14px;
  border:1px dashed #294b61;
}
.muted{
  color:var(--muted);
}
.status{
  margin-top:10px;
}

/* Share modal email spacing */
#share-modal .modal-card .modal-body #modal-step-email #email-form {
  display: flex;
  flex-direction: column;
}
#share-modal .modal-card .modal-body #modal-step-email #email-form > #email-input,
#share-modal .modal-card .modal-body #modal-step-email #email-form > .input {
  margin-bottom: 10px !important;
}
#share-modal .modal-card .modal-body #modal-step-email #email-form > .actions {
  margin-top: 16px !important;
  gap: 16px;
  justify-content: center;
}

/* Hidden logo 3 (still usable in canvas) */
.hidden-logo {
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Smile icon on welcome */
.smile-icon-wrap {
  text-align: center;
  margin-bottom: 0px;
}
.smile-icon {
  width: 120px;
  height: auto;
  display: inline-block;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.15));
}

/* ========================= */
/*    RESPONSIVE LAYOUT      */
/* ========================= */

/* Tablets and below (<= 1024px) */
@media (max-width: 1024px) {
  #topbar {
    padding: 12px 20px;
  }
  #header-logos img,
  #header-logos-right img {
    height: 40px;
  }

  .headline {
    font-size: 42px;
  }
  .subhead {
    font-size: 18px;
    padding: 0 12px;
  }

  .btn {
    font-size: 20px;
    padding: 14px 24px;
  }

  .camera-wrap {
    border-radius: 18px;
  }
}

/* 🔥 MOBILE VIEW (<= 768px) – layout + HUD overrides from the good version */
@media (max-width: 768px) {
  #topbar {
    padding: 8px 12px;
    height: auto;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 6px;
  }

  #header-logos {
    justify-content: center;
  }

  #header-logos img,
  #header-logos-right img {
    height: 32px;
  }

  #logo1 {
    height: 40px;
    transform: none;
  }

  .container {
    padding: 12px;
    height: calc(100dvh - 56px - 60px);
  }

  /* keep content higher on mobile */
  .screen.active{
    justify-content:flex-start;
    padding-top:8px;
  }

  .headline {
    font-size: 30px;
  }
  .subhead {
    font-size: 14px;
    max-width: 100%;
  }

  .smile-icon {
    width: 80px;
  }

  .btn {
    font-size: 18px;
    padding: 12px 20px;
    min-width: 130px;
  }

  /* Camera: more vertical, fills width nicely */
  .camera-wrap {
    width:100%;
    height:auto;           /* override desktop 100% height */
    max-height:100%;
    aspect-ratio:3/4;
    border-radius: 16px;
  }

  video#video,
  canvas.overlay{
    border-radius:16px;
  }

  video#video{
    width:100%;
    height:auto;
    max-height:100%;
    object-fit:cover;
  }

  /* HUD overrides on mobile (from your good snippet) */
  .hud {
    left: 12px;
    right: 12px;
    bottom: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .progress{
    height: 14px;
  }

  .tips{
    font-size: 14px;
  }

  .result-wrap img {
    max-height: 60vh;
    max-width: 100%;
  }

  .modal-card {
    width: 95vw;
    padding: 16px;
  }
  .modal-title {
    font-size: 22px;
  }
  .input {
    font-size: 16px;
    padding: 12px 14px;
  }

  .footer {
    padding: 8px 12px;
    height: auto;
    justify-content: center;
    text-align: center;
  }
}

/* Very large screens (>= 1600px) – your original desktop upscale */
@media (min-width: 1600px) {
  .container {
    max-width: 1600px;
    margin: 0 auto;
  }

  .headline {
    font-size: 70px;
  }

  .subhead {
    font-size: 24px;
  }

  .btn {
    font-size: 24px;
    padding: 18px 32px;
  }

  .result-wrap img {
    max-height: 70vh;
  }
}

/* ===== HEADER LOGOS LAYOUT (DESKTOP) ===== */

/* Make the single header-logos container span full width
   and push logo1 left, logo2 right */
   #topbar {
    display: flex;
    align-items: center;
    justify-content: center; /* center the flex container itself */
  }
  
  #header-logos {
    display: flex;
    align-items: center;
    justify-content: space-between; /* logo1 left, logo2 right */
    width: 100%;                    /* span full header width */
    gap: 20px;
  }
  
  #header-logos img {
    height: 50px;
    object-fit: contain;
  }
  
  /* ===== MOBILE OVERRIDES (<= 768px) ===== */
  @media (max-width: 768px) {
    #topbar {
      justify-content: center; /* keep header centered */
    }
  
    #header-logos {
      justify-content: center; /* center the pair */
      gap: 16px;               /* nice spacing between logos */
      width: auto;             /* no need to stretch full width */
    }
  
    /* Make logos a bit larger on mobile */
    #header-logos img {
      height: 68px;            /* was 32px before – slightly bigger */
    }
  
    #logo1 {
      height: 40px;
      transform: none;
    }
  }
