:root {
--ink:#e8e8e8;
--ink-d:#b9b9b9;
--p1:#171717;
--p2:#141414;
--line:#2a2a2a;
--acc:#7bdcff
}
* {
	box-sizing: border-box
}
html, body {
	height: 100%
}
body {
	margin: 0;
	background: #121212;
	color: var(--ink);
	font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif
}
.app {
	display: grid;
	gap: 12px;
	padding: 12px
}

/* === TOP BAR LOGO / BRAND ============================= */

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

.bar .logo {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 10px;
  display: block;
}

.bar {
	display: flex;
	gap: 12px;
	align-items: center;
	padding-top: 3px;
	padding-bottom: 2px;
	padding-left: 12px;
	padding-right: 12px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: #1b1b1b
}
.brand {
	font-weight: 700;
	text-transform: uppercase;
}
/* === BRAND TITLE — MOBILE WRAP FIX ==================== */
@media (max-width: 480px) {
  .bar .brand {
    white-space: normal;       /* allow wrapping */
    overflow-wrap: anywhere;   /* break long words if needed */
	text-transform: uppercase;
    text-wrap: balance;        /* optional, nice in modern browsers */
	text-transform: uppercase;
  }
}
.ver {
	color: #888;
	font-size: 11px;
	margin-left: 6px
}
.liveLib {
	margin-left: auto;
	color: #cacaca
}
.liveLib b {
	opacity: .85
}
.tool {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: nowrap;   /* default: single row */
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 10px 12px;
	background: var(--p1)
}
@media (max-width: 1024px) {
  .tool {
    flex-wrap: wrap !important;
    row-gap: 8px;
  }
}

/* === ZOOM CONTROL (DESKTOP) ========================================== */
.zoomCtl{
  display:flex;
  align-items:center;
  gap:8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--p2);
}
.zoomLbl{
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .02em;
}
#zoomRange{
  width: 140px;
}
#zoomSel{
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--p1);
  color: var(--ink);
  padding: 0 10px;
}
.zoomPct{
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

/* Mobile: hide zoom UI (pinch handles zoom) */
@media (max-width: 640px){
  #zoomCtl{ display:none; }
}


button, .btn {
	background: #202020;
	color: var(--ink);
	border: 1px solid var(--line);
	padding: 7px 12px;
	border-radius: 8px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 8px
}
button:disabled {
	opacity: .5;
	cursor: not-allowed
}
.on {
	outline: 2px solid var(--acc)
}
.div {
	width: 1px;
	height: 24px;
	background: var(--line);
	margin: 0 4px
}
.fileline {
	height: 36px;
	padding: 0 12px;
	display: flex;
	align-items: center;
	gap: 12px;
	border: 1px dashed var(--line);
	border-radius: 8px;
	color: #acacac;
	font-size: 13px;
	min-width: 0}

/* === FILELINE (IN TOP BAR) =========================================== */
.fileline--top{
  max-width: 42vw;
  height: 34px;
  padding: 0 10px;
  border-style: solid;
  border-radius: 10px;
  background: var(--p2);
  color: var(--ink);
  gap: 8px;
}

.fileline--top .filelabel{
  font-size: 12px;
  color: var(--muted);
}

.fileline--top .filetext{
  display: inline-block;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 1024px){
  .fileline--top{
    max-width: 60vw;
  }
}
.live {
	display: flex;
	align-items: center;
	gap: 10px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: #181818;
	padding: 6px 10px;
	min-height: 36px
}
/* === LIVE COLOR (TOP BAR) — FIXED WIDTH + ELLIPSIS ================== */
/* Prevents the right-side "Current" badge from expanding/shrinking and
   keeps long user-defined names from running off-screen. */

.live .live-text{
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  width: 30ch;       /* enough for: "#FFFFFF — RGB(255,255,255)" */
  min-width: 30ch;
}

#liveTitle,
.live-title{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#liveName,
.live-name{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

/* Mobile: allow a bit more room for buttons */
@media (max-width: 680px){
  .live .live-text{
    width: 24ch;
    min-width: 24ch;
  }
}

.chip {
	width: 22px;
	height: 22px;
	border-radius: 5px;
	border: 1px solid rgba(255,255,255,.15);
	cursor: pointer
}
.main {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 12px;
  padding: 12px;
}

.main > * {
  min-width: 0;
}

/* Palette JSON Sorter — tiny inline icon, same height as Color Basics */
#btnPaletteSorter {
  text-decoration: none;          /* keep it looking like a button, not a link */
}

#btnPaletteSorter .btn-icon-img {
  width: 14px;
  height: 14px;
  margin-right: 6px;
  vertical-align: text-bottom;
  display: inline-block;
}

/* Stack into one column on narrower screens */
@media (max-width: 980px) {
  .main {
    grid-template-columns: 1fr;
  }
}

/* === MAIN GRID — MOBILE PADDING FIX =================== */
@media (max-width: 900px) {
  .main {
    padding: 0;   /* cv/grid now same width as .bar/.tool */
    /* gap stays 12px from the base rule */
  }
}

.canvas-shell {
	position: relative;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: #222;
	height: 70vh;
	min-height: 360px;
	overflow: hidden
}
.canvas-wrap {
	position: relative;
	width: 100%;
	height: 100%;
	overflow: auto;
	border-radius: 12px;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-x pan-y;
	overscroll-behavior: contain
}
.canvas-wrap.eyedrop, .canvas-wrap.area {
	touch-action: none;
	cursor: crosshair
}
canvas {
	position: relative;
	z-index: 1;
	display: block;
	background: transparent;
}
.overlay {
	position: absolute;
	inset: 0;
	border-radius: 12px;
	pointer-events: none;
	z-index: 20
}

.hline,
.vline {
	position: absolute;
	background: rgba(216,222,234,.65); /* single, solid line */
}

/* Horizontal crosshair */
.hline {
	left: 0;
	width: 100%;
	height: 1px;
}

/* Vertical crosshair */
.vline {
	top: 0;
	height: 100%;
	width: 1px;
}

.hud {
	position: absolute;
	padding: 6px 8px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #0f0f0f;
	opacity: .92;
	min-width: 140px;
	display: none
}
.hud .chip {
	width: 18px;
	height: 18px;
	border-radius: 4px
}
#marq {
	position: absolute;
	border: 1px dashed rgba(255,255,255,.85);
	background: rgba(255,255,255,.05);
	display: none;
	border-radius: 2px
}

