:root{
  color-scheme:dark;
  --bg:#0b0b0b; --panel:#141414; --border:#2a2a2a; --accent:#2b8cff; --danger:#e14c4c;
  --text:#fff; --muted:#9aa0a6;
  --warning: #facc15; /* Sarı uyarı rengi */
  --c-bg:#101010; --c-btn:#202020; --c-text:#ffffff;
  --cols:5; --rows:3; --gapx:12px; --gapy:12px; --padx:20px; --pady:20px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial;
}
*{box-sizing:border-box}
/* DEĞİŞTİ: height: 100% -> min-height: 100vh olarak değiştirildi, böylece sayfa uzayabilir */
html,body{min-height: 100vh; overflow-x: hidden; overflow-y: auto;}
/* DEĞİŞTİ: body'den display:flex kaldırıldı, artık grid layout'u zorlamıyoruz */
body{margin:0;background:var(--bg);color:var(--text);
}
.layout{
  display:grid;
  gap:14px;
  /* DEĞİŞTİ: Gömülü iframe için yeni alan */
  grid-template-areas:
    "header header"
    "device sidebar"
    "embed embed";
  grid-template-columns:minmax(0, 1fr) 320px;
  /* DEĞİŞTİ: Gömülü iframe için yeni satır */
  grid-template-rows: auto 1fr auto;
  padding:16px;
  max-width:1400px;
  margin:0 auto;
  /* DEĞİŞTİ: flex: 1 ve min-height: 0 kaldırıldı */
}
.main-header {
  grid-area: header;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-left: 0;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}
.main-header h1 {
  margin: 0;
  font-size: 24px;
  color: var(--text);
}
.device{
  grid-area: device;
  background:var(--panel);border:1px solid var(--border);border-radius:16px;padding:16px;display:flex;flex-direction:column;gap:10px;
  overflow: hidden;
  align-items: center;
  min-height: 0;
}
.sidebar{
  grid-area: sidebar;
  background:var(--panel);border:1px solid var(--border);border-radius:16px;padding:16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
/* YENİ: Sidebar başlığı ve refresh butonu için */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  margin-bottom: 10px;
}
.sidebar h3 {
  margin: 0; /* Margin'i headera taşıdık */
}
#icons, #pickerList {
  flex: 1;
  overflow-y: auto;
  padding: 0; margin: 0;
}
.icon-folder {
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}
.icon-folder:last-child {
  border-bottom: none;
  margin-bottom: 0;
}
.icon-folder summary {
  padding: 8px 5px;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--muted);
  position: relative;
  transition: background-color 0.2s;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.icon-folder summary:hover {
  background-color: rgba(255, 255, 255, 0.05);
}
.icon-folder summary::before {
  content: '▶';
  display: inline-block;
  font-size: 0.8em;
  margin-right: 8px;
  transition: transform 0.2s;
}
.icon-folder[open] > summary::before {
  transform: rotate(90deg);
}
.icon-list-inner {
  list-style: none; padding: 10px 5px; margin: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.icon-list-inner li {
  display:block;
  width: 40px;
  height: 40px;
  padding: 2px;
  border:1px solid var(--border);
  border-radius:8px;
  background:#161616;
}
#pickerList .icon-list-inner li {
    width: 60px;
    height: 60px;
    cursor: pointer;
}
#pickerList .icon-list-inner li:hover {
    border-color: var(--accent);
}
.icon-list-inner .thumb{
  width: 100%;
  height: 100%;
  object-fit:contain;
  border-radius:6px;
  background:#111;
}


.device-frame{
  width:800px;height:480px;border-radius:24px;border:1px solid var(--border);display:flex;align-items:center;justify-content:center;background:#0e0e0e;overflow:hidden;
  flex-shrink: 0;
  transform-origin: top center;
  transition: transform 0.2s ease-out;
}
.grid{width:800px;height:480px;background:var(--c-bg);border:1px dashed #222;border-radius:20px;display:grid;
  grid-template-columns:repeat(var(--cols),110px);grid-template-rows:repeat(var(--rows),110px);
  column-gap:var(--gapx);row-gap:var(--gapy);padding:var(--pady) var(--padx)}

.cell{
  position: relative;
  width:110px;height:110px;border-radius:24px;
  border:1px solid #262626;
  background:#191919;display:flex;align-items:center;justify-content:center;overflow:hidden;
  cursor: grab;
}
.cell:hover {
  border-color: #444;
}
.cell.dragover {
  border: 2px solid var(--accent) !important;
  box-shadow: 0 0 8px rgba(43, 140, 255, 0.5);
}

.btn{position:relative;display:flex;align-items:center;justify-content:center;width:110px;height:110px;padding:0;
  border-radius:24px;
  background:var(--c-btn);
  border:2px solid #555555;
  color:var(--c-text);font-weight:600;overflow:hidden;
  cursor: pointer;
}

