*{box-sizing:border-box;margin:0;padding:0}
:root{
  --bg:#07090e;
  --surface:#0e121d;
  --panel:#121624;
  --panel-border:rgba(255,255,255,0.08);
  --gold:#e2b95e;
  --gold-light:#f4d58d;
  --gold-dark:#b88e36;
  --cream:#f6ecd9;
  --muted:#8e98a8;
  --subtle:#566173;
}
html{color-scheme:dark;height:100%;height:100dvh;overflow:hidden}
body{
  background:var(--bg);
  color:var(--cream);
  font-family:Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  height:100%;
  height:100dvh;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  user-select:none;
}

/* Common Screen Styles */
.screen{
  height:100%;
  height:100dvh;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  overflow:hidden;
  position:relative;
  width:100%;
  max-width:440px;
  margin:0 auto;
}
.hidden{display:none!important}

/* Top Navbars */
.top-nav{
  height:46px;
  min-height:46px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 14px;
  border-bottom:1px solid rgba(255,255,255,0.06);
  background:var(--bg);
  z-index:10;
}
.nav-title{
  font-size:15px;
  font-weight:700;
  letter-spacing:.02em;
  color:var(--cream);
  text-align:center;
}
.nav-btn{
  background:none;
  border:none;
  color:var(--cream);
  cursor:pointer;
  padding:6px;
  border-radius:8px;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:all .15s;
}
.nav-btn:hover{color:var(--gold-light)}
.nav-placeholder{width:32px}

.btn-use-photo{
  background:var(--gold);
  color:#07090e;
  border:none;
  border-radius:20px;
  font-weight:700;
  font-size:12px;
  letter-spacing:.02em;
  padding:7px 15px;
  cursor:pointer;
  box-shadow:0 2px 10px rgba(226,185,94,0.35);
  transition:all .15s;
}
.btn-use-photo:hover{filter:brightness(1.08)}
.btn-use-photo:active{transform:scale(0.97)}

/* ===================================================
   SCREEN 1: LANDING VIEW
   =================================================== */
.view-landing .landing-content{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:space-between;
  padding:10px 18px max(14px, env(safe-area-inset-bottom));
  text-align:center;
  gap:8px;
  overflow-y:auto;
  scrollbar-width:none;
}
.view-landing .landing-content::-webkit-scrollbar{display:none}

.sample-card{
  width:100%;
  max-width:180px;
  aspect-ratio:1;
  border-radius:20px;
  overflow:hidden;
  border:1px solid rgba(226,185,94,0.35);
  box-shadow:0 8px 30px rgba(0,0,0,0.6), 0 0 20px rgba(226,185,94,0.1);
  display:flex;
  align-items:center;
  justify-content:center;
  background:#0d101a;
  flex-shrink:0;
}
.sample-img-container{width:100%;height:100%;display:flex}
.sample-svg{width:100%;height:100%;display:block}

.landing-text{display:flex;flex-direction:column;gap:4px;flex-shrink:0}
.landing-headline{
  font-family:'Playfair Display',Georgia,serif;
  font-size:18px;
  font-weight:800;
  line-height:1.25;
  color:var(--cream);
}
.gold-gradient-text{
  background:linear-gradient(135deg, #fff3cf 0%, var(--gold) 50%, #b88e36 100%);
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
}
.landing-subtitle{
  font-size:11.5px;
  color:var(--muted);
  max-width:290px;
  line-height:1.35;
  margin:0 auto;
}

.features-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  width:100%;
  max-width:340px;
  flex-shrink:0;
}
.feature-card{
  display:flex;
  align-items:center;
  gap:8px;
  background:rgba(18,22,36,0.7);
  border:1px solid rgba(255,255,255,0.06);
  border-radius:10px;
  padding:8px 10px;
  text-align:left;
  font-size:10px;
  color:var(--muted);
  line-height:1.25;
}
.feature-icon{color:var(--gold);flex-shrink:0;display:flex}

