.zml-manage-host {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(16, 42, 67, .08);
  overflow: hidden;
}

.zml-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3vh 3vw;
  background: rgba(10, 25, 45, .58);
  box-sizing: border-box;
}

.zml-overlay:not(.active).zml-editor-overlay {
  display: none;
}

.zml-overlay:not(.active).zml-tag-manager-overlay {
  display: none;
}

.zml-overlay:not(.active).zml-category-manager-overlay {
  display: none;
}

.zml-dialog {
  width: min(1180px, 96vw);
  height: min(860px, 92vh);
  background: #f6f8fb;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(5, 20, 40, .28);
  display: flex;
  flex-direction: column;
}

.zml-root {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.zml-head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.zml-title {
  color: #173a5e;
  font-size: 18px;
  font-weight: 750;
}

.zml-sub {
  margin-top: 3px;
  color: #7a8ba0;
  font-size: 12px;
  line-height: 1.55;
}

.zml-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zml-icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: #edf1f6;
  color: #33415c;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.zml-body {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
}

.zml-side {
  overflow: auto;
  padding: 16px 12px;
  background: #fff;
  border-right: 1px solid #e2e8f0;
}

.zml-side-title {
  padding: 0 7px 9px;
  color: #60758c;
  font-size: 12px;
  font-weight: 700;
}

.zml-side-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.zml-side-title-row button {
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: #eef3f8;
  color: #526b84;
  font-size: 11px;
  cursor: pointer;
}

.zml-cats {
  display: grid;
  gap: 3px;
}

.zml-cats button {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #40556d;
  text-align: left;
  cursor: pointer;
}

.zml-cats button.active,
.zml-cats button:hover {
  background: #edf4fb;
  color: #174a78;
}

.zml-cats button span {
  color: #91a0b2;
  font-size: 11px;
}

.zml-main {
  min-width: 0;
  overflow: auto;
  padding: 14px 16px 22px;
}

.zml-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.zml-toolbar input,
.zml-toolbar select,
.zml-editor-form input,
.zml-editor-form select,
.zml-editor-form textarea {
  border: 1px solid #d8e2ec;
  border-radius: 8px;
  background: #fff;
  color: #33415c;
  font-size: 13px;
  padding: 8px 10px;
  box-sizing: border-box;
}

.zml-toolbar input[type="search"] {
  flex: 1 1 260px;
  min-width: 220px;
}

.zml-toolbar select[data-zml-tag] {
  width: 150px;
  max-width: 190px;
}

.zml-upload-zone {
  margin-top: 10px;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 15px;
  border: 1px dashed #b9c8d9;
  border-radius: 10px;
  background: #fbfdff;
  box-sizing: border-box;
}

.zml-upload-zone.dragging {
  border-color: #2d6ca2;
  background: #eef7ff;
}

.zml-upload-zone b {
  display: block;
  color: #264b6c;
  font-size: 13px;
}

.zml-upload-zone span {
  display: block;
  margin-top: 3px;
  color: #8494a6;
  font-size: 12px;
}

.zml-upload-status {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  font-size: 12px;
}

.zml-upload-status > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 8px;
  border-radius: 7px;
  background: #eef3f8;
  color: #52677e;
}

.zml-upload-status .error,
.zml-empty.error {
  color: #b42318;
}

.zml-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 12px 2px 8px;
  color: #7a8ba0;
  font-size: 12px;
}

.zml-batch-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid #cbdbea;
  border-radius: 9px;
  background: #eef5fb;
}

.zml-batch-summary,
.zml-batch-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.zml-batch-summary b {
  color: #234d73;
  font-size: 12px;
}

.zml-batch-actions select {
  min-width: 118px;
  max-width: 210px;
  padding: 5px 8px;
  border: 1px solid #cbd9e6;
  border-radius: 7px;
  background: #fff;
  color: #405a73;
  font-size: 12px;
}

.zml-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
}

.zml-card {
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dde6ef;
  border-radius: 11px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}

.zml-card:hover {
  border-color: #87aaca;
  box-shadow: 0 6px 18px rgba(24, 61, 95, .12);
  transform: translateY(-1px);
}

.zml-card.selected {
  border-color: #c8a96a;
  box-shadow: inset 0 0 0 2px #c8a96a;
}

.zml-card.unavailable {
  opacity: .6;
}

.zml-thumb {
  position: relative;
  height: 118px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(145deg, #eef3f8, #dfe8f2);
  color: #52677e;
  font-size: 34px;
}

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

.zml-image-transform-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.zml-image-transform-bar span {
  color: #7a8ba0;
  font-size: 11px;
}

.zml-transform-overlay {
  z-index: 390;
}

.zml-transform-dialog {
  width: min(980px, 96vw);
  height: min(760px, 92vh);
}

.zml-transform-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}

.zml-transform-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.zml-transform-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #52677e;
  font-size: 12px;
}

.zml-transform-toolbar select {
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid #d8e2ec;
  border-radius: 7px;
  background: #fff;
  color: #33415c;
  font-size: 12px;
}

