:root{
  --ui-border: rgba(255,255,255,0.12);
  --ui-text: #e7ecf5;
  --ui-muted: #b7c2d6;
  --shadow: 0 12px 30px rgba(0,0,0,.35);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;

  --panel-w: 420px;

  --bg-top: #486fa9;
  --bg-mid: #355a8a;
  --bg-bottom: #1e2b41;

  --design-ar: 16 / 9;
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
  margin: 0;
  background: linear-gradient(to bottom, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bottom) 100%);
  color: var(--ui-text);
  font-family: var(--font);
  overflow: hidden;
}

.app{
  height: 100%;
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
}

/* LEFT PANEL */
.panel{
  height: 100%;
  overflow: hidden;
  border-right: 1px solid var(--ui-border);
  background: rgba(10,12,18,0.55);
  backdrop-filter: blur(10px);
}

.panelHeader{
  padding: 18px;
  border-bottom: 1px solid var(--ui-border);
}

.panelHeaderRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel h1{
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.2px;
}

.hint{
  font-size: 12px;
  color: var(--ui-muted);
  line-height: 1.4;
  margin-top: 6px;
}

/* Burger / icon */
.iconBtn{
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.iconBtn:hover{ background: rgba(255,255,255,0.10); }

.burgerLines{
  width: 16px;
  height: 2px;
  background: var(--ui-text);
  position: relative;
}
.burgerLines::before,
.burgerLines::after{
  content: "";
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  background: var(--ui-text);
}
.burgerLines::before{ top: -5px; }
.burgerLines::after{ top: 5px; }

.closeX{ font-size: 20px; line-height: 1; }

/* Account drawer */
.drawer{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1200;
}
.drawer.show{ display:block; }

.drawerBackdrop{
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(3px);
}
.drawerPanel{
  position: absolute;
  top: 0;
  right: 0;
  width: min(360px, 92%);
  height: 100%;
  background: rgba(10,12,18,0.92);
  border-left: 1px solid var(--ui-border);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
}
.drawerHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 12px;
}
.drawerTitle{
  font-size: 15px;
  font-weight: 600;
}

/* Scroll area */
.scroll{
  height: calc(100% - 92px);
  overflow: auto;
  padding: 14px 14px 24px;
}

/* Sections */
.section{
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  background: rgba(8,10,14,0.55);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}

.section h2{
  margin: 0 0 12px 0;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.inlineMeta{
  font-size: 12px;
  color: var(--ui-muted);
  margin-top: 6px;
}

/* details collapse */
.sectionHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.presetsDetails > summary,
details.section > summary{
  list-style: none;
  cursor: pointer;
  outline: none;
}
.presetsDetails > summary::-webkit-details-marker,
details.section > summary::-webkit-details-marker{
  display:none;
}

.sectionToggle{
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 8px 12px;
  min-width: 90px;
  text-align:center;
  user-select:none;
}

.presetsDetails > summary .sectionToggle::after,
details.section > summary .sectionToggle::after{
  content: "Expand";
}
.presetsDetails[open] > summary .sectionToggle::after,
details.section[open] > summary .sectionToggle::after{
  content: "Collapse";
}

/* Form */
.row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.row.one{ grid-template-columns: 1fr; }

label{
  font-size: 12px;
  color: var(--ui-muted);
  margin-bottom: 6px;
  display:block;
}

input[type="text"],
input[type="number"],
select{
  width:100%;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  color: var(--ui-text);
  padding: 10px 12px;
}

input[type="range"]{ width:100%; }

input[type="color"]{
  width:100%;
  height:44px;              /* ensures Box BG and Border Color match */
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  padding: 6px;
}

/* Buttons */
button{
  width:100%;
  border-radius: 16px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  color: var(--ui-text);
  padding: 12px;
  cursor:pointer;
}
button:hover{ background: rgba(255,255,255,0.09); }

button.primary{
  border-color: rgba(106,167,255,0.55);
  background: rgba(106,167,255,0.16);
}
button.primary:hover{ background: rgba(106,167,255,0.24); }

button.danger{
  border-color: rgba(255,120,120,0.45);
  background: rgba(255,120,120,0.12);
}

button.disabled,
button:disabled{
  opacity: 0.55;
  cursor: not-allowed;
}

/* Stage / Canvas */
.stage{
  height: 100%;
  overflow: hidden;
  display:flex;
}

.canvasWrap{
  width: 100%;
  height: 100%;
  padding: 18px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  gap: 12px;
  overflow: hidden;
}

/* -------------------------------------------------------
   DESIGN FRAME (FIXED — NO CLIPPING)
   - We do NOT clip the canvas with border-radius/overflow hidden.
   - We draw the rounded card using ::before/::after.
-------------------------------------------------------- */
.designFrame{
  position: relative;

  /* JS may set exact px width/height. Provide safe defaults. */
  width: 1px;
  height: 1px;

  /* Do NOT clip child drawing */
  overflow: visible;

  /* Visuals are handled by pseudo elements */
  background: transparent;
  border: none;
  border-radius: 0;
}

/* Rounded background behind the canvas */
.designFrame::before{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: rgba(0,0,0,0.25);
  pointer-events: none;
  z-index: 0;
}

/* Rounded border above the canvas */
.designFrame::after{
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  pointer-events: none;
  z-index: 3;
}

#c{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
  background: transparent;

  /* IMPORTANT: do not mask bitmap */
  border-radius: 0 !important;

  z-index: 1;
}

