/* Ilo Raw — panel styles. Dark by default to sit inside Illustrator's darkest UI. */

:root {
    --bg: #262626;
    --bg-2: #2d2d2d;
    --bg-3: #353535;
    --stage: #1c1c1c;
    --field: #1f1f1f;
    --line: rgba(255, 255, 255, 0.07);
    --line-2: rgba(255, 255, 255, 0.13);
    --hover: rgba(255, 255, 255, 0.06);
    --press: rgba(255, 255, 255, 0.1);
    --text: #ededed;
    --text-2: #b9b9b9;
    --text-3: #858585;
    --track: #4a4a4a;
    --accent: #e562ef;
    --accent-2: #b23fc4;
    --accent-soft: rgba(229, 98, 239, 0.16);
    --ok: #4ec27e;
    --warn: #e8a93a;
    --bad: #f0616d;
    --rainbow: linear-gradient(90deg, #ff0000 0%, #ffe502 12%, #04fe02 28%, #02f7f5 48%, #001fff 67%, #ff00ff 85%, #fd002c 100%);
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.4);
    --ease: cubic-bezier(0.2, 0, 0, 1);
    --mono: 'SF Mono', Menlo, Consolas, monospace;
    --row: 24px;
}

:root[data-theme="light"] {
    --bg: #f0f0f0;
    --bg-2: #e6e6e6;
    --bg-3: #dadada;
    --stage: #d4d4d4;
    --field: #ffffff;
    --line: rgba(0, 0, 0, 0.08);
    --line-2: rgba(0, 0, 0, 0.16);
    --hover: rgba(0, 0, 0, 0.05);
    --press: rgba(0, 0, 0, 0.09);
    --text: #1d1d1d;
    --text-2: #474747;
    --text-3: #7a7a7a;
    --track: #bdbdbd;
    --accent: #b23fc4;
    --accent-soft: rgba(178, 63, 196, 0.14);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 11px/1.35 -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    user-select: none;
}

button { font: inherit; color: inherit; }
svg { display: block; }

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 260px;
}

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 34px;
    padding: 0 6px 0 10px;
    border-bottom: 1px solid var(--line);
    flex: none;
}

.brand { display: flex; align-items: center; gap: 6px; }
.brand-word { font-weight: 800; font-size: 14px; letter-spacing: -0.02em; }
.brand-raw { font-weight: 700; font-size: 9.5px; letter-spacing: 0.22em; color: var(--text-2); }
.brand-bar {
    position: relative;
    width: 26px;
    height: 5px;
    border-radius: 3px;
    background: var(--rainbow);
}
.brand-bar i {
    position: absolute;
    right: 4px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1.5px #fff;
}

.top-actions { display: flex; align-items: center; gap: 1px; }
.sep { width: 1px; height: 16px; background: var(--line-2); margin: 0 4px; }

.icon-btn, .tool {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.icon-btn svg, .tool svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.3;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-btn svg .fill, .tool svg .fill { fill: currentColor; stroke: none; opacity: 0.55; }
.icon-btn:hover, .tool:hover { background: var(--hover); color: var(--text); }
.icon-btn.on, .tool.on { background: var(--accent-soft); color: var(--accent); }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }

/* ── Viewer ──────────────────────────────────────────────── */
.viewer {
    position: relative;
    flex: none;
    height: 38vh;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    background: var(--stage);
    border-bottom: 1px solid var(--line);
}

.stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    background-color: var(--stage);
}
.stage.has-alpha {
    background-image: conic-gradient(#2a2a2a 25%, #232323 0 50%, #2a2a2a 0 75%, #232323 0);
    background-size: 14px 14px;
}

#view {
    position: absolute;
    display: block;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.45);
    image-rendering: auto;
}
.stage.pannable #view { cursor: grab; }
.stage.panning #view, .stage.space #view { cursor: grabbing !important; }

