#119 ui dark mobile: high Media & Comparison

Interactive Before/After Split Curtain Comparator

Draggable split-curtain comparator contrasting RAW vs. color-graded scenes with switchable LUTs and orientation toggle.

Inspired by Pixelmator ↗

Download .html
Fullscreen ↗

WHY THIS AESTHETIC IS UNIQUE

Makes subtle visual deltas instantly inspectable at pixel scale by letting users scrub a crisp divider line back and forth across identical geometry.

BEST FOR

Photo & AI upscaling editorsArchitecture & renovation showcasesDesign system theme comparisonsSatellite & map change viewers

TAGS

COLOR PALETTE (CLICK TO COPY HEX)

TYPOGRAPHY

Display
Space Grotesk
Body
Inter
Mono
JetBrains Mono
Scale
Crisp uppercase pill badges (RAW / GRADED) and mono split percentage telemetry.

Google Fonts Stylesheet ↗

ARCHITECTURE & MOBILE NOTES

LAYOUT

Centered color-accurate comparison stage framed by a compact preset LUT switcher, split percentage quick buttons (25%/50%/75%), and horizontal/vertical curtain toggle.

INTERACTION

Pointer drag anywhere on the curtain or stage repositions the clip-path divider smoothly at 60fps; Left/Right arrow keys nudge by 2% increments.

MOBILE

48px circular grab handle with touch-action: none prevents accidental page scrolling while scrubbing on phones.

AI AGENT GUARDRAILS

DO

  • Use clip-path inset rather than resizing inner images so both layers stay pixel-locked with zero aspect distortion
  • Provide keyboard arrow support and a visible role='slider' ARIA handle with aria-valuenow
  • Keep Before/After labels anchored to opposite corners so the curtain never collides awkwardly with them

DON'T

  • Do not allow dragging the handle outside 0-100% bounds where it disappears off-canvas
  • Do not make the divider handle too thin to grab comfortably on touch screens
STANDALONE SOURCE · demos/before-after-split-curtain.html (20.6 KB)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ChromaLab — Before/After Split Curtain Comparator</title>
<style>
  :root {
    --canvas: #0E1015;
    --surface: #181B24;
    --surface-2: #212634;
    --ink: #F8FAFC;
    --accent: #38BDF8;
    --accent-soft: rgba(56, 189, 248, 0.16);
    --muted: #94A3B8;
    --border: rgba(255, 255, 255, 0.09);
    --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

  html, body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--font);
    min-height: 100dvh;
    overflow-x: hidden;
  }

  .studio {
    max-width: 1120px;
    margin: 0 auto;
    padding: 14px 14px 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  @media (min-width: 820px) {
    .studio { padding: 24px 28px 36px; gap: 18px; }
  }

  .topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .brand-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, #38BDF8, #6366F1);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 13px;
    color: #091018;
  }

  .brand-text strong { font-size: 14px; display: block; }
  .brand-text span { font-size: 11px; color: var(--muted); font-family: var(--mono); }

  .top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mode-btn {
    min-height: 44px;
    padding: 0 13px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink);
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    transition: all 0.14s;
  }
  .mode-btn:hover { border-color: var(--accent); color: var(--accent); }

  /* Comparator Stage */
  .stage-wrap {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #07080B;
    aspect-ratio: 16 / 10;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
  }

  .stage-wrap:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35), 0 24px 60px rgba(0, 0, 0, 0.55);
  }

  .stage-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
  }

  /* Corner Labels */
  .side-label {
    position: absolute;
    z-index: 6;
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 5px 10px;
    border-radius: 8px;
    background: rgba(14, 16, 21, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    pointer-events: none;
  }

  .label-before { top: 12px; left: 12px; color: var(--muted); }
  .label-after { top: 12px; right: 12px; color: var(--accent); }

  .stage-wrap.horizontal .label-before { top: 12px; left: 12px; }
  .stage-wrap.horizontal .label-after { top: auto; bottom: 12px; right: 12px; }

  /* Split Curtain Divider + Handle */
  .curtain-line {
    position: absolute;
    z-index: 8;
    background: rgba(248, 250, 252, 0.92);
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.65);
    pointer-events: none;
  }

  .stage-wrap.vertical .curtain-line {
    top: 0; bottom: 0; width: 2px;
    transform: translateX(-1px);
  }

  .stage-wrap.horizontal .curtain-line {
    left: 0; right: 0; height: 2px;
    transform: translateY(-1px);
  }

  .curtain-handle {
    position: absolute;
    z-index: 10;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(24, 27, 36, 0.92);
    border: 2px solid var(--accent);
    color: var(--ink);
    display: grid;
    place-items: center;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.55), 0 0 0 4px rgba(56, 189, 248, 0.18);
    transform: translate(-50%, -50%);
    cursor: ew-resize;
    transition: transform 0.12s, background 0.12s;
  }

  .stage-wrap.horizontal .curtain-handle { cursor: ns-resize; }
  .curtain-handle:hover { background: var(--accent); color: #091018; }

  /* Controls Deck */
  .deck {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  @media (min-width: 820px) {
    .deck { grid-template-columns: 1.35fr 1fr; gap: 16px; }
  }

  .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .panel-head strong { color: var(--accent); font-family: var(--mono); }

  /* LUT Presets */
  .lut-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .lut-btn {
    min-height: 54px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--ink);
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    transition: all 0.15s;
  }
  .lut-btn:hover { border-color: rgba(255,255,255,0.22); }
  .lut-btn[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
  }

  .lut-swatch {
    height: 6px;
    width: 100%;
    border-radius: 999px;
  }
  .lut-name { font-size: 12px; font-weight: 700; }

  /* Percentage Split Presets */
  .pct-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .pct-btn {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.14s;
  }
  .pct-btn:hover { color: var(--ink); border-color: rgba(255,255,255,0.2); }
  .pct-btn.active {
    background: var(--accent);
    color: #091018;
    border-color: var(--accent);
  }

  .telemetry-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .metric {
    background: #12151C;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
  }
  .metric span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; }
  .metric b { display: block; font-family: var(--mono); font-size: 13px; color: var(--ink); margin-top: 2px; }