/* === SIDEBAR — CHROME & LAYOUT ======================== */

.side {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 70vh;
  overflow: hidden;
}

/* Header row ("Active Swatches") */
.side .hd {
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #171717;
  font-weight: 600;
}

/* Toolbar row (Add / Import JSON / Clear All) */
.side .sticky {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--panel, #121212);
  border-bottom: 1px solid var(--line);
}

.side .sticky .inner {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}

/* Scrollable swatch list */
.side .bd {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

/* === SIDEBAR — MOBILE BEHAVIOUR ======================= */
@media (max-width: 900px) {
  /* stop sticking on mobile */
  .side .sticky {
    position: static;
    top: auto;
    z-index: auto;
  }

  /* small breathing room under the palette bar */
  .side {
    margin-top: 8px;
  }
}


.swlist {
	padding: 10px 12px
}
.row {
	display: grid;
	grid-template-columns: 24px 1fr auto;
	gap: 10px;
	align-items: center;
	border: 1px solid var(--line);
	border-radius: 8px;
	padding: 6px 8px;
	margin-bottom: 6px;
	background: #181818;
	cursor: pointer
}
.row .chip {
	width: 24px;
	height: 24px;
	border-radius: 6px
}
.meta {
	color: #a9b1c2
}
.row.sel {
	outline: 2px solid var(--acc);
	box-shadow: 0 0 0 2px rgba(123,220,255,.15)
}
.acts {
	display: flex;
	gap: 6px
}
.ib {
	width: 28px;
	height: 28px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #1d1d1d;
	padding: 0
}
.ib svg {
	width: 14px;
	height: 14px
}
.ib.del:hover {
	background: #281616;
	border-color: #3a2323
}
.footer {
	border: 1px solid var(--line);
	border-radius: 12px;
	background: #151515
}
.fhd {
	padding: 10px 12px;
	border-bottom: 1px solid var(--line);
	font-weight: 600
}
/* === FOOTER INFO BLOCKS GRID === */

.infoGrid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 14px;
}

@media (min-width: 820px){
  .infoGrid{
    grid-template-columns: 1fr 1fr; /* 2×2 on desktop */
    gap: 14px;
  }
}

.info-block{
  background: #1b1b1b;
  border: 1px solid #2a2a2f;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
}

.info-block h3{
  margin: 0 0 6px 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #e8e8ec;
}

.info-block p{
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: #cfcfda;
}

/* === COPYRIGHT LINE === */

.copyright{
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #24242a;
  font-size: 11px;
  color: #8d8d98;
  text-align: center;
}


/* === GUIDE BUTTONS ON MOBILE === */
@media (max-width: 900px){
  .fhd{
    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-top:8px;
  }
}
@media (max-width: 820px) {
  .fhd .guideBtn,
  .fhd .colorBasicsBtn {
    display: inline-flex;   /* force them back on */
  }
}
.fbd {
	padding: 10px 12px
}
.grid5 {
	display: grid;
	grid-template-columns: repeat(6, 1fr)
}
@media (max-width:880px) {
.grid5 {
	grid-template-columns: 1fr
}
}
.gi {
	padding: 12px;
	border-top: 1px solid var(--line)
}
.kbd {
	font: 600 11px/1 ui-monospace, Menlo, Consolas, monospace;
padding:.25rem .45rem;
	border-radius: 6px;
	border: 1px solid #404040;
	background: #202020
}
@media (pointer:coarse) {
.footer {
	display: none
}
}
.menuwrap {
	position: relative
}
.menu {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 60;
	display: none;
	border: 1px solid var(--line);
	background: #0f0f0f;
	border-radius: 10px;
	padding: 6px;
	box-shadow: 0 8px 28px rgba(0,0,0,.45);
	min-width: 320px
}
.menu.open {
	display: block
}
.menu .item {
	display: block;
	width: 100%;
	text-align: left;
	padding: 8px 10px;
	border-radius: 8px;
	border: 1px solid transparent;
	background: transparent;
	color: var(--ink);
	cursor: pointer
}

