/* AI 生图独立页面样式（joe.aiimage.css）
 * 外部文件原因：主题 PJAX 换页只同步 <head> 中的外部 CSS/JS，
 * 内联 <style> 会导致 PJAX 进入本页时丢失样式。
 * 全部使用主题 CSS 变量，浅色/深色模式自动适配。 */

/* ---- 页面主体 ---- */
.ai-panel {
  padding: 32px 32px 28px;
  background: var(--background);
  border: 1px solid var(--classC);
  border-radius: var(--radius-wrap);
  margin-bottom: 20px;
}
.ai-panel h1 {
  font-size: 26px;
  margin-bottom: 8px;
}
.ai-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ai-head h1 {
  position: relative;
  padding-left: 14px;
  line-height: 1.4;
  margin-bottom: 0;
}
.ai-head h1::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 20px;
  border-radius: 4px;
  background: var(--theme);
}
.ai-muted {
  color: var(--routine);
  font-size: 14px;
  line-height: 1.8;
  margin: 6px 0;
}

/* ---- 表单 ---- */
.ai-form {
  margin: 16px 0 8px;
}
.ai-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--classC);
  border-radius: 8px;
  background: var(--classD);
  color: var(--main);
  font-size: 14px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s ease;
}
.ai-input:focus {
  border-color: var(--theme);
}
.ai-form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.ai-select {
  padding: 8px 12px;
  border: 1px solid var(--classC);
  border-radius: 8px;
  background: var(--classD);
  color: var(--main);
  font-size: 14px;
  outline: none;
  cursor: pointer;
}
.ai-btn {
  padding: 8px 28px;
  border: none;
  border-radius: 999px;
  background: var(--theme);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ai-btn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}
.ai-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.ai-status {
  color: var(--routine);
  font-size: 13px;
}
.ai-tip {
  font-size: 13px;
  opacity: 0.85;
}

/* ---- 结果网格 ---- */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 16px;
  margin-top: 16px;
}
.ai-card {
  display: block;
  width: 100%;
  margin: 0;
  position: relative;
  background: var(--classD);
  border: 1px solid var(--classC);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.ai-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.ai-card a {
  display: block;
  line-height: 0;
}
.ai-card img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}
/* 支持 aspect-ratio 的浏览器按 3:4 裁剪，旧的内核用上面的固定高度兜底 */
@supports (aspect-ratio: 1 / 1) {
  .ai-card img {
    height: auto;
    aspect-ratio: 3 / 4;
  }
}
.ai-card figcaption {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--routine);
  line-height: 1.6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-card-new {
  animation: aiCardIn 0.5s ease;
}
@keyframes aiCardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- 底部：统计 + 加载更多 ---- */
.ai-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px dashed var(--classC);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.ai-total {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border: 1px solid var(--classC);
  border-radius: 999px;
  background: var(--classD);
  color: var(--routine);
  font-size: 13px;
}
.ai-total::before {
  content: '';
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--theme);
}
.ai-more {
  padding: 9px 36px;
  border: 1px solid var(--theme);
  border-radius: 999px;
  background: transparent;
  color: var(--theme);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.ai-more:hover {
  background: var(--theme);
  color: #fff;
}
.ai-more:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.ai-more-end {
  font-size: 13px;
  color: var(--minor);
}
/* PC 端用点击分页，加载更多按钮隐藏 */
.ai-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.ai-pager a {
  font-size: 14px;
  padding: 7px 18px;
  border: 1px solid var(--classC);
  border-radius: 999px;
  color: var(--routine);
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.ai-pager a:hover {
  border-color: var(--theme);
  color: var(--theme);
}
.ai-pager span {
  font-size: 13px;
  padding: 7px 18px;
  border-radius: 999px;
  background: var(--theme);
  color: #fff;
}
@media (min-width: 961px) {
  .ai-more {
    display: none;
  }
}

/* ---- 移动端 / 中小屏 ---- */
@media (max-width: 960px) {
  .ai-panel {
    padding: 20px 14px 18px;
  }
  .ai-panel h1 {
    font-size: 20px;
  }
  .ai-head h1::before {
    height: 16px;
  }
  .ai-muted {
    font-size: 13px;
  }
  /* 模式切换 tab 占满一行，方便点按 */
  .ai-tabs {
    display: flex;
    width: 100%;
  }
  .ai-tab {
    flex: 1;
    padding: 9px 0;
  }
  /* 表单行：尺寸选择拉伸填空，按钮保持舒适宽度，状态提示独占一行 */
  .ai-form-row {
    gap: 8px;
  }
  .ai-select {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
  }
  .ai-btn {
    padding: 9px 18px;
  }
  .ai-status {
    flex-basis: 100%;
    line-height: 1.6;
  }
  .ai-ref-drop {
    padding: 18px 12px;
  }
  /* 网格：两列瀑布流。注意容器必须切回 block——columns 属性对 grid 容器无效，
     否则会退回基础样式的 3 列网格（每页 9 张也会空一格） */
  .ai-grid {
    display: block;
    -webkit-columns: 2;
    columns: 2;
    column-gap: 10px;
    margin-top: 12px;
  }
  .ai-card {
    display: block;
    width: 100%;
    break-inside: avoid;
    page-break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin: 0 0 10px;
    border-radius: 10px;
  }
  .ai-card figcaption {
    font-size: 12px;
    padding: 8px 10px 0;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
    min-height: 40px;
  }
  .ai-copy {
    margin: 8px 10px 10px;
    padding: 8px 12px;
    font-size: 12px;
    text-align: center;
    white-space: nowrap;
  }
  /* 页脚：统计与加载更多改为居中堆叠，PC 端的分页隐藏 */
  .ai-foot {
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    margin-top: 16px;
  }
  .ai-pager {
    display: none;
  }
  .ai-total {
    padding: 7px 18px;
  }
  .ai-more {
    width: 100%;
    padding: 11px 0;
  }
}

/* ---- 触屏设备：去掉无意义的 hover 位移 ---- */
@media (hover: none) {
  .ai-card:hover {
    transform: none;
    box-shadow: none;
  }
  .ai-btn:hover {
    transform: none;
  }
}

.ai-copy { display: block; margin: 0 12px 12px; padding: 5px 12px; border: 1px solid var(--classC); border-radius: 6px; background: var(--background); color: var(--routine); cursor: pointer; }
.ai-copy:hover { color: var(--theme); border-color: var(--theme); }

.ai-btn-secondary { background: var(--classD); color: var(--theme); border: 1px solid var(--theme); }

/* ---- 模式切换 tab ---- */
.ai-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--classD);
  border: 1px solid var(--classC);
  border-radius: 10px;
  margin-bottom: 12px;
}
.ai-tab {
  padding: 7px 20px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--routine);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.ai-tab:hover { color: var(--theme); }
