/* ═══════════════════════════════════════════════════════════════════
   Colurvist PHOTO — standalone pro photo editor
   Self-contained on purpose: does not load styles.css / app.js.
   Original dark-minimal design language — not anyone's clone.

   Themes: html[data-ptheme]  (carbon default · graphite · midnight · light)
   Layouts: html[data-playout] (classic default · flipped · focus · compact)
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --p-bg:      #0a0a0b;
  --p-bg2:     #101012;
  --p-panel:   #151517;
  --p-panel2:  #1b1b1e;
  --p-border:  #26262a;
  --p-border2: #333338;
  --p-text:    #ededed;
  --p-muted:   #9a9a9f;
  --p-dim:     #6b6b70;
  --p-accent:  #ffffff;
  --p-accent-ink: #000000;
  --p-green:   #4caf7d;
  --p-red:     #c0554a;
  --p-stage1:  #131315;
  --p-stage2:  #0a0a0b;
  /* the empty document is a FLAT sheet — this replaced the transparency checkerboard,
     which read as pattern behind every photo. One tone per theme, drawn by drawStage. */
  --p-sheet:   #1a1a1e;
  /* the ＋ split button (cv-split.js) reads these — mapped to the theme so the
     trigger stays accent-on-accent-ink in Daylight too */
  --cvsp-bg: var(--p-accent); --cvsp-ink: var(--p-accent-ink);
  --cvsp-act-bg: var(--p-panel2); --cvsp-act-ink: var(--p-text);
  --p-veil:    rgba(16,16,18,.55);
  --p-statusbg: rgba(10,10,11,.82);
  --p-glow:    rgba(255,255,255,.35);
  --p-font:    'Montserrat', system-ui, sans-serif;
  --p-radius:  6px;
  --p-rail-w:  84px;
  --p-side-w:  248px;
}

html[data-ptheme="graphite"] {
  --p-bg: #17181b; --p-bg2: #1c1d21; --p-panel: #232428; --p-panel2: #2a2b30;
  --p-border: #34353b; --p-border2: #41424a;
  --p-text: #f0f0f2; --p-muted: #a6a7ad; --p-dim: #77787f;
  --p-stage1: #202126; --p-stage2: #17181b;
  --p-sheet: #242529;
  --p-veil: rgba(28,29,33,.55); --p-statusbg: rgba(23,24,27,.85);
}
html[data-ptheme="midnight"] {
  --p-bg: #090d18; --p-bg2: #0d1220; --p-panel: #121a2c; --p-panel2: #182238;
  --p-border: #1f2a44; --p-border2: #2b3854;
  --p-text: #e8edf7; --p-muted: #93a0ba; --p-dim: #64708c;
  --p-accent: #9db7ff; --p-accent-ink: #0a1020; --p-glow: rgba(157,183,255,.4);
  --p-stage1: #101828; --p-stage2: #090d18;
  --p-sheet: #131b2c;
  --p-veil: rgba(13,18,32,.55); --p-statusbg: rgba(9,13,24,.85);
}
html[data-ptheme="light"] {
  --p-bg: #e6e7ea; --p-bg2: #f2f3f5; --p-panel: #ffffff; --p-panel2: #e9eaee;
  --p-border: #d3d5da; --p-border2: #bfc2c9;
  --p-text: #191a1d; --p-muted: #5c5f66; --p-dim: #8b8e96;
  --p-accent: #1b1c20; --p-accent-ink: #ffffff; --p-glow: rgba(0,0,0,.25);
  --p-stage1: #d6d8dc; --p-stage2: #c6c8cd;
  --p-sheet: #cfd1d6;
  --p-veil: rgba(255,255,255,.6); --p-statusbg: rgba(242,243,245,.88);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body.ph-body {
  height: 100%;
  overflow: hidden;
  background: var(--p-bg);
  color: var(--p-text);
  font-family: var(--p-font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
body.ph-body { display: flex; flex-direction: column; }

button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── sliders — matched to the main editor's hairline + glow-dot look ── */
.ph-body input[type=range] {
  -webkit-appearance: none; appearance: none;
  height: 2px; background: var(--p-border2);
  border-radius: 1px; outline: none; cursor: pointer;
}
.ph-body input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--p-accent); cursor: pointer;
  box-shadow: 0 0 8px var(--p-glow);
}
.ph-body input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%;
  background: var(--p-accent); cursor: pointer;
  box-shadow: 0 0 8px var(--p-glow);
}
.ph-body input[type=range]::-moz-range-track { height: 2px; background: var(--p-border2); border-radius: 1px; }

/* ── top bar ─────────────────────────────────────────────────────── */
.ph-top {
  display: flex; align-items: center; gap: 18px;
  height: 46px; padding: 0 14px;
  background: var(--p-bg2);
  border-bottom: 1px solid var(--p-border);
  flex: 0 0 auto;
  z-index: 40;
}
.ph-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--p-text); }
.ph-wordmark { height: 14px; mix-blend-mode: screen; display: block; }
html[data-ptheme="light"] .ph-wordmark { mix-blend-mode: multiply; filter: invert(1); }
.ph-appname {
  font-size: 10px; font-weight: 700; letter-spacing: 3px;
  color: var(--p-muted); border: 1px solid var(--p-border2);
  padding: 2px 7px 2px 9px; border-radius: 3px;
}