/* Export menu helpers (labels + separators) */
.menu .sep {
	height: 1px;
	margin: 6px 6px;
	background: var(--line);
	opacity: .7
}
.menu .menuLabel {
	padding: 6px 10px 2px;
	font-size: 11px;
	letter-spacing: .08em;
	text-transform: uppercase;
	color: rgba(232,232,236,.7)
}
.back {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,.55);
	z-index: 90;
	display: none;
	align-items: center;
	justify-content: center
}
.back.show {
	display: flex
}
.modal {
	position: fixed;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	width: min(860px, calc(100dvw - 24px));
	max-width: calc(100dvw - 24px);
	max-height: calc(100dvh - 40px);
	background: #121212;
	border: 1px solid var(--line);
	border-radius: 12px;
	z-index: 110;
	overflow: hidden;
	display: none;
	flex-direction: column
}
.modal.show {
	display: flex
}
.modal .body {
	padding: 12px;
	overflow: auto;
	-webkit-overflow-scrolling: touch;
	max-height: min(calc(100dvh - 96px), calc(100vh - 96px))
}
.mgrid {
	display: grid;
	gap: 12px
}
.mrow {
	display: grid;
	grid-template-columns: 110px 1fr 100px;
	gap: 10px;
	align-items: center
}
@media (max-width:520px) {
.mrow {
	grid-template-columns: 90px 1fr 90px
}
}
.slider {
	appearance: none;
	width: 100%;
	height: 6px;
	border-radius: 4px;
	background: #232323
}
.slider::-webkit-slider-thumb {
appearance:none;
width:14px;
height:14px;
border-radius:50%;
background:#e8e8e8;
border:1px solid #444
}
.rval {
	font-variant-numeric: tabular-nums;
	text-align: right;
	opacity: .85
}
.nameRow {
	display: grid;
	grid-template-columns: 110px 1fr 120px;
	gap: 10px;
	align-items: center
}
.auto {
	display: flex;
	align-items: center;
	gap: 8px;
	opacity: .9
}
.sugg {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	max-height: 192px;
	overflow: auto
}
.sugg .sitem {
	display: flex;
	align-items: center;
	gap: 8px;
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 6px 8px;
	background: #161616;
	cursor: pointer
}
.sugg .chip {
	width: 16px;
	height: 16px;
	border-radius: 4px;
	border: 1px solid rgba(255,255,255,.15)
}
.chipWrap {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	position: relative
}
#mixColor {
	height: 36px
}
#mixChipBtn {
	display: none
}
@media (max-width:640px) {
.chipWrap {
	width: 42px;
	height: 42px
}
#mixChipBtn {
	display: inline-flex;
	width: 42px;
	height: 42px;
	padding: 2px;
	border: none;
	border-radius: 6px;
	background: conic-gradient(red, #ff0, #0f0, #0ff, #00f, #f0f, red)
}
#mixChipBtn .inner {
	width: 100%;
	height: 100%;
	border-radius: 6px;
	background: #181818
}
#mixColor {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	appearance: none;
	border: 0;
	margin: 0;
	padding: 0;
	pointer-events: auto;
	z-index: 2
}
}
.status {
	border: 1px solid var(--line);
	border-radius: 12px;
	padding: 8px 12px;
	background: #141414
}
.toast {
	position: fixed;
	left: 50%;
	bottom: 16px;
	transform: translateX(-50%);
	display: none;
	align-items: center;
	gap: 10px;
	background: #0f0f0f;
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 8px 12px;
	z-index: 140
}
.toast.show {
	display: flex
}
.toast button {
	padding: 6px 10px;
	border-radius: 8px;
	background: #1f2937;
	color: #e8e8e8;
	border: 1px solid #394150
}
.libGrid {
	display: grid;
	grid-template-columns: 280px 1fr;
	gap: 12px
}
@media (max-width: 820px) {
  .libGrid {
    grid-template-columns: minmax(0, 1fr);   /* single column on mobile */
  }
}
@media (max-width:760px) {
.libGrid {
	grid-template-columns: 1fr
}
}

.libList {
	border: 1px solid var(--line);
	border-radius: 10px;
	overflow: auto;
	min-height: 240px
}
.libItem {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 10px 12px;
	border-bottom: 1px solid var(--line);
	cursor: pointer
}
.libItem.active {
	background: #182027;
	border-left: 2px solid var(--acc)
}
.libPrev {
	display: grid;
	grid-template-columns: repeat(8, 14px);
	gap: 6px
}
.libPrev span {
	width: 14px;
	height: 14px;
	border-radius: 3px;
	border: 1px solid rgba(255,255,255,.1)
}
.libPanel {
	border: 1px solid var(--line);
	border-radius: 10px;
	overflow: hidden
}
.libPanel .hd2 {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-bottom: 1px solid var(--line);
	background: #171717
}
.libPanel .bd2 {
	padding: 12px
}
.libChips {
	display: grid;
	grid-template-columns: repeat(8, 1fr);
	gap: 6px
}
.libChip {
	height: 26px;
	border-radius: 6px;
	border: 1px solid rgba(255,255,255,.15)
}
.canvas-shell {
	position: relative;
	background: #222;
	overflow: hidden;
	border-radius: 12px;
}
.canvas-shell::before {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	z-index: 0;
	background: repeating-linear-gradient(0deg, #333 0 1px, transparent 1px 16px), repeating-linear-gradient(90deg, #333 0 1px, transparent 1px 16px);
}
#marq, #marquee, .marquee, .area-marquee, #guideH, #guideV, .guide-h, .guide-v, #crossX, #crossY {
	position: absolute;
	pointer-events: none;
	z-index: 20;
}
#marq, #marquee, .marquee, .area-marquee {
	box-shadow: 0 0 0 1px rgba(255,255,255,.95), 0 0 0 2px rgba(0,0,0,.95);
	background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.18) 0 6px, rgba(0,0,0,.18) 6px 12px);
	background-size: 24px 24px;
	animation: pgMarqueeStripes 1s linear infinite;
}
@keyframes pgMarqueeStripes {
 from {
background-position: 0 0;
}
to {
	background-position: 24px 0;
}
}
/* === 82 Update: static, lighter marquee stripes; shell bg #202020 === */
.canvas-shell {
	background: #202020 !important;
}
#marq, #marquee, .marquee, .area-marquee {
	/* keep dual outline for contrast */
	box-shadow: 0 0 0 1px rgba(255,255,255,.95), 0 0 0 2px rgba(0,0,0,.95);
	/* full-coverage diagonal stripes, lighter (more transparent) */
	background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.10) 0 6px, rgba(0,0,0,0.10) 6px 12px);
	background-size: auto !important;
	/* no animation */
	animation: none !important;
}

