/* Structural wrappers: on desktop they disappear so existing flex toolbars
   keep working. html.cz-phone overrides these to a designed bar. */
.tb-bar,.tb-filters,.tb-actions{display:contents}
.tb-phone-only{display:none}

/* Phone chrome. Activated by html.cz-phone (see cz-phone.js).
   Desktop is untouched: these rules do not apply without that class. */

html.cz-phone{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  overflow-x:hidden;
  max-width:100%;
}
html.cz-phone body{
  overflow-x:hidden;
  max-width:100vw;
  font-size:16px!important;
}

/* ── Toolbar: title + refresh (+ weather). Never wrap, never leftover ── */
html.cz-phone .toolbar{
  display:flex;
  flex-direction:column;
  flex-wrap:nowrap;
  align-items:stretch;
  gap:0;
  padding:0;
  min-height:48px;
  height:auto;
  max-width:100vw;
  padding-left:env(safe-area-inset-left);
  padding-right:env(safe-area-inset-right);
}
html.cz-phone .tb-bar{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  height:48px;
  padding:0 12px;
  gap:10px;
  width:100%;
  box-sizing:border-box;
}
html.cz-phone .tb-bar .tb-left,
html.cz-phone .toolbar > .tb-left{
  display:flex;
  align-items:center;
  min-width:0;
  width:auto;
  flex:1;
  gap:8px;
}
html.cz-phone .toolbar h1,
html.cz-phone .tb-bar h1{
  font-size:17px!important;
  font-weight:600;
  letter-spacing:-0.022em;
  line-height:1;
  color:#f5f5f7;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  margin:0;
}
html.cz-phone .toolbar .spacer,
html.cz-phone .toolbar .sub,
html.cz-phone .nav-links,
html.cz-phone .last-upd-label,
html.cz-phone .last-upd,
html.cz-phone .tb-desk,
html.cz-phone .tb-aa-lbl,
html.cz-phone .tb-right > span,
html.cz-phone .refresh-dot,
html.cz-phone #fsSelect,
html.cz-phone .tb-fs,
html.cz-phone .toolbar button.m-hide,
html.cz-phone .m-hide{display:none!important}
html.cz-phone .tb-phone-only{
  display:inline-flex!important;
  align-items:center;
  justify-content:center;
}

html.cz-phone .tb-actions,
html.cz-phone .toolbar > .tb-right{
  display:flex!important;
  flex-wrap:nowrap;
  align-items:center;
  justify-content:flex-end;
  gap:6px;
  width:auto;
  flex:0 0 auto;
  min-width:0;
}
html.cz-phone #tzClock{display:none!important}

html.cz-phone #refreshBtn,
html.cz-phone .wx-tb-btn,
html.cz-phone #solWxBtn,
html.cz-phone #viewToggle,
html.cz-phone .tb-actions > .tb-phone-only{
  display:inline-flex!important;
  align-items:center;
  justify-content:center;
  height:36px;
  min-height:36px;
  min-width:36px;
  padding:0 10px;
  margin:0;
  border-radius:8px;
  font-size:17px;
  line-height:1;
  flex-shrink:0;
  color:#e5e7eb;
  background:#1a1a28;
  border:1px solid #333;
  visibility:visible!important;
  opacity:1!important;
}

/* Second row: filters. Date | train, then Load on its own full-width row. */
html.cz-phone .tb-filters.tb-filters-single{grid-template-columns:1fr}
html.cz-phone .tb-filters.tb-filters-solari{grid-template-columns:1fr 1fr 1fr}
html.cz-phone .tb-filters{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  align-items:center;
  width:100%;
  box-sizing:border-box;
  padding:0 12px 10px;
  min-height:44px;
}
html.cz-phone .tb-filters .nav-links,
html.cz-phone .tb-filters > input[type="hidden"]{display:none!important}
html.cz-phone .tb-filters label{
  display:flex;
  margin:0;
  min-width:0;
}
html.cz-phone .tb-filters label select,
html.cz-phone .tb-filters select,
html.cz-phone .tb-filters .cal-wrap,
html.cz-phone .tb-filters .cal-btn{
  width:100%;
  min-width:0;
  height:44px;
  min-height:44px;
  font-size:16px;
  border-radius:8px;
}
html.cz-phone .tb-filters > button:not(.tb-desk){
  grid-column:1 / -1;
  width:100%;
  height:44px;
  min-height:44px;
  padding:0 16px;
  font-size:16px;
  font-weight:600;
  border-radius:8px;
  white-space:nowrap;
  color:#f5f5f7;
  background:#1a1a2e;
  border:1px solid #3f3f46;
}

