/* ═══ Editor shell (shared by both editors) + image editor specifics ═══ */

.editor { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.ed-top {
  display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 10px;
  background: var(--glass); border-bottom: 1px solid var(--stroke-soft); flex: none;
  backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4);
}
.ed-top .title-input {
  border: 1px solid transparent; background: transparent; color: var(--text-1);
  font-weight: 600; font-size: 14px; padding: 6px 9px; border-radius: var(--radius-s);
  width: 200px; outline: none;
}
.ed-top .title-input:hover { border-color: var(--stroke); }
.ed-top .title-input:focus { border-color: var(--accent); background: var(--bg-2); }
.ed-top .zoom-lbl { font-size: 12px; color: var(--text-2); min-width: 42px; text-align: center; cursor: pointer; }

.ed-main { flex: 1; display: flex; min-height: 0; }

/* left icon rail */
.ed-rail {
  width: 64px; flex: none; background: var(--bg-1); border-right: 1px solid var(--stroke-soft);
  display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 2px; overflow-y: auto;
}
.ed-rail button {
  width: 56px; padding: 8px 0 6px; border: 0; background: transparent; color: var(--text-2);
  border-radius: var(--radius-m); cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 3px; font-size: 10px; line-height: 1.1;
}
.ed-rail button svg { width: 19px; height: 19px; }
.ed-rail button:hover { color: var(--text-1); background: var(--bg-2); }
.ed-rail button.on { color: var(--accent); background: var(--accent-soft); }

/* slide-out panel */
.ed-panel {
  width: 300px; flex: none; background: var(--bg-1); border-right: 1px solid var(--stroke-soft);
  overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px;
}
.ed-panel h4 { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); margin: 4px 0 2px; }
.panel-sec-head { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); margin: 4px 0 2px; }

.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.tpl-thumb {
  border-radius: var(--radius-m); overflow: hidden; cursor: pointer; border: 1.5px solid var(--stroke);
  background: var(--thumb-bg); transition: all var(--dur-fast); position: relative;
}
.tpl-thumb:hover { border-color: var(--accent); transform: translateY(-1px); }
.tpl-thumb.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.tpl-thumb canvas { width: 100%; height: auto; display: block; }
.tpl-thumb .nm {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 7px; font-size: 10.5px;
  background: linear-gradient(transparent, rgba(0,0,0,.72)); color: #fff;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

.style-chip {
  width: 100%; text-align: center; padding: 10px 8px; border-radius: var(--radius-m);
  border: 1px solid var(--stroke); background: var(--bg-2); color: var(--text-1); cursor: pointer;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; transition: border-color var(--dur-fast);
}
.style-chip:hover { border-color: var(--accent); }

.emoji-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.emoji-grid button {
  font-size: 24px; padding: 6px 0; background: transparent; border: 0; border-radius: var(--radius-s);
  cursor: pointer; transition: background var(--dur-fast), transform var(--dur-fast);
}
.emoji-grid button:hover { background: var(--bg-2); transform: scale(1.2); }

.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shape-grid button {
  aspect-ratio: 1.4; border-radius: var(--radius-m); border: 1px solid var(--stroke); background: var(--bg-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-2);
}
.shape-grid button:hover { border-color: var(--accent); color: var(--text-1); }
.shape-grid .shp { background: currentColor; }

.media-mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.media-mini-grid .cell {
  aspect-ratio: 1; border-radius: var(--radius-s); overflow: hidden; border: 1px solid var(--stroke);
  background: var(--thumb-bg); cursor: pointer; padding: 0;
}
.media-mini-grid .cell img { width: 100%; height: 100%; object-fit: cover; }
.media-mini-grid .cell:hover { border-color: var(--accent); }

.filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.filter-item { cursor: pointer; text-align: center; }
.filter-item canvas { width: 100%; border-radius: var(--radius-s); border: 1.5px solid var(--stroke); display: block; }
.filter-item.on canvas { border-color: var(--accent); }
.filter-item span { font-size: 10.5px; color: var(--text-2); display: block; margin-top: 3px; }

/* center stage */
.ed-stage {
  flex: 1; min-width: 0; position: relative; overflow: hidden; background: var(--bg-canvas);
  display: flex; align-items: center; justify-content: center;
}
/* flex: none + max-width: none — the base reset's max-width would clamp the
   zoomed width while the zoomed height stays, which reads as vertical stretch */
.ed-stage canvas.stage-canvas { box-shadow: var(--shadow-2); border-radius: 2px; touch-action: none; flex: none; max-width: none; }
.ed-stage .stage-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: var(--text-3); background: var(--bg-1); border: 1px solid var(--stroke-soft);
  padding: 5px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap;
}