/* 94d: Mobile circular reticle (enhanced: longer lines, dot on top) */
#reticle {
	position: absolute;
	width: 44px;
	height: 44px;
	margin-left: -22px;  /* center on point */
	margin-top: -22px;
	border-radius: 50%;
	border: 2px solid rgba(216,222,234,.85);
	box-shadow: 0 0 0 2px rgba(0,0,0,.25) inset, 0 0 0 1px rgba(0,0,0,.35);
	display: none;
	z-index: 25;
}
#reticle::before, #reticle::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 50%;
	width: 72px;
	height: 2px;     /* extended beyond outer circle */
	margin-left: -36px;
	margin-top: -1px;
	background: rgba(216,222,234,.85);
	border-radius: 2px;
	box-shadow: 0 0 0 1px rgba(0,0,0,.35);
}
#reticle::after {
	transform: rotate(90deg);
}
/* Center dot element explicitly present in DOM so it sits above ::before/::after */
#reticle .dot {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 6px;
	height: 6px;
	margin-left: -3px;
	margin-top: -3px;
	background: rgba(216,222,234,.98);
	border-radius: 50%;
	box-shadow: 0 0 0 1px rgba(0,0,0,.45);
	z-index: 1;
}
@media (pointer:coarse) {
#reticle {
	display: block;
}

  /* Sausage chip width on mobile */
  #paletteBar { --chip-w: 84px; }
.hline, .vline {
	display: none !important;
}
}
/* === TOOL STRIP BORDER LIGHTEN === */
.tool {
  /* if your components use CSS variables, this flips them to the lighter tone */
  --line: #3b3b3b;
 --stroke: #616161;
 --stroke-2:#616161;
}


/* === PG-Pro Toolbar — Base Borders ===================== */

/* Give everything in the tool row a consistent base border */
.tool :is(
  button,
  .btn,
  .menuwrap .menu,
  .menuwrap .item,
  .live,
  .fileline,
  .chip,
  .div
) {
  border-color: #616161;
}

/* Dashed separators in the row */
.tool .div {
  border-top-color: #616161;
  border-bottom-color: #616161;
}

/* === PG-Pro Toolbar — Hover Ring (All Buttons) ========= */

