#tab-custom-grids {
  height: 100%;
}

.custom-grid-panel {
  --custom-grid-height: calc(100dvh - 190px);
  gap: 16px;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

.custom-grid-actions,
.custom-grid-detail-actions,
.custom-grid-entry-actions,
.custom-grid-save-row,
.custom-grid-rail-actions,
.custom-grid-tool-actions,
.custom-grid-cache-actions,
.custom-grid-cache-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.custom-grid-layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.custom-grid-rail,
.custom-grid-detail {
  position: relative;
  display: grid;
  align-content: start;
  min-width: 0;
  min-height: 0;
  border: var(--border-width) solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
  padding: 12px;
  overflow: auto;
}

.custom-grid-toolbar,
.custom-grid-detail-head,
.custom-grid-tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.custom-grid-detail-head {
  align-items: flex-start;
}

.custom-grid-status,
.custom-grid-empty,
.custom-grid-item-copy span,
.custom-grid-item small,
.custom-grid-detail-head span,
.custom-grid-section-head span,
.custom-grid-tool-head span,
.custom-grid-tool-status span:last-child,
.custom-grid-bridge-status span:last-child,
.custom-grid-cache-status span:last-child,
.custom-grid-entry-copy span,
.custom-grid-technical {
  color: var(--muted);
  font-size: 13px;
}

.custom-grid-list {
  position: relative;
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.custom-grid-loading {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 180px;
  padding: 22px;
  border: var(--border-width) solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
  color: #dce4ec;
  font-family: var(--font-display);
  font-size: 14px;
  text-transform: uppercase;
}

.custom-grid-loading .button-spinner {
  width: 22px;
  height: 22px;
}

.custom-grid-loading-overlay {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: rgba(5, 7, 10, 0.72);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.custom-grid-loading-overlay .custom-grid-loading {
  min-width: 220px;
  min-height: 0;
}

.custom-grid-rail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.custom-grid-rail-actions button:first-child {
  grid-column: 1 / -1;
}

.custom-grid-bridge-tools {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: var(--border-width) solid var(--line-soft);
  background: rgba(255, 255, 255, 0.02);
}

.custom-grid-tool-head {
  gap: 8px;
}

.custom-grid-tool-head strong {
  color: #fff;
}

.custom-grid-tool-status {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.custom-grid-tool-status span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-grid-tool-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.custom-grid-tool-actions button {
  min-width: 0;
}

.custom-grid-bridge-install.primary {
  border-color: var(--accent-green);
  background: #1c7f14;
  color: #fff;
  font-weight: 800;
}

.custom-grid-bridge-install.primary:hover,
.custom-grid-bridge-install.primary:focus-visible {
  border-color: #7cff6e;
  background: #239b19;
}

.custom-grid-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: var(--border-width) solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
  text-align: left;
}

.custom-grid-item.active {
  border-color: var(--accent);
  background: rgba(23, 195, 178, 0.08);
}

.custom-grid-mark {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1 / 1;
  border: var(--border-width) solid var(--line-soft);
  background: #0c0f14;
  color: #fff;
  overflow: hidden;
}

.custom-grid-mark span {
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.custom-grid-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-grid-entry-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.custom-grid-entry-thumb span {
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.custom-grid-mark.is-large {
  width: 112px;
}

.custom-grid-item-copy,
.custom-grid-entry-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.custom-grid-item-copy strong,
.custom-grid-item-copy span,
.custom-grid-item small,
.custom-grid-entry-copy strong,
.custom-grid-entry-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-grid-item-copy strong,
.custom-grid-detail-head strong {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.custom-grid-item-copy strong > span:first-child,
.custom-grid-detail-head strong > span:first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--accent-3);
  font-size: 17px;
}

.custom-grid-active-pill {
  flex: 0 0 auto;
  min-height: 20px;
  padding: 0 7px;
  font-size: 11px;
}

.custom-grid-item-active-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 94px;
  min-height: 52px;
}

.custom-grid-detail {
  gap: 14px;
}

.custom-grid-detail-head > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
  max-width: min(360px, 40%);
}

.custom-grid-title-block h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.custom-grid-subtitle {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.25;
}

.custom-grid-bridge-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
  padding: 10px;
  border: var(--border-width) solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
}

.custom-grid-bridge-status span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-grid-action-status {
  display: grid;
  justify-items: end;
  gap: 4px;
  flex: 1 1 230px;
  min-width: 190px;
  max-width: 320px;
  margin-right: 2px;
  text-align: right;
}

.custom-grid-action-status span:last-child {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.custom-grid-detail-actions {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.custom-grid-detail-actions button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.custom-grid-white-icon {
  color: #fff;
}

.custom-grid-white-icon .button-icon,
.custom-grid-white-icon .button-icon svg,
.custom-grid-white-icon .button-icon path {
  color: #fff;
  stroke: #fff !important;
}

.custom-grid-detail-actions .icon-text,
.custom-grid-add-row .icon-text,
.custom-grid-save-row .icon-text {
  white-space: nowrap;
}

.custom-grid-editor-grid {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.custom-grid-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

#addCustomGridSkin {
  min-width: 150px;
}

.custom-grid-preview-box {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: var(--border-width) solid var(--line-soft);
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.custom-grid-preview-stage {
  display: grid;
  place-items: center;
  min-height: 116px;
}

.custom-grid-preview-stage .custom-grid-mark {
  width: min(100%, 132px);
}

.custom-grid-preview-box button {
  width: 100%;
}

.custom-grid-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.custom-grid-editor-grid label,
.custom-grid-add-row label,
.custom-grid-entry label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.custom-grid-editor-grid input,
.custom-grid-add-row select,
.custom-grid-entry input,
.custom-grid-entry select {
  width: 100%;
}

.custom-grid-entry-list {
  display: grid;
  gap: 8px;
}

.custom-grid-entry {
  display: grid;
  grid-template-columns: 52px 52px minmax(150px, 1.1fr) minmax(140px, 0.9fr) minmax(130px, 0.7fr) minmax(130px, 0.7fr) auto;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border: var(--border-width) solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
}

.custom-grid-entry-thumb {
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1 / 1;
  border: var(--border-width) solid var(--line-soft);
  background: #0c0f14;
  color: #fff;
  overflow: hidden;
}

.custom-grid-entry-index {
  align-self: center;
  display: grid;
  place-items: center;
  width: 52px;
  aspect-ratio: 1 / 1;
  border: var(--border-width) solid var(--line-soft);
  color: #fff;
  font-weight: 700;
}

.custom-grid-item-copy strong,
.custom-grid-entry-copy strong {
  color: #fff;
}

.custom-grid-entry-copy {
  align-self: center;
}

.custom-grid-entry-actions {
  align-self: end;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.custom-grid-entry-actions .icon-text svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.custom-grid-detail-actions .button-icon svg,
.custom-grid-add-row .button-icon svg,
.custom-grid-save-row .button-icon svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#saveCustomGrid {
  min-width: 170px;
}

.custom-grid-technical {
  border-top: var(--border-width) solid var(--line-soft);
  padding-top: 10px;
}

.custom-grid-technical summary {
  cursor: pointer;
  color: #fff;
}

.custom-grid-technical pre {
  margin: 10px 0 0;
  white-space: pre-wrap;
}

.custom-grid-cache-status {
  margin-top: 10px;
  min-width: 0;
}

.custom-grid-cache-status span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-grid-cache-actions {
  margin-top: 10px;
}

.custom-grid-guide-modal .status-modal-dialog {
  width: min(760px, calc(100vw - 80px));
}

.custom-grid-guide-image-slot {
  display: grid;
  place-items: center;
  width: 100%;
  border: var(--border-width) dashed var(--line-soft);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)),
    #0c0f14;
  color: var(--muted);
  overflow: hidden;
}

.custom-grid-guide-image-slot img {
  display: block;
  width: 100%;
  height: auto;
}

.custom-grid-guide-image-slot span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

@media (max-width: 1280px) {
  .custom-grid-layout,
  .custom-grid-editor-grid {
    grid-template-columns: 1fr;
  }

  .custom-grid-detail-head {
    display: grid;
    align-items: start;
  }

  .custom-grid-detail-head > div:first-child {
    max-width: none;
  }

  .custom-grid-detail-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .custom-grid-preview-box {
    grid-row: auto;
  }

  .custom-grid-entry {
    grid-template-columns: 52px 52px minmax(0, 1fr);
    align-items: start;
  }

  .custom-grid-entry label,
  .custom-grid-entry-actions {
    grid-column: 3;
  }

  .custom-grid-entry-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .custom-grid-entry-copy {
    grid-column: 3;
  }
}