[data-zml-transform-size] {
  margin-left: auto;
  color: #60758c;
  font-size: 12px;
}

.zml-transform-stage {
  flex: 1;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid #d8e2ec;
  border-radius: 12px;
  background:
    linear-gradient(45deg, #eef2f6 25%, transparent 25%) 0 0 / 20px 20px,
    linear-gradient(-45deg, #eef2f6 25%, transparent 25%) 0 10px / 20px 20px,
    linear-gradient(45deg, transparent 75%, #eef2f6 75%) 10px -10px / 20px 20px,
    linear-gradient(-45deg, transparent 75%, #eef2f6 75%) -10px 0 / 20px 20px,
    #fbfcfd;
}

.zml-transform-stage canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  user-select: none;
}

.zml-crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #c8a96a;
  box-shadow: 0 0 0 9999px rgba(8, 24, 42, .45);
  cursor: move;
  touch-action: none;
}

.zml-crop-box::before,
.zml-crop-box::after {
  content: '';
  position: absolute;
  pointer-events: none;
  background: rgba(255,255,255,.48);
}

.zml-crop-box::before {
  left: 33.333%;
  right: 33.333%;
  top: 0;
  bottom: 0;
  border-left: 1px dashed rgba(255,255,255,.9);
  border-right: 1px dashed rgba(255,255,255,.9);
}

.zml-crop-box::after {
  top: 33.333%;
  bottom: 33.333%;
  left: 0;
  right: 0;
  border-top: 1px dashed rgba(255,255,255,.9);
  border-bottom: 1px dashed rgba(255,255,255,.9);
}

.zml-crop-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #c8a96a;
  touch-action: none;
  z-index: 2;
}

[data-zml-crop-handle="nw"] { left: -7px; top: -7px; cursor: nwse-resize; }
[data-zml-crop-handle="ne"] { right: -7px; top: -7px; cursor: nesw-resize; }
[data-zml-crop-handle="sw"] { left: -7px; bottom: -7px; cursor: nesw-resize; }
[data-zml-crop-handle="se"] { right: -7px; bottom: -7px; cursor: nwse-resize; }

.zml-transform-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.zml-badges {
  position: absolute;
  inset: 6px 6px auto;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.zml-badges i,
.zml-badges label {
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(13, 38, 64, .8);
  color: #fff;
  font-size: 11px;
  font-style: normal;
}

.zml-badges input {
  vertical-align: -2px;
}

.zml-card-body {
  padding: 9px 10px 6px;
}

.zml-card-title {
  overflow: hidden;
  color: #273f5a;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zml-meta {
  overflow: hidden;
  margin-top: 3px;
  color: #8392a4;
  font-size: 11px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zml-tags {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.zml-tags span {
  padding: 2px 5px;
  border-radius: 5px;
  background: #eef4fa;
  color: #4b6784;
  font-size: 10px;
}

.zml-card-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  padding: 0 9px 9px;
}

.zml-btn {
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: #173f66;
  color: #fff;
  font-size: 12.5px;
  cursor: pointer;
}

.zml-btn.gold {
  background: #b7954f;
}

.zml-btn.gray {
  background: #e9eef4;
  color: #344f6a;
}

.zml-btn.danger {
  background: #b42318;
}

.zml-btn.small {
  min-height: 27px;
  padding: 4px 8px;
  font-size: 11px;
}

.zml-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.zml-empty {
  grid-column: 1 / -1;
  padding: 45px 20px;
  border: 1px dashed #cbd7e4;
  border-radius: 10px;
  color: #8292a4;
  text-align: center;
}

.zml-pager {
  margin-top: 14px;
}

.zml-pager-jump {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #6b7e92;
  font-size: 12px;
}

.zml-pager-jump input {
  width: 60px;
  min-height: 30px;
  padding: 3px 6px;
  border: 1px solid #d8e2ec;
  border-radius: 7px;
  background: #fff;
  color: #33415c;
  font-size: 12px;
  box-sizing: border-box;
}

.zml-foot {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  color: #6b7e92;
  font-size: 13px;
}

.zml-foot > div {
  display: flex;
  gap: 8px;
}

.zml-editor-overlay {
  z-index: 310;
}

.zml-tag-manager-overlay {
  z-index: 320;
}

.zml-category-manager-overlay {
  z-index: 320;
}

.zml-editor-dialog {
  width: min(920px, 94vw);
  height: auto;
  max-height: 92vh;
}

.zml-editor-body {
  overflow: auto;
  padding: 18px 20px 22px;
  background: #f7f9fc;
}

.zml-editor-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 18px;
}

.zml-editor-preview {
  padding: 12px;
  border: 1px solid #e0e7ef;
  border-radius: 10px;
  background: #fff;
}

.zml-editor-preview img,
.zml-editor-preview video {
  display: block;
  width: 100%;
  max-height: 330px;
  object-fit: contain;
  border-radius: 8px;
  background: #0f2440;
}

.zml-video-state {
  min-height: 230px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  border-radius: 8px;
  background: #0f2440;
  color: #dce9f7;
  text-align: center;
}

.zml-video-state span {
  max-width: 320px;
  color: #aebfd2;
  font-size: 12px;
  line-height: 1.65;
}

.zml-video-state.error b {
  color: #ffb4ab;
}

.zml-zoom-stage {
  width: 100%;
  max-height: 330px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #0f2440;
}

.zml-zoom-stage img {
  max-height: 330px;
  transform-origin: center center;
  transition: transform .08s ease-out;
  user-select: none;
  will-change: transform;
}

.zml-editor-form {
  display: grid;
  gap: 4px;
}

.zml-editor-form label {
  margin-top: 8px;
  color: #425a73;
  font-size: 12px;
  font-weight: 650;
}

.zml-editor-form input,
.zml-editor-form select,
.zml-editor-form textarea {
  width: 100%;
}

.zml-tag-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 6px;
}

.zml-tag-choice-list button {
  min-height: 29px;
  padding: 4px 9px;
  border: 1px solid #d5e0ea;
  border-radius: 999px;
  background: #fff;
  color: #49627c;
  font-size: 12px;
  cursor: pointer;
}

.zml-tag-choice-list button[aria-pressed="true"] {
  border-color: #b7954f;
  background: #f7edd8;
  color: #6d4d15;
  box-shadow: inset 0 0 0 1px #b7954f;
}

.zml-tag-entry {
  display: flex;
  gap: 7px;
  align-items: center;
}

.zml-tag-create-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 7px;
}

