/* ==========================================================================
   角色卡广场页面样式（/characters）
   复用 ai-chat.css 的设计令牌（--primary / --bg-card / --radius-* 等）与
   [data-ac-*] 外观层，本文件只补充广场专属布局组件（ch-* 前缀）。
   ========================================================================== */

.ch-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--bg-primary); color: var(--text-primary); }

/* ---------- 顶栏 ---------- */
.ch-topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  background: var(--header-bg); border-bottom: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
}
/* 品牌桥接：顶栏上沿主站樱花粉×薰衣草紫渐变细线 */
.ch-topbar::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #ec4899, #8b5cf6); pointer-events: none;
}
.ch-topbar-inner { max-width: 1200px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; }
.ch-brand { display: flex; align-items: center; gap: 9px; color: var(--text-primary); text-decoration: none; flex-shrink: 0; }
/* 品牌桥接：logo 升级为主站粉紫渐变徽章 */
.ch-brand-logo {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px; border-radius: 10px;
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  box-shadow: 0 4px 12px -6px rgba(236, 72, 153, 0.5);
}
.ch-brand-text { font-family: var(--font-serif); font-size: 18px; font-weight: var(--font-semibold); }
/* 品牌桥接：返回主站入口（主站粉紫渐变按钮，明暗模式通用） */
.ch-btn.ch-home-link {
  background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  border: none; color: #fff;
  box-shadow: 0 4px 12px -6px rgba(236, 72, 153, 0.5);
}
.ch-btn.ch-home-link:hover { color: #fff; border: none; opacity: 0.9; transform: translateY(-1px); }
.ch-search { flex: 1; min-width: 0; }
.ch-search input {
  width: 100%; padding: 9px 15px; border-radius: var(--radius-full);
  border: 1px solid var(--border-color); background: var(--bg-secondary);
  color: var(--text-primary); font-size: 13px; outline: none; font-family: inherit;
  transition: border-color var(--dur-2) ease, box-shadow var(--dur-2) ease;
}
.ch-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-focus); background: var(--bg-card); }
.ch-topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.ch-user { display: flex; align-items: center; gap: 8px; }
.ch-user-avatar { width: 32px; height: 32px; border-radius: var(--radius-full); object-fit: cover; box-shadow: var(--shadow-sm); }
.ch-user-name { font-size: 13px; color: var(--text-secondary); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 按钮 ---------- */
.ch-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-card); color: var(--text-secondary);
  font-size: 13px; font-family: inherit; cursor: pointer; text-decoration: none; transition: var(--transition-fast); white-space: nowrap;
}
.ch-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }
.ch-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ch-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px var(--primary-shadow); }
.ch-btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.ch-btn-ghost { background: var(--glass-bg-strong); }

/* ---------- Hero ---------- */
.ch-hero { max-width: 1200px; margin: 0 auto; padding: 34px 20px 18px; text-align: center; }
.ch-hero h1 { font-family: var(--font-serif); font-size: 28px; color: var(--text-primary); margin-bottom: 10px; }
.ch-hero p { font-size: 14px; line-height: 1.7; color: var(--text-secondary); max-width: 640px; margin: 0 auto; }

/* ---------- 主体 ---------- */
.ch-body { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 20px 40px; }

.ch-scope-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; }
.ch-scope-tab {
  padding: 8px 18px; border-radius: var(--radius-full); border: 1px solid var(--border-color);
  background: var(--bg-card); color: var(--text-secondary); font-size: 13px; cursor: pointer;
  font-family: inherit; transition: var(--transition-fast);
}
.ch-scope-tab:hover { color: var(--primary); border-color: var(--primary-border); }
.ch-scope-tab.active { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 6px 16px -8px var(--primary-shadow); }

.ch-filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.ch-filter-row { display: flex; align-items: flex-start; gap: 12px; }
.ch-filter-label { flex: 0 0 42px; font-size: 12px; color: var(--text-muted); padding-top: 5px; font-weight: var(--font-medium); }
.ch-cat-chips { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; }
.ch-chip {
  padding: 4px 12px; border-radius: var(--radius-full); border: 1px solid var(--border-color);
  background: var(--bg-card); color: var(--text-secondary); font-size: 12px; cursor: pointer;
  font-family: inherit; transition: var(--transition-fast);
}
.ch-chip:hover { color: var(--primary); border-color: var(--primary-border); background: var(--primary-bg); }
.ch-chip.active { color: var(--primary); border-color: var(--primary); background: var(--primary-bg); font-weight: var(--font-medium); }
.ch-chip-count { opacity: 0.6; font-size: 11px; }

.ch-result-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-size: 13px; color: var(--text-secondary); }
.ch-hint { font-size: 12px; color: var(--text-muted); }

