body {
  background: #f3f4f6;
}

.publish-main {
  padding: 60px 0;
}

.publish-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 20px;
}

.publish-head h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.publish-head p {
  color: #4b5563;
}

.publish-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: #4b5563;
}

.field input,
.field textarea {
  padding: 10px 12px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  font-size: 14px;
  resize: vertical;
}

.field select {
  padding: 10px 12px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
  font-size: 14px;
  background: #ffffff;
}

.ip-role-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.ghost-btn {
  border: 1px solid #e5e7eb;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #111827;
}

.ghost-btn:hover {
  border-color: #111827;
}

.upload-box {
  position: relative;
  border: 1px dashed #cbd2d9;
  border-radius: 12px;
  padding: 26px;
  text-align: center;
  background: #f9fafb;
  cursor: pointer;
}

.upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-tip {
  color: #6b7280;
}

.preview-grid {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.preview-item {
  position: relative;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.preview-item img {
  width: auto;
  height: auto;
  max-width: 100%;
  display: block;
  margin: 0 auto;
  cursor: zoom-in;
}

.remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(17, 24, 39, 0.7);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 14px;
}

.crop-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(15, 23, 42, 0.8);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 12px;
}

.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
}

.image-modal.show {
  opacity: 1;
  visibility: visible;
}

.image-modal-content {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
}

.image-modal-content img {
  display: block;
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.35);
}

.image-modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(17, 24, 39, 0.9);
  color: #ffffff;
  cursor: pointer;
  font-size: 18px;
}

.crop-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1001;
}

.crop-modal.show {
  opacity: 1;
  visibility: visible;
}

.crop-modal-content {
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-sizing: border-box;
  width: min(920px, 100%);
  max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow: auto;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  display: grid;
  gap: 12px;
}

.crop-title {
  font-size: 16px;
  color: #111827;
}

.crop-canvas {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 70vh;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  display: block;
  touch-action: none;
  user-select: none;
}

.crop-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  width: 100%;
}

.crop-actions button {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
}

.crop-add-btn {
  background: #111827;
  color: #ffffff;
}

.crop-diagonal-btn {
  background: #dbeafe;
  color: #1e3a8a;
}

.crop-diagonal-btn.active {
  background: #1d4ed8;
  color: #ffffff;
}

.crop-cancel-btn {
  background: #e5e7eb;
  color: #111827;
}

.ip-role-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1002;
}

.ip-role-modal.show {
  display: flex;
}

.ip-role-dialog {
  width: min(720px, 92vw);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  max-height: min(80vh, 760px);
  overflow: hidden;
}

.ip-role-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ip-role-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.ip-role-title {
  font-size: 16px;
  color: #111827;
  font-weight: 600;
}

.ip-role-close {
  border: none;
  background: #f3f4f6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
}

.add-ip-role-btn {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #111827;
  background: #111827;
  color: #ffffff;
  cursor: pointer;
  font-size: 13px;
}

.ip-role-form {
  display: grid;
  gap: 8px;
}

.ip-role-form input {
  padding: 8px 12px;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
}

.ip-role-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.ip-role-body {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  height: min(60vh, 560px);
  min-height: 0;
}

.ip-role-letters {
  display: grid;
  gap: 2px;
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  overflow: hidden;
  line-height: 1.1;
}

.ip-role-letters button {
  border: none;
  background: transparent;
  padding: 2px 0;
  cursor: pointer;
  color: inherit;
  border-radius: 6px;
}

.ip-role-letters button.active {
  background: #111827;
  color: #ffffff;
}

/* 发布页弹窗内的 IP/角色列表：单列，每个 IP 独占一行（覆盖首页 style.css 的 flex wrap） */
.ip-role-modal .ip-role-list {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 8px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: #ffffff;
}

.ip-role-modal .ip-role-section {
  display: block;
  width: 100%;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}

.ip-role-modal .ip-role-section:last-child {
  border-bottom: none;
}

.ip-role-modal .ip-role-section-title {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 6px;
  display: block;
}

.ip-role-modal .ip-role-ip {
  font-size: 13px;
  color: #111827;
  font-weight: 600;
  margin: 6px 0 4px;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  padding: 8px 10px;
  display: block;
  width: 100%;
  align-items: center;
  gap: 6px;
  border-radius: 8px;
}

.ip-role-modal .ip-role-ip:hover {
  background: #f3f4f6;
}

.ip-role-modal .ip-role-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px 8px 24px;
  border-radius: 8px;
  border: none;
  background: #f9fafb;
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 14px;
  color: #111827;
  margin-left: 0;
}

.ip-role-modal .ip-role-ip::before {
  content: "▶ ";
  font-size: 10px;
  color: #6b7280;
  transition: transform 0.2s ease;
}

.ip-role-modal .ip-role-ip.open::before {
  transform: rotate(90deg);
}

.ip-role-modal .ip-role-roles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 4px;
}

.ip-role-modal .ip-role-item:hover {
  background: #eef2ff;
}


.ip-role-modal .ip-role-empty {
  text-align: center;
  color: #9ca3af;
  padding: 20px 0;
}