.zoom-bar {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 2px;
    border-radius: 8px;
    background: rgba(20, 20, 20, 0.78);
    backdrop-filter: blur(6px);
    z-index: 4;
}
.zoom-bar button {
    height: 24px;
    min-width: 26px;
    padding: 0 7px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: #d6d6d6;
    font: 600 11px/1 -apple-system, BlinkMacSystemFont, sans-serif;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.zoom-bar button:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.zoom-bar.fit button[data-z="fit"] { color: var(--accent); }
.zoom-pct { min-width: 48px !important; }
#view[hidden] ~ .zoom-bar { display: none; }
#view[hidden] { display: none; }
.stage.picking #view { cursor: crosshair; }
.stage.tat #view { cursor: ns-resize; }

.split {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    cursor: ew-resize;
    touch-action: none;
}
.split i {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -1px;
    width: 2px;
    background: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
}
.split::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -11px;
    width: 22px;
    height: 22px;
    margin-top: -11px;
    border-radius: 50%;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M9 7 5 11l4 4M13 7l4 4-4 4' fill='none' stroke='%23222' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/100% no-repeat;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}
.split::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -10px;
    width: 20px;
}
.split-tag {
    position: absolute;
    top: 8px;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    pointer-events: none;
}
.split-tag.left { right: 8px; }
.split-tag.right { left: 8px; }

.empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 16px;
    text-align: center;
}
.empty[hidden] { display: none; }
.empty-mark { display: flex; gap: 4px; margin-bottom: 6px; }
.empty-mark span {
    width: 18px;
    height: 24px;
    border-radius: 4px;
    background: var(--bg-3);
    border: 1px solid var(--line-2);
}
.empty-mark span:nth-child(2) { background: var(--rainbow); opacity: 0.85; transform: translateY(-4px); }
.empty-title { font-size: 12px; font-weight: 600; }
.empty-sub { color: var(--text-3); max-width: 240px; }
.empty-actions { display: flex; gap: 6px; margin-top: 8px; }

.stage.drop::after {
    content: 'Drop image';
    position: absolute;
    inset: 8px;
    display: grid;
    place-items: center;
    border: 1.5px dashed var(--accent);
    border-radius: 8px;
    background: rgba(229, 98, 239, 0.08);
    color: var(--accent);
    font-weight: 600;
}

.busy {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 8px;
    border-radius: 20px;
    background: rgba(20, 20, 20, 0.85);
    color: #eee;
    backdrop-filter: blur(6px);
    white-space: nowrap;
}
.busy[hidden] { display: none; }
.spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--accent);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stage-tools {
    position: absolute;
    left: 8px;
    bottom: 8px;
    display: flex;
    gap: 2px;
    padding: 2px;
    border-radius: 8px;
    background: rgba(20, 20, 20, 0.72);
    backdrop-filter: blur(6px);
}
.stage-tools .tool { color: #ccc; }
.stage-tools .tool:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.stage-tools[hidden] { display: none; }

.toast {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    border-radius: 6px;
    background: rgba(20, 20, 20, 0.88);
    color: #eee;
    white-space: nowrap;
    pointer-events: none;
    animation: fade-in 0.15s var(--ease);
}
.toast.bad { color: #ffb3b9; }
.toast[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; transform: translate(-50%, -4px); } }

/* palette view for vector artwork */
.swatches {
    position: absolute;
    inset: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    align-content: center;
    gap: 6px;
    overflow: auto;
}
.swatches[hidden] { display: none; }
.sw {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 6px rgba(0, 0, 0, 0.35);
}
.sw i { position: absolute; inset: 0; }
.sw i:first-child { clip-path: polygon(0 0, 100% 0, 0 100%); }

.filmstrip {
    display: flex;
    gap: 5px;
    padding: 0 8px 7px;
    overflow-x: auto;
    flex: none;
    scrollbar-width: none;
}
.filmstrip:empty { display: none; }
.filmstrip::-webkit-scrollbar { display: none; }
.thumb {
    position: relative;
    flex: none;
    height: 38px;
    min-width: 38px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    overflow: hidden;
    background: var(--bg-3) center/cover no-repeat;
    box-shadow: inset 0 0 0 1px var(--line-2);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.12s, box-shadow 0.12s;
}
.thumb:hover { opacity: 1; }
.thumb.active { opacity: 1; box-shadow: inset 0 0 0 2px var(--accent); }
.thumb.edited::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.5);
}
.thumb.vector {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 9px;
    width: auto;
    background: var(--bg-3);
    color: var(--text-2);
    font-weight: 600;
}
.thumb.vector svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.3; }

