/* ========================================
  弹窗基础（转存 / 提交需求等通用弹窗）
======================================== */
.modal,
.protocol-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.protocol-modal {
  z-index: 3000;
}

.modal.active,
.protocol-modal.active {
  display: grid;
  place-items: center;
}

.protocol-modal[style*='display: flex'] {
  display: grid !important;
  place-items: center !important;
}

.modal-content {
  box-sizing: border-box;
  width: 100%;
  max-width: 520px;
  max-height: min(85vh, 720px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e4e7ed;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.2);
  position: relative;
  pointer-events: auto;
  animation: modal-fade-in 0.22s ease-out;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 16px 20px;
  border-bottom: 1px solid #ebeef5;
}

.modal-header h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: #303133;
}

.modal-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #909399;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover {
  background: #f5f7fa;
  color: #303133;
}

.modal-body {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: #606266;
  font-size: 14px;
  line-height: 1.6;
}

.modal-body button,
.modal-actions button {
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
}

.modal-body .form-group {
  margin-bottom: 16px;
}

.modal-body .form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #303133;
}

.modal-body .form-textarea {
  width: 100%;
  box-sizing: border-box;
  min-height: 120px;
  padding: 10px 14px;
  border: 1px solid #dcdfe6;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: #303133;
  resize: vertical;
}

.modal-body .form-textarea:focus {
  outline: none;
  border-color: #409eff;
  box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.15);
}

.modal-body .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

/* 通用弹窗按钮 */
.modal .btn-primary,
.protocol-modal .btn-primary,
.modal-body .btn-primary {
  padding: 9px 20px !important;
  border: none !important;
  border-radius: 8px !important;
  background: linear-gradient(135deg, #409eff 0%, #337ecc 100%) !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.28) !important;
  min-width: 88px;
  cursor: pointer;
}

.modal .btn-secondary,
.protocol-modal .btn-secondary,
.modal-body .btn-secondary {
  padding: 9px 20px !important;
  border: 1px solid #dcdfe6 !important;
  border-radius: 8px !important;
  background: #fff !important;
  color: #606266 !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  min-width: 88px;
  cursor: pointer;
}

.modal .btn-primary:hover,
.protocol-modal .btn-primary:hover,
.modal-body .btn-primary:hover {
  filter: brightness(1.05);
}

.modal .btn-secondary:hover,
.protocol-modal .btn-secondary:hover,
.modal-body .btn-secondary:hover {
  border-color: #409eff !important;
  color: #409eff !important;
  background: #ecf5ff !important;
}

/* ========================================
  转存结果弹窗 (#transferModal)
======================================== */
#transferModal .modal-content--transfer {
  max-width: 440px;
}

#transferModal .modal-header--transfer {
  align-items: flex-start;
  padding: 18px 20px 14px;
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
}

#transferModal .modal-header__titles {
  flex: 1;
  min-width: 0;
}

#transferModal .modal-header__sub {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 400;
  color: #909399;
  line-height: 1.45;
}

#transferModal .modal-body--transfer {
  padding: 8px 20px 22px;
}

.transfer-panel {
  text-align: center;
}

.transfer-panel__hero {
  margin-bottom: 18px;
}

.transfer-panel__icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: linear-gradient(145deg, #e8f4ff 0%, #ecf5ff 100%);
  box-shadow: 0 4px 14px rgba(64, 158, 255, 0.18);
  position: relative;
}

.transfer-panel__icon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 46%;
  width: 11px;
  height: 18px;
  margin-left: -4px;
  margin-top: -10px;
  border: solid #409eff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.transfer-panel__title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
  color: #303133;
  letter-spacing: 0.02em;
}

.transfer-panel__file {
  margin: 0;
  font-size: 14px;
  color: #909399;
  line-height: 1.5;
  word-break: break-word;
}

.transfer-panel--quark .transfer-qrcode__brand {
  color: #0066ff;
}

.transfer-panel--baidu .transfer-qrcode__brand {
  color: #2932e1;
}

.transfer-panel--xunlei .transfer-qrcode__brand {
  color: #3b82f6;
}

