:root{
  --top-h: 62px;
  --rail-w: 66px;
  --drawer-w: min(86vw, 360px);
  --bg:#050914;
  --bg2:#0b1630;
  --surface:rgba(7,14,31,.96);
  --surface2:rgba(255,255,255,.96);
  --text:#edf2ff;
  --text-dark:#0f172a;
  --muted:#a8b3c8;
  --line:rgba(148,163,184,.22);
  --accent:#7fb7ff;
  --accent2:#8fbaff;
  --shadow:0 18px 40px rgba(0,0,0,.30);
}
*{box-sizing:border-box}
html,body{width:100%;height:100%;margin:0;overflow:hidden;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif}
body{background:var(--bg);color:var(--text);touch-action:none;-webkit-tap-highlight-color:transparent}
body.light{background:#eef3fb;color:var(--text-dark)}
button,input,select,a{font:inherit}
button{cursor:pointer}
a{color:inherit;text-decoration:none}

.app{position:fixed;inset:0;display:grid;grid-template-rows:var(--top-h) 1fr;background:inherit}
.topbar{
  display:flex;align-items:center;gap:8px;
  padding:10px 10px calc(10px + env(safe-area-inset-top));
  background:var(--surface);
  border-bottom:1px solid var(--line);
  z-index:30;
}
body.light .topbar{background:var(--surface2)}
.icon-btn,.pill-btn,.action,.rail-btn,.chip,.mini-btn{
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  color:inherit;
  border-radius:14px;
  font-weight:700;
}
.icon-btn, .pill-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;
}
svg, .btn-svg{
  width:18px;height:18px;fill:currentColor;flex:0 0 auto;
}
body.light .icon-btn, body.light .pill-btn, body.light .action, body.light .rail-btn, body.light .chip, body.light .mini-btn{
  background:rgba(255,255,255,.96);
  color:#0f172a;
  border-color:rgba(15,23,42,.16);
}
.icon-btn{
  min-width:42px;min-height:42px;padding:0 10px;display:inline-flex;align-items:center;justify-content:center
}
.pill-btn{
  min-height:42px;padding:0 14px;display:inline-flex;align-items:center;justify-content:center
}
.finish{
  background:linear-gradient(180deg, #2fd46d 0%, #18b857 100%);
  border-color:transparent;
  color:#fff;
  box-shadow:0 10px 22px rgba(24,184,87,.22);
}
body.light .finish{
  background:linear-gradient(180deg, #2fd46d 0%, #18b857 100%);
  color:#fff;
  box-shadow:0 10px 22px rgba(24,184,87,.18);
}
.finish svg{width:18px;height:18px;fill:currentColor}
.topbar .title{min-width:0;flex:1;display:flex;flex-direction:column;gap:2px;line-height:1.1}
.topbar .title strong{font-size:.98rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar .title span{font-size:.78rem;color:var(--muted)}

.main{position:relative;overflow:hidden}
.scene{
  position:absolute;inset:0;
  overflow:hidden;
  background:
    linear-gradient(45deg, rgba(255,255,255,.03) 25%, transparent 25%) 0 0/18px 18px,
    linear-gradient(-45deg, rgba(255,255,255,.03) 25%, transparent 25%) 0 9px/18px 18px,
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.03) 75%) 9px -9px/18px 18px,
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.03) 75%) 9px 9px/18px 18px,
    var(--bg2);
  touch-action:none;
  border:1px solid rgba(148,163,184,.36);
  outline:1px solid rgba(15,23,42,.12);
  outline-offset:-1px;
}
body.light .scene{
  border-color:rgba(15,23,42,.18);
  outline-color:rgba(255,255,255,.62);
}
body.light .scene{
  background:
    linear-gradient(45deg, rgba(15,23,42,.06) 25%, transparent 25%) 0 0/18px 18px,
    linear-gradient(-45deg, rgba(15,23,42,.06) 25%, transparent 25%) 0 9px/18px 18px,
    linear-gradient(45deg, transparent 75%, rgba(15,23,42,.06) 75%) 9px -9px/18px 18px,
    linear-gradient(-45deg, transparent 75%, rgba(15,23,42,.06) 75%) 9px 9px/18px 18px,
    #dfe7f3;
}

.stage{
  position:absolute;left:0;top:0;
  transform-origin:0 0;
  will-change:transform;
  outline:2px solid rgba(255,255,255,.92);
  outline-offset:-2px;
  box-shadow:0 0 0 1px rgba(255,255,255,.18), 0 0 0 4px rgba(79,140,255,.10);
}
body.light .stage{
  outline-color:rgba(30,64,175,.92);
  box-shadow:0 0 0 1px rgba(15,23,42,.14), 0 0 0 4px rgba(30,64,175,.10);
}
.layer-host{
  position:relative;width:100%;height:100%;
}
.layer-canvas{
  position:absolute;left:0;top:0;width:100%;height:100%;
  image-rendering:auto;
  pointer-events:none;
}
.layer-canvas.active{outline:2px solid rgba(79,140,255,.45);outline-offset:-2px}

.selection-box{
  position:absolute;
  border:2px dashed rgba(79,140,255,.95);
  background:rgba(79,140,255,.12);
  color:#fff;
  min-width:18px;min-height:18px;
  z-index:50;
  pointer-events:auto;
}
.selection-box.hidden{display:none}
.selection-tag{
  position:absolute;left:6px;top:-22px;
  font-size:11px;font-weight:800;
  padding:3px 8px;border-radius:999px;
  background:rgba(79,140,255,.92);
}

.reference-wrap{
  position:absolute;top:10px;right:10px;width:170px;height:130px;
  border:1px solid var(--line);
  border-radius:16px;overflow:hidden;
  background:rgba(15,23,42,.98);
  box-shadow:var(--shadow);
  z-index:60;
  resize:none;
  pointer-events:auto;
}
body.light .reference-wrap{background:rgba(255,255,255,.98)}
.reference-wrap.hidden{display:none}
.reference-head{
  height:28px;padding:0 8px;
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  font-size:.75rem;font-weight:800;
  border-bottom:1px solid rgba(255,255,255,.08);
  cursor:move;user-select:none
}
body.light .reference-head{border-bottom:1px solid rgba(15,23,42,.08)}
.reference-body{position:absolute;inset:28px 0 0 0}
.reference-body img{width:100%;height:100%;object-fit:contain;display:block}
.reference-resize{
  position:absolute;right:2px;bottom:2px;width:18px;height:18px;
  border-radius:6px;background:rgba(79,140,255,.95);cursor:nwse-resize
}
.reference-mini{
  min-width:24px;min-height:24px;border-radius:999px;
  display:inline-flex;align-items:center;justify-content:center;
  padding:0 7px;border:1px solid var(--line);background:transparent;color:inherit
}

.rail{
  position:fixed;
  top:calc(var(--top-h) + env(safe-area-inset-top) + 8px);
  right:calc(6px + env(safe-area-inset-right));
  bottom:8px;
  width:52px;
  display:flex;
  flex-direction:column;
  gap:6px;
  z-index:45;
  align-items:stretch;
  overflow-y:auto;
  padding-right:0;
  scrollbar-width:none;
}
.rail::-webkit-scrollbar{display:none}
.rail-btn{
  min-height:40px;width:100%;
  padding:0;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 8px 20px rgba(0,0,0,.12);
  background:rgba(17,24,39,.78);
  border-color:rgba(255,255,255,.12);
}
body.light .rail-btn{
  background:rgba(255,255,255,.98);
  border-color:rgba(15,23,42,.16);
}
.rail-btn.active{
  background:rgba(79,140,255,.20);
  border-color:rgba(79,140,255,.70);
  box-shadow:0 0 0 2px rgba(79,140,255,.16), 0 8px 20px rgba(79,140,255,.12);
}
.rail-btn.active{background:rgba(79,140,255,.18);border-color:rgba(79,140,255,.45)}