/* Default transition on all toolbar buttons */
.tool :is(button, .btn, .menuwrap > button) {
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

/* Blue hover ring for ALL toolbar buttons (including Area) */
.tool :is(button, .btn, .menuwrap > button):hover {
  outline: 0 !important;
  box-shadow: 0 0 0 2px rgba(106, 163, 255, 0.35) inset !important;
  border-color: #6aa3ff !important;
}

/* Optional: keep the file input line “flat” if you prefer */
.tool .fileline:hover {
  box-shadow: none !important;
  border-color: #616161 !important;
}

/* (Leave these if they were working for you) */
.pg-lib-menu {
  z-index: 120;
}
.libItem.sel {
  background: #182027;
}
.libItem.active {
  border-left: 2px solid #6aa3ff;
}



/* Ensure sausage "Save palette…" menu anchors to the viewport, not the scrolled canvas */
.addlib-menu {
	position: fixed;
}
.addlib-menu {
	position: fixed;     /* anchor to viewport */
	z-index: 140;        /* above sausage and overlays */
	max-height: 50vh;    /* scroll if long */
	overflow: auto;
}
/* --- Libraries modal: stop right header from overlaying the left list --- */
.libGrid {
	position: relative;
}
.libList {
	position: relative;
	z-index: 2;                 /* always above the right panel */
	background: #0f0f0f;        /* prevents see-through edges */
}
.libPanel {
	position: relative;
	z-index: 1;
	overflow: hidden;           /* keep its header inside the column */
}
/* keep the right header pinned, but under the left list */
.libPanel .hd2 {
	position: sticky;
	top: 0;
	z-index: 1;
	background: #171717;
}
/* Libraries modal — lock columns so the left list is always on top */
.libGrid {
	display: grid;               /* already true, but harmless to repeat */
	grid-template-columns: 280px 1fr;  /* ensure fixed left col */
	position: relative;
	isolation: isolate;          /* new stacking context for children */
}
.libList {
	position: relative;
	z-index: 3;                  /* highest inside the grid */
	pointer-events: auto;
	background: #0f0f0f;         /* prevents any see-through */
}
.libPanel {
	position: relative;
	z-index: 1;                  /* always under the left column */
	overflow: hidden;            /* clip anything sticky inside */
}
/* Keep right header inside its column and beneath the left list */
.libPanel .hd2 {
	position: sticky;
	top: 0;
	z-index: 1;
	background: #171717;
	width: auto;                 /* avoid accidental full-width */
	max-width: 100%;
}
/* Libraries modal: clear, visible active state in the left list */
.libList .libItem {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 10px 12px;
	border-bottom: 1px solid var(--line);
	cursor: pointer;
	user-select: none;
}
.libList .libItem:hover {
	background: #161a20;
}
.libList .libItem.active {
	background: #182027;
	border-left: 2px solid var(--acc);
}
/* Keep columns independent; left list must be on top for clicks */
.libGrid {
	position: relative;
	isolation: isolate;
}
.libList {
	position: relative;
	z-index: 3;
	background: #0f0f0f;
}
.libPanel {
	position: relative;
	z-index: 1;
	overflow: hidden;
}
.libPanel .hd2 {
	position: sticky;
	top: 0;
	z-index: 1;
	background: #171717;
}

/* Right-pane preview grid */
.libPreviewGrid{
  display: grid;
  grid-template-columns: repeat(12, minmax(18px, 1fr));
  gap: 6px;
  align-items: start;
}
@media (max-width: 1200px){
  .libPreviewGrid{ grid-template-columns: repeat(10, minmax(18px,1fr)); }
}
@media (max-width: 900px){
  .libPreviewGrid{ grid-template-columns: repeat(8, minmax(18px,1fr)); }
}
.libChip{
  height: 22px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  cursor: pointer;
}
.libEmpty{
  opacity:.75; font-size:13px; padding:6px 0;
}

.libList{ overflow:auto; max-height: 360px; }
.libRow{
  display:flex; align-items:center; justify-content:space-between;
  gap:8px; padding:10px 12px; border-bottom:1px solid var(--line);
  cursor:pointer; background:#171717;
}
.libRow.active{
  background:#182027;
  box-shadow: inset 2px 0 0 #6aa3ff;
}

/* Keep the left column scrollable */
#libList, .libList { max-height: 420px; overflow: auto; }

/* Make the selected palette obvious */
.libItem.active { background:#182027; border-left:2px solid #6aa3ff; }

/* left list */
.pgp-lib-left{min-width:260px; max-height:56vh; overflow:auto; border-right:1px solid #24242a; padding:8px;}
.pgp-lib-item{padding:8px 10px; border-radius:8px; margin:4px 0; background:#1b1b22; border:1px solid #30303a; color:#e8e8ec; cursor:pointer}
.pgp-lib-item.is-active{outline:2px solid #6aa3ff}

/* right panel */
.pgp-lib-right{padding:12px; max-height:56vh; overflow:auto;}
.pgp-lib-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:10px}
.pgp-title{font-weight:600; color:#e8e8ec}
.pgp-lib-ctrls{display:flex; gap:8px; margin-bottom:10px}
.pgp-btn{padding:6px 10px; border-radius:10px; background:#1b1b22; border:1px solid #30303a; color:#e8e8ec}

/* chips */
.pgp-chip{min-width:88px; padding:6px 10px; margin:5px; border-radius:10px; background:#1b1b22; border:1px solid #30303a; color:#e8e8ec}
.pgp-chip-row{display:flex; flex-wrap:wrap}


.pgp-modal-body{display:grid;grid-template-columns:280px 1fr;gap:12px;max-height:56vh;overflow:hidden}
.pgp-lib-left{overflow:auto;border-right:1px solid #24242a;padding:8px}
.pgp-lib-right{overflow:auto;padding:12px}

#fname.fileline{
  flex:1 1 auto;
  min-width:0;
  display:flex;
  align-items:center;
  padding:0 12px;
  line-height:1;
  opacity:.85;
}

#fname .filetext{
  flex:1 1 auto;      /* take the space */
  min-width:0;        /* allow shrinking */
  overflow:hidden;
  white-space:nowrap;
  text-overflow:ellipsis;  /* shows … */
}

/* === Uppercase HEX everywhere it’s displayed === */
/* === PG-Pro: show all HEX values in uppercase (names unaffected) === */
#mixHex,                 /* main mixer HEX input */
.sqm-hex,                /* quick mixer HEX input */
#hudVals, #liveVals,     /* HUD + live readout under canvas */
.swlist .code,           /* sidebar row “#abc123 — rgb(…)” hex part */
.chip .hex,              /* any inline hex label in chips */
.sugg .shex,             /* mixer suggestion pills’ hex text */
#paletteBar .chip::after /* legacy sausage hex label, if ever re-enabled */
{
  text-transform: uppercase;
}

/* Force uppercase HEX inside mixer Suggestions row */
.sugg .sitem .shex {
  text-transform: uppercase !important;
}

/* Force uppercase HEX in mixer Suggestions (the (#ad1f1f) bits) */
.sugg .shex {
  text-transform: uppercase !important;
}

/* Uppercase the small HEX text inside Suggestions */
.sugg small {
  text-transform: uppercase !important;
}

/* === COLOR THEORY BASICS BOX === */

.ctBasics {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
}

.ctBasics[hidden] {
  display: none;
}

.ctBasics-inner {
  background: var(--panel, #111116);
  border: 1px solid var(--stroke, #30303a);
  border-radius: 12px;
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 18px 40px rgba(0,0,0,0.6);
}

.ctBasics-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--stroke, #30303a);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ctBasics-head h2 {
  margin: 0;
  font-size: 16px;
  color: var(--ink, #e8e8ec);
}

.ctBasics-close {
  border: 0;
  background: var(--panel2, #1b1b22);
  color: var(--ink, #e8e8ec);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
  font-size: 14px;
}

.ctBasics-body {
  padding: 14px 16px 16px;
  overflow-y: auto;
  font-size: 13px;
  color: var(--ink, #e8e8ec);
}

.ctBasics-body h3 {
  margin: 10px 0 4px;
  font-size: 13px;
}

.ctBasics-body p {
  margin: 4px 0 8px;
}

.ctBasics-body ul {
  margin: 0 0 8px 18px;
  padding: 0;
}

/* /////////////////////////////////////////////////////// */
/* /// ALL PALETTEBAR CODE GROUPED BELOW  /// */
/* /////////////////////////////////////////////////////// */

/* === PALETTE BAR — BASE LAYOUT & VISUALS ============== */

#paletteBar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: auto;

  display: flex;
  flex-direction: column;
  gap: 8px;

  max-width: min(96vw, 1100px);
  background: rgba(17,17,22, 0.92);
  border: 1px solid var(--line);
  border-color: #4a4a4a;
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  /* default chip width; tweak here if you want them narrower/wider */
  --chip-w: 140px;
}
/* Palette bar sits just under the canvas, with a small gap */
@media (max-width: 900px) {
  #paletteBar {
    position: static !important;
    transform: none !important;
    margin: 8px 0 6px;   /* top | sides | bottom */
    width: 100%;
    max-width: none;
	border: 4px solid var(--line);
	border-color: #8c8c8c;
	box-shadow: 0 14px 40px rgba(0,0,0,0.75);
  }

  .side {
    margin-top: 0;       /* remove extra offset if we added it earlier */
  }
}

/* === PALETTE BAR — ANALYZER TITLE ========================= */
#paletteBar .anTitle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px; /* space between text and lines */

  /* You can tweak all of these to taste */
  font-size: 12px; /* title size */
  font-weight: 600;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: #e8e8ec;
  padding: 0px 0;  /* vertical breathing room */
  margin-bottom: 4px; /* gap before the controls */
}

/* Lines on either side of "Color Analyzer" */
#paletteBar .anTitle::before,
#paletteBar .anTitle::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
}

/* Left line: fade from outer edge → solid near title */
#paletteBar .anTitle::before {
  background: linear-gradient(
    to right,
    rgba( var(--line-r, 48), var(--line-g, 48), var(--line-b, 58), 0 ) 0%,
    var(--line) 35%,
    var(--line) 100%
  );
}

/* Right line: fade from outer edge → solid near title */
#paletteBar .anTitle::after {
  background: linear-gradient(
    to left,
    rgba( var(--line-r, 48), var(--line-g, 48), var(--line-b, 58), 0 ) 0%,
    var(--line) 35%,
    var(--line) 100%
  );
}

/* === COLOR ANALYZER TITLE — DESKTOP LINE TINT ========= */
@media (min-width: 901px) {
  /* Left line: outer fade → lighter solid near title */
  #paletteBar .anTitle::before {
    background: linear-gradient(
      to right,
      rgba(77,77,77,0) 0%,          /* transparent outer edge */
      rgba(77,77,77,0.7) 35%,       /* lighter line */
      rgba(77,77,77,0.7) 100%
    );
  }

  /* Right line: mirror */
  #paletteBar .anTitle::after {
    background: linear-gradient(
      to left,
      rgba(77,77,77,0) 0%,
      rgba(77,77,77,0.7) 35%,
      rgba(77,77,77,0.7) 100%
    );
  }
}

/* === COLOR ANALYZER TITLE — MOBILE LINE OVERRIDE ======== */
@media (max-width: 900px) {
  #paletteBar .anTitle {
    color: #ffffff; /* title text white on mobile */
  }

  /* Left line: fade from outer edge -> solid near title */
  #paletteBar .anTitle::before {
    background: linear-gradient(
      to right,
      rgba(255,255,255,0) 0%,
      rgba(255,255,255,0.85) 35%,
      rgba(255,255,255,0.85) 100%
    );
  }

  /* Right line: fade from outer edge -> solid near title */
  #paletteBar .anTitle::after {
    background: linear-gradient(
      to left,
      rgba(255,255,255,0) 0%,
      rgba(255,255,255,0.85) 35%,
      rgba(255,255,255,0.85) 100%
    );
  }
}

