:root {
  color-scheme: light;
  --ink: #4c5141;
  --ink-strong: #59654b;
  --muted: #7c8271;
  --bg: #e5e8d6;
  --paper: #f7f3e3;
  --paper-deep: #eee9d8;
  --line: #c8ceb7;
  --line-strong: #aeb99a;
  --accent: #a4b96f;
  --accent-dark: #718650;
  --shadow: rgba(99, 108, 79, .18);
}

* { box-sizing: border-box; }
html { min-width: 320px; height: 100%; overflow: hidden; background: var(--bg); }
body {
  position: relative;
  margin: 0;
  min-width: 320px;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 12% 20%, rgba(159,180,107,.22), transparent 35%),
    radial-gradient(ellipse at 88% 72%, rgba(134,168,161,.18), transparent 30%);
  opacity: .45;
  transform: scale(1.01);
}
html[data-theme="zylatent"] body::before {
  background: url("./assets/courtyard-map-background.webp") center / cover no-repeat;
  filter: saturate(.56) contrast(.84) brightness(1.05) blur(1px);
  opacity: .25;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(100deg, rgba(239,241,224,.56), rgba(255,250,231,.70) 55%, rgba(244,240,225,.60));
}
a { color: var(--accent-dark); }
button, input { font: inherit; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 3px; }
.shell { position: relative; z-index: 1; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 11px; width: min(1320px, calc(100% - 48px)); height: 100dvh; margin: 0 auto; padding: clamp(12px, 2vh, 22px) 0 10px; }
.masthead { display: flex; align-items: end; justify-content: space-between; gap: 32px; padding: 2px 18px 5px; }
.eyebrow { margin: 0 0 10px; color: var(--accent-dark); font-size: 10px; letter-spacing: .18em; font-weight: 700; }
h1 { margin: 0; color: var(--ink-strong); font: 700 clamp(40px, 6.4vh, 66px)/.9 Georgia, "Songti SC", serif; letter-spacing: -.065em; text-shadow: 0 2px 0 rgba(255,255,255,.45); }
.dot { color: var(--accent); }
.intro { max-width: 560px; margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.meta { display: flex; gap: 20px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(199,205,180,.92);
  border-radius: 16px;
  background: rgba(247,243,226,.66);
  box-shadow: 0 10px 32px var(--shadow);
  backdrop-filter: blur(12px);
}
.view-switch { display: inline-flex; flex: 0 0 auto; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.24); }
.view-switch a { padding: 6px 9px; border-radius: 999px; color: var(--muted); font-size: 10px; text-decoration: none; white-space: nowrap; }
.view-switch a:hover { color: var(--ink); }
.view-switch a.active { background: rgba(159,180,107,.24); color: var(--accent-dark); font-weight: 700; }
.search { display: flex; align-items: center; gap: 9px; width: min(330px, 100%); color: var(--muted); }
.search span { font-size: 22px; line-height: 1; transform: translateY(-1px); }
input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
input::placeholder { color: #9ba08f; }
#reset {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  background: rgba(255,255,255,.24);
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: .2s ease;
}
#reset:hover { border-color: var(--accent-dark); color: var(--ink); background: rgba(255,255,255,.52); }
.hint { color: var(--muted); font-size: 11px; white-space: nowrap; }