.ph-menubar { display: flex; gap: 2px; }
.ph-menu { position: relative; }
.ph-menu-trig {
  padding: 6px 11px; border-radius: 4px;
  font-size: 12.5px; font-weight: 500; color: var(--p-muted);
}
.ph-menu-trig:hover, .ph-menu.open .ph-menu-trig { background: var(--p-panel2); color: var(--p-text); }
.ph-menu-drop {
  position: absolute; top: calc(100% + 4px); left: 0;
  min-width: 228px; padding: 5px;
  background: var(--p-panel);
  border: 1px solid var(--p-border2); border-radius: 8px;
  box-shadow: 0 14px 44px rgba(0,0,0,.6);
  display: none; z-index: 60;
}
.ph-menu-right { left: auto; right: 0; }
.ph-menu.open .ph-menu-drop { display: block; }
.ph-mi {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 7px 10px; border-radius: 5px;
  font-size: 12.5px; color: var(--p-text); text-align: left;
}
.ph-mi:hover { background: var(--p-panel2); }
.ph-mi[disabled] { opacity: .35; pointer-events: none; }
.ph-mi .ph-mi-k { margin-left: auto; font-size: 10.5px; color: var(--p-dim); letter-spacing: .5px; }
.ph-mi .ph-mi-check { width: 14px; color: var(--p-accent); flex: 0 0 auto; font-size: 11px; }
.ph-mi-sep { height: 1px; margin: 5px 8px; background: var(--p-border); }
.ph-mi-head { padding: 7px 10px 3px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px; color: var(--p-dim); text-transform: uppercase; }

.ph-topright { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.ph-topdiv { width: 1px; height: 20px; background: var(--p-border); margin: 0 6px; }
.ph-iconbtn {
  width: 30px; height: 30px; border-radius: 5px;
  display: grid; place-items: center; color: var(--p-muted);
}
.ph-iconbtn:hover { background: var(--p-panel2); color: var(--p-text); }
.ph-iconbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ph-iconbtn[disabled] { opacity: .3; pointer-events: none; }
.ph-menu.open .ph-layoutbtn { background: var(--p-panel2); color: var(--p-text); }
.ph-export-btn {
  padding: 7px 18px; border-radius: 6px;
  background: var(--p-accent); color: var(--p-accent-ink);
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
}
.ph-export-btn:hover { filter: brightness(.86); }

/* ── options bar ─────────────────────────────────────────────────── */
.ph-opts {
  display: flex; align-items: center; gap: 14px;
  height: 42px; padding: 0 14px;
  background: var(--p-bg2);
  border-bottom: 1px solid var(--p-border);
  flex: 0 0 auto; overflow-x: auto; overflow-y: hidden;
  white-space: nowrap; z-index: 30;
}
.ph-opts::-webkit-scrollbar { height: 0; }
.ph-opt { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--p-muted); flex: 0 0 auto; }
.ph-opt b { color: var(--p-text); font-weight: 600; font-size: 11.5px; }
.ph-opt input[type=range] { width: 92px; }
.ph-opt input[type=number] {
  width: 56px; padding: 4px 6px;
  background: var(--p-panel); color: var(--p-text);
  border: 1px solid var(--p-border2); border-radius: 4px; font-size: 12px;
}
.ph-opt select {
  padding: 4px 8px; background: var(--p-panel); color: var(--p-text);
  border: 1px solid var(--p-border2); border-radius: 4px; font-size: 12px;
  max-width: 170px;
}
.ph-opt-val { min-width: 34px; text-align: right; color: var(--p-text); font-variant-numeric: tabular-nums; }
.ph-optname {
  font-size: 10px; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--p-text); padding: 5px 10px; border-radius: 4px;
  background: var(--p-panel2); border: 1px solid var(--p-border);
}
.ph-chip {
  padding: 5px 11px; border-radius: 5px; font-size: 11.5px; font-weight: 600;
  color: var(--p-muted); border: 1px solid var(--p-border2);
}
.ph-chip:hover { color: var(--p-text); border-color: var(--p-dim); }
.ph-chip.on { background: var(--p-accent); color: var(--p-accent-ink); border-color: var(--p-accent); }
.ph-chip-solid { background: var(--p-accent); color: var(--p-accent-ink); border-color: var(--p-accent); }
.ph-chip-solid:hover { filter: brightness(.86); color: var(--p-accent-ink); }

/* ── main split ──────────────────────────────────────────────────────────────
   DEFAULT: the tool strip runs along the BOTTOM of the screen (deliberately NOT
   the Photoshop left-rail look — user request 2026-08-17). Grid areas, so the
   side panels keep the full height while the tools sit under the stage only.
   The old vertical rail is still available as the "flipped" layout. */
.ph-main {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: 1fr var(--p-side-w);
  grid-template-rows: 1fr auto;
  grid-template-areas: "stage side" "tools side";
}
.ph-stagewrap { grid-area: stage; }
.ph-side { grid-area: side; }