/* ---------- 卡片网格 ---------- */
.ch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.ch-card {
  display: flex; gap: 13px; padding: 16px; border-radius: var(--radius-md);
  border: 1px solid var(--glass-border); background: var(--bg-card); cursor: pointer;
  transition: var(--transition-fast); box-shadow: var(--shadow-xs); outline: none;
}
.ch-card:hover { border-color: var(--primary-border); box-shadow: var(--shadow-md); transform: translateY(-3px); }
.ch-card:focus-visible { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-focus); }
.ch-card-avatar {
  width: 58px; height: 58px; flex: 0 0 58px; border-radius: var(--radius-full); overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; box-shadow: var(--shadow-sm);
}
.ch-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ch-card-main { flex: 1; min-width: 0; }
.ch-card-name { font-family: var(--font-serif); font-size: 16px; color: var(--text-primary); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-card-badges { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 7px; }
.ch-badge { font-size: 10px; padding: 2px 8px; border-radius: var(--radius-full); background: var(--bg-tertiary); color: var(--text-secondary); }
.ch-badge-official { background: var(--primary-bg); color: var(--primary); border: 1px solid var(--primary-border); }
.ch-badge-shared { background: var(--success-bg); color: var(--success-dark); }
.ch-badge-hub { background: var(--info-bg); color: var(--info-dark); }
.ch-badge-book { background: var(--warning-bg); color: var(--warning-dark); }
.ch-badge-alt { background: var(--bg-tertiary); color: var(--text-secondary); }
.ch-card-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 9px; }
.ch-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 11px; color: var(--text-muted); }
.ch-card-cat { background: var(--bg-tertiary); padding: 2px 8px; border-radius: var(--radius-full); color: var(--text-secondary); }
.ch-card-creator { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
.ch-card-stats { margin-left: auto; font-variant-numeric: tabular-nums; }

.ch-empty { text-align: center; padding: 70px 20px; color: var(--text-secondary); }
.ch-empty-icon { font-size: 46px; margin-bottom: 14px; opacity: 0.5; }
.ch-empty p { font-size: 14px; }

.ch-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 28px; }
.ch-page-info { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------- 详情弹窗 ---------- */
.ch-detail-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.ch-detail-avatar {
  width: 72px; height: 72px; flex: 0 0 72px; border-radius: var(--radius-md); overflow: hidden;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex; align-items: center; justify-content: center; font-size: 30px; color: #fff; box-shadow: var(--shadow-md);
}
.ch-detail-avatar img { width: 100%; height: 100%; object-fit: cover; }
.ch-detail-head-main { flex: 1; min-width: 0; }
.ch-detail-sub { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); margin-top: 8px; }
.ch-detail-lock { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning-dark); font-size: 13px; margin-bottom: 14px; }
.ch-detail-field { margin-bottom: 14px; }
.ch-detail-field h4 { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; font-weight: var(--font-semibold); }
.ch-detail-text { font-size: 13.5px; line-height: 1.7; color: var(--text-primary); white-space: pre-wrap; word-break: break-word; background: var(--bg-secondary); padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--glass-border); max-height: 260px; overflow-y: auto; }
.ch-detail-loading { font-size: 13px; color: var(--text-muted); padding: 20px 0; text-align: center; }
.ch-alt-item { margin-bottom: 8px; }
.ch-alt-item b { color: var(--primary); }
.ch-book-line { padding: 4px 0; border-bottom: 1px dashed var(--border-color); font-size: 12.5px; }
.ch-book-line:last-child { border-bottom: none; }
.ch-book-line b { color: var(--primary-dark); }

/* ---------- 页脚 ---------- */
.ch-footer { border-top: 1px solid var(--glass-border); background: var(--footer-bg); padding: 18px 20px; text-align: center; }
.ch-footer p { font-size: 12px; color: var(--text-muted); max-width: 720px; margin: 0 auto; line-height: 1.6; }
.ch-footer-links { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 8px !important; }
.ch-footer-links a { color: var(--primary); text-decoration: none; font-size: 12px; }
.ch-footer-links a:hover { text-decoration: underline; }
.ch-footer-links span { color: var(--text-muted); opacity: 0.6; }

/* ---------- 治理与上传 ---------- */
.ch-badge-blocked { background: var(--danger-bg, #fee2e2); color: var(--danger-dark, #b91c1c); border: 1px solid var(--danger-border, #fecaca); }
.ch-btn-danger { background: var(--danger, #ef4444); border-color: var(--danger, #ef4444); color: #fff; }
.ch-btn-danger:hover { filter: brightness(0.94); color: #fff; }
.ch-admin-sep { margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--border-color); font-size: 13px; opacity: 0.75; }
.ch-detail-blocked { background: var(--danger-bg, #fee2e2); border-color: var(--danger-border, #fecaca); color: var(--danger-dark, #b91c1c); }

.ch-upload-hint { font-size: 13px; line-height: 1.7; color: var(--text-secondary); margin-bottom: 12px; }
.ch-upload-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 26px 16px; border: 1.5px dashed var(--border-color); border-radius: var(--radius-md);
  background: var(--bg-secondary); cursor: pointer; text-align: center; transition: border-color 0.15s, background 0.15s;
}
.ch-upload-drop:hover, .ac-modal-overlay.dragover .ch-upload-drop { border-color: var(--primary); background: var(--primary-bg); }
.ch-upload-icon { font-size: 26px; }
.ch-upload-text { font-size: 13.5px; color: var(--text-primary); font-weight: var(--font-medium); }
.ch-upload-sub { font-size: 11.5px; color: var(--text-muted); line-height: 1.6; }
.ch-upload-list { list-style: none; margin: 12px 0 0; max-height: 180px; overflow-y: auto; }
.ch-upload-list li {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 12.5px;
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm); background: var(--bg-secondary); margin-bottom: 6px;
}
.ch-upload-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-primary); }
.ch-upload-size { color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.ch-upload-del {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: var(--radius-full); border: none; cursor: pointer;
  background: var(--bg-tertiary); color: var(--text-secondary); font-size: 13px; line-height: 1;
}
.ch-upload-del:hover { background: var(--danger, #ef4444); color: #fff; }
.ch-upload-result { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bg-secondary); border: 1px solid var(--glass-border); font-size: 12.5px; line-height: 1.7; max-height: 160px; overflow-y: auto; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .ch-topbar-inner { flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .ch-search { order: 3; flex-basis: 100%; }
  .ch-brand-text { display: none; }
  .ch-hero { padding: 22px 16px 12px; }
  .ch-hero h1 { font-size: 22px; }
  .ch-body { padding: 6px 14px 32px; }
  .ch-grid { grid-template-columns: 1fr; }
  .ch-user-name { display: none; }
  .ch-filter-label { flex-basis: 34px; }
}