/* === END OF PALETTE BAR — ANALYZER TITLE ========================= */

/* === PALETTE BAR — MOBILE POSITION + SPACING ========= */
/* === PALETTE BAR — MOBILE BEHAVIOUR =================== */
@media (max-width: 900px) {
  #paletteBar {
    position: static !important;    /* no absolute overlay */
    transform: none !important;
    z-index: auto !important;       /* drop special stacking */
    width: 100%;
    max-width: none;

    /* give the swatch list some breathing room below */
    margin: 8px 0 20px;             /* top | sides | bottom */
  }

  .side {
    margin-top: 0;                  /* let the bar's margin create the gap */
  }
}




#paletteBar .ctrls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
  align-self: center;
}

/* Dropdowns in the analyzer bar */
#paletteBar .sel {
  background: #202020;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 7px 8px;
  border-radius: 10px;
  appearance: none;
}

/* Toggle groups (Cool/Warm etc.) */
#paletteBar .toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #202020;
}

#paletteBar .toggle input {
  accent-color: var(--acc);
}

/* Diversity slider container */
#paletteBar .range {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #202020;
}

/* Diversity slider track */
#divRange {
  flex: 0 0 auto;
  width: 97px;          /* adjust here if you want shorter/longer */
  max-width: 20vw;
}

/* Numeric readout for Diversity */
#divVal {
  display: inline-block;
  width: 3ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Slightly dim the Color Analyzer toggle when “off” */
#toggleAnalyzer[aria-pressed="false"] {
  opacity: 0.85;
}

/* === PALETTE BAR — SWATCH FILMSTRIP =================== */

#paletteBar .swatches {
  margin-top: 6px;
}

/* Only this track scrolls horizontally – not the buttons */
#paletteBar .swatchesTrack {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

/* Chips in the sausage (desktop baseline) */
#paletteBar .chip {
  flex: 0 0 var(--chip-w, 140px);
  min-width: var(--chip-w, 140px);
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  position: relative;
  box-sizing: border-box;
}