/* right props */
.ed-props {
  width: 280px; flex: none; background: var(--bg-1); border-left: 1px solid var(--stroke-soft);
  overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.ed-props h4 { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text-3); margin: 6px 0 2px; }
.props-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.props-row > label { font-size: 12.5px; color: var(--text-2); flex: none; }

.bg-swatch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.bg-swatch-grid .gsw { aspect-ratio: 1.5; border-radius: var(--radius-s); border: 1.5px solid var(--stroke); cursor: pointer; }
.bg-swatch-grid .gsw:hover, .bg-swatch-grid .gsw.on { border-color: var(--accent); }
.bg-swatch-grid .gsw-none {
  background:
    linear-gradient(45deg, var(--bg-3) 25%, transparent 25%, transparent 75%, var(--bg-3) 75%),
    linear-gradient(45deg, var(--bg-3) 25%, var(--bg-1) 25%, var(--bg-1) 75%, var(--bg-3) 75%);
  background-size: 12px 12px; background-position: 0 0, 6px 6px;
}

/* layers list */
.layer-list { display: flex; flex-direction: column; gap: 3px; }
.layer-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 7px 9px; border-radius: var(--radius-s); border: 1px solid transparent;
  background: transparent; color: var(--text-2); cursor: pointer; font-size: 12.5px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.layer-row:hover { background: var(--bg-2); color: var(--text-1); }
.layer-row.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text-1); }
.layer-row svg { flex: none; color: var(--text-3); }
.layer-row.on svg { color: var(--accent); }
.layer-row .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row { touch-action: none; }
.layer-row.dragging { opacity: .5; }
.layer-drop { height: 3px; border-radius: 2px; background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); margin: 1px 4px; }
.layer-x {
  flex: none; border: 0; background: transparent; color: var(--text-3); cursor: pointer;
  padding: 3px; border-radius: 5px; display: inline-flex;
}
.layer-x:hover { color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, transparent); }

/* draggable panel splitters (size remembered per browser) */
.splitter { flex: none; position: relative; z-index: 5; transition: background var(--dur-fast); }
.splitter.sp-v { width: 5px; margin: 0 -2px; cursor: col-resize; }
.splitter.sp-h { height: 5px; margin: -2px 0; cursor: row-resize; }
.splitter:hover, .splitter.dragging { background: var(--accent); }

@media (max-width: 1100px) { .ed-props { width: 240px; } .ed-panel { width: 264px; } }

/* ── custom font list (props panel) — identical in every browser ── */
.font-list {
  /* flex: none is load-bearing: the props panel is a flex column, and Firefox
     shrinks scrollable flex children to nothing instead of letting the panel
     scroll — Chrome happens to keep the height, Firefox collapses it to 10px */
  flex: none; height: 216px; overflow-y: auto; border: 1px solid var(--stroke);
  border-radius: var(--radius-m); background: var(--bg-2);
  display: flex; flex-direction: column; gap: 1px; padding: 4px;
}
.font-opt {
  text-align: left; padding: 7px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-1); font-size: 15px; cursor: pointer;
}
.font-opt:hover { background: var(--bg-3); }
.font-opt.on { background: var(--accent-soft); color: var(--accent); }
.font-group {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-3); padding: 6px 10px 2px;
}

/* phone-only controls (see mobile.css for their live styles) */
.ed-drawer-btn { display: none; }
.ed-rename { display: none; }
.rail-more { display: none; }

/* ── collapsible props sections ── */
.acc { display: flex; flex-direction: column; }
.acc-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: transparent; border: 0; cursor: pointer; padding: 4px 0 2px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--text-3);
}
.acc-head:hover { color: var(--text-1); }
.acc-head svg { transition: transform var(--dur-fast); }
.acc-head.closed svg { transform: rotate(-90deg); }
.acc-body { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }

/* while background removal runs: the stage dims and a scan line sweeps it,
   so the wait unambiguously reads as work happening, not as a hang */
.ed-stage.bg-working::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: rgba(0, 0, 0, .32); z-index: 3;
}
.ed-stage.bg-working::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4;
  background: linear-gradient(105deg, transparent 40%,
    color-mix(in srgb, var(--accent) 55%, transparent) 50%, transparent 60%);
  background-size: 250% 100%;
  animation: bg-scan 1.15s linear infinite;
}
@keyframes bg-scan {
  from { background-position: 125% 0; }
  to   { background-position: -125% 0; }
}

/* Edit panel toolbox: an icon grid, so the whole toolset reads at a glance
   instead of a column of word buttons. Tooltips carry the name + what it does. */
.tool-h { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); margin: 2px 0 -2px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 5px; }
.tool-btn {
  display: flex; align-items: center; justify-content: center;
  height: 36px; border-radius: var(--radius-s);
  border: 1px solid var(--stroke); background: var(--bg-2); color: var(--text-2);
  cursor: pointer; transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.tool-btn { position: relative; }
.tool-btn.locked { color: var(--text-3); }
.lock-badge {
  position: absolute; right: 2px; bottom: 2px;
  display: flex; align-items: center; justify-content: center;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg-1); border: 1px solid var(--stroke); color: var(--text-2);
}
.tool-btn.on .lock-badge { background: #fff; border-color: #fff; color: var(--accent); }
.tool-btn:hover { background: var(--bg-3); color: var(--text-1); }
.tool-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
/* the accordion header can carry one action (Layers has "+ new drawing layer") */
.acc-row { display: flex; align-items: center; gap: 4px; }
.acc-row .acc-head { flex: 1; }
.acc-add { flex: none; width: 26px; height: 26px; }
/* Actions explain themselves: the button says what happens, the line under it
   says it in plain words, so nobody has to hover to tell Cut out from Delete. */
.act { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.act > .btn { width: 100%; justify-content: flex-start; }
.act-note { font-size: 10.5px; line-height: 1.35; color: var(--text-3); padding-left: 2px; }
/* quick colour swatches in the Fill dialog */
.sw { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--stroke); cursor: pointer; padding: 0; }
.sw:hover { transform: scale(1.08); }

/* Pan arrows: zoomed in, each side that still has picture beyond it gets one.
   Hover or hold slides the canvas. Holding is what makes this usable on a
   phone, where there is no pointer to hover the stage edge with. */
.pan-arrow {
  position: absolute; z-index: 6; display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 999px; border: 0; padding: 0; cursor: pointer;
  color: #fff; background: rgba(18, 18, 22, .5);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  opacity: .55; transition: opacity var(--dur-fast), background var(--dur-fast);
  touch-action: none;
}
.pan-arrow:hover, .pan-arrow:active { opacity: 1; background: rgba(18, 18, 22, .78); }
.pan-arrow.hidden { display: none; }
.pan-top { top: 10px; left: 50%; transform: translateX(-50%); }
.pan-bottom { bottom: 10px; left: 50%; transform: translateX(-50%); }
.pan-left { left: 10px; top: 50%; transform: translateY(-50%); }
.pan-right { right: 10px; top: 50%; transform: translateY(-50%); }
/* bigger targets where fingers do the work, and always legible */
@media (pointer: coarse) {
  .pan-arrow { width: 44px; height: 44px; opacity: .8; }
}

/* Layer actions that ride on the selection: arranging happens where you are
   already looking, instead of in the side panel. Translucent so they never
   hide the artwork underneath. */
.sel-actions {
  position: absolute; z-index: 7; display: flex; gap: 3px; padding: 3px;
  transform: translateX(-50%);
  border-radius: 10px; background: rgba(18, 18, 22, .55);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .14);
}
.sel-actions.hidden { display: none; }
.sel-act {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 0; border-radius: 7px; padding: 0;
  background: none; color: #fff; opacity: .82; cursor: pointer;
}
.sel-act:hover { opacity: 1; background: rgba(255, 255, 255, .16); }
@media (pointer: coarse) { .sel-act { width: 34px; height: 34px; } }
.sel-act.danger { color: #ff8078; }
.sel-act.danger:hover { background: rgba(255, 90, 80, .22); }