.viewer-grip {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -4px;
    height: 8px;
    cursor: ns-resize;
    z-index: 3;
}

/* ── Histogram ───────────────────────────────────────────── */
.histo {
    position: relative;
    flex: none;
    height: 74px;
    padding: 8px 10px 16px;
    border-bottom: 1px solid var(--line);
}
#histo { width: 100%; height: 100%; display: block; }
.clip-tri {
    position: absolute;
    top: 5px;
    width: 12px;
    height: 10px;
    border: 0;
    padding: 0;
    background: var(--text-3);
    opacity: 0.45;
    cursor: pointer;
    clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.clip-tri.left { left: 6px; }
.clip-tri.right { right: 6px; }
.clip-tri.hot { opacity: 1; }
.clip-tri.left.hot { background: #3b7bff; }
.clip-tri.right.hot { background: #ff4757; }
.histo-meta {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 2px;
    display: flex;
    justify-content: space-between;
    color: var(--text-3);
    font-size: 9.5px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
}

/* ── Sections ────────────────────────────────────────────── */
.sections {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}
.sections::-webkit-scrollbar { width: 8px; }
.sections::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; border: 2px solid var(--bg); }
.sections.disabled { opacity: 0.4; pointer-events: none; }

.sec { border-bottom: 1px solid var(--line); }
.sec-head {
    display: flex;
    align-items: center;
    height: 32px;
    padding: 0 6px 0 8px;
    cursor: pointer;
}
.sec-head:hover { background: var(--hover); }
.chev {
    width: 14px;
    height: 14px;
    margin-right: 4px;
    fill: none;
    stroke: var(--text-3);
    stroke-width: 1.5;
    transition: transform 0.18s var(--ease);
}
.sec.open .chev { transform: rotate(90deg); }
.sec-title { flex: 1; font-weight: 600; font-size: 11.5px; }
.sec-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    margin-right: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}
.sec.changed .sec-dot { opacity: 1; }
.sec-btn {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 5px;
    background: none;
    color: var(--text-3);
    cursor: pointer;
    opacity: 0;
}
.sec-head:hover .sec-btn, .sec-btn.off { opacity: 1; }
.sec-btn:hover { color: var(--text); background: var(--press); }
.sec-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.sec-btn.off { color: var(--warn); }
.sec.bypassed .sec-body { opacity: 0.45; }
.sec-body { display: none; padding: 2px 10px 12px; }
.sec.open .sec-body { display: block; animation: open 0.18s var(--ease); }
@keyframes open { from { opacity: 0; transform: translateY(-3px); } }

.group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 0 3px;
    color: var(--text-3);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.group-label:first-child { margin-top: 4px; }

.link-btn {
    border: 0;
    background: none;
    padding: 2px 6px;
    margin-right: -6px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}
.link-btn:hover { background: var(--accent-soft); }

/* ── Slider row ──────────────────────────────────────────── */
.sl {
    display: grid;
    grid-template-columns: 76px 1fr 42px;
    align-items: center;
    gap: 8px;
    height: var(--row);
}
.sl-label {
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: default;
}
.sl.changed .sl-label { color: var(--text); }
.sl-track {
    position: relative;
    height: 18px;
    cursor: pointer;
    touch-action: none;
}
.sl-rail {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 2px;
    background: var(--grad, var(--track));
}
.sl.grad .sl-rail { height: 4px; margin-top: -2px; }
.sl-fill {
    position: absolute;
    top: 50%;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 2px;
    background: var(--accent);
}
.sl.grad .sl-fill { display: none; }
.sl-zero {
    position: absolute;
    top: 50%;
    width: 1px;
    height: 7px;
    margin-top: -3.5px;
    background: var(--text-3);
    opacity: 0.6;
}
.sl-thumb {
    position: absolute;
    top: 50%;
    width: 11px;
    height: 11px;
    margin: -5.5px 0 0 -5.5px;
    border-radius: 50%;
    background: #f4f4f4;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s var(--ease);
}
.sl-track:hover .sl-thumb, .sl.dragging .sl-thumb { transform: scale(1.18); }
.sl.dragging .sl-thumb { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 0 4px var(--accent-soft); }
.sl-val {
    width: 100%;
    height: 18px;
    padding: 0 4px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    color: var(--text-2);
    font: 10.5px var(--mono);
    text-align: right;
    outline: none;
    user-select: text;
}
.sl.changed .sl-val { color: var(--text); }
.sl-val:hover { border-color: var(--line-2); }
.sl-val:focus { border-color: var(--accent); background: var(--field); color: var(--text); }

/* ── Segmented control ───────────────────────────────────── */
.seg {
    display: flex;
    padding: 2px;
    margin: 4px 0 6px;
    border-radius: 7px;
    background: var(--field);
    box-shadow: inset 0 0 0 1px var(--line);
}
.seg button {
    flex: 1;
    height: 22px;
    border: 0;
    border-radius: 5px;
    background: none;
    color: var(--text-3);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--bg-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.seg button .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }

.row-inline { display: flex; align-items: center; gap: 6px; margin: 2px 0 4px; }
.row-inline .seg { flex: 1; margin: 0; }

/* ── Curve editor ────────────────────────────────────────── */
.curve-box {
    position: relative;
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1;
    margin: 4px auto 8px;
    border-radius: 6px;
    background: var(--field);
    box-shadow: inset 0 0 0 1px var(--line);
    touch-action: none;
}
.curve-box canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.curve-readout {
    position: absolute;
    right: 6px;
    top: 5px;
    color: var(--text-3);
    font: 9.5px var(--mono);
    pointer-events: none;
}
.curve-hint { color: var(--text-3); font-size: 10px; text-align: center; margin: -2px 0 6px; }

/* ── Colour grading ──────────────────────────────────────── */
.wheels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
    margin: 6px 0;
}
.wheels.single { grid-template-columns: 1fr; justify-items: center; }
.wheel-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.wheels:not(.single) .wheel-cell.mid { grid-column: 1 / -1; }
.wheel-name { color: var(--text-2); font-size: 10px; font-weight: 600; }
.wheel {
    position: relative;
    width: 100%;
    max-width: 104px;
    aspect-ratio: 1;
    touch-action: none;
    cursor: pointer;
}
.wheels.single .wheel { max-width: 176px; }
.wheel canvas { width: 100%; height: 100%; display: block; }
.wheel-puck {
    position: absolute;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}
