/* Keep the workspace wide without letting a filtered row resize the cards. */
#root :is(main, section, div)[class*="max-w-"]:has(#sd25-model-grid) {
  max-width: none;
}

#root :has(> #sd25-model-grid) {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 26px clamp(16px, 2vw, 36px) 34px;
  container: pony-gallery / inline-size;
}

#root :has(> #sd25-model-grid) > header {
  padding-block: 0 18px;
  margin-block: 0 15px;
}

#root :has(> #sd25-model-grid) > header h1 {
  font-size: clamp(25px, 2vw, 32px);
  line-height: 1.2;
}

#root #pony-model-family-groups {
  gap: 8px;
  margin-block: 0 16px;
}

#root #pony-model-family-groups button {
  padding: 7px 15px;
  font-size: 14px;
}

#root #sd25-model-grid {
  grid-template-columns: repeat(var(--gallery-columns, 1), minmax(0, 1fr)) !important;
  gap: 16px !important;
  align-items: start;
  margin-block: 0 12px;
}

@container pony-gallery (min-width: 610px) {
  #root #sd25-model-grid { --gallery-columns: 2; }
}

@container pony-gallery (min-width: 970px) {
  #root #sd25-model-grid { --gallery-columns: 3; }
}

@container pony-gallery (min-width: 1440px) {
  #root #sd25-model-grid { --gallery-columns: 4; }
}

#root #sd25-model-grid > article {
  min-width: 0;
  gap: 9px;
  padding: 18px !important;
  border-radius: 15px;
  align-self: start !important;
  overflow-wrap: anywhere;
}

#root #sd25-model-grid > article[data-gallery-card]:not([data-pony-family-filtered="true"], [data-pony-catalog-visibility="hidden"], [hidden]) {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: 28px 18px 46px minmax(92px, auto) minmax(68px, auto) minmax(34px, auto);
  background: linear-gradient(155deg, #111d2e, #0d1522 62%);
  border-color: #26364c;
}

#root #sd25-model-grid > article[data-gallery-card] > :is(h3, code, [data-gallery-description], .gallery-rates, .wan-health, details) {
  grid-column: 1 / -1;
  min-width: 0;
}

#root #sd25-model-grid > article[data-gallery-card] > h3 {
  grid-row: 1;
  font-size: 19px !important;
  line-height: 1.4;
  margin: 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#root #sd25-model-grid > article[data-gallery-card] > code {
  grid-row: 2;
  font-size: 12px;
  line-height: 1.45;
  color: #9fb4cf;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#root #sd25-model-grid > article[data-gallery-card] p {
  margin: 0 !important;
  line-height: 1.52 !important;
}

#root #sd25-model-grid > article[data-gallery-card] > [data-gallery-description] {
  grid-row: 3;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 14px;
  color: #b8c7d9;
}

#root #sd25-model-grid > article[data-gallery-card]:has(> details[open]:not([data-gallery-description-only])) {
  grid-template-rows: 28px 18px minmax(46px, auto) minmax(92px, auto) minmax(68px, auto) minmax(34px, auto);
}

#root #sd25-model-grid > article[data-gallery-card]:has(> details[open]:not([data-gallery-description-only])) > [data-gallery-description] {
  display: block;
  white-space: pre-wrap;
}

#root #sd25-model-grid > article > [data-gallery-rate-source] {
  display: none;
}

#root #sd25-model-grid > article > .gallery-rates {
  grid-row: 4;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  align-items: stretch;
  padding: 10px 11px;
  border: 1px solid #2d4260;
  border-radius: 10px;
  background: #131f32;
  font-variant-numeric: tabular-nums;
}

#root #sd25-model-grid .gallery-rate {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  padding-block: 4px;
  padding-inline: 9px;
}

#root #sd25-model-grid .gallery-rate:first-child { padding-inline-start: 0; }
#root #sd25-model-grid .gallery-rate:last-child { padding-inline-end: 0; }
#root #sd25-model-grid .gallery-rate + .gallery-rate { border-inline-start: 1px solid #324963; }
#root #sd25-model-grid .gallery-rate-resolution { color: #a9c1de; font-size: 12px; line-height: 1.15; }
#root #sd25-model-grid .gallery-rate-value { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 4px; line-height: 1.18; color: #edf6ff; }
#root #sd25-model-grid .gallery-rate-value strong { font-size: 20px; font-weight: 650; }
#root #sd25-model-grid .gallery-rate-value small { color: #acc1db; font-size: 12px; }
#root #sd25-model-grid .gallery-rate-personal { color: #a5d9fb; font-size: 11px; line-height: 1.15; }
#root #sd25-model-grid .gallery-rate-fallback { color: #edf6ff; font-size: 15px; font-weight: 600; }

#root #sd25-model-grid > article > .wan-health { margin: 0 !important; }

#root #sd25-model-grid > article[data-gallery-card] > .wan-health {
  grid-row: 5;
  min-height: 0 !important;
  padding: 6px 0 8px;
  border-radius: 0;
  background: transparent;
  border-bottom: 1px solid #26364c;
}

#root #sd25-model-grid > article[data-gallery-card] > .wan-health header {
  color: #a4b9d4;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 5px;
  line-height: 1.25;
}

#root #sd25-model-grid > article[data-gallery-card] > .wan-health .wh-label {
  font-size: 12px;
  line-height: 1.2;
}

#root #sd25-model-grid > article[data-gallery-card] > .wan-health .wh-row {
  margin-top: 2px;
  font-size: 15px;
  line-height: 1.25;
}

#root #sd25-model-grid > article[data-gallery-card] > details {
  grid-row: 6;
  display: block !important;
  margin: 0 !important;
  min-height: 0 !important;
  font-size: 14px;
  line-height: 1.5;
  color: #c6d6e8;
}

#root #sd25-model-grid > article[data-gallery-card] > details > summary {
  box-sizing: border-box;
  min-height: 34px;
  width: fit-content;
  cursor: pointer;
  padding: 6px 0;
}

#root #sd25-model-grid > article[data-gallery-card] > details[open] > p {
  margin-block: 5px !important;
}

#root #sd25-model-grid > article[data-gallery-card] > [data-gallery-docs] {
  grid-column: 2;
  grid-row: 6;
  justify-self: end;
  align-self: start;
  display: block !important;
  margin: 0 !important;
  min-height: 0 !important;
  z-index: 1;
}

#root #sd25-model-grid > article[data-gallery-card] :is(footer > a, a[data-gallery-docs]) {
  display: inline-flex !important;
  min-height: 34px !important;
  align-items: center;
  padding: 5px 11px;
  border: 1px solid #324964;
  border-radius: 8px;
  background: #172740;
  color: #b8dbff;
  font-size: 13px;
  font-weight: 550;
  line-height: 1.25;
}

#root #sd25-model-grid > article[data-gallery-card] :is(footer > a, a[data-gallery-docs]):hover {
  color: #edf8ff;
  border-color: #6086ad;
  background: #1b3351;
}

#root #sd25-model-grid > article[data-gallery-card] :is(summary, footer > a, a[data-gallery-docs]):focus-visible {
  outline: 2px solid #82c7ff;
  outline-offset: 3px;
}

@media (max-width: 600px) {
  #root :has(> #sd25-model-grid) { padding-top: 16px; }
  #root #sd25-model-grid > article { padding: 15px !important; }
}