/* Sausage chips: use the in-chip <span> label, not the ::after hex */
#paletteBar .chip::after {
  content: none !important;
}

/* === STACKING WITH CANVAS / HUD / CROSSHAIRS ========= */

/* Let the HUD and sausage spill over the canvas nicely */
.canvas-shell {
  overflow: visible !important;
}

/* Local stacking context for overlay, crosshairs, palette bar, HUD */
#wrap {
  position: relative;
}

/* Crosshair overlay layer */
.overlay,
#hl,
#vl {
  z-index: 10 !important;
  pointer-events: none;
}
/* === CROSSHAIRS — MOBILE ============================== */
@media (max-width: 900px) {
  /* Hide crosshair lines */
  .overlay .hline,
  .overlay .vline,
  #hl,
  #vl {
    display: none !important;
  }

  /* Keep the reticle visible and on top */
  #reticle {
    display: block;
  }
}

/* HUD card sits above everything except toasts */
.hud {
  z-index: 130 !important;
}

/* Sausage above crosshairs but below HUD */
#paletteBar {
  z-index: 60 !important;
}

/* === LIBRARY LIST — SINGLE COLUMN ON MOBILE ========== */

@media (max-width: 900px) {
  /* grid-style list */
  .libGrid,
  .lib-grid,
  #libGrid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* flex-style list */
  .libList,
  .lib-list,
  #libList {
    display: flex;
    flex-direction: column;
  }
}

/* === PALETTE BAR — MOBILE LAYOUT ===================== */

@media (max-width: 900px) {
  /* Move sausage into the normal flow, under the canvas */
  #paletteBar {
    position: static !important;
    transform: none !important;
    margin: 12px 0 0;
    width: 100%;
    max-width: none;
  }
  
  /* === PaletteBar mobile toggle button =================== */

/* Hidden on desktop */
.mobile-only {
  display: none;
}

/* Show on small screens */
@media (max-width: 900px) {
  .mobile-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Collapsed analyzer: hide inner controls and swatches */
  #paletteBar.is-collapsed .swatches {
    display: none !important;
  }

  #paletteBar.is-collapsed .ctrls > *:not(#paletteBarToggle) {
    display: none !important;
  }

  /* Let the toggle fill the bar when collapsed */
  #paletteBar.is-collapsed #paletteBarToggle {
    width: 100%;
    justify-content: center;
  }
}

/* === PALETTE BAR — MOBILE LAYOUT ===================== */
@media (max-width: 900px) {

  /* Toolbar toggle: use your new rainbow */
  .tool #toggleAnalyzer {
    background: linear-gradient(
      36deg,
      rgba(58, 84, 180, 1) 4%,
      rgba(170, 0, 176, 1) 59%,
      rgba(255, 0, 0, 1) 100%
    );
    color: #0f0f12;
    border-color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
  }

  /* PaletteBar: rainbow only at the very top */
  #paletteBar {
    background:
      /* DARK MASK: quickly fade to solid dark so swatches sit on grey */
      linear-gradient(
        to bottom,
        rgba(17, 17, 22, 0.00) 0%,
        rgba(17, 17, 22, 0.85) 28%,
        rgba(17, 17, 22, 0.95) 40%,
        rgba(17, 17, 22, 0.98) 100%
      ),
      /* YOUR RAINBOW underneath */
      linear-gradient(
        36deg,
        rgba(58, 84, 180, 1) 4%,
        rgba(170, 0, 176, 1) 59%,
        rgba(255, 0, 0, 1) 100%
      );
  }
}
@media (max-width: 900px) {
  /* Force white text just for the rainbow toggle button */
  .tool #toggleAnalyzer {
    color: #ffffff !important;
  }
}
@media (max-width: 900px) {
  .tool #toggleAnalyzer:hover,
  .tool #toggleAnalyzer:focus {
    color: #ffffff !important;
  }
}

@media (max-width: 900px) {
  /* Hide crosshair lines */
  .overlay .hline,
  .overlay .vline,
  #hl,
  #vl {
    display: none !important;
  }

  /* Keep the reticle visible and on top */
  #reticle {
    display: block;
  }
}

/* === MOBILE-ONLY BUTTONS ============================== */

  /* Analyzer controls can wrap */
  #paletteBar .ctrls {
    flex-wrap: wrap;
    white-space: normal;
    row-gap: 8px;
  }
  

  /* Swatch row sits under the controls */
  #paletteBar .swatches {
    margin-top: 8px;
  }

  /* Slightly tighter spacing between mobile chips */
  #paletteBar .swatchesTrack {
    gap: 6px;
  }

  /* Make chips large, thumb-friendly, single row scroll */
  #paletteBar .chip {
    /* Mobile chip width override (40% narrower than 140px) */
    flex: 0 0 var(--chip-w, 84px);
    min-width: var(--chip-w, 84px);
    max-width: var(--chip-w, 84px);
    height: 46px;
    border-radius: 10px;
  }
}

/* Hidden on desktop */
.btn.mobile-only {
  display: none !important;
}

/* Visible on small screens */
@media (max-width: 900px) {
  .btn.mobile-only {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
  }
}

/* /////////////////////////////////////////////////////// */
/* /////////  ALL PALETTEBAR CODE END  ///////// */
/* /////////////////////////////////////////////////////// */



/* === MOBILE LAYOUT TWEAKS (Mixer + Library + Export) ===================== */

