/* 组件层：按钮/徽章/chip/卡片/表格/抽屉/弹窗/骨架/toast（6.3 组件清单的样式基座）*/

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--fg);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-4);
  min-height: 40px;
  font-size: var(--t-sm);
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.btn:hover {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.06);
}
.btn-ghost {
  border-color: transparent;
  background: none;
  color: var(--fg-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--fg);
}
.btn-sm {
  min-height: 32px;
  padding: var(--s-1) var(--s-2);
  font-size: var(--t-xs);
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  border-radius: var(--r-sm);
  color: var(--fg-2);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--fg);
}

/* ---------- 徽章 / chip ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--t-xs);
  line-height: 1;
  padding: 3px var(--s-2);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--fg-2);
  background: var(--surface);
  white-space: nowrap;
}
.badge-ok {
  color: var(--ok);
  border-color: var(--ok);
}
.badge-warn {
  color: var(--warn);
  border-color: var(--warn);
}
.badge-danger {
  color: var(--danger);
  border-color: var(--danger);
}
.badge-info {
  color: var(--info);
  border-color: var(--info);
}
.badge-accent {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  font-size: var(--t-xs);
  padding: 2px var(--s-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ---------- 结果卡 ---------- */
.result-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.result-card + .result-card {
  margin-top: var(--s-3);
}
.result-card:hover {
  border-color: var(--line-strong);
}
.result-card.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.result-card .r-title {
  font-family: var(--font-serif);
  font-size: var(--t-md);
  line-height: 1.4;
  margin: 0 0 var(--s-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-card .r-title a {
  color: var(--fg);
}
.result-card .r-meta {
  color: var(--fg-2);
  font-size: var(--t-sm);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  align-items: center;
}
.result-card .r-actions {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  display: flex;
  gap: var(--s-1);
  opacity: 0;
  transition: opacity var(--dur-1) var(--ease);
}
.result-card:hover .r-actions,
.result-card:focus-within .r-actions,
.result-card.is-current .r-actions {
  opacity: 1;
}
@media (hover: none) {
  .result-card .r-actions {
    opacity: 1;
  }
}
.result-card .r-abstract {
  color: var(--fg-2);
  font-size: var(--t-sm);
  margin: var(--s-2) 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 骨架屏 ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: ps-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes ps-shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}
.skeleton-card {
  height: 96px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.skeleton-card .sk-line {
  height: 14px;
  margin-bottom: var(--s-2);
}
.skeleton-card .sk-line.w60 {
  width: 60%;
}

/* ---------- 空态 / 提示条 ---------- */
.empty-state {
  text-align: center;
  color: var(--fg-2);
  padding: var(--s-7) var(--s-4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
}
.empty-state .btn {
  margin: var(--s-2) var(--s-1) 0;
}

.notice-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
  font-size: var(--t-sm);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  margin-bottom: var(--s-3);
}
.notice-warn {
  background: var(--accent-soft);
  color: var(--warn);
  border: 1px solid var(--warn);
}
.notice-danger {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* ---------- 抽屉 / 弹窗 ---------- */
.drawer-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 24, 0.45);
  z-index: var(--z-drawer);
  display: flex;
  justify-content: flex-end;
}
.modal-overlay {
  justify-content: center;
  align-items: center;
  z-index: var(--z-modal);
}
.drawer-panel {
  width: min(480px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: var(--s-5);
  box-shadow: var(--shadow-pop);
}
.modal-card {
  width: min(560px, calc(100vw - var(--s-6)));
  max-height: 80dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-5);
  box-shadow: var(--shadow-pop);
}
@media (max-width: 639px) {
  .drawer-panel {
    width: 100%;
    border-left: none;
  }
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-6);
  transform: translateX(-50%);
  z-index: var(--z-toast);
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--r-pill);
  padding: var(--s-2) var(--s-4);
  font-size: var(--t-sm);
  display: flex;
  gap: var(--s-3);
  align-items: center;
  box-shadow: var(--shadow-pop);
}
.toast .btn-link {
  background: none;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: var(--t-sm);
}

/* ---------- 表格视图 ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.data-table th {
  background: var(--surface-2);
  color: var(--fg-2);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 56px;
}
.data-table tbody tr:hover {
  background: var(--surface-2);
}
.data-table .num {
  text-align: right;
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  margin-top: var(--s-5);
}

/* ---------- 进度条（顶部 2px，I-12） ---------- */
.top-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 30%;
  background: var(--accent);
  z-index: calc(var(--z-toast) + 1);
  transition: width var(--dur-2) var(--ease), opacity var(--dur-2) var(--ease);
}

/* ---------- 命令面板 ---------- */
.palette-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 20, 24, 0.45);
  z-index: var(--z-modal);
  display: flex;
  justify-content: center;
  padding-top: 12dvh;
}
.palette-panel {
  width: min(620px, calc(100vw - var(--s-6)));
  height: fit-content;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.palette-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: var(--s-4);
  font-size: var(--t-md);
}
.palette-list {
  max-height: 50dvh;
  overflow-y: auto;
  margin: 0;
  padding: var(--s-2);
  list-style: none;
}
.palette-list li {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: var(--t-sm);
}
.palette-list li.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.palette-list .pl-hint {
  margin-left: auto;
  color: var(--fg-3);
}

/* ---------- M2-15 关键词高亮 ---------- */
mark.ps-hl {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}

/* ---------- M2-15 关键词高亮（与 M8 合并确认） ---------- */
mark.ps-hl {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 1px;
}

/* ---------- M9-23 打印友好样式 ---------- */
@media print {
  .ps-header,
  .ps-nav,
  .ps-footer,
  .js-toolbar,
  .ps-col-filters,
  .ps-col-detail,
  .r-actions,
  .notice-bar,
  .pagination,
  .js-ai-panel,
  .toast,
  .top-progress,
  .palette-overlay,
  .drawer-overlay,
  .modal-overlay,
  button,
  input,
  select,
  textarea {
    display: none !important;
  }
  .ps-main {
    padding: 0;
    max-width: 100%;
  }
  .result-card,
  .data-table {
    break-inside: avoid;
    border: 1px solid #ccc;
    box-shadow: none;
  }
  .result-card a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 10px;
    color: #666;
    word-break: break-all;
  }
  body {
    color: #000;
    background: #fff;
    font-size: 12pt;
  }
}
