:root{
  --forest:#123b2a;
  --forest-deep:#08281c;
  --forest-soft:#1d513a;
  --orange:#ef6f17;
  --cream:#f7f1e6;
  --paper:#fffdf8;
  --ink:#17382b;
  --muted:#6d786f;
  --line:rgba(18,59,42,.13);
  --shadow:0 18px 44px rgba(9,45,31,.11);
  --danger:#b93434;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{margin:0;background:#f7f5ef;color:var(--ink);font-family:Inter,Arial,sans-serif}
button,input{font:inherit}
button{cursor:pointer}
img{display:block;max-width:100%}
[hidden]{display:none!important}
.eyebrow{display:block;color:#708073;font-size:11px;font-weight:900;letter-spacing:.16em}
.primary,.secondary,.danger,.icon-button{border:0;border-radius:12px;font-weight:800}
.primary{min-height:44px;padding:0 17px;background:var(--forest);color:#fff;display:inline-flex;align-items:center;justify-content:center;gap:9px;box-shadow:0 8px 20px rgba(18,59,42,.15)}
.primary:hover{background:#0d3022}
.primary:disabled{opacity:.55;cursor:not-allowed}
.secondary{min-height:43px;padding:0 17px;background:#eef1ed;color:var(--forest)}
.danger{min-height:43px;padding:0 17px;background:var(--danger);color:white;display:inline-flex;align-items:center;gap:8px}
.wide{width:100%}
.icon-button{width:42px;height:42px;background:#fff;border:1px solid var(--line);color:var(--forest)}
.toast{position:fixed;z-index:5000;left:50%;bottom:24px;transform:translate(-50%,20px);padding:12px 16px;border-radius:12px;background:#102f23;color:#fff;font-size:13px;font-weight:700;opacity:0;pointer-events:none;transition:.2s ease;box-shadow:var(--shadow)}
.toast.show{opacity:1;transform:translate(-50%,0)}
.toast.error{background:#8f2d2d}

.login-shell{min-height:100vh;display:grid;place-items:center;padding:28px;background:
  radial-gradient(circle at 18% 14%,rgba(239,111,23,.14),transparent 27%),
  linear-gradient(135deg,#07271b,#123b2a 55%,#1b533a)}
.login-card{width:min(460px,100%);padding:34px;border-radius:24px;background:rgba(255,253,248,.98);box-shadow:0 30px 70px rgba(0,0,0,.24)}
.login-brand{display:flex;align-items:center;gap:16px}
.login-brand img{width:70px;height:70px;object-fit:contain}
.login-brand h1{font:800 32px/1.05 "Playfair Display",serif;margin:5px 0 0}
.login-copy{margin:22px 0;color:var(--muted);line-height:1.6}
.login-form{display:grid;gap:16px}
.login-form label>span{display:block;margin-bottom:7px;font-size:12px;font-weight:800}
.input-wrap{position:relative}
.input-wrap>i{position:absolute;left:14px;top:50%;transform:translateY(-50%);color:#879087}
.input-wrap input{width:100%;height:48px;border:1px solid var(--line);border-radius:12px;background:#fff;padding:0 46px 0 42px;color:var(--ink);outline:none}
.input-wrap input:focus{border-color:rgba(18,59,42,.5);box-shadow:0 0 0 3px rgba(18,59,42,.08)}
.input-icon-button{position:absolute;right:5px;top:5px;width:38px;height:38px;border:0;background:transparent;color:#647267}
.form-error{margin:0;color:#a12c2c;font-size:13px;font-weight:700}

.app{min-height:100vh;display:grid;grid-template-columns:260px minmax(0,1fr)}
.sidebar{position:sticky;top:0;height:100vh;display:flex;flex-direction:column;padding:22px 16px;background:linear-gradient(180deg,#092d20,#123b2a);color:#fff;z-index:100}
.side-brand{display:flex;align-items:center;gap:11px;padding:4px 8px 22px;border-bottom:1px solid rgba(255,255,255,.11)}
.side-brand img{width:46px;height:46px;object-fit:contain}
.side-brand strong,.side-brand span{display:block}
.side-brand strong{font-size:14px}
.side-brand span{margin-top:2px;color:rgba(255,255,255,.63);font-size:11px}
.side-nav{display:grid;gap:7px;padding-top:24px}
.side-nav button,.signout{width:100%;min-height:44px;border:0;border-radius:11px;background:transparent;color:rgba(255,255,255,.75);display:flex;align-items:center;gap:11px;padding:0 13px;text-align:left;font-weight:750}
.side-nav button:hover,.side-nav button.active{background:rgba(255,255,255,.11);color:#fff}
.side-nav i,.signout i{width:20px;text-align:center}
.sidebar-note{margin-top:auto;padding:14px;border:1px solid rgba(255,255,255,.11);border-radius:14px;background:rgba(255,255,255,.06);color:rgba(255,255,255,.72)}
.sidebar-note i{color:#f0a35b}
.sidebar-note p{margin:8px 0 0;font-size:11px;line-height:1.55}
.signout{margin-top:10px}
.signout:hover{background:rgba(255,255,255,.08);color:#fff}
.sidebar-backdrop{display:none}
.main{min-width:0}
.topbar{position:sticky;top:0;z-index:80;min-height:82px;padding:14px 26px;background:rgba(247,245,239,.94);backdrop-filter:blur(14px);border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;gap:18px}
.top-left{display:flex;align-items:center;gap:12px}
.topbar h2{margin:4px 0 0;font-size:18px}
.top-actions{display:flex;align-items:center;gap:13px}
.signed-in-email{max-width:230px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:12px;font-weight:700}
.upload-button{cursor:pointer}
.mobile-menu{display:none}
.content{width:min(1260px,calc(100% - 42px));margin:26px auto 60px;display:grid;gap:22px}
.intro-card,.section-card{border:1px solid var(--line);border-radius:20px;background:var(--paper);box-shadow:0 8px 28px rgba(15,49,35,.05)}
.intro-card{display:flex;align-items:center;justify-content:space-between;gap:30px;padding:26px}
.intro-card h1{margin:7px 0 8px;font:800 clamp(25px,3vw,38px)/1.06 "Playfair Display",serif}
.intro-card p{max-width:720px;margin:0;color:var(--muted);line-height:1.65}
.rules{display:flex;gap:8px;flex:0 0 auto}
.rules div{min-width:100px;padding:13px 12px;border-radius:14px;background:#f0f3ef;text-align:center}
.rules strong,.rules span{display:block}
.rules strong{font-size:21px;color:var(--forest)}
.rules span{margin-top:3px;color:#7a857d;font-size:10px;font-weight:800}
.section-card{padding:24px}
.section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;margin-bottom:20px}
.section-head h2{margin:5px 0 6px;font-size:22px}
.section-head p{margin:0;color:var(--muted);font-size:13px;line-height:1.5}
.photo-count{min-width:72px;padding:10px 12px;border-radius:12px;background:#eef2ed;text-align:center}
.photo-count strong,.photo-count span{display:block}
.photo-count strong{font-size:20px}
.photo-count span{font-size:9px;text-transform:uppercase;font-weight:900;color:#7a847d;letter-spacing:.08em}
.state-box{min-height:210px;display:grid;place-items:center;align-content:center;gap:9px;border:1px dashed rgba(18,59,42,.2);border-radius:16px;color:#7b867e}
.state-box i{font-size:25px;color:var(--forest)}
.state-box strong{color:var(--ink)}
.state-box span{font-size:12px}
.photo-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}
.photo-card{position:relative;overflow:hidden;border:1px solid var(--line);border-radius:16px;background:#fff;transition:transform .15s ease,box-shadow .15s ease}
.photo-card:hover{transform:translateY(-2px);box-shadow:0 12px 28px rgba(12,50,34,.1)}
.photo-card.sortable-ghost{opacity:.34}
.photo-image-wrap{position:relative;aspect-ratio:4/3;overflow:hidden;background:#e8ece7}
.photo-image-wrap img{width:100%;height:100%;object-fit:cover}
.order-badge{position:absolute;left:9px;top:9px;min-width:32px;height:32px;padding:0 8px;border-radius:999px;background:rgba(8,40,28,.88);color:#fff;display:grid;place-items:center;font-size:12px;font-weight:900;backdrop-filter:blur(7px)}
.label-badge{position:absolute;right:9px;top:9px;padding:7px 9px;border-radius:999px;background:rgba(255,255,255,.92);color:var(--forest);font-size:9px;font-weight:900;letter-spacing:.08em;text-transform:uppercase}
.drag-handle{position:absolute;left:9px;bottom:9px;width:34px;height:34px;border:0;border-radius:10px;background:rgba(255,255,255,.92);color:var(--forest);display:grid;place-items:center;cursor:grab;box-shadow:0 4px 14px rgba(0,0,0,.13)}
.drag-handle:active{cursor:grabbing}
.photo-body{padding:12px}
.label-toggle{display:grid;grid-template-columns:repeat(3,1fr);padding:3px;border-radius:10px;background:#eef1ed}
.label-toggle button{height:34px;border:0;border-radius:8px;background:transparent;color:#718076;font-size:11px;font-weight:900}
.label-toggle button.active{background:#fff;color:var(--forest);box-shadow:0 2px 8px rgba(12,45,32,.09)}
.card-actions{display:flex;justify-content:space-between;align-items:center;margin-top:10px}
.card-position{font-size:10px;color:#8b958e;font-weight:800}
.delete-button{width:34px;height:34px;border:0;border-radius:9px;background:#fff1ef;color:#a93b33}
.delete-button:hover{background:#f8dfdb}

.modal-bg{position:fixed;inset:0;z-index:1000;padding:22px;background:rgba(4,22,15,.63);display:grid;place-items:center}
.modal{width:min(420px,100%);padding:28px;border-radius:20px;background:#fff;text-align:center;box-shadow:0 30px 70px rgba(0,0,0,.25)}
.modal-icon{width:54px;height:54px;margin:0 auto 13px;border-radius:50%;display:grid;place-items:center;background:#fff0ee;color:#ad3934;font-size:20px}
.modal h2{margin:0}
.modal p{margin:10px auto 21px;color:var(--muted);line-height:1.55;font-size:13px}
.modal-actions{display:flex;justify-content:center;gap:9px}

@media(max-width:1100px){
  .photo-grid{grid-template-columns:repeat(3,minmax(0,1fr))}
  .intro-card{align-items:flex-start;flex-direction:column}
}
@media(max-width:820px){
  .app{display:block}
  .sidebar{position:fixed;left:0;top:0;width:260px;transform:translateX(-105%);transition:.2s ease}
  .sidebar.open{transform:translateX(0)}
  .sidebar-backdrop{position:fixed;inset:0;z-index:90;background:rgba(2,20,13,.48)}
  .sidebar-backdrop.show{display:block}
  .mobile-menu{display:inline-grid;place-items:center}
  .topbar{padding:12px 16px}
  .signed-in-email{display:none}
  .content{width:min(100% - 24px,1260px);margin-top:14px}
  .photo-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:560px){
  .login-card{padding:25px 20px}
  .login-brand h1{font-size:27px}
  .topbar{align-items:center}
  .topbar .eyebrow{display:none}
  .topbar h2{margin:0;font-size:16px}
  .upload-button{font-size:0;width:44px;padding:0}
  .upload-button i{font-size:15px}
  .intro-card,.section-card{padding:18px}
  .rules{width:100%;display:grid;grid-template-columns:repeat(3,1fr)}
  .rules div{min-width:0;padding:10px 5px}
  .photo-grid{gap:9px}
  .photo-body{padding:9px}
  .section-head h2{font-size:19px}

}


.home-star{
  position:absolute;
  right:9px;
  bottom:9px;
  z-index:4;
  width:36px;
  height:36px;
  border:1px solid rgba(255,255,255,.55);
  border-radius:11px;
  display:grid;
  place-items:center;
  background:rgba(255,255,255,.94);
  color:#68756d;
  box-shadow:0 5px 15px rgba(0,0,0,.14);
}
.home-star:hover{transform:translateY(-1px);color:#b37b0c}
.home-star.featured{
  color:#c7890a;
  background:#fff8df;
  border-color:rgba(199,137,10,.28);
}
.home-star.featured:hover{transform:none}
.featured-modal{width:min(700px,100%);text-align:left}
.featured-modal h2,.featured-modal>p{text-align:center}
.featured-modal-icon{background:#fff7d9;color:#bd7f00}
.featured-choices{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  margin:20px 0 22px;
}
.featured-choice{
  position:relative;
  padding:0;
  overflow:hidden;
  border:2px solid transparent;
  border-radius:13px;
  background:#eef1ed;
  aspect-ratio:4/3;
}
.featured-choice img{width:100%;height:100%;object-fit:cover}
.featured-choice span{
  position:absolute;
  left:7px;
  top:7px;
  min-width:26px;
  height:26px;
  padding:0 7px;
  border-radius:999px;
  display:grid;
  place-items:center;
  background:rgba(8,40,28,.85);
  color:#fff;
  font-size:10px;
  font-weight:900;
}
.featured-choice .featured-check{
  position:absolute;
  right:7px;
  top:7px;
  width:27px;
  height:27px;
  border-radius:50%;
  display:none;
  place-items:center;
  background:#fff;
  color:var(--forest);
  box-shadow:0 3px 10px rgba(0,0,0,.15);
}
.featured-choice.selected{
  border-color:var(--orange);
  box-shadow:0 0 0 3px rgba(239,111,23,.11);
}
.featured-choice.selected .featured-check{display:grid}
.featured-empty{
  grid-column:1/-1;
  padding:18px;
  border:1px dashed var(--line);
  border-radius:12px;
  color:var(--muted);
  text-align:center;
  font-size:12px;
}
@media(max-width:560px){
  .featured-choices{grid-template-columns:repeat(2,minmax(0,1fr))}
  .home-star{width:33px;height:33px}
}


.pair-button{
  min-height:34px;
  padding:0 10px;
  border:0;
  border-radius:9px;
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:#edf3ef;
  color:var(--forest);
  font-size:10px;
  font-weight:900;
}
.pair-button:hover{background:#e3ece6}
.pair-button.paired{
  background:#e9f2ff;
  color:#285681;
}
.pair-meta{
  margin-top:8px;
  padding:8px 9px;
  border-radius:9px;
  background:#f4f6f3;
  color:#6f7b72;
  font-size:10px;
  line-height:1.4;
}
.pair-meta strong{color:var(--forest)}
.pair-modal{width:min(760px,100%);text-align:left}
.pair-modal h2,.pair-modal>p{text-align:center}
.pair-modal-icon{background:#e9f2ff;color:#315e88}
.pair-choice-type{
  position:absolute;
  left:7px;
  bottom:7px;
  padding:5px 7px;
  border-radius:7px;
  background:rgba(8,40,28,.85);
  color:#fff;
  font-size:8px;
  font-weight:900;
  letter-spacing:.06em;
}


/* Scrollable admin popups */
.modal-bg{
  overflow-y:auto;
  align-items:flex-start;
}

.modal{
  max-height:calc(100vh - 44px);
  overflow-y:auto;
  overscroll-behavior:contain;
  margin:auto;
}

.featured-modal,
.pair-modal{
  max-height:calc(100vh - 44px);
  overflow-y:auto;
}

.featured-choices{
  max-height:52vh;
  overflow-y:auto;
  padding-right:4px;
  overscroll-behavior:contain;
}

@media(max-width:560px){
  .modal-bg{
    padding:12px;
  }

  .modal,
  .featured-modal,
  .pair-modal{
    max-height:calc(100vh - 24px);
  }

  .featured-choices{
    max-height:58vh;
  }
}



/* =========================================================
   FULL MOBILE POLISH
   ========================================================= */

html,
body{
  width:100%;
  max-width:100%;
  overflow-x:hidden;
}

body{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}

button,
label,
input{
  -webkit-tap-highlight-color:transparent;
}

button,
.upload-button,
.side-nav button,
.signout{
  touch-action:manipulation;
}

/* Tablet / smaller desktop */
@media(max-width:900px){
  .app{
    display:block;
  }

  .main{
    width:100%;
    min-height:100vh;
  }

  .topbar{
    min-height:68px;
  }

  .content{
    width:min(100% - 24px,1260px);
    margin:14px auto 36px;
  }

  .intro-card,
  .section-card{
    border-radius:16px;
  }

  .photo-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

/* Phones */
@media(max-width:620px){
  body{
    background:#f6f4ee;
  }

  .login-shell{
    min-height:100dvh;
    padding:14px;
    align-items:center;
  }

  .login-card{
    width:100%;
    max-width:440px;
    padding:22px 18px;
    border-radius:20px;
  }

  .login-brand{
    gap:12px;
  }

  .login-brand img{
    width:58px;
    height:58px;
  }

  .login-brand h1{
    font-size:25px;
  }

  .login-copy{
    margin:16px 0 18px;
    font-size:13px;
  }

  .input-wrap input{
    height:50px;
    font-size:16px; /* prevents iPhone zoom */
  }

  .primary.wide{
    min-height:50px;
  }

  .sidebar{
    width:min(84vw,290px);
    padding-top:max(18px,env(safe-area-inset-top));
    padding-bottom:max(18px,env(safe-area-inset-bottom));
    overflow-y:auto;
  }

  .side-brand{
    padding-bottom:17px;
  }

  .side-nav{
    padding-top:16px;
  }

  .side-nav button,
  .signout{
    min-height:48px;
  }

  .sidebar-note{
    margin-top:24px;
  }

  .topbar{
    min-height:64px;
    padding:
      max(10px,env(safe-area-inset-top))
      12px
      10px;
    gap:8px;
  }

  .top-left{
    min-width:0;
    gap:8px;
  }

  .top-left > div{
    min-width:0;
  }

  .topbar h2{
    max-width:45vw;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
  }

  .icon-button{
    width:44px;
    height:44px;
    flex:0 0 44px;
  }

  .top-actions{
    gap:7px;
    flex:0 0 auto;
  }

  .upload-button{
    width:44px;
    height:44px;
    min-height:44px;
    padding:0;
    border-radius:11px;
  }

  .upload-button i{
    font-size:16px;
  }

  .content{
    width:100%;
    margin:0;
    padding:12px 10px 34px;
    gap:12px;
  }

  .intro-card,
  .section-card{
    padding:15px;
    border-radius:15px;
    box-shadow:0 5px 18px rgba(15,49,35,.045);
  }

  .intro-card{
    gap:17px;
  }

  .intro-card h1{
    font-size:25px;
    line-height:1.08;
  }

  .intro-card p{
    font-size:12px;
    line-height:1.55;
  }

  .rules{
    display:grid;
    width:100%;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:6px;
  }

  .rules div{
    min-width:0;
    padding:10px 5px;
    border-radius:11px;
  }

  .rules strong{
    font-size:18px;
  }

  .rules span{
    font-size:8px;
  }

  .section-head{
    gap:10px;
    margin-bottom:14px;
  }

  .section-head h2{
    margin-top:4px;
    font-size:19px;
  }

  .section-head p{
    font-size:11px;
    line-height:1.45;
  }

  .photo-count{
    min-width:58px;
    padding:8px;
  }

  .photo-count strong{
    font-size:18px;
  }

  .photo-grid{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:8px;
  }

  .photo-card{
    border-radius:13px;
  }

  .photo-card:hover{
    transform:none;
    box-shadow:none;
  }

  .photo-image-wrap{
    aspect-ratio:1/1;
  }

  .order-badge{
    left:6px;
    top:6px;
    min-width:27px;
    height:27px;
    padding:0 6px;
    font-size:10px;
  }

  .label-badge{
    right:6px;
    top:6px;
    padding:5px 6px;
    font-size:7px;
  }

  .drag-handle{
    left:6px;
    bottom:6px;
    width:34px;
    height:34px;
    border-radius:9px;
  }

  .home-star{
    right:6px;
    bottom:6px;
    width:34px;
    height:34px;
    border-radius:9px;
  }

  .photo-body{
    padding:8px;
  }

  .label-toggle{
    padding:2px;
  }

  .label-toggle button{
    height:32px;
    padding:0 4px;
    font-size:9px;
  }

  .card-actions{
    gap:5px;
    margin-top:7px;
  }

  .card-actions > div{
    gap:4px !important;
  }

  .card-position{
    max-width:60px;
    font-size:8px;
    line-height:1.2;
  }

  .pair-button{
    min-height:32px;
    padding:0 8px;
    gap:4px;
    font-size:0;
  }

  .pair-button i{
    font-size:12px;
  }

  .delete-button{
    width:32px;
    height:32px;
  }

  .pair-meta{
    margin-top:6px;
    padding:6px 7px;
    font-size:8px;
  }

  .state-box{
    min-height:170px;
  }



  .modal-bg{
    padding:
      max(10px,env(safe-area-inset-top))
      10px
      max(10px,env(safe-area-inset-bottom));
    overflow-y:auto;
    align-items:flex-start;
  }

  .modal{
    width:100%;
    max-width:560px;
    max-height:calc(100dvh - 20px);
    margin:auto;
    padding:20px 14px 14px;
    border-radius:18px;
    overflow:hidden;
    display:flex;
    flex-direction:column;
  }

  .modal-icon{
    flex:0 0 auto;
    width:46px;
    height:46px;
    margin-bottom:9px;
  }

  .modal h2{
    flex:0 0 auto;
    font-size:20px;
  }

  .modal > p{
    flex:0 0 auto;
    margin:8px auto 13px;
    font-size:11px;
  }

  .featured-choices{
    flex:1 1 auto;
    min-height:0;
    max-height:none;
    overflow-y:auto;
    -webkit-overflow-scrolling:touch;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:7px;
    margin:10px 0 12px;
    padding:2px 2px 10px;
  }

  .featured-choice{
    border-radius:10px;
  }

  .modal-actions{
    position:sticky;
    bottom:0;
    z-index:5;
    flex:0 0 auto;
    margin:0 -14px -14px;
    padding:10px 14px max(10px,env(safe-area-inset-bottom));
    background:rgba(255,255,255,.98);
    border-top:1px solid var(--line);
    backdrop-filter:blur(10px);
  }

  .modal-actions button{
    flex:1 1 0;
    min-height:46px;
  }

  .featured-choice span{
    left:5px;
    top:5px;
    min-width:24px;
    height:24px;
    font-size:9px;
  }

  .featured-choice .featured-check{
    right:5px;
    top:5px;
    width:24px;
    height:24px;
  }

  .pair-choice-type{
    left:5px;
    bottom:5px;
    font-size:7px;
    padding:4px 5px;
  }

  .toast{
    left:10px;
    right:10px;
    bottom:max(12px,env(safe-area-inset-bottom));
    width:auto;
    transform:translateY(20px);
    text-align:center;
  }

  .toast.show{
    transform:translateY(0);
  }
}

/* Very small phones */
@media(max-width:390px){
  .content{
    padding-left:8px;
    padding-right:8px;
  }

  .intro-card,
  .section-card{
    padding:13px;
  }

  .photo-grid{
    gap:6px;
  }

  .card-position{
    display:none;
  }

  .pair-button{
    width:32px;
    padding:0;
    justify-content:center;
  }

  .rules span{
    line-height:1.15;
  }
}

/* Landscape phones */
@media(max-height:500px) and (orientation:landscape){
  .modal{
    max-height:calc(100dvh - 12px);
    padding-top:12px;
  }

  .modal-icon{
    display:none;
  }

  .featured-choices{
    grid-template-columns:repeat(4,minmax(0,1fr));
  }

  .sidebar{
    padding-top:10px;
  }
}

/* Better touch dragging */
@media(pointer:coarse){
  .drag-handle{
    width:38px;
    height:38px;
  }

  .home-star{
    width:38px;
    height:38px;
  }

  .delete-button,
  .pair-button{
    min-width:36px;
    min-height:36px;
  }
}



/* =========================================================
   DESKTOP POPUP — FIT ALL CHOICES BETTER
   ========================================================= */
@media(min-width:621px){
  .featured-modal,
  .pair-modal{
    width:min(980px,calc(100vw - 48px));
    max-height:calc(100vh - 48px);
    padding:26px 28px 20px;
    overflow:hidden;
    display:flex;
    flex-direction:column;
  }

  .featured-modal > h2,
  .pair-modal > h2,
  .featured-modal > p,
  .pair-modal > p,
  .featured-modal > .modal-icon,
  .pair-modal > .modal-icon{
    flex:0 0 auto;
  }

  .featured-choices{
    flex:1 1 auto;
    min-height:0;
    max-height:none;
    overflow-y:auto;
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:10px;
    margin:16px 0;
    padding:2px 4px 4px 2px;
  }

  .featured-choice{
    aspect-ratio:16/10;
    min-height:0;
  }

  .featured-choice img{
    width:100%;
    height:100%;
    object-fit:cover;
  }

  .modal-actions{
    flex:0 0 auto;
    position:sticky;
    bottom:0;
    margin:0 -28px -20px;
    padding:12px 28px 16px;
    background:rgba(255,255,255,.98);
    border-top:1px solid var(--line);
    backdrop-filter:blur(10px);
  }

  .modal-actions button{
    min-width:130px;
    min-height:44px;
  }
}

@media(min-width:1180px){
  .featured-modal,
  .pair-modal{
    width:min(1080px,calc(100vw - 64px));
  }

  .featured-choices{
    grid-template-columns:repeat(5,minmax(0,1fr));
    gap:9px;
  }

  .featured-choice{
    aspect-ratio:4/3;
  }
}



/* Paired drag grouping */
.photo-card.pair-selected{
  outline:3px solid rgba(49,94,136,.28);
  box-shadow:0 0 0 3px rgba(49,94,136,.10),0 12px 28px rgba(12,50,34,.1);
}

.photo-card.pair-selected .photo-image-wrap::after{
  content:"PAIRED";
  position:absolute;
  left:50%;
  bottom:8px;
  transform:translateX(-50%);
  z-index:5;
  padding:5px 7px;
  border-radius:999px;
  background:rgba(49,94,136,.9);
  color:white;
  font-size:8px;
  font-weight:900;
  letter-spacing:.08em;
  pointer-events:none;
}

.photo-card.pair-dragging{
  opacity:.65;
}

@media(max-width:620px){
  .photo-card.pair-selected{
    outline-width:2px;
  }

  .photo-card.pair-selected .photo-image-wrap::after{
    bottom:5px;
    padding:4px 6px;
    font-size:7px;
  }
}



.unpair-button{
  min-height:34px;
  padding:0 9px;
  border:0;
  border-radius:9px;
  display:inline-flex;
  align-items:center;
  gap:6px;
  background:#fff1ef;
  color:#9c3a34;
  font-size:10px;
  font-weight:900;
}
.unpair-button:hover{
  background:#f9dfda;
}
@media(max-width:620px){
  .unpair-button{
    min-width:32px;
    width:32px;
    min-height:32px;
    padding:0;
    justify-content:center;
    font-size:0;
  }
  .unpair-button i{
    font-size:12px;
  }
}

.pair-button.disabled-pair{opacity:.45;cursor:not-allowed}



/* Floating scroll-to-top button */
.scroll-top-button{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:1200;
  width:48px;
  height:48px;
  border:0;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:var(--forest);
  color:#fff;
  box-shadow:0 10px 28px rgba(7,40,27,.22);
  cursor:pointer;
  opacity:0;
  transform:translateY(12px) scale(.96);
  pointer-events:none;
  transition:opacity .18s ease,transform .18s ease,background .18s ease;
}

.scroll-top-button.show{
  opacity:1;
  transform:translateY(0) scale(1);
  pointer-events:auto;
}

.scroll-top-button:hover{
  background:#0d4d34;
  transform:translateY(-2px) scale(1);
}

.scroll-top-button:active{
  transform:translateY(0) scale(.97);
}

.scroll-top-button i{
  font-size:17px;
}

@media(max-width:620px){
  .scroll-top-button{
    right:14px;
    bottom:max(14px,env(safe-area-inset-bottom));
    width:46px;
    height:46px;
  }
}



/* Sticky header + back-to-top button */
.topbar{
  position:sticky;
  top:0;
  z-index:80;
  background:rgba(255,255,255,.96);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  border-bottom:1px solid rgba(20,60,42,.08);
}

.scroll-top-button{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:95;
  width:48px;
  height:48px;
  border:0;
  border-radius:50%;
  display:grid;
  place-items:center;
  background:var(--forest);
  color:#fff;
  box-shadow:0 10px 28px rgba(11,48,33,.22);
  opacity:0;
  visibility:hidden;
  transform:translateY(12px) scale(.94);
  transition:opacity .18s ease,transform .18s ease,visibility .18s ease;
  cursor:pointer;
}

.scroll-top-button:hover{
  transform:translateY(-2px) scale(1);
}

.scroll-top-button.show{
  opacity:1;
  visibility:visible;
  transform:translateY(0) scale(1);
}

@media(max-width:620px){
  .topbar{
    top:0;
  }

  .scroll-top-button{
    right:14px;
    bottom:max(14px,env(safe-area-inset-bottom));
    width:46px;
    height:46px;
  }
}



/* Desktop sidebar should extend with the full page height */
@media(min-width:901px){
  .app{
    align-items:stretch;
    min-height:100vh;
  }

  .sidebar{
    position:relative;
    top:auto;
    height:auto;
    min-height:100vh;
    align-self:stretch;
  }

  .main{
    min-width:0;
  }
}

/* Explicit no-label button */
.label-toggle button[data-label="none"]{
  font-size:18px;
  line-height:1;
  font-weight:900;
}
.label-toggle button[data-label="none"].active{
  background:#e5e9e5;
  color:#38483f;
  box-shadow:inset 0 0 0 1px rgba(18,59,42,.12);
}



/* FINAL sticky mobile header + universal back-to-top */
.topbar{
  position:sticky;
  top:0;
  z-index:220;
}

.scroll-top-button{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:260;
  width:50px;
  height:50px;
  border-radius:50%;
  display:grid;
  place-items:center;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transform:translateY(12px) scale(.94);
}

.scroll-top-button.show{
  opacity:1;
  visibility:visible;
  pointer-events:auto;
  transform:translateY(0) scale(1);
}

@media(max-width:900px){
  .main{
    padding-top:calc(64px + env(safe-area-inset-top));
  }

  .topbar{
    position:fixed !important;
    top:0;
    left:0;
    right:0;
    width:100%;
    min-height:calc(64px + env(safe-area-inset-top));
    padding:
      max(10px,env(safe-area-inset-top))
      12px
      10px;
    z-index:220;
    box-sizing:border-box;
  }

  .scroll-top-button{
    right:14px;
    bottom:max(16px,env(safe-area-inset-bottom));
    width:48px;
    height:48px;
  }
}

@media(min-width:901px){
  .scroll-top-button{
    right:22px;
    bottom:22px;
  }
}

/* Save email login checkbox */
.save-email-row{
  display:flex !important;
  align-items:center;
  gap:10px;
  min-height:42px;
  margin-top:-2px;
  cursor:pointer;
  color:var(--muted);
  font-size:12px;
  font-weight:750;
  user-select:none;
}
.save-email-row input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}
.save-email-check{
  width:20px;
  height:20px;
  flex:0 0 20px;
  border:1.5px solid rgba(18,59,42,.28);
  border-radius:6px;
  display:grid;
  place-items:center;
  background:#fff;
  color:#fff;
  transition:.16s ease;
}
.save-email-check i{
  font-size:11px;
  opacity:0;
  transform:scale(.7);
  transition:.16s ease;
}
.save-email-row input:checked + .save-email-check{
  border-color:var(--forest);
  background:var(--forest);
}
.save-email-row input:checked + .save-email-check i{
  opacity:1;
  transform:scale(1);
}
.save-email-row input:focus-visible + .save-email-check{
  outline:3px solid rgba(18,59,42,.14);
  outline-offset:2px;
}

.signout-near-nav{
  margin-top:8px;
}

/* Website Stats view (Batch 1: analytics will be connected later) */
[hidden]{display:none!important}
.stats-view{max-width:1100px;margin:0 auto;width:100%}
.stats-intro h1{margin:10px 0 6px;font-size:clamp(25px,3vw,35px);color:var(--forest)}
.stats-intro p{color:var(--muted);margin:0 0 26px;line-height:1.6}
.stats-empty{border:1px dashed rgba(18,59,42,.22);border-radius:16px;min-height:250px;display:flex;align-items:center;justify-content:center;flex-direction:column;text-align:center;gap:12px;padding:28px;background:rgba(18,59,42,.035)}
.stats-empty i{font-size:32px;color:var(--forest)}
.stats-empty strong{font-size:17px;color:var(--forest)}
.stats-empty span{max-width:470px;color:var(--muted);font-size:13px;line-height:1.65}

/* Batch 4: real analytics dashboard */
.stats-toolbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:22px 0 12px}
.stats-toolbar label{font-size:13px;font-weight:800;color:var(--forest)}
.stats-toolbar select{min-height:40px;border:1px solid var(--line);background:#fff;border-radius:9px;padding:0 12px;font:inherit;color:var(--forest)}
.stats-toolbar button{min-height:40px;padding:0 14px}
.stats-status{font-size:13px!important;margin:8px 0 20px!important;color:var(--muted)}
.stats-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:18px 0 22px}
.stats-metrics article{background:#fff;border:1px solid var(--line);border-radius:15px;padding:20px 17px;display:flex;flex-direction:column;gap:14px}
.stats-metrics article span{color:var(--muted);font-size:12px;font-weight:750}
.stats-metrics article strong{font-size:clamp(23px,2.5vw,35px);color:var(--forest)}
.stats-panels{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}
.stats-panel{background:#fff;border:1px solid var(--line);border-radius:15px;padding:20px;min-width:0}
.stats-panel h3{margin:0 0 18px;color:var(--forest);font-size:16px}
.stats-progress-row{margin:0 0 14px}
.stats-progress-label{display:flex;justify-content:space-between;gap:12px;margin-bottom:7px;font-size:12px;color:#45594b;overflow-wrap:anywhere}
.stats-progress-label strong{color:var(--forest);white-space:nowrap}
.stats-progress-track{height:8px;background:#e9eee8;border-radius:99px;overflow:hidden}
.stats-progress-fill{height:100%;background:#38845b;border-radius:99px}
.stats-no-data{color:var(--muted);font-size:13px}
@media(max-width:900px){.stats-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:640px){.stats-panels{grid-template-columns:1fr}.stats-metrics article{padding:15px}.stats-toolbar{gap:8px}.stats-panel{padding:16px}}

.stats-metrics article small{color:var(--muted);font-size:10px;line-height:1.45}

/* Requested batches 7 + 13: devices and weekly comparison only */
.stats-weekly{border:1px solid var(--line);background:#fff;border-radius:16px;padding:20px;margin:0 0 20px}
.stats-weekly-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin-bottom:16px}
.stats-weekly-head h3{font-size:17px;margin:0 0 5px;color:var(--forest)}
.stats-weekly-head p,.stats-weekly-footnote{color:var(--muted);font-size:12px;line-height:1.5;margin:0}
.stats-weekly-head button{min-height:38px}
.stats-weekly-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px}
.stats-weekly-grid article{padding:16px;border:1px solid var(--line);border-radius:12px;background:#f8faf7;display:flex;flex-direction:column;gap:7px}
.stats-weekly-grid article span{font-size:12px;color:var(--muted);font-weight:800}
.stats-weekly-grid article strong{font-size:clamp(22px,2.5vw,32px);color:var(--forest)}
.stats-weekly-grid article small{font-size:12px;color:#2a744d;font-weight:700}
.stats-weekly-footnote{margin-top:13px}
@media(max-width:640px){.stats-weekly-grid{grid-template-columns:1fr}.stats-weekly{padding:15px}}

.form-status{margin:0;color:var(--forest);font-size:13px;font-weight:700;line-height:1.5}
.login-form .secondary:disabled{opacity:.55;cursor:not-allowed}


/* Signed-in admin password change */
.change-password-modal{max-height:min(90vh,760px);overflow:auto;text-align:left}
.change-password-modal .modal-icon{text-align:center}
.change-password-modal h2{text-align:center}
.change-password-modal>p{text-align:center}
.change-password-form label{display:block;margin:14px 0 7px;color:var(--ink);font-size:12px;font-weight:800}
.change-password-form input{width:100%;height:46px;box-sizing:border-box;border:1px solid var(--line);border-radius:11px;background:#fff;padding:0 13px;color:var(--ink);font:inherit;outline:none}
.change-password-form input:focus{border-color:rgba(18,59,42,.5);box-shadow:0 0 0 3px rgba(18,59,42,.08)}
.change-password-form .password-requirements{margin:10px 0;color:var(--muted);font-size:11px;line-height:1.5}
.change-password-form .form-error{margin:10px 0}
.change-password-form .modal-actions{margin-top:18px}
.change-password-form .modal-actions button{flex:1}
@media(max-width:480px){.change-password-modal{padding:22px}.change-password-form .modal-actions{flex-direction:column-reverse}}


/* Manage Team */
.team-toolbar{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-top:16px}
.team-toolbar .stats-status{margin:0}
.team-create-card h2,.team-list-card h2{margin:8px 0 6px;color:var(--forest)}
.team-create-card .section-head p,.team-list-card .section-head p{margin:0;color:var(--muted);font-size:13px;line-height:1.55}
.team-create-form{display:grid;gap:9px;max-width:760px}
.team-create-form>label,.team-field>span{font-size:12px;font-weight:800;color:var(--forest)}
.team-create-form>input,.team-field select{width:100%;min-height:44px;box-sizing:border-box;border:1px solid var(--line);border-radius:10px;padding:0 12px;background:#fff;color:var(--ink);font:inherit}
.team-mailbox-fieldset{min-width:0;margin:12px 0;padding:14px;border:1px solid var(--line);border-radius:12px}
.team-mailbox-fieldset legend{padding:0 6px;color:var(--forest);font-size:12px;font-weight:850}
.team-mailbox-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px}
.team-mailbox-choice{display:flex;align-items:center;gap:9px;min-width:0;padding:9px 10px;border:1px solid var(--line);border-radius:9px;background:#fbfcfa;font-size:12px;overflow-wrap:anywhere}
.team-mailbox-choice input,.team-active-toggle input{accent-color:var(--forest);width:16px;height:16px;flex:0 0 auto}
.team-mailbox-choice span{overflow-wrap:anywhere}
.team-members-list{display:grid;gap:15px}
.team-member-card{border:1px solid var(--line);border-radius:15px;background:#fff;padding:18px}
.team-member-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}
.team-member-head h3{margin:0 0 5px;font-size:16px;color:var(--forest)}
.team-member-head p{margin:0;color:var(--muted);font-size:12px;overflow-wrap:anywhere}
.team-reset-btn{white-space:nowrap;flex:0 0 auto}
.team-badges{display:flex;gap:6px;flex-wrap:wrap;margin-top:10px}
.team-badge{display:inline-flex;align-items:center;border-radius:999px;padding:5px 8px;background:#f0f2ef;color:#566359;font-size:10px;font-weight:850}
.team-badge.good{background:#e7f5eb;color:#24643a}
.team-badge.inactive{background:#fff0ed;color:#9f3429}
.team-badge.pending{background:#fff5df;color:#805819}
.team-member-settings{display:grid;grid-template-columns:minmax(170px,220px) minmax(150px,1fr);gap:15px;margin-top:18px}
.team-field{display:grid;gap:7px;align-content:start}
.team-active-toggle{display:flex;align-items:center;gap:8px;align-self:end;font-size:12px;font-weight:800;color:var(--forest);min-height:44px}
.team-mailbox-access{grid-column:1/-1;border-top:1px solid var(--line);padding-top:15px}
.team-mailbox-access>strong{display:block;margin-bottom:10px;font-size:12px;color:var(--forest)}
.team-help{margin:10px 0 0;color:#7c681f;font-size:11px;line-height:1.5}
.team-member-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:17px;padding-top:13px;border-top:1px solid var(--line)}
.team-member-footer>span{font-size:11px;color:var(--muted)}
.temporary-password-result{margin-top:22px;padding:17px;border:1px solid #d1e4d5;border-radius:14px;background:#f0f8f1}
.temporary-password-result h3{margin:0 0 8px;color:var(--forest);font-size:15px}
.temporary-password-result p{color:#52685a;font-size:12px;line-height:1.55}
.temporary-password-value{display:flex;align-items:center;gap:10px;justify-content:space-between;padding:12px;background:#fff;border:1px solid #d6e2d8;border-radius:10px}
.temporary-password-value code{font-size:14px;overflow-wrap:anywhere;user-select:all}
.temporary-password-result .password-warning{margin-bottom:0;color:#805819}
#addTeamStatus{margin:3px 0 0;font-size:12px}
#addTeamStatus.success{color:#24643a}
@media(max-width:700px){
 .team-member-head{flex-direction:column}
 .team-reset-btn{white-space:normal}
 .team-mailbox-options{grid-template-columns:1fr}
 .team-member-settings{grid-template-columns:1fr}
 .team-active-toggle{align-self:auto}
 .team-member-footer{align-items:stretch;flex-direction:column}
 .temporary-password-value{align-items:stretch;flex-direction:column}
 .temporary-password-value button{width:100%}
}
