:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --paper: #fffefb;
  --ink: #1f2521;
  --ink-soft: #4c534e;
  --muted: #6e746d;
  --green: #19644c;
  --green-deep: #124b39;
  --green-soft: rgba(25, 100, 76, 0.1);
  --amber: #b8873c;
  --line: rgba(34, 48, 40, 0.11);
  --line-strong: rgba(34, 48, 40, 0.2);
  --shadow-sm: 0 6px 22px rgba(32, 46, 38, 0.055);
  --shadow: 0 18px 46px rgba(32, 46, 38, 0.085);
  --shadow-hover: 0 22px 54px rgba(32, 46, 38, 0.13);
  --serif: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(25, 100, 76, 0.07), transparent 42%),
    radial-gradient(circle at 88% 8%, rgba(184, 135, 60, 0.07), transparent 36%),
    var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, a { transition: all 0.2s ease; }

/* ===== 顶栏 ===== */
.site-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 15px clamp(20px, 5vw, 72px);
  background: rgba(248, 246, 240, 0.88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(32, 46, 38, 0.035);
}

.brand {
  display: flex;
  flex-direction: column;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--serif);
  font-weight: 800;
  font-size: 21px;
  letter-spacing: 0.04em;
}
.brand small { font: 700 9.5px system-ui; letter-spacing: 0.24em; color: var(--green); }

