/* Navigation V5 · keep course controls in the course and make theory usable on phones. */
body[data-view]:not([data-view="course"]) .app-shell{
  grid-template-columns:minmax(0,1fr);
}
body[data-view]:not([data-view="course"]) .sidebar{
  display:none!important;
}

.atlas-mobile-topic{display:none}
#atlasNav .atlas-nav-item:focus-visible,
#atlasTopicSelect:focus-visible{
  outline:3px solid var(--accent);
  outline-offset:2px;
}

@media (max-width:1100px){
  #view-theory .atlas-index{
    position:static;
    max-height:none;
    margin:0 0 12px;
    padding:10px;
    border-radius:14px;
  }
  #view-theory .atlas-index-head,
  #view-theory .atlas-search,
  #view-theory #atlasNav{display:none!important}
  #view-theory .atlas-mobile-topic{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:4px 12px;
  }
  .atlas-mobile-topic-label{
    color:#fff;
    font-size:12px;
    font-weight:750;
  }
  .atlas-mobile-topic-count{
    color:#c7c0b7;
    font-size:11px;
    font-variant-numeric:tabular-nums;
  }
  #atlasTopicSelect{
    grid-column:1/-1;
    width:100%;
    min-height:46px;
    padding:9px 36px 9px 11px;
    border:1px solid rgba(255,255,255,.16);
    border-radius:10px;
    background:#fff;
    color:#1d1b18;
    font:inherit;
    font-size:14px;
    font-weight:650;
  }
}

/* Keep every Atlas topic visible at once on compact desktops and landscape tablets. */
@media (min-width:1101px) and (max-width:1280px){
  #view-theory #atlasNav{
    display:grid!important;
    grid-template-columns:repeat(auto-fit,minmax(min(100%,230px),1fr));
    gap:8px;
    overflow:visible;
    padding:0;
    scroll-snap-type:none;
  }
  #view-theory #atlasNav .atlas-nav-item{
    min-width:0;
    min-height:58px;
    flex:initial;
    scroll-snap-align:none;
    padding:9px 10px;
    border:1px solid rgba(255,255,255,.08);
    background:rgba(255,255,255,.035);
  }
  #view-theory #atlasNav .atlas-nav-item:hover{
    background:rgba(255,255,255,.09);
  }
  #view-theory #atlasNav .atlas-nav-item.active{
    border-color:transparent;
    background:#fff;
  }
}

@media (max-width:760px){
  body[data-view]:not([data-view="course"]) .topbar{
    display:flex!important;
    flex-direction:row;
    align-items:flex-start;
    gap:8px;
    margin:2px 2px 14px;
  }
  body[data-view]:not([data-view="course"]) .topbar>div:first-child{min-width:0}
  body[data-view]:not([data-view="course"]) .topbar .eyebrow{
    margin:0 0 2px;
    color:var(--accent-strong);
    font-size:10px;
    letter-spacing:.08em;
  }
  body[data-view]:not([data-view="course"]) .topbar h1{
    margin:0;
    font-size:clamp(20px,5.4vw,24px);
    line-height:1.14;
    letter-spacing:-.035em;
    text-wrap:balance;
  }
  body[data-view]:not([data-view="course"]) .top-stats{display:none}
  body[data-view]:not([data-view="course"]) .main{padding-top:15px}
}

/* The desktop section rail is wider than the available reading column on tablets. */
@media (min-width:761px) and (max-width:1100px){
  body{padding-bottom:calc(82px + env(safe-area-inset-bottom))}
  .tabs{display:none!important}
  .mobile-nav-v4{
    position:fixed;
    z-index:120;
    left:12px;
    right:12px;
    bottom:calc(10px + env(safe-area-inset-bottom));
    display:grid;
    grid-template-columns:repeat(6,minmax(0,1fr));
    gap:4px;
    min-height:66px;
    padding:6px;
    border:1px solid rgba(255,255,255,.08);
    border-radius:18px;
    background:rgba(24,23,21,.96);
    box-shadow:0 16px 40px rgba(0,0,0,.24);
    backdrop-filter:blur(18px);
  }
  .mobile-nav-v4 button{
    min-width:0;
    min-height:52px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:4px;
    padding:5px 4px;
    border:0;
    border-radius:13px;
    background:transparent;
    color:#aaa49c;
    font-size:11px;
    font-weight:800;
  }
  .mobile-nav-v4 button.active{background:#fff;color:#1f1d1a}
  .mobile-nav-v4 svg{
    width:21px;
    height:21px;
    fill:none;
    stroke:currentColor;
    stroke-width:1.8;
    stroke-linejoin:round;
    stroke-linecap:round;
  }
  .mobile-nav-v4 [data-mobile-view="train"] svg,
  .mobile-nav-v4 [data-mobile-view="aerith"] svg{fill:currentColor;stroke:none}
  .mobile-more-v4{
    position:fixed;
    z-index:119;
    left:18px;
    right:18px;
    bottom:calc(88px + env(safe-area-inset-bottom));
    display:grid;
    gap:5px;
    max-height:min(60vh,420px);
    overflow:auto;
    padding:10px;
    border-radius:18px;
    background:rgba(255,253,248,.98);
    border:1px solid var(--border);
    box-shadow:0 20px 54px rgba(0,0,0,.2);
    backdrop-filter:blur(18px);
  }
  .mobile-more-v4[hidden]{display:none}
  .mobile-more-v4 button{
    min-height:58px;
    display:grid;
    grid-template-columns:38px 1fr;
    gap:9px;
    align-items:center;
    padding:8px 10px;
    border:0;
    border-radius:12px;
    background:transparent;
    color:var(--text);
    text-align:left;
  }
  .mobile-more-v4 button:hover{background:var(--panel-soft)}
  .mobile-more-v4 svg{
    width:24px;
    height:24px;
    fill:none;
    stroke:var(--accent);
    stroke-width:1.7;
    stroke-linecap:round;
    stroke-linejoin:round;
  }
  .mobile-more-v4 span,.mobile-more-v4 strong,.mobile-more-v4 small{display:block}
  .mobile-more-v4 strong{font-size:12px}
  .mobile-more-v4 small{margin-top:2px;color:var(--muted);font-size:10px}
}

@media (max-width:380px){
  #view-theory .atlas-index{padding:9px}
  #atlasTopicSelect{min-height:44px}
}

@media (prefers-reduced-motion:reduce){
  #atlasNav .atlas-nav-item{transition:none}
}
