/* ═══════════════════════════════════════════════════════════════
   CreatorFrames — Overlay Editor
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #0b0d12;
  --panel: #111523;
  --panel2: #0f1320;
  --text: #e9eefc;
  --muted: #a9b3cf;
  --line: rgba(255, 255, 255, .10);
  --line2: rgba(255, 255, 255, .16);
  --accent: #7aa7ff;
  --accent2: #84f1c0;
  --shadow: 0 10px 28px rgba(0, 0, 0, .35);
  --radius: 16px;
  --radius2: 22px;
  --btn: #1a2040;
  --btn2: #20295a;
  --danger: #ff6b7a;
  --ok: #7cf6c6;
}

/* ── Reset ────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
               Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background:
    radial-gradient(1200px 900px at 20% 10%, rgba(122, 167, 255, .18), transparent 60%),
    radial-gradient(1200px 900px at 80% 25%, rgba(132, 241, 192, .10), transparent 60%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ── App grid ─────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  height: 100%;
  padding: 16px;
}

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .03));
  border: 1px solid var(--line);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 320px;
}

/* ── Left panel ───────────────────────────────────────────────── */
.left {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.left::-webkit-scrollbar       { width: 10px; }
.left::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .10);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, .35);
}

.brand {
  padding: 16px 16px 12px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .01));
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: .2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: radial-gradient(18px 18px at 30% 30%, rgba(132, 241, 192, .9), rgba(122, 167, 255, .95));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .22);
}

.brand p {
  margin: 6px 0 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

/* ── Sections ─────────────────────────────────────────────────── */
.section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.section h2 {
  margin: 0 0 10px 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: .28px;
  text-transform: uppercase;
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--line2);
  background: linear-gradient(180deg, var(--btn2), var(--btn));
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 650;
  letter-spacing: .15px;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0, 0, 0, .22);
  transition: transform .08s ease, filter .12s ease, border-color .12s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1;
}

.btn:hover  { filter: brightness(1.05); border-color: rgba(255, 255, 255, .26); }
.btn:active { transform: translateY(1px) scale(.99); }

.btn.primary {
  border-color: rgba(122, 167, 255, .35);
  background: linear-gradient(180deg, rgba(122, 167, 255, .30), rgba(26, 32, 64, .95));
}
.btn.ok {
  border-color: rgba(132, 241, 192, .34);
  background: linear-gradient(180deg, rgba(132, 241, 192, .24), rgba(26, 32, 64, .95));
}
.btn.danger {
  border-color: rgba(255, 107, 122, .45);
  background: linear-gradient(180deg, rgba(255, 107, 122, .20), rgba(26, 32, 64, .95));
}
.btn.ghost {
  background: rgba(255, 255, 255, .04);
  box-shadow: none;
}
.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  filter: saturate(.7);
}

/* ── Hints & kbd ──────────────────────────────────────────────── */
.hint {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(233, 238, 252, .75);
  line-height: 1.45;
}

.hint kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 2px 6px;
  border-radius: 8px;
  margin: 0 2px;
}

/* ── Layer list ───────────────────────────────────────────────── */
.list {
  padding: 0;
  margin: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 35vh;
  overflow: auto;
  padding-right: 6px;
}

.list::-webkit-scrollbar       { width: 10px; }
.list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .10);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, .35);
}

.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  cursor: pointer;
  user-select: none;
}

.item:hover { border-color: rgba(255, 255, 255, .18); }
.item.active {
  border-color: rgba(122, 167, 255, .42);
  background: rgba(122, 167, 255, .12);
}