/* ── tool strip — one horizontal row, grouped by hairlines ───────── */
.ph-tools {
  grid-area: tools;
  display: flex; flex-direction: row; align-items: center;
  /* `safe center` so a strip wider than the window scrolls from its left edge
     instead of clipping the first tools off-screen (plain center does that) */
  justify-content: center; justify-content: safe center;
  gap: 3px;
  padding: 7px 12px;
  background: var(--p-bg2);
  border-top: 1px solid var(--p-border);
  overflow-x: auto; overflow-y: hidden; z-index: 20;
}
.ph-tools::-webkit-scrollbar { width: 0; height: 0; }
.ph-tool {
  width: 34px; height: 34px; border-radius: 7px; flex: 0 0 34px;
  display: grid; place-items: center;
  color: var(--p-muted); position: relative;
  transition: background .12s, color .12s;
}
.ph-tool:hover { background: var(--p-panel2); color: var(--p-text); }
.ph-tool.on {
  background: var(--p-accent); color: var(--p-accent-ink);
  box-shadow: 0 0 14px var(--p-glow);
}
.ph-tool svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ph-tool-sep { width: 1px; height: 22px; flex: 0 0 1px; background: var(--p-border); margin: 0 6px; }

/* "flipped" = the classic vertical rail on the left */
html[data-playout="flipped"] .ph-main {
  grid-template-columns: var(--p-rail-w) 1fr var(--p-side-w);
  grid-template-rows: 1fr;
  grid-template-areas: "tools stage side";
}
html[data-playout="flipped"] .ph-tools {
  display: grid; grid-template-columns: repeat(2, 34px);
  gap: 3px; align-content: start; justify-content: center;
  padding: 10px 0;
  border-top: none; border-right: 1px solid var(--p-border);
  overflow-y: auto; overflow-x: hidden;
}
html[data-playout="flipped"] .ph-tool-sep { grid-column: 1 / -1; width: auto; height: 1px; margin: 5px 8px; }
html[data-playout="focus"] .ph-main {
  grid-template-columns: 1fr;
  grid-template-areas: "stage" "tools";
}
html[data-playout="focus"] .ph-side { display: none; }
html[data-playout="compact"] { --p-side-w: 208px; --p-rail-w: 46px; }
html[data-playout="compact"] .ph-tool { width: 30px; height: 30px; flex-basis: 30px; }

/* ── stage ───────────────────────────────────────────────────────── */
.ph-stagewrap {
  position: relative; min-width: 0; min-height: 0;
  background: radial-gradient(ellipse at 50% 40%, var(--p-stage1) 0%, var(--p-stage2) 75%);
  overflow: hidden;
}
#phStage, #phOverlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#phOverlay { pointer-events: none; }
#phStage { touch-action: none; }

.ph-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  z-index: 5;
}
.ph-empty.hidden { display: none; }
/* nothing but the ＋ button at rest — the dashed drop target only appears while a
   file is actually being dragged over the stage, so the affordance survives */
.ph-empty-in {
  text-align: center; padding: 40px 56px;
  border: 1.5px dashed transparent; border-radius: 16px;
  background: none;
  transition: border-color .16s, background .16s;
}
.ph-empty.drag .ph-empty-in { border-color: var(--p-accent); background: var(--p-veil); }

.ph-btn {
  padding: 9px 20px; border-radius: 7px;
  border: 1px solid var(--p-border2);
  color: var(--p-text); font-size: 12.5px; font-weight: 600;
}
.ph-btn:hover { border-color: var(--p-dim); }
.ph-btn-solid { background: var(--p-accent); color: var(--p-accent-ink); border-color: var(--p-accent); }
.ph-btn-solid:hover { filter: brightness(.86); }

.ph-status {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 18px;
  height: 26px; padding: 0 14px;
  background: var(--p-statusbg); backdrop-filter: blur(6px);
  border-top: 1px solid var(--p-border);
  font-size: 10.5px; color: var(--p-dim);
  font-variant-numeric: tabular-nums;
  z-index: 6;
}
.ph-st-spring { flex: 1; }
.ph-st-btn {
  padding: 2px 8px; border-radius: 4px;
  font-size: 10.5px; color: var(--p-muted);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.ph-st-btn:hover { color: var(--p-text); border-color: var(--p-border2); background: var(--p-panel); }

/* ── side panels ─────────────────────────────────────────────────── */
.ph-side {
  flex: 0 0 var(--p-side-w); display: flex; flex-direction: column;
  background: var(--p-bg2);
  border-left: 1px solid var(--p-border);
  overflow-y: auto; z-index: 20;
}
.ph-side::-webkit-scrollbar { width: 8px; }
.ph-side::-webkit-scrollbar-thumb { background: var(--p-border2); border-radius: 4px; }
.ph-panel { border-bottom: 1px solid var(--p-border); padding: 10px 12px 12px; }
.ph-panel-h {
  font-size: 10px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: var(--p-dim); margin-bottom: 9px;
  display: flex; align-items: center; gap: 8px;
}
.ph-panel-h::after { content: ""; flex: 1; height: 1px; background: var(--p-border); }
.ph-panel-layers { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 160px; }

/* color panel */
.ph-colors { display: flex; align-items: flex-start; gap: 12px; }
.ph-swatchpair { position: relative; width: 46px; height: 46px; flex: 0 0 auto; }
.ph-swatch {
  position: absolute; width: 30px; height: 30px;
  border: 2px solid var(--p-border2); border-radius: 6px;
  background: #fff; cursor: pointer; padding: 0;
  left: 0; top: 0; z-index: 2;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25);
}
.ph-swatch:hover { border-color: var(--p-dim); }
.ph-swatch-bg { left: auto; top: auto; right: 0; bottom: 0; z-index: 1; background: #000; }
.ph-swapxy {
  position: absolute; right: -4px; top: -6px;
  font-size: 11px; color: var(--p-dim);
}
.ph-swapxy:hover { color: var(--p-text); }
.ph-presetcolors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; flex: 1; }
.ph-pc { aspect-ratio: 1; border-radius: 3px; border: 1px solid rgba(128,128,128,.25); cursor: pointer; }
.ph-pc:hover { transform: scale(1.15); }