.transfer-qrcode {
  margin-bottom: 18px;
  padding: 16px 14px;
  border-radius: 12px;
  background: #f5f7fa;
  border: 1px solid #ebeef5;
}

.transfer-qrcode__lead {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
  color: #303133;
}

.transfer-qrcode__tips {
  margin: 0 0 14px;
  font-size: 13px;
  color: #909399;
  line-height: 1.55;
}

.transfer-qrcode__box {
  display: inline-block;
  padding: 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.transfer-qrcode__fallback {
  padding: 12px;
  font-size: 13px;
  color: #909399;
}

.transfer-qrcode__fallback a {
  color: #409eff;
  word-break: break-all;
}

.transfer-share {
  margin-bottom: 18px;
  text-align: left;
}

.transfer-share-card {
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
  border: 1px solid #ebeef5;
  border-radius: 10px;
  border-left: 3px solid #409eff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.transfer-share-card__label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: #909399;
}

.transfer-share-card__link {
  font-size: 14px;
  line-height: 1.5;
  color: #409eff;
  text-decoration: none;
  word-break: break-all;
}

.transfer-share-card__link:hover {
  text-decoration: underline;
}

.transfer-pwd {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 14px;
  background: #ecf5ff;
  border-radius: 10px;
}

.transfer-pwd__label {
  font-size: 13px;
  color: #606266;
}

.transfer-pwd__value {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: #409eff;
}

.transfer-expiry {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: #909399;
  line-height: 1.5;
}

.transfer-expiry__icon {
  margin-right: 4px;
}

.transfer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 4px;
}

.transfer-actions .btn-primary,
.transfer-actions .btn-secondary {
  flex: 1 1 auto;
  min-width: 100px;
}

.transfer-panel--loading {
  padding: 28px 12px 32px;
}

.transfer-loading__spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 18px;
  border: 3px solid #ebeef5;
  border-top-color: #409eff;
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.transfer-loading__text {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 500;
  color: #303133;
}

.transfer-loading__meta {
  margin: 0;
  font-size: 13px;
  color: #909399;
}

/* 兼容旧 class */
.modal-body .transfer-success h3,
.modal-body .transfer-panel__title {
  color: #303133 !important;
}

.modal-body .transfer-actions,
.modal-body .modal-actions {
  margin-top: 8px;
}

/* ========================================
  首页公告 / 扫码加群 — 统一卡片（modal-sheet）
  勿与 .modal-header / .modal-body 混用
======================================== */
/* 公告 / 群聊卡片：必须纵向 flex，避免子项横向散开 */
.protocol-modal > .modal-sheet,
.modal#groupQrcodeModal > .modal-sheet,
#protocolModal > .modal-sheet,
#groupQrcodeModal > .modal-sheet {
  box-sizing: border-box;
  position: relative;
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: stretch !important;
  width: min(100%, 520px);
  max-width: calc(100vw - 32px);
  max-height: min(88vh, 640px);
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e4e7ed;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  animation: modal-fade-in 0.22s ease-out;
  pointer-events: auto;
}

.modal-sheet--protocol,
#protocolModal > .modal-sheet {
  width: min(100%, 520px);
}

.modal-sheet--qrcode,
#groupQrcodeModal > .modal-sheet {
  width: min(100%, 400px);
}

.modal-sheet__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  color: #909399;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.modal-sheet__close:hover {
  background: #fff;
  color: #303133;
}

