/* Track Mechanics V38.81.134 — full-route responsive hardening
   Purpose: eliminate tablet/small-laptop text and layout overrun without changing
   application behavior. This file is intentionally loaded last. */

:root{
  --tm134-compact:360px;
  --tm134-phone:599px;
  --tm134-tablet:899px;
  --tm134-laptop:1179px;
  --tm134-desktop:1180px;
}

/* ---------- universal containment / readable text ---------- */
html,body,#app,.app-shell,.main-shell,#main,.page,.experience-page{max-width:100%;min-width:0;}
body{overflow-x:hidden;}
main,section,article,aside,header,footer,nav,form,fieldset,details,summary,div{min-width:0;}
img,video,canvas,iframe,svg{max-width:100%;}
input,select,textarea,button{max-width:100%;min-width:0;}

/* Ordinary copy should wrap. Deliberately tabular/measurement values are exempt below. */
:where(.page,.experience-page,.tm-dashboard-page,.tm-performance-shell,.tm-practice-workspace,.tm-tool-category-list,
       .team-page,.athlete-page,.results-page,.standards-page,.report-page,.settings-page,.user-guide-page,
       .tm-tryouts,.field-qualification-page,.practice-mesh-page,.performance-proof-page)
:where(h1,h2,h3,h4,p,li,dd,dt,label,summary,button,a,span,strong,small,th,td){
  overflow-wrap:anywhere;
  word-break:normal;
}

:where(.timer-clock,.timer-display,.recorded-mark,.result-mark,.tm-standard-mark,.standards-athlete-mark,
       .standards-current-mark,.proof-mark,.mesh-stopwatch strong,.tm-performance-table-row strong,
       .tm-performance-row>b,.result-session-head>span){
  overflow-wrap:normal;
  word-break:normal;
}

/* Flex/grid children are allowed to shrink; this is the most common source of desktop/tablet overrun. */
:where(.section-head,.actions,.tm-panel-head,.tm-priority-card,.tm-performance-title,.tm-practice-header,
       .experience-section-heading,.experience-team-head,.experience-recent-row,.location-map-card>summary,
       .mesh-station-row,.mesh-task-row,.proof-result-card,.guide-section-head,.analytics-heading,
       .continuity-banner,.runtime-qualification-heading,.runtime-manual-heading,.settings-public-heading)>*{
  min-width:0;
  max-width:100%;
}

:where(.section-head,.actions,.tm-panel-head,.experience-section-heading,.experience-team-head,
       .guide-section-head,.analytics-heading){flex-wrap:wrap;}

/* Tables and code-like evidence scroll locally instead of widening the whole page. */
:where(.table-wrap,.results-table-wrap,.tm-tryouts-table-wrap,.report-preview,.runtime-ledger,
       .qualification-ledger,.public-source-ledger,.board-ledger,.tm-results-evidence-body){
  max-width:100%;
  overflow-x:auto;
  overscroll-behavior-inline:contain;
}
:where(table){max-width:100%;}
:where(pre,code,.proof-fingerprint){max-width:100%;overflow-wrap:anywhere;word-break:break-word;}

/* ---------- approved shell: postpone desktop rail until it genuinely fits ---------- */
@media (max-width:1179px){
  .tm-approved-shell.app-shell{display:block!important;padding-bottom:calc(68px + env(safe-area-inset-bottom,0px))!important;}
  .tm-approved-rail{display:none!important;}
  .main-shell{width:100%!important;margin:0!important;}
  .tm-approved-topbar{padding:6px clamp(12px,2.4vw,22px)!important;min-height:60px!important;}
  .tm-desktop-context,.tm-sync-chip{display:none!important;}
  .tm-global-search{width:40px!important;height:40px!important;border:0!important;background:transparent!important;padding:0!important;display:grid!important;place-items:center!important;}
  .tm-global-search span,.tm-global-search kbd{display:none!important;}
  .tm-global-search svg{width:20px!important;height:20px!important;}
  .tm-profile-button{display:none!important;}
  .tm-approved-bottom-nav{position:fixed!important;left:0!important;right:0!important;bottom:0!important;z-index:60!important;display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr))!important;}
  #main{padding:clamp(18px,2.7vw,30px) clamp(16px,3vw,30px) calc(96px + env(safe-area-inset-bottom,0px))!important;}
}

