:root {
  --bg: #f3eee6;
  --white: #ffffff;
  --panel: #fcd9a8;
  --panel-border: #fdba74;
  --orange: #f97316;
  --green: #5aa83a;
  --stage-frame: #8e63cc;
  --text: #2b2b2b;
  --muted: #9a8f80;

  --trigger: #f9c623;  --trigger-bg: #fff6d6;
  --motion: #2f6fd8;   --motion-bg: #e6efff;
  --looks: #8b4fd8;    --looks-bg: #f1e8ff;
  --sound: #2fa84f;    --sound-bg: #e3f7e8;
  --control: #f08a1c;  --control-bg: #fff0e0;
  --end: #e03a3a;      --end-bg: #ffe4e6;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ÜST BAR */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 80px; padding: 0 32px;
  background: var(--white);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon { font-size: 40px; }
.logo-text { font-weight: 900; font-size: 24px; }

.toolbar { display: flex; align-items: center; gap: 14px; }
.tool {
  position: relative;
  width: 52px; height: 52px; border-radius: 12px;
  font-size: 30px;
  transition: transform .15s;
}
.tool:hover { transform: scale(1.1); }
.tool-orange { background: var(--orange); color: #fff; }
.sep { width: 2px; height: 36px; background: #e5e0d8; }
.badge {
  position: absolute; bottom: -6px; right: -10px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 800;
  padding: 1px 5px; border-radius: 6px;
}

/* ÇALIŞMA ALANI */
.workspace {
  display: grid;
  grid-template-columns: 280px 1fr 200px;
  gap: 24px;
  padding: 20px;
}
.panel {
  background: var(--panel);
  border: 3px solid var(--panel-border);
  border-radius: 32px;
  height: calc(100vh - 80px - 330px);
  min-height: 360px;
  padding: 28px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.add-btn {
  width: 60px; height: 60px; border-radius: 14px;
  background: var(--green); color: #fff;
  font-size: 40px; font-weight: 800; line-height: 1;
  box-shadow: 0 4px 0 #3f7d27;
}
.add-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #3f7d27; }

.sprite-list, .scene-list { width: 100%; display: flex; flex-direction: column; gap: 14px; }

.sprite-card {
  position: relative;
  background: #fde9b5;
  border: 4px solid transparent;
  border-radius: 22px;
  height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.sprite-card.active { border-color: var(--orange); }
.sprite-thumb { font-size: 56px; }
.sprite-name {
  background: #fff; border-radius: 10px;
  padding: 0 10px; font-size: 14px; font-weight: 800; color: #9a5b00;
}
.mini {
  position: absolute; right: 8px;
  width: 38px; height: 38px; border-radius: 50%;
  font-size: 16px;
}
.mini-edit { top: 8px; background: #fff; border: 2px solid #333; }
.mini-copy { bottom: 8px; background: #1d8fd8; color: #fff; }

.scene-card {
  position: relative;
  background: #eef5ff;
  border: 4px solid transparent;
  border-radius: 22px;
  height: 110px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
}
.scene-card.active { border-color: var(--orange); }
.scene-no {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: #1d8fd8; color: #fff;
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}

/* SAHNE */
.stage-wrap { display: flex; justify-content: center; align-items: flex-start; padding-top: 0; }
.stage {
  position: relative;
  height: 100%; max-width: 100%; aspect-ratio: 4 / 3;
  background: var(--white);
  border: 16px solid var(--stage-frame);
  border-radius: 28px;
  box-shadow: inset 0 0 0 2px #b79be6, 0 10px 30px rgba(0,0,0,.08);
  overflow: hidden;
}
.sprite {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 90px;
  user-select: none;
}

/* KODLAMA ALANI */
.coding {
  margin: 0 20px 20px;
  background: #fdf1e3;
  border: 3px solid var(--panel-border);
  border-radius: 36px;
  overflow: hidden;
}
.palette-bar { display: flex; min-height: 110px; }
.categories {
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--panel);
}
.cat {
  width: 56px; height: 62px; border-radius: 12px;
  font-size: 26px; color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
  opacity: .85;
}
.cat.active { opacity: 1; outline: 3px solid #fff; transform: scale(1.06); }
.cat-trigger { background: var(--trigger); }
.cat-motion  { background: var(--motion); }
.cat-looks   { background: var(--looks); }
.cat-sound   { background: var(--sound); }
.cat-control { background: var(--control); }
.cat-end     { background: var(--end); }

.palette { flex: 1; display: flex; align-items: center; gap: 30px; padding: 0 30px; }
.palette.trigger { background: var(--trigger-bg); }
.palette.motion  { background: var(--motion-bg); }
.palette.looks   { background: var(--looks-bg); }
.palette.sound   { background: var(--sound-bg); }
.palette.control { background: var(--control-bg); }
.palette.end     { background: var(--end-bg); }

/* Yapboz blok */
.block {
  position: relative;
  width: 100px; height: 76px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; color: #fff;
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
  cursor: grab; user-select: none;
}
.block::after {
  content: ""; position: absolute; right: -10px; top: 50%;
  width: 20px; height: 20px; border-radius: 50%;
  background: inherit; transform: translateY(-50%);
}
.block::before {
  content: ""; position: absolute; left: -10px; top: 50%;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--slot-bg, #fff); transform: translateY(-50%);
}
.block.trigger { background: var(--trigger); }
.block.motion  { background: var(--motion);  --slot-bg: var(--motion-bg); }
.block.looks   { background: var(--looks);   --slot-bg: var(--looks-bg); }
.block.sound   { background: var(--sound);   --slot-bg: var(--sound-bg); }
.block.control { background: var(--control); --slot-bg: var(--control-bg); }
.block.end     { background: var(--end);     --slot-bg: var(--end-bg); }
.block.trigger::before, .block.end::after { display: none; }

.code-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 30px;
  border-bottom: 1px solid #f1dcc2;
}
.code-title { font-weight: 900; color: #8a6a45; letter-spacing: .5px; }
.code-actions { display: flex; align-items: center; gap: 18px; }
.code-actions button { font-weight: 800; color: #8a6a45; }
.code-actions .sep { height: 20px; }

.code-area {
  position: relative;
  margin: 14px 18px 18px;
  min-height: 150px;
  background: var(--white);
  border-radius: 18px;
}
.code-ghost { position: absolute; left: 20px; top: 20px; font-size: 100px; opacity: .25; }
.empty-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-style: italic; color: var(--muted); font-size: 20px;
}
/* ===== ADIM 3: SVG ikonlar ve blok detayları ===== */
.cat { display: flex; align-items: center; justify-content: center; }
.cat svg { width: 32px; height: 32px; }
.block svg { width: 42px; height: 42px; position: relative; z-index: 1; }
.block.trigger { border-radius: 38px 12px 12px 38px; }
.block.end     { border-radius: 12px 38px 38px 12px; }
.param {
  position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
  min-width: 26px; height: 26px; padding: 0 6px;
  background: #fff; color: #333; border-radius: 13px;
  font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  max-width: 80px; overflow: hidden; white-space: nowrap;
  z-index: 2;
}
.palette { overflow-x: auto; padding-top: 10px; padding-bottom: 14px; }
.block:hover { transform: translateY(-3px); transition: transform .12s; }
/* ===== ADIM 4: Kod alanı ve sürükle-bırak ===== */
.code-area { overflow: auto; min-height: 220px; }
.code-ghost, .empty-hint { pointer-events: none; }
.script { position: absolute; display: flex; padding-bottom: 16px; }
.script .block { flex: 0 0 auto; }
.code-area .block::before { background: #fff; }
.block::after { z-index: 3; }
.block { touch-action: none; }
.script .block:hover { transform: none; filter: brightness(1.08); }
.code-area .param { cursor: text; }
.drag-ghost {
  position: fixed; z-index: 1000; display: flex;
  pointer-events: none; opacity: .9;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.25));
}
.drag-ghost .block::before { display: none; }
.drag-ghost .block:hover { transform: none; }
.param-input {
  position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%);
  width: 64px; height: 28px; z-index: 5;
  border: 2px solid var(--orange); border-radius: 14px; outline: none;
  text-align: center; font: 800 14px 'Nunito', sans-serif;
}
.code-actions button:disabled { opacity: .4; cursor: default; }
/* ===== ADIM 5: Sahne, balon, düzeltmeler ===== */
.sprite { cursor: grab; touch-action: none; transition: opacity .2s; line-height: 1; }
.stage.show-grid {
  background-image:
    linear-gradient(rgba(0,0,0,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.08) 1px, transparent 1px);
  background-size: calc(100% / 20) calc(100% / 15);
}
.bubble {
  position: absolute; z-index: 5; pointer-events: none;
  transform: translate(-50%, calc(-100% - 55px));
  background: #fff; border: 3px solid #333; border-radius: 16px;
  padding: 6px 14px; font-weight: 800; font-size: 18px; white-space: nowrap;
}
.bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%);
  border: 9px solid transparent; border-top-color: #333;
}
#btnFlag.running { background: #dcfce7; box-shadow: 0 0 0 3px #22c55e; }

/* Mesaj gönder bloğu normal yapboz şeklinde */
.block.trigger[data-type="sendMsg"] { border-radius: 12px; }
.block.trigger[data-type="sendMsg"]::before { display: block; }

/* Zincirdeki bloklar arası iz düzeltmesi */
.script .block + .block::before { display: none; }
.script .block:hover { filter: none; }
/* ===== Izgara: belirgin çizgiler ve numaralar ===== */
.stage.show-grid {
  background-image:
    linear-gradient(rgba(142,99,204,.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(142,99,204,.28) 1px, transparent 1px);
}
.grid-labels { position: absolute; inset: 0; pointer-events: none; display: none; z-index: 4; }
.stage.show-grid .grid-labels { display: block; }
.gx, .gy { position: absolute; font-size: 11px; font-weight: 800; color: #8e63cc; }
.gx { bottom: 2px; transform: translateX(-50%); }
.gy { left: 4px;  transform: translateY(-50%); }
#btnGrid.on { background: #f1e8ff; box-shadow: 0 0 0 3px #8e63cc; }
/* ===== ADIM 6: Karakter listesi ===== */
.panel { overflow: hidden; }
.sprite-list { flex: 1; overflow-y: auto; padding: 4px; }
.sprite-card { cursor: pointer; flex-shrink: 0; }
.sprite-thumb img, .sprite img, .code-ghost img, .g-icon img {
  width: 1em; height: 1em; object-fit: contain; display: block;
  pointer-events: none; -webkit-user-drag: none;
}
.mini-del {
  display: none; top: 8px; left: 8px; right: auto;
  width: 30px; height: 30px; font-size: 14px; font-weight: 800;
  background: #ef4444; color: #fff;
}
.sprite-card.active .mini-del { display: block; }

/* ===== Pencere (modal) ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 2000; padding: 20px;
  background: rgba(30,20,10,.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.modal {
  background: #fff; border-radius: 28px; width: min(1100px, 100%); max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 26px 30px 18px; background: #fff6ea;
}
.modal-head h2 { font-size: 30px; font-weight: 900; }
.modal-head p  { color: #6b5e4f; margin-top: 4px; }
.modal-close {
  width: 48px; height: 48px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12); font-size: 20px; font-weight: 800;
}
.modal-search { padding: 16px 30px; border-bottom: 1px solid #f1e6d8; }
.modal-search input {
  width: 100%; height: 54px; padding: 0 20px; outline: none;
  border: 2px solid #e8ded2; border-radius: 16px; font: 600 18px 'Nunito', sans-serif;
}
.modal-search input:focus { border-color: var(--orange); }

/* ===== Galeri ===== */
.gallery {
  padding: 24px 30px 30px; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px;
}
.gallery-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  height: 170px; border-radius: 22px; cursor: pointer;
  background: #fff; border: 2px solid #efe6db; box-shadow: 0 3px 0 #efe6db;
  transition: transform .12s, border-color .12s;
}
.gallery-card:hover { transform: translateY(-3px); border-color: var(--orange); }
.g-icon { font-size: 64px; line-height: 1; }
.g-name { font-weight: 800; font-size: 17px; }
.gallery-card.upload { border: 2px dashed #8b8cf8; background: #f4f4ff; color: #4f46e5; }
.gallery-card.upload .g-icon { font-size: 48px; }
/* ===== ADIM 7: Sahneler ve arka planlar ===== */
.stage-bg { position: absolute; inset: 0; z-index: 0; background: #fff; }
.sprite { z-index: 1; }
.stage.show-grid { background-image: none; }
.stage.show-grid .stage-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(142,99,204,.28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(142,99,204,.28) 1px, transparent 1px);
  background-size: calc(100% / 20) calc(100% / 15);
}

.scene-list { flex: 1; overflow-y: auto; padding: 4px; }
.scene-card { cursor: pointer; flex-shrink: 0; overflow: hidden; height: auto; aspect-ratio: 4 / 3; }
.scene-preview { position: absolute; inset: 6px; border-radius: 14px; overflow: hidden; }
.scene-preview span { position: absolute; transform: translate(-50%, -50%); font-size: 18px; line-height: 1; }
.scene-preview img { width: 1em; height: 1em; object-fit: contain; display: block; }
.scene-no { z-index: 2; }
.scene-card.active .mini-del { display: block; z-index: 2; }

.bg-card { padding: 10px; justify-content: flex-start; }
.bg-preview { width: 100%; height: 110px; border-radius: 14px; display: block; border: 1px solid #eee; }

/* Karakter kartlarını biraz küçült */
.sprite-card { height: 100px; }
.sprite-thumb { font-size: 46px; }
/* ===== ADIM 8: Sahneye göre ölçeklenen karakterler ===== */
.stage { container-type: inline-size; }
.sprite { font-size: 16cqw; }
.bubble { font-size: 3.2cqw; }
.sprite .txt, .sprite-thumb .txt, .scene-preview .txt {
  display: block; white-space: nowrap; font-weight: 900; line-height: 1.1;
  text-shadow: 0 0 2px rgba(0,0,0,.35);
}
.sprite-thumb .txt { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }

/* ===== Yazı penceresi ===== */
.modal.modal-text {
  position: relative; width: min(740px, 100%);
  background: #3d84c6; border: 6px solid #2f6aa3; border-radius: 22px;
  padding: 40px 36px 30px; overflow: visible;
}
.te-close { position: absolute; top: -22px; right: -22px; color: #2f6aa3; border: 4px solid #2f6aa3; }
.te-input {
  width: 100%; height: 110px; border: 4px solid #2f6aa3; border-radius: 12px;
  font: 900 34px 'Nunito', sans-serif; text-align: center; outline: none; background: #fff;
}
.te-colors { display: flex; justify-content: center; gap: 14px; margin: 28px 0; }
.te-color { width: 52px; height: 52px; border-radius: 50%; border: 4px solid #fff; }
.te-color.on { outline: 4px solid #facc15; outline-offset: 2px; }
.te-row { display: flex; justify-content: space-between; align-items: center; }
.te-sizes { display: flex; align-items: flex-end; gap: 14px; }
.te-size { color: #fff; font-weight: 900; line-height: 1; }
.te-size.on { color: #facc15; }
.te-ok {
  width: 76px; height: 76px; border-radius: 50%; background: #fff;
  color: #3d84c6; font-size: 40px; font-weight: 900;
  box-shadow: 0 4px 0 #2f6aa3;
}

/* ===== Sunum modu ===== */
.present-label { display: none; }
body.present .present-label {
  display: block; position: absolute; left: 50%; transform: translateX(-50%);
  font-weight: 900; font-size: 26px; color: #6d4bd1;
}
body.present .topbar { position: relative; }
body.present .panel,
body.present .coding,
body.present #btnText,
body.present #btnGrid,
body.present #btnBackground,
body.present #btnSave,
body.present #btnOpen,
body.present .toolbar .sep,
body.present .toolbar:last-of-type { display: none; }
body.present .workspace { grid-template-columns: 1fr; height: calc(100vh - 80px); padding: 24px; }
body.present .stage-wrap { height: 100%; }
body.present #btnPresent { background: #f1e8ff; box-shadow: 0 0 0 3px #8e63cc; }
/* ===== Sunum modu düzeltmeleri ===== */
body.present .logo,
body.present #btnVideos,
body.present #btnContact,
body.present #btnCards,
body.present #btnSites { display: none; }
body.present .topbar { justify-content: flex-start; }
body.present .toolbar { gap: 24px; }
/* ===== ADIM 9: Çizim editörü ===== */
.modal.modal-paint { width: min(1200px, 100%); max-height: 95vh; background: #f6efe4; }
.pt-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 2px solid #ece0cf;
}
.pt-group { display: flex; gap: 12px; }
.pt-btn {
  width: 56px; height: 56px; border-radius: 50%;
  background: #bcd5ee; color: #fff; display: flex; align-items: center; justify-content: center;
}
.pt-btn svg { width: 28px; height: 28px; }
.pt-cancel { background: #9aa8bd; }
.pt-ok { background: #4ea4f0; }
.pt-name, .pt-title {
  width: min(390px, 40%); height: 52px; border-radius: 26px; border: 2px solid #d8e2f0;
  background: #fff; text-align: center; font: 900 22px 'Nunito', sans-serif; color: #4a5bb5; outline: none;
  display: flex; align-items: center; justify-content: center;
}
.pt-body { display: grid; grid-template-columns: 76px 1fr 76px; gap: 16px; padding: 16px 24px; min-height: 0; }
.pt-tools { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pt-tool {
  width: 60px; height: 56px; border-radius: 14px; background: #fff; color: #333;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 3px 0 #e5d9c6;
}
.pt-tool svg { width: 28px; height: 28px; }
.pt-tool.on { background: #fff4c2; outline: 3px solid #f6b73c; }
.pt-width span { display: block; width: 34px; background: #333; border-radius: 4px; }
.pt-sep { width: 44px; height: 2px; background: #e5d9c6; margin: 2px 0; }
.pt-canvas-wrap {
  background: #fff; border-radius: 20px; padding: 10px;
  display: flex; align-items: center; justify-content: center; min-height: 0;
}
.pt-canvas {
  max-width: 100%; max-height: 56vh; touch-action: none; cursor: crosshair;
  border: 2px dashed #f2c6d2; border-radius: 6px;
  background: conic-gradient(#f4f4f4 25%, #fff 0 50%, #f4f4f4 0 75%, #fff 0) 0 0 / 24px 24px;
}
.pt-canvas.bg { background: #fff; }
.pt-colors {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center;
  padding: 14px 24px 22px; background: #fff;
}
.pt-color { width: 38px; height: 38px; border-radius: 50%; border: 2px solid #e5e7eb; }
.pt-color.on { outline: 4px solid #f6b73c; outline-offset: 2px; }

/* Galerideki çiz kartı */
.paint-card { border: 2px dashed #f97316; background: #fff7ed; color: #c2410c; }
.paint-card .g-icon svg { width: 56px; height: 56px; }
/* ===== Çizim penceresini ekrana sığdır ===== */
.modal.modal-paint { max-height: 96vh; }
.pt-head { padding: 10px 20px; }
.pt-btn { width: 48px; height: 48px; }
.pt-name, .pt-title { height: 46px; font-size: 20px; }
.pt-body { padding: 10px 20px; gap: 12px; flex: 1; min-height: 0; overflow: hidden; }
.pt-tools { gap: 7px; overflow-y: auto; max-height: calc(96vh - 190px); padding: 4px; }
.pt-tool { width: 54px; height: 46px; flex-shrink: 0; }
.pt-tool svg { width: 24px; height: 24px; }
.pt-canvas { max-height: calc(96vh - 230px); }
.pt-colors { gap: 7px; padding: 10px 20px 14px; }
.pt-color { width: 30px; height: 30px; }
/* ===== ADIM 10A: Bildirim ===== */
.toast {
  position: fixed; left: 50%; bottom: 30px; z-index: 3000;
  transform: translate(-50%, 20px); opacity: 0;
  background: #2b2b2b; color: #fff; font-weight: 800;
  padding: 12px 22px; border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* ===== ADIM 10B: Video dersler ===== */
.modal.modal-videos { width: min(1200px, 100%); }
.vh-head {
  display: flex; align-items: center; gap: 16px; padding: 22px 28px;
  background: linear-gradient(90deg, #f97316, #fb923c); color: #fff;
}
.vh-head h2 { font-size: 28px; font-weight: 900; }
.vh-head p { opacity: .9; }
.vh-head .modal-close { margin-left: auto; background: rgba(255,255,255,.25); color: #fff; box-shadow: none; }
.vh-ico { width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,.25); display: flex; align-items: center; justify-content: center; }
.vh-ico svg { width: 30px; height: 30px; }
.vh-bar {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center;
  margin: 20px 28px 0; padding: 14px; border-radius: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.vh-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.vh-chip { padding: 9px 16px; border-radius: 12px; background: #f3f4f6; font-weight: 800; color: #444; }
.vh-chip.on { background: #f97316; color: #fff; }
.vh-search { display: flex; align-items: center; gap: 8px; border: 2px solid #e5e7eb; border-radius: 12px; padding: 0 12px; height: 44px; color: #9ca3af; }
.vh-search svg { width: 20px; height: 20px; }
.vh-search input { border: none; outline: none; font: 600 16px 'Nunito', sans-serif; width: 200px; }
.vh-count { margin: 18px 28px 0; font-weight: 900; font-size: 20px; }
.vh-count span { background: #ffedd5; color: #c2410c; border-radius: 8px; padding: 0 8px; font-size: 16px; }
.vh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; padding: 16px 28px; overflow-y: auto; }
.vh-card {
  display: flex; flex-direction: column; text-align: left; border-radius: 18px; overflow: hidden;
  background: #fff; border: 2px solid #f1ece5; transition: transform .12s, border-color .12s;
}
.vh-card:hover { transform: translateY(-3px); border-color: #f97316; }
.vh-thumb {
  height: 130px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #fde9b5, #fcd9a8 50%, #e6efff);
}
.vh-play { width: 64px; height: 64px; border-radius: 50%; background: #f97316; color: #fff; display: flex; align-items: center; justify-content: center; }
.vh-play svg { width: 30px; height: 30px; }
.vh-soon { background: rgba(0,0,0,.55); color: #fff; font-weight: 800; padding: 6px 14px; border-radius: 10px; }
.vh-level { margin: 12px 16px 0; align-self: flex-start; font-size: 12px; font-weight: 900; color: #c2410c; border: 2px solid #fed7aa; background: #fff7ed; border-radius: 8px; padding: 2px 8px; }
.vh-title { margin: 8px 16px 0; font-weight: 900; font-size: 17px; }
.vh-desc { margin: 4px 16px 0; color: #6b7280; font-size: 14px; flex: 1; }
.vh-watch { margin: 12px 16px 14px; padding-top: 10px; border-top: 1px solid #f3f4f6; color: #f97316; font-weight: 800; }
.vh-empty { color: #6b7280; padding: 20px 0; }
.vh-foot { display: flex; justify-content: space-between; padding: 14px 28px; border-top: 1px solid #f1ece5; color: #6b7280; }
.modal.modal-player { width: min(960px, 100%); background: #111; }
.vp-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; color: #fff; }
.vp-frame { aspect-ratio: 16 / 9; }
.vp-frame iframe { width: 100%; height: 100%; border: 0; }

/* ===== İletişim ===== */
.modal.modal-contact { width: min(640px, 100%); }
.ct-head {
  display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 28px;
  background: linear-gradient(90deg, #4f46e5, #a855f7); color: #fff;
}
.ct-head h2 { font-size: 28px; font-weight: 900; }
.ct-head .modal-close { background: rgba(255,255,255,.25); color: #fff; box-shadow: none; }
.ct-form { display: flex; flex-direction: column; gap: 14px; padding: 24px 28px 28px; overflow-y: auto; }
.ct-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 800; }
.ct-form b { color: #ef4444; }
.ct-form input, .ct-form select, .ct-form textarea {
  border: 2px solid #e5e7eb; border-radius: 12px; padding: 12px 14px; outline: none;
  font: 600 16px 'Nunito', sans-serif; resize: vertical;
}
.ct-form input:focus, .ct-form select:focus, .ct-form textarea:focus { border-color: #6366f1; }
.ct-info { display: flex; justify-content: space-between; color: #6b7280; font-size: 14px; margin-top: -6px; }
.ct-count { color: #f97316; font-weight: 800; }
.ct-count.ok { color: #16a34a; }
.ct-send {
  height: 56px; border-radius: 14px; color: #fff; font-size: 18px; font-weight: 900;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.ct-send svg { width: 22px; height: 22px; }

/* ===== Kodlama kartları ===== */
.modal.modal-cards { width: min(1100px, 100%); }
.cd-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 28px; background: #fff6ea; }
.cd-head h2 { font-size: 28px; font-weight: 900; }
.cd-body { overflow-y: auto; padding: 24px 28px 30px; }
.cd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 22px; }
.cd-card { display: flex; flex-direction: column; border-radius: 6px; background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.1); overflow: hidden; transition: transform .12s; }
.cd-card:hover { transform: translateY(-4px) rotate(-1deg); }
.cd-icon { height: 150px; display: flex; align-items: center; justify-content: center; font-size: 80px; background: #fdf1e3; }
.cd-label { display: flex; align-items: center; gap: 10px; background: #f97316; color: #fff; font-weight: 900; font-size: 19px; padding: 10px 12px; text-align: left; }
.cd-no { flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%; background: #111; color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.cd-detail { max-width: 640px; margin: 0 auto; }
.cd-back { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: #c2410c; }
.cd-back svg { width: 20px; height: 20px; }
.cd-big { font-size: 110px; text-align: center; margin: 10px 0; }
.cd-detail h3 { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 28px; font-weight: 900; }
.cd-detail h3 .cd-no { background: #f97316; }
.cd-detail ol { margin: 22px 0 0 0; padding-left: 0; list-style: none; counter-reset: s; }
.cd-detail li {
  counter-increment: s; position: relative; padding: 14px 16px 14px 60px; margin-bottom: 12px;
  background: #fdf1e3; border-radius: 14px; font-weight: 700; font-size: 18px;
}
.cd-detail li::before {
  content: counter(s); position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%; background: #2f6fd8; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 900;
}

/* ===== Kodlama siteleri ===== */
.sites-pop {
  position: fixed; top: 90px; right: 20px; z-index: 2500; width: 360px;
  background: #fff; border-radius: 22px; padding: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.2);
}
.sp-head { display: flex; align-items: center; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid #f1ece5; font-size: 18px; }
.sp-ico { width: 36px; height: 36px; border-radius: 10px; background: #fff7ed; color: #f97316; display: flex; align-items: center; justify-content: center; }
.sp-ico svg { width: 22px; height: 22px; }
.sp-close { margin-left: auto; width: 32px; height: 32px; border-radius: 50%; background: #f3f4f6; font-weight: 800; }
.sp-group { margin: 14px 0 8px; color: #f97316; font-weight: 800; font-size: 14px; }
.sp-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; margin-bottom: 8px;
  border-radius: 16px; border: 2px solid #f1ece5; text-decoration: none; color: inherit; transition: border-color .12s;
}
.sp-item:hover { border-color: #f97316; }
.sp-emoji { width: 52px; height: 52px; border-radius: 12px; background: #fdf1e3; display: flex; align-items: center; justify-content: center; font-size: 30px; }
.sp-item b { display: block; font-size: 17px; }
.sp-item small { color: #6b7280; }
.sp-ext { margin-left: auto; color: #f97316; }
.sp-ext svg { width: 20px; height: 20px; }
/* ===== Logo resmi ===== */
.logo-icon img { width: 58px; height: 58px; display: block; object-fit: contain; }
/* ===== Logo resmi ===== */
.logo-icon img { width: 58px; height: 58px; display: block; object-fit: contain; }
/* ===== Logo resmi ===== */
.logo-icon img { width: 58px; height: 58px; display: block; object-fit: contain; }
/* ===== Üst bar resim ikonları ===== */
.tool img { width: 46px; height: 46px; object-fit: contain; display: block; margin: auto; pointer-events: none; }
/* ===== Gruplu karakter galerisi ===== */
.gallery-wrap { overflow-y: auto; padding: 0 30px 30px; }
.gallery-wrap .gallery { padding: 8px 0 16px; overflow: visible; }
.g-group { font-size: 20px; font-weight: 900; color: #c2410c; margin: 18px 0 4px; }
/* ===== Resimli karakterler sahnede biraz daha büyük ===== */
.sprite img { width: 1.4em; height: 1.4em; }
/* ===== Kart görselleri ===== */
.cd-icon img { height: 130px; width: 90%; object-fit: contain; }
.cd-big img { height: 200px; max-width: 100%; object-fit: contain; display: block; margin: 0 auto; }
.sp-emoji img { width: 42px; height: 42px; object-fit: contain; }
/* ===== ADIM T1: Yapboz blok şekilleri ===== */
.block { background: transparent !important; box-shadow: none !important; border-radius: 0 !important; overflow: visible; }
.block::before, .block::after { display: none !important; }
.block > svg.shape {
  position: absolute; left: -2px; top: -2px; width: 116px; height: 88px; z-index: 0; overflow: visible;
  filter: drop-shadow(0 5px 0 var(--d)) drop-shadow(0 9px 6px rgba(0,0,0,.18));
  transition: filter .12s;
}
.block > svg.shape .body { fill: var(--c); stroke: rgba(255,255,255,.35); stroke-width: 2; }
.block > svg.shape .hl { fill: none; stroke: rgba(255,255,255,.45); stroke-width: 4; stroke-linecap: round; }
.block > svg:not(.shape) { position: relative; z-index: 1; filter: drop-shadow(0 2px 0 rgba(0,0,0,.22)); }
.block:hover > svg.shape { filter: drop-shadow(0 5px 0 var(--d)) drop-shadow(0 12px 10px rgba(0,0,0,.25)) brightness(1.06); }
.block.trigger { --c: #fbc531; --d: #c99700; }
.block.motion  { --c: #3b7ddd; --d: #1f4fa3; }
.block.looks   { --c: #9459e0; --d: #6532a8; }
.block.sound   { --c: #34b356; --d: #1f7a37; }
.block.control { --c: #f5931f; --d: #b86400; }
.block.end     { --c: #e8453c; --d: #a82222; }
.palette { gap: 24px; }
.block .param { z-index: 2; border: 2px solid var(--d); }
/* ===== ADIM T1B: Kategori butonları ===== */
.categories {
  gap: 14px; padding: 0 22px;
  background: linear-gradient(180deg, #fde3bd 0%, #fbd29a 100%);
  border-right: 3px solid #fdba74;
}
.cat {
  position: relative; width: 72px; height: 84px; border-radius: 18px;
  flex-direction: column; gap: 3px; opacity: .78; outline: none !important;
  background: linear-gradient(180deg, var(--c1) 0%, var(--c2) 100%) !important;
  box-shadow: 0 6px 0 var(--d), 0 10px 14px rgba(0,0,0,.15), inset 0 2px 0 rgba(255,255,255,.35);
  transition: transform .15s, opacity .15s, box-shadow .15s;
}
.cat::before {
  content: ""; position: absolute; left: 12px; right: 12px; top: 7px; height: 5px;
  border-radius: 3px; background: rgba(255,255,255,.4);
}
.cat svg { width: 32px; height: 32px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.2)); }
.cat-label { font-size: 11px; font-weight: 900; color: #fff; letter-spacing: .2px; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.cat:hover { opacity: 1; transform: translateY(-2px); }
.cat.active {
  opacity: 1; transform: translateY(-5px) scale(1.06);
  box-shadow: 0 6px 0 var(--d), 0 0 0 4px #fff, 0 12px 22px rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.35);
}
.cat:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--d), inset 0 2px 0 rgba(255,255,255,.35); }
.cat-trigger { --c1: #ffd54a; --c2: #f5b800; --d: #c99700; }
.cat-motion  { --c1: #5a96f0; --c2: #2f6fd8; --d: #1f4fa3; }
.cat-looks   { --c1: #a874ec; --c2: #8b4fd8; --d: #6532a8; }
.cat-sound   { --c1: #4cc66c; --c2: #2fa84f; --d: #1f7a37; }
.cat-control { --c1: #ffa940; --c2: #f08a1c; --d: #b86400; }
.cat-end     { --c1: #f1625a; --c2: #e03a3a; --d: #a82222; }
.palette-bar { min-height: 122px; }
/* ===== ADIM T2: Tema butonu ===== */
.theme-toggle {
  width: 50px; height: 50px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #1e2a4f; color: #ffd166; box-shadow: 0 4px 0 #0e1530;
}
.theme-toggle svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
body.dark .theme-toggle { background: #fff4d6; color: #f59e0b; box-shadow: 0 4px 0 #e8c98a; }

/* ===== GECE MODU (Füzyon lacivert) ===== */
body.dark {
  --bg: #0a0f22;
  color: #edeff7;
  background:
    radial-gradient(circle at 15% 10%, rgba(255,107,53,.10), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(142,99,204,.14), transparent 45%),
    radial-gradient(rgba(255,255,255,.05) 1px, transparent 1.5px) 0 0 / 26px 26px,
    linear-gradient(180deg, #0a0f22 0%, #111a38 100%);
  background-attachment: fixed;
}
body.dark .topbar { background: #0e1530; box-shadow: 0 2px 0 #2a3660, 0 6px 20px rgba(0,0,0,.35); }
body.dark .logo-text { color: #fff; }
body.dark .logo-text::first-letter { color: #ff6b35; }
body.dark .sep { background: #2a3660; }

body.dark .panel { background: linear-gradient(180deg, #16213e, #121b36); border-color: #2a3660; box-shadow: inset 0 1px 0 rgba(255,255,255,.04); }
body.dark .sprite-card { background: #212f52; }
body.dark .sprite-card.active, body.dark .scene-card.active { border-color: #ff6b35; box-shadow: 0 0 0 3px rgba(255,107,53,.25); }
body.dark .sprite-name { background: #0e1530; color: #ffb74d; }
body.dark .mini-edit { background: #edeff7; border-color: #0e1530; }
body.dark .scene-card { background: #212f52; }

body.dark .stage { border-color: #ff6b35; box-shadow: 0 0 0 4px rgba(255,107,53,.18), 0 14px 40px rgba(0,0,0,.45); }

body.dark .coding { background: #0e1530; border-color: #2a3660; }
body.dark .categories { background: linear-gradient(180deg, #16213e, #1b2849); border-right-color: #2a3660; }
body.dark .palette.trigger { background: color-mix(in srgb, #f9c623 14%, #111a36); }
body.dark .palette.motion  { background: color-mix(in srgb, #2f6fd8 18%, #111a36); }
body.dark .palette.looks   { background: color-mix(in srgb, #8b4fd8 18%, #111a36); }
body.dark .palette.sound   { background: color-mix(in srgb, #2fa84f 16%, #111a36); }
body.dark .palette.control { background: color-mix(in srgb, #f08a1c 16%, #111a36); }
body.dark .palette.end     { background: color-mix(in srgb, #e03a3a 16%, #111a36); }
body.dark .code-head { border-bottom-color: #2a3660; }
body.dark .code-title { color: #ffb74d; }
body.dark .code-actions button { color: #9aa3c4; }
body.dark .code-area {
  background: radial-gradient(rgba(255,255,255,.07) 1px, transparent 1.5px) 0 0 / 22px 22px, #121a36;
  box-shadow: inset 0 0 0 2px #2a3660;
}
body.dark .empty-hint { color: #9aa3c4; }
body.dark .code-ghost { opacity: .18; }
body.dark .gx, body.dark .gy { color: #ffb74d; }

/* Pencereler */
body.dark .modal { background: #16213e; color: #edeff7; }
body.dark .modal-head, body.dark .cd-head { background: #0e1530; }
body.dark .modal-head p, body.dark .cd-head p { color: #9aa3c4; }
body.dark .modal-close { background: #212f52; color: #edeff7; }
body.dark .modal-search { border-bottom-color: #2a3660; }
body.dark .modal-search input, body.dark .vh-search, body.dark .vh-search input,
body.dark .ct-form input, body.dark .ct-form select, body.dark .ct-form textarea {
  background: #0e1530; color: #edeff7; border-color: #2a3660;
}
body.dark .gallery-card, body.dark .vh-card, body.dark .cd-card, body.dark .sp-item { background: #212f52; border-color: #2a3660; box-shadow: none; }
body.dark .g-name, body.dark .vh-title, body.dark .sp-item b { color: #edeff7; }
body.dark .g-group { color: #ffb74d; }
body.dark .gallery-card.upload { background: #1e2550; border-color: #8b8cf8; color: #a5b4fc; }
body.dark .paint-card { background: #2a1f1a; color: #ffb74d; }
body.dark .bg-preview { border-color: #2a3660; }
body.dark .vh-bar { background: #0e1530; box-shadow: none; }
body.dark .vh-chip { background: #212f52; color: #cbd2ea; }
body.dark .vh-chip.on { background: #ff6b35; color: #fff; }
body.dark .vh-desc, body.dark .vh-foot, body.dark .sp-item small, body.dark .ct-info { color: #9aa3c4; }
body.dark .vh-foot, body.dark .vh-watch { border-color: #2a3660; }
body.dark .cd-icon, body.dark .sp-emoji { background: #1b2849; }
body.dark .cd-detail li { background: #212f52; }
body.dark .sites-pop { background: #16213e; color: #edeff7; }
body.dark .sp-head { border-bottom-color: #2a3660; }
body.dark .sp-close { background: #212f52; color: #edeff7; }
body.dark .present-label { color: #ffb74d; }
/* ===== ADIM T3: Füzyon tarzı logo yazısı ===== */
.logo-text { display: inline-flex; flex-direction: column; gap: 5px; line-height: 1; }
.lg-main {
  font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 30px;
  color: #0b4f78; letter-spacing: 1px;
}
.lg-u { position: relative; display: inline-block; }
.lg-u::before {
  content: ""; position: absolute; top: -0.2em; left: 0.1em;
  width: 0.2em; height: 0.15em; background: #f07f1e;
  box-shadow: 0.42em 0 0 #f07f1e;
}
.lg-sub {
  font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 12px;
  color: #fff; background: #f07f1e; text-align: center;
  letter-spacing: 0.6em; padding: 4px 0 4px 0.6em;
  border-radius: 10px 3px 10px 3px;
}
body.dark .lg-main { color: #fff; }
/* ===== Logo yazısı görseli ===== */
.lg-img { height: 58px; width: auto; display: block; }
.lg-night { display: none; }
body.dark .lg-day { display: none; }
body.dark .lg-night { display: block; }
/* Logo: sadece F amblemli yazı */
.logo-icon { display: none; }

/* ===== ADIM T4: Palet zemini, balon, zincir ===== */
.bubble { color: #1f2340; }

body.dark .palette {
  --pc: 59,125,221;
  background:
    radial-gradient(ellipse 60% 120% at 0% 50%, rgba(var(--pc), .28), transparent 70%),
    linear-gradient(180deg, #16213e 0%, #121b36 100%) !important;
  box-shadow: inset 0 -4px 0 rgba(var(--pc), .55);
}
body.dark .palette.trigger { --pc: 251,197,49; }
body.dark .palette.motion  { --pc: 59,125,221; }
body.dark .palette.looks   { --pc: 148,89,224; }
body.dark .palette.sound   { --pc: 52,179,86; }
body.dark .palette.control { --pc: 245,147,31; }
body.dark .palette.end     { --pc: 232,69,60; }

.script .block { position: relative; }
/* ================= ADIM R1: TABLET / TELEFON UYUMU ================= */
button, .block, .sprite, .cat { touch-action: manipulation; }
.block, .sprite { touch-action: none; }

/* ---- Yatay tablet / küçük dizüstü ---- */
@media (max-width: 1100px) {
  .topbar { padding: 0 14px; height: 72px; }
  .toolbar { gap: 8px; }
  .tool, .theme-toggle { width: 44px; height: 44px; }
  .tool img { width: 38px; height: 38px; }
  .lg-img { height: 46px; }
  .workspace { grid-template-columns: 200px 1fr 150px; gap: 14px; padding: 14px; }
  .panel { height: calc(100vh - 72px - 300px); min-height: 320px; padding: 18px 10px; gap: 14px; }
  .add-btn { width: 52px; height: 52px; font-size: 34px; }
  .sprite-card { height: 92px; }
  .sprite-thumb { font-size: 40px; }
  .categories { gap: 8px; padding: 0 12px; }
  .cat { width: 60px; height: 72px; }
  .palette { gap: 20px; padding-left: 20px; padding-right: 20px; }
}

/* ---- Dikey tablet / telefon ---- */
@media (max-width: 860px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .logo { order: 1; }
  .toolbar:has(#btnVideos) { order: 2; margin-left: auto; gap: 6px; }
  .toolbar:has(#btnFlag) { order: 3; width: 100%; justify-content: center; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .tool, .theme-toggle { width: 40px; height: 40px; flex-shrink: 0; }
  .tool img { width: 34px; height: 34px; }
  .theme-toggle svg { width: 22px; height: 22px; }
  .lg-img { height: 38px; }
  .sep { height: 26px; flex-shrink: 0; }

  .workspace { grid-template-columns: 1fr 1fr; grid-template-areas: "stage stage" "sprites scenes"; padding: 10px; gap: 10px; }
  .workspace > .panel:first-child { grid-area: sprites; }
  .workspace > .stage-wrap { grid-area: stage; }
  .workspace > .panel:last-child { grid-area: scenes; }
  .stage { width: 100%; height: auto; border-width: 10px; border-radius: 20px; }

  .panel { height: auto; min-height: 0; flex-direction: row; align-items: center; padding: 10px; gap: 10px; border-radius: 20px; }
  .add-btn { flex-shrink: 0; width: 46px; height: 46px; font-size: 30px; }
  .sprite-list, .scene-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; flex: 1; padding: 4px; }
  .sprite-card { width: 112px; height: 90px; flex-shrink: 0; }
  .sprite-thumb { font-size: 34px; }
  .sprite-name { font-size: 11px; max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mini { width: 28px; height: 28px; font-size: 12px; right: 4px; }
  .mini-edit { top: 4px; } .mini-copy { bottom: 4px; }
  .mini-del { width: 24px; height: 24px; top: 4px; left: 4px; font-size: 11px; }
  .scene-card { width: 104px; flex-shrink: 0; }

  .coding { margin: 0 10px 10px; border-radius: 24px; }
  .palette-bar { flex-direction: column; min-height: 0; }
  .categories { overflow-x: auto; padding: 12px 10px 8px; border-right: none; border-bottom: 3px solid #fdba74; }
  body.dark .categories { border-bottom-color: #2a3660; }
  .cat { flex-shrink: 0; width: 56px; height: 66px; }
  .palette { min-height: 112px; }
  .code-head { padding: 10px 16px; }
  .code-actions { gap: 10px; font-size: 13px; }
  .code-area { margin: 10px; min-height: 200px; }

  .modal-head { padding: 18px 18px 12px; }
  .modal-head h2 { font-size: 22px; }
  .modal-search, .gallery-wrap { padding-left: 16px; padding-right: 16px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
  .gallery-card { height: 140px; }
  .g-icon { font-size: 48px; }
  .g-name { font-size: 14px; }

  .pt-body { grid-template-columns: 52px 1fr 52px; gap: 8px; padding: 8px 10px; }
  .pt-tool { width: 46px; height: 42px; }
  .pt-color { width: 26px; height: 26px; }
  .pt-name, .pt-title { width: 45%; font-size: 16px; }

  .sites-pop { right: 10px; left: 10px; width: auto; top: 120px; }
}

/* ---- Küçük telefon ---- */
@media (max-width: 520px) {
  .workspace { grid-template-columns: 1fr; grid-template-areas: "stage" "sprites" "scenes"; }
  .lg-img { height: 32px; }
  .toolbar:has(#btnVideos) .sep { display: none; }
  .gallery { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .gallery-card { height: 112px; border-radius: 16px; }
  .g-icon { font-size: 40px; }
  .g-name { font-size: 12px; }
  .vh-grid, .cd-grid { grid-template-columns: 1fr 1fr; gap: 10px; padding-left: 12px; padding-right: 12px; }
  .modal.modal-text { padding: 30px 16px 20px; }
  .te-input { height: 80px; font-size: 24px; }
  .te-color { width: 38px; height: 38px; }
}
/* ===== R1 düzeltmeleri ===== */
.palette .block { flex-shrink: 0; }
.workspace > * { min-width: 0; }

@media (max-width: 860px) {
  .toolbar:has(#btnFlag) { justify-content: safe center; }
  .workspace > .stage-wrap { display: block; width: 100%; padding: 0; }
  .workspace .stage { display: block; width: 100%; height: auto; max-width: none; aspect-ratio: 4 / 3; }
  .palette { justify-content: flex-start; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
/* Telefon: karakter ve sahne şeritleri yan yana */
@media (max-width: 520px) {
  .workspace { grid-template-columns: 1fr 1fr; grid-template-areas: "stage stage" "sprites scenes"; gap: 8px; }
  .panel { padding: 8px; gap: 6px; }
  .add-btn { width: 38px; height: 38px; font-size: 26px; }
  .sprite-card { width: 96px; height: 80px; }
  .scene-card { width: 86px; }
}
/* ===== ADIM B1: Tekrar köprüsü + ses kaydı ===== */
.loop-bar { position: absolute; left: -4px; right: -4px; height: 8px; border-radius: 4px; z-index: 5;
  background: #f5931f; box-shadow: 0 2px 0 #b86400; pointer-events: none; }
.loop-bar.start { left: 50%; }
.loop-bar.end { right: 50%; }
.script { padding-top: 14px; }

.modal.modal-rec { width: min(460px, 100%); }
.rec-body { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 26px 24px 30px; }
.rec-btn { width: 110px; height: 110px; border-radius: 50%; background: #fff; color: #ef4444;
  border: 6px solid #fecaca; display: flex; align-items: center; justify-content: center; transition: transform .15s; }
.rec-btn svg { width: 60px; height: 60px; }
.rec-btn.on { background: #ef4444; color: #fff; border-color: #fca5a5; animation: recPulse 1s infinite; }
@keyframes recPulse { 50% { transform: scale(1.08); } }
.rec-time { font-size: 28px; font-weight: 900; }
.rec-info { color: #9a8f80; text-align: center; }
body.dark .rec-info { color: #9aa3c4; }
.rec-actions { display: flex; gap: 12px; }
.rec-play, .rec-ok { height: 48px; padding: 0 22px; border-radius: 14px; font-weight: 900; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.rec-play { background: #e3f7e8; color: #1f7a37; }
.rec-play svg { width: 18px; height: 18px; }
.rec-ok { background: #34b356; color: #fff; box-shadow: 0 4px 0 #1f7a37; }
.rec-play:disabled, .rec-ok:disabled { opacity: .4; cursor: default; }
/* ===== Yükleme ekranı ===== */
#loader { position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: #f3eee6; transition: opacity .35s; }
html.ld-dark #loader { background: radial-gradient(circle at 50% 40%, #16213e, #0a0f22); }
#loader img { width: min(340px, 70vw); animation: ldPulse 1.4s ease-in-out infinite; }
#loader .ld-night, html.ld-dark #loader .ld-day { display: none; }
html.ld-dark #loader .ld-night { display: block; }
.ld-bar { width: min(240px, 50vw); height: 6px; border-radius: 3px; background: rgba(240,127,30,.2); overflow: hidden; }
.ld-bar span { display: block; width: 40%; height: 100%; border-radius: 3px; background: #f07f1e; animation: ldBar 1s ease-in-out infinite; }
#loader.hide { opacity: 0; pointer-events: none; }
@keyframes ldPulse { 50% { transform: scale(1.04); } }
@keyframes ldBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
/* ===== Dokunmatik: palette yana kaydırma, yukarı çekince sürükleme ===== */
.palette .block { touch-action: pan-x; }
.palette { overscroll-behavior-x: contain; }
@media (max-width: 520px) {
  .sprite-card { width: 120px; }
  .sprite-name { font-size: 10px; }
}
/* ===== Mekan seçme penceresi ===== */
.bg-card.sel { border-color: #f97316; box-shadow: 0 0 0 4px rgba(249,115,22,.35); transform: translateY(-3px); }
.pick-foot { display: flex; justify-content: flex-end; gap: 12px; padding: 14px 30px 22px; border-top: 1px solid #f1e6d8; }
.pick-cancel, .pick-ok { height: 50px; padding: 0 28px; border-radius: 14px; font-weight: 900; font-size: 17px; }
.pick-cancel { background: #f3f4f6; color: #444; }
.pick-ok { background: #34b356; color: #fff; box-shadow: 0 4px 0 #1f7a37; }
.pick-ok:disabled { opacity: .4; cursor: default; box-shadow: none; }
body.dark .pick-foot { border-top-color: #2a3660; }
body.dark .pick-cancel { background: #212f52; color: #edeff7; }
/* Sunum modunda tema butonu gizli */
body.present .theme-toggle { display: none; }