.modal-sheet__head {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 24px 18px;
  background: linear-gradient(180deg, #e8f3ff 0%, #f7fbff 45%, #fff 100%);
  border-bottom: 1px solid #ebeef5;
}

.modal-sheet__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0 0 12px;
  border-radius: 50%;
  background: linear-gradient(145deg, #409eff 0%, #2d7dd2 100%);
  font-size: 26px;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(64, 158, 255, 0.35);
}

.modal-sheet__title {
  margin: 0;
  padding: 0;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  color: #303133;
}

.modal-sheet__desc {
  margin: 8px 0 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #909399;
}

.modal-sheet__body {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 24px;
  font-size: 14px;
  line-height: 1.75;
  color: #606266;
  word-break: break-word;
}

.modal-sheet__body--center {
  display: flex !important;
  flex-direction: column !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  text-align: center;
  padding: 20px 24px 24px;
}

.modal-sheet__hint {
  display: block;
  width: 100%;
  max-width: 100%;
  float: none;
}

/* 公告富文本 */
.modal-sheet__body.protocol-body.rich-html,
.protocol-body.rich-html,
.disclaimer-rich {
  max-height: min(50vh, 380px);
}

.disclaimer-rich {
  max-height: none;
}

.modal-sheet__body.rich-html strong,
.modal-sheet__body.rich-html b,
.protocol-body.rich-html strong,
.protocol-body.rich-html b,
.disclaimer-rich strong,
.disclaimer-rich b {
  font-weight: 600;
}

.modal-sheet__body.rich-html em,
.modal-sheet__body.rich-html i,
.protocol-body.rich-html em,
.protocol-body.rich-html i,
.disclaimer-rich em,
.disclaimer-rich i {
  font-style: italic;
}

.modal-sheet__body.rich-html u,
.protocol-body.rich-html u,
.disclaimer-rich u {
  text-decoration: underline;
}

.modal-sheet__body.rich-html p,
.protocol-body.rich-html p {
  margin: 0 0 12px;
}

.modal-sheet__body.rich-html p:last-child,
.protocol-body.rich-html p:last-child {
  margin-bottom: 0;
}

.modal-sheet__body.rich-html h1,
.modal-sheet__body.rich-html h2,
.modal-sheet__body.rich-html h3,
.modal-sheet__body.rich-html h4,
.protocol-body.rich-html h1,
.protocol-body.rich-html h2,
.protocol-body.rich-html h3,
.protocol-body.rich-html h4 {
  margin: 12px 0 8px;
  font-weight: 600;
  color: #303133;
}

.modal-sheet__body.rich-html a,
.protocol-body.rich-html a {
  color: #409eff;
  text-decoration: underline;
}

.modal-sheet__body.rich-html img,
.protocol-body.rich-html img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.modal-sheet__foot,
.protocol-footer {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
  border-top: 1px solid #ebeef5;
  background: #fafbfc;
}

.modal-sheet__foot .btn-primary,
.protocol-footer .btn-primary {
  min-width: 110px;
}

.modal-sheet__qrcode {
  box-sizing: border-box;
  display: inline-block;
  max-width: 100%;
  padding: 14px;
  background: #fff;
  border: 1px solid #e4e7ed;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

.modal-sheet__qrcode img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: min(52vh, 320px);
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  object-fit: contain;
}

.modal-sheet__hint {
  margin: 16px 0 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #909399;
}

/* 移动端 */
@media (max-width: 768px) {
  .modal,
  .protocol-modal {
    padding: 12px;
    place-items: center;
  }

  .modal-content {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px;
  }

  .protocol-modal > .modal-sheet,
  .modal#groupQrcodeModal > .modal-sheet,
  #protocolModal > .modal-sheet,
  #groupQrcodeModal > .modal-sheet {
    width: 100%;
    max-width: 100%;
    max-height: min(92vh, 640px);
    border-radius: 16px;
  }

  .modal-sheet__head {
    padding: 24px 20px 16px;
  }

  .modal-sheet__body,
  .modal-sheet__body.protocol-body.rich-html {
    padding: 16px 18px;
    max-height: none;
  }

  .modal-sheet__body--center {
    padding: 16px 18px 20px;
  }

  .modal-sheet__foot,
  .protocol-footer {
    flex-direction: column-reverse;
    padding: 12px 16px 16px;
  }

  .modal-sheet__foot .btn-primary,
  .modal-sheet__foot .btn-secondary,
  .protocol-footer .btn-primary,
  .protocol-footer .btn-secondary {
    width: 100%;
    min-width: 0;
  }

  .modal-sheet__qrcode img {
    max-height: min(48vh, 280px);
  }
}