/* layers panel */
.ph-layerctl { display: flex; flex-direction: column; gap: 7px; margin-bottom: 9px; }
.ph-layerctl select {
  width: 100%; padding: 5px 8px;
  background: var(--p-panel); color: var(--p-text);
  border: 1px solid var(--p-border2); border-radius: 5px; font-size: 12px;
}
.ph-oprow { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--p-muted); }
.ph-oprow input[type=range] { flex: 1; }
.ph-oprow span { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; color: var(--p-text); }

.ph-layerlist { flex: 1 1 auto; overflow-y: auto; min-height: 90px; display: flex; flex-direction: column; gap: 3px; }
.ph-layerlist::-webkit-scrollbar { width: 6px; }
.ph-layerlist::-webkit-scrollbar-thumb { background: var(--p-border2); border-radius: 3px; }
.ph-lyr {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px; border-radius: 6px; cursor: pointer;
  border: 1px solid transparent;
}
.ph-lyr:hover { background: var(--p-panel); }
.ph-lyr.on { background: var(--p-panel2); border-color: var(--p-border2); }
.ph-lyr-eye { width: 20px; height: 20px; display: grid; place-items: center; color: var(--p-muted); flex: 0 0 auto; }
.ph-lyr-eye.off { color: var(--p-border2); }
.ph-lyr-eye svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.ph-lyr-thumb {
  width: 40px; height: 30px; flex: 0 0 auto;
  border: 1px solid var(--p-border2); border-radius: 3px;
  background: var(--p-sheet);        /* flat, same as the stage — no checkerboard */
  object-fit: contain;
}
/* the mask chip: the mask stores visibility as ALPHA, so painting its white
   pixels straight onto this black background is what makes it read as the
   familiar black-and-white mask without any per-pixel conversion */
