/* 白色和浅白色为主，青色只做点缀 */
:root {
  --bg: #f7f8f8;
  --panel: #ffffff;
  --panel-2: #f3f4f4;
  --text: #1d2224;
  --muted: #6c7478;
  --line: #e8eaea;
  --accent: #8cffde;          /* rgb(140,255,222)：按钮底色、点缀 */
  --accent-hover: #6ff3cd;
  --accent-text: #0a7a5c;     /* 白底上的青色文字，保证看得清 */
  --accent-line: #45d9ae;     /* 输入框聚焦边框 */
  --accent-tint: #ebfff9;
  --accent-ink: #0b3b30;
  --accent-soft: #f3f4f4;
  --danger: #d6336c;
  --ok: #0f9d76;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 6px 20px rgb(0 0 0 / 5%);
  --radius: 14px;
  --top: 64px;
  --side: 232px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--top);
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: .5px; flex: none; color: var(--text); width: calc(var(--side) - 24px); }
.admin .brand { width: auto; }
.brand img { border-radius: 8px; display: block; }
.search {
  flex: 1; max-width: 560px;
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent-line); background: var(--panel); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.spacer { flex: 1; }

/* ---------- 布局 ---------- */
.layout { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: calc(100vh - var(--top)); }
.sidebar {
  position: sticky; top: var(--top);
  align-self: start;
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 16px 0;
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.nav-title { font-size: 12px; color: var(--muted); padding: 18px 26px 8px; letter-spacing: 1px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 1px 12px; padding: 10px 14px; border-radius: 10px;
  text-decoration: none; color: var(--text);
}
.nav-item:hover { background: var(--panel-2); }
.nav-item.active { background: var(--accent-tint); color: var(--accent-text); font-weight: 600; }
.nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { min-width: 0; display: flex; flex-direction: column; min-height: calc(100vh - var(--top)); }
.main { flex: 1; width: 100%; max-width: 1240px; padding: 28px 32px 40px; }
/* ---------- 页脚 ---------- */
.footer { margin-top: 24px; padding: 36px 32px 0; background: var(--panel); border-top: 1px solid var(--line); color: var(--muted); font-size: 13.5px; }
.footer-grid, .footer-bottom { max-width: 1176px; }
.footer-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1.4fr); gap: 32px; padding-bottom: 28px; }
.footer .brand { width: auto; font-size: 17px; }
.footer-brand p { margin: 10px 0 0; max-width: 340px; line-height: 1.7; }
.footer-col h4 { margin: 4px 0 12px; font-size: 14px; color: var(--text); }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent-text); }
.footer-notes { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.footer-bottom { padding: 16px 0 22px; border-top: 1px solid var(--line); font-size: 12.5px; }

/* ---------- 首页 ---------- */
.hero {
  padding: 28px 28px 24px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 28px;
}
.hero h1 { font-size: 26px; }
.hero p { margin: 8px 0 0; color: var(--muted); }
.hero-stats { display: flex; gap: 20px; margin-top: 14px; color: var(--muted); font-size: 14px; }
.hero-stats strong { color: var(--text); font-size: 18px; margin-right: 2px; }
.shelf { margin-bottom: 32px; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.shelf-head h2 { font-size: 19px; }
.more { font-size: 14px; color: var(--accent-text); text-decoration: none; }
.more:hover { text-decoration: underline; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; }
.status, .empty { color: var(--muted); padding: 24px 0; margin: 0; }

/* ---------- 卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
/* 卡片 3:2，本身不可点 */
.card {
  aspect-ratio: 3 / 2;
  display: flex; flex-direction: column; gap: 12px;
  padding: 18px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.card-title { min-width: 0; display: flex; flex-direction: column; }
.icon { flex: none; width: 48px; height: 48px; border-radius: 12px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--line); }
.icon-lg { width: 72px; height: 72px; border-radius: 16px; }
.icon-sm { width: 40px; height: 40px; border-radius: 10px; }
.card-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-desc {
  margin: 0; color: var(--muted); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-foot { margin-top: auto; display: flex; justify-content: flex-end; }
.host { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 18px;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-sm { height: 30px; padding: 0 14px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.chip { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.chip-accent { color: var(--accent-text); margin-left: 6px; }
/* 卡片上的下载：浅底，青色字 */
.btn-soft { background: var(--panel-2); color: var(--accent-text); border-color: var(--line); }
.btn-soft:hover { background: var(--accent-tint); border-color: var(--accent-line); }

/* ---------- 详情弹窗 ---------- */
.detail {
  width: min(560px, calc(100vw - 32px));
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--panel); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 25%);
}
.detail::backdrop { background: rgb(20 15 10 / 45%); backdrop-filter: blur(2px); }
.detail-inner { padding: 24px; }
.detail-head { display: flex; align-items: center; gap: 16px; }
.detail-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.detail-title h2 { font-size: 21px; word-break: break-word; }
.close { align-self: flex-start; width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--panel-2); color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.close:hover { color: var(--text); }
.detail-desc { margin: 20px 0; white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow-y: auto; }
.detail-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.source { display: flex; flex-direction: column; font-size: 13px; min-width: 0; }
.source strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 后台 ---------- */
.admin-tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--panel-2); color: var(--accent-text); font-weight: 600; margin-left: -12px; }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 24px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.panel h2 { font-size: 18px; margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.panel-head input { max-width: 200px; }
.gate { max-width: 440px; margin: 10vh auto 0; }
.gate h1 { font-size: 22px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; align-items: start; }
.admin-grid .panel { margin-bottom: 0; }
.admin-grid + .panel { margin-top: 20px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.form label.btn { flex-direction: row; font-weight: 600; }
input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; min-height: 38px; font-weight: 400;
  width: 100%;
}
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-line); background: var(--panel); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row > input:not(.w-num) { flex: 1; min-width: 140px; width: auto; }
.w-num { width: 90px; flex: none; }
.icon-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 400; }
.msg { margin: 8px 0 0; font-size: 14px; min-height: 1.4em; }
.msg.ok { color: var(--ok); }
.msg.err { color: var(--danger); }
.app-list { display: flex; flex-direction: column; max-height: 70vh; overflow-y: auto; }
.app-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.app-row:last-child { border-bottom: 0; }
.app-row.editing { background: var(--accent-soft); }
.app-row-main { flex: 1; min-width: 0; }
.app-row-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.count-cell { width: 44px; }

/* ---------- 手机 ---------- */
@media (max-width: 860px) {
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --top: 56px; }
  .topbar { gap: 12px; padding: 0 16px; }
  .brand { width: auto; }
  .brand span { display: none; }
  .admin .brand span, .footer .brand span { display: inline; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: var(--top); z-index: 5;
    height: auto; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 10px 16px; gap: 6px;
    border-right: 0; border-bottom: 1px solid var(--line);
    scrollbar-width: none;
  }
  .nav-title { display: none; }
  .nav-item { flex: none; margin: 0; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); }
  .nav-item.active { border-color: var(--accent-line); color: var(--accent-text); background: var(--panel); }
  .main { padding: 16px 16px 32px; }
  .footer { padding: 28px 16px 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 22px; }
  .hero { padding: 20px; }
  .hero h1 { font-size: 21px; }
  .grid { grid-template-columns: 1fr; }
  .admin-main { padding: 16px; }
  .detail-foot { flex-direction: column; align-items: stretch; }
}
