:root {
  --paper: #efeae2;
  --paper-2: #f7f3ec;
  --ink: #1c1914;
  --ink-soft: #5c564c;
  --line: #d8d0c4;
  --teal: #0f5c4c;
  --teal-2: #1a7a66;
  --teal-on: #f4fff9;
  --warn: #9a3412;
  --danger: #9f1239;
  --graph: #12161c;
  --strong: #5ee0c0;
  --mid: #7aa7c7;
  --weak: #64748b;
  --radius: 10px;
  --font: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --shadow: 0 10px 30px rgba(28, 25, 20, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100dvh; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 650; }
.muted { color: var(--ink-soft); margin: 0; }
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-2);
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-btn:focus-visible,
.role-card:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.btn.primary {
  background: var(--teal);
  color: var(--teal-on);
  border-color: var(--teal);
}
.btn.primary:hover { background: var(--teal-2); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--danger); border-color: #e8b4c0; }

.login-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px 40px;
  background:
    radial-gradient(900px 420px at 10% -10%, #dce8e2, transparent 60%),
    var(--paper);
}
.login-panel {
  width: min(440px, 100%);
}
.brand-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal);
}
.login-panel h1 { font-size: 42px; margin: 0 0 22px; }
.login-form { display: grid; gap: 12px; }
.linkish {
  border: 0;
  background: none;
  color: var(--teal);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}
.login-form label, .import-form label, .search-label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}
input, select, textarea {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
textarea { min-height: 160px; resize: vertical; }
.form-error { color: var(--danger); margin: 0; font-size: 13px; }
.login-hint { margin: 22px 0 10px; font-size: 13px; color: var(--ink-soft); }
.role-cards { display: grid; gap: 8px; }
.role-card {
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-2);
  min-height: 64px;
}
.role-card:hover { border-color: var(--teal); }
.role-tag {
  grid-row: 1 / 3;
  align-self: center;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #dce8e2;
  color: var(--teal);
}
.role-card strong { font-size: 15px; }
.role-card span { font-size: 12px; color: var(--ink-soft); }

.app-view {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.rail {
  background: #e7e1d6;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 16px;
  gap: 18px;
}
.rail-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 0;
  background: transparent;
  padding: 4px;
  margin: -4px;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
  width: 100%;
}
.rail-brand:hover { background: rgba(255,255,255,0.35); }
.park-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  background: #fff;
}
.park-avatar.sm { width: 28px; height: 28px; border-radius: 8px; }
.park-avatar.lg { width: 72px; height: 72px; border-radius: 16px; }
.park-preview-row { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--teal);
  color: var(--teal-on);
  display: grid;
  place-items: center;
  font-weight: 700;
}
.rail-brand small, .rail-user small {
  display: block;
  color: var(--ink-soft);
  font-size: 12px;
}
.rail-nav { display: grid; gap: 6px; }
.nav-btn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  padding: 0 12px;
  position: relative;
}
.nav-btn.is-on { background: var(--paper-2); font-weight: 650; }
.badge {
  margin-left: 8px;
  background: var(--warn);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  padding: 1px 6px;
}
.rail-user {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 8px;
}
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
}
.topbar {
  padding: 16px 20px 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}
.topbar h2 { font-size: 22px; }
.topbar-left { display: flex; gap: 10px; align-items: start; min-width: 0; }
.top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.me-chip {
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 10px;
  padding: 6px 12px;
  text-align: right;
  cursor: pointer;
  min-height: 44px;
}
.me-chip strong { display: block; font-size: 14px; }
.me-chip small { display: block; color: var(--ink-soft); font-size: 12px; }
.park-chip {
  display: none;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  border-radius: 10px;
  padding: 6px 10px;
  min-height: 44px;
}

.page { display: none; padding: 8px 20px 24px; flex: 1; min-height: 0; }
.page.is-on { display: flex; flex-direction: column; }
#page-graph.is-on { display: grid; grid-template-columns: 1fr 280px; gap: 12px; min-height: 0; }

.graph-shell {
  position: relative;
  background: var(--graph);
  border-radius: 14px;
  min-height: 62vh;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#graph { width: 100%; height: 100%; min-height: 62vh; display: block; }
.graph-toolbar {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: #d7ddd8;
  font-size: 12px;
}
.chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(18, 22, 28, 0.72);
  color: #e8eeea;
}
.chip.is-on { border-color: var(--strong); color: var(--strong); }
.legend { display: inline-flex; gap: 8px; align-items: center; margin-left: 6px; }
.lg { width: 18px; height: 3px; display: inline-block; border-radius: 2px; }
.lg.strong { background: var(--strong); height: 4px; }
.lg.mid { background: var(--mid); }
.lg.weak { background: var(--weak); opacity: 0.5; }
.graph-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  color: #9aa3ad;
  font-size: 12px;
}

