/* ---------- Brush UI (brushui.js) ---------- */

/* tool panel */
#tools.bu-panel {
  gap: 5px; padding: 7px 6px; width: 62px; max-height: min(480px, calc(100% - 24px));
  overflow-x: hidden;
}
#tools.bu-panel::-webkit-scrollbar { display: none; }
.bu-panel .bu-tool { width: 46px; height: 44px; color: var(--text); }
.bu-panel .bu-tool svg { width: 23px; height: 23px; }
.bu-panel .bu-tool.active { background: var(--accent); color: #1a0d07; }
.bu-name {
  width: 54px; min-height: 26px; padding: 2px 2px; margin: -1px 0 1px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); font-size: 10px; line-height: 1.15; font-weight: 600;
  text-align: center; cursor: pointer; overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word;
}
.bu-name:active, .bu-popopen .bu-name { color: var(--accent); }
.bu-colorbtn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; background: transparent; flex: none;
}
.bu-colordot {
  width: 32px; height: 32px; border-radius: 50%; display: block;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px rgba(255,255,255,.55);
}
.bu-colorbtn:active .bu-colordot { transform: scale(.92); }
.bu-panel .divider { margin: 2px 0; flex: none; }
.bu-vbox { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: none; }
.bu-vval {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600;
  min-width: 40px; text-align: center; line-height: 14px;
}

