/* Fixed54 - mobile-first class mode. Desktop layout remains unchanged. */
.mobile-only{display:none!important}

@media (max-width: 768px){
  html,body{width:100%;max-width:100%;overflow-x:hidden}
  body{padding-bottom:64px;-webkit-text-size-adjust:100%}

  /* Landing */
  .join-view{min-height:100dvh;padding:12px!important;align-items:flex-start!important}
  .landing-theme-toggle{top:10px!important;right:10px!important;z-index:20}
  .landing-shell{display:flex!important;flex-direction:column!important;gap:12px!important;width:100%!important;max-width:none!important;margin:54px auto 0!important}
  .landing-hero,.join-card{width:100%!important;min-width:0!important;border-radius:22px!important}
  .landing-hero{min-height:0!important;padding:8px!important;overflow:hidden}
  .landing-class-visual{display:block!important;width:100%!important;height:auto!important;max-height:42dvh!important;object-fit:contain!important}
  .join-card{padding:22px 18px!important}
  .join-card-title strong{font-size:22px!important}
  .mode-tabs{height:52px!important}
  .contact-card{padding-top:16px!important}

  /* App shell */
  #appView{min-height:100dvh;padding-bottom:64px}
  .topbar{position:sticky!important;top:0;z-index:80;height:58px!important;min-height:58px!important;padding:8px 10px!important;display:flex!important;align-items:center!important;gap:8px!important;background:var(--panel)!important;border-bottom:1px solid var(--line)!important}
  .topbar .brand{min-width:0;flex:1;gap:8px!important}
  .brand-j-logo{width:38px!important;height:38px!important;min-width:38px!important;font-size:20px!important}
  .topbar .brand strong{font-size:15px!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .user-progress{display:none!important}
  .room-tools{display:none!important}
  .mobile-only{display:flex!important}
  .mobile-top-actions{align-items:center;gap:6px}
  .mobile-icon-btn{position:relative;width:40px;height:40px;padding:0;border:1px solid var(--line);border-radius:12px;background:var(--panel2);color:var(--text);font:inherit;font-size:20px;align-items:center;justify-content:center;cursor:pointer}
  .mobile-count{position:absolute;right:-3px;top:-4px;min-width:18px;height:18px;padding:0 5px;border-radius:999px;background:#dc2626;color:#fff;font-size:11px;font-weight:800;display:flex;align-items:center;justify-content:center}

  .workspace{display:block!important;height:calc(100dvh - 122px)!important;min-height:0!important;padding:0!important;overflow:hidden!important}
  .editor-panel{height:100%!important;border-radius:0!important;border-left:0!important;border-right:0!important;min-width:0!important}
  .editor-view-tabs{height:46px!important;position:sticky;top:58px;z-index:20;background:var(--panel)}
  .editor-view-tab{font-size:14px!important;padding:0 18px!important}
  .panel-titlebar{min-height:44px!important;padding:8px 12px!important;gap:6px!important}
  .panel-titlebar>div:first-child{min-width:0}
  .panel-titlebar #fileName{font-size:15px!important}
  .editor-meta{gap:5px!important;min-width:0;overflow:hidden}
  .editor-meta>span:first-child,.editor-meta #cursorPosition,.editor-meta #executionModeBadge,.editor-meta #findCodeBtn,.editor-meta #formatCodeBtn,.editor-meta #toggleCommentBtn{display:none!important}
  .editor-meta select{max-width:94px;height:32px!important;font-size:12px!important}
  #editor,.code-editor,.CodeMirror{height:calc(100dvh - 212px)!important;min-height:0!important}
  .CodeMirror{font-size:14px!important;line-height:22px!important}
  .CodeMirror-lines{padding:8px 0 24px!important}
  .CodeMirror-gutters{min-width:42px!important}

  /* Problem mobile layout */
  .problem-layout{display:block!important;height:calc(100dvh - 168px)!important;overflow:hidden!important}
  .problem-sidebar{display:none!important;width:100%!important;height:100%!important;border-right:0!important;background:var(--panel)!important}
  .problem-main{width:100%!important;height:100%!important;overflow:auto!important;padding:12px!important}
  #appView.mobile-problem-list .problem-sidebar{display:flex!important}
  #appView.mobile-problem-list .problem-main{display:none!important}
  .problem-sidebar-head{padding:12px!important;position:sticky;top:0;z-index:2;background:var(--panel)}
  .problem-list{padding-bottom:24px!important}
  .problem-list button,.problem-item{min-height:58px!important}
  .problem-head h2{font-size:21px!important;line-height:1.3!important}
  .problem-io{grid-template-columns:1fr!important}
  .problem-code-toolbar{position:sticky;top:0;z-index:4;flex-wrap:wrap}
  .problem-code-toolbar #findProblemCodeBtn,.problem-code-toolbar #formatProblemCodeBtn,.problem-code-toolbar #toggleProblemCommentBtn{display:none!important}
  .problem-code-wrap .CodeMirror{height:42dvh!important}
  .problem-submit-row{position:sticky;bottom:0;background:var(--panel);padding:10px 0!important;gap:8px!important}
  .problem-submit-row #problemNotice{display:none!important}
  .problem-submit-row button{flex:1;min-height:44px}

  /* Right-side panels become bottom sheets */
  .right-column{display:none!important;position:fixed!important;z-index:120;left:0;right:0;bottom:64px;top:auto;width:100%!important;max-height:72dvh;padding:10px!important;background:var(--bg);border-top:1px solid var(--line);border-radius:22px 22px 0 0;box-shadow:0 -16px 40px rgba(0,0,0,.25);overflow:auto!important}
  #appView.mobile-sheet-open .right-column{display:block!important}
  .right-column>.panel{display:none!important;border-radius:16px!important;margin:0!important;min-height:0!important}
  #appView.mobile-sheet-members .members-panel,
  #appView.mobile-sheet-output .io-panel,
  #appView.mobile-sheet-chat .chat-panel{display:flex!important}
  .members-panel{max-height:58dvh}
  .io-panel{height:58dvh!important}
  .chat-panel{height:64dvh!important}
  .chat-messages{min-height:0!important;max-height:none!important;flex:1;overflow:auto}
  .chat-form{padding-bottom:max(10px,env(safe-area-inset-bottom))!important}
  .mobile-sheet-handle{position:fixed;z-index:130;left:50%;transform:translateX(-50%);bottom:calc(64px + 72dvh - 4px);width:44px;height:5px;border-radius:999px;background:var(--muted);display:none!important}
  #appView.mobile-sheet-open .mobile-sheet-handle{display:block!important}

  /* Fixed bottom navigation */
  .mobile-bottom-nav{position:fixed;z-index:140;left:0;right:0;bottom:0;height:64px;padding:5px 6px max(5px,env(safe-area-inset-bottom));background:var(--panel);border-top:1px solid var(--line);display:grid!important;grid-template-columns:repeat(5,1fr);gap:2px}
  .mobile-nav-btn{border:0;background:transparent;color:var(--muted);font:inherit;font-size:10px;font-weight:700;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;border-radius:10px;min-width:0}
  .mobile-nav-btn span{font-size:21px;line-height:1}
  .mobile-nav-btn.active{color:var(--accent);background:color-mix(in srgb,var(--accent) 12%,transparent)}

  /* Menu drawer */
  .mobile-drawer-backdrop{position:fixed;z-index:160;inset:0;background:rgba(0,0,0,.52);display:none!important}
  .mobile-drawer{position:absolute;right:0;top:0;bottom:0;width:min(86vw,340px);padding:18px;background:var(--panel);box-shadow:-16px 0 40px rgba(0,0,0,.25);display:flex;flex-direction:column;gap:10px;overflow:auto;transform:translateX(100%);transition:transform .2s ease}
  #appView.mobile-menu-open .mobile-drawer-backdrop{display:block!important}
  #appView.mobile-menu-open .mobile-drawer{transform:translateX(0)}
  .mobile-drawer-head{display:flex;align-items:center;justify-content:space-between;padding-bottom:12px;border-bottom:1px solid var(--line)}
  .mobile-drawer-head strong{font-size:20px}
  .mobile-drawer-close{border:0;background:transparent;color:var(--text);font-size:28px}
  .mobile-drawer button.mobile-menu-action{width:100%;min-height:48px;padding:0 14px;border:1px solid var(--line);border-radius:12px;background:var(--panel2);color:var(--text);font:inherit;font-weight:700;text-align:left}
  .mobile-drawer button.danger{color:#ef4444}

  /* Modal usability */
  .modal{padding:0!important;align-items:flex-end!important}
  .modal-card{width:100%!important;max-width:none!important;max-height:92dvh!important;border-radius:22px 22px 0 0!important;padding:18px 14px!important;overflow:auto!important}
  .board-modal-card,.learning-modal-card,.communications-modal-card{height:92dvh!important}
  .learning-layout{grid-template-columns:1fr!important}
  .learning-chapter-list{max-height:28dvh!important}
  .board-toolbar{overflow-x:auto!important;flex-wrap:nowrap!important;padding-bottom:8px!important}
  .board-toolbar>*{flex:0 0 auto}

  /* Hide desktop-only/student-irrelevant controls on mobile */
  #appView.student-mode #aiReviewBtn,#appView.student-mode #lineReviewBtn,#appView.student-mode #engineStatusBtn,#appView.student-mode #splitModeBtn{display:none!important}
}

@media (max-width: 420px){
  .landing-class-visual{max-height:34dvh!important}
  .join-card{padding:18px 14px!important}
  .topbar .brand strong{max-width:145px}
  .mobile-icon-btn{width:38px;height:38px}
  .CodeMirror{font-size:13px!important}
}
