:root{
  --bg:#061827;
  --bg2:#08233a;
  --panel:#0c2945;
  --panel2:#103452;
  --text:#f7fbff;
  --muted:#b9ccda;
  --accent:#f05a13;
  --accent2:#ff7a2f;
  --line:rgba(255,255,255,.11);
  --line2:rgba(255,255,255,.18);
  --shadow:0 18px 48px rgba(0,0,0,.26);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}
body{
  margin:0;
  min-width:0;
  min-height:100vh;
  overflow-x:hidden;
  font-family:Tahoma,"Segoe UI",Arial,sans-serif;
  color:var(--text);
  background:
    radial-gradient(circle at 10% 0,rgba(21,80,124,.42),transparent 30%),
    radial-gradient(circle at 92% 8%,rgba(240,90,19,.08),transparent 20%),
    linear-gradient(180deg,var(--bg),var(--bg2) 58%,var(--bg));
}
button,input,label{font:inherit}
img{max-width:100%}
.topbar{position:sticky;top:0;z-index:50;background:rgba(5,22,37,.88);backdrop-filter:blur(14px);border-bottom:1px solid var(--line)}
.topbar-inner,.page,footer{width:min(1180px,calc(100% - 32px));margin-inline:auto}
.topbar-inner{height:72px;display:flex;align-items:center;justify-content:space-between;gap:16px}
.brand{display:flex;align-items:center;gap:12px;color:inherit;text-decoration:none;min-width:0}
.brand-logo-wrap{width:74px;height:48px;border:1px solid var(--line2);border-radius:13px;overflow:hidden;display:grid;place-items:center;background:#174f7d;flex:0 0 auto}
.brand-logo{width:100%;height:100%;object-fit:cover;display:block}
.brand-copy{min-width:0}
.brand-copy strong,.brand-copy small{display:block}
.brand-copy strong{font-size:20px;line-height:1.15}
.brand-copy small{font-size:12px;color:var(--muted);margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:340px}
.occasion-chip{padding:8px 13px;border-radius:999px;border:1px solid rgba(255,122,47,.34);background:rgba(240,90,19,.12);color:#ffd8c4;font-weight:800;font-size:12px;white-space:nowrap}
.page{padding-top:32px;padding-bottom:52px}
.hero{text-align:center;max-width:850px;margin:0 auto 28px}
.eyebrow{display:inline-block;padding:7px 13px;border-radius:999px;border:1px solid rgba(255,122,47,.30);background:rgba(240,90,19,.11);color:#ffd8c4;font-size:12px;font-weight:800}
.hero h1{font-size:clamp(30px,4.3vw,50px);line-height:1.2;margin:14px 0 10px;letter-spacing:-.2px}
.hero p{margin:0 auto;color:var(--muted);font-size:15px;line-height:1.9;max-width:760px}
.workspace{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:22px;align-items:start}
.canvas-card,.controls{border:1px solid var(--line);background:linear-gradient(180deg,rgba(16,53,83,.94),rgba(8,35,58,.97));border-radius:22px;box-shadow:var(--shadow)}
.canvas-card{padding:16px;min-width:0}
.section-head{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:2px 2px 14px;border-bottom:1px solid var(--line);margin-bottom:14px}
.section-head strong,.section-head span{display:block}
.section-head strong{font-size:16px;margin-bottom:5px}
.section-head .desktop-help,.section-head .mobile-help{font-size:12px;color:var(--muted)}
.mobile-help{display:none!important}
.status-dot{font-size:11px!important;color:#cde9d7!important;background:rgba(76,175,80,.09);border:1px solid rgba(76,175,80,.24);border-radius:999px;padding:7px 10px;white-space:nowrap}
.canvas-shell{display:flex;justify-content:center;min-width:0}
.canvas-wrap{position:relative;width:min(100%,760px);aspect-ratio:1/1;border-radius:18px;overflow:hidden;background:#123552;touch-action:none;user-select:none;-webkit-user-select:none;overscroll-behavior:contain}
.canvas-wrap canvas{display:block;width:100%;height:100%;touch-action:none}
.empty-state{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:7px;background:rgba(4,24,40,.42);backdrop-filter:blur(2px);pointer-events:none;text-align:center;padding:20px}
.empty-state.hidden{display:none}
.upload-icon{width:56px;height:56px;border-radius:17px;display:grid;place-items:center;background:rgba(255,255,255,.1);border:1px dashed rgba(255,255,255,.38);font-size:32px}
.empty-state strong{font-size:16px}
.empty-state small{color:var(--muted);font-size:11px}
.mobile-gesture-note{display:none}
.controls{padding:20px;position:sticky;top:92px}
.panel-title{padding-bottom:14px;margin-bottom:16px;border-bottom:1px solid var(--line)}
.panel-title strong,.panel-title span{display:block}
.panel-title strong{font-size:18px;margin-bottom:5px}
.panel-title span{font-size:12.5px;color:var(--muted);line-height:1.75}
.upload-btn,.controls button{width:100%;min-height:48px;border:0;border-radius:14px;font-weight:800;font-size:14px;display:grid;place-items:center;cursor:pointer;transition:transform .18s ease,opacity .18s ease}
.upload-btn{background:linear-gradient(135deg,var(--accent2),var(--accent));color:white;box-shadow:0 10px 22px rgba(240,90,19,.22)}
.upload-btn:hover,.controls button:hover:not(:disabled){transform:translateY(-1px)}
.control-group{margin:20px 0}
.control-label{display:flex;align-items:center;justify-content:space-between;color:var(--muted);font-size:12.5px;margin-bottom:10px}
.control-label output{color:var(--text);font-weight:800}
.control-group input{width:100%;accent-color:var(--accent)}
.button-row{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.primary{background:white;color:#0a2943}
.secondary,.share{background:rgba(255,255,255,.06);color:white;border:1px solid var(--line2)!important}
.share{margin-top:9px}
.controls button:disabled{opacity:.42;cursor:not-allowed;transform:none}
.privacy-card{margin-top:14px;padding:13px 14px;border-radius:15px;background:rgba(255,255,255,.04);border:1px solid var(--line)}
.privacy-card strong,.privacy-card span{display:block}
.privacy-card strong{font-size:12.5px;margin-bottom:5px}
.privacy-card span{font-size:11px;line-height:1.7;color:var(--muted)}
footer{text-align:center;color:#8eacbf;font-size:11.5px;padding:0 0 30px}

@media(max-width:900px){
  .workspace{grid-template-columns:1fr}
  .canvas-card{order:1}
  .controls{order:2;position:static}
  .canvas-wrap{width:min(100%,680px)}
}

@media(max-width:600px){
  .topbar-inner,.page,footer{width:min(100% - 24px,1180px)}
  .topbar-inner{height:62px;gap:10px}
  .brand{gap:9px;min-width:0}
  .brand-logo-wrap{width:62px;height:40px;border-radius:10px}
  .brand-copy strong{font-size:17px}
  .brand-copy small{font-size:10.5px;max-width:180px}
  .occasion-chip{padding:6px 9px;font-size:10.5px}
  .page{padding-top:20px;padding-bottom:34px}
  .hero{margin-bottom:18px}
  .eyebrow{font-size:10.5px;padding:6px 10px}
  .hero h1{font-size:clamp(25px,8vw,34px);line-height:1.22;margin:11px 0 8px}
  .hero p{font-size:12.5px;line-height:1.75;max-width:92%}
  .desktop-break{display:none}
  .canvas-card{padding:10px;border-radius:17px}
  .section-head{padding:2px 2px 10px;margin-bottom:10px;align-items:flex-start}
  .section-head strong{font-size:14px}
  .desktop-help{display:none!important}
  .mobile-help{display:block!important;font-size:10.5px!important;line-height:1.55}
  .status-dot{display:none!important}
  .canvas-wrap{width:100%;border-radius:14px}
  .empty-state{gap:6px}
  .upload-icon{width:50px;height:50px;border-radius:15px;font-size:28px}
  .empty-state strong{font-size:14px}
  .empty-state small{font-size:10px}
  .mobile-gesture-note{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;margin:10px 0 1px}
  .mobile-gesture-note span{font-size:10.5px;color:var(--muted);padding:6px 9px;border-radius:999px;background:rgba(255,255,255,.04);border:1px solid var(--line)}
  .controls{padding:14px;border-radius:17px}
  .panel-title{padding-bottom:11px;margin-bottom:12px}
  .panel-title strong{font-size:16px}
  .panel-title span{font-size:11px}
  .upload-btn,.controls button{min-height:46px;font-size:13px;border-radius:13px}
  .control-group{margin:16px 0}
  .button-row{grid-template-columns:1fr 1fr}
}

@media(max-width:340px){
  .brand-copy small{display:none}
  .occasion-chip{font-size:9.5px;padding:5px 7px}
  .hero h1{font-size:25px}
  .button-row{grid-template-columns:1fr}
}

/* Template gallery */
.occasion-link{text-decoration:none}
.templates-main{padding-top:42px}
.templates-hero{text-align:center;max-width:820px;margin:0 auto 38px}
.templates-hero h1{font-size:clamp(30px,4.5vw,52px);line-height:1.2;margin:14px 0 11px}
.templates-hero p{margin:0;color:var(--muted);font-size:15px;line-height:1.9}
.templates-section{margin-top:12px}
.templates-heading{display:flex;align-items:flex-end;justify-content:space-between;gap:20px;margin-bottom:18px}
.templates-heading h2{margin:0 0 7px;font-size:24px}
.templates-heading p{margin:0;color:var(--muted);font-size:13px}
.templates-count{flex:0 0 auto;padding:8px 12px;border-radius:999px;background:rgba(255,255,255,.05);border:1px solid var(--line);color:var(--muted);font-size:12px;font-weight:700}
.templates-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:20px}
.template-card{overflow:hidden;border:1px solid var(--line);border-radius:22px;background:linear-gradient(180deg,rgba(16,53,83,.94),rgba(8,35,58,.97));box-shadow:var(--shadow);transition:transform .2s ease,border-color .2s ease}
.template-card:hover{transform:translateY(-3px);border-color:rgba(255,122,47,.28)}
.template-preview{position:relative;display:block;aspect-ratio:1/1;overflow:hidden;background:#123552}
.template-preview img{width:100%;height:100%;display:block;object-fit:cover;transition:transform .3s ease}
.template-card:hover .template-preview img{transform:scale(1.015)}
.template-badge{position:absolute;top:12px;right:12px;padding:7px 10px;border-radius:999px;background:rgba(6,24,39,.86);border:1px solid rgba(255,255,255,.16);color:#fff;font-size:11px;font-weight:800;backdrop-filter:blur(8px)}
.template-info{padding:17px}
.template-category{display:inline-block;color:#ffd8c4;font-size:11px;font-weight:700;margin-bottom:7px}
.template-info h3{font-size:20px;margin:0 0 8px}
.template-info p{min-height:42px;margin:0 0 16px;color:var(--muted);font-size:12px;line-height:1.75}
.template-use{display:flex;align-items:center;justify-content:center;min-height:46px;border-radius:14px;text-decoration:none;color:#fff;font-size:13px;font-weight:800;background:linear-gradient(135deg,var(--accent2),var(--accent));box-shadow:0 9px 20px rgba(240,90,19,.18)}
.templates-loading,.templates-empty{grid-column:1/-1;padding:38px;text-align:center;border:1px dashed var(--line2);border-radius:20px;color:var(--muted);background:rgba(255,255,255,.025)}
.brand-logo-wrap{background:transparent!important;border-color:transparent!important;overflow:visible!important}
.brand-logo{object-fit:contain!important}

@media(max-width:900px){
  .templates-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:600px){
  .templates-main{padding-top:24px}
  .templates-hero{margin-bottom:24px}
  .templates-hero h1{font-size:30px}
  .templates-hero p{font-size:12.5px}
  .templates-heading{align-items:flex-start;margin-bottom:14px}
  .templates-heading h2{font-size:20px}
  .templates-heading p{font-size:11.5px;line-height:1.6}
  .templates-grid{grid-template-columns:1fr;gap:16px}
  .template-card{border-radius:18px}
  .template-info{padding:15px}
  .template-info h3{font-size:18px}
  .template-info p{min-height:0}
}

/* v7: mobile upload access and safer responsive behavior */
.empty-state{
  pointer-events:auto;
  cursor:pointer;
  color:inherit;
  text-decoration:none;
  -webkit-tap-highlight-color:transparent;
}
.empty-state:focus-visible{
  outline:3px solid rgba(255,122,47,.75);
  outline-offset:-6px;
}
.empty-state:hover .upload-icon,
.empty-state:active .upload-icon{
  transform:scale(1.04);
  border-color:rgba(255,122,47,.7);
  background:rgba(240,90,19,.18);
}
.upload-icon{transition:transform .18s ease,border-color .18s ease,background .18s ease}

@media(max-width:600px){
  .canvas-card{overflow:visible}
  .canvas-wrap{min-height:0}
  .empty-state{padding:16px}
  .empty-state strong{font-size:15px}
  .empty-state small{max-width:230px;line-height:1.6}
  .mobile-gesture-note{margin-bottom:4px}
  .controls{margin-top:0}
}
