:root {
  --card-text: #0f0f0f;
  --card-meta: rgb(0 0 0 / 0.6);
  --card-shadow: none;
  --chip: rgb(0 0 0 / 0.06);
  --chip-hover: rgb(0 0 0 / 0.1);
  --field-line: rgb(0 0 0 / 0.3);
}

@media (prefers-color-scheme: dark) {
  :root {
    --card-text: #ffffff;
    --card-meta: rgb(255 255 255 / 0.72);
    --card-shadow: drop-shadow(0 1px 1px rgb(0 0 0 / 0.6));
    --chip: rgb(0 0 0 / 0.22);
    --chip-hover: rgb(0 0 0 / 0.32);
    --field-line: rgb(255 255 255 / 0.35);
  }
}

.card,
.inspector .sheet {
  --card: var(--tint-light, #f2f2f2);
  --card-edge: var(--tint-light-edge, #dedede);
}

@media (prefers-color-scheme: dark) {
  .card,
  .inspector .sheet {
    --card: var(--tint, #272727);
    --card-edge: var(--tint-edge, #3a3a3a);
  }
}

.gallery .top {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery .brand {
  font-size: 1.3rem;
  text-decoration: none;
}

.models {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 28px;
}

.models h1 {
  margin-bottom: 8px;
  font-size: 3rem;
}

.summary {
  margin: 0 0 20px;
  text-align: center;
  color: var(--tagline);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.line {
  width: 240px;
  padding: 4px 2px;
  font: inherit;
  font-size: 0.95rem;
  color: var(--heading);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--field-line);
  outline: 0;
}

select.line {
  width: auto;
  cursor: pointer;
}

select.line option {
  color: var(--text);
  background: var(--page);
}

.filters .favorites {
  display: flex;
  align-items: center;
  gap: 6px;
  width: auto;
  cursor: pointer;
}

.favorites svg {
  width: 18px;
  height: 18px;
}

.favorites .count {
  color: var(--tagline);
}

.favorites[aria-pressed="true"] svg {
  color: #ff4d6d;
}

.favorites[aria-pressed="true"] path {
  fill: currentColor;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

.card {
  --corner: 7px;
  --edge: 2px;
  --cut: var(--corner);
  position: relative;
  isolation: isolate;
  margin: 0;
  padding: 10px;
  background: var(--card-edge);
}

.card::before {
  --cut: calc(var(--corner) - 0.586 * var(--edge));
  content: "";
  position: absolute;
  inset: var(--edge);
  z-index: -1;
  background: var(--card);
}

.card,
.card::before {
  clip-path: polygon(
    var(--cut) 0, calc(100% - var(--cut)) 0,
    100% var(--cut), 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, var(--cut) 100%,
    0 calc(100% - var(--cut)), 0 var(--cut)
  );
}

.picture {
  --rotate-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4'%3E%3Cpath d='M20 11a8 8 0 0 0-14.5-4.6M4 13a8 8 0 0 0 14.5 4.6'/%3E%3Cpath d='M5 2.5v4.2h4.2M19 21.5v-4.2h-4.2'/%3E%3C/svg%3E");
  position: relative;
  aspect-ratio: 1;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.picture::before {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 1;
  width: 20px;
  height: 20px;
  background: var(--card-meta);
  -webkit-mask: var(--rotate-icon) center / contain no-repeat;
  mask: var(--rotate-icon) center / contain no-repeat;
  pointer-events: none;
}

.picture.touch {
  touch-action: none;
}

.picture.touch::before {
  content: "";
}

@media (hover: hover) and (pointer: fine) {
  .card:not(.too-big, .failed) .picture:hover::before {
    content: "";
  }
}

.picture.dragging {
  cursor: grabbing;
}

.card.too-big .picture,
.card.failed .picture {
  cursor: default;
}

.picture canvas,
.picture img {
  display: block;
  width: 100%;
  height: 100%;
  -webkit-user-drag: none;
}

.picture > img,
.picture > canvas:not(.viewer) {
  transition: opacity 0.18s;
}

.picture > img:not(.shown),
.picture > canvas:not(.viewer, .shown) {
  opacity: 0;
}

.picture .viewer {
  position: absolute;
  inset: 0;
}

.picture.live > img,
.picture.live > canvas:not(.viewer) {
  visibility: hidden;
}

.card.too-big .picture::after,
.card.failed .picture::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  color: var(--card-meta);
  text-align: center;
}

.card.too-big .picture::after { content: "Too big to preview"; }
.card.failed .picture::after { content: "Preview unavailable"; }

.icon {
  display: grid;
  place-items: center;
  padding: 6px;
  color: var(--card-meta);
  background: none;
  border: 0;
  cursor: pointer;
  filter: var(--card-shadow);
}

.icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.icon:hover {
  color: var(--card-text);
}

.icon:disabled {
  cursor: progress;
  opacity: 0.5;
}

.icon.error {
  color: #e06c6c;
}

.icon.like.on {
  color: #ff4d6d;
}

.icon.like.on path {
  fill: currentColor;
}

.picture .tools {
  position: absolute;
  top: -4px;
  right: -4px;
  z-index: 1;
  display: flex;
}

.picture .like {
  position: absolute;
  top: -4px;
  left: -4px;
  z-index: 1;
}

html.inspecting,
html.inspecting body {
  overflow: hidden;
}

.inspector {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgb(0 0 0 / 0.72);
  touch-action: none;
  overscroll-behavior: contain;
}

.inspector .sheet {
  --corner: 10px;
  --edge: 2px;
  --cut: var(--corner);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 20px;
  width: min(960px, 100%);
  max-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  padding: 20px;
  color: var(--card-text);
  background: var(--card-edge);
}

.inspector .sheet::before {
  --cut: calc(var(--corner) - 0.586 * var(--edge));
  content: "";
  position: absolute;
  inset: var(--edge);
  z-index: -1;
  background: var(--card);
}

.inspector .sheet,
.inspector .sheet::before {
  clip-path: polygon(
    var(--cut) 0, calc(100% - var(--cut)) 0,
    100% var(--cut), 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, var(--cut) 100%,
    0 calc(100% - var(--cut)), 0 var(--cut)
  );
}

.inspector .close {
  position: absolute;
  top: 6px;
  right: 12px;
  z-index: 2;
  padding: 0 4px;
  font-size: 2rem;
  line-height: 1;
  color: var(--card-text);
  background: none;
  border: 0;
  cursor: pointer;
  opacity: 0.8;
}

.inspector .close:hover {
  opacity: 1;
}

.inspector .stage {
  position: relative;
  aspect-ratio: 1;
  max-height: calc(100dvh - 72px);
  justify-self: center;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.inspector .stage.dragging {
  cursor: grabbing;
}

.inspector .stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.inspector .stage[data-state]::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--card-meta);
}

.inspector .stage[data-state="loading"]::after { content: "Loading"; }
.inspector .stage[data-state="big"]::after { content: "Too big to preview"; }
.inspector .stage[data-state="failed"]::after { content: "Preview unavailable"; }

.inspector .about {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding-top: 28px;
}

.inspector .title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.inspector .details {
  margin: 0;
  color: var(--card-meta);
}

.inspector .actions {
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  gap: 10px;
}

.inspector .actions .button {
  flex: 1;
  justify-content: center;
  border: 0;
  cursor: pointer;
}

.inspector .actions .like {
  --cut: 7px;
  flex: none;
  width: 44px;
  padding: 0;
  background: var(--chip);
  filter: none;
  clip-path: polygon(
    var(--cut) 0, calc(100% - var(--cut)) 0,
    100% var(--cut), 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, var(--cut) 100%,
    0 calc(100% - var(--cut)), 0 var(--cut)
  );
}

.inspector .actions .like:hover {
  background: var(--chip-hover);
}

.inspector .actions .icon svg {
  width: 22px;
  height: 22px;
}

.inspector .hint {
  margin: auto 0 0;
  font-size: 0.85rem;
  color: var(--card-meta);
}

@media (max-width: 700px) {
  .inspector {
    place-items: stretch;
    padding: 0;
  }

  .inspector .sheet {
    --corner: 0px;
    --edge: 0px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    height: 100%;
    max-height: none;
    padding: 0 0 calc(20px + env(safe-area-inset-bottom));
  }

  .inspector .stage {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    max-height: none;
    aspect-ratio: auto;
    margin-top: env(safe-area-inset-top);
    display: grid;
    place-items: center;
    container-type: size;
  }

  .inspector .stage canvas {
    width: min(100cqw, 100cqh);
    height: min(100cqw, 100cqh);
  }

  .inspector .about {
    flex: none;
    gap: 10px;
    padding: 0 16px;
  }

  .inspector .hint {
    margin: 0;
  }

  .inspector .close {
    --cut: 7px;
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: 10px;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    font-size: 1.8rem;
    color: var(--card-text);
    background: none;
    filter: var(--card-shadow);
    opacity: 1;
  }
}

.name,
.meta {
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.name {
  margin-top: 8px;
  font-size: 0.9rem;
  color: var(--card-text);
}

.meta {
  font-size: 0.78rem;
  color: var(--card-meta);
}

.status {
  min-height: 1.6em;
  margin: 20px 0 0;
  text-align: center;
  color: var(--tagline);
}

.sentinel {
  height: 1px;
}

@media (max-width: 600px) {
  .gallery .top { justify-content: center; }
  .models h1 { font-size: 2.2rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .line { width: 100%; }
  .gallery .top { flex-wrap: wrap; row-gap: 12px; }
  .gallery .top .brand { flex-basis: 100%; justify-content: center; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
  .filters input.line { grid-column: 1 / -1; }
  .filters select.line { width: 100%; }
  .filters .favorites { justify-content: center; }
}

.name .badge {
  display: inline-block;
  margin-right: 6px;
  padding: 0 5px;
  font-size: 0.7rem;
  line-height: 1.5;
  color: #fff;
  vertical-align: 1px;
  background: #c0392b;
}

.inspector .description {
  margin: 0;
  line-height: 1.45;
  color: var(--card-text);
}

.inspector .description + .details {
  font-size: 0.85rem;
}

.favorites.adult span {
  white-space: nowrap;
}

.favorites.adult[aria-pressed="true"] {
  padding: 4px 10px;
  color: #fff;
  background: #c0392b;
  border-color: #c0392b;
}

.inspector .close:focus:not(:focus-visible) {
  outline: none;
}
