.demo-index-page,
.demo-post-page {
  background: #f2f3f5;
}

.demo-library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.1rem;
}

.demo-card-item {
  position: relative;
  min-width: 0;
}

.demo-card {
  display: flex;
  height: 100%;
  min-height: 310px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #d5d9dd;
  border-radius: 0.7rem;
  color: inherit;
  background: #fff;
  box-shadow: 0 0.4rem 1.4rem rgb(33 37 41 / 7%);
  text-decoration: none;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.demo-card:hover {
  color: inherit;
  box-shadow: 0 0.8rem 2rem rgb(33 37 41 / 13%);
  transform: translateY(-3px);
}

.demo-card__preview {
  display: grid;
  min-height: 180px;
  flex: 1;
  place-items: center;
  overflow: hidden;
  color: #6c757d;
  background: linear-gradient(145deg, #fff, #edf1f4);
  font-size: 2.2rem;
}

.demo-card__preview img {
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: cover;
}

.demo-card__body {
  padding: 1rem 1.05rem;
}

.demo-card__body h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.35;
}

.demo-card__meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
  color: #6c757d;
  font-size: 0.75rem;
}

.demo-card-delete {
  position: absolute;
  z-index: 2;
  top: 0.7rem;
  right: 0.7rem;
  display: grid;
  width: 2.35rem;
  height: 2.35rem;
  place-items: center;
  border: 1px solid #f1aeb5;
  border-radius: 50%;
  color: #b02a37;
  background: rgb(255 255 255 / 94%);
  box-shadow: 0 0.25rem 0.8rem rgb(33 37 41 / 12%);
}

.demo-card-delete[hidden] {
  display: none;
}

.demo-card-delete:hover {
  color: #fff;
  background: #dc3545;
}

.demo-editor-chrome.is-sticky {
  position: sticky;
  top: calc(var(--zj-nav-height) + 0.5rem);
  z-index: 1040;
  margin-bottom: 1rem;
  border-radius: 0.6rem;
  padding-top: 0.05rem;
  background: rgb(242 243 245 / 96%);
  box-shadow: 0 0.7rem 1.4rem rgb(33 37 41 / 8%);
  backdrop-filter: blur(8px);
}

.demo-editor-chrome.is-sticky .admin-toolbar {
  margin-top: 0;
}

.demo-post {
  width: 100%;
  margin: 0;
  border: 1px solid #d5d9dd;
  border-radius: 0.75rem;
  padding: clamp(1.25rem, 3vw, 2.75rem);
  background: #fff;
  box-shadow: 0 0.5rem 1.7rem rgb(33 37 41 / 7%);
}

.demo-post__header {
  margin-bottom: 1.75rem;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 1.25rem;
}

.demo-post__header h1 {
  max-width: 950px;
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.65rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

.demo-post__date {
  display: block;
  margin: 0.45rem 0 0;
  color: #6c757d;
  font-size: 0.78rem;
}

.demo-post__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.5rem;
}

.demo-post__layout:has(.demo-toc:not([hidden])) {
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr);
}

.demo-toc {
  position: sticky;
  top: calc(var(--zj-nav-height) + 1rem);
  align-self: start;
  border-left: 3px solid #0d6efd;
  padding: 0.2rem 0 0.2rem 0.8rem;
  font-size: 0.8rem;
}

.demo-toc nav {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.demo-toc a {
  color: #6c757d;
  text-decoration: none;
}

.demo-toc a:hover {
  color: #0d6efd;
}

.demo-content {
  min-width: 0;
}

.demo-content > * + * {
  margin-top: 1rem;
}

.demo-section {
  border: 1px solid #e2e6ea;
  border-radius: 0.65rem;
  padding: 1rem;
  background: #fff;
  box-shadow: 0 0.3rem 1rem rgb(33 37 41 / 5%);
}

.demo-section + .demo-section {
  margin-top: 1.1rem;
}

.demo-section h2 {
  margin: 0 0 0.85rem;
  font-size: 1.2rem;
  font-weight: 800;
}

.demo-media-titles {
  border-radius: 0.35rem;
  padding: 0.45rem 0.65rem;
  background: #f8f9fa;
  font-size: 0.84rem;
  font-weight: 600;
}

.demo-media-titles p {
  margin: 0;
}

.demo-media-titles p + p {
  margin-top: 0.35rem;
}

.demo-media-titles i {
  margin-right: 0.3rem;
  color: #6c757d;
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(var(--demo-columns, 2), minmax(0, 1fr));
  gap: 0.85rem;
}

.demo-grid--1 { --demo-columns: 1; }
.demo-grid--2 { --demo-columns: 2; }
.demo-grid--3 { --demo-columns: 3; }
.demo-grid--4 { --demo-columns: 4; }

.demo-grid-column {
  min-width: 0;
  border: 1px dashed #ced4da;
  border-radius: 0.45rem;
  padding: 0.75rem;
}

.demo-grid-column > :last-child {
  margin-bottom: 0;
}

.demo-media-item {
  min-width: 0;
  margin: 0;
}

.demo-media-caption {
  min-height: 1.2em;
  text-align: left;
}

.demo-media-caption:empty {
  display: none;
}

.demo-media-frame {
  position: relative;
  overflow: hidden;
  border-radius: 0.45rem;
  background: #111;
}

.demo-media-frame--1x1 { aspect-ratio: 1; }
.demo-media-frame--4x3 { aspect-ratio: 4 / 3; }
.demo-media-frame--16x9 { aspect-ratio: 16 / 9; }
.demo-media-frame--21x9 { aspect-ratio: 21 / 9; }

.demo-media-frame img,
.demo-media-frame video,
.demo-media-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.demo-content > img,
.demo-content video,
.demo-content iframe,
.demo-grid-column img,
.demo-grid-column video,
.demo-grid-column iframe {
  max-width: 100%;
}

.demo-post:not(.is-editing) .demo-content img {
  cursor: zoom-in;
}

.demo-media-preview {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  color: #fff;
  background: transparent;
}

.demo-media-preview::backdrop {
  background: rgb(7 10 15 / 88%);
  backdrop-filter: blur(5px);
}

.demo-media-preview__frame {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: clamp(1.25rem, 4vw, 3.5rem);
}

.demo-media-preview__frame img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 0.35rem;
  object-fit: contain;
  box-shadow: 0 1.2rem 4rem rgb(0 0 0 / 42%);
}

.demo-media-preview__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  width: 2.6rem;
  height: 2.6rem;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 50%;
  color: #fff;
  background: rgb(0 0 0 / 55%);
  font-size: 1rem;
}

.demo-media-preview__close:hover {
  background: rgb(0 0 0 / 82%);
}

.demo-media-preview__hint {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  margin: 0;
  color: rgb(255 255 255 / 72%);
  font-size: 0.75rem;
  transform: translateX(-50%);
}

.demo-media-preview__hint kbd {
  padding: 0.12rem 0.4rem;
}

.demo-post.is-editing iframe,
.demo-post.is-editing video {
  pointer-events: none;
}

.demo-post.is-editing [data-demo-media],
.demo-post.is-editing .demo-grid-column,
.demo-post.is-editing .demo-section {
  outline: 2px dashed rgb(13 110 253 / 22%);
  outline-offset: 2px;
}

@media (max-width: 991px) {
  .demo-library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .demo-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .demo-library-grid,
  .demo-post__layout:has(.demo-toc:not([hidden])),
  .demo-grid {
    grid-template-columns: 1fr;
  }

  .demo-toc {
    position: static;
  }

  .demo-card {
    min-height: 280px;
  }
}