/* custom sliders */
.bu-slider { position: relative; touch-action: none; cursor: pointer; flex: none; }
.bu-slider .bu-track { position: absolute; background: #14151a; border: 1px solid var(--line); overflow: visible; }
.bu-slider .bu-fill { position: absolute; background: rgba(255,106,61,.55); }
.bu-slider .bu-thumb {
  position: absolute; background: #f4f4f6; border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,.55); pointer-events: none;
}
.bu-slider.drag .bu-thumb { background: var(--accent); }

.bu-slider.v { width: 42px; height: 124px; }
.bu-slider.v .bu-track { left: 12px; right: 12px; top: 6px; bottom: 6px; border-radius: 9px; }
.bu-slider.v .bu-fill { left: 0; right: 0; bottom: 0; border-radius: 0 0 8px 8px; }
.bu-slider.v .bu-thumb { left: -5px; right: -5px; height: 12px; transform: translateY(50%); }

.bu-slider.h { height: 40px; flex: 1; min-width: 80px; }
.bu-slider.h .bu-track { left: 6px; right: 6px; top: 15px; height: 10px; border-radius: 5px; }
.bu-slider.h .bu-fill { left: 0; top: 0; bottom: 0; border-radius: 5px 0 0 5px; }
.bu-slider.h .bu-thumb { top: -9px; width: 14px; height: 26px; transform: translateX(-50%); border-radius: 7px; }

.bu-bubble {
  position: fixed; z-index: 40; transform: translateY(-50%); pointer-events: none;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 48px;
  background: rgba(20,20,24,.95); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.bu-bubble[hidden] { display: none; }
.bu-bubble-dot { border-radius: 50%; box-shadow: 0 0 0 1px rgba(255,255,255,.35); flex: none; }

/* popovers */
.bu-pop {
  position: fixed; z-index: 30; display: flex; flex-direction: column; overflow: hidden;
  background: rgba(30,32,38,.97); color: var(--text); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 18px 60px rgba(0,0,0,.6);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.bu-pop[hidden] { display: none; }
.bu-pop button { font: inherit; color: inherit; }
.bu-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  border-bottom: 1px solid var(--line); flex: none;
}
.bu-tabs { display: flex; gap: 2px; padding: 3px; background: #15161a; border-radius: 11px; border: 1px solid var(--line); }
.bu-tab {
  height: 36px; padding: 0 14px; border-radius: 8px; border: 0; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.bu-tab.on { background: var(--panel2); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.bu-title {
  flex: 1; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; text-align: right;
}
.bu-title.big { font-size: 17px; color: var(--text); font-weight: 700; text-align: left; }
.bu-x {
  width: 40px; height: 40px; flex: none; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel2); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.bu-x svg { width: 18px; height: 18px; }
.bu-x:active { filter: brightness(1.25); }

/* library */
.bu-libbody { flex: 1; min-height: 0; display: flex; }
.bu-libbody[hidden], .bu-stubody[hidden] { display: none; }
.bu-cats {
  flex: 0 0 158px; overflow-y: auto; padding: 8px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; overscroll-behavior: contain;
}
.bu-cat {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; text-align: left;
  min-height: 42px; padding: 0 10px 0 12px; border-radius: 10px; border: 0; background: transparent;
  color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; flex: none;
}
.bu-cat.on { background: var(--panel2); color: var(--text); }
.bu-catdot { width: 6px; height: 6px; border-radius: 50%; background: transparent; flex: none; }
.bu-cat.has .bu-catdot { background: var(--accent); }
.bu-list {
  flex: 1; min-width: 0; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.bu-row {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 4px; border-radius: 12px; flex: none;
  background: #17181c; border: 1px solid #2a2d35; cursor: pointer; text-align: left;
}
.bu-row:active { filter: brightness(1.15); }
.bu-row.on { border-color: var(--accent); background: rgba(255,106,61,.12); box-shadow: inset 0 0 0 1px var(--accent); }
.bu-rowname { display: flex; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 600; }
.bu-row.on .bu-rowname { color: var(--accent2); }
.bu-edited { display: none; font-size: 11px; color: var(--accent); font-weight: 600; }
.bu-row.mod .bu-edited { display: inline; }
.bu-prev { width: 100%; height: 58px; display: block; }

/* studio */
.bu-stubody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bu-padwrap {
  position: relative; flex: none; height: clamp(96px, 17vh, 190px); margin: 10px 10px 0;
  border-radius: 12px; background: #111215; border: 1px solid var(--line); overflow: hidden;
}
.bu-pad { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.bu-padhint {
  position: absolute; left: 12px; top: 8px; font-size: 11px; color: #5d6370; pointer-events: none;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.bu-padclear {
  position: absolute; right: 8px; top: 8px; height: 32px; padding: 0 10px; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(42,45,53,.9); font-size: 12px; font-weight: 600;
  cursor: pointer; display: none;
}
.bu-padwrap.used .bu-padclear { display: block; }
.bu-padwrap.used .bu-padhint { display: none; }
.bu-stubar { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 14px; flex: none; border-bottom: 1px solid var(--line); }
.bu-stuname { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bu-btn {
  height: 40px; padding: 0 14px; border-radius: 10px; background: var(--panel2);
  border: 1px solid var(--line); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.bu-btn:disabled { opacity: .35; pointer-events: none; }
.bu-stuscroll {
  flex: 1; min-height: 0; overflow-y: auto; padding: 4px 12px 16px;
  overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); column-gap: 18px; align-content: start;
}
.bu-sec[hidden] { display: none; }
.bu-sec h4, .bu-col h4 {
  margin: 12px 0 2px; font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .07em; font-weight: 700;
}
.bu-ctl { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.bu-ctl[hidden] { display: none; }
.bu-ctl.dis { opacity: .35; pointer-events: none; }
.bu-lab { flex: 0 0 112px; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bu-val { flex: 0 0 52px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bu-grow { flex: 1; }
.bu-sel {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px; border-radius: 10px; background: var(--panel2);
  border: 1px solid var(--line); color: var(--text); font-weight: 600; font-size: 14px;
}
.bu-switch {
  width: 52px; height: 32px; border-radius: 16px; border: 1px solid var(--line); background: #15161a;
  position: relative; cursor: pointer; padding: 0; flex: none; margin-right: 4px;
}
.bu-switch i {
  position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #c9ccd4; transition: transform .15s;
}
.bu-switch.on { background: var(--accent); border-color: var(--accent); }
.bu-switch.on i { transform: translateX(20px); background: #fff; }
.bu-seg { flex: 1; display: flex; gap: 2px; padding: 3px; background: #15161a; border: 1px solid var(--line); border-radius: 10px; }
.bu-seg button {
  flex: 1; height: 34px; border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.bu-seg button.on { background: var(--panel2); color: var(--text); }

/* colour */
.bu-cmp { display: flex; border-radius: 10px; overflow: hidden; border: 1px solid rgba(255,255,255,.2); flex: none; }
.bu-cmp-prev, .bu-cmp-cur { width: 44px; height: 32px; border: 0; padding: 0; display: block; }
.bu-cmp-prev { cursor: pointer; }
.bu-col .bu-head { padding-left: 16px; }
.bu-colbody { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 16px; overscroll-behavior: contain; }
.bu-sv {
  position: relative; width: 100%; aspect-ratio: 1.45; max-height: 36vh; border-radius: 12px; overflow: visible;
  touch-action: none; cursor: crosshair;
}
.bu-sv canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; display: block; }
.bu-knob {
  position: absolute; width: 28px; height: 28px; margin: -14px 0 0 -14px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.5); pointer-events: none;
}
.drag > .bu-knob { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
.bu-hue {
  position: relative; height: 32px; margin: 16px 2px 0; border-radius: 16px; touch-action: none; cursor: pointer;
  background: linear-gradient(90deg, #f00 0%, #ff0 16.66%, #0f0 33.33%, #0ff 50%, #00f 66.66%, #f0f 83.33%, #f00 100%);
}
.bu-hue .bu-knob { top: 50%; }
.bu-hexrow { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.bu-hexrow .bu-lab { flex: none; color: var(--muted); }
.bu-hex {
  flex: 1; height: 40px; padding: 0 12px; border-radius: 10px; background: #15161a; border: 1px solid var(--line);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 16px; letter-spacing: .06em;
  -webkit-user-select: text; user-select: text; text-transform: uppercase;
}
.bu-hex:focus { outline: none; border-color: var(--accent); }
.bu-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; margin-top: 8px; }
.bu-sw {
  aspect-ratio: 1; min-height: 28px; border-radius: 8px; border: 1px solid rgba(255,255,255,.14);
  padding: 0; cursor: pointer;
}
.bu-sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.bu-sw:active { transform: scale(.92); }
.bu-empty { grid-column: 1 / -1; font-size: 13px; color: var(--muted); padding: 6px 0; }

@media (max-width: 600px) {
  .bu-cats { flex-basis: 118px; }
  .bu-cat { font-size: 13px; padding: 0 8px; }
  .bu-tab { padding: 0 10px; }
}