nav {
  display: flex;
  gap: 6px;
  margin-right: auto;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--line);
}
nav a {
  padding: 8px 15px;
  border-radius: 999px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
}
nav a:hover { color: var(--green); background: rgba(25, 100, 76, 0.06); }
nav a.active {
  background: linear-gradient(135deg, var(--green), #247c60);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(25, 100, 76, 0.22);
}

main { width: min(1140px, calc(100% - 40px)); margin: auto; min-height: calc(100vh - 150px); }
.view { display: none; padding: 42px 0 72px; }
.view.active { display: block; animation: fadeIn 0.24s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hero { padding: 48px 0 40px; max-width: 780px; }
.eyebrow {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}
.hero h1, .page-title h1 {
  font: 700 clamp(38px, 6vw, 68px)/1.1 var(--serif);
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.hero > p:last-child, .page-title > p:last-child {
  max-width: 640px;
  color: var(--muted);
  font-size: 16.5px;
  line-height: 1.8;
  margin-top: 14px;
}
.page-title { padding: 20px 0 32px; }
.page-title h1 { font-size: clamp(32px, 4.5vw, 52px); }

/* ===== 按钮 ===== */
.button {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--green) 0%, #247c60 100%);
  color: #ffffff;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(25, 100, 76, 0.22);
}
.button:hover { transform: translateY(-1px); filter: brightness(1.04); box-shadow: 0 12px 26px rgba(25, 100, 76, 0.28); }
.button.secondary { background: #e5efe9; color: var(--green); box-shadow: none; border: 1px solid rgba(25, 100, 76, 0.14); }
.button.secondary:hover { background: #d8e9df; }
.button.small { padding: 9px 17px; font-size: 13.5px; }

/* ===== 统计卡 & 快捷操作 ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat {
  padding: 24px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: rgba(25, 100, 76, 0.25); }
.stat b { display: block; font: 800 38px Georgia, serif; color: var(--green); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { display: block; margin-top: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }

.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.action {
  min-height: 172px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
}
.action:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); border-color: rgba(25, 100, 76, 0.3); }
.action.primary { background: linear-gradient(145deg, #1b6d53 0%, #124d3b 100%); color: #ffffff; border-color: transparent; }
.action.dark { background: linear-gradient(145deg, #27332d 0%, #1b2420 100%); color: #ffffff; border-color: transparent; }
.action b, .action span, .action small { display: block; }
.action b { font: 600 32px var(--serif); margin-bottom: 22px; }
.action span { font-size: 16px; font-weight: 800; }
.action small { margin-top: 8px; color: inherit; opacity: 0.78; font-size: 12.5px; line-height: 1.5; }

.section-title { display: flex; justify-content: space-between; align-items: flex-end; margin: 44px 0 14px; }
.section-title h2 { margin: 0; font-family: var(--serif); font-size: 22px; }
.section-title span, .muted { color: var(--muted); font-size: 13.5px; }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.recent-row, .person-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 4px;
  border-bottom: 1px solid rgba(34, 48, 40, 0.08);
}
.recent-row:last-child, .person-row:last-child { border: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.grow { flex: 1; }
.score { font: 800 26px Georgia, serif; font-variant-numeric: tabular-nums; }
.privacy { margin-top: 20px; background: linear-gradient(135deg, #fbfaf5 0%, #edf4ef 100%); }
.privacy p { margin: 6px 0 0; color: var(--muted); }

.toolbar { display: flex; gap: 12px; margin-bottom: 20px; }
.toolbar input { flex: 1; }
.people-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.person-row {
  padding: 20px 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.person-row:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: rgba(25, 100, 76, 0.28); }
.avatar {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e2efe8, #d1e6da);
  color: var(--green-deep);
  font-weight: 800;
  font-size: 16px;
}
.tag {
  display: inline-block;
  margin: 5px 6px 0 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eff2ee;
  border: 1px solid rgba(34, 48, 40, 0.08);
  font-size: 11.5px;
  color: #555c57;
}

/* ===== 关系星图 ===== */
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.legend i { width: 24px; height: 4px; border-radius: 4px; }
.graph-card {
  overflow: auto;
  min-height: 520px;
  background:
    radial-gradient(circle at 50% 45%, #fffefb 0%, #f1ede4 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
#graph-svg { display: block; width: 100%; height: 520px; }
.edge { stroke-width: 3; opacity: 0.85; }
.node circle { fill: var(--paper); stroke: var(--green); stroke-width: 3; filter: drop-shadow(0 6px 12px rgba(25, 100, 76, 0.16)); }
.node.self circle { fill: var(--green); stroke: #b7d7c8; stroke-width: 4; }
.node text { font-size: 12.5px; font-weight: 700; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.node.self text { fill: #ffffff; }
.node { cursor: pointer; }
.graph-card + .card { margin-top: 16px; }

.guest-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.guest {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff;
  cursor: pointer;
}
.guest:hover { border-color: var(--line-strong); }
.guest.selected { border-color: var(--green); background: #e8f3ec; box-shadow: 0 4px 12px rgba(25, 100, 76, 0.1); }

.result { margin-top: 18px; padding: 26px; border-radius: 24px; border: 1px solid rgba(0, 0, 0, 0.06); }
.result.risk { background: #fdeae5; }
.result.watch { background: #fef4d9; }
.result.clear { background: #e4f4ea; }
.pair { padding: 13px 0; border-top: 1px solid rgba(0, 0, 0, 0.08); }

.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
.form-grid label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.form-grid input, .form-grid select, .form-grid textarea, .toolbar input, #import-text, #import-file {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: #faf8f3;
  padding: 12px 14px;
  color: var(--ink);
  outline: none;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus, .toolbar input:focus, #import-text:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--green-soft);
}
.check { display: flex !important; align-items: center; grid-template-columns: auto 1fr !important; }
.check input { width: auto; }
.notice { padding: 15px 16px; border-radius: 14px; background: #fef3d8; border: 1px solid rgba(184, 135, 60, 0.28); color: #74551d; line-height: 1.65; }

.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.report-score {
  display: grid;
  place-items: center;
  min-height: 200px;
  background: linear-gradient(145deg, #1b6d53 0%, #114a38 100%);
  color: #ffffff;
  border-radius: 24px;
  box-shadow: 0 14px 32px rgba(17, 74, 56, 0.24);
}
.report-score b { font: 800 66px Georgia, serif; font-variant-numeric: tabular-nums; }
.dimension { margin: 16px 0; }
.bar { height: 8px; background: #e8e4dc; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), #339c79); }

dialog {
  width: min(760px, calc(100% - 24px));
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 0;
  background: var(--paper);
  box-shadow: 0 32px 100px rgba(20, 30, 24, 0.28);
}
dialog::backdrop { background: rgba(24, 30, 26, 0.54); backdrop-filter: blur(5px); }
dialog form { padding: 28px; }
.dialog-head, .dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-head h2 { margin: 0; font-family: var(--serif); }
.dialog-actions { justify-content: flex-end; margin-top: 22px; }
.icon-button { border: 0; background: transparent; font-size: 30px; cursor: pointer; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
#import-text { display: block; margin: 14px 0; resize: vertical; }

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  transform: translateY(120px);
  opacity: 0;
  background: rgba(27, 42, 36, 0.94);
  color: #ffffff;
  padding: 13px 22px;
  border-radius: 999px;
  box-shadow: 0 14px 32px rgba(18, 30, 24, 0.25);
  transition: 0.25s ease;
}
#toast.show { transform: none; opacity: 1; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 24px clamp(20px, 5vw, 72px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

@media (max-width: 760px) {
  .site-head { gap: 12px; padding: 12px 16px; }
  .site-head nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    justify-content: space-around;
    border-radius: 0;
    background: rgba(255, 254, 251, 0.95);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 8px;
  }
  .site-head nav a { font-size: 12px; padding: 8px 10px; }
  .site-head > .button { margin-left: auto; }
  .view { padding: 28px 0 88px; }
  .hero { padding: 28px 0; }
  .stats, .action-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .people-list { grid-template-columns: 1fr; }
  .guest-list { grid-template-columns: 1fr 1fr; }
  .form-grid.two, .report-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { flex-basis: 100%; }
  footer { padding-bottom: 84px; flex-direction: column; }
  .graph-card { min-height: 430px; }
  #graph-svg { height: 430px; }
}