.thumb {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  overflow: hidden;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meta     { min-width: 0; flex: 1 1 auto; }
.meta .name {
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta .sub {
  font-size: 11px;
  color: rgba(233, 238, 252, .72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.miniRow { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }

.pill {
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(0, 0, 0, .12);
  color: rgba(233, 238, 252, .78);
  user-select: none;
}

/* ── Right panel / stage ──────────────────────────────────────── */
.right {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.stageTop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .01));
  gap: 12px;
  flex-wrap: wrap;
}

.stageTop .status {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .22);
}
.dot.good { background: rgba(124, 246, 198, .55); border-color: rgba(124, 246, 198, .65); }
.dot.warn { background: rgba(255, 217, 102, .55); border-color: rgba(255, 217, 102, .70); }

.statusText {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.statusText .title {
  font-weight: 750;
  font-size: 13px;
  letter-spacing: .15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

.statusText .desc {
  font-size: 11px;
  color: rgba(233, 238, 252, .70);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 52vw;
}

/* ── Canvas / dropzone ────────────────────────────────────────── */
.stageWrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 14px;
  display: flex;
}

.dropzone {
  position: relative;
  flex: 1 1 auto;
  border-radius: 22px;
  border: 1px dashed rgba(255, 255, 255, .18);
  background:
    radial-gradient(900px 700px at 50% 20%, rgba(122, 167, 255, .10), transparent 60%),
    radial-gradient(900px 700px at 30% 80%, rgba(132, 241, 192, .08), transparent 60%),
    rgba(255, 255, 255, .03);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 18px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .40);
  background: rgba(0, 0, 0, .18);
}

/* ── Overlay help card ────────────────────────────────────────── */
.overlayHelp {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  padding: 24px;
}

.overlayHelp .card {
  max-width: 780px;
  width: min(780px, 95%);
  background: rgba(16, 20, 33, .78);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 22px;
  padding: 18px 18px 16px 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.overlayHelp .card h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
  letter-spacing: .2px;
}

.overlayHelp .card p {
  margin: 0;
  color: rgba(233, 238, 252, .78);
  font-size: 13px;
  line-height: 1.45;
}

.overlayHelp .card .mini {
  margin-top: 10px;
  color: rgba(233, 238, 252, .75);
  font-size: 12px;
  line-height: 1.55;
}

.overlayHelp .card .mini kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
               "Liberation Mono", "Courier New", monospace;
  font-size: 11px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 2px 6px;
  border-radius: 8px;
  margin: 0 2px;
}

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: absolute;
  left: 16px;
  bottom: 16px;
  background: rgba(16, 20, 33, .82);
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 12px;
  color: rgba(233, 238, 252, .86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  display: none;
  max-width: min(560px, calc(100% - 32px));
  pointer-events: none;
}

.toast.show { display: block; }
.toast b    { color: var(--text); }

/* ── Footer ───────────────────────────────────────────────────── */
.footerNote {
  padding: 12px 16px 14px 16px;
  color: rgba(233, 238, 252, .70);
  font-size: 12px;
  line-height: 1.45;
}

/* ── Misc helpers ─────────────────────────────────────────────── */
.sep   { height: 8px; }

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 120px;
  flex: 1 1 auto;
}

.field label           { font-size: 11px; color: rgba(233, 238, 252, .72); }
.field input[type="range"] { width: 100%; }
.field .value          { font-size: 12px; color: rgba(233, 238, 252, .86); font-weight: 650; }

.small {
  font-size: 11px;
  color: rgba(233, 238, 252, .70);
  line-height: 1.45;
}

/* ── Export format modal ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: linear-gradient(180deg, rgba(24, 28, 48, .98), rgba(16, 20, 33, .98));
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 22px;
  padding: 22px 24px 18px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .55);
  max-width: 380px;
  width: min(380px, 92vw);
}

.modal h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
  letter-spacing: .15px;
}

.modal p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.modal .choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal .choice {
  appearance: none;
  border: 1px solid var(--line2);
  background: linear-gradient(180deg, var(--btn2), var(--btn));
  color: var(--text);
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 650;
  letter-spacing: .15px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .22);
  transition: transform .08s ease, filter .12s ease, border-color .12s ease;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 14px;
  line-height: 1;
  text-align: left;
}

.modal .choice:hover  { filter: brightness(1.08); border-color: rgba(255, 255, 255, .26); }
.modal .choice:active { transform: translateY(1px) scale(.99); }

.modal .choice .sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.modal .choice.rec {
  border-color: rgba(132, 241, 192, .34);
  background: linear-gradient(180deg, rgba(132, 241, 192, .18), rgba(26, 32, 64, .95));
}

.modal .cancel-row {
  margin-top: 14px;
  text-align: center;
}

/* ── Number inputs ────────────────────────────────────────────── */
.num-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line2);
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  outline: none;
  transition: border-color .15s ease;
}
.num-input:focus {
  border-color: var(--accent);
  background: rgba(122, 167, 255, .08);
}
.num-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button {
  opacity: 1;
}

