/* Couche mobile commune : lisibilité, zones tactiles et aucune colonne cassée. */
* { -webkit-tap-highlight-color: transparent; }
img, svg, video, canvas { max-width: 100%; }
button, a, input, select, textarea { touch-action: manipulation; }

@media (max-width: 900px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .container { width: min(var(--max), calc(100% - 30px)); }
  .topbar-inner { min-height: 62px; gap: 12px; }
  .topbar-nav { gap: 10px; font-size: .78rem; }
  .brand { min-width: 0; font-size: .84rem; white-space: nowrap; }
  .brand em { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }
  .page { padding: 32px 0; }
  input, select, textarea { font-size: 16px; } /* évite le zoom automatique iOS */
  .button { min-height: 46px; }
}

@media (max-width: 980px) {
  .topbar-nav a:not(.button), .topbar-nav > span { display: none; }
  .topbar-nav { margin-left: auto; }
  .topbar-nav a:last-child { display: inline-flex; }
  .brand { font-size: .76rem; letter-spacing: -.02em; }
  .brand-mark, .site-header .brand-mark { width: 32px; height: 32px; flex-basis: 32px; }
  .card { padding: 19px; border-radius: 12px; }
  .choice { grid-template-columns: 1fr; }
  .choice label { min-height: auto; }
  .academy-layout { display:block !important; height:auto !important; overflow:visible !important; }
  .academy-main { height:auto !important; min-height:0; padding:20px 15px 94px !important; overflow:visible !important; }
  .academy-sidebar { position:fixed !important; right:0; bottom:0; left:0; z-index:40; display:block !important; height:auto !important; max-height:none; padding:7px 7px calc(7px + env(safe-area-inset-bottom)); overflow:visible; border-top:1px solid rgba(22,137,255,.35); border-right:0; background:rgba(4,19,47,.96); box-shadow:0 -12px 34px rgba(0,0,0,.28); backdrop-filter:blur(16px); }
  .academy-sidebar .dashboard-logo,.academy-sidebar .student-mini,.academy-sidebar .streak-card { display:none !important; }
  .academy-nav { display:flex !important; justify-content:space-around; gap:2px; margin:0; }
  .academy-nav a,.academy-nav button { display:grid !important; min-width:0; min-height:52px; flex:1; place-items:center; padding:24px 3px 3px; border:0; border-radius:8px; font-size:.59rem; line-height:1.1; text-align:center; }
  .academy-nav a::before,.academy-nav button::before { top:6px; left:50%; transform:translateX(-50%); font-size:1rem; }
  .academy-nav a:nth-of-type(n+6), .academy-nav button { display:none !important; }
  .academy-nav [data-portfolio-link] { display:grid !important; }
  .academy-hero { gap:18px; padding:27px 21px; border-radius:14px; }
  .academy-hero h1 { font-size:clamp(2.2rem,7vw,3.25rem); }
  .hero-actions { display:grid; grid-template-columns:1fr; }.hero-actions .button { width:100%; }
  .hero-metric { max-width:none; padding:17px; }
  .dashboard-columns,.studio-grid,.enterprise-grid,.marketing-grid { grid-template-columns:1fr; }
  .section-heading,.class-top { align-items:flex-start; flex-direction:column; gap:9px; }
  .tool-library-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .learning-detail-modal { width:calc(100% - 18px); max-height:calc(100dvh - 18px); }
  .learning-detail-content { max-height:calc(100dvh - 18px); padding:28px 20px; }
  .reader-footer { padding-bottom:75px; }
  .foundation-course-grid,.foundation-project,.foundation-weekly,.foundation-certificate,.payment-layout,.dash-grid,.upgrade-hero,.roadmap-heading,.showcase-grid,.upgrade-activation,.upgrade-account,.affiliate-grid { grid-template-columns:1fr !important; }
  .foundation-project,.foundation-weekly,.upgrade-account { gap:24px !important; }
  .foundation-certificate { align-items:flex-start; }
  .upgrade-paths,.account-grid,.payment-grid,.methods-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .affiliate-stats { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .affiliate-link-card,.foundation-next { align-items:flex-start; flex-direction:column; }
  .affiliate-history,.table-panel,.pro-result,.learning-detail-content { overflow-x:auto; -webkit-overflow-scrolling:touch; }
  .affiliate-history table,.data-table,.pro-result table { min-width:620px; }
  .tool-fields,.workbook-grid,.dialog-grid { grid-template-columns:1fr !important; }
}

@media (max-width: 700px) {
  .tool-library-grid { grid-template-columns:1fr; }
  .topbar-nav a:not(.button), .topbar-nav > span { display:none; }
  .topbar-nav a:last-child { display:inline-flex; }
  .brand { font-size:.76rem; letter-spacing:-.02em; }
  .brand em { max-width:76px; overflow:hidden; text-overflow:ellipsis; }
  .academy-hero h1 { font-size:clamp(2.2rem,11vw,3.25rem); }
  .academy-nav a,.academy-nav button { font-size:.59rem; }
  .upgrade-paths,.account-grid,.payment-grid,.methods-grid,.affiliate-stats { grid-template-columns:1fr; }
  .foundation-project,.foundation-weekly,.foundation-certificate,.foundation-next,.affiliate-link-card,.payment-layout { padding:22px !important; }
  .upgrade-footer,.dialog-footer,.reader-footer { display:grid; }
  .upgrade-footer .button,.dialog-footer .button,.reader-footer .button { width:100%; }
  .payment-method,.method { min-height:auto; }
}

@media (max-width: 390px) {
  .academy-nav a,.academy-nav button { font-size:.52rem; }
  .brand em { max-width:70px; }
  .academy-main { padding-inline:12px !important; }
}