@media (min-width:1180px){
  .tm-approved-shell.app-shell{display:grid!important;grid-template-columns:224px minmax(0,1fr)!important;padding-bottom:0!important;}
  .tm-approved-rail{width:224px!important;display:flex!important;flex-direction:column!important;position:fixed!important;inset:0 auto 0 0!important;z-index:40!important;}
  .main-shell{grid-column:2!important;min-width:0!important;width:auto!important;}
  .tm-approved-bottom-nav{display:none!important;}
  .tm-mobile-brand-text{display:none!important;}
  #main{padding:30px clamp(24px,2.7vw,38px) 92px!important;}
  .tm-approved-brand strong{font-size:.78rem!important;letter-spacing:.09em!important;white-space:normal!important;line-height:1.08!important;}
  .tm-approved-brand small{font-size:.53rem!important;letter-spacing:.12em!important;white-space:normal!important;line-height:1.2!important;}
  .tm-approved-brand>span:last-child{max-width:138px!important;}
}

@media (min-width:1480px){
  .tm-approved-shell.app-shell{grid-template-columns:236px minmax(0,1fr)!important;}
  .tm-approved-rail{width:236px!important;}
  #main{max-width:1280px!important;padding-inline:40px!important;}
}

/* ---------- redesigned primary screens ---------- */
.tm-dashboard-columns,.tm-dashboard-columns-priority,.tm-practice-workspace,.tm-performance-grid,
.tm-tool-chip-row,.tm-metric-strip,.tm-hero-status-row{min-width:0;}
.tm-priority-card,.tm-next-action-card,.tm-capture-primary,.tm-upcoming-row,.tm-performance-table-row,
.tm-tool-chip,.tm-tool-category>summary{min-width:0;}
.tm-priority-card>*,.tm-next-action-card>*,.tm-capture-primary>*,.tm-upcoming-row>*,
.tm-performance-table-row>*,.tm-tool-chip>*,.tm-tool-category>summary>*{min-width:0;max-width:100%;}

/* Long names/statuses should wrap on mid-size displays instead of disappearing under ellipsis. */
@media (min-width:600px) and (max-width:1279px){
  .tm-hero-status-row span,.tm-upcoming-row strong,.tm-metric-strip span,.tm-event-mix-row>span,
  .tm-tool-chip small,.tm-tool-category-copy small{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;}
  .tm-dashboard-columns,.tm-dashboard-columns-priority{grid-template-columns:1fr!important;}
  .tm-practice-workspace,.tm-performance-grid{grid-template-columns:1fr!important;}
  .tm-practice-header{align-items:flex-start!important;flex-direction:column!important;}
  .tm-practice-progress{width:100%!important;min-width:0!important;justify-content:flex-start!important;flex-wrap:wrap!important;}
  .tm-practice-progress i{flex:1 1 20px!important;max-width:72px!important;}
  .tm-performance-title{align-items:flex-start!important;flex-direction:column!important;}
  .tm-performance-actions{width:100%!important;flex-wrap:wrap!important;}
  .tm-results-tabs{max-width:100%!important;overflow-x:auto!important;scrollbar-width:thin!important;}
  .tm-results-tabs a,.tm-results-tabs button{flex:0 0 auto!important;white-space:nowrap!important;}
}

