/* Card Gallery — quiet mobile workspace. */

:root{
  --black:#ffffff;
  --ink:#ffffff;
  --ink-2:#f2f2f7;
  --silver:#1d1d1f;
  --paper:#ffffff;
  --muted:#6e6e73;
  --dim:#8e8e93;
  --blue:#007aff;
  --red:#ff3b30;

  /* hairlines */
  --line:rgba(0,0,0,.14);
  --line-2:rgba(0,0,0,.08);
  --glass:rgba(255,255,255,.8);
  --glass-strong:rgba(255,255,255,.95);

  /* geometry */
  --r:12px;
  --r-md:18px;
  --r-pill:999px;

  /* type */
  --ui:-apple-system,BlinkMacSystemFont,"SF Pro Display","Segoe UI",sans-serif;
  --mono:ui-monospace,"SF Mono",Menlo,monospace;
  --track-label:.08em;
  --track-nav:.12em;

  /* motion */
  --ease:cubic-bezier(.32,.72,0,1);

  color-scheme:light;
}

*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{height:100%;}
body{
  margin:0;
  background:var(--black);
  color:var(--silver);
  font-family:var(--ui);
  overflow-x:hidden;
  -webkit-font-smoothing:antialiased;
}

/* screens */
[data-screen="editor"] .screen-gallery{ display:none; }
[data-screen="gallery"] .screen-editor{ display:none; }

/* ───────────── shared chrome ───────────── */
.topbar{
  position:sticky; top:0; z-index:30;
  display:flex; align-items:center; justify-content:space-between;
  height:calc(52px + env(safe-area-inset-top)); padding:calc(env(safe-area-inset-top) + 8px) 18px 8px;
  background:rgba(255,255,255,.92); border-bottom:1px solid var(--line-2);
  -webkit-backdrop-filter:blur(18px); backdrop-filter:blur(18px);
}
.wordmark{
  font-size:15px; font-weight:700; letter-spacing:var(--track-nav);
  text-transform:uppercase; color:var(--silver); margin:0;
  flex:1; text-align:center;
}
.topbar .slot{ width:40px; display:flex; align-items:center; }
.topbar .slot.right{ justify-content:flex-end; }
.ver-tag{ font-family:var(--mono); font-size:9px; letter-spacing:.1em; color:var(--dim);
  border:1px solid var(--line); border-radius:var(--r-pill); padding:2px 8px; }

.iconbtn{
  width:40px; height:40px; border:none; background:transparent;
  color:var(--silver); display:grid; place-items:center; cursor:pointer;
  border-radius:var(--r); transition:opacity .15s var(--ease), transform .1s var(--ease);
}
.iconbtn:active{ transform:scale(.9); opacity:.7; }
.iconbtn svg{ width:22px; height:22px; }