</style>
</head>
<body>
  <div class="studio">
    <header class="topbar">
      <div class="brand">
        <div class="brand-badge">CL</div>
        <div class="brand-text">
          <strong>ChromaLab · Split Curtain</strong>
          <span>OSLO_OPERA_DUSK_04.DNG · 16-BIT LINEAR</span>
        </div>
      </div>
      <div class="top-controls">
        <button class="mode-btn" id="orientBtn" title="Toggle Vertical or Horizontal Split">Split: Vertical ⇄</button>
      </div>
    </header>

    <section class="stage-wrap vertical" id="stage" tabindex="0" role="slider" aria-label="Before and After Split Position" aria-valuemin="0" aria-valuemax="100" aria-valuenow="50">
      <canvas class="stage-canvas" id="rawCanvas" width="960" height="600"></canvas>
      <canvas class="stage-canvas" id="gradedCanvas" width="960" height="600"></canvas>
      <div class="side-label label-before">BEFORE · RAW LOG</div>
      <div class="side-label label-after" id="afterLabel">AFTER · NORDIC COOL</div>
      <div class="curtain-line" id="curtainLine"></div>
      <div class="curtain-handle" id="curtainHandle" aria-hidden="true">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" id="handleIcon">
          <polyline points="8 7 3 12 8 17"/><polyline points="16 7 21 12 16 17"/>
        </svg>
      </div>
    </section>

    <section class="deck">
      <div class="panel">
        <div class="panel-head">
          <span>Color Grading LUT</span>
          <strong id="lutStatus">NORDIC COOL</strong>
        </div>
        <div class="lut-grid" role="group" aria-label="Color LUT Presets">
          <button class="lut-btn" data-lut="nordic" aria-pressed="true">
            <span class="lut-swatch" style="background:linear-gradient(90deg,#0f172a,#38bdf8,#e0f2fe)"></span>
            <span class="lut-name">Nordic Cool</span>
          </button>
          <button class="lut-btn" data-lut="golden" aria-pressed="false">
            <span class="lut-swatch" style="background:linear-gradient(90deg,#291d14,#f59e0b,#fef3c7)"></span>
            <span class="lut-name">Golden Film</span>
          </button>
          <button class="lut-btn" data-lut="noir" aria-pressed="false">
            <span class="lut-swatch" style="background:linear-gradient(90deg,#09090b,#71717a,#f4f4f5)"></span>
            <span class="lut-name">Monochrome Noir</span>
          </button>
        </div>
        <div class="telemetry-grid">
          <div class="metric"><span>Temp</span><b id="mTemp">-18</b></div>
          <div class="metric"><span>Contrast</span><b id="mContrast">+24</b></div>
          <div class="metric"><span>Shadows</span><b id="mShadows">-12</b></div>
          <div class="metric"><span>Saturate</span><b id="mSat">+14</b></div>
        </div>
      </div>

      <div class="panel">
        <div class="panel-head">
          <span>Curtain Position</span>
          <strong id="pctReadout">50%</strong>
        </div>
        <div class="pct-row" role="group" aria-label="Split percentage presets">
          <button class="pct-btn" data-pct="0">0%</button>
          <button class="pct-btn" data-pct="25">25%</button>
          <button class="pct-btn active" data-pct="50">50%</button>
          <button class="pct-btn" data-pct="75">75%</button>
          <button class="pct-btn" data-pct="100">100%</button>
        </div>
        <div style="font-size:12px; color:var(--muted); line-height:1.45;">
          Drag anywhere on the canvas to scrub the curtain, or focus the viewport and press <strong style="color:var(--ink)">← / →</strong> arrow keys for 2% steps.
        </div>
      </div>
    </section>
  </div>

