:root{
  --blue:#3e98bb;

  --bg:#0f1115;
  --panel: rgba(0,0,0,.22);
  --panel2: rgba(255,255,255,.06);
  --stroke: rgba(255,255,255,.12);

  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.64);

  --r: 16px;
  --shadow: 0 18px 60px rgba(0,0,0,.45);

  --pad: 12px;
  --gap: 12px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  overflow:hidden; /* ✅ page scroll OFF */
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color: var(--text);
  background:
    radial-gradient(900px 650px at 20% 10%, rgba(62,152,187,.18), transparent 60%),
    radial-gradient(900px 650px at 80% 30%, rgba(62,152,187,.10), transparent 60%),
    var(--bg);
}

/* Header */
.topbar{
  height:56px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 var(--pad);
  border-bottom: 1px solid var(--stroke);
  background: var(--blue);
}
.brand{ font-weight:900; letter-spacing:.2px; color:#fff; }
.badge{
  font-size:12px;
  font-weight:900;
  padding:5px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.28);
  background: rgba(0,0,0,.18);
  color:#fff;
}
.topbar-left{ display:flex; align-items:center; gap:10px; }

/* Layout: ✅ single source of truth (FLEX) */
.layout{
  height: calc(100vh - 56px);
  display:flex;
  gap: var(--gap);
  padding: var(--pad);
  overflow:hidden;
}

/* Sidebar */
.sidebar{
  width: 380px;
  min-width: 330px;

  border:1px solid var(--stroke);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow:hidden;

  display:flex;
  flex-direction:column;
  min-height:0;

  background: linear-gradient(180deg, rgba(62,152,187,.12) 0%, rgba(0,0,0,.22) 45%, rgba(0,0,0,.34) 100%);
}

.side-actions{
  padding: var(--pad);
  display:flex;
  gap:10px;
  border-bottom: 1px solid var(--stroke);
}

.tabs{
  padding: 10px var(--pad);
  display:grid;
  gap:10px;
  border-bottom: 1px solid var(--stroke);
}

/* 5 tabs */
.tabs-5 { grid-template-columns: repeat(5, 1fr); }

.tab{
  border:1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.18);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 10px;
  font-weight: 900;
  cursor:pointer;
  white-space:nowrap;
}
.tab.active{
  border-color: rgba(255,255,255,.35);
  background: rgba(255,255,255,.14);
}

.tab-panel{
  display:none;
  padding: var(--pad);
  overflow:auto;   /* ✅ only panel scroll */
  min-height:0;    /* ✅ flex scroll fix */
}
.tab-panel.active{ display:block; }

/* Card system */
.card{
  border:1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.22);
  border-radius: var(--r);
  padding: var(--pad);
  margin-bottom: var(--gap);
}
.card-tight{ padding: 10px; }

.card-title{
  font-weight:900;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.7px;
  color: var(--muted);
}
.card-sub{ color: var(--muted); font-size:12px; font-weight:700; line-height:1.35; }

.sp-10{ height:10px; }
.sp-12{ height:12px; }

.search{
  width:100%;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 12px;
  outline:none;
  font-weight: 900;
}
.search::placeholder{ color: rgba(255,255,255,.45); }

/* Buttons */
.btn{
  border:1px solid rgba(255,255,255,.18);
  background: rgba(0,0,0,.18);
  color:#fff;
  border-radius: 999px;
  padding: 10px 12px;
  font-weight: 900;
  font-size: 12px;
  cursor:pointer;
  transition: transform .12s ease, background .12s ease;
}
.btn:hover{ transform: translateY(-1px); background: rgba(255,255,255,.10); }

.btn-primary{
  border-color: rgba(255,255,255,.35);
  background: rgba(0,0,0,.18);
  box-shadow: 0 0 0 2px rgba(255,255,255,.08) inset;
}
.btn-primary:hover{ background: rgba(0,0,0,.24); }

.btn-soft{
  border-color: rgba(62,152,187,.50);
  background: rgba(62,152,187,.22);
}
.btn-soft:hover{ background: rgba(62,152,187,.30); }

.btn-danger{
  border-color: rgba(255,59,48,.55);
  background: rgba(255,59,48,.18);
}
.w-full{ width:100%; }

/* Grid items */
.categories{ padding-top: 4px; }
.cat{ margin-bottom: 14px; }
.cat-title{
  font-weight: 900;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .7px;
  margin: 6px 0 10px;
}

.grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap:10px; }
.online-grid{ grid-template-columns: repeat(2, 1fr); }