/* DEĞİŞTİ: .btn img stilleri .btn .icon-img olarak güncellendi */
.btn .icon-img {
  display: block;
  width: 100%;
  height: 100%;
  
  /* Orijinal resmi (tint yokken) göstermek için */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;

  /* Tint (maskeleme) için */
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;

  /* Hem scale hem de geçiş için */
  transform-origin: center;
  transition: transform 0.1s ease-out;
  
  image-rendering: auto;
  pointer-events: none;
}

.btn .label{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-size:18px;font-weight:700;text-shadow:0 1px 2px rgba(0,0,0,.6);padding:0 6px;text-align:center;
  display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden;white-space:normal;max-width:92%;
  overflow-wrap: break-word;
  word-break: normal;
  pointer-events: none;
}
.btn .label.top{top:6px;transform:translateX(-50%)}
.btn .label.bottom{top:auto;bottom:6px;transform:translateX(-50%)}

.plus{width:110px;height:110px;border-radius:24px;border:1px solid #555555;color:#e5e7eb;background:transparent;display:flex;align-items:center;justify-content:center;
  font-size:48px;
  cursor: pointer;
}

.pagebar{display:flex;gap:10px;align:items:center;justify-content:center;margin-top:10px;flex-wrap:wrap}
.page-pill{position:relative;min-width:36px;height:36px;padding:0 12px;background:#202020;border:1px solid #2b2b2b;border-radius:999px;color:#d0d0d0;font-size:15px;display:flex;align-items:center;justify-content:center;cursor:pointer}
.page-pill.active{background:var(--accent);color:#fff;border-color:transparent}
.page-pill.add{background:transparent;border-style:dashed;opacity:.9}
.page-pill .close{position:absolute;top:-6px;right:-6px;width:18px;height:18px;border-radius:999px;background:#2d2d2d;color:#fff;border:1px solid #444;display:none;align-items:center;justify-content:center;font-size:12px;line-height:1}
.page-pill:hover .close{display:flex}

.page-pill .edit-name {
  display: none;
  margin-left: 8px;
  width: 18px;
  height: 18px;
  font-size: 12px;
  font-style: normal;
  border-radius: 4px;
  background: rgba(0,0,0,0.2);
  line-height: 18px;
  text-align: center;
}
.page-pill:hover .edit-name {
  display: inline-block;
}
.page-pill .edit-name:hover {
  background: rgba(255,255,255,0.3);
  color: #000;
}
.page-pill.active:hover .edit-name:hover {
    background: rgba(0,0,0,0.3);
    color: #fff;
}


.cell .close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 25px;
  height: 25px;
  border-radius: 999px;
  background: rgba(45, 45, 45, 0.7);
  color: #fff;
  border: 1px solid #444;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
}
.cell:hover .close {
  display: flex;
}


.settings{margin-top:10px;border-top:1px dashed #2a2a2a;padding-top:10px}
.row.inline{display:flex;flex-direction:row; flex-wrap: wrap; gap:12px;align-items: flex-end; }
.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
#buttonControls {
  align-items: center;
}
.control label{display:block;font-size:12px;color:var(--muted);margin-bottom:4px}
#gridControl {
  margin-right: 20px;
}

.wifi-settings-row {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 10px;
}
.wifi-settings-row .control-group {
  width: 100%;
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrapper input.text {
  padding-right: 40px;
}
.toggle-password {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 38px;
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.toggle-password:hover {
  color: var(--text);
  background-color: rgba(255, 255, 255, 0.05);
}


.icon-source-status {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
#iconStatusIndicator {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
}
#iconStatusIndicator.status-ok { color: #65c76a; }
#iconStatusIndicator.status-warning { color: var(--warning); }
#iconStatusIndicator.status-error { color: var(--danger); }


.ghost{background:#1d1d1d;color:#fff;border:1px solid var(--border);border-radius:10px;padding:8px 12px;cursor:pointer}
.primary{background:var(--accent);color:#fff;border:1px solid transparent;border-radius:10px;padding:8px 12px;cursor:pointer}
.danger{background:var(--danger);color:#fff;border:1px solid transparent;border-radius:10px;padding:8px 12px;cursor:pointer}

/* YENİ: Refresh butonu stilleri */
.refresh-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
}
.refresh-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text);
}
.refresh-btn.small {
    height: 38px; /* Input ile aynı yükseklik */
    width: 38px;
    font-size: 16px;
    border-radius: 10px;
}


dialog{border:none;border-radius:16px;background:#161616;color:#fff;width:min(720px,94vw);box-shadow:0 6px 24px rgba(0,0,0,.35);padding:0}
dialog::backdrop{background:rgba(0,0,0,.5)}
.editor,.picker{padding:16px}
.row{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}
.row.actions{flex-direction:row;align-items:center}
.fld label{font-size:12px;color:#c7c7c7;margin-bottom:4px}

.fld .text, .fld .num, #iconPath, #combo, textarea.text,
input.text[type="text"], input.text[type="search"], input.text[type="password"] {
  background:#111;color:#fff;border:1px solid var(--border);border-radius:10px;padding:10px 12px;
  width: 100%;
  font-family: inherit;
  font-size: 14px;
}
.fld .num{width:70px;padding:8px 6px}
.hstack{display:flex;gap:8px;align-items:center}

/* DEĞİŞTİ: #iconScaleRange eklendi */
#labelSizeRange, #iconScaleRange {
  flex:1;
  accent-color:var(--accent);
  max-width: 200px;
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 99px;
  outline: none;
}
/* DEĞİŞTİ: #iconScaleRange eklendi */
#labelSizeRange::-webkit-slider-thumb, #iconScaleRange::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
}
/* DEĞİŞTİ: #iconScaleRange eklendi */
#labelSizeRange::-moz-range-thumb, #iconScaleRange::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid #fff;
}

.muted{color:#9aa0a6;font-size:12px}
.seg{display:flex;gap:8px;flex-wrap:wrap}
.seg-btn{padding:8px 12px;border:1px solid var(--border);background:#1d1d1d;color:#fff;border-radius:10px;cursor:pointer}
.seg-btn.active{background:var(--accent);border-color:transparent}
.previewBtn{margin:auto}

/* YENİ: Önizleme ikonu için geçiş */
#previewIcon {
  transition: transform 0.1s ease-out;
}

.icon-path {
  display: flex;
  gap: 8px;
  align-items: center; /* Butonları dikeyde ortala */
}
.icon-path input {
  flex: 1;
}

.editor-icon-list {
  max-height: 190px;
  overflow-y: auto;
  background: #111;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-top: 6px;
  display: none;
}
.editor-icon-list li {
  width: 60px;
  height: 60px;
  cursor: pointer;
}
.editor-icon-list li:hover {
  border-color: var(--accent);
}


select {
  background: #1d1d1d;
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
input[type="color"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 44px;
  height: 38px;
  background-color: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 4px;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 4px;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}
input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}

/* DEĞİŞTİ: #iconColor eklendi */
input[type="color"].unset, #iconColor.unset {
  background-image: linear-gradient(45deg, #444 25%, transparent 25%),
                    linear-gradient(-45deg, #444 25%, transparent 25%),
                    linear-gradient(45deg, transparent 75%, #444 75%),
                    linear-gradient(-45deg, transparent 75%, #444 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
}
/* DEĞİŞTİ: #iconColor eklendi */
input[type="color"].unset::-webkit-color-swatch, #iconColor.unset::-webkit-color-swatch {
  background-color: transparent !important;
}
/* DEĞİŞTİ: #iconColor eklendi */
input[type="color"].unset::-moz-color-swatch, #iconColor.unset::-moz-color-swatch {
  background-color: transparent !important;
}


.mods {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.mod {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: #1d1d1d;
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
.mod.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.page-chooser {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.picker, .editor {
  position: relative;
}
.dialog-close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 99px;
  background: #333;
  color: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}
.dialog-close-btn:hover {
  background: var(--danger);
  border-color: transparent;
}
.picker h3, .editor h3 {
  margin-top: 0;
  margin-right: 30px;
}

/* YENİ: Gömülü Cihaz Arayüzü Stilleri */
.device-embed {
  grid-area: embed;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-top: 14px; /* Yukarıdaki ana bölümlerle aynı boşluk */
  display: flex;
  flex-direction: column;
}
/* YENİ: Iframe başlığı (Başlık + Spacer + Refresh Butonu) */
.embed-header {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}
.device-embed h3 {
  margin: 0; /* margin-top ve bottom kaldırıldı */
  font-size: 18px;
}
.spacer {
  flex: 1; /* Boşluğu doldurur */
}
/* YENİ: Iframe refresh butonunu küçültme */
.embed-header .refresh-btn.small {
  height: 30px;
  width: 30px;
  font-size: 18px;
}

.iframe-container {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 30%; /* 5:3 Aspect Ratio (800x480) */
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border);
}

/* YENİ: Iframe collapse/expand butonu için ayar */
#toggleIframeBtn {
  font-size: 14px; /* '▼' ikonu için ayar */
  padding-bottom: 2px; /* Dikey hizalama */
}

/* YENİ: Iframe'in gizlenmiş hali */
.iframe-container.collapsed {
  display: none;
}

.iframe-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}


/* Mobil için responsive kurallar */
@media (max-width: 1200px) {
  .layout {
    /* DEĞİŞTİ: Gömülü iframe için alan eklendi */
    grid-template-areas: "header header" "device device" "sidebar sidebar" "embed embed";
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
  }
  .sidebar {
    height: auto;
    max-height: 300px;
    width: 100%;
  }
}
@media (max-width: 659px) {
  .settings .control-group,
  .settings .row.inline {
      flex-direction: column;
      width: 100%;
      align-items: stretch; /* Dikeyde uzat */
  }
  .settings .control-group > .control,
  .settings .control-group {
      width: 100%;
  }
  .control-group button {
      width: 100%;
  }
  .control-group .control:has(button) {
      width: 100%;
  }
  .wifi-settings-row .control-group {
      flex-direction: column;
      align-items: stretch;
  }
  .wifi-settings-row .control {
      width: 100%;
  }
}