.ph-lyr-mask {
  width: 40px; height: 30px; flex: 0 0 auto;
  border: 1px solid var(--p-border2); border-radius: 3px;
  background: #000;
}
.ph-lyr-mask.off { opacity: .35; }
/* which of the two canvases the paint tools are aimed at */
.ph-lyr-thumb.tgt, .ph-lyr-mask.tgt { border-color: var(--p-accent); box-shadow: 0 0 0 1px var(--p-accent); }
.ph-lyr-name { flex: 1; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-lyr-lock { width: 18px; height: 18px; display: grid; place-items: center; color: var(--p-border2); flex: 0 0 auto; }
.ph-lyr-lock:hover { color: var(--p-muted); }
.ph-lyr-lock.on { color: var(--p-muted); }
.ph-lyr-lock svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.ph-lyr-name input {
  width: 100%; background: var(--p-bg); color: var(--p-text);
  border: 1px solid var(--p-border2); border-radius: 3px; padding: 2px 4px; font-size: 11.5px;
}
.ph-layerbtns { display: flex; gap: 3px; margin-top: 8px; }
.ph-layerbtns button {
  flex: 1; height: 26px; border-radius: 5px;
  border: 1px solid var(--p-border); color: var(--p-muted); font-size: 12px;
}
.ph-layerbtns button:hover { color: var(--p-text); border-color: var(--p-border2); background: var(--p-panel); }

/* history panel */
.ph-panel-history { max-height: 180px; display: flex; flex-direction: column; }
.ph-historylist { overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
.ph-hi {
  text-align: left; padding: 5px 9px; border-radius: 5px;
  font-size: 11.5px; color: var(--p-muted);
}
.ph-hi:hover { background: var(--p-panel); color: var(--p-text); }
.ph-hi.on { background: var(--p-panel2); color: var(--p-text); }
.ph-hi.future { opacity: .4; }

/* ── modal ───────────────────────────────────────────────────────── */
.ph-modalback {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.62); backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
/* author display beats the UA's [hidden]{display:none} — restate it */
.ph-modalback[hidden] { display: none; }
.ph-modal {
  width: min(430px, calc(100vw - 40px));
  max-height: calc(100vh - 60px); overflow-y: auto;
  background: var(--p-panel);
  border: 1px solid var(--p-border2); border-radius: 14px;
  padding: 22px 24px;
  box-shadow: 0 30px 90px rgba(0,0,0,.7);
}
.ph-modal h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.ph-modal .ph-mrow { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-size: 12px; color: var(--p-muted); }
.ph-modal .ph-mrow label { flex: 0 0 92px; }
.ph-modal input[type=number], .ph-modal input[type=text], .ph-modal select {
  flex: 1; padding: 7px 10px;
  background: var(--p-bg2); color: var(--p-text);
  border: 1px solid var(--p-border2); border-radius: 6px; font-size: 12.5px;
  min-width: 0;
}
.ph-modal input[type=range] { flex: 1; }
.ph-mval { min-width: 40px; text-align: right; color: var(--p-text); font-variant-numeric: tabular-nums; font-size: 12px; }
.ph-mbtns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.ph-presetgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 14px; }
.ph-preset {
  padding: 9px 10px; border-radius: 7px; text-align: left;
  border: 1px solid var(--p-border2); font-size: 11.5px; color: var(--p-muted);
}
.ph-preset b { display: block; color: var(--p-text); font-size: 12px; margin-bottom: 2px; }
.ph-preset:hover, .ph-preset.on { border-color: var(--p-accent); color: var(--p-text); }

/* ── color picker ────────────────────────────────────────────────── */
.ph-picker {
  position: fixed; z-index: 95;
  width: 356px;
  background: var(--p-panel);
  border: 1px solid var(--p-border2); border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.65);
  display: flex; flex-direction: column;
  user-select: none;
}
.ph-picker[hidden] { display: none; }
.ph-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; cursor: grab;
  font-size: 10.5px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: var(--p-dim); border-bottom: 1px solid var(--p-border);
}
.ph-picker-head:active { cursor: grabbing; }
.ph-picker-x { color: var(--p-dim); font-size: 13px; padding: 2px 4px; }
.ph-picker-x:hover { color: var(--p-text); }
.ph-picker-body { display: flex; gap: 10px; padding: 14px; }
#phPkSV { width: 190px; height: 170px; border-radius: 6px; cursor: crosshair; flex: 0 0 auto; border: 1px solid var(--p-border2); }
#phPkHue { width: 16px; height: 170px; border-radius: 4px; cursor: ns-resize; flex: 0 0 auto; border: 1px solid var(--p-border2); }
.ph-picker-right { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ph-pk-preview { display: flex; gap: 8px; align-items: center; }
.ph-pk-chip { flex: 1; }
.ph-pk-chip span { display: block; font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: var(--p-dim); margin-bottom: 3px; }
.ph-pk-chip div { height: 26px; border-radius: 5px; border: 1px solid var(--p-border2); }
.ph-pk-grid { display: grid; grid-template-columns: auto 1fr; gap: 5px 7px; align-items: center; }
.ph-pk-grid label { font-size: 10px; color: var(--p-dim); text-align: right; }
.ph-pk-grid input {
  width: 100%; padding: 4px 7px;
  background: var(--p-bg2); color: var(--p-text);
  border: 1px solid var(--p-border2); border-radius: 4px;
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.ph-picker-foot {
  display: flex; gap: 8px; padding: 0 14px 12px;
}
.ph-picker-foot .ph-chip { flex: 1; text-align: center; }
.ph-pk-swatches {
  display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px;
  padding: 0 14px 14px;
}
.ph-pk-swatches .ph-pc { border-radius: 3px; }

/* ── progress readout ─────────────────────────────────────────────
   Shown only for work that actually takes time (the per-pixel filters on a big
   document). The percentage is the real row counter, never a fake timer. */
.ph-busy {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%);
  z-index: 96; display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-radius: 10px;
  background: var(--p-panel); border: 1px solid var(--p-border2);
  box-shadow: 0 14px 40px rgba(0,0,0,.55);
  font-size: 12px; color: var(--p-text); pointer-events: none;
}
.ph-busy[hidden] { display: none; }
.ph-busy-bar { width: 132px; height: 4px; border-radius: 2px; background: var(--p-border); overflow: hidden; }
.ph-busy-fill { height: 100%; width: 0%; background: var(--p-accent); transition: width .09s linear; }
.ph-busy-pct { min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; color: var(--p-muted); }

/* ── context menu ────────────────────────────────────────────────── */
.ph-ctx {
  position: fixed; z-index: 97;
  min-width: 208px; padding: 5px;
  background: var(--p-panel);
  border: 1px solid var(--p-border2); border-radius: 8px;
  box-shadow: 0 14px 44px rgba(0,0,0,.6);
}
.ph-ctx[hidden] { display: none; }
.ph-ctx .ph-mi[disabled] { opacity: .35; pointer-events: none; }

/* ── projects browser ────────────────────────────────────────────── */
.ph-modal-wide { width: min(620px, calc(100vw - 40px)); }
.ph-projlist { display: flex; flex-direction: column; gap: 7px; max-height: 52vh; overflow-y: auto; margin-bottom: 6px; }
.ph-proj {
  display: flex; align-items: center; gap: 12px;
  padding: 8px; border-radius: 9px;
  border: 1px solid var(--p-border); background: var(--p-bg2);
}
.ph-proj:hover { border-color: var(--p-border2); }
.ph-proj img {
  width: 86px; height: 58px; object-fit: cover; border-radius: 5px;
  border: 1px solid var(--p-border2); flex: 0 0 auto;
  background: var(--p-sheet);        /* flat, same as the stage — no checkerboard */
}
.ph-proj-info { flex: 1; min-width: 0; }
.ph-proj-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-proj-meta { font-size: 10.5px; color: var(--p-dim); margin-top: 2px; }
.ph-proj-x { color: var(--p-dim); font-size: 13px; padding: 6px; }
.ph-proj-x:hover { color: var(--p-red); }
.ph-proj-empty { padding: 30px 10px; text-align: center; color: var(--p-dim); font-size: 12.5px; line-height: 1.6; }

/* ── web photo search drawer ─────────────────────────────────────── */
.ph-websearch {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 88;
  width: 340px; display: flex; flex-direction: column;
  background: var(--p-bg2);
  border-left: 1px solid var(--p-border2);
  box-shadow: -18px 0 50px rgba(0,0,0,.5);
  animation: phWebIn .18s ease;
}
.ph-websearch[hidden] { display: none; }
@keyframes phWebIn { from { transform: translateX(24px); opacity: 0; } }
.ph-web-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px; border-bottom: 1px solid var(--p-border);
}
.ph-web-title { font-size: 10.5px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--p-dim); }
/* the drawer holds three kinds of thing now, one tab each */
.ph-web-tabs { display: flex; gap: 6px; padding: 11px 14px 4px; }
.ph-web-tabs .ph-chip { flex: 1; text-align: center; }
.ph-add-sec { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.ph-add-sec[hidden] { display: none; }

/* upload sits directly under the search field — the other way to get a picture in */
.ph-web-upload { padding: 2px 14px 10px; }
.ph-web-uploadbtn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 12px; }
.ph-web-uploadbtn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ── stickers ───────────────────────────────────────────────────── */
.ph-sticker-cats { display: flex; flex-wrap: wrap; gap: 5px; padding: 8px 14px 10px; }
.ph-sticker-cats .ph-chip { padding: 4px 9px; font-size: 11px; }
.ph-sticker-grid {
  flex: 1 1 auto; overflow-y: auto; padding: 0 14px 14px;
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; align-content: start;
}
.ph-sticker-grid::-webkit-scrollbar { width: 7px; }
.ph-sticker-grid::-webkit-scrollbar-thumb { background: var(--p-border2); border-radius: 4px; }
.ph-sticker {
  height: 52px; border-radius: 8px; border: 1px solid var(--p-border);
  background: var(--p-panel); cursor: pointer; font-size: 26px; line-height: 1;
  display: grid; place-items: center; padding: 0; transition: transform .1s, border-color .12s;
}
.ph-sticker:hover { border-color: var(--p-accent); transform: scale(1.08); }

