/* One final responsive layer: desktop stays intact, touch layouts reflow. */
.mobile-menu-toggle,.mobile-toc-toggle { display:none; }
@media (max-width:1024px) {
  html { scroll-padding-top:20px; }
  body { overflow-x:clip; }
  .sidebar,body.internal-page .sidebar {
    inset:calc(10px + env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) auto max(12px,env(safe-area-inset-left));
    height:60px; min-height:60px; padding:8px 12px; display:grid;
    grid-template-columns:auto minmax(0,1fr) auto; gap:12px;
  }
  .brand { width:auto; }
  .brand h1 { font-size:1.1rem; }
  .side-footer { grid-column:2; grid-row:1; width:auto; flex-direction:row; justify-content:flex-end; }
  .status-badge { display:none; }
  .code-btn { max-width:none; min-height:44px; padding:8px 10px; font-size:.78rem; white-space:normal; }
  .mobile-menu-toggle { display:flex; align-items:center; justify-content:center; gap:8px; grid-column:3; grid-row:1;
    min-height:44px; padding:8px 12px; border:1px solid var(--line); border-radius:10px; color:var(--text); background:#17121f; font:inherit; font-size:.85rem; }
  .sidebar .nav,body.internal-page .sidebar .nav {
    display:none; position:absolute; inset:calc(100% + 8px) 0 auto; width:auto; min-width:0;
    max-height:calc(100dvh - 100px - env(safe-area-inset-top)); overflow-y:auto;
    padding:10px; background:#100d16; border:1px solid var(--line); border-radius:16px;
    box-shadow:0 16px 40px #0008; flex-direction:column; flex-wrap:nowrap; gap:4px;
  }
  .sidebar.mobile-menu-open .nav,body.internal-page .sidebar.mobile-menu-open .nav { display:flex; }
  .sidebar .nav .nav-btn,.sidebar .nav .nav-btn:nth-of-type(5) {
    display:flex; flex:none; width:100%; min-height:48px; padding:12px 16px; font-size:.95rem; justify-content:flex-start; text-align:left;
  }
  main { padding:calc(92px + env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left)); min-height:100dvh; height:auto; overflow:visible; }
  .page { min-width:0; }
  .hero-panel { min-height:auto; padding:36px; }
  .hero-grid { grid-template-columns:minmax(0,1.1fr) minmax(0,.9fr); gap:24px; }
  .hero-right { grid-row:auto; order:0; min-height:280px; }
  .hero-logo { width:100%; max-width:380px; }
  .hero-left h2 { font-size:clamp(2.5rem,5.8vw,4rem); line-height:1.08; letter-spacing:-.05em; }
  .hero-inline-stats { grid-template-columns:1fr; }
  .mini-stat+.mini-stat { border-left:0; border-top:1px solid var(--line); padding-left:0; }
  .home-explore,.home-video-panel { min-height:auto; padding:32px; scroll-margin-top:90px; }
  .home-explore .home-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
  .home-explore .home-card { min-height:200px; padding:24px; }
  .home-explore .home-card:last-child:nth-child(odd) { grid-column:1/-1; }
  #homeVideoList { grid-template-columns:repeat(2,minmax(0,1fr))!important; gap:20px!important; }
  .home-video-panel .video-embed { max-height:none; aspect-ratio:16/9; }
  .video-embed iframe { width:100%; height:100%; }
  .section-title,.reader-top h3 { line-height:1.18; overflow:visible; overflow-wrap:anywhere; }
  .section-header,.rules-header,.staff-top { min-height:0; padding-bottom:24px; margin-bottom:24px; gap:20px; }
  #loreOverview { margin-top:0; }
  #loreList .lore-card:first-child { grid-column:auto; min-height:220px; }
  #loreList.lore-village-list { grid-template-columns:repeat(2,minmax(0,1fr)); }
  #loreList.lore-village-list>.lore-world-card { width:calc((100% - 20px)/2); }
  .lore-reader-layout { grid-template-columns:minmax(0,1fr); }
  .lore-reader-layout .lore-toc.show { position:sticky; top:12px; z-index:30; }
  .lore-reader-layout .lore-toc .lore-toc-panel { position:static; width:100%; padding:12px; max-height:none; background:#100d16; }
  .mobile-toc-toggle { display:flex; width:100%; align-items:center; justify-content:space-between; min-height:44px; padding:8px 12px; border:0; border-radius:8px; color:var(--text); background:transparent; font:inherit; text-align:left; }
  .lore-toc-title { display:none; }
  .lore-toc-list { max-height:28dvh; overflow-y:auto; grid-template-columns:1fr; }
  .lore-toc.mobile-toc-collapsed .lore-toc-list { display:none; }
  .lore-toc-link { min-height:44px; }
  .lore-reader-panel,.rules-reader-panel { min-width:0; padding:28px; }
  .reader-top { min-height:0; flex-wrap:wrap; gap:16px; align-items:flex-start; }
  .reader-body,.lore-section-body { overflow-wrap:anywhere; }
  .reader-body img,.lore-section-body img { max-width:100%; height:auto; }
  .reader-body table,.lore-section-body table { display:block; max-width:100%; overflow-x:auto; }
  .staff-grid,.staff-toolbar { grid-template-columns:minmax(0,1fr); }
  .staff-content-grid>.card-panel:first-child { grid-column:auto; }
  .staff-workspace-nav { position:static; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .staff-list { max-height:none; }
  .modal { width:min(100%,620px); max-height:calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y:auto; padding:24px; }
  .overlay { z-index:200; padding:calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
  .input,.textarea,.search-bar input,select { font-size:16px; min-width:0; }
  .btn,.ghost-btn,.reaction-btn,.mini,.staff-workspace-tab { min-height:44px; }
  :is(button,a,input,textarea,select):focus-visible { outline:2px solid #c8a3ed; outline-offset:3px; }
}
@media (max-width:600px) {
  .sidebar { gap:8px; }
  .mobile-menu-toggle { padding:8px 10px; }
  main { padding-inline:12px; }
  .hero-panel { padding:28px 22px; border-radius:22px; }
  .hero-grid { grid-template-columns:1fr; gap:24px; }
  .hero-right { grid-row:auto; min-height:260px; }
  .hero-logo { max-width:260px; }
  .hero-left h2 { font-size:clamp(2.25rem,9.5vw,3.5rem); }
  .hero-actions { display:grid; grid-template-columns:1fr; gap:12px; }
  .hero-sub { font-size:1rem; line-height:1.65; }
  .mini-stat-value { overflow-wrap:anywhere; }
  .home-explore,.home-video-panel { padding:28px 20px; border-radius:22px; }
  .home-section-heading { padding-top:0; }
  .home-section-heading h3,.section-title { font-size:clamp(2rem,9vw,3rem); }
  .home-explore .home-grid,#homeVideoList,#loreList,#loreList.lore-village-list,
  #rulesCategories,#candidatureCategoryList { grid-template-columns:1fr!important; }
  #loreList.lore-village-list>.lore-world-card { width:100%; }
  #loreList .lore-card,#loreList .lore-card:first-child { min-height:180px; padding:24px; }
  .rules-ai-heading { flex-wrap:wrap; }
  #page-reglement .rules-ai { padding:18px; }
  #page-reglement .rules-reader-panel,.lore-reader-panel,#candidatureReader>.card-panel { padding:22px 18px; }
  #page-reglement .reader-top,.reader-top { flex-direction:column; align-items:stretch; }
  .reader-top h3,#candidatureReaderTitle { font-size:clamp(1.7rem,7vw,2.4rem); }
  .lore-summary { padding:18px; font-size:1rem; }
  .lore-section-body,.reader-body,.rule-section-text { font-size:1rem; line-height:1.75; }
  .lore-section-block { padding-block:28px; }
  #candidatureHome { grid-template-columns:1fr; }
  #candidatureHome .candidature-intro-visual { min-height:180px; }
  #candidatureReader .candidature-item { padding:18px; }
  .staff-grid>.card-panel { padding:22px 18px; }
  .staff-account-top,.staff-section-heading { flex-wrap:wrap; gap:12px; }
  .staff-permissions-grid { grid-template-columns:1fr; }
  .staff-workspace-tab { padding:12px; grid-template-columns:minmax(0,1fr); }
  .staff-workspace-tab strong { font-size:.85rem; overflow-wrap:anywhere; }
  .modal-actions { flex-wrap:wrap; }
}
@media (pointer:coarse) {
  .btn,.ghost-btn,.code-btn,.reaction-btn,.mini,.nav-btn { min-height:44px; touch-action:manipulation; }
  .home-shell>.home-block,.reveal-item { opacity:1; transform:none; }
}
@media (hover:none) {
  .home-card:hover,.category-card:hover,.lore-card:hover,.video-card:hover { box-shadow:none; }
}
