:root {
  --ink: #1c1c28; --paper: #fff9eb; --panel: #ffffff; --line: #e7e3d9; --bg: #f3f1ea;
  --accent: #e0533d; --accent-dark: #c8432f; --accent2: #3d8ee0; --muted: #6b7280;
  --r-sm: 7px; --r-md: 11px; --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(28,28,40,.07);
  --shadow-md: 0 6px 16px rgba(28,28,40,.10), 0 1px 3px rgba(28,28,40,.06);
  --shadow-lg: 0 14px 34px rgba(28,28,40,.16);
  --topbar-h: 56px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Arial, sans-serif; color: var(--ink); background: var(--bg);
  display: flex; flex-direction: column; min-height: 100vh; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
fieldset { border: none; margin: 0; padding: 0; }
fieldset:disabled { opacity: .5; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 12px; letter-spacing: .01em; }
input[type=text], input[type=number], select, textarea {
  font-weight: 500; color: var(--ink); padding: 9px 11px; border: 1.5px solid var(--line); border-radius: var(--r-sm); background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=number]:focus, select:focus, textarea:focus, input[type=color]:focus {
  outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(61,142,224,.18);
}
input[type=color] { width: 38px; height: 34px; border: 1.5px solid var(--line); border-radius: var(--r-sm); padding: 2px; background: #fff; }
input[type=range] { accent-color: var(--accent2); height: 20px; }
textarea { resize: vertical; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.hint.small { font-size: 12px; margin: 4px 0 0; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

/* ---- top bar ---- */
#topbar {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px; background: var(--ink); color: var(--paper);
  flex-wrap: wrap; position: sticky; top: 0; z-index: 20; min-height: var(--topbar-h); box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
#brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .2px; white-space: nowrap; font-size: 15px; }
#brand img { border-radius: 6px; }
#kitTitle {
  background: rgba(255,255,255,.09); border: 1.5px solid rgba(255,255,255,.16); color: #fff; border-radius: var(--r-sm);
  padding: 7px 11px; min-width: 140px; flex: 1 1 180px; max-width: 300px; font-weight: 600;
}
#kitTitle:focus { border-color: rgba(255,255,255,.5); box-shadow: none; background: rgba(255,255,255,.14); }
#kitTitle::placeholder { color: rgba(255,255,255,.45); }
#topActions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.btn {
  border: none; border-radius: var(--r-sm); padding: 9px 14px; font-weight: 700; white-space: nowrap; flex: none;
  display: inline-flex; align-items: center; gap: 6px; transition: filter .15s, transform .1s, background .15s;
}
.btn:active { transform: translateY(1px); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(224,83,61,.35); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: rgba(255,255,255,.09); color: #fff; border: 1.5px solid rgba(255,255,255,.16); }
.btn.ghost:hover { background: rgba(255,255,255,.16); }
.btn.ghost.small { padding: 6px 10px; font-size: 13px; color: var(--ink); background: #fff; border-color: var(--line); }
.btn.ghost.small:hover { background: #f6f5f1; }
.btn.ghost.tiny { padding: 4px 6px; font-size: 12px; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 6px; }
.btn.ghost.tiny:hover { background: #f6f5f1; }
.btn.ghost.icon { padding: 6px 11px; font-size: 15px; line-height: 1; }
.btn.danger { color: var(--accent); }
.btn:disabled { opacity: .35; cursor: default; transform: none; }
.filebtn { display: inline-flex; align-items: center; margin: 0; }
.lbl { display: inline; }

/* ---- layout ---- */
#layout { display: flex; flex: 1; min-height: 0; }
.sideHead { display: flex; align-items: center; justify-content: space-between; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 12px 0 8px; }

#editorPane { flex: 1; overflow-y: auto; padding: 18px; min-width: 0; }
#editor { display: flex; gap: 16px; align-items: flex-start; }

/* document (name/size/category) panel — a slim strip on the left of the canvas */
#docPanel { flex: 0 0 210px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-sm); }
#docPanel label { margin-bottom: 13px; }

/* canvas + toolbar, center */
#canvasArea { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#previewHint { font-size: 12px; color: var(--muted); max-width: 360px; text-align: center; }

/* layers + properties panel, right */
#layersPanel { flex: 0 0 300px; overflow-x: hidden; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px; overflow-y: auto; max-height: 100%; box-shadow: var(--shadow-sm); }
#layerProps { border-top: 1px solid var(--line); padding-top: 12px; }
.propHead { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 10px; }
.layerNameBig { flex: 1; font-weight: 700; padding: 7px 9px; }

/* ---- kit info ---- */
#infoPane { max-width: 620px; margin: 28px auto; padding: 0 16px 48px; }
#infoPane h1 { font-size: 22px; margin-bottom: 18px; }
#warnings ul { padding-left: 20px; }
#warnings h3 { font-size: 14px; color: var(--accent); }
.importNote { background: #f4f3ef; border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px; margin: 18px 0; }
.importNote h3 { font-size: 14px; margin: 0 0 6px; }

/* ---- toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; text-align: center; box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- mobile bottom nav (hidden on desktop) ---- */
#mobileNav { display: none; }
.mnav { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none; padding: 7px 4px 5px; border-radius: var(--r-sm); font-size: 10.5px; font-weight: 700; color: var(--muted); }
.mnav .ico { font-size: 19px; line-height: 1; }
.mnav[aria-current="true"] { color: var(--accent2); }

/* ---- responsive: tablet ---- */
@media (max-width: 1000px) {
  #editor { flex-direction: column; align-items: stretch; }
  #docPanel { flex: none; width: 100%; }
}

/* ---- responsive: phone — one panel at a time, switched by the bottom nav ---- */
@media (max-width: 760px) {
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  #brand span:not(.ico) { display: none; }
  .lbl { display: none; }

  #layout { display: block; }
  #editorPane, #layersPanel { display: none; width: 100%; border: none; box-shadow: none; overflow: visible; max-height: none; border-radius: 0; }
  body[data-mview="canvas"] #editorPane { display: block; padding: 14px 14px 24px; }
  body[data-mview="layers"] #layersPanel { display: block; padding: 14px 14px 24px; }

  #docPanel, #layersPanel { border-radius: var(--r-md); }

  #mobileNav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 14px rgba(28,28,40,.08);
  }
}

/* ---- art workspace: soft paint-app canvas (tool rail, zoom, layers, properties) ---- */
:root {
  --ws: #e8e6df; --ws-dot: rgba(28,28,40,.09);
  --glass: rgba(255,255,255,.86); --glass-line: rgba(28,28,40,.09); --glass-text: #1c1c28; --glass-muted: #6b7280;
  --glass-hover: rgba(28,28,40,.055); --glass-on: #2f7bff; --glass-on-text: #fff; --glass-soft-on: rgba(47,123,255,.12);
  --glass-shadow: 0 10px 28px rgba(28,28,40,.13), 0 1px 3px rgba(28,28,40,.08);
}
.ico { display: block; flex-shrink: 0; }
.glass { background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow); -webkit-backdrop-filter: blur(16px) saturate(1.4); backdrop-filter: blur(16px) saturate(1.4); }
#canvasStage {
  position: relative; width: 100%; display: flex; justify-content: center; align-items: center; padding: 18px 84px;
  min-height: 460px; border-radius: var(--r-lg); overflow: hidden;
  background: radial-gradient(var(--ws-dot) 1.2px, transparent 1.3px) 0 0/22px 22px, var(--ws);
}
#previewWrap { background: repeating-conic-gradient(#eceae2 0% 25%, #f8f7f2 0% 50%) 0 0 / 20px 20px; border-radius: 6px; padding: 0; box-shadow: 0 12px 30px rgba(28,28,40,.22); max-width: 100%; overflow: hidden; line-height: 0; }
#previewSvg svg { display: block; width: min(440px, 64vw); max-height: calc(100vh - 220px); height: auto; cursor: default; touch-action: none; }
#previewSvg svg .layer { cursor: move; }
#canvasStage.hand #previewSvg svg, #canvasStage.hand #previewSvg svg * { cursor: grab !important; }
#canvasStage.panning #previewSvg svg, #canvasStage.panning #previewSvg svg * { cursor: grabbing !important; }
#previewSvg [data-handle="scale"] { cursor: nwse-resize; }
#previewSvg [data-handle="rotate"] { cursor: grab; }

.rail { position: absolute; left: 12px; top: 12px; z-index: 3; display: flex; flex-direction: column; gap: 2px; padding: 6px; border-radius: 18px; max-height: calc(100% - 24px); overflow-y: auto; scrollbar-width: none; }
.rail .tool {
  width: 54px; padding: 7px 0 5px; margin: 0; border: 0; border-radius: 12px; background: none; color: var(--glass-text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-weight: 600; letter-spacing: 0; text-transform: none; transition: background .15s, transform .1s;
}
.rail .tool small { font-size: 10px; font-weight: 600; color: var(--glass-muted); }
.rail .tool:hover { background: var(--glass-hover); }
.rail .tool:active { transform: scale(.94); }
.rail .tool[aria-pressed="true"] { background: var(--glass-on); color: var(--glass-on-text); }
.rail .tool[aria-pressed="true"] small { color: inherit; }
.rail-sep { height: 1px; margin: 4px 8px; background: var(--glass-line); flex-shrink: 0; }

.zoom-pill { position: absolute; right: 12px; bottom: 12px; z-index: 3; display: flex; align-items: center; border-radius: 999px; padding: 3px; }
.zoom-pill button { border: 0; background: none; color: var(--glass-text); height: 30px; min-width: 30px; border-radius: 999px; display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.zoom-pill button:hover { background: var(--glass-hover); }
.zoom-pill #zoomPct { min-width: 52px; }
.zoom-pill .ico { width: 16px; height: 16px; }

/* layers list */
#layerList { list-style: none; margin: 0 0 12px; padding: 6px; display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow-y: auto; background: var(--ws); border-radius: var(--r-md); }
.lp-empty { color: var(--muted); font-size: 12px; padding: 8px; }
.lp-row { display: flex; align-items: center; gap: 6px; padding: 5px 4px 5px 2px; border-radius: 11px; background: var(--glass); border: 1.5px solid transparent; transition: background .12s, border-color .12s; }
.lp-row.on { background: #eef4ff; border-color: var(--glass-on); }
.lp-row.off .thumb, .lp-row.off .nm { opacity: .45; }
.lp-row.dragging { opacity: .45; }
.lp-row.drop { border-color: var(--glass-on); border-style: dashed; }
.lp-row .grip { color: var(--glass-muted); cursor: grab; touch-action: none; }
.lp-row .grip .ico { width: 14px; height: 18px; stroke-width: 3.2; }
.thumb { width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0; display: grid; place-items: center; overflow: hidden; object-fit: contain;
  background: repeating-conic-gradient(#dedbd2 0 25%, #f6f5f0 0 50%) 0 0/10px 10px; color: #1d2030; box-shadow: inset 0 0 0 1px var(--glass-line); }
.thumb.txt { font: 800 15px Impact, Arial, sans-serif; background: #3a3d52; }
.lp-row .nm { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 2px 4px; color: inherit; }
.lp-row .nm span { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-row .nm small { display: block; font-size: 11px; color: var(--glass-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lp-ic { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 9px; background: none; color: var(--glass-text); flex-shrink: 0; }
.lp-ic:hover { background: var(--glass-hover); }
.lp-ic .ico { width: 17px; height: 17px; }
.lp-row .lock[aria-pressed="false"] { opacity: .3; }
.lp-row .lock[aria-pressed="false"]:hover { opacity: 1; }
.lp-row .lp-ic[aria-pressed="false"]:not(.lock) { color: var(--glass-muted); }

/* properties */
.propHead .thumb { width: 34px; height: 34px; }
.propHead .dk-ic { flex-shrink: 0; }
.psec { border-top: 1px solid var(--line); padding: 12px 0 4px; display: grid; gap: 10px; }
.psec-h { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.psec label { margin: 0; }
.dock-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dk-group { display: inline-flex; gap: 1px; padding: 2px; border-radius: 11px; background: var(--glass-hover); }
.dk-ic { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 9px; background: none; color: var(--glass-text); font-size: 15px; }
.dk-ic:hover { background: rgba(28,28,40,.08); }
.dk-ic[aria-pressed="true"] { background: var(--glass-on); color: #fff; }
.dk-ic .ico { width: 17px; height: 17px; }
.dk-btn { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 6px !important; border: 1.5px solid var(--line); background: #fff; color: var(--ink) !important; border-radius: 10px; padding: 7px 11px; font-weight: 700; font-size: 12.5px !important; cursor: pointer; margin: 0; }
.dk-btn:hover { border-color: var(--glass-on); }
.dk-btn .ico { width: 16px; height: 16px; }
.dk-btn.accent { background: linear-gradient(135deg, #7b5cff, #ff5fa2); color: #fff !important; border-color: transparent; }
.dk-field { flex-direction: row !important; align-items: center; gap: 8px !important; }
.dk-field select { flex: 1; }
.dk-check { flex-direction: row !important; align-items: center; gap: 6px !important; color: var(--ink) !important; }
.dk-check input { width: auto; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); transition: transform .12s; margin: 0; position: relative; }
.sw:hover { transform: scale(1.12); }
.sw[aria-pressed="true"] { box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 0 0 2px #fff, 0 0 0 4px var(--glass-on); }
.sw-any { background: conic-gradient(#ff5a5a, #ffda52, #aff57e, #89e4d7, #89d6ff, #ceacff, #ff71ce, #ff5a5a); overflow: hidden; display: block; cursor: pointer; }
.sw-any input[type=color] { opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.seg-soft { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; border-radius: 11px; background: var(--glass-hover); }
.seg-soft button { flex: 1 1 auto; border: 0; background: none; color: var(--ink); padding: 6px 8px; border-radius: 8px; font-weight: 700; font-size: 12px; }
.seg-soft button[aria-pressed="true"] { background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.16); color: var(--glass-on); }
.sl { display: grid !important; grid-template-columns: 70px 1fr 40px; align-items: center; gap: 8px !important; font-size: 12px !important; color: var(--ink) !important; }
.sl output { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
.sl input[type=range] { -webkit-appearance: none; appearance: none; height: 22px; background: none; margin: 0; width: 100%; }
.sl input[type=range]::-webkit-slider-runnable-track { height: 5px; border-radius: 999px; background: rgba(28,28,40,.12); }
.sl input[type=range]::-moz-range-track { height: 5px; border-radius: 999px; background: rgba(28,28,40,.12); }
.sl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6.5px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.35), 0 0 0 1px rgba(0,0,0,.08); cursor: pointer; }
.sl input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 1px 4px rgba(0,0,0,.35); cursor: pointer; }

@media (max-width: 760px) {
  #canvasStage { flex-wrap: wrap; padding: 8px; gap: 8px; min-height: 0; }
  .rail { position: static; flex-direction: row; width: 100%; overflow-x: auto; border-radius: 16px; padding: 4px; }
  .rail .tool { width: 50px; flex-shrink: 0; }
  .rail-sep { width: 1px; height: auto; margin: 6px 3px; }
  #previewSvg svg { width: min(440px, 86vw); }
  .zoom-pill { position: static; margin: 0 auto; }
}
.propHead { min-width: 0; } .layerNameBig { min-width: 0; width: 100%; }

/* right-click layer menu */
.ctx-menu { position: fixed; z-index: 80; min-width: 210px; padding: 5px; border-radius: 12px; background: rgba(255,255,255,.96); border: 1px solid var(--glass-line); box-shadow: 0 14px 34px rgba(28,28,40,.2); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.ctx-menu[hidden] { display: none; }
.ctx-menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--ink); }
.ctx-menu button:hover, .ctx-menu button:focus-visible { background: var(--glass-on); color: #fff; outline: none; }
.ctx-menu button.danger { color: var(--accent); }
.ctx-menu button.danger:hover { color: #fff; background: var(--accent); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }

/* ================= screens: gallery · editor · info ================= */
body:not([data-screen="gallery"]) [data-only="gallery"],
body:not([data-screen="editor"]) [data-only="editor"],
body:not([data-screen="info"]) [data-only="info"] { display: none !important; }
body:not([data-screen="editor"]) #mobileNav { display: none !important; }
.ed-name { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
#btnGallery .ico { font-size: 20px; line-height: 1; margin-top: -2px; }

/* ================= gallery ================= */
#gallery { flex: 1; padding: 18px clamp(14px, 3vw, 36px) 110px; background: radial-gradient(var(--ws-dot) 1.2px, transparent 1.3px) 0 0/22px 22px, var(--ws); }
.g-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.g-chips { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: rgba(28,28,40,.07); }
.g-chips button { border: 0; background: none; padding: 7px 14px; border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--muted); }
.g-chips button span { font-weight: 600; opacity: .6; margin-left: 2px; }
.g-chips button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.14); }
.g-head .dk-btn { border-radius: 999px; padding: 8px 14px; }
.g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 20px; align-items: start; }
.g-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 0; border: 0; background: none; font: inherit; color: inherit;
  cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: pan-y; outline: none; border-radius: 16px;
}
.g-art {
  width: 100%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 16px; position: relative;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s;
}
.g-art img { max-width: 86%; max-height: 86%; object-fit: contain; border-radius: 5px; box-shadow: 0 6px 18px rgba(28,28,40,.2), 0 1px 3px rgba(28,28,40,.12); background: #fff; pointer-events: none; }
.g-art.g-piece img { border-radius: 50%; background: none; box-shadow: none; filter: drop-shadow(0 6px 10px rgba(28,28,40,.25)); }
.g-art.g-board img { max-width: 94%; }
.g-tile:hover .g-art, .g-tile:focus-visible .g-art { transform: translateY(-3px); }
.g-tile:focus-visible .g-art { box-shadow: 0 0 0 3px var(--glass-on); }
.g-cap { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 100%; }
.g-cap b { font-size: 14px; font-weight: 700; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-cap small { font-size: 11.5px; color: var(--muted); }
/* decks: a fanned stack on a soft tinted tray */
.deck .g-art { background: color-mix(in srgb, var(--deck) 18%, rgba(255,255,255,.7)); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--deck) 45%, transparent); }
.g-stack img { position: absolute; max-width: 62%; max-height: 72%; }
.g-stack img.s0 { transform: rotate(-9deg) translate(-12%, 2%); }
.g-stack img.s1 { transform: rotate(7deg) translate(12%, 1%); }
.g-stack img.s2 { transform: translateY(-3%); }
.g-stack.n1 img.s0 { transform: none; }
.g-stack.n2 img.s1 { transform: rotate(6deg) translate(10%, 0); }
.g-empty-deck { color: var(--muted); font-size: 12px; font-weight: 700; }
.deck .g-cap b::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--deck); margin-right: 6px; vertical-align: 1px; }
/* the + tile */
.g-add .g-art { border: 2px dashed rgba(28,28,40,.18); color: var(--muted); }
.g-add .g-art .ico { width: 34px; height: 34px; }
.g-add:hover .g-art { border-color: var(--glass-on); color: var(--glass-on); }
/* select mode */
.g-check { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; background: rgba(28,28,40,.25); box-shadow: 0 1px 4px rgba(0,0,0,.25); display: grid; place-items: center; color: #fff; }
.g-check .ico { width: 16px; height: 16px; stroke-width: 3; }
.g-tile.picked .g-check { background: var(--glass-on); }
.g-tile.picked .g-art { box-shadow: 0 0 0 3px var(--glass-on); }
.g-selbar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; padding: 8px 10px 8px 16px; border-radius: 18px; max-width: calc(100vw - 24px); }
.g-selbar[hidden] { display: none; }
.dk-btn.danger { color: var(--accent) !important; }
.dk-btn:disabled { opacity: .4; cursor: default; }
.g-note { color: var(--muted); font-size: 12.5px; text-align: center; margin: 22px 0 0; }
/* dragging */
body.g-dragging, body.g-dragging * { cursor: grabbing !important; }
.g-lifted { opacity: .25; }
.g-lifted .g-art { transform: scale(.94); }
.g-ghost { position: fixed; z-index: 90; pointer-events: none; margin: 0; transform-origin: 30% 30%; }
.g-ghost .g-art { box-shadow: 0 22px 44px rgba(28,28,40,.28); background: rgba(255,255,255,.55); }
.g-ghost .g-cap { opacity: 0; }
.g-merge .g-art { transform: scale(1.1); box-shadow: 0 0 0 3px var(--glass-on), 0 14px 30px rgba(47,123,255,.25); background: rgba(47,123,255,.1); }

/* ================= open deck (iOS folder) ================= */
.deck-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(28,28,40,.28); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: g-fade .18s ease; }
.deck-overlay[hidden] { display: none; }
.deck-panel { width: min(760px, 100%); max-height: min(80vh, 760px); overflow: auto; border-radius: 26px; padding: 18px 22px 16px; animation: g-pop .22s cubic-bezier(.2,.9,.3,1.2); border-top: 5px solid var(--deck); }
.deck-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.deck-head #deckName { font-size: 20px; font-weight: 800; border: 0; background: transparent; padding: 4px 6px; border-radius: 8px; min-width: 0; flex: 1 1 180px; }
.deck-head #deckName:hover, .deck-head #deckName:focus { background: rgba(28,28,40,.06); box-shadow: none; }
.deck-colors { display: flex; gap: 4px; }
.deck-colors .sw { width: 22px; height: 22px; }
.deck-panel .g-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 20px 16px; }
@keyframes g-fade { from { opacity: 0; } }
@keyframes g-pop { from { opacity: 0; transform: scale(.9); } }

/* ================= new sheet ================= */
.new-sheet { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(28,28,40,.3); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: g-fade .15s ease; }
.new-sheet[hidden] { display: none; }
.ns-panel { width: min(680px, 100%); max-height: 90vh; overflow: auto; border-radius: 24px; padding: 16px 20px 18px; animation: g-pop .2s cubic-bezier(.2,.9,.3,1.2); }
.ns-head { display: flex; align-items: center; font-size: 18px; margin-bottom: 6px; }
.ns-shape { display: block; background: #fff9eb; border: 2px solid #1c1c28; border-radius: 3px; margin: 2px 0 4px; }
.ns-shape.piece { border-radius: 50%; background: #ffda52; }
.ns-shape.board { background: #89e4d7; }

/* ================= info screen ================= */
#infoPane #btnInfoBack { margin-bottom: 8px; }

@media (max-width: 760px) {
  #gallery { padding: 12px 12px 110px; }
  .g-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 18px 12px; }
  .g-head .dk-btn span { display: none; }
  .ed-name { max-width: 40vw; }
  #layout { display: block; }
  body[data-mview="canvas"] #editorPane { display: block; padding: 10px 10px 24px; }
}
.spacer { flex: 1; }

/* ================= studios, flyouts, tool options ================= */
.studio-switch { display: flex; flex-direction: column; gap: 2px; padding: 3px; margin-bottom: 2px; border-radius: 12px; background: var(--glass-hover); }
.studio-switch button { width: 48px; height: 32px; border: 0; border-radius: 9px; background: none; color: var(--glass-muted); display: grid; place-items: center; }
.studio-switch button .ico { width: 18px; height: 18px; }
.studio-switch button:hover { color: var(--glass-text); }
.studio-switch button[aria-pressed="true"] { background: #fff; color: var(--glass-on); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.studio-name { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--glass-muted); text-align: center; margin: 1px 0 3px; }
.rail .tool { position: relative; }
.fly-tri { position: absolute; right: 4px; bottom: 4px; width: 0; height: 0; border-left: 6px solid transparent; border-bottom: 6px solid currentColor; opacity: .45; padding: 4px; margin: -4px; box-sizing: content-box; background-clip: content-box; }
.rail .tool[aria-pressed="true"] .fly-tri { opacity: .8; }
.tool-fly { position: fixed; z-index: 85; min-width: 200px; padding: 5px; border-radius: 14px; background: rgba(255,255,255,.97); border: 1px solid var(--glass-line); box-shadow: 0 14px 34px rgba(28,28,40,.2); animation: g-pop .14s ease; }
.tool-fly[hidden] { display: none; }
.tool-fly button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 7px 10px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--ink); text-align: left; }
.tool-fly button:hover, .tool-fly button:focus-visible { background: var(--glass-soft-on); outline: none; }
.tool-fly button[aria-pressed="true"] { color: var(--glass-on); }
.tool-fly button span { flex: 1; }
.tool-fly kbd { font: 700 11px var(--ws-font, system-ui); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.tool-opts { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 12px; padding: 6px 14px; border-radius: 999px; max-width: calc(100% - 180px); flex-wrap: wrap; justify-content: center; }
.tool-opts[hidden] { display: none; }
.to-note { font-size: 12px; color: var(--glass-muted); }
.to-note b { color: var(--glass-text); }
.to-sl { grid-template-columns: auto 110px 34px !important; }
.to-color { width: 28px; height: 28px; border-radius: 50%; overflow: hidden; box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px rgba(0,0,0,.2); margin: 0 !important; }
.to-color input { width: 150%; height: 150%; margin: -25%; border: 0; padding: 0; cursor: pointer; }
.to-chip { width: 22px; height: 22px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0,0,0,.2); }
#canvasStage.draw #previewSvg svg, #canvasStage.draw #previewSvg svg * { cursor: crosshair !important; }

/* ================= New dialog ================= */
.ns-kinds { margin: 4px 0 14px; }
.ns-kinds button { flex: 1; padding: 8px 10px; font-size: 13px; }
.ns-body { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; }
.ns-list { display: flex; flex-direction: column; gap: 4px; max-height: 330px; overflow: auto; }
.ns-list button { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 9px 12px; border: 1.5px solid transparent; border-radius: 12px; background: none; text-align: left; }
.ns-list button:hover { background: var(--glass-hover); }
.ns-list button.on { border-color: var(--glass-on); background: #f3f7ff; }
.ns-list button > .ns-shape { justify-self: center; }
.ns-list span { font-weight: 700; font-size: 13.5px; }
.ns-list small { color: var(--muted); font-size: 12px; }
.ns-side { display: flex; flex-direction: column; gap: 10px; }
.ns-preview { height: 150px; display: grid; place-items: center; border-radius: 14px; background: radial-gradient(var(--ws-dot) 1.2px, transparent 1.3px) 0 0/14px 14px, var(--ws); }
.ns-shape { display: block; background: #fff9eb; border: 2px solid #1c1c28; border-radius: 3px; transition: width .15s, height .15s; }
.ns-shape.piece { background: #ffda52; border-radius: 0; }
.ns-shape.piece.m-circle { border-radius: 50%; } .ns-shape.piece.m-rounded { border-radius: 22%; }
.ns-shape.piece.m-hex { clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); border: 0; }
.ns-shape.piece.m-diamond { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); border: 0; }
.ns-shape.board { background: #89e4d7; }
.ns-f { margin: 0 !important; font-size: 11.5px !important; }
.ns-dims { display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: end; gap: 6px; }
.ns-dims .lp-ic { margin-bottom: 4px; font-size: 16px; }
.ns-unit { font-size: 12px; color: var(--muted); margin-bottom: 11px; }
.ns-create { justify-content: center; padding: 11px !important; font-size: 14px !important; margin-top: 4px !important; }
@media (max-width: 760px) {
  .ns-body { grid-template-columns: 1fr; }
  .ns-preview { display: none; }
  .ns-list { max-height: 34vh; }
  .studio-switch { flex-direction: row; margin: 0 4px 0 0; }
  .studio-switch button { width: 34px; }
  .studio-name { display: none; }
  .tool-opts { position: static; transform: none; max-width: 100%; order: 1; border-radius: 16px; }
}
.tool-opts label { margin: 0 !important; flex-direction: row; }
.tool-opts .to-note { max-width: 300px; line-height: 1.3; }
.tool-opts { flex-wrap: nowrap; }
.to-color { flex-shrink: 0; }