/* ── movable effects ────────────────────────────────────────────── */
.ph-fx-note { padding: 8px 14px 6px; font-size: 11px; color: var(--p-dim); line-height: 1.5; }
.ph-fx-grid {
  flex: 1 1 auto; overflow-y: auto; padding: 0 14px 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start;
}
.ph-fx-grid::-webkit-scrollbar { width: 7px; }
.ph-fx-grid::-webkit-scrollbar-thumb { background: var(--p-border2); border-radius: 4px; }
.ph-fx-tile {
  position: relative; border-radius: 8px; overflow: hidden; padding: 0;
  border: 1px solid var(--p-border); background: #0c0c0e; cursor: pointer; height: 82px;
}
.ph-fx-tile:hover { border-color: var(--p-accent); }
.ph-fx-tile canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ph-fx-tile span {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 7px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,.86));
  color: #fff; font-size: 10px; font-weight: 600; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.ph-web-form { display: flex; gap: 7px; padding: 12px 14px 9px; }
.ph-web-form input {
  flex: 1; min-width: 0; padding: 8px 11px;
  background: var(--p-panel); color: var(--p-text);
  border: 1px solid var(--p-border2); border-radius: 7px; font-size: 12.5px;
  outline: none;
}
.ph-web-form input:focus { border-color: var(--p-dim); }
.ph-web-sources { display: flex; gap: 6px; padding: 0 14px 11px; flex-wrap: wrap; }
.ph-web-results {
  flex: 1 1 auto; overflow-y: auto; padding: 0 14px 14px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start;
}
.ph-web-results::-webkit-scrollbar { width: 7px; }
.ph-web-results::-webkit-scrollbar-thumb { background: var(--p-border2); border-radius: 4px; }
.ph-web-card {
  position: relative; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--p-border); background: var(--p-panel);
  cursor: pointer; padding: 0;
  /* fixed height, not aspect-ratio: Chromium sizes implicit grid rows
     before aspect-ratio resolves, so ratio-sized cards overflowed their
     rows and the photos stacked on each other */
  height: 148px;
}
/* absolutely positioned so the image's intrinsic size can NEVER stretch the
   card past its square slot — in-flow height:100% inside an aspect-ratio
   grid item let tall photos blow out and overlap the rows below */
.ph-web-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-web-card:hover { border-color: var(--p-accent); }
.ph-web-card:hover .ph-web-cap { opacity: 1; }
.ph-web-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 14px 7px 5px; opacity: 0; transition: opacity .14s;
  background: linear-gradient(transparent, rgba(0,0,0,.85));
  color: #fff; font-size: 9.5px; line-height: 1.3; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ph-web-msg { grid-column: 1 / -1; padding: 26px 6px; text-align: center; font-size: 12px; color: var(--p-dim); line-height: 1.6; }