.ai-tab.active { background: var(--theme); color: #fff; }

/* ---- 以图生图：参考图上传 ---- */
.ai-ref[hidden],
.ai-ref-drop[hidden],
.ai-ref-preview[hidden] { display: none; }
.ai-ref { margin-bottom: 12px; }
.ai-ref-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 22px 16px;
  border: 1px dashed var(--theme);
  border-radius: 8px;
  background: var(--classD);
  cursor: pointer;
  text-align: center;
  transition: background 0.2s ease;
  outline: none;
}
.ai-ref-drop:hover,
.ai-ref-drop:focus,
.ai-ref-drop.dragging { background: var(--classC); }
.ai-ref-hint { margin: 0; font-size: 14px; color: var(--theme); }
.ai-ref-sub { margin: 0; font-size: 12px; color: var(--routine); opacity: 0.8; }
.ai-ref-preview {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--classC);
  border-radius: 8px;
  background: var(--classD);
}
.ai-ref-preview a {
  display: block;
  line-height: 0;
  cursor: zoom-in;
  position: relative;
}
.ai-ref-preview a::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
}
.ai-ref-preview a::before {
  content: '';
  position: absolute;
  right: 9px;
  bottom: 8px;
  width: 6px;
  height: 6px;
  border: 1.5px solid #fff;
  border-left: none;
  border-top: none;
  transform: rotate(45deg);
  z-index: 1;
}
.ai-ref-preview img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}
#ai-ref-remove {
  padding: 5px 14px;
  border: 1px solid var(--classC);
  border-radius: 6px;
  background: var(--background);
  color: var(--routine);
  font-size: 13px;
  cursor: pointer;
}
#ai-ref-remove:hover { color: #e24b4a; border-color: #e24b4a; }

/* ---- 图生图卡片角标：悬浮在图片左上角，不占布局空间，保证卡片等高 ---- */
.ai-mode-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  margin: 0;
  padding: 1px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  line-height: 1.7;
  pointer-events: none;
}