.wheel-lum {
    width: 100%;
    max-width: 104px;
}
.wheels.single .wheel-lum { max-width: 176px; }
.wheel-lum .sl { grid-template-columns: 1fr 34px; gap: 4px; }
.wheel-lum .sl-label { display: none; }
.wheel-values { color: var(--text-3); font: 9.5px var(--mono); height: 12px; }

/* ── Masks ───────────────────────────────────────────────── */
.mask-add { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 4px 0 8px; }
.mask-new {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: var(--bg-3);
    color: var(--text-2);
    font-weight: 600;
    cursor: pointer;
}
.mask-new:hover { background: var(--press); color: var(--text); }
.mask-new svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.mask-new svg .fill { fill: currentColor; stroke: none; }
.mask-new.ai { background: linear-gradient(135deg, rgba(229, 98, 239, 0.18), rgba(63, 199, 212, 0.14)); color: var(--text); }
.mask-new.ai:hover { background: linear-gradient(135deg, rgba(229, 98, 239, 0.3), rgba(63, 199, 212, 0.22)); }
.mask-empty { color: var(--text-3); font-size: 10.5px; line-height: 1.5; padding: 2px 2px 4px; }
.mask-empty b { color: var(--text-2); }
.mask-list { display: flex; flex-direction: column; gap: 2px; }
.mask-row {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 28px;
    padding: 0 4px 0 8px;
    border-radius: 6px;
    cursor: pointer;
}
.mask-row:hover { background: var(--hover); }
.mask-row.on { background: var(--accent-soft); }
.mask-row.hidden-mask .mask-name { opacity: 0.45; text-decoration: line-through; }
.mask-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.mask-name { flex: 1; font-weight: 600; }
.mask-ic {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 5px;
    background: none;
    color: var(--text-3);
    cursor: pointer;
}
.mask-ic:hover { background: var(--press); color: var(--text); }
.mask-ic.del:hover { color: var(--bad); }
.mask-ic svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.mask-detail { margin-top: 6px; }
.mask-detail:empty { display: none; }
.mask-toggles { display: flex; gap: 14px; margin: 4px 0 6px; }
.chk { display: flex; align-items: center; gap: 5px; color: var(--text-2); cursor: pointer; }
.chk input { accent-color: var(--accent); margin: 0; }

