/* Lodge history follows the portal's existing light and dark themes. */
.d21-history{--d21-history-gold:#a77b00;--d21-history-edge:#579469;min-width:0}
.d21-portal[data-theme=dark] .d21-history{--d21-history-gold:#f5cf62;--d21-history-edge:#79c891}
.d21-history-controls{display:grid;grid-template-columns:auto minmax(180px,440px) minmax(0,1fr);gap:18px;align-items:center;padding:17px 22px;margin-bottom:24px;border:1px solid var(--d21-line);border-radius:14px;background:var(--d21-paper)}
.d21-history-controls>label{font-size:16px;font-weight:650;white-space:nowrap}
.d21-history-controls>.d21-select{width:100%;min-width:0;font-weight:600}
.d21-history-modes{display:flex;justify-content:flex-end;gap:10px;min-width:0}
.d21-history-modes .d21-button{min-width:110px}
.d21-history-canvas{min-width:0;margin:0 0 24px;padding:18px 16px 8px;border:1px solid var(--d21-line);border-radius:16px;background:var(--d21-paper);box-shadow:var(--d21-shadow)}
.d21-history-canvas figcaption{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:0 6px;color:var(--d21-muted);font-size:12px;font-weight:600}
.d21-history-canvas figcaption span{font-weight:400}
.d21-portal .d21-history-overview{appearance:none;display:grid;grid-template-rows:minmax(0,1fr) auto;gap:6px;width:100%;height:clamp(160px,24vw,290px);min-width:0;padding:8px 0 3px;margin:0;border:0;border-radius:8px;background:transparent;color:var(--d21-text);font:inherit;cursor:zoom-in;overflow:hidden;text-align:center}
.d21-portal .d21-history-overview>.d21-history-overview-vector{display:block;width:100%;height:100%;min-height:0;overflow:hidden;pointer-events:none}
.d21-history-overview-hint{display:flex;align-items:center;justify-content:center;gap:6px;font-size:12px;font-weight:600;color:var(--d21-link)}
.d21-history-overview-hint>svg{width:18px;height:18px;flex:none}
.d21-history-overview:focus-visible{outline:3px solid var(--d21-gold);outline-offset:3px}
.d21-history-scroll{overflow-x:auto;max-width:100%;padding-bottom:8px;scroll-padding-inline:20px;scrollbar-color:var(--d21-history-edge) var(--d21-soft);scrollbar-width:thin;border-radius:8px}
.d21-history-scene{position:relative;min-width:0;margin:0 auto}
.d21-portal .d21-history-graph-dialog{width:min(1400px,calc(100% - 32px));height:min(800px,calc(100dvh - 32px));max-width:none;max-height:calc(100dvh - 32px);padding:0;margin:auto;overflow:hidden}
.d21-history-graph-dialog[open]{display:grid;grid-template-rows:auto auto minmax(0,1fr)}
.d21-history-graph-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:20px 20px 0}
.d21-history-graph-head>div{min-width:0}
.d21-history-graph-head h2{font-size:28px;line-height:1.2;margin:0}
.d21-history-graph-head p{font-size:12px;color:var(--d21-muted);margin:6px 0 0!important}
.d21-history-graph-head>.d21-icon-button{min-width:44px;min-height:44px;flex:none}
.d21-history-zoom{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:12px 20px;border-bottom:1px solid var(--d21-line)}
.d21-portal .d21-history-zoom>.d21-button,.d21-portal .d21-history-zoom>.d21-icon-button{min-height:44px;min-width:44px;justify-content:center;padding:9px 10px;line-height:1.2}
.d21-history-zoom>output{min-width:48px;text-align:center;color:var(--d21-muted);font-size:13px;font-variant-numeric:tabular-nums}
.d21-portal .d21-history-graph-viewport{min-width:0;min-height:0;max-width:100%;padding:16px;overflow:auto;border-radius:0;overscroll-behavior:contain}
.d21-history-graph-space{position:relative;margin:auto;min-width:0;overflow:hidden}
.d21-history-graph-space>.d21-history-scene{position:absolute;left:0;top:0;margin:0;transform-origin:0 0;transition:none}
.d21-portal .d21-history-scene>svg{position:absolute;inset:0;display:block;width:100%;height:100%;overflow:visible}
.d21-history-path{fill:none;stroke:var(--d21-history-gold);stroke-width:4}
.d21-history-path-planned{stroke-dasharray:8 6}
.d21-history-scene marker path{fill:var(--d21-history-gold)}
.d21-history-junction{fill:var(--d21-paper);stroke:var(--d21-history-gold);stroke-width:4}
.d21-history-junction-planned{stroke-dasharray:3 2}
.d21-history-annotation-leader{fill:none;stroke:var(--d21-muted);stroke-width:1;stroke-dasharray:3 4;opacity:.65;pointer-events:none}
.d21-portal .d21-history-node{position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;width:196px;height:96px;min-height:96px;padding:10px 12px;border:2px solid var(--d21-history-edge);border-radius:10px;background:var(--d21-soft);color:var(--d21-text);font:600 20px/1.15 Georgia,"Times New Roman",serif;text-align:center;box-shadow:0 4px 10px #08251a0a;overflow-wrap:anywhere}
.d21-history-node>span,.d21-history-node>strong{font:inherit;line-height:inherit}
.d21-history-node>span{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;max-height:46px}
.d21-portal .d21-history-node-selected{border-color:var(--d21-gold);box-shadow:0 0 0 1px var(--d21-gold),0 4px 12px #08251a14}
.d21-portal .d21-history-event-label{position:absolute;display:block;width:180px;min-height:36px;border:0;background:var(--d21-paper);padding:0 4px 4px;color:var(--d21-text);text-align:center;font-size:10.5px;line-height:1.25;overflow-wrap:normal;word-break:normal;hyphens:none}
.d21-history-event-label strong{display:block;margin-bottom:2px;font:600 italic 13px/1.25 Georgia,"Times New Roman",serif;white-space:nowrap}
.d21-history-event-label span{display:block}
.d21-history-records{padding:22px;border:1px solid var(--d21-line);border-radius:16px;background:var(--d21-paper);box-shadow:var(--d21-shadow)}
.d21-history-records h2{margin-bottom:18px!important}
.d21-history-records>ol{list-style:none;padding:0;margin:0;display:grid;gap:8px}
.d21-history-records li{display:grid;grid-template-columns:200px minmax(0,1fr);gap:20px;align-items:start;padding:12px 16px;background:var(--d21-soft);border-radius:8px}
.d21-history-records li>div{min-width:0;padding-left:20px;border-left:1px solid var(--d21-line);line-height:1.55}
.d21-history-date-link{min-height:32px;padding:0;background:none;color:var(--d21-text);border:0;text-align:left;font-weight:650;line-height:1.4}
.d21-history-records small{display:block;margin-top:3px;color:var(--d21-muted);font-size:11px}
.d21-history-lodge-link{display:inline;padding:0;background:transparent;color:var(--d21-link);border:0;border-bottom:1px solid currentColor;font-size:inherit;font-weight:inherit;line-height:inherit;text-align:left}
.d21-history-timeline{list-style:none;padding:0 0 0 28px;margin:0 0 24px;position:relative}
.d21-history-timeline:before{content:"";position:absolute;left:6px;top:10px;bottom:36px;width:2px;background:var(--d21-gold)}
.d21-history-timeline>li{position:relative;margin:0;padding:4px 0 27px 13px;min-width:0}
.d21-history-timeline>li:before{content:"";position:absolute;left:-28px;top:11px;width:14px;height:14px;border:3px solid var(--d21-gold);background:var(--d21-paper);border-radius:50%}
.d21-history-timeline>li.d21-history-planned:before{border-style:dashed}
.d21-history-timeline>li:not(:last-child):after{content:"";position:absolute;left:13px;right:0;bottom:13px;height:1px;background:var(--d21-line)}
.d21-history-timeline-date{font:600 25px/1.25 Georgia,"Times New Roman",serif;margin-bottom:7px;color:var(--d21-text)}
.d21-history-status{display:inline-block;padding:4px 9px;margin:0 0 10px;border-radius:5px;background:var(--d21-soft);color:var(--d21-muted);font-size:11px;font-weight:600;line-height:1.4}
.d21-history-status-planned{background:var(--d21-gold-soft);color:var(--d21-text);border-left:3px solid var(--d21-gold)}
.d21-history-relationship{font-size:15px;line-height:1.7;overflow-wrap:anywhere}
.d21-history-timeline li>p{max-width:780px;margin-top:7px!important;color:var(--d21-muted);font-size:13px;line-height:1.65}
.d21-history-row-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}
.d21-history-row-actions .d21-button{min-height:36px;padding:7px 11px;font-size:12px}
.d21-history-source-note{margin:15px 6px 0!important;color:var(--d21-muted)!important;font-size:12px;font-style:italic;line-height:1.6}
.d21-history-management{padding:0;margin:17px 0 0;list-style:none}
.d21-history-management>li{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:14px 0;border-bottom:1px solid var(--d21-line);font-size:13px}
.d21-history-management>li>div,.d21-history-management>li>strong{min-width:0;overflow-wrap:anywhere}
.d21-history-management>li>.d21-button{flex:none}
.d21-history-management p{margin-top:5px!important;color:var(--d21-muted)}
.d21-history-date-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;min-width:0;padding:15px;border:1px solid var(--d21-line);border-radius:9px;margin:0}
.d21-history-date-fields legend{font-weight:600;padding-inline:5px}
.d21-history-merge-fields,.d21-history-move-fields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:15px;min-width:0}
.d21-history-merge-fields>label,.d21-history-move-fields>label:first-child{grid-column:1/-1}
.d21-history-merge-fields select[multiple]{min-height:130px}
.d21-history-event-detail{padding-top:18px}
.d21-history-event-detail>.d21-history-relationship{margin-top:12px!important}
.d21-history-event-detail>p:not(.d21-history-status){margin-top:12px!important}
.d21-history-printed{margin-top:20px;padding-top:14px;border-top:1px solid var(--d21-line);color:var(--d21-muted);font-size:12px}
.d21-history-printed summary{cursor:pointer;font-weight:600;min-height:32px}
.d21-history-printed p{margin-top:8px!important;line-height:1.65}
@media(hover:hover){.d21-history-node:hover{background:var(--d21-gold-soft)}.d21-history-event-label:hover strong,.d21-history-date-link:hover{text-decoration:underline;text-underline-offset:3px}.d21-history-lodge-link:hover{color:var(--d21-text)}}
@media(max-width:1000px){.d21-history-controls{grid-template-columns:auto minmax(0,1fr);gap:12px}.d21-history-modes{grid-column:1/-1;justify-content:flex-start}}
@media(max-width:700px){
    .d21-history-controls{grid-template-columns:minmax(0,1fr);gap:10px;padding:16px;margin-bottom:25px;border-radius:12px}
    .d21-history-controls>label{font-size:14px}
    .d21-history-controls>.d21-select{font-size:16px;min-height:46px}
    .d21-history-modes{gap:8px;margin-top:4px}
    .d21-history-modes>.d21-button{flex:1;min-width:0}
    .d21-history-canvas{padding:14px 8px 4px;border-radius:12px}
    .d21-history-canvas figcaption{font-size:11px;padding-inline:5px}
    .d21-history-canvas figcaption span{display:none}
    .d21-history-overview{height:180px}
    .d21-history-graph-head{padding:15px 12px 0}
    .d21-history-graph-head h2{font-size:25px}
    .d21-history-zoom{padding:10px;gap:4px}
    .d21-history-records{padding:18px 14px;border-radius:12px}
    .d21-history-records li{grid-template-columns:minmax(0,1fr);gap:5px;padding:11px 12px}
    .d21-history-records li>div{border:0;padding:0;font-size:13px}
    .d21-history-date-link{min-height:30px}
    .d21-history-timeline{padding-left:22px}
    .d21-history-timeline>li{padding-left:9px}
    .d21-history-timeline>li:before{left:-22px}
    .d21-history-timeline>li:not(:last-child):after{left:9px}
    .d21-history-timeline-date{font-size:25px}
    .d21-history-relationship{font-size:14px;line-height:1.75}
    .d21-history-timeline li>p{font-size:12px}
    .d21-history-status{font-size:10px;padding:5px 7px}
    .d21-history-source-note{margin-inline:0!important;font-size:11px}
    .d21-history-date-fields{gap:10px;padding:12px}
    .d21-history-date-fields .d21-field{font-size:11px}
    .d21-history-date-fields input{padding-inline:7px}
    .d21-history-merge-fields,.d21-history-move-fields{grid-template-columns:minmax(0,1fr)}
}
