/* Photo Editor — workspace layout. Colours come from the kit's variables so light and dark both work. */
.pe-main { max-width: 1760px; }
.pe-hero { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; margin: 2px 0 12px; }
.pe-hero h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.pe-hero p { margin: 0; color: var(--text-2); font-size: 13.5px; }

.pe-app { display: flex; flex-direction: column; height: max(640px, calc(100vh - 140px)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); }
.pe-top { display: flex; align-items: center; gap: 4px; padding: 5px 8px; border-bottom: 1px solid var(--line); min-width: 0; }
.pe-top .grow { flex: 1; }
.pe-top .btn:disabled { opacity: .35; }
.pe-menus { display: flex; gap: 1px; flex: none; }
.pe-mwrap { position: relative; }
.pe-mbtn { height: 30px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text); font: 600 13px var(--font); cursor: pointer; }
.pe-mbtn:hover, .pe-mbtn[aria-expanded="true"] { background: var(--surface-3); }
.pe-menu { position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; min-width: 260px; max-height: min(70vh, 560px); overflow-y: auto; padding: 5px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: var(--shadow-pop); }
.pe-menu[hidden] { display: none; }
.pe-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.pe-mi { display: flex; width: 100%; align-items: center; gap: 18px; padding: 6px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--text);
  font: 13px var(--font); text-align: start; cursor: pointer; }
.pe-mi span { flex: 1; }
.pe-mi kbd { font: 11.5px var(--mono); color: var(--text-3); white-space: nowrap; }
.pe-mi:hover:not(:disabled), .pe-mi:focus-visible { background: var(--accent-soft); color: var(--accent); outline: none; }
.pe-mi:disabled { opacity: .4; cursor: default; }
.pe-name { min-width: 0; margin-left: 6px; }
.pe-name .input { width: 190px; max-width: 100%; height: 30px; padding: 3px 9px; font-weight: 600; font-size: 13px; }
.pe-save { font-size: 11.5px; white-space: nowrap; }
.pe-save.ok { color: var(--ok); }
.pe-save.warn { color: var(--warn); }

.pe-opts { display: flex; align-items: center; gap: 6px 14px; padding: 6px 12px; min-height: 46px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  flex-wrap: wrap; font-size: 12.5px; }
.pe-oname { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); padding-right: 4px; border-right: 1px solid var(--line); margin-right: 2px; }
.pe-oname .i { width: 18px; height: 18px; color: var(--accent); }
.pe-of { display: inline-flex; align-items: center; gap: 7px; color: var(--text-2); white-space: nowrap; }
.pe-of .select, .pe-of .input { height: 30px; padding: 3px 8px; font-size: 12.5px; }
.pe-of .select { max-width: 170px; }
.pe-num .input { width: 70px; }
.pe-rng input[type="range"] { width: 110px; accent-color: var(--accent); margin: 0; }
.pe-rng output { min-width: 44px; font-variant-numeric: tabular-nums; color: var(--text); font-size: 12px; }
.pe-seg button { padding: 4px 10px; font-size: 12px; }
.pe-seg .i { width: 16px; height: 16px; }
.pe-chk { font-size: 12.5px; white-space: nowrap; }
.pe-hint { color: var(--text-3); font-size: 12px; }
.pe-opts .btn.small { height: 30px; }

