/* ============================================================
   文章库
   ============================================================ */
.library-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.library-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px;
  margin-bottom: 22px;
  background: rgba(255, 252, 247, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  backdrop-filter: blur(8px);
}

.search-box {
  position: relative;
  flex: 1 1 220px;
  min-width: 160px;
  max-width: 420px;
}
.search-box svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}
.search-box .input {
  padding-left: 34px;
  background: var(--surface);
  border-color: transparent;
  box-shadow: none;
}
.search-box .input:hover { border-color: var(--line-strong); }
.search-box .input:focus { border-color: var(--accent); background: var(--surface); }

.status-tabs {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.status-tab {
  position: relative;
  padding: 6px 13px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease);
}
.status-tab:hover { color: var(--ink); }
.status-tab[aria-selected="true"] {
  background: var(--surface);
  color: var(--accent-deep);
  box-shadow: var(--shadow-xs);
}
.status-tab .count {
  display: inline-block;
  margin-left: 5px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}
.status-tab[aria-selected="true"] .count { color: var(--accent); }

.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--line);
  flex: none;
}

.view-switch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-sunken);
  border-radius: var(--radius-sm);
}
.view-switch button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 27px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--ink-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.view-switch button:hover { color: var(--ink); }
.view-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent-deep);
  box-shadow: var(--shadow-xs);
}

/* ---------------- 选择模式 ---------------- */
.selection-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 16px;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  background: var(--accent-wash);
  border: 1px solid var(--accent-soft);
  color: var(--accent-deep);
  font-size: 13.5px;
  animation: slideDown 200ms var(--ease);
}
.selection-bar.visible { display: flex; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.selection-bar strong { font-variant-numeric: tabular-nums; }

/* ---------------- 网格：块视图 ---------------- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 218px;
  padding: 20px 20px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform 220ms var(--ease), box-shadow 220ms var(--ease),
              border-color 220ms var(--ease);
  user-select: none;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  pointer-events: none;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-md);
  background: #fffdf9;
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  min-height: 22px;
}
.card-check {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: transparent;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), opacity var(--dur) var(--ease);
  cursor: pointer;
  opacity: 0;
}
.card:hover .card-check,
.card:focus-within .card-check,
.selection-bar.visible ~ #library-list .card-check,
.card.selected .card-check,
.table-row:hover .card-check,
.table-row:focus-within .card-check,
.table-row.selected .card-check {
  opacity: 1;
}
.card-check:hover { border-color: var(--accent); }
.card.selected .card-check,
.card-check[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fffaf3;
}
.card-meta-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.card-menu {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-faint);
  opacity: 0;
  transition: opacity var(--dur) var(--ease), background var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.card:hover .card-menu,
.card:focus-within .card-menu { opacity: 1; }
.card-menu:hover { background: var(--accent-wash); color: var(--accent-deep); }

.card-title {
  font-family: var(--font-serif);
  font-size: 17.5px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.card-excerpt {
  margin-top: 9px;
  font-size: 13px;
  line-height: 1.78;
  color: var(--ink-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  flex: 1 1 auto;
}
.card-excerpt.empty { color: var(--ink-faint); font-style: italic; }

.card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-faint);
}
.card-foot .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }

/* ---------------- 列表视图 ---------------- */
.article-table {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.table-head, .table-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 2.4fr) 96px minmax(0, 1fr) 116px 44px;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 10px;
}
.table-head {
  height: 42px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-alt);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  text-transform: uppercase;
}
.table-row {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.table-row:last-child { border-bottom: 0; }
.table-row:hover { background: var(--surface-alt); }
.table-row.selected { background: var(--accent-wash); }
.table-row .cell-title {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-row .cell-excerpt {
  font-size: 12.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-row .cell-time {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.table-row .cell-actions {
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.table-row:hover .cell-actions,
.table-row:focus-within .cell-actions { opacity: 1; }
.table-check-cell { display: flex; justify-content: center; }

/* ---------------- 骨架 ---------------- */
.library-skeleton { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 18px; }
.skeleton-card {
  height: 218px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .table-head { display: none; }
  .table-row {
    grid-template-columns: 36px minmax(0, 1fr) 78px 30px;
    grid-template-areas: "check title status actions" "check excerpt time actions";
    row-gap: 3px;
    padding: 12px 12px 12px 6px;
    min-height: 0;
  }
  .table-row .cell-check { grid-area: check; }
  .table-row .cell-title { grid-area: title; white-space: normal; }
  .table-row .cell-excerpt { grid-area: excerpt; }
  .table-row .cell-status { grid-area: status; justify-self: start; }
  .table-row .cell-time { grid-area: time; justify-self: end; }
  .table-row .cell-actions { grid-area: actions; opacity: 1; }
  .article-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
  .library-toolbar { gap: 8px; }
  .toolbar-sep { display: none; }
}

@media (max-width: 520px) {
  .article-grid { grid-template-columns: 1fr; }
  .card { min-height: 176px; padding: 17px; }
  .library-head { margin-bottom: 14px; }
  .status-tabs { flex: 1 1 100%; justify-content: space-between; }
  .status-tab { flex: 1; text-align: center; }
  .view-switch { margin-left: auto; }
}
