/* Pixelstretch editor panel — same token language as the landing page. */

.editor { display: flex; }

/* --- Stage --- */

.ed-stage {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel2);
}

.ed-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel2);
}
.ed-toolbar-group { display: flex; align-items: center; gap: 10px; }

.ed-chip {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
}
.ed-chip:hover { border-color: var(--acc); }

.ed-seg {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.ed-seg-btn {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
}
.ed-seg-btn:hover { color: var(--ink); }
.ed-seg-btn.is-on { color: var(--acc-ink); background: var(--acc); }

/* .ed-seg sets display:flex, which overrides the UA [hidden] rule — restore it
   so the mode switch can hide the stretch tool/source rows in chameleon mode */
.ed-seg[hidden] { display: none; }

/* top-level editor mode switch — distinct from tool selection: a light pill,
   so "which tool" (accent yellow) reads apart from "which editor" (mode) */
.ed-mode-seg { border-color: var(--muted); }
.ed-mode-seg .ed-seg-btn.is-on { color: var(--bg); background: var(--ink); }

.ed-export { font-size: 11.5px; padding: 10px 18px; }

.ed-canvas-holder {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.ed-canvas-holder.is-dropping { outline: 2px dashed var(--acc); outline-offset: -14px; }

/* zoom control — bottom-right of the canvas holder */
.ed-zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  z-index: 3;
  backdrop-filter: blur(6px);
}
.ed-zoom[hidden] { display: none; }
.ed-zoom-btn {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  cursor: pointer;
}
.ed-zoom-btn:hover { color: var(--ink); background: var(--line); }
.ed-zoom-pct {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
  min-width: 42px;
  text-align: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0 2px;
}
.ed-zoom.is-zoomed .ed-zoom-pct { color: var(--acc); }
.ed-zoom-pct:hover { color: var(--ink); }

.ed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--rad);
  padding: 64px 84px;
}
.ed-empty[hidden] { display: none; }
.ed-empty-cta { font-size: 13px; padding: 15px 28px; }
.ed-empty-note {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
}

/* absolutely positioned at the holder's top-left; centering + pan come from a
   css translate the editor controls, so an overflowing (zoomed) image never
   gets start-aligned the way a flex child would */
.ed-frame { position: absolute; top: 0; left: 0; border: 1px solid var(--line); border-radius: var(--rad); overflow: hidden; }
.ed-frame[hidden] { display: none; }
.ed-frame canvas { display: block; }
#ed-gizmo { position: absolute; inset: 0; touch-action: none; }

.ed-hint {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 0 18px 14px;
  text-align: center;
}

/* --- Sidebar --- */