.pe-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 78px minmax(0, 1fr) 304px; }
.pe-tools { display: flex; flex-direction: column; gap: 10px; padding: 8px 6px; background: var(--surface-2); border-right: 1px solid var(--line); overflow-y: auto; }
.pe-tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.pe-tool { display: grid; place-items: center; height: 32px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer; }
.pe-tool:hover { color: var(--text); background: var(--surface-3); }
.pe-tool[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.pe-tool .i { width: 19px; height: 19px; }
.pe-colors { position: relative; width: 60px; height: 58px; margin: 2px auto 0; }
.pe-fg, .pe-bg { position: absolute; width: 34px; height: 34px; border-radius: 7px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; overflow: hidden; }
.pe-fg { left: 0; top: 0; z-index: 2; background: #111; }
.pe-bg { right: 0; bottom: 0; background: #fff; }
.pe-cin { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.pe-mini { position: absolute; width: 18px; height: 18px; padding: 0; border: 0; background: transparent; color: var(--text-2); cursor: pointer; display: grid; place-items: center; }
.pe-mini .i { width: 15px; height: 15px; }
.pe-mini:hover { color: var(--accent); }
.pe-swap { right: 0; top: 0; }
.pe-reset { left: 0; bottom: 0; }

.pe-center { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.pe-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; outline: none; touch-action: none; user-select: none; -webkit-user-select: none;
  background-color: var(--bg); background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 22px 22px; }
.pe-stage:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-soft); }
.pe-stage.is-over { box-shadow: inset 0 0 0 3px var(--accent); }
.pe-stage canvas { position: absolute; left: 0; top: 0; display: block; pointer-events: none; }
.pe-textedit { position: absolute; z-index: 3; margin: 0; padding: 0 4px; border: 0; border-radius: 0; background: transparent; resize: none; overflow: hidden;
  white-space: pre; transform-origin: center center; outline: 1.5px dashed var(--accent); outline-offset: 2px; caret-color: var(--accent); }
.pe-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; overflow-y: auto; z-index: 2; }
.pe-empty[hidden] { display: none; }
.pe-ecard { width: min(560px, 100%); text-align: center; padding: 28px 22px; background: var(--surface); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-lg); }
.pe-ecard h2 { margin: 6px 0 6px; font-size: 19px; }
.pe-ecard p { margin: 0 auto 16px; max-width: 420px; font-size: 13px; line-height: 1.5; }
.pe-eicon { width: 38px; height: 38px; color: var(--accent); }
.pe-ebtns { justify-content: center; gap: 8px; }
.pe-ecard h3, .pe-sheet h3 { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); margin: 22px 0 8px; }
.pe-egrid, .pe-recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; text-align: start; }
.pe-ritem { position: relative; }
.pe-ritem > .btn { position: absolute; top: 4px; right: 4px; background: var(--surface); }
.pe-rcard { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.pe-rcard:hover { border-color: var(--accent); }
.pe-rcard img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--surface-3); border-radius: 6px; margin-bottom: 4px; }
.pe-rcard b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-rcard .faint { font-size: 11px; }
.pe-busy { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6; padding: 6px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); color: var(--text); }
.pe-busy[hidden] { display: none; }
.pe-float { position: absolute; z-index: 5; top: 12px; right: 12px; width: 300px; max-width: calc(100% - 24px); max-height: calc(100% - 24px); overflow-y: auto;
  padding: 12px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-pop); font-size: 12.5px; }
.pe-float[hidden] { display: none; }
.pe-fhead { margin-bottom: 8px; }
.pe-fhead b { font-size: 14px; }
.pe-fbody { display: flex; flex-direction: column; gap: 8px; }
.pe-fbody .pe-rng { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; white-space: normal; }
.pe-fbody .pe-rng span { grid-column: 1 / -1; font-size: 12px; }
.pe-fbody .pe-rng input[type="range"] { width: 100%; }
.pe-fbody .pe-of:not(.pe-rng) { flex-wrap: wrap; }
.pe-ffoot { margin-top: 12px; gap: 6px; flex-wrap: wrap; }
.pe-hist, .pe-curve { display: block; width: 100%; border-radius: 6px; background: var(--surface-2); }
.pe-curve { aspect-ratio: 1; touch-action: none; cursor: crosshair; border: 1px solid var(--line); }
canvas.pe-hist { height: 70px; }
.pe-status { display: flex; align-items: center; gap: 12px; padding: 4px 10px; border-top: 1px solid var(--line); background: var(--surface); min-width: 0; font-size: 12px; }
.pe-zoom { display: flex; align-items: center; }
.pe-zl { min-width: 58px; justify-content: center; font-variant-numeric: tabular-nums; }

