:root{
  /* ===== Colors ===== */
  --bg: #ffffff;
  --surface: #ffffff;

  --text:#111111;
  --muted: rgba(0,0,0,.55);

  --stroke: rgba(0,0,0,.10);
  --stroke2: rgba(0,0,0,.18);

  /* ===== Geometry ===== */
  --radius: 0px;

  --pad: 1%;     /* outer gutter (matches top bar) */
  --gap: 0.5%;   /* inner gap between panels */

  /* ===== Layout widths ===== */
  --leftW: 13%;
  --centerW: 61%;
  --rightW: 23%;
}

body[data-theme="dark"]{
  --bg:#0f0f10;
  --surface:#121212;

  --text:#ffffff;
  --muted: rgba(255,255,255,.62);

  --stroke: rgba(255,255,255,.14);
  --stroke2: rgba(255,255,255,.22);
}

/* ===== Reset ===== */
*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background: var(--bg);
  color: var(--text);

  display:flex;
  flex-direction:column;
  overflow:hidden;
}

/* =========================================================
   TOP BAR
========================================================= */
.osd-topbar{
  margin: var(--pad) !important;
  width: calc(100% - (var(--pad) * 2)) !important;

  background: var(--surface) !important;
  border: none !important;
  border-bottom: 1px solid var(--stroke2) !important;

  border-radius:0 !important;
  box-shadow: none !important;
}

.osd-btn{
  border-radius:0 !important;
  border:1px solid var(--stroke2) !important;
  background: transparent !important;
  color: var(--text) !important;

  font-weight:600;
  padding:6px 10px !important;
}

.osd-btn:hover{
  background: rgba(0,0,0,.04) !important;
}
body[data-theme="dark"] .osd-btn:hover{
  background: rgba(255,255,255,.06) !important;
}

.osd-divider{
  width:1px;
  height:26px;
  background: var(--stroke2);
}

/* =========================================================
   MAIN GRID
========================================================= */
.appGrid{
  margin: 0 var(--pad) var(--pad);
  width: calc(100% - (var(--pad) * 2));

  flex:1;
  min-height:0;

  display:grid;
  grid-template-columns: var(--leftW) var(--centerW) var(--rightW);
  column-gap: var(--gap);
}

/* prevent overflow in grid children */
.panel,
.center{
  min-width:0;
}

/* =========================================================
   PANELS (shared)
========================================================= */
.panel{
  background: var(--surface);
  border-radius:0;
  overflow:hidden;
}

/* left panel */
.panel.left{
  display:flex;
  flex-direction:column;
  min-height:0;
  border:1px solid var(--stroke);
}

/* center column */
.center{
  display:flex;
  flex-direction:column;
  min-height:0;
  gap: var(--gap);
}

/* =========================================================
   PANEL HEAD / FOOT
========================================================= */
.panelHead{
  padding:14px 12px;
  border-bottom:1px solid var(--stroke);
}
.panelTitle{
  font-weight:700;
}
.panelHint{
  font-size:12px;
  color:var(--muted);
  margin-top:4px;
}

.panelFoot{
  padding:12px;
  border-top:1px solid var(--stroke);
}

.tiny{ font-size:12px; }
.muted{ color:var(--muted); }

/* =========================================================
   LEFT PANEL — THUMBNAILS
========================================================= */
.thumbs{
  padding:12px;
  flex:1;
  min-height:0;
  overflow:auto;

  display:flex;
  flex-direction:column;
  gap:12px;
}

