/* FLAITOPS — smartphone / touch layout */
@media (max-width: 760px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body.workspace-open,
  body.chat-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* Landing & chat */
  .landing-hero {
    padding-top: calc(4.2rem + env(safe-area-inset-top));
    padding-left: max(.75rem, env(safe-area-inset-left));
    padding-right: max(.75rem, env(safe-area-inset-right));
  }

  .typing-area {
    width: min(680px, calc(100% - 1.25rem)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    bottom: max(.75rem, env(safe-area-inset-bottom)) !important;
  }

  body.chat-open.conversation-started .typing-area {
    width: min(680px, calc(100% - 1rem)) !important;
  }

  body.chat-open .chat-view {
    touch-action: pan-y;
    overscroll-behavior: contain;
    min-height: 100dvh;
  }

  body.chat-open .chat-shell {
    height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0) - 5.75rem);
    max-height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0) - 5.75rem);
    padding-top: calc(4.2rem + env(safe-area-inset-top, 0));
    min-height: 0;
  }

  body.chat-open .chat-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
  }

  body.chat-open.conversation-started .chat-list {
    padding-bottom: calc(6.25rem + env(safe-area-inset-bottom, 0));
  }

  body.chat-open.conversation-started .typing-area {
    bottom: max(.65rem, env(safe-area-inset-bottom)) !important;
  }

  .workspace-compose-tube {
    min-height: 48px;
  }

  .workspace-unified-shell .workspace-pro-compose-foot,
  .workspace-world-focus .workspace-pro-compose-foot {
    padding-bottom: max(.35rem, env(safe-area-inset-bottom));
  }

  /* Workspace shell */
  body.workspace-mobile .workspace-shell {
    height: 100dvh;
    min-height: 100dvh;
  }

  body.workspace-mobile .workspace-study-topbar {
    grid-template-columns: minmax(0, 1fr) auto !important;
    min-height: 58px;
    padding-top: env(safe-area-inset-top, 0);
  }

  body.workspace-mobile .workspace-study-topbar-brand {
    min-height: 58px;
    padding: .32rem .45rem .32rem max(.45rem, env(safe-area-inset-left));
  }

  body.workspace-mobile .workspace-study-topbar-brand-bubble {
    max-width: min(148px, 42vw);
    padding: .38rem .5rem;
  }

  body.workspace-mobile .workspace-study-topbar-collapse-slot,
  body.workspace-mobile .workspace-study-topbar-action span:not(.material-symbols-rounded):not(.workspace-study-topbar-badge),
  body.workspace-mobile #workspaceStudyTopMilestone,
  body.workspace-mobile #workspaceStudyTopNotifications {
    display: none !important;
  }

  body.workspace-mobile .workspace-study-topbar-action {
    min-width: 42px;
    padding: .3rem;
  }

  body.workspace-mobile .workspace-study-topbar-right {
    padding-right: max(.55rem, env(safe-area-inset-right));
    gap: .08rem;
  }

  body.workspace-mobile .workspace-study-topbar-utc {
    display: none !important;
  }

  body.workspace-mobile .workspace-main {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) !important;
    min-height: 0;
    padding-bottom: calc(4.35rem + env(safe-area-inset-bottom, 0));
  }

  /* Bottom navigation rail */
  body.workspace-mobile .workspace-rail {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 125;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-height: none;
    padding: 0;
    margin: 0;
    border-right: 0;
    border-top: 1px solid rgba(8, 24, 18, .1);
    border-radius: 1rem 1rem 0 0;
    background: rgba(255, 255, 255, .97) !important;
    backdrop-filter: blur(14px);
    box-shadow: 0 -10px 36px rgba(8, 18, 30, .1);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  body.workspace-mobile:not(.light-theme) .workspace-rail {
    background: rgba(7, 17, 27, .96) !important;
    border-top-color: rgba(255, 255, 255, .08);
  }

  body.workspace-mobile .workspace-rail-nav {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    overflow: hidden;
  }

  body.workspace-mobile .workspace-rail-brand,
  body.workspace-mobile .workspace-rail-profile,
  body.workspace-mobile .workspace-rail-decor,
  body.workspace-mobile .workspace-rail-footer,
  body.workspace-mobile .workspace-rail-collapse-btn,
  body.workspace-mobile .workspace-rail-divider,
  body.workspace-mobile .workspace-rail-sep {
    display: none !important;
  }

  body.workspace-mobile .workspace-rail-brand--student-track-only,
  body.workspace-mobile .workspace-rail-brand--student-rail-mini {
    display: flex !important;
    flex-direction: column;
    gap: 0;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent !important;
    min-height: 0;
  }

  body.workspace-mobile .workspace-area-picker,
  body.workspace-mobile .workspace-student-track-picker {
    display: flex !important;
    flex-direction: row;
    align-items: center;
    gap: .45rem;
    margin: 0;
    padding: .42rem max(.65rem, env(safe-area-inset-right)) .32rem max(.65rem, env(safe-area-inset-left));
    border-bottom: 1px solid rgba(8, 24, 18, .06);
    flex-shrink: 0;
  }

  body.workspace-mobile .workspace-student-track-picker-label,
  body.workspace-mobile .workspace-area-picker .workspace-student-track-picker-label {
    font-size: .58rem;
    white-space: nowrap;
  }

  body.workspace-mobile .workspace-area-picker select,
  body.workspace-mobile .workspace-student-track-picker select {
    flex: 1;
    min-width: 0;
    min-height: 34px;
    font-size: .68rem;
  }

  body.workspace-mobile .workspace-rail-menu,
  body.workspace-mobile .workspace-rail-menu-scroll {
    display: flex !important;
    flex-direction: row;
    align-items: stretch;
    gap: .2rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: .38rem max(.45rem, env(safe-area-inset-right)) .42rem max(.45rem, env(safe-area-inset-left));
    flex: 0 0 auto;
  }

  body.workspace-mobile .workspace-rail-menu::-webkit-scrollbar {
    display: none;
  }

  body.workspace-mobile .workspace-rail-item,
  body.workspace-mobile .workspace-rail-item--labeled,
  body.workspace-mobile .workspace-rail-item--group {
    flex: 0 0 auto;
    width: auto !important;
    min-width: 58px;
    max-width: 88px;
    min-height: 52px;
    height: auto;
    padding: .35rem .42rem !important;
    border-radius: .72rem !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: .18rem !important;
    text-align: center;
  }

  body.workspace-mobile .workspace-rail-item.active::before {
    display: none !important;
  }

  body.workspace-mobile .workspace-rail-item .material-symbols-rounded,
  body.workspace-mobile .workspace-rail-item .rail-icon {
    font-size: 1.15rem !important;
    width: 1.15rem;
    height: 1.15rem;
  }

  body.workspace-mobile .workspace-rail-label {
    display: block !important;
    font-size: .5rem !important;
    line-height: 1.15;
    max-width: 72px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.workspace-mobile .workspace-rail-item--group .workspace-rail-chevron,
  body.workspace-mobile .workspace-rail-group-children {
    display: none !important;
  }

  body.workspace-mobile .workspace-rail-add-btn {
    flex: 0 0 auto;
    min-width: 52px;
    min-height: 52px;
    flex-direction: column;
    gap: .12rem;
    font-size: .48rem;
  }

  body.workspace-mobile .workspace-chat-pane,
  body.workspace-mobile .workspace-desk-pane {
    grid-column: 1 !important;
    grid-row: 1 !important;
    border-right: 0 !important;
    border-bottom: 0 !important;
    min-height: 0;
    max-height: none !important;
  }

  body.workspace-mobile .workspace-chat-feed {
    padding: .65rem .75rem .5rem;
  }

  body.workspace-mobile .workspace-unified-shell .workspace-typing-area,
  body.workspace-mobile.workspace-world-focus .workspace-typing-area {
    margin: .25rem .65rem max(.55rem, env(safe-area-inset-bottom));
  }

  /* Passenger / student: desk compact below chat */
  body.workspace-mobile.workspace-passenger .workspace-desk-pane,
  body.workspace-mobile.workspace-student .workspace-desk-pane {
    display: flex !important;
    max-height: 42vh;
    border-top: 1px solid rgba(8, 24, 18, .08);
  }

  body.workspace-mobile.workspace-passenger:not(.workspace-world-focus) .workspace-main,
  body.workspace-mobile.workspace-student:not(.workspace-world-focus) .workspace-main {
    grid-template-rows: minmax(0, 1fr) auto !important;
  }

  body.workspace-mobile.workspace-passenger:not(.workspace-world-focus) .workspace-chat-pane,
  body.workspace-mobile.workspace-student:not(.workspace-world-focus) .workspace-chat-pane {
    grid-row: 1 !important;
  }

  body.workspace-mobile.workspace-passenger:not(.workspace-world-focus) .workspace-desk-pane,
  body.workspace-mobile.workspace-student:not(.workspace-world-focus) .workspace-desk-pane {
    grid-row: 2 !important;
  }

  /* Professional: full-screen desk when selected */
  body.workspace-mobile.workspace-professional:not(.workspace-mobile-show-desk) .workspace-desk-pane {
    display: none !important;
  }

  body.workspace-mobile.workspace-professional.workspace-mobile-show-desk .workspace-chat-pane {
    display: none !important;
  }

  body.workspace-mobile.workspace-professional.workspace-mobile-show-desk .workspace-desk-pane {
    display: flex !important;
    max-height: none !important;
  }

  body.workspace-mobile.workspace-professional.workspace-mobile-show-desk .workspace-main {
    padding-bottom: calc(4.35rem + env(safe-area-inset-bottom, 0));
  }

  /* FLAITOPS World — mobile */
  body.workspace-mobile.workspace-world-focus .workspace-main {
    grid-template-columns: 1fr !important;
    grid-template-rows: minmax(0, 1fr) !important;
    gap: 0 !important;
    padding: 0 0 calc(7.1rem + env(safe-area-inset-bottom, 0)) !important;
    background: #f0f3f1;
  }

  body.workspace-mobile.workspace-world-focus .workspace-chat-pane,
  body.workspace-mobile.workspace-world-focus .workspace-world-map-pane {
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: 0 !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    min-height: 0;
  }

  body.workspace-mobile.workspace-world-focus.workspace-world-mobile-tab-map .workspace-chat-pane {
    display: none !important;
  }

  body.workspace-mobile.workspace-world-focus.workspace-world-mobile-tab-chat .workspace-world-map-pane {
    display: none !important;
  }

  body.workspace-mobile.workspace-world-focus .workspace-world-panel {
    display: none !important;
    grid-column: unset !important;
    grid-row: unset !important;
    max-height: none !important;
  }

  body.workspace-mobile.workspace-world-focus.workspace-world-panel-open .workspace-world-panel {
    display: flex !important;
    position: fixed;
    left: .65rem;
    right: .65rem;
    bottom: calc(7.2rem + env(safe-area-inset-bottom, 0));
    top: auto;
    width: auto;
    max-width: none;
    max-height: min(52vh, 420px);
    transform: none;
    opacity: 1;
    pointer-events: auto;
    border-radius: 1rem;
    z-index: 130;
  }

  body.workspace-mobile.workspace-world-focus:not(.workspace-world-passenger) .workspace-world-panel {
    display: none !important;
  }

  body.workspace-mobile.workspace-world-focus:not(.workspace-world-passenger).workspace-world-panel-open .workspace-world-panel {
    display: flex !important;
    position: fixed;
    left: .65rem;
    right: .65rem;
    bottom: calc(7.2rem + env(safe-area-inset-bottom, 0));
    top: auto;
    width: auto;
    max-height: min(58vh, 480px);
    z-index: 130;
    border-radius: 1rem;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
  }

  .world-mobile-tabs {
    position: fixed;
    left: 50%;
    bottom: calc(4.55rem + env(safe-area-inset-bottom, 0));
    transform: translateX(-50%);
    z-index: 126;
    display: flex;
    gap: .35rem;
    padding: .28rem;
    border-radius: 999px;
    border: 1px solid rgba(8, 24, 18, .1);
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 10px 32px rgba(8, 18, 30, .12);
    backdrop-filter: blur(12px);
  }

  body:not(.light-theme) .world-mobile-tabs {
    background: rgba(7, 17, 27, .94);
    border-color: rgba(255, 255, 255, .1);
  }

  .world-mobile-tabs[hidden] {
    display: none !important;
  }

  .world-mobile-tab {
    appearance: none;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #5c6b62;
    font: inherit;
    font-size: .62rem;
    font-weight: 750;
    padding: .48rem .82rem;
    display: inline-flex;
    align-items: center;
    gap: .32rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .2s ease, color .2s ease;
  }

  body:not(.light-theme) .world-mobile-tab {
    color: var(--muted);
  }

  .world-mobile-tab .material-symbols-rounded {
    font-size: 1rem;
  }

  .world-mobile-tab.is-active {
    background: rgba(31, 201, 0, .14);
    color: #128a00;
  }

  body.workspace-mobile .world-map-head {
    padding: .55rem .65rem;
    gap: .5rem;
  }

  body.workspace-mobile .world-map-search-form {
    width: 100%;
  }

  body.workspace-mobile .world-map-search-tube {
    min-height: 48px;
    padding: .32rem .4rem .32rem .75rem;
  }

  body.workspace-mobile .world-map-mode-tabs.area-tabs--hero {
    min-width: min(280px, 100%);
    max-width: 100%;
  }

  body.workspace-mobile .world-map-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: .42rem .65rem .5rem;
  }

  body.workspace-mobile .world-map-filters::-webkit-scrollbar {
    display: none;
  }

  body.workspace-mobile .world-map-chip {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  body.workspace-mobile .world-map-legend {
    display: none;
  }

  body.workspace-mobile .world-map-foot {
    padding: .35rem .65rem .45rem;
  }

  body.workspace-mobile .world-map-tools,
  body.workspace-mobile .world-map-zoom {
    transform: scale(.92);
    transform-origin: bottom right;
  }

  body.workspace-mobile .message.incoming .message-content {
    gap: .62rem;
  }

  body.workspace-mobile .response-shell {
    max-width: calc(100vw - 4.5rem) !important;
  }

  body.workspace-mobile .workspace-chat-intro--pro-card {
    margin: .65rem .65rem 0;
    padding: .75rem .8rem;
  }

  body.workspace-mobile .account-view {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

@media (max-width: 400px) {
  body.workspace-mobile .workspace-rail-item,
  body.workspace-mobile .workspace-rail-item--labeled {
    min-width: 52px;
    max-width: 72px;
    padding: .32rem .28rem !important;
  }

  body.workspace-mobile .workspace-rail-label {
    font-size: .46rem !important;
    max-width: 64px;
  }

  .world-mobile-tab span:not(.material-symbols-rounded) {
    display: none;
  }

  .world-mobile-tab {
    padding: .52rem .62rem;
  }
}
