:root{
  --site-font: Tahoma, Arial, sans-serif;
  --chat-font: Tahoma, Arial, sans-serif;
}

*{ margin:0; padding:0; box-sizing:border-box; }

body{
  font-family: var(--site-font);
  background:#2b2d31;
  color:#fff;
  padding:20px;
  min-height:100vh;
  display:flex;
  flex-direction:column;
  align-items:center;
}

/* Header */
.logo{
  text-align:center;
  margin:10px 0 18px;
}
.logo-text{
  font-size:72px;
  font-weight:900;
  line-height:1;
}
.subtitle{
  font-size:18px;
  color:#aaa;
  margin-top:10px;
  font-style:italic;
}
.gta-white{ color:#fff; }
.gta-yellow{ color:#f4d03f; font-style:italic; }

/* Controls */
.controls{
  display:flex;
  flex-wrap:wrap;
  gap:16px;
  align-items:center;
  justify-content:center;
  margin-bottom:10px;
}
.control-group{
  display:flex;
  align-items:center;
  gap:10px;
}
.control-group label{
  font-size:14px;
  color:#b5b5b5;
  white-space:nowrap;
}

.size-controls{
  display:flex;
  gap:5px;
  align-items:center;
}
.size-controls button{
  width:35px;
  height:35px;
  border:none;
  border-radius:6px;
  background:#3a3d44;
  color:#fff;
  font-size:18px;
  cursor:pointer;
}
.size-controls input{
  width:70px;
  height:35px;
  border:2px solid #404249;
  border-radius:6px;
  background:#1e1f22;
  color:#fff;
  text-align:center;
}

.font-select{
  height:35px;
  border:2px solid #404249;
  border-radius:6px;
  background:#1e1f22;
  color:#fff;
  padding:0 10px;
}

.color-picker{
  width:55px;
  height:35px;
  border:2px solid #404249;
  border-radius:6px;
  background:#1e1f22;
  cursor:pointer;
}

.color-picker-wrap{
  display:flex;
  gap:8px;
  align-items:center;
}

.save-in-picker{
  height:35px;
  padding:0 12px;
  border:none;
  border-radius:8px;
  background:#5865f2;
  color:#fff;
  font-weight:700;
  cursor:pointer;
}

.bg-label{
  display:flex;
  align-items:center;
  gap:8px;
  cursor:pointer;
}

.link-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height:35px;
  padding:0 14px;
  border-radius:8px;
  background:#3a3d44;
  color:#fff;
  text-decoration:none;
  font-weight:700;
}

/* Helper */
.helper{
  margin:10px 0 14px;
  color:#cfcfcf;
  font-size:14px;
  text-align:center;
  opacity:.9;
  max-width:1100px;
}

/* Editor */
.chat-scope{
  width:min(1100px, 96vw);
}

.editor-box{
  display:flex;
  gap:10px;
  align-items:stretch;
}

.line-select{
  width:26px;
  border:2px solid #404249;
  border-radius:10px;
  background:#1e1f22;
  overflow:hidden;
}
.line-select-inner{
  will-change:transform;
}
.line-check-row{
  display:flex;
  align-items:center;
  justify-content:center;
  height:20px;
}
.line-check{
  width:16px;
  height:16px;
  cursor:pointer;
}
.line-check-row.spacer{
  opacity:0;
  pointer-events:none;
}

textarea{
  flex:1;
  min-height:240px;
  width:100%;
  padding:14px;
  border-radius:12px;
  border:2px solid #404249;
  background:#1e1f22;
  color:#fff;
  outline:none;
  resize:vertical;
  font-family: var(--site-font);
  font-size:16px;
  line-height:20px; /* مهم للـ checkbox alignment */
}

/* Output preview */
.output-box{
  width:min(620px, 96vw);
  margin-top:16px;
  padding:16px;
  border:2px solid #404249;
  border-radius:12px;
  background:#2f3136;

  /* ✅ كان كبير - خليناه أصغر زي الأول */
  min-height:140px;
}

#previewLines{
  font-family: var(--chat-font);
  max-width:100%;
}