/* ✅ Thumbnail base */
.thumb{
  display:grid;
  grid-template-columns: 68px minmax(0,1fr) auto;
  gap:10px;
  align-items:center;

  padding:10px;
  border:1px solid var(--stroke);
  background: transparent;

  /* ✅ make it feel draggable */
  cursor: grab;
  user-select: none;
  -webkit-user-select:none;

  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

/* ✅ Hover effect */
.thumb:hover{
  border-color: var(--stroke2);
  background: rgba(0,0,0,.03);
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  
  /* =========================================================
   THUMBNAIL DRAG + DROP POLISH (SortableJS)
   - shows clear drop location + nicer motion
========================================================= */

/* While you grab an item */
.thumbs .thumb.sortable-chosen{
  cursor: grabbing !important;
  transform: scale(1.01);
  box-shadow: 0 10px 26px rgba(0,0,0,.18);
  border-color: rgba(217,194,108,.85);
  background: rgba(217,194,108,.10);
}
body[data-theme="dark"] .thumbs .thumb.sortable-chosen{
  box-shadow: 0 14px 34px rgba(0,0,0,.55);
  background: rgba(217,194,108,.12);
}

/* The floating “ghost” copy that follows the cursor */
.thumbs .thumb.sortable-drag{
  opacity: .98;
  transform: rotate(-0.35deg) scale(1.02);
}

/* The gap placeholder (where the item will be dropped) */
.thumbs .thumb.sortable-ghost{
  opacity: 0.35;
  background: transparent !important;
  border: 2px dashed rgba(217,194,108,.90) !important;
  box-shadow: none !important;
  transform: none !important;
}

/* A clear “drop line” indicator (thin gold bar) inside the ghost */
.thumbs .thumb.sortable-ghost::before{
  content:"";
  display:block;
  height: 6px;
  margin: 6px 0;
  background: rgba(217,194,108,.95);
}

/* Smooth sibling shifting while dragging */
.thumbs .thumb{
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

/* When Sortable animates reorder */
.thumbs.sortable-animating .thumb{
  transition: transform 160ms ease;
}

/* Optional: reduce “jitter” on drag on some browsers */
.thumbs .thumb *{
  pointer-events: auto;
}

}
body[data-theme="dark"] .thumb:hover{
  background: rgba(255,255,255,.05);
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}

/* ✅ Selected / Active effect (clear!) */
.thumb.active{
  border-color: rgba(217,194,108,.95);
  background: rgba(217,194,108,.10);
  box-shadow: 0 0 0 2px rgba(217,194,108,.55) inset, 0 2px 10px rgba(0,0,0,.10);
}
body[data-theme="dark"] .thumb.active{
  background: rgba(217,194,108,.12);
  box-shadow: 0 0 0 2px rgba(217,194,108,.65) inset, 0 2px 12px rgba(0,0,0,.38);
}

/* ✅ If selected + hover, slightly stronger */
.thumb.active:hover{
  box-shadow: 0 0 0 2px rgba(217,194,108,.70) inset, 0 4px 14px rgba(0,0,0,.14);
}

/* ✅ While dragging (Sortable adds .sortable-ghost / .sortable-chosen often) */
.sortable-chosen{ cursor: grabbing !important; }
.sortable-ghost{
  opacity: .65;
  transform: scale(0.985);
}

/* image box */
.thumbImg{
  width:68px;
  height:68px;
  border:1px solid var(--stroke);
  background:#fff;
}
body[data-theme="dark"] .thumbImg{
  background:#0f0f10;
}

.thumbImg img{
  width:100%;
  height:100%;
  object-fit:cover;
}

/* selected: make preview border pop */
.thumb.active .thumbImg{
  border-color: rgba(217,194,108,.95);
}

.thumbName{
  font-size:13px;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.thumbSub{
  font-size:12px;
  color:var(--muted);
  margin-top:4px;
}

/* tools area */
.thumbTools{
  display:flex;
  gap:8px;
  align-items:center;
}

/* keep your same buttons/classes, but don’t let them look like “drag is only here” */
.iconBtn{
  border:1px solid var(--stroke);
  background: transparent;
  color: var(--text);
  width:32px;
  height:32px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  cursor:pointer;
}
.iconBtn:hover{
  border-color: var(--stroke2);
  background: rgba(0,0,0,.04);
}
body[data-theme="dark"] .iconBtn:hover{
  background: rgba(255,255,255,.06);
}

/* ✅ When hovering buttons, do NOT show grab cursor */
.thumb .iconBtn{ cursor:pointer; }
.thumb .dragHandle{ cursor:grab; } /* still fine if you keep it */
.thumb .delBtn{ cursor:pointer; }

/* add page */
.addPageBtn{
  padding:14px 10px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;

  border:1px dashed var(--stroke2);
  color:var(--muted);
  cursor:pointer;
}

.addPageBtn:hover{
  background: rgba(0,0,0,.03);
  color:var(--text);
}

.addPageBtn.isDrop{
  border-color: rgba(217,194,108,.95);
  background: rgba(217,194,108,.10);
  color: var(--text);
}

/* =========================================================
   CENTER — CANVAS
========================================================= */
.stage{
  flex:1;
  min-height:0;
  border:1px solid var(--stroke);
  position:relative;
}

.canvasWrap{
  width:100%;
  height:100%;
  overflow:auto;
  padding: 2% 16px 16px 16px;

  display:flex;
  align-items:flex-start;
  justify-content:center;
}

canvas{
  border:1px solid var(--stroke);
  background:#ffffff;
}

/* =========================================================
   STATUS BAR
========================================================= */
.statusBar{
  border:1px solid var(--stroke);
  padding:12px;

  display:flex;
  justify-content:space-between;
  align-items:center;
}

.pill{
  border:1px solid var(--stroke);
  padding:6px 10px;
  font-size:12px;
  font-weight:600;
}

/* =========================================================
   RIGHT PANEL — BOOTSTRAP ACCORDION CARDS
========================================================= */
.osd-rightStack{
  padding: 8px;
  overflow: auto;
  min-height: 0;
}

/* Card background: delicate metallic light grey */
.osd-accordion .osd-accItem{
  border: 1px dashed var(--stroke2);
  background: rgba(120,130,150,.10);
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
  margin-bottom: 12px;
}

body[data-theme="dark"] .osd-accordion .osd-accItem{
  background: rgba(170,185,220,.08);
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}

/* No rounded corners anywhere */
.osd-accordion .accordion-item,
.osd-accordion .accordion-button,
.osd-accordion .accordion-body{
  border-radius: 0 !important;
}

/* Header button */
.osd-accBtn{
  background: transparent !important;
  color: var(--text) !important;
  border: none !important;
  box-shadow: none !important;
  padding: 12px 12px !important;
  font-weight: 800;
}

.osd-accBtn:focus{
  box-shadow: none !important;
}

.osd-accTitle{
  display:flex;
  align-items:center;
  gap:6px;
}

/* Body padding */
.osd-accBody{
  padding: 12px !important;
}

/* Dividers inside card */
.osd-accDivider{
  height: 1px;
  background: var(--stroke);
  margin: 10px 0;
}

/* Sub headings inside card */
.osd-subHead{
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Tool rows */
.osd-toolRow{
  display:flex;
  gap:10px;
  align-items:center;
}

.osd-toolRow3 .osd-toolBtn{ flex: 1; }
.osd-toolRow4 .osd-toolBtn{ flex: 1; }

/* Tool buttons */
.osd-toolBtn{
  border: none;
  background: #ffffff;
  color: #111;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-height: 38px;
  user-select: none;
}

body[data-theme="dark"] .osd-toolBtn{
  background: #17181a;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.osd-toolBtn:hover{ filter: brightness(0.98); }
body[data-theme="dark"] .osd-toolBtn:hover{ filter: brightness(1.08); }

.osd-toolBtn.active{
  outline: 2px solid rgba(217,194,108,.85);
  outline-offset: 0;
}

.osd-miniText{ min-width: 64px; }

.osd-angleLine{
  display:flex;
  gap:10px;
  align-items:center;
}

.osd-angleInputWrap{
  position: relative;
  flex: 1;
  min-width: 90px;
}

.osd-angleInput{
  width: 100%;
  border: none;
  background: #ffffff;
  color: #111;
  padding: 10px 34px 10px 12px;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
  border-radius: 0;
  outline: none;
  min-height: 38px;
}

body[data-theme="dark"] .osd-angleInput{
  background: #17181a;
  color: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.osd-angleUnit{
  position:absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 800;
}

.osd-applyLine{ margin-top: 10px; }
.osd-applyBtn{ width: 100%; }

/* =========================================================
   PRESETS (3 per row)
========================================================= */

#presetBwGrid,
#presetGrayGrid{
  display: contents;
}

.osd-presetGrid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
}

.osd-presetBtn{
  border: none;
  background: #ffffff;
  color: #111;
  padding: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.10);
  min-height: 98px;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  justify-content:space-between;
  gap:8px;
  user-select:none;
}

body[data-theme="dark"] .osd-presetBtn{
  background: #17181a;
  color:#fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}

.osd-presetBtn:hover{ filter: brightness(0.98); }
body[data-theme="dark"] .osd-presetBtn:hover{ filter: brightness(1.08); }

.osd-presetBtn.active{
  outline: 2px solid rgba(217,194,108,.85);
  outline-offset: 0;
}

.osd-presetImg{
  width:100%;
  height: 58px;
  border: 1px solid var(--stroke);
  background: rgba(0,0,0,.02);
  overflow:hidden;
}

body[data-theme="dark"] .osd-presetImg{
  background: rgba(255,255,255,.03);
}

.osd-presetImg img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.osd-presetName{
  font-size: 12px;
  font-weight: 800;
  text-align:center;
  color: var(--muted);
  letter-spacing: .01em;
}

.osd-presetFoot{ text-align:center; }

/* =========================================================
   MOBILE
========================================================= */
@media (max-width: 980px){
  body{ overflow:auto; }
  .appGrid{ grid-template-columns: 1fr; }
}



