/* 文章宣传图生成器 — 前缀 apci- 避免与主题/插件冲突 */

/* 工具条整体靠右，与 999wp 一致并可覆盖主题的 flex */
div.wbi-copy-toolbar {
  justify-content: flex-end !important;
  gap: 6px !important;
}

/*
 * 「分享文章」包在 slot 里：若 slot 参与 flex，默认 flex-shrink:1 会被压窄，看起来比另三个按钮小。
 * display:contents 让内部 button 与三个复制按钮同为工具条的 flex 子项，尺寸规则一致。
 */
.wbi-copy-toolbar .apci-toolbar-slot {
  display: contents;
}

@supports not (display: contents) {
  .wbi-copy-toolbar .apci-toolbar-slot {
    display: inline-flex;
    flex: 0 0 5.85rem !important;
    flex-shrink: 0 !important;
    min-width: 5.85rem !important;
    max-width: 5.85rem !important;
    width: 5.85rem !important;
    box-sizing: border-box;
    align-items: stretch;
    justify-content: center;
    vertical-align: middle;
    margin: 0;
  }

  div.wbi-copy-toolbar .apci-toolbar-slot > button {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
}

/*
 * 工具条四个按钮：同宽同高、中号（分享文章 + 三个复制）。
 */
div.wbi-copy-toolbar button {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  box-sizing: border-box;
  margin: 0;
  flex: 0 0 5.85rem;
  width: 5.85rem !important;
  min-width: 5.85rem !important;
  max-width: 5.85rem !important;
  min-height: 2.15rem;
  padding: 5px 4px !important;
  border: 1px solid #2271b1;
  background: #fff;
  color: #2271b1;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px !important;
  font-weight: inherit;
  line-height: 1.35 !important;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

div.wbi-copy-toolbar button:hover {
  background: #eaf4fb;
}

div.wbi-copy-toolbar button:focus {
  outline: 2px solid #2271b1;
  outline-offset: 1px;
}

/* 无复制条时：单独「分享文章」与工具条按钮同尺寸、靠右 */
.apci-toolbar-wrap {
  display: flex;
  justify-content: flex-end;
  margin: 1.25em 0;
  clear: both;
}

.apci-toolbar-wrap .apci-open-btn.apci-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  box-sizing: border-box;
  margin: 0;
  width: 5.85rem;
  min-width: 5.85rem;
  max-width: 5.85rem;
  min-height: 2.15rem;
  padding: 5px 4px;
  border: 1px solid #2271b1;
  background: #fff;
  color: #2271b1;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.35;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apci-toolbar-wrap .apci-open-btn:hover {
  background: #eaf4fb;
}

.apci-toolbar-wrap .apci-open-btn:focus {
  outline: 2px solid #2271b1;
  outline-offset: 1px;
}

/* 手机：单行 + 整体仍靠右；中号略紧凑；放不下时可横滑 */
@media (max-width: 782px) {
  div.wbi-copy-toolbar {
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    gap: 4px !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    padding-bottom: 4px;
    box-sizing: border-box;
    scrollbar-width: thin;
  }

  div.wbi-copy-toolbar::-webkit-scrollbar {
    height: 4px;
  }

  div.wbi-copy-toolbar::-webkit-scrollbar-thumb {
    background: rgba(34, 113, 177, 0.35);
    border-radius: 4px;
  }

  @supports not (display: contents) {
    .wbi-copy-toolbar .apci-toolbar-slot {
      flex: 0 0 5.35rem !important;
      min-width: 5.35rem !important;
      max-width: 5.35rem !important;
      width: 5.35rem !important;
    }
  }

  div.wbi-copy-toolbar button {
    flex: 0 0 5.35rem !important;
    width: 5.35rem !important;
    min-width: 5.35rem !important;
    max-width: 5.35rem !important;
    min-height: 2rem;
    flex-shrink: 0;
    padding: 4px 3px !important;
    font-size: 12px !important;
    line-height: 1.35 !important;
    white-space: nowrap;
  }

  .apci-toolbar-wrap .apci-open-btn.apci-open-btn {
    width: 5.35rem;
    min-width: 5.35rem;
    max-width: 5.35rem;
    min-height: 2rem;
    padding: 4px 3px;
    font-size: 12px;
  }
}

/* 页脚兜底时与正文区隔开 */
.apci-footer-fallback {
  margin: 1.5em auto 2em;
  max-width: 100%;
  clear: both;
  padding: 0 16px;
  box-sizing: border-box;
}

/* 配色方案选择（叠在宣传图弹窗之上） */
.apci-preset-overlay {
  position: fixed;
  inset: 0;
  z-index: 100002;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.apci-preset-overlay.apci-visible {
  opacity: 1;
  visibility: visible;
}

.apci-preset-panel {
  width: 100%;
  max-width: 400px;
  max-height: 88vh;
  background: #161616;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.apci-preset-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.apci-preset-title {
  font-size: 15px;
  font-weight: 600;
  color: #eee;
}

.apci-preset-close {
  background: transparent;
  border: none;
  color: #999;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.apci-preset-close:hover {
  color: #fff;
}

.apci-preset-grid {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-content: start;
}

@media (min-width: 380px) {
  .apci-preset-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.apci-preset-card {
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  min-height: 56px;
  cursor: pointer;
  padding: 8px 6px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.apci-preset-card:hover {
  transform: scale(1.02);
  border-color: rgba(255, 255, 255, 0.45);
}

.apci-preset-card-name {
  display: block;
  font-size: 11px;
  line-height: 1.25;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.apci-preset-foot {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.apci-preset-cancel {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #2a2a2a;
  color: #ddd;
}

.apci-preset-cancel:hover {
  background: #333;
}

.apci-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.apci-modal-overlay.apci-visible {
  opacity: 1;
  visibility: visible;
}

.apci-modal-panel {
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  background: #111;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.apci-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #eee;
  font-size: 15px;
}

.apci-modal-close {
  background: transparent;
  border: none;
  color: #aaa;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.apci-modal-close:hover {
  color: #fff;
}

.apci-modal-body {
  padding: 12px;
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.apci-preview-wrap {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 9 / 16;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.apci-preview-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.apci-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}

.apci-modal-actions button {
  padding: 0.45em 0.9em;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #2a2a2a;
  color: #eee;
}

.apci-modal-actions button:hover:not(:disabled) {
  background: #3a3a3a;
}

.apci-modal-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.apci-status {
  color: #aaa;
  font-size: 13px;
  text-align: center;
  min-height: 1.2em;
}

.apci-theme-panel {
  width: 100%;
  max-width: 360px;
  margin-bottom: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #ccc;
  font-size: 13px;
  box-sizing: border-box;
}

.apci-theme-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: #eee;
  margin-bottom: 6px;
}

.apci-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0;
}

.apci-theme-row label {
  flex: 1;
  min-width: 0;
}

.apci-theme-row input[type='color'] {
  width: 48px;
  height: 32px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

.apci-theme-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.apci-theme-shuffle,
.apci-theme-regen {
  flex: 1;
  min-width: 120px;
  padding: 0.5em 0.65em;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: #2f3f5f;
  color: #eee;
}

.apci-theme-shuffle:hover:not(:disabled),
.apci-theme-regen:hover:not(:disabled) {
  background: #3d5280;
}

.apci-theme-shuffle:disabled,
.apci-theme-regen:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.apci-slogan-field {
  width: 100%;
  margin-top: 10px;
}

.apci-slogan-field label {
  display: block;
  margin-bottom: 4px;
  color: #bbb;
  font-size: 12px;
}

.apci-slogan-input {
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  color: #eee;
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
}

.apci-slogan-hint {
  margin-top: 4px;
  font-size: 11px;
  color: #888;
  line-height: 1.35;
}

.apci-size-field,
.apci-font-field {
  width: 100%;
  max-width: 360px;
  margin-bottom: 4px;
}

.apci-size-field label,
.apci-font-field label {
  display: block;
  margin-bottom: 4px;
  color: #bbb;
  font-size: 12px;
}

.apci-size-select,
.apci-font-select {
  width: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  color: #eee;
  font-size: 13px;
}

.apci-size-hint,
.apci-font-hint {
  margin-top: 4px;
  font-size: 11px;
  color: #888;
  line-height: 1.35;
}

/* 离屏渲染层：宽度由 JS 按所选尺寸设置 */
.apci-render-host {
  position: fixed;
  left: -20000px;
  top: 0;
  width: auto;
  pointer-events: none;
  z-index: -1;
  overflow: visible;
}

/* --apci-font-scale：跟随系统或用户档位，与导出画布尺寸无关 */
.apci-slide-frame {
  --apci-font-scale: 1;
  box-sizing: border-box;
  background: #fafafa;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.apci-slide-header {
  flex-shrink: 0;
  min-height: calc(168px * var(--apci-font-scale, 1));
  padding: calc(20px * var(--apci-font-scale, 1)) calc(40px * var(--apci-font-scale, 1)) calc(14px * var(--apci-font-scale, 1));
  box-sizing: border-box;
  background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(10px * var(--apci-font-scale, 1));
}

.apci-slide-time {
  font-size: calc(32px * var(--apci-font-scale, 1));
  font-weight: 600;
  letter-spacing: 0.02em;
}

.apci-slide-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(20px * var(--apci-font-scale, 1));
  font-size: calc(28px * var(--apci-font-scale, 1));
  opacity: 0.95;
}

.apci-slide-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
  max-width: 68%;
}

.apci-slide-site {
  font-size: calc(26px * var(--apci-font-scale, 1));
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}

.apci-slide-footer {
  flex-shrink: 0;
  min-height: calc(64px * var(--apci-font-scale, 1));
  padding: calc(14px * var(--apci-font-scale, 1)) calc(40px * var(--apci-font-scale, 1));
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: calc(24px * var(--apci-font-scale, 1));
  line-height: 1.4;
  color: #475569;
  background: rgba(15, 23, 42, 0.06);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.apci-slide-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.apci-slide-inner {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding: calc(36px * var(--apci-font-scale, 1)) calc(48px * var(--apci-font-scale, 1)) calc(48px * var(--apci-font-scale, 1));
  box-sizing: border-box;
  color: #1a1a1a;
  font-size: calc(34px * var(--apci-font-scale, 1));
  line-height: 1.65;
  word-wrap: break-word;
}

/* 文章标题上方的站点 Logo */
.apci-slide-title-logo {
  display: block;
  max-height: calc(72px * var(--apci-font-scale, 1));
  max-width: calc(520px * var(--apci-font-scale, 1));
  width: auto;
  height: auto;
  object-fit: contain;
  margin: 0 0 calc(20px * var(--apci-font-scale, 1));
}

.apci-slide-title-logo.apci-slide-title-logo--hidden {
  display: none;
}

.apci-slide-inner .apci-slide-title {
  font-size: calc(48px * var(--apci-font-scale, 1));
  font-weight: 700;
  line-height: 1.35;
  margin: 0 0 calc(28px * var(--apci-font-scale, 1));
  color: #0f172a;
}

.apci-slide-inner img {
  max-width: 100%;
  height: auto;
  border-radius: calc(8px * var(--apci-font-scale, 1));
}

.apci-slide-inner p {
  margin: 0 0 0.75em;
}

.apci-slide-inner h1,
.apci-slide-inner h2,
.apci-slide-inner h3 {
  margin: 0.6em 0 0.4em;
  line-height: 1.3;
}
