:root{--ink:#273d34;--muted:#83907d;--border:#e1e7db;--green:#315943;--surface:#fdfdf9;--sans:"PingFang SC","Microsoft YaHei",sans-serif}
*{box-sizing:border-box}html,body{margin:0;width:100%;height:100%;overflow:hidden}body{font:13px var(--sans);color:var(--ink);background:var(--surface)}button,input,select{font:inherit;color:inherit}button{border:0;background:none;cursor:pointer;-webkit-tap-highlight-color:transparent}input,select{-webkit-tap-highlight-color:transparent}button:focus-visible,select:focus-visible,input:focus-visible{outline:2px solid #739f89;outline-offset:2px}svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}[hidden]{display:none!important}.sprite{position:absolute;width:0;height:0;overflow:hidden}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.app-shell{display:grid;grid-template-columns:190px minmax(0,1fr);height:100%;height:100dvh}.sidebar{background:#f2f4ed;border-right:1px solid var(--border);padding:20px 14px;overflow-y:auto}.nav-label{font-size:12px;color:#809073;margin:0 8px 18px}.book-nav-item{display:flex;align-items:center;gap:9px;width:100%;padding:13px 12px;margin-bottom:7px;border:1px solid transparent;border-radius:6px;text-align:left;line-height:1.5}.book-nav-item svg{width:17px;height:17px;flex-shrink:0}.book-nav-item.selected{background:#e5eddf;border-color:#d7e1ce;color:#42683b}.book-nav-item:not(.selected):hover{background:#eaf0e4}.main,.workspace,.explorer{min-width:0;min-height:0;height:100%}.explorer{display:flex;flex-direction:column;background:var(--surface)}.toolbar{padding:12px 18px;border-bottom:1px solid #edf0e5;flex-shrink:0}.search-box{position:relative;display:flex;align-items:center;gap:8px;background:#f6f8f1;border:1px solid #e3e8dc;border-radius:6px;height:37px;padding:0 11px;max-width:460px}.search-box>svg{width:16px;height:16px;color:#8e9d81;flex-shrink:0}.search-box input{width:100%;min-width:0;border:0;background:none;outline:0;font-size:12px}.search-box input::placeholder{color:#98a58c}.search-box kbd{font:10px var(--sans);border:1px solid #dfe5d6;border-radius:3px;padding:0 5px;color:#98a58c}.search-results{position:absolute;z-index:20;top:43px;left:-1px;right:-1px;background:var(--surface);border:1px solid var(--border);border-radius:6px;max-height:270px;overflow:auto;box-shadow:0 6px 20px #263d341a}.search-result{display:flex;align-items:center;gap:8px;width:100%;padding:12px;text-align:left}.search-result:hover,.search-result:focus{background:#edf3e6}.search-result small{margin-left:auto;color:var(--muted)}.search-noresult{padding:16px;color:var(--muted)}
.filterbar{display:flex;align-items:center;gap:12px;padding:9px 18px;border-bottom:1px solid #edf0e5;flex-shrink:0;min-height:45px}.select-wrap{display:flex;align-items:center;gap:6px}.select-wrap label{font-size:11px;color:#909f82}.select-wrap select{border:0;background:transparent;max-width:110px;padding:4px 1px;font-size:11px;cursor:pointer}.filter-separator{height:13px;width:1px;background:#e1e6d9;margin:0 2px}.scope-button{font-size:11px;color:#829275;white-space:nowrap;padding:6px 9px;border-radius:5px}.scope-button.active{background:#eaf1e4;color:#446638}
.graph-area{position:relative;flex:1;min-height:0;overflow:hidden;background-color:#fdfdf9;}.graph-context{position:absolute;top:17px;left:20px;z-index:3;display:flex;align-items:center;gap:7px;font-size:11px;color:#65745e;pointer-events:none}.graph-context select{pointer-events:auto;background:#fdfdf9;border:0;font-size:11px;color:#7a8b70;max-width:95px;padding:3px}.context-dot{width:5px;height:5px;border-radius:50%;background:#719068}.context-divider{color:#b9c6ae;padding:0 3px}
#graph{width:100%;height:100%;stroke-width:1;touch-action:none;cursor:grab;display:block}#graph:active{cursor:grabbing}.node{cursor:pointer}.node:hover .node-ring{stroke:#779e69;stroke-width:2}.node text{font-family:var(--sans);stroke:none;pointer-events:none}.node:focus{outline:0}.node:focus .node-ring{stroke:#446c39;stroke-width:3}.edge-label{font-family:var(--sans);fill:#71816a;stroke:#fdfdf9;stroke-width:6px;paint-order:stroke;pointer-events:none}.graph-controls{position:absolute;bottom:22px;right:18px;display:flex;flex-direction:column;border:1px solid #e3e8dc;background:#fffefa;border-radius:7px;box-shadow:0 3px 8px #3d4b2f0a}.graph-controls button{width:36px;height:36px;display:grid;place-items:center;color:#6f8560}.graph-controls button:hover{background:#edf3e6}.graph-controls svg{width:17px;height:17px}.graph-controls>span{height:1px;background:#e6ebde;margin:0 7px}.graph-legend{position:absolute;left:19px;bottom:28px;display:flex;flex-wrap:wrap;gap:13px;font-size:10px;color:#7f8e75;pointer-events:none}.legend-item{display:flex;gap:5px;align-items:center}.type-dot{width:7px;height:7px;display:inline-block;border-radius:50%;background:var(--type-color,#52714d);flex-shrink:0}
.graph-empty{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:12px;pointer-events:none;background:#fdfdf9e6}.graph-empty svg{color:#adb7a2;width:32px;height:32px}.graph-empty strong{font-weight:500;color:#748467}.graph-empty span{color:#8c9c80;font-size:11px}.graph-empty button{pointer-events:auto}.text-button{color:#52734b;font-size:11px;text-decoration:underline;text-underline-offset:4px}.toast{position:fixed;bottom:24px;left:50%;transform:translate(-50%,15px);background:var(--green);color:white;padding:12px 20px;border-radius:8px;font-size:12px;opacity:0;pointer-events:none;transition:.2s;z-index:80;max-width:90vw;width:max-content}.toast.show{opacity:1;transform:translate(-50%,0)}
@media(max-width:760px){.app-shell{display:flex;flex-direction:column}.sidebar{padding:9px 12px;border-right:0;border-bottom:1px solid var(--border);overflow:hidden;flex-shrink:0}.nav-label{display:none}#book-nav{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none}#book-nav::-webkit-scrollbar{display:none}.book-nav-item{width:auto;flex-shrink:0;padding:9px 13px;margin:0;font-size:12px}.book-nav-item svg{width:16px;height:16px}.main{flex:1;height:auto;min-height:0}.toolbar{padding:10px 12px}.search-box{max-width:none;height:36px}.search-box input{font-size:12px}.search-box kbd{display:none}.filterbar{padding:8px 10px;gap:5px;min-height:44px}.select-wrap{gap:2px}.select-wrap label{display:none}.select-wrap select{font-size:10px;max-width:94px}.scope-button{font-size:10px;padding:6px}.filter-separator{margin:0 2px}.graph-context{left:12px;top:12px;font-size:10px}.graph-context select{font-size:10px}.graph-controls{flex-direction:row;bottom:max(16px,env(safe-area-inset-bottom));right:12px}.graph-controls button{width:34px;height:34px}.graph-controls>span{height:18px;width:1px;margin:0 2px;align-self:center}.graph-legend{left:12px;bottom:max(27px,calc(env(safe-area-inset-bottom) + 9px));gap:9px;font-size:9px}}
@media(prefers-reduced-motion:reduce){*{transition:none!important}}


.app-shell{display:block}.toolbar{display:flex;align-items:center;gap:10px}.search-box{flex:1;max-width:460px}
.book-toggle{display:flex;align-items:center;gap:7px;min-height:37px;padding:8px 10px;border:1px solid #dce5d4;border-radius:6px;background:#eef3e8;color:#526f45;font-size:12px;white-space:nowrap}.book-toggle svg{width:17px;height:17px}
.sidebar{position:fixed;inset:0 auto 0 0;width:300px;max-width:88vw;height:100%;height:100dvh;z-index:40;padding:0;display:flex;flex-direction:column;background:#fdfdf9;box-shadow:8px 0 35px #223b2920;border-right:1px solid var(--border);overflow:hidden}
.book-scrim{position:fixed;inset:0;z-index:35;background:#223f3455}
.book-panel-header{display:flex;align-items:center;justify-content:space-between;padding:17px 16px 12px;flex-shrink:0}.book-panel-header>span{font-size:13px}.book-panel-header small{font-size:10px;color:#8d9c81;margin-left:8px}.book-panel-header button{width:34px;height:34px;display:grid;place-items:center;color:#7d906e}.book-panel-header button svg{width:17px;height:17px}
.book-search-wrap{display:flex;align-items:center;gap:8px;margin:0 16px 12px;padding:0 10px;height:37px;flex-shrink:0;background:#f5f8ef;border:1px solid #e1e8d8;border-radius:6px}.book-search-wrap svg{width:15px;height:15px;color:#91a181;flex-shrink:0}.book-search-wrap input{width:100%;min-width:0;background:none;border:0;outline:0;font-size:12px}
#book-nav{display:block;flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:0 12px max(16px,env(safe-area-inset-bottom));scrollbar-width:thin;scrollbar-color:#ccd8c0 transparent}
#book-nav::-webkit-scrollbar{display:block;width:4px}.book-nav-item{width:100%;margin:0 0 6px;padding:12px;text-align:left;flex-shrink:0}.book-noresult{padding:20px 10px;color:#8c9d7f;font-size:12px}
@media(max-width:760px){.toolbar{padding:10px 12px;gap:8px}.search-box{max-width:none}.sidebar{border-bottom:0}.book-toggle{min-height:36px;padding:8px 9px;font-size:11px}.book-toggle svg{width:16px;height:16px}.filterbar{gap:9px;padding-left:12px}}
/* Keep the embedded graph's height definite, including mobile WebViews. */
.app-shell{display:block;height:100vh;height:100dvh}
.main{height:100%;width:100%;flex:none}
.workspace,.explorer{height:100%;min-height:0}
.graph-area{flex:1 1 0;min-height:0}
#graph{position:absolute;inset:0;width:100%;height:100%}

.edge-caption{pointer-events:none}.edge-caption text{font-family:var(--sans);stroke:none}.node{cursor:grab}.node:active{cursor:grabbing}
.edge-caption rect{stroke:none}

.graph-area,#graph,#graph *{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.graph-enter .node{animation:node-arrive .38s ease-out both;animation-delay:var(--enter-delay,0ms)}
.graph-enter .graph-edge{stroke-dasharray:1;animation:edge-arrive .48s ease-out both}
.graph-enter .edge-caption{animation:caption-arrive .3s ease-out .18s both}
.focus-halo{animation:halo-breathe 2.8s ease-in-out infinite}
@keyframes node-arrive{from{opacity:0}to{opacity:1}}
@keyframes edge-arrive{from{stroke-dashoffset:1;opacity:0}to{stroke-dashoffset:0;opacity:1}}
@keyframes caption-arrive{from{opacity:0}to{opacity:1}}
@keyframes halo-breathe{0%,100%{opacity:.4}50%{opacity:1}}
@media(prefers-reduced-motion:reduce){.graph-enter .node,.graph-enter .graph-edge,.graph-enter .edge-caption,.focus-halo{animation:none!important}}



.node-bumped .node-ring{transform-box:fill-box;transform-origin:center;animation:node-bump .28s ease-out}
.repel-wave{pointer-events:none;transform-origin:0 0;animation:repel-ripple .42s ease-out both}
@keyframes node-bump{0%{filter:drop-shadow(0 0 0 #7da56f);transform:scale(1)}40%{filter:drop-shadow(0 0 5px #7da56f);transform:scale(1.07)}100%{filter:drop-shadow(0 0 0 #7da56f);transform:scale(1)}}
@keyframes repel-ripple{from{opacity:.7;transform:scale(1)}to{opacity:0;transform:scale(1.65)}}
@media(prefers-reduced-motion:reduce){.node-bumped .node-ring,.repel-wave{animation:none!important}}

@font-face{font-family:"Atlas Mongolian";src:url("assets/fonts/NotoSansMongolian-Regular.ttf") format("truetype");font-display:swap;unicode-range:U+1800-18AF,U+202F}
:root{--sans:"PingFang SC","Microsoft YaHei","Atlas Mongolian","Mongolian Baiti",sans-serif}
.graph-context{max-width:calc(100% - 24px)}#context-name{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.graph-context select{flex-shrink:0}
.search-match-name{min-width:0;overflow-wrap:anywhere;line-height:1.65}.search-result small{white-space:nowrap;flex-shrink:0}

#graph.graph-dragging .edge-caption{visibility:hidden}

@font-face{font-family:"Atlas Oyun";src:url("assets/fonts/OyunQaganTig.ttf") format("truetype");font-display:swap}
.node text.mongolian-node{font-family:"Atlas Oyun","Atlas Mongolian",sans-serif;writing-mode:vertical-lr;text-orientation:sideways}

.mongolian-caption,.edge-caption text.mongolian-caption{font-family:"Atlas Oyun","Atlas Mongolian",sans-serif;writing-mode:vertical-lr;text-orientation:sideways}

.node-tooltip{position:fixed;z-index:60;max-width:min(360px,calc(100vw - 16px));max-height:55vh;overflow:auto;padding:12px 14px;border:1px solid #cbd8c1;border-radius:8px;background:#fffef7;box-shadow:0 5px 20px #223b2924;color:#315943;font-family:var(--sans);font-size:14px;line-height:1.65;overflow-wrap:anywhere;white-space:pre-wrap}
.node-tooltip.mongolian-tooltip{font-family:"Atlas Oyun","Atlas Mongolian",sans-serif;writing-mode:vertical-lr;text-orientation:sideways;height:min(280px,45vh);max-width:calc(100vw - 16px);word-break:normal;overflow-wrap:normal;white-space:normal;line-height:1.6}