.map-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 282px;
  min-height: 0;
  height: 100%;
  margin-top: 0;
  overflow: hidden;
  border: 1px solid rgba(199,205,180,.95);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(247,243,226,.88), rgba(224,231,207,.68));
  box-shadow: 0 18px 50px var(--shadow);
}
.map-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .48;
  background: radial-gradient(ellipse at 12% 12%, rgba(150,171,117,.16), transparent 22%), radial-gradient(ellipse at 88% 76%, rgba(205,185,139,.18), transparent 25%), repeating-linear-gradient(90deg, rgba(255,255,255,.12) 0 1px, transparent 1px 7px);
}
.map-stage { position: relative; min-width: 0; min-height: 0; padding: 14px 12px 12px 18px; }
#map { display: block; width: 100%; height: 100%; min-height: 0; cursor: default; overflow: hidden; }
#map.can-pan { cursor: grab; }
#map.can-pan:active { cursor: grabbing; }
.map-surface { fill: rgba(251,248,235,.54); stroke: rgba(174,185,154,.72); stroke-width: .012; }
#grid circle { fill: none; stroke: #87986a; stroke-opacity: .22; stroke-width: .004; }
#grid path { fill: none; stroke: #87986a; stroke-opacity: .13; stroke-width: .0025; stroke-dasharray: .012 .014; }
#grid .center { fill: rgba(164,185,111,.16); stroke: #87986a; stroke-opacity: .3; stroke-width: .004; }
#edges .edge { pointer-events: none; stroke: #77836b; stroke-opacity: .16; stroke-width: .003; transition: stroke-opacity .16s, stroke-width .16s; }
#edges .edge.same-topic { stroke: var(--edge-color); stroke-opacity: .27; }
#edges .edge.dim { stroke-opacity: .035; }
#edges .edge.focus { stroke-opacity: .8; stroke-width: .006; }
.node { cursor: pointer; transition: opacity .18s, r .18s; }
.node-link { outline: none; }
.node.dim { opacity: .14; }
.node circle { stroke: var(--paper); stroke-width: .008; }
.node-link:hover .node circle, .node-link:focus .node circle, .node-fallback:hover .node circle, .node-fallback:focus .node circle { stroke: #566946; stroke-width: .012; filter: url(#glow); }
.node-link:focus, .node-fallback:focus { outline: none; }
.node-label { pointer-events: none; opacity: 0; transition: opacity .16s ease; }
.node-label.hover-label, .node-label.show-label { opacity: 1; }
.node-label text { fill: #3f4738; font-size: .037px; font-weight: 650; paint-order: stroke fill; stroke: rgba(251,248,235,.98); stroke-width: .018px; stroke-linejoin: round; }
.map-note { position: absolute; left: 36px; bottom: 19px; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; pointer-events: none; }
.note-mark { display: inline-block; width: 7px; height: 7px; border: 1px solid var(--accent-dark); border-radius: 50%; background: rgba(164,185,111,.55); }
.status { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); color: var(--muted); font-size: 13px; z-index: 1; }

.topic-panel { position: relative; z-index: 1; display: flex; flex-direction: column; min-width: 0; padding: 24px 24px 20px; border-left: 1px solid rgba(199,205,180,.82); background: rgba(247,243,226,.58); }
.topic-heading h2 { margin: 0; color: var(--ink-strong); font: 700 30px/1 Georgia, "Songti SC", serif; letter-spacing: -.04em; }
.topic-heading p:not(.eyebrow) { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.legend { display: grid; min-width: 0; gap: 6px; margin-top: 20px; }
.legend button { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 8px; width: 100%; min-width: 0; border: 1px solid transparent; border-radius: 12px; padding: 10px 10px; background: transparent; color: var(--muted); text-align: left; font-size: 12px; cursor: pointer; transition: .2s ease; }
.legend button:hover { border-color: var(--line); background: rgba(255,255,255,.3); color: var(--ink); }
.legend button.active { border-color: var(--line-strong); background: rgba(164,185,111,.18); color: var(--ink); }
.legend i { display: block; width: 10px; height: 10px; border: 2px solid rgba(255,255,255,.72); border-radius: 50%; box-shadow: 0 0 0 1px rgba(86,105,70,.1); }
.legend .cluster-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .cluster-count { color: #9ba08f; font-size: 10px; }
.detail { position: absolute; right: 24px; bottom: 42px; z-index: 2; width: min(360px, calc(100% - 48px)); padding: 22px; border: 1px solid var(--line-strong); border-radius: 16px; background: rgba(247,243,226,.94); backdrop-filter: blur(14px); box-shadow: 0 16px 50px var(--shadow); }
.detail h2 { margin: 4px 0 10px; color: var(--ink-strong); font: 700 27px/1.08 Georgia, "Songti SC", serif; }
.detail p:not(.eyebrow) { color: var(--muted); line-height: 1.55; font-size: 13px; }
.close { position: absolute; top: 9px; right: 12px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0; }
.tags span { padding: 5px 8px; border-radius: 999px; background: rgba(164,185,111,.24); color: var(--accent-dark); font-size: 11px; }
footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 0 5px; color: var(--muted); font-size: 11px; }
.source-credit, .blog-link { display: inline-flex; align-items: center; gap: 5px; }
.blog-link img { width: 1.08em; height: 1.08em; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px rgba(89,101,75,.22); }

html[data-embed="true"] .shell { width: 100%; padding: 0; gap: 0; }
html[data-embed="true"] .masthead, html[data-embed="true"] footer { display: none; }
html[data-embed="true"] .toolbar { border-radius: 0; border-left: 0; border-right: 0; margin: 0; }
html[data-embed="true"] .map-card { min-height: 100vh; margin-top: 0; border-radius: 0; border-left: 0; border-right: 0; }

@media (max-width: 860px) {
  .map-card { grid-template-columns: minmax(0, 1fr) 236px; }
  .topic-panel { padding-left: 20px; padding-right: 20px; }
  .map-stage { padding-left: 12px; }
  .map-note { left: 30px; }
}
@media (max-width: 700px) {
  .shell { width: min(100% - 16px, 1280px); padding: 8px 0 6px; gap: 7px; }
  .masthead { display: flex; align-items: center; padding: 0 6px; }
  .masthead .eyebrow, .intro, .meta { display: none; }
  h1 { font-size: 38px; }
  .toolbar { flex-wrap: nowrap; min-height: 44px; padding: 7px 9px; }
  .view-switch a { padding: 5px 7px; font-size: 9px; }
  .search { min-width: 80px; }
  #reset { margin-left: auto; }
  .hint { display: none; }
  .map-card { display: grid; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .map-stage { min-height: 0; padding: 6px 4px 8px; }
  #map { min-height: 0; }
  .map-note { left: 18px; bottom: 13px; font-size: 9px; }
  .topic-panel { display: block; max-height: 152px; border-top: 1px solid rgba(199,205,180,.82); border-left: 0; padding: 10px 13px 9px; }
  .topic-heading { display: flex; align-items: baseline; gap: 9px; }
  .topic-heading .eyebrow, .topic-heading p:not(.eyebrow) { display: none; }
  .topic-heading h2 { font-size: 20px; }
  .legend { grid-template-columns: 1fr 1fr; gap: 3px 6px; margin-top: 7px; }
  .legend button { padding: 5px 6px; font-size: 10px; }
  .legend .cluster-count { font-size: 9px; }
  .detail { right: 14px; bottom: 42px; width: calc(100% - 28px); }
  footer { font-size: 9px; }
}
