/* v427/v428: compact route headings and nested prefecture boundaries.
 * The server retains verified station order and produces all headings/frames.
 * These rules change presentation only; frame geometry shares the existing
 * grid fallback and optional measured-layout adapter. */
:is([data-route-presentation="333"],[data-route-presentation="334"]) .aga-route-region-title{
    align-items:start;line-height:1.5;
}
[data-route-presentation="334"] .aga-route-diagram-region .aga-route-region-title{line-height:1.5}
:is([data-route-presentation="333"],[data-route-presentation="334"]) .aga-route-region-title>span{
    align-items:center;column-gap:8px;row-gap:0;
}
:is([data-route-presentation="333"],[data-route-presentation="334"]) .aga-route-region-title :is(.aga-route-region-link,.aga-route-region-name,.aga-route-prefecture-link){
    display:inline-flex;align-items:center;box-sizing:border-box;min-height:32px;max-width:100%;margin-block:0;padding:4px 0!important;line-height:1.5;
}
:is([data-route-presentation="333"],[data-route-presentation="334"]) .aga-route-region-title .aga-route-prefecture-links{
    line-height:1.5;
}
:is([data-route-presentation="333"],[data-route-presentation="334"]) .aga-route-region-title .aga-route-prefecture-unit{
    white-space:nowrap;word-break:normal;overflow-wrap:normal;
}
:is([data-route-presentation="333"],[data-route-presentation="334"]) .aga-route-region-title .aga-route-prefecture-link{
    white-space:nowrap;word-break:normal;overflow-wrap:normal;
}
/* Keep the pin next to the first heading line when the prefecture summary
 * wraps. A 16px glyph is centered within the compact 32px link target. */
[data-route-presentation="334"] .aga-route-diagram-region .aga-route-region-title>.aga-ui-icon{
    align-self:start;margin-top:8px!important;
}
[data-route-presentation="334"] .aga-route-diagram-grid:has(>.aga-route-region-frame)>.aga-route-diagram-region{
    padding-top:6px;padding-bottom:4px;
}
/* The outer regional surface remains authoritative. Insets leave its border
 * visible without moving the existing numbered rail at x=22px.
 * Frame divs precede rails/cards in the DOM and never intercept interaction. */
[data-route-presentation="334"] .aga-route-prefecture-frame{
    display:block;position:relative;z-index:0;align-self:stretch;justify-self:stretch;box-sizing:border-box;min-width:0;min-height:0;
    margin:0 6px 8px 6px;padding:0;border:1px solid var(--aga-region-border,#c9d1d8);border-radius:5px;background:transparent;pointer-events:none;
}
[data-route-presentation="334"] .aga-route-diagram-prefecture{
    position:relative;z-index:2;box-sizing:border-box;min-width:0;margin:1px 7px 0 7px;padding:2px 8px 2px 34px;
    border:0;border-radius:4px 4px 0 0;background:var(--aga-region-surface,var(--aga-route-surface,#fff));
}
[data-route-presentation="334"] .aga-route-diagram-prefecture.aga-route-prefecture-continued-above{
    margin-bottom:14px;
}
/* Expose the existing admitted rail above the prefecture frame. The region
 * title and note keep their compact line height; no new rail is painted. */
[data-route-presentation="334"] .aga-route-diagram-grid:has(>.aga-route-region-frame)>.aga-route-diagram-region.aga-route-region-continued-above{
    margin-bottom:12px;
}
/* The outer frame ends 4px before the lane's right edge. Inner insets 6/10
 * therefore produce the same 6px border offset on both sides. Station cards
 * keep 8px to the inner frame without moving their left edge or numbered rail.
 * Only new renderer output has member markers: previously saved v427 HTML
 * keeps its matching old frame/header insets until it is normally rebuilt. */
[data-route-presentation="334"] .aga-route-diagram-grid:has(>.aga-route-diagram-node.aga-route-prefecture-member)>.aga-route-prefecture-frame{
    margin-right:10px;
}
[data-route-presentation="334"] .aga-route-diagram-grid:has(>.aga-route-diagram-node.aga-route-prefecture-member)>.aga-route-diagram-prefecture{
    margin-right:11px;
}
[data-route-presentation="334"] .aga-route-diagram-node.aga-route-prefecture-member{
    padding-right:18px;
}
/* Only the final prefecture in a region needs an extra 6px footer. Move its
 * inner bottom edge up while preserving the existing card-to-frame clearance;
 * intermediate stations and prefecture boundaries do not gain extra height. */
[data-route-presentation="334"] .aga-route-diagram-node.aga-route-prefecture-region-end{
    padding-bottom:22px;
}
[data-route-presentation="334"] .aga-route-prefecture-frame.aga-route-prefecture-region-end{
    margin-bottom:14px;
}
[data-route-presentation="334"] :is(.aga-search-station-name,.aga-route-station-name){
    font-size:14px;font-weight:700;
}
[data-route-presentation="334"] .aga-route-diagram-prefecture .aga-route-prefecture-title{
    display:block;min-width:0;margin:0;padding:0;border:0;background:none;box-shadow:none;color:#484a4e;font-size:14px;font-weight:700;line-height:1.5;
}
[data-route-presentation="334"] .aga-route-prefecture-title :is(.aga-route-prefecture-heading-link,.aga-route-prefecture-heading-name){
    display:inline-flex;align-items:center;box-sizing:border-box;min-width:0;max-width:100%;min-height:32px;margin:0;padding:4px 0!important;
    font:inherit;line-height:1.5;white-space:nowrap;word-break:normal;overflow-wrap:normal;
}
[data-route-presentation="334"] .aga-route-prefecture-heading-link{
    text-decoration:underline;text-underline-offset:.15em;
}
[data-route-presentation="334"] .aga-route-prefecture-heading-link:focus-visible{
    outline:2px solid #18664d;outline-offset:2px;border-radius:2px;
}
@media(forced-colors:active){
    [data-route-presentation="334"] .aga-route-prefecture-frame{border-color:CanvasText}
    [data-route-presentation="334"] .aga-route-diagram-prefecture{background:Canvas;color:CanvasText}
    [data-route-presentation="334"] .aga-route-diagram-prefecture .aga-route-prefecture-title{color:CanvasText}
    [data-route-presentation="334"] .aga-route-prefecture-heading-link:focus-visible{outline-color:Highlight}
}