/* Index: no filter row. Title + ⟳ + ⚠️ on one bar. */
html.cz-phone body > .toolbar{
  flex-direction:row;
  flex-wrap:nowrap;
  height:48px;
  padding:0 12px;
  gap:10px;
  align-items:center;
}
html.cz-phone .tb-filters + .tb-bar,
html.cz-phone .toolbar:has(.tb-filters){
  flex-direction:column;
  height:auto;
  padding:0;
}
html.cz-phone .toolbar:has(.tb-filters){
  padding-left:env(safe-area-inset-left);
  padding-right:env(safe-area-inset-right);
}
html.cz-phone .toolbar:has(.tb-filters) .tb-bar{
  padding-left:12px;
  padding-right:12px;
}

/* ── Bottom nav: four destinations, always all visible ── */
html.cz-phone .m-nav{
  display:block;
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  width:100%!important;
  max-width:100%!important;
  overflow:hidden;
  background:rgba(8,8,16,0.94);
  -webkit-backdrop-filter:blur(20px);
  backdrop-filter:blur(20px);
  border-top:0.5px solid rgba(255,255,255,0.12);
  padding:4px 0 max(4px,env(safe-area-inset-bottom));
  z-index:9999;
}
html.cz-phone .m-nav-inner{
  width:100%!important;
  max-width:100%!important;
  margin:0 auto!important;
  padding:0!important;
  box-sizing:border-box!important;
  display:grid!important;
  grid-template-columns:repeat(4,minmax(0,1fr))!important;
  align-items:stretch;
}
html.cz-phone .m-nav-btn{
  min-height:44px;
  min-width:0!important;
  width:auto!important;
  max-width:none!important;
  padding:4px 0 2px!important;
  gap:2px;
  font-size:11px;
  font-weight:500;
  letter-spacing:0.02em;
  color:#8e8e93;
  border-radius:8px;
  overflow:visible;
  display:flex!important;
}
html.cz-phone .m-nav-btn .m-nav-icon{font-size:20px;line-height:1.1}
html.cz-phone .m-nav-btn.active{color:#60a5fa;background:transparent}
html.cz-phone body{
  padding-bottom:calc(54px + env(safe-area-inset-bottom));
}

/* ── Live trains: stacked full-width rows, never a clipped carousel ── */
html.cz-phone body:has(#tsumm):not(.mode-kiosk):not(.mode-display):not(.mode-conductor):not(.map-fullscreen){
  display:flex;
  flex-direction:column;
}
html.cz-phone .toolbar{order:1}
html.cz-phone .map-wrap{order:2}
html.cz-phone .tabs{order:3}
html.cz-phone #tsumm{order:4}
html.cz-phone .status-line{order:5}
html.cz-phone .data{order:6}
html.cz-phone .tdetail{order:7}
html.cz-phone #otpSection{order:8}
html.cz-phone .alerts-panel{order:9}
html.cz-phone .hist-panel{order:10}
html.cz-phone .foot{order:11}
html.cz-phone .m-nav{order:20}

html.cz-phone #tsumm,
html.cz-phone .tsumm{
  display:flex!important;
  flex-direction:column!important;
  flex-wrap:nowrap!important;
  align-items:stretch!important;
  justify-content:flex-start!important;
  width:100%;
  max-width:100%;
  box-sizing:border-box;
  padding:8px 10px!important;
  gap:6px!important;
  overflow:visible;
}
html.cz-phone #tsumm .tsumm-card,
html.cz-phone .tsumm-card{
  flex:0 0 auto!important;
  min-width:100%!important;
  width:100%!important;
  max-width:100%!important;
  box-sizing:border-box;
  padding:8px 12px!important;
  border-radius:12px;
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1fr);
  gap:2px 8px;
  align-items:center;
}
html.cz-phone .tsumm-hdr{
  grid-column:1 / -1;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:6px;
  margin:0;
  min-width:0;
}
html.cz-phone .tsumm-num{
  font-size:20px!important;
  font-weight:800;
  letter-spacing:-0.03em;
  line-height:1.1;
  flex-shrink:0;
}
html.cz-phone .tsumm-dir{
  font-size:0!important;
  letter-spacing:0;
  padding:3px 6px;
  border-radius:4px;
  flex-shrink:0;
  line-height:1;
}
html.cz-phone .tsumm-dir.wb::after,
html.cz-phone .tsumm-dir.eb::after{
  font-size:11px;
  font-weight:700;
  letter-spacing:0.06em;
}
html.cz-phone .tsumm-dir.wb::after{content:"WB";color:#60a5fa}
html.cz-phone .tsumm-dir.eb::after{content:"EB";color:#c084fc}
html.cz-phone .tsumm-spd{
  font-size:12px!important;
  color:#888;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  min-width:0;
}
html.cz-phone .tsumm-del{
  flex:1 1 100%;
  margin-left:0;
  font-size:14px!important;
  font-weight:700;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:100%;
  text-align:left;
}
html.cz-phone .tsumm-state,
html.cz-phone .tsumm-card > div:not([class]){
  grid-column:1 / -1;
  font-size:13px!important;
  color:#ccc!important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  margin:0!important;
}
html.cz-phone .wpe-banner{grid-column:1 / -1}
html.cz-phone .tsumm-loc,
html.cz-phone .tsumm-nxt,
html.cz-phone .tsumm-nodata{
  grid-column:1 / -1;
  display:flex;
  align-items:center;
  gap:4px;
  padding:0;
  border:0;
  margin:0;
  min-width:0;
}
html.cz-phone .tsumm-loc .pin{flex-shrink:0;font-size:12px}
html.cz-phone .tsumm-loc .sub{
  font-size:13px!important;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  min-width:0;
}
html.cz-phone .tsumm-loc .mp{
  font-size:13px!important;
  flex-shrink:0;
  white-space:nowrap;
}
html.cz-phone .tsumm-nxt .arr{font-size:11px!important;flex-shrink:0}
html.cz-phone .tsumm-nxt .nm{
  font-size:14px!important;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  min-width:0;
}
html.cz-phone .tsumm-nxt .dst{
  font-size:13px!important;
  font-weight:600;
  flex-shrink:0;
  white-space:nowrap;
}
html.cz-phone .tsumm-alerts-compact{
  grid-column:1 / -1;
  margin-top:2px;
  padding-top:4px;
}
html.cz-phone .tsumm-alerts-latest .al-text{
  font-size:13px!important;
}
html.cz-phone .tsumm-alerts-badge{font-size:12px!important}

html.cz-phone .info-val{font-size:18px!important}
html.cz-phone .info-lbl{font-size:11px!important}
html.cz-phone .info-sub{font-size:12px!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
html.cz-phone .info-row{
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  padding:8px 10px!important;
  gap:8px!important;
}
html.cz-phone .hero-num{font-size:40px!important}
html.cz-phone .hero-name{font-size:17px!important}
html.cz-phone .hero-route{font-size:14px!important}
html.cz-phone .hero-pill .delay-num{font-size:28px!important}
html.cz-phone .stn-name,
html.cz-phone .stn-info .stn-name{font-size:16px!important}
html.cz-phone .list-hdr{flex-wrap:wrap!important;gap:4px}
html.cz-phone .list-hdr h3{font-size:13px!important}
html.cz-phone .list-hdr .count{font-size:12px!important;white-space:normal!important;max-width:100%;overflow:visible}

/* History stats: 2×N, never a clipped strip */
html.cz-phone .stats-row{
  display:grid!important;
  grid-template-columns:repeat(2,minmax(0,1fr))!important;
  gap:8px!important;
  width:100%;
  box-sizing:border-box;
}
html.cz-phone .stat{
  min-width:0!important;
  width:auto!important;
  padding:8px 10px!important;
}
html.cz-phone .stat .value{
  font-size:16px!important;
  font-weight:700;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
html.cz-phone .stat .label{font-size:11px!important}

/* ── Elevation: tall enough to use with a thumb ── */
html.cz-phone #elevCanvas,
html.cz-phone .elev-canvas{
  height:168px!important;
  min-height:168px!important;
}
html.cz-phone #speedCanvas{height:72px}

/* ── History / station: cards instead of sideways tables ── */
.ping-list{display:none}
html.cz-phone .ping-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:4px 0 12px;
}
html.cz-phone #locationTable,
html.cz-phone .hist-tbl{
  display:none;
}
html.cz-phone .scroll-tbl,
html.cz-phone .hist-table-wrap{max-height:none;overflow:visible}
.ping-card{
  display:none;
  text-align:left;
  width:100%;
  background:#0c0c14;
  border:1px solid #1c1c28;
  border-radius:12px;
  padding:12px 14px;
  color:inherit;
  font:inherit;
  cursor:pointer;
  -webkit-tap-highlight-color:transparent;
}
html.cz-phone .ping-card{display:block}
.ping-card .ping-top{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
}
.ping-card .ping-time{
  font-size:16px;
  font-weight:600;
  font-variant-numeric:tabular-nums;
  color:#f5f5f7;
}
.ping-card .ping-spd{
  font-size:16px;
  font-weight:600;
  font-variant-numeric:tabular-nums;
  white-space:nowrap;
}
.ping-card .ping-status{
  margin-top:4px;
  font-size:15px;
  font-weight:600;
}
.ping-card .ping-meta{
  margin-top:4px;
  font-size:13px;
  color:#a1a1aa;
  line-height:1.35;
}
.ping-card.interp-row{opacity:0.55}
.ping-card.station-row{border-left:3px solid #f59e0b}
.ping-card.active-row,
html.cz-phone .ping-card.active-row{
  background:#0c1e3a;
  border-color:#1e3a5f;
}

/* ── Tabs / filters: 44px, no smash ── */
html.cz-phone .tabs{
  flex-wrap:nowrap;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
  padding:4px 8px;
}
html.cz-phone .tabs::-webkit-scrollbar{display:none}
html.cz-phone .tab{
  min-height:40px;
  padding:8px 12px;
  font-size:13px;
  flex-shrink:0;
}
html.cz-phone .filters button{
  min-height:40px;
  font-size:15px;
  padding:8px 14px;
}
html.cz-phone #stnSelect{
  height:44px;
  font-size:16px;
  min-width:0;
  flex:1;
}

/* Map overlay buttons */
html.cz-phone .map-ctrl button,
html.cz-phone .hist-map-ctrl button{
  min-height:36px;
  min-width:36px;
  font-size:13px;
  border-radius:8px;
}
html.cz-phone .leaflet-control-zoom a{
  width:36px!important;
  height:36px!important;
  line-height:36px!important;
}
html.cz-phone .leaflet-control-zoom{margin-bottom:8px!important}

/* Live trains: thin map peek, pull the sheet handle to expand or collapse */
html.cz-phone body:has(#tsumm) .map-wrap{
  height:var(--cz-phone-map-h,148px)!important;
  min-height:104px;
  flex:0 0 auto;
  width:100%;
  max-width:100%!important;
  margin:0!important;
  border:none!important;
  border-radius:0!important;
  box-shadow:none;
  overflow:hidden;
}
html.cz-phone body:has(#tsumm) .map-wrap.cz-map-ready:not(.is-dragging){
  transition:height 0.32s cubic-bezier(0.2,0.8,0.2,1);
}
html.cz-phone body:has(#tsumm) .map-drag-hint,
html.cz-phone body:has(#tsumm) #cockpit{display:none!important}
html.cz-phone body:has(#tsumm) .map-ctrl{
  top:8px;
  right:8px;
  bottom:auto;
  left:auto;
  max-width:calc(100% - 56px);
}
html.cz-phone body:has(#tsumm) .leaflet-bottom{
  margin-bottom:28px;
}
html.cz-phone body:has(#tsumm) .map-resize{
  display:block!important;
  position:absolute;
  left:0;right:0;bottom:0;
  height:44px;
  z-index:1200;
  cursor:ns-resize;
  touch-action:none;
  background:transparent;
}
html.cz-phone body:has(#tsumm) .map-resize::after{
  content:"";
  position:absolute;
  left:0;right:0;bottom:0;
  height:28px;
  background:#000;
  border-radius:16px 16px 0 0;
  box-shadow:0 -10px 28px rgba(0,0,0,0.42),inset 0 1px 0 rgba(255,255,255,0.08);
  pointer-events:none;
}
html.cz-phone body:has(#tsumm) .map-resize::before{
  content:"";
  position:absolute;
  left:50%;
  bottom:14px;
  width:40px;
  height:5px;
  margin-left:-20px;
  border-radius:99px;
  background:rgba(255,255,255,0.34);
  box-shadow:0 1px 2px rgba(0,0,0,0.35);
  z-index:1;
}
html.cz-phone body:has(#tsumm) .map-resize:active::before{
  background:rgba(255,255,255,0.62);
  width:48px;
  margin-left:-24px;
}
html.cz-phone body.map-fullscreen .map-resize{display:none!important}
html.cz-phone body:has(#tsumm) .tabs{
  background:#000;
  border-top:none;
  padding-top:2px;
}