@media (min-width:600px) and (max-width:899px){
  .tm-hero-status-row{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .tm-hero-status-row button:last-child:nth-child(odd){grid-column:1/-1!important;}
  .tm-metric-strip{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .tm-metric-strip article:nth-child(2n){border-right:0!important;}
  .tm-metric-strip article:nth-child(-n+2){border-bottom:1px solid #edf0f3!important;}
  .tm-tool-chip-row{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .tm-performance-table-head{display:none!important;}
  .tm-performance-table-row{grid-template-columns:minmax(0,1fr) auto 18px!important;grid-template-areas:"athlete result arrow" "event date arrow"!important;gap:3px 12px!important;}
  .tm-performance-table-row span:first-child{grid-area:athlete!important;font-weight:750!important;}
  .tm-performance-table-row span:nth-child(2){grid-area:event!important;color:#748294!important;}
  .tm-performance-table-row strong{grid-area:result!important;text-align:right!important;}
  .tm-performance-table-row small{grid-area:date!important;text-align:right!important;}
  .tm-performance-table-row b{grid-area:arrow!important;align-self:center!important;}
}

@media (min-width:900px) and (max-width:1279px){
  .tm-hero-status-row{grid-template-columns:repeat(3,minmax(0,1fr))!important;max-width:none!important;}
  .tm-metric-strip{grid-template-columns:repeat(4,minmax(0,1fr))!important;}
  .tm-tool-chip-row{grid-template-columns:repeat(3,minmax(0,1fr))!important;}
}

@media (min-width:1280px){
  .tm-dashboard-columns{grid-template-columns:minmax(0,1.45fr) minmax(280px,.85fr)!important;}
  .tm-dashboard-columns-priority{grid-template-columns:minmax(0,1.65fr) minmax(280px,.8fr)!important;}
  .tm-practice-workspace{grid-template-columns:minmax(0,1.25fr) minmax(320px,.9fr)!important;}
  .tm-performance-grid{grid-template-columns:minmax(0,1.65fr) minmax(270px,.72fr)!important;}
}

/* ---------- generic mid-size hardening for every routed legacy screen ---------- */
@media (min-width:600px) and (max-width:1179px){
  /* Two-pane screens become one coherent reading column before their fixed side rails can squeeze text. */
  .work-choice,.home-grid,.split-layout,.command-grid,.log-choice,.timer-setup-layout,.timer-ready-stage,
  .gate-entry-grid,.gate-running-layout,.gate-ready-stage,.video-source-composer,.video-entry-focus,
  .video-capture-instrument,.video-review-layout,.video-analysis-workbench,.video-evidence-summary,
  .dossier-opening,.readiness-ledger,.research-notebook,.support-two-column,.plan-overview,.protocol-boundary,
  .new-group-composition,.group-room,.run-start,.notification-delivery-boundary,.notification-ledger-layout,
  .about-proposition,.roster-import-layout,.readiness-evidence-gate,.active-plan-handoff,.revision-bench-context,
  .public-standard-hero,.public-reading-desk,.weather-permission-boundary,.quote-provenance-pair,
  .settings-public-heading,.continuity-workbench,.qualification-gate-heading,.runtime-qualification-heading,
  .runtime-manual-heading,.build17-source-proof,.team-invite-result,.board-hero,.quote-center-controls,
  .report-builder,.guide-start-card,.mesh-invite-grid,.qualification-camera,
  #practice-plan .practice-stage-content,#practice-run .practice-stage-content,#practice-review .practice-stage-content{
    grid-template-columns:minmax(0,1fr)!important;
  }

  /* Dense ledgers use two stages at tablet/laptop widths, then collapse further on phones. */
  .run-live-metrics{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .run-live-metrics>*:last-child:nth-child(odd){grid-column:1/-1!important;}
  .season-map article,.report-ledger article,.public-source-ledger article,.capability-ledger article,
  .qualification-ledger article,.runtime-auto-ledger article,.runtime-imported-ledger article,
  .cancel-report-row{grid-template-columns:minmax(0,1fr) minmax(160px,.55fr)!important;align-items:start!important;}
  .season-map article>*:nth-child(n+3),.report-ledger article>*:nth-child(n+3),
  .public-source-ledger article>*:nth-child(n+3),.capability-ledger article>*:nth-child(n+3),
  .qualification-ledger article>*:nth-child(n+3),.runtime-auto-ledger article>*:nth-child(n+3),
  .runtime-imported-ledger article>*:nth-child(n+3),.cancel-report-row>*:nth-child(n+3){grid-column:1/-1!important;}

  .runtime-environment-form,.runtime-manual-ledger fieldset{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .runtime-manual-ledger fieldset>*:last-child:nth-child(odd){grid-column:1/-1!important;}
  .experience-filter-bar,.standards-filter-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .standards-athlete-picker{grid-template-columns:minmax(180px,.7fr) minmax(0,1.3fr)!important;}
  .guide-toc{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
}

@media (max-width:760px){
  .work-choice,.home-grid,.split-layout,.command-grid,.log-choice,.timer-setup-layout,.timer-ready-stage,
  .gate-entry-grid,.gate-running-layout,.gate-ready-stage,.video-source-composer,.video-entry-focus,
  .video-capture-instrument,.video-review-layout,.video-analysis-workbench,.video-evidence-summary,
  .dossier-opening,.readiness-ledger,.research-notebook,.support-two-column,.plan-overview,.protocol-boundary,
  .new-group-composition,.group-room,.run-start,.notification-delivery-boundary,.notification-ledger-layout,
  .about-proposition,.roster-import-layout,.readiness-evidence-gate,.active-plan-handoff,.revision-bench-context,
  .public-standard-hero,.public-reading-desk,.weather-permission-boundary,.quote-provenance-pair,
  .settings-public-heading,.continuity-workbench,.qualification-gate-heading,.runtime-qualification-heading,
  .runtime-manual-heading,.build17-source-proof,.team-invite-result,.board-hero,.quote-center-controls,
  .report-builder,.guide-start-card,.mesh-invite-grid,.qualification-camera,
  .run-live-metrics,.season-map article,.report-ledger article,.public-source-ledger article,
  .capability-ledger article,.qualification-ledger article,.runtime-auto-ledger article,
  .runtime-imported-ledger article,.cancel-report-row,.runtime-environment-form,.runtime-manual-ledger fieldset,
  .experience-filter-bar,.standards-filter-grid,.standards-athlete-picker{
    grid-template-columns:minmax(0,1fr)!important;
  }
  :where(.season-map article,.report-ledger article,.public-source-ledger article,.capability-ledger article,
         .qualification-ledger article,.runtime-auto-ledger article,.runtime-imported-ledger article,
         .cancel-report-row)>*{grid-column:auto!important;}
  .guide-toc{grid-template-columns:1fr!important;}
}

/* ---------- field/timing/video: preserve geometry while allowing labels and controls to breathe ---------- */
@media (max-width:1179px){
  .single-setup-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;}
  .single-setup-grid>*:first-child{grid-column:1/-1!important;}
  .capture-actions,.notebook-command-grid,.experience-tool-section .experience-action-grid{
    grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr))!important;
  }
  .video-report-phase-grid,.video-report-metric-grid{
    grid-template-columns:repeat(auto-fit,minmax(min(100%,190px),1fr))!important;
  }
  .tm-glance-charts,.athlete-topfold-dashboard .tm-glance-charts{
    grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr))!important;
  }
}

@media (max-width:599px){
  .single-setup-grid{grid-template-columns:1fr!important;}
  .single-setup-grid>*:first-child{grid-column:auto!important;}
  .proof-result-card,.mesh-station-row,.mesh-task-row{flex-direction:column!important;align-items:stretch!important;}
  .proof-mark{text-align:left!important;white-space:normal!important;}
}

/* ---------- semantic rows / controls ---------- */
.inline-launch{min-width:0!important;grid-template-columns:minmax(0,1fr) auto!important;}
@media(max-width:760px){.inline-launch{grid-template-columns:1fr!important;}}

.attendance-row{grid-template-columns:minmax(0,1fr) minmax(150px,220px)!important;}
@media(max-width:760px){.attendance-row{grid-template-columns:1fr!important;align-items:start!important;}}

.actions>.btn,.actions>button,.experience-team-actions>.btn,.experience-team-actions>button{min-width:0;white-space:normal!important;}

/* Keep intentional compact pills/marks single-line while never allowing them to widen their container. */
:where(.status-pill,.guest-timing-badge,.field-qualification-page .status-pill,.privacy-trust-strip>summary::after){max-width:100%;}

/* ---------- ultra-wide: don't let reading lines become tiring ---------- */
@media(min-width:1600px){
  .page-heading,.tm-performance-title,.tm-practice-header{max-width:1180px;}
  .tm-dashboard-page,.tm-performance-shell,.tm-practice-shell,.tm-tools-page{max-width:1240px;margin-inline:auto;}
}

/* ---------- accessibility zoom / large text defensive behavior ---------- */
@media (max-width:1400px){
  .tm-panel-head,.tm-priority-card,.tm-next-action-card{flex-wrap:wrap;}
  .tm-priority-card>.btn{flex:0 0 auto;}
}

@media (forced-colors:active){
  .tm-approved-bottom-nav,.tm-approved-topbar,.tm-approved-rail{forced-color-adjust:auto!important;}
}

/* ---------- remaining medium-screen pressure points from legacy surfaces ---------- */
@media (max-width:1179px){
  .standards-actions,.season-map-actions,.proposal-actions,.capability-counts{min-width:0!important;max-width:100%!important;}
  .video-report-phase strong,.video-report-finding>div span,.video-report-progress-grid article>b{white-space:normal!important;}
  .experience-current-title,.experience-context span:last-child{max-width:100%!important;}
}

/* V38.81.136 — compact-screen geometry repair.
   Loaded last. Neutralizes inherited floating-nav transforms/widths and establishes
   symmetric safe-area-aware gutters on small screens without changing component logic. */
@media (max-width:1179px){
  .tm-approved-bottom-nav{
    left:max(10px,env(safe-area-inset-left,0px))!important;
    right:max(10px,env(safe-area-inset-right,0px))!important;
    bottom:max(8px,env(safe-area-inset-bottom,0px))!important;
    width:auto!important;
    max-width:560px!important;
    margin-inline:auto!important;
    transform:none!important;
    box-sizing:border-box!important;
  }
  .tm-approved-topbar{
    padding-left:max(14px,calc(env(safe-area-inset-left,0px) + 10px))!important;
    padding-right:max(14px,calc(env(safe-area-inset-right,0px) + 10px))!important;
  }
  #main{
    width:100%!important;
    max-width:100%!important;
    margin-inline:auto!important;
    padding-left:max(18px,calc(env(safe-area-inset-left,0px) + 14px))!important;
    padding-right:max(18px,calc(env(safe-area-inset-right,0px) + 14px))!important;
  }
  .tm-manual-shortcut form{
    left:max(14px,calc(env(safe-area-inset-left,0px) + 10px))!important;
    right:max(14px,calc(env(safe-area-inset-right,0px) + 10px))!important;
    width:auto!important;
    max-width:none!important;
    transform:none!important;
  }
  .quick-help,.experience-tool-finder{
    left:max(12px,env(safe-area-inset-left,0px))!important;
    right:max(12px,env(safe-area-inset-right,0px))!important;
    width:auto!important;
    max-width:420px!important;
    margin-left:auto!important;
  }
}

@media (max-width:599px){
  :root{--tm-page-inline:18px!important;}
  .tm-approved-bottom-nav{
    left:max(8px,env(safe-area-inset-left,0px))!important;
    right:max(8px,env(safe-area-inset-right,0px))!important;
    width:auto!important;
    max-width:none!important;
    margin-inline:0!important;
    transform:none!important;
    border-radius:18px!important;
  }
  #main{
    padding-left:max(16px,calc(env(safe-area-inset-left,0px) + 12px))!important;
    padding-right:max(16px,calc(env(safe-area-inset-right,0px) + 12px))!important;
    padding-bottom:calc(104px + env(safe-area-inset-bottom,0px))!important;
  }
  .page,.experience-page,.tm-dashboard-page,.tm-performance-shell,.tm-practice-shell,.tm-tools-page{
    width:100%!important;
    max-width:100%!important;
    margin-inline:0!important;
  }
  .tm-approved-topbar{
    padding-left:max(12px,calc(env(safe-area-inset-left,0px) + 8px))!important;
    padding-right:max(12px,calc(env(safe-area-inset-right,0px) + 8px))!important;
  }
  .tm-approved-bottom-nav .nav-link{min-width:0!important;max-width:100%!important;}
  .tm-approved-bottom-nav .nav-link span:last-child{
    max-width:100%!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
}

@media (max-width:380px){
  #main{
    padding-left:max(14px,calc(env(safe-area-inset-left,0px) + 10px))!important;
    padding-right:max(14px,calc(env(safe-area-inset-right,0px) + 10px))!important;
  }
  .tm-approved-bottom-nav{
    left:max(6px,env(safe-area-inset-left,0px))!important;
    right:max(6px,env(safe-area-inset-right,0px))!important;
    padding-left:4px!important;
    padding-right:4px!important;
  }
}



/* V38.81.137 — approved mobile navigation five-slot integrity.
   Coach Try-outs capability is contextual under Tools; the primary shell always has five destinations.
   This block is intentionally final so legacy Try-outs CSS cannot reopen a phantom sixth column. */
@media (max-width:1179px){
  .tm-approved-bottom-nav,
  .tm-approved-bottom-nav.tryouts-coach-nav-active{
    display:grid!important;
    grid-template-columns:repeat(5,minmax(0,1fr))!important;
    grid-auto-columns:minmax(0,1fr)!important;
    grid-auto-flow:column!important;
    justify-content:stretch!important;
    align-items:stretch!important;
    transform:none!important;
    box-sizing:border-box!important;
    overflow:visible!important;
  }
  .tm-approved-bottom-nav>.nav-link{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    justify-self:stretch!important;
    overflow:hidden!important;
  }
}
@media (max-width:599px){
  .tm-approved-bottom-nav,
  .tm-approved-bottom-nav.tryouts-coach-nav-active{
    left:max(8px,env(safe-area-inset-left,0px))!important;
    right:max(8px,env(safe-area-inset-right,0px))!important;
    width:auto!important;
    max-width:none!important;
    margin:0!important;
  }
}