.ph-web-foot { padding: 10px 14px 12px; border-top: 1px solid var(--p-border); font-size: 9.5px; color: var(--p-dim); line-height: 1.5; }
.ph-web-busy { grid-column: 1 / -1; display: grid; place-items: center; gap: 12px; padding: 30px 6px; }
.ph-web-slow { font-size: 10.5px; color: var(--p-dim); text-align: center; line-height: 1.5; }
.ph-spin {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--p-border2); border-top-color: var(--p-accent);
  animation: phSpin .8s linear infinite;
}
@keyframes phSpin { to { transform: rotate(360deg); } }

/* full screen: the browser paints its own black backdrop — keep our chrome flush */
.ph-body:fullscreen { background: var(--p-bg); }
.ph-body:fullscreen .ph-top { padding-top: 0; }

/* ── floating text editor ────────────────────────────────────────── */
.ph-textedit {
  position: absolute; z-index: 50;
  background: rgba(0,0,0,.25);
  border: 1.5px dashed rgba(255,255,255,.65); border-radius: 4px;
  color: #fff; padding: 4px 6px; outline: none; resize: both;
  min-width: 120px; min-height: 34px; overflow: hidden;
  line-height: 1.25;
}
html[data-ptheme="light"] .ph-textedit { background: rgba(255,255,255,.25); border-color: rgba(0,0,0,.55); }

/* cursors per tool — "icon" means photo.js set an inline data-URI cursor */
.ph-stagewrap[data-cursor="icon"] #phStage { cursor: crosshair; }
.ph-stagewrap[data-cursor="crosshair"] #phStage { cursor: crosshair; }
.ph-stagewrap[data-cursor="move"]      #phStage { cursor: move; }
.ph-stagewrap[data-cursor="grab"]      #phStage { cursor: grab; }
.ph-stagewrap[data-cursor="grabbing"]  #phStage { cursor: grabbing; }
.ph-stagewrap[data-cursor="text"]      #phStage { cursor: text; }
.ph-stagewrap[data-cursor="zoom-in"]   #phStage { cursor: zoom-in; }
.ph-stagewrap[data-cursor="zoom-out"]  #phStage { cursor: zoom-out; }
.ph-stagewrap[data-cursor="picker"]    #phStage { cursor: crosshair; }
.ph-stagewrap[data-cursor="none"]      #phStage { cursor: none; }

@media (max-width: 900px) {
  .ph-main { --p-side-w: 210px; }
  .ph-menubar { overflow-x: auto; }
}

