/* =============================================
   文章库页面样式（仅主内容区，不影响整体框架）
   ============================================= */

.alib-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
  --alib-border: rgba(51, 65, 85, 0.4);
  --alib-border-light: rgba(51, 65, 85, 0.55);
  --alib-blue: #60a5fa;
  --alib-danger: #f87171;
}

.alib-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.alib-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ---- 按钮 ---- */
.alib-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-btn);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.alib-btn--sm {
  padding: 6px 12px;
  font-size: 12px;
}

.alib-btn--primary {
  background: var(--accent-emerald);
  color: #fff;
  box-shadow: var(--shadow-emerald);
}

.alib-btn--primary:hover {
  background: #059669;
}

.alib-btn--secondary {
  background: var(--bg-card);
  border-color: var(--alib-border-light);
  color: var(--text-title);
}

.alib-btn--secondary:hover {
  background: var(--bg-elevated);
  border-color: rgba(51, 65, 85, 0.8);
}

.alib-btn--ghost {
  background: transparent;
  border-color: var(--alib-border);
  color: var(--text-body);
}

.alib-btn--ghost:hover {
  color: var(--text-title);
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--alib-border-light);
}

.alib-btn--danger {
  color: var(--alib-danger);
  border-color: rgba(248, 113, 113, 0.25);
}

.alib-btn--danger:hover {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.4);
}

.alib-btn--disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---- 工具栏 ---- */
.alib-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.alib-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  height: 38px;
  padding: 0 14px;
  background: var(--bg-card);
  border: 1px solid var(--alib-border);
  border-radius: var(--radius-btn);
  color: var(--text-muted);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.alib-search:focus-within {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.alib-search-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-title);
  font-size: 13px;
  font-family: inherit;
}

.alib-search-input::placeholder {
  color: var(--text-muted);
}

.alib-select {
  height: 38px;
  padding: 0 12px;
  min-width: 128px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--alib-border);
  background: var(--bg-card);
  color: var(--text-title);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.alib-select:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.alib-toolbar-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- 主体：分类 + 列表 ---- */
.alib-body {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 20px;
}

.alib-cat-panel {
  width: 196px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--alib-border);
  border-radius: var(--radius-card);
  padding: 14px 10px 12px;
  display: flex;
  flex-direction: column;
}

.alib-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
}

.alib-cat-add {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  transition: color 0.15s ease, background 0.15s ease;
}

.alib-cat-add:hover {
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
}

.alib-cat-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.alib-cat-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-body);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  border: 1px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.alib-cat-item svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.alib-cat-item:hover {
  background: var(--bg-elevated);
  color: var(--text-title);
}

.alib-cat-item--active {
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent-emerald);
  font-weight: 600;
  border-color: rgba(16, 185, 129, 0.12);
}

.alib-cat-item--active svg {
  opacity: 1;
}

.alib-cat-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alib-cat-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-primary);
  padding: 1px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.alib-cat-item--active .alib-cat-count {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
}

.alib-cat-item--custom {
  position: relative;
}

.alib-cat-item--custom .alib-cat-count {
  transition: opacity 0.15s ease;
}

.alib-cat-del {
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-left: -2px;
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
}

.alib-cat-item--custom:hover .alib-cat-count {
  display: none;
}

.alib-cat-item--custom:hover .alib-cat-del {
  display: flex;
}

.alib-cat-del:hover {
  color: var(--alib-danger);
  background: rgba(248, 113, 113, 0.1);
}

.alib-cat-empty-hint {
  padding: 16px 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* ---- 列表面板 ---- */
.alib-list-panel {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--alib-border);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.alib-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.alib-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.alib-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 12px 16px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.4px;
  white-space: nowrap;
  background: var(--bg-card);
  border-bottom: 1px solid var(--alib-border);
}

.alib-table tbody td {
  padding: 12px 16px;
  color: var(--text-body);
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid rgba(51, 65, 85, 0.25);
}

.alib-table tbody tr:last-child td {
  border-bottom: none;
}

.alib-table tbody tr:hover {
  background: rgba(16, 185, 129, 0.04);
}

.alib-table tbody tr:hover .alib-title {
  color: var(--accent-emerald);
}

.alib-check {
  width: 15px;
  height: 15px;
  accent-color: var(--accent-emerald);
  cursor: pointer;
}

.alib-title {
  display: block;
  color: var(--text-title);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}

.alib-score {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-emerald);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.alib-score--empty {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--alib-border);
  font-weight: 600;
}

.alib-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border: 1px solid transparent;
}

.alib-tag--blue {
  background: rgba(96, 165, 250, 0.08);
  color: var(--alib-blue);
  border-color: rgba(96, 165, 250, 0.16);
}

.alib-tag--green {
  background: rgba(16, 185, 129, 0.08);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.16);
}

.alib-tag--gray {
  background: rgba(148, 163, 184, 0.06);
  color: var(--text-muted);
  border-color: rgba(148, 163, 184, 0.12);
}

.alib-row-actions {
  display: flex;
  gap: 6px;
}