.upload-box{
  width:100%;
  max-width:340px;
  border:1.5px dashed rgba(226,185,94,0.4);
  border-radius:16px;
  background:radial-gradient(circle at center, rgba(18,22,36,0.85), rgba(9,12,20,0.95));
  padding:14px 16px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:4px;
  cursor:pointer;
  transition:border-color .2s;
  flex-shrink:0;
}
.upload-box:hover{border-color:var(--gold)}
.upload-icon{color:var(--gold);margin-bottom:2px}
.upload-title{font-size:13px;color:var(--cream);font-weight:700}
.upload-desc{font-size:10.5px;color:var(--muted)}
.btn-choose{
  background:#181f2f;
  color:var(--gold-light);
  border:1px solid rgba(226,185,94,0.35);
  border-radius:18px;
  font-size:12px;
  font-weight:700;
  padding:6px 18px;
  margin-top:6px;
  cursor:pointer;
  transition:all .15s;
}
.btn-choose:hover{
  background:rgba(226,185,94,0.15);
  border-color:var(--gold);
}

.landing-footnote{
  font-size:9.5px;
  color:var(--subtle);
  max-width:300px;
  line-height:1.3;
  flex-shrink:0;
}
.btn-dismiss{
  background:none;
  border:none;
  font-size:11px;
  color:var(--muted);
  cursor:pointer;
  text-decoration:underline;
  text-underline-offset:3px;
  flex-shrink:0;
}
.btn-dismiss:hover{color:var(--gold-light)}

/* ===================================================
   SCREEN 2: EDITOR VIEW
   =================================================== */
.view-editor{position:relative}
.editor-viewport{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  position:relative;
  padding:6px 14px;
}
.canvas-stage{
  position:relative;
  width:100%;
  max-width:360px;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:0;
}
.canvas-container{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  max-width:100%;
  max-height:100%;
}
canvas#cv{
  display:block;
  max-width:100%;
  max-height:100%;
  width:auto;
  height:auto;
  aspect-ratio:1;
  border-radius:18px;
  border:1px solid rgba(255,255,255,0.08);
  background:#07090e;
  box-shadow:0 8px 32px rgba(0,0,0,0.65), 0 0 20px rgba(226,185,94,0.04);
  touch-action:none;
  object-fit:contain;
}

/* Crop Active State: Canvas displays full photo without any letterbox black bars */
.canvas-stage.crop-active canvas#cv {
  aspect-ratio: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  width: auto !important;
  height: auto !important;
  border-radius: 4px !important;
  background: transparent !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
}

/* Windows-style Interactive Crop Overlay */
.windows-crop-overlay{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  pointer-events:none;
  z-index:15;
  border-radius:18px;
  overflow:hidden;
  touch-action:none;
}
.canvas-stage.crop-active .windows-crop-overlay {
  border-radius: 4px !important;
}
.windows-crop-overlay.hidden{display:none}

.crop-scrim{
  position:absolute;
  background:rgba(0,0,0,0.68);
  pointer-events:none;
}

.crop-box{
  position:absolute;
  box-sizing:border-box;
  border:1.5px solid rgba(255,255,255,0.95);
  box-shadow:0 0 0 1px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(0,0,0,0.25);
  cursor:move;
  pointer-events:auto;
  touch-action:none;
}

/* 3x3 Grid inside crop box */
.crop-grid-line{
  position:absolute;
  background:rgba(255,255,255,0.32);
  pointer-events:none;
}
.crop-grid-h{left:0;right:0;height:1px}
.crop-grid-h1{top:33.33%}
.crop-grid-h2{top:66.67%}
.crop-grid-v{top:0;bottom:0;width:1px}
.crop-grid-v1{left:33.33%}
.crop-grid-v2{left:66.67%}

/* Handles */
.crop-handle{
  position:absolute;
  box-sizing:border-box;
  pointer-events:auto;
  touch-action:none;
  z-index:10;
}
.crop-handle::before{
  content:'';
  position:absolute;
  top:50%;
  left:50%;
  transform:translate(-50%, -50%);
  width:42px;
  height:42px;
}