.ed-side {
  width: 320px;
  flex: none;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.ed-section { padding: 16px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }

/* the LAYERS list only takes the space it needs and scrolls on its own once it
   would push past the available height, so the BRUSH / MAGIC / CHAMELEON
   controls below it always stay visible without scrolling the whole sidebar */
#ed-sec-layers {
  flex: 0 1 auto;
  min-height: 96px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#ed-sec-layers .ed-strips {
  flex: 0 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.ed-eyebrow {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}

.ed-strips { display: flex; flex-direction: column; gap: 6px; }
.ed-strip-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}
.ed-strip-item:hover { border-color: var(--acc); }
.ed-strip-item.is-on { border-color: var(--acc); color: var(--acc); }
.ed-strip-del {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.ed-strip-del:hover { color: var(--acc); }
.ed-strip-name { flex: 1; text-align: left; }
.ed-strip-lock {
  background: none;
  border: 0;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  filter: grayscale(1) brightness(1.4);
}
.ed-strip-lock:hover { filter: none; }
.ed-strip-item[draggable='true'] { cursor: grab; }
/* the row being dragged rides the list at reduced opacity + a dashed accent
   outline, so you preview where it lands before releasing to commit */
.ed-strip-item.is-dragging {
  opacity: 0.5;
  border-style: dashed;
  border-color: var(--acc);
  cursor: grabbing;
}
.ed-strip-eye {
  background: none;
  border: 0;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  filter: grayscale(1) brightness(1.4);
}
.ed-strip-eye:hover { filter: none; }
.ed-strip-eye.is-off { opacity: 0.3; }
.ed-strip-item.is-hidden .ed-strip-name { opacity: 0.45; }
.ed-strip-kind {
  font-size: 11px;
  line-height: 1;
  padding: 0 2px;
  filter: grayscale(1) brightness(1.4);
}
@keyframes ed-strip-flash {
  0% { background: rgba(255, 212, 0, 0.4); }
  100% { background: var(--panel); }
}
.ed-strip-item.is-flash { animation: ed-strip-flash 0.9s ease-out; }
.ed-side-note {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.7;
  color: var(--muted);
  margin-top: 10px;
}
.ed-section > .ed-row { margin-bottom: 10px; }
.ed-section > .ed-ghost-btn { width: 100%; }
.ed-section > .ed-ghost-btn + .ed-ghost-btn { margin-top: 6px; }

/* --- Control groups --- */

.ed-group { border-bottom: 1px solid var(--line); }
.ed-group > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 13px 16px;
  cursor: pointer;
  user-select: none;
}
.ed-group > summary::-webkit-details-marker { display: none; }
.ed-group > summary::after { content: '+'; color: var(--muted); }
.ed-group[open] > summary::after { content: '−'; }
.ed-group > summary:hover { color: var(--ink); }
.ed-group-body { padding: 2px 16px 16px; display: flex; flex-direction: column; gap: 11px; }

.ed-row { display: flex; flex-direction: column; gap: 5px; }
.ed-row[hidden] { display: none; }
.ed-row-head { display: flex; align-items: baseline; justify-content: space-between; }
.ed-label { font-family: var(--font-ui); font-size: 11px; font-weight: 500; letter-spacing: 0.04em; color: var(--ink); }
.ed-value { font-family: var(--font-ui); font-size: 10.5px; font-weight: 600; color: var(--acc); }

.ed-range {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.ed-range::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line); }
.ed-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--acc);
  border: 0;
}
.ed-range::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line); }
.ed-range::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--acc); border: 0; }
.ed-range:focus-visible { outline: 1px solid var(--acc); outline-offset: 2px; border-radius: 4px; }

.ed-row-seg { display: flex; gap: 5px; }
.ed-opt {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 4px;
  cursor: pointer;
}
.ed-opt:hover { color: var(--ink); }
.ed-opt.is-on { color: var(--acc-ink); background: var(--acc); border-color: var(--acc); }

.ed-select {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 8px;
}

.ed-color-row { display: flex; align-items: center; gap: 8px; }
.ed-color {
  appearance: none;
  -webkit-appearance: none;
  width: 30px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}
.ed-color::-webkit-color-swatch-wrapper { padding: 2px; }
.ed-color::-webkit-color-swatch { border: 0; border-radius: 4px; }
.ed-color::-moz-color-swatch { border: 0; border-radius: 4px; }

.ed-ghost-btn {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  cursor: pointer;
}
.ed-ghost-btn:hover { border-color: var(--acc); }

/* --- Projects modal --- */

.ed-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}
.ed-modal[hidden] { display: none; }
.ed-modal-card {
  width: min(560px, 100%);
  max-height: min(80vh, 720px);
  overflow-y: auto;
  scrollbar-width: thin;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--rad);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ed-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ed-modal-head .ed-eyebrow { margin-bottom: 0; }
.ed-modal-saverow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
/* explicit display beats the UA [hidden] rule — restore it */
.ed-modal-saverow[hidden],
.ed-proj-list[hidden],
.ed-auth[hidden] { display: none; }
.ed-modal-saverow .ed-text { flex: 1; min-width: 140px; }
.ed-modal-target { flex: none; }
.ed-modal-savebtn { font-size: 11px; padding: 9px 16px; }
/* a save is in flight — no re-clicks (they used to spawn duplicate projects) */
.ed-modal-savebtn:disabled,
.ed-modal-saverow .ed-ghost-btn:disabled { opacity: 0.5; cursor: progress; }