.mask-overlay {
    position: absolute;
    pointer-events: none;
    overflow: visible;
    z-index: 2;
}
.mo-line { fill: none; stroke: #fff; stroke-width: 1.2; filter: drop-shadow(0 0 1.5px rgba(0, 0, 0, 0.8)); }
.mo-line.dash { stroke-dasharray: 4 4; opacity: 0.8; }
.mo-axis { stroke: rgba(255, 255, 255, 0.6); stroke-width: 1; stroke-dasharray: 2 3; }
.mo-handle {
    fill: #fff;
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 1.2;
    pointer-events: all;
    cursor: grab;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}
.mo-handle.big { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.mo-handle:active { cursor: grabbing; }

.grid-overlay {
    position: absolute;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.28) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.28) 1px, transparent 1px);
    background-size: 12.5% 12.5%;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.grid-overlay[hidden] { display: none; }

/* brush cursor */
.brush-cursor {
    position: absolute;
    border-radius: 50%;
    border: 1.5px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 3;
}
.brush-cursor.erase { border-style: dashed; }
.stage.brushing #view { cursor: none; }

/* ── Profile ─────────────────────────────────────────────── */
.profile-row {
    display: grid;
    grid-template-columns: 76px 1fr;
    align-items: center;
    gap: 8px;
    margin: 6px 0 2px;
}
.profile-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 24px;
    padding: 0 8px;
    border: 1px solid var(--line-2);
    border-radius: 6px;
    background: var(--field);
    color: var(--text);
    cursor: pointer;
    min-width: 0;
}
.profile-btn:hover { border-color: var(--text-3); }
.profile-btn .pname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-btn svg { width: 10px; height: 10px; fill: none; stroke: var(--text-3); stroke-width: 1.4; flex: none; }
.menu {
    position: fixed;
    z-index: 30;
    max-height: 60vh;
    overflow-y: auto;
    padding: 4px;
    border-radius: 8px;
    background: var(--bg-2);
    box-shadow: var(--shadow);
    animation: pop 0.12s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-3px); } }
.menu[hidden] { display: none; }
.menu-item {
    display: block;
    width: 100%;
    padding: 6px 10px;
    border: 0;
    border-radius: 5px;
    background: none;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}
.menu-item:hover { background: var(--accent-2); color: #fff; }
.menu-item.on { color: var(--accent); }
.menu-info { padding: 8px 10px; color: var(--text-2); font-size: 10.5px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.menu-info b { color: var(--text); font-size: 11.5px; }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--line-2); }

/* ── Point colour ────────────────────────────────────────── */
.pt-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
.pt-pick { display: flex; align-items: center; gap: 5px; flex: none; }
.pt-pick svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.pt-swatches { display: flex; gap: 4px; flex-wrap: wrap; }
.pt-sw {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}
.pt-sw.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 3.5px var(--accent); }
.pt-empty { color: var(--text-3); font-size: 10.5px; line-height: 1.5; }
.pt-del { margin-top: 4px; }

