/* Keep grid children within their columns, including a long thumbnail strip. */
.collection-controls select,
.collection-controls option {
  background-color: var(--paper);
  color: var(--ink);
  color-scheme: light;
}
html[data-color-mode="dark"] .collection-controls select,
html[data-color-mode="dark"] .collection-controls option {
  color-scheme: dark;
}
.sort-direction {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
}
.sort-direction.ascending svg {
  transform: rotate(180deg);
}
.batch-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
  color: var(--ink);
}
.batch-count {
  font-size: 13px;
}
.batch-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  flex-shrink: 0;
  color: var(--ink);
}
.batch-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-dark);
}
.admin-photo > .batch-checkbox {
  margin-bottom: 12px;
}
.hero-models {
  display: grid;
  min-width: 0;
}
.hero-models .hero-art {
  display: block;
}
.hero-carousel {
  position: relative;
}
.hero-carousel .hero-slide {
  grid-area: 1 / 1;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transition: opacity 800ms ease;
}
.hero-carousel .hero-slide.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}
.hero-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  color: var(--ink);
}
.hero-controls button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
}
.hero-controls button:hover {
  background: var(--accent-soft);
}
.hero-position {
  font-size: 12px;
  min-width: 32px;
  text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .hero-carousel .hero-slide {
    transition: none;
  }
}
.hero-model-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.hero-model-row .field {
  flex: 1;
  min-width: 0;
}
.hero-model-editor {
  margin: 18px 0;
}
.cover-crop-dialog {
  max-width: 520px;
  max-height: calc(100dvh - 24px);
  padding: 20px;
  overflow: auto;
}
.crop-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.crop-heading h2 {
  font-size: 20px;
}
.round-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 24px;
}
.crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--accent-soft);
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
}
.crop-stage:active {
  cursor: grabbing;
}
.crop-stage img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  max-height: none;
  user-select: none;
  pointer-events: none;
}
.cover-crop-dialog .field {
  margin-top: 18px;
}
.crop-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
@media (max-width: 720px) {
  .hero-models {
    width: 100%;
  }
  .batch-toolbar .button {
    font-size: 11px;
    padding: 7px 10px;
  }
  .admin-model-row:has(.batch-checkbox) {
    flex-wrap: wrap;
  }
  .admin-model-row:has(.batch-checkbox) .batch-checkbox {
    width: 100%;
  }
  .cover-crop-dialog {
    padding: 14px;
  }
  .collection-controls {
    flex-wrap: wrap;
  }
}
.detail-layout {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}
.detail-layout > *,
.detail-content > * {
  min-width: 0;
}
.detail-gallery,
.main-picture,
.gallery-thumbs {
  min-width: 0;
  max-width: 100%;
}
.detail-info,
.prose,
.spec-panel {
  overflow-wrap: anywhere;
}
.detail-cover {
  position: absolute;
  inset: 0;
}
.site-footer {
  margin-top: clamp(56px, 7vw, 100px);
}
.catalogue-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 32px 20px;
}
.pagination {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: center;
  margin-top: 36px;
  font-size: 13px;
}
[hidden] {
  display: none !important;
}
.card-badges {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 42px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  pointer-events: none;
}
.card-badges span {
  background: var(--paper);
  color: var(--accent-dark);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  opacity: 0.9;
  z-index: 4;
}
.gallery-arrow:hover {
  opacity: 1;
}
.gallery-prev {
  left: 12px;
}
.gallery-next {
  right: 12px;
}
.gallery-position {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  color: var(--ink);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 12px;
  opacity: 0.9;
  z-index: 4;
  pointer-events: none;
}
.header-inner {
  gap: 20px;
}
.floating-control {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom));
  right: max(24px, env(safe-area-inset-right));
  width: 46px;
  height: 46px;
  z-index: 40;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 18px #0002;
  font-size: 24px;
  display: grid;
  place-items: center;
  padding: 0;
}
.mode-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.color-mode-button {
  transition:
    transform 280ms ease,
    background-color 180ms ease;
}
.color-mode-button.above-top {
  transform: translateY(-58px);
}
.floating-control:hover {
  background: var(--accent-soft);
}
.admin-sidebar .admin-color-control {
  margin-top: auto;
  padding: 18px 0 14px;
}
.admin-color-control .sidebar-color-mode {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 12px;
}
.sidebar-color-mode:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.sidebar-color-mode .mode-icon {
  width: 18px;
  height: 18px;
}
.admin-color-control + .admin-sidebar-bottom {
  margin-top: 0;
}
.picture-zoom {
  position: absolute;
  inset: 0;
  z-index: 3;
  cursor: zoom-in;
  background: transparent;
  border: 0;
  border-radius: inherit;
}
.picture-zoom:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: -5px;
}
.slide-outgoing {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 2;
}
.picture-viewer {
  width: fit-content;
  max-width: calc(100vw - 24px);
  height: fit-content;
  max-height: calc(100dvh - 24px);
  padding: 48px 0 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;
}
.picture-viewer::backdrop {
  background: #18202b88;
}
.viewer-stage {
  position: relative;
}
.viewer-picture {
  width: min(80vw, 800px);
  height: min(70dvh, 800px);
  position: relative;
  overflow: hidden;
}
.viewer-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.viewer-close {
  position: absolute;
  top: 4px;
  right: 0;
  width: 36px;
  height: 36px;
  border: 1px solid #ffffff66;
  border-radius: 50%;
  background: #27303ddd;
  color: #fff;
  display: grid;
  place-items: center;
  padding: 0;
  line-height: 0;
}
.control-icon {
  display: block;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.viewer-position {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #fff;
}
.picture-viewer .gallery-arrow {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid #ffffff66;
  background: #27303ddd;
  color: #fff;
  opacity: 1;
}
.picture-viewer .gallery-prev {
  left: 6px;
}
.picture-viewer .gallery-next {
  right: 6px;
}
.gallery-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}
.gallery-editor .field-label {
  font-size: 12px;
  color: var(--muted);
}
.gallery-editor > .field-help {
  margin: 12px 0 0;
  line-height: 1.8;
}
.gallery-preview-card {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--wash);
}
.gallery-preview-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.image-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 2px 8px #0002;
}
.image-remove .icon {
  width: 16px;
  height: 16px;
}
.image-remove:hover {
  color: #cf466d;
  background: var(--accent-soft);
}
.upload-preview {
  position: relative;
}
.gallery-empty {
  margin: 12px 0;
  padding: 26px 16px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
}
.gallery-links {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
}
.gallery-links summary {
  cursor: pointer;
}
.gallery-links .field {
  margin-top: 12px;
}
:root {
  color-scheme: light;
}
:root[data-color-mode="dark"] {
  color-scheme: dark;
  color: #ececf2;
  background: #191b22;
}
html[data-color-mode="dark"] body {
  --paper: #242730;
  --wash: #191b22;
  --ink: #ececf2;
  --muted: #b3b5c1;
  --line: #3a3e4b;
  --accent: #ed9caf;
  --accent-dark: #efb7c4;
  --accent-soft: #3a2934;
  color: var(--ink);
}
html[data-color-mode="dark"] .palette-lilac {
  --accent: #c8adf0;
  --accent-dark: #d6c1f2;
  --accent-soft: #322b41;
}
html[data-color-mode="dark"] .palette-mint {
  --accent: #8cceb9;
  --accent-dark: #b0e5d5;
  --accent-soft: #233b34;
}
html[data-color-mode="dark"] .palette-sky {
  --accent: #96c9f0;
  --accent-dark: #b9ddf7;
  --accent-soft: #263746;
}
html[data-color-mode="dark"] .palette-peach {
  --accent: #eabd91;
  --accent-dark: #f3d0ad;
  --accent-soft: #413128;
}
html[data-color-mode="dark"]
  :is(
    .site-header,
    .site-footer,
    .announcement,
    .search-box,
    .description-panel,
    .spec-panel,
    .admin-sidebar,
    .admin-panel,
    .stats > div,
    .login-card,
    .login-card input,
    .customer-empty,
    .tags span,
    .hero-art-note,
    .favorite,
    .round-arrow,
    .card-hover,
    .upload-controls input,
    .field input,
    .field textarea,
    .field select,
    .group-button
  ) {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}