/* Corner Handles: Windows Photos L-brackets */
.handle-corner{
  width:20px;
  height:20px;
}
.handle-nw{
  top:-3px;
  left:-3px;
  border-top:3.5px solid #ffffff;
  border-left:3.5px solid #ffffff;
  cursor:nwse-resize;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,0.85));
}
.handle-ne{
  top:-3px;
  right:-3px;
  border-top:3.5px solid #ffffff;
  border-right:3.5px solid #ffffff;
  cursor:nesw-resize;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,0.85));
}
.handle-sw{
  bottom:-3px;
  left:-3px;
  border-bottom:3.5px solid #ffffff;
  border-left:3.5px solid #ffffff;
  cursor:nesw-resize;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,0.85));
}
.handle-se{
  bottom:-3px;
  right:-3px;
  border-bottom:3.5px solid #ffffff;
  border-right:3.5px solid #ffffff;
  cursor:nwse-resize;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,0.85));
}

/* Edge Handles: Midpoint bars */
.handle-edge{
  background:#ffffff;
  border-radius:2px;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,0.85));
}
.handle-n{
  top:-3px;
  left:50%;
  transform:translateX(-50%);
  width:26px;
  height:4px;
  cursor:ns-resize;
}
.handle-s{
  bottom:-3px;
  left:50%;
  transform:translateX(-50%);
  width:26px;
  height:4px;
  cursor:ns-resize;
}
.handle-w{
  left:-3px;
  top:50%;
  transform:translateY(-50%);
  width:4px;
  height:26px;
  cursor:ew-resize;
}
.handle-e{
  right:-3px;
  top:50%;
  transform:translateY(-50%);
  width:4px;
  height:26px;
  cursor:ew-resize;
}

/* Floating Segmented Pill on Photo */
.photo-styler-pill{
  position:absolute;
  bottom:10px;
  left:50%;
  transform:translateX(-50%);
  display:flex;
  background:rgba(7,9,14,0.85);
  backdrop-filter:blur(12px);
  border:1px solid rgba(255,255,255,0.12);
  border-radius:20px;
  padding:3px;
  gap:2px;
  z-index:10;
  box-shadow:0 4px 16px rgba(0,0,0,0.5);
}
.styler-btn{
  padding:4px 12px;
  font-size:10.5px;
  font-weight:600;
  border-radius:16px;
  border:none;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  transition:all .15s;
}
.styler-btn.active{
  background:var(--gold);
  color:#07090e;
  font-weight:700;
  box-shadow:0 2px 8px rgba(226,185,94,0.3);
}

/* Status text */
#status{
  font-size:11px;
  line-height:1.4;
  margin-top:2px;
  color:var(--gold-light);
  overflow-wrap:anywhere;
  text-align:center;
}
#status.error{color:#ffb2a8}

/* Bottom Navigation / Dock */
.bottom-dock{
  height:64px;
  min-height:64px;
  background:#0c0f18;
  border-top:1px solid rgba(255,255,255,0.07);
  display:flex;
  flex-direction:column;
  justify-content:center;
  position:relative;
  padding-bottom:env(safe-area-inset-bottom);
}
.bottom-dock.expanded-effects,
.bottom-dock.expanded-edit{
  height:122px;
}
.bottom-dock.expanded-slider{
  height:92px;
}
.bottom-dock.expanded-crop{
  height:130px;
}

