/* ==========================================
   资源工作台 · 设计系统
   前台：浅色（对外，可读性优先）
   后台：深色（对内，信息密度优先）
   ========================================== */

:root {
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
             "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC",
             "Microsoft YaHei", sans-serif;
  --font-display: "Noto Serif CJK SC", "Songti SC", "Source Han Serif SC",
                  Georgia, serif;
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ---------- 浅色（前台） ---------- */
body.pub {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --surface-2: #FBFAF6;
  --line: #E7E3DA;
  --line-strong: #D6D1C5;
  --ink: #1A1A17;
  --ink-2: #565650;
  --ink-3: #8B8B82;
  --accent: #1F6B57;
  --accent-hover: #185646;
  --accent-ink: #FFFFFF;
  --accent-soft: #E8F1EC;
  --ok: #15803D;
  --warn: #B45309;
  --danger: #B91C1C;
  --shadow: 0 1px 2px rgba(26,26,23,.04), 0 8px 24px -12px rgba(26,26,23,.12);
  background: var(--bg);
  color: var(--ink);
}

/* ---------- 深色（后台） ---------- */
body.admin {
  --bg: #0A0D10;
  --surface: #11151A;
  --surface-2: #161B21;
  --surface-3: #1B2128;
  --line: #232A33;
  --line-strong: #303945;
  --ink: #E9EBEE;
  --ink-2: #98A2AE;
  --ink-3: #68727E;
  --accent: #3DDC9A;
  --accent-hover: #55E8AB;
  --accent-ink: #042018;
  --accent-soft: rgba(61,220,154,.12);
  --ok: #3DDC9A;
  --warn: #F5A524;
  --danger: #F0616D;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -16px rgba(0,0,0,.8);
  background: var(--bg);
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--accent-ink); }

/* ================= 前台 ================= */
.pub-wrap { max-width: 1120px; margin: 0 auto; padding: 0 var(--sp-5); }

.pub-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-5) 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-size: 19px; font-weight: 700; letter-spacing: .02em;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--accent-ink); font-size: 14px; font-weight: 700;
  font-family: var(--font-ui);
}
.pub-nav .muted { color: var(--ink-3); font-size: 13px; }

.hero { padding: var(--sp-7) 0 var(--sp-5); text-align: center; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.15;
  margin: 0 0 var(--sp-3);
  letter-spacing: -.01em;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--ink-2); margin: 0 auto var(--sp-6); max-width: 460px; }

.searchbar {
  display: flex; gap: var(--sp-2);
  max-width: 620px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 7px 7px 20px;
  box-shadow: var(--shadow);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}
.searchbar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; padding: 10px 0;
}
.searchbar input::placeholder { color: var(--ink-3); }
.btn {
  border: 1px solid transparent; border-radius: 999px;
  padding: 10px 22px; font-size: 14px; font-weight: 600;
  cursor: pointer; background: var(--accent); color: var(--accent-ink);
  transition: transform .15s var(--ease), background .2s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: scale(.97); }
.btn.ghost {
  background: transparent; color: var(--ink); border-color: var(--line-strong);
}
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.quick { margin-top: var(--sp-4); color: var(--ink-3); font-size: 13px; }
.quick button {
  background: none; border: none; color: var(--ink-2); cursor: pointer;
  padding: 2px 6px; border-radius: 6px; font-size: 13px;
}
.quick button:hover { color: var(--accent); background: var(--accent-soft); }

/* 分享：首页一组，结果卡片一个 */
.sharebar {
  margin-top: var(--sp-4);
  display: flex; align-items: center; justify-content: center;
  gap: var(--sp-3); flex-wrap: wrap;
}
.sharebar .sharehint { color: var(--ink-3); font-size: 12px; }

.grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-items: start;
  padding: var(--sp-4) 0 var(--sp-8);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  animation: rise .35s var(--ease) both;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card-cover { aspect-ratio: 4 / 5; background: var(--surface-2); overflow: hidden; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: var(--sp-3) var(--sp-4) var(--sp-4); display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-body h3 {
  margin: 0; font-size: 15px; font-weight: 650; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--ink-2); }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12px;
}
.pill.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.pill.warn { background: rgba(180,83,9,.1); border-color: transparent; color: var(--warn); }
.pill.hot { background: rgba(220,38,38,.1); border-color: transparent; color: #dc2626; font-weight: 600; }
.card-foot { margin-top: auto; display: flex; gap: 8px; }
.card-foot .btn { flex: 1; justify-content: center; text-align: center; }

.empty {
  text-align: center; padding: var(--sp-8) var(--sp-5);
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg);
  color: var(--ink-2); margin-bottom: var(--sp-8);
}
.empty h3 { font-size: 17px; color: var(--ink); margin: 0 0 6px; font-weight: 600; }
.empty p { margin: 0 0 var(--sp-4); font-size: 14px; }
.apply-form { display: flex; gap: 8px; max-width: 420px; margin: 0 auto; }
.apply-form input {
  flex: 1; padding: 10px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); outline: none;
}
.apply-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.pub-foot {
  border-top: 1px solid var(--line); padding: var(--sp-5) 0 var(--sp-7);
  color: var(--ink-3); font-size: 12px; display: flex; justify-content: space-between;
}

