/* ==========================================================================
   Study Hub · 导航中心页面
   ========================================================================== */

/* -------------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 9px; flex: none; user-select: none; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 2px 8px var(--accent-ring);
}
.brand .logo svg { width: 16px; height: 16px; }
.brand .name { font-size: 14.5px; font-weight: 680; letter-spacing: -.01em; }
.brand .name span { color: var(--text-dim); font-weight: 450; }

.search {
  position: relative; flex: 1; max-width: 460px;
}
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-dim); pointer-events: none;
}
.search input {
  width: 100%; height: 36px; padding: 0 62px 0 34px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font-size: 13.5px;
  transition: border-color .14s, box-shadow .14s;
}
.search input::placeholder { color: var(--text-dim); }
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.search kbd {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 5px; pointer-events: none;
}
.search .clear {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; border: none; border-radius: 50%;
  background: var(--border); color: var(--text-soft); cursor: pointer;
  display: none; place-items: center; font-size: 13px; line-height: 1; padding: 0;
}
.search.has-value .clear { display: grid; }
.search.has-value kbd { display: none; }

.topbar .actions { display: flex; align-items: center; gap: 7px; flex: none; margin-left: auto; }

/* 已登录状态：管理员按钮变成实心强调色 */
#btn-admin.on {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--accent-soft);
}
#btn-admin.on:hover { border-color: var(--accent); background: var(--accent-soft); }

/* -------------------------------------------------------------- 工具条 */

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px 10px;
}
.cats { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; flex: 1; min-width: 0; }
.toolbar .tools { display: flex; align-items: center; gap: 7px; }

/* -------------------------------------------------------------- 主区 */

.wrap { padding: 4px 20px 80px; max-width: 1680px; margin: 0 auto; }

.stat-line {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--text-dim);
  padding: 4px 2px 12px;
}
.stat-line b { color: var(--text-soft); font-weight: 600; }

/* 卡片网格 */
.grid {
  display: grid; gap: 13px;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
}
.grid.list-view { grid-template-columns: 1fr; gap: 7px; }

.card {
  position: relative;
  display: flex; flex-direction: column; gap: 9px;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .12s, background .15s;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--card-color, var(--accent));
  opacity: 0; transition: opacity .15s;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.card:hover::before { opacity: 1; }
.card:active { transform: translateY(0); }
.card.pinned { background: var(--surface-2); }
.card.pinned::before { opacity: 1; }
.card.missing { border-style: dashed; }
.card.missing .card-title { color: var(--text-dim); }

.card-head { display: flex; align-items: flex-start; gap: 10px; }

.card-icon {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--card-color, var(--accent)) 13%, transparent);
  color: var(--card-color, var(--accent));
}
.card-icon svg { width: 16px; height: 16px; }

.card-titles { flex: 1; min-width: 0; }
.card-title {
  font-size: 14px; font-weight: 600; line-height: 1.42; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.card-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }

.card-desc {
  font-size: 12.5px; color: var(--text-soft); line-height: 1.58;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}

.card-path {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  direction: rtl; text-align: left;
}

.card-foot {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: auto; padding-top: 2px;
}
.card-foot .meta { font-size: 11px; color: var(--text-dim); margin-left: auto; white-space: nowrap; }

.card-ops {
  position: absolute; top: 9px; right: 9px;
  display: flex; gap: 3px; opacity: 0; transform: translateY(-3px);
  transition: opacity .14s, transform .14s;
  background: var(--surface); border-radius: 8px; padding: 2px;
  box-shadow: var(--shadow-sm);
}
.card:hover .card-ops, .card:focus-within .card-ops { opacity: 1; transform: none; }
.card-ops button {
  width: 26px; height: 26px; border: none; border-radius: 6px;
  background: transparent; color: var(--text-dim); cursor: pointer;
  display: grid; place-items: center; padding: 0; transition: all .12s;
}
.card-ops button:hover { background: var(--surface-hover); color: var(--text); }
.card-ops button.del:hover { background: color-mix(in srgb, var(--red) 14%, transparent); color: var(--red); }
.card-ops button svg { width: 14px; height: 14px; }

.star-btn { color: var(--text-dim); }
.star-btn.on { color: var(--orange); }
.star-btn.on svg { fill: currentColor; }

/* 列表视图 */
.grid.list-view .card { flex-direction: row; align-items: center; gap: 13px; padding: 10px 14px; }
.grid.list-view .card-head { flex: none; align-items: center; }
.grid.list-view .card-titles { display: flex; align-items: baseline; gap: 10px; }
.grid.list-view .card-title { -webkit-line-clamp: 1; }
.grid.list-view .card-desc { display: none; }
.grid.list-view .card-path { flex: 1; min-width: 0; }
.grid.list-view .card-foot { margin: 0; flex: none; padding: 0; }
.grid.list-view .card-foot .meta { display: none; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 9px; }
  .brand .name span { display: none; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .wrap, .toolbar { padding-left: 14px; padding-right: 14px; }
  .grid { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------- 扫描面板 */

.scan-dir-row { display: flex; gap: 8px; align-items: flex-end; }
.scan-dir-row .field { flex: 1; }

.scan-list {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; max-height: 46vh; overflow-y: auto; background: var(--surface-2);
}
.scan-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
}
.scan-item:last-child { border-bottom: none; }
.scan-item:hover { background: var(--surface-hover); }
.scan-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex: none; }
.scan-item .info { flex: 1; min-width: 0; }
.scan-item .t { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-item .p { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }
.scan-item.already { opacity: .5; }
.scan-item .badge { font-size: 10.5px; color: var(--text-dim); flex: none; }

.scan-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-soft);
}

/* -------------------------------------------------------------- 离线提示 */

.offline-banner {
  display: flex; align-items: flex-start; gap: 11px;
  margin: 14px 20px 0; padding: 12px 15px;
  border: 1px solid color-mix(in srgb, var(--orange) 42%, var(--border));
  background: color-mix(in srgb, var(--orange) 9%, var(--surface));
  border-radius: var(--radius);
  font-size: 12.5px; color: var(--text-soft); line-height: 1.65;
}
.offline-banner svg { width: 17px; height: 17px; color: var(--orange); flex: none; margin-top: 1px; }
.offline-banner b { color: var(--text); }
.offline-banner code {
  font-family: var(--font-mono); font-size: 11.5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 5px;
}

/* -------------------------------------------------------------- 拖拽排序 */

.card.dragging { opacity: .4; }
.card.drop-target { box-shadow: 0 0 0 2px var(--accent); }

/* -------------------------------------------------------------- 分类管理行 */

.cat-row {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2);
}
.cat-row .swatch {
  width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--border-strong);
  padding: 0; cursor: pointer; background: none; flex: none;
}
.cat-row .input { height: 30px; padding: 0 9px; font-size: 13px; background: var(--surface); }
