/* ================= 诗词地图 · 水墨风样式 ================= */
:root {
  --paper: #f4edd9;
  --paper2: #ece1c4;
  --card: rgba(248, 243, 228, 0.96);
  --ink: #35312a;
  --ink2: #7a705d;
  --line: #d9cca9;
  --red: #a63b2a;
  --red2: #c0492f;
  --gold: #97742a;
  --shadow: 0 4px 24px rgba(60, 48, 20, 0.18);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  color: var(--ink);
  background: var(--paper);
  overflow: hidden;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr);
  grid-template-columns: 330px minmax(0, 1fr);
  grid-template-areas: "top top" "side map";
}
#map, #sidebar { min-height: 0; min-width: 0; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9bb95; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 顶栏 ---------- */
#topbar {
  grid-area: top; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: linear-gradient(180deg, #f7f1de, #efe4c6);
  border-bottom: 1px solid var(--line); z-index: 1200;
}
.brand { display: flex; align-items: center; gap: 10px; }
.seal {
  width: 38px; height: 38px; background: var(--red); color: #f7ecd7;
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
  border-radius: 6px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); font-family: "KaiTi","STKaiti",serif;
}
.brand-t h1 { font-size: 19px; letter-spacing: 6px; font-family: "KaiTi","STKaiti",serif; }
.brand-t .sub { font-size: 11px; color: var(--ink2); letter-spacing: 1px; }
.stats { font-size: 12px; color: var(--ink2); letter-spacing: 1px; }
.stats b { color: var(--red); font-size: 15px; margin: 0 1px; }
.tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff8; }
.seg button { border: 0; background: transparent; padding: 5px 12px; font-size: 12px; color: var(--ink2); }
.seg button.on { background: var(--red); color: #f7ecd7; }
.btn { border: 1px solid var(--line); background: #fff8; border-radius: 6px; padding: 5px 12px; font-size: 12px; color: var(--ink); }
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; }

/* ---------- 侧栏 ---------- */
#sidebar {
  grid-area: side; display: flex; flex-direction: column;
  background: var(--paper); border-right: 1px solid var(--line); z-index: 1100;
}
.search-row { padding: 10px 12px 6px; }
#search {
  width: 100%; padding: 8px 12px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 8px; background: #fffdf4; color: var(--ink); outline: none;
}
#search:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(151,116,42,.12); }
.chips { display: flex; gap: 6px; padding: 4px 12px 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: transparent; border-radius: 20px;
  font-size: 12px; padding: 3px 12px; color: var(--ink2);
}
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.poet-row { display: flex; gap: 6px; padding: 0 12px 8px; align-items: center; }
#poetSel {
  flex: 1; padding: 6px 8px; font-family: inherit; font-size: 12px;
  border: 1px solid var(--line); border-radius: 6px; background: #fffdf4; color: var(--ink);
}
.list-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 12px 6px; font-size: 11px; color: var(--ink2); border-bottom: 1px dashed var(--line);
}
.deb-toggle { display: flex; gap: 4px; align-items: center; cursor: pointer; }
#poemList { flex: 1; overflow-y: auto; list-style: none; padding: 6px 8px 12px; }
#poemList li {
  padding: 8px 10px; border-radius: 8px; cursor: pointer; margin-bottom: 2px;
  border: 1px solid transparent; transition: background .15s;
}
#poemList li:hover { background: #fff8e6; }
#poemList li.on { background: #fff; border-color: var(--gold); box-shadow: 0 2px 8px rgba(120,90,20,.08); }
#poemList .t { font-size: 14px; }
#poemList .t b { font-weight: 600; }
#poemList .m { font-size: 11px; color: var(--ink2); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
#poemList .m .pn { color: var(--red2); }
#poemList .flag { font-size: 10px; color: #8a6d1f; background: #f3e6bd; border-radius: 3px; padding: 0 4px; }
#poemList .nores { text-align: center; color: var(--ink2); font-size: 12px; padding: 30px 0; }
.side-foot { padding: 8px 12px; font-size: 10px; color: #a4977c; border-top: 1px dashed var(--line); line-height: 1.6; }

/* ---------- 地图 ---------- */
#map { grid-area: map; position: relative; background: var(--paper2); }
#map.ink { background: linear-gradient(160deg, #f6efdb 0%, #efe5c8 55%, #e9dcba 100%); }
.leaflet-container { font: inherit; background: transparent; }
.leaflet-control-zoom a { background: var(--card) !important; color: var(--ink) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { font-size: 9px !important; background: rgba(248,243,228,.7) !important; }

/* 水墨图层 */
.grat-line { stroke: #b9a87e; stroke-width: .6; stroke-dasharray: 2 7; fill: none; }
.river { stroke: #8ba7b0; stroke-width: 2.2; fill: none; opacity: .75; stroke-linecap: round; }
.river-label { color: #6f93a0; font-size: 11px; letter-spacing: 4px; white-space: nowrap; text-shadow: 0 0 4px #f4edd9; }
.region-label { color: #a8946a; font-size: 13px; letter-spacing: 6px; white-space: nowrap; opacity: .8; font-family: "KaiTi","STKaiti",serif; }

/* 诗词点位 */
.pm { position: relative; transform: translate(-50%, -50%); text-align: center; }
.pm .dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--red2); border: 2px solid #fdf7e6; box-shadow: 0 1px 4px rgba(90,30,10,.45);
  transition: transform .15s;
}
.pm:hover .dot { transform: scale(1.35); }
.pm .lbl {
  display: block; margin-top: 3px; font-size: 11px; color: #4c4433; white-space: nowrap;
  text-shadow: 0 0 3px #f4edd9, 0 0 3px #f4edd9, 0 0 3px #f4edd9; letter-spacing: 1px;
}
.pm .cnt {
  position: absolute; top: -7px; right: -10px; min-width: 15px; height: 15px; border-radius: 8px;
  background: var(--gold); color: #fdf7e6; font-size: 10px; line-height: 15px; padding: 0 3px;
  box-shadow: 0 1px 3px rgba(80,60,10,.4);
}
.pm.deb .dot { background: #b98a1f; border-color: #fff3cf; }
.pm.deb .lbl { color: #8a6a12; }
.pm.sel .dot { background: var(--red); animation: pulse 1.6s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(166,59,42,.55); }
  70% { box-shadow: 0 0 0 14px rgba(166,59,42,0); }
  100% { box-shadow: 0 0 0 0 rgba(166,59,42,0); }
}
#map.zoom-low .pm .lbl { display: none; }
#map.zoom-low .pm.hot .lbl { display: block; }

/* 路线 */
.route-line { stroke: var(--red2) !important; stroke-width: 2.5 !important; stroke-dasharray: 7 9 !important; animation: dashmove 1.4s linear infinite; opacity: .85; }
@keyframes dashmove { to { stroke-dashoffset: -32; } }
.stop-mk { transform: translate(-50%, -50%); }
.stop-mk .n {
  width: 19px; height: 19px; border-radius: 50%; background: var(--ink); color: var(--paper);
  font-size: 11px; display: grid; place-items: center; border: 2px solid #f4edd9; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.stop-mk .y { font-size: 9px; color: #6d6248; margin-top: 1px; text-shadow: 0 0 3px #f4edd9, 0 0 3px #f4edd9; white-space: nowrap; }
.stop-pop { font-size: 12px; line-height: 1.6; max-width: 220px; }
.stop-pop b { color: var(--red); }
.stop-pop .yy { color: var(--gold); font-size: 11px; }

/* ---------- 通用面板 ---------- */
.panel {
  position: absolute; z-index: 1300; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); backdrop-filter: blur(4px);
  animation: slidein .22s ease-out;
}
@keyframes slidein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.panel .close {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border: 0; background: transparent;
  color: var(--ink2); font-size: 13px; border-radius: 6px; z-index: 2;
}
.panel .close:hover { background: #eee2c2; color: var(--red); }
.hidden { display: none !important; }

/* 诗词详情 */
#detail { right: 14px; top: 14px; bottom: 14px; width: 402px; overflow: hidden; display: flex; flex-direction: column; }
#detailBody { overflow-y: auto; padding: 18px 20px 22px; }
.d-form { font-size: 11px; color: var(--gold); letter-spacing: 2px; margin-bottom: 4px; }
.d-title { font-size: 21px; font-weight: 700; letter-spacing: 2px; font-family: "KaiTi","STKaiti",serif; line-height: 1.35; }
.d-author { font-size: 12px; color: var(--ink2); margin: 6px 0 2px; }
.d-author b { color: var(--red); font-size: 14px; }
.d-context { font-size: 12px; color: #8a7c5e; background: #f3ead2; border-left: 3px solid var(--gold); padding: 7px 10px; border-radius: 0 6px 6px 0; margin: 10px 0 4px; line-height: 1.7; }
.d-text { margin: 12px 0 6px; line-height: 2.1; font-size: 15.5px; font-family: "KaiTi","STKaiti","Noto Serif SC",serif; }
.d-text .ln { display: block; }
.d-text .pl {
  color: var(--red2); font-weight: 600; cursor: pointer; border-bottom: 1px dotted var(--red2);
  text-decoration: none; padding: 0 1px;
}
.d-text .pl:hover { background: #f7dfc9; }
.d-text .pl.pin { color: var(--gold); border-bottom: 1px dotted var(--gold); }
.d-sec { font-size: 12px; color: var(--ink2); letter-spacing: 2px; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.d-sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.d-places { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip {
  font-size: 11px; border: 1px solid #d8b7a8; background: #faf0e4; color: #7c3a28;
  border-radius: 6px; padding: 3px 8px; cursor: pointer; line-height: 1.5;
}
.pchip:hover { background: var(--red2); color: #fff; }
.pchip .fg { font-size: 9px; background: #e3c675; color: #6b4d0a; border-radius: 3px; padding: 0 3px; margin-left: 3px; }
.d-notes { font-size: 12.5px; color: #5c5340; line-height: 1.9; }
.d-notes li { list-style: none; padding-left: 14px; position: relative; margin-bottom: 3px; }
.d-notes li::before { content: "◦"; position: absolute; left: 0; color: var(--gold); }
.d-route-btn {
  width: 100%; margin-top: 6px; padding: 9px; border: 1px solid var(--red2); background: #fdf3e3;
  color: var(--red2); border-radius: 8px; font-size: 13px; letter-spacing: 1px;
}
.d-route-btn:hover { background: var(--red2); color: #fff; }
.d-route-btn:disabled { border-color: var(--line); color: #b0a486; background: transparent; cursor: not-allowed; }
.d-fix { font-size: 11px; color: #8a6d1f; background: #f7ecc8; border-radius: 6px; padding: 5px 9px; margin-top: 6px; line-height: 1.6; }

/* 多诗同点位列表 */
.place-poems .pp {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; background: #fffdf2;
}
.place-poems .pp:hover { border-color: var(--gold); }
.place-poems .pp b { font-size: 14px; }
.place-poems .pp span { display: block; font-size: 11px; color: var(--ink2); margin-top: 2px; }

/* 路线卡 */
#routeCard { left: 344px; bottom: 14px; width: 330px; max-height: 46vh; display: flex; flex-direction: column; }
#routeBody { overflow-y: auto; padding: 14px 16px 16px; }
.r-name { font-size: 16px; font-family: "KaiTi","STKaiti",serif; }
.r-name b { color: var(--red); }
.r-desc { font-size: 11px; color: var(--ink2); margin: 4px 0 8px; line-height: 1.6; }
.stop-item { display: flex; gap: 9px; padding: 6px 4px; cursor: pointer; border-radius: 6px; }
.stop-item:hover { background: #f6ecd2; }
.stop-item .no {
  flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--ink); color: var(--paper);
  font-size: 11px; display: grid; place-items: center; margin-top: 2px;
}
.stop-item .tx b { font-size: 13px; }
.stop-item .tx .yy { color: var(--gold); font-size: 11px; margin-left: 5px; }
.stop-item .tx p { font-size: 11px; color: var(--ink2); line-height: 1.55; margin-top: 1px; }

/* ---------- 核查台 ---------- */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(40,32,16,.45); display: grid; place-items: center; }
.modal-box { width: min(880px, 92vw); height: min(640px, 88vh); background: var(--paper); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; border: 1px solid var(--line); }
.modal-box header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-box h2 { font-size: 16px; letter-spacing: 2px; font-family: "KaiTi","STKaiti",serif; }
#auditStats { font-size: 11px; color: var(--ink2); }
.modal-box header .close { margin-left: auto; }
.modal-body { overflow-y: auto; padding: 14px 18px 20px; }
.a-sec { margin-bottom: 16px; }
.a-sec h3 { font-size: 13px; color: var(--red); letter-spacing: 1px; margin-bottom: 6px; }
.a-sec h3 small { color: var(--ink2); font-weight: 400; margin-left: 6px; }
.a-row { font-size: 12px; line-height: 1.7; padding: 4px 8px; border-left: 3px solid var(--line); background: #faf5e4; margin-bottom: 4px; border-radius: 0 6px 6px 0; }
.a-row .lnk { color: var(--red2); cursor: pointer; text-decoration: underline dotted; }
.a-row .why { color: #6e6248; }
.a-row.fix { border-left-color: var(--gold); }
.a-row.warn { border-left-color: #c07f2a; }
.a-row.err { border-left-color: var(--red); background: #f9e4dc; }
.a-tip { font-size: 12px; color: var(--ink2); line-height: 1.8; background: #f3ead2; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }

/* 暗色底图时的浮层保持纸色即可（面板自带背景），地图标记加强投影 */
#map.darkmode .pm .lbl { color: #f2e8cd; text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 4px rgba(0,0,0,.7); }
#map.darkmode .pm.deb .lbl { color: #e8c96a; }
#map.darkmode .stop-mk .y { color: #e2d6b4; text-shadow: 0 1px 3px rgba(0,0,0,.9); }