/* editing together: a layer someone else is working on */
.ph-lyr.held { opacity: .55; }
.ph-lyr.held::after { content: "●"; color: var(--cvc-held, #7b3fe4); font-size: 9px; margin-left: 4px; }

/* ── COLOR WHEELS (2026-09-18) — the editor's instrument wheels, in Plate ─────────── */
.ph-wheels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 4px 0 6px; }
.ph-wbox { text-align: center; min-width: 0; }
.ph-wlbl { font-size: 9.5px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--p-text); margin-bottom: 10px; }
.ph-wlbl i { font-style: normal; color: var(--p-muted); margin-left: 6px; }
.ph-wheel { --wc: #fff; position: relative; width: 132px; max-width: 100%; aspect-ratio: 1; margin: 0 auto; border-radius: 50%; cursor: crosshair; touch-action: none;
  background:
    radial-gradient(circle, #0b0c0f 0 60%, rgba(11,12,15,0) 61%),
    radial-gradient(circle, rgba(8,9,11,.92) 0 62.5%, transparent 63.5%),
    conic-gradient(from 0deg, #ff4d4d, #ffb938, #d9e84a, #4fe07a, #35d6d0, #4c8dff, #a05bff, #ff4dc4, #ff4d4d);
  box-shadow: 0 0 0 1px rgba(255,255,255,.10), 0 0 0 5px #08090b, 0 0 0 6px rgba(255,255,255,.07), 0 10px 26px rgba(0,0,0,.55); }
.ph-wheel::before { content: ''; position: absolute; inset: 7%; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 50% 38%, rgba(255,255,255,.07), rgba(255,255,255,0) 58%), conic-gradient(from 0deg, rgba(255,77,77,.10), rgba(255,185,56,.10), rgba(79,224,122,.10), rgba(53,214,208,.10), rgba(76,141,255,.10), rgba(160,91,255,.10), rgba(255,77,77,.10));
  box-shadow: inset 0 0 18px rgba(0,0,0,.85), inset 0 0 0 1px rgba(255,255,255,.06); }
.ph-wheel .wgrid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ph-wheel .wgrid line, .ph-wheel .wgrid circle { stroke: rgba(255,255,255,.13); stroke-width: .5; fill: none; vector-effect: non-scaling-stroke; }
.ph-wheel .wgrid line.mj { stroke: rgba(255,255,255,.42); }
.ph-wheel .wgrid .wvec { stroke: var(--wc); stroke-width: 1.2; opacity: 0; }
.ph-wheel.live .wgrid .wvec { opacity: .9; filter: drop-shadow(0 0 3px var(--wc)); }
.ph-wheel .wdot { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; border-radius: 50%; transform: translate(-50%,-50%); pointer-events: none;
  background: #0b0c0f; border: 2px solid var(--wc); box-shadow: 0 0 0 1px rgba(0,0,0,.8), 0 0 10px var(--wc), inset 0 0 0 2px #0b0c0f, inset 0 0 0 6px var(--wc); }
.ph-wheel:active .wdot { width: 14px; height: 14px; }
.ph-wvals { display: flex; justify-content: center; gap: 5px; margin-top: 12px; font-size: 10px; font-variant-numeric: tabular-nums; }
.ph-wvals span, .ph-wlumv { display: inline-flex; align-items: baseline; gap: 5px; padding: 3px 7px; border-radius: 3px; background: rgba(255,255,255,.04); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); color: var(--p-text); }
.ph-wvals i, .ph-wlumv i { font-style: normal; font-size: 8.5px; letter-spacing: 1.2px; color: var(--p-muted); }
.ph-wvals b, .ph-wlumv b { font-weight: 500; min-width: 3ch; text-align: right; }
.ph-modal input.ph-wlum { width: 100%; margin: 10px 0 4px; }
.ph-wlumv { font-size: 10px; font-variant-numeric: tabular-nums; }
.ph-wfoot { display: flex; justify-content: flex-end; margin: 4px 0 2px; }
.ph-modal-wide:has(.ph-wheels) { width: min(560px, calc(100vw - 40px)); }
@media (max-width: 520px) { .ph-wheels { grid-template-columns: 1fr; } }

/* ── Plate add-ons (2026-09-22): curves pad · adjustment layers · groups · liquify ── */
.ph-h3-sub { margin-left: 8px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--p-dim); }
.ph-mnote { margin: 4px 0 0; font-size: 11.5px; line-height: 1.55; color: var(--p-muted); }
.ph-cv { margin: 0 0 14px; }
.ph-cv-seg { display: flex; border: 1px solid var(--p-border2); border-radius: 6px; overflow: hidden; }
.ph-cv-seg button { flex: 1 1 0; min-width: 0; height: 28px; padding: 0 8px; border: none; border-right: 1px solid var(--p-border2); background: transparent; color: var(--p-muted); font: inherit; font-size: 11.5px; cursor: pointer; transition: background .12s, color .12s; }
.ph-cv-seg button:last-child { border-right: none; }
.ph-cv-seg button:hover { color: var(--p-text); background: var(--p-panel2); }
.ph-cv-seg button.on { background: var(--p-accent); color: var(--p-accent-ink); }
.ph-cv-pad { display: block; margin: 10px auto 0; border: 1px solid var(--p-border); border-radius: 4px; background: var(--p-bg); cursor: crosshair; }
.ph-cv-read { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 11px; color: var(--p-dim); font-variant-numeric: tabular-nums; }
.ph-cv-reset { border: none; background: none; color: var(--p-muted); font: inherit; font-size: 11px; cursor: pointer; padding: 2px 0; }
.ph-cv-reset:hover { color: var(--p-text); }
/* layers panel */
.ph-lyr.in-grp { margin-left: 14px; }
.ph-lyr.adj .ph-lyr-name { font-style: italic; color: var(--p-muted); }
.ph-lyr.txt .ph-lyr-name::before { content: 'T'; display: inline-block; margin-right: 6px; font-family: Georgia, serif; font-weight: 700; font-size: 11px; color: var(--p-dim); }
.ph-grp { display: flex; align-items: center; gap: 6px; padding: 5px 7px 5px 3px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; color: var(--p-text); }
.ph-grp:hover { background: var(--p-panel); }
.ph-grp.on { background: var(--p-panel2); border-color: var(--p-border2); }
.ph-grp-caret { width: 16px; height: 20px; display: grid; place-items: center; border: none; background: none; color: var(--p-dim); cursor: pointer; padding: 0; }
.ph-grp-caret svg, .ph-grp-ico { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .14s; }
.ph-grp-caret.open svg { transform: rotate(90deg); }
.ph-grp-ico { width: 15px; height: 15px; color: var(--p-muted); flex: 0 0 auto; }
.ph-grp-n { font-size: 10px; color: var(--p-dim); font-variant-numeric: tabular-nums; }
/* liquify */
.ph-lq { display: flex; gap: 18px; align-items: flex-start; }
.ph-lq-stage { position: relative; flex: 1 1 auto; min-width: 0; line-height: 0; overflow: hidden; border: 1px solid var(--p-border); border-radius: 4px; background: var(--p-bg); }
.ph-lq-stage canvas { display: block; width: 100%; height: auto; max-height: 68vh; object-fit: contain; cursor: none; }
#phLqRing { position: absolute; display: none; border: 1px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,.7); pointer-events: none; }
.ph-lq-side { flex: 0 0 250px; }
.ph-lq-tools { flex-wrap: wrap; margin-bottom: 14px; }
.ph-lq-tools button { flex: 1 1 30%; border-bottom: 1px solid var(--p-border2); }
@media (max-width: 860px) { .ph-lq { flex-direction: column; } .ph-lq-side { flex: 1 1 auto; width: 100%; } }
