/* v3.2: universal sound layouts, colored using the v2-inspired token system. */
.sbp-view-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin: 19px 0;
  padding: 11px 13px 11px 19px;
  border: 1px solid rgba(148, 136, 222, .28);
  border-radius: 16px;
  background: linear-gradient(110deg, rgba(119, 77, 209, .15), rgba(17, 24, 48, .95) 45%, rgba(40, 183, 182, .07));
}
.sbp-view-caption { display: flex; flex-direction: column; gap: 0; }
.sbp-view-caption strong { color: var(--text); font-weight: 850; font-size: 13px; }
.sbp-view-caption small { color: var(--muted); font-size: 11px; }
.sbp-view-options { display: flex; flex-wrap: wrap; gap: 5px; }
.sbp-view-button {
  border: 1px solid rgba(146, 149, 207, .22);
  border-radius: 10px;
  background: rgba(20, 27, 53, .92);
  color: #c0c8de;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 750;
  transition: border-color .15s, background .15s, color .15s;
}
.sbp-view-button .sbp-icon { width: 16px; height: 16px; }
.sbp-view-button:hover { color: #fff; border-color: rgba(185, 132, 255, .65); }
.sbp-view-button.is-active, .sbp-view-button[aria-pressed="true"] {
  background: linear-gradient(135deg, #995af0, #5654c3);
  border-color: rgba(220, 172, 255, .65);
  color: #fff;
  box-shadow: 0 6px 23px rgba(140, 79, 241, .25);
}
.sbp-view-button:focus-visible, .sbp-tree-heading:focus-visible {
  outline: 3px solid #40e6d8;
  outline-offset: 2px;
}
/* Grid view: classic v2-style colorful sound tiles. */
.sbp-sound-grid[data-sbp-view][data-view="grid"] {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.sbp-sound-grid[data-view="grid"] > .sbp-sound { min-width: 0; }
/* Vertical list: prioritize scan speed, whole sound titles and actions. */
.sbp-sound-grid[data-view="list"] {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}
.sbp-sound-grid[data-view="list"] > .sbp-sound {
  padding: 13px 18px;
  min-height: 79px;
}
.sbp-sound-grid[data-view="list"] .sbp-sound-title {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.4;
  font-size: 14px;
}
.sbp-sound-grid[data-view="list"] .sbp-fake-wave { max-width: 200px; }
/* Horizontal list: scrollable one-row snap rail, no forced pagination changes. */
.sbp-sound-grid[data-view="horizontal"] {
  display: flex;
  gap: 13px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 3px 17px;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  scrollbar-color: #9c67ff #11162c;
  overscroll-behavior-x: contain;
}
.sbp-sound-grid[data-view="horizontal"] > .sbp-sound {
  flex: 0 0 clamp(285px, 34vw, 390px);
  scroll-snap-align: start;
}
.sbp-sound-grid[data-view="horizontal"] .sbp-sound-title { font-size: 13px; }
/* Staggered masonry: keep DOM/reading order; different card heights are visual only. */
.sbp-sound-grid[data-view="masonry"] {
  display: block;
  columns: 3 280px;
  column-gap: 16px;
}
.sbp-sound-grid[data-view="masonry"] > .sbp-sound {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  width: 100%;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin: 0 0 15px;
  padding: 19px 17px;
  min-height: 174px;
}
.sbp-sound-grid[data-view="masonry"] > .sbp-sound:nth-child(4n+2) { min-height: 208px; }
.sbp-sound-grid[data-view="masonry"] > .sbp-sound:nth-child(4n+3) { min-height: 191px; }
.sbp-sound-grid[data-view="masonry"] > .sbp-sound:nth-child(4n) { min-height: 225px; }
.sbp-sound-grid[data-view="masonry"] .sbp-sound-play {
  width: 53px;
  height: 53px;
  flex: 0 0 53px;
}
.sbp-sound-grid[data-view="masonry"] .sbp-sound-body { width: 100%; }
.sbp-sound-grid[data-view="masonry"] .sbp-sound-title {
  white-space: normal;
  text-overflow: clip;
  overflow: visible;
  font-size: 14px;
  line-height: 1.35;
}
.sbp-sound-grid[data-view="masonry"] .sbp-sound-actions {
  width: 100%;
  margin-top: auto;
  justify-content: flex-start;
  border-top: 1px solid rgba(255, 255, 255, .06);
  padding-top: 7px;
}
.sbp-sound-grid[data-view="masonry"] .sbp-fake-wave { max-width: 210px; }
/* Tree view: only a presentation of existing categories/soundboard relationships. */
.sbp-sound-grid[data-view="tree"] { display: block; }
.sbp-tree-group {
  position: relative;
  margin: 0 0 17px;
  border: 1px solid rgba(142, 133, 202, .22);
  background: linear-gradient(125deg, rgba(103, 67, 186, .12), rgba(16, 21, 42, .8));
  border-radius: 17px;
  padding: 9px 12px 11px;
}
.sbp-tree-heading {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  gap: 10px;
  padding: 10px 11px;
  background: transparent;
  border: none;
  color: #f1ebff;
  font-weight: 800;
}
.sbp-tree-caret { color: #5de9dc; font-size: 20px; transition: transform .18s; }
.sbp-tree-heading[aria-expanded="false"] .sbp-tree-caret { transform: rotate(-90deg); }
.sbp-tree-heading small { margin-left: auto; font-weight: 650; color: #a5acc6; }
.sbp-tree-children {
  border-left: 2px solid rgba(119, 90, 219, .65);
  margin: 1px 6px 7px 18px;
  padding-left: 19px;
  display: grid;
  gap: 9px;
}
.sbp-tree-children[hidden] { display: none !important; }
.sbp-tree-children > .sbp-sound { position: relative; min-width: 0; }
.sbp-tree-children > .sbp-sound::after {
  content: '';
  position: absolute;
  top: 50%;
  left: -19px;
  width: 17px;
  border-top: 2px solid rgba(119, 90, 219, .65);
}
.sbp-tree-children .sbp-sound-title { white-space: normal; }
/* Layout selector is an optional enhancement. Default theme grid is still usable without JS. */
@media (max-width: 1080px) {
  .sbp-sound-grid[data-sbp-view][data-view="grid"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sbp-view-button span { display: none; }
  .sbp-view-button { width: 41px; padding: 8px; }
}
@media (max-width: 680px) {
  .sbp-view-bar { padding: 12px; align-items: flex-start; }
  .sbp-view-caption small { display: none; }
  .sbp-view-options { margin-left: auto; }
  .sbp-view-button { width: 38px; min-width: 38px; }
  .sbp-sound-grid[data-sbp-view][data-view="grid"] { grid-template-columns: minmax(0, 1fr); }
  .sbp-sound-grid[data-view="horizontal"] > .sbp-sound { flex-basis: min(86vw, 360px); }
  .sbp-sound-grid[data-view="masonry"] { columns: 2 170px; column-gap: 10px; }
  .sbp-sound-grid[data-view="masonry"] > .sbp-sound { min-height: 188px; padding: 13px; }
  .sbp-sound-grid[data-view="masonry"] .sbp-sound-actions { flex-wrap: wrap; }
  .sbp-tree-children { margin-left: 10px; padding-left: 13px; }
  .sbp-tree-children > .sbp-sound::after { left: -13px; width: 11px; }
  .sbp-tree-heading { padding: 9px 5px; }
}
@media (max-width: 410px) {
  .sbp-view-bar { flex-direction: column; }
  .sbp-view-options { width: 100%; justify-content: space-between; margin-left: 0; }
  .sbp-sound-grid[data-view="masonry"] { columns: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sbp-tree-caret, .sbp-view-button { transition: none; }
}
