/* FDBM reading mode v1: isolated from the ordinary portal view. */
.fdbm-reader-bar[hidden]{display:none!important}
.fdbm-reader-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:40px;padding:5px 12px;border-bottom:1px solid #d2d2d2;background:#f0f6f2;font:12px Arial,sans-serif;flex:none}
.fdbm-reader-bar button{border:1px solid #777;border-radius:6px;background:white;padding:5px 10px;color:#171717;cursor:pointer}
.fdbm-reader-bar strong{font-size:12px}
.fdbm-reader-bar .fdbm-reader-location{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#41564a;min-width:0;flex:1;text-align:right}
.fdbm-reader-open{font:inherit;cursor:pointer}
.fdbm-reading{overflow:hidden!important}
.fdbm-reading > header,.fdbm-reading > footer{display:none!important}
.fdbm-reading main{max-width:none!important;width:100%!important;height:100vh;height:100dvh;margin:0!important;padding:0!important;display:flex!important;flex-direction:column!important;gap:0!important;overflow:hidden!important}
.fdbm-reading main > .notice,.fdbm-reading main > .geo-map{display:none!important}
.fdbm-reading .fdbm-reader-bar{flex:0 0 40px;z-index:30}
.fdbm-reading .phase-shell{flex:0 0 calc((100% - 40px)/2);height:calc((100% - 40px)/2);min-height:0;max-height:none;margin:0!important;border-radius:0;display:flex;flex-direction:column;overflow:hidden}
.fdbm-reading .phase-shell > .phase-toggle{flex:0 0 auto;min-height:34px;padding-top:7px;padding-bottom:7px}
.fdbm-reading #phaseNarrative{flex:1 1 auto;min-height:0;display:flex!important;flex-direction:column;overflow:hidden;padding:0 8px 6px}
.fdbm-reading #phaseNarrative[hidden]{display:flex!important}
.fdbm-reading .tabs{flex:0 0 auto;display:flex!important;overflow-x:auto;overflow-y:hidden;gap:6px;margin:0 0 4px;padding:2px 0 4px;-webkit-overflow-scrolling:touch}
.fdbm-reading .tabs .tab{flex:0 0 155px;min-width:0;min-height:30px;padding:5px 7px;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.fdbm-reading #shared{min-height:0;flex:1 1 auto;margin:0!important;padding:6px 9px!important;display:flex;flex-direction:column;overflow:hidden}
.fdbm-reading #shared[hidden]{display:none!important}
.fdbm-reading #sharedTitle{flex:0 0 auto;margin-bottom:4px}
.fdbm-reading #viewport{flex:1 1 auto;min-height:0;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
.fdbm-reading #tools{flex:0 0 auto;margin-top:4px;padding-top:4px;max-height:33px;overflow-y:auto}
.fdbm-reading .disc-wrap{flex:1 1 auto;min-height:0;max-height:none;border-radius:0;border-top:3px solid #558a73;display:flex;flex-direction:column;overflow:hidden!important}
.fdbm-reading .disc-wrap > summary{flex:0 0 auto;min-height:34px;padding-top:8px;padding-bottom:8px}
.fdbm-reading .disc-wrap > .map{flex:0 0 auto;min-height:0;height:100%!important;max-height:100%!important;display:flex!important;flex-wrap:nowrap!important;grid-template-columns:none!important;overflow-x:auto!important;overflow-y:hidden!important;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable}
.fdbm-reading .disc-wrap .col{display:block;flex:0 0 clamp(250px,27vw,390px);width:clamp(250px,27vw,390px);min-width:0;min-height:0!important;height:100%;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable}
.fdbm-reading .disc-wrap .col h2{position:sticky;top:0;z-index:2;background:#f2f2f2}
.fdbm-reading .disc-wrap .cards{min-height:100%;padding-bottom:32px}
.fdbm-reading .disc-wrap .card.fdbm-reading-target{background:#fff2a6!important;outline:2px solid #bb8500!important;outline-offset:-2px;scroll-margin:48px 10px}
.fdbm-reading .content a[href^="#fdbm-card-"],.fdbm-reading #content a[data-fdbm-card]{color:#165f9b;text-decoration:underline}
@media(max-width:760px){
  .fdbm-reading .disc-wrap .col{flex-basis:min(84vw,350px);width:min(84vw,350px)}
  /* Override the mobile hero's normal stacked / unbounded layout in this fixed-height mode only. */
  .fdbm-reading .content .overview-hero-layout{display:grid!important;grid-template-columns:minmax(0,42%) minmax(0,1fr)!important;height:100%!important;gap:8px!important}
  .fdbm-reading .content .overview-hero-visual,.fdbm-reading .content .overview-hero-text-shell{height:100%!important;min-height:0!important;overflow:hidden!important}
  .fdbm-reading .content .overview-hero-scroll{height:100%!important;max-height:none!important;overflow-x:auto!important;overflow-y:hidden!important}
  .fdbm-reading .content .overview-hero-columns{height:100%!important;min-width:100%!important;column-count:initial!important;column-width:285px!important;column-fill:auto!important}
  .fdbm-reading .content .overview-hero-visual img{width:auto!important;max-width:100%!important;max-height:100%!important;object-fit:contain!important}
  .fdbm-reading .fdbm-reader-bar .fdbm-reader-location{font-size:10px}
}

/* Only appears when reader_test=1 is explicitly present in the URL. */
.fdbm-reader-demo{background:#eaf5ef;border:2px dashed #39835b;border-radius:7px;padding:9px;margin:0 0 10px;break-inside:avoid;page-break-inside:avoid;font:12px/1.45 Arial,sans-serif;}
.fdbm-reader-demo strong{display:block;margin-bottom:4px;font-size:11px;}
.fdbm-reader-demo p{margin:0!important;}
.fdbm-reader-demo a{color:#165f9b!important;font-weight:700;display:inline;}

/* v1.2: descriptive discipline-reference anchors; no styling outside narrative. */
#content a[href^="#fdbm-ref:"]{color:#165f9b;text-decoration:underline;text-underline-offset:2px}
#content a.fdbm-ref-missing{outline:1px dashed #a45100;background:#fff2d6}

/* v1.3 — Exit control floats on the divider; the former 40px toolbar uses no height. */
.fdbm-reading .fdbm-reader-bar{
  position:fixed!important;top:calc(50dvh - 17px)!important;right:8px!important;
  left:auto!important;width:34px!important;height:34px!important;min-height:0!important;
  padding:0!important;margin:0!important;border:0!important;background:transparent!important;
  flex:0 0 0!important;display:block!important;z-index:90!important;
  pointer-events:none!important;overflow:visible!important;
}
.fdbm-reading .fdbm-reader-bar strong,
.fdbm-reading .fdbm-reader-bar .fdbm-reader-location{
  position:absolute!important;width:1px!important;height:1px!important;overflow:hidden!important;
  clip-path:inset(50%)!important;white-space:nowrap!important;
}
.fdbm-reading #fdbmReaderExit{
  pointer-events:auto!important;display:block!important;width:34px!important;height:34px!important;
  padding:0!important;line-height:32px!important;font-size:0!important;
  color:#204b3b!important;background:#f0f6f2!important;border:1px solid #59816e!important;
  border-radius:50%!important;box-shadow:0 2px 7px #0003!important;cursor:pointer!important;
}
.fdbm-reading #fdbmReaderExit::before{content:'×';font:24px/30px Arial,sans-serif;color:#204b3b}
.fdbm-reading #fdbmReaderExit:focus-visible{outline:3px solid #2678c5!important;outline-offset:3px}
.fdbm-reading .phase-shell{flex:0 0 50%!important;height:50%!important}

/* v1.4 — restore the original eight-column density on wide screens only. */
@media(min-width:1051px){
  .fdbm-reading .disc-wrap .col{
    flex:0 0 max(170px,12.5%)!important;
    width:max(170px,12.5%)!important;
  }
}
/* An audit panel is transient; it consumes no reading-area height. */
.fdbm-audit-back{position:fixed;inset:0;z-index:5000;background:#0007;display:flex;align-items:center;justify-content:center;padding:16px}
.fdbm-audit-panel{box-sizing:border-box;background:#fff;color:#171717;border-radius:10px;padding:16px;width:min(780px,100%);max-height:90dvh;display:flex;flex-direction:column;gap:10px;box-shadow:0 10px 40px #0004;font:13px/1.4 Arial,sans-serif}
.fdbm-audit-panel h2{font-size:16px;margin:0}.fdbm-audit-panel p{margin:0}
.fdbm-audit-text{box-sizing:border-box;resize:vertical;width:100%;min-height:160px;height:50dvh;max-height:65dvh;overflow:auto;padding:10px;border:1px solid #aaa;border-radius:6px;font:12px/1.5 monospace}
.fdbm-audit-actions{display:flex;justify-content:flex-end;gap:8px}
.fdbm-audit-actions button{background:#fff;border:1px solid #888;border-radius:5px;padding:7px 12px;cursor:pointer}


/* v1.5: ordinary overview (only the population-map heading): map flows WITH the horizontal newspaper. */
@media(min-width:761px){
  body:not(.fdbm-reading) #content.fdbm-population-overview{width:max-content!important;min-width:100%!important}
  body:not(.fdbm-reading) #viewport:has(> #content.fdbm-population-overview){overflow-x:auto!important;overflow-y:hidden!important}
  body:not(.fdbm-reading) #content.fdbm-population-overview .overview-hero-layout{
    display:flex!important;align-items:flex-start!important;gap:24px!important;
    width:max-content!important;min-width:100%!important;
  }
  body:not(.fdbm-reading) #content.fdbm-population-overview .overview-hero-visual{
    flex:0 0 var(--overview-hero-w, 42%)!important;width:var(--overview-hero-w, 42%)!important;
  }
  body:not(.fdbm-reading) #content.fdbm-population-overview .overview-hero-text-shell{
    flex:0 0 auto!important;width:max-content!important;max-width:none!important;
  }
  body:not(.fdbm-reading) #content.fdbm-population-overview .overview-hero-scroll{
    width:max-content!important;max-width:none!important;overflow:visible!important;
  }
}
/* The pin belongs to the IMAGE, not its caption; display ONLY in linked reading. */
.fdbm-map-image-stage{position:relative!important;display:inline-block!important;align-self:flex-start!important;max-width:100%!important;line-height:0!important;vertical-align:top}
.fdbm-map-image-stage img{display:block!important;max-width:100%!important}
.fdbm-map-pin{display:none!important}
/* v1.6: SVG flag's POLE FOOT is the selected map coordinate (not its glyph centre).
   The white outline and shadow are independent of system emoji/fonts. */
.fdbm-reading .fdbm-map-pin{
  position:absolute!important;display:block!important;
  left:var(--fdbm-pin-x, 0px);top:var(--fdbm-pin-y, 0px);
  transform:translate(-5px,-28px)!important;width:24px;height:30px;padding:0;
  border:0;background:transparent;z-index:6;pointer-events:none;
  filter:drop-shadow(0 1px 2px rgba(0,0,0,.38));
}
.fdbm-map-pin::before{content:none!important}
.fdbm-map-pin svg{width:24px;height:30px;display:block;overflow:visible}
.fdbm-map-pin[hidden]{display:none!important}
.fdbm-reading .fdbm-map-note{
  display:block!important;margin:4px 0 0!important;padding:3px 5px;
  max-width:100%;font:10px/1.35 Arial,sans-serif;color:#263b32;background:#f4f9f2;
  border-left:3px solid #bd9526;white-space:normal
}
.fdbm-map-note[hidden]{display:none!important}
@media(max-width:760px){
  .fdbm-reading .fdbm-map-note{font-size:9px}
  .fdbm-reading .fdbm-map-pin{transform:translate(-5px,-28px)!important}
}

/* v1.5: use the ACTUAL original eight equal fractions, including 1051–1360px. */
@media(min-width:1051px){
  .fdbm-reading .disc-wrap .col{flex:0 0 12.5%!important;width:12.5%!important;min-width:0!important}
}

/* v1.6: explanatory source is compact and does not alter the image's coordinate frame. */
.fdbm-reading .fdbm-map-note a{color:#125885;text-decoration:underline}
.fdbm-reading .fdbm-map-note strong{font-weight:700}

/* v1.7: focus on ONE selected explanation, not the whole row of phase headings.
   All selectors are reading-mode-scoped; normal portal/editor remain intact. */
.fdbm-reading .phase-shell > .phase-toggle,
.fdbm-reading #phaseNarrative > .tabs,
.fdbm-reading .phase-shell > .phase-font-tools,
.fdbm-reading #tools{display:none!important}
.fdbm-reading #phaseNarrative{padding:0 8px 4px!important}
.fdbm-reading #shared{padding:5px 9px!important}
/* The selected heading survives for ordinary explanation records;
   the population hero already renders its heading on the text side. */
.fdbm-reading #sharedTitle{margin-bottom:4px!important}

/* v1.8: calibration UI exists only for authenticated administrators in linked reading.
   The editing panel overlays the lower area temporarily; no permanent toolbar is added. */
.fdbm-reading .fdbm-map-image-stage.fdbm-map-calibrating{cursor:crosshair!important;touch-action:manipulation}
.fdbm-reading .fdbm-map-calibrating img{cursor:crosshair!important}
.fdbm-reading .fdbm-map-calibrating .fdbm-map-pin{filter:drop-shadow(0 1px 3px rgba(0,0,0,.52))}
.fdbm-reading .fdbm-geo-edit{
  display:inline-block;max-width:100%;margin-left:5px;padding:2px 5px;
  background:#fff;border:1px solid #59816e;border-radius:4px;color:#144735;
  font:600 10px/1.2 Arial,sans-serif;cursor:pointer
}
.fdbm-reading .fdbm-geo-edit:focus-visible{outline:2px solid #217bc4;outline-offset:2px}
.fdbm-map-editor[hidden]{display:none!important}
.fdbm-map-editor{
  position:fixed;z-index:180;top:calc(50dvh + 9px);right:45px;
  width:min(380px,calc(100vw - 55px));max-height:calc(50dvh - 19px);
  overflow-y:auto;overscroll-behavior:contain;box-sizing:border-box;
  background:#fff;color:#1b2620;border:2px solid #498369;border-radius:10px;
  padding:12px;box-shadow:0 12px 38px rgba(0,0,0,.3);
  font:12px/1.35 Arial,sans-serif
}
.fdbm-map-editor > strong{display:block;font-size:14px;margin:0 0 5px}
.fdbm-map-editor p{font-size:11px;margin:0 0 7px}
.fdbm-map-coordinate{display:block;background:#e8f3ed;color:#165039;padding:5px;margin-bottom:6px;border-radius:4px;font-variant-numeric:tabular-nums}
.fdbm-calibrate-label{display:block;font-size:11px;font-weight:600;margin:6px 0 3px}
.fdbm-calibrate-label input,.fdbm-calibrate-label textarea{
  display:block;box-sizing:border-box;width:100%;min-height:28px;padding:6px;margin:3px 0 0;
  border:1px solid #abb5af;border-radius:5px;background:#fff;color:#1b2620;
  font:12px/1.3 Arial,sans-serif;resize:vertical
}
.fdbm-map-error{color:#a20f0f;font-size:11px;min-height:15px;margin:5px 0}
.fdbm-map-edit-actions{display:flex;justify-content:flex-end;gap:7px;position:sticky;bottom:-12px;background:#fff;padding:7px 0 0;border-top:1px solid #dde7df}
.fdbm-map-edit-actions button{border:1px solid #65907a;background:#fff;color:#183f30;padding:7px 10px;border-radius:5px;cursor:pointer;font:600 12px Arial,sans-serif}
.fdbm-map-edit-actions button.fdbm-map-save{background:#236744;color:#fff}
.fdbm-map-edit-actions button:disabled{opacity:.55;cursor:wait}
@media(max-width:760px){
  .fdbm-map-editor{top:calc(50dvh + 4px);right:40px;width:calc(100vw - 50px);max-height:calc(50dvh - 12px);padding:9px}
}

/* FDBM mobile linked reading v2.2
   Upper half is ONE horizontal strip:
   population map -> guide page 1 -> guide page 2 -> ...
   The inner text scroller is deliberately disabled on mobile reader mode.
   Lower half keeps the linked discipline entry as a vertical scroller. */
@media(max-width:760px){
  .fdbm-reading #viewport{
    overflow:hidden!important;
  }

  .fdbm-reading .content .overview-hero-layout{
    display:flex!important;
    flex-wrap:nowrap!important;
    grid-template-columns:none!important;
    width:100%!important;
    height:100%!important;
    gap:0!important;
    overflow-x:auto!important;
    overflow-y:hidden!important;
    -webkit-overflow-scrolling:touch!important;
    overscroll-behavior-x:contain!important;
  }

  .fdbm-reading .content .overview-hero-visual{
    flex:0 0 100%!important;
    width:100%!important;
    min-width:100%!important;
    max-width:100%!important;
    height:100%!important;
    min-height:0!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    overflow:auto!important;
    padding:4px!important;
  }

  /* JS expands this shell to exactly as many text pages as the guide needs. */
  .fdbm-reading .content .overview-hero-text-shell{
    flex:0 0 100%!important;
    width:100%!important;
    min-width:100%!important;
    max-width:none!important;
    height:100%!important;
    min-height:0!important;
    display:grid!important;
    grid-template-rows:auto minmax(0,1fr)!important;
    overflow:hidden!important;
    padding:0 4px!important;
  }

  .fdbm-reading .content .overview-hero-visual img{
    width:auto!important;
    max-width:100%!important;
    max-height:calc(100% - 22px)!important;
    object-fit:contain!important;
  }

  /* No second horizontal scroller: the OUTER hero strip owns all horizontal motion. */
  .fdbm-reading .content .overview-hero-scroll{
    height:100%!important;
    max-height:none!important;
    width:100%!important;
    max-width:none!important;
    overflow:visible!important;
    padding-bottom:0!important;
  }

  .fdbm-reading .content .overview-hero-columns{
    height:100%!important;
    min-height:0!important;
    min-width:0!important;
    width:100%!important;
    column-count:1!important;
    column-width:auto!important;
    column-gap:18px!important;
    column-fill:auto!important;
    column-rule:0!important;
  }

  .fdbm-reading .disc-wrap > .map{
    overflow-x:hidden!important;
    overflow-y:hidden!important;
    display:block!important;
  }
  .fdbm-reading .disc-wrap .col{
    display:none!important;
  }
  .fdbm-reading .disc-wrap .col.fdbm-reading-column-active{
    display:block!important;
    box-sizing:border-box!important;
    flex:0 0 100%!important;
    width:100%!important;
    min-width:100%!important;
    max-width:100%!important;
    height:100%!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    padding:0 7px 24px!important;
    overscroll-behavior-y:contain!important;
    -webkit-overflow-scrolling:touch!important;
  }
  .fdbm-reading .disc-wrap .col.fdbm-reading-column-active .cards{
    width:100%!important;
    min-width:0!important;
  }
  .fdbm-reading .disc-wrap .col.fdbm-reading-column-active .card{
    display:none!important;
  }
  .fdbm-reading .disc-wrap .col.fdbm-reading-column-active .card.fdbm-reading-target{
    display:block!important;
    width:100%!important;
    max-width:none!important;
    margin:0!important;
  }
}

/* v2 multi-point editor additions */
.fdbm-map-point-list{display:grid;gap:4px;margin:7px 0;padding:6px;border:1px solid #d9e1dc;border-radius:6px;background:#f8fbf9}
.fdbm-map-point-row{display:flex;align-items:center;justify-content:space-between;gap:8px;font:10px/1.3 Arial,sans-serif}
.fdbm-map-point-row button{width:24px;height:24px;padding:0!important;border-radius:50%!important}
.fdbm-map-point-actions{display:flex;gap:6px;flex-wrap:wrap;margin:6px 0 9px}
.fdbm-map-point-actions button{font-size:10px!important;padding:4px 7px!important}