html, body {
  overflow: hidden;
  height: 100%;
  margin: 0;
  padding: 0;
}
/* Basit kopya engeli (seçim kapat) */
body.nocopy, body.nocopy *{
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* input/textarea/select içinde seçim serbest */
body.nocopy input,
body.nocopy textarea,
body.nocopy select{
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* ---------- SOL MENU ---------- */
.export-menu{
  position: fixed;
  z-index: 999999;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12);
  width: max-content;
  height: auto;
  pointer-events: auto;
} 
.left-menu{
 position:fixed;
 left:20px;
 top:20px;
 width:150px;
 background:#fff;
 border-radius:12px;
 box-shadow:0 10px 25px rgba(0,0,0,.15);
 overflow:hidden;
 z-index:999;
}

.menu-btn{
 padding: 5px 2px 5px 10px;
 text-align:center;
 border-bottom:1px solid #eee;
 cursor:pointer;
 font-size:13px;
 user-select:none;
 display:flex;
 flex-wrap:wrap;
 font-weight: 700;
}
.menu-btn:hover{ background:#f5f5f5; }

.menu-btn select,
.menu-btn input[type=range]{
 width:90%;
 margin-top:5px;
}

.uk-button {
    border: none;
    padding: 2px 7px 2px 7px;
    font-size: 0.8em;
    border-radius: 5px;
}
.uk-icon{ margin-right:3px; }

.uk-container{ max-width: fit-content; }
.editor-layout{ margin-left:170px; }

.pen-wrap{ position: relative; }

/* penPanel sağa submenu gibi açılsın */
.pen-wrap{ position: relative; }  /* REFERANS BU! */

/* KALEM PANEL (butona göre JS ile konumlanır) */
#penPanel.tool-panel{
  position: fixed;
  width: 240px;
  z-index: 3000;

  display: none;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 25px rgba(0,0,0,.12);

  transform: translateX(-6px);
  opacity: 0;
  transition: all .15s ease;
}

#penPanel.tool-panel.open{
  display: block;
  transform: translateX(0);
  opacity: 1;
}
#penPanel{
  position: fixed !important;
  z-index: 3000 !important;
}
@media (max-width: 768px){
  body{ margin:0; padding:0; overflow-x:hidden; }

  .left-menu{
    left:10px;
    right:10px;
    top:auto;
    bottom:10px;
    width:auto;
    height:92px;
    display:flex;
    flex-direction:row;
    align-items:stretch;
    gap:6px;
    padding:6px;
    overflow-x:auto;
    overflow-y:hidden;
    border-radius:14px;
    z-index:9999;
    -webkit-overflow-scrolling: touch;
  }

  .menu-btn{
    min-width:95px;
    border-bottom:none;
    border-right:1px solid #eee;
    padding:6px 8px;
    font-size:12px;
    display:flex;
    flex-direction:column;
    justify-content:center;
  }
  .menu-btn:last-child{ border-right:none; }

  .menu-btn select,
  .menu-btn input[type=range]{ width:100%; margin-top:4px; }

  .editor-layout{
    margin-left:0 !important;
    padding:10px;
    padding-bottom:120px;
  }

  .uk-container{ max-width:100% !important; width:100% !important; }
  .uk-card{ overflow:auto; }
}

/* ---------- RIGHT CLICK MENU ---------- */
#contextMenu {
  position: fixed;
  display: none;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,.2);
  z-index: 9999999;
  width: 170px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}

#contextMenu::-webkit-scrollbar {
  width: 4px;
}

#contextMenu::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}
#contextMenu .menu-row,
#contextMenu #groupBtn,
#contextMenu #ungroupBtn{
 padding:10px;
 cursor:pointer;
 border-bottom:1px solid #eee;
 font-size:13px;
}
#contextMenu .menu-row:hover,
#contextMenu #groupBtn:hover,
#contextMenu #ungroupBtn:hover{ background:#f0f0f0; }
#contextMenu input[type="color"],
#contextMenu input[type="range"]{ cursor:pointer; }