/* ───────────── GALLERY ───────────── */
.grid{
  display:grid; grid-template-columns:1fr 1fr; gap:12px;
  padding:12px 12px calc(env(safe-area-inset-bottom) + 104px);
}
.cover{
  position:relative; overflow:hidden; cursor:pointer;
  border-radius:18px; aspect-ratio:4/5;
  background:var(--ink-2);
  border:1px solid var(--line-2);
  display:flex; align-items:flex-end;
  contain:layout paint style;
  content-visibility:auto;
  contain-intrinsic-size:auto 400px;
  transition:transform .18s var(--ease);
}
.cover:active{ transform:scale(.985); }
.cover .art{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; background:var(--ink-2); }
.cover .meta{
  position:relative; z-index:2; padding:10px 12px;
  display:flex; justify-content:space-between; width:100%;
  font-family:var(--mono); font-size:10px; letter-spacing:.16em;
  text-transform:uppercase; color:#fff;
  text-shadow:0 1px 8px rgba(0,0,0,.7);
}
.cover .meta .num{ color:rgba(255,255,255,.72); }
.cover .scrim{ position:absolute; inset:0; background:linear-gradient(180deg,transparent 55%, rgba(0,0,0,.45)); pointer-events:none; }
.cover-edit, .cover-revert, .cover-badge{
  position:absolute; z-index:3; top:10px;
  font-family:var(--mono); font-size:10px; letter-spacing:.1em;
  border-radius:var(--r-pill); cursor:pointer; border:1px solid rgba(255,255,255,.5);
  backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px);
}
.cover-edit{ left:10px; padding:6px 12px; color:#fff; background:rgba(0,0,0,.35); }
.cover-edit:active{ transform:scale(.94); }
.cover-revert{ right:10px; width:30px; height:30px; display:grid; place-items:center; color:#fff; background:rgba(0,0,0,.35); font-size:14px; }
.cover-revert:active{ transform:scale(.94); }
.cover-badge{ left:50%; transform:translateX(-50%); top:10px; padding:4px 9px; color:#0a0b0c; background:var(--silver); font-weight:700; }
.cover[hidden]{ display:none; }
.cover .cover-edit[hidden], .cover .cover-revert[hidden]{ display:none; }

/* ───────────── SWIPE ───────────── */
.swipe{ position:fixed; inset:0; z-index:20; display:none;
  padding:calc(env(safe-area-inset-top) + 60px) 14px calc(env(safe-area-inset-bottom) + 100px); }
body[data-view="swipe"] .swipe{ display:block; }
body[data-view="swipe"] .grid{ display:none; }
.deck{ position:relative; width:100%; height:100%; max-width:440px; margin:0 auto; }
.scard{
  position:absolute; inset:0; border-radius:22px;
  overflow:hidden; outline:1px solid var(--line); outline-offset:-1px;
  background:var(--ink); will-change:transform; touch-action:none; user-select:none;
  -webkit-touch-callout:none; -webkit-user-drag:none;
  display:flex; align-items:flex-end;
}
.scard .art{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; background:var(--ink-2);
  pointer-events:none; -webkit-user-drag:none; }
.scard .meta{ position:relative; z-index:2; padding:16px; width:100%;
  pointer-events:none;
  display:flex; align-items:center; justify-content:space-between;
  font-family:var(--mono); font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:#fff;
  text-shadow:0 1px 10px rgba(0,0,0,.8); }
.scard .tap-hint{ color:var(--blue); font-size:10px; letter-spacing:.14em;
  border:1px solid var(--blue); border-radius:var(--r-pill); padding:5px 10px; opacity:.9; }
.counter{ position:absolute; top:calc(env(safe-area-inset-top) + 20px); left:0; right:0; text-align:center;
  font-family:var(--mono); font-size:11px; letter-spacing:.2em; color:var(--muted); z-index:25; pointer-events:none; }

/* ───────────── DOCK ───────────── */
.dock{ position:fixed; left:0; right:0; bottom:0; z-index:40;
  display:flex; justify-content:center; padding:0 16px calc(env(safe-area-inset-bottom) + 16px); }
.dock-inner{
  display:flex; align-items:center; gap:2px; padding:5px;
  background:var(--glass-strong);
  border:1px solid var(--line);
  border-radius:var(--r-pill);
  box-shadow:0 12px 32px rgba(0,0,0,.12);
  -webkit-backdrop-filter:blur(20px) saturate(140%); backdrop-filter:blur(20px) saturate(140%);
}
.dock .iconbtn{ width:46px; height:46px; border-radius:var(--r-pill); }
.dock .iconbtn.primary{ background:var(--silver); color:var(--black); }
.dock .iconbtn.primary:active{ background:var(--paper); }
.dock .sep{ width:1px; height:22px; background:var(--line); margin:0 3px; }

/* ───────────── EDITOR ───────────── */
.screen-editor{ min-height:100dvh; overflow:hidden; }
.editor-top{ position:relative; z-index:60; display:flex; align-items:center; justify-content:space-between;
  height:calc(52px + env(safe-area-inset-top)); padding:calc(env(safe-area-inset-top) + 8px) 12px 8px; border-bottom:1px solid var(--line-2);
  background:rgba(255,255,255,.96); -webkit-backdrop-filter:blur(18px); backdrop-filter:blur(18px); }
.editor-top .name{ font-family:var(--mono); font-size:11px; letter-spacing:.16em; text-transform:uppercase; color:var(--muted); }
/* aspect selector lives in the top bar (replaces the title) */
.aspect-seg{ display:flex; gap:2px; background:var(--ink-2); border:1px solid var(--line-2); border-radius:var(--r); padding:2px; }
.aspect-seg button{ min-width:44px; height:32px; border:none; background:transparent; color:var(--muted); cursor:pointer;
  font-family:var(--mono); font-size:11px; letter-spacing:.06em; border-radius:2px; }
.aspect-seg button[aria-selected="true"]{ background:var(--silver); color:var(--black); }
.export-btn{ height:34px; padding:0 16px; border:none; border-radius:var(--r);
  background:var(--silver); color:var(--black); font-family:var(--ui);
  font-size:11px; font-weight:800; letter-spacing:.14em; text-transform:uppercase; cursor:pointer; }
.export-btn:active{ transform:scale(.96); }
.tbtn{ height:34px; padding:0 16px; border:1px solid var(--line-2); border-radius:var(--r);
  background:transparent; color:var(--silver); font-family:var(--ui);
  font-size:12px; font-weight:800; letter-spacing:.04em; cursor:pointer; }
.tbtn:active{ transform:scale(.96); }
.tbtn.primary{ background:var(--silver); color:#fff; border-color:var(--silver); }
.tbtn.primary:active{ background:#000; }
.tbtn.active{ background:var(--blue); color:#fff; border-color:var(--blue); }
.tbtn:disabled{ opacity:.4; pointer-events:none; }
.color-row{ display:flex; align-items:center; gap:10px; }
.colorin{ width:48px; height:40px; padding:0; border:1px solid var(--line-2); border-radius:var(--r); background:none; cursor:pointer; }
.colorin::-webkit-color-swatch-wrapper{ padding:4px; }
.colorin::-webkit-color-swatch{ border:none; border-radius:6px; }
.hexin{ flex:1; text-transform:uppercase; }

.stage{ position:fixed; inset:0; display:grid; place-items:center; background:#f5f5f7;
  padding:calc(env(safe-area-inset-top) + 68px) 16px calc(env(safe-area-inset-bottom) + 96px); }
.board{ position:relative; max-width:100%; max-height:100%; aspect-ratio:4/5;
  background:var(--ink); border:1px solid var(--line); border-radius:4px; overflow:hidden;
  box-shadow:0 12px 36px rgba(0,0,0,.1);
  touch-action:none; }  /* Konva canvas must own the gesture — otherwise Safari steals it as sheet scroll */
.board .art{ position:absolute; inset:0; background-size:cover; background-position:center; }

/* Five stable editor destinations. Detailed controls only appear after choosing one. */
.editor-dock{ position:fixed; left:0; right:0; bottom:0; z-index:60;
  display:grid; grid-template-columns:repeat(5,1fr); gap:2px;
  padding:8px 8px max(8px,env(safe-area-inset-bottom));
  background:rgba(255,255,255,.96); border-top:1px solid var(--line-2);
  -webkit-backdrop-filter:blur(18px); backdrop-filter:blur(18px); }
.editor-dock button{ min-width:0; height:54px; border:0; border-radius:12px; background:transparent; color:var(--muted);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px; font:600 10px/1 var(--ui); cursor:pointer; }
.editor-dock svg{ width:21px; height:21px; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.editor-dock button[aria-current="page"]{ color:var(--blue); background:#eef6ff; }
.editor-dock button:active{ transform:scale(.96); }

/* Contextual tray. Libraries switch to a dedicated full-screen browser. */
.sheet{ position:fixed; left:0; right:0; top:var(--sheet-y, 55%); bottom:0; z-index:50;
  display:flex; flex-direction:column; min-height:0;
  background:var(--glass-strong); border-top:1px solid var(--line);
  -webkit-backdrop-filter:blur(24px) saturate(140%); backdrop-filter:blur(24px) saturate(140%);
  border-radius:24px 24px 0 0;
  box-shadow:0 -12px 40px rgba(0,0,0,.08);
  opacity:0; visibility:hidden; pointer-events:none;
  transition:top .35s var(--ease),opacity .2s ease,visibility 0s linear .35s;
  padding-bottom:env(safe-area-inset-bottom);
}
.sheet.is-open{ z-index:70; opacity:1; visibility:visible; pointer-events:auto; transition-delay:0s; }
.sheet[data-mode="library"]{ top:calc(env(safe-area-inset-top) + 52px); border-radius:0; box-shadow:none; }
.sheet[data-mode="library"] .grab{ display:none; }
.sheet[data-mode="library"] .sheet-head{ padding:15px 18px; }
.sheet[data-mode="library"] .sheet-body{ padding-top:8px; }
.sheet[data-mode="mask"]{ top:var(--sheet-y,58%); }
.sheet .grab{ width:36px; height:5px; border-radius:var(--r-pill); background:#d1d1d6;
  margin:10px auto 6px; flex:0 0 auto; touch-action:none; }
.sheet-head{ display:flex; align-items:center; justify-content:space-between; flex:0 0 auto; padding:2px 18px 12px; border-bottom:1px solid var(--line-2); }
.sheet-title{ font-size:11px; font-weight:800; letter-spacing:var(--track-label); text-transform:uppercase; color:var(--silver); }
.sheet-body{ flex:1 1 auto; min-height:0; padding:16px 18px max(24px,env(safe-area-inset-bottom));
  overflow-y:auto; overscroll-behavior:contain; touch-action:pan-y; -webkit-overflow-scrolling:touch; }

/* technical controls */
.ctl{ margin-bottom:20px; }
.ctl-label{ display:flex; justify-content:space-between; align-items:baseline; margin-bottom:9px; }
.ctl-label .k{ font-size:10px; font-weight:700; letter-spacing:.2em; text-transform:uppercase; color:var(--muted); }
.ctl-label .v{ font-family:var(--mono); font-size:11px; color:var(--silver); letter-spacing:.04em; }

input[type=range]{ -webkit-appearance:none; appearance:none; width:100%; height:6px;
  background:var(--ink-2); border:1px solid var(--line-2); border-radius:var(--r-pill); outline:none; }
input[type=range]::-webkit-slider-thumb{ -webkit-appearance:none; width:20px; height:20px; border-radius:50%;
  background:var(--paper); cursor:pointer; border:1px solid var(--line); box-shadow:0 1px 4px rgba(0,0,0,.18); }
input[type=range]::-moz-range-thumb{ width:20px; height:20px; border-radius:50%; background:var(--paper); border:1px solid var(--line); }

.seg{ display:flex; gap:2px; background:var(--ink-2); border:1px solid var(--line-2); border-radius:var(--r); padding:2px; }
.seg button{ flex:1; height:38px; border:none; background:transparent; color:var(--muted);
  font-family:var(--mono); font-size:11px; letter-spacing:.08em; cursor:pointer; border-radius:2px; text-transform:uppercase; }
.seg button[aria-selected="true"]{ background:var(--paper); color:var(--blue); box-shadow:0 1px 3px rgba(0,0,0,.1); }

.insp-actions,.hub-actions{ display:flex; align-items:center; gap:6px; margin-bottom:10px; }
.sheet[data-mode="library"] .insp-actions{ position:sticky; top:-8px; z-index:2; margin:0 -18px 12px; padding:8px 18px; background:rgba(255,255,255,.96); border-bottom:1px solid var(--line-2); }
.marklib{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.markbtn{ aspect-ratio:1; display:grid; place-items:center; cursor:pointer; overflow:hidden;
  background:var(--ink-2); border:1px solid var(--line-2); border-radius:var(--r); color:var(--silver);
  font-family:var(--mono); font-size:9px; letter-spacing:.04em; padding:0; }
.markbtn svg{ width:24px; height:24px; }
.markbtn img{ width:100%; height:100%; display:block; object-fit:contain; pointer-events:none; }
.markbtn.grain-thumb img{ object-fit:cover; }
.markbtn.on{ box-shadow:0 0 0 2px var(--paper), 0 0 0 4px var(--blue); }
.markbtn:active{ background:var(--ink); }
.markbtn.imgicon{ background-size:contain; background-repeat:no-repeat; background-position:center; background-color:var(--ink-2); }
.toast{ position:fixed; left:50%; bottom:calc(env(safe-area-inset-bottom) + 24px); transform:translate(-50%,20px);
  background:var(--silver); color:var(--black); font-size:13px; font-weight:600; letter-spacing:.02em;
  padding:10px 18px; border-radius:var(--r-pill); z-index:80; opacity:0; pointer-events:none;
  transition:opacity .25s var(--ease), transform .25s var(--ease); }
.toast.show{ opacity:1; transform:translate(-50%,0); }
.iconbtn.danger{ color:var(--red); }
.txtin{ width:100%; background:var(--ink-2); border:1px solid var(--line-2); border-radius:var(--r);
  color:var(--silver); font-family:var(--ui); font-size:14px; padding:10px 12px; resize:vertical; outline:none; }
.txtin:focus{ border-color:var(--blue); }
.selectin{ width:100%; height:44px; padding:0 12px; border:1px solid var(--line-2); border-radius:var(--r);
  background:var(--ink-2); color:var(--silver); font-family:var(--ui); font-size:14px; outline:none; }
.selectin:focus-visible{ border-color:var(--blue); }
.add-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:3px; }
.add-grid button{ min-height:48px; border:1px solid var(--line-2); border-radius:var(--r); background:var(--ink-2);
  color:var(--silver); font:700 10px/1 var(--ui); letter-spacing:.14em; text-transform:uppercase; }
.wide-action{ width:100%; min-height:44px; margin-bottom:20px; border:1px solid var(--line-2); border-radius:var(--r);
  background:var(--ink-2); color:var(--silver); font:700 10px/1 var(--ui); letter-spacing:.14em; text-transform:uppercase; }
.color-input-row input[type=color]{ width:100%; height:44px; padding:4px; border:1px solid var(--line-2); border-radius:var(--r);
  background:var(--ink-2); }
.luts{ display:flex; gap:6px; flex-wrap:wrap; }
.lut{ height:36px; padding:0 12px; border-radius:var(--r); cursor:pointer;
  background:var(--ink-2); border:1px solid var(--line-2); color:var(--muted);
  font-family:var(--mono); font-size:11px; letter-spacing:.04em; }
.lut.on{ background:var(--silver); color:var(--black); border-color:transparent; }
.swatches{ display:flex; gap:8px; flex-wrap:wrap; }
.swatch{ width:34px; height:34px; border-radius:50%; border:1px solid var(--line); cursor:pointer; }
.swatch[aria-selected="true"]{ box-shadow:0 0 0 2px var(--black), 0 0 0 3px var(--blue); }

/* tool rail (no selection) — icon row */
.toolrow{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.tool{ height:76px; border:1px solid var(--line-2); border-radius:14px; background:var(--paper);
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:8px; cursor:pointer; color:var(--silver); }
.tool:active{ background:var(--ink-2); }
.tool svg{ width:22px; height:22px; }
.tool span{ max-width:100%; padding:0 3px; font-size:8px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; color:var(--muted); }
.tool-note{ margin-top:8px; color:var(--muted); font-size:12px; line-height:1.5; }
.design-summary{ display:flex; flex-direction:column; gap:5px; padding:4px 0 24px; }
.design-summary span,.layer-kind{ color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.08em; }
.design-summary strong{ font-size:20px; font-weight:650; letter-spacing:-.02em; }
.danger-action{ color:var(--red); }
.layer-list{ display:flex; flex-direction:column; gap:1px; }
.layer-item{ display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; border-bottom:1px solid var(--line-2); }
.layer-select{ min-width:0; min-height:58px; border:0; background:transparent; text-align:left; display:flex; flex-direction:column; justify-content:center; gap:4px; padding:8px 6px; color:var(--silver); }
.layer-select strong{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:14px; font-weight:600; }
.layer-eye{ min-width:52px; height:40px; border:0; border-radius:10px; background:var(--ink-2); color:var(--muted); font:600 11px/1 var(--ui); }
.empty-note{ color:var(--muted); font-size:14px; text-align:center; padding:40px 0; }
.target-note{ margin:0 0 14px; padding:10px 12px; border-radius:10px; background:#eef6ff;
  color:#0058b0; font-size:12px; font-weight:700; line-height:1.4; text-align:right; direction:rtl; }
.replace-image{ color:var(--blue); border-color:rgba(0,122,255,.22); background:#f3f8ff; }

@media (max-width:899px){
  body[data-panel="open"] .stage{
    bottom:calc(100% - var(--panel-top,68%));
    padding-bottom:12px;
  }
  .sheet .grab{ width:52px; height:6px; margin-top:9px; }
  .sheet-head{ min-height:42px; }
}

@media (max-width:600px){
  .topbar,.editor-top,.dock-inner,.editor-dock{
    -webkit-backdrop-filter:none;
    backdrop-filter:none;
  }
  .topbar,.editor-top,.editor-dock{ background:#fff; }
  .dock-inner{ background:rgba(255,255,255,.98); }
  .editor-top{
    height:calc(96px + env(safe-area-inset-top));
    padding:env(safe-area-inset-top) 8px 8px;
    display:grid;
    grid-template-columns:40px 40px 40px minmax(0,1fr) auto;
    grid-template-rows:40px 36px;
    gap:4px;
    justify-content:normal;
  }
  .editor-top #backBtn{ grid-column:1; grid-row:1; }
  .editor-top #undoBtn{ grid-column:2; grid-row:1; }
  .editor-top #redoBtn{ grid-column:3; grid-row:1; }
  .editor-top #savePresetBtn{ grid-column:4; grid-row:1; justify-self:end; }
  .editor-top #exportBtn{ grid-column:5; grid-row:1; justify-self:end; margin-inline-start:4px; }
  .editor-top #aspectSeg{ grid-column:1 / span 3; grid-row:2; justify-self:start; }
  .editor-top #origBtn{ grid-column:4; grid-row:2; justify-self:end; }
  .editor-top #saveBtn{ grid-column:5; grid-row:2; justify-self:stretch; }
  .editor-top .aspect-seg button{ min-width:36px; height:30px; padding:0 5px; }
  .editor-top .tbtn,.editor-top .export-btn{ height:34px; padding:0 11px; }
  .stage{ padding-top:calc(env(safe-area-inset-top) + 112px); }
  .sheet[data-mode="library"]{ top:calc(env(safe-area-inset-top) + 96px); }
}

@media (min-width:900px){
  .editor-top{ height:60px; padding:8px 16px; }
  .editor-dock{ top:60px; right:auto; bottom:0; width:88px; grid-template-columns:1fr; grid-template-rows:repeat(5,74px);
    align-content:start; gap:4px; padding:14px 8px; border-top:0; border-right:1px solid var(--line-2); }
  .editor-dock button{ height:70px; }
  .stage{ left:88px; padding:84px 40px 28px; transition:right .3s var(--ease); }
  body[data-panel="open"] .stage{ right:360px; }
  .sheet,.sheet[data-mode="library"],.sheet[data-mode="mask"]{ left:auto; right:0; top:60px; bottom:0; width:360px;
    border-radius:0; border-top:0; border-left:1px solid var(--line-2); box-shadow:-16px 0 36px rgba(0,0,0,.06); }
  .sheet[data-mode="library"]{ width:420px; }
  body:has(.sheet[data-mode="library"].is-open) .stage{ right:420px; }
  .sheet .grab{ display:none; }
  .sheet-head,.sheet[data-mode="library"] .sheet-head{ padding:18px 20px; }
  .sheet-body{ padding:18px 20px 28px; }
  .toolrow{ grid-template-columns:repeat(2,1fr); gap:8px; }
  .marklib{ grid-template-columns:repeat(3,1fr); }
  .board{ max-width:min(70vw,760px); max-height:calc(100dvh - 120px); }
}

@media (prefers-reduced-transparency: reduce){
  .dock-inner,.sheet{ background:#fff; backdrop-filter:none; }
  .topbar{ backdrop-filter:none; background:#fff; }
}
@media (prefers-reduced-motion: reduce){
  .sheet{ transition:none; }
  .cover,.iconbtn{ transition:none; }
}
input[type=file]{ display:none; }

/* Phase 2 — unified numeric control */
.ctl-num .num-wrap{ display:flex; align-items:center; gap:4px; }
.ctl-num .num{ width:56px; text-align:right; font:600 12px/1 var(--mono); color:var(--silver);
  background:var(--panel,#fff); border:1px solid var(--line-2); border-radius:8px; padding:5px 7px; }
.ctl-num .unit{ font:600 10px var(--mono); color:var(--muted); }
.ctl-num .mini{ width:26px; height:26px; border:1px solid var(--line-2); background:var(--panel,#fff);
  border-radius:7px; color:var(--muted); font-size:11px; line-height:1; display:flex; align-items:center; justify-content:center; cursor:pointer; padding:0; }
.ctl-num .mini:active{ background:var(--blue); color:#fff; border-color:var(--blue); }
.ctl-num .mini.reset{ font-size:13px; }
.ctl-num .k[data-scrub]{ cursor:ew-resize; user-select:none; }

/* Phase 5 — inspector sections, paired controls, alignment grid, multi-select header */
.section{ margin-bottom:14px; border:1px solid var(--line-2); border-radius:var(--r); overflow:hidden; background:var(--paper); }
.section-head{ width:100%; display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px; background:transparent; border:0; cursor:pointer; color:var(--silver); }
.section-head span:first-child{ font-size:10px; font-weight:800; letter-spacing:.2em; text-transform:uppercase; color:var(--silver); }
.section-head .chev{ font-size:11px; color:var(--muted); transition:transform .2s var(--ease); }
.section[data-open="false"] .section-head .chev{ transform:rotate(-90deg); }
.section-body{ padding:4px 14px 14px; }
.section[data-open="false"] .section-body{ display:none; }

.ctl-pair{ margin-bottom:16px; }
.ctl-pair .ctl-label{ margin-bottom:8px; }
.ctl-pair .pair-cols{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.ctl-pair .pair-col{ min-width:0; }
.ctl-pair .pair-col > .ctl-num{ margin-bottom:0; }
.ctl-pair .pair-col .ctl-label{ margin-bottom:6px; }

.align-grid{ display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(5,28px); gap:4px; margin-bottom:8px; }
.align-cell{ border:1px solid var(--line-2); border-radius:8px; background:var(--ink-2); cursor:pointer; padding:0; }
.align-cell:hover{ border-color:var(--blue); background:var(--paper); }
.align-cell:active{ background:var(--blue); }
.align-note{ font-size:10px; letter-spacing:.1em; text-transform:uppercase; color:var(--muted); }
.align-cell.fine{ opacity:.5; }
.align-cell.fine:hover{ opacity:1; }

.multi-head{ padding:2px 0 12px; }
.multi-head strong{ font-size:14px; font-weight:700; color:var(--silver); letter-spacing:.02em; }

/* Version 30: quiet controls, readable type, continuous canvas access. */
:root{ --muted:#595e65; --dim:#62676d; --blue:#23594b; --line:rgba(20,30,26,.18); --ink-2:#f2f4f2; --track-label:0; --track-nav:0; }
button,input,select,textarea{font-family:var(--ui);}
button{cursor:pointer;}
button:disabled{cursor:default;opacity:.45;}
button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:2px solid var(--blue);outline-offset:3px;}
.topbar{height:64px;padding:12px 24px;background:#fff;backdrop-filter:none;}
.wordmark{text-transform:none;font-size:18px;letter-spacing:-.03em;text-align:left;}
.topbar .slot:first-child{display:none;}
.ver-tag{font:600 12px var(--ui);letter-spacing:0;color:#23594b;background:#edf4ef;border:0;padding:6px 10px;}
.gallery-intro{max-width:1200px;margin:0 auto;padding:38px 24px 28px;display:flex;align-items:center;justify-content:space-between;gap:24px;}
.gallery-intro h2{font-size:clamp(26px,3vw,38px);line-height:1.15;letter-spacing:-.035em;font-weight:600;margin:0 0 12px;max-width:20ch;text-wrap:balance;}
.gallery-intro p{font-size:15px;line-height:1.5;color:var(--muted);margin:0;}
.upload-action{min-height:48px;flex-shrink:0;padding:0 22px;background:#23594b;color:white;border:0;border-radius:10px;font-size:15px;font-weight:600;display:flex;gap:25px;align-items:center;justify-content:center;}
.gallery-heading{max-width:1200px;margin:auto;padding:12px 24px 4px;display:flex;justify-content:space-between;align-items:center;gap:12px;}
.gallery-heading h3{font-size:15px;font-weight:600;margin:0;}
.gallery-heading span{font-size:13px;color:var(--muted);}
.grid{max-width:1200px;margin:auto;padding:16px 24px 110px;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px;}
.cover{border:0;border-radius:10px;}
.cover .meta{font:500 12px/1.35 var(--ui);letter-spacing:0;text-transform:none;gap:8px;}
.cover .meta .num{font-variant-numeric:tabular-nums;}
.cover-edit{font:600 12px var(--ui);letter-spacing:0;min-width:44px;min-height:36px;padding:6px 12px;}
.cover-badge{font:600 11px var(--ui);letter-spacing:0;background:white;color:#23594b;}
.cover-revert{min-width:36px;min-height:36px;}
.sheet{background:#fff;backdrop-filter:none;border-radius:18px 18px 0 0;box-shadow:0 -8px 24px rgba(0,0,0,.04);bottom:calc(74px + env(safe-area-inset-bottom));padding-bottom:0;}
.sheet-head{padding:4px 18px 10px;min-height:48px;}
.sheet-title{font-size:16px;font-weight:650;letter-spacing:-.015em;text-transform:none;}
.sheet-done{height:36px;color:#23594b;background:#edf4ef;border:0;}
.sheet-body{padding:16px 18px 28px;}
.editor-top{height:calc(64px + env(safe-area-inset-top));padding:calc(8px + env(safe-area-inset-top)) 12px 8px;display:flex;justify-content:flex-start;gap:4px;backdrop-filter:none;}
.editor-top #aspectSeg,.editor-top #origBtn,.editor-top #savePresetBtn{display:none;}
.editor-top #saveBtn{margin-left:auto;background:transparent;color:var(--silver);border:1px solid var(--line-2);}
.editor-top #exportBtn{margin-left:4px;background:#23594b;}
.editor-top .tbtn,.editor-top .export-btn{height:42px;padding:0 16px;font-size:14px;letter-spacing:0;text-transform:none;font-weight:600;}
.iconbtn{width:44px;height:44px;}
.stage{padding-top:calc(80px + env(safe-area-inset-top));background:#edefec;}
.board{border:0;border-radius:2px;}
.editor-dock{padding:6px 8px max(8px,env(safe-area-inset-bottom));backdrop-filter:none;background:#fff;}
.editor-dock button{height:58px;font-size:12px;gap:6px;}
.editor-dock button[aria-current="page"]{background:#edf4ef;}
body[data-panel="open"] .stage{padding-bottom:14px;}
.section{border:0;border-top:1px solid var(--line-2);border-radius:0;margin-bottom:16px;overflow:visible;background:transparent;}
.section-head{padding:16px 0;min-height:48px;}
.section-head span:first-child{font-size:14px;font-weight:600;letter-spacing:0;text-transform:none;}
.section-body{padding:0;}
.ctl{margin-bottom:22px;}
.ctl-label .k{font-size:13px;font-weight:500;letter-spacing:0;text-transform:none;line-height:1.4;color:var(--muted);}
.ctl-label .v{font:500 12px var(--ui);font-variant-numeric:tabular-nums;letter-spacing:0;}
input[type=range]{height:22px;border:0;background:transparent;accent-color:var(--blue);direction:ltr;}
input[type=range]::-webkit-slider-runnable-track{height:4px;border-radius:4px;background:#dde4df;}
input[type=range]::-webkit-slider-thumb{width:22px;height:22px;margin-top:-9px;background:#23594b;border:3px solid white;box-shadow:0 1px 4px #0003;}
input[type=range]::-moz-range-track{height:4px;border-radius:4px;background:#dde4df;}
input[type=range]::-moz-range-thumb{background:#23594b;border:3px solid white;}
.ctl-num .num{font:500 14px var(--ui);min-height:36px;width:66px;}
.ctl-num .mini.down,.ctl-num .mini.up{display:none;}
.ctl-num .mini.reset{width:36px;height:36px;}
.ctl-num .unit{font:500 12px var(--ui);}
.seg{gap:3px;padding:3px;border:0;}
.seg button{height:42px;font:500 13px var(--ui);letter-spacing:0;text-transform:none;border-radius:7px;}
.seg button[aria-selected="true"]{color:#23594b;}
.selectin,.txtin{font-size:16px;line-height:1.5;background:#f7f8f6;border-radius:9px;}
.txtin{padding:12px;}
.quick-text{min-height:100px;margin-bottom:16px;resize:vertical;}
.quick-line{display:grid;grid-template-columns:minmax(0,1fr) 48px;gap:8px;margin:18px 0;align-items:center;}
.text-style{height:44px;background:transparent;color:#23594b;border:0;font-size:13px;}
.wide-action,.add-grid button{font:600 14px/1.4 var(--ui);letter-spacing:0;text-transform:none;min-height:46px;margin-bottom:14px;background:#f2f4f2;}
.wide-action.primary-action{background:#23594b;color:white;border:0;}
.wide-action.replace-image{background:#edf4ef;color:#23594b;border:0;}
.custom-color{display:flex;align-items:center;justify-content:space-between;font-size:13px;color:var(--muted);margin-bottom:22px;min-height:44px;}
.custom-color input{width:56px;height:36px;border:1px solid var(--line-2);border-radius:6px;background:white;}
.control-heading{display:block;font-size:14px;font-weight:600;margin:6px 0 12px;}
.target-note{direction:ltr;text-align:left;padding:0;margin-bottom:14px;background:transparent;color:var(--muted);font-size:12px;font-weight:500;}
.photo-looks{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin:0 0 22px;}
.look-option{padding:3px;border:1px solid var(--line-2);background:#fff;border-radius:8px;overflow:hidden;min-height:44px;}
.look-option img{display:block;width:100%;aspect-ratio:1.4;object-fit:cover;border-radius:5px;}
.look-option span{display:block;font-size:12px;font-weight:500;padding:8px 2px;}
.look-option[aria-pressed="true"]{border:2px solid #23594b;padding:2px;color:#23594b;background:#edf4ef;}
.toolrow{grid-template-columns:repeat(3,1fr);}
.tool{height:84px;border-radius:10px;}
.tool span{font-size:12px;font-weight:500;letter-spacing:0;text-transform:none;}
.hub-actions{display:none;}
.swatch{width:38px;height:38px;}
.swatches{gap:7px;}
.align-grid{grid-template-rows:repeat(3,38px);}
.align-cell{font-size:18px;color:var(--muted);}
.align-note{font-size:12px;letter-spacing:0;text-transform:none;line-height:1.5;margin-bottom:18px;}
.tool-note{font-size:13px;line-height:1.6;margin:8px 0 20px;}
.suggestion-results{display:grid;grid-template-columns:1fr;gap:24px;}
.suggestion-card{display:grid;grid-template-columns:100px minmax(0,1fr);gap:10px 16px;align-items:center;border-top:1px solid var(--line-2);padding-top:20px;}
.suggestion-card img{width:100px;border-radius:6px;grid-row:span 2;}
.suggestion-card strong{font-size:14px;}
.suggestion-card .wide-action{margin:0;}
.layer-eye{height:44px;min-width:56px;}
.insp-actions{margin-top:-6px;margin-bottom:6px;}
@media(max-width:899px){
  .grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;padding-inline:16px;}
  .gallery-intro{padding:28px 18px 24px;align-items:flex-start;}
  .gallery-heading{padding-inline:18px;}
  .sheet[data-mode="library"]{top:calc(64px + env(safe-area-inset-top));}
}
@media(max-width:540px){
  .gallery-intro{flex-direction:column;gap:20px;}
  .upload-action{width:100%;}
  .gallery-heading span{font-size:12px;}
  .topbar{padding-inline:18px;}
  .cover .meta{font-size:11px;padding:10px;}
  .cover-edit{min-height:32px;font-size:11px;padding:6px 10px;}
  .editor-top{grid-template-columns:none;grid-template-rows:none;}
}
@media(min-width:900px){
  .editor-dock{top:64px;width:88px;grid-template-columns:1fr;grid-template-rows:repeat(5,74px);padding:14px 8px;}
  .stage{left:88px;padding:88px 32px 24px;}
  .sheet,.sheet[data-mode="library"],.sheet[data-mode="mask"]{width:370px;top:64px;bottom:0;border-radius:0;box-shadow:none;}
  body[data-panel="open"] .stage,body:has(.sheet[data-mode="library"].is-open) .stage{right:370px;}
  .sheet-head{padding:14px 20px;}
  .sheet-body{padding:18px 20px 28px;}
}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important;}}
.gallery-filter{display:block;margin:0 auto 110px;min-height:46px;padding:0 24px;background:#f2f4f2;color:#23594b;border:1px solid var(--line-2);border-radius:9px;font-size:14px;font-weight:600;}
.grid{padding-bottom:28px;}
.stage{transition:none;}
.toast{bottom:calc(env(safe-area-inset-bottom) + 86px);max-width:calc(100vw - 32px);text-align:center;}

/* Image V2.1 only: direct content editing and a compact, expandable tray. */
.sheet[data-mode="image"]{transition:none;}
.sheet[data-mode="image"] .grab{position:absolute;top:12px;left:12px;transform:none;width:calc(100% - 178px);height:44px;margin:0;background:transparent;z-index:2;border-radius:8px;cursor:ns-resize;}
.sheet[data-mode="image"]::before{content:"";position:absolute;width:36px;height:4px;left:calc(50% - 18px);top:9px;border-radius:3px;background:#c7cec9;pointer-events:none;}
.sheet[data-mode="image"] .grab::before{content:"⌃";position:absolute;left:50px;top:13px;color:#66716a;font:500 16px var(--ui);}
.sheet[data-mode="image"] .grab[aria-expanded="true"]::before{transform:rotate(180deg);}
.sheet[data-mode="image"] .grab:focus-visible{outline:2px solid #23594b;outline-offset:-4px;border-radius:8px;}
.sheet[data-mode="image"] .sheet-head{padding:12px 16px 4px;min-height:60px;gap:8px;}
.sheet[data-mode="image"] .sheet-title{flex:1;font-size:15px;}
.sheet[data-mode="image"] .sheet-done{min-height:44px;margin:0;}
.sheet[data-mode="image"] .image-replace-small{width:auto;min-height:44px;min-width:64px;margin:0;padding:8px;color:#23594b;background:transparent;border:0;font:600 13px var(--ui);}
.sheet[data-mode="image"] .sheet-body{padding:8px 16px 12px;}
.sheet[data-mode="image"] .image-source-row{margin:0 0 8px;}
.sheet[data-mode="image"] .image-source-row .ctl{margin:0;}
.sheet[data-mode="image"] .image-source-row .ctl-label{display:none;}
.sheet[data-mode="image"] .image-source-row .selectin{height:44px;padding:8px;font-size:14px;}
.image-tool-tabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px;padding:3px;background:#f0f3ef;border-radius:10px;margin-bottom:6px;}
.image-tool-tabs button{min-width:0;min-height:44px;padding:8px 3px;border:0;border-radius:7px;background:transparent;color:#66716a;font:600 13px/1.2 var(--ui);touch-action:manipulation;}
.image-tool-tabs button[aria-selected="true"]{background:white;color:#23594b;box-shadow:0 1px 3px #203d2914;}
.image-tool-tabs button:active,.image-text-action:active,.image-replace-small:active{opacity:.65;}
.image-tool-panel{min-width:0;}
.image-slider{display:block;margin:0;}
.image-slider-label{display:flex;align-items:center;justify-content:space-between;font:500 13px/1.4 var(--ui);color:var(--silver);}
.image-slider output{color:#66716a;font-variant-numeric:tabular-nums;}
.image-slider input[type="range"]{display:block;height:44px;margin:0;touch-action:pan-y;}
.image-slider input[type="range"]::-webkit-slider-thumb{width:28px;height:28px;margin-top:-12px;}
.image-slider input[type="range"]::-moz-range-thumb{width:24px;height:24px;}
.image-slider-inline{display:flex;flex-direction:row-reverse;align-items:center;gap:14px;}
.image-slider-inline .image-slider-label{flex-shrink:0;gap:8px;}
.image-slider-inline .image-slider-label>span{display:none;}
.image-slider-inline input{min-width:0;flex:1;}
.image-slider-inline output{min-width:42px;text-align:right;font-size:12px;}
.image-adjust-hint{margin:4px 0 0;color:#66716a;font:400 12px/1.4 var(--ui);}
.image-adjust-actions{display:flex;align-items:center;justify-content:space-between;gap:12px;}
.image-text-action,.image-reset{min-height:44px;min-width:44px;padding:8px 0;border:0;background:transparent;color:#23594b;font:600 13px var(--ui);touch-action:manipulation;}
.image-text-action[aria-pressed="true"]{text-decoration:underline;text-underline-offset:4px;}
.image-tools button:focus-visible,.image-tools input:focus-visible{outline:2px solid #23594b;outline-offset:2px;}
.sheet[data-mode="image"] .section{margin-bottom:8px;}
.sheet[data-mode="image"] .section-head{min-height:44px;padding:10px 0;}
.photo-adjust-overlay{position:absolute;inset:0;z-index:3;pointer-events:none;}
.photo-adjust-surface{position:absolute;transform-origin:0 0;pointer-events:auto;touch-action:none;cursor:grab;outline:1px solid #ffffff9c;outline-offset:-1px;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;}
.photo-adjust-surface:active{cursor:grabbing;}
.photo-adjust-surface:focus-visible{outline:2px solid #5b8cff;outline-offset:-2px;}
.photo-crop-line{position:absolute;left:0;right:0;height:0;border-top:1px dashed white;pointer-events:none;filter:drop-shadow(0 1px 1px #0009);}
.photo-crop-handle{position:absolute;width:44px;height:44px;touch-action:none;cursor:ns-resize;outline:0;}
.photo-crop-handle.cropTop{left:0;}
.photo-crop-handle.cropBottom{right:0;}
.photo-crop-handle::before{content:"";position:absolute;left:8px;right:8px;top:var(--crop-mark-y,19px);height:6px;border-radius:4px;background:white;box-shadow:0 1px 5px #0008;}
.photo-crop-handle:focus-visible::before{outline:3px solid #5b8cff;outline-offset:2px;}
@media(min-width:900px){.sheet[data-mode="image"] .grab{display:none;}}
