*{box-sizing:border-box}

html,
body{
  width:100%;
  height:100%;
  margin:0;
  overflow:hidden;
  background:#edf3fb;
  color:#26221f
}

body.ksl-preview-page{
  font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  overscroll-behavior:none
}

body.ksl-preview-page.admin-bar{margin-top:0!important}
#wpadminbar{display:none!important}

/* App: fixed browser-like workspace. Only the iframe content scrolls. */
.kslp-app{
  width:min(1180px,calc(100% - 32px));
  height:100vh;
  height:100dvh;
  margin:0 auto;
  display:grid;
  grid-template-rows:auto minmax(0,1fr) auto;
  overflow:hidden;
  background:#f5f0ea;
  box-shadow:0 0 0 1px rgba(80,70,60,.05)
}

/* Header */
.kslp-header{
  position:relative;
  z-index:20;
  min-height:82px;
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  background:rgba(255,255,255,.97);
  backdrop-filter:blur(12px);
  border-bottom:1px solid #eee8e2
}

.kslp-heading{min-width:0}

.kslp-kicker{
  display:block;
  margin-bottom:5px;
  color:#9a9b8f;
  font-size:10px;
  font-weight:700;
  letter-spacing:.24em;
  text-transform:uppercase
}

.kslp-heading h1{
  margin:0;
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;
  font:500 19px/1.15 Georgia,serif
}

/* Device picker */
.kslp-devices{
  display:flex;
  align-items:center;
  gap:2px;
  padding:4px;
  border-radius:999px;
  background:#f3f2ef;
  box-shadow:inset 0 0 0 1px rgba(50,45,40,.025)
}

.kslp-devices button{
  width:48px;
  height:44px;
  padding:0;
  border:0;
  border-radius:999px;
  background:transparent;
  color:#777c78;
  display:grid;
  place-items:center;
  cursor:pointer;
  transition:.18s ease
}

.kslp-devices button:hover{color:#1d211e}

.kslp-devices button.active{
  background:#fff;
  color:#202421;
  box-shadow:0 2px 8px rgba(43,39,35,.13),0 0 0 1px rgba(43,39,35,.06)
}

.kslp-devices svg{
  width:20px;
  height:20px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.65;
  stroke-linecap:round;
  stroke-linejoin:round
}

/* Main preview area */
.kslp-main{
  min-width:0;
  min-height:0;
  padding:24px;
  overflow:hidden;
  background:#f5f0ea
}

.kslp-preview-area{
  position:relative;
  width:100%;
  height:100%;
  min-width:0;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden
}

/*
 * Shell always fits completely inside the available stage.
 * The iframe keeps the actual virtual device viewport and is scaled visually.
 */
.kslp-device-shell{
  position:relative;
  flex:0 0 auto;
  overflow:hidden;
  background:#fff;
  box-shadow:0 14px 34px rgba(66,52,42,.18);
  transition:width .22s ease,height .22s ease,border-radius .22s ease
}

.kslp-viewport{
  position:absolute;
  left:0;
  top:0;
  transform-origin:0 0;
  will-change:transform;
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden
}

.kslp-viewport iframe{
  display:block!important;
  width:100%!important;
  height:100%!important;
  min-width:100%!important;
  min-height:100%!important;
  margin:0!important;
  padding:0!important;
  border:0!important;
  background:#fff;
  pointer-events:auto!important;
  touch-action:auto!important
}

/* Footer is a real grid row, never overlays the device preview. */
.kslp-footer{
  position:relative;
  z-index:20;
  min-height:76px;
  padding:10px 14px;
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  align-items:center;
  gap:16px;
  background:#fff;
  border-top:1px solid #ebe7e2
}

.kslp-back{
  height:44px;
  padding:0 13px;
  border:0;
  border-radius:10px;
  background:#f5f4f2;
  color:#424844;
  display:inline-flex;
  align-items:center;
  gap:7px;
  font-weight:700;
  cursor:pointer
}

.kslp-back svg{
  width:18px;
  height:18px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round
}

.kslp-promo{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#676b68;
  font-size:12px;
  text-align:center
}

.kslp-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px
}

.kslp-open,
.kslp-cta{
  min-height:44px;
  padding:0 15px;
  border-radius:10px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none!important;
  font-size:13px;
  font-weight:750;
  white-space:nowrap
}

.kslp-open{
  background:#f3f2ef;
  color:#343936
}

.kslp-cta{
  background:var(--cta-bg,#25D366);
  color:var(--cta-color,#07180e)!important;
  font-family:var(--cta-font,system-ui);
  font-size:var(--cta-size,13px);
  font-weight:var(--cta-weight,800)
}

/* Loading veil prevents a flash while the real page initializes. */
.kslp-loading{
  position:absolute;
  inset:0;
  z-index:5;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#f5f0ea;
  opacity:1;
  visibility:visible;
  transition:opacity .25s ease,visibility .25s ease
}

.kslp-loading.is-hidden{
  opacity:0;
  visibility:hidden;
  pointer-events:none
}

.kslp-loading-dot{
  width:24px;
  height:24px;
  border:2px solid rgba(38,34,31,.15);
  border-top-color:#4f514d;
  border-radius:50%;
  animation:kslpSpin .75s linear infinite
}

@keyframes kslpSpin{to{transform:rotate(360deg)}}

@media(max-width:767px){
  html,body{background:#f5f0ea}

  .kslp-app{
    width:100%;
    box-shadow:none
  }

  .kslp-header{
    min-height:70px;
    padding:
      max(9px,env(safe-area-inset-top))
      16px
      9px
  }

  .kslp-heading h1{font-size:17px}
  .kslp-kicker{font-size:9px}

  .kslp-devices button{
    width:43px;
    height:40px
  }

  .kslp-devices svg{
    width:18px;
    height:18px
  }

  .kslp-main{
    padding:18px 14px
  }

  .kslp-footer{
    min-height:62px;
    grid-template-columns:auto minmax(0,1fr);
    gap:9px;
    padding:
      8px
      max(10px,env(safe-area-inset-right))
      calc(8px + env(safe-area-inset-bottom))
      max(10px,env(safe-area-inset-left))
  }

  .kslp-back{
    width:42px;
    height:42px;
    padding:0;
    justify-content:center
  }

  .kslp-back span,
  .kslp-promo{
    display:none
  }

  .kslp-actions{
    min-width:0;
    gap:7px
  }

  .kslp-open{display:none}

  .kslp-cta{
    max-width:100%;
    min-width:0;
    overflow:hidden;
    text-overflow:ellipsis;
    padding:0 12px
  }
}