<script>
(() => {
  const LUTS = {
    nordic: {
      name: 'Nordic Cool',
      metrics: { temp: '-18', contrast: '+24', shadows: '-12', sat: '+14' },
      grade: (r, g, b) => {
        // Crisp cyan shadows, icy sky, elevated contrast, preserved warm interior lamps
        const lum = 0.299 * r + 0.587 * g + 0.114 * b;
        const c = 1.24;
        let nr = (r - 122) * c + 116;
        let ng = (g - 122) * c + 125;
        let nb = (b - 122) * c + 144;
        // Preserve warm tungsten highlights
        if (r > b + 35 && lum > 130) { nr += 18; ng += 8; nb -= 12; }
        else { nb += 14; ng += 5; nr -= 8; }
        return [nr, ng, nb];
      }
    },
    golden: {
      name: 'Golden Film',
      metrics: { temp: '+26', contrast: '+18', shadows: '+6', sat: '+22' },
      grade: (r, g, b) => {
        // Kodak-inspired warm amber highlights, subtle olive-teal lifted shadows
        const c = 1.18;
        let nr = (r - 124) * c + 136;
        let ng = (g - 124) * c + 126;
        let nb = (b - 124) * c + 104;
        const lum = 0.299 * r + 0.587 * g + 0.114 * b;
        if (lum < 85) { nr += 4; ng += 10; nb += 12; } // soft shadow lift
        else { nr += 16; ng += 7; nb -= 14; }
        return [nr, ng, nb];
      }
    },
    noir: {
      name: 'Monochrome Noir',
      metrics: { temp: '0', contrast: '+42', shadows: '-26', sat: '-100' },
      grade: (r, g, b) => {
        // High-contrast silver gelatin B&W with slight cool selenium split-tone
        let y = 0.24 * r + 0.62 * g + 0.14 * b;
        y = (y - 126) * 1.44 + 122;
        return [y - 2, y, y + 6];
      }
    }
  };

  let splitPct = 50;
  let orientation = 'vertical'; // 'vertical' | 'horizontal'
  let activeLut = 'nordic';

  const stage = document.getElementById('stage');
  const rawCanvas = document.getElementById('rawCanvas');
  const gradedCanvas = document.getElementById('gradedCanvas');
  const rawCtx = rawCanvas.getContext('2d', { willReadFrequently: true });
  const gradedCtx = gradedCanvas.getContext('2d');
  const curtainLine = document.getElementById('curtainLine');
  const curtainHandle = document.getElementById('curtainHandle');
  const handleIcon = document.getElementById('handleIcon');
  const afterLabel = document.getElementById('afterLabel');
  const lutStatus = document.getElementById('lutStatus');
  const pctReadout = document.getElementById('pctReadout');

  // Render crisp flat-profile RAW architectural dusk scene
  function drawRawArchitecturalScene() {
    const w = rawCanvas.width, h = rawCanvas.height;

    // Flat-log low-contrast dusk sky
    const sky = rawCtx.createLinearGradient(0, 0, 0, h * 0.68);
    sky.addColorStop(0, '#3a4252');
    sky.addColorStop(0.5, '#646c7a');
    sky.addColorStop(0.82, '#998982');
    sky.addColorStop(1, '#b8a596');
    rawCtx.fillStyle = sky;
    rawCtx.fillRect(0, 0, w, h);

    // Subtle overcast horizon glow
    const glow = rawCtx.createRadialGradient(w * 0.72, h * 0.56, 12, w * 0.72, h * 0.56, 260);
    glow.addColorStop(0, 'rgba(225, 206, 185, 0.72)');
    glow.addColorStop(1, 'rgba(180, 165, 155, 0)');
    rawCtx.fillStyle = glow;
    rawCtx.fillRect(0, 0, w, h);

    // Distant fjord hills
    rawCtx.fillStyle = '#4c5361';
    rawCtx.beginPath();
    rawCtx.moveTo(0, h * 0.62);
    rawCtx.lineTo(w * 0.16, h * 0.52);
    rawCtx.lineTo(w * 0.38, h * 0.58);
    rawCtx.lineTo(w * 0.62, h * 0.49);
    rawCtx.lineTo(w * 0.84, h * 0.55);
    rawCtx.lineTo(w, h * 0.48);
    rawCtx.lineTo(w, h * 0.7);
    rawCtx.lineTo(0, h * 0.7);
    rawCtx.closePath();
    rawCtx.fill();

    // Calm harbor water
    const water = rawCtx.createLinearGradient(0, h * 0.66, 0, h);
    water.addColorStop(0, '#6c727e');
    water.addColorStop(0.5, '#4b525e');
    water.addColorStop(1, '#323843');
    rawCtx.fillStyle = water;
    rawCtx.fillRect(0, h * 0.66, w, h * 0.34);

    // Water reflection streaks
    for (let i = 0; i < 36; i++) {
      const y = h * 0.68 + i * 5.2;
      rawCtx.fillStyle = `rgba(218, 200, 178, ${Math.max(0.06, 0.35 - i * 0.008)})`;
      rawCtx.fillRect(w * 0.62 - i * 2 + Math.sin(i * 1.4) * 14, y, 70 + i * 3, 2);
    }

    // Cantilevered modernist opera pavilion (angular white marble & glass)
    rawCtx.fillStyle = '#adb2ba';
    rawCtx.beginPath();
    rawCtx.moveTo(80, h * 0.72);
    rawCtx.lineTo(290, h * 0.40);
    rawCtx.lineTo(620, h * 0.44);
    rawCtx.lineTo(660, h * 0.72);
    rawCtx.closePath();
    rawCtx.fill();

    // Shaded architectural facade
    rawCtx.fillStyle = '#535966';
    rawCtx.beginPath();
    rawCtx.moveTo(290, h * 0.40);
    rawCtx.lineTo(290, h * 0.72);
    rawCtx.lineTo(660, h * 0.72);
    rawCtx.lineTo(620, h * 0.44);
    rawCtx.closePath();
    rawCtx.fill();

    // Warm interior atrium glass bays
    for (let i = 0; i < 6; i++) {
      const x = 315 + i * 52;
      const g = rawCtx.createLinearGradient(x, h * 0.48, x, h * 0.70);
      g.addColorStop(0, '#d8b48e');
      g.addColorStop(1, '#b68a63');
      rawCtx.fillStyle = g;
      rawCtx.fillRect(x, h * 0.48, 38, h * 0.21);
      // Water reflection of warm glass
      rawCtx.fillStyle = 'rgba(206, 165, 122, 0.28)';
      rawCtx.fillRect(x, h * 0.73, 38, 72);
    }

    // Left foreground promenade pier & minimalist bollards
    rawCtx.fillStyle = '#383e4a';
    rawCtx.fillRect(0, h * 0.71, w * 0.44, 18);
    rawCtx.fillStyle = '#2d323d';
    rawCtx.fillRect(0, h * 0.74, w * 0.34, h * 0.26);

    // Tall architectural glass tower on right
    rawCtx.fillStyle = '#434a57';
    rawCtx.fillRect(720, 118, 124, 290);
    rawCtx.fillStyle = '#555d6d';
    rawCtx.fillRect(812, 118, 32, 290);
    for (let r = 0; r < 11; r++) {
      for (let c = 0; c < 4; c++) {
        rawCtx.fillStyle = (r + c) % 3 === 0 ? '#d8b992' : 'rgba(175, 190, 210, 0.32)';
        rawCtx.fillRect(732 + c * 19, 134 + r * 23, 12, 13);
      }
    }
  }

  drawRawArchitecturalScene();
  const rawImageData = rawCtx.getImageData(0, 0, rawCanvas.width, rawCanvas.height);

  function renderGradedCanvas() {
    const lut = LUTS[activeLut];
    const src = rawImageData.data;
    const out = gradedCtx.createImageData(rawCanvas.width, rawCanvas.height);
    const dst = out.data;

    for (let i = 0; i < src.length; i += 4) {
      const [r, g, b] = lut.grade(src[i], src[i + 1], src[i + 2]);
      dst[i] = r < 0 ? 0 : (r > 255 ? 255 : r);
      dst[i + 1] = g < 0 ? 0 : (g > 255 ? 255 : g);
      dst[i + 2] = b < 0 ? 0 : (b > 255 ? 255 : b);
      dst[i + 3] = 255;
    }
    gradedCtx.putImageData(out, 0, 0);

    afterLabel.textContent = `AFTER · ${lut.name.toUpperCase()}`;
    lutStatus.textContent = lut.name.toUpperCase();
    document.getElementById('mTemp').textContent = lut.metrics.temp;
    document.getElementById('mContrast').textContent = lut.metrics.contrast;
    document.getElementById('mShadows').textContent = lut.metrics.shadows;
    document.getElementById('mSat').textContent = lut.metrics.sat;
  }

  function updateCurtain() {
    const clamped = Math.max(0, Math.min(100, splitPct));
    splitPct = clamped;

    if (orientation === 'vertical') {
      // Left side = RAW, Right side = Graded
      gradedCanvas.style.clipPath = `inset(0 0 0 ${clamped}%)`;
      curtainLine.style.left = `${clamped}%`;
      curtainLine.style.top = '0';
      curtainHandle.style.left = `${clamped}%`;
      curtainHandle.style.top = '50%';
    } else {
      // Top side = RAW, Bottom side = Graded
      gradedCanvas.style.clipPath = `inset(${clamped}% 0 0 0)`;
      curtainLine.style.top = `${clamped}%`;
      curtainLine.style.left = '0';
      curtainHandle.style.top = `${clamped}%`;
      curtainHandle.style.left = '50%';
    }

    pctReadout.textContent = `${Math.round(clamped)}%`;
    stage.setAttribute('aria-valuenow', Math.round(clamped));

    document.querySelectorAll('.pct-btn').forEach(btn => {
      btn.classList.toggle('active', Math.abs(Number(btn.dataset.pct) - clamped) < 1.5);
    });
  }

  // Drag anywhere on stage
  let dragging = false;
  function updateFromPointer(e) {
    const rect = stage.getBoundingClientRect();
    if (orientation === 'vertical') {
      splitPct = ((e.clientX - rect.left) / rect.width) * 100;
    } else {
      splitPct = ((e.clientY - rect.top) / rect.height) * 100;
    }
    updateCurtain();
  }

  stage.addEventListener('pointerdown', e => {
    dragging = true;
    stage.setPointerCapture(e.pointerId);
    updateFromPointer(e);
  });
  stage.addEventListener('pointermove', e => { if (dragging) updateFromPointer(e); });
  stage.addEventListener('pointerup', () => { dragging = false; });
  stage.addEventListener('pointercancel', () => { dragging = false; });

  // Keyboard support
  stage.addEventListener('keydown', e => {
    if (e.key === 'ArrowRight' || e.key === 'ArrowDown') { e.preventDefault(); splitPct += 2; updateCurtain(); }
    else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') { e.preventDefault(); splitPct -= 2; updateCurtain(); }
    else if (e.key === 'Home') { e.preventDefault(); splitPct = 0; updateCurtain(); }
    else if (e.key === 'End') { e.preventDefault(); splitPct = 100; updateCurtain(); }
  });

  // Preset percentages
  document.querySelectorAll('.pct-btn').forEach(btn => {
    btn.addEventListener('click', () => {
      splitPct = Number(btn.dataset.pct);
      updateCurtain();
    });
  });

  // LUT switching
  document.querySelectorAll('.lut-btn').forEach(btn => {
    btn.addEventListener('click', () => {
      document.querySelectorAll('.lut-btn').forEach(b => b.setAttribute('aria-pressed', 'false'));
      btn.setAttribute('aria-pressed', 'true');
      activeLut = btn.dataset.lut;
      renderGradedCanvas();
    });
  });

  // Orientation toggle
  document.getElementById('orientBtn').addEventListener('click', e => {
    orientation = orientation === 'vertical' ? 'horizontal' : 'vertical';
    stage.classList.toggle('vertical', orientation === 'vertical');
    stage.classList.toggle('horizontal', orientation === 'horizontal');
    e.currentTarget.textContent = orientation === 'vertical' ? 'Split: Vertical ⇄' : 'Split: Horizontal ⇅';
    handleIcon.style.transform = orientation === 'vertical' ? 'rotate(0deg)' : 'rotate(90deg)';
    updateCurtain();
  });

  renderGradedCanvas();
  updateCurtain();
})();
</script>
</body>
</html>