/* mhpb: Mister Horse preset browser. Self-contained, every class prefixed "mhpb-". */
.mhpb {
  --mhpb-bg: #232323;
  --mhpb-side: #1d1d1d;
  --mhpb-line: #303030;
  --mhpb-row-hover: #2c2c2c;
  --mhpb-row-active: #383838;
  --mhpb-text: #e4e4e4;
  --mhpb-muted: #9a9a9a;
  --mhpb-faint: #6c6c6c;
  --mhpb-accent: #2680eb;
  --mhpb-focus: #4b9cff;
  --mhpb-radius: 10px;
  --mhpb-cols: 3;
  container: mhpb / inline-size;
  display: block;
  margin: 2rem 0;
  color: var(--mhpb-text);
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
  -webkit-font-smoothing: antialiased;
}
.mhpb *, .mhpb *::before, .mhpb *::after { box-sizing: border-box; }
/* Wider than a text column: centred on the column, up to 960px, never wider than the viewport. */
.mhpb.mhpb--breakout {
  width: min(960px, 100vw - 32px);
  margin-left: calc(50% - min(480px, 50vw - 16px));
}
.mhpb ul { list-style: none; margin: 0; padding: 0; }
.mhpb button, .mhpb select {
  font: inherit; color: inherit; margin: 0; border-radius: 0; text-transform: none; letter-spacing: normal;
}
.mhpb button { background: none; border: 0; padding: 0; cursor: pointer; }
.mhpb :focus { outline: none; }
.mhpb :focus-visible { outline: 2px solid var(--mhpb-focus); outline-offset: 2px; }
.mhpb svg { display: block; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.mhpb-panel {
  background: var(--mhpb-bg);
  border: 1px solid #000;
  border-radius: var(--mhpb-radius);
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 18px 40px -18px rgba(0,0,0,.55);
  overflow: hidden;
}

/* Head */
.mhpb-head {
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 8px 10px 8px 18px;
  border-bottom: 1px solid #191919;
}
.mhpb-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mhpb-sub { color: var(--mhpb-muted); font-size: 13px; white-space: nowrap; }
.mhpb-hint { margin-left: auto; color: var(--mhpb-muted); font-size: 12px; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.mhpb-hint:empty { display: none; }
.mhpb-close {
  margin-left: 4px; width: 32px; height: 32px; border-radius: 6px !important;
  display: grid; place-items: center; color: var(--mhpb-muted);
}
.mhpb-hint:empty + .mhpb-close { margin-left: auto; }
.mhpb-close:hover { background: var(--mhpb-row-hover); color: var(--mhpb-text); }

/* Body: sidebar + main */
.mhpb-body { display: grid; grid-template-columns: 1fr; }
.mhpb-side { display: none; position: relative; background: var(--mhpb-side); border-right: 1px solid #161616; }
/* The tree never sets the panel height: the grid does, the tree scrolls inside it. */
.mhpb-tree { position: absolute; inset: 0; overflow-y: auto; padding: 8px 0; scrollbar-width: thin; scrollbar-color: #444 transparent; }
.mhpb-node {
  display: flex !important; align-items: center; gap: 8px; width: 100%;
  min-height: 34px; padding: 6px 12px 6px 10px !important;
  text-align: left; color: var(--mhpb-text); font-size: 13.5px;
  border-bottom: 1px solid #171717 !important;
}
.mhpb-node:hover { background: var(--mhpb-row-hover) !important; }
.mhpb-node[aria-current="true"] { background: var(--mhpb-row-active) !important; box-shadow: inset 3px 0 0 var(--mhpb-accent); }
.mhpb-node:focus-visible { outline-offset: -2px; }
.mhpb-node-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mhpb-count { color: var(--mhpb-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.mhpb-node[aria-current="true"] .mhpb-count { color: var(--mhpb-muted); }
.mhpb-chev { width: 12px; height: 12px; color: var(--mhpb-muted); transition: transform .15s; }
.mhpb-node[aria-expanded="true"] .mhpb-chev { transform: rotate(90deg); }
.mhpb-folder { width: 16px; height: 16px; color: #bdbdbd; }
.mhpb-folder path { fill: currentColor; stroke: none; }
.mhpb-node--all { font-weight: 600; }
.mhpb-node--all .mhpb-chev { visibility: hidden; }
.mhpb-node--cat { font-weight: 600; }
.mhpb-node--group { padding-left: 34px !important; color: #cfcfcf; }

/* Compact category picker (narrow containers) */
.mhpb-pick { display: block; padding: 10px 12px 0; }
.mhpb-pick-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mhpb-select {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 38px; padding: 0 36px 0 12px !important;
  background: #1a1a1a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23aaa' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid #3a3a3a !important; border-radius: 6px !important;
  color: var(--mhpb-text); font-size: 14px;
}
.mhpb-select option { background: #1a1a1a; color: var(--mhpb-text); }

/* Grid */
.mhpb-main { min-width: 0; display: flex; flex-direction: column; }
/* Scrolling view: JS sets the height to three rows; max-height is only the fallback if that fails. */
.mhpb-scroll { min-height: 0; scroll-padding-top: 12px; }
.mhpb[data-mhpb-view="scroll"] .mhpb-scroll {
  overflow-y: auto; max-height: 90vh; scroll-snap-type: y proximity;
  scrollbar-width: thin; scrollbar-color: #4a4a4a transparent;
}
.mhpb[data-mhpb-view="scroll"] .mhpb-scroll::-webkit-scrollbar { width: 10px; }
.mhpb[data-mhpb-view="scroll"] .mhpb-scroll::-webkit-scrollbar-thumb { background: #4a4a4a; border-radius: 5px; border: 2px solid var(--mhpb-bg); }
.mhpb[data-mhpb-view="scroll"] .mhpb-tile { scroll-snap-align: start; }
.mhpb[data-mhpb-view="scroll"] .mhpb-pager { display: none; }
.mhpb[data-mhpb-view="scroll"] .mhpb-foot { min-height: 51px; }
.mhpb-grid {
  display: grid !important; grid-template-columns: repeat(var(--mhpb-cols), minmax(0, 1fr));
  gap: 16px 12px; padding: 12px !important;
}
.mhpb-tile { min-width: 0; }
.mhpb-tile--empty { visibility: hidden; }
.mhpb-media {
  display: block; position: relative; aspect-ratio: 16 / 9; overflow: hidden;
  background: #000; border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06);
}
.mhpb-poster, .mhpb-video {
  position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none;
  object-fit: contain; display: block; background: #000; border: 0;
}
.mhpb-video { opacity: 0; transition: opacity .12s; }
.mhpb-tile.mhpb-is-on .mhpb-video { opacity: 1; }
.mhpb-hit { position: absolute; inset: 0; width: 100%; height: 100%; display: grid; place-items: center; border-radius: 4px !important; }
.mhpb-hit:focus-visible { outline-offset: -2px; }
.mhpb-play {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(20,20,20,.72); color: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.18);
  opacity: 0; transform: scale(.92); transition: opacity .15s, transform .15s;
}
.mhpb-play svg { width: 14px; height: 14px; margin-left: 2px; }
.mhpb-play svg path { fill: currentColor; stroke: none; }
/* Play affordance: when playback is click-driven, or autoplay was refused, or on hover/focus while paused. */
.mhpb[data-mhpb-policy="click"] .mhpb-tile:not(.mhpb-is-on) .mhpb-play,
.mhpb-tile.mhpb-is-blocked:not(.mhpb-is-on) .mhpb-play,
.mhpb[data-mhpb-policy="loop"] .mhpb-tile.mhpb-is-paused .mhpb-play,
.mhpb-hit:focus-visible .mhpb-play { opacity: 1; transform: none; }
.mhpb-tile.mhpb-is-on .mhpb-hit:focus-visible .mhpb-play { opacity: 0; }

/* Name gets the whole first row; the variant picker sits under it. The height is reserved so pages don't jump. */
.mhpb-meta { display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 5px 6px; min-height: 60px; padding-top: 7px; }
.mhpb-icon { width: 15px; height: 15px; color: #39b1c8; }
.mhpb-name { flex: 1 1 calc(100% - 24px); min-width: 0; font-size: 13px; color: var(--mhpb-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mhpb-var { position: relative; flex: none; max-width: calc(100% - 21px); margin-left: 21px; display: flex; }
.mhpb-var-select {
  appearance: none; -webkit-appearance: none; max-width: 100%;
  height: 24px; padding: 0 20px 0 8px !important;
  background: #2e2e2e url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 4 5 6.5 7.5 4' fill='none' stroke='%23aaa' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 6px center;
  border: 1px solid #3c3c3c !important; border-radius: 12px !important;
  color: #d0d0d0; font-size: 12px; cursor: pointer; text-overflow: ellipsis;
}
.mhpb-var-select:hover { border-color: #555 !important; color: #fff; }
.mhpb-var-select option { background: #1a1a1a; color: var(--mhpb-text); }

/* Footer / pager */
.mhpb-foot {
  margin-top: auto; display: flex; align-items: center; gap: 12px;
  padding: 8px 12px 10px; border-top: 1px solid #1b1b1b; color: var(--mhpb-muted); font-size: 12.5px;
}
.mhpb-status { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.mhpb-pager { display: flex; align-items: center; gap: 4px; }
.mhpb-pages { min-width: 48px; text-align: center; color: var(--mhpb-text); font-variant-numeric: tabular-nums; }
.mhpb-pg {
  width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px !important;
  border: 1px solid #3a3a3a !important; color: var(--mhpb-text);
}
.mhpb-pg svg { width: 14px; height: 14px; }
.mhpb-pg:hover:not(:disabled) { background: var(--mhpb-row-hover); border-color: #4a4a4a !important; }
.mhpb-pg:disabled { opacity: .35; cursor: default; }

/* Layout by container width */
@container mhpb (min-width: 600px) {
  .mhpb-body { grid-template-columns: 196px minmax(0, 1fr); }
  .mhpb-side { display: block; }
  .mhpb-pick { display: none; }
  .mhpb-grid { padding: 14px 14px 8px !important; }
  .mhpb-scroll { scroll-padding-top: 14px; }
}
@container mhpb (min-width: 860px) {
  .mhpb-body { grid-template-columns: 224px minmax(0, 1fr); }
  .mhpb-grid { gap: 18px 16px; padding: 16px 16px 8px !important; }
  .mhpb-scroll { scroll-padding-top: 16px; }
  .mhpb-name { font-size: 13.5px; }
}
@container mhpb (max-width: 459px) {
  .mhpb-grid { --mhpb-cols: 2; gap: 12px 10px; padding: 10px 12px !important; }
  .mhpb-scroll { scroll-padding-top: 10px; }
  .mhpb-head { padding-left: 14px; }
  .mhpb-hint { display: none; }
  .mhpb-hint + .mhpb-close { margin-left: auto; }
}

/* Modal */
.mhpb-dialog {
  /* Third term keeps the whole 3x3 panel inside short viewports (panel height is about 200px + 0.5625 x width). */
  width: min(1040px, 100vw - 32px, max(560px, (100dvh - 240px) * 1.78)); max-width: none; max-height: calc(100dvh - 32px);
  padding: 0; border: 0; background: transparent; color: inherit; overflow: auto;
}
.mhpb-dialog::backdrop { background: rgba(8,8,8,.72); }
.mhpb-dialog .mhpb { margin: 0; }
.mhpb-dialog[open] { animation: mhpb-in .18s ease-out; }
@keyframes mhpb-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }
@media (max-width: 480px) {
  .mhpb-dialog { width: 100vw; max-height: 100dvh; margin: auto 0 0; }
  .mhpb-dialog .mhpb-panel { border-radius: 12px 12px 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mhpb *, .mhpb-dialog[open] { transition: none !important; animation: none !important; }
}