.pe-side { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; border-left: 1px solid var(--line); }
.pe-panel { border-bottom: 1px solid var(--line); }
.pe-panel > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3); cursor: pointer; user-select: none; }
.pe-panel > summary::-webkit-details-marker { display: none; }
.pe-panel > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--dur); }
.pe-panel[open] > summary::before { transform: rotate(45deg); }
.pe-panel > summary .faint { margin-left: auto; text-transform: none; letter-spacing: 0; font-weight: 500; }
.pe-pbody { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.pe-phead { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pe-phead .i { flex: none; color: var(--accent); width: 18px; height: 18px; }
.pe-phead b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-phead .faint { font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.pe-p { margin: 0; font-size: 12px; line-height: 1.45; }
.pe-pbody h3 { margin: 6px 0 0; font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }
.pe-pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; }
.pe-span2 { grid-column: 1 / -1; }
.pe-pf { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: 11.5px; color: var(--text-2); }
.pe-pf .input, .pe-pf .select { height: 30px; padding: 3px 8px; font-size: 12.5px; width: 100%; }
.pe-pcol input[type="color"] { width: 100%; height: 30px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.pe-pbody .textarea { min-height: 64px; font-size: 13px; padding: 7px 9px; }
.pe-prow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pe-prow .btn.small { height: 30px; }

.pe-lpanel { display: flex; flex-direction: column; flex: 1 0 auto; min-height: 220px; padding: 8px 10px 6px; }
.pe-lhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pe-lhead h2 { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); margin: 0; }
.pe-lblend .select { height: 30px; padding: 3px 8px; font-size: 12.5px; width: 138px; }
.pe-lop { display: grid; grid-template-columns: auto 1fr auto; margin: 6px 0; }
.pe-lop input[type="range"] { width: 100%; }
.pe-layers { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 60px; overflow-y: auto; }
.pe-layer { display: flex; align-items: center; gap: 5px; padding: 3px 4px; border: 1px solid transparent; border-radius: 9px; background: var(--surface-2); cursor: pointer; font-size: 12.5px; }
.pe-layer:hover { border-color: var(--line-strong); }
.pe-layer.on { border-color: var(--accent); background: var(--accent-soft); }
.pe-layer.off .pe-lmid, .pe-layer.off .pe-tb { opacity: .45; }
.pe-layer.over { box-shadow: 0 -2px 0 var(--accent); }
.pe-layer.drag { opacity: .4; }
.pe-lbtn { flex: none; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--text-3); cursor: pointer; }
.pe-lbtn:hover { color: var(--text); background: var(--surface-3); }
.pe-lbtn.lk { color: var(--warn); }
.pe-lbtn .i { width: 15px; height: 15px; }
.pe-tb { flex: none; padding: 0; border: 1.5px solid transparent; border-radius: 5px; background: none; cursor: pointer; line-height: 0; }
.pe-tb.on { border-color: var(--accent); }
.pe-mtb.off { opacity: .4; }
.pe-thumb { width: 44px; height: 34px; border-radius: 3px; display: block; }
.pe-lmid { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pe-lname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-lmeta { font-size: 10.5px; color: var(--text-3); text-transform: capitalize; }
.pe-rename { height: 26px; padding: 2px 6px; font-size: 12.5px; flex: 1; min-width: 0; }
.pe-lfoot { display: flex; align-items: center; gap: 0; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 6px; }
.pe-hist { position: relative; display: flex; flex-direction: column; gap: 1px; padding: 0 8px 10px; max-height: 210px; overflow-y: auto; }
.pe-hrow { padding: 5px 9px; border: 0; border-radius: 7px; background: transparent; color: var(--text); font: 12.5px var(--font); text-align: start; cursor: pointer; }
.pe-hrow:hover { background: var(--surface-3); }
.pe-hrow.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.pe-hrow.fut { color: var(--text-3); font-style: italic; }

/* dialogs */
.pe-sheet { width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.pe-sheet.wide { width: min(780px, calc(100vw - 24px)); }
.pe-sheet h2 { margin: 0; }
.pe-sheet .pe-of { flex-wrap: wrap; white-space: normal; }
.pe-foot { margin-top: 14px; gap: 8px; align-items: center; }
.pe-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.pe-preset { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; text-align: start; color: var(--text); font: inherit; font-size: 12.5px;
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; }
.pe-preset[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pe-preset .faint { font-size: 11px; }
.pe-custom { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.pe-custom .pe-of { flex-direction: column; align-items: flex-start; gap: 4px; }
.pe-custom .input { width: 120px; height: 34px; }
.pe-anchor { display: grid; grid-template-columns: repeat(3, 22px); gap: 3px; }
.pe-anchor button { width: 22px; height: 22px; padding: 0; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface-2); cursor: pointer; }
.pe-anchor button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.pe-sheet .tbl td { padding: 7px 8px; font-size: 13px; }

.pe-app.no-doc .pe-opts > :not(.pe-oname) { opacity: .5; pointer-events: none; }

@media (max-width: 1180px) {
  .pe-body { grid-template-columns: 78px minmax(0, 1fr) 270px; }
  .pe-hint { display: none; }
}
@media (max-width: 860px) {
  .pe-app { height: auto; border-radius: var(--radius); }
  .pe-top { flex-wrap: wrap; }
  .pe-menus { flex-basis: 100%; overflow-x: auto; scrollbar-width: none; }
  .pe-menu { position: fixed; left: 8px; right: 8px; top: auto; min-width: 0; }
  .pe-name .input { width: 130px; }
  .pe-save, .pe-lbl { display: none; }
  .pe-body { display: flex; flex-direction: column; }
  .pe-tools { flex-direction: row; align-items: center; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 4px 6px; }
  .pe-tgrid { display: flex; gap: 2px; }
  .pe-tool { width: 34px; flex: none; }
  .pe-colors { flex: none; width: 52px; height: 40px; margin: 0 4px; }
  .pe-fg, .pe-bg { width: 26px; height: 26px; }
  .pe-mini { display: none; }
  .pe-stage { flex: none; height: 64vh; min-height: 340px; }
  .pe-side { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .pe-lpanel { min-height: 0; }
  .pe-layers { max-height: 300px; }
  .pe-float { left: 8px; right: 8px; width: auto; top: 8px; max-height: 70%; }
  .pe-status #cursor { display: none; }
}