/* Preview tiles retain the selected pattern image; a background shorthand
   would erase it and leave every option blank. */
html[data-color-mode="dark"] .pattern-swatch {
  background-color: var(--paper);
  border-color: var(--line);
}
html[data-color-mode="dark"] .pattern-swatch span {
  background: var(--wash);
  color: var(--muted);
}
html[data-color-mode="dark"] .pattern-swatch:is(:hover, .active) {
  border-color: var(--accent);
}
html[data-color-mode="dark"] .upload-preview {
  background: var(--wash);
  border-color: var(--line);
}
html[data-color-mode="dark"] :is(input, textarea, select) {
  color: var(--ink);
  caret-color: var(--ink);
}
html[data-color-mode="dark"] :is(input, textarea)::placeholder {
  color: var(--muted);
  opacity: 1;
}
html[data-color-mode="dark"] input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--paper) inset;
  caret-color: var(--ink);
}
html[data-color-mode="dark"] .login-card input:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}
html[data-color-mode="dark"] .round-arrow {
  color: var(--accent-dark);
}
html[data-color-mode="dark"] .hero-art:hover .round-arrow {
  background: var(--accent-soft);
  color: var(--accent);
}
html[data-color-mode="dark"]
  :is(
    .field,
    .field small,
    .checkbox-field,
    .login-card form > label,
    .login-card > p,
    .login-foot,
    .admin-label,
    .admin-heading p,
    .admin-sidebar nav > :is(button, a),
    .admin-sidebar-bottom,
    .admin-sidebar-bottom button,
    .stats span,
    .stats small,
    .admin-model-title span,
    .panel-top p,
    .panel-top span,
    .photo-file-info,
    .upload-progress,
    .customer-introduction,
    .customer-photo > span,
    .customer-photo-count,
    .announcement-end,
    .hero-art-note > span:first-child,
    .hero-note,
    .hero-meta,
    .english-name,
    .platform,
    .public-note,
    .footer-inner > div:last-child,
    .detail-note,
    .platform-row,
    .detail-price > span,
    .results-line,
    .collection-controls,
    .favorites-filter,
    .category-tabs button,
    .empty-state,
    .footer-inner,
    .back-link,
    .dialog-close
  ) {
  color: var(--muted);
}
html[data-color-mode="dark"] :is(.form-error, .button.danger) {
  color: #ffacb5;
}
html[data-color-mode="dark"] .danger:hover {
  background: #47232d;
  color: #ffacb5;
}
html[data-color-mode="dark"] .card-meta span:last-child {
  background: var(--accent-soft);
  border-color: var(--line);
  color: var(--muted);
}
html[data-color-mode="dark"]
  body
  :is(.favorite.selected, .detail-favorite.selected, .favorites-filter.active) {
  color: var(--accent);
}
html[data-color-mode="dark"] .admin-sidebar nav > button.active {
  color: var(--accent-dark);
}
html[data-color-mode="dark"] .category-tabs button.active {
  color: var(--wash);
}
html[data-color-mode="dark"]
  :is(.main-picture, .card-image, .gallery-thumbs button, .hero-art) {
  background: #303440;
}
html[data-color-mode="dark"]
  :is(
    .card-name,
    .detail-info h1,
    .section-heading h2,
    .hero h1,
    .admin-heading h1,
    .description-panel h2,
    .description-panel h3,
    .spec-panel h3,
    .login-card h1
  ) {
  color: var(--ink);
}
html[data-color-mode="dark"]
  :is(
    .card-summary,
    .card-meta,
    .detail-summary,
    .detail-category,
    .prose,
    .spec-panel dd,
    .hero-copy > p,
    .footer-inner p,
    .field-help,
    .panel-description
  ) {
  color: #bdc0cd;
}
html[data-color-mode="dark"] .button.primary {
  background: var(--accent);
  color: #191b22;
}
html[data-color-mode="dark"] .status-badge {
  background: #343845;
  color: #d5d8e2;
}
html[data-color-mode="dark"] .status-badge.published {
  background: #253e32;
  color: #b7dfc7;
}
html[data-color-mode="dark"] .category-tabs button.active {
  background: var(--accent);
  color: #191b22;
}
html[data-color-mode="dark"] .custom-background {
  opacity: 0.17;
}
html[data-color-mode="dark"] .floating-control {
  background: #242730;
  color: #ececf2;
  border-color: #3a3e4b;
}
@media (max-width: 950px) {
  .catalogue-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 720px) {
  .detail-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .catalogue-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px 12px;
  }
  .header-inner {
    gap: 8px;
  }
  .admin-sidebar .admin-color-control {
    grid-column: 1 / -1;
    padding: 12px 0 0;
  }
  .admin-color-control .sidebar-color-mode {
    width: auto;
    padding: 8px 11px;
    font-size: 11px;
  }
  .admin-color-control + .admin-sidebar-bottom {
    margin: 0;
  }
  .floating-control {
    width: 42px;
    height: 42px;
    bottom: max(18px, env(safe-area-inset-bottom));
    right: 16px;
  }
  .color-mode-button.above-top {
    transform: translateY(-54px);
  }
  .picture-viewer {
    padding: 48px 0 32px;
  }
  .picture-viewer .gallery-prev {
    left: 5px;
  }
  .picture-viewer .gallery-next {
    right: 5px;
  }
  .picture-viewer .gallery-arrow {
    width: 34px;
    height: 34px;
  }
  .gallery-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (prefers-reduced-motion: reduce) {
  .color-mode-button {
    transition: none;
  }
}