/* each original line container */
.chat-line{
  font-family: var(--chat-font);
  margin:0;
  padding:0;
  text-align:left;
  display:block;
  max-width:100%;
}

/* inline span that clones background across wrapped lines */
.chat-span{
  display:inline;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  word-break:break-word;
  padding:0 4px;
  line-height:1.3;
  -webkit-box-decoration-break:clone;
  box-decoration-break:clone;
}

/* Buttons */
.action-buttons{
  width:min(1100px, 96vw);
  margin-top:14px;
  display:flex;
  justify-content:center;
}
.copy-btn{
  height:42px;
  padding:0 22px;
  border:none;
  border-radius:10px;
  background:#5865f2;
  color:#fff;
  font-weight:800;
  cursor:pointer;
}

.download-buttons{
  width:min(1100px, 96vw);
  margin-top:14px;
  display:flex;
  gap:12px;
  justify-content:center;
  flex-wrap:wrap;
}
.download-btn{
  height:50px;
  padding:0 22px;
  border:none;
  border-radius:12px;
  font-size:18px;
  font-weight:900;
  cursor:pointer;
}
.btn-transparent{ background:#2ecc71; color:#000; }
.btn-filled{ background:#5865f2; color:#fff; }

/* Notifications + Footer */
.copied-notification{
  position:fixed;
  bottom:30px;
  left:50%;
  transform:translateX(-50%);
  background:#2ecc71;
  color:#000;
  padding:12px 16px;
  border-radius:10px;
  font-weight:900;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease;
}
.copied-notification.show{ opacity:1; }

.contact-info{
  width:min(1100px, 96vw);
  margin-top:26px;
  padding-top:16px;
  border-top:1px solid #404249;
  text-align:center;
  color:#bdbdbd;
}
.contact-info .credit{
  margin-top:8px;
  color:#f4d03f;
  font-weight:900;
}

/* Photo Composer */
.upload-row{
  width:min(1100px, 96vw);
  margin:10px 0 12px;
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:center;
  flex-wrap:wrap;
}
.file-input{
  background:#1e1f22;
  border:2px solid #404249;
  border-radius:10px;
  color:#fff;
  padding:10px;
}

.stage-wrap{
  width:min(1100px, 96vw);
  margin-top:12px;
  display:flex;
  justify-content:center;
}

/* ✅ اخفاء مكان الصورة بالكامل قبل الرفع */
.stage-wrap.hidden{
  display:none;
}

/* ✅ الـ stage يصير على قد الصورة (JS بيحدد width/height) */
.stage{
  position:relative;
  border:2px solid #404249;
  border-radius:14px;
  background:#000;
  overflow:hidden;
  width:300px;   /* fallback */
  height:200px;  /* fallback */
}

#bgImg{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:fill; /* بما أن stage صار نفس أبعاد الصورة، ما نحتاج contain */
}

#chatOverlay{
  position:absolute;
  left:20px;
  top:20px;

  width:620px;          /* ✅ نفس عرض مربع الكتابة */
  max-width:620px;      /* ✅ يمنع التمدد مع الصورة */

  cursor:grab;
  transform-origin:center center;
}

#chatOverlay.dragging{ cursor:grabbing; }

.rotation-readonly{
  height:35px;
  width:70px;
  border:2px solid #404249;
  border-radius:6px;
  background:#1e1f22;
  color:#fff;
  text-align:center;
}

#rotateHandle{
  position:absolute;
  width:16px;
  height:16px;
  right:-10px;
  bottom:-10px;
  border-radius:999px;
  background:#5865f2;
  border:2px solid #ffffff;
  box-shadow:0 2px 8px rgba(0,0,0,.4);
  cursor:grab;
}
#chatOverlay.rotating #rotateHandle{ cursor:grabbing; }
#chatOverlay.rotating{
  outline:1px dashed rgba(255,255,255,.5);
  outline-offset:4px;
}