/* ── Color picker row ─────────────────────────────────────────── */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.color-input {
  width: 36px;
  height: 30px;
  border: 1px solid var(--line2);
  border-radius: 8px;
  padding: 2px;
  background: rgba(255, 255, 255, .04);
  cursor: pointer;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}
.color-hex {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  min-width: 60px;
}
.color-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.color-check input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ── Anchor grid ──────────────────────────────────────────────── */
.anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, 28px);
  gap: 4px;
}
.anchor-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line2);
  border-radius: 7px;
  background: rgba(255, 255, 255, .04);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: background .1s, border-color .1s, color .1s;
  padding: 0;
  line-height: 1;
}
.anchor-btn:hover {
  background: rgba(122, 167, 255, .12);
  border-color: rgba(122, 167, 255, .35);
  color: var(--text);
}
.anchor-btn.active {
  background: rgba(122, 167, 255, .22);
  border-color: rgba(122, 167, 255, .50);
  color: #fff;
  box-shadow: 0 0 8px rgba(122, 167, 255, .25);
}

/* ── Toolbar tool buttons ─────────────────────────────────────── */
.toolbar-row {
  gap: 6px !important;
  align-items: center;
}
.toolbar-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, .12);
  margin: 0 2px;
}
.tool-btn {
  position: relative;
}
.tool-btn.tool-active {
  border-color: rgba(122, 167, 255, .55) !important;
  background: linear-gradient(180deg, rgba(122, 167, 255, .30), rgba(26, 32, 64, .95)) !important;
  color: #a0c4ff !important;
  box-shadow: 0 0 12px rgba(122, 167, 255, .20);
}

/* ── Eraser brush controls ────────────────────────────────────── */
.btn.eraser-active {
  border-color: rgba(255, 107, 122, .55) !important;
  background: linear-gradient(180deg, rgba(255, 107, 122, .28), rgba(26, 32, 64, .95)) !important;
  color: #ff9da7 !important;
}
.btn.brush-active {
  border-color: rgba(122, 167, 255, .50) !important;
  background: linear-gradient(180deg, rgba(122, 167, 255, .28), rgba(26, 32, 64, .95)) !important;
  color: #a0c4ff !important;
}

/* ── Eraser modal body ────────────────────────────────────────── */
.eraser-modal-body .field {
  margin-bottom: 6px;
}

/* ── Crop confirm bar ─────────────────────────────────────────── */
.crop-confirm-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 0;
  background: rgba(122, 167, 255, .08);
  border-bottom: 1px solid rgba(122, 167, 255, .18);
}
.crop-confirm-bar.open {
  display: flex;
}
.crop-info {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  flex: 1;
}

/* ── Remove BG preset buttons ─────────────────────────────────── */
.removebg-preset.active {
  border-color: rgba(132, 241, 192, .50) !important;
  background: linear-gradient(180deg, rgba(132, 241, 192, .22), rgba(26, 32, 64, .95)) !important;
  color: #a0f6d4 !important;
}

/* ── Eraser cursor overlay ────────────────────────────────────── */
.eraser-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 15000;
  border: 2px solid #ff6b7a;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: none;
  background: rgba(255, 107, 122, .12);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.eraser-cursor.show {
  display: block;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 980px) {
  body { overflow: auto; }
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100%;
  }
  .right { height: 72vh; }
  .statusText .title,
  .statusText .desc { max-width: 78vw; }
}
