.product-space-view,
.product-space-dialog,
.product-catalog-editor,
.app-shell:has(.product-space-view) {
  --ps-bg: #0b1116;
  --ps-card: #141f25;
  --ps-raised: #1b2b31;
  --ps-line: #2d3f46;
  --ps-ink: #eef7f6;
  --ps-muted: #a6b8bf;
  --ps-mint: #69e1cb;
  --ps-amber: #ffc990;
  color: var(--ps-ink);
  color-scheme: dark;
}

.app-shell:has(.product-space-view) { background: var(--ps-bg); }
.app-shell:has(.product-space-view) > .rail { background: linear-gradient(152deg, #142626, #111920 72%); }
.app-shell:has(.product-space-view) :is(.step-button.active, .step-button:hover) { border-color: #3c635e; background: #1a3334; }
.app-shell:has(.product-space-view) .step-button.active .step-index { color: var(--ps-mint); }

.workspace:has(.product-space-view) > .topbar {
  --ink: var(--ps-ink);
  --muted: var(--ps-muted);
  --line: var(--ps-line);
  --surface: var(--ps-card);
  color: var(--ps-ink);
}
.workspace:has(.product-space-view) > .topbar :is(button, select) { background: var(--ps-card); color: var(--ps-ink); border-color: var(--ps-line); }
.main-panel:has(.product-space-view) { border: 0; padding: 0; background: none; box-shadow: none; }
.product-space-view { container-type: inline-size; display: grid; gap: 15px; }

.product-space-banner {
  position: relative;
  isolation: isolate;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid #33464b;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(110deg, #142623, #19252a 65%, #131a24);
}

.product-space-banner::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image: linear-gradient(#69e1cb1b 1px, transparent 1px), linear-gradient(90deg, #69e1cb1b 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(90deg, transparent 22%, #000);
  content: "";
}

.product-space-banner::after {
  position: absolute;
  inset: auto auto 0 0;
  width: 70px;
  height: 2px;
  background: var(--ps-mint);
  content: "";
}

.product-space-banner h3 { margin: 3px 0 0; font-size: 23px; line-height: 1.2; }
.product-space-kicker { color: var(--ps-mint); font: 700 12px/1.35 ui-monospace, monospace; }
.product-space-kicker i { display: inline-block; width: 6px; height: 6px; margin: 0 6px 2px 1px; border: 1px solid currentColor; transform: rotate(45deg); }
.product-space-controls, .product-space-switch, .product-space-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.product-space-switch { gap: 3px; padding: 3px; border: 1px solid var(--ps-line); border-radius: 7px; background: #0e1a1e; }

.product-space-switch button,
.product-space-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 11px;
  border: 1px solid var(--ps-line);
  border-radius: 6px;
  background: var(--ps-raised);
  color: var(--ps-ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.3;
  white-space: normal;
  transition: border-color 150ms, background-color 150ms, transform 150ms;
}
.product-space-switch button { min-height: 30px; border-color: transparent; background: transparent; color: var(--ps-muted); }
.product-space-switch button[aria-pressed="true"] { border-color: #3c635e; background: #243b3a; color: var(--ps-mint); }
.product-space-button.primary { color: #0b2922; background: var(--ps-mint); border-color: var(--ps-mint); }
.product-space-button.icon { flex: 0 0 36px; width: 36px; padding: 0; }
.product-space-button:hover:not(:disabled), .product-space-switch button:hover { border-color: #6bb4a7; transform: translateY(-1px); }
.product-space-button.primary:hover:not(:disabled) { background: #91eddb; }
.product-space-button:disabled { opacity: .55; }
.product-icon { flex: none; vertical-align: middle; }

.product-space-filters { gap: 9px; }
.product-space-search {
  display: flex;
  align-items: center;
  gap: 7px;
  width: min(330px, 100%);
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--ps-line);
  border-radius: 7px;
  background: var(--ps-card);
  color: var(--ps-muted);
}
.product-space-search input { border: 0; width: 100%; min-width: 0; padding: 8px 0; color: var(--ps-ink); background: transparent; }
.product-space-search input::placeholder { color: var(--ps-muted); }
.product-space-search:focus-within { border-color: var(--ps-mint); }
.product-space-filters select { min-height: 40px; max-width: 100%; color: var(--ps-ink); background: var(--ps-card); border-color: var(--ps-line); }
.product-space-filters output { margin-inline-start: auto; color: var(--ps-muted); font-size: 13px; }

.product-space-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 12px; align-items: start; }
.product-tile {
  display: grid;
  grid-template-columns: minmax(0, 41%) minmax(0, 1fr);
  min-width: 0;
  height: 166px;
  padding: 0;
  border: 1px solid var(--ps-line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--ps-card);
  color: var(--ps-ink);
  text-align: left;
  transition: transform 160ms, border-color 160ms, background-color 160ms;
}
.product-tile:hover { border-color: #5b9289; background: var(--ps-raised); transform: translateY(-2px); }
.product-tile:active { transform: none; }
.product-tile-info { display: grid; grid-template-rows: auto auto minmax(20px, 1fr) auto; min-width: 0; min-height: 0; padding: 13px; gap: 6px; }
.product-tile-kind, .product-tile-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.product-tile-kind { color: var(--ps-mint); }
.product-tile-meta { color: var(--ps-muted); }
.product-tile-info strong { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 17px; line-height: 1.28; overflow-wrap: anywhere; }
.product-tile-foot { display: flex; justify-content: space-between; align-items: center; min-width: 0; gap: 4px; color: var(--ps-amber); font-size: 13px; overflow-wrap: anywhere; }
.product-tile-foot .product-icon { color: var(--ps-mint); transition: transform 150ms; }
.product-tile:hover .product-tile-foot .product-icon { transform: translateX(2px); }

.product-space-cover { position: relative; isolation: isolate; display: grid; place-items: center; min-height: 0; min-width: 0; overflow: hidden; background: #10181c; }
.product-tile .product-space-cover { border-right: 1px solid var(--ps-line); }
.product-space-cover::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image: linear-gradient(#56736b23 1px, transparent 1px), linear-gradient(90deg, #56736b23 1px, transparent 1px);
  background-size: 22px 22px;
  content: "";
}
.product-space-cover img { position: absolute; inset: 0; width: 100%; height: 100%; background: #11191d; object-fit: contain; }
.product-space-cover-empty { display: grid; justify-items: center; gap: 8px; padding: 8px; text-align: center; color: var(--ps-muted); font-size: 12px; }
.product-space-cover-empty .product-icon { width: 25px; height: 25px; color: var(--ps-mint); }
.product-space-empty { grid-column: 1 / -1; display: grid; justify-items: center; gap: 10px; padding: 50px 14px; color: var(--ps-muted); }
.product-space-empty .product-icon { width: 28px; height: 28px; color: var(--ps-mint); }

.product-space-dialog,
.product-catalog-editor {
  --ink: var(--ps-ink);
  --muted: var(--ps-muted);
  --line: var(--ps-line);
  --surface: var(--ps-card);
  --accent: var(--ps-mint);
  background: var(--ps-bg);
  border: 1px solid #3c5d5f;
  border-radius: 8px;
  color: var(--ps-ink);
}

.product-space-dialog[open] {
  display: grid;
  position: fixed;
  inset: 0;
  width: min(820px, calc(100vw - 26px));
  max-width: none;
  max-height: calc(100dvh - 28px);
  padding: 0;
  margin: auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  animation: product-dialog-in 160ms ease-out;
}
.product-space-dialog:not([open]) { display: none; }
.product-space-dialog::backdrop, .product-catalog-backdrop { background: #050a0dd9; backdrop-filter: blur(5px); }
@keyframes product-dialog-in { from { transform: translateY(7px); opacity: .65; } }

:is(.product-space-dialog, .product-catalog-editor) .modal-head { background: var(--ps-card); color: var(--ps-ink); }
:is(.product-space-dialog, .product-catalog-editor) .modal-head h3 { overflow-wrap: anywhere; }
:is(.product-space-dialog, .product-catalog-editor) .eyebrow { color: var(--ps-mint); overflow-wrap: anywhere; }
.product-space-dialog .modal-body { min-height: 0; overflow: auto; overscroll-behavior: contain; }
.product-space-dialog .modal-actions { background: var(--ps-card); }
.product-assignment-dialog[open] { grid-template-rows: minmax(0, 1fr); }
.product-assignment-dialog > form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; }

.product-detail-intro { display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); gap: 16px; align-items: start; }
.product-detail-intro .product-space-cover { aspect-ratio: 4 / 3; border: 1px solid var(--ps-line); border-radius: 6px; }
.product-detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; margin: 0; }
.product-detail-list > div { min-width: 0; padding: 8px 0; border-bottom: 1px solid var(--ps-line); }
.product-detail-list dt { margin: 0 0 3px; font-size: 12px; color: var(--ps-muted); overflow-wrap: anywhere; }
.product-detail-list dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.5; }
.product-detail-list.compact { gap: 0 11px; }
.product-description { margin-top: 17px; }
.product-description h4 { margin: 0 0 5px; font-size: 16px; }
.product-muted { color: var(--ps-muted); }
.product-attachment-links { margin: 0; padding-inline-start: 19px; display: grid; gap: 5px; overflow-wrap: anywhere; }
.product-attachment-links a { color: var(--ps-mint); }
.product-attachment-links svg { margin-left: 5px; width: 14px; height: 14px; }

.product-assignment-dialog fieldset { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.product-assignment-dialog legend { padding: 0; margin-bottom: 9px; font-size: 15px; font-weight: 800; }
.product-assignment-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); gap: 7px; }
.product-assignment-option { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--ps-line); border-radius: 6px; background: var(--ps-card); cursor: pointer; }
.product-assignment-option:has(input:checked) { border-color: #4b8b7d; background: #1a3833; }
.product-assignment-option input { flex: none; accent-color: var(--ps-mint); }
.product-assignment-option span { min-width: 0; overflow-wrap: anywhere; }
.product-assignment-option strong { display: block; font-size: 13px; }
.product-assignment-option small { color: var(--ps-muted); }
#productAssignmentStatus, #productCoverStatus { color: var(--ps-amber); margin: 0; overflow-wrap: anywhere; }
#productAssignmentStatus:empty, #productCoverStatus:empty { display: none; }

.product-cover-edit { display: grid; grid-template-columns: minmax(92px, 162px) minmax(0, 1fr); align-items: start; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--ps-line); }
.product-cover-edit .product-space-cover { aspect-ratio: 4 / 3; border: 1px solid var(--ps-line); border-radius: 6px; }
.product-cover-inputs { display: grid; justify-items: start; gap: 7px; min-width: 0; }
.product-cover-inputs .field { width: 100%; }
.product-catalog-editor :is(input:not([type="checkbox"]), textarea, select, .icon-button, .secondary-button, .mini-check, .attachment-panel, .attachment-row, .attachment-upload) {
  background: var(--ps-card); border-color: var(--ps-line); color: var(--ps-ink);
}
.product-catalog-editor :is(input, textarea)::placeholder { color: var(--ps-muted); }
.product-catalog-editor .primary-button { background: var(--ps-mint); border-color: var(--ps-mint); color: #0b2922; }
.product-catalog-editor .danger-button { background: #3a2028; border-color: #69444e; color: #ffadb7; }
:is(.product-space-view, .product-space-dialog, .product-catalog-editor) :focus-visible { outline: 2px solid var(--ps-mint); outline-offset: 2px; }
.product-space-search input:focus-visible { outline: none; }

@container (max-width: 520px) {
  .product-space-banner { align-items: start; flex-direction: column; padding: 13px; }
  .product-space-controls { width: 100%; justify-content: space-between; }
  .product-space-search { width: 100%; }
  .product-tile { height: 145px; grid-template-columns: minmax(0, 35%) minmax(0, 1fr); }
  .product-tile-info { padding: 10px; }
  .product-tile-info strong { font-size: 16px; }
}

@media (max-width: 550px) {
  .product-detail-intro { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .product-detail-intro .product-space-cover { max-height: 240px; }
  .product-detail-list:not(.compact) { grid-template-columns: minmax(0, 1fr); }
  .product-cover-edit { grid-template-columns: minmax(0, 1fr); }
  #productCoverEditPreview { width: min(160px, 100%); }
}

@media (prefers-reduced-motion: reduce) {
  .product-space-dialog[open] { animation: none; }
  .product-tile, .product-tile-foot .product-icon, .product-space-button, .product-space-switch button { transition: none; transform: none; }
}