.side-list, .meet-detail, .import-help, .review-card, .drawer {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.side-list { padding: 12px; overflow: auto; max-height: calc(100dvh - 120px); }
.plain-list { list-style: none; margin: 8px 0 0; padding: 0; }
.plain-list li { padding: 0; }
.person-row {
  display: grid;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 10px 8px;
  border: 0;
  border-radius: 8px;
  min-height: 44px;
  background: transparent;
  cursor: pointer;
}
.person-row:hover { background: #efe8dc; }
.person-row.is-on { background: #dce8e2; }
.plain-list small { color: var(--ink-soft); }

.meet-layout { display: grid; grid-template-columns: 280px 1fr; gap: 12px; min-height: 60vh; }
.meet-list { margin: 0; }
.meet-detail { padding: 16px; }
.kv { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0 16px; font-size: 13px; color: var(--ink-soft); }
.star { width: 100%; height: 280px; background: var(--graph); border-radius: 12px; }
.brief { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.brief div {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.brief strong { display: block; font-size: 20px; }
.attendee-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.attendee-chips button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 10px;
}

.review-cards { display: grid; gap: 12px; }
.review-card { padding: 16px; display: grid; gap: 12px; }
.review-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pane {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.pane h4 { margin: 0 0 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.reason { color: var(--warn); font-size: 13px; margin: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cand {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  min-height: 44px;
}
.cand.is-on { border-color: var(--teal); background: #dce8e2; }

.import-grid { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.import-form, .import-help { padding: 16px; display: grid; gap: 12px; }
.file-pick input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--paper-2);
}
.import-help { align-content: start; }
.import-help ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(400px, 100%);
  height: 100dvh;
  z-index: 20;
  padding: 18px 18px 24px;
  overflow: auto;
  box-shadow: -16px 0 40px rgba(28,25,20,0.12);
}
.drawer-close {
  position: absolute;
  right: 12px;
  top: 12px;
  min-height: 44px;
  min-width: 44px;
  border: 0;
  background: transparent;
}
.drawer h3 { padding-right: 48px; }
.evidence { margin: 14px 0; }
.evidence h4 { font-size: 13px; color: var(--ink-soft); margin: 0 0 8px; }
.evidence article, .rel-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #fff;
  display: block;
  width: 100%;
  text-align: left;
}
.rel-row p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13px; }
.search-form { display: grid; gap: 12px; margin-top: 10px; }
.pub-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 6px;
}
.pub-card strong { font-size: 15px; }
.pub-card a { color: var(--teal); }
.clue-card-actions { margin-top: 8px; }
.clues-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
.clues-toolbar label {
  display: grid;
  gap: 4px;
  font-size: 13px;
  color: var(--ink-soft);
}
.clues-toolbar select { min-height: 44px; min-width: 140px; }
#scan-schedule-hint { align-self: center; }
.clue-group { margin: 16px 0 8px; }
.clue-group h3, .clue-group summary {
  font-size: 16px;
  font-weight: 650;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.clue-group summary { cursor: pointer; }
.meet-rename {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin: 10px 0 14px;
}
.meet-rename label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); flex: 1; min-width: 200px; }
.meet-rename input { min-height: 44px; width: 100%; }
.add-person { position: relative; margin: 12px 0; }
.add-person label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.suggest {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 240px;
  overflow: auto;
  z-index: 5;
  position: absolute;
  left: 0;
  right: 0;
}
#btn-meet-delete { margin-top: 16px; }
.clue-group > .muted { margin: 0 0 10px; }
.advice { font-size: 13px; color: var(--ink-soft); margin: 0; }
.check-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  min-height: 36px;
}
.check-line input { margin-top: 4px; flex: none; }
.mention-list { display: grid; gap: 4px; padding: 6px 0; }
#search-box { margin: 12px 0; }
#btn-public-search { margin: 8px 0 4px; }
.bar {
  height: 8px;
  background: #e7e1d6;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 16px;
}
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--teal);
}
.dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(28, 25, 20, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
}
.dialog-card {
  width: min(400px, 100%);
  background: var(--paper-2);
  border-radius: 12px;
  padding: 20px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow);
}
.dialog-card label { display: grid; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.phone-lock { font-size: 12px; color: var(--ink-soft); }
.tier-pill {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dce8e2;
  color: var(--teal);
}

.tabbar {
  display: none;
}

.node-label { font-size: 11px; fill: #d5ddd8; font-family: var(--font); }
.node-sub { font-size: 10px; fill: #8b9590; }

@media (max-width: 900px) {
  .app-view {
    grid-template-columns: 1fr;
    padding-bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  }
  .rail { display: none; }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #e7e1d6;
    border-top: 1px solid var(--line);
    z-index: 15;
    padding: 4px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .tabbar .nav-btn {
    text-align: center;
    padding: 8px 4px;
    font-size: 13px;
    min-height: 48px;
    line-height: 1.2;
  }
  #page-graph.is-on, .meet-layout, .import-grid, .review-split, .row2 {
    grid-template-columns: 1fr;
  }
  .graph-shell, #graph { min-height: 48vh; }
  .side-list { max-height: 38vh; }
  .drawer {
    top: auto;
    bottom: 0;
    height: min(72dvh, 640px);
    width: 100%;
    border-radius: 16px 16px 0 0;
  }
  .brief { grid-template-columns: 1fr; }
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px 8px;
  }
  .topbar-left {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .topbar-left > div { flex: 1 1 180px; min-width: 0; }
  .topbar h2 { font-size: 18px; line-height: 1.3; }
  #page-sub { font-size: 12px; line-height: 1.45; margin-top: 4px; }
  .top-actions { width: 100%; justify-content: space-between; }
  .me-chip { flex: 1; text-align: left; min-width: 0; }
  .park-chip { display: inline-flex; max-width: 100%; }
  .page { padding: 8px 14px 20px; }
  .graph-toolbar {
    max-width: calc(100% - 16px);
    right: 8px;
  }
  .graph-hint {
    max-width: calc(100% - 24px);
    line-height: 1.4;
  }
  .login-panel h1 { font-size: 32px; }
  .login-view { padding: 20px 16px 32px; }
  .clues-toolbar { flex-direction: column; align-items: stretch; }
  .clues-toolbar select { min-width: 0; width: 100%; }
  .btn-row .btn { flex: 1 1 140px; }
  .dialog-card { width: min(400px, calc(100% - 24px)); padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
