.cms-page {
  background:
    linear-gradient(90deg, rgba(24, 32, 51, 0.035) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(180deg, rgba(255, 243, 214, 0.96), rgba(255, 250, 240, 0.98) 44%, rgba(8, 124, 122, 0.08)),
    var(--paper);
}

.cms-header {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(214, 166, 55, 0.08) 1px, transparent 1px) 0 0 / 28px 100%,
    rgba(255, 250, 240, 0.96);
  border-bottom: 4px double rgba(24, 32, 51, 0.44);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-height: 72px;
  padding: 0.8rem 5vw;
  position: sticky;
  top: 0;
  z-index: 10;
}

.cms-main {
  margin: 0 auto;
  max-width: 1500px;
  padding: 2rem 5vw 4rem;
}

.cms-hero {
  align-items: end;
  border-bottom: 4px double rgba(24, 32, 51, 0.34);
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
}

.cms-hero h1 {
  font-family: "Limelight", Georgia, serif;
  font-size: clamp(2rem, 5vw, 4.2rem);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.02;
  margin: 0;
  max-width: 920px;
}

.cms-meters {
  display: grid;
  gap: 0.45rem;
  min-width: 210px;
}

.cms-meters span {
  align-items: center;
  background: rgba(255, 250, 240, 0.86);
  border: 1px solid rgba(24, 32, 51, 0.16);
  display: flex;
  font-size: 0.76rem;
  font-weight: 800;
  gap: 0.45rem;
  justify-content: space-between;
  min-height: 36px;
  padding: 0.45rem 0.55rem;
  text-transform: uppercase;
}

.cms-meters strong {
  color: var(--red);
  font-family: "Limelight", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 400;
}

.cms-workbench {
  align-items: start;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(220px, 280px) minmax(360px, 1fr) minmax(320px, 420px);
}

.cms-panel {
  background: rgba(255, 250, 240, 0.94);
  border: 1px solid rgba(24, 32, 51, 0.18);
  box-shadow: 0 12px 30px rgba(17, 21, 33, 0.1);
  min-width: 0;
}

.post-rail,
.preview-panel {
  position: sticky;
  top: 96px;
}

.panel-head {
  align-items: start;
  border-bottom: 1px solid rgba(24, 32, 51, 0.14);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 1rem;
}

.panel-head.compact {
  border-top: 4px double rgba(24, 32, 51, 0.26);
  margin-top: 0.4rem;
}

.panel-head h2,
.post-group h3 {
  font-size: 0.92rem;
  line-height: 1.12;
  margin: 0;
  text-transform: uppercase;
}

.panel-head .sample-eyebrow {
  margin-bottom: 0.28rem;
}

