/* REVIEW_NOTES_23: reach counter, time machine, cabin and bus animation, station dashboards. . */
#map { --qt-tm-h: 8.6rem; }

/* ---------- shared bits ---------- */
.qt-btn {
  border: 1px solid #1d4e89;
  background: #f7f3ec;
  color: var(--ink);
  font: 600 0.85rem "Source Sans 3", sans-serif;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  border-radius: 3px;
  min-height: 2rem;
}
.qt-btn:hover { background: #fff; }
.qt-btn.qt-small { font-size: 0.75rem; padding: 0.15rem 0.45rem; min-height: 1.6rem; }
.qt-play { min-width: 2.4rem; font-size: 1rem; }
.qt-i {
  border: 1px solid #8798a8;
  background: #fff;
  color: #1d4e89;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  font: 700 0.8rem "Source Sans 3", sans-serif;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
.qt-i-s { width: 1.15rem; height: 1.15rem; font-size: 0.7rem; margin-left: 0.25rem; vertical-align: middle; }
.qt-i:focus-visible, .qt-btn:focus-visible, .qt-sp:focus-visible, .qt-reach-head:focus-visible, .qt-close:focus-visible { outline: 3px solid #f2a541; outline-offset: 1px; }

/* ---------- 22-M2 tools stack (chips, bottom-left) ---------- */
.qt-tools {
  position: absolute;
  z-index: 4;
  left: 0.65rem;
  bottom: 1.9rem;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.35rem;
  width: min(22rem, calc(100% - 1.5rem));
  pointer-events: none;
}
.qt-tools > * { pointer-events: auto; }
.qt-chip-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  border: none;
  border-bottom: 1px solid #e7e0d6;
  background: transparent;
  padding: 0.35rem 0.65rem;
  font: 700 0.82rem "Source Sans 3", sans-serif;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.qt-chip-head .qt-chev { margin-left: auto; transition: transform 0.15s; }
.qt-def-line { margin: 0.25rem 0 0.35rem; font-size: 0.72rem; color: var(--muted); line-height: 1.3; }

/* ---------- reach panel ---------- */
.qt-reach {
  position: relative;
  z-index: 4;
  top: auto;
  right: auto;
  width: 100%;
  max-height: min(70vh, 28rem);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  font-size: 0.82rem;
  line-height: 1.3;
}
.qt-reach-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border: none;
  border-bottom: 1px solid #e7e0d6;
  background: transparent;
  padding: 0.4rem 0.7rem;
  font: 700 0.8rem "Source Sans 3", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
}
.qt-reach-head .qt-reach-mini { font-size: 1.05rem; color: var(--accent); letter-spacing: 0; display: none; }
.qt-reach-head .qt-chev { margin-left: auto; transition: transform 0.15s; }
.qt-reach.collapsed .qt-chev { transform: rotate(-90deg); }
.qt-reach.collapsed .qt-reach-mini { display: inline; }
.qt-reach.collapsed .qt-reach-body { display: none; }
.qt-reach-body { padding: 0.45rem 0.75rem 0.65rem; }
.qt-net-label { font-weight: 600; color: var(--ink); margin-bottom: 0.3rem; font-size: 0.78rem; }
.qt-headline { display: flex; align-items: flex-start; gap: 0.5rem; }
.qt-big { font: 700 2.1rem/1 "Fraunces", Georgia, serif; color: var(--accent); }
.qt-head-text { flex: 1; font-size: 0.82rem; }
.qt-sub { margin: 0.3rem 0 0.45rem; color: var(--muted); font-size: 0.8rem; }
.qt-sub b { color: var(--ink); }
.qt-stack { display: flex; height: 0.95rem; background: #e9e4da; border-radius: 3px; overflow: hidden; border: 1px solid #d3cbbd; }
.qt-stack .seg { display: block; height: 100%; transition: width 0.5s ease; }
.seg.walk, .sw.walk { background: #0b6e4f; }
.seg.cycle, .sw.cycle { background: #7fb7d6; background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.55) 0 3px, transparent 3px 6px); }
.seg.bus, .sw.bus { background: #d98e04; }
.qt-legend { list-style: none; margin: 0.35rem 0 0.4rem; padding: 0; }
.qt-legend li { display: flex; gap: 0.4rem; align-items: flex-start; margin: 0.15rem 0; font-size: 0.78rem; }
.qt-legend .sw { width: 0.8rem; height: 0.8rem; border-radius: 2px; margin-top: 0.15rem; flex: 0 0 auto; border: 1px solid rgba(0, 0, 0, 0.15); }
.qt-legend em { color: var(--muted); font-style: normal; font-size: 0.72rem; }
.qt-legend .tot { color: var(--muted); border-top: 1px solid #e7e0d6; padding-top: 0.25rem; margin-top: 0.3rem; }
.qt-legend .tot b { color: var(--ink); }
.qt-h4 { margin: 0.5rem 0 0.25rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.qt-bar { margin: 0.25rem 0; }
.qt-bar-top { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.76rem; }
.qt-bar-top b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.qt-bar-track { height: 0.45rem; background: #e9e4da; border-radius: 2px; overflow: hidden; }
.qt-bar-track i { display: block; height: 100%; background: var(--accent); transition: width 0.5s ease; }
.qt-def { background: #f4efe5; border-left: 3px solid #1d4e89; padding: 0.4rem 0.6rem; margin: 0.45rem 0; font-size: 0.76rem; }
.qt-def p { margin: 0.3rem 0; }
.qt-def ol { margin: 0.25rem 0; padding-left: 1.1rem; }
.qt-foot { margin-top: 0.5rem; font-size: 0.7rem; color: var(--muted); }

/* ---------- time machine ---------- */
.qt-tm {
  position: relative;
  z-index: 4;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  padding: 0;
  font-size: 0.82rem;
}
.qt-tm.collapsed .qt-tm-body { display: none; }
.qt-tm.collapsed .qt-chip-head .qt-chev { transform: rotate(-90deg); }
.qt-tm-body { padding: 0.45rem 0.8rem 0.5rem; }
.qt-tm-row { display: flex; align-items: center; gap: 0.75rem; }
.qt-tm-slider { flex: 1; min-width: 10rem; }
.qt-tm-slider input[type="range"] { width: 100%; margin: 0; accent-color: var(--accent); height: 1.6rem; }
.qt-tm-ticks { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); margin-top: -0.15rem; padding: 0 0.3rem; font-variant-numeric: tabular-nums; }
/* NOTES_33-8: growth pattern on its own full-width row under the year slider */
.qt-gv { display: flex; flex-direction: column; width: 100%; margin-top: 0.35rem; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); gap: 0.1rem; box-sizing: border-box; }
.qt-gv select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  font: 600 0.8rem "Source Sans 3", sans-serif;
  text-transform: none;
  letter-spacing: 0;
  padding: 0.2rem 0.35rem;
  border: 1px solid #8798a8;
  background: #fff;
  color: var(--ink);
  text-overflow: ellipsis;
}
.qt-tm-caption { margin-top: 0.3rem; font-size: 0.85rem; }
.qt-hash-notice { margin-top: 0.35rem; padding: 0.35rem 0.45rem; font-size: 0.78rem; line-height: 1.35; color: #5a3400; background: #fff4e0; border: 1px solid #e8c88a; border-radius: 3px; }
.qt-hash-notice p { margin: 0; }
.qt-hash-notice p + p { margin-top: 0.25rem; }
.qt-tm-caption .qt-sc { color: #7f1d1d; font-size: 0.78rem; }
.qt-tm-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem 0.8rem; margin-top: 0.25rem; font-size: 0.74rem; }
.qt-prov { color: #8a4b08; background: #f8ead7; border: 1px solid #e3c79d; padding: 0.05rem 0.35rem; border-radius: 3px; font-weight: 600; }
.qt-prov .qt-prov-short { display: none; }
.qt-chk { display: inline-flex; align-items: center; gap: 0.25rem; cursor: pointer; }
.qt-tm-info { margin-top: 0.35rem; padding: 0.4rem 0.6rem; background: #f4efe5; border-left: 3px solid #8a4b08; font-size: 0.76rem; max-height: 11rem; overflow: auto; }
.qt-tm-info p { margin: 0.25rem 0; }
.qt-hex-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
.qt-hex-legend i { display: inline-block; width: 0.9rem; height: 0.9rem; border: 1px solid rgba(0, 0, 0, 0.2); }

/* REVIEW_NOTES_27 E-M1: fly control docked in the 22-M2 tools stack (not under the chips) */
#fly-cable.qt-fly-chip {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  top: auto;
  transform: none;
  width: 100%;
  box-sizing: border-box;
  z-index: auto;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  text-align: left;
  min-height: 2.05rem;
  margin: 0;
}
body.has-qt23 .guided-caption:not([hidden]) {
  left: 0.65rem;
  right: auto;
  bottom: calc(var(--qt-tm-h, 3rem) + var(--qt-stack-h, 9rem) + 0.5rem);
  z-index: 5;
  max-width: min(22rem, calc(100% - 1.5rem));
  pointer-events: auto;
}
body.has-qt23 #map .maplibregl-ctrl-bottom-left { bottom: calc(var(--qt-tm-h) + 1.9rem); }
body.has-qt23 #map .maplibregl-ctrl-bottom-right { bottom: 0; }

/* ---------- animation card ---------- */
.qt-anim {
  position: relative;
  z-index: 4;
  left: auto;
  bottom: auto;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  padding: 0;
  font-size: 0.75rem;
}
.qt-anim.collapsed .qt-anim-body { display: none; }
.qt-anim.collapsed .qt-chip-head .qt-chev { transform: rotate(-90deg); }
.qt-anim-body { padding: 0.4rem 0.55rem 0.45rem; }
.qt-anim-row { display: flex; align-items: center; gap: 0.4rem; }
.qt-clock { font: 700 1.1rem "Source Sans 3", sans-serif; font-variant-numeric: tabular-nums; min-width: 3.2rem; }
.qt-speed { margin-left: auto; display: inline-flex; border: 1px solid #1d4e89; border-radius: 3px; overflow: hidden; }
.qt-sp { border: none; background: #f7f3ec; padding: 0.25rem 0.45rem; font: 600 0.78rem "Source Sans 3", sans-serif; cursor: pointer; min-height: 2rem; }
.qt-sp + .qt-sp { border-left: 1px solid #1d4e89; }
.qt-sp.on { background: #1d4e89; color: #fff; }
.qt-anim input[type="range"] { width: 100%; margin: 0.15rem 0 0; accent-color: #1d4e89; }
.qt-anim-count { margin-top: 0.2rem; line-height: 1.3; }
.qt-anim-note { margin-top: 0.2rem; font-size: 0.68rem; color: var(--muted); line-height: 1.25; }

/* ---------- station card ---------- */
.qt-station {
  position: absolute;
  z-index: 6;
  /* NOTES_42-7: sit below the scenario bar so the card never covers Network/Growth/year */
  top: calc(var(--o36-bar-h, 5.5rem) + 0.55rem);
  right: 3.4rem;
  bottom: calc(var(--qt-tm-h) + 2.2rem);
  width: min(22rem, calc(100% - 5rem));
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  font-size: 0.82rem;
  line-height: 1.35;
}
.qt-station[hidden] { display: none; }
body.qt-station-open .qt-reach { display: none; }
.qt-st-head { position: sticky; top: 0; background: #f7f3ec; padding: 0.55rem 2.4rem 0.45rem 0.8rem; border-bottom: 1px solid var(--line); z-index: 1; }
.qt-st-head h3 { margin: 0; font: 700 1.1rem "Fraunces", Georgia, serif; }
.qt-role { font-weight: 600; color: var(--accent); font-size: 0.78rem; }
.qt-stage { color: var(--muted); font-size: 0.74rem; }
.qt-close { position: absolute; top: 0.3rem; right: 0.4rem; width: 2rem; height: 2rem; border: none; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--ink); }
.qt-sec { padding: 0.45rem 0.8rem; border-bottom: 1px solid #e7e0d6; }
.qt-sec h4 { margin: 0 0 0.3rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.qt-sec p { margin: 0.25rem 0; }
.qt-muted { color: var(--muted); font-size: 0.74rem; }
.qt-draft { background: #fde2e2; color: #9d0208; border-radius: 3px; padding: 0 0.3rem; font-size: 0.65rem; letter-spacing: 0.04em; vertical-align: middle; }
.qt-tip { background: #f4efe5; border-left: 3px solid #1d4e89; padding: 0.3rem 0.5rem; margin: 0.3rem 0; font-size: 0.74rem; text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 400; }
.qt-tip[hidden] { display: none; }
.qt-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.qt-table th { text-align: right; font-size: 0.68rem; color: var(--muted); font-weight: 600; }
.qt-table td { padding: 0.12rem 0; border-bottom: 1px dotted #e0d9cc; vertical-align: top; }
.qt-table td + td, .qt-table th + th { text-align: right; padding-left: 0.5rem; font-variant-numeric: tabular-nums; }
.qt-table td + td { white-space: nowrap; }
.qt-list { margin: 0.2rem 0; padding-left: 1.1rem; }
.qt-list em { color: var(--muted); font-style: normal; font-size: 0.72rem; }
.qt-dest { font-size: 0.76rem; }
.qt-render { margin: 0; position: relative; aspect-ratio: 16 / 9; background: #e9e4da; }
.qt-render img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qt-render figcaption, .qt-render.empty small { position: absolute; left: 0; right: 0; bottom: 0; padding: 0.2rem 0.5rem; background: rgba(26, 35, 50, 0.72); color: #fff; font-size: 0.7rem; }
.qt-render.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #a99d89;
  margin: 0.55rem 0.8rem;
  width: auto;
  color: #6b5f4b;
  font: 600 0.9rem "Source Sans 3", sans-serif;
  background: repeating-linear-gradient(45deg, #efe9dc 0 10px, #e9e2d3 10px 20px);
}
.qt-render.empty small { font-weight: 400; }
.qt-chart { width: 100%; max-width: 20rem; height: auto; display: block; }
.qt-chart rect { fill: #9fc5b6; }
.qt-chart rect.on { fill: var(--accent); }
.qt-chart text { font: 600 8px "Source Sans 3", sans-serif; fill: var(--muted); }
.qt-chart text.v { font-size: 7.5px; fill: var(--ink); }
.qt-chart text.on { fill: var(--ink); font-weight: 700; }
.qt-chart-lines .qt-line { stroke-width: 1.4; opacity: 0.55; }
.qt-chart-lines .qt-line-on { stroke-width: 2.6; opacity: 1; }
.qt-chart-lines .qt-line-pf { stroke: #5b7c6e; }
.qt-chart-lines .qt-line-if { stroke: #3d6b8a; }
.qt-chart-lines .qt-line-zb { stroke: #8a6a3d; }
.qt-chart-lines .qt-line-su { stroke: #7a3d5a; }
.qt-leg-row { font-size: 0.8rem; color: var(--muted); margin: 0.25rem 0 0; }
.qt-leg { display: inline-block; margin-right: 0.45rem; font-weight: 600; }
.qt-leg-pf { color: #5b7c6e; }
.qt-leg-if { color: #3d6b8a; }
.qt-leg-zb { color: #8a6a3d; }
.qt-leg-su { color: #7a3d5a; }
.qt-leg-on { text-decoration: underline; color: var(--ink); }
.qt-sources p { font-size: 0.72rem; color: var(--muted); }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  #map { --qt-tm-h: 3.2rem; }
  .qt-tools {
    left: 0.4rem;
    right: 0.4rem;
    width: auto;
    bottom: 1.4rem;
  }
  .qt-tm-row { gap: 0.4rem; }
  .qt-tm-caption { font-size: 0.78rem; }
  .qt-tm-caption .qt-sc { font-size: 0.72rem; }
  .qt-tm-sub .qt-chk, .qt-tm-sub #qt-3d { display: none; }
  .qt-tm-sub .qt-prov { font-size: 0.68rem; white-space: nowrap; max-width: 14rem; } /* 22-P2 */
  .qt-tm-sub .qt-prov .qt-prov-full { display: none; }
  .qt-tm-sub .qt-prov .qt-prov-short { display: inline; }
  .qt-anim-note, .qt-anim-count { display: none; }
  body.has-qt23 .guided-caption:not([hidden]) {
    left: 0.4rem;
    max-width: calc(100% - 0.85rem);
    bottom: calc(var(--qt-tm-h, 3.2rem) + var(--qt-stack-h, 7rem) + 0.35rem);
    font-size: 0.72rem;
  }
  #fly-cable.qt-fly-chip { font-size: 0.78rem; padding: 0.35rem 0.55rem; }
  body.has-qt23 #map .maplibregl-ctrl-bottom-left { bottom: 5.5rem; }
  .qt-station {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 66%;
    border-radius: 12px 12px 0 0;
  }
  .qt-st-head::before { content: ""; display: block; width: 2.6rem; height: 4px; border-radius: 2px; background: #b9b1a2; margin: 0 auto 0.35rem; }
}
@media (max-width: 560px) {
  .qt-big { font-size: 1.8rem; }
}

/* NOTES_33-7: one expandable bar below 600 px; REACH always visible; attribution clear */
.qt-tools-more { display: none; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16); }
.qt-tools-more-body { padding: 0.35rem; display: flex; flex-direction: column; gap: 0.35rem; }
.qt-tools-more.collapsed .qt-tools-more-body { display: none; }
.qt-tools-more.collapsed .qt-chip-head .qt-chev { transform: rotate(-90deg); }
@media (max-width: 600px) {
  .qt-tools.qt-tools-narrow {
    left: 0.4rem;
    right: 0.4rem;
    width: auto;
    bottom: 2.6rem; /* clear MapLibre attribution */
    max-height: min(52vh, 22rem);
    overflow-y: auto;
  }
  .qt-tools.qt-tools-narrow .qt-tools-more { display: block; order: -1; }
  .qt-tools.qt-tools-narrow .qt-reach {
    max-height: min(38vh, 16rem);
  }
  .qt-tools.qt-tools-narrow .qt-reach.collapsed .qt-reach-body {
    /* REACH stays readable on phone even if the chip was collapsed elsewhere */
    display: block;
  }
  body.has-qt23 #map .maplibregl-ctrl-bottom-left { bottom: 2.4rem; }
  body.has-qt23 #map .maplibregl-ctrl-attrib {
    margin-bottom: 0.15rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .qt-stack .seg, .qt-bar-track i, .qt-reach-head .qt-chev { transition: none; }
}

/* REVIEW_NOTES_27 S27-13 / S27-18 */
.qt-chk[hidden] { display: none; }
.qt-chk select { font: inherit; font-size: 0.75rem; padding: 0.1rem 0.2rem; }
#qt-3d.on { background: #0b3d3a; color: #fff; border-color: #0b3d3a; }
#qt-3d:disabled { opacity: 0.55; cursor: not-allowed; }
.qt-newhomes-entry { margin-bottom: 0.25rem; }
.qt-newhomes-entry .qt-hex-legend { font-size: 0.72rem; margin: 0.15rem 0 0.35rem 1.4rem; color: #334155; }
.qt-newhomes-entry .qt-hex-legend[hidden] { display: none; }