@media (max-width: 768px) {

  /* ----- Generic modals (Mixer + Library) -------------------------------- */

  .modal {
    width: calc(100dvw - 12px);
    max-width: calc(100dvw - 12px);
    max-height: calc(100dvh - 12px);
  }

  /* ----- COLOR MIXER ----------------------------------------------------- */

  .mgrid {
    gap: 10px;
  }

  .mrow {
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: stretch;
  }

  .mrow label {
    margin-bottom: 2px;
  }

  .mrow .rval {
    justify-self: flex-end;
  }

  .nameRow {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .nameRow .auto {
    margin-left: 0;
  }

  #mixer #mixPrev {
    height: 64px;
  }

  /* ----- LIBRARY LAYOUT -------------------------------------------------- */

  /* Let the Library modal use almost full height on phones */
  #libMgr.modal {
    height: calc(100dvh - 16px);
    max-height: calc(100dvh - 16px);
  }

  /* Body: fixed height between title and footer, stacked columns */
  #libMgr .pgp-modal-body {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 120px);  /* adjust if title/footer ever change */
    max-height: none;
  }

  /* Palette list (top) gets a fixed slice; scrolls if long */
  .pgp-lib-left {
    flex: 0 0 42%;       /* ~40% of the body height */
    overflow-y: auto;
    border-right: none !important;
    border-bottom: 1px solid #24242a;
    padding: 8px;
    min-width: 0;
  }

  /* Detail panel (bottom) fills the rest; also scrollable */
  .pgp-lib-right {
    flex: 1 1 0;
    overflow-y: auto;
    width: 100%;
    padding: 10px;
  }

  /* Each library row stacks: name on top, preview full-width under it */
  .libItem {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px;
  }

  /* Preview bar: 3 chips wide, full width */
  .libItem .libPrev {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    align-self: stretch;
    width: 100%;
    margin-top: 4px;
  }

  .libPrev span {
    width: 100%;
    height: 16px;
    border-radius: 3px;
  }

  /* Detail chip grid: single column, full width */
  .libChips {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px;
    align-items: stretch;
  }

  .libChip {
    display: block !important;
    width: 100% !important;
    height: 24px;
    border-radius: 4px;
    margin: 2px 0;
  }

  /* ----- Library detail header: title + buttons -------------------------- */

  .libPanel .hd2 {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;   /* keep them on one row */
	
	/* Mobile: keep Library header buttons aligned instead of pushed right */
@media (max-width: 768px) {
  .libPanel .hd2 > div:last-of-type {
    margin-left: 0 !important;   /* cancels the inline margin-left:auto */
  }
}
  }

  /* Title + count stay as auto-width items */
  .libPanel .hd2 #libTitle,
  .libPanel .hd2 #libCount {
    flex: 0 0 auto;
  }

  /* Buttons: allow shrinking so “Duplicate” fits */
  .libPanel .hd2 .btn,
  .libPanel .hd2 button {
    flex: 0 1 auto;           /* can shrink */
    /* min-width: 0 !important;  /* kill any global min-width */
    width: auto;
    padding-inline: 2px;
    font-size: 12px;
    white-space: wrap;      /* keep text on one line */
  }
  

/* === Footer: buttons with icons (Color Basics + JSON Sorter) === */
/* Force the Palette JSON Sorter icon to 30×30 */

/*.btn .btn-small .btn-with-icon {
	font-size: 12px;
}

/* Palette JSON Sorter – remove underline */
/*.btn-with-icon .btn.icon .btn-small {
  text-decoration: none;
  font-size: 12px;
}

.btn-with-icon, .btn-icon .btn-small
.btn-with-icon:focus {
  text-decoration: none;
  font-size: 12px;
  padding: 4px 10px;
}

/* === Palette JSON Sorter footer button === */
/*.footer .fhd #btnPaletteSorter img {
  width: 30px !important;
  height: 30px !important;
  display: block;
  border-radius: 6px;
  font-size: 12px;
} */

/* === Footer icon buttons (Color Basics + JSON Sorter) === */

/* === Footer icon buttons (Color Basics + JSON Sorter) === */
/* Put this *after* your generic .btn / .btn-small / .footer a rules */

.footer .fhd .btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  /* Force both buttons to share the same text style */
  font-size: 11px;
  font-weight: 400;
  line-height: 1.4;
  padding: 3px 8px;        /* keep them nice and compact */
}

/* Tiny logo icon in both buttons */
.footer .fhd .btn-with-icon .btn-icon {
  width: 14px;
  height: 14px;
  display: block;
  flex: 0 0 14px;
}

/* Make the JSON Sorter link behave visually like the button */
#btnPaletteSorter {
  text-decoration: none;
  color: inherit;

  /* In case some other link rule is forcing bold/size, override it */
  font-size: 11px !important;
  font-weight: 400 !important;
}


  #libTop {
  display: flex;
  gap: 8px;
}


/* === MOBILE EXPORT DROPDOWN (TOP TOOLBAR) =============================== */
@media (max-width: 768px) {

  /* Make sure the Export button is the positioning anchor */
  .menuwrap {
    position: relative !important;
  }

  /* Position the dropdown centered under the Export button */
  .menuwrap > .menu {
    position: absolute !important;
    top: calc(100% + 4px) !important;  /* just below the button */
    left: 50% !important;              /* center horizontally */
    right: auto !important;
    transform: translateX(-50%) !important;

    /* Stay above any dark overlays */
    z-index: 3000 !important;

    /* Keep it inside the viewport horizontally */
    max-width: calc(100dvw - 16px);
    width: max-content;
    min-width: 0 !important;          /* override base min-width: max-content */
    box-sizing: border-box;
  }

  /* Menu items can wrap if needed on very narrow screens */
  .menu .item {
    white-space: normal;
  }
}
