:root {
  --bg: #0e0f13;
  --bg2: #15171d;
  --bg3: #1c1f27;
  --line: #262a34;
  --fg: #e8eaf0;
  --muted: #8b90a0;
  --accent: #6366f1;
  --accent2: #22d3ee;
  --danger: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 13px/1.45 -apple-system, system-ui, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.brand { font-size: 14px; letter-spacing: .2px; }
.grow { flex: 1; }

.btn {
  background: var(--bg3); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-size: 12.5px;
  transition: .12s;
}
.btn:hover { background: #262b36; border-color: #39404f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.12); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.tiny { padding: 5px 9px; font-size: 11.5px; }
.btn.wide { width: 100%; }
.btn.icon { padding: 7px 10px; }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.field.inline { display: flex; align-items: center; gap: 6px; }
.field.inline > span { color: var(--muted); font-size: 11.5px; }
select, input[type=text], input[type=number], textarea {
  background: var(--bg3); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; font: inherit; outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); }
.size-inputs input { width: 74px; }
.size-inputs { color: var(--muted); gap: 4px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: 110%;
  background: var(--bg3); border: 1px solid var(--line);
  border-radius: 10px; padding: 5px; display: none; z-index: 30; min-width: 190px;
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
}
.menu.open { display: block; }
.menu button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; color: var(--fg);
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font: inherit;
}
.menu button:hover { background: #2b3140; }

/* ---------- layout ---------- */
main {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 172px 1fr 328px;
}
.rail, .panel {
  background: var(--bg2);
  display: flex; flex-direction: column; min-height: 0;
}
.rail { border-right: 1px solid var(--line); }
.panel { border-left: 1px solid var(--line); }

.rail-head, .rail-foot, .panel-foot {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 10px; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
}
.rail-head span { flex: 1; }
.rail-foot, .panel-foot { border-bottom: 0; border-top: 1px solid var(--line); }

.slide-list { flex: 1; overflow-y: auto; padding: 9px; display: flex; flex-direction: column; gap: 9px; }
.slide-item {
  position: relative; border: 2px solid transparent; border-radius: 9px;
  overflow: hidden; cursor: pointer; background: #0a0b0e;
}
.slide-item canvas { display: block; width: 100%; }
.slide-item.sel { border-color: var(--accent); }
.slide-item .num {
  position: absolute; left: 5px; top: 5px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 20px;
}
.slide-item .mv {
  position: absolute; right: 4px; bottom: 4px; display: flex; gap: 3px; opacity: 0;
  transition: .12s;
}
.slide-item:hover .mv { opacity: 1; }
.slide-item .mv button {
  background: rgba(0,0,0,.65); border: 0; color: #fff;
  width: 20px; height: 20px; border-radius: 5px; cursor: pointer; font-size: 11px; line-height: 1;
}

.stage { display: flex; flex-direction: column; min-height: 0; background:
  repeating-conic-gradient(#141519 0% 25%, #0e0f13 0% 50%) 50% / 22px 22px; }
.stage-inner {
  flex: 1; min-height: 0; padding: 18px;
  display: grid; place-items: center;
  grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
}
#preview {
  max-width: 100%; max-height: 100%;
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.stage-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-top: 1px solid var(--line);
  background: var(--bg2); font-size: 11.5px; color: var(--muted);
}
.muted { color: var(--muted); }

/* ---------- panel ---------- */
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 11px 4px; cursor: pointer; font: inherit;
}
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }
.panel-body { flex: 1; overflow-y: auto; padding: 12px; }

.row { margin-bottom: 12px; }
.row > label.lbl {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--muted); font-size: 11.5px; margin-bottom: 5px;
}
.row .val { color: var(--fg); font-variant-numeric: tabular-nums; }
.row input[type=range] { width: 100%; accent-color: var(--accent); }
.row select, .row input[type=text], .row textarea { width: 100%; }
.row textarea { resize: vertical; min-height: 54px; }
.row.hidden { display: none; }

.colors { display: flex; gap: 8px; }
.colors input[type=color] {
  flex: 1; height: 32px; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: none; cursor: pointer;
}
.seg { display: flex; gap: 4px; }
.seg button {
  flex: 1; background: var(--bg3); border: 1px solid var(--line); color: var(--muted);
  padding: 6px 4px; border-radius: 7px; cursor: pointer; font-size: 11.5px;
}
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.check { display: flex; align-items: center; gap: 8px; color: var(--fg); cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.section-title {
  color: var(--muted); font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase;
  margin: 16px 0 8px; padding-top: 12px; border-top: 1px solid var(--line);
}
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.swatch {
  height: 42px; border-radius: 8px; border: 1px solid var(--line);
  cursor: pointer; position: relative; overflow: hidden;
}
.swatch:hover { outline: 2px solid var(--accent); }
.presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }

/* ---------- misc ---------- */
#dropzone {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(10,11,15,.85); backdrop-filter: blur(3px);
  place-items: center; font-size: 20px; color: #fff;
}
#dropzone.on { display: grid; }
#dropzone div { border: 2px dashed var(--accent); border-radius: 18px; padding: 60px 90px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--bg3); border: 1px solid var(--line); color: var(--fg);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: .18s; z-index: 60; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2c313d; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 70; display: none;
  background: rgba(6,7,10,.72); backdrop-filter: blur(4px);
  place-items: center; padding: 24px;
}
.modal.open { display: grid; }
.modal-card {
  width: min(620px, 100%); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 30px 90px rgba(0,0,0,.6);
}
.modal-head, .modal-foot {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
}
.modal-head { border-bottom: 1px solid var(--line); }
.modal-head b { flex: 1; font-size: 13.5px; }
.modal-foot { border-top: 1px solid var(--line); }
.modal-body { padding: 14px; overflow-y: auto; }
.modal-body textarea { width: 100%; font-size: 12.5px; }
#importJson { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; }
.hint { color: var(--muted); font-size: 11.5px; margin: 6px 0 0; }
.hint.grow { flex: 1; margin: 0; }
#variantPick:empty { display: none; }
#variantPick { margin-bottom: 10px; }
#variantPick .btn { text-align: left; line-height: 1.3; }
#promptBox { margin-top: 8px; }
#promptBox summary { color: var(--muted); font-size: 11.5px; cursor: pointer; }
#promptBox textarea {
  margin-top: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px; color: var(--muted);
}

.histo { display: flex; gap: 4px; }
.histo .btn { font-size: 15px; line-height: 1; padding: 5px 10px; }
.btn:disabled { opacity: .35; cursor: default; }
.btn:disabled:hover { background: var(--bg3); border-color: var(--line); }
#btnLang { font-size: 11px; font-weight: 600; letter-spacing: .5px; min-width: 38px; }

/* ---------- şablon galerisi ---------- */
.modal-card.wide { width: min(1000px, 100%); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tpl-card {
  background: var(--bg3); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; cursor: pointer; text-align: left; color: var(--fg);
  font: inherit; transition: .12s;
}
.tpl-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.tpl-shots { display: flex; gap: 6px; margin-bottom: 9px; }
.tpl-shots canvas { width: 33%; border-radius: 5px; display: block; }
.tpl-name { font-weight: 600; font-size: 12.5px; }
.tpl-cat { color: var(--muted); font-size: 11px; margin-top: 2px; }