/* Screen 2: Main Toolbar */
.main-toolbar{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  align-items:center;
  height:100%;
}
.tile-back-btn{
  width:36px;
  height:36px;
  background:#111624;
  border:1px solid rgba(255,255,255,0.06);
  border-radius:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#ffffff;
  cursor:pointer;
  transition:all .15s;
}
.tile-back-btn:hover{background:#181f33;border-color:rgba(226,185,94,0.3)}

.btn-close-gold{
  background:none;
  border:none;
  color:var(--gold);
  padding:6px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:transform .15s;
}
.btn-close-gold:hover{transform:scale(1.1)}

.slider-placeholder{
  width:36px;
  height:36px;
}

.tool-btn{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:5px;
  background:none;
  border:none;
  cursor:pointer;
  padding:2px;
  transition:all .15s;
}
.tool-icon{
  display:flex;
  align-items:center;
  justify-content:center;
  width:44px;
  height:44px;
  background:#131826;
  border:1px solid rgba(255,255,255,0.07);
  border-radius:12px;
  color:var(--gold);
  transition:all .15s;
}
.tool-label{
  font-size:11px;
  font-weight:500;
  color:#7c8599;
  transition:all .15s;
}
.tool-btn:hover .tool-icon,
.tool-btn.active .tool-icon{
  background:rgba(226,185,94,0.15);
  border-color:var(--gold);
  box-shadow:0 0 10px rgba(226,185,94,0.2);
}
.tool-btn:hover .tool-label,
.tool-btn.active .tool-label{
  color:var(--gold);
  font-weight:600;
}

/* ===================================================
   DRAWERS (Screens 3, 4, 5)
   =================================================== */
.drawer{
  position:absolute;
  inset:0;
  background:#0c101a;
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  padding:8px 14px max(8px, env(safe-area-inset-bottom));
  z-index:20;
}

.drawer-handle{
  width:38px;
  height:4px;
  background:#353d52;
  border-radius:2px;
  margin:0 auto 6px;
}

.drawer-action-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  height:40px;
  padding-top:2px;
}
.drawer-title{
  font-size:13px;
  font-weight:500;
  color:#7c8599;
  letter-spacing:.02em;
}
.circle-btn{
  width:42px;
  height:42px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  border:none;
  transition:transform .15s, background .15s;
}
.circle-btn:active{transform:scale(0.92)}
.btn-cancel{
  background:#262d3e;
  color:#9aa3b5;
}
.btn-cancel:hover{background:#303a4f;color:#ffffff}
.btn-confirm{
  background:#f4ecdc;
  color:#11141c;
  box-shadow:0 2px 10px rgba(0,0,0,0.4);
}
.btn-confirm:hover{background:#ffffff;transform:scale(1.05)}

/* Screen 3: Effects Carousel */
.effects-carousel{
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding-bottom:6px;
  scrollbar-width:none;
  -webkit-overflow-scrolling:touch;
}
.effects-carousel::-webkit-scrollbar{display:none}

.effect-card{
  flex:0 0 72px;
  height:58px;
  background:#10141f;
  border:1px solid rgba(255,255,255,0.06);
  border-radius:10px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:4px;
  cursor:pointer;
  transition:all .15s;
}
.effect-card.active{
  border:1.5px solid var(--gold);
  background:#151822;
  box-shadow:0 0 12px rgba(226,185,94,0.18);
}
.effect-icon{display:flex;align-items:center;justify-content:center}
.effect-name{
  font-size:10px;
  font-weight:500;
  color:#7c8599;
  text-align:center;
}
.effect-card.active .effect-name{
  color:#ffffff;
  font-weight:600;
}

/* Screen 4: Edit Menu */
.edit-tools-row{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:4px;
  margin:4px 0 6px;
  align-items:center;
}
.edit-tool-item{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  background:none;
  border:none;
  cursor:pointer;
  padding:2px;
}
.edit-tool-label{
  font-size:10.5px;
  font-weight:500;
  color:#7c8599;
  text-align:center;
  white-space:nowrap;
}
.edit-tool-icon{
  width:36px;
  height:36px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:var(--gold);
  transition:transform .15s;
}
.edit-tool-item:hover .edit-tool-icon,
.edit-tool-item.active .edit-tool-icon{
  transform:scale(1.1);
  filter:drop-shadow(0 0 8px rgba(226,185,94,0.45));
}
.edit-tool-item:hover .edit-tool-label{
  color:var(--gold-light);
}

.edit-toggles-row{
  display:flex;
  justify-content:space-around;
  font-size:10.5px;
  color:var(--muted);
  margin-top:2px;
}
.compact-toggle{
  display:flex;
  align-items:center;
  gap:6px;
  cursor:pointer;
  user-select:none;
}
.compact-toggle input{
  accent-color:var(--gold);
  width:14px;
  height:14px;
}

/* Screen 5: Slider Drawer */
.slider-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
  padding:0 2px;
}
.slider-title{
  font-size:14px;
  font-weight:600;
  color:#ffffff;
  text-align:center;
}

.figma-slider{
  -webkit-appearance:none;
  appearance:none;
  width:100%;
  height:3px;
  border-radius:2px;
  background:linear-gradient(to right, var(--gold) 0%, var(--gold) var(--val-pct, 50%), #252d3d var(--val-pct, 50%), #252d3d 100%);
  outline:none;
  cursor:pointer;
  margin:14px 0;
}
.figma-slider::-webkit-slider-thumb{
  -webkit-appearance:none;
  appearance:none;
  width:22px;
  height:22px;
  border-radius:50%;
  background:var(--gold);
  border:none;
  cursor:pointer;
  box-shadow:0 0 10px rgba(226,185,94,0.45);
}
.figma-slider::-moz-range-thumb{
  width:22px;
  height:22px;
  border-radius:50%;
  background:var(--gold);
  border:none;
  cursor:pointer;
  box-shadow:0 0 10px rgba(226,185,94,0.45);
}

/* Crop Multi-Slider */
.crop-controls-box{
  display:flex;
  flex-direction:column;
  gap:4px;
}
.slider-row{
  display:flex;
  align-items:center;
  gap:8px;
}
.row-label{
  font-family:"DM Mono",monospace;
  font-size:9.5px;
  color:var(--muted);
  width:50px;
  flex-shrink:0;
}
.row-val{
  font-family:"DM Mono",monospace;
  font-size:10px;
  color:var(--gold-light);
  min-width:32px;
  text-align:right;
  flex-shrink:0;
}
.pan-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}
.pan-grid .row-label{width:36px}
.btn-reset-crop{
  background:none;
  border:none;
  color:var(--gold);
  font-family:"DM Mono",monospace;
  font-size:9.5px;
  cursor:pointer;
  padding:2px;
  text-align:right;
}
.btn-reset-crop:hover{text-decoration:underline}

/* Windows Crop Drawer */
.drawer-crop{
  gap:8px;
}
.crop-drawer-toolbar{
  display:flex;
  flex-direction:column;
  gap:7px;
  width:100%;
}
.crop-aspect-pills{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  overflow-x:auto;
  scrollbar-width:none;
  padding:1px 0;
}
.crop-aspect-pills::-webkit-scrollbar{display:none}
.aspect-pill{
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.1);
  border-radius:12px;
  color:var(--muted);
  font-size:10.5px;
  font-weight:500;
  padding:3px 9px;
  cursor:pointer;
  white-space:nowrap;
  transition:all .15s;
}
.aspect-pill:hover, .aspect-pill.active{
  background:rgba(226,185,94,0.16);
  border-color:var(--gold);
  color:var(--gold-light);
}
.crop-actions-mini{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
}
.crop-mini-btn{
  display:flex;
  align-items:center;
  gap:5px;
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.08);
  border-radius:7px;
  color:var(--cream);
  font-size:10.5px;
  padding:3px 10px;
  cursor:pointer;
  transition:all .15s;
}
.crop-mini-btn:hover{
  background:rgba(255,255,255,0.12);
  color:var(--gold-light);
}

@media(min-width:760px){
  .screen{max-width:960px}
  .view-landing .landing-content{
    max-width:440px;
    margin:0 auto;
    width:100%;
  }
  .view-editor{
    display:grid;
    grid-template-rows:46px 1fr 64px;
  }
  .bottom-dock.expanded-effects,
  .bottom-dock.expanded-edit{
    height:120px;
  }
}
