:root {
  --bg: #0b0f17; --bg2: #111827; --panel: rgba(255,255,255,.04); --line: rgba(255,255,255,.09);
  --fg: #e5e7eb; --muted: #9ca3af; --accent: #f43f5e; --accent2: #6366f1; --ok: #22c55e; --warn: #f59e0b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at -10% -20%, rgba(244,63,94,.14), transparent 60%),
              radial-gradient(900px 500px at 110% 10%, rgba(99,102,241,.16), transparent 60%), var(--bg);
  color: var(--fg); font: 14px/1.5 -apple-system, "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: #93c5fd; text-decoration: none; } a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 18px; } h2 { font-size: 15px; }

.topbar { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: rgba(11,15,23,.7); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent2)); box-shadow: 0 6px 18px rgba(244,63,94,.35); }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; background: transparent; padding: 6px 10px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: rgba(244,63,94,.18); color: #fff; }
.ctl { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
.ctl input, .ctl select { font: inherit; color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; color-scheme: dark; }
.chk input { width: 15px; height: 15px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 5px 10px; line-height: 1.2; }
.btn:hover { background: rgba(255,255,255,.09); }
.btn.ghost { border-color: transparent; background: transparent; }
.linkbtn { border: 0; background: none; color: #93c5fd; font-size: 12px; padding: 0; cursor: pointer; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 16px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); }
.stats b { color: var(--fg); font-weight: 600; }
.stats .err { color: #fca5a5; }

.layout { flex: 1; display: grid; grid-template-columns: 300px 1fr 360px; min-height: 0; }
.panel { background: var(--panel); border-right: 1px solid var(--line); padding: 14px; overflow: auto; }
.panel.right { border-right: 0; border-left: 1px solid var(--line); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }

.hot-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hot-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; background: rgba(255,255,255,.02); transition: background .15s, border-color .15s; }
.hot-item:hover, .hot-item.active { background: rgba(99,102,241,.12); border-color: rgba(99,102,241,.5); }
.hot-item .lbl { font-weight: 600; display: block; margin-bottom: 4px; }
.hot-item .meta { color: var(--muted); font-size: 12px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.published { color: #86efac; border-color: rgba(34,197,94,.5); background: rgba(34,197,94,.1); }
.badge.picked { color: #fde68a; border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.1); }
.badge.candidate { color: #c7d2fe; border-color: rgba(99,102,241,.5); background: rgba(99,102,241,.1); }
.badge.short { color: #fda4af; border-color: rgba(244,63,94,.5); background: rgba(244,63,94,.1); }
.empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }

.graph-wrap { position: relative; min-height: 420px; background: linear-gradient(transparent 0, transparent 100%); }
#graph { width: 100%; height: 100%; display: block; touch-action: none; }
.graph-tools { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px; z-index: 5; }
.node circle { stroke: rgba(255,255,255,.35); stroke-width: 1; transition: stroke-width .15s; }
.node:hover circle, .node.selected circle { stroke: #fff; stroke-width: 2.5; }
.node text { fill: #f9fafb; pointer-events: none; text-shadow: 0 1px 2px rgba(0,0,0,.9), 0 0 6px rgba(0,0,0,.7); }
.link { stroke: #a5b4fc; stroke-opacity: .28; }
.link.hl { stroke: #fda4af; stroke-opacity: .9; }
.tooltip { position: absolute; pointer-events: none; background: rgba(17,24,39,.96); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12px; max-width: 260px; z-index: 6; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.tooltip b { display: block; font-size: 13px; margin-bottom: 2px; }
.tooltip .muted { color: var(--muted); }
.overlay { position: absolute; inset: 0; display: flex; gap: 10px; align-items: center; justify-content: center; background: rgba(11,15,23,.55); color: var(--muted); z-index: 7; backdrop-filter: blur(2px); }
.overlay[hidden] { display: none; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 12px; }
.kv div { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.kv .n { font-size: 20px; font-weight: 700; display: block; }
.kv .l { color: var(--muted); font-size: 11px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: linear-gradient(135deg, rgba(244,63,94,.25), rgba(99,102,241,.25)); border: 1px solid var(--line); }
.chip small { color: var(--muted); margin-left: 4px; }
.section-title { font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.vcard { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: rgba(255,255,255,.02); }
.vcard img { width: 112px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #1f2937; }
.vcard .t { font-weight: 600; line-height: 1.35; display: block; margin-bottom: 4px; color: var(--fg); }
.vcard .m { color: var(--muted); font-size: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.vcard.src { border-color: rgba(245,158,11,.5); }
.pub-links { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 4px; }
.pub-links a { border: 1px solid rgba(34,197,94,.5); background: rgba(34,197,94,.1); color: #86efac; padding: 4px 10px; border-radius: 999px; font-size: 12px; }

.foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }

@media (max-width: 1100px) { .layout { grid-template-columns: 260px 1fr; } .panel.right { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 100%); z-index: 30; background: #0f1522; box-shadow: -10px 0 40px rgba(0,0,0,.5); } }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 62vh auto; }
  .panel.left { order: 2; border-right: 0; border-top: 1px solid var(--line); }
  .graph-wrap { order: 1; min-height: 0; }
  .topbar { padding: 10px 16px; }
}

.rec-head { margin-top: 18px; }
.hint-inline { color: var(--muted); font-size: 11px; }
.rec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: rec; }
.rec-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px 10px 38px; cursor: pointer; background: rgba(255,255,255,.02); position: relative; transition: background .15s, border-color .15s; }
.rec-item:hover { background: rgba(244,63,94,.1); border-color: rgba(244,63,94,.5); }
.rec-item::before { counter-increment: rec; content: counter(rec); position: absolute; left: 12px; top: 10px; width: 18px; height: 18px; border-radius: 6px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.rec-item .kw { font-weight: 650; display: block; margin-bottom: 3px; }
.rec-item .why { color: var(--muted); font-size: 12px; line-height: 1.45; }
.rec-item .why b { color: var(--fg); font-weight: 600; }
.rec-item .covered { display: block; margin-top: 4px; font-size: 11px; color: #fde68a; }
.stat-line { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.up { color: #86efac; } .down { color: #fca5a5; }
.kv.four { grid-template-columns: repeat(4, 1fr); }