/* ================= 后台 ================= */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.side {
  border-right: 1px solid var(--line);
  padding: var(--sp-5) var(--sp-3);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--sp-5);
  background: var(--surface);
}
.side .brand { padding: 0 var(--sp-3); font-size: 17px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.side a:hover { background: var(--surface-2); color: var(--ink); }
.side a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side a .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3);
  margin-left: auto;
}
.side a .dot.ok { background: var(--ok); }
.side .side-foot { margin-top: auto; font-size: 12px; color: var(--ink-3); padding: 0 var(--sp-3); }

.main { padding: var(--sp-6) var(--sp-7); max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: var(--sp-5); gap: var(--sp-4); flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--ink-3); font-size: 13px; }

.panel { display: none; }
.panel.active { display: block; animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-5); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-4);
}
.stat .k { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; color: var(--ink-3); font-weight: 400; margin-left: 4px; }

.box {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: var(--sp-5); margin-bottom: var(--sp-4);
}
.box h2 { font-size: 15px; margin: 0 0 var(--sp-4); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.box h2 .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-3); }
.field label { font-size: 12px; color: var(--ink-3); }
.input, .textarea, .select {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; outline: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  width: 100%;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 88px; resize: vertical; font-size: 13px; line-height: 1.6; }
.row { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 150px; }
.row > .fixed { flex: 0 0 auto; min-width: 0; }

/* 按钮组：自然宽度，不被拉伸 */
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .btn { flex: 0 0 auto; }
.actions .spacer { flex: 1; }

/* 行内勾选 */
.checkline {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none;
  white-space: nowrap;
}
.checkline input { accent-color: var(--accent); width: 15px; height: 15px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 15px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; color: var(--ink-2);
  transition: all .15s var(--ease);
  user-select: none;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip.on {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--ink-3);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  font-size: 12px; white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }
.t-title { font-weight: 550; color: var(--ink); max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; background: var(--surface-3); color: var(--ink-2); margin-right: 4px; }
.dot-ok, .dot-bad, .dot-mid, .dot-idle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
}
.dot-ok::before, .dot-bad::before, .dot-mid::before, .dot-idle::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
}
.dot-ok::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(61,220,154,.15); }
.dot-bad::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(240,97,109,.15); }
.dot-mid::before { background: var(--warn); }
.dot-idle::before { background: var(--ink-3); }

.bar { height: 4px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s var(--ease); }

.log {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  background: #05070A; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: var(--sp-3); max-height: 300px; overflow: auto; line-height: 1.75;
  color: #B6C2CF;
}
.log .err { color: #F0616D; }
.log .warn { color: #F5A524; }
.log .ts { color: #4A5563; margin-right: 8px; }

.empty-row { text-align: center; color: var(--ink-3); padding: var(--sp-6); font-size: 13px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-3); border: 1px solid var(--line-strong);
  color: var(--ink); padding: 11px 20px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: all .25s var(--ease); z-index: 99; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: var(--danger); }

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal-mask.show { display: flex; }
.modal {
  position: relative;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-lg); padding: var(--sp-5); width: min(720px, 92vw);
  max-height: 84vh; overflow: auto; box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 var(--sp-4); font-size: 16px; }

.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.right { text-align: right; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; align-items: center; }
  .side nav { flex-direction: row; }
  .side .side-foot { display: none; }
  .main { padding: var(--sp-4); }
  .pub-wrap { padding: 0 var(--sp-4); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

.modal-x {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer;
  display: grid; place-items: center;
}
.modal-x:hover { background: var(--surface-3); color: var(--ink); }

.result-count {
  font-size: 13px; color: var(--ink-3);
  padding: var(--sp-5) 0 0;
}

/* 后端未连接提示 */
.notice {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 20px auto 0; padding: 10px 18px;
  border: 1px solid #E8CFA6; background: #FCF5E7; color: #8A5A12;
  border-radius: 999px; font-size: 13px;
  animation: fade .25s var(--ease);
}
.notice strong { font-weight: 650; }
.notice.hidden { display: none; }