/* -------- LOCAL FONTS -------- */
@font-face { font-family:'Roboto'; src:url('/fonts/Roboto-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Oswald'; src:url('/fonts/Oswald-VariableFont_wght.woff2') format('woff2'); font-weight:700; font-style:normal; font-display:swap; }
@font-face { font-family:'Montserrat'; src:url('/fonts/Montserrat-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Lobster'; src:url('/fonts/Lobster-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'BungeeShade'; src:url('/fonts/BungeeShade-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Jacques'; src:url('/fonts/JacquesFrancoisShadow-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'NotoColorEmoji'; src:url('/fonts/NotoColorEmoji-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'GreatVibes'; src:url('/fonts/GreatVibes-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Charm'; src:url('/fonts/Charm-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Bruno'; src:url('/fonts/BrunoAceSC-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Dosis'; src:url('/fonts/Dosis-VariableFont_wght.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'Phenomena'; src:url('/fonts/Phenomena-Regular.woff2') format('woff2'); font-weight:400; font-style:normal; font-display:swap; }

.uk-card-body{ padding:20px; }
html{ background:#ececec; }
.uk-card.uk-card-default.uk-card-body.uk-margin{ display:flex; flex-wrap:wrap; }

/* ✅ Özel ölçü */
.custom-size{
  width:100%;
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:6px;
}
.custom-size .row{ width:100%; display:flex; gap:6px; }
.custom-size input{
  flex:1 1 0;
  height:32px;
  line-height:32px;
  padding:0 8px;
  font-size:13px;
}
.custom-size button{
  width:100%;
  height:32px;
  padding:0 10px;
  font-size:13px;
}

/* HEADER */
.editor-header{ padding:12px 20px; }
.header-inner{ display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; }
.header-left{ font-size:20px; }
.header-left .version{ font-size:12px; margin-left:8px; color:#888; }
.header-right{ display:flex; gap:8px; }

.left-menu{
  transform-origin: top left;
  will-change: transform;
}

/* ================= TEMPLATE MODAL (✅ POPUP 800x600 + 2'li grid + scroll) ================= */
#templateModal .uk-modal-dialog{
  width: 800px;
  max-width: calc(100vw - 20px);
  height: 600px;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  border-radius: 12px;
}
#templateModal .tpl-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
}
#templateModal .tpl-scroll{
  height: calc(600px - 120px);
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 6px;
}
@media (max-width: 768px){
  #templateModal .uk-modal-dialog{
    width: calc(100vw - 20px);
    height: 600px;
    max-height: calc(100vh - 40px);
  }
  #templateModal .tpl-scroll{
    height: calc(600px - 130px);
    max-height: calc(100vh - 230px);
  }
}

/* ✅ Grid CSS background — zoom'dan bağımsız */
.canvas-container {
  background-image: 
    linear-gradient(rgba(0,0,0,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0;
}

.canvas-container {
  background-image: none; /* default kapalı */
}

.canvas-container.grid-visible {
  background-image: 
    linear-gradient(rgba(0,0,0,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px);
  background-size: 20px 20px;
}

.canvas-container.grid-visible canvas {
  background-image: 
    linear-gradient(rgba(0,0,0,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0;
}
/* ✅ Editor layout scroll yerine canvas container scroll */
.editor-layout {
  overflow: hidden;
}

.canvas-container {
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-center {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  justify-content: center;
}

.header-left {
  min-width: 180px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 180px;
  justify-content: flex-end;
}

.ctx-icon-row {
  display: flex;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
  margin: 4px 0;
}

.ctx-icon-wrap {
  position: relative;
  flex: 1;
}

.ctx-icon-btn {
  width: 100%;
  padding: 7px 0;
  background: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  transition: background 0.12s, border-color 0.12s;
}

.ctx-icon-btn:hover {
  background: #f0f4ff;
  border-color: #aac4ff;
  color: #1a56db;
}

.ctx-icon-btn:active {
  background: #e0eaff;
  transform: scale(0.95);
}

.ctx-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  font-size: 11px;
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 99999;
}

.ctx-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #222;
}

.ctx-icon-wrap:hover .ctx-tooltip {
  opacity: 1;
}
.pen-mode-btn {
  color: #555;
  transition: border-color 0.15s, background 0.15s;
}
 
.pen-mode-btn:hover {
  border-color: #aac4ff !important;
  background: #f0f4ff !important;
  color: #1a56db;
}
 
.pen-mode-active {
  border-color: #4da3ff !important;
  background: #eef4ff !important;
  color: #1a56db !important;
}
#penPanel.open {
  display: block !important;
}