/* ── Cut out ─────────────────────────────────────────────── */
.cut-on { margin: 4px 0 8px; font-weight: 600; color: var(--text); }
.cut-engine { margin-top: 0; }
.cut-status { margin: 2px 0 6px; color: var(--accent); font-size: 10.5px; }
.cut-inv { margin: 6px 0; }
.cut-actions { display: flex; gap: 6px; margin: 8px 0 4px; }
.cut-note { color: var(--text-3); font-size: 10.5px; line-height: 1.5; }

/* ── Harmonize ───────────────────────────────────────────── */
.hz-src { display: flex; gap: 6px; margin: 4px 0 8px; }
.hz-src .btn { flex: 1; }
.hz-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-bottom: 8px; }
.hz-chips:empty { display: none; }
.hz-chip {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0.3;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    transition: opacity 0.12s, transform 0.12s var(--ease);
}
.hz-chip.on { opacity: 1; box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px rgba(255, 255, 255, 0.5); }
.hz-chip:hover { transform: scale(1.1); }
.hz-empty, .duo-note { color: var(--text-3); font-size: 10.5px; line-height: 1.5; margin: 2px 0 6px; }

/* ── Print / duotone ─────────────────────────────────────── */
.duo-on { margin: 4px 0 8px; font-weight: 600; color: var(--text); }
.duo-ink { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 8px; margin-bottom: 6px; }
.duo-ink .profile-btn { justify-content: flex-start; gap: 7px; }
.ink-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); }
.ink-item { display: flex; align-items: center; gap: 8px; }
.ink-item span { flex: 1; }
.ink-item em { font-style: normal; font-size: 9.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }
.ink-item:hover em { color: #fff; }

/* ── Footer ──────────────────────────────────────────────── */
.footer {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 10px;
    border-top: 1px solid var(--line);
    background: var(--bg-2);
    flex: none;
}
.status {
    flex: 1;
    min-width: 0;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: right;
}
.status.live { color: var(--ok); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 26px;
    padding: 0 12px;
    line-height: 1;
    border: 0;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, opacity 0.12s;
}
[hidden], .btn[hidden], .app.wide .wide-only[hidden] { display: none !important; }
.btn.ghost { background: transparent; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.primary { background: var(--accent-2); color: #fff; min-width: 76px; }
.btn.primary:hover { background: #c04ed2; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.small { height: 24px; padding: 0 10px; background: var(--bg-3); }
.btn.small:hover { background: var(--press); }

/* ── Editor window layout (Camera Raw style) ─────────────── */
.wide-only, .rail, .top-title { display: none; }
.app.wide {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px 56px;
    grid-template-rows: 44px auto minmax(0, 1fr) 56px;
    grid-template-areas: "top top top" "viewer histo rail" "viewer side rail" "foot foot foot";
}
.app.wide .wide-only { display: inline-flex; }
.app.wide .icon-btn.wide-only { display: grid; }
.app.wide .topbar { grid-area: top; height: 44px; padding: 0 10px 0 16px; background: var(--bg-2); }
.app.wide .top-title {
    display: block;
    flex: 1;
    min-width: 0;
    margin: 0 16px;
    color: var(--text-2);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app.wide .top-title b { color: var(--text); font-weight: 600; }
.app.wide .viewer { grid-area: viewer; height: auto !important; min-height: 0; border-bottom: 0; border-right: 1px solid var(--line); }
.app.wide .viewer-grip { display: none; }
.app.wide .filmstrip { padding: 8px 12px 10px; border-top: 1px solid var(--line); background: var(--bg); gap: 8px; }
.app.wide .filmstrip .thumb { height: 58px; min-width: 58px; }
.app.wide .filmstrip .thumb:not(.vector) { width: 86px !important; }
.app.wide .histo { grid-area: histo; height: 110px; padding: 12px 14px 18px; background: var(--bg); }
.app.wide .sections { grid-area: side; background: var(--bg); }
.app.wide .looks { grid-area: side; border-top: 0; overflow-y: auto; background: var(--bg); }
.app.wide .looks-scroll { flex-direction: column; overflow: visible; padding: 10px 12px 16px; }
.app.wide .look-row { flex-wrap: wrap; }
.app.wide .look { width: 100px; }
.app.wide .look-img { width: 100px; height: 72px; }
.app.wide.mode-presets .sections { display: none; }
.app.wide .footer { grid-area: foot; height: 56px; padding: 0 16px; gap: 8px; }
.app.wide .footer .btn { height: 32px; padding: 0 18px; }
.app.wide #btn-apply { display: none; }
.app.wide .sec-head { height: 36px; padding: 0 10px 0 12px; }
.app.wide .sec-body { padding: 2px 14px 14px; }
.app.wide .sl { grid-template-columns: 84px 1fr 46px; height: 26px; }
.app.wide .stage-tools { left: 14px; bottom: 14px; }

.rail {
    grid-area: rail;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 0;
    background: var(--bg-2);
    border-left: 1px solid var(--line);
}
.app.wide .rail { display: flex; }
.rail-btn {
    width: 46px;
    padding: 7px 0 5px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 9px;
    font-weight: 600;
}
.rail-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.rail-btn:hover { color: var(--text); background: var(--hover); }
.rail-btn.on { color: var(--accent); background: var(--accent-soft); }


/* ── Looks tray (presets rendered on the current image) ─── */
.looks {
    flex: none;
    border-top: 1px solid var(--line);
    background: var(--bg-2);
    animation: open 0.16s var(--ease);
}
.looks[hidden] { display: none; }
.looks-scroll {
    display: flex;
    gap: 14px;
    padding: 8px 10px 8px;
    overflow-x: auto;
    scrollbar-width: thin;
}
.looks-scroll::-webkit-scrollbar { height: 6px; }
.looks-scroll::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.look-group { display: flex; flex-direction: column; gap: 4px; flex: none; }
.look-group-name {
    color: var(--text-3);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}
.look-row { display: flex; gap: 6px; }
.look {
    position: relative;
    width: 62px;
    flex: none;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    text-align: center;
}
.look-img {
    width: 62px;
    height: 46px;
    border-radius: 5px;
    background: var(--bg-3) center/cover no-repeat;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    transition: box-shadow 0.12s, transform 0.12s var(--ease);
}
.look:hover .look-img { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.5); transform: translateY(-1px); }
.look.on .look-img { box-shadow: inset 0 0 0 2px var(--accent); }
.look-name {
    display: block;
    margin-top: 3px;
    color: var(--text-2);
    font-size: 9.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.look:hover .look-name { color: var(--text); }
.look .del {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: none;
    place-items: center;
    background: #111;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    box-shadow: 0 0 0 1px var(--line-2);
}
.look:hover .del { display: grid; }
.look.add .look-img {
    display: grid;
    place-items: center;
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--line-2);
    color: var(--text-3);
    font-size: 20px;
    font-weight: 300;
}
.look-save {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
    align-self: center;
}
.look-save input {
    width: 130px;
    height: 24px;
    padding: 0 8px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    background: var(--field);
    color: var(--text);
    font: inherit;
    outline: none;
    user-select: text;
}

/* ── License gate ────────────────────────────────────────── */
.gate {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(120% 80% at 50% 0%, rgba(229, 98, 239, 0.16), transparent 60%), var(--bg);
}
.gate[hidden] { display: none; }
.gate-card { width: 100%; max-width: 300px; text-align: center; }
.brand.big { justify-content: center; margin-bottom: 18px; transform: scale(1.5); }
.gate h1 { margin: 0 0 4px; font-size: 17px; }
.gate-sub { margin: 0 0 16px; color: var(--text-2); }
.gate-input {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line-2);
    border-radius: 8px;
    background: var(--field);
    color: var(--text);
    font: 12px var(--mono);
    text-align: center;
    letter-spacing: 0.04em;
    outline: none;
    user-select: text;
}
.gate-input:focus { border-color: var(--accent); }
.gate-msg { min-height: 30px; padding: 6px 0; color: var(--bad); font-size: 11px; }
.gate-msg.ok { color: var(--ok); }
.gate-btn { width: 100%; height: 32px; }
.gate-foot { margin: 14px 0 0; color: var(--text-3); font-size: 10.5px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
