/* TODOCAP: ajustes de presentacion para movil y tableta. */
:root{--tc-header-height:80px;--tc-exam-toolbar-height:0px}
.tc-table-scroll{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;-webkit-overflow-scrolling:touch}
.tc-table-scroll:focus-visible{outline:3px solid #0284c7;outline-offset:3px}
@media(max-width:900px){
  html{-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-padding-top:calc(var(--tc-header-height) + 12px)}
  *,*::before,*::after{box-sizing:border-box}
  body{min-width:0;overflow-wrap:anywhere}
  :where(main,section,article,aside,form,fieldset,header,footer,nav,div){min-width:0}
  img,video,canvas,svg{max-width:100%}
  iframe{max-width:100%}
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea{min-width:0;max-width:100%;font-size:16px!important}
  input[type=file]{width:100%;padding:10px!important;min-height:48px}
  select{width:100%;text-overflow:ellipsis}
  button,input[type=submit],input[type=button]{max-width:100%;white-space:normal;overflow-wrap:anywhere;touch-action:manipulation}
  :where(button,input[type=submit],input[type=button],select){min-height:44px}
  :where(h1,h2,h3,p,label,td,th,a,strong,small,span){overflow-wrap:anywhere}
  pre{max-width:100%;overflow:auto;white-space:pre-wrap}
  fieldset{min-inline-size:0;max-width:100%}
  legend{max-width:100%;white-space:normal}

  /* La cabecera debe caber incluso con los tres botones de administrador. */
  html body .header-container{display:grid!important;grid-template-columns:minmax(0,1fr) auto;gap:8px!important;padding:10px 12px!important;width:100%;align-items:center}
  html body .brand-logo{min-width:0;max-width:100%}
  html body .brand-logo img{width:auto!important;max-width:100%!important;height:auto!important;max-height:48px;object-fit:contain}
  html body .header-right{min-width:0;max-width:100%;gap:6px!important;flex-wrap:wrap!important;justify-content:flex-end}
  html body .header-btn{height:auto!important;min-height:44px;padding:9px 11px!important;font-size:14px!important;line-height:1.25;white-space:normal!important;text-align:center;border-radius:13px}
  html body .header-container:has(a[href="/admin/index.php"]){grid-template-columns:1fr}
  html body .header-container:has(a[href="/admin/index.php"]) .brand-logo{justify-self:center;max-width:145px}
  html body .header-container:has(a[href="/admin/index.php"]) .header-right{justify-content:center}
  .main-header{max-width:100%}

  /* Celdas de rejillas flexibles: sin anchos minimos implicitos del texto. */
  .study-grid,.sim-grid,.perfil-grid,.prep-layout,.real-grid,.contact-grid,.import-grid,.hero-grid,.guarantee-box{grid-template-columns:minmax(0,1fr)!important}
  .study-grid>*,.sim-grid>*,.perfil-grid>*,.prep-layout>*,.real-grid>*,.contact-grid>*,.hero-grid>*{min-width:0;max-width:100%}
  .dashboard-history,.recommendation,.score-top,.exam-top,.panel-head,.real-head,.review-top,.results-head,.perfil-hero,.topbar,.nav{min-width:0;max-width:100%}
  .score-top,.panel-head,.real-head,.review-top{flex-wrap:wrap}
  .recommendation{grid-template-columns:auto minmax(0,1fr)!important}
  .recommendation-link{grid-column:1/-1;width:100%;white-space:normal!important;text-align:center;padding-block:12px}
  .dashboard-history{flex-direction:column!important;align-items:stretch!important}
  .dashboard-history .study-primary{white-space:normal}
  .study-actions,.sim-actions,.exam-actions,.review-actions,.result-pro-actions,.hero-actions{max-width:100%;flex-wrap:wrap}
  .study-primary,.study-secondary,.btn-main,.btn-soft,.exam-btn,.review-action,.result-pro-btn,.back,.back-btn,.hist-back,.review-back{max-width:100%;white-space:normal!important;text-align:center;height:auto;line-height:1.4;padding-block:12px}
  .progress-summary-top{flex-wrap:wrap}
  .next-modal-backdrop,.modal-backdrop{padding:12px}
  .next-modal,.next-modal-backdrop>div{max-width:100%;max-height:calc(100dvh - 24px);overflow:auto;overscroll-behavior:contain}
  .table-wrap,.table-responsive,.tc-table-scroll{min-width:0!important;max-width:100%!important;overflow-x:auto!important}
  .chart-wrap{max-width:100%;overflow-x:auto;overscroll-behavior-x:contain}

  /* Test: barra compacta bajo la cabecera real, sin tapar preguntas. */
  .test-page .exam-layout{display:flex!important;flex-direction:column!important;gap:16px!important}
  .test-page .exam-main{width:100%;min-width:0!important}
  .test-page .exam-sidebar{position:sticky!important;top:var(--tc-header-height)!important;max-width:100%!important;max-height:calc(100dvh - var(--tc-header-height) - 12px);overflow:auto;overscroll-behavior:contain;padding:8px!important}
  .test-page .exam-sidebar .timer-box{position:static!important;margin:0 0 8px!important;min-height:0!important;padding:8px 10px!important;display:flex!important;flex-wrap:wrap!important;gap:8px!important;max-width:100%!important}
  .test-page .timer-value{min-width:0!important;font-size:22px!important;white-space:nowrap}
  .test-page .mobile-map-toggle{min-height:44px!important;height:auto!important;padding:10px 12px!important;white-space:normal!important}
  .test-page .exam-sidebar .question-map:not(.result-map){position:static!important;max-height:min(40dvh,320px)!important;overflow:auto!important}
  .test-page .question-card{scroll-margin-top:calc(var(--tc-header-height) + var(--tc-exam-toolbar-height) + 16px)!important;max-width:100%}
  .test-page .question-head{flex-wrap:wrap!important;gap:8px!important}
  .test-page .question-number{max-width:100%!important;min-width:0!important;flex:1 1 120px!important;height:auto!important;min-height:44px!important;white-space:normal!important;overflow:visible!important;text-overflow:clip!important;line-height:1.4!important;padding:10px 12px!important}
  .test-page .review-btn{height:auto!important;min-height:44px!important;max-width:100%!important;padding:10px 12px!important;font-size:14px!important}
  .test-page .option{grid-template-columns:36px minmax(0,1fr)!important;gap:10px!important;padding:12px!important;min-width:0!important}
  .test-page .option-letter{width:34px!important;height:34px!important;min-width:34px!important;margin:0!important;align-self:start;font-size:16px!important}
  .test-page .option-text{min-width:0;font-size:16px!important;line-height:1.5!important;overflow-wrap:anywhere}
  .test-page .map-grid{grid-template-columns:repeat(auto-fit,minmax(44px,1fr))!important}
  .test-page .map-item{min-width:0!important;min-height:44px!important;height:44px!important;max-height:none!important;font-size:13px!important}
  .test-page .result-pro-main,.test-page .result-pro-insights{grid-template-columns:minmax(0,1fr)!important}
  .test-page .result-pro-score-card{justify-self:center!important;max-width:100%}
  .test-page .result-pro-ring{width:min(180px,100%)!important;height:auto!important;aspect-ratio:1}
  .test-page .result-pro-ring>div{max-width:80%;max-height:80%;aspect-ratio:1}
  .test-page .review-full-head{flex-wrap:wrap;gap:12px;min-width:0}
  .test-page .review-card,.test-page .review-card-full{max-width:100%}
  .test-page .review-full-option{min-width:0}
  .review-map-dialog{max-height:calc(100dvh - 24px)!important;max-width:calc(100% - 24px)!important}
  .review-map-dialog .resultado-final-map .map-grid{grid-template-columns:repeat(auto-fit,minmax(44px,1fr))!important}
  .test-page .review-card-full{scroll-margin-top:calc(var(--tc-header-height) + 84px + env(safe-area-inset-top))!important}
}
@media(max-width:600px){
  .search-wrap,.prep-page,.perfil-page,.hist-page,.review-page,.sim-page,.real-page,.import-page{padding-left:12px!important;padding-right:12px!important}
  .dashboard-page,.custom-page{padding-left:12px!important;padding-right:12px!important}
  .search-box,.question-result,.prep-card,.sim-card,.perfil-card-body,.perfil-card-head,.exam-card,.real-card,.import-card{padding:18px!important;border-radius:20px}
  .prep-hero,.sim-hero,.hist-hero,.review-hero,.perfil-hero{padding:22px 18px!important;border-radius:24px}
  .prep-hero h1,.sim-hero h1,.hist-hero h1,.review-hero h1,.perfil-hero h1,.search-hero h1{font-size:clamp(28px,8vw,38px)!important;letter-spacing:-1px!important;line-height:1.15!important}
  .study-card h2,.sim-card h2,.prep-card h2,.perfil-card-head h2{font-size:26px!important;line-height:1.2!important}
  .study-stats,.exam-meta,.result-pro-metrics{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .study-stat strong,.exam-mini strong{font-size:20px!important;overflow-wrap:anywhere}
  .study-actions,.sim-actions,.exam-actions,.review-actions,.hero-actions{display:grid!important;grid-template-columns:minmax(0,1fr)!important}
  .study-actions>*,.sim-actions>*,.exam-actions>*,.review-actions>*,.hero-actions>*{width:100%;min-width:0}
  .test-builder{width:100%;justify-content:stretch!important}
  .test-builder>div,.test-builder input,.test-builder button{width:100%!important;min-width:0}
  .search-form,.prep-grid,.prep-stats,.form-grid,.real-row,.pdf-tabs,.meta-edit{grid-template-columns:minmax(0,1fr)!important}
  .pdf-frame iframe{height:60dvh;min-height:250px}
  .test-page .result-pro-v2{padding:20px 16px!important;border-radius:24px!important}
  .test-page .result-pro-copy h1{font-size:30px!important;letter-spacing:-.8px!important;line-height:1.15!important}
  .test-page .result-pro-pills{flex-wrap:wrap;max-width:100%}
  .test-page .result-pro-pills span{max-width:100%;white-space:normal!important;line-height:1.4}
  .test-page .result-pro-metrics article{padding:14px 10px!important;min-width:0}
  .test-page .result-pro-metrics strong{font-size:26px!important}
  .test-page .question-card,.test-page .review-card{padding:16px!important}
  .test-page .review-card h3{font-size:20px!important;line-height:1.4!important}
  .test-page .result-pro-actions{display:grid!important;grid-template-columns:minmax(0,1fr)!important}
  .test-page .result-pro-btn{width:100%!important;min-width:0!important}
  .test-page .map-head{flex-wrap:wrap!important}
  .test-page .map-legend{justify-content:flex-start!important;line-height:1.4!important}
  .test-page .review-full-head>div{width:100%}
  .test-page .review-full-number{white-space:normal;line-height:1.4}
  .test-page .review-status-badge{white-space:normal;max-width:100%}
  .answer-boxes{grid-template-columns:minmax(0,1fr)!important}
  .custom-row{grid-template-columns:minmax(0,1fr)!important}
  .custom-row input{width:100%!important;min-height:48px}
  .custom-summary{flex-direction:column;align-items:stretch}
  .custom-summary>.custom-button{width:100%}
}
@media(max-width:380px){
  html body .header-container{padding:8px 10px!important;gap:6px!important}
  html body .header-btn{font-size:13px!important;padding:8px 9px!important}
  .study-stats,.exam-meta{grid-template-columns:minmax(0,1fr)!important}
  .test-page .result-pro-metrics{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}
@media(max-height:500px) and (max-width:900px){
  .test-page .exam-sidebar{position:static!important;max-height:none!important}
  .test-page .question-card{scroll-margin-top:calc(var(--tc-header-height) + 12px)!important}
  .review-map-dialog{max-height:calc(100dvh - 16px)!important}
}