.item{
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  border-radius: 14px;
  padding: 10px;
  cursor: grab;
  user-select:none;
  transition: transform .12s ease, background .12s ease;
}
.item:hover{ transform: translateY(-2px); background: rgba(255,255,255,.10); }
.item img{ width:100%; height: 96px; object-fit:contain; display:block; }
.item .name{ margin-top:8px; text-align:center; font-size:12px; font-weight:900; }

/* Form controls */
.form-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.field{ font-size:12px; font-weight:900; color: var(--muted); }
.field.full{ grid-column:1 / -1; }
.control{
  width:100%;
  margin-top:6px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 12px;
  outline:none;
  font-weight:900;
}
.color{
  width:100%;
  height: 40px;
  margin-top:6px;
  border:1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.06);
  border-radius: 12px;
  padding:0;
}

/* ✅ Text tab: stack vertically (looks like other cards) */
#tab-text .form-grid{
  grid-template-columns: 1fr;
  gap: 12px;
}
#tab-text .field.full{ grid-column:auto; }

/* Toggle buttons */
.toggle{ display:flex; gap:10px; }
.toggle-btn{
  flex:1;
  border:1px solid rgba(62,152,187,.45);
  background: rgba(62,152,187,.16);
  color:#fff;
  border-radius: 999px;
  padding: 10px 12px;
  font-weight: 900;
  cursor:pointer;
}
.toggle-btn.active{
  background: rgba(62,152,187,.30);
  border-color: rgba(62,152,187,.70);
}

/* Upload: dropzone */
.dropzone{
  border: 1.5px dashed rgba(62,152,187,.55);
  background: rgba(62,152,187,.10);
  border-radius: 18px;
  padding: 14px;
  display:flex;
  align-items:center;
  gap:12px;
  cursor:pointer;
  outline:none;
}
.dropzone:hover{ background: rgba(62,152,187,.14); }
.dz-icon{
  width:40px; height:40px; border-radius: 14px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(0,0,0,.20);
  border:1px solid rgba(255,255,255,.12);
}
.dz-text{ flex:1; }
.dz-head{ font-weight:900; }
.dz-sub{ font-size:12px; color: var(--muted); font-weight:700; margin-top:2px; }
.dz-btn{ white-space:nowrap; }
.file-hidden{ display:none; }

/* Workspace */
.workspace{
  flex: 1;
  min-width: 0;

  border:1px solid rgba(255,255,255,.12);
  border-radius: var(--r);
  background: rgba(0,0,0,.18);
  box-shadow: var(--shadow);
  overflow:hidden;

  display:flex;
}
.work-inner{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: var(--pad);
}
.canvas-card{
  width: 100%;
  height: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  border:1px solid rgba(255,255,255,.10);
  border-radius: 20px;
  background: rgba(0,0,0,.12);
  padding: 12px;
}
.canvas-area{
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: #ffffff;
  overflow:hidden;
  display:flex;
  align-items:center;
  justify-content:center;
}
#c{ display:block; }

/* Right tools (wider, scroll inside) */
.tools{
  width: 320px;
  min-width: 280px;

  border:1px solid rgba(255,255,255,.12);
  border-radius: var(--r);
  background: rgba(0,0,0,.18);
  box-shadow: var(--shadow);
  overflow:auto;
}
.toolbox{ padding: 10px; display:flex; flex-direction:column; gap:8px; }
.toolbox-title{
  font-size:11px;
  font-weight:900;
  color: var(--muted);
  text-transform:uppercase;
  letter-spacing:.7px;
  margin-top: 2px;
}
.sep{ height:1px; background: rgba(255,255,255,.10); margin: 6px 0; }
.tbtn{
  border:1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 8px;
  font-weight:900;
  cursor:pointer;
}
.tbtn:hover{ background: rgba(255,255,255,.10); }

/* ✅ Layers list: dark theme */
.layers{ display:flex; flex-direction:column; gap:10px; }
.layer-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  cursor:pointer;
}
.layer-row.is-active{
  border-color: rgba(62,152,187,.65);
  box-shadow: 0 0 0 3px rgba(62,152,187,.15);
}
.layer-row.is-over{ outline:2px dashed rgba(62,152,187,.55); }
.layer-thumb{
  width:44px; height:44px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.20);
  object-fit:cover;
}
.layer-name{ font-weight:900; font-size:13px; color: var(--text); }

/* Responsive */
@media (max-width: 1100px){
  .sidebar{ width: 340px; }
  .tools{ width: 280px; }
}
@media (max-width: 900px){
  body{ overflow:auto; } /* mobile: allow scroll */
  .layout{
    height: auto;
    min-height: calc(100vh - 56px);
    flex-direction: column;
    overflow: visible;
  }
  .sidebar, .tools{ width: 100%; min-width: 0; }
  .workspace{ min-height: 60vh; }
}
.row-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