.zml-tag-manager-dialog {
  width: min(660px, 94vw);
  height: auto;
  max-height: 82vh;
}

.zml-tag-manager-body {
  overflow: auto;
  padding: 18px 20px 22px;
  background: #f7f9fc;
}

.zml-tag-manager-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.zml-tag-manager-create input {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid #d8e2ec;
  border-radius: 8px;
  background: #fff;
  color: #33415c;
  font-size: 13px;
}

.zml-tag-manager-list {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.zml-tag-manager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e0e7ef;
  border-radius: 9px;
  background: #fff;
}

.zml-tag-manager-row b {
  color: #294763;
  font-size: 13px;
}

.zml-tag-manager-row span {
  color: #7d8fa3;
  font-size: 12px;
}

.zml-tag-manager-row.disabled {
  opacity: .58;
  background: #f1f3f6;
}

.zml-category-manager-dialog {
  width: min(760px, 94vw);
  height: auto;
  max-height: 86vh;
}

.zml-category-manager-body {
  overflow: auto;
  padding: 18px 20px 22px;
  background: #f7f9fc;
}

.zml-category-form {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(130px, 1fr) 88px auto;
  gap: 10px;
  align-items: end;
  padding: 13px;
  border: 1px solid #e0e7ef;
  border-radius: 10px;
  background: #fff;
}

.zml-category-form label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: #536c84;
  font-size: 12px;
}

.zml-category-form input,
.zml-category-form select {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #d8e2ec;
  border-radius: 8px;
  background: #fff;
  color: #33415c;
  font-size: 13px;
  box-sizing: border-box;
}

.zml-category-form .zml-cat-enabled {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-bottom: 8px;
  white-space: nowrap;
}

.zml-category-form-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-bottom: 1px;
}

.zml-cat-manager-list {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.zml-cat-manager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid #e0e7ef;
  border-radius: 9px;
  background: #fff;
}

.zml-cat-manager-row > div:first-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.zml-cat-manager-row b {
  color: #294763;
  font-size: 13px;
}

.zml-cat-manager-row span {
  color: #7d8fa3;
  font-size: 11px;
}

.zml-cat-manager-row.disabled {
  opacity: .58;
  background: #f1f3f6;
}

.zml-cat-manager-actions {
  display: flex;
  flex: none;
  gap: 6px;
}

@media (max-width: 760px) {
  .zml-category-form {
    grid-template-columns: 1fr;
  }

  .zml-cat-manager-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

.zml-editor-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

.zml-editor-columns section {
  padding: 12px;
  border: 1px solid #e0e7ef;
  border-radius: 10px;
  background: #fff;
}

.zml-editor-columns h4 {
  margin: 0 0 8px;
  color: #294763;
  font-size: 13px;
}

.zml-usage,
.zml-versions {
  max-height: 170px;
  overflow: auto;
}

.zml-usage > div,
.zml-versions > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed #e6edf5;
  color: #718196;
  font-size: 12px;
}

.zml-usage b,
.zml-versions b {
  color: #344f6a;
}

.zml-editor-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #dfe7f0;
}

@media (max-width: 760px) {
  .zml-overlay {
    padding: 0;
  }

  .zml-dialog {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .zml-body {
    grid-template-columns: 1fr;
  }

  .zml-side {
    max-height: 118px;
    border-right: 0;
    border-bottom: 1px solid #e2e8f0;
  }

  .zml-cats {
    display: flex;
    overflow-x: auto;
  }

  .zml-cats button {
    width: auto;
    min-width: 100px;
  }

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

  .zml-thumb {
    height: 94px;
  }

  .zml-editor-grid,
  .zml-editor-columns {
    grid-template-columns: 1fr;
  }
}