.drawer{
  position:fixed;
  top:calc(var(--top-h) + env(safe-area-inset-top) + 8px);
  right:calc(60px + env(safe-area-inset-right));
  width:var(--drawer-w);
  max-width:calc(100vw - 74px);
  bottom:8px;
  transform:translateX(calc(100% + 28px));
  transition:transform .22s ease, opacity .18s ease, visibility .18s ease;
  z-index:34;
  display:flex;flex-direction:column;
  pointer-events:none;
  opacity:0;
  visibility:hidden;
}
.drawer.open{transform:translateX(0);pointer-events:auto;opacity:1;visibility:visible}
.drawer-head{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:12px 12px;
  border:1px solid var(--line);border-bottom:none;
  border-radius:18px 18px 0 0;
  background:var(--surface);
  box-shadow:var(--shadow);
}
body.light .drawer-head{background:var(--surface2)}
.panel{
  flex:1;
  overflow:auto;
  padding:12px;
  border:1px solid var(--line);
  border-radius:0 0 18px 18px;
  background:color-mix(in srgb, var(--surface) 96%, #000 4%);
  box-shadow:var(--shadow);
}
body.light .panel{
  background:color-mix(in srgb, var(--surface2) 96%, #fff 4%);
}
body.light .panel{background:var(--surface2)}
.panel.hidden{display:none}
.stack{display:grid;gap:12px}
.grid{display:grid;gap:8px}
.tools-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.btnrow{display:flex;gap:8px;flex-wrap:wrap}
.chip{
  min-height:42px;padding:0 12px;
  display:inline-flex;align-items:center;justify-content:center;
}
.chip.active{background:rgba(79,140,255,.18);border-color:rgba(79,140,255,.45)}
.action{
  min-height:44px;padding:0 14px;
  display:flex;align-items:center;justify-content:center;
}
.primary{background:var(--accent);border-color:transparent;color:#fff}
.mini-btn{
  min-width:36px;min-height:36px;border-radius:10px;padding:0 8px
}
label{display:grid;gap:6px;font-size:.88rem}
label span,.hint{color:var(--muted);font-size:.8rem}

.color-wheel{
  width:100%;
  aspect-ratio:1;
  border-radius:50%;
  border:1px solid var(--line);
  background:
    radial-gradient(circle at center, rgba(255,255,255,.98) 0 0%, rgba(255,255,255,.0) 0 0),
    conic-gradient(#ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
  position:relative;
  overflow:hidden;
}
.color-wheel::after{
  content:'';
  position:absolute;
  inset:18%;
  border-radius:50%;
  background:var(--surface);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.08);
  pointer-events:none;
}
body.light .color-wheel::after{background:var(--surface2)}
.color-wheel.active{
  outline:2px solid rgba(79,140,255,.65);
  outline-offset:2px;
}
input[type="range"],input[type="number"],input[type="color"],input[type="file"],select{
  width:100%;min-height:42px;border-radius:12px;border:1px solid var(--line);
  background:rgba(255,255,255,.04);color:inherit;padding:8px 10px
}
input[type="range"]{padding:0}
.palette{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px
}
.swatch{
  width:100%;aspect-ratio:1;border-radius:999px;border:1px solid rgba(255,255,255,.16)
}
body.light .swatch{border-color:rgba(15,23,42,.14)}
.layer-list{display:grid;gap:8px}
.layer-item{
  display:grid;
  grid-template-columns:1fr auto auto auto;
  gap:6px;
  align-items:center;
  padding:10px;border:1px solid var(--line);border-radius:14px;
}
.layer-item.active{background:rgba(79,140,255,.12);border-color:rgba(79,140,255,.35)}
.layer-name{font-weight:800;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.layer-name small{display:block;color:var(--muted);font-weight:600}
.layer-actions{display:flex;gap:6px}
.layer-actions button{
  min-width:36px;min-height:36px;border-radius:10px;border:1px solid var(--line);background:transparent;color:inherit
}
body.light .layer-actions button{
  background:rgba(255,255,255,.96);
  color:#0f172a;
  border-color:rgba(15,23,42,.16);
}
.hint{margin:0;line-height:1.5}

.modal{
  position:fixed;inset:0;display:flex;align-items:center;justify-content:center;
  background:rgba(0,0,0,.48);z-index:60;padding:16px
}
.modal.hidden{display:none}
.modal-card{
  width:min(92vw, 420px);
  border:1px solid var(--line);
  border-radius:18px;
  background:var(--surface);
  box-shadow:var(--shadow);
  overflow:hidden;
}
body.light .modal-card{background:var(--surface2)}
.modal-head{
  display:flex;align-items:center;justify-content:space-between;gap:8px;
  padding:12px 12px;border-bottom:1px solid var(--line)
}
.modal-body{padding:12px;display:grid;gap:12px}
.modal-body .stack{display:grid;gap:6px}
.modal-body input[type="text"]{
  width:100%;
  min-height:42px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  color:inherit;
  padding:10px 12px;
}
body.light .modal-body input[type="text"]{background:rgba(15,23,42,.02)}
.modal-body img{
  width:100%;max-height:50vh;object-fit:contain;
  border-radius:14px;border:1px solid var(--line);background:rgba(0,0,0,.04)
}

@media (max-width: 520px){
  :root{--top-h:60px;--rail-w:60px}
  .drawer{right:calc(var(--rail-w) + 10px)}
}
.scene.texture-plain{}
.scene.texture-grid{
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.07) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.07) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.07) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.07) 75%);
  background-size:18px 18px;
  background-position:0 0, 0 9px, 9px -9px, 9px 9px;
}
body.light .scene.texture-grid{
  background-image:
    linear-gradient(45deg, rgba(15,23,42,.07) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(15,23,42,.07) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(15,23,42,.07) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(15,23,42,.07) 75%);
}
.scene.texture-paper{
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.16), transparent 22%),
    radial-gradient(circle at 80% 30%, rgba(255,255,255,.10), transparent 18%),
    radial-gradient(circle at 35% 75%, rgba(255,255,255,.08), transparent 20%),
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)),
    var(--bg2);
}
body.light .scene.texture-paper{
  background:
    radial-gradient(circle at 20% 20%, rgba(15,23,42,.06), transparent 22%),
    radial-gradient(circle at 80% 30%, rgba(15,23,42,.04), transparent 18%),
    radial-gradient(circle at 35% 75%, rgba(15,23,42,.04), transparent 20%),
    linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.06)),
    #f3e9d4;
}
.scene.texture-sand{
  background:
    radial-gradient(circle at 10% 15%, rgba(255,255,255,.07), transparent 18%),
    radial-gradient(circle at 80% 65%, rgba(255,255,255,.06), transparent 22%),
    linear-gradient(180deg, #c8b28a, #b7956a);
}
body.light .scene.texture-sand{
  background:
    radial-gradient(circle at 10% 15%, rgba(15,23,42,.05), transparent 18%),
    radial-gradient(circle at 80% 65%, rgba(15,23,42,.04), transparent 22%),
    linear-gradient(180deg, #e9d7b7, #d7bf92);
}

#helpModal .stack{display:grid;gap:8px}
#helpModal span{line-height:1.5}
.modal-body input[type="text"]{
  width:100%;
  min-height:42px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  color:inherit;
  padding:10px 12px;
}
body.light .modal-body input[type="text"]{background:rgba(255,255,255,.96);color:#0f172a;border-color:rgba(15,23,42,.16)}

.help-fab{
  position:fixed;
  left:calc(8px + env(safe-area-inset-left));
  bottom:calc(8px + env(safe-area-inset-bottom));
  width:44px;
  height:44px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  z-index:46;
  border:1px solid var(--line);
  background:rgba(17,24,39,.82);
  color:inherit;
  box-shadow:0 10px 24px rgba(0,0,0,.22);
}
body.light .help-fab{
  background:rgba(255,255,255,.96);
  color:#0f172a;
  border-color:rgba(15,23,42,.16);
}

body.light .rail-btn.active,
body.light .chip.active{
  border-color:rgba(37,99,235,.85);
  box-shadow:0 0 0 2px rgba(37,99,235,.16), 0 8px 18px rgba(37,99,235,.10);
  background:rgba(37,99,235,.16);
}
.rail-btn.active,
.chip.active{
  border-color:rgba(79,140,255,.85);
  box-shadow:0 0 0 2px rgba(79,140,255,.16), 0 8px 18px rgba(79,140,255,.10);
}

body.light .layer-actions button{
  background:rgba(255,255,255,.98);
  color:#0f172a;
  border-color:rgba(15,23,42,.18);
}

.scene{
  border:1px solid rgba(148,163,184,.38);
}
body.light .scene{
  border-color:rgba(15,23,42,.20);
}
.stage{
  border:1px solid rgba(255,255,255,.92);
}
body.light .stage{
  border-color:rgba(37,99,235,.75);
}

.hidden{display:none !important}

.stage.bg-plain{background:#fff}
.stage.bg-solid{background:#fff}
.stage.bg-transparent{
  background-color:#fff;
  background-image:
    linear-gradient(45deg, rgba(15,23,42,.10) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(15,23,42,.10) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(15,23,42,.10) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(15,23,42,.10) 75%);
  background-size:18px 18px;
  background-position:0 0,0 9px,9px -9px,9px 9px;
}
.stage.bg-grid{
  background-color:#fff;
  background-image:
    linear-gradient(rgba(37,99,235,.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.14) 1px, transparent 1px);
  background-size:24px 24px;
}
.stage.bg-paper{
  background-color:#f3e8cf;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(15,23,42,.055), transparent 22%),
    radial-gradient(circle at 80% 30%, rgba(15,23,42,.04), transparent 18%),
    radial-gradient(circle at 35% 75%, rgba(15,23,42,.04), transparent 20%),
    linear-gradient(180deg, rgba(255,255,255,.25), rgba(255,255,255,.06));
}
.stage.bg-sand{
  background-color:#e8d0a1;
  background-image:
    radial-gradient(circle at 10% 15%, rgba(15,23,42,.05), transparent 18%),
    radial-gradient(circle at 80% 65%, rgba(15,23,42,.04), transparent 22%),
    linear-gradient(180deg, #e9d7b7, #d7bf92);
}
body:not(.light) .stage.bg-transparent{
  background-color:#1f2937;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,.10) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,.10) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,.10) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.10) 75%);
}
body:not(.light) .stage.bg-grid{
  background-color:#0f172a;
  background-image:
    linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
}
body:not(.light) .stage.bg-paper{
  background-color:#1c2433;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.12), transparent 22%),
    radial-gradient(circle at 80% 30%, rgba(255,255,255,.08), transparent 18%),
    radial-gradient(circle at 35% 75%, rgba(255,255,255,.06), transparent 20%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
}
body:not(.light) .stage.bg-sand{
  background-color:#a88a61;
  background-image:
    radial-gradient(circle at 10% 15%, rgba(255,255,255,.06), transparent 18%),
    radial-gradient(circle at 80% 65%, rgba(255,255,255,.05), transparent 22%),
    linear-gradient(180deg, #c8b28a, #b7956a);
}

/* v12 artist tooling polish */
.tool-status,
.layer-summary,
.brush-preview-card{
  border:1px solid var(--line);
  border-radius:16px;
  padding:10px;
  background:rgba(255,255,255,.04);
  display:grid;
  gap:6px;
}
body.light .tool-status,
body.light .layer-summary,
body.light .brush-preview-card{
  background:rgba(255,255,255,.96);
  border-color:rgba(15,23,42,.16);
}
.status-label,
.brush-preview-head span{
  color:var(--muted);
  font-size:.78rem;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.04em;
}
.tool-chip{
  justify-content:flex-start;
  gap:8px;
  padding:8px 10px;
  min-height:44px;
}
.tool-ico{
  width:26px;height:26px;
  display:inline-flex;align-items:center;justify-content:center;
  border-radius:10px;
  background:rgba(79,140,255,.14);
  font-weight:900;
  flex:0 0 auto;
}
body.light .tool-ico{background:rgba(37,99,235,.12)}
.brush-preview-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
#brushPreview{
  width:100%;
  height:74px;
  display:block;
  border-radius:14px;
  border:1px solid var(--line);
  background:
    linear-gradient(45deg, rgba(255,255,255,.04) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, rgba(255,255,255,.04) 25%, transparent 25%) 0 8px/16px 16px,
    rgba(15,23,42,.28);
}
body.light #brushPreview{
  background:
    linear-gradient(45deg, rgba(15,23,42,.04) 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, rgba(15,23,42,.04) 25%, transparent 25%) 0 8px/16px 16px,
    rgba(255,255,255,.92);
}
.layer-list{
  display:grid;
  gap:12px;
}
.layer-item{
  display:grid !important;
  grid-template-columns:1fr !important;
  gap:10px !important;
  align-items:stretch !important;
  padding:12px !important;
  border-radius:18px !important;
}
.layer-item.active{
  border-color:rgba(79,140,255,.70) !important;
  box-shadow:0 0 0 2px rgba(79,140,255,.15);
}
body.light .layer-item.active{
  border-color:rgba(37,99,235,.75) !important;
  box-shadow:0 0 0 2px rgba(37,99,235,.14);
}
.layer-card-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
}
.layer-name{
  width:100%;
  min-height:46px;
  text-align:left;
  justify-content:flex-start;
}
.layer-meta{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  color:var(--muted);
  font-size:.78rem;
  font-weight:800;
}
.layer-badge{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:4px 8px;
  border:1px solid var(--line);
  background:rgba(79,140,255,.12);
}
.layer-opacity-row{
  display:grid;
  grid-template-columns:auto 1fr auto;
  gap:8px;
  align-items:center;
  font-size:.82rem;
  color:var(--muted);
  font-weight:800;
}
.layer-opacity-row input[type="range"]{
  min-height:30px;
}
.layer-actions{
  display:grid !important;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px !important;
}
.layer-actions button{
  min-height:40px !important;
  width:100%;
  font-weight:800;
}
.layer-actions button:disabled{
  opacity:.38;
  cursor:not-allowed;
}
.current-layer-pill{
  position:fixed;
  left:calc(60px + env(safe-area-inset-left));
  bottom:calc(10px + env(safe-area-inset-bottom));
  z-index:44;
  max-width:calc(100vw - 128px);
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:999px;
  background:rgba(15,23,42,.82);
  color:#fff;
  font-size:.78rem;
  font-weight:900;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  box-shadow:0 10px 24px rgba(0,0,0,.18);
}
body.light .current-layer-pill{
  background:rgba(255,255,255,.96);
  color:#0f172a;
  border-color:rgba(15,23,42,.16);
}

/* v13 bugfix polish */
.layer-name{
  display:grid !important;
  grid-template-columns:1fr auto;
  align-items:center;
  gap:14px !important;
}
.layer-name span{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.layer-name small{
  justify-self:end;
  white-space:nowrap;
  opacity:.82;
}
.stage.bg-grid{
  background-color:#fff !important;
  background-image:
    linear-gradient(rgba(37,99,235,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.18) 1px, transparent 1px) !important;
  background-size:24px 24px !important;
}
.stage.bg-paper{
  background-color:#f3e8cf !important;
  background-image:
    repeating-linear-gradient(0deg, rgba(120,100,70,.055) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 20% 20%, rgba(15,23,42,.045), transparent 20%),
    radial-gradient(circle at 80% 30%, rgba(15,23,42,.035), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,.25), rgba(255,255,255,.06)) !important;
}
.stage.bg-sand{
  background-color:#e8d0a1 !important;
  background-image:
    radial-gradient(circle, rgba(70,50,25,.16) 0 1px, transparent 1.3px),
    radial-gradient(circle, rgba(255,255,255,.20) 0 1px, transparent 1.4px),
    linear-gradient(180deg, #e9d7b7, #d7bf92) !important;
  background-size:13px 13px, 19px 19px, auto !important;
  background-position:0 0, 6px 8px, 0 0 !important;
}
body:not(.light) .stage.bg-grid{
  background-color:#0f172a !important;
  background-image:
    linear-gradient(rgba(255,255,255,.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.16) 1px, transparent 1px) !important;
}
body:not(.light) .stage.bg-paper{
  background-color:#1c2433 !important;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.045) 0 1px, transparent 1px 7px),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.10), transparent 20%),
    radial-gradient(circle at 80% 30%, rgba(255,255,255,.075), transparent 18%) !important;
}
body:not(.light) .stage.bg-sand{
  background-color:#a88a61 !important;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.18) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(55,38,20,.20) 0 1px, transparent 1.4px),
    linear-gradient(180deg, #c8b28a, #b7956a) !important;
}
.tool-chip.active .tool-ico{
  background:rgba(34,197,94,.20);
  box-shadow:0 0 0 2px rgba(34,197,94,.18);
}
body.light .tool-chip.active .tool-ico{
  background:rgba(37,99,235,.18);
}

/* v13 fixes */
.layer-name{
  display:grid !important;
  grid-template-columns:1fr !important;
  gap:8px !important;
  align-items:start !important;
}
.layer-name small{
  margin-top:4px;
  display:block;
  opacity:.82;
}
.layer-title{
  display:block;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
}
.stage.bg-plain{background:#fff}
.stage.bg-solid{background:#fff}
.stage.bg-transparent{
  background-color:#fff;
  background-image:
    linear-gradient(45deg, rgba(15,23,42,.10) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(15,23,42,.10) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(15,23,42,.10) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(15,23,42,.10) 75%);
  background-size:18px 18px;
  background-position:0 0,0 9px,9px -9px,9px 9px;
}
.stage.bg-grid{
  background-color:#fff;
  background-image:
    linear-gradient(rgba(37,99,235,.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.14) 1px, transparent 1px);
  background-size:24px 24px;
}
.stage.bg-paper{
  background-color:#f3e8cf;
  background-image:
    repeating-linear-gradient(0deg, rgba(92,64,28,.035) 0 1px, transparent 1px 11px),
    radial-gradient(circle at 20% 20%, rgba(92,64,28,.05), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,.28), rgba(255,255,255,.04));
}
.stage.bg-sand{
  background-color:#e8d0a1;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(80,55,20,.08) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 58%, rgba(80,55,20,.07) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 82%, rgba(255,255,255,.14) 0 1px, transparent 2px),
    linear-gradient(180deg, #e9d7b7, #d7bf92);
  background-size:18px 18px, 22px 22px, 26px 26px, auto;
}
body:not(.light) .stage.bg-grid{
  background-color:#0f172a;
  background-image:
    linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
}
body:not(.light) .stage.bg-paper{
  background-color:#1c2433;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.035) 0 1px, transparent 1px 11px),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.08), transparent 18%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
}
body:not(.light) .stage.bg-sand{
  background-color:#a88a61;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255,255,255,.06) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 58%, rgba(255,255,255,.05) 0 1px, transparent 2px),
    linear-gradient(180deg, #c8b28a, #b7956a);
}

/* v15 corrective polish */
.layer-name.chip{
  white-space:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
  display:grid !important;
  grid-template-columns:1fr !important;
  justify-items:start !important;
  align-items:start !important;
  gap:10px !important;
  padding:12px !important;
}
.layer-name.chip small{
  display:block !important;
  margin-top:2px !important;
  line-height:1.35 !important;
  color:var(--muted) !important;
}
.layer-name .layer-title{
  display:block !important;
  width:100% !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  white-space:nowrap !important;
}
.layer-actions{
  grid-template-columns:repeat(2,minmax(0,1fr)) !important;
}
.stage.bg-grid{
  background-color:#ffffff !important;
  background-image:
    linear-gradient(rgba(37,99,235,.24) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.24) 1px, transparent 1px) !important;
  background-size:24px 24px !important;
}
body:not(.light) .stage.bg-grid{
  background-color:#0f172a !important;
  background-image:
    linear-gradient(rgba(255,255,255,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.18) 1px, transparent 1px) !important;
}
.stage.bg-paper{
  background-color:#f4ead7 !important;
  background-image:
    repeating-linear-gradient(0deg, rgba(93,64,27,.055) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, rgba(93,64,27,.025) 0 1px, transparent 1px 18px),
    radial-gradient(circle at 20% 20%, rgba(93,64,27,.06), transparent 22%),
    linear-gradient(180deg, rgba(255,255,255,.32), rgba(255,255,255,.04)) !important;
}
body:not(.light) .stage.bg-paper{
  background-color:#1f2937 !important;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.045) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 1px, transparent 1px 18px),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.08), transparent 22%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01)) !important;
}
.stage.bg-sand{
  background-color:#e8d0a1 !important;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(80,55,20,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 58%, rgba(80,55,20,.09) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 82%, rgba(255,255,255,.18) 0 1px, transparent 2px),
    linear-gradient(180deg, #ead8b8, #d8bf91) !important;
  background-size:18px 18px,22px 22px,26px 26px,auto !important;
}

/* v16 corrective pass */
.layer-name.chip{
  white-space:normal !important;
  overflow:visible !important;
  text-overflow:clip !important;
  display:grid !important;
  grid-template-columns:1fr !important;
  justify-items:start !important;
  align-items:start !important;
  gap:10px !important;
  padding:12px !important;
}
.layer-name.chip small{
  display:block !important;
  margin-top:2px !important;
  line-height:1.35 !important;
  color:var(--muted) !important;
}
.layer-name .layer-title{
  display:block !important;
  width:100% !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  white-space:nowrap !important;
}
.layer-actions{grid-template-columns:repeat(2,minmax(0,1fr)) !important}
.stage.bg-grid{
  background-color:#fff !important;
  background-image:
    linear-gradient(rgba(37,99,235,.24) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.24) 1px, transparent 1px) !important;
  background-size:24px 24px !important;
}
body:not(.light) .stage.bg-grid{
  background-color:#0f172a !important;
  background-image:
    linear-gradient(rgba(255,255,255,.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.18) 1px, transparent 1px) !important;
}
.stage.bg-paper{
  background-color:#f4ead7 !important;
  background-image:
    repeating-linear-gradient(0deg, rgba(93,64,27,.055) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, rgba(93,64,27,.025) 0 1px, transparent 1px 18px),
    radial-gradient(circle at 20% 20%, rgba(93,64,27,.06), transparent 22%),
    linear-gradient(180deg, rgba(255,255,255,.32), rgba(255,255,255,.04)) !important;
}
body:not(.light) .stage.bg-paper{
  background-color:#1f2937 !important;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.045) 0 1px, transparent 1px 10px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.02) 0 1px, transparent 1px 18px),
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.08), transparent 22%),
    linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01)) !important;
}
.stage.bg-sand{
  background-color:#e8d0a1 !important;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(80,55,20,.12) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 58%, rgba(80,55,20,.09) 0 1px, transparent 2px),
    radial-gradient(circle at 40% 82%, rgba(255,255,255,.18) 0 1px, transparent 2px),
    linear-gradient(180deg, #ead8b8, #d8bf91) !important;
  background-size:18px 18px,22px 22px,26px 26px,auto !important;
}

/* v18 stability pass: remove unreliable preview/status widgets */
.tool-status,
.brush-preview-card,
#brushPreview,
#currentToolLabel,
#brushPresetLabel{
  display:none !important;
}
.tools-grid{
  margin-top:0 !important;
}
.panel .stack{
  gap:14px;
}

/* v19 layer controls, color saver, compact color wheel */
.compact-wheel{
  width:min(230px, 72vw) !important;
  max-width:230px !important;
  margin:0 auto 10px !important;
}
.saved-color-card{
  border:1px solid var(--line);
  border-radius:16px;
  padding:10px;
  display:grid;
  gap:10px;
  background:rgba(255,255,255,.04);
}
body.light .saved-color-card{
  background:rgba(255,255,255,.96);
  border-color:rgba(15,23,42,.16);
}
.saved-color-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.saved-colors{
  display:grid;
  grid-template-columns:repeat(8, minmax(26px, 1fr));
  gap:8px;
}
.saved-color{
  min-height:30px;
  border-radius:10px;
  border:1px solid var(--line);
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.18);
}
.saved-color.active{
  outline:2px solid rgba(79,140,255,.85);
  outline-offset:2px;
}
.danger-soft{
  color:#ef4444 !important;
}
.layer-actions button{
  touch-action:manipulation;
}
.layer-move-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}

/* v20 layer workflow + brush test pad */
.brush-test-card{
  margin-top:14px;
  border:1px solid var(--line);
  border-radius:16px;
  padding:10px;
  display:grid;
  gap:10px;
  background:rgba(255,255,255,.04);
}
body.light .brush-test-card{
  background:rgba(255,255,255,.96);
  border-color:rgba(15,23,42,.16);
}
.brush-test-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  flex-wrap:wrap;
}
#brushTestCanvas{
  width:100%;
  height:126px;
  display:block;
  background:#fff;
  border:1px solid rgba(15,23,42,.16);
  border-radius:14px;
  touch-action:none;
}
.layer-actions.layer-actions-v20{
  grid-template-columns:repeat(2,minmax(0,1fr)) !important;
}
.layer-actions .wide-action{
  grid-column:span 2;
}
.layer-item.locked{
  opacity:.82;
}
.layer-badge.locked{
  color:#f59e0b;
  border-color:rgba(245,158,11,.36);
  background:rgba(245,158,11,.10);
}

/* v21 reliability fixes */
.help-guide span{
  line-height:1.5;
}
#brushTestCanvas{
  pointer-events:auto !important;
  touch-action:none !important;
  user-select:none !important;
}
.layer-actions button{
  -webkit-tap-highlight-color:transparent;
}

