.novel-image-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .72);
}

.novel-image-backdrop.active {
  display: flex;
}

.novel-image-modal {
  width: min(1480px, 98vw);
  height: calc(100vh - 12px);
  max-height: none;
  display: grid;
  grid-template-columns: minmax(520px, 1.2fr) minmax(460px, .8fr);
  padding: 0;
  overflow: hidden;
  border: 1px solid #333;
  border-radius: 14px;
  background: #101010;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}

.novel-image-stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #333;
  background: #0b0b0b;
}

.novel-image-stage-top,
.novel-image-editor-top {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid #333;
  background: #111;
}

.novel-image-stage-content {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  overflow: hidden;
}

.novel-image-history {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #2f2f2f;
  background: #0f0f12;
}

.novel-image-history-head {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid #2a2a2a;
  color: #f3f4f6;
  font-size: 13px;
  font-weight: 800;
}

.novel-image-history-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 10px 8px;
}

.novel-image-history-empty {
  padding: 16px 4px;
  color: #666;
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.novel-image-history-thumb {
  width: 72px;
  aspect-ratio: 3 / 4;
  padding: 0;
  overflow: hidden;
  border: 1px solid #343434;
  border-radius: 10px;
  background: #151515;
  cursor: pointer;
}

.novel-image-history-thumb.active {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.novel-image-history-thumb img,
.novel-image-slot img {
  width: 100%;
  height: 100%;
  display: block;
}

.novel-image-history-thumb img {
  object-fit: cover;
}

.novel-image-grid {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow: hidden;
  padding: 16px;
}

.novel-image-grid.count1 {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.novel-image-grid.count2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.novel-image-grid.count3,
.novel-image-grid.count4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.novel-image-slot {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #333;
  border-radius: 14px;
  background: #151515;
  color: #777;
  cursor: pointer;
}

.novel-image-slot.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.novel-image-slot img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #050505;
}

.novel-image-editor {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #101010;
}

.novel-image-editor-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 96px;
}

.novel-image-editor label {
  display: block;
  margin: 14px 0 7px;
  font-weight: 800;
}

.novel-image-source {
  max-height: 150px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #303030;
  border-radius: 10px;
  background: #070707;
  color: #cfcfcf;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.novel-image-style-grid,
.novel-image-shot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.novel-style-card,
.novel-shot-button {
  min-height: 42px;
  border: 1px solid #333;
  border-radius: 10px;
  background: #171717;
  color: #f4f4f4;
  font-weight: 800;
  cursor: pointer;
}

.novel-style-card {
  min-height: 88px;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  padding: 8px;
}

.novel-style-card.active,
.novel-shot-button.active {
  border-color: var(--accent);
  background: rgba(255, 59, 48, .18);
}

.novel-style-preview {
  min-height: 42px;
  border-radius: 8px;
  background: linear-gradient(135deg, #29324a, #ff6b6b);
}

.novel-style-preview.dark {
  background: linear-gradient(135deg, #0d1117, #57606a);
}

.novel-style-preview.soft {
  background: linear-gradient(135deg, #4b5563, #d1d5db);
}

.novel-image-actions {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #333;
  background: #111;
}

.novel-anlas-tag {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #333;
  border-radius: 999px;
  background: #181818;
  color: #d8d8d8;
  font-size: 12px;
  font-weight: 800;
}

.novel-image-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.novel-image-row select {
  width: 120px;
}

.novel-nsfw-toggle {
  min-height: 36px;
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  margin: 0 !important;
  padding: 0 12px;
  border: 1px solid #333;
  border-radius: 10px;
  background: #171717;
  color: #f4f4f4;
  font-weight: 800;
}

.novel-nsfw-toggle input {
  width: auto;
  margin: 0;
}

@media (max-width: 850px) {
  .novel-image-modal {
    grid-template-columns: 1fr;
    height: 92vh;
  }

  .novel-image-stage {
    min-height: 420px;
    border-right: 0;
    border-bottom: 1px solid #333;
  }

  .novel-image-style-grid,
  .novel-image-shot-grid {
    grid-template-columns: 1fr;
  }
}