.cms-state {
  background: var(--ink);
  color: var(--ivory);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1;
  padding: 0.5rem 0.55rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.post-group {
  padding: 1rem;
}

.post-group + .post-group {
  border-top: 4px double rgba(24, 32, 51, 0.18);
}

.post-group h3 {
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.post-list {
  display: grid;
  gap: 0.55rem;
}

.post-list-empty {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0;
}

.post-picker {
  background: var(--paper);
  border: 1px solid rgba(24, 32, 51, 0.2);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 0.25rem;
  min-height: 74px;
  padding: 0.65rem;
  text-align: left;
  width: 100%;
}

.post-picker:hover,
.post-picker.is-active {
  border-color: var(--red);
  box-shadow: inset 4px 0 0 var(--red);
}

.post-picker strong {
  font-size: 0.76rem;
  line-height: 1.18;
  text-transform: uppercase;
}

.post-picker span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.editor-panel {
  padding-bottom: 1rem;
}

.field-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 1rem 1rem 0;
}

.field-full {
  display: grid;
  gap: 0.35rem;
  padding: 1rem 1rem 0;
}

.field-grid label {
  display: grid;
  gap: 0.35rem;
}

.editor-panel label span,
.media-editor summary {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.editor-panel input,
.editor-panel select,
.editor-panel textarea {
  background: #fffdf7;
  border: 1px solid rgba(24, 32, 51, 0.24);
  color: var(--ink);
  font: inherit;
  min-height: 44px;
  padding: 0.62rem 0.72rem;
  width: 100%;
}

.editor-panel textarea {
  line-height: 1.5;
  min-height: 0;
  resize: vertical;
}

.editor-panel input:focus,
.editor-panel select:focus,
.editor-panel textarea:focus,
.cms-button:focus-visible,
.cms-small-button:focus-visible,
.gallery-action:focus-visible,
.library-thumb:focus-visible {
  outline: 3px solid rgba(214, 166, 55, 0.7);
  outline-offset: 2px;
}

.media-editor {
  padding-top: 0.25rem;
}

.gallery-list {
  display: grid;
  gap: 0.6rem;
  padding: 1rem;
}

.gallery-empty {
  background:
    linear-gradient(90deg, rgba(214, 166, 55, 0.12) 1px, transparent 1px) 0 0 / 28px 100%,
    rgba(255, 243, 214, 0.58);
  border: 1px dashed rgba(24, 32, 51, 0.28);
  color: var(--muted);
  font-size: 0.86rem;
  margin: 0;
  padding: 1rem;
}

.gallery-row {
  align-items: center;
  background: rgba(255, 243, 214, 0.48);
  border: 1px solid rgba(24, 32, 51, 0.16);
  display: grid;
  gap: 0.65rem;
  grid-template-columns: 86px minmax(0, 1fr);
  padding: 0.55rem;
}

.gallery-row.is-cover {
  border-color: rgba(214, 66, 58, 0.55);
  box-shadow: inset 4px 0 0 var(--red);
}

.gallery-thumb {
  aspect-ratio: 1;
  background:
    linear-gradient(90deg, rgba(214, 166, 55, 0.16) 1px, transparent 1px) 0 0 / 18px 100%,
    linear-gradient(180deg, var(--plum), var(--night));
  overflow: hidden;
}

.gallery-thumb img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.gallery-meta {
  display: grid;
  gap: 0.5rem;
  min-width: 0;
}

.gallery-meta input {
  min-height: 38px;
}

.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.library-picker {
  border-top: 1px solid rgba(24, 32, 51, 0.14);
  padding: 0.9rem 1rem 1rem;
}

.library-picker summary {
  cursor: pointer;
  margin-bottom: 0.75rem;
}

.library-grid {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  max-height: 250px;
  overflow: auto;
  padding-right: 0.25rem;
}

.library-thumb {
  aspect-ratio: 1;
  background:
    linear-gradient(90deg, rgba(214, 166, 55, 0.16) 1px, transparent 1px) 0 0 / 18px 100%,
    linear-gradient(180deg, var(--plum), var(--night));
  border: 1px solid rgba(24, 32, 51, 0.18);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}

.library-thumb img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.editor-actions {
  border-top: 4px double rgba(24, 32, 51, 0.2);
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1rem 1rem 0;
  padding-top: 1rem;
}

.cms-button,
.cms-small-button,
.gallery-action {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  min-height: 40px;
  padding: 0.62rem 0.78rem;
  text-transform: uppercase;
}

.cms-small-button {
  align-items: center;
  background: var(--ink);
  color: var(--ivory);
  display: inline-flex;
  min-height: 36px;
  text-decoration: none;
  white-space: nowrap;
}

.cms-small-button:hover,
.cms-button.primary:hover {
  background: var(--red);
}

.cms-button.primary {
  background: var(--ink);
  color: var(--ivory);
}

.cms-button.secondary,
.gallery-action {
  background: var(--gold);
  color: var(--ink);
}

.cms-button.ghost {
  background: transparent;
  border: 1px solid rgba(24, 32, 51, 0.28);
  color: var(--ink);
}

.cms-button.danger {
  background: #fff0ec;
  border: 1px solid rgba(214, 66, 58, 0.42);
  color: #9d2d25;
}

.gallery-action {
  min-height: 32px;
  padding: 0.45rem 0.55rem;
}

.gallery-action.danger {
  background: #fff0ec;
  color: #9d2d25;
}

.file-button {
  overflow: hidden;
  position: relative;
}

.file-button input {
  inset: 0;
  opacity: 0;
  position: absolute;
}

.preview-panel {
  overflow: hidden;
}

.preview-stack {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.preview-stack .dispatch-card {
  cursor: default;
}

.preview-stack .dispatch-card:hover {
  border-color: rgba(24, 32, 51, 0.18);
  box-shadow: 0 12px 30px rgba(17, 21, 33, 0.11);
  transform: none;
}

.preview-stack .dispatch-card.is-featured {
  grid-column: auto;
}

.preview-stack .dispatch-card.is-featured h3 {
  font-size: 1.25rem;
}

.preview-detail {
  border-top: 4px double rgba(24, 32, 51, 0.24);
  padding-top: 1rem;
}

.preview-detail h3 {
  font-family: "Limelight", Georgia, serif;
  font-size: 1.7rem;
  font-weight: 400;
  line-height: 1.06;
  margin: 0 0 0.75rem;
}

.preview-gallery {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preview-gallery figure {
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(90deg, rgba(214, 166, 55, 0.16) 1px, transparent 1px) 0 0 / 18px 100%,
    linear-gradient(180deg, var(--plum), var(--night));
  margin: 0;
  overflow: hidden;
}

.preview-gallery figure:first-child {
  grid-column: 1 / -1;
}

.preview-gallery img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.preview-copy {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .cms-workbench {
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  }

  .preview-panel {
    grid-column: 1 / -1;
    position: static;
  }
}

@media (max-width: 820px) {
  .cms-header,
  .cms-hero {
    align-items: start;
    flex-direction: column;
  }

  .cms-workbench,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .post-rail {
    position: static;
  }

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

@media (max-width: 520px) {
  .cms-main {
    padding: 1.25rem 4vw 3rem;
  }

  .gallery-row {
    grid-template-columns: 68px minmax(0, 1fr);
  }

  .library-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .editor-actions {
    display: grid;
  }
}