.ed-text {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}
.ed-text:focus-visible { outline: 1px solid var(--acc); outline-offset: 1px; }

.ed-proj-list { display: flex; flex-direction: column; gap: 6px; }
.ed-proj-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
.ed-proj-item:hover { border-color: var(--acc); }
.ed-proj-item.is-on { border-color: var(--acc); }

/* in-app delete confirm — overlays the item, replaces window.confirm() */
.ed-proj-confirm {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px;
  background: rgba(13, 12, 19, 0.94);
  border-radius: 8px;
}
.ed-proj-confirm-msg {
  flex: 1;
  min-width: 0;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ed-proj-confirm-no { font-size: 10px; padding: 6px 12px; flex: none; }
.ed-proj-confirm-yes {
  flex: none;
  font-size: 10px;
  padding: 7px 16px;
  color: #fff;
  background: #ff4d67;
}
.ed-proj-confirm-yes:hover { color: #fff; background: #ff3355; }
.ed-proj-confirm-yes:disabled,
.ed-proj-confirm-no:disabled { opacity: 0.5; cursor: progress; }
.ed-proj-thumb {
  width: 64px;
  height: 36px;
  flex: none;
  border-radius: 5px;
  overflow: hidden;
  background: var(--line);
}
.ed-proj-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ed-proj-meta { flex: 1; min-width: 0; }
.ed-proj-name {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ed-proj-date {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-top: 2px;
}

.ed-auth { display: flex; flex-direction: column; gap: 8px; }

/* --- Sign-in card (logged-out modal) --- */

.ed-modal-card.is-login {
  width: min(400px, 100%);
  padding: 26px 32px 32px;
}
.ed-modal-card.is-login .ed-auth { gap: 12px; text-align: center; }
.ed-login-logo {
  width: 46px;
  height: 46px;
  margin: 0 auto 2px;
  background: var(--acc);
  color: var(--acc-ink);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-d);
  font-size: 26px;
}
.ed-login-title {
  font-family: var(--font-d);
  font-size: 25px;
  letter-spacing: 0.03em;
  color: var(--ink);
}
.ed-login-sub {
  font-size: 12px;
  font-weight: 500;
  line-height: 1.65;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin-bottom: 6px;
}
.ed-login-mail {
  padding: 13px 14px;
  font-size: 12.5px;
  text-align: center;
  border-radius: 9px;
}
.ed-login-primary {
  width: 100%;
  font-size: 12px;
  padding: 13px 18px;
}
.ed-login-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.ed-login-or::before,
.ed-login-or::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.ed-login-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 12px 14px;
  font-size: 11px;
  border-radius: 9px;
}
.ed-login-gsi { display: flex; justify-content: center; min-height: 40px; }
.ed-auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ed-auth-mail {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Chameleon pose grid --- */

.ed-cham-poses {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.ed-cham-pose {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  aspect-ratio: 1 / 1;
  padding: 5px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.03) 0 6px, rgba(255,255,255,0) 6px 12px),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
}
.ed-cham-pose:hover { border-color: var(--acc); }
.ed-cham-pose.is-on { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.ed-cham-pose canvas { max-width: 100%; max-height: 100%; display: block; }
.ed-cham-flipbtn { width: 100%; margin-bottom: 4px; }

/* --- Quality floor: small screens --- */

@media (max-width: 900px) {
  .editor { flex-direction: column; height: auto; }
  .ed-stage { min-height: 480px; }
  .ed-side { width: 100%; border-left: 0; border-top: 1px solid var(--line); max-height: 420px; }
  .ed-toolbar { flex-wrap: wrap; }
}