/* Toast */
.toast{
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--ui-border);
  background: rgba(10,12,18,0.85);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.toast.show{ opacity: 1; }

/* Preset grid cards */
.presetGrid{
  display:grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 10px;
}

.presetCard{
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  padding: 10px;
  cursor:pointer;
  display:flex;
  flex-direction: column;
  overflow: hidden;
}
.presetCard:hover{ background: rgba(255,255,255,0.08); }
.presetCard.selected{
  border-color: rgba(106,167,255,0.9);
  box-shadow: 0 0 0 2px rgba(106,167,255,0.35) inset;
}

.presetThumb{
  width:100%;
  aspect-ratio: 16/9;
  border-radius: 12px;
  overflow:hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.25);
  margin-bottom: 8px;
}
.presetThumbImg{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}
.presetName{
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.presetDesc{
  font-size: 12px;
  color: var(--ui-muted);
  line-height: 1.35;
}

/* Modal (paywall) */
.modalMask{
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 1000;
}
.modalMask.show{ display:flex; }

.modal{
  width: min(560px, 92%);
  border-radius: 18px;
  border: 1px solid var(--ui-border);
  background: rgba(10,12,18,0.90);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal header{
  padding: 14px 16px;
  border-bottom: 1px solid var(--ui-border);
}
.modal .body{
  padding: 14px 16px;
  color: var(--ui-muted);
  font-size: 13px;
  line-height: 1.45;
}
.modal .actions{
  padding: 14px 16px;
  border-top: 1px solid var(--ui-border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal .actions .wide{ grid-column: 1 / -1; }

.linkBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  border-radius: 16px;
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.06);
  color: var(--ui-text);
  padding: 12px 12px;
  cursor: pointer;
}
.linkBtn.primary{
  border-color: rgba(106,167,255,0.55);
  background: rgba(106,167,255,0.14);
}

/* Locked overlay (SaaS modal) */
.lockMask{
  position:absolute;
  inset:0;
  border-radius: 18px;
  display:none;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,0.50);
  backdrop-filter: blur(6px);
  z-index: 4; /* above frame border */
}
.lockMask.show{ display:flex; }

.lockCard{
  width: min(880px, 92%);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10,12,18,0.92);
  box-shadow: 0 18px 70px rgba(0,0,0,0.55);
  overflow: hidden;
}

/* Entrance animation */
@keyframes lockIn {
  from { opacity: 0; transform: translateY(16px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.lockEnter{
  animation: lockIn 260ms ease-out both;
}

.lockSplit{
  display:grid;
  grid-template-columns: 1fr 1px 1fr;
}

.lockPane{
  padding: 28px 24px;
  display:flex;
  flex-direction: column;
  justify-content: center;
}

.lockLeft{
  background: linear-gradient(to bottom, rgba(106,167,255,0.18), rgba(106,167,255,0.06));
}

.lockRight{
  background: rgba(255,255,255,0.04);
}

.lockDivider{
  background: rgba(255,255,255,0.12);
}

.lockH{
  margin: 0 0 10px 0;
  font-size: 18px;
}

.lockSub{
  font-size: 13px;
  color: var(--ui-muted);
  margin: 0 0 18px 0;
  line-height: 1.4;
}

button.big{
  padding: 14px;
  font-size: 15px;
}

.subscribeBtn{
  display:block;
  text-align:center;
  text-decoration:none;
  padding: 12px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-weight: 700;
  border: 1px solid rgba(106,167,255,0.55);
  background: rgba(106,167,255,0.18);
  color: var(--ui-text);
}
.subscribeBtn:hover{ background: rgba(106,167,255,0.28); }

.subscribeBtn.secondary{
  border-color: rgba(130,255,170,0.55);
  background: rgba(130,255,170,0.16);
}
.subscribeBtn.secondary:hover{ background: rgba(130,255,170,0.26); }

.lockNote{
  margin-top: 6px;
  font-size: 12px;
  color: var(--ui-muted);
  text-align:center;
}

.lockMicro{
  margin-top: 10px;
  font-size: 12px;
  color: var(--ui-muted);
  text-align:center;
}

.linkLike{
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: rgba(106,167,255,0.95);
  cursor: pointer;
  font-weight: 700;
}
.linkLike:hover{ text-decoration: underline; }

.testimonials{
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.10);
}
.tTitle{
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.80);
  margin-bottom: 8px;
}
.tItem{
  font-size: 12px;
  color: var(--ui-muted);
  line-height: 1.35;
  margin-bottom: 6px;
}

/* Keep these in DOM for JS compatibility but hide visually */
.lockBodyVisuallyHidden{
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.lockDismissHidden{
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Keyboard shortcuts card */
.shortcutsCard{
  width: min(25%, 1400px);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(10,12,18,0.55);
  box-shadow: var(--shadow);
  padding: 14px 14px;
}

.shortcutsTitle{
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  margin-bottom: 10px;
}

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

.scRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.scKey{
  font-size: 12px;
  color: rgba(255,255,255,0.92);
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  white-space: nowrap;
}

.scText{
  font-size: 12px;
  color: var(--ui-muted);
  text-align: right;
}

/* =========================================================
   FULL-SCREEN LOCKED STATE
   Hide left panel when lock overlay is visible
========================================================= */
.app:has(#editorLock.show){
  grid-template-columns: 1fr !important;
}
.app:has(#editorLock.show) .panel{
  display: none !important;
}
.app:has(#editorLock.show) .stage{
  width: 100% !important;
}
.app:has(#editorLock.show) .lockCard{
  width: min(980px, 94%) !important;
}