.line-preview{
  position:absolute;
  left:0;top:0;
  height:0;
  border-top:3px solid rgba(79,140,255,.95);
  transform-origin:0 50%;
  pointer-events:none;
  z-index:55;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.25));
}
.line-preview.hidden{display:none}

/* v23 stability and UX verification */
.save-status{
  max-width:94px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:.72rem;
  font-weight:800;
  color:var(--muted);
}
.layer-item.flash-moved{
  animation: layerFlashV23 900ms ease-out 1;
}
@keyframes layerFlashV23{
  0%{box-shadow:0 0 0 3px rgba(34,197,94,.42), 0 0 24px rgba(34,197,94,.26)}
  100%{box-shadow:none}
}
.help-guide{
  display:grid;
  gap:12px !important;
}
.help-guide section{
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px;
  display:grid;
  gap:6px;
  background:rgba(255,255,255,.04);
}
body.light .help-guide section{
  background:rgba(255,255,255,.96);
  border-color:rgba(15,23,42,.16);
}
.help-guide section span{
  color:var(--muted);
  line-height:1.5;
}
.brush-test-head{
  justify-content:flex-start !important;
}

/* v24 production hardening */
.mode-card,
.canvas-presets{
  border:1px solid var(--line);
  border-radius:16px;
  padding:10px;
  display:grid;
  gap:10px;
  background:rgba(255,255,255,.04);
}
body.light .mode-card,
body.light .canvas-presets{
  background:rgba(255,255,255,.96);
  border-color:rgba(15,23,42,.16);
}
.mode-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  flex-wrap:wrap;
}
.mode-row > span{
  font-weight:900;
  color:var(--muted);
  font-size:.82rem;
}
.canvas-presets{
  grid-template-columns:repeat(2,minmax(0,1fr));
}
.canvas-presets .chip{
  min-height:40px;
}
body.stable-mode [data-tool="select"],
body.stable-mode [data-tool="move"]{
  opacity:.48;
}
body.stable-mode .advanced-only{
  opacity:.55;
}
body.performance-mode .scene.texture-paper,
body.performance-mode .scene.texture-sand{
  background-image:none !important;
}
.performance-mode .stage.bg-paper,
.performance-mode .stage.bg-sand{
  background-image:none !important;
}
.save-status{
  min-width:68px;
  text-align:right;
}
.layer-order-strip{
  border:1px solid var(--line);
  border-radius:14px;
  padding:8px;
  display:grid;
  gap:6px;
  background:rgba(255,255,255,.035);
  font-size:.78rem;
  color:var(--muted);
}
.layer-order-strip strong{
  color:inherit;
}
.layer-order-item{
  display:flex;
  justify-content:space-between;
  gap:8px;
  border-radius:10px;
  padding:5px 7px;
  background:rgba(255,255,255,.04);
}
body.light .layer-order-strip,
body.light .layer-order-item{
  background:rgba(255,255,255,.86);
  border-color:rgba(15,23,42,.12);
}