.alib-action {
  background: var(--bg-primary);
  border: 1px solid var(--alib-border);
  color: var(--text-body);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.alib-action:hover {
  color: var(--text-title);
  background: var(--bg-elevated);
  border-color: var(--alib-border-light);
}

.alib-action--danger:hover {
  color: var(--alib-danger);
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.3);
}

/* ---- 空状态 ---- */
.alib-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  gap: 8px;
}

.alib-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  border: 1px solid var(--alib-border);
  color: var(--text-muted);
  opacity: 0.85;
}

.alib-empty-title {
  color: var(--text-body);
  font-size: 15px;
  font-weight: 600;
}

.alib-empty-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 10px;
}

/* ---- GEO 评分 / 一键优化弹窗（页面级，不依赖工作台容器） ---- */
.geo-modal {
  --accent-green: var(--accent-emerald);
  --accent-blue: #60a5fa;
  --accent-cyan: #22d3ee;
  --accent-orange: #f59e0b;
  --text-primary: var(--text-title);
  --text-secondary: var(--text-body);
  --bg-input: var(--bg-card);
  --border-color: rgba(51, 65, 85, 0.4);
  --border-light: rgba(51, 65, 85, 0.55);
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 24px;
  pointer-events: auto;
}

.geo-modal.on { display: flex !important; }
#optimize-modal { z-index: 420; }

.geo-modal-card {
  width: 560px;
  max-width: 100%;
  background: var(--bg-card);
  border: 1px solid rgba(51, 65, 85, 0.5);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-modal);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-title);
}

.geo-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(51, 65, 85, 0.3);
}

.geo-modal-title { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; color: var(--text-title); }
.geo-modal-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.geo-modal-x {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.geo-modal-x:hover { color: var(--text-title); background: var(--bg-elevated); }

.geo-modal-body { padding: 16px 20px 8px; }

.geo-modal-body textarea {
  width: 100%;
  min-height: 220px;
  padding: 12px 14px;
  border-radius: var(--radius-btn);
  border: 1px solid rgba(51, 65, 85, 0.5);
  background: var(--bg-primary);
  color: var(--text-title);
  font-size: 13px;
  line-height: 1.7;
  outline: none;
  resize: vertical;
  font-family: inherit;
}

.geo-modal-body textarea:focus {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
  background: var(--bg-elevated);
}

.geo-modal-body textarea::placeholder { color: var(--text-muted); }

.geo-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px 18px;
}

.geo-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(51, 65, 85, 0.5);
  border-top-color: var(--accent-emerald);
  border-radius: 50%;
  animation: alib-wb-spin 0.8s linear infinite;
}

@keyframes alib-wb-spin { to { transform: rotate(360deg); } }

.geo-score-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 56px 24px;
}

.geo-score-loading-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-title);
}

.geo-score-loading-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.geo-score-result { display: none; padding: 16px 20px 8px; }
.geo-score-result.on { display: block; }

.geo-score-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.geo-score-card {
  position: relative;
  background: var(--bg-primary);
  border: 1px solid rgba(51, 65, 85, 0.4);
  border-radius: 12px;
  padding: 16px 14px 14px;
  overflow: hidden;
  min-height: 92px;
}

.geo-score-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--card-accent, var(--accent-emerald));
}

.geo-score-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-body);
  margin-bottom: 8px;
}

.geo-score-card-num {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
  color: var(--card-accent, var(--accent-emerald));
}

.geo-score-card-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.geo-modal .btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 500;
}

.geo-modal .btn-ghost {
  background: transparent;
  border-color: rgba(51, 65, 85, 0.5);
  color: var(--text-body);
}

.geo-modal .btn-ghost:hover {
  color: var(--text-title);
  background: var(--bg-elevated);
}

.geo-modal .btn-primary {
  background: var(--accent-emerald);
  color: #fff;
}

.geo-modal .btn-primary:hover { background: #059669; }

/* 全部关键词弹窗：复用工作台原有标签样式 */
#kw-all-modal .kw-area {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}
#kw-all-modal .kw-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.15);
}
#kw-all-modal .kw-tag .x {
  cursor: pointer;
  opacity: 0.5;
  font-size: 11px;
}
#kw-all-modal .kw-tag .x:hover { opacity: 1; }
#kw-all-modal .btn-ghost {
  background: transparent;
  border-color: rgba(51, 65, 85, 0.55);
  color: var(--text-body);
}
#kw-all-modal .btn-ghost:hover {
  color: var(--text-title);
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(148, 163, 184, 0.2);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  border: 1px solid rgba(51, 65, 85, 0.5);
  color: var(--text-title);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 220;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Lightbox（页面级，避免被工作台 overflow 裁切） */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 410;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.lightbox.on { display: flex !important; }
.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid rgba(51, 65, 85, 0.5);
  color: var(--text-body);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.lightbox-close:hover {
  background: var(--bg-card);
  color: var(--text-title);
}
.lightbox-img {
  max-width: 85vw;
  max-height: 85vh;
  border-radius: var(--radius-card);
  background: var(--bg-elevated);
  border: 1px solid rgba(51, 65, 85, 0.4);
  box-shadow: var(--shadow-modal);
}
.lightbox-info {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid rgba(51, 65, 85, 0.5);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-body);
}
