/* The photo editor: the page (Pages/Photo) and everything js/photo-ui.js builds inside it. Chrome follows the app's
   tokens, so it follows light and dark with the rest of the site; only the workspace around the picture is its own. */

.pe-host { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.pe {
    --pe-work: #c9ccd3;
    --pe-line: var(--rl-border);
    --pe-shadow: 0 10px 34px rgba(15, 23, 42, .28), 0 1px 3px rgba(15, 23, 42, .18);
    position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
    background-color: var(--rl-bg); background-image: var(--rl-bg-image, none); background-attachment: fixed;
    color: var(--rl-text); font-size: .82rem; outline: none;
    user-select: none; -webkit-user-select: none;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .pe { --pe-work: #0f1114; --pe-shadow: 0 10px 34px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .5); }
}
:root[data-theme="dark"] .pe { --pe-work: #0f1114; --pe-shadow: 0 10px 34px rgba(0, 0, 0, .6), 0 1px 3px rgba(0, 0, 0, .5); }

.pe button { font: inherit; color: inherit; }
.pe-ico { display: inline-flex; flex: none; }
.pe__grow { flex: 1; }
.pe__hint { color: var(--rl-text-muted); font-size: .76rem; line-height: 1.35; }

/* ---- top bar and menus ---- */
.pe__top { display: flex; align-items: center; gap: .35rem; padding: .25rem .6rem; border-bottom: 1px solid var(--pe-line); background: var(--rl-surface); min-height: 2.5rem; }
/* Only a phone hides the sidebar outright; on a desktop the icon rail stays put. */
@media (max-width: 780px) { :root[data-sidebar="collapsed"] .pe__top { padding-left: 3.4rem; } }
.pe__brand { font-weight: 700; letter-spacing: .01em; margin-right: .4rem; }
.pe-menubar { display: flex; gap: .1rem; }
.pe-menubar__b { border: 0; background: transparent; padding: .3rem .6rem; border-radius: 8px; cursor: pointer; }
.pe-menubar__b:hover, .pe-menubar__b.is-open { background: var(--rl-surface-sunken); }

.pe-menu {
    position: absolute; z-index: 50; min-width: 15rem; max-height: 80vh; overflow-y: auto; padding: .25rem;
    background: var(--rl-surface); border: 1px solid var(--pe-line); border-radius: var(--rl-radius); box-shadow: var(--pe-shadow);
}
.pe-menu--sub { overflow: visible; max-height: none; z-index: 60; }
.pe-menu__subwrap { position: relative; }
.pe-menu__item {
    display: grid; grid-template-columns: 1.2rem 1fr auto; align-items: center; gap: .3rem; width: 100%; text-align: left;
    border: 0; background: transparent; padding: .34rem .5rem; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.pe-menu__item:hover:not(:disabled), .pe-menu__subwrap:hover > .pe-menu__item { background: var(--rl-accent); color: var(--rl-accent-contrast); }
.pe-menu__item.is-off { opacity: .42; cursor: default; }
.pe-menu__key { color: var(--rl-text-muted); font-size: .74rem; padding-left: 1.4rem; }
.pe-menu__item:hover:not(:disabled) .pe-menu__key, .pe-menu__subwrap:hover > .pe-menu__item .pe-menu__key { color: inherit; opacity: .85; }
.pe-menu__sep { height: 1px; margin: .25rem .3rem; background: var(--pe-line); }

.pe-ib { display: inline-grid; place-items: center; min-width: 1.9rem; height: 1.9rem; padding: 0 .3rem; border: 0; background: transparent; border-radius: 8px; cursor: pointer; }
/* Reason: the display above outranks the browser's own [hidden] rule, so a kit button marked hidden still showed. */
.pe-ib[hidden] { display: none; }
.pe-ib:hover:not(:disabled) { background: var(--rl-surface-sunken); }
.pe-ib:disabled { opacity: .35; cursor: default; }
.pe-ib.is-on { background: var(--rl-accent); color: var(--rl-accent-contrast); }
.pe-ib--panels { display: none; }

.pe-btn { border: 1px solid var(--pe-line); background: var(--rl-surface-raised); padding: .4rem .85rem; border-radius: 8px; cursor: pointer; }
.pe-btn:hover:not(:disabled) { background: var(--rl-surface-sunken); }
.pe-btn:disabled { opacity: .55; cursor: default; }
.pe-btn--sm { padding: .22rem .6rem; font-size: .8rem; }
.pe-btn--primary { background: var(--rl-accent); border-color: var(--rl-accent); color: var(--rl-accent-contrast); font-weight: 600; }
.pe-btn--primary:hover:not(:disabled) { background: var(--rl-accent); filter: brightness(1.08); }
.pe-btn--danger { color: var(--rl-danger); }

/* ---- options bar ---- */
.pe__opts { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; padding: .3rem .7rem; border-bottom: 1px solid var(--pe-line); background: var(--rl-surface-raised); min-height: 2.5rem; }
.pe__toolname { display: inline-flex; align-items: center; gap: .4rem; font-weight: 650; padding-right: .5rem; border-right: 1px solid var(--pe-line); margin-right: .1rem; }

.pe-rng { display: inline-flex; align-items: center; gap: .45rem; }
.pe-rng__label, .pe-sel__label { color: var(--rl-text-muted); font-size: .76rem; white-space: nowrap; }
.pe-rng input[type=range] { width: 7.5rem; accent-color: var(--rl-accent); }
.pe-rng__val { display: inline-flex; align-items: center; gap: .15rem; }
.pe-rng__num, .pe-input, .pe-hex, .pe-zoomnum {
    border: 1px solid var(--pe-line); background: var(--rl-surface); color: var(--rl-text); border-radius: 8px; padding: .2rem .35rem; font: inherit;
}
.pe-rng__num { width: 3.9rem; text-align: right; }
.pe-rng__unit { color: var(--rl-text-muted); font-size: .74rem; }
.pe-sel { display: inline-flex; align-items: center; gap: .4rem; }
.pe-sel select { border: 1px solid var(--pe-line); background: var(--rl-surface); color: var(--rl-text); border-radius: 8px; padding: .2rem .3rem; font: inherit; max-width: 12rem; }
.pe-sel input[type=color] { width: 2rem; height: 1.6rem; padding: 0; border: 1px solid var(--pe-line); border-radius: 5px; background: none; cursor: pointer; }
.pe-chk { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; white-space: nowrap; }
.pe-chk input { accent-color: var(--rl-accent); width: 1rem; height: 1rem; }
.pe-seg { display: inline-flex; align-items: center; gap: .4rem; }
.pe-seg__row { display: inline-flex; border: 1px solid var(--pe-line); border-radius: 8px; overflow: hidden; }
.pe-seg__b { border: 0; background: var(--rl-surface); padding: .22rem .6rem; cursor: pointer; border-right: 1px solid var(--pe-line); }
.pe-seg__b:last-child { border-right: 0; }
.pe-seg__b.is-on { background: var(--rl-accent); color: var(--rl-accent-contrast); }

/* ---- body: tools, stage, panels ---- */
.pe__body { flex: 1; min-height: 0; display: flex; position: relative; }
.pe__tools { width: 3.1rem; flex: none; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .4rem .2rem; overflow-y: auto; border-right: 1px solid var(--pe-line); background: var(--rl-surface); }
.pe__sep { width: 1.7rem; height: 1px; background: var(--pe-line); margin: .25rem 0; flex: none; }
.pe-tool { flex: none; width: 2.35rem; height: 2.35rem; display: grid; place-items: center; border: 0; background: transparent; border-radius: 9px; cursor: pointer; }
.pe-tool:hover { background: var(--rl-surface-sunken); }
.pe-tool.is-on { background: var(--rl-accent); color: var(--rl-accent-contrast); }
.pe-tool:focus-visible, .pe-ib:focus-visible, .pe-layer:focus-visible, .pe-menu__item:focus-visible { outline: 2px solid var(--rl-accent); outline-offset: 1px; }

.pe-pair { position: relative; width: 2.4rem; height: 2.4rem; flex: none; margin-top: .4rem; }
.pe-sw { appearance: none; -webkit-appearance: none; border: 2px solid var(--rl-surface); outline: 1px solid var(--pe-line); border-radius: 4px; padding: 0; cursor: pointer; position: absolute; width: 1.35rem; height: 1.35rem; background: none; }
.pe-sw::-webkit-color-swatch-wrapper { padding: 0; }
.pe-sw::-webkit-color-swatch { border: 0; border-radius: 2px; }
.pe-sw--fg { left: 0; top: 0; z-index: 2; }
.pe-sw--bg { right: 0; bottom: 0; }
.pe-pair__swap, .pe-pair__reset { position: absolute; border: 0; background: transparent; padding: 0; cursor: pointer; line-height: 1; color: var(--rl-text-muted); }
.pe-pair__swap { right: -1px; top: -2px; }
.pe-pair__reset { left: -2px; bottom: -3px; font-size: .8rem; }

.pe__center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pe__tabs { display: flex; align-items: stretch; overflow-x: auto; background: var(--rl-surface-raised); border-bottom: 1px solid var(--pe-line); min-height: 2rem; scrollbar-width: thin; }
.pe-tab { display: inline-flex; align-items: center; gap: .4rem; padding: 0 .35rem 0 .75rem; border: 0; border-right: 1px solid var(--pe-line); background: transparent; cursor: pointer; white-space: nowrap; max-width: 14rem; }
.pe-tab.is-on { background: var(--rl-bg); font-weight: 600; box-shadow: inset 0 -2px 0 var(--rl-accent); }
.pe-tab__name { overflow: hidden; text-overflow: ellipsis; }
.pe-tab__x { border: 0; background: transparent; border-radius: 5px; padding: .2rem; cursor: pointer; display: grid; place-items: center; opacity: .6; }
.pe-tab__x:hover { opacity: 1; background: var(--rl-surface-sunken); }
.pe-tab--new { padding: 0 .65rem; }

.pe__stage { flex: 1; min-height: 0; position: relative; overflow: hidden; background: var(--pe-work); }
.pe__stage.is-drop { outline: 3px dashed var(--rl-accent); outline-offset: -8px; }
.pe__view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.pe__welcome {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(30rem, 90%); text-align: center; z-index: 2;
    background: var(--rl-surface); border: 1px solid var(--pe-line); border-radius: 16px; padding: 1.6rem 1.4rem; box-shadow: var(--pe-shadow);
}
.pe__welcome h2 { font-size: 1.25rem; margin: 0 0 .5rem; }
.pe__welcome p { margin: 0 0 1rem; color: var(--rl-text-muted); }
.pe__welcomeBtns { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-bottom: 1rem; }

.pe__status { display: flex; align-items: center; gap: 1rem; padding: .15rem .7rem; border-top: 1px solid var(--pe-line); background: var(--rl-surface); color: var(--rl-text-muted); font-size: .75rem; min-height: 1.9rem; }
.pe__info--cur { font-variant-numeric: tabular-nums; min-width: 6rem; text-align: right; }
.pe-zoom { display: inline-flex; align-items: center; gap: .15rem; }
.pe-zoomnum { width: 3.6rem; text-align: right; padding: .1rem .25rem; }

.pe-text { position: absolute; z-index: 6; margin: 0; padding: 0; resize: none; overflow: hidden; white-space: pre; color: transparent; background: transparent; border: 1px dashed var(--rl-accent); outline: none; user-select: text; -webkit-user-select: text; }
.pe-text::selection { background: rgba(47, 109, 246, .35); }

/* ---- panels ---- */
.pe__panels { width: 17.5rem; flex: none; display: flex; flex-direction: column; min-height: 0; overflow-y: auto; border-left: 1px solid var(--pe-line); background: var(--rl-surface); }
.pe--nopanels .pe__panels { display: none; }
.pe-sec { border-bottom: 1px solid var(--pe-line); display: flex; flex-direction: column; min-height: 0; }
.pe-sec > summary { display: flex; align-items: center; gap: .35rem; padding: .4rem .6rem; cursor: pointer; font-weight: 650; list-style: none; background: var(--rl-surface-raised); }
.pe-sec > summary::-webkit-details-marker { display: none; }
.pe-sec > summary .pe-ico { transition: transform .12s; }
.pe-sec[open] > summary .pe-ico { transform: rotate(90deg); }
.pe-sec--grow[open] { flex: 1; }

.pe-colors { padding: .55rem .6rem .7rem; display: flex; flex-direction: column; gap: .5rem; }
.pe-hexrow { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--rl-text-muted); }
.pe-hex { width: 6.2rem; font-family: ui-monospace, Consolas, monospace; }
.pe-palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.pe-palette__c { aspect-ratio: 1; border: 1px solid rgba(128, 128, 128, .4); border-radius: 4px; cursor: pointer; padding: 0; }
.pe-palette__c:hover { outline: 2px solid var(--rl-accent); outline-offset: 1px; }

.pe-layerpanel { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.pe-layers__props { padding: .45rem .6rem; display: flex; flex-direction: column; gap: .4rem; border-bottom: 1px solid var(--pe-line); }
.pe-blend { width: 100%; border: 1px solid var(--pe-line); background: var(--rl-surface); color: var(--rl-text); border-radius: 8px; padding: .22rem .3rem; font: inherit; }
.pe-layers__props .pe-rng { display: grid; grid-template-columns: 3.6rem 1fr auto; }
.pe-layers__props .pe-rng input[type=range] { width: 100%; }
.pe-layers__locks { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .76rem; }
.pe-layers { flex: 1; min-height: 7rem; max-height: 24rem; overflow-y: auto; padding: .25rem; }
.pe-layer { display: flex; align-items: center; gap: .4rem; padding: .22rem .3rem; border-radius: 8px; cursor: pointer; border: 1px solid transparent; position: relative; }
.pe-layer:hover { background: var(--rl-surface-sunken); }
.pe-layer.is-active { background: color-mix(in srgb, var(--rl-accent) 18%, transparent); border-color: color-mix(in srgb, var(--rl-accent) 55%, transparent); }
.pe-layer.is-hidden .pe-thumb { opacity: .4; }
.pe-layer.is-drag { opacity: .45; }
.pe-layer.drop-above::before, .pe-layer.drop-below::after { content: ""; position: absolute; left: 4px; right: 4px; height: 2px; background: var(--rl-accent); border-radius: 2px; }
.pe-layer.drop-above::before { top: -2px; }
.pe-layer.drop-below::after { bottom: -2px; }
.pe-layer__eye { border: 0; background: transparent; padding: .15rem; border-radius: 5px; cursor: pointer; display: grid; place-items: center; color: var(--rl-text-muted); }
.pe-layer__eye:hover { color: var(--rl-text); }
.pe-layer__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-layer__rename { flex: 1; min-width: 0; border: 1px solid var(--rl-accent); border-radius: 5px; background: var(--rl-surface); color: var(--rl-text); padding: .1rem .3rem; font: inherit; user-select: text; }
.pe-layer__badge { font-size: .68rem; font-weight: 700; padding: 0 .3rem; border-radius: 4px; background: var(--rl-surface-sunken); color: var(--rl-text-muted); }
.pe-layer__lock { color: var(--rl-text-muted); display: inline-grid; }
.pe-thumb { flex: none; border: 1px solid var(--pe-line); border-radius: 3px; background: repeating-conic-gradient(#d4d6db 0 25%, #fff 0 50%) 0 0 / 8px 8px; }
.pe-thumb--mask { background: #000; }
.pe-thumb--mask.is-edit { outline: 2px solid var(--rl-accent); }
.pe-thumb--mask.is-off { opacity: .35; }
.pe-layers__bar { display: flex; align-items: center; padding: .25rem .4rem; border-top: 1px solid var(--pe-line); gap: .1rem; }

.pe-history { max-height: 13rem; overflow-y: auto; padding: .2rem; display: flex; flex-direction: column; }
.pe-history__row { text-align: left; border: 0; background: transparent; padding: .22rem .5rem; border-radius: 8px; cursor: pointer; }
.pe-history__row:hover { background: var(--rl-surface-sunken); }
.pe-history__row.is-on { background: color-mix(in srgb, var(--rl-accent) 20%, transparent); font-weight: 600; }
.pe-history__row.is-future { opacity: .45; }

/* ---- dialogs and toasts ---- */
.pe-dlg__back { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(8, 10, 14, .5); padding: 1rem; }
.pe-dlg__back--side { background: transparent; place-items: start end; padding: 3.2rem 1rem 1rem; }
.pe-dlg { width: min(30rem, 100%); max-height: 100%; display: flex; flex-direction: column; background: var(--rl-surface); color: var(--rl-text); border: 1px solid var(--pe-line); border-radius: 14px; box-shadow: var(--pe-shadow); outline: none; }
.pe-dlg--side { width: min(22rem, 100%); }
.pe-dlg--wide { width: min(44rem, 100%); }
.pe-dlg--side.pe-dlg--wide { width: min(22rem, 100%); }
.pe-dlg__head { padding: .75rem 1rem .4rem; }
.pe-dlg__head h2 { margin: 0; font-size: 1.02rem; }
.pe-dlg__body { padding: .3rem 1rem .8rem; overflow-y: auto; min-height: 0; }
.pe-dlg__foot { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; padding: .7rem 1rem; border-top: 1px solid var(--pe-line); }

.pe-form { display: flex; flex-direction: column; gap: .7rem; }
.pe-form__row { display: flex; gap: .7rem; flex-wrap: wrap; }
.pe-form__row > * { flex: 1; min-width: 7rem; }
.pe-field { display: flex; flex-direction: column; gap: .25rem; }
.pe-field__label { color: var(--rl-text-muted); font-size: .76rem; }
.pe-input { width: 100%; }
.pe-input--color { height: 2.1rem; padding: .1rem; }
.pe-form--fx .pe-rng { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; }
.pe-form--fx .pe-rng__label { grid-column: 1 / -1; }
.pe-form--fx .pe-rng input[type=range] { width: 100%; }
.pe-form--fx .pe-sel { display: flex; justify-content: space-between; }
.pe-hist { width: 100%; height: 70px; background: rgba(128, 128, 128, .12); border-radius: 6px; display: block; }
.pe-curve { width: 100%; max-width: 256px; aspect-ratio: 1; margin: 0 auto; display: block; border-radius: 6px; cursor: crosshair; touch-action: none; }
.pe-anchor { display: grid; grid-template-columns: repeat(3, 1.6rem); gap: 3px; }
.pe-anchor__c { width: 1.6rem; height: 1.6rem; border: 1px solid var(--pe-line); border-radius: 4px; background: var(--rl-surface-raised); cursor: pointer; }
.pe-anchor__c.is-on { background: var(--rl-accent); border-color: var(--rl-accent); }

.pe-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .6rem; max-height: 55vh; overflow-y: auto; }
.pe-lib__item { display: flex; flex-direction: column; gap: .25rem; padding: .3rem; border: 1px solid var(--pe-line); border-radius: 10px; background: var(--rl-surface-raised); cursor: pointer; text-align: left; }
.pe-lib__item:hover { border-color: var(--rl-accent); }
.pe-lib__item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 7px; background: var(--rl-surface-sunken); }
.pe-lib__item span { font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pe-keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem 1.5rem; }
.pe-keys h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--rl-text-muted); margin: 0 0 .3rem; }
.pe-keys dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; }
.pe-keys dt { font-family: ui-monospace, Consolas, monospace; font-size: .76rem; white-space: nowrap; }
.pe-keys dd { margin: 0; color: var(--rl-text-muted); }

.pe-toasts { position: absolute; left: 50%; bottom: 2.6rem; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; width: max-content; max-width: 92%; }
.pe-toast { background: #1d2026; color: #f3f4f6; padding: .5rem .9rem; border-radius: 10px; box-shadow: var(--pe-shadow); transition: opacity .25s, transform .25s; border-left: 4px solid var(--rl-accent); }
.pe-toast--warn { border-left-color: #f59e0b; }
.pe-toast--error { border-left-color: var(--rl-danger); }
.pe-toast--ok { border-left-color: var(--rl-ok); }
.pe-toast.is-out { opacity: 0; transform: translateY(6px); }

/* ---- narrow screens: the panels become a drawer ---- */
@media (max-width: 899px) {
    .pe-ib--panels { display: inline-grid; }
    .pe__panels { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--pe-shadow); display: none; }
    .pe--panels .pe__panels { display: flex; }
    .pe--nopanels .pe__panels { display: none; }
    .pe--panels.pe--nopanels .pe__panels { display: flex; }
    .pe__brand { display: none; }
    /* One scrollable row each: wrapped, the options bar takes half the screen and leaves no room for the picture. */
    .pe__top, .pe__opts { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .pe__top > *, .pe__opts > * { flex: none; }
    .pe__top .pe__grow { flex: 1 0 .5rem; }
    .pe__status { white-space: nowrap; overflow-x: auto; scrollbar-width: none; gap: .7rem; }
    .pe__status > * { flex: none; }
    .pe__panels { width: min(17.5rem, 86vw); }
    .pe-rng input[type=range] { width: 5.5rem; }
    .pe__hint { display: none; }
    .pe-dlg__back--side { place-items: end center; padding: 1rem; }
}

/* ---- layer kinds, styles, gradients (adjustment and fill layers, Layer Style, the gradient editor) ---- */
.pe-layer__clip { flex: none; font-size: .8rem; color: var(--rl-text-muted); pointer-events: none; margin-right: -.15rem; }
.pe-layer__fx { border: 0; background: transparent; padding: 0 .25rem; border-radius: 4px; font-style: italic; font-weight: 700; font-size: .74rem; color: var(--rl-text-muted); cursor: pointer; }
.pe-layer__fx:hover { color: var(--rl-text); background: var(--rl-surface-sunken); }
.pe-thumb--virtual { width: 34px; height: 34px; }
.pe-ib--fx { font-style: italic; font-weight: 700; font-size: .78rem; }
.pe-menu--popup { position: absolute; z-index: 55; min-width: 13rem; }

.pe-grad { display: flex; flex-direction: column; gap: .45rem; }
.pe-grad__bar { width: 100%; height: 22px; border-radius: 5px; border: 1px solid var(--pe-line); cursor: copy; display: block; touch-action: none; }
.pe-grad__track { position: relative; height: 14px; margin: -.3rem 6px 0; }
.pe-grad__stop { position: absolute; top: 0; width: 12px; height: 12px; margin-left: -6px; padding: 0; border: 2px solid var(--rl-surface); outline: 1px solid var(--pe-line); border-radius: 3px 3px 6px 6px; cursor: ew-resize; touch-action: none; }
.pe-grad__stop.is-on { outline: 2px solid var(--rl-accent); }
.pe-grad__row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.pe-grad__color { width: 2.4rem; height: 1.7rem; padding: 0; border: 1px solid var(--pe-line); border-radius: 5px; background: none; cursor: pointer; }
.pe-grad__presets { display: flex; flex-wrap: wrap; gap: 4px; }
.pe-grad__preset { padding: 1px; border: 1px solid var(--pe-line); border-radius: 4px; background: var(--rl-surface); cursor: pointer; line-height: 0; }
.pe-grad__preset:hover { border-color: var(--rl-accent); }
.pe-grad__preset canvas { border-radius: 3px; }

.pe-dlg--side.pe-dlg--style { width: min(40rem, 100%); }
.pe-style { display: grid; grid-template-columns: 12rem 1fr; gap: .9rem; align-items: start; }
.pe-style__side { display: flex; flex-direction: column; gap: .6rem; }
.pe-style__side .pe-rng { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; }
.pe-style__side .pe-rng__label { grid-column: 1 / -1; }
.pe-style__side .pe-rng input[type=range] { width: 100%; }
.pe-fxlist { display: flex; flex-direction: column; gap: 1px; border: 1px solid var(--pe-line); border-radius: 9px; padding: .2rem; }
.pe-fxlist__row { display: flex; align-items: center; gap: .45rem; padding: .3rem .45rem; border-radius: 7px; cursor: pointer; }
.pe-fxlist__row:hover { background: var(--rl-surface-sunken); }
.pe-fxlist__row.is-on { background: color-mix(in srgb, var(--rl-accent) 18%, transparent); font-weight: 600; }
.pe-fxlist__row input { accent-color: var(--rl-accent); }
.pe-fxpane { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.pe-fxpane__title { margin: 0; font-size: .9rem; }
.pe-fxpane .pe-rng { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; }
.pe-fxpane .pe-rng__label { grid-column: 1 / -1; }
.pe-fxpane .pe-rng input[type=range] { width: 100%; }
.pe-fxpane .pe-sel { display: flex; justify-content: space-between; }
.pe-fxpane > .pe-btn { align-self: flex-start; }

.pe-crange__chips { display: flex; flex-wrap: wrap; gap: 4px; }
.pe-crange__chip { width: 1.6rem; height: 1.6rem; border: 1px solid var(--pe-line); border-radius: 5px; cursor: pointer; padding: 0; }
.pe-crange__preview { display: block; max-width: 100%; margin: 0 auto; border: 1px solid var(--pe-line); border-radius: 4px; background: #000; }

@media (max-width: 899px) {
    .pe-style { grid-template-columns: 1fr; }
}

/* ---- recovered drafts (welcome card and File › Recover) ---- */
.pe-drafts { display: flex; flex-direction: column; gap: .35rem; text-align: left; margin-top: .4rem; }
.pe-drafts__title { margin: .4rem 0 .1rem; font-weight: 650; color: var(--rl-text); }
.pe-draft { display: grid; grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; gap: .1rem .4rem; align-items: center; padding: .4rem .5rem; border: 1px solid var(--pe-line); border-radius: 9px; background: var(--rl-surface-raised); }
.pe-draft__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-draft .pe__hint { grid-column: 1; grid-row: 2; }
.pe-draft .pe-btn { grid-row: 1 / span 2; }

/* ---- history snapshots ---- */
.pe-histpanel { display: flex; flex-direction: column; }
.pe-snaps { display: flex; flex-direction: column; padding: .2rem .2rem 0; }
.pe-snaps:empty { display: none; }
.pe-snap { display: flex; align-items: center; border-bottom: 1px dashed var(--pe-line); }
.pe-snap__go { flex: 1; font-weight: 600; }

/* ---- histogram panel ---- */
.pe-histo { padding: .5rem .6rem .6rem; display: flex; flex-direction: column; gap: .4rem; }
.pe-hist--panel { height: 90px; }
.pe-hist__info { font-variant-numeric: tabular-nums; }

/* ---- groups in the Layers panel ---- */
.pe-layer__indent { flex: none; }
.pe-layer__fold { flex: none; border: 0; background: transparent; padding: .1rem; border-radius: 4px; cursor: pointer; display: grid; place-items: center; color: var(--rl-text-muted); }
.pe-layer__fold .pe-ico { transition: transform .12s; }
.pe-layer__fold.is-open .pe-ico { transform: rotate(90deg); }
.pe-layer.is-group .pe-layer__name { font-weight: 600; }
/* Scoped to the photo editor's list: the vector editor's rows are .pe-layer too, with their own drop-into look. */
.pe-photo-layers .pe-layer.drop-into { outline: 2px solid var(--rl-accent); outline-offset: -2px; }