/* v45 guest mobile polish */
.version-badge{display:inline-flex;width:max-content;margin-left:6px;padding:1px 6px;border-radius:999px;font-size:.68rem;font-weight:900;color:#9cc9ff;border:1px solid rgba(93,160,255,.28);background:rgba(93,160,255,.10)}
body.light .version-badge{color:#1f64bd;background:rgba(31,100,189,.10);border-color:rgba(31,100,189,.18)}
.icon-btn svg,.pill-btn svg,.rail-btn svg,.tool-ico svg{width:19px;height:19px;display:block;fill:none;stroke:currentColor;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}
.tool-ico{min-width:21px;min-height:21px;display:inline-flex;align-items:center;justify-content:center}
html.icons-ready .rail-btn,html.icons-ready .icon-btn{transition:transform .12s ease,background .16s ease,border-color .16s ease}
.rail-btn:active,.icon-btn:active,.chip:active,.action:active{transform:scale(.96)}
.brush-test-card canvas{background:#fff;border:1px solid rgba(148,163,184,.24);border-radius:14px}
.scene,.stage,.layer-host{contain:layout paint style}
body{overscroll-behavior:none}

/* v45 reliability polish */
.gallery-admin-note{font-size:.78rem;color:var(--muted)}
.autosave-warning{border:1px solid rgba(245,158,11,.35);background:rgba(245,158,11,.10);color:var(--text);border-radius:14px;padding:.65rem .8rem}
.action.danger,.chip.danger{background:linear-gradient(135deg,#b91c1c,#ef4444)!important;color:#fff!important}

/* v60 finish modal tag chips */
.tagchips{display:flex;gap:.45rem;flex-wrap:wrap;margin:.35rem 0 .75rem}
.tagchips button{border:1px solid rgba(148,163,184,.28);background:rgba(255,255,255,.08);color:var(--text,#f8fbff);border-radius:999px;padding:.42rem .62rem;font-weight:850;font-size:.78rem}
.tagchips button.active{background:rgba(79,140,255,.24);border-color:rgba(79,140,255,.8)}

/* v62 privacy controls */
.checkline{display:flex!important;grid-template-columns:auto 1fr!important;align-items:center;gap:.55rem}
.checkline input{width:auto!important}
.field select{width:100%;border-radius:12px;border:1px solid rgba(148,163,184,.35);background:rgba(15,23,42,.92);color:var(--text,#f8fbff);padding:.7rem}

/* v63 community policy upload confirmation */
.policybox{border:1px solid rgba(148,163,184,.24);background:rgba(255,255,255,.06);border-radius:14px;padding:.75rem;margin:.5rem 0;color:var(--text,#f8fbff)}
.policybox p{margin:.35rem 0;color:var(--muted,#aebdd2);font-size:.84rem;line-height:1.35}

/* v67 upload modal polish */
.upload-summary{
  display:grid;
  gap:.28rem;
  border:1px solid rgba(79,140,255,.28);
  background:rgba(79,140,255,.08);
  color:var(--text,#f8fbff);
  border-radius:14px;
  padding:.72rem;
  margin:.6rem 0;
  font-size:.84rem;
  line-height:1.32;
}
.upload-summary strong{font-size:.9rem}
.finish-modal .field{margin-bottom:.55rem}
.finish-modal .policybox{margin-top:.55rem}
.finish-modal img#modalImage{max-height:min(42vh,420px);object-fit:contain}
@media(max-width:680px){
  .upload-summary{font-size:.78rem;padding:.62rem}
  .tagchips{gap:.35rem}
  .tagchips button{padding:.36rem .5rem;font-size:.74rem}
  .finish-modal img#modalImage{max-height:34vh}
}


/* v69 canvas scroll safety + modal UX stabilization */
html.modal-open,
body.modal-open{
  overflow:hidden!important;
  overscroll-behavior:none;
  touch-action:none;
}
.modal{
  align-items:stretch!important;
  justify-content:center!important;
  padding:clamp(8px,2vw,16px)!important;
  overflow:hidden!important;
  overscroll-behavior:contain;
}
.modal-card{
  width:min(94vw, 560px)!important;
  max-height:calc(100dvh - 24px)!important;
  display:flex!important;
  flex-direction:column!important;
  overflow:hidden!important;
  border-radius:18px!important;
}
#helpModal .modal-card{
  width:min(94vw, 720px)!important;
}
.modal-head{
  position:sticky;
  top:0;
  z-index:3;
  flex:0 0 auto;
  background:var(--surface);
}
body.light .modal-head{background:var(--surface2)}
.modal-body{
  overflow-y:auto!important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  max-height:none!important;
  flex:1 1 auto;
  padding:12px!important;
  scroll-padding-bottom:90px;
}
#finishModal .modal-body{
  display:grid!important;
  grid-template-columns:1fr!important;
  gap:10px!important;
}
#finishModal .modal-body > p,
#finishModal .modal-body > label,
#finishModal .modal-body > .field,
#finishModal .modal-body > .tagchips,
#finishModal .modal-body > .policybox,
#finishModal .modal-body > .upload-summary,
#finishModal .modal-body > img{
  min-width:0;
}
#modalInitialActions,
#modalSuccessActions{
  position:sticky;
  bottom:-12px;
  z-index:4;
  margin:4px -12px -12px!important;
  padding:10px 12px calc(10px + env(safe-area-inset-bottom))!important;
  background:linear-gradient(180deg,rgba(15,23,42,.80),var(--surface));
  border-top:1px solid var(--line);
  backdrop-filter:blur(14px);
}
body.light #modalInitialActions,
body.light #modalSuccessActions{
  background:linear-gradient(180deg,rgba(255,255,255,.78),var(--surface2));
}
#modalInitialActions.hidden,
#modalSuccessActions.hidden{display:none!important}
#localPrivacyNote{
  flex:1 1 100%;
  font-size:.82rem;
}
#helpModal .modal-body{
  max-height:calc(100dvh - 96px)!important;
}
.help-guide section{
  border:1px solid var(--line);
  border-radius:14px;
  padding:10px;
  background:rgba(255,255,255,.045);
}
body.light .help-guide section{background:rgba(15,23,42,.025)}
.drawer{
  max-height:calc(100dvh - var(--top-h,72px) - 22px)!important;
  overflow:hidden!important;
  display:flex!important;
  flex-direction:column!important;
}
.drawer-head{
  flex:0 0 auto;
  position:sticky;
  top:0;
  z-index:2;
  background:var(--surface);
}
body.light .drawer-head{background:var(--surface2)}
.drawer .panel{
  overflow-y:auto!important;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  padding-bottom:calc(14px + env(safe-area-inset-bottom));
}
.layer-list{
  max-height:min(44dvh,420px);
  overflow-y:auto;
  overscroll-behavior:contain;
}
.reference-wrap{
  max-height:calc(100dvh - 120px);
}
.field select,
.modal-body select{
  width:100%;
  min-height:42px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.04);
  color:inherit;
  padding:10px 12px;
}
body.light .field select,
body.light .modal-body select{background:rgba(15,23,42,.02)}
@media(max-width:680px){
  .modal{padding:8px!important}
  .modal-card{width:100%!important;max-height:calc(100dvh - 16px)!important;border-radius:16px!important}
  #helpModal .modal-card{width:100%!important}
  .modal-head{padding:10px!important}
  .modal-body{padding:10px!important;gap:9px!important}
  #modalInitialActions,
  #modalSuccessActions{margin:4px -10px -10px!important;padding:9px 10px calc(9px + env(safe-area-inset-bottom))!important}
  #modalInitialActions .action,
  #modalSuccessActions .action,
  #modalInitialActions button,
  #modalSuccessActions button,
  #modalInitialActions a,
  #modalSuccessActions a{width:100%;justify-content:center}
  .drawer{right:calc(var(--rail-w,60px) + 8px)!important;max-width:calc(100vw - var(--rail-w,60px) - 18px)!important;max-height:calc(100dvh - var(--top-h,60px) - 18px)!important}
}

/* v70 subtle canvas community prompt */
.canvas-community-prompt{
  margin:.3rem 0 .2rem;
  color:var(--muted,#aebdd2);
  font-size:.86rem;
  line-height:1.35;
}
.canvas-community-prompt::before{
  content:"✦ ";
  color:#7fb7ff;
  font-weight:900;
}

/* v71 canvas home shortcut */
.home-fab{
  position:fixed;
  right:72px;
  bottom:calc(16px + env(safe-area-inset-bottom));
  z-index:45;
  width:44px;
  height:44px;
  display:grid;
  place-items:center;
  border-radius:999px;
  border:1px solid var(--line);
  background:var(--surface);
  color:var(--text,#f8fbff);
  text-decoration:none;
  font-weight:950;
  box-shadow:var(--shadow);
}
body.light .home-fab{background:var(--surface2);color:#0f172a}
@media(max-width:520px){.home-fab{right:66px;width:42px;height:42px}}


/* v85 canvas studio stability */
.hidden-file{display:none!important}
.topbar{min-width:0}
.title{min-width:0}
.title strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:min(36vw,360px)}
.save-status{
  border:1px solid rgba(148,163,184,.24);
  border-radius:999px;
  padding:.12rem .45rem;
  background:rgba(255,255,255,.06);
}
body[data-save-state*="unsaved"] .save-status{border-color:rgba(250,204,21,.45);background:rgba(250,204,21,.10);color:#fde68a}
body[data-save-state*="saving"] .save-status{border-color:rgba(96,165,250,.45);background:rgba(96,165,250,.10);color:#bfdbfe}
body[data-save-state*="saved"],
body[data-save-state*="exported"],
body[data-save-state*="imported"] .save-status{border-color:rgba(34,197,94,.45);background:rgba(34,197,94,.10);color:#bbf7d0}
body[data-save-state*="failed"] .save-status{border-color:rgba(248,113,113,.55);background:rgba(248,113,113,.12);color:#fecaca}

.diagnostics-card{
  border:1px solid var(--line);
  border-radius:16px;
  padding:10px;
  background:rgba(255,255,255,.045);
}
.diagnostics-card summary{
  cursor:pointer;
  font-weight:900;
  color:var(--text);
}
.diagnostics-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
  margin-top:10px;
}
.diagnostics-grid span{
  display:grid;
  gap:2px;
  border:1px solid rgba(148,163,184,.18);
  border-radius:12px;
  padding:8px;
  color:var(--muted);
  background:rgba(2,6,23,.22);
}
.diagnostics-grid strong{color:var(--text)}
.upload-progress{
  position:relative;
  min-height:10px;
  border:1px solid rgba(96,165,250,.28);
  background:rgba(96,165,250,.08);
  border-radius:999px;
  overflow:hidden;
  padding:7px 10px;
  font-weight:900;
  color:#dbeafe;
}
.upload-progress::before{
  content:"";
  position:absolute;
  inset:0;
  width:45%;
  background:linear-gradient(90deg,transparent,rgba(96,165,250,.28),transparent);
  animation:v85UploadSweep 1.4s linear infinite;
}
.upload-progress span{position:relative;z-index:1}
@keyframes v85UploadSweep{from{transform:translateX(-100%)}to{transform:translateX(240%)}}

.chip:focus-visible,.action:focus-visible,.rail-btn:focus-visible,.icon-btn:focus-visible,.pill-btn:focus-visible{
  outline:3px solid rgba(103,232,249,.65);
  outline-offset:2px;
}
.mode-card,.brush-test-card,.layer-item{
  content-visibility:auto;
  contain-intrinsic-size:220px;
}
@media(max-width:720px){
  :root{--top-h:58px;--rail-w:58px}
  .topbar{gap:5px;padding-inline:7px}
  .title strong{max-width:30vw;font-size:.88rem}
  #timer{display:none}
  .version-badge{font-size:.7rem}
  .save-status{font-size:.7rem;max-width:28vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .pill-btn.finish{padding-inline:.68rem}
  .diagnostics-grid{grid-template-columns:1fr}
  .btnrow{gap:6px}
  .chip,.action{min-height:42px}
}
@media(min-width:1000px){
  .drawer{width:min(420px,34vw)}
  .stage{box-shadow:0 22px 60px rgba(0,0,0,.30)}
}
@media(prefers-reduced-motion:reduce){
  .upload-progress::before{animation:none}
  *{scroll-behavior:auto!important}
}


/* v86 canvas layer project safety */
.version-badge:empty{display:none!important}
.project-safety-card{
  border:1px solid rgba(127,183,255,.25);
  background:linear-gradient(135deg,rgba(127,183,255,.08),rgba(15,23,42,.42));
  border-radius:16px;
  padding:10px;
}
.project-safety-card summary{
  cursor:pointer;
  font-weight:950;
  letter-spacing:.02em;
}
.project-safety-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
  margin:10px 0;
}
.project-safety-grid span{
  display:grid;
  gap:2px;
  border:1px solid rgba(148,163,184,.18);
  border-radius:12px;
  padding:8px;
  background:rgba(2,6,23,.22);
  color:var(--muted);
}
.project-safety-grid strong{color:var(--text)}
.danger-soft{
  border-color:rgba(248,113,113,.32)!important;
  background:rgba(248,113,113,.09)!important;
  color:#fecaca!important;
}
.layer-card-top{
  display:grid;
  grid-template-columns:58px 1fr;
  gap:10px;
  align-items:center;
}
.layer-thumb-btn{
  width:58px;
  height:58px;
  padding:0;
  border:1px solid rgba(148,163,184,.28);
  background:rgba(255,255,255,.04);
  border-radius:14px;
  overflow:hidden;
}
.layer-thumb{
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  background:linear-gradient(45deg,rgba(255,255,255,.08) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.08) 50%,rgba(255,255,255,.08) 75%,transparent 75%);
  background-size:12px 12px;
}
.layer-thumb.blank::before{
  content:"Empty";
  display:grid;
  place-items:center;
  height:100%;
  color:var(--muted);
  font-size:.72rem;
  font-weight:900;
}
.layer-item.active .layer-thumb-btn{
  border-color:rgba(127,183,255,.75);
  box-shadow:0 0 0 3px rgba(127,183,255,.12);
}
.reference-wrap.is-locked{
  outline:2px dashed rgba(127,183,255,.45);
}
.reference-wrap.is-locked .reference-head::after{
  content:"Locked";
  margin-left:auto;
  font-size:.72rem;
  border:1px solid rgba(127,183,255,.28);
  border-radius:999px;
  padding:.12rem .42rem;
  color:#dbeafe;
}
.rail-btn:disabled{
  opacity:.42;
  cursor:not-allowed;
}
body[data-save-state*="autosaved"] .save-status{
  border-color:rgba(127,183,255,.45);
  background:rgba(127,183,255,.10);
  color:#dbeafe;
}
@media(max-width:720px){
  .project-safety-grid{grid-template-columns:1fr}
  .layer-card-top{grid-template-columns:50px 1fr}
  .layer-thumb-btn{width:50px;height:50px}
  .layer-actions-v20{grid-template-columns:repeat(2,minmax(0,1fr))}
}


/* v87 brush feel and light text fix */
:root{
  --canvas-blue-text:#b9d7ff;
  --canvas-navy-text:#dbeafe;
}
body.light{
  --surface2:#ffffff;
  --text-dark:#0b1220;
  --muted:#475569;
  color:#0b1220;
}
body.light .drawer,
body.light .panel,
body.light .mode-card,
body.light .brush-test-card,
body.light .saved-color-card,
body.light .project-safety-card,
body.light .diagnostics-card{
  color:#0b1220;
}
body.light .drawer-title,
body.light .panel strong,
body.light label,
body.light .hint,
body.light .mode-row span,
body.light .project-safety-grid span,
body.light .diagnostics-grid span{
  color:#0f172a!important;
}
body.light .hint,
body.light .save-status,
body.light .version-badge{
  color:#334155!important;
}
body.light input,
body.light select,
body.light textarea{
  color:#0b1220!important;
  background:#ffffff!important;
  border-color:rgba(15,23,42,.22)!important;
}
body:not(.light) .drawer-title,
body:not(.light) .panel strong,
body:not(.light) label,
body:not(.light) .hint,
body:not(.light) .mode-row span{
  color:var(--canvas-blue-text);
}
body:not(.light) .save-status,
body:not(.light) .current-layer-pill,
body:not(.light) .brush-readout{
  color:var(--canvas-navy-text);
}
.brush-preset-card,
.current-color-card{
  border:1px solid rgba(127,183,255,.24);
  background:linear-gradient(135deg,rgba(127,183,255,.08),rgba(15,23,42,.38));
  border-radius:16px;
  padding:10px;
}
.brush-preset-head,
.saved-color-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px;
}
.brush-preset-quick{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
}
.brush-preset-pill{
  min-height:46px;
  border:1px solid rgba(148,163,184,.22);
  border-radius:14px;
  background:rgba(255,255,255,.045);
  color:inherit;
  font-weight:950;
  display:grid;
  gap:1px;
  text-align:left;
  padding:8px 10px;
}
.brush-preset-pill small{
  color:var(--muted);
  font-size:.7rem;
  font-weight:850;
  text-transform:uppercase;
  letter-spacing:.06em;
}
.brush-preset-pill.active{
  border-color:rgba(127,183,255,.72);
  background:rgba(127,183,255,.14);
  box-shadow:0 0 0 3px rgba(127,183,255,.10);
}
.brush-readout{
  margin-top:8px;
  border:1px solid rgba(148,163,184,.18);
  border-radius:999px;
  padding:.45rem .7rem;
  background:rgba(2,6,23,.18);
  font-weight:900;
  font-size:.86rem;
}
.brush-controls label{
  display:grid;
  grid-template-columns:1fr auto;
  gap:6px 10px;
  align-items:center;
}
.brush-controls label input{
  grid-column:1 / -1;
}
.brush-controls label strong{
  font-size:.84rem;
}
.current-color-card{
  display:grid;
  grid-template-columns:1fr 52px;
  gap:8px;
  align-items:center;
}
.current-color-card label{
  grid-column:1 / -1;
}
.current-color-preview{
  width:52px;
  height:42px;
  border-radius:14px;
  border:1px solid rgba(148,163,184,.28);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.16);
}
.brush-hud{
  position:absolute;
  left:50%;
  bottom:18px;
  transform:translateX(-50%) translateY(8px);
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  justify-content:center;
  max-width:min(92%,760px);
  padding:8px;
  border-radius:999px;
  background:rgba(7,14,31,.78);
  border:1px solid rgba(127,183,255,.24);
  box-shadow:0 16px 40px rgba(0,0,0,.25);
  backdrop-filter:blur(12px);
  opacity:0;
  pointer-events:none;
  transition:opacity .18s ease, transform .18s ease;
  z-index:15;
}
.brush-hud.show{
  opacity:1;
  transform:translateX(-50%) translateY(0);
}
.brush-hud span{
  color:#dbeafe;
  font-weight:900;
  font-size:.78rem;
  border:1px solid rgba(127,183,255,.18);
  background:rgba(255,255,255,.05);
  border-radius:999px;
  padding:.28rem .5rem;
}
body.light .brush-hud{
  background:rgba(255,255,255,.92);
  border-color:rgba(37,99,235,.22);
}
body.light .brush-hud span{
  color:#0f172a;
  background:rgba(37,99,235,.06);
  border-color:rgba(37,99,235,.16);
}
.profile-row .chip.active{
  border-color:rgba(127,183,255,.72);
  background:rgba(127,183,255,.14);
}
@media(max-width:720px){
  .brush-preset-quick{grid-template-columns:1fr}
  .brush-hud{bottom:72px;border-radius:18px}
  .brush-hud span{font-size:.72rem}
}
@media(prefers-reduced-motion:reduce){
  .brush-hud{transition:none}
}


/* v88 canvas workspace comfort */
.drawer-head{
  position:sticky;
  top:0;
  z-index:5;
  min-height:46px;
  padding-block:8px;
  background:linear-gradient(180deg,rgba(7,14,31,.98),rgba(7,14,31,.86));
  backdrop-filter:blur(12px);
}
body.light .drawer-head{
  background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(255,255,255,.88));
}
.tool-groups{
  display:grid;
  gap:12px;
}
.tool-group{
  border:1px solid rgba(127,183,255,.18);
  border-radius:16px;
  padding:10px;
  background:rgba(255,255,255,.035);
}
.tool-group h3{
  margin:0 0 8px;
  color:#dbeafe;
  font-size:.78rem;
  letter-spacing:.08em;
  text-transform:uppercase;
}
body.light .tool-group h3{color:#1e3a8a}
.tools-grid.compact{grid-template-columns:repeat(2,minmax(0,1fr))}
.tool-chip.active{
  border-color:rgba(127,183,255,.9)!important;
  box-shadow:0 0 0 3px rgba(127,183,255,.14), inset 0 0 0 1px rgba(255,255,255,.08);
}
.tool-chip.active .tool-ico{
  filter:drop-shadow(0 0 8px rgba(127,183,255,.45));
}
.project-safety-card.compact{
  padding:8px 10px;
}
.project-safety-card.compact summary{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.project-safety-card.compact summary strong{
  font-size:.78rem;
  color:#dbeafe;
  border:1px solid rgba(127,183,255,.22);
  background:rgba(127,183,255,.08);
  border-radius:999px;
  padding:.22rem .48rem;
}
body.light .project-safety-card.compact summary strong{color:#1e3a8a;background:rgba(37,99,235,.06)}
.project-safety-card.compact:not([open]){background:rgba(127,183,255,.055)}
.quick-size-row,.zoom-actions{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:7px;
}
.zoom-actions{grid-template-columns:repeat(4,minmax(0,1fr))}
.quick-size-row .chip,.zoom-actions .chip{
  min-height:38px;
  font-size:.8rem;
}
.focus-exit{
  position:fixed;
  right:18px;
  top:18px;
  z-index:80;
  border:1px solid rgba(127,183,255,.28);
  background:rgba(7,14,31,.90);
  color:#dbeafe;
  border-radius:999px;
  padding:.65rem .9rem;
  font-weight:950;
  box-shadow:0 16px 40px rgba(0,0,0,.28);
}
body.focus-mode .topbar,
body.focus-mode .rail,
body.focus-mode .drawer,
body.focus-mode .statusbar{
  opacity:0!important;
  pointer-events:none!important;
  transform:translateY(-6px);
}
body.focus-mode .main{
  grid-template-columns:1fr!important;
}
body.focus-mode .scene{
  inset:0!important;
}
body.focus-mode .brush-hud{
  opacity:1;
}
.brush-hud{
  max-width:min(96%,920px);
}
.brush-hud span:last-child{
  color:#bfdbfe;
}
body.light .brush-hud span:last-child{color:#1e40af}
body.light .chip:disabled,
body.light .rail-btn:disabled{
  color:#64748b!important;
  background:#e2e8f0!important;
}
body:not(.light) .chip:disabled,
body:not(.light) .rail-btn:disabled{
  color:#64748b!important;
  background:rgba(148,163,184,.08)!important;
}
.drawer{
  scrollbar-color:rgba(127,183,255,.45) transparent;
}
.drawer::-webkit-scrollbar{width:10px}
.drawer::-webkit-scrollbar-thumb{background:rgba(127,183,255,.35);border-radius:999px}
@media(max-width:900px){
  .drawer{max-height:calc(100dvh - var(--top-h) - 8px)}
  .quick-size-row{grid-template-columns:repeat(2,minmax(0,1fr))}
  .quick-size-row .chip:last-child{grid-column:span 2}
  .zoom-actions{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:640px){
  .drawer{border-radius:22px 22px 0 0;max-height:72dvh}
  .tool-group{padding:8px}
  .project-safety-grid{display:none}
  .project-safety-card[open] .project-safety-grid{display:grid}
  .focus-exit{top:auto;bottom:18px;right:50%;transform:translateX(50%)}
}


/* v89 header performance light polish */
.topbar{
  background:rgba(7,14,31,.96);
  border-bottom:1px solid rgba(127,183,255,.16);
}
body.light .topbar{
  background:rgba(255,255,255,.96);
  border-bottom:1px solid rgba(15,23,42,.10);
  color:#0b1220;
}
body.light{
  --bg:#e8eef7;
  --surface:#ffffff;
  --surface2:#f8fafc;
  --line:rgba(15,23,42,.14);
  --text:#0b1220;
  --muted:#475569;
  --accent:#2563eb;
  --accent2:#3b82f6;
}
body.light .scene{
  background:#dbe4ef;
}
body.light .drawer{
  background:rgba(255,255,255,.96);
  border-color:rgba(15,23,42,.12);
  box-shadow:0 18px 48px rgba(15,23,42,.14);
}
body.light .drawer-head,
body.light .panel,
body.light .tool-group,
body.light .mode-card,
body.light .project-safety-card,
body.light .brush-preset-card,
body.light .saved-color-card,
body.light .current-color-card,
body.light .diagnostics-card{
  background:#ffffff!important;
  color:#0b1220!important;
  border-color:rgba(15,23,42,.12)!important;
}
body.light .drawer-title,
body.light .tool-group h3,
body.light .mode-row span,
body.light .panel strong,
body.light .project-safety-card summary,
body.light .brush-preset-head strong,
body.light .saved-color-head strong,
body.light label{
  color:#0f172a!important;
}
body.light .hint,
body.light .project-safety-grid span,
body.light .diagnostics-grid span,
body.light .brush-readout,
body.light .save-status{
  color:#334155!important;
}
body.light .chip,
body.light .action,
body.light .tool-chip,
body.light .rail-btn,
body.light .icon-btn,
body.light .pill-btn{
  background:#ffffff!important;
  color:#0f172a!important;
  border-color:rgba(15,23,42,.16)!important;
}
body.light .chip.active,
body.light .tool-chip.active,
body.light .rail-btn.active,
body.light .profile-row .chip.active{
  background:#dbeafe!important;
  color:#0b1f47!important;
  border-color:#3b82f6!important;
  box-shadow:0 0 0 3px rgba(59,130,246,.14)!important;
}
body.light input,
body.light select,
body.light textarea{
  color:#0b1220!important;
  background:#ffffff!important;
  border-color:rgba(15,23,42,.18)!important;
}
body.light input[type="range"]{
  accent-color:#2563eb;
}
body:not(.light) .drawer,
body:not(.light) .panel,
body:not(.light) .tool-group,
body:not(.light) .mode-card,
body:not(.light) .project-safety-card{
  color:#dbeafe;
}
body:not(.light) .chip.active,
body:not(.light) .tool-chip.active,
body:not(.light) .rail-btn.active,
body:not(.light) .profile-row .chip.active{
  color:#eaf4ff!important;
  border-color:rgba(127,183,255,.82)!important;
  background:rgba(59,130,246,.18)!important;
}
.topbar #saveProjectBtn,
.topbar #publishProjectBtn,
.topbar #focusModeBtn{
  display:none!important;
}
.project-safety-card.compact{
  max-height:none;
}
.project-safety-card.compact:not([open]) .project-safety-grid,
.project-safety-card.compact:not([open]) .btnrow{
  display:none!important;
}
.statusbar{
  color:#dbeafe;
}
body.light .statusbar{
  color:#0f172a;
}
body.light .statusbar .pill,
body.light .statusbar span,
body.light .statusbar strong{
  color:#0f172a!important;
}
body[data-performance-profile="quality"] .profile-row #profileQuality,
body[data-performance-profile="balanced"] .profile-row #profileBalanced,
body[data-performance-profile="performance"] .profile-row #profilePerformance{
  border-color:rgba(127,183,255,.82)!important;
  background:rgba(59,130,246,.18)!important;
}
@media(max-width:720px){
  .topbar .icon-btn{min-width:40px}
  .topbar{gap:6px}
}


/* v90 professional framework ui */
:root{
  --fw-bg:#eef3f8;
  --fw-panel:#ffffff;
  --fw-panel-2:#f8fafc;
  --fw-border:#d7e0ea;
  --fw-text:#101828;
  --fw-muted:#536173;
  --fw-blue:#2563eb;
  --fw-blue-soft:#dbeafe;
  --fw-shadow:0 18px 50px rgba(15,23,42,.12);
}
body.light{
  background:var(--fw-bg);
  color:var(--fw-text);
}
body.light .topbar{
  background:rgba(255,255,255,.92)!important;
  border-bottom:1px solid var(--fw-border)!important;
  backdrop-filter:blur(14px);
}
body.light .scene{
  background:linear-gradient(135deg,#e8eef6,#dce6f2)!important;
}
body.light .drawer{
  background:rgba(255,255,255,.96)!important;
  border-color:var(--fw-border)!important;
  box-shadow:var(--fw-shadow)!important;
}
body.light .drawer-head{
  background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(255,255,255,.92))!important;
  border-bottom:1px solid rgba(15,23,42,.08);
}
body.light .tool-group,
body.light .mode-card,
body.light .project-safety-card,
body.light .brush-preset-card,
body.light .current-color-card,
body.light .saved-color-card,
body.light .diagnostics-card,
body.light .layer-item{
  background:var(--fw-panel)!important;
  border-color:var(--fw-border)!important;
  box-shadow:0 1px 2px rgba(15,23,42,.04);
}
body.light .chip,
body.light .action,
body.light .tool-chip,
body.light .rail-btn,
body.light .icon-btn{
  background:var(--fw-panel)!important;
  color:var(--fw-text)!important;
  border-color:var(--fw-border)!important;
  box-shadow:0 1px 1px rgba(15,23,42,.035);
}
body.light .chip.active,
body.light .tool-chip.active,
body.light .rail-btn.active,
body.light .profile-row .chip.active,
body.light [data-active="true"]{
  background:var(--fw-blue-soft)!important;
  color:#0b1f47!important;
  border-color:#6096f6!important;
  box-shadow:0 0 0 3px rgba(37,99,235,.12)!important;
}
body.light .profile-status,
.profile-status{
  margin-top:8px;
  border:1px solid rgba(37,99,235,.18);
  background:rgba(37,99,235,.07);
  border-radius:12px;
  padding:.48rem .62rem;
  font-weight:900;
  font-size:.82rem;
  color:#1e3a8a;
}
body:not(.light) .profile-status{
  color:#dbeafe;
  background:rgba(96,165,250,.10);
  border-color:rgba(96,165,250,.22);
}
body:not(.light){
  --text:#e8f1ff;
  --muted:#a8b8d0;
}
body:not(.light) .drawer,
body:not(.light) .tool-group,
body:not(.light) .mode-card,
body:not(.light) .project-safety-card,
body:not(.light) .brush-preset-card,
body:not(.light) .layer-item{
  background:rgba(9,18,38,.94);
  border-color:rgba(127,183,255,.18);
}
.drawer-title{
  letter-spacing:.01em;
}
.tool-group h3{
  letter-spacing:.11em;
  font-size:.74rem;
}
.tool-chip{
  align-items:center;
  gap:9px;
}
.tool-ico{
  width:24px;
  height:24px;
  display:inline-grid;
  place-items:center;
  border-radius:8px;
  background:rgba(37,99,235,.08);
}
body:not(.light) .tool-ico{
  background:rgba(96,165,250,.10);
}
.profile-row .chip{
  transition:transform .12s ease, border-color .12s ease, background .12s ease;
}
.profile-row .chip:active{
  transform:translateY(1px);
}
body[data-performance-profile="quality"] #profileQuality,
body[data-performance-profile="balanced"] #profileBalanced,
body[data-performance-profile="performance"] #profilePerformance{
  background:var(--fw-blue-soft)!important;
  color:#0b1f47!important;
  border-color:#6096f6!important;
}
body:not(.light)[data-performance-profile="quality"] #profileQuality,
body:not(.light)[data-performance-profile="balanced"] #profileBalanced,
body:not(.light)[data-performance-profile="performance"] #profilePerformance{
  background:rgba(96,165,250,.18)!important;
  color:#e8f1ff!important;
  border-color:rgba(127,183,255,.75)!important;
}
.statusbar{
  border:1px solid rgba(127,183,255,.18);
  background:rgba(7,14,31,.76);
  backdrop-filter:blur(12px);
}
body.light .statusbar{
  background:rgba(255,255,255,.88);
  border-color:var(--fw-border);
  box-shadow:0 10px 28px rgba(15,23,42,.10);
}
.brush-hud{
  border-radius:18px;
}
.brush-hud span{
  padding:.32rem .56rem;
}
body[data-performance-profile="performance"] .brush-hud{
  transition:none;
}
@media(max-width:720px){
  .profile-status{font-size:.76rem}
  .topbar .title strong{max-width:34vw}
}


/* v91 performance adaptive hardening */
.device-capability-notice{
  margin-top:8px;
  border:1px solid rgba(245,158,11,.24);
  background:rgba(245,158,11,.08);
  color:#92400e;
  border-radius:12px;
  padding:.48rem .62rem;
  font-size:.8rem;
  font-weight:900;
}
body:not(.light) .device-capability-notice{
  color:#fde68a;
  background:rgba(245,158,11,.09);
  border-color:rgba(245,158,11,.22);
}
body[data-device-class="conserve"] .drawer{
  scroll-behavior:auto;
}
.stage,.layer-canvas{
  touch-action:none;
  -webkit-user-select:none;
  user-select:none;
}
.scene{
  overscroll-behavior:contain;
}
.drawer{
  overscroll-behavior:contain;
  scroll-padding:14px;
}
.rail-btn{
  min-width:46px;
  min-height:46px;
}
body.light .rail{
  background:rgba(255,255,255,.82);
  border-color:rgba(15,23,42,.10);
}
body.light .rail-btn{
  background:#ffffff!important;
  color:#0f172a!important;
}
body.light .rail-btn.active{
  background:#dbeafe!important;
  color:#0b1f47!important;
}
@media(min-width:1180px){
  .drawer{width:min(430px,31vw)}
  .tool-group,.mode-card,.project-safety-card,.brush-preset-card{padding:12px}
}
@media(min-width:760px) and (max-width:1179px){
  .drawer{width:min(390px,42vw)}
  .tools-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:759px){
  .main{grid-template-columns:1fr}
  .rail{
    position:fixed;
    right:8px;
    top:calc(var(--top-h) + 8px);
    z-index:30;
    border-radius:18px;
    padding:6px;
    gap:5px;
  }
  .rail-btn{
    min-width:48px;
    min-height:48px;
  }
  .drawer{
    position:fixed;
    left:8px;
    right:8px;
    bottom:8px;
    top:auto;
    width:auto!important;
    max-height:min(74dvh,620px);
    border-radius:22px;
    z-index:40;
    box-shadow:0 22px 70px rgba(15,23,42,.28);
  }
  .drawer.hidden{
    transform:translateY(105%);
  }
  .drawer:not(.hidden){
    transform:translateY(0);
  }
  .drawer-head{
    border-radius:22px 22px 0 0;
  }
}
body[data-performance-profile="performance"] .layer-thumb{
  image-rendering:auto;
}
body[data-performance-profile="performance"] .brush-hud{
  backdrop-filter:none;
}
body[data-performance-profile="performance"] .mode-card,
body[data-performance-profile="performance"] .tool-group,
body[data-performance-profile="performance"] .project-safety-card{
  box-shadow:none!important;
}
@media(prefers-reduced-motion:reduce){
  .drawer,.rail-btn,.tool-chip,.chip,.action{
    transition:none!important;
  }
}


/* v92 layer layout cache public polish */
:root{
  --sky-text:#dbeafe;
  --sky-muted:#a9c7ef;
  --sky-active:#7fb7ff;
}
body:not(.light){
  --accent:#7fb7ff;
  --accent2:#8fbaff;
}
body:not(.light) .drawer,
body:not(.light) .panel,
body:not(.light) .tool-group,
body:not(.light) .project-safety-card,
body:not(.light) .layer-layout-card,
body:not(.light) .layer-item{
  color:var(--sky-text);
  border-color:rgba(127,183,255,.20);
}
body:not(.light) .hint,
body:not(.light) .layer-badge,
body:not(.light) .layer-strip-item small,
body:not(.light) .device-capability-notice{
  color:var(--sky-muted);
}
.layer-layout-card{
  border:1px solid rgba(127,183,255,.20);
  border-radius:16px;
  padding:10px;
  background:rgba(255,255,255,.04);
}
.layer-layout-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  margin-bottom:8px;
}
.layer-layout-head strong{
  font-weight:950;
}
.layer-layout-head span{
  border:1px solid rgba(127,183,255,.22);
  background:rgba(127,183,255,.08);
  border-radius:999px;
  padding:.22rem .5rem;
  font-size:.78rem;
  font-weight:900;
}
.layer-layout-actions .chip.active{
  border-color:rgba(127,183,255,.75)!important;
  background:rgba(59,130,246,.18)!important;
  color:#eaf4ff!important;
}
body.light .layer-layout-actions .chip.active{
  background:#dbeafe!important;
  color:#0b1f47!important;
}
.layer-strip{
  display:flex;
  gap:8px;
  overflow-x:auto;
  overflow-y:hidden;
  padding:4px 2px 10px;
  scroll-snap-type:x proximity;
  scrollbar-width:thin;
}
.layer-strip-item{
  flex:0 0 74px;
  min-height:76px;
  border:1px solid rgba(148,163,184,.22);
  background:rgba(255,255,255,.045);
  color:inherit;
  border-radius:14px;
  padding:6px;
  display:grid;
  gap:4px;
  place-items:center;
  scroll-snap-align:start;
}
.layer-strip-item img,
.layer-strip-empty{
  width:54px;
  height:42px;
  border-radius:10px;
  object-fit:contain;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(2,6,23,.20);
}
.layer-strip-empty{
  display:grid;
  place-items:center;
  font-weight:950;
  color:var(--muted);
}
.layer-strip-item small{
  font-size:.72rem;
  white-space:nowrap;
}
.layer-strip-item.active{
  border-color:rgba(127,183,255,.85);
  background:rgba(59,130,246,.16);
  box-shadow:0 0 0 3px rgba(127,183,255,.10);
}
.layer-strip-item.add{
  font-size:1.3rem;
  font-weight:950;
}
.layer-list.is-horizontal{
  display:flex;
  gap:10px;
  overflow-x:auto;
  overflow-y:hidden;
  padding-bottom:8px;
  scroll-snap-type:x proximity;
}
.layer-list.is-horizontal .layer-item{
  flex:0 0 min(300px,82vw);
  scroll-snap-align:start;
}
.layer-list.is-horizontal .layer-order-strip{
  display:none;
}
.layer-item.compact .layer-actions-v20{
  grid-template-columns:repeat(2,minmax(0,1fr));
}
.memory-warning{
  margin:8px 0;
  border:1px solid rgba(245,158,11,.26);
  background:rgba(245,158,11,.09);
  color:#92400e;
  border-radius:12px;
  padding:.55rem .7rem;
  font-weight:900;
  font-size:.82rem;
}
body:not(.light) .memory-warning{
  color:#fde68a;
  background:rgba(245,158,11,.09);
  border-color:rgba(245,158,11,.26);
}
body.light .layer-layout-card,
body.light .layer-strip-item{
  background:#ffffff!important;
  color:#0b1220!important;
  border-color:#d7e0ea!important;
}
body.light .layer-strip-item.active{
  background:#dbeafe!important;
  color:#0b1f47!important;
  border-color:#6096f6!important;
}
body[data-project-size="large"] .project-safety-card{
  border-color:rgba(245,158,11,.36)!important;
}
@media(max-width:759px){
  body[data-layer-layout="vertical"] .layer-list{
    max-height:48dvh;
    overflow:auto;
  }
  body[data-layer-layout="horizontal"] .layer-list{
    max-height:none;
  }
  .layer-strip{
    position:sticky;
    top:48px;
    z-index:3;
    background:linear-gradient(180deg,rgba(7,14,31,.96),rgba(7,14,31,.82));
    border-radius:14px;
  }
  body.light .layer-strip{
    background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(255,255,255,.88));
  }
}
@media(min-width:960px){
  .layer-list.is-horizontal .layer-item{
    flex-basis:320px;
  }
}


/* v93 tool reliability compact ux */
.quick-action-bar{
  position:absolute;
  left:50%;
  bottom:72px;
  transform:translateX(-50%);
  z-index:16;
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  justify-content:center;
  max-width:min(96%,860px);
  padding:7px;
  border:1px solid rgba(127,183,255,.22);
  background:rgba(7,14,31,.74);
  backdrop-filter:blur(12px);
  border-radius:18px;
  box-shadow:0 16px 40px rgba(0,0,0,.20);
}
.quick-action-bar button{
  min-height:36px;
  border:1px solid rgba(127,183,255,.20);
  background:rgba(255,255,255,.06);
  color:#dbeafe;
  border-radius:12px;
  padding:.38rem .58rem;
  font-weight:950;
}
body.light .quick-action-bar{
  background:rgba(255,255,255,.90);
  border-color:#d7e0ea;
}
body.light .quick-action-bar button{
  color:#0b1220;
  background:#ffffff;
  border-color:#d7e0ea;
}
.tool-inspector{
  border:1px solid rgba(127,183,255,.20);
  background:rgba(255,255,255,.045);
  border-radius:16px;
  padding:10px;
  margin:10px 0;
}
.tool-inspector-head{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}
.tool-inspector-head strong{
  font-weight:950;
}
.tool-inspector-head span{
  font-size:.78rem;
  font-weight:900;
  color:var(--sky-muted,#a9c7ef);
}
.tool-inspector-body{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
  margin-top:8px;
}
.tool-inspector-body span{
  display:grid;
  gap:2px;
  border:1px solid rgba(148,163,184,.18);
  background:rgba(2,6,23,.14);
  border-radius:12px;
  padding:7px;
  color:var(--muted);
  font-size:.78rem;
}
.tool-inspector-body strong{
  color:var(--text);
}
.tool-inspector.is-warning{
  border-color:rgba(245,158,11,.42);
  background:rgba(245,158,11,.08);
}
.current-color-preview.previous{
  opacity:.82;
  position:relative;
}
.current-color-preview.previous::after{
  content:"Prev";
  position:absolute;
  right:4px;
  bottom:3px;
  font-size:.62rem;
  font-weight:950;
  border-radius:999px;
  padding:.06rem .22rem;
  background:rgba(0,0,0,.35);
  color:#fff;
}
body.light .tool-inspector,
body.light .tool-inspector-body span{
  background:#ffffff!important;
  color:#0b1220!important;
  border-color:#d7e0ea!important;
}
body.light .tool-inspector-head span{
  color:#475569!important;
}
body.light .tool-inspector-body strong{
  color:#0b1220!important;
}
.drawer::before{
  content:"";
  display:block;
  width:44px;
  height:5px;
  border-radius:999px;
  background:rgba(148,163,184,.45);
  margin:6px auto 2px;
}
@media(min-width:760px){
  .drawer::before{display:none}
}
@media(max-width:759px){
  .quick-action-bar{
    bottom:calc(env(safe-area-inset-bottom,0px) + 12px);
    max-width:calc(100vw - 18px);
    border-radius:16px;
  }
  .quick-action-bar button{
    min-width:42px;
  }
  .brush-hud{
    bottom:calc(env(safe-area-inset-bottom,0px) + 70px);
  }
  .tool-inspector-body{
    grid-template-columns:1fr;
  }
}
body[data-layer-layout="horizontal"] .layer-strip{
  display:flex;
}
body[data-layer-layout="vertical"] .layer-strip{
  opacity:.92;
}
body:not(.light) .tool-chip.active,
body:not(.light) .chip.active,
body:not(.light) .rail-btn.active{
  color:#eef7ff!important;
  border-color:rgba(127,183,255,.86)!important;
  background:rgba(59,130,246,.18)!important;
}


/* v94 clickable overlay and panel repair */
.quick-action-bar,
.quick-action-bar *,
.quick-bar-toggle,
.brush-hud,
.brush-hud *{
  pointer-events:auto;
  touch-action:manipulation;
}
.quick-bar-toggle{
  position:absolute;
  left:50%;
  bottom:calc(72px + 62px);
  transform:translateX(-50%);
  z-index:17;
  min-width:42px;
  min-height:34px;
  border:1px solid rgba(127,183,255,.24);
  background:rgba(7,14,31,.78);
  color:#dbeafe;
  border-radius:999px;
  font-weight:950;
  box-shadow:0 12px 28px rgba(0,0,0,.18);
}
body.light .quick-bar-toggle{
  background:rgba(255,255,255,.92);
  color:#0b1220;
  border-color:#d7e0ea;
}
.quick-action-bar.collapsed{
  display:none!important;
}
body.quick-bar-collapsed .brush-hud{
  bottom:18px;
}
.drawer.open{
  transform:translateX(0)!important;
  pointer-events:auto!important;
  opacity:1!important;
  visibility:visible!important;
}
.rail-btn{
  touch-action:manipulation;
}
@media(max-width:759px){
  .drawer.open{
    transform:translateY(0)!important;
    pointer-events:auto!important;
    opacity:1!important;
    visibility:visible!important;
  }
  .quick-bar-toggle{
    bottom:calc(env(safe-area-inset-bottom,0px) + 72px);
  }
  body.quick-bar-collapsed .quick-bar-toggle{
    bottom:calc(env(safe-area-inset-bottom,0px) + 14px);
  }
}
body:not(.light) .quick-action-bar,
body:not(.light) .quick-bar-toggle{
  color:#dbeafe;
  border-color:rgba(127,183,255,.24);
}


/* v95 clean workspace refinement */
.quick-action-bar,
.quick-bar-toggle{
  display:none!important;
  pointer-events:none!important;
}
.brush-hud{
  bottom:18px!important;
}
body.quick-bar-collapsed .brush-hud{
  bottom:18px!important;
}
.tool-inspector{
  margin-top:12px;
}
.tool-inspector-body{
  grid-template-columns:repeat(5,minmax(0,1fr));
}
.tool-inspector-body span{
  min-height:54px;
}
.statusbar{
  max-width:min(88vw,620px);
}
.statusbar .pill,
.statusbar span,
.statusbar strong{
  white-space:nowrap;
}
.drawer.open{
  pointer-events:auto!important;
  visibility:visible!important;
}
.rail-btn[title]{
  position:relative;
}
body:not(.light){
  --sky-text:#dbeafe;
  --sky-muted:#a9c7ef;
  --sky-active:#7fb7ff;
}
body:not(.light) .tool-inspector,
body:not(.light) .drawer,
body:not(.light) .panel{
  color:var(--sky-text);
}
body:not(.light) .tool-inspector-head span,
body:not(.light) .tool-inspector-body span{
  color:var(--sky-muted);
}
@media(max-width:759px){
  .brush-hud{
    bottom:calc(env(safe-area-inset-bottom,0px) + 14px)!important;
  }
  .tool-inspector-body{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .tool-inspector-body span:last-child{
    grid-column:span 2;
  }
}
@media(max-width:520px){
  .tool-inspector-body{
    grid-template-columns:1fr;
  }
  .tool-inspector-body span:last-child{
    grid-column:auto;
  }
}


/* v96 canvas stability tool polish */
.current-layer-label{
  border:1px solid rgba(127,183,255,.22);
  background:rgba(127,183,255,.075);
  color:#dbeafe;
  border-radius:14px;
  padding:.58rem .72rem;
  font-weight:950;
  letter-spacing:.01em;
}
body.light .current-layer-label{
  background:#eff6ff;
  color:#0b1f47;
  border-color:#bfdbfe;
}
.project-recovery-note{
  margin:8px 0;
  border:1px solid rgba(127,183,255,.20);
  background:rgba(127,183,255,.065);
  color:#b9d7ff;
  border-radius:12px;
  padding:.55rem .7rem;
  font-weight:850;
  font-size:.82rem;
}
body.light .project-recovery-note{
  color:#1e3a8a;
  background:#eff6ff;
  border-color:#bfdbfe;
}
body[data-tool-ready="blocked"] .tool-inspector{
  border-color:rgba(245,158,11,.46)!important;
  background:rgba(245,158,11,.08)!important;
}
body[data-tool-ready="ready"] .tool-inspector{
  border-color:rgba(127,183,255,.22);
}
.rail-btn{
  transition:background .12s ease,border-color .12s ease,transform .12s ease;
}
.rail-btn:active{
  transform:translateY(1px) scale(.98);
}
.rail-btn[disabled],
.rail-btn:disabled{
  opacity:.52;
  cursor:not-allowed;
  filter:saturate(.55);
}
body:not(.light) .rail-btn.active{
  background:rgba(59,130,246,.20)!important;
  border-color:rgba(127,183,255,.86)!important;
  color:#eef7ff!important;
}
body.light .rail-btn.active{
  background:#dbeafe!important;
  border-color:#60a5fa!important;
  color:#0b1f47!important;
}
.layer-item.locked,
.layer-item:not(.active)[data-locked="true"]{
  opacity:.88;
}
.layer-badge.locked{
  color:#fde68a!important;
  border-color:rgba(245,158,11,.32)!important;
  background:rgba(245,158,11,.10)!important;
}
.layer-list,
.layer-strip,
.drawer{
  scrollbar-color:rgba(127,183,255,.45) transparent;
}
body:not(.light){
  --sky-text:#dbeafe;
  --sky-muted:#a9c7ef;
  --sky-active:#7fb7ff;
}
body:not(.light) .drawer,
body:not(.light) .panel,
body:not(.light) .tool-inspector,
body:not(.light) .layer-item,
body:not(.light) .project-safety-card{
  color:var(--sky-text);
}
body:not(.light) .hint,
body:not(.light) .tool-inspector-head span,
body:not(.light) .project-recovery-note{
  color:var(--sky-muted);
}
@media(max-width:759px){
  .current-layer-label{
    font-size:.84rem;
    padding:.5rem .62rem;
  }
  .project-recovery-note{
    font-size:.78rem;
  }
  .rail-btn{
    min-width:50px;
    min-height:50px;
  }
}


/* v97 canvas visibility recovery */
.canvas-boot-error{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  z-index:90;
  display:grid;
  gap:6px;
  max-width:min(420px,82vw);
  border:1px solid rgba(245,158,11,.32);
  background:rgba(15,23,42,.92);
  color:#dbeafe;
  border-radius:18px;
  padding:14px 16px;
  box-shadow:0 22px 60px rgba(0,0,0,.28);
  text-align:center;
}
.canvas-boot-error strong{font-weight:950;color:#fde68a}
.canvas-boot-error span{font-size:.88rem;color:#bfdbfe}
body.light .canvas-boot-error{
  background:rgba(255,255,255,.96);
  color:#0f172a;
  border-color:#f59e0b;
}
body.light .canvas-boot-error span{color:#334155}

/* v98 canvas recovery tool stability */
.draft-recovery-dialog{
  position:fixed;
  inset:0;
  z-index:120;
  display:grid;
  place-items:center;
  padding:16px;
  background:rgba(2,6,23,.58);
  backdrop-filter:blur(10px);
}
.draft-recovery-card{
  width:min(92vw,460px);
  display:grid;
  gap:10px;
  border:1px solid rgba(127,183,255,.28);
  border-radius:18px;
  background:rgba(7,14,31,.96);
  color:#dbeafe;
  padding:16px;
  box-shadow:0 24px 70px rgba(0,0,0,.34);
}
.draft-recovery-card strong{font-size:1.02rem;font-weight:950;color:#eff6ff}
.draft-recovery-card p{margin:0;color:#bfdbfe;line-height:1.38}
.draft-recovery-detail{font-size:.82rem;color:#a9c7ef!important}
.draft-recovery-actions{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:8px;
}
.draft-recovery-actions button{
  min-height:44px;
  border:1px solid rgba(127,183,255,.26);
  border-radius:12px;
  background:rgba(255,255,255,.06);
  color:#eff6ff;
  font-weight:900;
}
.draft-recovery-actions button[data-draft-action="clear"]{
  border-color:rgba(239,68,68,.36);
  color:#fee2e2;
}
body.light .draft-recovery-dialog{background:rgba(15,23,42,.32)}
body.light .draft-recovery-card{
  background:#ffffff;
  color:#0f172a;
  border-color:#bfdbfe;
}
body.light .draft-recovery-card strong{color:#0b1220}
body.light .draft-recovery-card p,
body.light .draft-recovery-detail{color:#334155!important}
body.light .draft-recovery-actions button{
  background:#f8fafc;
  color:#0b1220;
  border-color:#cbd5e1;
}
.stage,.layer-host,.layer-canvas{min-width:1px;min-height:1px}
.layer-item.active,
.layer-strip-item.active{
  outline:2px solid rgba(127,183,255,.74);
  outline-offset:2px;
}
.chip:disabled,
.action:disabled,
.layer-actions button:disabled{
  opacity:.45;
  cursor:not-allowed;
  filter:saturate(.55);
}
@media(max-width:759px){
  .rail{width:54px;gap:7px}
  .drawer{
    left:0!important;
    right:0!important;
    bottom:0!important;
    top:auto!important;
    width:100%!important;
    max-width:100%!important;
    max-height:min(68dvh,560px)!important;
    border-radius:18px 18px 0 0!important;
    transform:translateY(calc(100% - 46px));
  }
  .drawer.open{transform:translateY(0)!important}
  .drawer .panel{
    max-height:calc(68dvh - 54px);
    overflow-y:auto!important;
  }
  .scene{bottom:46px}
  .draft-recovery-actions{grid-template-columns:1fr}
  .draft-recovery-actions button{min-height:48px}
}

/* v99 potato phone performance profile */
.potato-chip{
  border-color:rgba(127,183,255,.26)!important;
}
.profile-row{
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr));
}
body[data-performance-profile="potato"] #profilePotato,
body:not(.light)[data-performance-profile="potato"] #profilePotato{
  background:rgba(59,130,246,.22)!important;
  border-color:rgba(127,183,255,.88)!important;
  color:#eef7ff!important;
}
body.light[data-performance-profile="potato"] #profilePotato{
  background:#dbeafe!important;
  border-color:#60a5fa!important;
  color:#0b1f47!important;
}
body[data-performance-profile="potato"] .layer-thumb,
body[data-performance-profile="potato"] .layer-strip-item img{
  image-rendering:auto;
}
body[data-performance-profile="potato"] .brush-hud{
  transition:none!important;
  box-shadow:none!important;
}
body[data-performance-profile="potato"] .tool-group,
body[data-performance-profile="potato"] .mode-card,
body[data-performance-profile="potato"] .project-safety-card,
body[data-performance-profile="potato"] .layer-layout-card{
  box-shadow:none!important;
}
body[data-device-class="potato"] .device-capability-notice{
  border-color:rgba(127,183,255,.30);
  background:rgba(127,183,255,.10);
  color:#dbeafe;
}
body.light[data-device-class="potato"] .device-capability-notice{
  color:#1e3a8a;
  background:#eff6ff;
  border-color:#bfdbfe;
}
@media(max-width:520px){
  .profile-row{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  .profile-row .chip{
    min-height:42px;
  }
}


/* v100 canvas ux qa real device polish */
:root{
  --canvas-safe-gap:8px;
}
.main{
  min-height:calc(100dvh - var(--top-h));
  height:calc(100dvh - var(--top-h));
}
.scene{
  min-height:240px;
  contain:layout paint size;
}
.scene[data-viewport-ready="true"] .stage{
  visibility:visible;
}
.stage{
  visibility:visible;
  backface-visibility:hidden;
}
.layer-host,
.layer-canvas{
  display:block;
}
.wide-safety,
.wide-inspector{
  grid-column:1 / -1;
}
.project-safety-grid .wide-safety strong{
  color:#dbeafe;
}
body.light .project-safety-grid .wide-safety strong{
  color:#1e40af;
}
body[data-recommended-action*="potato"] #recommendedActionLabel,
body[data-recommended-action*="performance"] #recommendedActionLabel,
body[data-recommended-action*="backup"] #recommendedActionLabel{
  color:#fde68a;
}
body.light[data-recommended-action*="potato"] #recommendedActionLabel,
body.light[data-recommended-action*="performance"] #recommendedActionLabel,
body.light[data-recommended-action*="backup"] #recommendedActionLabel{
  color:#92400e;
}
.tool-inspector-body .wide-inspector{
  min-height:46px;
}
.drawer{
  max-height:calc(100dvh - var(--top-h) - 16px);
}
.panel{
  scroll-padding:18px;
}
.rail{
  overscroll-behavior:contain;
}
@media(min-width:1180px){
  .scene{
    inset:0 60px 0 0;
  }
  .drawer.open ~ .unused-never{display:none}
}
@media(max-width:900px){
  .topbar{
    gap:6px;
  }
  .title{
    min-width:0;
  }
  .title strong{
    max-width:52vw;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
  }
  .drawer{
    right:calc(58px + env(safe-area-inset-right));
    max-width:calc(100vw - 70px);
  }
  .profile-row{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
}
@media(max-width:759px){
  .main{
    min-height:calc(100dvh - var(--top-h));
    height:calc(100dvh - var(--top-h));
  }
  .scene{
    inset:0 58px 0 0!important;
    border-left:0;
    border-bottom:0;
  }
  .rail{
    top:calc(var(--top-h) + env(safe-area-inset-top) + 6px);
    right:calc(5px + env(safe-area-inset-right));
    bottom:calc(env(safe-area-inset-bottom) + 74px);
    width:50px;
  }
  .rail-btn{
    min-height:48px;
    border-radius:15px;
  }
  .drawer{
    left:8px!important;
    right:calc(58px + env(safe-area-inset-right))!important;
    bottom:calc(env(safe-area-inset-bottom) + 8px)!important;
    top:auto!important;
    width:auto!important;
    max-width:none!important;
    max-height:min(76dvh,640px)!important;
    border-radius:22px 22px 0 0;
  }
  .drawer-head{
    position:sticky;
    top:0;
    z-index:2;
  }
  .panel{
    max-height:calc(min(76dvh,640px) - 58px);
    -webkit-overflow-scrolling:touch;
  }
  .tool-inspector-body{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
  }
  .tool-inspector-body .wide-inspector{
    grid-column:1 / -1;
  }
  .project-safety-grid{
    grid-template-columns:1fr!important;
  }
  .brush-hud{
    left:10px!important;
    right:68px!important;
    transform:none!important;
    max-width:none!important;
  }
}
@media(max-width:480px){
  .topbar{
    padding-left:6px;
    padding-right:6px;
  }
  .pill-btn{
    padding:0 10px;
  }
  .finish{
    min-width:auto;
  }
  .drawer{
    left:6px!important;
    right:calc(56px + env(safe-area-inset-right))!important;
  }
  .tools-grid{
    grid-template-columns:1fr!important;
  }
  .btnrow .chip,
  .btnrow .action{
    flex:1 1 100%;
  }
}
@media(orientation:landscape) and (max-height:520px){
  .topbar{
    padding-top:5px;
    padding-bottom:5px;
  }
  .drawer{
    max-height:calc(100dvh - var(--top-h) - 8px)!important;
  }
  .panel{
    max-height:calc(100dvh - var(--top-h) - 60px)!important;
  }
  .brush-hud{
    display:none;
  }
}


/* v101 mobile layout repair */
html, body{
  min-height:100%;
}
body:not(.light){
  background:#07111f!important;
}
body:not(.light) .main{
  background:#07111f!important;
}
body.light .main{
  background:#e8eef7!important;
}
body:not(.light) .scene{
  background:
    linear-gradient(45deg, rgba(127,183,255,.035) 25%, transparent 25%) 0 0/18px 18px,
    linear-gradient(-45deg, rgba(127,183,255,.035) 25%, transparent 25%) 0 9px/18px 18px,
    linear-gradient(45deg, transparent 75%, rgba(127,183,255,.035) 75%) 9px -9px/18px 18px,
    linear-gradient(-45deg, transparent 75%, rgba(127,183,255,.035) 75%) 9px 9px/18px 18px,
    #07111f!important;
}
body:not(.light) .rail{
  background:linear-gradient(180deg, rgba(7,17,31,.92), rgba(7,17,31,.72))!important;
  border-left:1px solid rgba(127,183,255,.10);
  border-radius:20px 0 0 20px;
  padding:6px 5px;
}
body.light .rail{
  background:linear-gradient(180deg, rgba(232,238,247,.94), rgba(232,238,247,.78))!important;
  border-left:1px solid rgba(15,23,42,.08);
}
body:not(.light) .rail-btn{
  background:rgba(15,23,42,.86)!important;
  color:#dbeafe!important;
  border-color:rgba(127,183,255,.18)!important;
}
body:not(.light) .rail-btn.active{
  background:rgba(59,130,246,.22)!important;
  color:#f0f8ff!important;
  border-color:rgba(127,183,255,.86)!important;
}
body:not(.light) .drawer-head,
body:not(.light) .panel{
  background:#0b1527!important;
  color:#dbeafe!important;
}
body:not(.light) .drawer{
  color:#dbeafe;
}
.scene[data-v101-fit="mobile"] .stage{
  transition:transform .12s ease-out;
}
@media(max-width:900px){
  .topbar{
    min-height:var(--top-h);
    padding:8px 8px calc(8px + env(safe-area-inset-top));
  }
  .title strong{
    font-size:.9rem;
    max-width:44vw!important;
  }
  .topbar .title span{
    font-size:.70rem;
  }
  .pill-btn{
    min-height:38px;
    padding:0 10px;
    border-radius:13px;
  }
  .icon-btn{
    min-width:38px;
    min-height:38px;
  }
  .finish{
    min-height:38px;
    padding:0 12px;
  }
}
@media(max-width:759px){
  .main{
    background:#07111f!important;
    min-height:calc(100dvh - var(--top-h))!important;
    height:calc(100dvh - var(--top-h))!important;
  }
  body.light .main{
    background:#e8eef7!important;
  }
  .scene{
    inset:0 56px 0 0!important;
    border-left:0!important;
    border-top:0!important;
    border-bottom:0!important;
    min-height:calc(100dvh - var(--top-h))!important;
  }
  .rail{
    top:calc(var(--top-h) + env(safe-area-inset-top) + 4px)!important;
    right:0!important;
    bottom:calc(env(safe-area-inset-bottom) + 4px)!important;
    width:56px!important;
    border-radius:18px 0 0 18px!important;
    padding:5px 4px!important;
    z-index:46!important;
  }
  .rail-btn{
    min-width:46px!important;
    min-height:46px!important;
    border-radius:14px!important;
    box-shadow:none!important;
  }
  .drawer{
    left:8px!important;
    right:64px!important;
    bottom:calc(env(safe-area-inset-bottom) + 8px)!important;
    top:auto!important;
    width:auto!important;
    max-width:none!important;
    max-height:min(70dvh,600px)!important;
    border-radius:22px 22px 0 0!important;
    z-index:44!important;
  }
  .drawer.open{
    transform:translateY(0)!important;
    opacity:1!important;
    visibility:visible!important;
    pointer-events:auto!important;
  }
  .drawer-head{
    position:sticky!important;
    top:0!important;
    z-index:3!important;
    padding:10px 12px!important;
  }
  .panel{
    max-height:calc(min(70dvh,600px) - 56px)!important;
    padding:10px!important;
    overflow:auto!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior:contain!important;
  }
  .brush-hud{
    left:10px!important;
    right:66px!important;
    bottom:calc(env(safe-area-inset-bottom) + 12px)!important;
    transform:none!important;
    max-width:none!important;
    font-size:.78rem!important;
  }
  .stage{
    outline-width:2px!important;
  }
}
@media(max-width:480px){
  .title strong::after{
    content:"";
  }
  .title strong{
    max-width:36vw!important;
  }
  .topbar .title span{
    max-width:34vw;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .finish span,
  .finish .label{
    display:inline;
  }
}
@media(max-width:390px){
  .title strong{
    max-width:30vw!important;
  }
  .finish{
    padding:0 10px!important;
  }
}
@media(orientation:landscape) and (max-height:540px){
  .scene{
    inset:0 54px 0 0!important;
  }
  .rail{
    width:54px!important;
    gap:4px!important;
    padding:4px!important;
  }
  .rail-btn{
    min-height:40px!important;
  }
  .drawer{
    max-height:calc(100dvh - var(--top-h) - 8px)!important;
    right:60px!important;
  }
  .panel{
    max-height:calc(100dvh - var(--top-h) - 58px)!important;
  }
}


/* v102 mobile canvas fit recovery */
:root{
  --vvw:100vw;
  --vvh:100dvh;
  --vvo-top:0px;
  --vvo-left:0px;
  --mobile-rail-w:56px;
}
html, body{
  width:100%;
  min-height:var(--vvh);
  overflow:hidden;
}
body:not(.light),
body:not(.light) .app,
body:not(.light) .main{
  background:#07111f!important;
}
body.light,
body.light .app,
body.light .main{
  background:#e8eef7!important;
}
.main{
  width:100vw;
  height:calc(var(--vvh) - var(--top-h))!important;
  min-height:calc(var(--vvh) - var(--top-h))!important;
  overflow:hidden;
}
.scene{
  height:100%!important;
  overflow:hidden!important;
}
.scene[data-v102-fit="mobile-safe"] .stage{
  transform-origin:0 0!important;
  will-change:transform;
}
body:not(.light) .scene{
  background:
    radial-gradient(circle at 30% 20%, rgba(127,183,255,.07), transparent 28%),
    linear-gradient(45deg, rgba(127,183,255,.035) 25%, transparent 25%) 0 0/18px 18px,
    linear-gradient(-45deg, rgba(127,183,255,.035) 25%, transparent 25%) 0 9px/18px 18px,
    #07111f!important;
}
body.light .scene{
  background:#e8eef7!important;
}
body:not(.light) .rail{
  background:linear-gradient(180deg,rgba(7,17,31,.96),rgba(7,17,31,.88))!important;
  box-shadow:-12px 0 30px rgba(7,17,31,.28);
}
body.light .rail{
  background:linear-gradient(180deg,rgba(232,238,247,.98),rgba(232,238,247,.88))!important;
}
body:not(.light) .drawer{
  background:#0b1527!important;
  border-color:rgba(127,183,255,.20)!important;
  box-shadow:0 20px 60px rgba(0,0,0,.32);
}
body.light .drawer{
  background:#ffffff!important;
}
@media(max-width:759px){
  body{
    height:var(--vvh)!important;
  }
  .topbar{
    height:var(--top-h);
    min-height:var(--top-h);
    max-height:var(--top-h);
    overflow:hidden;
  }
  .main{
    height:calc(var(--vvh) - var(--top-h))!important;
    min-height:calc(var(--vvh) - var(--top-h))!important;
  }
  .scene{
    position:fixed!important;
    left:0!important;
    right:var(--mobile-rail-w)!important;
    top:calc(var(--top-h) + var(--vvo-top))!important;
    bottom:0!important;
    width:auto!important;
    height:calc(var(--vvh) - var(--top-h))!important;
    min-height:0!important;
    border:0!important;
  }
  .rail{
    position:fixed!important;
    top:calc(var(--top-h) + var(--vvo-top) + 4px)!important;
    right:0!important;
    bottom:calc(env(safe-area-inset-bottom) + 4px)!important;
    width:var(--mobile-rail-w)!important;
    max-width:var(--mobile-rail-w)!important;
    z-index:58!important;
  }
  .drawer{
    position:fixed!important;
    left:8px!important;
    right:calc(var(--mobile-rail-w) + 8px)!important;
    bottom:calc(env(safe-area-inset-bottom) + 8px)!important;
    top:auto!important;
    max-height:min(calc(var(--vvh) * .70),600px)!important;
    z-index:54!important;
  }
  .drawer.open{
    transform:translateY(0)!important;
    opacity:1!important;
    visibility:visible!important;
    pointer-events:auto!important;
  }
  .panel{
    max-height:calc(min(calc(var(--vvh) * .70),600px) - 58px)!important;
  }
  .brush-hud{
    right:calc(var(--mobile-rail-w) + 10px)!important;
    bottom:calc(env(safe-area-inset-bottom) + 12px)!important;
  }
  .statusbar{
    right:calc(var(--mobile-rail-w) + 10px)!important;
  }
}
@media(max-width:430px){
  :root{--mobile-rail-w:54px}
  .title strong{
    max-width:32vw!important;
  }
}
@media(orientation:landscape) and (max-height:540px){
  :root{--mobile-rail-w:52px}
  .scene{
    height:calc(var(--vvh) - var(--top-h))!important;
  }
  .drawer{
    max-height:calc(var(--vvh) - var(--top-h) - 8px)!important;
  }
  .panel{
    max-height:calc(var(--vvh) - var(--top-h) - 62px)!important;
  }
}


/* v103 mobile simplified stable workspace */
.home-fab{
  display:none!important;
  pointer-events:none!important;
}
body[data-user-view-adjusted] .scene .stage{
  transition:none!important;
}
@media(max-width:759px){
  body:not(.light),
  body:not(.light) .main,
  body:not(.light) .scene{
    background:#07111f!important;
  }
  .scene{
    right:var(--mobile-rail-w)!important;
  }
  .drawer{
    top:calc(var(--top-h) + var(--vvo-top) + 6px)!important;
    bottom:calc(env(safe-area-inset-bottom) + 8px)!important;
    left:8px!important;
    right:calc(var(--mobile-rail-w) + 8px)!important;
    max-height:none!important;
    height:auto!important;
    border-radius:18px!important;
    transform:translateY(0)!important;
  }
  .drawer:not(.open){
    opacity:0!important;
    visibility:hidden!important;
    pointer-events:none!important;
    transform:translateX(14px)!important;
  }
  .drawer.open{
    opacity:1!important;
    visibility:visible!important;
    pointer-events:auto!important;
    transform:translateX(0)!important;
  }
  .drawer-head{
    min-height:42px!important;
    padding:8px 10px!important;
    border-radius:18px 18px 0 0!important;
    box-shadow:none!important;
  }
  .panel{
    max-height:calc(var(--vvh) - var(--top-h) - 64px - env(safe-area-inset-bottom))!important;
    padding:8px!important;
    border-radius:0 0 18px 18px!important;
    box-shadow:none!important;
    background:#0b1527!important;
  }
  body.light .panel{
    background:#fff!important;
  }
  .tool-groups,
  .stack{
    gap:8px!important;
  }
  .tool-group,
  .mode-card,
  .project-safety-card,
  .tool-inspector{
    box-shadow:none!important;
    border-radius:14px!important;
    padding:8px!important;
    background:rgba(15,23,42,.72)!important;
  }
  body.light .tool-group,
  body.light .mode-card,
  body.light .project-safety-card,
  body.light .tool-inspector{
    background:#fff!important;
  }
  .tool-group h3{
    margin:0 0 6px!important;
    font-size:.76rem!important;
    letter-spacing:.12em!important;
  }
  .tools-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:6px!important;
  }
  .chip,
  .action,
  .mini-btn{
    min-height:38px!important;
    border-radius:12px!important;
    padding:0 9px!important;
    font-size:.86rem!important;
  }
  .tool-chip{
    justify-content:flex-start!important;
    gap:8px!important;
  }
  .grid,
  .grid2,
  .btnrow{
    gap:6px!important;
  }
  .rail{
    box-shadow:none!important;
    border-radius:14px 0 0 14px!important;
  }
  .rail-btn{
    box-shadow:none!important;
  }
  .selection-box{
    pointer-events:none!important;
    z-index:24!important;
  }
  .selection-tag{
    pointer-events:none!important;
  }
  .brush-hud{
    display:none!important;
  }
}
@media(max-width:480px){
  .panel{
    padding:7px!important;
  }
  .tools-grid,
  .grid2{
    grid-template-columns:1fr 1fr!important;
  }
  .tool-ico{
    width:20px;
    display:inline-flex;
    justify-content:center;
  }
}
@media(orientation:landscape) and (max-height:540px){
  .drawer{
    top:calc(var(--top-h) + var(--vvo-top) + 4px)!important;
    bottom:4px!important;
  }
  .panel{
    max-height:calc(var(--vvh) - var(--top-h) - 50px)!important;
  }
  .chip,
  .action{
    min-height:34px!important;
  }
}
body[data-performance-profile="potato"] .drawer,
body[data-performance-profile="potato"] .panel,
body[data-performance-profile="potato"] .tool-group,
body[data-performance-profile="potato"] .mode-card,
body[data-performance-profile="potato"] .project-safety-card,
body[data-performance-profile="potato"] .tool-inspector{
  box-shadow:none!important;
  backdrop-filter:none!important;
}
